diff --git a/.github/workflows/ci-ultra-tests.yml b/.github/workflows/ci-ultra-tests.yml index 6a07ef8b1f..b79070453f 100644 --- a/.github/workflows/ci-ultra-tests.yml +++ b/.github/workflows/ci-ultra-tests.yml @@ -34,11 +34,6 @@ jobs: . .venv/bin/activate scl scenario build-all ultra/scenarios/pool pytest -v ./tests/ - - name: Run Header test - run : | - cd ultra - ./header_test.sh - test-package-via-setup: runs-on: ubuntu-18.04 if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository @@ -60,7 +55,7 @@ jobs: cd ultra python3.7 -m venv .venv . .venv/bin/activate - pip install --upgrade --upgrade-strategy eager pip + pip install --upgrade pip pip install --upgrade -e . pip install --upgrade numpy - name: Run test @@ -69,7 +64,6 @@ jobs: . .venv/bin/activate scl scenario build-all ultra/scenarios/pool pytest -v ./tests/test_ultra_package.py - test-package-via-wheel: runs-on: ubuntu-18.04 if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository @@ -93,6 +87,7 @@ jobs: . .venv/bin/activate pip install --upgrade --upgrade-strategy eager pip pip install --upgrade --upgrade-strategy eager wheel + pip install --upgrade --upgrade-strategy eager -e . python setup.py bdist_wheel cd dist pip install $(ls . | grep ultra) @@ -104,7 +99,6 @@ jobs: . .venv/bin/activate scl scenario build-all ultra/scenarios/pool pytest -v ./tests/test_ultra_package.py - # test-package-via-pypi: # runs-on: ubuntu-18.04 # if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository @@ -132,4 +126,4 @@ jobs: # cd ultra # . .venv/bin/activate # scl scenario build-all ultra/scenarios/pool - # pytest -v ./tests/test_ultra_package.py \ No newline at end of file + # pytest -v ./tests/test_ultra_package.py diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000000..334c1f044f --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,19 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/conf.py + +# Optionally set the version of Python and requirements required to build your docs +python: + version: 3.7 + install: + - method: pip + path: . + extra_requirements: + - dev diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..a94da8e0d2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,51 @@ +# Change Log +All notable changes to this project will be documented in this file. + +This changelog is to adhere to the format given at [keepachangelog](keepachangelog.com/en/1.0.0/) +and should maintain [semantic versioning](semver.org). + +All text added must be human readable. + +Copy and pasting the git commit messages is __NOT__ enough. + +## [Unrealeased] + +## [0.4.15] - 2021-03-18 +### Added +- This CHANGELOG as a change log to help keep track of changes in the SMARTS project that can get easily lost. +- Hosted Documentation on `readthedocs` and pointed to the smarts paper and useful parts of the documentation in the README. +- Running imitation learning will now create a cached history_mission.pkl file in scenario folder that stores +the missions for all agents. +- Added ijson as a dependency. +- Added cached_property as a dependency. +### Changed +- Lowered CPU cost of waypoint generation. This will result in a small increase in memory usage. +- Set the number of processes used in `make test` to ignore 2 CPUs if possible. +- Use the dummy OpEn agent (open-agent version 0.0.0) for all examples. +- Improved performance by removing unused traffic light functionality. +- Limit the memory use of traffic histories by incrementally loading the traffic history file with a worker process. +### Fixed +- In order to avoid precision issues in our coordinates with big floating point numbers, +we now initially shift road networks (maps) that are offset back to the origin +using [netconvert](https://sumo.dlr.de/docs/netconvert.html). +We adapt Sumo vehicle positions to take this into account to allow Sumo to continue +using the original coordinate system. See Issue #325. +- Cleanly close down the traffic history provider thread. See PR #665. +- Improved the disposal of a SMARTS instance. See issue #378. +- Envision now resumes from current frame after un-pausing. +- Skipped generation of cut-in waypoints if they are further off-road than SMARTS currently supports to avoid process crash. +- Fix envision error 15 by cleanly shutting down the envision worker process. + +## [Format] - 2021-03-12 +### Added +– Describe any new features that have been added since the last version was released. +### Changed +– Note any changes to the software’s existing functionality. +### Deprecated +– Note any features that were once stable but are no longer and have thus been removed. +### Fixed +– List any bugs or errors that have been fixed in a change. +### Removed +– Note any features that have been deleted and removed from the software. +### Security +– Invite users to upgrade and avoid fixed software vulnerabilities. diff --git a/Makefile b/Makefile index ffd2e686d0..308ac3f542 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ test: build-all-scenarios --doctest-modules \ --forked \ --dist=loadscope \ - -n `nproc --ignore 1` \ + -n `nproc --ignore 2` \ ./envision ./smarts/contrib ./smarts/core ./smarts/env ./smarts/sstudio ./tests \ --ignore=./smarts/core/tests/test_smarts_memory_growth.py \ --ignore=./smarts/env/tests/test_benchmark.py \ diff --git a/README.md b/README.md index 6d8f6cd098..209c7949d7 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ SMARTS (Scalable Multi-Agent RL Training School) is a simulation platform for reinforcement learning and multi-agent research on autonomous driving. Its focus is on realistic and diverse interactions. It is part of the [XingTian](https://github.com/huawei-noah/xingtian/) suite of RL platforms from Huawei Noah's Ark Lab. +Check out the paper at [SMARTS: Scalable Multi-Agent Reinforcement Learning Training School for Autonomous Driving](https://arxiv.org/abs/2010.09776) for background on some of the project goals. + ![](docs/_static/smarts_envision.gif) ## Multi-Agent experiment as simple as... @@ -107,6 +109,10 @@ Several example scripts are provided under [`SMARTS/examples`](./examples), as w # ... ``` +## Documentation + +Documentation is available at [smarts.readthedocs.io](https://smarts.readthedocs.io/en/latest) + ## CLI tool SMARTS provides a command-line tool to interact with scenario studio and Envision. diff --git a/cli/studio.py b/cli/studio.py index 1857bdc111..588be96e84 100644 --- a/cli/studio.py +++ b/cli/studio.py @@ -145,6 +145,7 @@ def _clean(scenario): "*.rou.alt.xml", "social_agents/*", "traffic/*", + "history_mission.pkl", ] p = Path(scenario) for file_name in to_be_removed: diff --git a/docs/conf.py b/docs/conf.py index 5d12891c75..9744ca51a8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,7 +23,7 @@ author = "Huawei Noah's Ark Lab." # The full version, including alpha/beta/rc tags -release = "0.3.6" +release = "0.4.15" # -- General configuration --------------------------------------------------- diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 4599ed6de7..ef099ed7d1 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -73,7 +73,7 @@ This is done by implementing the :class:`smarts.core.agent.Agent` interface: ) return traj -Here we are implementing a simple lane following agent using the BezierMotionPlanner. The `obs` argument to `ExampleAgent.act()` will contain the observations specified in the `AgentInterface` above, and it's expected that the return value of the `act` method matches the `ActipnSpaceType` chosen as well. (This constraint is relaxed when adapters are introduced.) +Here we are implementing a simple lane following agent using the BezierMotionPlanner. The `obs` argument to `ExampleAgent.act()` will contain the observations specified in the `AgentInterface` above, and it's expected that the return value of the `act` method matches the `ActionSpaceType` chosen as well. (This constraint is relaxed when adapters are introduced.) AgentSpec :class:`smarts.core.agent.AgentSpec` diff --git a/docs/sim/agent.rst b/docs/sim/agent.rst index 7ccb171b8f..f38506abaa 100644 --- a/docs/sim/agent.rst +++ b/docs/sim/agent.rst @@ -3,7 +3,7 @@ How to build an Agent ====================== -SMARTS provides users the ability to custom their agents. :class:`smarts.core.agent.AgentSpec` has the following fields: +SMARTS provides users the ability to customize their agents. :class:`smarts.core.agent.AgentSpec` has the following fields: .. code-block:: python @@ -31,7 +31,7 @@ An example of how to create an `Agent` instance is shown below. agent = agent_spec.build_agent() -We will further explain the fields of `Agent` class later on this page. You can also read the source code at :class:`smarts.env.agent`. +We will further explain the fields of the `Agent` class later on this page. You can also read the source code at :class:`smarts.env.agent`. ============== AgentInterface @@ -64,7 +64,7 @@ SMARTS provide some interface types, and the differences between them is shown i | debug | **T** | **T** | **T** | **T** | `max_episode_steps` controls the max running steps allowed for the agent in an episode. The default `None` setting means agents have no such limit. -You can move max_episode_steps control authority to RLlib with their config option `horizon`, but lose the ability to customize +You can move `max_episode_steps` control authority to RLlib with their config option `horizon`, but lose the ability to customize different max_episode_len for each agent. `action` controls the agent action type used. There are three `ActionSpaceType`: ActionSpaceType.Continuous, ActionSpaceType.Lane @@ -72,7 +72,7 @@ and ActionSpaceType.ActuatorDynamic. - `ActionSpaceType.Continuous`: continuous action space with throttle, brake, absolute steering angle. - `ActionSpaceType.ActuatorDynamic`: continuous action space with throttle, brake, steering rate. Steering rate means the amount of steering angle change *per second* (either positive or negative) to be applied to the current steering angle. -- `ActionSpaceType.Lane`: discrete lane action space of strings including "keep_lane", "slow_down", "change_lane_left", "change_lane_right". (WARNING: This is the case in the current version 0.3.2b, but a newer version will soon be released. In this newer version, the action space will no longer being strings, but will be a tuple of an integer for `lane_change` and a float for `target_speed`.) +- `ActionSpaceType.Lane`: discrete lane action space of strings including "keep_lane", "slow_down", "change_lane_left", "change_lane_right". (WARNING: This is the case in the current version 0.3.2b, but a newer version will soon be released. In this newer version, the action space will no longer consist of strings, but will be a tuple of an integer for `lane_change` and a float for `target_speed`.) For other observation options, see :ref:`observations` for details. @@ -112,10 +112,10 @@ For further customization, you can try: action=ActionSpaceType.Continuous, ) -refer to :class:`smarts/core/agent_interface` for more details. +Refer to :class:`smarts/core/agent_interface` for more details. -IMPORTANT: The generation of DrivableAreaGridMap(`drivable_area_grid_map=True`), OGM (`ogm=True`) and RGB (`rgb=True`) images may significantly slow down the environment `step()`. If your model does not consume such observations, we recommend that you set them to `False`. +IMPORTANT: The generation of a DrivableAreaGridMap (`drivable_area_grid_map=True`), OGM (`ogm=True`) and/or RGB (`rgb=True`) images may significantly slow down the environment `step()`. If your model does not consume such observations, we recommend that you set them to `False`. IMPORTANT: Depending on how your agent model is set up, `ActionSpaceType.ActuatorDynamic` might allow the agent to learn faster than `ActionSpaceType.Continuous` simply because learning to correct steering could be simpler than learning a mapping to all the absolute steering angle values. But, again, it also depends on the design of your agent model. diff --git a/docs/sim/observations.rst b/docs/sim/observations.rst index d029e350e6..0e4b8aa658 100644 --- a/docs/sim/observations.rst +++ b/docs/sim/observations.rst @@ -82,4 +82,4 @@ Actions * `ActionSpaceType.Continuous`: continuous action space with throttle, brake, absolute steering angle. It is a tuple of `throttle` [0, 1], `brake` [0, 1], and `steering` [-1, 1]. * `ActionSpaceType.ActuatorDynamic`: continuous action space with throttle, brake, steering rate. Steering rate means the amount of steering angle change *per second* (either positive or negative) to be applied to the current steering angle. It is also a tuple of `throttle` [0, 1], `brake` [0, 1], and `steering_rate`, where steering rate is in number of radians per second. -* `ActionSpaceType.Lane`: discrete lane action space of *strings* including "keep_lane", "slow_down", "change_lane_left", "change_lane_right" as of version 0.3.2b, but a newer version will soon be released. In this newer version, the action space will no longer being strings, but will be a tuple of an integer for `lane_change` and a float for `target_speed`. +* `ActionSpaceType.Lane`: discrete lane action space of *strings* including "keep_lane", "slow_down", "change_lane_left", "change_lane_right" as of version 0.3.2b, but a newer version will soon be released. In this newer version, the action space will no longer consist of strings, but will be a tuple of an integer for `lane_change` and a float for `target_speed`. diff --git a/docs/sim/rllib_in_smarts.rst b/docs/sim/rllib_in_smarts.rst index 1db5979026..899f86db73 100644 --- a/docs/sim/rllib_in_smarts.rst +++ b/docs/sim/rllib_in_smarts.rst @@ -31,7 +31,7 @@ SMARTS RLlib Tips Resume or continue training --------------------------- -If you want to continue an aborted experiemnt. you can set `resume=True` in `tune.run`. But note that`resume=True` will continue to use the same configuration as was set in the original experiment. +If you want to continue an aborted experiment. you can set `resume=True` in `tune.run`. But note that`resume=True` will continue to use the same configuration as was set in the original experiment. To make changes to a started experiment, you can edit the latest experiment file in `~/ray_results/rllib_example`. Or if you want to start a new experiment but train from an existing checkpoint, you can set `restore=checkpoint_path` in `tune.run`. diff --git a/envision/client.py b/envision/client.py index 6d6b324bdd..8d9066c7e6 100644 --- a/envision/client.py +++ b/envision/client.py @@ -213,6 +213,9 @@ def run_socket(endpoint, wait_between_retries): if not connection_established: self._log.info(f"Attempt {tries} to connect to Envision.") else: + # No information left to send, connection is likely done + if state_queue.empty(): + break # When connection lost, retry again every 3 seconds wait_between_retries = 3 self._log.info( @@ -237,14 +240,16 @@ def _send_raw(self, state: str): self._state_queue.put(state) def teardown(self): - if not self._headless: + if not self._headless and self._state_queue: self._state_queue.put(Client.QueueDone()) self._process.join(timeout=3) self._process = None self._state_queue.close() + self._state_queue = None - if self._logging_process: + if self._logging_process and self._logging_queue: self._logging_queue.put(Client.QueueDone()) self._logging_process.join(timeout=3) self._logging_process = None self._logging_queue.close() + self._logging_queue = None diff --git a/envision/web/dist/main.js b/envision/web/dist/main.js index e70e4b8fc7..00713640be 100644 --- a/envision/web/dist/main.js +++ b/envision/web/dist/main.js @@ -367,7 +367,7 @@ e.exports=function(){"use strict"; * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var r="function"==typeof Symbol&&Symbol.for,i=r?Symbol.for("react.element"):60103,o=r?Symbol.for("react.portal"):60106,a=r?Symbol.for("react.fragment"):60107,s=r?Symbol.for("react.strict_mode"):60108,l=r?Symbol.for("react.profiler"):60114,c=r?Symbol.for("react.provider"):60109,u=r?Symbol.for("react.context"):60110,d=r?Symbol.for("react.async_mode"):60111,h=r?Symbol.for("react.concurrent_mode"):60111,p=r?Symbol.for("react.forward_ref"):60112,f=r?Symbol.for("react.suspense"):60113,m=r?Symbol.for("react.suspense_list"):60120,g=r?Symbol.for("react.memo"):60115,b=r?Symbol.for("react.lazy"):60116,v=r?Symbol.for("react.block"):60121,A=r?Symbol.for("react.fundamental"):60117,_=r?Symbol.for("react.responder"):60118,y=r?Symbol.for("react.scope"):60119;function x(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case i:switch(e=e.type){case d:case h:case a:case l:case s:case f:return e;default:switch(e=e&&e.$$typeof){case u:case p:case b:case g:case c:return e;default:return t}}case o:return t}}}function w(e){return x(e)===h}t.AsyncMode=d,t.ConcurrentMode=h,t.ContextConsumer=u,t.ContextProvider=c,t.Element=i,t.ForwardRef=p,t.Fragment=a,t.Lazy=b,t.Memo=g,t.Portal=o,t.Profiler=l,t.StrictMode=s,t.Suspense=f,t.isAsyncMode=function(e){return w(e)||x(e)===d},t.isConcurrentMode=w,t.isContextConsumer=function(e){return x(e)===u},t.isContextProvider=function(e){return x(e)===c},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===i},t.isForwardRef=function(e){return x(e)===p},t.isFragment=function(e){return x(e)===a},t.isLazy=function(e){return x(e)===b},t.isMemo=function(e){return x(e)===g},t.isPortal=function(e){return x(e)===o},t.isProfiler=function(e){return x(e)===l},t.isStrictMode=function(e){return x(e)===s},t.isSuspense=function(e){return x(e)===f},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===h||e===l||e===s||e===f||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===b||e.$$typeof===g||e.$$typeof===c||e.$$typeof===u||e.$$typeof===p||e.$$typeof===A||e.$$typeof===_||e.$$typeof===y||e.$$typeof===v)},t.typeOf=x},function(e,t,n){n(199);var r=n(32).Object;e.exports=function(e,t,n){return r.defineProperty(e,t,n)}},function(e,t,n){var r=n(47);r(r.S+r.F*!n(50),"Object",{defineProperty:n(49).f})},function(e,t,n){e.exports={default:n(201),__esModule:!0}},function(e,t,n){n(129),n(206),e.exports=n(105).f("iterator")},function(e,t,n){var r=n(97),i=n(96);e.exports=function(e){return function(t,n){var o,a,s=String(i(t)),l=r(n),c=s.length;return l<0||l>=c?e?"":void 0:(o=s.charCodeAt(l))<55296||o>56319||l+1===c||(a=s.charCodeAt(l+1))<56320||a>57343?e?s.charAt(l):o:e?s.slice(l,l+2):a-56320+(o-55296<<10)+65536}}},function(e,t,n){"use strict";var r=n(103),i=n(68),o=n(104),a={};n(59)(a,n(37)("iterator"),(function(){return this})),e.exports=function(e,t,n){e.prototype=r(a,{next:i(1,n)}),o(e,t+" Iterator")}},function(e,t,n){var r=n(49),i=n(60),o=n(73);e.exports=n(50)?Object.defineProperties:function(e,t){i(e);for(var n,a=o(t),s=a.length,l=0;s>l;)r.f(e,n=a[l++],t[n]);return e}},function(e,t,n){var r=n(48).document;e.exports=r&&r.documentElement},function(e,t,n){n(207);for(var r=n(48),i=n(59),o=n(70),a=n(37)("toStringTag"),s="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),l=0;l=e.length?(this._t=void 0,i(1)):i(0,"keys"==t?n:"values"==t?e[n]:[n,e[n]])}),"values"),o.Arguments=o.Array,r("keys"),r("values"),r("entries")},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){e.exports={default:n(211),__esModule:!0}},function(e,t,n){n(212),n(217),n(218),n(219),e.exports=n(32).Symbol},function(e,t,n){"use strict";var r=n(48),i=n(53),o=n(50),a=n(47),s=n(131),l=n(213).KEY,c=n(62),u=n(99),d=n(104),h=n(75),p=n(37),f=n(105),m=n(106),g=n(214),b=n(215),v=n(60),A=n(61),_=n(69),y=n(54),x=n(94),w=n(68),E=n(103),C=n(216),S=n(107),T=n(101),P=n(49),O=n(73),R=S.f,M=P.f,I=C.f,k=r.Symbol,D=r.JSON,B=D&&D.stringify,F=p("_hidden"),N=p("toPrimitive"),L={}.propertyIsEnumerable,U=u("symbol-registry"),V=u("symbols"),z=u("op-symbols"),j=Object.prototype,G="function"==typeof k&&!!T.f,H=r.QObject,Q=!H||!H.prototype||!H.prototype.findChild,W=o&&c((function(){return 7!=E(M({},"a",{get:function(){return M(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=R(j,t);r&&delete j[t],M(e,t,n),r&&e!==j&&M(j,t,r)}:M,K=function(e){var t=V[e]=E(k.prototype);return t._k=e,t},X=G&&"symbol"==typeof k.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof k},Y=function(e,t,n){return e===j&&Y(z,t,n),v(e),t=x(t,!0),v(n),i(V,t)?(n.enumerable?(i(e,F)&&e[F][t]&&(e[F][t]=!1),n=E(n,{enumerable:w(0,!1)})):(i(e,F)||M(e,F,w(1,{})),e[F][t]=!0),W(e,t,n)):M(e,t,n)},q=function(e,t){v(e);for(var n,r=g(t=y(t)),i=0,o=r.length;o>i;)Y(e,n=r[i++],t[n]);return e},Z=function(e){var t=L.call(this,e=x(e,!0));return!(this===j&&i(V,e)&&!i(z,e))&&(!(t||!i(this,e)||!i(V,e)||i(this,F)&&this[F][e])||t)},J=function(e,t){if(e=y(e),t=x(t,!0),e!==j||!i(V,t)||i(z,t)){var n=R(e,t);return!n||!i(V,t)||i(e,F)&&e[F][t]||(n.enumerable=!0),n}},$=function(e){for(var t,n=I(y(e)),r=[],o=0;n.length>o;)i(V,t=n[o++])||t==F||t==l||r.push(t);return r},ee=function(e){for(var t,n=e===j,r=I(n?z:y(e)),o=[],a=0;r.length>a;)!i(V,t=r[a++])||n&&!i(j,t)||o.push(V[t]);return o};G||(s((k=function(){if(this instanceof k)throw TypeError("Symbol is not a constructor!");var e=h(arguments.length>0?arguments[0]:void 0),t=function(n){this===j&&t.call(z,n),i(this,F)&&i(this[F],e)&&(this[F][e]=!1),W(this,e,w(1,n))};return o&&Q&&W(j,e,{configurable:!0,set:t}),K(e)}).prototype,"toString",(function(){return this._k})),S.f=J,P.f=Y,n(133).f=C.f=$,n(76).f=Z,T.f=ee,o&&!n(74)&&s(j,"propertyIsEnumerable",Z,!0),f.f=function(e){return K(p(e))}),a(a.G+a.W+a.F*!G,{Symbol:k});for(var te="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),ne=0;te.length>ne;)p(te[ne++]);for(var re=O(p.store),ie=0;re.length>ie;)m(re[ie++]);a(a.S+a.F*!G,"Symbol",{for:function(e){return i(U,e+="")?U[e]:U[e]=k(e)},keyFor:function(e){if(!X(e))throw TypeError(e+" is not a symbol!");for(var t in U)if(U[t]===e)return t},useSetter:function(){Q=!0},useSimple:function(){Q=!1}}),a(a.S+a.F*!G,"Object",{create:function(e,t){return void 0===t?E(e):q(E(e),t)},defineProperty:Y,defineProperties:q,getOwnPropertyDescriptor:J,getOwnPropertyNames:$,getOwnPropertySymbols:ee});var oe=c((function(){T.f(1)}));a(a.S+a.F*oe,"Object",{getOwnPropertySymbols:function(e){return T.f(_(e))}}),D&&a(a.S+a.F*(!G||c((function(){var e=k();return"[null]"!=B([e])||"{}"!=B({a:e})||"{}"!=B(Object(e))}))),"JSON",{stringify:function(e){for(var t,n,r=[e],i=1;arguments.length>i;)r.push(arguments[i++]);if(n=t=r[1],(A(t)||void 0!==e)&&!X(e))return b(t)||(t=function(e,t){if("function"==typeof n&&(t=n.call(this,e,t)),!X(t))return t}),r[1]=t,B.apply(D,r)}}),k.prototype[N]||n(59)(k.prototype,N,k.prototype.valueOf),d(k,"Symbol"),d(Math,"Math",!0),d(r.JSON,"JSON",!0)},function(e,t,n){var r=n(75)("meta"),i=n(61),o=n(53),a=n(49).f,s=0,l=Object.isExtensible||function(){return!0},c=!n(62)((function(){return l(Object.preventExtensions({}))})),u=function(e){a(e,r,{value:{i:"O"+ ++s,w:{}}})},d=e.exports={KEY:r,NEED:!1,fastKey:function(e,t){if(!i(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!o(e,r)){if(!l(e))return"F";if(!t)return"E";u(e)}return e[r].i},getWeak:function(e,t){if(!o(e,r)){if(!l(e))return!0;if(!t)return!1;u(e)}return e[r].w},onFreeze:function(e){return c&&d.NEED&&l(e)&&!o(e,r)&&u(e),e}}},function(e,t,n){var r=n(73),i=n(101),o=n(76);e.exports=function(e){var t=r(e),n=i.f;if(n)for(var a,s=n(e),l=o.f,c=0;s.length>c;)l.call(e,a=s[c++])&&t.push(a);return t}},function(e,t,n){var r=n(95);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,n){var r=n(54),i=n(133).f,o={}.toString,a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.f=function(e){return a&&"[object Window]"==o.call(e)?function(e){try{return i(e)}catch(e){return a.slice()}}(e):i(r(e))}},function(e,t){},function(e,t,n){n(106)("asyncIterator")},function(e,t,n){n(106)("observable")},function(e,t,n){e.exports={default:n(221),__esModule:!0}},function(e,t,n){n(222),e.exports=n(32).Object.setPrototypeOf},function(e,t,n){var r=n(47);r(r.S,"Object",{setPrototypeOf:n(223).set})},function(e,t,n){var r=n(61),i=n(60),o=function(e,t){if(i(e),!r(t)&&null!==t)throw TypeError(t+": can't set as prototype!")};e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,r){try{(r=n(93)(Function.call,n(107).f(Object.prototype,"__proto__").set,2))(e,[]),t=!(e instanceof Array)}catch(e){t=!0}return function(e,n){return o(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:o}},function(e,t,n){e.exports={default:n(225),__esModule:!0}},function(e,t,n){n(226);var r=n(32).Object;e.exports=function(e,t){return r.create(e,t)}},function(e,t,n){var r=n(47);r(r.S,"Object",{create:n(103)})},function(e,t,n){"use strict";var r=n(228);function i(){}function o(){}o.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,o,a){if(a!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:i};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(230)),o=r(n(91)),a=["altKey","bubbles","cancelable","ctrlKey","currentTarget","eventPhase","metaKey","shiftKey","target","timeStamp","view","type"];function s(e){return null==e}var l=[{reg:/^key/,props:["char","charCode","key","keyCode","which"],fix:function(e,t){s(e.which)&&(e.which=s(t.charCode)?t.keyCode:t.charCode),void 0===e.metaKey&&(e.metaKey=e.ctrlKey)}},{reg:/^touch/,props:["touches","changedTouches","targetTouches"]},{reg:/^hashchange$/,props:["newURL","oldURL"]},{reg:/^gesturechange$/i,props:["rotation","scale"]},{reg:/^(mousewheel|DOMMouseScroll)$/,props:[],fix:function(e,t){var n=void 0,r=void 0,i=void 0,o=t.wheelDelta,a=t.axis,s=t.wheelDeltaY,l=t.wheelDeltaX,c=t.detail;o&&(i=o/120),c&&(i=0-(c%3==0?c/3:c)),void 0!==a&&(a===e.HORIZONTAL_AXIS?(r=0,n=0-i):a===e.VERTICAL_AXIS&&(n=0,r=i)),void 0!==s&&(r=s/120),void 0!==l&&(n=-1*l/120),n||r||(r=i),void 0!==n&&(e.deltaX=n),void 0!==r&&(e.deltaY=r),void 0!==i&&(e.delta=i)}},{reg:/^mouse|contextmenu|click|mspointer|(^DOMMouseScroll$)/i,props:["buttons","clientX","clientY","button","offsetX","relatedTarget","which","fromElement","toElement","offsetY","pageX","pageY","screenX","screenY"],fix:function(e,t){var n=void 0,r=void 0,i=void 0,o=e.target,a=t.button;return o&&s(e.pageX)&&!s(t.clientX)&&(r=(n=o.ownerDocument||document).documentElement,i=n.body,e.pageX=t.clientX+(r&&r.scrollLeft||i&&i.scrollLeft||0)-(r&&r.clientLeft||i&&i.clientLeft||0),e.pageY=t.clientY+(r&&r.scrollTop||i&&i.scrollTop||0)-(r&&r.clientTop||i&&i.clientTop||0)),e.which||void 0===a||(e.which=1&a?1:2&a?3:4&a?2:0),!e.relatedTarget&&e.fromElement&&(e.relatedTarget=e.fromElement===o?e.toElement:e.fromElement),e}}];function c(){return!0}function u(){return!1}function d(e){var t=e.type,n="function"==typeof e.stopPropagation||"boolean"==typeof e.cancelBubble;i.default.call(this),this.nativeEvent=e;var r=u;"defaultPrevented"in e?r=e.defaultPrevented?c:u:"getPreventDefault"in e?r=e.getPreventDefault()?c:u:"returnValue"in e&&(r=!1===e.returnValue?c:u),this.isDefaultPrevented=r;var o=[],s=void 0,d=void 0,h=a.concat();for(l.forEach((function(e){t.match(e.reg)&&(h=h.concat(e.props),e.fix&&o.push(e.fix))})),s=h.length;s;)this[d=h[--s]]=e[d];for(!this.target&&n&&(this.target=e.srcElement||document),this.target&&3===this.target.nodeType&&(this.target=this.target.parentNode),s=o.length;s;)(0,o[--s])(this,e);this.timeStamp=e.timeStamp||Date.now()}var h=i.default.prototype;(0,o.default)(d.prototype,h,{constructor:d,preventDefault:function(){var e=this.nativeEvent;e.preventDefault?e.preventDefault():e.returnValue=!1,h.preventDefault.call(this)},stopPropagation:function(){var e=this.nativeEvent;e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,h.stopPropagation.call(this)}}),t.default=d,e.exports=t.default},function(e,t,n){"use strict";function r(){return!1}function i(){return!0}function o(){this.timeStamp=Date.now(),this.target=void 0,this.currentTarget=void 0}Object.defineProperty(t,"__esModule",{value:!0}),o.prototype={isEventObject:1,constructor:o,isDefaultPrevented:r,isPropagationStopped:r,isImmediatePropagationStopped:r,preventDefault:function(){this.isDefaultPrevented=i},stopPropagation:function(){this.isPropagationStopped=i},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=i,this.stopPropagation()},halt:function(e){e?this.stopImmediatePropagation():this.stopPropagation(),this.preventDefault()}},t.default=o,e.exports=t.default},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(232)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="CloseCircleFilled";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"close-circle",theme:"filled",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(234)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="LoadingOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"loading",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(236)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="SearchOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"search",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(238)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="DownOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"down",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(240)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="CheckOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"check",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 00-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(242)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="CloseOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"close",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"}}]}}},function(e,t){e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(245)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="FileOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"file",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(247)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="MinusSquareOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"minus-square",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M328 544h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(249)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="PlusSquareOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"plus-square",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(251)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="CaretDownFilled";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"caret-down",theme:"filled",icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"}}]}}},function(e,t,n){var r=n(136);e.exports=function(){return r.Date.now()}},function(e,t,n){(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(58))},function(e,t,n){var r=n(135),i=n(255),o=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(r(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=r(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var n=s.test(e);return n||l.test(e)?c(e.slice(2),n?2:8):a.test(e)?NaN:+e}},function(e,t,n){var r=n(256),i=n(259);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==r(e)}},function(e,t,n){var r=n(137),i=n(257),o=n(258),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?i(e):o(e)}},function(e,t,n){var r=n(137),i=Object.prototype,o=i.hasOwnProperty,a=i.toString,s=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,s),n=e[s];try{e[s]=void 0;var r=!0}catch(e){}var i=a.call(e);return r&&(t?e[s]=n:delete e[s]),i}},function(e,t){var n=Object.prototype.toString;e.exports=function(e){return n.call(e)}},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(261)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="FolderOpenOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"folder-open",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 00-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(263)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="FolderOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"folder",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"}}]}}},function(e,t,n){e.exports={default:n(265),__esModule:!0}},function(e,t,n){n(266),e.exports=n(32).Object.getPrototypeOf},function(e,t,n){var r=n(69),i=n(132);n(138)("getPrototypeOf",(function(){return function(e){return i(r(e))}}))},function(e,t,n){e.exports={default:n(268),__esModule:!0}},function(e,t,n){n(269);var r=n(32).Object;e.exports=function(e,t){return r.getOwnPropertyDescriptor(e,t)}},function(e,t,n){var r=n(54),i=n(107).f;n(138)("getOwnPropertyDescriptor",(function(){return function(e,t){return i(r(e),t)}}))},function(e,t,n){e.exports={default:n(271),__esModule:!0}},function(e,t,n){n(129),n(272),e.exports=n(32).Array.from},function(e,t,n){"use strict";var r=n(93),i=n(47),o=n(69),a=n(273),s=n(274),l=n(125),c=n(275),u=n(276);i(i.S+i.F*!n(278)((function(e){Array.from(e)})),"Array",{from:function(e){var t,n,i,d,h=o(e),p="function"==typeof this?this:Array,f=arguments.length,m=f>1?arguments[1]:void 0,g=void 0!==m,b=0,v=u(h);if(g&&(m=r(m,f>2?arguments[2]:void 0,2)),null==v||p==Array&&s(v))for(n=new p(t=l(h.length));t>b;b++)c(n,b,g?m(h[b],b):h[b]);else for(d=v.call(h),n=new p;!(i=d.next()).done;b++)c(n,b,g?a(d,m,[i.value,b],!0):i.value);return n.length=b,n}})},function(e,t,n){var r=n(60);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var o=e.return;throw void 0!==o&&r(o.call(e)),t}}},function(e,t,n){var r=n(70),i=n(37)("iterator"),o=Array.prototype;e.exports=function(e){return void 0!==e&&(r.Array===e||o[i]===e)}},function(e,t,n){"use strict";var r=n(49),i=n(68);e.exports=function(e,t,n){t in e?r.f(e,t,i(0,n)):e[t]=n}},function(e,t,n){var r=n(277),i=n(37)("iterator"),o=n(70);e.exports=n(32).getIteratorMethod=function(e){if(null!=e)return e[i]||e["@@iterator"]||o[r(e)]}},function(e,t,n){var r=n(95),i=n(37)("toStringTag"),o="Arguments"==r(function(){return arguments}());e.exports=function(e){var t,n,a;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),i))?n:o?r(t):"Object"==(a=r(t))&&"function"==typeof t.callee?"Arguments":a}},function(e,t,n){var r=n(37)("iterator"),i=!1;try{var o=[7][r]();o.return=function(){i=!0},Array.from(o,(function(){throw 2}))}catch(e){}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var o=[7],a=o[r]();a.next=function(){return{done:n=!0}},o[r]=function(){return a},e(o)}catch(e){}return n}},function(e,t){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CloseIcon=t.InfoIcon=t.FlameIcon=t.CheckIcon=t.AlertIcon=void 0;var r,i=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:p.NOOP;return function(){t(e),r.remove(e)}},r.add=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p.NOOP,o=t.id||(0,p.generateUEID)(),a=function(){return n(o)};if(!r.has(o))return r.setState((function(n){var r=i({content:e,id:o},t);return{toasts:[].concat(f(n.toasts),[r])}}),a),o},r.remove=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p.NOOP,n=function(){return t(e)};r.has(e)&&r.setState((function(t){return{toasts:t.toasts.filter((function(t){return t.id!==e}))}}),n)},r.removeAll=function(){r.state.toasts.length&&r.state.toasts.forEach((function(e){return r.remove(e.id)}))},r.update=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p.NOOP,o=function(){return n(e)};r.has(e)&&r.setState((function(n){var r=n.toasts,o=r.findIndex((function(t){return t.id===e})),a=i({},r[o],t);return{toasts:[].concat(f(r.slice(0,o)),[a],f(r.slice(o+1)))}}),o)},g(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"render",value:function(){var e=this,t=this.props,n=t.autoDismiss,r=t.autoDismissTimeout,o=t.children,a=t.components,d=t.placement,h=t.transitionDuration,p=i({},b,a),f=p.Toast,m=p.ToastContainer,g=this.add,v=this.remove,A=this.removeAll,x=this.update,w=Object.freeze(this.state.toasts),E=Boolean(w.length),C=y?document.body:null;return s.default.createElement(_,{value:{add:g,remove:v,removeAll:A,update:x,toasts:w}},o,C?(0,l.createPortal)(s.default.createElement(m,{placement:d,hasToasts:E},s.default.createElement(c.TransitionGroup,{component:null},w.map((function(t){var o=t.appearance,a=t.autoDismiss,l=t.content,p=t.id,m=t.onDismiss,g=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(t,["appearance","autoDismiss","content","id","onDismiss"]);return s.default.createElement(c.Transition,{appear:!0,key:p,mountOnEnter:!0,timeout:h,unmountOnExit:!0},(function(t){return s.default.createElement(u.ToastController,i({appearance:o,autoDismiss:void 0!==a?a:n,autoDismissTimeout:r,component:f,key:p,onDismiss:e.onDismiss(p,m),placement:d,transitionDuration:h,transitionState:t},g),l)}))})))),C):s.default.createElement(m,{placement:d,hasToasts:E}))}}]),t}(a.Component)).defaultProps={autoDismiss:!1,autoDismissTimeout:5e3,components:b,placement:"top-right",transitionDuration:220};var x=t.ToastConsumer=function(e){var t=e.children;return s.default.createElement(A,null,(function(e){return t(e)}))};t.withToastManager=function(e){return s.default.forwardRef((function(t,n){return s.default.createElement(x,null,(function(r){return s.default.createElement(e,i({toastManager:r},t,{ref:n}))}))}))},t.useToasts=function(){var e=(0,a.useContext)(v);if(!e)throw Error("The `useToasts` hook must be called from a descendent of the `ToastProvider`.");return{addToast:e.add,removeToast:e.remove,removeAllToasts:e.removeAll,updateToast:e.update,toastStack:e.toasts}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ToastController=void 0;var r,i=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["autoDismiss","autoDismissTimeout","component"]),a=this.state.isRunning,c=t?this.onMouseEnter:l.NOOP,u=t?this.onMouseLeave:l.NOOP;return s.default.createElement(r,i({autoDismiss:t,autoDismissTimeout:n,isRunning:a,onMouseEnter:c,onMouseLeave:u},o))}}]),t}(a.Component)).defaultProps={autoDismiss:!1}},function(e,t,n){const{defaultArgs:r,baseOptions:i}=n(285),{setLogging:o,setCustomLogger:a,log:s}=n(140),l=n(286),c=n(287),{defaultOptions:u,getCreateFFmpegCore:d}=n(141),{version:h}=n(142),p=Error("ffmpeg.wasm is not ready, make sure you have completed load().");e.exports=(e={})=>{const{log:t,logger:n,progress:f,...m}={...i,...u,...e};let g=null,b=null,v=null,A=!1,_=f;const y=({type:e,message:t})=>{s(e,t),l(t,_),(e=>{"FFMPEG_END"===e&&null!==v&&(v(),v=null,A=!1)})(t)};return o(t),a(n),s("info",`use ffmpeg.wasm v${h}`),{setProgress:e=>{_=e},setLogger:e=>{a(e)},setLogging:o,load:async()=>{if(s("info","load ffmpeg-core"),null!==g)throw Error("ffmpeg.wasm was loaded, you should not load it again, use ffmpeg.isLoaded() to check next time.");{s("info","loading ffmpeg-core");const{createFFmpegCore:e,corePath:t,workerPath:n,wasmPath:r}=await d(m);g=await e({mainScriptUrlOrBlob:t,printErr:e=>y({type:"fferr",message:e}),print:e=>y({type:"ffout",message:e}),locateFile:(e,t)=>{if("undefined"!=typeof window){if(void 0!==r&&e.endsWith("ffmpeg-core.wasm"))return r;if(void 0!==n&&e.endsWith("ffmpeg-core.worker.js"))return n}return t+e}}),b=g.cwrap("proxy_main","number",["number","number"]),s("info","ffmpeg-core loaded")}},isLoaded:()=>null!==g,run:(...e)=>{if(s("info",`run ffmpeg command: ${e.join(" ")}`),null===g)throw p;if(A)throw Error("ffmpeg.wasm can only run one command at a time");return A=!0,new Promise(t=>{const n=[...r,...e].filter(e=>0!==e.length);v=t,b(...c(g,n))})},FS:(e,...t)=>{if(s("info",`run FS.${e} ${t.map(e=>"string"==typeof e?e:`<${e.length} bytes binary file>`).join(" ")}`),null===g)throw p;{let n=null;try{n=g.FS[e](...t)}catch(n){throw"readdir"===e?Error(`ffmpeg.FS('readdir', '${t[0]}') error. Check if the path exists, ex: ffmpeg.FS('readdir', '/')`):"readFile"===e?Error(`ffmpeg.FS('readFile', '${t[0]}') error. Check if the path exists`):Error("Oops, something went wrong in FS operation.")}return n}}}}},function(e,t){e.exports={defaultArgs:["./ffmpeg","-nostdin","-y"],baseOptions:{log:!1,logger:()=>{},progress:()=>{},corePath:""}}},function(e,t){let n=0;const r=e=>{const[t,n,r]=e.split(":");return 60*parseFloat(t)*60+60*parseFloat(n)+parseFloat(r)};e.exports=(e,t)=>{if("string"==typeof e)if(e.startsWith(" Duration")){const t=e.split(", ")[0].split(": ")[1],i=r(t);(0===n||n>i)&&(n=i)}else if(e.startsWith("frame")){const i=e.split("time=")[1].split(" ")[0];t({ratio:r(i)/n})}else e.startsWith("video:")&&(t({ratio:1}),n=0)}},function(e,t){e.exports=(e,t)=>{const n=e._malloc(t.length*Uint32Array.BYTES_PER_ELEMENT);return t.forEach((t,r)=>{const i=e._malloc(t.length+1);e.writeAsciiToMemory(t,i),e.setValue(n+Uint32Array.BYTES_PER_ELEMENT*r,i,"i32")}),[t.length,n]}},function(e,t,n){(function(t){const r=n(110),{devDependencies:i}=n(142);e.exports={corePath:void 0!==t&&"development"===t.env.FFMPEG_ENV?r("/node_modules/@ffmpeg/core/dist/ffmpeg-core.js"):`https://unpkg.com/@ffmpeg/core@${i["@ffmpeg/core"].substring(1)}/dist/ffmpeg-core.js`}}).call(this,n(92))},function(e,t,n){const r=n(110),{log:i}=n(140),o=async(e,t)=>{i("info",`fetch ${e}`);const n=await(await fetch(e)).arrayBuffer();i("info",`${e} file size = ${n.byteLength} bytes`);const r=new Blob([n],{type:t}),o=URL.createObjectURL(r);return i("info",`${e} blob URL = ${o}`),o};e.exports=async({corePath:e})=>{if("string"!=typeof e)throw Error("corePath should be a string!");const t=r(e),n=await o(t,"application/javascript"),a=await o(t.replace("ffmpeg-core.js","ffmpeg-core.wasm"),"application/wasm"),s=await o(t.replace("ffmpeg-core.js","ffmpeg-core.worker.js"),"application/javascript");return"undefined"==typeof createFFmpegCore?new Promise(e=>{const t=document.createElement("script"),r=()=>{t.removeEventListener("load",r),i("info","ffmpeg-core.js script loaded"),e({createFFmpegCore:createFFmpegCore,corePath:n,wasmPath:a,workerPath:s})};t.src=n,t.type="text/javascript",t.addEventListener("load",r),document.getElementsByTagName("head")[0].appendChild(t)}):(i("info","ffmpeg-core.js script is loaded already"),Promise.resolve({createFFmpegCore:createFFmpegCore,corePath:n,wasmPath:a,workerPath:s}))}},function(e,t,n){const r=n(110);e.exports=async e=>{let t=e;if(void 0===e)return new Uint8Array;if("string"==typeof e)if(/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(e))t=atob(e.split(",")[1]).split("").map(e=>e.charCodeAt(0));else{const n=await fetch(r(e));t=await n.arrayBuffer()}else(e instanceof File||e instanceof Blob)&&(t=await(n=e,new Promise((e,t)=>{const r=new FileReader;r.onload=()=>{e(r.result)},r.onerror=({target:{error:{code:e}}})=>{t(Error(`File could not be read! Code=${e}`))},r.readAsArrayBuffer(n)})));var n;return new Uint8Array(t)}},function(e,t,n){"use strict";n.r(t);n(171),n(120);var r=n(1),i=n.n(r),o=n(21),a=n.n(o),s=n(20),l=n(6),c=n(23);function u(e){return"/"===e.charAt(0)}function d(e,t){for(var n=t,r=n+1,i=e.length;r=0;h--){var p=i[h];"."===p?d(i,h):".."===p?(d(i,h),c++):c&&(d(i,h),c--)}if(!s)for(;c--;c)i.unshift("..");!s||""===i[0]||i[0]&&u(i[0])||i.unshift("");var f=i.join("/");return n&&"/"!==f.substr(-1)&&(f+="/"),f};var p=function(e,t){if(!e)throw new Error("Invariant failed")};function f(e){return"/"===e.charAt(0)?e:"/"+e}function m(e){return"/"===e.charAt(0)?e.substr(1):e}function g(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function b(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function v(e){var t=e.pathname,n=e.search,r=e.hash,i=t||"/";return n&&"?"!==n&&(i+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(i+="#"===r.charAt(0)?r:"#"+r),i}function A(e,t,n,r){var i;"string"==typeof e?(i=function(e){var t=e||"/",n="",r="",i=t.indexOf("#");-1!==i&&(r=t.substr(i),t=t.substr(0,i));var o=t.indexOf("?");return-1!==o&&(n=t.substr(o),t=t.substr(0,o)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e)).state=t:(void 0===(i=Object(c.a)({},e)).pathname&&(i.pathname=""),i.search?"?"!==i.search.charAt(0)&&(i.search="?"+i.search):i.search="",i.hash?"#"!==i.hash.charAt(0)&&(i.hash="#"+i.hash):i.hash="",void 0!==t&&void 0===i.state&&(i.state=t));try{i.pathname=decodeURI(i.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+i.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return n&&(i.key=n),r?i.pathname?"/"!==i.pathname.charAt(0)&&(i.pathname=h(i.pathname,r.pathname)):i.pathname=r.pathname:i.pathname||(i.pathname="/"),i}function _(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,i){if(null!=e){var o="function"==typeof e?e(t,n):e;"string"==typeof o?"function"==typeof r?r(o,i):i(!0):i(!1!==o)}else i(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;rt?n.splice(t,n.length-t,r):n.push(r),d({action:"PUSH",location:r,index:t,entries:n})}}))},replace:function(e,t){var r=A(e,t,h(),b.location);u.confirmTransitionTo(r,"REPLACE",n,(function(e){e&&(b.entries[b.index]=r,d({action:"REPLACE",location:r}))}))},go:g,goBack:function(){g(-1)},goForward:function(){g(1)},canGo:function(e){var t=b.index+e;return t>=0&&t0)){t.next=19;break}if(!n._flushStream[e]){t.next=13;break}return n._flushStream[e]=!1,n._stateQueues[e].length=0,t.abrupt("continue",8);case 13:return i=n._stateQueues[e].pop(),o=[i.current_elapsed_time,i.total_elapsed_time],t.next=17,[i.state,o];case 17:t.next=8;break;case 19:t.next=24;break;case 21:return t.next=23,de(n._obtainStream(e,n._stateQueues[e],n._maxRetries));case 23:n._sockets[e]=t.sent;case 24:if(!(re.length)&&(t=e.length);for(var n=0,r=new Array(t);n0),qe(n,"".concat(a,"-rtl"),"rtl"===i),n),s);return r.createElement(lt.Provider,{value:{siderHook:e.getSiderHook()}},r.createElement(u,Ze({className:h},d),l))},e}return et(n,[{key:"getSiderHook",value:function(){var e=this;return{addSider:function(t){e.setState((function(e){return{siders:[].concat(Xe(e.siders),[t])}}))},removeSider:function(t){e.setState((function(e){return{siders:e.siders.filter((function(e){return e!==t}))}}))}}}},{key:"render",value:function(){return r.createElement(We,null,this.renderComponent)}}]),n}(r.Component),ht=ct({suffixCls:"layout",tagName:"section",displayName:"Layout"})(dt),pt=ct({suffixCls:"layout-header",tagName:"header",displayName:"Header"})(ut),ft=ct({suffixCls:"layout-footer",tagName:"footer",displayName:"Footer"})(ut),mt=ct({suffixCls:"layout-content",tagName:"main",displayName:"Content"})(ut);ht.Header=pt,ht.Footer=ft,ht.Content=mt;var gt=ht,bt=n(12),vt=n.n(bt);var At=function(e,t){for(var n=vt()({},e),r=0;r0&&void 0!==arguments[0]?arguments[0]:"";return Ut+=1,"".concat(e).concat(Ut)}),Ht=function(e){kt(n,e);var t=Bt(n);function n(e){var i,o,a;return Rt(this,n),(i=t.call(this,e)).responsiveHandler=function(e){i.setState({below:e.matches});var t=i.props.onBreakpoint;t&&t(e.matches),i.state.collapsed!==e.matches&&i.setCollapsed(e.matches,"responsive")},i.setCollapsed=function(e,t){"collapsed"in i.props||i.setState({collapsed:e});var n=i.props.onCollapse;n&&n(e,t)},i.toggle=function(){var e=!i.state.collapsed;i.setCollapsed(e,"clickTrigger")},i.belowShowChange=function(){i.setState((function(e){return{belowShow:!e.belowShow}}))},i.renderSider=function(e){var t,n=e.getPrefixCls,o=i.props,a=o.prefixCls,s=o.className,l=o.theme,c=o.collapsible,u=o.reverseArrow,d=o.trigger,h=o.style,p=o.width,f=o.collapsedWidth,m=o.zeroWidthTriggerStyle,g=Vt(o,["prefixCls","className","theme","collapsible","reverseArrow","trigger","style","width","collapsedWidth","zeroWidthTriggerStyle"]),b=n("layout-sider",a),v=At(g,["collapsed","defaultCollapsed","onCollapse","breakpoint","onBreakpoint","siderHook","zeroWidthTriggerStyle"]),A=i.state.collapsed?f:p,_=St(A)?"".concat(A,"px"):String(A),y=0===parseFloat(String(f||0))?r.createElement("span",{onClick:i.toggle,className:"".concat(b,"-zero-width-trigger ").concat(b,"-zero-width-trigger-").concat(u?"right":"left"),style:m},r.createElement(yt.a,null)):null,x={expanded:u?r.createElement(wt.a,null):r.createElement(Ct.a,null),collapsed:u?r.createElement(Ct.a,null):r.createElement(wt.a,null)}[i.state.collapsed?"collapsed":"expanded"],w=null!==d?y||r.createElement("div",{className:"".concat(b,"-trigger"),onClick:i.toggle,style:{width:_}},d||x):null,E=Ot(Ot({},h),{flex:"0 0 ".concat(_),maxWidth:_,minWidth:_,width:_}),C=_e()(s,b,"".concat(b,"-").concat(l),(Pt(t={},"".concat(b,"-collapsed"),!!i.state.collapsed),Pt(t,"".concat(b,"-has-trigger"),c&&null!==d&&!y),Pt(t,"".concat(b,"-below"),!!i.state.below),Pt(t,"".concat(b,"-zero-width"),0===parseFloat(_)),t));return r.createElement("aside",Ot({className:C},v,{style:E}),r.createElement("div",{className:"".concat(b,"-children")},i.props.children),c||i.state.below&&y?w:null)},i.uniqueId=Gt("ant-sider-"),"undefined"!=typeof window&&(o=window.matchMedia),o&&e.breakpoint&&e.breakpoint in zt&&(i.mql=o("(max-width: ".concat(zt[e.breakpoint],")"))),a="collapsed"in e?e.collapsed:e.defaultCollapsed,i.state={collapsed:a,below:!1},i}return It(n,[{key:"componentDidMount",value:function(){this.mql&&(this.mql.addListener(this.responsiveHandler),this.responsiveHandler(this.mql)),this.props.siderHook&&this.props.siderHook.addSider(this.uniqueId)}},{key:"componentWillUnmount",value:function(){this.mql&&this.mql.removeListener(this.responsiveHandler),this.props.siderHook&&this.props.siderHook.removeSider(this.uniqueId)}},{key:"render",value:function(){var e=this.state.collapsed,t=this.props.collapsedWidth;return r.createElement(jt.Provider,{value:{siderCollapsed:e,collapsedWidth:t}},r.createElement(We,null,this.renderSider))}}],[{key:"getDerivedStateFromProps",value:function(e){return"collapsed"in e?{collapsed:e.collapsed}:null}}]),n}(r.Component);Ht.defaultProps={collapsible:!1,defaultCollapsed:!1,reverseArrow:!1,width:200,collapsedWidth:80,style:{},theme:"dark"};var Qt=function(e){kt(n,e);var t=Bt(n);function n(){return Rt(this,n),t.apply(this,arguments)}return It(n,[{key:"render",value:function(){var e=this;return(r.createElement(lt.Consumer,null,(function(t){return r.createElement(Ht,Ot({},t,e.props))})))}}]),n}(r.Component);gt.Sider=Qt;var Wt=gt,Kt=n(18),Xt=n(146),Yt=n(86),qt=n(55);function Zt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jt(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function $t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return en(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return en(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function en(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&void 0!==arguments[1]?arguments[1]:1,n=x.length,r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function pn(e){var t=e.key,n=e.props,r=n.children,i=n.value;return un({key:t,value:void 0!==i?i:t,children:r},hn(n,["children","value"]))}function fn(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Object(ln.a)(e).map((function(e,n){if(!r.isValidElement(e)||!e.type)return null;var i=e.type.isSelectOptGroup,o=e.key,a=e.props,s=a.children,l=hn(a,["children"]);return t||!i?pn(e):un({key:"__RC_SELECT_GRP__".concat(null===o?n:o,"__"),label:o},l,{options:fn(s)})})).filter((function(e){return e}))}var mn=n(46),gn=n(168),bn=n(17),vn=n(34);function An(e){return(An="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var _n=function(e){var t=e.mode,n=e.options,r=e.children,o=e.backfill,a=e.allowClear,s=e.placeholder,l=e.getInputElement,c=e.showSearch,u=e.onSearch,d=e.defaultOpen,h=e.autoFocus,p=e.labelInValue,f=e.value,m=e.inputValue,g=e.optionLabelProp,b="multiple"===t||"tags"===t,v=void 0!==c?c:b||"combobox"===t,A=n||fn(r);if(Object(bn.a)("tags"!==t||A.every((function(e){return!e.disabled})),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),"tags"===t||"combobox"===t){var _=A.some((function(e){return e.options?e.options.some((function(e){return"number"==typeof("value"in e?e.value:e.key)})):"number"==typeof("value"in e?e.value:e.key)}));Object(bn.a)(!_,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(bn.a)("combobox"!==t||!g,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(bn.a)("combobox"===t||!o,"`backfill` only works with `combobox` mode."),Object(bn.a)("combobox"===t||!l,"`getInputElement` only work with `combobox` mode."),Object(bn.b)("combobox"!==t||!l||!a||!s,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),u&&!v&&"combobox"!==t&&"tags"!==t&&Object(bn.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(bn.b)(!d||h,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),null!=f){var y=Object(vn.d)(f);Object(bn.a)(!p||y.every((function(e){return"object"===An(e)&&("key"in e||"value"in e)})),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(bn.a)(!b||Array.isArray(f),"`value` should be array when `mode` is `multiple` or `tags`")}if(r){var x=null;Object(ln.a)(r).some((function(e){if(!i.a.isValidElement(e)||!e.type)return!1;var t=e.type;return!t.isSelectOption&&(t.isSelectOptGroup?!Object(ln.a)(e.props.children).every((function(t){return!(i.a.isValidElement(t)&&e.type&&!t.type.isSelectOption)||(x=t.type,!1)})):(x=t,!0))})),x&&Object(bn.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(x.displayName||x.name||x,"`.")),Object(bn.a)(void 0===m,"`inputValue` is deprecated, please use `searchValue` instead.")}};function yn(e){return(yn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function xn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wn(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:1,n=hr++,r=t;function i(){(r-=1)<=0?(e(),delete pr[n]):pr[n]=dr()(i)}return pr[n]=dr()(i),n}function mr(e){return(mr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function gr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function br(e,t){for(var n=0;n=0)){var r=e.props.insertExtraNode;e.extraNode=document.createElement("div");var i=_r(e).extraNode;i.className="ant-click-animating-node";var o=e.getAttributeName();t.setAttribute(o,"true"),or=or||document.createElement("style"),n&&"#ffffff"!==n&&"rgb(255, 255, 255)"!==n&&Er(n)&&!/rgba\((?:\d*, ){3}0\)/.test(n)&&"transparent"!==n&&(e.csp&&e.csp.nonce&&(or.nonce=e.csp.nonce),i.style.borderColor=n,or.innerHTML="\n [ant-click-animating-without-extra-node='true']::after, .ant-click-animating-node {\n --antd-wave-shadow-color: ".concat(n,";\n }"),document.body.contains(or)||document.body.appendChild(or)),r&&t.appendChild(i),cr.a.addStartEventListener(t,e.onTransitionStart),cr.a.addEndEventListener(t,e.onTransitionEnd)}},e.onTransitionStart=function(t){if(!e.destroyed){var n=Object(o.findDOMNode)(_r(e));t&&t.target===n&&!e.animationStart&&e.resetEffect(n)}},e.onTransitionEnd=function(t){t&&"fadeEffect"===t.animationName&&e.resetEffect(t.target)},e.bindAnimationEvent=function(t){if(t&&t.getAttribute&&!t.getAttribute("disabled")&&!(t.className.indexOf("disabled")>=0)){var n=function(n){if("INPUT"!==n.target.tagName&&!wr(n.target)){e.resetEffect(t);var r=getComputedStyle(t).getPropertyValue("border-top-color")||getComputedStyle(t).getPropertyValue("border-color")||getComputedStyle(t).getPropertyValue("background-color");e.clickWaveTimeoutId=window.setTimeout((function(){return e.onClick(t,r)}),0),fr.cancel(e.animationStartId),e.animationStart=!0,e.animationStartId=fr((function(){e.animationStart=!1}),10)}};return t.addEventListener("click",n,!0),{cancel:function(){t.removeEventListener("click",n,!0)}}}},e.renderWave=function(t){var n=t.csp,r=e.props.children;return e.csp=n,r},e}return n=l,(i=[{key:"componentDidMount",value:function(){var e=Object(o.findDOMNode)(this);e&&1===e.nodeType&&(this.instance=this.bindAnimationEvent(e))}},{key:"componentWillUnmount",value:function(){this.instance&&this.instance.cancel(),this.clickWaveTimeoutId&&clearTimeout(this.clickWaveTimeoutId),this.destroyed=!0}},{key:"getAttributeName",value:function(){return this.props.insertExtraNode?"ant-click-animating":"ant-click-animating-without-extra-node"}},{key:"resetEffect",value:function(e){if(e&&e!==this.extraNode&&e instanceof Element){var t=this.props.insertExtraNode,n=this.getAttributeName();e.setAttribute(n,"false"),or&&(or.innerHTML=""),t&&this.extraNode&&e.contains(this.extraNode)&&e.removeChild(this.extraNode),cr.a.removeStartEventListener(e,this.onTransitionStart),cr.a.removeEndEventListener(e,this.onTransitionEnd)}}},{key:"render",value:function(){return r.createElement(We,null,this.renderWave)}}])&&br(n.prototype,i),a&&br(n,a),l}(r.Component),Sr=function(){for(var e=arguments.length,t=new Array(e),n=0;n2),"Button","`icon` is using ReactNode instead of string naming in v4. Please check `".concat(m,"` at https://ant.design/components/icon"));var x=n("btn",l),w=!1!==i,E="";switch(h||t){case"large":E="lg";break;case"small":E="sm"}var C=_?"loading":m,S=_e()(x,p,(kr(a={},"".concat(x,"-").concat(c),c),kr(a,"".concat(x,"-").concat(d),d),kr(a,"".concat(x,"-").concat(E),E),kr(a,"".concat(x,"-icon-only"),!f&&0!==f&&C),kr(a,"".concat(x,"-background-ghost"),g),kr(a,"".concat(x,"-loading"),_),kr(a,"".concat(x,"-two-chinese-chars"),y&&w),kr(a,"".concat(x,"-block"),b),kr(a,"".concat(x,"-dangerous"),!!u),kr(a,"".concat(x,"-rtl"),"rtl"===o),a)),T=m&&!_?m:r.createElement(Mr,{existIcon:!!m,prefixCls:x,loading:_}),P=f||0===f?Gr(f,e.isNeedInserted()&&w):null,O=At(v,["htmlType","loading"]);if(void 0!==O.href)return r.createElement("a",Ir({},O,{className:S,onClick:e.handleClick,ref:e.saveButtonRef}),T,P);var R=v,M=R.htmlType,I=Vr(R,["htmlType"]),k=r.createElement("button",Ir({},At(I,["loading"]),{type:M,className:S,onClick:e.handleClick,ref:e.saveButtonRef}),T,P);return"link"===c?k:r.createElement(Cr,null,k)}))}}])&&Dr(n.prototype,i),o&&Dr(n,o),s}(r.Component);Hr.__ANT_BUTTON=!0,Hr.contextType=Qe,Hr.defaultProps={loading:!1,ghost:!1,block:!1,htmlType:"button"};var Qr=Hr;var Wr=function e(t){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new Error("unreachable case: ".concat(JSON.stringify(t)))};function Kr(){return(Kr=Object.assign||function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(g=t.getOptions().map((function(e){return r.createElement(Di,{prefixCls:p,key:e.value.toString(),disabled:"disabled"in e?e.disabled:a.disabled,value:e.value,checked:-1!==s.value.indexOf(e.value),onChange:e.onChange,className:"".concat(f,"-item"),style:e.style},e.label)})));var b,v,A,_={toggleOption:t.toggleOption,value:t.state.value,disabled:t.props.disabled,name:t.props.name,registerValue:t.registerValue,cancelValue:t.cancelValue},y=_e()(f,c,(b={},v="".concat(f,"-rtl"),A="rtl"===i,v in b?Object.defineProperty(b,v,{value:A,enumerable:!0,configurable:!0,writable:!0}):b[v]=A,b));return r.createElement("div",ci({className:y,style:u},m),r.createElement(Ai.Provider,{value:_},g))},t.state={value:e.value||e.defaultValue||[],registeredValues:[]},t}return n=s,o=[{key:"getDerivedStateFromProps",value:function(e){return"value"in e?{value:e.value||[]}:null}}],(i=[{key:"getOptions",value:function(){return this.props.options.map((function(e){return"string"==typeof e?{label:e,value:e}:e}))}},{key:"render",value:function(){return r.createElement(We,null,this.renderGroup)}}])&&hi(n.prototype,i),o&&hi(n,o),s}(r.PureComponent);_i.defaultProps={options:[]},_i.propTypes={defaultValue:l.array,value:l.array,options:l.array.isRequired,onChange:l.func};var yi=_i;function xi(e){return(xi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function wi(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ei(){return(Ei=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};return Object.keys(e).reduce((function(t,n){var r=e[n];switch(n){case"class":t.className=r,delete t.class;break;default:t[n]=r}return t}),{})}function Qi(e){return Object(Ni.generate)(e)[0]}function Wi(e){return e?Array.isArray(e)?e:[e]:[]}var Ki="\n.anticon {\n display: inline-block;\n color: inherit;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -0.125em;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.anticon > * {\n line-height: 1;\n}\n\n.anticon svg {\n display: inline-block;\n}\n\n.anticon::before {\n display: none;\n}\n\n.anticon .anticon-icon {\n display: block;\n}\n\n.anticon[tabindex] {\n cursor: pointer;\n}\n\n.anticon-spin::before,\n.anticon-spin {\n display: inline-block;\n -webkit-animation: loadingCircle 1s infinite linear;\n animation: loadingCircle 1s infinite linear;\n}\n\n@-webkit-keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n",Xi=!1;function Yi(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function qi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Zi(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:Ki;Object(r.useEffect)((function(){Xi||(Object(Li.insertCss)(e,{prepend:!0}),Xi=!0)}),[])}(),t=Gi(o),n="icon should be icon definiton, but got ".concat(o),Object(bn.a)(t,"[@ant-design/icons] ".concat(n)),!Gi(o))return null;var p=o;return p&&"function"==typeof p.icon&&(p=Zi({},p,{icon:p.icon(h.primaryColor,h.secondaryColor)})),function e(t,n,r){return r?i.a.createElement(t.tag,Vi({key:n},Hi(t.attrs),{},r),(t.children||[]).map((function(r,i){return e(r,"".concat(n,"-").concat(t.tag,"-").concat(i))}))):i.a.createElement(t.tag,Vi({key:n},Hi(t.attrs)),(t.children||[]).map((function(r,i){return e(r,"".concat(n,"-").concat(t.tag,"-").concat(i))})))}(p.icon,"svg-".concat(p.name),Zi({className:a,onClick:s,style:l,"data-icon":p.name,width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true"},d))};eo.displayName="IconReact",eo.getTwoToneColors=function(){return Zi({},$i)},eo.setTwoToneColors=function(e){var t=e.primaryColor,n=e.secondaryColor;$i.primaryColor=t,$i.secondaryColor=n||Qi(t),$i.calculated=!!n};var to=eo;function no(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return ro(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ro(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ro(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}io("#1890ff");var lo=r.forwardRef((function(e,t){var n,i,o,a=e.className,s=e.icon,l=e.spin,c=e.rotate,u=e.tabIndex,d=e.onClick,h=e.twoToneColor,p=so(e,["className","icon","spin","rotate","tabIndex","onClick","twoToneColor"]),f=_e()("anticon",(n={},i="anticon-".concat(s.name),o=Boolean(s.name),i in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o,n),a),m=_e()({"anticon-spin":!!l||"loading"===s.name}),g=u;void 0===g&&d&&(g=-1);var b=c?{msTransform:"rotate(".concat(c,"deg)"),transform:"rotate(".concat(c,"deg)")}:void 0,v=oo(Wi(h),2),A=v[0],_=v[1];return r.createElement("span",Object.assign({role:"img","aria-label":s.name},p,{ref:t,tabIndex:g,onClick:d,className:f}),r.createElement(to,{className:m,icon:s,primaryColor:A,secondaryColor:_,style:b}))}));lo.displayName="AntdIcon",lo.getTwoToneColor=function(){var e=to.getTwoToneColors();return e.calculated?[e.primaryColor,e.secondaryColor]:e.primaryColor},lo.setTwoToneColor=io;var co=lo,uo=function(e,t){return r.createElement(co,Object.assign({},e,{ref:t,icon:Fi}))};uo.displayName="LoadingOutlined";var ho=r.forwardRef(uo);function po(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return fo(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fo(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=1&&n<=7)return!0}return!1},enumerable:!0,configurable:!0}),e.HasSpecificTrigger=function(t){for(var n in e.Triggers){if(e.Triggers.hasOwnProperty(n))if(parseInt(n)===t)return!0}return!1},e.Triggers={},e}(),yo=n(2),xo=function(){function e(){}return e.WithinEpsilon=function(e,t,n){void 0===n&&(n=1401298e-51);var r=e-t;return-n<=r&&r<=n},e.ToHex=function(e){var t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()},e.Sign=function(e){return 0===(e=+e)||isNaN(e)?e:e>0?1:-1},e.Clamp=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),Math.min(n,Math.max(t,e))},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,n){return(e-t)/(n-t)},e.Denormalize=function(e,t,n){return e*(n-t)+t},e.DeltaAngle=function(t,n){var r=e.Repeat(n-t,360);return r>180&&(r-=360),r},e.PingPong=function(t,n){var r=e.Repeat(t,2*n);return n-Math.abs(r-n)},e.SmoothStep=function(t,n,r){var i=e.Clamp(r);return n*(i=-2*i*i*i+3*i*i)+t*(1-i)},e.MoveTowards=function(t,n,r){return Math.abs(n-t)<=r?n:t+e.Sign(n-t)*r},e.MoveTowardsAngle=function(t,n,r){var i=e.DeltaAngle(t,n),o=0;return-r180&&(i-=360),t+i*e.Clamp(r)},e.InverseLerp=function(t,n,r){return t!=n?e.Clamp((r-t)/(n-t)):0},e.Hermite=function(e,t,n,r,i){var o=i*i,a=i*o;return e*(2*a-3*o+1)+n*(-2*a+3*o)+t*(a-2*o+i)+r*(a-o)},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,n){return(e-t)/(n-t)},e.PercentToRange=function(e,t,n){return(n-t)*e+t},e.NormalizeRadians=function(t){return t-=e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.TwoPi=2*Math.PI,e}(),wo=function(){function e(){}return e.BuildArray=function(e,t){for(var n=[],r=0;rr.x?r.x:i)r.y?r.y:o)n.x?t.x:n.x,t.y>n.y?t.y:n.y)},e.Transform=function(t,n){var r=e.Zero();return e.TransformToRef(t,n,r),r},e.TransformToRef=function(e,t,n){var r=t.m,i=e.x*r[0]+e.y*r[4]+r[12],o=e.x*r[1]+e.y*r[5]+r[13];n.x=i,n.y=o},e.PointInTriangle=function(e,t,n,r){var i=.5*(-n.y*r.x+t.y*(-n.x+r.x)+t.x*(n.y-r.y)+n.x*r.y),o=i<0?-1:1,a=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,s=(t.x*n.y-t.y*n.x+(t.y-n.y)*e.x+(n.x-t.x)*e.y)*o;return a>0&&s>0&&a+s<2*i*o},e.Distance=function(t,n){return Math.sqrt(e.DistanceSquared(t,n))},e.DistanceSquared=function(e,t){var n=e.x-t.x,r=e.y-t.y;return n*n+r*r},e.Center=function(e,t){var n=e.add(t);return n.scaleInPlace(.5),n},e.DistanceOfPointFromSegment=function(t,n,r){var i=e.DistanceSquared(n,r);if(0===i)return e.Distance(t,n);var o=r.subtract(n),a=Math.max(0,Math.min(1,e.Dot(t.subtract(n),o)/i)),s=n.add(o.multiplyByFloats(a,a));return e.Distance(t,s)},e}(),So=function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this.x=e,this.y=t,this.z=n}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},e.prototype.getClassName=function(){return"Vector3"},e.prototype.getHashCode=function(){var e=0|this.x;return e=397*(e=397*e^(0|this.y))^(0|this.z)},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,this},e.prototype.toQuaternion=function(){return Po.RotationYawPitchRoll(this.y,this.x,this.z)},e.prototype.addInPlace=function(e){return this.addInPlaceFromFloats(e.x,e.y,e.z)},e.prototype.addInPlaceFromFloats=function(e,t,n){return this.x+=e,this.y+=t,this.z+=n,this},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z)},e.prototype.addToRef=function(e,t){return t.copyFromFloats(this.x+e.x,this.y+e.y,this.z+e.z)},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z)},e.prototype.subtractToRef=function(e,t){return this.subtractFromFloatsToRef(e.x,e.y,e.z,t)},e.prototype.subtractFromFloats=function(t,n,r){return new e(this.x-t,this.y-n,this.z-r)},e.prototype.subtractFromFloatsToRef=function(e,t,n,r){return r.copyFromFloats(this.x-e,this.y-t,this.z-n)},e.prototype.negate=function(){return new e(-this.x,-this.y,-this.z)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this.x,-1*this.y,-1*this.z)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t)},e.prototype.scaleToRef=function(e,t){return t.copyFromFloats(this.x*e,this.y*e,this.z*e)},e.prototype.scaleAndAddToRef=function(e,t){return t.addInPlaceFromFloats(this.x*e,this.y*e,this.z*e)},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=.001),e&&xo.WithinEpsilon(this.x,e.x,t)&&xo.WithinEpsilon(this.y,e.y,t)&&xo.WithinEpsilon(this.z,e.z,t)},e.prototype.equalsToFloats=function(e,t,n){return this.x===e&&this.y===t&&this.z===n},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},e.prototype.multiply=function(e){return this.multiplyByFloats(e.x,e.y,e.z)},e.prototype.multiplyToRef=function(e,t){return t.copyFromFloats(this.x*e.x,this.y*e.y,this.z*e.z)},e.prototype.multiplyByFloats=function(t,n,r){return new e(this.x*t,this.y*n,this.z*r)},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y,this.z/t.z)},e.prototype.divideToRef=function(e,t){return t.copyFromFloats(this.x/e.x,this.y/e.y,this.z/e.z)},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.minimizeInPlace=function(e){return this.minimizeInPlaceFromFloats(e.x,e.y,e.z)},e.prototype.maximizeInPlace=function(e){return this.maximizeInPlaceFromFloats(e.x,e.y,e.z)},e.prototype.minimizeInPlaceFromFloats=function(e,t,n){return ethis.x&&(this.x=e),t>this.y&&(this.y=t),n>this.z&&(this.z=n),this},e.prototype.isNonUniformWithinEpsilon=function(e){var t=Math.abs(this.x),n=Math.abs(this.y);if(!xo.WithinEpsilon(t,n,e))return!0;var r=Math.abs(this.z);return!xo.WithinEpsilon(t,r,e)||!xo.WithinEpsilon(n,r,e)},Object.defineProperty(e.prototype,"isNonUniform",{get:function(){var e=Math.abs(this.x),t=Math.abs(this.y);if(e!==t)return!0;var n=Math.abs(this.z);return e!==n||t!==n},enumerable:!0,configurable:!0}),e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},e.prototype.normalize=function(){return this.normalizeFromLength(this.length())},e.prototype.reorderInPlace=function(e){var t=this;return"xyz"===(e=e.toLowerCase())||(Ro.Vector3[0].copyFrom(this),["x","y","z"].forEach((function(n,r){t[n]=Ro.Vector3[0][e[r]]}))),this},e.prototype.rotateByQuaternionToRef=function(t,n){return t.toRotationMatrix(Ro.Matrix[0]),e.TransformCoordinatesToRef(this,Ro.Matrix[0],n),n},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,n){return this.subtractToRef(t,Ro.Vector3[0]),Ro.Vector3[0].rotateByQuaternionToRef(e,Ro.Vector3[0]),t.addToRef(Ro.Vector3[0],n),n},e.prototype.cross=function(t){return e.Cross(this,t)},e.prototype.normalizeFromLength=function(e){return 0===e||1===e?this:this.scaleInPlace(1/e)},e.prototype.normalizeToNew=function(){var t=new e(0,0,0);return this.normalizeToRef(t),t},e.prototype.normalizeToRef=function(e){var t=this.length();return 0===t||1===t?e.copyFromFloats(this.x,this.y,this.z):this.scaleToRef(1/t,e)},e.prototype.clone=function(){return new e(this.x,this.y,this.z)},e.prototype.copyFrom=function(e){return this.copyFromFloats(e.x,e.y,e.z)},e.prototype.copyFromFloats=function(e,t,n){return this.x=e,this.y=t,this.z=n,this},e.prototype.set=function(e,t,n){return this.copyFromFloats(e,t,n)},e.prototype.setAll=function(e){return this.x=this.y=this.z=e,this},e.GetClipFactor=function(t,n,r,i){var o=e.Dot(t,r)-i;return o/(o-(e.Dot(n,r)-i))},e.GetAngleBetweenVectors=function(t,n,r){var i=t.normalizeToRef(Ro.Vector3[1]),o=n.normalizeToRef(Ro.Vector3[2]),a=e.Dot(i,o),s=Ro.Vector3[3];return e.CrossToRef(i,o,s),e.Dot(s,r)>0?Math.acos(a):-Math.acos(a)},e.FromArray=function(t,n){return void 0===n&&(n=0),new e(t[n],t[n+1],t[n+2])},e.FromFloatArray=function(t,n){return e.FromArray(t,n)},e.FromArrayToRef=function(e,t,n){n.x=e[t],n.y=e[t+1],n.z=e[t+2]},e.FromFloatArrayToRef=function(t,n,r){return e.FromArrayToRef(t,n,r)},e.FromFloatsToRef=function(e,t,n,r){r.copyFromFloats(e,t,n)},e.Zero=function(){return new e(0,0,0)},e.One=function(){return new e(1,1,1)},e.Up=function(){return new e(0,1,0)},Object.defineProperty(e,"UpReadOnly",{get:function(){return e._UpReadOnly},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ZeroReadOnly",{get:function(){return e._ZeroReadOnly},enumerable:!0,configurable:!0}),e.Down=function(){return new e(0,-1,0)},e.Forward=function(){return new e(0,0,1)},e.Backward=function(){return new e(0,0,-1)},e.Right=function(){return new e(1,0,0)},e.Left=function(){return new e(-1,0,0)},e.TransformCoordinates=function(t,n){var r=e.Zero();return e.TransformCoordinatesToRef(t,n,r),r},e.TransformCoordinatesToRef=function(t,n,r){e.TransformCoordinatesFromFloatsToRef(t.x,t.y,t.z,n,r)},e.TransformCoordinatesFromFloatsToRef=function(e,t,n,r,i){var o=r.m,a=e*o[0]+t*o[4]+n*o[8]+o[12],s=e*o[1]+t*o[5]+n*o[9]+o[13],l=e*o[2]+t*o[6]+n*o[10]+o[14],c=1/(e*o[3]+t*o[7]+n*o[11]+o[15]);i.x=a*c,i.y=s*c,i.z=l*c},e.TransformNormal=function(t,n){var r=e.Zero();return e.TransformNormalToRef(t,n,r),r},e.TransformNormalToRef=function(e,t,n){this.TransformNormalFromFloatsToRef(e.x,e.y,e.z,t,n)},e.TransformNormalFromFloatsToRef=function(e,t,n,r,i){var o=r.m;i.x=e*o[0]+t*o[4]+n*o[8],i.y=e*o[1]+t*o[5]+n*o[9],i.z=e*o[2]+t*o[6]+n*o[10]},e.CatmullRom=function(t,n,r,i,o){var a=o*o,s=o*a;return new e(.5*(2*n.x+(-t.x+r.x)*o+(2*t.x-5*n.x+4*r.x-i.x)*a+(-t.x+3*n.x-3*r.x+i.x)*s),.5*(2*n.y+(-t.y+r.y)*o+(2*t.y-5*n.y+4*r.y-i.y)*a+(-t.y+3*n.y-3*r.y+i.y)*s),.5*(2*n.z+(-t.z+r.z)*o+(2*t.z-5*n.z+4*r.z-i.z)*a+(-t.z+3*n.z-3*r.z+i.z)*s))},e.Clamp=function(t,n,r){var i=new e;return e.ClampToRef(t,n,r,i),i},e.ClampToRef=function(e,t,n,r){var i=e.x;i=(i=i>n.x?n.x:i)n.y?n.y:o)n.z?n.z:a)this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.prototype.normalize=function(){var e=this.length();return 0===e?this:this.scaleInPlace(1/e)},e.prototype.toVector3=function(){return new So(this.x,this.y,this.z)},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this},e.prototype.set=function(e,t,n,r){return this.copyFromFloats(e,t,n,r)},e.prototype.setAll=function(e){return this.x=this.y=this.z=this.w=e,this},e.FromArray=function(t,n){return n||(n=0),new e(t[n],t[n+1],t[n+2],t[n+3])},e.FromArrayToRef=function(e,t,n){n.x=e[t],n.y=e[t+1],n.z=e[t+2],n.w=e[t+3]},e.FromFloatArrayToRef=function(t,n,r){e.FromArrayToRef(t,n,r)},e.FromFloatsToRef=function(e,t,n,r,i){i.x=e,i.y=t,i.z=n,i.w=r},e.Zero=function(){return new e(0,0,0,0)},e.One=function(){return new e(1,1,1,1)},e.Normalize=function(t){var n=e.Zero();return e.NormalizeToRef(t,n),n},e.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},e.Minimize=function(e,t){var n=e.clone();return n.minimizeInPlace(t),n},e.Maximize=function(e,t){var n=e.clone();return n.maximizeInPlace(t),n},e.Distance=function(t,n){return Math.sqrt(e.DistanceSquared(t,n))},e.DistanceSquared=function(e,t){var n=e.x-t.x,r=e.y-t.y,i=e.z-t.z,o=e.w-t.w;return n*n+r*r+i*i+o*o},e.Center=function(e,t){var n=e.add(t);return n.scaleInPlace(.5),n},e.TransformNormal=function(t,n){var r=e.Zero();return e.TransformNormalToRef(t,n,r),r},e.TransformNormalToRef=function(e,t,n){var r=t.m,i=e.x*r[0]+e.y*r[4]+e.z*r[8],o=e.x*r[1]+e.y*r[5]+e.z*r[9],a=e.x*r[2]+e.y*r[6]+e.z*r[10];n.x=i,n.y=o,n.z=a,n.w=e.w},e.TransformNormalFromFloatsToRef=function(e,t,n,r,i,o){var a=i.m;o.x=e*a[0]+t*a[4]+n*a[8],o.y=e*a[1]+t*a[5]+n*a[9],o.z=e*a[2]+t*a[6]+n*a[10],o.w=r},e.FromVector3=function(t,n){return void 0===n&&(n=0),new e(t.x,t.y,t.z,n)},e}(),Po=function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=n,this.w=r}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=0|this.x;return e=397*(e=397*(e=397*e^(0|this.y))^(0|this.z))^(0|this.w)},e.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=.001),e&&xo.WithinEpsilon(this.x,e.x,t)&&xo.WithinEpsilon(this.y,e.y,t)&&xo.WithinEpsilon(this.z,e.z,t)&&xo.WithinEpsilon(this.w,e.w,t)},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this},e.prototype.set=function(e,t,n,r){return this.copyFromFloats(e,t,n,r)},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t,this.w*t)},e.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e,this},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,t.z+=this.z*e,t.w+=this.w*e,this},e.prototype.multiply=function(t){var n=new e(0,0,0,1);return this.multiplyToRef(t,n),n},e.prototype.multiplyToRef=function(e,t){var n=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,i=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,o=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(n,r,i,o),this},e.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},e.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},e.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.conjugate=function(){return new e(-this.x,-this.y,-this.z,this.w)},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=So.Zero();return this.toEulerAnglesToRef(t),t},e.prototype.toEulerAnglesToRef=function(e){var t=this.z,n=this.x,r=this.y,i=this.w,o=i*i,a=t*t,s=n*n,l=r*r,c=r*t-n*i;return c<-.4999999?(e.y=2*Math.atan2(r,i),e.x=Math.PI/2,e.z=0):c>.4999999?(e.y=2*Math.atan2(r,i),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(n*r+t*i),-a-s+l+o),e.x=Math.asin(-2*(t*r-n*i)),e.y=Math.atan2(2*(t*n+r*i),a-s-l+o)),this},e.prototype.toRotationMatrix=function(e){return Oo.FromQuaternionToRef(this,e),this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var n=new e;return e.FromRotationMatrixToRef(t,n),n},e.FromRotationMatrixToRef=function(e,t){var n,r=e.m,i=r[0],o=r[4],a=r[8],s=r[1],l=r[5],c=r[9],u=r[2],d=r[6],h=r[10],p=i+l+h;p>0?(n=.5/Math.sqrt(p+1),t.w=.25/n,t.x=(d-c)*n,t.y=(a-u)*n,t.z=(s-o)*n):i>l&&i>h?(n=2*Math.sqrt(1+i-l-h),t.w=(d-c)/n,t.x=.25*n,t.y=(o+s)/n,t.z=(a+u)/n):l>h?(n=2*Math.sqrt(1+l-i-h),t.w=(a-u)/n,t.x=(o+s)/n,t.y=.25*n,t.z=(c+d)/n):(n=2*Math.sqrt(1+h-i-l),t.w=(s-o)/n,t.x=(a+u)/n,t.y=(c+d)/n,t.z=.25*n)},e.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},e.AreClose=function(t,n){return e.Dot(t,n)>=0},e.Zero=function(){return new e(0,0,0,0)},e.Inverse=function(t){return new e(-t.x,-t.y,-t.z,t.w)},e.InverseToRef=function(e,t){return t.set(-e.x,-e.y,-e.z,e.w),t},e.Identity=function(){return new e(0,0,0,1)},e.IsIdentity=function(e){return e&&0===e.x&&0===e.y&&0===e.z&&1===e.w},e.RotationAxis=function(t,n){return e.RotationAxisToRef(t,n,new e)},e.RotationAxisToRef=function(e,t,n){var r=Math.sin(t/2);return e.normalize(),n.w=Math.cos(t/2),n.x=e.x*r,n.y=e.y*r,n.z=e.z*r,n},e.FromArray=function(t,n){return n||(n=0),new e(t[n],t[n+1],t[n+2],t[n+3])},e.FromEulerAngles=function(t,n,r){var i=new e;return e.RotationYawPitchRollToRef(n,t,r,i),i},e.FromEulerAnglesToRef=function(t,n,r,i){return e.RotationYawPitchRollToRef(n,t,r,i),i},e.FromEulerVector=function(t){var n=new e;return e.RotationYawPitchRollToRef(t.y,t.x,t.z,n),n},e.FromEulerVectorToRef=function(t,n){return e.RotationYawPitchRollToRef(t.y,t.x,t.z,n),n},e.RotationYawPitchRoll=function(t,n,r){var i=new e;return e.RotationYawPitchRollToRef(t,n,r,i),i},e.RotationYawPitchRollToRef=function(e,t,n,r){var i=.5*n,o=.5*t,a=.5*e,s=Math.sin(i),l=Math.cos(i),c=Math.sin(o),u=Math.cos(o),d=Math.sin(a),h=Math.cos(a);r.x=h*c*l+d*u*s,r.y=d*u*l-h*c*s,r.z=h*u*s-d*c*l,r.w=h*u*l+d*c*s},e.RotationAlphaBetaGamma=function(t,n,r){var i=new e;return e.RotationAlphaBetaGammaToRef(t,n,r,i),i},e.RotationAlphaBetaGammaToRef=function(e,t,n,r){var i=.5*(n+e),o=.5*(n-e),a=.5*t;r.x=Math.cos(o)*Math.sin(a),r.y=Math.sin(o)*Math.sin(a),r.z=Math.sin(i)*Math.cos(a),r.w=Math.cos(i)*Math.cos(a)},e.RotationQuaternionFromAxis=function(t,n,r){var i=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,n,r,i),i},e.RotationQuaternionFromAxisToRef=function(t,n,r,i){var o=Ro.Matrix[0];Oo.FromXYZAxesToRef(t.normalize(),n.normalize(),r.normalize(),o),e.FromRotationMatrixToRef(o,i)},e.Slerp=function(t,n,r){var i=e.Identity();return e.SlerpToRef(t,n,r,i),i},e.SlerpToRef=function(e,t,n,r){var i,o,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,s=!1;if(a<0&&(s=!0,a=-a),a>.999999)o=1-n,i=s?-n:n;else{var l=Math.acos(a),c=1/Math.sin(l);o=Math.sin((1-n)*l)*c,i=s?-Math.sin(n*l)*c:Math.sin(n*l)*c}r.x=o*e.x+i*t.x,r.y=o*e.y+i*t.y,r.z=o*e.z+i*t.z,r.w=o*e.w+i*t.w},e.Hermite=function(t,n,r,i,o){var a=o*o,s=o*a,l=2*s-3*a+1,c=-2*s+3*a,u=s-2*a+o,d=s-a;return new e(t.x*l+r.x*c+n.x*u+i.x*d,t.y*l+r.y*c+n.y*u+i.y*d,t.z*l+r.z*c+n.z*u+i.z*d,t.w*l+r.w*c+n.w*u+i.w*d)},e}(),Oo=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,this._m=new Float32Array(16),this._updateIdentityStatus(!1)}return Object.defineProperty(e.prototype,"m",{get:function(){return this._m},enumerable:!0,configurable:!0}),e.prototype._markAsUpdated=function(){this.updateFlag=e._updateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0},e.prototype._updateIdentityStatus=function(t,n,r,i){void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===i&&(i=!0),this.updateFlag=e._updateFlagSeed++,this._isIdentity=t,this._isIdentity3x2=t||r,this._isIdentityDirty=!this._isIdentity&&n,this._isIdentity3x2Dirty=!this._isIdentity3x2&&i},e.prototype.isIdentity=function(){if(this._isIdentityDirty){this._isIdentityDirty=!1;var e=this._m;this._isIdentity=1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity},e.prototype.isIdentityAs3x2=function(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]||0!==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]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2},e.prototype.determinant=function(){if(!0===this._isIdentity)return 1;var e=this._m,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],p=e[12],f=e[13],m=e[14],g=e[15],b=d*g-m*h,v=u*g-f*h,A=u*m-f*d,_=c*g-p*h,y=c*m-d*p,x=c*f-p*u;return t*+(a*b-s*v+l*A)+n*-(o*b-s*_+l*y)+r*+(o*v-a*_+l*x)+i*-(o*A-a*y+s*x)},e.prototype.toArray=function(){return this._m},e.prototype.asArray=function(){return this._m},e.prototype.invert=function(){return this.invertToRef(this),this},e.prototype.reset=function(){return e.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this},e.prototype.add=function(t){var n=new e;return this.addToRef(t,n),n},e.prototype.addToRef=function(e,t){for(var n=this._m,r=t._m,i=e.m,o=0;o<16;o++)r[o]=n[o]+i[o];return t._markAsUpdated(),this},e.prototype.addToSelf=function(e){for(var t=this._m,n=e.m,r=0;r<16;r++)t[r]+=n[r];return this._markAsUpdated(),this},e.prototype.invertToRef=function(t){if(!0===this._isIdentity)return e.IdentityToRef(t),this;var n=this._m,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],c=n[6],u=n[7],d=n[8],h=n[9],p=n[10],f=n[11],m=n[12],g=n[13],b=n[14],v=n[15],A=p*v-b*f,_=h*v-g*f,y=h*b-g*p,x=d*v-m*f,w=d*b-p*m,E=d*g-m*h,C=+(l*A-c*_+u*y),S=-(s*A-c*x+u*w),T=+(s*_-l*x+u*E),P=-(s*y-l*w+c*E),O=r*C+i*S+o*T+a*P;if(0===O)return t.copyFrom(this),this;var R=1/O,M=c*v-b*u,I=l*v-g*u,k=l*b-g*c,D=s*v-m*u,B=s*b-m*c,F=s*g-m*l,N=c*f-p*u,L=l*f-h*u,U=l*p-h*c,V=s*f-d*u,z=s*p-d*c,j=s*h-d*l,G=-(i*A-o*_+a*y),H=+(r*A-o*x+a*w),Q=-(r*_-i*x+a*E),W=+(r*y-i*w+o*E),K=+(i*M-o*I+a*k),X=-(r*M-o*D+a*B),Y=+(r*I-i*D+a*F),q=-(r*k-i*B+o*F),Z=-(i*N-o*L+a*U),J=+(r*N-o*V+a*z),$=-(r*L-i*V+a*j),ee=+(r*U-i*z+o*j);return e.FromValuesToRef(C*R,G*R,K*R,Z*R,S*R,H*R,X*R,J*R,T*R,Q*R,Y*R,$*R,P*R,W*R,q*R,ee*R,t),this},e.prototype.addAtIndex=function(e,t){return this._m[e]+=t,this._markAsUpdated(),this},e.prototype.multiplyAtIndex=function(e,t){return this._m[e]*=t,this._markAsUpdated(),this},e.prototype.setTranslationFromFloats=function(e,t,n){return this._m[12]=e,this._m[13]=t,this._m[14]=n,this._markAsUpdated(),this},e.prototype.addTranslationFromFloats=function(e,t,n){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=n,this._markAsUpdated(),this},e.prototype.setTranslation=function(e){return this.setTranslationFromFloats(e.x,e.y,e.z)},e.prototype.getTranslation=function(){return new So(this._m[12],this._m[13],this._m[14])},e.prototype.getTranslationToRef=function(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],this},e.prototype.removeRotationAndScaling=function(){var t=this.m;return e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t[12],t[13],t[14],t[15],this),this._updateIdentityStatus(0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]),this},e.prototype.multiply=function(t){var n=new e;return this.multiplyToRef(t,n),n},e.prototype.copyFrom=function(e){e.copyToArray(this._m);var t=e;return this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);var n=this._m;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],this},e.prototype.multiplyToRef=function(e,t){return this._isIdentity?(t.copyFrom(e),this):e._isIdentity?(t.copyFrom(this),this):(this.multiplyToArray(e,t._m,0),t._markAsUpdated(),this)},e.prototype.multiplyToArray=function(e,t,n){var r=this._m,i=e.m,o=r[0],a=r[1],s=r[2],l=r[3],c=r[4],u=r[5],d=r[6],h=r[7],p=r[8],f=r[9],m=r[10],g=r[11],b=r[12],v=r[13],A=r[14],_=r[15],y=i[0],x=i[1],w=i[2],E=i[3],C=i[4],S=i[5],T=i[6],P=i[7],O=i[8],R=i[9],M=i[10],I=i[11],k=i[12],D=i[13],B=i[14],F=i[15];return t[n]=o*y+a*C+s*O+l*k,t[n+1]=o*x+a*S+s*R+l*D,t[n+2]=o*w+a*T+s*M+l*B,t[n+3]=o*E+a*P+s*I+l*F,t[n+4]=c*y+u*C+d*O+h*k,t[n+5]=c*x+u*S+d*R+h*D,t[n+6]=c*w+u*T+d*M+h*B,t[n+7]=c*E+u*P+d*I+h*F,t[n+8]=p*y+f*C+m*O+g*k,t[n+9]=p*x+f*S+m*R+g*D,t[n+10]=p*w+f*T+m*M+g*B,t[n+11]=p*E+f*P+m*I+g*F,t[n+12]=b*y+v*C+A*O+_*k,t[n+13]=b*x+v*S+A*R+_*D,t[n+14]=b*w+v*T+A*M+_*B,t[n+15]=b*E+v*P+A*I+_*F,this},e.prototype.equals=function(e){var t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;var n=this.m,r=t.m;return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3]&&n[4]===r[4]&&n[5]===r[5]&&n[6]===r[6]&&n[7]===r[7]&&n[8]===r[8]&&n[9]===r[9]&&n[10]===r[10]&&n[11]===r[11]&&n[12]===r[12]&&n[13]===r[13]&&n[14]===r[14]&&n[15]===r[15]},e.prototype.clone=function(){var t=new e;return t.copyFrom(this),t},e.prototype.getClassName=function(){return"Matrix"},e.prototype.getHashCode=function(){for(var e=0|this._m[0],t=1;t<16;t++)e=397*e^(0|this._m[t]);return e},e.prototype.decompose=function(t,n,r){if(this._isIdentity)return r&&r.setAll(0),t&&t.setAll(1),n&&n.copyFromFloats(0,0,0,1),!0;var i=this._m;if(r&&r.copyFromFloats(i[12],i[13],i[14]),(t=t||Ro.Vector3[0]).x=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),t.y=Math.sqrt(i[4]*i[4]+i[5]*i[5]+i[6]*i[6]),t.z=Math.sqrt(i[8]*i[8]+i[9]*i[9]+i[10]*i[10]),this.determinant()<=0&&(t.y*=-1),0===t.x||0===t.y||0===t.z)return n&&n.copyFromFloats(0,0,0,1),!1;if(n){var o=1/t.x,a=1/t.y,s=1/t.z;e.FromValuesToRef(i[0]*o,i[1]*o,i[2]*o,0,i[4]*a,i[5]*a,i[6]*a,0,i[8]*s,i[9]*s,i[10]*s,0,0,0,0,1,Ro.Matrix[0]),Po.FromRotationMatrixToRef(Ro.Matrix[0],n)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new To(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])},e.prototype.setRow=function(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)},e.prototype.transpose=function(){return e.Transpose(this)},e.prototype.transposeToRef=function(t){return e.TransposeToRef(this,t),this},e.prototype.setRowFromFloats=function(e,t,n,r,i){if(e<0||e>3)return this;var o=4*e;return this._m[o+0]=t,this._m[o+1]=n,this._m[o+2]=r,this._m[o+3]=i,this._markAsUpdated(),this},e.prototype.scale=function(t){var n=new e;return this.scaleToRef(t,n),n},e.prototype.scaleToRef=function(e,t){for(var n=0;n<16;n++)t._m[n]=this._m[n]*e;return t._markAsUpdated(),this},e.prototype.scaleAndAddToRef=function(e,t){for(var n=0;n<16;n++)t._m[n]+=this._m[n]*e;return t._markAsUpdated(),this},e.prototype.toNormalMatrix=function(t){var n=Ro.Matrix[0];this.invertToRef(n),n.transposeToRef(t);var r=t._m;e.FromValuesToRef(r[0],r[1],r[2],0,r[4],r[5],r[6],0,r[8],r[9],r[10],0,0,0,0,1,t)},e.prototype.getRotationMatrix=function(){var t=new e;return this.getRotationMatrixToRef(t),t},e.prototype.getRotationMatrixToRef=function(t){var n=Ro.Vector3[0];if(!this.decompose(n))return e.IdentityToRef(t),this;var r=this._m,i=1/n.x,o=1/n.y,a=1/n.z;return e.FromValuesToRef(r[0]*i,r[1]*i,r[2]*i,0,r[4]*o,r[5]*o,r[6]*o,0,r[8]*a,r[9]*a,r[10]*a,0,0,0,0,1,t),this},e.prototype.toggleModelMatrixHandInPlace=function(){var e=this._m;e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this._markAsUpdated()},e.prototype.toggleProjectionMatrixHandInPlace=function(){var e=this._m;e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this._markAsUpdated()},e.FromArray=function(t,n){void 0===n&&(n=0);var r=new e;return e.FromArrayToRef(t,n,r),r},e.FromArrayToRef=function(e,t,n){for(var r=0;r<16;r++)n._m[r]=e[r+t];n._markAsUpdated()},e.FromFloat32ArrayToRefScaled=function(e,t,n,r){for(var i=0;i<16;i++)r._m[i]=e[i+t]*n;r._markAsUpdated()},Object.defineProperty(e,"IdentityReadOnly",{get:function(){return e._identityReadOnly},enumerable:!0,configurable:!0}),e.FromValuesToRef=function(e,t,n,r,i,o,a,s,l,c,u,d,h,p,f,m,g){var b=g._m;b[0]=e,b[1]=t,b[2]=n,b[3]=r,b[4]=i,b[5]=o,b[6]=a,b[7]=s,b[8]=l,b[9]=c,b[10]=u,b[11]=d,b[12]=h,b[13]=p,b[14]=f,b[15]=m,g._markAsUpdated()},e.FromValues=function(t,n,r,i,o,a,s,l,c,u,d,h,p,f,m,g){var b=new e,v=b._m;return v[0]=t,v[1]=n,v[2]=r,v[3]=i,v[4]=o,v[5]=a,v[6]=s,v[7]=l,v[8]=c,v[9]=u,v[10]=d,v[11]=h,v[12]=p,v[13]=f,v[14]=m,v[15]=g,b._markAsUpdated(),b},e.Compose=function(t,n,r){var i=new e;return e.ComposeToRef(t,n,r,i),i},e.ComposeToRef=function(e,t,n,r){var i=r._m,o=t.x,a=t.y,s=t.z,l=t.w,c=o+o,u=a+a,d=s+s,h=o*c,p=o*u,f=o*d,m=a*u,g=a*d,b=s*d,v=l*c,A=l*u,_=l*d,y=e.x,x=e.y,w=e.z;i[0]=(1-(m+b))*y,i[1]=(p+_)*y,i[2]=(f-A)*y,i[3]=0,i[4]=(p-_)*x,i[5]=(1-(h+b))*x,i[6]=(g+v)*x,i[7]=0,i[8]=(f+A)*w,i[9]=(g-v)*w,i[10]=(1-(h+m))*w,i[11]=0,i[12]=n.x,i[13]=n.y,i[14]=n.z,i[15]=1,r._markAsUpdated()},e.Identity=function(){var t=e.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return t._updateIdentityStatus(!0),t},e.IdentityToRef=function(t){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(!0)},e.Zero=function(){var t=e.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return t._updateIdentityStatus(!1),t},e.RotationX=function(t){var n=new e;return e.RotationXToRef(t,n),n},e.Invert=function(t){var n=new e;return t.invertToRef(n),n},e.RotationXToRef=function(t,n){var r=Math.sin(t),i=Math.cos(t);e.FromValuesToRef(1,0,0,0,0,i,r,0,0,-r,i,0,0,0,0,1,n),n._updateIdentityStatus(1===i&&0===r)},e.RotationY=function(t){var n=new e;return e.RotationYToRef(t,n),n},e.RotationYToRef=function(t,n){var r=Math.sin(t),i=Math.cos(t);e.FromValuesToRef(i,0,-r,0,0,1,0,0,r,0,i,0,0,0,0,1,n),n._updateIdentityStatus(1===i&&0===r)},e.RotationZ=function(t){var n=new e;return e.RotationZToRef(t,n),n},e.RotationZToRef=function(t,n){var r=Math.sin(t),i=Math.cos(t);e.FromValuesToRef(i,r,0,0,-r,i,0,0,0,0,1,0,0,0,0,1,n),n._updateIdentityStatus(1===i&&0===r)},e.RotationAxis=function(t,n){var r=new e;return e.RotationAxisToRef(t,n,r),r},e.RotationAxisToRef=function(e,t,n){var r=Math.sin(-t),i=Math.cos(-t),o=1-i;e.normalize();var a=n._m;a[0]=e.x*e.x*o+i,a[1]=e.x*e.y*o-e.z*r,a[2]=e.x*e.z*o+e.y*r,a[3]=0,a[4]=e.y*e.x*o+e.z*r,a[5]=e.y*e.y*o+i,a[6]=e.y*e.z*o-e.x*r,a[7]=0,a[8]=e.z*e.x*o-e.y*r,a[9]=e.z*e.y*o+e.x*r,a[10]=e.z*e.z*o+i,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,n._markAsUpdated()},e.RotationAlignToRef=function(e,t,n){var r=So.Cross(t,e),i=So.Dot(t,e),o=1/(1+i),a=n._m;a[0]=r.x*r.x*o+i,a[1]=r.y*r.x*o-r.z,a[2]=r.z*r.x*o+r.y,a[3]=0,a[4]=r.x*r.y*o+r.z,a[5]=r.y*r.y*o+i,a[6]=r.z*r.y*o-r.x,a[7]=0,a[8]=r.x*r.z*o-r.y,a[9]=r.y*r.z*o+r.x,a[10]=r.z*r.z*o+i,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,n._markAsUpdated()},e.RotationYawPitchRoll=function(t,n,r){var i=new e;return e.RotationYawPitchRollToRef(t,n,r,i),i},e.RotationYawPitchRollToRef=function(e,t,n,r){Po.RotationYawPitchRollToRef(e,t,n,Ro.Quaternion[0]),Ro.Quaternion[0].toRotationMatrix(r)},e.Scaling=function(t,n,r){var i=new e;return e.ScalingToRef(t,n,r,i),i},e.ScalingToRef=function(t,n,r,i){e.FromValuesToRef(t,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1,i),i._updateIdentityStatus(1===t&&1===n&&1===r)},e.Translation=function(t,n,r){var i=new e;return e.TranslationToRef(t,n,r,i),i},e.TranslationToRef=function(t,n,r,i){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,n,r,1,i),i._updateIdentityStatus(0===t&&0===n&&0===r)},e.Lerp=function(t,n,r){var i=new e;return e.LerpToRef(t,n,r,i),i},e.LerpToRef=function(e,t,n,r){for(var i=r._m,o=e.m,a=t.m,s=0;s<16;s++)i[s]=o[s]*(1-n)+a[s]*n;r._markAsUpdated()},e.DecomposeLerp=function(t,n,r){var i=new e;return e.DecomposeLerpToRef(t,n,r,i),i},e.DecomposeLerpToRef=function(t,n,r,i){var o=Ro.Vector3[0],a=Ro.Quaternion[0],s=Ro.Vector3[1];t.decompose(o,a,s);var l=Ro.Vector3[2],c=Ro.Quaternion[1],u=Ro.Vector3[3];n.decompose(l,c,u);var d=Ro.Vector3[4];So.LerpToRef(o,l,r,d);var h=Ro.Quaternion[2];Po.SlerpToRef(a,c,r,h);var p=Ro.Vector3[5];So.LerpToRef(s,u,r,p),e.ComposeToRef(d,h,p,i)},e.LookAtLH=function(t,n,r){var i=new e;return e.LookAtLHToRef(t,n,r,i),i},e.LookAtLHToRef=function(t,n,r,i){var o=Ro.Vector3[0],a=Ro.Vector3[1],s=Ro.Vector3[2];n.subtractToRef(t,s),s.normalize(),So.CrossToRef(r,s,o);var l=o.lengthSquared();0===l?o.x=1:o.normalizeFromLength(Math.sqrt(l)),So.CrossToRef(s,o,a),a.normalize();var c=-So.Dot(o,t),u=-So.Dot(a,t),d=-So.Dot(s,t);e.FromValuesToRef(o.x,a.x,s.x,0,o.y,a.y,s.y,0,o.z,a.z,s.z,0,c,u,d,1,i)},e.LookAtRH=function(t,n,r){var i=new e;return e.LookAtRHToRef(t,n,r,i),i},e.LookAtRHToRef=function(t,n,r,i){var o=Ro.Vector3[0],a=Ro.Vector3[1],s=Ro.Vector3[2];t.subtractToRef(n,s),s.normalize(),So.CrossToRef(r,s,o);var l=o.lengthSquared();0===l?o.x=1:o.normalizeFromLength(Math.sqrt(l)),So.CrossToRef(s,o,a),a.normalize();var c=-So.Dot(o,t),u=-So.Dot(a,t),d=-So.Dot(s,t);e.FromValuesToRef(o.x,a.x,s.x,0,o.y,a.y,s.y,0,o.z,a.z,s.z,0,c,u,d,1,i)},e.OrthoLH=function(t,n,r,i){var o=new e;return e.OrthoLHToRef(t,n,r,i,o),o},e.OrthoLHToRef=function(t,n,r,i,o){var a=2/t,s=2/n,l=2/(i-r),c=-(i+r)/(i-r);e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,l,0,0,0,c,1,o),o._updateIdentityStatus(1===a&&1===s&&1===l&&0===c)},e.OrthoOffCenterLH=function(t,n,r,i,o,a){var s=new e;return e.OrthoOffCenterLHToRef(t,n,r,i,o,a,s),s},e.OrthoOffCenterLHToRef=function(t,n,r,i,o,a,s){var l=2/(n-t),c=2/(i-r),u=2/(a-o),d=-(a+o)/(a-o),h=(t+n)/(t-n),p=(i+r)/(r-i);e.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,u,0,h,p,d,1,s),s._markAsUpdated()},e.OrthoOffCenterRH=function(t,n,r,i,o,a){var s=new e;return e.OrthoOffCenterRHToRef(t,n,r,i,o,a,s),s},e.OrthoOffCenterRHToRef=function(t,n,r,i,o,a,s){e.OrthoOffCenterLHToRef(t,n,r,i,o,a,s),s._m[10]*=-1},e.PerspectiveLH=function(t,n,r,i){var o=new e,a=2*r/t,s=2*r/n,l=(i+r)/(i-r),c=-2*i*r/(i-r);return e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,l,1,0,0,c,0,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovLH=function(t,n,r,i){var o=new e;return e.PerspectiveFovLHToRef(t,n,r,i,o),o},e.PerspectiveFovLHToRef=function(t,n,r,i,o,a){void 0===a&&(a=!0);var s=r,l=i,c=1/Math.tan(.5*t),u=a?c/n:c,d=a?c:c*n,h=(l+s)/(l-s),p=-2*l*s/(l-s);e.FromValuesToRef(u,0,0,0,0,d,0,0,0,0,h,1,0,0,p,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseLHToRef=function(t,n,r,i,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),l=a?s/n:s,c=a?s:s*n;e.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,-r,1,0,0,1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovRH=function(t,n,r,i){var o=new e;return e.PerspectiveFovRHToRef(t,n,r,i,o),o},e.PerspectiveFovRHToRef=function(t,n,r,i,o,a){void 0===a&&(a=!0);var s=r,l=i,c=1/Math.tan(.5*t),u=a?c/n:c,d=a?c:c*n,h=-(l+s)/(l-s),p=-2*l*s/(l-s);e.FromValuesToRef(u,0,0,0,0,d,0,0,0,0,h,-1,0,0,p,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseRHToRef=function(t,n,r,i,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),l=a?s/n:s,c=a?s:s*n;e.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,-r,-1,0,0,-1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovWebVRToRef=function(e,t,n,r,i){void 0===i&&(i=!1);var o=i?-1:1,a=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),l=Math.tan(e.leftDegrees*Math.PI/180),c=Math.tan(e.rightDegrees*Math.PI/180),u=2/(l+c),d=2/(a+s),h=r._m;h[0]=u,h[1]=h[2]=h[3]=h[4]=0,h[5]=d,h[6]=h[7]=0,h[8]=(l-c)*u*.5,h[9]=-(a-s)*d*.5,h[10]=-n/(t-n),h[11]=1*o,h[12]=h[13]=h[15]=0,h[14]=-2*n*t/(n-t),r._markAsUpdated()},e.GetFinalMatrix=function(t,n,r,i,o,a){var s=t.width,l=t.height,c=t.x,u=t.y,d=e.FromValues(s/2,0,0,0,0,-l/2,0,0,0,0,a-o,0,c+s/2,l/2+u,o,1),h=Ro.Matrix[0];return n.multiplyToRef(r,h),h.multiplyToRef(i,h),h.multiply(d)},e.GetAsMatrix2x2=function(e){var t=e.m;return new Float32Array([t[0],t[1],t[4],t[5]])},e.GetAsMatrix3x3=function(e){var t=e.m;return new Float32Array([t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]])},e.Transpose=function(t){var n=new e;return e.TransposeToRef(t,n),n},e.TransposeToRef=function(e,t){var n=t._m,r=e.m;n[0]=r[0],n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=r[1],n[5]=r[5],n[6]=r[9],n[7]=r[13],n[8]=r[2],n[9]=r[6],n[10]=r[10],n[11]=r[14],n[12]=r[3],n[13]=r[7],n[14]=r[11],n[15]=r[15],t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty)},e.Reflection=function(t){var n=new e;return e.ReflectionToRef(t,n),n},e.ReflectionToRef=function(t,n){t.normalize();var r=t.normal.x,i=t.normal.y,o=t.normal.z,a=-2*r,s=-2*i,l=-2*o;e.FromValuesToRef(a*r+1,s*r,l*r,0,a*i,s*i+1,l*i,0,a*o,s*o,l*o+1,0,a*t.d,s*t.d,l*t.d,1,n)},e.FromXYZAxesToRef=function(t,n,r,i){e.FromValuesToRef(t.x,t.y,t.z,0,n.x,n.y,n.z,0,r.x,r.y,r.z,0,0,0,0,1,i)},e.FromQuaternionToRef=function(e,t){var n=e.x*e.x,r=e.y*e.y,i=e.z*e.z,o=e.x*e.y,a=e.z*e.w,s=e.z*e.x,l=e.y*e.w,c=e.y*e.z,u=e.x*e.w;t._m[0]=1-2*(r+i),t._m[1]=2*(o+a),t._m[2]=2*(s-l),t._m[3]=0,t._m[4]=2*(o-a),t._m[5]=1-2*(i+n),t._m[6]=2*(c+u),t._m[7]=0,t._m[8]=2*(s+l),t._m[9]=2*(c-u),t._m[10]=1-2*(r+n),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t._markAsUpdated()},e._updateFlagSeed=0,e._identityReadOnly=e.Identity(),e}(),Ro=function(){function e(){}return e.Vector3=wo.BuildArray(6,So.Zero),e.Matrix=wo.BuildArray(2,Oo.Identity),e.Quaternion=wo.BuildArray(3,Po.Zero),e}(),Mo=function(){function e(){}return e.Vector2=wo.BuildArray(3,Co.Zero),e.Vector3=wo.BuildArray(13,So.Zero),e.Vector4=wo.BuildArray(3,To.Zero),e.Quaternion=wo.BuildArray(2,Po.Zero),e.Matrix=wo.BuildArray(8,Oo.Identity),e}();Eo.RegisteredTypes["BABYLON.Vector2"]=Co,Eo.RegisteredTypes["BABYLON.Vector3"]=So,Eo.RegisteredTypes["BABYLON.Vector4"]=To,Eo.RegisteredTypes["BABYLON.Matrix"]=Oo;var Io=function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this.r=e,this.g=t,this.b=n}return e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},e.prototype.getClassName=function(){return"Color3"},e.prototype.getHashCode=function(){var e=255*this.r|0;return e=397*(e=397*e^(255*this.g|0))^(255*this.b|0)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},e.prototype.toColor4=function(e){return void 0===e&&(e=1),new ko(this.r,this.g,this.b,e)},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},e.prototype.equalsFloats=function(e,t,n){return this.r===e&&this.g===t&&this.b===n},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this},e.prototype.clampToRef=function(e,t,n){return void 0===e&&(e=0),void 0===t&&(t=1),n.r=xo.Clamp(this.r,e,t),n.g=xo.Clamp(this.g,e,t),n.b=xo.Clamp(this.b,e,t),this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b)},e.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},e.prototype.clone=function(){return new e(this.r,this.g,this.b)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},e.prototype.copyFromFloats=function(e,t,n){return this.r=e,this.g=t,this.b=n,this},e.prototype.set=function(e,t,n){return this.copyFromFloats(e,t,n)},e.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,n=255*this.b|0;return"#"+xo.ToHex(e)+xo.ToHex(t)+xo.ToHex(n)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toHSV=function(){var t=new e;return this.toHSVToRef(t),t},e.prototype.toHSVToRef=function(e){var t=this.r,n=this.g,r=this.b,i=Math.max(t,n,r),o=Math.min(t,n,r),a=0,s=0,l=i,c=i-o;0!==i&&(s=c/i),i!=o&&(i==t?(a=(n-r)/c,n=0&&o<=1?(s=i,l=a):o>=1&&o<=2?(s=a,l=i):o>=2&&o<=3?(l=i,c=a):o>=3&&o<=4?(l=a,c=i):o>=4&&o<=5?(s=a,c=i):o>=5&&o<=6&&(s=i,c=a);var u=n-i;r.set(s+u,l+u,c+u)},e.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new e(0,0,0);var n=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),i=parseInt(t.substring(5,7),16);return e.FromInts(n,r,i)},e.FromArray=function(t,n){return void 0===n&&(n=0),new e(t[n],t[n+1],t[n+2])},e.FromInts=function(t,n,r){return new e(t/255,n/255,r/255)},e.Lerp=function(t,n,r){var i=new e(0,0,0);return e.LerpToRef(t,n,r,i),i},e.LerpToRef=function(e,t,n,r){r.r=e.r+(t.r-e.r)*n,r.g=e.g+(t.g-e.g)*n,r.b=e.b+(t.b-e.b)*n},e.Red=function(){return new e(1,0,0)},e.Green=function(){return new e(0,1,0)},e.Blue=function(){return new e(0,0,1)},e.Black=function(){return new e(0,0,0)},Object.defineProperty(e,"BlackReadOnly",{get:function(){return e._BlackReadOnly},enumerable:!0,configurable:!0}),e.White=function(){return new e(1,1,1)},e.Purple=function(){return new e(.5,0,.5)},e.Magenta=function(){return new e(1,0,1)},e.Yellow=function(){return new e(1,1,0)},e.Gray=function(){return new e(.5,.5,.5)},e.Teal=function(){return new e(0,1,1)},e.Random=function(){return new e(Math.random(),Math.random(),Math.random())},e._BlackReadOnly=e.Black(),e}(),ko=function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1),this.r=e,this.g=t,this.b=n,this.a=r}return e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t,this.a*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,this},e.prototype.clampToRef=function(e,t,n){return void 0===e&&(e=0),void 0===t&&(t=1),n.r=xo.Clamp(this.r,e,t),n.g=xo.Clamp(this.g,e,t),n.b=xo.Clamp(this.b,e,t),n.a=xo.Clamp(this.a,e,t),this},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},e.prototype.getClassName=function(){return"Color4"},e.prototype.getHashCode=function(){var e=255*this.r|0;return e=397*(e=397*(e=397*e^(255*this.g|0))^(255*this.b|0))^(255*this.a|0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.copyFromFloats=function(e,t,n,r){return this.r=e,this.g=t,this.b=n,this.a=r,this},e.prototype.set=function(e,t,n,r){return this.copyFromFloats(e,t,n,r)},e.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,n=255*this.b|0,r=255*this.a|0;return"#"+xo.ToHex(e)+xo.ToHex(t)+xo.ToHex(n)+xo.ToHex(r)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,2.2),e.g=Math.pow(this.g,2.2),e.b=Math.pow(this.b,2.2),e.a=this.a,this},e.prototype.toGammaSpace=function(){var t=new e;return this.toGammaSpaceToRef(t),t},e.prototype.toGammaSpaceToRef=function(e){return e.r=Math.pow(this.r,1/2.2),e.g=Math.pow(this.g,1/2.2),e.b=Math.pow(this.b,1/2.2),e.a=this.a,this},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var n=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),i=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(n,r,i,o)},e.Lerp=function(t,n,r){var i=new e(0,0,0,0);return e.LerpToRef(t,n,r,i),i},e.LerpToRef=function(e,t,n,r){r.r=e.r+(t.r-e.r)*n,r.g=e.g+(t.g-e.g)*n,r.b=e.b+(t.b-e.b)*n,r.a=e.a+(t.a-e.a)*n},e.FromColor3=function(t,n){return void 0===n&&(n=1),new e(t.r,t.g,t.b,n)},e.FromArray=function(t,n){return void 0===n&&(n=0),new e(t[n],t[n+1],t[n+2],t[n+3])},e.FromInts=function(t,n,r,i){return new e(t/255,n/255,r/255,i/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var n=[],r=0;rthis.value;case t.IsLesser:return this._effectiveTarget[this._property]0)if("object"==typeof o[0])for(var s=0;s-1&&this._scene.actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTriggers2=function(e,t){for(var n=0;n=t.OnPickTrigger&&n.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t.OnPickTrigger&&n.trigger<=t.OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(jo.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-1!==n&&(this.actions.splice(n,1),t.Triggers[e.trigger]-=1,0===t.Triggers[e.trigger]&&delete t.Triggers[e.trigger],delete e._actionManager,!0)},t.prototype.processTrigger=function(e,n){for(var r=0;r0;if(2===e.type?u.push(i):u.push(n),p){for(var f=new Array,m=0;m0){var u=c.properties[0].value,d=null===c.properties[0].targetType?u:r.getMeshByName(u);d._meshId&&(d.mesh=r.getMeshByID(d._meshId)),l={trigger:t[c.name],parameter:d}}else l=t[c.name];for(var h=0;h1)for(var l=0;l=0;o--)this._keys[o].frame>=r&&this._keys[o].frame<=i&&this._keys.splice(o,1);this._ranges[e]=null}},e.prototype.getRange=function(e){return this._ranges[e]},e.prototype.getKeys=function(){return this._keys},e.prototype.getHighestFrame=function(){for(var e=0,t=0,n=this._keys.length;t0)return n.highLimitValue.clone?n.highLimitValue.clone():n.highLimitValue;var r=this._keys;if(1===r.length)return this._getKeyValue(r[0].value);var i=n.key;if(r[i].frame>=t)for(;i-1>=0&&r[i].frame>=t;)i--;for(var o=i;o=t){n.key=o;var s=r[o],l=this._getKeyValue(s.value);if(s.interpolation===_a.STEP)return l;var c=this._getKeyValue(a.value),u=void 0!==s.outTangent&&void 0!==a.inTangent,d=a.frame-s.frame,h=(t-s.frame)/d,p=this.getEasingFunction();switch(null!=p&&(h=p.ease(h)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var f=u?this.floatInterpolateFunctionWithTangents(l,s.outTangent*d,c,a.inTangent*d,h):this.floatInterpolateFunction(l,c,h);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return f;case e.ANIMATIONLOOPMODE_RELATIVE:return n.offsetValue*n.repeatCount+f}break;case e.ANIMATIONTYPE_QUATERNION:var m=u?this.quaternionInterpolateFunctionWithTangents(l,s.outTangent.scale(d),c,a.inTangent.scale(d),h):this.quaternionInterpolateFunction(l,c,h);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return m;case e.ANIMATIONLOOPMODE_RELATIVE:return m.addInPlace(n.offsetValue.scale(n.repeatCount))}return m;case e.ANIMATIONTYPE_VECTOR3:var g=u?this.vector3InterpolateFunctionWithTangents(l,s.outTangent.scale(d),c,a.inTangent.scale(d),h):this.vector3InterpolateFunction(l,c,h);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return g;case e.ANIMATIONLOOPMODE_RELATIVE:return g.add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_VECTOR2:var b=u?this.vector2InterpolateFunctionWithTangents(l,s.outTangent.scale(d),c,a.inTangent.scale(d),h):this.vector2InterpolateFunction(l,c,h);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return b;case e.ANIMATIONLOOPMODE_RELATIVE:return b.add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_SIZE:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(l,c,h);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(l,c,h).add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_COLOR3:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(l,c,h);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(l,c,h).add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_COLOR4:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color4InterpolateFunction(l,c,h);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color4InterpolateFunction(l,c,h).add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_MATRIX:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:if(e.AllowMatricesInterpolation)return this.matrixInterpolateFunction(l,c,h,n.workValue);case e.ANIMATIONLOOPMODE_RELATIVE:return l}}break}}return this._getKeyValue(r[r.length-1].value)},e.prototype.matrixInterpolateFunction=function(t,n,r,i){return e.AllowMatrixDecomposeForInterpolation?i?(Oo.DecomposeLerpToRef(t,n,r,i),i):Oo.DecomposeLerp(t,n,r):i?(Oo.LerpToRef(t,n,r,i),i):Oo.Lerp(t,n,r)},e.prototype.clone=function(){var t=new e(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 n in t._ranges={},this._ranges){var r=this._ranges[n];r&&(t._ranges[n]=r.clone())}return t},e.prototype.setKeys=function(e){this._keys=e.slice(0)},e.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 n=this.dataType;t.keys=[];for(var r=this.getKeys(),i=0;i=1&&(s=c.values[1]),c.values.length>=2&&(l=c.values[2]);break;case e.ANIMATIONTYPE_QUATERNION:if(n=Po.FromArray(c.values),c.values.length>=8){var u=Po.FromArray(c.values.slice(4,8));u.equals(Po.Zero())||(s=u)}if(c.values.length>=12){var d=Po.FromArray(c.values.slice(8,12));d.equals(Po.Zero())||(l=d)}break;case e.ANIMATIONTYPE_MATRIX:n=Oo.FromArray(c.values);break;case e.ANIMATIONTYPE_COLOR3:n=Io.FromArray(c.values);break;case e.ANIMATIONTYPE_COLOR4:n=ko.FromArray(c.values);break;case e.ANIMATIONTYPE_VECTOR3:default:n=So.FromArray(c.values)}var h={};h.frame=c.frame,h.value=n,null!=s&&(h.inTangent=s),null!=l&&(h.outTangent=l),a.push(h)}if(i.setKeys(a),t.ranges)for(r=0;r0&&u.forEach((function(e){i._events.push(e._clone())})),this._enableBlending=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending}return Object.defineProperty(e.prototype,"currentFrame",{get:function(){return this._currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._currentActiveTarget},enumerable:!0,configurable:!0}),e.prototype._preparePath=function(e,t){void 0===t&&(t=0);var n=this._animation.targetPropertyPath;if(n.length>1){for(var r=e[n[0]],i=1;i-1&&this._animation.runtimeAnimations.splice(e,1)},e.prototype.setValue=function(e,t){if(this._targetIsArray)for(var n=0;nt[t.length-1].frame&&(e=t[t.length-1].frame);var n=this._events;if(n.length)for(var r=0;rthis._maxFrame)&&(t=this._minFrame),(nthis._maxFrame)&&(n=this._maxFrame);var c,u,d=n-t,h=e*(a.framePerSecond*i)/1e3+this._ratioOffset,p=0;if(this._previousDelay=e,this._previousRatio=h,!r&&n>=t&&h>=d)l=!1,p=a._getKeyValue(this._maxValue);else if(!r&&t>=n&&h<=d)l=!1,p=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==Ca.ANIMATIONLOOPMODE_CYCLE){var f=n.toString()+t.toString();if(!this._offsetsCache[f]){this._animationState.repeatCount=0,this._animationState.loopMode=Ca.ANIMATIONLOOPMODE_CYCLE;var m=a._interpolate(t,this._animationState),g=a._interpolate(n,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case Ca.ANIMATIONTYPE_FLOAT:this._offsetsCache[f]=g-m;break;case Ca.ANIMATIONTYPE_QUATERNION:this._offsetsCache[f]=g.subtract(m);break;case Ca.ANIMATIONTYPE_VECTOR3:this._offsetsCache[f]=g.subtract(m);case Ca.ANIMATIONTYPE_VECTOR2:this._offsetsCache[f]=g.subtract(m);case Ca.ANIMATIONTYPE_SIZE:this._offsetsCache[f]=g.subtract(m);case Ca.ANIMATIONTYPE_COLOR3:this._offsetsCache[f]=g.subtract(m)}this._highLimitsCache[f]=g}p=this._highLimitsCache[f],c=this._offsetsCache[f]}if(void 0===c)switch(a.dataType){case Ca.ANIMATIONTYPE_FLOAT:c=0;break;case Ca.ANIMATIONTYPE_QUATERNION:c=Pa;break;case Ca.ANIMATIONTYPE_VECTOR3:c=Oa;break;case Ca.ANIMATIONTYPE_VECTOR2:c=Ra;break;case Ca.ANIMATIONTYPE_SIZE:c=Ma;break;case Ca.ANIMATIONTYPE_COLOR3:c=Ia}if(this._host&&this._host.syncRoot){var b=this._host.syncRoot;u=t+(n-t)*((b.masterFrame-b.fromFrame)/(b.toFrame-b.fromFrame))}else u=l&&0!==d?t+h%d:n;var v=this._events;if((d>0&&this.currentFrame>u||d<0&&this.currentFrame>0,this._animationState.highLimitValue=p,this._animationState.offsetValue=c;var _=a._interpolate(u,this._animationState);if(this.setValue(_,o),v.length)for(A=0;A0&&u>=v[A].frame&&v[A].frame>=t||d<0&&u<=v[A].frame&&v[A].frame<=t){var y=v[A];y.isDone||(y.onlyOnce&&(v.splice(A,1),A--),y.isDone=!0,y.action(u))}return l||(this._stopped=!0),l},e}(),Da=n(16),Ba=n(24),Fa=function(){function e(){this._xhr=new XMLHttpRequest}return e.prototype._injectCustomRequestHeaders=function(){for(var t in e.CustomRequestHeaders){var n=e.CustomRequestHeaders[t];n&&this._xhr.setRequestHeader(t,n)}},Object.defineProperty(e.prototype,"onprogress",{get:function(){return this._xhr.onprogress},set:function(e){this._xhr.onprogress=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._xhr.readyState},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._xhr.status},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"statusText",{get:function(){return this._xhr.statusText},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"response",{get:function(){return this._xhr.response},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"responseURL",{get:function(){return this._xhr.responseURL},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"responseText",{get:function(){return this._xhr.responseText},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"responseType",{get:function(){return this._xhr.responseType},set:function(e){this._xhr.responseType=e},enumerable:!0,configurable:!0}),e.prototype.addEventListener=function(e,t,n){this._xhr.addEventListener(e,t,n)},e.prototype.removeEventListener=function(e,t,n){this._xhr.removeEventListener(e,t,n)},e.prototype.abort=function(){this._xhr.abort()},e.prototype.send=function(t){e.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(t)},e.prototype.open=function(t,n){for(var r=0,i=e.CustomRequestModifiers;r=e||-1!==n.indexOf("file:")?-1:Math.pow(2,i)*t}},e}(),Ua=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t}(Error),Va=n(11),za=n(71),ja=function(e){function t(n,r){var i=e.call(this,n)||this;return i.name="LoadFileError",Ua._setPrototypeOf(i,t.prototype),r instanceof Fa?i.request=r:i.file=r,i}return Object(No.d)(t,e),t}(Ua),Ga=function(e){function t(n,r){var i=e.call(this,n)||this;return i.request=r,i.name="RequestFileError",Ua._setPrototypeOf(i,t.prototype),i}return Object(No.d)(t,e),t}(Ua),Ha=function(e){function t(n,r){var i=e.call(this,n)||this;return i.file=r,i.name="ReadFileError",Ua._setPrototypeOf(i,t.prototype),i}return Object(No.d)(t,e),t}(Ua),Qa=function(){function e(){}return e._CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},e.SetCorsBehavior=function(t,n){if((!t||0!==t.indexOf("data:"))&&e.CorsBehavior)if("string"==typeof e.CorsBehavior||this.CorsBehavior instanceof String)n.crossOrigin=e.CorsBehavior;else{var r=e.CorsBehavior(t);r&&(n.crossOrigin=r)}},e.LoadImage=function(t,n,r,i,o){var a;void 0===o&&(o="");var s=!1;if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)?"undefined"!=typeof Blob?(a=URL.createObjectURL(new Blob([t],{type:o})),s=!0):a="data:"+o+";base64,"+Jo.a.EncodeArrayBufferToBase64(t):t instanceof Blob?(a=URL.createObjectURL(t),s=!0):(a=e._CleanUrl(t),a=e.PreprocessUrl(t)),"undefined"==typeof Image)return e.LoadFile(a,(function(e){createImageBitmap(new Blob([e],{type:o})).then((function(e){n(e),s&&URL.revokeObjectURL(a)})).catch((function(e){r&&r("Error while trying to load image: "+t,e)}))}),void 0,i||void 0,!0,(function(e,n){r&&r("Error while trying to load image: "+t,n)})),null;var l=new Image;e.SetCorsBehavior(a,l);var c=function(){l.removeEventListener("load",c),l.removeEventListener("error",u),n(l),s&&l.src&&URL.revokeObjectURL(l.src)},u=function(e){l.removeEventListener("load",c),l.removeEventListener("error",u),r&&r("Error while trying to load image: "+t,e),s&&l.src&&URL.revokeObjectURL(l.src)};l.addEventListener("load",c),l.addEventListener("error",u);var d=function(){l.src=a};if("data:"!==a.substr(0,5)&&i&&i.enableTexturesOffline)i.open((function(){i&&i.loadImage(a,l)}),d);else{if(-1!==a.indexOf("file:")){var h=decodeURIComponent(a.substring(5).toLowerCase());if(Na.FilesToLoad[h]){try{var p;try{p=URL.createObjectURL(Na.FilesToLoad[h])}catch(e){p=URL.createObjectURL(Na.FilesToLoad[h])}l.src=p,s=!0}catch(e){l.src=""}return l}}d()}return l},e.ReadFile=function(e,t,n,r,i){var o=new FileReader,a={onCompleteObservable:new yo.a,abort:function(){return o.abort()}};return o.onloadend=function(e){return a.onCompleteObservable.notifyObservers(a)},i&&(o.onerror=function(t){i(new Ha("Unable to read "+e.name,e))}),o.onload=function(e){t(e.target.result)},n&&(o.onprogress=n),r?o.readAsArrayBuffer(e):o.readAsText(e),a},e.LoadFile=function(t,n,r,i,o,a){if(-1!==t.indexOf("file:")){var s=decodeURIComponent(t.substring(5).toLowerCase());0===s.indexOf("./")&&(s=s.substring(2));var l=Na.FilesToLoad[s];if(l)return e.ReadFile(l,n,r,o,a?function(e){return a(void 0,new ja(e.message,e.file))}:void 0)}return e.RequestFile(t,(function(e,t){n(e,t?t.responseURL:void 0)}),r,i,o,a?function(e){a(e.request,new ja(e.message,e.request))}:void 0)},e.RequestFile=function(t,n,r,i,o,a,s){t=e._CleanUrl(t),t=e.PreprocessUrl(t);var l=e.BaseUrl+t,c=!1,u={onCompleteObservable:new yo.a,abort:function(){return c=!0}},d=function(){var t=new Fa,i=null;u.abort=function(){c=!0,t.readyState!==(XMLHttpRequest.DONE||4)&&t.abort(),null!==i&&(clearTimeout(i),i=null)};var d=function(h){t.open("GET",l),s&&s(t),o&&(t.responseType="arraybuffer"),r&&t.addEventListener("progress",r);var p=function(){t.removeEventListener("loadend",p),u.onCompleteObservable.notifyObservers(u),u.onCompleteObservable.clear()};t.addEventListener("loadend",p);var f=function(){if(!c&&t.readyState===(XMLHttpRequest.DONE||4)){if(t.removeEventListener("readystatechange",f),t.status>=200&&t.status<300||0===t.status&&(!Da.a.IsWindowObjectExist()||e.IsFileURL()))return void n(o?t.response:t.responseText,t);var r=e.DefaultRetryStrategy;if(r){var s=r(l,t,h);if(-1!==s)return t.removeEventListener("loadend",p),t=new Fa,void(i=setTimeout((function(){return d(h+1)}),s))}var u=new Ga("Error status: "+t.status+" "+t.statusText+" - Unable to load "+l,t);a&&a(u)}};t.addEventListener("readystatechange",f),t.send()};d(0)};if(i&&i.enableSceneOffline){var h=function(e){e&&e.status>400?a&&a(e):d()};i.open((function(){i&&i.loadFile(e.BaseUrl+t,(function(e){c||n(e),u.onCompleteObservable.notifyObservers(u)}),r?function(e){c||r(e)}:void 0,h,o)}),h)}else d();return u},e.IsFileURL=function(){return"file:"===location.protocol},e.DefaultRetryStrategy=La.ExponentialBackoff(),e.BaseUrl="",e.CorsBehavior="anonymous",e.PreprocessUrl=function(e){return e},e}();Va.a._FileToolsLoadImage=Qa.LoadImage.bind(Qa),Va.a._FileToolsLoadFile=Qa.LoadFile.bind(Qa),za.a._FileToolsLoadFile=Qa.LoadFile.bind(Qa),function(e){e[e.Pending=0]="Pending",e[e.Fulfilled=1]="Fulfilled",e[e.Rejected=2]="Rejected"}(Ta||(Ta={}));var Wa=function(){this.count=0,this.target=0,this.results=[]},Ka=function(){function e(e){var t=this;if(this._state=Ta.Pending,this._children=new Array,this._rejectWasConsumed=!1,e)try{e((function(e){t._resolve(e)}),(function(e){t._reject(e)}))}catch(e){this._reject(e)}}return Object.defineProperty(e.prototype,"_result",{get:function(){return this._resultValue},set:function(e){this._resultValue=e,this._parent&&void 0===this._parent._result&&(this._parent._result=e)},enumerable:!0,configurable:!0}),e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.then=function(t,n){var r=this,i=new e;return i._onFulfilled=t,i._onRejected=n,this._children.push(i),i._parent=this,this._state!==Ta.Pending&&setTimeout((function(){if(r._state===Ta.Fulfilled||r._rejectWasConsumed){var e=i._resolve(r._result);if(null!=e)if(void 0!==e._state){var t=e;i._children.push(t),t._parent=i,i=t}else i._result=e}else i._reject(r._reason)})),i},e.prototype._moveChildren=function(e){var t,n=this;if((t=this._children).push.apply(t,e.splice(0,e.length)),this._children.forEach((function(e){e._parent=n})),this._state===Ta.Fulfilled)for(var r=0,i=this._children;r=t)break;if(r(a),o&&o()){e.breakLoop();break}}e.executeNext()}),a)}),i)},e}();Zo.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",Xa.Apply();var es,ts,ns=function(){function e(t){this.length=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)},e.prototype.forEach=function(e){for(var t=0;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e.prototype.contains=function(e){return-1!==this.indexOf(e)},e._GlobalId=0,e}(),rs=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return Object(No.d)(t,e),t.prototype.push=function(t){e.prototype.push.call(this,t),t.__smartArrayFlags||(t.__smartArrayFlags={}),t.__smartArrayFlags[this._id]=this._duplicateId},t.prototype.pushNoDuplicate=function(e){return(!e.__smartArrayFlags||e.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(e),!0)},t.prototype.reset=function(){e.prototype.reset.call(this),this._duplicateId++},t.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;tr.bbSize.y?r.bbSize.x:r.bbSize.y;J=J>r.bbSize.z?J:r.bbSize.z,I=r.subDiv.X*O/r.bbSize.x,k=r.subDiv.Y*O/r.bbSize.y,D=r.subDiv.Z*O/r.bbSize.z,B=r.subDiv.max*r.subDiv.max,r.facetPartitioning.length=0}for(i=0;ic-r)&&(!(s-u<-.001||-.001>u-i)&&!(l-d<-.001||-.001>d-o))},e.prototype.intersectsSphere=function(t){return e.IntersectsSphere(this.minimumWorld,this.maximumWorld,t.centerWorld,t.radiusWorld)},e.prototype.intersectsMinMax=function(e,t){var n=this.minimumWorld,r=this.maximumWorld,i=n.x,o=n.y,a=n.z,s=r.x,l=r.y,c=r.z,u=e.x,d=e.y,h=e.z,p=t.x,f=t.y,m=t.z;return!(sp)&&(!(lf)&&!(cm))},e.Intersects=function(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)},e.IntersectsSphere=function(t,n,r,i){var o=e.TmpVector3[0];return So.ClampToRef(r,t,n,o),So.DistanceSquared(r,o)<=i*i},e.IsCompletelyInFrustum=function(e,t){for(var n=0;n<6;++n)for(var r=t[n],i=0;i<8;++i)if(r.dotCoordinate(e[i])<0)return!1;return!0},e.IsInFrustum=function(e,t){for(var n=0;n<6;++n){for(var r=!0,i=t[n],o=0;o<8;++o)if(i.dotCoordinate(e[o])>=0){r=!1;break}if(r)return!1}return!0},e.TmpVector3=wo.BuildArray(3,So.Zero),e}(),ps=function(){function e(e,t,n){this.center=So.Zero(),this.centerWorld=So.Zero(),this.minimum=So.Zero(),this.maximum=So.Zero(),this.reConstruct(e,t,n)}return e.prototype.reConstruct=function(e,t,n){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var r=So.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*r,this._update(n||Oo.IdentityReadOnly)},e.prototype.scale=function(t){var n=this.radius*t,r=e.TmpVector3,i=r[0].setAll(n),o=this.center.subtractToRef(i,r[1]),a=this.center.addToRef(i,r[2]);return this.reConstruct(o,a,this._worldMatrix),this},e.prototype.getWorldMatrix=function(){return this._worldMatrix},e.prototype._update=function(t){if(t.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{So.TransformCoordinatesToRef(this.center,t,this.centerWorld);var n=e.TmpVector3[0];So.TransformNormalFromFloatsToRef(1,1,1,t,n),this.radiusWorld=Math.max(Math.abs(n.x),Math.abs(n.y),Math.abs(n.z))*this.radius}},e.prototype.isInFrustum=function(e){for(var t=this.centerWorld,n=this.radiusWorld,r=0;r<6;r++)if(e[r].dotCoordinate(t)<=-n)return!1;return!0},e.prototype.isCenterInFrustum=function(e){for(var t=this.centerWorld,n=0;n<6;n++)if(e[n].dotCoordinate(t)<0)return!1;return!0},e.prototype.intersectsPoint=function(e){var t=So.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorldms.max||ms.min>fs.max)},vs=function(){function e(e,t,n){this._isLocked=!1,this.boundingBox=new hs(e,t,n),this.boundingSphere=new ps(e,t,n)}return e.prototype.reConstruct=function(e,t,n){this.boundingBox.reConstruct(e,t,n),this.boundingSphere.reConstruct(e,t,n)},Object.defineProperty(e.prototype,"minimum",{get:function(){return this.boundingBox.minimum},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!0,configurable:!0}),e.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},e.prototype.centerOn=function(t,n){var r=e.TmpVector3[0].copyFrom(t).subtractInPlace(n),i=e.TmpVector3[1].copyFrom(t).addInPlace(n);return this.boundingBox.reConstruct(r,i,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(r,i,this.boundingBox.getWorldMatrix()),this},e.prototype.scale=function(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this},e.prototype.isInFrustum=function(e,t){return void 0===t&&(t=0),!(2!==t&&3!==t||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(1!==t&&3!==t)||this.boundingBox.isInFrustum(e))},Object.defineProperty(e.prototype,"diagonalLength",{get:function(){var t=this.boundingBox;return t.maximumWorld.subtractToRef(t.minimumWorld,e.TmpVector3[0]).length()},enumerable:!0,configurable:!0}),e.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},e.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},e.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},e.prototype.intersects=function(e,t){if(!ps.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!hs.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var n=this.boundingBox,r=e.boundingBox;return!!bs(n.directions[0],n,r)&&(!!bs(n.directions[1],n,r)&&(!!bs(n.directions[2],n,r)&&(!!bs(r.directions[0],n,r)&&(!!bs(r.directions[1],n,r)&&(!!bs(r.directions[2],n,r)&&(!!bs(So.Cross(n.directions[0],r.directions[0]),n,r)&&(!!bs(So.Cross(n.directions[0],r.directions[1]),n,r)&&(!!bs(So.Cross(n.directions[0],r.directions[2]),n,r)&&(!!bs(So.Cross(n.directions[1],r.directions[0]),n,r)&&(!!bs(So.Cross(n.directions[1],r.directions[1]),n,r)&&(!!bs(So.Cross(n.directions[1],r.directions[2]),n,r)&&(!!bs(So.Cross(n.directions[2],r.directions[0]),n,r)&&(!!bs(So.Cross(n.directions[2],r.directions[1]),n,r)&&!!bs(So.Cross(n.directions[2],r.directions[2]),n,r))))))))))))))},e.TmpVector3=wo.BuildArray(2,So.Zero),e}(),As=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._collider=null,this._oldPositionForCollisions=new So(0,0,0),this._diffPositionForCollisions=new So(0,0,0)};function _s(e,t,n,r,i){void 0===r&&(r=null);var o=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new So(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);i||(i=3);for(var s=t,l=t*i;sss.a.CollisionsEpsilon&&i.position.addInPlace(i._meshCollisionData._diffPositionForCollisions),n&&i.onCollideObservable.notifyObservers(n),i.onCollisionPositionChangeObservable.notifyObservers(i.position)},i.getScene().addMesh(i),i._resyncLightSources(),i}return Object(No.d)(t,e),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return as.BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return as.BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return as.BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return as.BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return as.BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_USE_POSITION",{get:function(){return as.BILLBOARDMODE_USE_POSITION},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!0,configurable:!0}),t.prototype._updateNonUniformScalingState=function(t){return!!e.prototype._updateNonUniformScalingState.call(this,t)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(t.prototype,"onCollide",{set:function(e){this._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver),this._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onCollisionPositionChange",{set:function(e){this._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver),this._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(e){this._internalAbstractMeshDataInfo._visibility!==e&&(this._internalAbstractMeshDataInfo._visibility=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},set:function(e){this._material!==e&&(this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&this._unBindEffect())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasVertexAlpha",{get:function(){return this._internalAbstractMeshDataInfo._hasVertexAlpha},set:function(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVertexColors",{get:function(){return this._internalAbstractMeshDataInfo._useVertexColors},set:function(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numBoneInfluencers",{get:function(){return this._internalAbstractMeshDataInfo._numBoneInfluencers},set:function(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"applyFog",{get:function(){return this._internalAbstractMeshDataInfo._applyFog},set:function(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"layerMask",{get:function(){return this._internalAbstractMeshDataInfo._layerMask},set:function(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._meshCollisionData._collisionMask},set:function(e){this._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collisionGroup",{get:function(){return this._meshCollisionData._collisionGroup},set:function(e){this._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_positions",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"skeleton",{get:function(){return this._internalAbstractMeshDataInfo._skeleton},set:function(e){var t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"AbstractMesh"},t.prototype.toString=function(e){var t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);var n=this._internalAbstractMeshDataInfo._skeleton;return n&&(t+=", skeleton: "+n.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t},t.prototype._getEffectiveParent=function(){return this._masterMesh&&this.billboardMode!==as.BILLBOARDMODE_NONE?this._masterMesh:e.prototype._getEffectiveParent.call(this)},t.prototype._getActionManagerForTrigger=function(e,t){if(void 0===t&&(t=!0),this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null},t.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var e=0,t=this.subMeshes;e4,o=i?this.getVerticesData(cs.MatricesIndicesExtraKind):null,a=i?this.getVerticesData(cs.MatricesWeightsExtraKind):null;this.skeleton.prepare();for(var s=this.skeleton.getTransformMatrices(this),l=Mo.Vector3[0],c=Mo.Matrix[0],u=Mo.Matrix[1],d=0,h=0;h0&&(Oo.FromFloat32ArrayToRefScaled(s,Math.floor(16*n[d+p]),f,u),c.addToSelf(u));if(i)for(p=0;p<4;p++)(f=a[d+p])>0&&(Oo.FromFloat32ArrayToRefScaled(s,Math.floor(16*o[d+p]),f,u),c.addToSelf(u));So.TransformCoordinatesFromFloatsToRef(t[h],t[h+1],t[h+2],c,l),l.toArray(t,h),this._positions&&this._positions[h/3].copyFrom(l)}}}return t},t.prototype._updateBoundingInfo=function(){var e=this._effectiveMesh;return this._boundingInfo?this._boundingInfo.update(e.worldMatrixFromCache):this._boundingInfo=new vs(this.absolutePosition,this.absolutePosition,e.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(e.worldMatrixFromCache),this},t.prototype._updateSubMeshesBoundingInfo=function(e){if(!this.subMeshes)return this;for(var t=this.subMeshes.length,n=0;n1||!r.IsGlobal)&&r.updateBoundingInfo(e)}return this},t.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||this._updateBoundingInfo()},Object.defineProperty(t.prototype,"_effectiveMesh",{get:function(){return this.skeleton&&this.skeleton.overrideMesh||this},enumerable:!0,configurable:!0}),t.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e,this.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isCompletelyInFrustum(e)},t.prototype.intersectsMesh=function(e,t,n){if(void 0===t&&(t=!1),!this._boundingInfo||!e._boundingInfo)return!1;if(this._boundingInfo.intersects(e._boundingInfo,t))return!0;if(n)for(var r=0,i=this.getChildMeshes();r1&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},t.prototype._checkCollision=function(e){if(!this._boundingInfo||!this._boundingInfo._checkCollision(e))return this;var t=Mo.Matrix[0],n=Mo.Matrix[1];return Oo.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,n),this._processCollisionsForSubMeshes(e,n),this},t.prototype._generatePointsArray=function(){return!1},t.prototype.intersects=function(e,t,n){var r=new ds,i="InstancedLinesMesh"===this.getClassName()||"LinesMesh"===this.getClassName()?this.intersectionThreshold:0,o=this._boundingInfo;if(!(this.subMeshes&&o&&e.intersectsSphere(o.boundingSphere,i)&&e.intersectsBox(o.boundingBox,i)))return r;if(!this._generatePointsArray())return r;for(var a=null,s=this._scene.getIntersectingSubMeshCandidates(this,e),l=s.length,c=0;c1)||u.canIntersects(e)){var d=u.intersects(e,this._positions,this.getIndices(),t,n);if(d&&(t||!a||d.distance65535){o=!0;break}e.depthSortedIndices=o?new Uint32Array(n):new Uint16Array(n)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){var s=this.getScene().activeCamera;e.facetDepthSortFrom=s?s.position:So.Zero()}e.depthSortedFacets=[];for(var l=0;l.001?i.maximum.x-i.minimum.x:.001,e.bbSize.y=i.maximum.y-i.minimum.y>.001?i.maximum.y-i.minimum.y:.001,e.bbSize.z=i.maximum.z-i.minimum.z>.001?i.maximum.z-i.minimum.z:.001;var u=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(u=u>e.bbSize.z?u:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/u),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/u),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/u),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=i,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),So.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,us.ComputeNormals(t,n,r,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var d=e.depthSortedIndices.length/3|0;for(l=0;li.subDiv.max||a<0||a>i.subDiv.max||s<0||s>i.subDiv.max?null:i.facetPartitioning[o+i.subDiv.max*a+i.subDiv.max*i.subDiv.max*s]},t.prototype.getClosestFacetAtCoordinates=function(e,t,n,r,i,o){void 0===i&&(i=!1),void 0===o&&(o=!0);var a=this.getWorldMatrix(),s=Mo.Matrix[5];a.invertToRef(s);var l=Mo.Vector3[8];So.TransformCoordinatesFromFloatsToRef(e,t,n,s,l);var c=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,r,i,o);return r&&So.TransformCoordinatesFromFloatsToRef(r.x,r.y,r.z,a,r),c},t.prototype.getClosestFacetAtLocalCoordinates=function(e,t,n,r,i,o){void 0===i&&(i=!1),void 0===o&&(o=!0);var a=null,s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),b=this.getFacetsAtLocalCoordinates(e,t,n);if(!b)return null;for(var v,A,_,y=Number.MAX_VALUE,x=y,w=0;w=0||i&&!o&&u<=0)&&(u=A.x*_.x+A.y*_.y+A.z*_.z,d=-(A.x*e+A.y*t+A.z*n-u)/(A.x*A.x+A.y*A.y+A.z*A.z),(x=(s=(h=e+A.x*d)-e)*s+(l=(p=t+A.y*d)-t)*l+(c=(f=n+A.z*d)-n)*c)-1?(jo.a.Error("You're trying to reuse a post process not defined as reusable."),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(e))},t.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._cascadePostProcessesToRigCams()},t.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},t.prototype._getViewMatrix=function(){return Oo.Identity()},t.prototype.getViewMatrix=function(e){return!e&&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},t.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},t.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},t.prototype.getProjectionMatrix=function(e){if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var n=this.getEngine(),r=this.getScene();if(this.mode===t.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=n.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1);var i=n.useReverseDepthBuffer;(r.useRightHandedSystem?i?Oo.PerspectiveFovReverseRHToRef:Oo.PerspectiveFovRHToRef:i?Oo.PerspectiveFovReverseLHToRef:Oo.PerspectiveFovLHToRef)(this.fov,n.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED)}else{var o=n.getRenderWidth()/2,a=n.getRenderHeight()/2;r.useRightHandedSystem?Oo.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-a,this.orthoTop||a,this.minZ,this.maxZ,this._projectionMatrix):Oo.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-a,this.orthoTop||a,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=n.getRenderWidth(),this._cache.renderHeight=n.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},t.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},t.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?Ss.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Ss.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},t.prototype.isInFrustum=function(e,t){if(void 0===t&&(t=!1),this._updateFrustumPlanes(),t&&this.rigCameras.length>0){var n=!1;return this.rigCameras.forEach((function(t){t._updateFrustumPlanes(),n=n||e.isInFrustum(t._frustumPlanes)})),n}return e.isInFrustum(this._frustumPlanes)},t.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},t.prototype.getForwardRay=function(e,t,n){throw void 0===e&&(e=100),oa.a.WarnImport("Ray")},t.prototype.dispose=function(n,r){for(void 0===r&&(r=!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 i=this._rigCameras.pop();i&&i.dispose()}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==t.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var o=this._postProcesses.length;--o>=0;){var a=this._postProcesses[o];a&&a.dispose(this)}for(o=this.customRenderTargets.length;--o>=0;)this.customRenderTargets[o].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),e.prototype.dispose.call(this,n,r)},Object.defineProperty(t.prototype,"isLeftCamera",{get:function(){return this._isLeftCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRightCamera",{get:function(){return this._isRightCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!0,configurable:!0}),t.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},t.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},t.prototype.setCameraRigMode=function(e,n){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){var r=this._rigCameras.pop();r&&r.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=n.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=Ja.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==t.RIG_MODE_NONE){var i=this.createRigCamera(this.name+"_L",0);i&&(i._isLeftCamera=!0);var o=this.createRigCamera(this.name+"_R",1);o&&(o._isRightCamera=!0),i&&o&&(this._rigCameras.push(i),this._rigCameras.push(o))}switch(this.cameraRigMode){case t.RIG_MODE_STEREOSCOPIC_ANAGLYPH:t._setStereoscopicAnaglyphRigMode(this);break;case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case t.RIG_MODE_STEREOSCOPIC_OVERUNDER:case t.RIG_MODE_STEREOSCOPIC_INTERLACED:t._setStereoscopicRigMode(this);break;case t.RIG_MODE_VR:t._setVRRigMode(this,n);break;case t.RIG_MODE_WEBVR:t._setWebVRRigMode(this,n)}this._cascadePostProcessesToRigCams(),this.update()}},t._setStereoscopicRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode"},t._setStereoscopicAnaglyphRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode"},t._setVRRigMode=function(e,t){throw"Import Cameras/RigModes/vrRigMode before using VR rig mode"},t._setWebVRRigMode=function(e,t){throw"Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode"},t.prototype._getVRProjectionMatrix=function(){return Oo.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},t.prototype._updateCameraRotationMatrix=function(){},t.prototype._updateWebVRCameraRotationMatrix=function(){},t.prototype._getWebVRProjectionMatrix=function(){return Oo.Identity()},t.prototype._getWebVRViewMatrix=function(){return Oo.Identity()},t.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=Ja.ToRadians(t/.0637))},t.prototype.createRigCamera=function(e,t){return null},t.prototype._updateRigCameras=function(){for(var e=0;e0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},t.CompareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},t.prototype.dispose=function(t,n){void 0===n&&(n=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var r=0,i=this.getScene().meshes;r0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach((function(t){e.excludedMeshesIds.push(t.id)}))),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(t){e.includedOnlyMeshesIds.push(t.id)}))),ya.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},t.GetConstructorFromName=function(e,t,n){var r=wa.Construct("Light_Type_"+e,t,n);return r||null},t.Parse=function(e,n){var r=t.GetConstructorFromName(e.type,e.name,n);if(!r)return null;var i=ya.Parse(r,e,n);if(e.excludedMeshesIds&&(i._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(i._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId&&(i._waitingParentId=e.parentId),void 0!==e.falloffType&&(i.falloffType=e.falloffType),void 0!==e.lightmapMode&&(i.lightmapMode=e.lightmapMode),e.animations){for(var o=0;os&&(s=u)}return new t(e,a,s-a+1,n,r,i,o)},t}(Fs),Ls=function(){function e(t,n,r){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 yo.a,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=2,this._needDepthPrePass=!1,this.disableDepthWrite=!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._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this.name=t,this.id=t||Ja.RandomId(),this._scene=n||Zo.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.useRightHandedSystem?this.sideOrientation=e.ClockWiseSideOrientation:this.sideOrientation=e.CounterClockWiseSideOrientation,this._uniformBuffer=new ks(this._scene.getEngine()),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,r||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={})}return Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alpha=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(t){this._backFaceCulling!==t&&(this._backFaceCulling=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasRenderTargetTextures",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new yo.a),this._onBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new yo.a),this._onUnBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaMode",{get:function(){return this._alphaMode},set:function(t){this._alphaMode!==t&&(this._alphaMode=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"needDepthPrePass",{get:function(){return this._needDepthPrePass},set:function(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(t){this._fogEnabled!==t&&(this._fogEnabled=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!0,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(t){this.fillMode=t?e.WireFrameFillMode:e.TriangleFillMode},enumerable:!0,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(t){this.fillMode=t?e.PointFillMode:e.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fillMode",{get:function(){return this._fillMode},set:function(t){this._fillMode!==t&&(this._fillMode=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!0,configurable:!0}),e.prototype.toString=function(e){return"Name: "+this.name},e.prototype.getClassName=function(){return"Material"},Object.defineProperty(e.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),e.prototype.freeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!0},e.prototype.unfreeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!1},e.prototype.isReady=function(e,t){return!0},e.prototype.isReadyForSubMesh=function(e,t,n){return!1},e.prototype.getEffect=function(){return this._effect},e.prototype.getScene=function(){return this._scene},e.prototype.needAlphaBlending=function(){return this.alpha<1},e.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()||e.visibility<1||e.hasVertexAlpha},e.prototype.needAlphaTesting=function(){return!1},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.markDirty=function(){for(var e=0,t=this.getScene().meshes;en._alphaIndex?1:t._alphaIndext._distanceToCamera?-1:0},e.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},e.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},e.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},e.prototype.dispatch=function(e,t,n){void 0===t&&(t=e.getMesh()),void 0===n&&(n=e.getMaterial()),null!=n&&(n.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):n.needAlphaTesting()?(n.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(n.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t._edgesRenderer.isEnabled&&this._edgesRenderers.push(t._edgesRenderer))},e.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},e.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},e.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var n=0;ne.LongPressDelay&&!r._isPointerSwiping()&&(r._startingPointerTime=0,o.processTrigger(8,Fo.CreateNew(t.pickedMesh,n)))}),e.LongPressDelay)}}else for(var a=0,s=i._pointerDownStage;ae.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>e.DragMovementThreshold},e.prototype.simulatePointerUp=function(e,t,n){var r=new PointerEvent("pointerup",t),i=new Js;n?i.doubleClick=!0:i.singleClick=!0,this._checkPrePointerObservable(e,r,Qs.POINTERUP)||this._processPointerUp(e,r,i)},e.prototype._processPointerUp=function(e,t,n){var r=this._scene;if(e&&e&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(r.onPointerPick&&r.onPointerPick(t,e),n.singleClick&&!n.ignore&&r.onPointerObservable.hasObservers())){var i=Qs.POINTERPICK,o=new Xs(i,t,e);this._setRayOnPointerInfo(o),r.onPointerObservable.notifyObservers(o,i)}var a=e.pickedMesh._getActionManagerForTrigger();if(a&&!n.ignore){a.processTrigger(7,Fo.CreateNew(e.pickedMesh,t)),!n.hasSwiped&&n.singleClick&&a.processTrigger(1,Fo.CreateNew(e.pickedMesh,t));var s=e.pickedMesh._getActionManagerForTrigger(6);n.doubleClick&&s&&s.processTrigger(6,Fo.CreateNew(e.pickedMesh,t))}}else if(!n.ignore)for(var l=0,c=r._pointerUpStage;le.DoubleClickDelay&&!o._doubleClickOccured||t!==o._previousButtonPressed)&&(o._doubleClickOccured=!1,n.singleClick=!0,n.ignore=!1,r(n,o._currentPickResult))},this._initClickEvent=function(t,n,r,i){var a=new Js;o._currentPickResult=null;var s=null,l=t.hasSpecificMask(Qs.POINTERPICK)||n.hasSpecificMask(Qs.POINTERPICK)||t.hasSpecificMask(Qs.POINTERTAP)||n.hasSpecificMask(Qs.POINTERTAP)||t.hasSpecificMask(Qs.POINTERDOUBLETAP)||n.hasSpecificMask(Qs.POINTERDOUBLETAP);!l&&_o&&(s=o._initActionManager(s,a))&&(l=s.hasPickTriggers);var c=!1;if(l){var u=r.button;if(a.hasSwiped=o._isPointerSwiping(),!a.hasSwiped){var d=!e.ExclusiveDoubleClickMode;d||(d=!t.hasSpecificMask(Qs.POINTERDOUBLETAP)&&!n.hasSpecificMask(Qs.POINTERDOUBLETAP))&&!_o.HasSpecificTrigger(6)&&(s=o._initActionManager(s,a))&&(d=!s.hasSpecificTrigger(6)),d?(Date.now()-o._previousStartingPointerTime>e.DoubleClickDelay||u!==o._previousButtonPressed)&&(a.singleClick=!0,i(a,o._currentPickResult),c=!0):(o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,o._delayedSimpleClickTimeout=window.setTimeout(o._delayedSimpleClick.bind(o,u,a,i),e.DoubleClickDelay));var h=t.hasSpecificMask(Qs.POINTERDOUBLETAP)||n.hasSpecificMask(Qs.POINTERDOUBLETAP);!h&&_o.HasSpecificTrigger(6)&&(s=o._initActionManager(s,a))&&(h=s.hasSpecificTrigger(6)),h&&(u===o._previousButtonPressed&&Date.now()-o._previousStartingPointerTime0){for(var e=0,t=this._transientComponents;e0)return!1;for(e=0;e0,i=0,o=this._isReadyForMeshStage;i0)for(var a=0,s=this.activeCameras;a0},enumerable:!0,configurable:!0}),t.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},t.prototype.whenReadyAsync=function(){var e=this;return new Promise((function(t){e.executeWhenReady((function(){t()}))}))},t.prototype._checkIsReady=function(){var e=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(){e._checkIsReady()}),150))},Object.defineProperty(t.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),t.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=Ba.a.Now},t.prototype.getViewMatrix=function(){return this._viewMatrix},t.prototype.getProjectionMatrix=function(){return this._projectionMatrix},t.prototype.getTransformMatrix=function(){return this._transformMatrix},t.prototype.setTransformMatrix=function(e,t,n,r){this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag||(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?Ss.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Ss.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(n,r):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.update()))},t.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},t.prototype.getUniqueId=function(){return tl.UniqueId},t.prototype.addMesh=function(e,t){var n=this;void 0===t&&(t=!1),this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),this.onNewMeshAddedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){n.addMesh(e)})))},t.prototype.removeMesh=function(e,t){var n=this;void 0===t&&(t=!1);var r=this.meshes.indexOf(e);return-1!==r&&(this.meshes[r]=this.meshes[this.meshes.length-1],this.meshes.pop(),e.parent||e._removeFromSceneRootNodes()),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){n.removeMesh(e)})),r},t.prototype.addTransformNode=function(e){this._blockEntityCollection||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))},t.prototype.removeTransformNode=function(e){var t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){var n=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=n,n._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t},t.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e)),t},t.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},t.prototype.removeLight=function(e){var t=this.lights.indexOf(e);if(-1!==t){for(var n=0,r=this.meshes;n0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},t.prototype.removeParticleSystem=function(e){var t=this.particleSystems.indexOf(e);return-1!==t&&this.particleSystems.splice(t,1),t},t.prototype.removeAnimation=function(e){var t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t},t.prototype.stopAnimation=function(e,t,n){},t.prototype.removeAnimationGroup=function(e){var t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t},t.prototype.removeMultiMaterial=function(e){var t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),t},t.prototype.removeMaterial=function(e){var t=e._indexInSceneMaterialArray;if(-1!==t&&t=0;t--)if(this.materials[t].id===e)return this.materials[t];return null},t.prototype.getMaterialByName=function(e){for(var t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},t.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},t.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var n=this.getTransformNodeByID(e);if(n)return n;var r=this.getLightByID(e);if(r)return r;var i=this.getCameraByID(e);if(i)return i;var o=this.getBoneByID(e);return o||null},t.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var n=this.getTransformNodeByName(e);if(n)return n;var r=this.getLightByName(e);if(r)return r;var i=this.getCameraByName(e);if(i)return i;var o=this.getBoneByName(e);return o||null},t.prototype.getMeshByName=function(e){for(var t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},t.prototype.getSkeletonByUniqueId=function(e){for(var t=0;t0&&0!=(a.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||a.alwaysSelectAsActiveMesh||a.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(a),this.activeCamera._activeMeshes.push(a),s!==a&&s._activate(this._renderId,!1),a._activate(this._renderId,!1)&&(a.isAnInstance?a._internalAbstractMeshDataInfo._actAsRegularMesh&&(s=a):s._internalAbstractMeshDataInfo._onlyForInstances=!1,s._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(a,s)),a._postActivate()))}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var l=0;l0)for(var i=this.getActiveSubMeshCandidates(t),o=i.length,a=0;a1)this.activeCamera.outputRenderTarget._bindFrameBuffer();else{var e=this.activeCamera.outputRenderTarget.getInternalTexture();e?this.getEngine().bindFramebuffer(e):jo.a.Error("Camera contains invalid customDefaultRenderTarget")}}else this.getEngine().restoreDefaultFramebuffer()},t.prototype._renderForCamera=function(e,t){if(!e||!e._skipRendering){var n=this._engine;if(this._activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");n.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.getEngine().getCaps().multiview&&e.outputRenderTarget&&e.outputRenderTarget.getViewCount()>1?this.setTransformMatrix(e._rigCameras[0].getViewMatrix(),e._rigCameras[0].getProjectionMatrix(),e._rigCameras[1].getViewMatrix(),e._rigCameras[1].getProjectionMatrix()):this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var r=0;r0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets);for(var o=0,a=this._gatherActiveCameraRenderTargetsStage;o0){Ja.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var l=0;l0),this._renderId++}for(var d=0,h=this._cameraDrawRenderTargetStage;d1&&this.getEngine().getCaps().multiview)return this._renderForCamera(e),void this.onAfterRenderCameraObservable.notifyObservers(e);if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else for(var t=0;t-1&&(13===r.trigger&&r._executeCurrent(Fo.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(13,(function(e){var t=e instanceof ws?e:e.mesh;return o===t}))&&13!==r.trigger||t._intersectionsInProgress.splice(s,1))}}}},t.prototype._advancePhysicsEngineStep=function(e){},t.prototype._animate=function(){},t.prototype.animate=function(){if(this._engine.isDeterministicLockStep()){var e=Math.max(t.MinDeltaTime,Math.min(this._engine.getDeltaTime(),t.MaxDeltaTime))+this._timeAccumulator,n=this._engine.getTimeStep(),r=1e3/n/1e3,i=0,o=this._engine.getLockstepMaxSteps(),a=Math.floor(e/n);for(a=Math.min(a,o);e>0&&i0)for(var i=0;i0),this._intermediateRendering=!0;for(var c=0;c0),this._intermediateRendering=!1,this._renderId++}this.activeCamera=l,this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var d=0,h=this._beforeClearStage;d0)for(i=0;i0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[i]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var m=0,g=this._afterRenderStage;m-1&&this._engine.scenes.splice(i,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),t.prototype.clearCachedVertexData=function(){for(var e=0;e-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this},e.prototype.getAnimations=function(){return this._runtimeAnimations},e.prototype.appendAnimations=function(e,t){for(var n=this,r=0;r-1){for(var r=(o=this._runtimeAnimations).length-1;r>=0;r--){var i=o[r];e&&i.animation.name!=e||(t&&!t(i.target)||(i.dispose(),o.splice(r,1)))}0==o.length&&(this._scene._activeAnimatables.splice(n,1),this._raiseOnAnimationEnd())}}else{if((r=this._scene._activeAnimatables.indexOf(this))>-1){this._scene._activeAnimatables.splice(r,1);var o=this._runtimeAnimations;for(r=0;r0)return;this._animationTimeLast=e}this.deltaTime=this.useConstantAnimationDeltaTime?16:(e-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=e;var t=this._activeAnimatables;if(0!==t.length){this._animationTime+=this.deltaTime;for(var n=this._animationTime,r=0;rn&&i>0&&(i*=-1),s&&this.stopAnimation(e,void 0,l),a||(a=new il(this,e,t,n,r,i,o,void 0,c));var u=!l||l(e);if(e.animations&&u&&a.appendAnimations(e,e.animations),e.getAnimatables)for(var d=e.getAnimatables(),h=0;hr&&o>0&&(o*=-1),new il(this,e,n,r,i,o,a,t,s)},nl.prototype.beginDirectHierarchyAnimation=function(e,t,n,r,i,o,a,s,l){var c=e.getDescendants(t),u=[];u.push(this.beginDirectAnimation(e,n,r,i,o,a,s,l));for(var d=0,h=c;d=c&&a.frame<=u&&(r?(l=a.value.clone(),m?(s=l.getTranslation(),l.setTranslation(s.scaleInPlace(g))):b&&i?(s=l.getTranslation(),l.setTranslation(s.multiplyInPlace(i))):l=a.value):l=a.value,v.push({frame:a.frame+n,value:l}));return this.animations[0].createRange(t,c+n,u+n),!0};var ol,al=function(){function e(){}return e.prototype.serialize=function(){var e={};return e.animation=this.animation.serialize(),e.targetId=this.target.id,e},e}(),sl=function(){function e(e,t){void 0===t&&(t=null),this.name=e,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.onAnimationEndObservable=new yo.a,this.onAnimationLoopObservable=new yo.a,this.onAnimationGroupLoopObservable=new yo.a,this.onAnimationGroupEndObservable=new yo.a,this.onAnimationGroupPauseObservable=new yo.a,this.onAnimationGroupPlayObservable=new yo.a,this._scene=t||Zo.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.animationGroups.push(this)}return Object.defineProperty(e.prototype,"from",{get:function(){return this._from},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"to",{get:function(){return this._to},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isPlaying",{get:function(){return this._isStarted&&!this._isPaused},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(e){if(this._speedRatio!==e){this._speedRatio=e;for(var t=0;tr[0].frame&&(this._from=r[0].frame),this._toe){var a={frame:e,value:i.value,inTangent:i.inTangent,outTangent:i.outTangent,interpolation:i.interpolation};r.splice(0,0,a)}if(o.framer&&this._speedRatio>0&&(this._speedRatio=-t);return this._isStarted=!0,this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this},e.prototype.pause=function(){if(!this._isStarted)return this;this._isPaused=!0;for(var e=0;e-1&&this._scene.animationGroups.splice(e,1),this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear(),this.onAnimationGroupLoopObservable.clear()},e.prototype._checkAnimationGroupEnded=function(e){var t=this._animatables.indexOf(e);t>-1&&this._animatables.splice(t,1),0===this._animatables.length&&(this._isStarted=!1,this.onAnimationGroupEndObservable.notifyObservers(this))},e.prototype.clone=function(t,n){for(var r=new e(t||this.name,this._scene),i=0,o=this._targetedAnimations;i180&&(l-=360),l-s<-180&&(l+=360),c-l>180&&(c-=360),c-l<-180&&(c+=360),this.orientation=l-s<0?ol.CW:ol.CCW,this.angle=cl.FromDegrees(this.orientation===ol.CW?s-c:c-s)},dl=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new Co(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var n=new Co(e,t),r=this._points[this._points.length-1];return this._points.push(n),this._length+=n.subtract(r).length(),this},e.prototype.addArcTo=function(e,t,n,r,i){if(void 0===i&&(i=36),this.closed)return this;var o=this._points[this._points.length-1],a=new Co(e,t),s=new Co(n,r),l=new ul(o,a,s),c=l.angle.radians()/i;l.orientation===ol.CW&&(c*=-1);for(var u=l.startAngle.radians()+c,d=0;d1)return Co.Zero();for(var t=e*this.length(),n=0,r=0;r=n&&t<=s){var l=a.normalize(),c=t-n;return new Co(o.x+l.x*c,o.y+l.y*c)}n=s}return Co.Zero()},e.StartingAt=function(t,n){return new e(t,n)},e}(),hl=function(){function e(e,t,n,r){void 0===t&&(t=null),void 0===r&&(r=!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:So.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:Oo.Identity()};for(var i=0;in){var r=t;t=n,n=r}var i=this.getCurve(),o=this.getPointAt(t),a=this.getPreviousPointIndexAt(t),s=this.getPointAt(n),l=this.getPreviousPointIndexAt(n)+1,c=[];return 0!==t&&(a++,c.push(o)),c.push.apply(c,i.slice(a,l)),1===n&&1!==t||c.push(s),new e(c,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)},e.prototype.update=function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);for(var r=0;rt+1;)t++,n=this._curve[e].subtract(this._curve[e-t]);return n},e.prototype._normalVector=function(e,t){var n,r,i=e.length();(0===i&&(i=1),null==t)?(r=xo.WithinEpsilon(Math.abs(e.y)/i,1,.001)?xo.WithinEpsilon(Math.abs(e.x)/i,1,.001)?xo.WithinEpsilon(Math.abs(e.z)/i,1,.001)?So.Zero():new So(0,0,1):new So(1,0,0):new So(0,-1,0),n=So.Cross(e,r)):(n=So.Cross(e,t),So.CrossToRef(n,e,n));return n.normalize(),n},e.prototype._updatePointAtData=function(e,t){if(void 0===t&&(t=!1),this._pointAtData.id===e)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=e;var n=this.getPoints();if(e<=0)return this._setPointAtData(0,0,n[0],0,t);if(e>=1)return this._setPointAtData(1,1,n[n.length-1],n.length-1,t);for(var r,i=n[0],o=0,a=e*this.length(),s=1;sa){var c=(o-a)/l,u=i.subtract(r),d=r.add(u.scaleInPlace(c));return this._setPointAtData(e,1-c,d,s-1,t)}i=r}return this._pointAtData},e.prototype._setPointAtData=function(e,t,n,r,i){return this._pointAtData.point=n,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=r,this._pointAtData.interpolateReady=i,i&&this._updateInterpolationMatrix(),this._pointAtData},e.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=Oo.Identity();var e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){var t=e+1,n=this._tangents[e].clone(),r=this._normals[e].clone(),i=this._binormals[e].clone(),o=this._tangents[t].clone(),a=this._normals[t].clone(),s=this._binormals[t].clone(),l=Po.RotationQuaternionFromAxis(r,i,n),c=Po.RotationQuaternionFromAxis(a,s,o);Po.Slerp(l,c,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},e}(),pl=function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,n,r,i){i=i>2?i:3;for(var o=new Array,a=function(e,t,n,r){return(1-e)*(1-e)*t+2*e*(1-e)*n+e*e*r},s=0;s<=i;s++)o.push(new So(a(s/i,t.x,n.x,r.x),a(s/i,t.y,n.y,r.y),a(s/i,t.z,n.z,r.z)));return new e(o)},e.CreateCubicBezier=function(t,n,r,i,o){o=o>3?o:4;for(var a=new Array,s=function(e,t,n,r,i){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*n+3*e*e*(1-e)*r+e*e*e*i},l=0;l<=o;l++)a.push(new So(s(l/o,t.x,n.x,r.x,i.x),s(l/o,t.y,n.y,r.y,i.y),s(l/o,t.z,n.z,r.z,i.z)));return new e(a)},e.CreateHermiteSpline=function(t,n,r,i,o){for(var a=new Array,s=1/o,l=0;l<=o;l++)a.push(So.Hermite(t,n,r,i,l*s));return new e(a)},e.CreateCatmullRomSpline=function(t,n,r){var i=new Array,o=1/n,a=0;if(r){for(var s=t.length,l=0;l=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e.EASINGMODE_EASEIN=0,e.EASINGMODE_EASEOUT=1,e.EASINGMODE_EASEINOUT=2,e}(),ml=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(fl),gl=function(e){function t(t){void 0===t&&(t=1);var n=e.call(this)||this;return n.amplitude=t,n}return Object(No.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t}(fl),bl=(function(e){function t(t,n){void 0===t&&(t=3),void 0===n&&(n=2);var r=e.call(this)||this;return r.bounces=t,r.bounciness=n,r}Object(No.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),n=this.bounciness;n<=1&&(n=1.001);var r=Math.pow(n,t),i=1-n,o=(1-r)/i+.5*r,a=e*o,s=Math.log(-a*(1-n)+1)/Math.log(n),l=Math.floor(s),c=l+1,u=(1-Math.pow(n,l))/(i*o),d=.5*(u+(1-Math.pow(n,c))/(i*o)),h=e-d,p=d-u;return-Math.pow(1/n,t-l)/(p*p)*(h-p)*(h+p)}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e}}(fl),function(e){function t(t,n){void 0===t&&(t=3),void 0===n&&(n=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=n,r}Object(No.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),n=Math.max(0,this.springiness);return(0==n?e:(Math.exp(n*e)-1)/(Math.exp(n)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)}}(fl),function(e){function t(t){void 0===t&&(t=2);var n=e.call(this)||this;return n.exponent=t,n}return Object(No.d)(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(fl)),vl=(function(e){function t(t){void 0===t&&(t=2);var n=e.call(this)||this;return n.power=t,n}Object(No.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e*e}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(fl)),Al=(function(e){function t(t,n,r,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===i&&(i=1);var o=e.call(this)||this;return o.x1=t,o.y1=n,o.x2=r,o.y2=i,o}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return ll.Interpolate(e,this.x1,this.y1,this.x2,this.y2)}}(fl),function(){function e(e,t,n){this.frame=e,this.action=t,this.onlyOnce=n,this.isDone=!1}e.prototype._clone=function(){return new e(this.frame,this.action,this.onlyOnce)}}(),function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return e._ForceFullSceneLoadingForIncremental},set:function(t){e._ForceFullSceneLoadingForIncremental=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return e._ShowLoadingScreen},set:function(t){e._ShowLoadingScreen=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return e._loggingLevel},set:function(t){e._loggingLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return e._CleanBoneMatrixWeights},set:function(t){e._CleanBoneMatrixWeights=t},enumerable:!0,configurable:!0}),e._ForceFullSceneLoadingForIncremental=!1,e._ShowLoadingScreen=!0,e._CleanBoneMatrixWeights=!1,e._loggingLevel=0,e}()),_l=function(){function e(e,t,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=null),this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this.id=e,this.uniqueId=t.getUniqueId(),this._engine=t.getEngine(),this._meshes=[],this._scene=t,this._vertexBuffers={},this._indices=[],this._updatable=r,n?this.setAllVerticesData(n,r):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),i&&(this.applyToMesh(i),i.computeWorldMatrix(!0))}return Object.defineProperty(e.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(e){this._boundingBias?this._boundingBias.copyFrom(e):this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null)},enumerable:!0,configurable:!0}),e.CreateGeometryForMesh=function(t){var n=new e(e.RandomId(),t.getScene());return n.applyToMesh(t),n},Object.defineProperty(e.prototype,"extend",{get:function(){return this._extend},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._engine},e.prototype.isReady=function(){return 1===this.delayLoadState||0===this.delayLoadState},Object.defineProperty(e.prototype,"doNotSerialize",{get:function(){for(var e=0;e0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=t),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()},e.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,n=this._meshes;t0){for(var t=0;t0){for(t=0;t0){for(t=0;t0){var s=new Float32Array(t,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);n.setVerticesData(cs.PositionKind,s,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var l=new Float32Array(t,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);n.setVerticesData(cs.NormalKind,l,!1)}if(a.tangetsAttrDesc&&a.tangetsAttrDesc.count>0){var c=new Float32Array(t,a.tangetsAttrDesc.offset,a.tangetsAttrDesc.count);n.setVerticesData(cs.TangentKind,c,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var u=new Float32Array(t,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);n.setVerticesData(cs.UVKind,u,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var d=new Float32Array(t,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);n.setVerticesData(cs.UV2Kind,d,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var h=new Float32Array(t,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);n.setVerticesData(cs.UV3Kind,h,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var p=new Float32Array(t,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);n.setVerticesData(cs.UV4Kind,p,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var f=new Float32Array(t,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);n.setVerticesData(cs.UV5Kind,f,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var m=new Float32Array(t,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);n.setVerticesData(cs.UV6Kind,m,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var g=new Float32Array(t,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);n.setVerticesData(cs.ColorKind,g,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){for(var b=new Int32Array(t,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count),v=[],A=0;A>8),v.push((16711680&_)>>16),v.push(_>>24)}n.setVerticesData(cs.MatricesIndicesKind,v,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var y=new Float32Array(t,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);n.setVerticesData(cs.MatricesWeightsKind,y,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var x=new Int32Array(t,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);n.setIndices(x,null)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var w=new Int32Array(t,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);n.subMeshes=[];for(A=0;A>8),v.push((16711680&O)>>16),v.push(O>>24)}n.setVerticesData(cs.MatricesIndicesKind,v,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,n.setVerticesData(cs.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(v=[],A=0;A>8),v.push((16711680&O)>>16),v.push(O>>24)}n.setVerticesData(cs.MatricesIndicesExtraKind,v,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,n),n.setVerticesData(cs.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&n.setVerticesData(cs.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),n.setIndices(t.indices,null)}if(t.subMeshes){n.subMeshes=[];for(var R=0;R-1){var r=t.getScene().getLastSkeletonByID(e.skeletonId);if(r){n=r.bones.length;for(var i=t.getVerticesData(cs.MatricesIndicesKind),o=t.getVerticesData(cs.MatricesIndicesExtraKind),a=e.matricesWeights,s=e.matricesWeightsExtra,l=e.numBoneInfluencer,c=a.length,u=0;ul-1)&&(h=l-1),d>.001){var m=1/d;for(p=0;p<4;p++)a[u+p]*=m;if(s)for(p=0;p<4;p++)s[u+p]*=m}else h>=4?(s[u+h-4]=1-d,o[u+h-4]=n):(a[u+h]=1-d,i[u+h]=n)}t.setVerticesData(cs.MatricesIndicesKind,i),e.matricesWeightsExtra&&t.setVerticesData(cs.MatricesIndicesExtraKind,o)}}}},e.Parse=function(t,n,r){if(n.getGeometryByID(t.id))return null;var i=new e(t.id,n,void 0,t.updatable);return ia&&ia.AddTagsTo(i,t.tags),t.delayLoadingFile?(i.delayLoadState=4,i.delayLoadingFile=r+t.delayLoadingFile,i._boundingInfo=new vs(So.FromArray(t.boundingBoxMinimum),So.FromArray(t.boundingBoxMaximum)),i._delayInfo=[],t.hasUVs&&i._delayInfo.push(cs.UVKind),t.hasUVs2&&i._delayInfo.push(cs.UV2Kind),t.hasUVs3&&i._delayInfo.push(cs.UV3Kind),t.hasUVs4&&i._delayInfo.push(cs.UV4Kind),t.hasUVs5&&i._delayInfo.push(cs.UV5Kind),t.hasUVs6&&i._delayInfo.push(cs.UV6Kind),t.hasColors&&i._delayInfo.push(cs.ColorKind),t.hasMatricesIndices&&i._delayInfo.push(cs.MatricesIndicesKind),t.hasMatricesWeights&&i._delayInfo.push(cs.MatricesWeightsKind),i._delayLoadingFunction=us.ImportVertexData):us.ImportVertexData(t,i),n.pushGeometry(i,!0),i},e}(),yl=function(e){function t(t,n){var r=e.call(this,t,n,!0)||this;return n.multiMaterials.push(r),r.subMaterials=new Array,r._storeEffectOnSubMeshes=!0,r}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),t.prototype.getChildren=function(){return this.subMaterials},t.prototype._hookArray=function(e){var t=this,n=e.push;e.push=function(){for(var r=[],i=0;i=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},t.prototype.getActiveTextures=function(){var t;return(t=e.prototype.getActiveTextures.call(this)).concat.apply(t,this.subMaterials.map((function(e){return e?e.getActiveTextures():[]})))},t.prototype.getClassName=function(){return"MultiMaterial"},t.prototype.isReadyForSubMesh=function(e,t,n){for(var r=0;r=0&&i.multiMaterials.splice(o,1),e.prototype.dispose.call(this,t,n)}},t.ParseMultiMaterial=function(e,n){var r=new t(e.name,n);r.id=e.id,ia&&ia.AddTagsTo(r,e.tags);for(var i=0;i0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"morphTargetManager",{get:function(){return this._internalMeshDataInfo._morphTargetManager},set:function(e){this._internalMeshDataInfo._morphTargetManager!==e&&(this._internalMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._internalMeshDataInfo._source},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"worldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"manualUpdateOfWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.manualUpdate},set:function(e){this._instanceDataStorage.manualUpdate=e},enumerable:!0,configurable:!0}),t.prototype.instantiateHierarchy=function(e,t,n){void 0===e&&(e=null);var r=!(this.getTotalVertices()>0)||t&&t.doNotInstantiate?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));r&&(r.parent=e||this.parent,r.position=this.position.clone(),r.scaling=this.scaling.clone(),this.rotationQuaternion?r.rotationQuaternion=this.rotationQuaternion.clone():r.rotation=this.rotation.clone(),n&&n(this,r));for(var i=0,o=this.getChildTransformNodes(!0);i0},enumerable:!0,configurable:!0}),t.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},t.prototype._sortLODLevels=function(){this._internalMeshDataInfo._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},t.prototype.addLODLevel=function(e,t){if(t&&t._masterMesh)return jo.a.Warn("You cannot use a mesh as LOD level twice"),this;var n=new xl(e,t);return this._internalMeshDataInfo._LODLevels.push(n),t&&(t._masterMesh=this),this._sortLODLevels(),this},t.prototype.getLODLevelAtDistance=function(e){for(var t=this._internalMeshDataInfo,n=0;ni)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this),this;for(var o=0;o0;this.computeWorldMatrix();var a=this.material||i.defaultMaterial;if(a)if(a._storeEffectOnSubMeshes)for(var s=0,l=this.subMeshes;s0){var n=this.getIndices();if(!n)return null;var r=n.length,i=!1;if(e)i=!0;else for(var o=0,a=this.subMeshes;o=r){i=!0;break}if(s.verticesStart+s.verticesCount>=t){i=!0;break}}if(!i)return this.subMeshes[0]}return this.releaseSubMeshes(),new Ns(0,0,t,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),n=t/e|0,r=0;n%3!=0;)n++;this.releaseSubMeshes();for(var i=0;i=t);i++)Ns.CreateFromIndices(0,r,Math.min(n,t-r),this),r+=n;this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,t,n,r){if(void 0===n&&(n=!1),this._geometry)this._geometry.setVerticesData(e,t,n,r);else{var i=new us;i.set(t,e);var o=this.getScene();new _l(_l.RandomId(),o,i,n,this)}return this},t.prototype.removeVerticesData=function(e){this._geometry&&this._geometry.removeVerticesData(e)},t.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0);var n=this.getVertexBuffer(e);n&&n.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},t.prototype.setVerticesBuffer=function(e){return this._geometry||(this._geometry=_l.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e),this},t.prototype.updateVerticesData=function(e,t,n,r){return this._geometry?(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,n,!1)):this._geometry.updateVerticesData(e,t,n),this):this},t.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var n=this.getVerticesData(cs.PositionKind);if(!n)return this;if(e(n),this.updateVerticesData(cs.PositionKind,n,!1,!1),t){var r=this.getIndices(),i=this.getVerticesData(cs.NormalKind);if(!i)return this;us.ComputeNormals(n,r,i),this.updateVerticesData(cs.NormalKind,i,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;var e=this._geometry,t=this._geometry.copy(_l.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},t.prototype.setIndices=function(e,t,n){if(void 0===t&&(t=null),void 0===n&&(n=!1),this._geometry)this._geometry.setIndices(e,t,n);else{var r=new us;r.indices=e;var i=this.getScene();new _l(_l.RandomId(),i,r,n,this)}return this},t.prototype.updateIndices=function(e,t,n){return void 0===n&&(n=!1),this._geometry?(this._geometry.updateIndices(e,t,n),this):this},t.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},t.prototype._bind=function(e,t,n){if(!this._geometry)return this;var r,i=this.getScene().getEngine();if(this._unIndexed)r=null;else switch(n){case Ls.PointFillMode:r=null;break;case Ls.WireFrameFillMode:r=e._getLinesIndexBuffer(this.getIndices(),i);break;default:case Ls.TriangleFillMode:r=this._geometry.getIndexBuffer()}return this._geometry._bind(t,r),this},t.prototype._draw=function(e,t,n){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var r=this.getScene().getEngine();return this._unIndexed||t==Ls.PointFillMode?r.drawArraysType(t,e.verticesStart,e.verticesCount,n):t==Ls.WireFrameFillMode?r.drawElementsType(t,0,e._linesIndexCount,n):r.drawElementsType(t,e.indexStart,e.indexCount,n),this},t.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},t.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},t.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},t.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},t.prototype._getInstancesRenderList=function(e,t){if(void 0===t&&(t=!1),this._instanceDataStorage.isFrozen&&this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch;var n=this.getScene(),r=n._isInIntermediateRendering(),i=r?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=this._instanceDataStorage.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!i&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){var a=this._instanceDataStorage.visibleInstances,s=n.getRenderId(),l=r?a.intermediateDefaultRenderId:a.defaultRenderId;o.visibleInstances[e]=a[s],!o.visibleInstances[e]&&l&&(o.visibleInstances[e]=a[l])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==o.visibleInstances[e]&&void 0!==o.visibleInstances[e],this._instanceDataStorage.previousBatch=o,o},t.prototype._renderWithInstances=function(e,t,n,r,i){var o=n.visibleInstances[e._id];if(!o)return this;for(var a=this._instanceDataStorage,s=a.instancesBufferSize,l=a.instancesBuffer,c=16*(o.length+1)*4;a.instancesBufferSizeu&&r++,0!==f&&h++,d+=f,u=f}if(l[h]++,h>o&&(o=h),0===d)i++;else{var m=1/d,g=0;for(p=0;p.001&&a++}}var b=this.skeleton.bones.length,v=this.getVerticesData(cs.MatricesIndicesKind),A=this.getVerticesData(cs.MatricesIndicesExtraKind),_=0;for(c=0;c=b||y<0)&&_++}return{skinned:!0,valid:0===i&&0===a&&0===_,report:"Number of Weights = "+n/4+"\nMaximum influences = "+o+"\nMissing Weights = "+i+"\nNot Sorted = "+r+"\nNot Normalized = "+a+"\nWeightCounts = ["+l+"]\nNumber of bones = "+b+"\nBad Bone Indices = "+_}},t.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):4===this.delayLoadState&&(this.delayLoadState=2,this._queueLoad(e)),this},t.prototype._queueLoad=function(e){var t=this;e._addPendingData(this);var n=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return Ja.LoadFile(this.delayLoadingFile,(function(n){n instanceof ArrayBuffer?t._delayLoadingFunction(n,t):t._delayLoadingFunction(JSON.parse(n),t),t.instances.forEach((function(e){e.refreshBoundingInfo(),e._syncSubMeshes()})),t.delayLoadState=1,e._removePendingData(t)}),(function(){}),e.offlineProvider,n),this},t.prototype.isInFrustum=function(t){return 2!==this.delayLoadState&&(!!e.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},t.prototype.setMaterialByID=function(e){var t,n=this.getScene().materials;for(t=n.length-1;t>-1;t--)if(n[t].id===e)return this.material=n[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},t.prototype.getAnimatables=function(){var e=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},t.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(cs.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var n,r=this.getVerticesData(cs.PositionKind),i=new Array;for(n=0;n-1&&(i.morphTargetManager=n.getMorphTargetManagerById(e.morphTargetManagerId)),e.skeletonId>-1&&(i.skeleton=n.getLastSkeletonByID(e.skeletonId),e.numBoneInfluencers&&(i.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o4,c=l?this.getVerticesData(cs.MatricesIndicesExtraKind):null,u=l?this.getVerticesData(cs.MatricesWeightsExtraKind):null,d=e.getTransformMatrices(this),h=So.Zero(),p=new Oo,f=new Oo,m=0,g=0;g0&&(Oo.FromFloat32ArrayToRefScaled(d,Math.floor(16*o[m+s]),b,f),p.addToSelf(f));if(l)for(s=0;s<4;s++)(b=u[m+s])>0&&(Oo.FromFloat32ArrayToRefScaled(d,Math.floor(16*c[m+s]),b,f),p.addToSelf(f));So.TransformCoordinatesFromFloatsToRef(t._sourcePositions[g],t._sourcePositions[g+1],t._sourcePositions[g+2],p,h),h.toArray(r,g),So.TransformNormalFromFloatsToRef(t._sourceNormals[g],t._sourceNormals[g+1],t._sourceNormals[g+2],p,h),h.toArray(i,g),p.reset()}return this.updateVerticesData(cs.PositionKind,r),this.updateVerticesData(cs.NormalKind,i),this},t.MinMax=function(e){var t=null,n=null;return e.forEach((function(e){var r=e.getBoundingInfo().boundingBox;t&&n?(t.minimizeInPlace(r.minimumWorld),n.maximizeInPlace(r.maximumWorld)):(t=r.minimumWorld,n=r.maximumWorld)})),t&&n?{min:t,max:n}:{min:So.Zero(),max:So.Zero()}},t.Center=function(e){var n=e instanceof Array?t.MinMax(e):e;return So.Center(n.min,n.max)},t.MergeMeshes=function(e,n,r,i,o,a){var s;if(void 0===n&&(n=!0),!r){var l=0;for(s=0;s=65536)return jo.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(a){var c,u,d=null;o=!1}var h,p=new Array,f=new Array,m=null,g=new Array,b=null;for(s=0;s-1&&t.animations.splice(o,1)}},i=0,o=e.animations;i0&&(c=!0,this._soundLoaded(n));break;case"String":l.push(n);case"Array":0===l.length&&(l=n);for(var u=0;u0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if(ss.a.audioEngine.audioContext&&this._soundSource){var n=e?ss.a.audioEngine.audioContext.currentTime+e:ss.a.audioEngine.audioContext.currentTime;this._soundSource.stop(n),this._soundSource.onended=function(){t.isPlaying=!1},this.isPaused||(this._startOffset=0)}},e.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect():ss.a.audioEngine.audioContext&&(this.stop(0),this._startOffset+=ss.a.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){ss.a.audioEngine.canUseWebAudio&&this._soundGain&&(t&&ss.a.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(ss.a.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,ss.a.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,ss.a.audioEngine.audioContext.currentTime+t)):this._soundGain.gain.value=e),this._volume=e},e.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},e.prototype.getVolume=function(){return this._volume},e.prototype.attachToMesh=function(e){var t=this;this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedTransformNode=e,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(e){return t._onRegisterAfterWorldMatrixUpdate(e)},this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)},e.prototype.detachFromMesh=function(){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedTransformNode=null)},e.prototype._onRegisterAfterWorldMatrixUpdate=function(e){if(e.getBoundingInfo){var t=e;if(this._positionInEmitterSpace)t.worldMatrixFromCache.invertToRef(Mo.Matrix[0]),this.setPosition(Mo.Matrix[0].getTranslation());else{var n=t.getBoundingInfo();this.setPosition(n.boundingSphere.centerWorld)}ss.a.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()}},e.prototype.clone=function(){var t=this;if(this._streaming)return null;var n=function(){t._isReadyToPlay?(i._audioBuffer=t.getAudioBuffer(),i._isReadyToPlay=!0,i.autoplay&&i.play(0,t._offset,t._length)):window.setTimeout(n,300)},r={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 e(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&i.setAttenuationFunction(this._customAttenuationFunction),i.setPosition(this._position),i.setPlaybackRate(this._playbackRate),n(),i},e.prototype.getAudioBuffer=function(){return this._audioBuffer},e.prototype.serialize=function(){var e={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};return this.spatialSound&&(this._connectedTransformNode&&(e.connectedMeshId=this._connectedTransformNode.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},e.Parse=function(t,n,r,i){var o,a=t.name;o=t.url?r+t.url:r+a;var s,l={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 c=function(){i._isReadyToPlay?(s._audioBuffer=i.getAudioBuffer(),s._isReadyToPlay=!0,s.autoplay&&s.play(0,s._offset,s._length)):window.setTimeout(c,300)};s=new e(a,new ArrayBuffer(0),n,null,l),c()}else s=new e(a,o,n,(function(){n._removePendingData(s)}),l),n._addPendingData(s);if(t.position){var u=So.FromArray(t.position);s.setPosition(u)}if(t.isDirectional&&(s.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var d=So.FromArray(t.localDirectionToMesh);s.setLocalDirectionToMesh(d)}if(t.connectedMeshId){var h=n.getMeshByID(t.connectedMeshId);h&&s.attachToMesh(h)}return s},e._SceneComponentInitialization=function(e){throw oa.a.WarnImport("AudioSceneComponent")},e}(),Dl=function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,!this._options.mainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return e.prototype._initializeSoundTrackAudioGraph=function(){ss.a.audioEngine.canUseWebAudio&&ss.a.audioEngine.audioContext&&(this._outputAudioNode=ss.a.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(ss.a.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},e.prototype.dispose=function(){if(ss.a.audioEngine&&ss.a.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},e.prototype.AddSound=function(e){this._isInitialized||this._initializeSoundTrackAudioGraph(),ss.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&e.connectToSoundTrackAudioNode(this._outputAudioNode),e.soundTrackId&&(-1===e.soundTrackId?this._scene.mainSoundTrack.RemoveSound(e):this._scene.soundTracks&&this._scene.soundTracks[e.soundTrackId].RemoveSound(e)),this.soundCollection.push(e),e.soundTrackId=this.id},e.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},e.prototype.setVolume=function(e){ss.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){if(ss.a.audioEngine.canUseWebAudio)for(var e=0;e0?t.activeCameras[0]:t.activeCamera){this._cachedCameraPosition.equals(i.globalPosition)||(this._cachedCameraPosition.copyFrom(i.globalPosition),n.audioContext.listener.setPosition(i.globalPosition.x,i.globalPosition.y,i.globalPosition.z)),i.rigCameras&&i.rigCameras.length>0&&(i=i.rigCameras[0]);var o=Oo.Invert(i.getViewMatrix()),a=So.TransformNormal(new So(0,0,-1),o);a.normalize(),isNaN(a.x)||isNaN(a.y)||isNaN(a.z)||this._cachedCameraDirection.equals(a)||(this._cachedCameraDirection.copyFrom(a),n.audioContext.listener.setOrientation(a.x,a.y,a.z,0,1,0))}else n.audioContext.listener.setPosition(0,0,0)}var s;for(s=0;s0?1/i:0,l=0;l0},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e;var n=this._attachedCamera.getScene();this._onPrePointerObservableObserver=n.onPrePointerObservable.add((function(e){e.type!==Qs.POINTERDOWN?e.type===Qs.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){var e=Ba.a.Now,n=0;null!=t._lastFrameTime&&(n=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var r=e-t._lastInteractionTime-t._idleRotationWaitTime,i=Math.max(Math.min(r/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*i,t._attachedCamera&&(t._attachedCamera.alpha-=t._cameraRotationSpeed*(n/1e3))}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},e.prototype._userIsZooming=function(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset},e.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},e.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=Ba.a.Now)},e.prototype._userIsMoving=function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},e}(),Nl=function(){function e(){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(e.prototype,"name",{get:function(){return"Bouncing"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var n=this._attachedCamera;n&&(e?this._onMeshTargetChangedObserver=n.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var n=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*n,t.upperRadiusTransitionRange=.05*n}})):this._onMeshTargetChangedObserver&&n.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))}))},e.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},e.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)},e.prototype._applyBoundRadiusAnimation=function(t){var n=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=Ca.CreateAnimation("radius",Ca.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var r=Ca.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return n._clearAnimationLocks()}));r&&this._animatables.push(r)}},e.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},e.EasingFunction=new gl(.3),e.EasingMode=fl.EASINGMODE_EASEOUT,e}(),Ll=function(){function e(){this._mode=e.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.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(e.prototype,"name",{get:function(){return"Framing"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var n=this;this._attachedCamera=t;var r=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=r.onPrePointerObservable.add((function(e){e.type!==Qs.POINTERDOWN?e.type===Qs.POINTERUP&&(n._isPointerDown=!1):n._isPointerDown=!0})),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){e&&n.zoomOnMesh(e)})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){n._applyUserInteraction(),n._maintainCameraAboveGround()}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},e.prototype.zoomOnMesh=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null),e.computeWorldMatrix(!0);var r=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(r.minimumWorld,r.maximumWorld,t,n)},e.prototype.zoomOnMeshHierarchy=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null),e.computeWorldMatrix(!0);var r=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(r.min,r.max,t,n)},e.prototype.zoomOnMeshesHierarchy=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null);for(var r=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new So(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o=0;oc.upperRadiusLimit?c.upperRadiusLimit:l),l):0},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var n=Ba.a.Now-this._lastInteractionTime,r=.5*Math.PI-this._defaultElevation,i=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>i&&n>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=Ca.CreateAnimation("beta",Ca.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=Ca.TransitionTo("beta",r,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(function(){t._clearAnimationLocks(),t.stopAllAnimations()}));o&&this._animatables.push(o)}}},e.prototype._getFrustumSlope=function(){var e=this._attachedCamera;if(!e)return Co.Zero();var t=e.getScene().getEngine().getAspectRatio(e),n=Math.tan(e.fov/2);return new Co(n*t,n)},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=Ba.a.Now,this.stopAllAnimations(),this._clearAnimationLocks())},e.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(e.prototype,"isUserIsMoving",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!0,configurable:!0}),e.EasingFunction=new bl,e.EasingMode=fl.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),Ul=function(e,t,n,r){void 0===t&&(t=new So),void 0===n&&(n=0),void 0===r&&(r=!1),this.direction=e,this.rotatedDirection=t,this.diff=n,this.ignore=r},Vl=(function(){function e(e){this.ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new Ul(So.Up()),new Ul(So.Down()),new Ul(So.Left()),new Ul(So.Right()),new Ul(So.Forward()),new Ul(So.Forward().scaleInPlace(-1))],this._tmpMatrix=new Oo,this._tmpVector=new So,this._zeroVector=So.Zero(),this._lookAtTmpMatrix=new Oo}e.prototype.init=function(){},e.prototype._closestFace=function(e){var t=this;return this._faceVectors.forEach((function(n){t._target.rotationQuaternion||(t._target.rotationQuaternion=Po.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),So.TransformCoordinatesToRef(n.direction,t._tmpMatrix,n.rotatedDirection),n.diff=So.GetAngleBetweenVectors(n.rotatedDirection,e,So.Cross(n.rotatedDirection,e))})),this._faceVectors.reduce((function(e,t){return e.ignore?t:t.ignore||e.diff1)return e._setAllVisibility(e._ownerNode,1),void(e._hoverValue=e.fadeInTime+e.delay);if(e._ownerNode.visibility<0&&(e._setAllVisibility(e._ownerNode,0),e._hoverValue<0))return void(e._hoverValue=0);setTimeout(e._update,e._millisecondsPerFrame)}}}Object.defineProperty(e.prototype,"name",{get:function(){return"FadeInOut"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this._ownerNode=e,this._setAllVisibility(this._ownerNode,0)},e.prototype.detach=function(){this._ownerNode=null},e.prototype.fadeIn=function(e){this._hovered=e,this._update()},e.prototype._setAllVisibility=function(e,t){var n=this;e.visibility=t,e.getChildMeshes().forEach((function(e){n._setAllVisibility(e,t)}))}}(),function(){function e(e,t,n){void 0===n&&(n=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=n}return e.prototype.intersectsBoxMinMax=function(t,n,r){void 0===r&&(r=0);var i,o,a,s,l=e.TmpVector3[0].copyFromFloats(t.x-r,t.y-r,t.z-r),c=e.TmpVector3[1].copyFromFloats(n.x+r,n.y+r,n.z+r),u=0,d=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xc.x)return!1}else if(i=1/this.direction.x,o=(l.x-this.origin.x)*i,(a=(c.x-this.origin.x)*i)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(d=Math.min(a,d)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yc.y)return!1}else if(i=1/this.direction.y,o=(l.y-this.origin.y)*i,(a=(c.y-this.origin.y)*i)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(d=Math.min(a,d)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zc.z)return!1}else if(i=1/this.direction.z,o=(l.z-this.origin.z)*i,(a=(c.z-this.origin.z)*i)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(d=Math.min(a,d)))return!1;return!0},e.prototype.intersectsBox=function(e,t){return void 0===t&&(t=0),this.intersectsBoxMinMax(e.minimum,e.maximum,t)},e.prototype.intersectsSphere=function(e,t){void 0===t&&(t=0);var n=e.center.x-this.origin.x,r=e.center.y-this.origin.y,i=e.center.z-this.origin.z,o=n*n+r*r+i*i,a=e.radius+t,s=a*a;if(o<=s)return!0;var l=n*this.direction.x+r*this.direction.y+i*this.direction.z;return!(l<0)&&o-l*l<=s},e.prototype.intersectsTriangle=function(t,n,r){var i=e.TmpVector3[0],o=e.TmpVector3[1],a=e.TmpVector3[2],s=e.TmpVector3[3],l=e.TmpVector3[4];n.subtractToRef(t,i),r.subtractToRef(t,o),So.CrossToRef(this.direction,o,a);var c=So.Dot(i,a);if(0===c)return null;var u=1/c;this.origin.subtractToRef(t,s);var d=So.Dot(s,a)*u;if(d<0||d>1)return null;So.CrossToRef(s,i,l);var h=So.Dot(this.direction,l)*u;if(h<0||d+h>1)return null;var p=So.Dot(o,l)*u;return p>this.length?null:new Bs(1-d-h,d,p)},e.prototype.intersectsPlane=function(e){var t,n=So.Dot(e.normal,this.direction);if(Math.abs(n)<9.99999997475243e-7)return null;var r=So.Dot(e.normal,this.origin);return(t=(-e.d-r)/n)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsAxis=function(e,t){switch(void 0===t&&(t=0),e){case"y":return(n=(this.origin.y-t)/this.direction.y)>0?null:new So(this.origin.x+this.direction.x*-n,t,this.origin.z+this.direction.z*-n);case"x":return(n=(this.origin.x-t)/this.direction.x)>0?null:new So(t,this.origin.y+this.direction.y*-n,this.origin.z+this.direction.z*-n);case"z":var n;return(n=(this.origin.z-t)/this.direction.z)>0?null:new So(this.origin.x+this.direction.x*-n,this.origin.y+this.direction.y*-n,t);default:return null}},e.prototype.intersectsMesh=function(t,n){var r=Mo.Matrix[0];return t.getWorldMatrix().invertToRef(r),this._tmpRay?e.TransformToRef(this,r,this._tmpRay):this._tmpRay=e.Transform(this,r),t.intersects(this._tmpRay,n)},e.prototype.intersectsMeshes=function(e,t,n){n?n.length=0:n=[];for(var r=0;rt.distance?1:0},e.prototype.intersectionSegment=function(t,n,r){var i=this.origin,o=Mo.Vector3[0],a=Mo.Vector3[1],s=Mo.Vector3[2],l=Mo.Vector3[3];n.subtractToRef(t,o),this.direction.scaleToRef(e.rayl,s),i.addToRef(s,a),t.subtractToRef(i,l);var c,u,d,h,p=So.Dot(o,o),f=So.Dot(o,s),m=So.Dot(s,s),g=So.Dot(o,l),b=So.Dot(s,l),v=p*m-f*f,A=v,_=v;vA&&(u=A,h=b+f,_=m)),h<0?(h=0,-g<0?u=0:-g>p?u=A:(u=-g,A=p)):h>_&&(h=_,-g+f<0?u=0:-g+f>p?u=A:(u=-g+f,A=p)),c=Math.abs(u)0&&d<=this.length&&w.lengthSquared()=i.distance))&&(i=l,n)))break}return i||new ds},nl.prototype._internalMultiPick=function(e,t,n){if(!ds)return null;for(var r=new Array,i=0;i1)throw"Multiple drag modes specified in dragBehavior options. Only one expected"}return Object.defineProperty(e.prototype,"options",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t,n){var r=this;this._scene=t.getScene(),this.attachedNode=t,e._planeScene||(this._debugMode?e._planeScene=this._scene:(e._planeScene=new nl(this._scene.getEngine(),{virtual:!0}),e._planeScene.detachControl(),this._scene.onDisposeObservable.addOnce((function(){e._planeScene.dispose(),e._planeScene=null})))),this._dragPlane=Pl.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,e._planeScene,!1,Pl.DOUBLESIDE),this.lastDragPosition=new So(0,0,0);var i=n||function(e){return r.attachedNode==e||e.isDescendantOf(r.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add((function(t,n){if(r.enabled)if(t.type==Qs.POINTERDOWN)r.startAndReleaseDragOnPointerEvents&&!r.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.pickedPoint&&t.pickInfo.ray&&i(t.pickInfo.pickedMesh)&&r._startDrag(t.event.pointerId,t.pickInfo.ray,t.pickInfo.pickedPoint);else if(t.type==Qs.POINTERUP)r.startAndReleaseDragOnPointerEvents&&r.currentDraggingPointerID==t.event.pointerId&&r.releaseDrag();else if(t.type==Qs.POINTERMOVE){var o=t.event.pointerId;r.currentDraggingPointerID===e._AnyMouseID&&o!==e._AnyMouseID&&"mouse"==t.event.pointerType&&(r._lastPointerRay[r.currentDraggingPointerID]&&(r._lastPointerRay[o]=r._lastPointerRay[r.currentDraggingPointerID],delete r._lastPointerRay[r.currentDraggingPointerID]),r.currentDraggingPointerID=o),r._lastPointerRay[o]||(r._lastPointerRay[o]=new Vl(new So,new So)),t.pickInfo&&t.pickInfo.ray&&(r._lastPointerRay[o].origin.copyFrom(t.pickInfo.ray.origin),r._lastPointerRay[o].direction.copyFrom(t.pickInfo.ray.direction),r.currentDraggingPointerID==o&&r.dragging&&r._moveDrag(t.pickInfo.ray))}})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){r._moving&&r.moveAttached&&(zl._RemoveAndStorePivotPoint(r.attachedNode),r._targetPosition.subtractToRef(r.attachedNode.absolutePosition,r._tmpVector),r._tmpVector.scaleInPlace(r.dragDeltaRatio),r.attachedNode.getAbsolutePosition().addToRef(r._tmpVector,r._tmpVector),r.validateDrag(r._tmpVector)&&r.attachedNode.setAbsolutePosition(r._tmpVector),zl._RestorePivotPoint(r.attachedNode))}))},e.prototype.releaseDrag=function(){this.dragging&&(this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerID}),this.dragging=!1),this.currentDraggingPointerID=-1,this._moving=!1,this.detachCameraControls&&this._attachedElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera&&this._scene.activeCamera.attachControl(this._attachedElement,!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault)},e.prototype.startDrag=function(t,n,r){void 0===t&&(t=e._AnyMouseID),this._startDrag(t,n,r);var i=this._lastPointerRay[t];t===e._AnyMouseID&&(i=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),i&&this._moveDrag(i)},e.prototype._startDrag=function(e,t,n){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){zl._RemoveAndStorePivotPoint(this.attachedNode),t?(this._startDragRay.direction.copyFrom(t.direction),this._startDragRay.origin.copyFrom(t.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,n||this._tmpVector);var r=this._pickWithRayOnDragPlane(this._startDragRay);r&&(this.dragging=!0,this.currentDraggingPointerID=e,this.lastDragPosition.copyFrom(r),this.onDragStartObservable.notifyObservers({dragPlanePoint:r,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.attachedElement?(this._attachedElement=this._scene.activeCamera.inputs.attachedElement,this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement)):this._attachedElement=null)),zl._RestorePivotPoint(this.attachedNode)}},e.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){this.updateDragPlane&&this._updateDragPlanePosition(e,t);var n=0;this._options.dragAxis?(this.useObjectOrientationForDragging?So.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),n=So.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(n,this._dragDelta)):(n=this._dragDelta.length(),t.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:n,delta:this._dragDelta,dragPlanePoint:t,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerID}),this.lastDragPosition.copyFrom(t)}},e.prototype._pickWithRayOnDragPlane=function(t){var n=this;if(!t)return null;var r=Math.acos(So.Dot(this._dragPlane.forward,t.direction));if(r>Math.PI/2&&(r=Math.PI-r),this.maxDragAngle>0&&r>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*So.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var i=So.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-i,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),this._alternatePickedPoint}return null}var o=e._planeScene.pickWithRay(t,(function(e){return e==n._dragPlane}));return o&&o.hit&&o.pickedMesh&&o.pickedPoint?o.pickedPoint:null},e.prototype._updateDragPlanePosition=function(e,t){this._pointA.copyFrom(t),this._options.dragAxis?(this.useObjectOrientationForDragging?So.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),this._pointA.addToRef(this._localAxis,this._pointB),e.origin.subtractToRef(this._pointA,this._pointC),this._pointA.addToRef(this._pointC.normalize(),this._pointC),this._pointB.subtractToRef(this._pointA,this._lineA),this._pointC.subtractToRef(this._pointA,this._lineB),So.CrossToRef(this._lineA,this._lineB,this._lookAt),So.CrossToRef(this._lineA,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?So.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(e.origin)),this._dragPlane.position.copyFrom(this.attachedNode.absolutePosition),this._dragPlane.computeWorldMatrix(!0)},e.prototype.detach=function(){this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this.releaseDrag()},e._AnyMouseID=-2,e}(),Hl=(function(){function e(){this._startDistance=0,this._initialScale=new So(0,0,0),this._targetScale=new So(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new Gl({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new Gl({}),this._dragBehaviorB.moveAttached=!1}Object.defineProperty(e.prototype,"name",{get:function(){return"MultiPointerScale"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype._getCurrentDistance=function(){return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()},e.prototype.attach=function(e){var t=this;this._ownerNode=e,this._dragBehaviorA.onDragStartObservable.add((function(n){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorA.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),this._dragBehaviorB.onDragStartObservable.add((function(n){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorB.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(e){e.onDragObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var e=t._getCurrentDistance()/t._startDistance;t._initialScale.scaleToRef(e,t._targetScale)}}))})),e.addBehavior(this._dragBehaviorA),e.addBehavior(this._dragBehaviorB),this._sceneRenderObserver=e.getScene().onBeforeRenderObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var n=t._targetScale.subtract(e.scaling).scaleInPlace(.1);n.length()>.01&&e.scaling.addInPlace(n)}}))},e.prototype.detach=function(){var e=this;this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(t){t.onDragStartObservable.clear(),t.onDragObservable.clear(),e._ownerNode.removeBehavior(t)}))}}(),function(){function e(){this._sceneRenderObserver=null,this._targetPosition=new So(0,0,0),this._moving=!1,this._startingOrientation=new Po,this.zDragFactor=3,this.rotateDraggedObject=!0,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new yo.a,this.onDragEndObservable=new yo.a}return Object.defineProperty(e.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},Object.defineProperty(e.prototype,"_pointerCamera",{get:function(){return this._scene.cameraToUseForPointers?this._scene.cameraToUseForPointers:this._scene.activeCamera},enumerable:!0,configurable:!0}),e.prototype.attach=function(t){var n=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),e._virtualScene||(e._virtualScene=new nl(this._scene.getEngine()),e._virtualScene.detachControl(),this._scene.getEngine().scenes.pop());var r=null,i=new So(0,0,0);this._virtualOriginMesh=new ws("",e._virtualScene),this._virtualOriginMesh.rotationQuaternion=new Po,this._virtualDragMesh=new ws("",e._virtualScene),this._virtualDragMesh.rotationQuaternion=new Po;var o=null;this._pointerObserver=this._scene.onPointerObservable.add((function(e,t){if(e.type==Qs.POINTERDOWN){if(!n.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.ray&&(u=e.pickInfo.pickedMesh,n._ownerNode==u||u.isDescendantOf(n._ownerNode))){n._pointerCamera&&n._pointerCamera.cameraRigMode==Ts.RIG_MODE_NONE&&e.pickInfo.ray.origin.copyFrom(n._pointerCamera.globalPosition),r=n._ownerNode,zl._RemoveAndStorePivotPoint(r),i.copyFrom(e.pickInfo.ray.origin),n._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),n._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),n._virtualOriginMesh.removeChild(n._virtualDragMesh),r.computeWorldMatrix(),n._virtualDragMesh.position.copyFrom(r.absolutePosition),r.rotationQuaternion||(r.rotationQuaternion=Po.RotationYawPitchRoll(r.rotation.y,r.rotation.x,r.rotation.z));var a=r.parent;r.setParent(null),n._virtualDragMesh.rotationQuaternion.copyFrom(r.rotationQuaternion),r.setParent(a),n._virtualOriginMesh.addChild(n._virtualDragMesh),n._targetPosition.copyFrom(n._virtualDragMesh.absolutePosition),n.dragging=!0,n.currentDraggingPointerID=e.event.pointerId,n.detachCameraControls&&n._pointerCamera&&!n._pointerCamera.leftCamera&&(n._pointerCamera.inputs.attachedElement?(o=n._pointerCamera.inputs.attachedElement,n._pointerCamera.detachControl(n._pointerCamera.inputs.attachedElement)):o=null),zl._RestorePivotPoint(r),n.onDragStartObservable.notifyObservers({})}}else if(e.type==Qs.POINTERUP)n.currentDraggingPointerID==e.event.pointerId&&(n.dragging=!1,n._moving=!1,n.currentDraggingPointerID=-1,r=null,n._virtualOriginMesh.removeChild(n._virtualDragMesh),n.detachCameraControls&&o&&n._pointerCamera&&!n._pointerCamera.leftCamera&&n._pointerCamera.attachControl(o,!0),n.onDragEndObservable.notifyObservers({}));else if(e.type==Qs.POINTERMOVE&&n.currentDraggingPointerID==e.event.pointerId&&n.dragging&&e.pickInfo&&e.pickInfo.ray&&r){var s=n.zDragFactor;n._pointerCamera&&n._pointerCamera.cameraRigMode==Ts.RIG_MODE_NONE&&(e.pickInfo.ray.origin.copyFrom(n._pointerCamera.globalPosition),s=0);var l=e.pickInfo.ray.origin.subtract(i);i.copyFrom(e.pickInfo.ray.origin);var c=-So.Dot(l,e.pickInfo.ray.direction);n._virtualOriginMesh.addChild(n._virtualDragMesh),n._virtualDragMesh.position.z-=n._virtualDragMesh.position.z<1?c*n.zDragFactor:c*s*n._virtualDragMesh.position.z,n._virtualDragMesh.position.z<0&&(n._virtualDragMesh.position.z=0),n._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),n._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),n._virtualOriginMesh.removeChild(n._virtualDragMesh),n._targetPosition.copyFrom(n._virtualDragMesh.absolutePosition),r.parent&&So.TransformCoordinatesToRef(n._targetPosition,Oo.Invert(r.parent.getWorldMatrix()),n._targetPosition),n._moving||n._startingOrientation.copyFrom(n._virtualDragMesh.rotationQuaternion),n._moving=!0}var u}));var a=new Po;this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(n.dragging&&n._moving&&r){if(zl._RemoveAndStorePivotPoint(r),r.position.addInPlace(n._targetPosition.subtract(r.position).scale(n.dragDeltaRatio)),n.rotateDraggedObject){a.copyFrom(n._startingOrientation),a.x=-a.x,a.y=-a.y,a.z=-a.z,n._virtualDragMesh.rotationQuaternion.multiplyToRef(a,a),Po.RotationYawPitchRollToRef(a.toEulerAngles("xyz").y,0,0,a),a.multiplyToRef(n._startingOrientation,a);var e=r.parent;(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&(r.setParent(null),Po.SlerpToRef(r.rotationQuaternion,a,n.dragDeltaRatio,r.rotationQuaternion),r.setParent(e))}zl._RestorePivotPoint(r)}}))},e.prototype.detach=function(){this._scene&&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.onDragStartObservable.clear()},e}()),Ql=(function(){function e(e,t,n){if(this.targetPosition=So.Zero(),this.poleTargetPosition=So.Zero(),this.poleTargetLocalOffset=So.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=Po.Identity(),this._bone1Mat=Oo.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=So.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=t,this._bone1=t.getParent(),this._bone1){this.mesh=e;var r=t.getPosition();if(t.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,r.x>r.y&&r.x>r.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var i=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*i.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){e.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(e),s=this._bone2.getAbsolutePosition(e),l=this._bone1.getAbsolutePosition(e);this._bone1Length=So.Distance(a,s),this._bone2Length=So.Distance(s,l)}this._bone1.getRotationMatrixToRef(es.WORLD,e,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))}}Object.defineProperty(e.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),e.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||null==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,n=this._bone2Length;this._maxReach=Math.sqrt(t*t+n*n-2*t*n*Math.cos(e))},e.prototype.update=function(){var t=this._bone1;if(t){var n=this.targetPosition,r=this.poleTargetPosition,i=e._tmpMats[0],o=e._tmpMats[1];this.targetMesh&&n.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,r):this.poleTargetMesh&&So.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),r);var a=e._tmpVecs[0],s=e._tmpVecs[1],l=e._tmpVecs[2],c=e._tmpVecs[3],u=e._tmpVecs[4],d=e._tmpQuat;t.getAbsolutePositionToRef(this.mesh,a),r.subtractToRef(a,u),0==u.x&&0==u.y&&0==u.z?u.y=1:u.normalize(),n.subtractToRef(a,c),c.normalize(),So.CrossToRef(c,u,s),s.normalize(),So.CrossToRef(c,s,l),l.normalize(),Oo.FromXYZAxesToRef(l,c,s,i);var h=this._bone1Length,p=this._bone2Length,f=So.Distance(a,n);this._maxReach>0&&(f=Math.min(this._maxReach,f));var m=(p*p+f*f-h*h)/(2*p*f),g=(f*f+h*h-p*p)/(2*f*h);m>1&&(m=1),g>1&&(g=1),m<-1&&(m=-1),g<-1&&(g=-1);var b=Math.acos(m),v=Math.acos(g),A=-b-v;if(this._rightHandedSystem)Oo.RotationYawPitchRollToRef(0,0,this._adjustRoll,o),o.multiplyToRef(i,i),Oo.RotationAxisToRef(this._bendAxis,v,o),o.multiplyToRef(i,i);else{var _=e._tmpVecs[5];_.copyFrom(this._bendAxis),_.x*=-1,Oo.RotationAxisToRef(_,-v,o),o.multiplyToRef(i,i)}this.poleAngle&&(Oo.RotationAxisToRef(c,this.poleAngle,o),i.multiplyToRef(o,i)),this._bone1&&(this.slerpAmount<1?(this._slerping||Po.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),Po.FromRotationMatrixToRef(i,d),Po.SlerpToRef(this._bone1Quat,d,this.slerpAmount,this._bone1Quat),A=this._bone2Ang*(1-this.slerpAmount)+A*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,es.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(i,es.WORLD,this.mesh),this._bone1Mat.copyFrom(i),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,A,es.LOCAL),this._bone2Ang=A}},e._tmpVecs=[So.Zero(),So.Zero(),So.Zero(),So.Zero(),So.Zero(),So.Zero()],e._tmpQuat=Po.Identity(),e._tmpMats=[Oo.Identity(),Oo.Identity()]}(),function(){function e(e,t,n,r){if(this.upAxis=So.Up(),this.upAxisSpace=es.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=Po.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=So.Forward(),this.mesh=e,this.bone=t,this.target=n,r&&(r.adjustYaw&&(this.adjustYaw=r.adjustYaw),r.adjustPitch&&(this.adjustPitch=r.adjustPitch),r.adjustRoll&&(this.adjustRoll=r.adjustRoll),null!=r.maxYaw?this.maxYaw=r.maxYaw:this.maxYaw=Math.PI,null!=r.minYaw?this.minYaw=r.minYaw:this.minYaw=-Math.PI,null!=r.maxPitch?this.maxPitch=r.maxPitch:this.maxPitch=Math.PI,null!=r.minPitch?this.minPitch=r.minPitch:this.minPitch=-Math.PI,null!=r.slerpAmount&&(this.slerpAmount=r.slerpAmount),null!=r.upAxis&&(this.upAxis=r.upAxis),null!=r.upAxisSpace&&(this.upAxisSpace=r.upAxisSpace),null!=r.yawAxis||null!=r.pitchAxis)){var i=os.Y,o=os.X;null!=r.yawAxis&&(i=r.yawAxis.clone()).normalize(),null!=r.pitchAxis&&(o=r.pitchAxis.clone()).normalize();var a=So.Cross(o,i);this._transformYawPitch=Oo.Identity(),Oo.FromXYZAxesToRef(o,i,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}t.getParent()||this.upAxisSpace!=es.BONE||(this.upAxisSpace=es.LOCAL)}Object.defineProperty(e.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),e.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var t=this.bone,n=e._tmpVecs[0];t.getAbsolutePositionToRef(this.mesh,n);var r=this.target,i=e._tmpMats[0],o=e._tmpMats[1],a=this.mesh,s=t.getParent(),l=e._tmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==es.BONE&&s?(this._transformYawPitch&&So.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),s.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==es.LOCAL&&(a.getDirectionToRef(l,l),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||l.normalize());var c=!1,u=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(c=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(u=!0),c||u){var d=e._tmpMats[2],h=e._tmpMats[3];if(this.upAxisSpace==es.BONE&&1==l.y&&s)s.getRotationMatrixToRef(es.WORLD,this.mesh,d);else if(this.upAxisSpace!=es.LOCAL||1!=l.y||s){(f=e._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&So.TransformCoordinatesToRef(f,this._transformYawPitchInv,f),s?s.getDirectionToRef(f,this.mesh,f):a.getDirectionToRef(f,f);var p=So.Cross(l,f);p.normalize();var f=So.Cross(p,l);Oo.FromXYZAxesToRef(p,l,f,d)}else d.copyFrom(a.getWorldMatrix());d.invertToRef(h);var m=null;if(u){var g=e._tmpVecs[3];r.subtractToRef(n,g),So.TransformCoordinatesToRef(g,h,g),m=Math.sqrt(g.x*g.x+g.z*g.z);var b=Math.atan2(g.y,m),v=b;b>this._maxPitch?(g.y=this._maxPitchTan*m,v=this._maxPitch):bthis._maxYaw||AMath.PI?this._isAngleBetween(A,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,_=this._maxYaw):this._isAngleBetween(A,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*m,g.x=this._minYawSin*m,_=this._minYaw):A>this._maxYaw?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,_=this._maxYaw):AMath.PI){var y=e._tmpVecs[8];y.copyFrom(os.Z),this._transformYawPitch&&So.TransformCoordinatesToRef(y,this._transformYawPitchInv,y);var x=e._tmpMats[4];this._boneQuat.toRotationMatrix(x),this.mesh.getWorldMatrix().multiplyToRef(x,x),So.TransformCoordinatesToRef(y,x,y),So.TransformCoordinatesToRef(y,h,y);var w=Math.atan2(y.x,y.z);if(this._getAngleBetween(w,A)>this._getAngleBetween(w,this._midYawConstraint)){null==m&&(m=Math.sqrt(g.x*g.x+g.z*g.z));var E=this._getAngleBetween(w,this._maxYaw);this._getAngleBetween(w,this._minYaw)Math.PI?n-=2*Math.PI:n<-Math.PI&&(n+=2*Math.PI),n},e.prototype._getAngleBetween=function(e,t){var n=0;return(n=(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)?t-e:e-t)>Math.PI&&(n=2*Math.PI-n),n},e.prototype._isAngleBetween=function(e,t,n){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(n=(n%=2*Math.PI)<0?n+2*Math.PI:n)){if(e>t&&en&&e=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this)}void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())},e.prototype.serialize=function(){if(!this.name)return null;var e=ya.Serialize(this);return ya.AppendSerializedAnimations(this,e),e},e.WhenAllReady=function(e,t){var n=e.length;if(0!==n)for(var r,i,o=function(){if((r=e[a]).isReady())0==--n&&t();else if(i=r.onLoadObservable){var o=function(){i.removeCallback(o),0==--n&&t()};i.add(o)}},a=0;a>v,_=0;_<6;_++){var y=b[v][_];g&&(y=h._convertRGBtoRGBATextureData(y,A,A,i)),p.texImage2D(_,v,m,A,A,0,u,c,y)}h._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else h.updateRawCubeTexture(f,o,r,i,d);f.isReady=!0,t._removePendingData(f),l&&l()}}(e)}),void 0,t.offlineProvider,!0,(function(e,n){t._removePendingData(f),c&&e&&c(e.status+" "+e.statusText,n)})),f},ss.a.prototype.createRawTexture2DArray=Xl(!1),ss.a.prototype.createRawTexture3D=Xl(!0),ss.a.prototype.updateRawTexture2DArray=Yl(!1),ss.a.prototype.updateRawTexture3D=Yl(!0);var ql=function(e){function t(t,n,r,i,o,a,s,l,c){void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===l&&(l=3),void 0===c&&(c=0);var u=e.call(this,null,o,!a,s)||this;return u.format=i,u._engine=o.getEngine(),u._texture=o.getEngine().createRawTexture(t,n,r,i,a,s,l,null,c),u.wrapU=Wl.CLAMP_ADDRESSMODE,u.wrapV=Wl.CLAMP_ADDRESSMODE,u}return Object(No.d)(t,e),t.prototype.update=function(e){this._engine.updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t.CreateLuminanceTexture=function(e,n,r,i,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),new t(e,n,r,1,i,o,a,s)},t.CreateLuminanceAlphaTexture=function(e,n,r,i,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),new t(e,n,r,2,i,o,a,s)},t.CreateAlphaTexture=function(e,n,r,i,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),new t(e,n,r,0,i,o,a,s)},t.CreateRGBTexture=function(e,n,r,i,o,a,s,l){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),void 0===l&&(l=0),new t(e,n,r,4,i,o,a,s,l)},t.CreateRGBATexture=function(e,n,r,i,o,a,s,l){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),void 0===l&&(l=0),new t(e,n,r,5,i,o,a,s,l)},t.CreateRTexture=function(e,n,r,i,o,a,s,l){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=Wl.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=1),new t(e,n,r,6,i,o,a,s,l)},t}(Wl),Zl=function(){function e(e,t,n){this.name=e,this.id=t,this.bones=new Array,this.needInitialSkinMatrix=!1,this.overrideMesh=null,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=Oo.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new yo.a,this.bones=[],this._scene=n||Zo.a.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;var r=this._scene.getEngine().getCaps();this._canUseTextureForBones=r.textureFloat&&r.maxVertexTextureImageUnits>0}return Object.defineProperty(e.prototype,"useTextureToStoreBoneMatrices",{get:function(){return this._useTextureToStoreBoneMatrices},set:function(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTextureForMatrices",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"Skeleton"},e.prototype.getChildren=function(){return this.bones.filter((function(e){return!e.getParent()}))},e.prototype.getTransformMatrices=function(e){return this.needInitialSkinMatrix&&e._bonesTransformMatrices?e._bonesTransformMatrices:(this._transformMatrices||this.prepare(),this._transformMatrices)},e.prototype.getTransformMatrixTexture=function(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture:this._transformMatrixTexture},e.prototype.getScene=function(){return this._scene},e.prototype.toString=function(e){var t="Name: "+this.name+", nBones: "+this.bones.length;if(t+=", nAnimationRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var n=!0;for(var r in this._ranges)n&&(t+=", ",n=!1),t+=r;t+="}"}return t},e.prototype.getBoneIndexByName=function(e){for(var t=0,n=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)},e.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var n=0;n0)for(var e=0,t=this.bones;e0&&(i.animation=n.animations[0].serialize()),e.ranges=[],this._ranges){var a=this._ranges[o];if(a){var s={};s.name=o,s.from=a.from,s.to=a.to,e.ranges.push(s)}}}return e},e.Parse=function(t,n){var r,i=new e(t.name,t.id,n);for(t.dimensionsAtRest&&(i.dimensionsAtRest=So.FromArray(t.dimensionsAtRest)),i.needInitialSkinMatrix=t.needInitialSkinMatrix,r=0;r-1&&(a=i.bones[o.parentBoneIndex]);var s=o.rest?Oo.FromArray(o.rest):null,l=new rl(o.name,i,a,Oo.FromArray(o.matrix),s);void 0!==o.id&&null!==o.id&&(l.id=o.id),o.length&&(l.length=o.length),o.metadata&&(l.metadata=o.metadata),o.animation&&l.animations.push(Ca.Parse(o.animation)),void 0!==o.linkedTransformNodeId&&null!==o.linkedTransformNodeId&&(i._hasWaitingData=!0,l._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(r=0;r0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},e.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),n=0;n=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(e.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!0,configurable:!0}),e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.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]})},e.prototype.dispose=function(){},e.GAMEPAD=0,e.GENERIC=1,e.XBOX=2,e.POSE_ENABLED=3,e.DUALSHOCK=4,e}(),tc=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i.onButtonDownObservable=new yo.a,i.onButtonUpObservable=new yo.a,i.type=ec.GENERIC,i._buttons=new Array(r.buttons.length),i}return Object(No.d)(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,n){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(n),this.onButtonDownObservable.notifyObservers(n)),0===e&&(this._onbuttonup&&this._onbuttonup(n),this.onButtonUpObservable.notifyObservers(n))),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t.005&&(e.inertialAlphaOffset+=n)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility*this._yAxisScale;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var i=this.gamepad.leftStick;if(i&&0!=i.y){var o=i.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},e.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},Object(No.c)([ha()],e.prototype,"gamepadRotationSensibility",void 0),Object(No.c)([ha()],e.prototype,"gamepadMoveSensibility",void 0),e}();Jl.ArcRotateCameraGamepadInput=nc;var rc=function(){function e(){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=.01,this._keys=new Array}return e.prototype.attachControl=function(e,t){var n=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){n._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(e){var r,i=e.event;i.metaKey||(e.type===Ys.KEYDOWN?(n._ctrlPressed=i.ctrlKey,n._altPressed=i.altKey,(-1!==n.keysUp.indexOf(i.keyCode)||-1!==n.keysDown.indexOf(i.keyCode)||-1!==n.keysLeft.indexOf(i.keyCode)||-1!==n.keysRight.indexOf(i.keyCode)||-1!==n.keysReset.indexOf(i.keyCode))&&(-1===(r=n._keys.indexOf(i.keyCode))&&n._keys.push(i.keyCode),i.preventDefault&&(t||i.preventDefault()))):-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)&&-1===n.keysReset.indexOf(i.keyCode)||((r=n._keys.indexOf(i.keyCode))>=0&&n._keys.splice(r,1),i.preventDefault&&(t||i.preventDefault())))})))},e.prototype.detachControl=function(e){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=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t0?n/(1+this.wheelDeltaPercentage):n*(1+this.wheelDeltaPercentage)},e.prototype.attachControl=function(e,t){var n=this;this._wheel=function(e,r){if(e.type===Qs.POINTERWHEEL){var i=e.event,o=0,a=i,s=0;if(s=a.wheelDelta?a.wheelDelta:60*-(i.deltaY||i.detail),n.wheelDeltaPercentage){if((o=n.computeDeltaFromMouseWheelLegacyEvent(s,n.camera.radius))>0){for(var l=n.camera.radius,c=n.camera.inertialRadiusOffset+o,u=0;u<20&&Math.abs(c)>.001;u++)l-=c,c*=n.camera.inertia;l=xo.Clamp(l,0,Number.MAX_VALUE),o=n.computeDeltaFromMouseWheelLegacyEvent(s,l)}}else o=s/(40*n.wheelPrecision);o&&(n.camera.inertialRadiusOffset+=o),i.preventDefault&&(t||i.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Qs.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},Object(No.c)([ha()],e.prototype,"wheelPrecision",void 0),Object(No.c)([ha()],e.prototype,"wheelDeltaPercentage",void 0),e}();Jl.ArcRotateCameraMouseWheelInput=ic;var oc=function(){function e(){this.buttons=[0,1,2]}return e.prototype.attachControl=function(e,t){var n=this,r=this.camera.getEngine(),i=0,o=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(a,s){var l=a.event,c="touch"===l.pointerType;if(!r.isInVRExclusivePointerMode&&(a.type===Qs.POINTERMOVE||-1!==n.buttons.indexOf(l.button))){var u=l.srcElement||l.target;if(n._altKey=l.altKey,n._ctrlKey=l.ctrlKey,n._metaKey=l.metaKey,n._shiftKey=l.shiftKey,n._buttonsPressed=l.buttons,r.isPointerLock){var d=l.movementX||l.mozMovementX||l.webkitMovementX||l.msMovementX||0,h=l.movementY||l.mozMovementY||l.webkitMovementY||l.msMovementY||0;n.onTouch(null,d,h),n.pointA=null,n.pointB=null}else if(a.type===Qs.POINTERDOWN&&u){try{u.setPointerCapture(l.pointerId)}catch(e){}null===n.pointA?n.pointA={x:l.clientX,y:l.clientY,pointerId:l.pointerId,type:l.pointerType}:null===n.pointB&&(n.pointB={x:l.clientX,y:l.clientY,pointerId:l.pointerId,type:l.pointerType}),n.onButtonDown(l),t||(l.preventDefault(),e.focus())}else if(a.type===Qs.POINTERDOUBLETAP)n.onDoubleTap(l.pointerType);else if(a.type===Qs.POINTERUP&&u){try{u.releasePointerCapture(l.pointerId)}catch(e){}c||(n.pointB=null),r._badOS?n.pointA=n.pointB=null:n.pointB&&n.pointA&&n.pointA.pointerId==l.pointerId?(n.pointA=n.pointB,n.pointB=null):n.pointA&&n.pointB&&n.pointB.pointerId==l.pointerId?n.pointB=null:n.pointA=n.pointB=null,(0!==i||o)&&(n.onMultiTouch(n.pointA,n.pointB,i,0,o,null),i=0,o=null),n.onButtonUp(l),t||l.preventDefault()}else if(a.type===Qs.POINTERMOVE)if(t||l.preventDefault(),n.pointA&&null===n.pointB){d=l.clientX-n.pointA.x,h=l.clientY-n.pointA.y;n.onTouch(n.pointA,d,h),n.pointA.x=l.clientX,n.pointA.y=l.clientY}else if(n.pointA&&n.pointB){var p=n.pointA.pointerId===l.pointerId?n.pointA:n.pointB;p.x=l.clientX,p.y=l.clientY;var f=n.pointA.x-n.pointB.x,m=n.pointA.y-n.pointB.y,g=f*f+m*m,b={x:(n.pointA.x+n.pointB.x)/2,y:(n.pointA.y+n.pointB.y)/2,pointerId:l.pointerId,type:a.type};n.onMultiTouch(n.pointA,n.pointB,i,g,o,b),o=b,i=g}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Qs.POINTERDOWN|Qs.POINTERUP|Qs.POINTERMOVE),this._onLostFocus=function(){n.pointA=n.pointB=null,i=0,o=null,n.onLostFocus()},e.addEventListener("contextmenu",this.onContextMenu.bind(this),!1);var a=this.camera.getScene().getEngine().getHostWindow();a&&Ja.RegisterTopRootEvents(a,[{name:"blur",handler:this._onLostFocus}])},e.prototype.detachControl=function(e){if(this._onLostFocus){var t=this.camera.getScene().getEngine().getHostWindow();t&&Ja.UnregisterTopRootEvents(t,[{name:"blur",handler:this._onLostFocus}])}e&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this.onContextMenu&&e.removeEventListener("contextmenu",this.onContextMenu),this._onLostFocus=null),this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0},e.prototype.getClassName=function(){return"BaseCameraPointersInput"},e.prototype.getSimpleName=function(){return"pointers"},e.prototype.onDoubleTap=function(e){},e.prototype.onTouch=function(e,t,n){},e.prototype.onMultiTouch=function(e,t,n,r,i,o){},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.onButtonDown=function(e){},e.prototype.onButtonUp=function(e){},e.prototype.onLostFocus=function(){},Object(No.c)([ha()],e.prototype,"buttons",void 0),e}(),ac=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.buttons=[0,1,2],t.angularSensibilityX=1e3,t.angularSensibilityY=1e3,t.pinchPrecision=12,t.pinchDeltaPercentage=0,t.useNaturalPinchZoom=!1,t.panningSensibility=1e3,t.multiTouchPanning=!0,t.multiTouchPanAndZoom=!0,t.pinchInwards=!0,t._isPanClick=!1,t._twoFingerActivityCount=0,t._isPinching=!1,t}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype.onTouch=function(e,t,n){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=n/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=n/this.angularSensibilityY)},t.prototype.onDoubleTap=function(e){this.camera.useInputToRestoreState&&this.camera.restoreState()},t.prototype.onMultiTouch=function(e,t,n,r,i,o){if(!(0===n&&null===i||0===r&&null===o)){var a=this.pinchInwards?1:-1;if(this.multiTouchPanAndZoom){if(this.useNaturalPinchZoom?this.camera.radius=this.camera.radius*Math.sqrt(n)/Math.sqrt(r):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(r-n)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(r-n)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),0!==this.panningSensibility&&i&&o){var s=o.x-i.x,l=o.y-i.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=l/this.panningSensibility}}else{this._twoFingerActivityCount++;var c=Math.sqrt(n),u=Math.sqrt(r);if(this._isPinching||this._twoFingerActivityCount<20&&Math.abs(u-c)>this.camera.pinchToPanMaxDistance)this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(r-n)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(r-n)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),this._isPinching=!0;else if(0!==this.panningSensibility&&this.multiTouchPanning&&o&&i){s=o.x-i.x,l=o.y-i.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=l/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(No.c)([ha()],t.prototype,"buttons",void 0),Object(No.c)([ha()],t.prototype,"angularSensibilityX",void 0),Object(No.c)([ha()],t.prototype,"angularSensibilityY",void 0),Object(No.c)([ha()],t.prototype,"pinchPrecision",void 0),Object(No.c)([ha()],t.prototype,"pinchDeltaPercentage",void 0),Object(No.c)([ha()],t.prototype,"useNaturalPinchZoom",void 0),Object(No.c)([ha()],t.prototype,"panningSensibility",void 0),Object(No.c)([ha()],t.prototype,"multiTouchPanning",void 0),Object(No.c)([ha()],t.prototype,"multiTouchPanAndZoom",void 0),t}(oc);Jl.ArcRotateCameraPointersInput=ac;var sc=function(e){function t(t){return e.call(this,t)||this}return Object(No.d)(t,e),t.prototype.addMouseWheel=function(){return this.add(new ic),this},t.prototype.addPointers=function(){return this.add(new ac),this},t.prototype.addKeyboard=function(){return this.add(new rc),this},t}($l);sc.prototype.addVRDeviceOrientation=function(){return this.add(new lc),this};var lc=function(){function e(){this.alphaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){var n=this;this.camera.attachControl(e,t);var r=this.camera.getScene().getEngine().getHostWindow();r&&("undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?r.addEventListener("deviceorientation",n._deviceOrientationHandler):Ja.Warn("Permission not granted.")})).catch((function(e){Ja.Error(e)})):r.addEventListener("deviceorientation",this._deviceOrientationHandler))},e.prototype._onOrientationEvent=function(e){null!==e.alpha&&(this._alpha=(0|+e.alpha)*this.alphaCorrection),null!==e.gamma&&(this._gamma=(0|+e.gamma)*this.gammaCorrection),this._dirty=!0},e.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)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e}();Jl.ArcRotateCameraVRDeviceOrientationInput=lc;var cc=function(){function e(){this.keysForward=[87],this.keysBackward=[83],this.keysUp=[69],this.keysDown=[81],this.keysRight=[68],this.keysLeft=[65],this._keys=new Array}return e.prototype.attachControl=function(e,t){var n=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){n._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(e){var r,i=e.event;e.type===Ys.KEYDOWN?-1===n.keysForward.indexOf(i.keyCode)&&-1===n.keysBackward.indexOf(i.keyCode)&&-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||(-1===(r=n._keys.indexOf(i.keyCode))&&n._keys.push(i.keyCode),t||i.preventDefault()):-1===n.keysForward.indexOf(i.keyCode)&&-1===n.keysBackward.indexOf(i.keyCode)&&-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||((r=n._keys.indexOf(i.keyCode))>=0&&n._keys.splice(r,1),t||i.preventDefault())})))},e.prototype.detachControl=function(e){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=[]},e.prototype.getClassName=function(){return"FlyCameraKeyboardInput"},e.prototype._onLostFocus=function(e){this._keys=[]},e.prototype.getSimpleName=function(){return"keyboard"},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t=0&&n._keys.splice(r,1),i.preventDefault&&(t||i.preventDefault())))})))},e.prototype.detachControl=function(e){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=[]},e.prototype.checkInputs=function(){var e=this;this._onKeyboardObserver&&this._keys.forEach((function(t){-1!==e.keysHeightOffsetIncr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset+=e.heightSensibility:-1!==e.keysHeightOffsetDecr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset-=e.heightSensibility:-1!==e.keysRotationOffsetIncr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset+=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRotationOffsetDecr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset-=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRadiusIncr.indexOf(t)&&e._modifierRadius()?e.camera.radius+=e.radiusSensibility:-1!==e.keysRadiusDecr.indexOf(t)&&e._modifierRadius()&&(e.camera.radius-=e.radiusSensibility)}))},e.prototype.getClassName=function(){return"FollowCameraKeyboardMoveInput"},e.prototype.getSimpleName=function(){return"keyboard"},e.prototype._modifierHeightOffset=function(){return this.keysHeightOffsetModifierAlt===this._altPressed&&this.keysHeightOffsetModifierCtrl===this._ctrlPressed&&this.keysHeightOffsetModifierShift===this._shiftPressed},e.prototype._modifierRotationOffset=function(){return this.keysRotationOffsetModifierAlt===this._altPressed&&this.keysRotationOffsetModifierCtrl===this._ctrlPressed&&this.keysRotationOffsetModifierShift===this._shiftPressed},e.prototype._modifierRadius=function(){return this.keysRadiusModifierAlt===this._altPressed&&this.keysRadiusModifierCtrl===this._ctrlPressed&&this.keysRadiusModifierShift===this._shiftPressed},Object(No.c)([ha()],e.prototype,"keysHeightOffsetIncr",void 0),Object(No.c)([ha()],e.prototype,"keysHeightOffsetDecr",void 0),Object(No.c)([ha()],e.prototype,"keysHeightOffsetModifierAlt",void 0),Object(No.c)([ha()],e.prototype,"keysHeightOffsetModifierCtrl",void 0),Object(No.c)([ha()],e.prototype,"keysHeightOffsetModifierShift",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetIncr",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetDecr",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetModifierAlt",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetModifierCtrl",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetModifierShift",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusIncr",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusDecr",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusModifierAlt",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusModifierCtrl",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusModifierShift",void 0),Object(No.c)([ha()],e.prototype,"heightSensibility",void 0),Object(No.c)([ha()],e.prototype,"rotationSensibility",void 0),Object(No.c)([ha()],e.prototype,"radiusSensibility",void 0),e}();Jl.FollowCameraKeyboardMoveInput=dc;var hc=function(){function e(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e,t){var n=this;this._wheel=function(e,r){if(e.type===Qs.POINTERWHEEL){var i=e.event,o=0,a=Math.max(-1,Math.min(1,i.deltaY||i.wheelDelta||-i.detail));n.wheelDeltaPercentage?(console.assert(n.axisControlRadius+n.axisControlHeight+n.axisControlRotation<=1,"wheelDeltaPercentage only usable when mouse wheel controlls ONE axis. Currently enabled: axisControlRadius: "+n.axisControlRadius+", axisControlHeightOffset: "+n.axisControlHeight+", axisControlRotationOffset: "+n.axisControlRotation),n.axisControlRadius?o=.01*a*n.wheelDeltaPercentage*n.camera.radius:n.axisControlHeight?o=.01*a*n.wheelDeltaPercentage*n.camera.heightOffset:n.axisControlRotation&&(o=.01*a*n.wheelDeltaPercentage*n.camera.rotationOffset)):o=a*n.wheelPrecision,o&&(n.axisControlRadius?n.camera.radius+=o:n.axisControlHeight?n.camera.heightOffset-=o:n.axisControlRotation&&(n.camera.rotationOffset-=o)),i.preventDefault&&(t||i.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Qs.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},Object(No.c)([ha()],e.prototype,"axisControlRadius",void 0),Object(No.c)([ha()],e.prototype,"axisControlHeight",void 0),Object(No.c)([ha()],e.prototype,"axisControlRotation",void 0),Object(No.c)([ha()],e.prototype,"wheelPrecision",void 0),Object(No.c)([ha()],e.prototype,"wheelDeltaPercentage",void 0),e}();Jl.FollowCameraMouseWheelInput=hc;var pc=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.angularSensibilityX=1,t.angularSensibilityY=1,t.pinchPrecision=1e4,t.pinchDeltaPercentage=0,t.axisXControlRadius=!1,t.axisXControlHeight=!1,t.axisXControlRotation=!0,t.axisYControlRadius=!1,t.axisYControlHeight=!0,t.axisYControlRotation=!1,t.axisPinchControlRadius=!0,t.axisPinchControlHeight=!1,t.axisPinchControlRotation=!1,t.warningEnable=!0,t._warningCounter=0,t}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"FollowCameraPointersInput"},t.prototype.onTouch=function(e,t,n){this._warning(),this.axisXControlRotation?this.camera.rotationOffset+=t/this.angularSensibilityX:this.axisYControlRotation&&(this.camera.rotationOffset+=n/this.angularSensibilityX),this.axisXControlHeight?this.camera.heightOffset+=t/this.angularSensibilityY:this.axisYControlHeight&&(this.camera.heightOffset+=n/this.angularSensibilityY),this.axisXControlRadius?this.camera.radius-=t/this.angularSensibilityY:this.axisYControlRadius&&(this.camera.radius-=n/this.angularSensibilityY)},t.prototype.onMultiTouch=function(e,t,n,r,i,o){if(!(0===n&&null===i||0===r&&null===o)){var a=(r-n)/(this.pinchPrecision*(this.angularSensibilityX+this.angularSensibilityY)/2);this.pinchDeltaPercentage?(a*=.01*this.pinchDeltaPercentage,this.axisPinchControlRotation&&(this.camera.rotationOffset+=a*this.camera.rotationOffset),this.axisPinchControlHeight&&(this.camera.heightOffset+=a*this.camera.heightOffset),this.axisPinchControlRadius&&(this.camera.radius-=a*this.camera.radius)):(this.axisPinchControlRotation&&(this.camera.rotationOffset+=a),this.axisPinchControlHeight&&(this.camera.heightOffset+=a),this.axisPinchControlRadius&&(this.camera.radius-=a))}},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(No.c)([ha()],t.prototype,"angularSensibilityX",void 0),Object(No.c)([ha()],t.prototype,"angularSensibilityY",void 0),Object(No.c)([ha()],t.prototype,"pinchPrecision",void 0),Object(No.c)([ha()],t.prototype,"pinchDeltaPercentage",void 0),Object(No.c)([ha()],t.prototype,"axisXControlRadius",void 0),Object(No.c)([ha()],t.prototype,"axisXControlHeight",void 0),Object(No.c)([ha()],t.prototype,"axisXControlRotation",void 0),Object(No.c)([ha()],t.prototype,"axisYControlRadius",void 0),Object(No.c)([ha()],t.prototype,"axisYControlHeight",void 0),Object(No.c)([ha()],t.prototype,"axisYControlRotation",void 0),Object(No.c)([ha()],t.prototype,"axisPinchControlRadius",void 0),Object(No.c)([ha()],t.prototype,"axisPinchControlHeight",void 0),Object(No.c)([ha()],t.prototype,"axisPinchControlRotation",void 0),t}(oc);Jl.FollowCameraPointersInput=pc;var fc=function(){function e(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this._keys=new Array}return e.prototype.attachControl=function(e,t){var n=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){n._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(e){var r,i=e.event;i.metaKey||(e.type===Ys.KEYDOWN?-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||(-1===(r=n._keys.indexOf(i.keyCode))&&n._keys.push(i.keyCode),t||i.preventDefault()):-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||((r=n._keys.indexOf(i.keyCode))>=0&&n._keys.splice(r,1),t||i.preventDefault()))})))},e.prototype.detachControl=function(e){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=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t1)e.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var t=e._computeLocalCameraSpeed(),n=new So(0,0,t*this._offsetY/this.touchMoveSensibility);Oo.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(So.TransformCoordinates(n,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},Object(No.c)([ha()],e.prototype,"touchAngularSensibility",void 0),Object(No.c)([ha()],e.prototype,"touchMoveSensibility",void 0),e}();Jl.FreeCameraTouchInput=gc;var bc=function(e){function t(t){var n=e.call(this,t)||this;return n._mouseInput=null,n}return Object(No.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new fc),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this._mouseInput||(this._mouseInput=new mc(e),this.add(this._mouseInput)),this},t.prototype.removeMouse=function(){return this._mouseInput&&this.remove(this._mouseInput),this},t.prototype.addTouch=function(){return this.add(new gc),this},t.prototype.clear=function(){e.prototype.clear.call(this),this._mouseInput=null},t}($l);bc.prototype.addDeviceOrientation=function(){return this._deviceOrientationInput||(this._deviceOrientationInput=new vc,this.add(this._deviceOrientationInput)),this};var vc=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new Po,this._alpha=0,this._beta=0,this._gamma=0,this._onDeviceOrientationChangedObservable=new yo.a,this._orientationChanged=function(){e._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,e._screenOrientationAngle=-Ja.ToRadians(e._screenOrientationAngle/2),e._screenQuaternion.copyFromFloats(0,Math.sin(e._screenOrientationAngle),0,Math.cos(e._screenOrientationAngle))},this._deviceOrientation=function(t){e._alpha=null!==t.alpha?t.alpha:0,e._beta=null!==t.beta?t.beta:0,e._gamma=null!==t.gamma?t.gamma:0,null!==t.alpha&&e._onDeviceOrientationChangedObservable.notifyObservers()},this._constantTranform=new Po(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return e.WaitForOrientationChangeAsync=function(e){return new Promise((function(t,n){var r=!1,i=function(){window.removeEventListener("deviceorientation",i),r=!0,t()};e&&setTimeout((function(){r||(window.removeEventListener("deviceorientation",i),n("WaitForOrientationChangeAsync timed out"))}),e),"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e?window.addEventListener("deviceorientation",i):Ja.Warn("Permission not granted.")})).catch((function(e){Ja.Error(e)})):window.addEventListener("deviceorientation",i)}))},Object.defineProperty(e.prototype,"camera",{get:function(){return this._camera},set:function(e){var t=this;this._camera=e,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new Po),this._camera&&this._camera.onDisposeObservable.add((function(){t._onDeviceOrientationChangedObservable.clear()}))},enumerable:!0,configurable:!0}),e.prototype.attachControl=function(e,t){var n=this,r=this.camera.getScene().getEngine().getHostWindow();if(r){var i=function(){r.addEventListener("orientationchange",n._orientationChanged),r.addEventListener("deviceorientation",n._deviceOrientation),n._orientationChanged()};"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?i():Ja.Warn("Permission not granted.")})).catch((function(e){Ja.Error(e)})):i()}},e.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation),this._alpha=0},e.prototype.checkInputs=function(){this._alpha&&(Po.RotationYawPitchRollToRef(Ja.ToRadians(this._alpha),Ja.ToRadians(this._beta),-Ja.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)},e.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"deviceOrientation"},e}();Jl.FreeCameraDeviceOrientationInput=vc;var Ac,_c=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._yAxisScale=1,this._cameraTransform=Oo.Identity(),this._deltaTransform=So.Zero(),this._vector3=So.Zero(),this._vector2=Co.Zero()}return Object.defineProperty(e.prototype,"invertYAxis",{get:function(){return 1!==this._yAxisScale},set:function(e){this._yAxisScale=e?-1:1},enumerable:!0,configurable:!0}),e.prototype.attachControl=function(e,t){var n=this,r=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=r.onGamepadConnectedObservable.add((function(e){e.type!==ec.POSE_ENABLED&&(n.gamepad&&e.type!==ec.XBOX||(n.gamepad=e))})),this._onGamepadDisconnectedObserver=r.onGamepadDisconnectedObservable.add((function(e){n.gamepad===e&&(n.gamepad=null)})),this.gamepad=r.getGamepadByType(ec.XBOX)},e.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var e=this.camera,t=this.gamepad.leftStick,n=t.x/this.gamepadMoveSensibility,r=t.y/this.gamepadMoveSensibility;t.x=Math.abs(n)>.005?0+n:0,t.y=Math.abs(r)>.005?0+r:0;var i=this.gamepad.rightStick;if(i){var o=i.x/this.gamepadAngularSensibility,a=i.y/this.gamepadAngularSensibility*this._yAxisScale;i.x=Math.abs(o)>.001?0+o:0,i.y=Math.abs(a)>.001?0+a:0}else i={x:0,y:0};e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):Oo.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var s=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*s,0,-t.y*s),So.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(i.y,i.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},Object(No.c)([ha()],e.prototype,"gamepadAngularSensibility",void 0),Object(No.c)([ha()],e.prototype,"gamepadMoveSensibility",void 0),e}();Jl.FreeCameraGamepadInput=_c,function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(Ac||(Ac={}));var yc=function(){function e(t){var n=this;if(this._leftJoystick=!!t,e._globalJoystickIndex++,this._axisTargetedByLeftAndRight=Ac.X,this._axisTargetedByUpAndDown=Ac.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new is,this.deltaPosition=So.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(t){e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas&&(e.Canvas.width=e.vjCanvasWidth,e.Canvas.height=e.vjCanvasHeight),e.halfWidth=e.vjCanvasWidth/2},!e.Canvas){window.addEventListener("resize",this._onResize,!1),e.Canvas=document.createElement("canvas"),e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas.width=window.innerWidth,e.Canvas.height=window.innerHeight,e.Canvas.style.width="100%",e.Canvas.style.height="100%",e.Canvas.style.position="absolute",e.Canvas.style.backgroundColor="transparent",e.Canvas.style.top="0px",e.Canvas.style.left="0px",e.Canvas.style.zIndex="5",e.Canvas.style.msTouchAction="none",e.Canvas.setAttribute("touch-action","none");var r=e.Canvas.getContext("2d");if(!r)throw new Error("Unable to create canvas for virtual joystick");e.vjCanvasContext=r,e.vjCanvasContext.strokeStyle="#ffffff",e.vjCanvasContext.lineWidth=2,document.body.appendChild(e.Canvas)}e.halfWidth=e.Canvas.width/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new Co(0,0),this._joystickPreviousPointerPos=new Co(0,0),this._joystickPointerStartPos=new Co(0,0),this._deltaJoystickVector=new Co(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){n._onPointerUp(e)},e.Canvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),e.Canvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),e.Canvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("contextmenu",(function(e){e.preventDefault()}),!1),requestAnimationFrame((function(){n._drawVirtualJoystick()}))}return e.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},e.prototype._onPointerDown=function(t){t.preventDefault(),(!0===this._leftJoystick?t.clientXe.halfWidth)&&this._joystickPointerID<0?(this._joystickPointerID=t.pointerId,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)):e._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(t.pointerId.toString(),{x:t.clientX,y:t.clientY,prevX:t.clientX,prevY:t.clientY}))},e.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var t=(this.reverseLeftRight?-1:1)*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case Ac.X:this.deltaPosition.x=Math.min(1,Math.max(-1,t));break;case Ac.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,t));break;case Ac.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,t))}var n=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case Ac.X:this.deltaPosition.x=Math.min(1,Math.max(-1,n));break;case Ac.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,n));break;case Ac.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,n))}}else{var r=this._touches.get(e.pointerId.toString());r&&(r.x=e.clientX,r.y=e.clientY)}},e.prototype._onPointerUp=function(t){if(this._joystickPointerID==t.pointerId)e.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),e.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var n=this._touches.get(t.pointerId.toString());n&&e.vjCanvasContext.clearRect(n.prevX-44,n.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(t.pointerId.toString())},e.prototype.setJoystickColor=function(e){this._joystickColor=e},e.prototype.setActionOnTouch=function(e){this._action=e},e.prototype.setAxisForLeftRight=function(e){switch(e){case Ac.X:case Ac.Y:case Ac.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=Ac.X}},e.prototype.setAxisForUpDown=function(e){switch(e){case Ac.X:case Ac.Y:case Ac.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=Ac.Y}},e.prototype._drawVirtualJoystick=function(){var t=this;this.pressed&&this._touches.forEach((function(n,r){r.pointerId===t._joystickPointerID?(e.vjCanvasContext.clearRect(t._joystickPointerStartPos.x-64,t._joystickPointerStartPos.y-64,128,128),e.vjCanvasContext.clearRect(t._joystickPreviousPointerPos.x-42,t._joystickPreviousPointerPos.y-42,84,84),e.vjCanvasContext.beginPath(),e.vjCanvasContext.lineWidth=6,e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.arc(t._joystickPointerStartPos.x,t._joystickPointerStartPos.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.lineWidth=2,e.vjCanvasContext.arc(t._joystickPointerStartPos.x,t._joystickPointerStartPos.y,60,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.arc(t._joystickPointerPos.x,t._joystickPointerPos.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),t._joystickPreviousPointerPos=t._joystickPointerPos.clone()):(e.vjCanvasContext.clearRect(r.prevX-44,r.prevY-44,88,88),e.vjCanvasContext.beginPath(),e.vjCanvasContext.fillStyle="white",e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle="red",e.vjCanvasContext.lineWidth=6,e.vjCanvasContext.arc(r.x,r.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.y)})),requestAnimationFrame((function(){t._drawVirtualJoystick()}))},e.prototype.releaseCanvas=function(){e.Canvas&&(e.Canvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),e.Canvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),e.Canvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),e.Canvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(e.Canvas),e.Canvas=null)},e._globalJoystickIndex=0,e}();bc.prototype.addVirtualJoystick=function(){return this.add(new xc),this};var xc=function(){function e(){}return e.prototype.getLeftJoystick=function(){return this._leftjoystick},e.prototype.getRightJoystick=function(){return this._rightjoystick},e.prototype.checkInputs=function(){if(this._leftjoystick){var e=this.camera,t=50*e._computeLocalCameraSpeed(),n=Oo.RotationYawPitchRoll(e.rotation.y,e.rotation.x,0),r=So.TransformCoordinates(new So(this._leftjoystick.deltaPosition.x*t,this._leftjoystick.deltaPosition.y*t,this._leftjoystick.deltaPosition.z*t),n);e.cameraDirection=e.cameraDirection.add(r),e.cameraRotation=e.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},e.prototype.attachControl=function(e,t){this._leftjoystick=new yc(!0),this._leftjoystick.setAxisForUpDown(Ac.Z),this._leftjoystick.setAxisForLeftRight(Ac.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new yc(!1),this._rightjoystick.setAxisForUpDown(Ac.X),this._rightjoystick.setAxisForLeftRight(Ac.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},e.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},e.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},e.prototype.getSimpleName=function(){return"virtualJoystick"},e}();Jl.FreeCameraVirtualJoystickInput=xc;var wc=function(e){function t(t,n,r,i){void 0===i&&(i=!0);var o=e.call(this,t,n,r,i)||this;return o.cameraDirection=new So(0,0,0),o.cameraRotation=new Co(0,0),o.updateUpVectorFromRotation=!1,o._tmpQuaternion=new Po,o.rotation=new So(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=So.Zero(),o._initialFocalDistance=1,o._viewMatrix=Oo.Zero(),o._camMatrix=Oo.Zero(),o._cameraTransformMatrix=Oo.Zero(),o._cameraRotationMatrix=Oo.Zero(),o._referencePoint=new So(0,0,1),o._transformedReferencePoint=So.Zero(),o._globalCurrentTarget=So.Zero(),o._globalCurrentUpVector=So.Zero(),o._defaultUp=So.Up(),o._cachedRotationZ=0,o._cachedQuaternionRotationZ=0,o}return Object(No.d)(t,e),t.prototype.getFrontPosition=function(e){this.getWorldMatrix();var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},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()),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.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(){e.prototype._initCache.call(this),this._cache.lockedTarget=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new Po(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},t.prototype._updateCache=function(t){t||e.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(!e.prototype._isSynchronizedViewMatrix.call(this))return!1;var t=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(t):!t)&&(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+=.001),Oo.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 t=e.subtract(this.position);t.x>=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.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&&Po.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},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(Mo.Matrix[0]),So.TransformNormalToRef(this.cameraDirection,Mo.Matrix[0],Mo.Vector3[0]),void this.position.addInPlace(Mo.Vector3[0]);this.position.addInPlace(this.cameraDirection)},t.prototype._checkInputs=function(){var t=this._decideIfNeedsToMove(),n=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(t&&this._updatePosition(),n){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion)this.rotation.lengthSquared()&&Po.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion);if(!this.noRotationConstraint){this.rotation.x>1.570796&&(this.rotation.x=1.570796),this.rotation.x<-1.570796&&(this.rotation.x=-1.570796)}}t&&(Math.abs(this.cameraDirection.x)<.001*this.speed&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<.001*this.speed&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<.001*this.speed&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),n&&(Math.abs(this.cameraRotation.x)<.001*this.speed&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<.001*this.speed&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),e.prototype._checkInputs.call(this)},t.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):Oo.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},t.prototype._rotateUpVectorWithCameraRotationMatrix=function(){return So.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),So.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?os.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(Po.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),os.Y.rotateByQuaternionToRef(this._tmpQuaternion,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix},t.prototype._computeViewMatrix=function(e,t,n){if(this.parent){var r=this.parent.getWorldMatrix();So.TransformCoordinatesToRef(e,r,this._globalPosition),So.TransformCoordinatesToRef(t,r,this._globalCurrentTarget),So.TransformNormalToRef(n,r,this._globalCurrentUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._globalCurrentTarget.copyFrom(t),this._globalCurrentUpVector.copyFrom(n);this.getScene().useRightHandedSystem?Oo.LookAtRHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix):Oo.LookAtLHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix)},t.prototype.createRigCamera=function(e,n){if(this.cameraRigMode!==Ts.RIG_MODE_NONE){var r=new t(e,this.position.clone(),this.getScene());return r.isRigCamera=!0,r.rigParent=this,this.cameraRigMode!==Ts.RIG_MODE_VR&&this.cameraRigMode!==Ts.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new Po),r._cameraRigParams={},r.rotationQuaternion=new Po),r}return null},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],n=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ts.RIG_MODE_STEREOSCOPIC_INTERLACED:var r=this.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,i=this.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*r,t),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*i,n);break;case Ts.RIG_MODE_VR:t.rotationQuaternion?(t.rotationQuaternion.copyFrom(this.rotationQuaternion),n.rotationQuaternion.copyFrom(this.rotationQuaternion)):(t.rotation.copyFrom(this.rotation),n.rotation.copyFrom(this.rotation)),t.position.copyFrom(this.position),n.position.copyFrom(this.position)}e.prototype._updateRigCameras.call(this)},t.prototype._getRigCamPositionAndTarget=function(e,n){this.getTarget().subtractToRef(this.position,t._TargetFocalPoint),t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);var r=t._TargetFocalPoint.addInPlace(this.position);Oo.TranslationToRef(-r.x,-r.y,-r.z,t._TargetTransformMatrix),t._TargetTransformMatrix.multiplyToRef(Oo.RotationY(e),t._RigCamTransformMatrix),Oo.TranslationToRef(r.x,r.y,r.z,t._TargetTransformMatrix),t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix,t._RigCamTransformMatrix),So.TransformCoordinatesToRef(this.position,t._RigCamTransformMatrix,n.position),n.setTarget(r)},t.prototype.getClassName=function(){return"TargetCamera"},t._RigCamTransformMatrix=new Oo,t._TargetTransformMatrix=new Oo,t._TargetFocalPoint=new So,Object(No.c)([ga()],t.prototype,"rotation",void 0),Object(No.c)([ha()],t.prototype,"speed",void 0),Object(No.c)([ba("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(Ts),Ec=function(e){function t(t,n,r,i){void 0===i&&(i=!0);var o=e.call(this,t,n,r,i)||this;return o.ellipsoid=new So(.5,1,.5),o.ellipsoidOffset=new So(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o._needMoveForGravity=!1,o._oldPosition=So.Zero(),o._diffPosition=So.Zero(),o._newPosition=So.Zero(),o._collisionMask=-1,o._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null);var r;r=t,o._newPosition.copyFrom(r),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>ss.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&n&&o.onCollide(n))},o.inputs=new bc(o),o.inputs.addKeyboard().addMouse(),o}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this.cameraDirection=new So(0,0,0),this.cameraRotation=new Co(0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?So.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var n=e;this.applyGravity&&(n=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,n,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=So.Zero(),this._transformedDirection=So.Zero()),this.inputs.checkInputs(),e.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):e.prototype._updatePosition.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FreeCamera"},Object(No.c)([ga()],t.prototype,"ellipsoid",void 0),Object(No.c)([ga()],t.prototype,"ellipsoidOffset",void 0),Object(No.c)([ha()],t.prototype,"checkCollisions",void 0),Object(No.c)([ha()],t.prototype,"applyGravity",void 0),t}(wc);wa.AddNodeConstructor("TouchCamera",(function(e,t){return function(){return new Cc(e,So.Zero(),t)}}));var Cc=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i.inputs.addTouch(),i._setupInputs(),i}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t}(Ec);wa.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new Sc(e,0,0,1,So.Zero(),t)}}));var Sc=function(e){function t(t,n,r,i,o,a,s){void 0===s&&(s=!0);var l=e.call(this,t,So.Zero(),a,s)||this;return l._upVector=So.Up(),l.inertialAlphaOffset=0,l.inertialBetaOffset=0,l.inertialRadiusOffset=0,l.lowerAlphaLimit=null,l.upperAlphaLimit=null,l.lowerBetaLimit=.01,l.upperBetaLimit=Math.PI-.01,l.lowerRadiusLimit=null,l.upperRadiusLimit=null,l.inertialPanningX=0,l.inertialPanningY=0,l.pinchToPanMaxDistance=20,l.panningDistanceLimit=null,l.panningOriginTarget=So.Zero(),l.panningInertia=.9,l.zoomOnFactor=1,l.targetScreenOffset=Co.Zero(),l.allowUpsideDown=!0,l.useInputToRestoreState=!0,l._viewMatrix=new Oo,l.panningAxis=new So(1,1,0),l.onMeshTargetChangedObservable=new yo.a,l.checkCollisions=!1,l.collisionRadius=new So(.5,.5,.5),l._previousPosition=So.Zero(),l._collisionVelocity=So.Zero(),l._newPosition=So.Zero(),l._computationVector=So.Zero(),l._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null),n?(l.setPosition(t),l.onCollide&&l.onCollide(n)):l._previousPosition.copyFrom(l._position);var r=Math.cos(l.alpha),i=Math.sin(l.alpha),o=Math.cos(l.beta),a=Math.sin(l.beta);0===a&&(a=1e-4);var s=l._getTargetPosition();l._computationVector.copyFromFloats(l.radius*r*a,l.radius*o,l.radius*i*a),s.addToRef(l._computationVector,l._newPosition),l._position.copyFrom(l._newPosition);var c=l.upVector;l.allowUpsideDown&&l.beta<0&&(c=(c=c.clone()).negate()),l._computeViewMatrix(l._position,s,c),l._viewMatrix.addAtIndex(12,l.targetScreenOffset.x),l._viewMatrix.addAtIndex(13,l.targetScreenOffset.y),l._collisionTriggered=!1},l._target=So.Zero(),o&&l.setTarget(o),l.alpha=n,l.beta=r,l.radius=i,l.getViewMatrix(),l.inputs=new sc(l),l.inputs.addKeyboard().addMouseWheel().addPointers(),l}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this.setPosition(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upToYMatrix||(this._YToUpMatrix=new Oo,this._upToYMatrix=new Oo,this._upVector=So.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!0,configurable:!0}),t.prototype.setMatUp=function(){Oo.RotationAlignToRef(So.UpReadOnly,this._upVector,this._YToUpMatrix),Oo.RotationAlignToRef(this._upVector,So.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 t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pinchDeltaPercentage",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useNaturalPinchZoom",{get:function(){var e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom},set:function(e){var t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wheelDeltaPercentage",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new Nl,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new Ll,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new Fl,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!0,configurable:!0}),t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache._target=new So(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=Co.Zero()},t.prototype._updateCache=function(t){t||e.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 t=this._getLockedTargetPosition();return t||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(),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.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!!e.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,t,n,r){var i=this;void 0===n&&(n=!0),void 0===r&&(r=2),this._useCtrlForPanning=n,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){i.inertialAlphaOffset=0,i.inertialBetaOffset=0,i.inertialRadiusOffset=0,i.inertialPanningX=0,i.inertialPanningY=0}},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},t.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){var t=this.inertialAlphaOffset;this.beta<=0&&(t*=-1),this.getScene().useRightHandedSystem&&(t*=-1),this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(t*=-1),this.alpha+=t,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<.001&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<.001&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<.001*this.speed&&(this.inertialRadiusOffset=0)}if(0!==this.inertialPanningX||0!==this.inertialPanningY){if(this._localDirection||(this._localDirection=So.Zero(),this._transformedDirection=So.Zero()),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),So.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),So.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else this._target.addInPlace(this._transformedDirection);this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<.001*this.speed&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<.001*this.speed&&(this.inertialPanningY=0)}this._checkLimits(),e.prototype._checkInputs.call(this)}},t.prototype._checkLimits=function(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)},t.prototype.rebuildAnglesAndRadius=function(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||So.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4),0===this._computationVector.x&&0===this._computationVector.z?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),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,t,n){if(void 0===t&&(t=!1),void 0===n&&(n=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var r=e,i=this._getTargetPosition();if(i&&!n&&i.equals(r))return;this._targetHost=null,this._target=r,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}this.rebuildAnglesAndRadius()},t.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),t=Math.sin(this.alpha),n=Math.cos(this.beta),r=Math.sin(this.beta);0===r&&(r=1e-4);var i=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*r,this.radius*n,this.radius*t*r),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||So.TransformCoordinatesToRef(this._computationVector,this._YToUpMatrix,this._computationVector),i.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){var o=this.getScene().collisionCoordinator;this._collider||(this._collider=o.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,o.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);var a=this.upVector;this.allowUpsideDown&&r<0&&(a=a.negate()),this._computeViewMatrix(this._position,i,a),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=i,this._viewMatrix},t.prototype.zoomOn=function(e,t){void 0===t&&(t=!1),e=e||this.getScene().meshes;var n=Pl.MinMax(e),r=So.Distance(n.min,n.max);this.radius=r*this.zoomOnFactor,this.focusOn({min:n.min,max:n.max,distance:r},t)},t.prototype.focusOn=function(e,t){var n,r;if(void 0===t&&(t=!1),void 0===e.min){var i=e||this.getScene().meshes;n=Pl.MinMax(i),r=So.Distance(n.min,n.max)}else{n=e,r=e.distance}this._target=Pl.Center(n),t||(this.maxZ=2*r)},t.prototype.createRigCamera=function(e,n){var r=0;switch(this.cameraRigMode){case Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ts.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ts.RIG_MODE_VR:r=this._cameraRigParams.stereoHalfAngle*(0===n?1:-1);break;case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:r=this._cameraRigParams.stereoHalfAngle*(0===n?-1:1)}var i=new t(e,this.alpha+r,this.beta,this.radius,this._target,this.getScene());return i._cameraRigParams={},i.isRigCamera=!0,i.rigParent=this,i},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],n=this._rigCameras[1];switch(t.beta=n.beta=this.beta,this.cameraRigMode){case Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ts.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ts.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,n.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,n.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}e.prototype._updateRigCameras.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"ArcRotateCamera"},Object(No.c)([ha()],t.prototype,"alpha",void 0),Object(No.c)([ha()],t.prototype,"beta",void 0),Object(No.c)([ha()],t.prototype,"radius",void 0),Object(No.c)([ga("target")],t.prototype,"_target",void 0),Object(No.c)([ga("upVector")],t.prototype,"_upVector",void 0),Object(No.c)([ha()],t.prototype,"inertialAlphaOffset",void 0),Object(No.c)([ha()],t.prototype,"inertialBetaOffset",void 0),Object(No.c)([ha()],t.prototype,"inertialRadiusOffset",void 0),Object(No.c)([ha()],t.prototype,"lowerAlphaLimit",void 0),Object(No.c)([ha()],t.prototype,"upperAlphaLimit",void 0),Object(No.c)([ha()],t.prototype,"lowerBetaLimit",void 0),Object(No.c)([ha()],t.prototype,"upperBetaLimit",void 0),Object(No.c)([ha()],t.prototype,"lowerRadiusLimit",void 0),Object(No.c)([ha()],t.prototype,"upperRadiusLimit",void 0),Object(No.c)([ha()],t.prototype,"inertialPanningX",void 0),Object(No.c)([ha()],t.prototype,"inertialPanningY",void 0),Object(No.c)([ha()],t.prototype,"pinchToPanMaxDistance",void 0),Object(No.c)([ha()],t.prototype,"panningDistanceLimit",void 0),Object(No.c)([ga()],t.prototype,"panningOriginTarget",void 0),Object(No.c)([ha()],t.prototype,"panningInertia",void 0),Object(No.c)([ha()],t.prototype,"zoomOnFactor",void 0),Object(No.c)([ha()],t.prototype,"targetScreenOffset",void 0),Object(No.c)([ha()],t.prototype,"allowUpsideDown",void 0),Object(No.c)([ha()],t.prototype,"useInputToRestoreState",void 0),t}(wc);wa.AddNodeConstructor("DeviceOrientationCamera",(function(e,t){return function(){return new Tc(e,So.Zero(),t)}}));var Tc=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i._tmpDragQuaternion=new Po,i._disablePointerInputWhenUsingDeviceOrientation=!0,i._dragFactor=0,i._quaternionCache=new Po,i.inputs.addDeviceOrientation(),i.inputs._deviceOrientationInput&&i.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce((function(){i._disablePointerInputWhenUsingDeviceOrientation&&i.inputs._mouseInput&&(i.inputs._mouseInput._allowCameraRotation=!1,i.inputs._mouseInput.onPointerMovedObservable.add((function(e){0!=i._dragFactor&&(i._initialQuaternion||(i._initialQuaternion=new Po),Po.FromEulerAnglesToRef(0,e.offsetX*i._dragFactor,0,i._tmpDragQuaternion),i._initialQuaternion.multiplyToRef(i._tmpDragQuaternion,i._initialQuaternion))})))})),i}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"disablePointerInputWhenUsingDeviceOrientation",{get:function(){return this._disablePointerInputWhenUsingDeviceOrientation},set:function(e){this._disablePointerInputWhenUsingDeviceOrientation=e},enumerable:!0,configurable:!0}),t.prototype.enableHorizontalDragging=function(e){void 0===e&&(e=1/300),this._dragFactor=e},t.prototype.getClassName=function(){return"DeviceOrientationCamera"},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._quaternionCache.copyFrom(this.rotationQuaternion),this._initialQuaternion&&this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)},t.prototype.resetToCurrentRotation=function(e){var t=this;void 0===e&&(e=os.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new Po),this._initialQuaternion.copyFrom(this._quaternionCache||this.rotationQuaternion),["x","y","z"].forEach((function(n){e[n]?t._initialQuaternion[n]*=-1:t._initialQuaternion[n]=0})),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},t}(Ec),Pc=function(e){function t(t){return e.call(this,t)||this}return Object(No.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new cc),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new uc(e)),this},t}($l),Oc=(function(e){function t(t,n,r,i){void 0===i&&(i=!0);var o=e.call(this,t,n,r,i)||this;return o.ellipsoid=new So(1,1,1),o.ellipsoidOffset=new So(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o.cameraDirection=So.Zero(),o._trackRoll=0,o.rollCorrect=100,o.bankedTurn=!1,o.bankedTurnLimit=Math.PI/2,o.bankedTurnMultiplier=1,o._needMoveForGravity=!1,o._oldPosition=So.Zero(),o._diffPosition=So.Zero(),o._newPosition=So.Zero(),o._collisionMask=-1,o._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null);var r;r=t,o._newPosition.copyFrom(r),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>ss.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&n&&o.onCollide(n))},o.inputs=new Pc(o),o.inputs.addKeyboard().addMouse(),o}Object(No.d)(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysForward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysForward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysForward=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysBackward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysBackward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysBackward=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this.cameraDirection=new So(0,0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?So.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var n=e;this.applyGravity&&(n=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,n,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=So.Zero(),this._transformedDirection=So.Zero()),this.inputs.checkInputs(),e.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):e.prototype._updatePosition.call(this)},t.prototype.restoreRoll=function(e){var t=this._trackRoll,n=t-this.rotation.z;Math.abs(n)>=.001&&(this.rotation.z+=n/e,Math.abs(t-this.rotation.z)<=.001&&(this.rotation.z=t))},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FlyCamera"},Object(No.c)([ga()],t.prototype,"ellipsoid",void 0),Object(No.c)([ga()],t.prototype,"ellipsoidOffset",void 0),Object(No.c)([ha()],t.prototype,"checkCollisions",void 0),Object(No.c)([ha()],t.prototype,"applyGravity",void 0)}(wc),function(e){function t(t){return e.call(this,t)||this}return Object(No.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new dc),this},t.prototype.addMouseWheel=function(){return this.add(new hc),this},t.prototype.addPointers=function(){return this.add(new pc),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}($l));wa.AddNodeConstructor("FollowCamera",(function(e,t){return function(){return new Mc(e,So.Zero(),t)}})),wa.AddNodeConstructor("ArcFollowCamera",(function(e,t){return function(){return new Ic(e,0,0,1,null,t)}}));var Rc,Mc=function(e){function t(t,n,r,i){void 0===i&&(i=null);var o=e.call(this,t,n,r)||this;return o.radius=12,o.lowerRadiusLimit=null,o.upperRadiusLimit=null,o.rotationOffset=0,o.lowerRotationOffsetLimit=null,o.upperRotationOffsetLimit=null,o.heightOffset=4,o.lowerHeightOffsetLimit=null,o.upperHeightOffsetLimit=null,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=i,o.inputs=new Oc(o),o.inputs.addKeyboard().addMouseWheel().addPointers(),o}return Object(No.d)(t,e),t.prototype._follow=function(e){if(e){var t;if(e.rotationQuaternion){var n=new Oo;e.rotationQuaternion.toRotationMatrix(n),t=Math.atan2(n.m[8],n.m[10])}else t=e.rotation.y;var r=Ja.ToRadians(this.rotationOffset)+t,i=e.getAbsolutePosition(),o=i.x+Math.sin(r)*this.radius,a=i.z+Math.cos(r)*this.radius,s=o-this.position.x,l=i.y+this.heightOffset-this.position.y,c=a-this.position.z,u=s*this.cameraAcceleration*2,d=l*this.cameraAcceleration,h=c*this.cameraAcceleration*2;(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new So(this.position.x+u,this.position.y+d,this.position.z+h),this.setTarget(i)}},t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t),this._reset=function(){}},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},t.prototype._checkInputs=function(){this.inputs.checkInputs(),this._checkLimits(),e.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},t.prototype._checkLimits=function(){null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),null!==this.lowerHeightOffsetLimit&&this.heightOffsetthis.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),null!==this.lowerRotationOffsetLimit&&this.rotationOffsetthis.upperRotationOffsetLimit&&(this.rotationOffset=this.upperRotationOffsetLimit)},t.prototype.getClassName=function(){return"FollowCamera"},Object(No.c)([ha()],t.prototype,"radius",void 0),Object(No.c)([ha()],t.prototype,"lowerRadiusLimit",void 0),Object(No.c)([ha()],t.prototype,"upperRadiusLimit",void 0),Object(No.c)([ha()],t.prototype,"rotationOffset",void 0),Object(No.c)([ha()],t.prototype,"lowerRotationOffsetLimit",void 0),Object(No.c)([ha()],t.prototype,"upperRotationOffsetLimit",void 0),Object(No.c)([ha()],t.prototype,"heightOffset",void 0),Object(No.c)([ha()],t.prototype,"lowerHeightOffsetLimit",void 0),Object(No.c)([ha()],t.prototype,"upperHeightOffsetLimit",void 0),Object(No.c)([ha()],t.prototype,"cameraAcceleration",void 0),Object(No.c)([ha()],t.prototype,"maxCameraSpeed",void 0),Object(No.c)([ba("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(wc),Ic=function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,So.Zero(),a)||this;return s.alpha=n,s.beta=r,s.radius=i,s.target=o,s._cartesianCoordinates=So.Zero(),s._follow(),s}return Object(No.d)(t,e),t.prototype._follow=function(){if(this.target){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.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._follow()},t.prototype.getClassName=function(){return"ArcFollowCamera"},t}(wc);!function(e){e[e.VIVE=0]="VIVE",e[e.OCULUS=1]="OCULUS",e[e.WINDOWS=2]="WINDOWS",e[e.GEAR_VR=3]="GEAR_VR",e[e.DAYDREAM=4]="DAYDREAM",e[e.GENERIC=5]="GENERIC"}(Rc||(Rc={}));var kc,Dc,Bc=function(){function e(){}return e.InitiateController=function(e){for(var t=0,n=this._ControllerFactories;tthis._maxRotationDistFromHeadset){var r=n-(n<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=r;var i=Math.sin(-r),o=Math.cos(-r);this._calculatedPosition.x=this._calculatedPosition.x*o-this._calculatedPosition.z*i,this._calculatedPosition.z=this._calculatedPosition.x*i+this._calculatedPosition.z*o}}So.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),Po.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 t=this.rawPose;e.orientation&&t.orientation&&4===t.orientation.length&&(this._deviceRoomRotationQuaternion.copyFromFloats(t.orientation[0],t.orientation[1],-t.orientation[2],-t.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 Po),!this.isXR&&(this._updatePoseAndMesh(),this._pointingPoseNode)){for(var t=[],n=this._pointingPoseNode;n.parent;)t.push(n.parent),n=n.parent;t.reverse().forEach((function(e){e.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,e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},enumerable:!0,configurable:!0}),t.prototype.getForwardRay=function(e){if(void 0===e&&(e=100),!this.mesh)return new Vl(So.Zero(),new So(0,0,1),e);var t=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),n=t.getTranslation(),r=new So(0,0,-1),i=So.TransformNormal(r,t),o=So.Normalize(i);return new Vl(n,o,e)},t.POINTING_POSE="POINTING_POSE",t}(ec);!function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.LB=4]="LB",e[e.RB=5]="RB",e[e.Back=8]="Back",e[e.Start=9]="Start",e[e.LeftStick=10]="LeftStick",e[e.RightStick=11]="RightStick"}(kc||(kc={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Dc||(Dc={}));var Nc,Lc,Uc=function(e){function t(t,n,r,i){void 0===i&&(i=!1);var o=e.call(this,t,n,r,0,1,2,3)||this;return o._leftTrigger=0,o._rightTrigger=0,o.onButtonDownObservable=new yo.a,o.onButtonUpObservable=new yo.a,o.onPadDownObservable=new yo.a,o.onPadUpObservable=new yo.a,o._buttonA=0,o._buttonB=0,o._buttonX=0,o._buttonY=0,o._buttonBack=0,o._buttonStart=0,o._buttonLB=0,o._buttonRB=0,o._buttonLeftStick=0,o._buttonRightStick=0,o._dPadUp=0,o._dPadDown=0,o._dPadLeft=0,o._dPadRight=0,o._isXboxOnePad=!1,o.type=ec.XBOX,o._isXboxOnePad=i,o}return Object(No.d)(t,e),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:!0,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:!0,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,t,n){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(n),this.onButtonDownObservable.notifyObservers(n)),0===e&&(this._onbuttonup&&this._onbuttonup(n),this.onButtonUpObservable.notifyObservers(n))),e},t.prototype._setDPadValue=function(e,t,n){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(n),this.onPadDownObservable.notifyObservers(n)),0===e&&(this._ondpadup&&this._ondpadup(n),this.onPadUpObservable.notifyObservers(n))),e},Object.defineProperty(t.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,kc.A)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,kc.B)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,kc.X)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,kc.Y)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,kc.Start)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,kc.Back)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,kc.LB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,kc.RB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,kc.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,kc.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Dc.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Dc.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Dc.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Dc.Right)},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.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(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(ec);!function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.Share=8]="Share",e[e.Options=9]="Options",e[e.LeftStick=10]="LeftStick",e[e.RightStick=11]="RightStick"}(Nc||(Nc={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Lc||(Lc={}));var Vc=function(e){function t(t,n,r){var i=e.call(this,t.replace("STANDARD GAMEPAD","SONY PLAYSTATION DUALSHOCK"),n,r,0,1,2,3)||this;return i._leftTrigger=0,i._rightTrigger=0,i.onButtonDownObservable=new yo.a,i.onButtonUpObservable=new yo.a,i.onPadDownObservable=new yo.a,i.onPadUpObservable=new yo.a,i._buttonCross=0,i._buttonCircle=0,i._buttonSquare=0,i._buttonTriangle=0,i._buttonShare=0,i._buttonOptions=0,i._buttonL1=0,i._buttonR1=0,i._buttonLeftStick=0,i._buttonRightStick=0,i._dPadUp=0,i._dPadDown=0,i._dPadLeft=0,i._dPadRight=0,i.type=ec.DUALSHOCK,i}return Object(No.d)(t,e),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:!0,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:!0,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,t,n){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(n),this.onButtonDownObservable.notifyObservers(n)),0===e&&(this._onbuttonup&&this._onbuttonup(n),this.onButtonUpObservable.notifyObservers(n))),e},t.prototype._setDPadValue=function(e,t,n){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(n),this.onPadDownObservable.notifyObservers(n)),0===e&&(this._ondpadup&&this._ondpadup(n),this.onPadUpObservable.notifyObservers(n))),e},Object.defineProperty(t.prototype,"buttonCross",{get:function(){return this._buttonCross},set:function(e){this._buttonCross=this._setButtonValue(e,this._buttonCross,Nc.Cross)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonCircle",{get:function(){return this._buttonCircle},set:function(e){this._buttonCircle=this._setButtonValue(e,this._buttonCircle,Nc.Circle)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonSquare",{get:function(){return this._buttonSquare},set:function(e){this._buttonSquare=this._setButtonValue(e,this._buttonSquare,Nc.Square)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonTriangle",{get:function(){return this._buttonTriangle},set:function(e){this._buttonTriangle=this._setButtonValue(e,this._buttonTriangle,Nc.Triangle)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonOptions",{get:function(){return this._buttonOptions},set:function(e){this._buttonOptions=this._setButtonValue(e,this._buttonOptions,Nc.Options)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonShare",{get:function(){return this._buttonShare},set:function(e){this._buttonShare=this._setButtonValue(e,this._buttonShare,Nc.Share)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonL1",{get:function(){return this._buttonL1},set:function(e){this._buttonL1=this._setButtonValue(e,this._buttonL1,Nc.L1)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonR1",{get:function(){return this._buttonR1},set:function(e){this._buttonR1=this._setButtonValue(e,this._buttonR1,Nc.R1)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Nc.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Nc.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Lc.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Lc.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Lc.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Lc.Right)},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.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(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(ec),zc=function(){function e(e){var t=this;if(this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new yo.a,Da.a.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new yo.a((function(e){for(var n in t._babylonGamepads){var r=t._babylonGamepads[n];r&&r._isConnected&&t.onGamepadConnectedObservable.notifyObserver(e,r)}})),this._onGamepadConnectedEvent=function(e){var n,r=e.gamepad;r.index in t._babylonGamepads&&t._babylonGamepads[r.index].isConnected||(t._babylonGamepads[r.index]?((n=t._babylonGamepads[r.index]).browserGamepad=r,n._isConnected=!0):n=t._addNewGamepad(r),t.onGamepadConnectedObservable.notifyObservers(n),t._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var n=e.gamepad;for(var r in t._babylonGamepads)if(t._babylonGamepads[r].index===n.index){var i=t._babylonGamepads[r];i._isConnected=!1,t.onGamepadDisconnectedObservable.notifyObservers(i),i.dispose&&i.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(e.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!0,configurable:!0}),e.prototype.getGamepadByType=function(e){void 0===e&&(e=ec.XBOX);for(var t=0,n=this._babylonGamepads;t1&&(c=a.generateStencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24),o.is2DArray?n.texImage3D(i,0,c,o.width,o.height,r,0,l,s,null):n.texImage2D(i,0,c,o.width,o.height,0,l,s,null),this._bindTextureDirectly(i,null),o};var Xc=function(){function e(e,t,n,r,i,o,a,s,l,c,u,d,h,p,f){void 0===a&&(a=1),void 0===c&&(c=null),void 0===u&&(u=0),void 0===d&&(d="postprocess"),void 0===p&&(p=!1),void 0===f&&(f=5),this.name=e,this.width=-1,this.height=-1,this._outputTexture=null,this.autoClear=!0,this.alphaMode=0,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=1,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new ns(2),this._currentRenderTextureInd=0,this._scaleRatio=new Co(1,1),this._texelSize=Co.Zero(),this.onActivateObservable=new yo.a,this.onSizeChangedObservable=new yo.a,this.onApplyObservable=new yo.a,this.onBeforeRenderObservable=new yo.a,this.onAfterRenderObservable=new yo.a,null!=o?(this._camera=o,this._scene=o.getScene(),o.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):s&&(this._engine=s,this._engine.postProcesses.push(this)),this._options=i,this.renderTargetSamplingMode=a||1,this._reusable=l||!1,this._textureType=u,this._textureFormat=f,this._samplers=r||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=d,this._parameters=n||[],this._parameters.push("scale"),this._indexParameters=h,p||this.updateEffect(c)}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._samples},set:function(e){var t=this;this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach((function(e){e.samples!==t._samples&&t._engine.updateRenderTargetTextureSampleCount(e,t._samples)}))},enumerable:!0,configurable:!0}),e.prototype.getEffectName=function(){return this._fragmentUrl},Object.defineProperty(e.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),e.prototype.getCamera=function(){return this._camera},Object.defineProperty(e.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:!0,configurable:!0}),e.prototype.getClassName=function(){return"PostProcess"},e.prototype.getEngine=function(){return this._engine},e.prototype.getEffect=function(){return this._effect},e.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},e.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new ns(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(e,t,n,r,i,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null),this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,n||this._samplers,null!==e?e:"",void 0,i,o,r||this._indexParameters)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype.activate=function(e,t,n){var r=this;void 0===t&&(t=null);var i=(e=e||this._camera).getScene(),o=i.getEngine(),a=o.getCaps().maxTextureSize,s=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,l=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0,c=e.parent;!c||c.leftCamera!=e&&c.rightCamera!=e||(s/=2);var u,d=this._options.width||s,h=this._options.height||l,p=7!==this.renderTargetSamplingMode&&1!==this.renderTargetSamplingMode&&2!==this.renderTargetSamplingMode;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var f=o.currentViewport;f&&(d*=f.width,h*=f.height)}if((p||this.alwaysForcePOT)&&(this._options.width||(d=o.needPOTTextures?ss.a.GetExponentOfTwo(d,a,this.scaleMode):d),this._options.height||(h=o.needPOTTextures?ss.a.GetExponentOfTwo(h,a,this.scaleMode):h)),this.width!==d||this.height!==h){if(this._textures.length>0){for(var m=0;m0)for(var e=0;e0){var r=this._camera._getFirstPostProcess();r&&r.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e}(),Yc="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";Qc.a.ShadersStore.passPixelShader=Yc;var qc="\nvarying vec2 vUV;\nuniform samplerCube textureSampler;\nvoid main(void)\n{\nvec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\n#endif\n}";Qc.a.ShadersStore.passCubePixelShader=qc;var Zc=function(e){function t(t,n,r,i,o,a,s,l){return void 0===r&&(r=null),void 0===s&&(s=0),void 0===l&&(l=!1),e.call(this,t,"pass",null,null,n,r,i,o,a,void 0,s,void 0,null,l)||this}return Object(No.d)(t,e),t}(Xc);!function(e){function t(t,n,r,i,o,a,s,l){void 0===r&&(r=null),void 0===s&&(s=0),void 0===l&&(l=!1);var c=e.call(this,t,"passCube",null,null,n,r,i,o,a,"#define POSITIVEX",s,void 0,null,l)||this;return c._face=0,c}Object(No.d)(t,e),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:!0,configurable:!0})}(Xc);ss.a._RescalePostProcessFactory=function(e){return new Zc("rescale",1,null,2,e,!1,0)};var Jc="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}";Qc.a.ShadersStore.anaglyphPixelShader=Jc;var $c=function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,"anaglyph",null,["leftSampler"],n,r[1],i,o,a)||this;return s._passedProcess=r[0]._rigPostProcess,s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",s._passedProcess)})),s}return Object(No.d)(t,e),t}(Xc);Ts._setStereoscopicAnaglyphRigMode=function(e){e._rigCameras[0]._rigPostProcess=new Zc(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new $c(e.name+"_anaglyph",1,e._rigCameras)},wa.AddNodeConstructor("AnaglyphArcRotateCamera",(function(e,t,n){return function(){return new eu(e,0,0,1,So.Zero(),n.interaxial_distance,t)}}));var eu=function(e){function t(t,n,r,i,o,a,s){var l=e.call(this,t,n,r,i,o,s)||this;return l.interaxialDistance=a,l.setCameraRigMode(Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a}),l}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(Sc);wa.AddNodeConstructor("AnaglyphFreeCamera",(function(e,t,n){return function(){return new tu(e,So.Zero(),n.interaxial_distance,t)}}));var tu=function(e){function t(t,n,r,i){var o=e.call(this,t,n,i)||this;return o.interaxialDistance=r,o.setCameraRigMode(Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(Ec);wa.AddNodeConstructor("AnaglyphGamepadCamera",(function(e,t,n){return function(){return new nu(e,So.Zero(),n.interaxial_distance,t)}}));var nu=function(e){function t(t,n,r,i){var o=e.call(this,t,n,i)||this;return o.interaxialDistance=r,o.setCameraRigMode(Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(Hc);wa.AddNodeConstructor("AnaglyphUniversalCamera",(function(e,t,n){return function(){return new ru(e,So.Zero(),n.interaxial_distance,t)}}));var ru=function(e){function t(t,n,r,i){var o=e.call(this,t,n,i)||this;return o.interaxialDistance=r,o.setCameraRigMode(Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(Gc),iu="const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\nvoid main(void)\n{\nbool useCamA;\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\n#ifdef IS_STEREOSCOPIC_INTERLACED\nfloat rowNum=floor(vUV.y/stepSize.y);\nuseCamA=mod(rowNum,2.0) == 1.0;\nuseCamB=mod(rowNum,2.0) == 0.0;\ntexCoord1=vec2(vUV.x,vUV.y);\ntexCoord2=vec2(vUV.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n#endif\n\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else if (useCamA){\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}else {\ndiscard;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}\n";Qc.a.ShadersStore.stereoscopicInterlacePixelShader=iu;var ou=function(e){function t(t,n,r,i,o,a,s){var l=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],o,a,s,i?"#define IS_STEREOSCOPIC_INTERLACED 1":r?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return l._passedProcess=n[0]._rigPostProcess,l._stepSize=new Co(1/l.width,1/l.height),l.onSizeChangedObservable.add((function(){l._stepSize=new Co(1/l.width,1/l.height)})),l.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",l._passedProcess),e.setFloat2("stepSize",l._stepSize.x,l._stepSize.y)})),l}return Object(No.d)(t,e),t}(Xc);!function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],i,o,a,r?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return s._passedProcess=n[0]._rigPostProcess,s._stepSize=new Co(1/s.width,1/s.height),s.onSizeChangedObservable.add((function(){s._stepSize=new Co(1/s.width,1/s.height)})),s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",s._passedProcess),e.setFloat2("stepSize",s._stepSize.x,s._stepSize.y)})),s}Object(No.d)(t,e)}(Xc);Ts._setStereoscopicRigMode=function(e){var t=e.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,n=e.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_INTERLACED;e._rigCameras[0]._rigPostProcess=new Zc(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new ou(e.name+"_stereoInterlace",e._rigCameras,t,n)},wa.AddNodeConstructor("StereoscopicArcRotateCamera",(function(e,t,n){return function(){return new au(e,0,0,1,So.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var au=function(e){function t(t,n,r,i,o,a,s,l){var c=e.call(this,t,n,r,i,o,l)||this;return c.interaxialDistance=a,c.isStereoscopicSideBySide=s,c.setCameraRigMode(s?Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),c}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(Sc);wa.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,n){return function(){return new su(e,So.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var su=function(e){function t(t,n,r,i,o){var a=e.call(this,t,n,o)||this;return a.interaxialDistance=r,a.isStereoscopicSideBySide=i,a.setCameraRigMode(i?Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(Ec);wa.AddNodeConstructor("StereoscopicGamepadCamera",(function(e,t,n){return function(){return new lu(e,So.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var lu=function(e){function t(t,n,r,i,o){var a=e.call(this,t,n,o)||this;return a.interaxialDistance=r,a.isStereoscopicSideBySide=i,a.setCameraRigMode(i?Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(Hc);wa.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,n){return function(){return new cu(e,So.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var cu=function(e){function t(t,n,r,i,o){var a=e.call(this,t,n,o)||this;return a.interaxialDistance=r,a.isStereoscopicSideBySide=i,a.setCameraRigMode(i?Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(Gc);wa.AddNodeConstructor("VirtualJoysticksCamera",(function(e,t){return function(){return new uu(e,So.Zero(),t)}}));var uu=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i.inputs.addVirtualJoystick(),i}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t}(Ec),du=function(){function e(){this.compensateDistortion=!0,this.multiviewEnabled=!1}return Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return Oo.Translation(e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return Oo.Translation(-e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftPreViewMatrix",{get:function(){return Oo.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightPreViewMatrix",{get:function(){return Oo.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),e.GetDefault=function(){var t=new e;return t.hResolution=1280,t.vResolution=800,t.hScreenSize=.149759993,t.vScreenSize=.0935999975,t.vScreenCenter=.0467999987,t.eyeToScreenDistance=.0410000011,t.lensSeparationDistance=.063500002,t.interpupillaryDistance=.064000003,t.distortionK=[1,.219999999,.239999995,0],t.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],t.postProcessScaleFactor=1.714605507808412,t.lensCenterOffset=.151976421,t},e}(),hu="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn;\nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\nelse{\ngl_FragColor=texture2D(textureSampler,tc);\n}\n}";Qc.a.ShadersStore.vrDistortionCorrectionPixelShader=hu;var pu=function(e){function t(t,n,r,i){var o=e.call(this,t,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,i.postProcessScaleFactor,n,Wl.BILINEAR_SAMPLINGMODE)||this;return o._isRightEye=r,o._distortionFactors=i.distortionK,o._postProcessScaleFactor=i.postProcessScaleFactor,o._lensCenterOffset=i.lensCenterOffset,o.adaptScaleToCurrentViewport=!0,o.onSizeChangedObservable.add((function(){o._scaleIn=new Co(2,2/o.aspectRatio),o._scaleFactor=new Co(1/o._postProcessScaleFactor*.5,1/o._postProcessScaleFactor*.5*o.aspectRatio),o._lensCenter=new Co(o._isRightEye?.5-.5*o._lensCenterOffset:.5+.5*o._lensCenterOffset,.5)})),o.onApplyObservable.add((function(e){e.setFloat2("LensCenter",o._lensCenter.x,o._lensCenter.y),e.setFloat2("Scale",o._scaleFactor.x,o._scaleFactor.y),e.setFloat2("ScaleIn",o._scaleIn.x,o._scaleIn.y),e.setFloat4("HmdWarpParam",o._distortionFactors[0],o._distortionFactors[1],o._distortionFactors[2],o._distortionFactors[3])})),o}return Object(No.d)(t,e),t}(Xc),fu="precision mediump sampler2DArray;\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\nvoid main(void)\n{\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\n}";Qc.a.ShadersStore.vrMultiviewToSingleviewPixelShader=fu;Va.a.prototype.createRenderTargetCubeTexture=function(e,t){var n=Object(No.a)({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:0,samplingMode:3,format:5},t);n.generateStencilBuffer=n.generateDepthBuffer&&n.generateStencilBuffer,(1!==n.type||this._caps.textureFloatLinearFiltering)&&(2!==n.type||this._caps.textureHalfFloatLinearFiltering)||(n.samplingMode=1);var r=this._gl,i=new Kl.a(this,Kl.b.RenderTarget);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,i,!0);var o=this._getSamplingParameters(n.samplingMode,n.generateMipMaps);1!==n.type||this._caps.textureFloat||(n.type=0,jo.a.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,o.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,o.min),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);for(var a=0;a<6;a++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,this._getRGBABufferInternalSizedFormat(n.type,n.format),e,e,0,this._getInternalFormat(n.format),this._getWebGLTextureType(n.type),null);var s=r.createFramebuffer();return this._bindUnboundFramebuffer(s),i._depthStencilBuffer=this._setupFramebufferDepthAttachments(n.generateStencilBuffer,n.generateDepthBuffer,e,e),n.generateMipMaps&&r.generateMipmap(r.TEXTURE_CUBE_MAP),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),i._framebuffer=s,i.width=e,i.height=e,i.isReady=!0,i.isCube=!0,i.samples=1,i.generateMipMaps=n.generateMipMaps,i.samplingMode=n.samplingMode,i.type=n.type,i.format=n.format,i._generateDepthBuffer=n.generateDepthBuffer,i._generateStencilBuffer=n.generateStencilBuffer,this._internalTexturesCache.push(i),i};var mu=function(e){function t(t,n,r,i,o,a,s,l,c,u,d,h,p){void 0===o&&(o=!0),void 0===a&&(a=0),void 0===s&&(s=!1),void 0===l&&(l=Wl.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=!0),void 0===u&&(u=!1),void 0===d&&(d=!1),void 0===h&&(h=5),void 0===p&&(p=!1);var f=e.call(this,null,r,!i)||this;return f.isCube=s,f.renderParticles=!0,f.renderSprites=!1,f.coordinatesMode=Wl.PROJECTION_MODE,f.ignoreCameraViewport=!1,f.onBeforeBindObservable=new yo.a,f.onAfterUnbindObservable=new yo.a,f.onBeforeRenderObservable=new yo.a,f.onAfterRenderObservable=new yo.a,f.onClearObservable=new yo.a,f.onResizeObservable=new yo.a,f._currentRefreshId=-1,f._refreshRate=1,f._samples=1,f.boundingBoxPosition=So.Zero(),(r=f.getScene())?(f.renderList=new Array,f._engine=r.getEngine(),f.name=t,f.isRenderTarget=!0,f._initialSizeParameter=n,f._processSizeParameter(n),f._resizeObserver=f.getScene().getEngine().onResizeObservable.add((function(){})),f._generateMipMaps=!!i,f._doNotChangeAspectRatio=o,f._renderingManager=new js(r),f._renderingManager._useSceneAutoClearSetup=!0,d||(f._renderTargetOptions={generateMipMaps:i,type:a,format:h,samplingMode:l,generateDepthBuffer:c,generateStencilBuffer:u},l===Wl.NEAREST_SAMPLINGMODE&&(f.wrapU=Wl.CLAMP_ADDRESSMODE,f.wrapV=Wl.CLAMP_ADDRESSMODE),p||(s?(f._texture=r.getEngine().createRenderTargetCubeTexture(f.getRenderSize(),f._renderTargetOptions),f.coordinatesMode=Wl.INVCUBIC_MODE,f._textureMatrix=Oo.Identity()):f._texture=r.getEngine().createRenderTargetTexture(f._size,f._renderTargetOptions))),f):f}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"renderList",{get:function(){return this._renderList},set:function(e){this._renderList=e,this._renderList&&this._hookArray(this._renderList)},enumerable:!0,configurable:!0}),t.prototype._hookArray=function(e){var t=this,n=e.push;e.push=function(){for(var r=[],i=0;i0&&(this._postProcesses[0].autoClear=!1))}},t.prototype._shouldRender=function(){return-1===this._currentRefreshId||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:!0,configurable:!0}),t.prototype.scale=function(e){var t=Math.max(1,this.getRenderSize()*e);this.resize(t)},t.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:e.prototype.getReflectionTextureMatrix.call(this)},t.prototype.resize=function(e){var t=this.isCube;this.releaseInternalTexture();var n=this.getScene();n&&(this._processSizeParameter(e),this._texture=t?n.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):n.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},t.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),s=this.getScene()){var n,r=s.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var i=0;i1||this.activeCamera&&this.activeCamera!==s.activeCamera)&&s.setTransformMatrix(s.activeCamera.getViewMatrix(),s.activeCamera.getProjectionMatrix(!0)),r.setViewport(s.activeCamera.viewport)),s.resetCachedMaterial()}},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var n=e*t,r=ss.a.NearestPOT(n+16384/(128+n));return Math.min(ss.a.FloorPOT(e),r)},t.prototype._prepareRenderingManager=function(e,t,n,r){var i=this.getScene();if(i){this._renderingManager.reset();for(var o=i.getRenderId(),a=0;a=0&&this._renderingManager.dispatchParticles(h))}}},t.prototype._bindFrameBuffer=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0);var n=this.getScene();if(n){var r=n.getEngine();this._texture&&r.bindFramebuffer(this._texture,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}},t.prototype.unbindFrameBuffer=function(e,t){var n=this;this._texture&&e.unBindFramebuffer(this._texture,this.isCube,(function(){n.onAfterRenderObservable.notifyObservers(t)}))},t.prototype.renderToTarget=function(e,t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=null);var o=this.getScene();if(o){var a=o.getEngine();if(this._texture){this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):t&&o.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(e,r),this.is2DArray?this.onBeforeRenderObservable.notifyObservers(r):this.onBeforeRenderObservable.notifyObservers(e);var s=null,l=this.renderList?this.renderList:o.getActiveMeshes().data,c=this.renderList?this.renderList.length:o.getActiveMeshes().length;this.getCustomRenderList&&(s=this.getCustomRenderList(this.is2DArray?r:e,l,c)),s?this._prepareRenderingManager(s,s.length,i,!1):(this._defaultRenderListPrepared||(this._prepareRenderingManager(l,c,i,!this.renderList),this._defaultRenderListPrepared=!0),s=l),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(a):a.clear(this.clearColor||o.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0);for(var u=0,d=o._beforeRenderTargetDrawStage;u=0&&t.customRenderTargets.splice(n,1);for(var r=0,i=t.cameras;r=0&&o.customRenderTargets.splice(n,1)}this.depthStencilTexture&&this.getScene().getEngine()._releaseTexture(this.depthStencilTexture),e.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}(Wl);Wl._CreateRenderTargetTexture=function(e,t,n,r){return new mu(e,t,n,r)};var gu=function(e){function t(t,n){void 0===n&&(n=512);var r=e.call(this,"multiview rtt",n,t,!1,!0,Kl.b.Unknown,!1,void 0,!1,!1,!0,void 0,!0)||this,i=t.getEngine().createMultiviewRenderTargetTexture(r.getRenderWidth(),r.getRenderHeight());return i.isMultiview=!0,i.format=5,r._texture=i,r.samples=r._engine.getCaps().maxSamples||r.samples,r}return Object(No.d)(t,e),t.prototype._bindFrameBuffer=function(e){void 0===e&&(e=0),this._texture&&this.getScene().getEngine().bindMultiviewFramebuffer(this._texture)},t.prototype.getViewCount=function(){return 2},t}(mu);ss.a.prototype.createMultiviewRenderTargetTexture=function(e,t){var n=this._gl;if(!this.getCaps().multiview)throw"Multiview is not supported";var r=new Kl.a(this,Kl.b.Unknown,!0);return r.width=e,r.height=t,r._framebuffer=n.createFramebuffer(),r._colorTextureArray=n.createTexture(),n.bindTexture(n.TEXTURE_2D_ARRAY,r._colorTextureArray),n.texStorage3D(n.TEXTURE_2D_ARRAY,1,n.RGBA8,e,t,2),r._depthStencilTextureArray=n.createTexture(),n.bindTexture(n.TEXTURE_2D_ARRAY,r._depthStencilTextureArray),n.texStorage3D(n.TEXTURE_2D_ARRAY,1,n.DEPTH32F_STENCIL8,e,t,2),r.isReady=!0,r},ss.a.prototype.bindMultiviewFramebuffer=function(e){var t=this._gl,n=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(e,void 0,void 0,void 0,!0),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,e._framebuffer),!e._colorTextureArray||!e._depthStencilTextureArray)throw"Invalid multiview frame buffer";this.getCaps().oculusMultiview?(n.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,e.samples,0,2),n.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,e.samples,0,2)):(n.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,0,2),n.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,0,2))},Ts.prototype._useMultiviewToSingleView=!1,Ts.prototype._multiviewTexture=null,Ts.prototype._resizeOrCreateMultiviewTexture=function(e,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==e&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new gu(this.getScene(),{width:e,height:t})):this._multiviewTexture=new gu(this.getScene(),{width:e,height:t})},nl.prototype._transformMatrixR=Oo.Zero(),nl.prototype._multiviewSceneUbo=null,nl.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=new ks(this.getEngine(),void 0,!0),this._multiviewSceneUbo.addUniform("viewProjection",16),this._multiviewSceneUbo.addUniform("viewProjectionR",16),this._multiviewSceneUbo.addUniform("view",16)},nl.prototype._updateMultiviewUbo=function(e,t){e&&t&&e.multiplyToRef(t,this._transformMatrixR),e&&t&&(e.multiplyToRef(t,Mo.Matrix[0]),Ss.GetRightPlaneToRef(Mo.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())},nl.prototype._renderMultiviewToSingleView=function(e){e._resizeOrCreateMultiviewTexture(e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.width>0?e._rigPostProcess.width:this.getEngine().getRenderWidth(!0),e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.height>0?e._rigPostProcess.height:this.getEngine().getRenderHeight(!0)),this._multiviewSceneUbo||this._createMultiviewUbo(),e.outputRenderTarget=e._multiviewTexture,this._renderForCamera(e),e.outputRenderTarget=null;for(var t=0;t=2&&e.onControllersAttachedObservable.notifyObservers(e.controllers)}}}))},t}(Ec),wu=function(e){function t(t){var n=e.call(this,t)||this;return n.onTriggerStateChangedObservable=new yo.a,n.onMainButtonStateChangedObservable=new yo.a,n.onSecondaryButtonStateChangedObservable=new yo.a,n.onPadStateChangedObservable=new yo.a,n.onPadValuesChangedObservable=new yo.a,n.pad={x:0,y:0},n._changes={pressChanged:!1,touchChanged:!1,valueChanged:!1,changed:!1},n._buttons=new Array(t.buttons.length),n.hand=t.hand,n}return Object(No.d)(t,e),t.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(t.prototype,"defaultModel",{get:function(){return this._defaultModel},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t0,t.NUM_MORPH_INFLUENCERS=n.numInfluencers):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)},e.PrepareDefinesForAttributes=function(e,t,n,r,i,o){if(void 0===i&&(i=!1),void 0===o&&(o=!0),!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;if(t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent(cs.NormalKind),t._needNormals&&e.isVerticesDataPresent(cs.TangentKind)&&(t.TANGENT=!0),t._needUVs?(t.UV1=e.isVerticesDataPresent(cs.UVKind),t.UV2=e.isVerticesDataPresent(cs.UV2Kind)):(t.UV1=!1,t.UV2=!1),n){var a=e.useVertexColors&&e.isVerticesDataPresent(cs.ColorKind);t.VERTEXCOLOR=a,t.VERTEXALPHA=e.hasVertexAlpha&&a&&o}return r&&this.PrepareDefinesForBones(e,t),i&&this.PrepareDefinesForMorphTargets(e,t),!0},e.PrepareDefinesForMultiview=function(e,t){if(e.activeCamera){var n=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=n&&t.markAsUnprocessed()}},e.PrepareDefinesForLight=function(e,t,n,r,i,o,a){switch(a.needNormals=!0,void 0===i["LIGHT"+r]&&(a.needRebuild=!0),i["LIGHT"+r]=!0,i["SPOTLIGHT"+r]=!1,i["HEMILIGHT"+r]=!1,i["POINTLIGHT"+r]=!1,i["DIRLIGHT"+r]=!1,n.prepareLightSpecificDefines(i,r),i["LIGHT_FALLOFF_PHYSICAL"+r]=!1,i["LIGHT_FALLOFF_GLTF"+r]=!1,i["LIGHT_FALLOFF_STANDARD"+r]=!1,n.falloffType){case Ds.FALLOFF_GLTF:i["LIGHT_FALLOFF_GLTF"+r]=!0;break;case Ds.FALLOFF_PHYSICAL:i["LIGHT_FALLOFF_PHYSICAL"+r]=!0;break;case Ds.FALLOFF_STANDARD:i["LIGHT_FALLOFF_STANDARD"+r]=!0}if(o&&!n.specular.equalsFloats(0,0,0)&&(a.specularEnabled=!0),i["SHADOW"+r]=!1,i["SHADOWCSM"+r]=!1,i["SHADOWCSMDEBUG"+r]=!1,i["SHADOWCSMNUM_CASCADES"+r]=!1,i["SHADOWCSMUSESHADOWMAXZ"+r]=!1,i["SHADOWCSMNOBLEND"+r]=!1,i["SHADOWCSM_RIGHTHANDED"+r]=!1,i["SHADOWPCF"+r]=!1,i["SHADOWPCSS"+r]=!1,i["SHADOWPOISSON"+r]=!1,i["SHADOWESM"+r]=!1,i["SHADOWCUBE"+r]=!1,i["SHADOWLOWQUALITY"+r]=!1,i["SHADOWMEDIUMQUALITY"+r]=!1,t&&t.receiveShadows&&e.shadowsEnabled&&n.shadowEnabled){var s=n.getShadowGenerator();if(s){var l=s.getShadowMap();l&&l.renderList&&l.renderList.length>0&&(a.shadowEnabled=!0,s.prepareDefines(i,r))}}n.lightmapMode!=Ds.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,i["LIGHTMAPEXCLUDED"+r]=!0,i["LIGHTMAPNOSPECULAR"+r]=n.lightmapMode==Ds.LIGHTMAP_SHADOWSONLY):(i["LIGHTMAPEXCLUDED"+r]=!1,i["LIGHTMAPNOSPECULAR"+r]=!1)},e.PrepareDefinesForLights=function(e,t,n,r,i,o){if(void 0===i&&(i=4),void 0===o&&(o=!1),!n._areLightsDirty)return n._needNormals;var a=0,s={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!o)for(var l=0,c=t.lightSources;l0&&(i=r+o,t.addFallback(i,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(r,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(r,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(r,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(r,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(r,"SHADOWESM"+o));return i++},e.PrepareAttributesForMorphTargetsInfluencers=function(e,t,n){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=n,this.PrepareAttributesForMorphTargets(e,t,this._TmpMorphInfluencers)},e.PrepareAttributesForMorphTargets=function(e,t,n){var r=n.NUM_MORPH_INFLUENCERS;if(r>0&&Zo.a.LastCreatedEngine)for(var i=Zo.a.LastCreatedEngine.getCaps().maxVertexAttribs,o=t.morphTargetManager,a=o&&o.supportsNormals&&n.NORMAL,s=o&&o.supportsTangents&&n.TANGENT,l=o&&o.supportsUVs&&n.UV1,c=0;ci&&jo.a.Error("Cannot add more vertex attributes for mesh "+t.name)},e.PrepareAttributesForBones=function(e,t,n,r){n.NUM_BONE_INFLUENCERS>0&&(r.addCPUSkinningFallback(0,t),e.push(cs.MatricesIndicesKind),e.push(cs.MatricesWeightsKind),n.NUM_BONE_INFLUENCERS>4&&(e.push(cs.MatricesIndicesExtraKind),e.push(cs.MatricesWeightsExtraKind)))},e.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&this.PushAttributesForInstances(e)},e.PushAttributesForInstances=function(e){e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3")},e.BindLightProperties=function(e,t,n){e.transferToEffect(t,n+"")},e.BindLight=function(e,t,n,r,i,o){void 0===o&&(o=!1),e._bindLight(t,n,r,i,o)},e.BindLights=function(e,t,n,r,i,o){void 0===i&&(i=4),void 0===o&&(o=!1);for(var a=Math.min(t.lightSources.length,i),s=0;s-1){var r=n.getTransformMatrixTexture(e);t.setTexture("boneSampler",r),t.setFloat("boneTextureWidth",4*(n.bones.length+1))}else{var i=n.getTransformMatrices(e);i&&t.setMatrices("mBones",i)}}},e.BindMorphTargetParameters=function(e,t){var n=e.morphTargetManager;e&&n&&t.setFloatArray("morphTargetInfluences",n.influences)},e.BindLogDepth=function(e,t,n){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(n.activeCamera.maxZ+1)/Math.LN2))},e.BindClipPlane=function(e,t){if(t.clipPlane){var n=t.clipPlane;e.setFloat4("vClipPlane",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane2){n=t.clipPlane2;e.setFloat4("vClipPlane2",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane3){n=t.clipPlane3;e.setFloat4("vClipPlane3",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane4){n=t.clipPlane4;e.setFloat4("vClipPlane4",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane5){n=t.clipPlane5;e.setFloat4("vClipPlane5",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane6){n=t.clipPlane6;e.setFloat4("vClipPlane6",n.normal.x,n.normal.y,n.normal.z,n.d)}},e._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},e._tempFogColor=Io.Black(),e}(),Su=function(){function e(){}return Object.defineProperty(e,"DiffuseTextureEnabled",{get:function(){return this._DiffuseTextureEnabled},set:function(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AmbientTextureEnabled",{get:function(){return this._AmbientTextureEnabled},set:function(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OpacityTextureEnabled",{get:function(){return this._OpacityTextureEnabled},set:function(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ReflectionTextureEnabled",{get:function(){return this._ReflectionTextureEnabled},set:function(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EmissiveTextureEnabled",{get:function(){return this._EmissiveTextureEnabled},set:function(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"SpecularTextureEnabled",{get:function(){return this._SpecularTextureEnabled},set:function(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"BumpTextureEnabled",{get:function(){return this._BumpTextureEnabled},set:function(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"LightmapTextureEnabled",{get:function(){return this._LightmapTextureEnabled},set:function(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RefractionTextureEnabled",{get:function(){return this._RefractionTextureEnabled},set:function(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ColorGradingTextureEnabled",{get:function(){return this._ColorGradingTextureEnabled},set:function(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"FresnelEnabled",{get:function(){return this._FresnelEnabled},set:function(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,ss.a.MarkAllMaterialsAsDirty(4))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ClearCoatTextureEnabled",{get:function(){return this._ClearCoatTextureEnabled},set:function(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ClearCoatBumpTextureEnabled",{get:function(){return this._ClearCoatBumpTextureEnabled},set:function(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ClearCoatTintTextureEnabled",{get:function(){return this._ClearCoatTintTextureEnabled},set:function(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"SheenTextureEnabled",{get:function(){return this._SheenTextureEnabled},set:function(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AnisotropicTextureEnabled",{get:function(){return this._AnisotropicTextureEnabled},set:function(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ThicknessTextureEnabled",{get:function(){return this._ThicknessTextureEnabled},set:function(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),e._DiffuseTextureEnabled=!0,e._AmbientTextureEnabled=!0,e._OpacityTextureEnabled=!0,e._ReflectionTextureEnabled=!0,e._EmissiveTextureEnabled=!0,e._SpecularTextureEnabled=!0,e._BumpTextureEnabled=!0,e._LightmapTextureEnabled=!0,e._RefractionTextureEnabled=!0,e._ColorGradingTextureEnabled=!0,e._FresnelEnabled=!0,e._ClearCoatTextureEnabled=!0,e._ClearCoatBumpTextureEnabled=!0,e._ClearCoatTintTextureEnabled=!0,e._SheenTextureEnabled=!0,e._AnisotropicTextureEnabled=!0,e._ThicknessTextureEnabled=!0,e}(),Tu="uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";Qc.a.IncludesShadersStore.defaultFragmentDeclaration=Tu;var Pu="layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nfloat visibility;\nvec4 vDiffuseColor;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};\n";Qc.a.IncludesShadersStore.defaultUboDeclaration=Pu;var Ou="const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat toGammaSpace(float color)\n{\nreturn pow(color,GammaEncodePowerApprox);\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}\n";Qc.a.IncludesShadersStore.helperFunctions=Ou;var Ru="#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#endif";Qc.a.IncludesShadersStore.lightFragmentDeclaration=Ru;var Mu="#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif";Qc.a.IncludesShadersStore.lightUboDeclaration=Mu;var Iu="\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn textureColor;\n}";Qc.a.IncludesShadersStore.lightsFragmentFunctions=Iu;var ku="#ifdef SHADOWS\n#ifndef SHADOWFLOAT\n\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\n#endif\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n#define GREATEST_LESS_THAN_ONE 0.99999994\n\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat shadow=texture(shadowSampler,uvDepthLayer);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; ithis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"hasMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;for(var n=this._mesh.getScene(),r=0;r0&&(i.computeBonesUsingShaders=!1)}}else{var s=this._defines[this._currentRank];if(s)for(r=0;r0,o.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,o.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===Wl.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case Wl.EXPLICIT_MODE:o.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case Wl.PLANAR_MODE:o.setReflectionMode("REFLECTIONMAP_PLANAR");break;case Wl.PROJECTION_MODE:o.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case Wl.SKYBOX_MODE:o.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case Wl.SPHERICAL_MODE:o.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case Wl.EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case Wl.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case Wl.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case Wl.CUBIC_MODE:case Wl.INVCUBIC_MODE:default:o.setReflectionMode("REFLECTIONMAP_CUBIC")}o.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else o.REFLECTION=!1;if(this._emissiveTexture&&t.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;Cu.PrepareDefinesForMergedUV(this._emissiveTexture,o,"EMISSIVE")}else o.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;Cu.PrepareDefinesForMergedUV(this._lightmapTexture,o,"LIGHTMAP"),o.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else o.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;Cu.PrepareDefinesForMergedUV(this._specularTexture,o,"SPECULAR"),o.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else o.SPECULAR=!1;if(i.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;Cu.PrepareDefinesForMergedUV(this._bumpTexture,o,"BUMP"),o.PARALLAX=this._useParallax,o.PARALLAXOCCLUSION=this._useParallaxOcclusion,o.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else o.BUMP=!1;if(this._refractionTexture&&t.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;o._needUVs=!0,o.REFRACTION=!0,o.REFRACTIONMAP_3D=this._refractionTexture.isCube}else o.REFRACTION=!1;o.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else o.DIFFUSE=!1,o.AMBIENT=!1,o.OPACITY=!1,o.REFLECTION=!1,o.EMISSIVE=!1,o.LIGHTMAP=!1,o.BUMP=!1,o.REFRACTION=!1;o.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),o.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,o.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,o.SPECULAROVERALPHA=this._useSpecularOverAlpha,o.PREMULTIPLYALPHA=7===this.alphaMode||8===this.alphaMode}if(o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(o._areFresnelDirty&&(t.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(o.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,o.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,o.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,o.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,o.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,o.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,o._needNormals=!0,o.FRESNEL=!0):o.FRESNEL=!1),Cu.PrepareDefinesForMisc(e,i,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),Cu.PrepareDefinesForAttributes(e,o,!0,!0,!0),Cu.PrepareDefinesForFrameBoundValues(i,a,o,r),o.isDirty){var s=o._areLightsDisposed;o.markAsProcessed();var l=new ud;o.REFLECTION&&l.addFallback(0,"REFLECTION"),o.SPECULAR&&l.addFallback(0,"SPECULAR"),o.BUMP&&l.addFallback(0,"BUMP"),o.PARALLAX&&l.addFallback(1,"PARALLAX"),o.PARALLAXOCCLUSION&&l.addFallback(0,"PARALLAXOCCLUSION"),o.SPECULAROVERALPHA&&l.addFallback(0,"SPECULAROVERALPHA"),o.FOG&&l.addFallback(1,"FOG"),o.POINTSIZE&&l.addFallback(0,"POINTSIZE"),o.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),Cu.HandleFallbacksForShadows(o,l,this._maxSimultaneousLights),o.SPECULARTERM&&l.addFallback(0,"SPECULARTERM"),o.DIFFUSEFRESNEL&&l.addFallback(1,"DIFFUSEFRESNEL"),o.OPACITYFRESNEL&&l.addFallback(2,"OPACITYFRESNEL"),o.REFLECTIONFRESNEL&&l.addFallback(3,"REFLECTIONFRESNEL"),o.EMISSIVEFRESNEL&&l.addFallback(4,"EMISSIVEFRESNEL"),o.FRESNEL&&l.addFallback(4,"FRESNEL"),o.MULTIVIEW&&l.addFallback(0,"MULTIVIEW");var c=[cs.PositionKind];o.NORMAL&&c.push(cs.NormalKind),o.UV1&&c.push(cs.UVKind),o.UV2&&c.push(cs.UV2Kind),o.VERTEXCOLOR&&c.push(cs.ColorKind),Cu.PrepareAttributesForBones(c,e,o,l),Cu.PrepareAttributesForInstances(c,o),Cu.PrepareAttributesForMorphTargets(c,e,o);var u="default",d=["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"],h=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler"],p=["Material","Scene"];Ms&&(Ms.PrepareUniforms(d,o),Ms.PrepareSamplers(h,o)),Cu.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:h,defines:o,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,d,p,h,o));var f=o.toString(),m=n.effect,g=i.getEngine().createEffect(u,{attributes:c,uniformsNames:d,uniformBuffersNames:p,samplers:h,defines:f,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS}},a);if(g)if(this.allowShaderHotSwapping&&m&&!g.isReady()){if(g=m,this._rebuildInParallel=!0,o.markAsUnprocessed(),s)return o._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,i.resetCachedMaterial(),n.setEffect(g,o),this.buildUniformLayout()}return!(!n.effect||!n.effect.isReady())&&(o._renderId=i.getRenderId(),n.effect._wasPreviouslyReady=!0,!0)},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("reflectionMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("visibility",1),e.addUniform("vDiffuseColor",4),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),t=!0),this._refractionTexture&&this._refractionTexture.isRenderTarget&&(this._activeEffect.setTexture("refraction2DSampler",null),t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,n,r){var i=this.getScene(),o=r._materialDefines;if(o){var a=r.effect;if(a){this._activeEffect=a,o.INSTANCES||this.bindOnlyWorldMatrix(e),o.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var s=this._mustRebind(i,a,n.visibility);Cu.BindBonesParameters(n,a);var l=this._uniformBuffer;if(s){if(l.bindToEffect(a,"Material"),this.bindViewProjection(a),!l.useUbo||!this.isFrozen||!l.isSync){if(t.FresnelEnabled&&o.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(l.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),l.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&l.updateColor4("opacityParts",new Io(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(l.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),l.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(l.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),l.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(l.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),l.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),i.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(l.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),Cu.BindTextureMatrix(this._diffuseTexture,l,"diffuse"),this._diffuseTexture.hasAlpha&&a.setFloat("alphaCutOff",this.alphaCutOff)),this._ambientTexture&&t.AmbientTextureEnabled&&(l.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),Cu.BindTextureMatrix(this._ambientTexture,l,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(l.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),Cu.BindTextureMatrix(this._opacityTexture,l,"opacity")),this._reflectionTexture&&t.ReflectionTextureEnabled&&(l.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),l.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var c=this._reflectionTexture;l.updateVector3("vReflectionPosition",c.boundingBoxPosition),l.updateVector3("vReflectionSize",c.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(l.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),Cu.BindTextureMatrix(this._emissiveTexture,l,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(l.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),Cu.BindTextureMatrix(this._lightmapTexture,l,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(l.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),Cu.BindTextureMatrix(this._specularTexture,l,"specular")),this._bumpTexture&&i.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(l.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),Cu.BindTextureMatrix(this._bumpTexture,l,"bump"),i._mirroredCameraPosition?l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.RefractionTextureEnabled){var u=1;this._refractionTexture.isCube||(l.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(u=this._refractionTexture.depth)),l.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,u,this.invertRefractionY?-1:1)}}this.pointsCloud&&l.updateFloat("pointSize",this.pointSize),o.SPECULARTERM&&l.updateColor4("vSpecularColor",this.specularColor,this.specularPower),l.updateColor3("vEmissiveColor",t.EmissiveTextureEnabled?this.emissiveColor:Io.BlackReadOnly),l.updateFloat("visibility",n.visibility),l.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha)}if(i.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&i.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled)){u=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}Cu.BindClipPlane(a,i),i.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),Cu.BindEyePosition(a,i),a.setColor3("vAmbientColor",this._globalAmbientColor)}!s&&this.isFrozen||(i.lightsEnabled&&!this._disableLighting&&Cu.BindLights(i,n,a,o,this._maxSimultaneousLights,this._rebuildInParallel),(i.fogEnabled&&n.applyFog&&i.fogMode!==nl.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),Cu.BindFogParameters(i,n,a),o.NUM_MORPH_INFLUENCERS&&Cu.BindMorphTargetParameters(n,a),this.useLogarithmicDepth&&Cu.BindLogDepth(o,a,i),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),l.update(),this._afterBind(n,this._activeEffect)}}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),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._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),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._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._specularTexture&&t.push(this._specularTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this._refractionTexture&&t.push(this._refractionTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._emissiveTexture===t||(this._specularTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||this._refractionTexture===t))))))))},t.prototype.dispose=function(t,n){n&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,n)},t.prototype.clone=function(e){var n=this,r=ya.Clone((function(){return new t(e,n.getScene())}),this);return r.name=e,r.id=e,r},t.prototype.serialize=function(){return ya.Serialize(this)},t.Parse=function(e,n,r){return ya.Parse((function(){return new t(e.name,n)}),e,n,r)},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return Su.DiffuseTextureEnabled},set:function(e){Su.DiffuseTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return Su.AmbientTextureEnabled},set:function(e){Su.AmbientTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return Su.OpacityTextureEnabled},set:function(e){Su.OpacityTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return Su.ReflectionTextureEnabled},set:function(e){Su.ReflectionTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return Su.EmissiveTextureEnabled},set:function(e){Su.EmissiveTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return Su.SpecularTextureEnabled},set:function(e){Su.SpecularTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return Su.BumpTextureEnabled},set:function(e){Su.BumpTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return Su.LightmapTextureEnabled},set:function(e){Su.LightmapTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return Su.RefractionTextureEnabled},set:function(e){Su.RefractionTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return Su.ColorGradingTextureEnabled},set:function(e){Su.ColorGradingTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return Su.FresnelEnabled},set:function(e){Su.FresnelEnabled=e},enumerable:!0,configurable:!0}),Object(No.c)([pa("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),Object(No.c)([pa("ambientTexture")],t.prototype,"_ambientTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(No.c)([pa("opacityTexture")],t.prototype,"_opacityTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(No.c)([pa("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(No.c)([pa("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(No.c)([pa("specularTexture")],t.prototype,"_specularTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),Object(No.c)([pa("bumpTexture")],t.prototype,"_bumpTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(No.c)([pa("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),Object(No.c)([pa("refractionTexture")],t.prototype,"_refractionTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),Object(No.c)([fa("ambient")],t.prototype,"ambientColor",void 0),Object(No.c)([fa("diffuse")],t.prototype,"diffuseColor",void 0),Object(No.c)([fa("specular")],t.prototype,"specularColor",void 0),Object(No.c)([fa("emissive")],t.prototype,"emissiveColor",void 0),Object(No.c)([ha()],t.prototype,"specularPower",void 0),Object(No.c)([ha("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),Object(No.c)([ha("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),Object(No.c)([ha("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),Object(No.c)([ha("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(No.c)([ha("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),Object(No.c)([ha("disableLighting")],t.prototype,"_disableLighting",void 0),Object(No.c)([da("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(No.c)([ha("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(No.c)([ha("useParallax")],t.prototype,"_useParallax",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(No.c)([ha("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(No.c)([ha()],t.prototype,"parallaxScaleBias",void 0),Object(No.c)([ha("roughness")],t.prototype,"_roughness",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(No.c)([ha()],t.prototype,"indexOfRefraction",void 0),Object(No.c)([ha()],t.prototype,"invertRefractionY",void 0),Object(No.c)([ha()],t.prototype,"alphaCutOff",void 0),Object(No.c)([ha("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(No.c)([ma("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),Object(No.c)([ma("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),Object(No.c)([ma("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),Object(No.c)([ma("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),Object(No.c)([ma("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),Object(No.c)([ha("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),Object(No.c)([ha("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),Object(No.c)([ha("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(No.c)([da("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(No.c)([ha("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(No.c)([ha("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(No.c)([ha("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(No.c)([ha()],t.prototype,"useLogarithmicDepth",null),t}(Eu);Eo.RegisteredTypes["BABYLON.StandardMaterial"]=hd,nl.DefaultMaterialFactory=function(e){return new hd("default material",e)},Va.a.prototype.createDynamicTexture=function(e,t,n,r){var i=new Kl.a(this,Kl.b.Dynamic);return i.baseWidth=e,i.baseHeight=t,n&&(e=this.needPOTTextures?Va.a.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?Va.a.GetExponentOfTwo(t,this._caps.maxTextureSize):t),i.width=e,i.height=t,i.isReady=!1,i.generateMipMaps=n,i.samplingMode=r,this.updateTextureSamplingMode(r,i),this._internalTexturesCache.push(i),i},Va.a.prototype.updateDynamicTexture=function(e,t,n,r,i,o){if(void 0===r&&(r=!1),void 0===o&&(o=!1),e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0,o),this._unpackFlipY(n),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var a=i?this._getInternalFormat(i):this._gl.RGBA;this._gl.texImage2D(this._gl.TEXTURE_2D,0,a,a,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}};var pd=function(e){function t(t,n,r,i,o,a){void 0===r&&(r=null),void 0===o&&(o=3),void 0===a&&(a=5);var s=e.call(this,null,r,!i,void 0,o,void 0,void 0,void 0,void 0,a)||this;s.name=t,s._engine=s.getScene().getEngine(),s.wrapU=Wl.CLAMP_ADDRESSMODE,s.wrapV=Wl.CLAMP_ADDRESSMODE,s._generateMipMaps=i,n.getContext?(s._canvas=n,s._texture=s._engine.createDynamicTexture(n.width,n.height,i,o)):(s._canvas=wl.a.CreateCanvas(1,1),n.width||0===n.width?s._texture=s._engine.createDynamicTexture(n.width,n.height,i,o):s._texture=s._engine.createDynamicTexture(n,n,i,o));var l=s.getSize();return s._canvas.width=l.width,s._canvas.height=l.height,s._context=s._canvas.getContext("2d"),s}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"DynamicTexture"},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._engine.createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)},t.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},t.prototype.scaleTo=function(e,t){var n=this.getSize();n.width=e,n.height=t,this._recreate(n)},t.prototype.getContext=function(){return this._context},t.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},t.prototype.update=function(e,t){void 0===t&&(t=!1),this._engine.updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0)},t.prototype.drawText=function(e,t,n,r,i,o,a,s){void 0===s&&(s=!0);var l=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,l.width,l.height)),this._context.font=r,null==t){var c=this._context.measureText(e);t=(l.width-c.width)/2}if(null==n){var u=parseInt(r.replace(/\D/g,""));n=l.height/2+u/3.65}this._context.fillStyle=i,this._context.fillText(e,t,n),s&&this.update(a)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=this.getSize(),r=new t(this.name,n,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.wrapU=this.wrapU,r.wrapV=this.wrapV,r},t.prototype.serialize=function(){var t=this.getScene();t&&!t.isReady()&&jo.a.Warn("The scene must be ready before serializing the dynamic texture");var n=e.prototype.serialize.call(this);return this._canvas.toDataURL&&(n.base64String=this._canvas.toDataURL()),n.invertY=this._invertY,n.samplingMode=this.samplingMode,n},t.prototype._rebuild=function(){this.update()},t}(Wl),fd="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include\n#include\n#include\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\n\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}";Qc.a.ShadersStore.imageProcessingPixelShader=fd;var md=function(e){function t(t,n,r,i,o,a,s,l){void 0===r&&(r=null),void 0===s&&(s=0);var c=e.call(this,t,"imageProcessing",[],[],n,r,i,o,a,null,s,"postprocess",null,!0)||this;return c._fromLinearSpace=!0,c._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},l?(l.applyByPostProcess=!0,c._attachImageProcessingConfiguration(l,!0),c.fromLinearSpace=!1):(c._attachImageProcessingConfiguration(null,!0),c.imageProcessingConfiguration.applyByPostProcess=!0),c.onApply=function(e){c.imageProcessingConfiguration.bind(e,c.aspectRatio)},c}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e,t){var n=this;if(void 0===t&&(t=!1),e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{var r=null,i=this.getEngine(),o=this.getCamera();if(o)r=o.getScene();else if(i&&i.scenes){var a=i.scenes;r=a[a.length-1]}else r=Zo.a.LastCreatedScene;this._imageProcessingConfiguration=r.imageProcessingConfiguration}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){n._updateParameters()}))),t||this._updateParameters()}},Object.defineProperty(t.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingType",{get:function(){return this._imageProcessingConfiguration.toneMappingType},set:function(e){this._imageProcessingConfiguration.toneMappingType=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!0,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 t in this._defines)this._defines[t]&&(e+="#define "+t+";\r\n");var n=["textureSampler"],r=["scale"];Ms&&(Ms.PrepareSamplers(n,this._defines),Ms.PrepareUniforms(r,this._defines)),this.updateEffect(e,r,n)},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)},Object(No.c)([ha()],t.prototype,"_fromLinearSpace",void 0),t}(Xc);Pl._GroundMeshParser=function(e,t){return gd.Parse(e,t)};var gd=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.generateOctree=!1,r}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(t.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!0,configurable:!0}),t.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)},t.prototype.getHeightAtCoordinates=function(e,t){var n=this.getWorldMatrix(),r=Mo.Matrix[5];n.invertToRef(r);var i=Mo.Vector3[8];if(So.TransformCoordinatesFromFloatsToRef(e,0,t,r,i),e=i.x,t=i.z,ethis._maxX||tthis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var o=this._getFacetAt(e,t),a=-(o.x*e+o.z*t+o.w)/o.y;return So.TransformCoordinatesFromFloatsToRef(0,a,0,n,i),i.y},t.prototype.getNormalAtCoordinates=function(e,t){var n=new So(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,n),n},t.prototype.getNormalAtCoordinatesToRef=function(e,t,n){var r=this.getWorldMatrix(),i=Mo.Matrix[5];r.invertToRef(i);var o=Mo.Vector3[8];if(So.TransformCoordinatesFromFloatsToRef(e,0,t,i,o),e=o.x,t=o.z,ethis._maxX||tthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(e,t);return So.TransformNormalFromFloatsToRef(a.x,a.y,a.z,r,n),this},t.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},t.prototype._getFacetAt=function(e,t){var n=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),i=this._heightQuads[r*this._subdivisionsX+n];return te.maxHeight){c=!0;var u=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=u}for(t=0;t<=e.subdivisions;t++)for(n=0;n<=e.subdivisions;n++){var d=new So(n*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),h=4*(((d.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(d.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),p=e.buffer[h]/255,f=e.buffer[h+1]/255,m=e.buffer[h+2]/255,g=e.buffer[h+3]/255;c&&(p=1-p,f=1-f,m=1-m);var b=p*s.r+f*s.g+m*s.b;d.y=g>=l?e.minHeight+(e.maxHeight-e.minHeight)*b:e.minHeight-.001,i.push(d.x,d.y,d.z),o.push(0,0,0),a.push(n/e.subdivisions,1-t/e.subdivisions)}for(t=0;t=e.minHeight,w=i[3*A+1]>=e.minHeight,E=i[3*_+1]>=e.minHeight;x&&w&&E&&(r.push(v),r.push(A),r.push(_)),i[3*y+1]>=e.minHeight&&x&&E&&(r.push(y),r.push(v),r.push(_))}us.ComputeNormals(i,r,o);var C=new us;return C.indices=r,C.positions=i,C.normals=o,C.uvs=a,C},Pl.CreateGround=function(e,t,n,r,i,o){var a={width:t,height:n,subdivisions:r,updatable:o};return bd.CreateGround(e,a,i)},Pl.CreateTiledGround=function(e,t,n,r,i,o,a,s,l){var c={xmin:t,zmin:n,xmax:r,zmax:i,subdivisions:o,precision:a,updatable:l};return bd.CreateTiledGround(e,c,s)},Pl.CreateGroundFromHeightMap=function(e,t,n,r,i,o,a,s,l,c,u){var d={width:n,height:r,subdivisions:i,minHeight:o,maxHeight:a,updatable:l,onReady:c,alphaFilter:u};return bd.CreateGroundFromHeightMap(e,t,d,s)};var bd=function(){function e(){}return e.CreateGround=function(e,t,n){var r=new gd(e,n);return r._setReady(!1),r._subdivisionsX=t.subdivisionsX||t.subdivisions||1,r._subdivisionsY=t.subdivisionsY||t.subdivisions||1,r._width=t.width||1,r._height=t.height||1,r._maxX=r._width/2,r._maxZ=r._height/2,r._minX=-r._maxX,r._minZ=-r._maxZ,us.CreateGround(t).applyToMesh(r,t.updatable),r._setReady(!0),r},e.CreateTiledGround=function(e,t,n){void 0===n&&(n=null);var r=new Pl(e,n);return us.CreateTiledGround(t).applyToMesh(r,t.updatable),r},e.CreateGroundFromHeightMap=function(e,t,n,r){void 0===r&&(r=null);var i=n.width||10,o=n.height||10,a=n.subdivisions||1,s=n.minHeight||0,l=n.maxHeight||1,c=n.colorFilter||new Io(.3,.59,.11),u=n.alphaFilter||0,d=n.updatable,h=n.onReady;r=r||Zo.a.LastCreatedScene;var p=new gd(e,r);p._subdivisionsX=a,p._subdivisionsY=a,p._width=i,p._height=o,p._maxX=p._width/2,p._maxZ=p._height/2,p._minX=-p._maxX,p._minZ=-p._maxZ,p._setReady(!1);return Ja.LoadImage(t,(function(e){var t=e.width,n=e.height,f=wl.a.CreateCanvas(t,n).getContext("2d");if(!f)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!r.isDisposed){f.drawImage(e,0,0);var m=f.getImageData(0,0,t,n).data;us.CreateGroundFromHeightMap({width:i,height:o,subdivisions:a,minHeight:s,maxHeight:l,colorFilter:c,buffer:m,bufferWidth:t,bufferHeight:n,alphaFilter:u}).applyToMesh(p,d),h&&h(p),p._setReady(!0)}}),(function(){}),r.offlineProvider),p},e}();us.CreateTorus=function(e){for(var t=[],n=[],r=[],i=[],o=e.diameter||1,a=e.thickness||.5,s=e.tessellation||16,l=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,c=s+1,u=0;u<=s;u++)for(var d=u/s,h=u*Math.PI*2/s-Math.PI/2,p=Oo.Translation(o/2,0,0).multiply(Oo.RotationY(h)),f=0;f<=s;f++){var m=1-f/s,g=f*Math.PI*2/s+Math.PI,b=Math.cos(g),v=Math.sin(g),A=new So(b,v,0),_=A.scale(a/2),y=new Co(d,m);_=So.TransformCoordinates(_,p),A=So.TransformNormal(A,p),n.push(_.x,_.y,_.z),r.push(A.x,A.y,A.z),i.push(y.x,y.y);var x=(u+1)%c,w=(f+1)%c;t.push(u*c+f),t.push(u*c+w),t.push(x*c+f),t.push(u*c+w),t.push(x*c+w),t.push(x*c+f)}us._ComputeSides(l,n,t,r,i,e.frontUVs,e.backUVs);var E=new us;return E.indices=t,E.positions=n,E.normals=r,E.uvs=i,E},Pl.CreateTorus=function(e,t,n,r,i,o,a){var s={diameter:t,thickness:n,tessellation:r,sideOrientation:a,updatable:o};return vd.CreateTorus(e,s,i)};var vd=function(){function e(){}return e.CreateTorus=function(e,t,n){var r=new Pl(e,n);return t.sideOrientation=Pl._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,us.CreateTorus(t).applyToMesh(r,t.updatable),r},e}();us.CreateCylinder=function(e){var t=e.height||2,n=0===e.diameterTop?0:e.diameterTop||e.diameter||1,r=0===e.diameterBottom?0:e.diameterBottom||e.diameter||1;n=n||1e-5,r=r||1e-5;var i,o=e.tessellation||24,a=e.subdivisions||1,s=!!e.hasRings,l=!!e.enclose,c=0===e.cap?0:e.cap||Pl.CAP_ALL,u=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,d=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,h=e.faceUV||new Array(3),p=e.faceColors,f=2+(1+(1!==u&&l?2:0))*(s?a:1);for(i=0;i=0){r=n[i],this.webVRController._pointingPoseNode=r;break}this._laserPointer.parent=r},t.prototype._updatePointerDistance=function(e){void 0===e&&(e=100),this._laserPointer.scaling.y=e,this._laserPointer.position.z=-e/2},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._laserPointer.dispose(),this._meshAttachedObserver&&this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)},t}(Cd),Td=function(e){function t(t,n){var r=e.call(this,n)||this;return r.getCamera=t,r}return Object(No.d)(t,e),t.prototype._getForwardRay=function(e){var t=this.getCamera();return t?t.getForwardRay(e):new Vl(So.Zero(),So.Forward())},t}(Cd),Pd=function(){function e(t,n){var r=this;if(void 0===n&&(n={}),this.webVROptions=n,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.enableGazeEvenWhenNoPointerLock=!1,this.exitVROnDoubleTap=!0,this.onEnteringVRObservable=new yo.a,this.onAfterEnteringVRObservable=new yo.a,this.onExitingVRObservable=new yo.a,this.onControllerMeshLoadedObservable=new yo.a,this._useCustomVRButton=!1,this._teleportationRequested=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._teleportationMode=e.TELEPORTATIONMODE_CONSTANTTIME,this._teleportationTime=122,this._teleportationSpeed=20,this._rotationAllowed=!0,this._teleportBackwardsVector=new So(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new So(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this._gazeColor=new Io(.7,.7,.7),this._laserColor=new Io(.7,.7,.7),this._pickedLaserColor=new Io(.2,.2,1),this._pickedGazeColor=new Io(0,0,1),this.onNewMeshSelected=new yo.a,this.onMeshSelectedWithController=new yo.a,this.onNewMeshPicked=new yo.a,this.onBeforeCameraTeleport=new yo.a,this.onAfterCameraTeleport=new yo.a,this.onSelectedMeshUnselected=new yo.a,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(){r.moveButtonToBottomRight(),r._fullscreenVRpresenting&&r._webVRready&&r.exitVR()},this._onFullscreenChange=function(){var e=document;void 0!==e.fullscreen?r._fullscreenVRpresenting=document.fullscreen:void 0!==e.mozFullScreen?r._fullscreenVRpresenting=e.mozFullScreen:void 0!==e.webkitIsFullScreen?r._fullscreenVRpresenting=e.webkitIsFullScreen:void 0!==e.msIsFullScreen?r._fullscreenVRpresenting=e.msIsFullScreen:void 0!==document.msFullscreenElement&&(r._fullscreenVRpresenting=document.msFullscreenElement),!r._fullscreenVRpresenting&&r._inputElement&&(r.exitVR(),!r._useCustomVRButton&&r._btnVR&&(r._btnVR.style.top=r._inputElement.offsetTop+r._inputElement.offsetHeight-70+"px",r._btnVR.style.left=r._inputElement.offsetLeft+r._inputElement.offsetWidth-100+"px",r.updateButtonVisibility()))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this.beforeRender=function(){r._leftController&&r._leftController._activePointer&&r._castRayAndSelectObject(r._leftController),r._rightController&&r._rightController._activePointer&&r._castRayAndSelectObject(r._rightController),r._noControllerIsActive&&(r._scene.getEngine().isPointerLock||r.enableGazeEvenWhenNoPointerLock)?r._castRayAndSelectObject(r._cameraGazer):r._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(e){if(e.type!==ec.POSE_ENABLED)e.leftStick&&e.onleftstickchanged((function(e){r._teleportationInitialized&&r.teleportationEnabled&&(!r._leftController&&!r._rightController||r._leftController&&!r._leftController._activePointer&&r._rightController&&!r._rightController._activePointer)&&(r._checkTeleportWithRay(e,r._cameraGazer),r._checkTeleportBackwards(e,r._cameraGazer))})),e.rightStick&&e.onrightstickchanged((function(e){r._teleportationInitialized&&r._checkRotate(e,r._cameraGazer)})),e.type===ec.XBOX&&(e.onbuttondown((function(e){r._interactionsEnabled&&e===kc.A&&r._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){r._interactionsEnabled&&e===kc.A&&r._cameraGazer._selectionPointerUp()})));else{var t=e,n=new Sd(t,r._scene,r._cameraGazer._gazeTracker);"right"===t.hand||r._leftController&&r._leftController.webVRController!=t?r._rightController=n:r._leftController=n,r._tryEnableInteractionOnController(n)}},this._tryEnableInteractionOnController=function(e){r._interactionsRequested&&!e._interactionsEnabled&&r._enableInteractionOnController(e),r._teleportationRequested&&!e._teleportationEnabled&&r._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(e){e instanceof wu&&("left"===e.hand&&null!=r._leftController&&(r._leftController.dispose(),r._leftController=null),"right"===e.hand&&null!=r._rightController&&(r._rightController.dispose(),r._rightController=null))},this._workingVector=So.Zero(),this._workingQuaternion=Po.Identity(),this._workingMatrix=Oo.Identity(),this._scene=t,this._inputElement=t.getEngine().getInputElement(),"getVRDisplays"in navigator||(n.useXR=!0),void 0===n.createFallbackVRDeviceOrientationFreeCamera&&(n.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===n.createDeviceOrientationCamera&&(n.createDeviceOrientationCamera=!0),void 0===n.laserToggle&&(n.laserToggle=!0),void 0===n.defaultHeight&&(n.defaultHeight=1.7),n.useCustomVRButton&&(this._useCustomVRButton=!0,n.customVRButton&&(this._btnVR=n.customVRButton)),n.rayLength&&(this._rayLength=n.rayLength),this._defaultHeight=n.defaultHeight,n.positionScale&&(this._rayLength*=n.positionScale,this._defaultHeight*=n.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new So(0,this._defaultHeight,0),n.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new Tc("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 wc&&this._scene.activeCamera.rotation)){var i=this._scene.activeCamera;i.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(i.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(Po.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(this._inputElement)}else this._existingCamera=this._scene.activeCamera;this.webVROptions.useXR&&navigator.xr?wd.IsSessionSupportedAsync("immersive-vr").then((function(e){e?(jo.a.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),t.createDefaultXRExperienceAsync({floorMeshes:n.floorMeshes||[]}).then((function(e){r.xr=e,r.xrTestDone=!0,r._cameraGazer=new Td((function(){return r.xr.baseExperience.camera}),t),r.xr.baseExperience.onStateChangedObservable.add((function(e){switch(e){case Ad.ENTERING_XR:r.onEnteringVRObservable.notifyObservers(r),r._interactionsEnabled||r.xr.pointerSelection.detach(),r.xr.pointerSelection.displayLaserPointer=r._displayLaserPointer;break;case Ad.EXITING_XR:r.onExitingVRObservable.notifyObservers(r),r._scene.getEngine().resize();break;case Ad.IN_XR:r._hasEnteredVR=!0;break;case Ad.NOT_IN_XR:r._hasEnteredVR=!1}}))}))):r.completeVRInit(t,n)})):this.completeVRInit(t,n)}return Object.defineProperty(e.prototype,"onEnteringVR",{get:function(){return this.onEnteringVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onExitingVR",{get:function(){return this.onExitingVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onControllerMeshLoaded",{get:function(){return this.onControllerMeshLoadedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"teleportationTarget",{get:function(){return this._teleportationTarget},set:function(e){e&&(e.name="teleportationTarget",this._isDefaultTeleportationTarget=!1,this._teleportationTarget=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gazeTrackerMesh",{get:function(){return this._cameraGazer._gazeTracker},set:function(e){e&&(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=e,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:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftControllerGazeTrackerMesh",{get:function(){return this._leftController?this._leftController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightControllerGazeTrackerMesh",{get:function(){return this._rightController?this._rightController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayGaze",{get:function(){return this._displayGaze},set:function(e){this._displayGaze=e,e||(this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayLaserPointer",{get:function(){return this._displayLaserPointer},set:function(e){this._displayLaserPointer=e,e?(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:!0,configurable:!0}),Object.defineProperty(e.prototype,"deviceOrientationCamera",{get:function(){return this._deviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentVRCamera",{get:function(){return this._webVRready?this._webVRCamera:this._scene.activeCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"webVRCamera",{get:function(){return this._webVRCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vrDeviceOrientationCamera",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vrButton",{get:function(){return this._btnVR},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_teleportationRequestInitiated",{get:function(){return this._cameraGazer._teleportationRequestInitiated||null!==this._leftController&&this._leftController._teleportationRequestInitiated||null!==this._rightController&&this._rightController._teleportationRequestInitiated},enumerable:!0,configurable:!0}),e.prototype.completeVRInit=function(e,t){var n=this;if(this.xrTestDone=!0,t.createFallbackVRDeviceOrientationFreeCamera&&(t.useMultiview&&(t.vrDeviceOrientationCameraMetrics||(t.vrDeviceOrientationCameraMetrics=du.GetDefault()),t.vrDeviceOrientationCameraMetrics.multiviewEnabled=!0),this._vrDeviceOrientationCamera=new Au("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new xu("WebVRHelper",this._position,this._scene,t),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new Td((function(){return n.currentVRCamera}),e),!this._useCustomVRButton){this._btnVR=document.createElement("BUTTON"),this._btnVR.className="babylonVRicon",this._btnVR.id="babylonVRiconbtn",this._btnVR.title="Click to switch to VR";var r=".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) }";r+=".babylonVRicon.vrdisplaypresenting { display: none; }";var i=document.createElement("style");i.appendChild(document.createTextNode(r)),document.getElementsByTagName("head")[0].appendChild(i),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",(function(){n.isInVRMode?n._scene.getEngine().disableVR():n.enterVR()}));var o=this._scene.getEngine().getHostWindow();o&&(o.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,t.createFallbackVRDeviceOrientationFreeCamera?this.displayVRButton():this._scene.getEngine().onVRDisplayChangedObservable.add((function(e){e.vrDisplay&&n.displayVRButton()})),this._onKeyDown=function(e){27===e.keyCode&&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())}),Qs.POINTERDOUBLETAP,!1),this._onVRDisplayChanged=function(e){return n.onVRDisplayChanged(e)},this._onVrDisplayPresentChange=function(){return n.onVrDisplayPresentChange()},this._onVRRequestPresentStart=function(){n._webVRrequesting=!0,n.updateButtonVisibility()},this._onVRRequestPresentComplete=function(){n._webVRrequesting=!1,n.updateButtonVisibility()},e.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged),e.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),e.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),o.addEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),e.onDisposeObservable.add((function(){n.dispose()})),this._webVRCamera.onControllerMeshLoadedObservable.add((function(e){return n._onDefaultMeshLoaded(e)})),this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),this.updateButtonVisibility(),this._circleEase=new ml,this._circleEase.setEasingMode(fl.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,e.onPointerObservable.add((function(t){n._interactionsEnabled&&e.activeCamera===n.vrDeviceOrientationCamera&&"mouse"===t.event.pointerType&&(t.type===Qs.POINTERDOWN?n._cameraGazer._selectionPointerDown():t.type===Qs.POINTERUP&&n._cameraGazer._selectionPointerUp())})),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes}))},e.prototype._onDefaultMeshLoaded=function(e){this._leftController&&this._leftController.webVRController==e&&e.mesh&&this._leftController._setLaserPointerParent(e.mesh),this._rightController&&this._rightController.webVRController==e&&e.mesh&&this._rightController._setLaserPointerParent(e.mesh);try{this.onControllerMeshLoadedObservable.notifyObservers(e)}catch(e){jo.a.Warn("Error in your custom logic onControllerMeshLoaded: "+e)}},Object.defineProperty(e.prototype,"isInVRMode",{get:function(){return this.xr&&this.webVROptions.useXR&&this.xr.baseExperience.state===Ad.IN_XR||this._webVRpresenting||this._fullscreenVRpresenting},enumerable:!0,configurable:!0}),e.prototype.onVrDisplayPresentChange=function(){var e=this._scene.getEngine().getVRDevice();if(e){var t=this._webVRpresenting;this._webVRpresenting=e.isPresenting,t&&!this._webVRpresenting&&this.exitVR()}else jo.a.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");this.updateButtonVisibility()},e.prototype.onVRDisplayChanged=function(e){this._webVRsupported=e.vrSupported,this._webVRready=!!e.vrDisplay,this._webVRpresenting=e.vrDisplay&&e.vrDisplay.isPresenting,this.updateButtonVisibility()},e.prototype.moveButtonToBottomRight=function(){if(this._inputElement&&!this._useCustomVRButton&&this._btnVR){var e=this._inputElement.getBoundingClientRect();this._btnVR.style.top=e.top+e.height-70+"px",this._btnVR.style.left=e.left+e.width-100+"px"}},e.prototype.displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||!this._btnVR||(document.body.appendChild(this._btnVR),this._btnVRDisplayed=!0)},e.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")))},e.prototype.enterVR=function(){var e=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(e){jo.a.Warn("Error in your custom logic onEnteringVR: "+e)}if(this._scene.activeCamera){if(this._position=this._scene.activeCamera.position.clone(),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.rotation=Po.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this.webVRCamera){var t=this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y,n=Po.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y-t,r=this.webVRCamera.rotationQuaternion.toEulerAngles().y;this.webVRCamera.rotationQuaternion=Po.FromEulerAngles(0,r+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(t){e.onAfterEnteringVRObservable.notifyObservers({success:t})})),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(){e.onAfterEnteringVRObservable.notifyObservers({success:!0})}))),this._scene.activeCamera&&this._inputElement&&this._scene.activeCamera.attachControl(this._inputElement),this._interactionsEnabled&&this._scene.registerBeforeRender(this.beforeRender),this._displayLaserPointer&&[this._leftController,this._rightController].forEach((function(e){e&&e._activatePointer()})),this._hasEnteredVR=!0)}},e.prototype.exitVR=function(){if(this.xr)this.xr.baseExperience.exitXRAsync();else if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(e){jo.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._inputElement),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 e=this._scene.getEngine();e._onVrDisplayPresentChange&&e._onVrDisplayPresentChange()}},Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._scene.activeCamera&&(this._scene.activeCamera.position=e)},enumerable:!0,configurable:!0}),e.prototype.enableInteractions=function(){var e=this;if(!this._interactionsEnabled){if(this._interactionsRequested=!0,this.xr)return void(this.xr.baseExperience.state===Ad.IN_XR&&this.xr.pointerSelection.attach());this._leftController&&this._enableInteractionOnController(this._leftController),this._rightController&&this._enableInteractionOnController(this._rightController),this.raySelectionPredicate=function(t){return t.isVisible&&(t.isPickable||t.name===e._floorMeshName)},this.meshSelectionPredicate=function(){return!0},this._raySelectionPredicate=function(t){return!!(e._isTeleportationFloor(t)||-1===t.name.indexOf("gazeTracker")&&-1===t.name.indexOf("teleportationTarget")&&-1===t.name.indexOf("torusTeleportation"))&&e.raySelectionPredicate(t)},this._interactionsEnabled=!0}},Object.defineProperty(e.prototype,"_noControllerIsActive",{get:function(){return!(this._leftController&&this._leftController._activePointer||this._rightController&&this._rightController._activePointer)},enumerable:!0,configurable:!0}),e.prototype._isTeleportationFloor=function(e){for(var t=0;t-1||this._floorMeshesCollection.push(e))},e.prototype.removeFloorMesh=function(e){if(this._floorMeshesCollection){var t=this._floorMeshesCollection.indexOf(e);-1!==t&&this._floorMeshesCollection.splice(t,1)}},e.prototype.enableTeleportation=function(e){var t=this;if(void 0===e&&(e={}),!this._teleportationInitialized){if(this._teleportationRequested=!0,this.enableInteractions(),this.webVROptions.useXR&&(e.floorMeshes||e.floorMeshName)){var n=e.floorMeshes||[];if(!n.length){var r=this._scene.getMeshByName(e.floorMeshName);r&&n.push(r)}if(this.xr)return n.forEach((function(e){t.xr.teleportation.addFloorMesh(e)})),void(this.xr.teleportation.attached||this.xr.teleportation.attach());if(!this.xrTestDone){var i=function(){t.xrTestDone&&(t._scene.unregisterBeforeRender(i),t.xr?t.xr.teleportation.attached||t.xr.teleportation.attach():t.enableTeleportation(e))};return void this._scene.registerBeforeRender(i)}}e.floorMeshName&&(this._floorMeshName=e.floorMeshName),e.floorMeshes&&(this._floorMeshesCollection=e.floorMeshes),e.teleportationMode&&(this._teleportationMode=e.teleportationMode),e.teleportationTime&&e.teleportationTime>0&&(this._teleportationTime=e.teleportationTime),e.teleportationSpeed&&e.teleportationSpeed>0&&(this._teleportationSpeed=e.teleportationSpeed),void 0!==e.easingFunction&&(this._teleportationEasing=e.easingFunction),null!=this._leftController&&this._enableTeleportationOnController(this._leftController),null!=this._rightController&&this._enableTeleportationOnController(this._rightController);var o=new Ms;o.vignetteColor=new ko(0,0,0,0),o.vignetteEnabled=!0,this._postProcessMove=new md("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,o),this._webVRCamera.detachPostProcess(this._postProcessMove),this._teleportationInitialized=!0,this._isDefaultTeleportationTarget&&(this._createTeleportationCircles(),this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))}},e.prototype._enableInteractionOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled=!0,this.isInVRMode&&this._displayLaserPointer&&e._activatePointer(),this.webVROptions.laserToggle&&e.webVRController.onMainButtonStateChangedObservable.add((function(n){t._displayLaserPointer&&1===n.value&&(e._activePointer?e._deactivatePointer():e._activatePointer(),t.displayGaze&&(e._gazeTracker.isVisible=e._activePointer))})),e.webVRController.onTriggerStateChangedObservable.add((function(n){var r=e;t._noControllerIsActive&&(r=t._cameraGazer),r._pointerDownOnMeshAsked?n.valuet._padSensibilityUp&&r._selectionPointerDown()})))},e.prototype._checkTeleportWithRay=function(e,t){this._teleportationRequestInitiated&&!t._teleportationRequestInitiated||(t._teleportationRequestInitiated?Math.sqrt(e.y*e.y+e.x*e.x)-this._padSensibilityDown&&(t._rotationLeftAsked=!1):e.x<-this._padSensibilityUp&&t._dpadPressed&&(t._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),t._rotationRightAsked?e.xthis._padSensibilityUp&&t._dpadPressed&&(t._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},e.prototype._checkTeleportBackwards=function(e,t){if(!t._teleportationRequestInitiated)if(e.y>this._padSensibilityUp&&t._dpadPressed){if(!t._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var n=Po.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),r=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(n=this.currentVRCamera.deviceRotationQuaternion,r=this.currentVRCamera.devicePosition),n.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,Po.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),So.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var i=new Vl(r,this._workingVector),o=this._scene.pickWithRay(i,this._raySelectionPredicate);o&&o.pickedPoint&&o.pickedMesh&&this._isTeleportationFloor(o.pickedMesh)&&o.distance<5&&this.teleportCamera(o.pickedPoint),t._teleportationBackRequestInitiated=!0}}else t._teleportationBackRequestInitiated=!1},e.prototype._enableTeleportationOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled||this._enableInteractionOnController(e),e._interactionsEnabled=!0,e._teleportationEnabled=!0,e.webVRController.controllerType===Rc.VIVE&&(e._dpadPressed=!1,e.webVRController.onPadStateChangedObservable.add((function(t){e._dpadPressed=t.pressed,e._dpadPressed||(e._rotationLeftAsked=!1,e._rotationRightAsked=!1,e._teleportationBackRequestInitiated=!1)}))),e.webVRController.onPadValuesChangedObservable.add((function(n){t.teleportationEnabled&&(t._checkTeleportBackwards(n,e),t._checkTeleportWithRay(n,e)),t._checkRotate(n,e)})))},e.prototype._createTeleportationCircles=function(){this._teleportationTarget=Pl.CreateGround("teleportationTarget",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var e=new pd("DynamicTexture",512,this._scene,!0);e.hasAlpha=!0;var t=e.getContext();t.beginPath(),t.arc(256,256,200,0,2*Math.PI,!1),t.fillStyle=this._teleportationFillColor,t.fill(),t.lineWidth=10,t.strokeStyle=this._teleportationBorderColor,t.stroke(),t.closePath(),e.update();var n=new hd("TextPlaneMaterial",this._scene);n.diffuseTexture=e,this._teleportationTarget.material=n;var r=Pl.CreateTorus("torusTeleportation",.75,.1,25,this._scene,!1);r.isPickable=!1,r.parent=this._teleportationTarget;var i=new Ca("animationInnerCircle","position.y",30,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:0}),o.push({frame:30,value:.4}),o.push({frame:60,value:0}),i.setKeys(o);var a=new vl;a.setEasingMode(fl.EASINGMODE_EASEINOUT),i.setEasingFunction(a),r.animations=[],r.animations.push(i),this._scene.beginAnimation(r,0,60,!0),this._hideTeleportationTarget()},e.prototype._displayTeleportationTarget=function(){this._teleportActive=!0,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!0,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!0))},e.prototype._hideTeleportationTarget=function(){this._teleportActive=!1,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!1,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!1))},e.prototype._rotateCamera=function(e){var t=this;if(this.currentVRCamera instanceof Ec){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var n=Po.FromRotationMatrix(Oo.RotationY(Math.PI/4*this._rotationAngle)),r=new Ca("animationRotation","rotationQuaternion",90,Ca.ANIMATIONTYPE_QUATERNION,Ca.ANIMATIONLOOPMODE_CONSTANT),i=[];i.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),i.push({frame:6,value:n}),r.setKeys(i),r.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(r),this._postProcessMove.animations=[];var o=new Ca("animationPP","vignetteWeight",90,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CONSTANT),a=[];a.push({frame:0,value:0}),a.push({frame:3,value:4}),a.push({frame:6,value:0}),o.setKeys(a),o.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(o);var s=new Ca("animationPP2","vignetteStretch",90,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CONSTANT),l=[];l.push({frame:0,value:0}),l.push({frame:3,value:10}),l.push({frame:6,value:0}),s.setKeys(l),s.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(s),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(){t._webVRCamera.detachPostProcess(t._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},e.prototype._moveTeleportationSelectorTo=function(e,t,n){if(e.pickedPoint){t._teleportationRequestInitiated&&(this._displayTeleportationTarget(),this._haloCenter.copyFrom(e.pickedPoint),this._teleportationTarget.position.copyFrom(e.pickedPoint));var r=this._convertNormalToDirectionOfRay(e.getNormal(!0,!1),n);if(r){var i=So.Cross(os.Y,r),o=So.Cross(r,i);So.RotationFromAxisToRef(o,r,i,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},e.prototype.teleportCamera=function(t){var n=this;if(this.currentVRCamera instanceof Ec){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 r,i;if(this._teleportationMode==e.TELEPORTATIONMODE_CONSTANTSPEED){i=90;var o=So.Distance(this.currentVRCamera.position,this._workingVector);r=this._teleportationSpeed/o}else i=Math.round(90*this._teleportationTime/1e3),r=1;this.currentVRCamera.animations=[];var a=new Ca("animationCameraTeleportation","position",90,Ca.ANIMATIONTYPE_VECTOR3,Ca.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 l=Math.round(i/2),c=new Ca("animationPP","vignetteWeight",90,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CONSTANT),u=[];u.push({frame:0,value:0}),u.push({frame:l,value:8}),u.push({frame:i,value:0}),c.setKeys(u),this._postProcessMove.animations.push(c);var d=new Ca("animationPP2","vignetteStretch",90,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CONSTANT),h=[];h.push({frame:0,value:0}),h.push({frame:l,value:10}),h.push({frame:i,value:0}),d.setKeys(h),this._postProcessMove.animations.push(d),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,i,!1,r,(function(){n._webVRCamera.detachPostProcess(n._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,i,!1,r,(function(){n.onAfterCameraTeleport.notifyObservers(n._workingVector)})),this._hideTeleportationTarget()}},e.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(So.Dot(e,t.direction))s){var l=s;s=a,a=l}return a>0&&a0&&s=0))},e.prototype._canDoCollision=function(e,t,n,r){var i=So.Distance(this._basePointWorld,e),o=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(i>this._velocityWorldLength+o+t)&&!!function(e,t,n,r){return!(e.x>n.x+r)&&(!(n.x-r>t.x)&&(!(e.y>n.y+r)&&(!(n.y-r>t.y)&&(!(e.z>n.z+r)&&!(n.z-r>t.z)))))}(n,r,this._basePointWorld,this._velocityWorldLength+o)},e.prototype._testTriangle=function(e,t,n,r,i,o,a){var s,l=!1;t||(t=[]),t[e]||(t[e]=new Cs(0,0,0,0),t[e].copyFromPoints(n,r,i));var c=t[e];if(o||c.isFrontFacingTo(this._normalizedVelocity,0)){var u=c.signedDistanceTo(this._basePoint),d=So.Dot(c.normal,this._velocity);if(0==d){if(Math.abs(u)>=1)return;l=!0,s=0}else{var h=(1-u)/d;if((s=(-1-u)/d)>h){var p=h;h=s,s=p}if(s>1||h<0)return;s<0&&(s=0),s>1&&(s=1)}this._collisionPoint.copyFromFloats(0,0,0);var f=!1,m=1;if(l||(this._basePoint.subtractToRef(c.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(s,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,r,i,c.normal)&&(f=!0,m=s,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!f){var g=this._velocity.lengthSquared(),b=g;this._basePoint.subtractToRef(n,this._tempVector);var v=2*So.Dot(this._velocity,this._tempVector),A=this._tempVector.lengthSquared()-1,_=Od(b,v,A,m);_.found&&(m=_.root,f=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(r,this._tempVector),v=2*So.Dot(this._velocity,this._tempVector),A=this._tempVector.lengthSquared()-1,(_=Od(b,v,A,m)).found&&(m=_.root,f=!0,this._collisionPoint.copyFrom(r)),this._basePoint.subtractToRef(i,this._tempVector),v=2*So.Dot(this._velocity,this._tempVector),A=this._tempVector.lengthSquared()-1,(_=Od(b,v,A,m)).found&&(m=_.root,f=!0,this._collisionPoint.copyFrom(i)),r.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex);var y=this._edge.lengthSquared(),x=So.Dot(this._edge,this._velocity),w=So.Dot(this._edge,this._baseToVertex);if(b=y*-g+x*x,v=y*(2*So.Dot(this._velocity,this._baseToVertex))-2*x*w,A=y*(1-this._baseToVertex.lengthSquared())+w*w,(_=Od(b,v,A,m)).found){var E=(x*_.root-w)/y;E>=0&&E<=1&&(m=_.root,f=!0,this._edge.scaleInPlace(E),n.addToRef(this._edge,this._collisionPoint))}i.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex),y=this._edge.lengthSquared(),x=So.Dot(this._edge,this._velocity),w=So.Dot(this._edge,this._baseToVertex),b=y*-g+x*x,v=y*(2*So.Dot(this._velocity,this._baseToVertex))-2*x*w,A=y*(1-this._baseToVertex.lengthSquared())+w*w,(_=Od(b,v,A,m)).found&&(E=(x*_.root-w)/y)>=0&&E<=1&&(m=_.root,f=!0,this._edge.scaleInPlace(E),r.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex),y=this._edge.lengthSquared(),x=So.Dot(this._edge,this._velocity),w=So.Dot(this._edge,this._baseToVertex),b=y*-g+x*x,v=y*(2*So.Dot(this._velocity,this._baseToVertex))-2*x*w,A=y*(1-this._baseToVertex.lengthSquared())+w*w,(_=Od(b,v,A,m)).found&&(E=(x*_.root-w)/y)>=0&&E<=1&&(m=_.root,f=!0,this._edge.scaleInPlace(E),i.addToRef(this._edge,this._collisionPoint))}if(f){var C=m*this._velocity.length();(!this.collisionFound||C=r)i.copyFrom(e);else{var s=o?o.collisionMask:n.collisionMask;n._initialize(e,t,a);for(var l=0;lthis.capacity&&this._depth-1&&this.entries.splice(n,1)}},e.prototype.addEntries=function(e){for(var t=0;t0)):!n._pointerCaptures[s.pointerId]&&o.distance>a.distance&&(n.mainSceneTrackerPredicate&&n.mainSceneTrackerPredicate(a.pickedMesh)?(n._notifyObservers(t,a,s),t.skipOnPointerObservable=!0):n._lastPointerEvents[s.pointerId]&&(n.onPointerOutObservable.notifyObservers(s.pointerId),delete n._lastPointerEvents[s.pointerId])),t.type===Qs.POINTERUP&&n._pointerCaptures[s.pointerId]&&(n._pointerCaptures[s.pointerId]=!1))}}}})),this._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterCameraRenderObservable.add((function(e){n.shouldRender&&e==n.getRenderCamera()&&n.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add((function(){n.dispose()})),this._updateCamera()}return e.prototype.getRenderCamera=function(e){if(this._renderCamera)return this._renderCamera;var t=void 0;return t=this.originalScene.activeCameras.length>1?this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:this.originalScene.activeCamera,e&&t&&t.isRigCamera?t.rigParent:t},e.prototype.setRenderCamera=function(e){this._renderCamera=e},e.prototype._getSharedGizmoLight=function(){return this._sharedGizmoLight||(this._sharedGizmoLight=new yu("shared gizmo light",new So(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=Io.Gray()),this._sharedGizmoLight},Object.defineProperty(e,"DefaultUtilityLayer",{get:function(){return null==e._DefaultUtilityLayer&&(e._DefaultUtilityLayer=new e(Zo.a.LastCreatedScene),e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultUtilityLayer=null}))),e._DefaultUtilityLayer},enumerable:!0,configurable:!0}),Object.defineProperty(e,"DefaultKeepDepthUtilityLayer",{get:function(){return null==e._DefaultKeepDepthUtilityLayer&&(e._DefaultKeepDepthUtilityLayer=new e(Zo.a.LastCreatedScene),e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultKeepDepthUtilityLayer=null}))),e._DefaultKeepDepthUtilityLayer},enumerable:!0,configurable:!0}),e.prototype._notifyObservers=function(e,t,n){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new Xs(e.type,e.event,t)),this._lastPointerEvents[n.pointerId]=!0)},e.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var e=this.utilityLayerScene.activeCamera.getScene(),t=this.utilityLayerScene.activeCamera;t._scene=this.utilityLayerScene,t.leftCamera&&(t.leftCamera._scene=this.utilityLayerScene),t.rightCamera&&(t.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),t._scene=e,t.leftCamera&&(t.leftCamera._scene=e),t.rightCamera&&(t.rightCamera._scene=e)}},e.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()},e.prototype._updateCamera=function(){this.utilityLayerScene.cameraToUseForPointers=this.getRenderCamera(),this.utilityLayerScene.activeCamera=this.getRenderCamera()},e._DefaultUtilityLayer=null,e._DefaultKeepDepthUtilityLayer=null,e}(),Nd=function(){function e(e){var t=this;void 0===e&&(e=Fd.DefaultUtilityLayer),this.gizmoLayer=e,this._attachedMesh=null,this.scaleRatio=1,this._customMeshSet=!1,this.updateGizmoRotationToMatchAttachedMesh=!0,this.updateGizmoPositionToMatchAttachedMesh=!0,this.updateScale=!0,this._interactionsEnabled=!0,this._tempVector=new So,this._rootMesh=new Pl("gizmoRootNode",e.utilityLayerScene),this._rootMesh.rotationQuaternion=Po.Identity(),this._beforeRenderObserver=this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add((function(){t._update()}))}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e,this._rootMesh.setEnabled(!!e),this._attachedMeshChanged(e)},enumerable:!0,configurable:!0}),e.prototype.setCustomMesh=function(e){if(e.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(e){e.dispose()})),e.parent=this._rootMesh,this._customMeshSet=!0},e.prototype._attachedMeshChanged=function(e){},e.prototype._update=function(){if(this.attachedMesh){var e=this.attachedMesh._effectiveMesh||this.attachedMesh;if(this.updateGizmoPositionToMatchAttachedMesh&&this._rootMesh.position.copyFrom(e.absolutePosition),this.updateGizmoRotationToMatchAttachedMesh?e.getWorldMatrix().decompose(void 0,this._rootMesh.rotationQuaternion):this._rootMesh.rotationQuaternion.set(0,0,0,1),this.updateScale){var t=this.gizmoLayer.utilityLayerScene.activeCamera,n=t.globalPosition;t.devicePosition&&(n=t.devicePosition),this._rootMesh.position.subtractToRef(n,this._tempVector);var r=this._tempVector.length()*this.scaleRatio;this._rootMesh.scaling.set(r,r,r),e._getWorldMatrixDeterminant()<0&&(this._rootMesh.scaling.y*=-1)}else this._rootMesh.scaling.setAll(this.scaleRatio)}},e.prototype.dispose=function(){this._rootMesh.dispose(),this._beforeRenderObserver&&this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},e}(),Ld=function(e){function t(n,r,i,o){void 0===r&&(r=Io.Gray()),void 0===i&&(i=Fd.DefaultUtilityLayer),void 0===o&&(o=null);var a=e.call(this,i)||this;a._pointerObserver=null,a.snapDistance=0,a.onSnapObservable=new yo.a,a._isEnabled=!0,a._parent=null,a._parent=o,a._coloredMaterial=new hd("",i.utilityLayerScene),a._coloredMaterial.diffuseColor=r,a._coloredMaterial.specularColor=r.subtract(new Io(.1,.1,.1)),a._hoverMaterial=new hd("",i.utilityLayerScene),a._hoverMaterial.diffuseColor=r.add(new Io(.3,.3,.3)),a._arrow=t._CreateArrow(i.utilityLayerScene,a._coloredMaterial),a._arrow.lookAt(a._rootMesh.position.add(n)),a._arrow.scaling.scaleInPlace(1/3),a._arrow.parent=a._rootMesh;var s=0,l=new So,c={snapDistance:0};a.dragBehavior=new Gl({dragAxis:n}),a.dragBehavior.moveAttached=!1,a._rootMesh.addBehavior(a.dragBehavior);var u=new So,d=new Oo;a.dragBehavior.onDragObservable.add((function(e){if(a.attachedMesh)if(a.attachedMesh.parent?(a.attachedMesh.parent.computeWorldMatrix().invertToRef(d),d.setTranslationFromFloats(0,0,0),So.TransformCoordinatesToRef(e.delta,d,u)):u.copyFrom(e.delta),0==a.snapDistance)a.attachedMesh.position.addInPlace(u);else if(s+=e.dragDistance,Math.abs(s)>a.snapDistance){var t=Math.floor(Math.abs(s)/a.snapDistance);s%=a.snapDistance,u.normalizeToRef(l),l.scaleInPlace(a.snapDistance*t),a.attachedMesh.position.addInPlace(l),c.snapDistance=a.snapDistance*t,a.onSnapObservable.notifyObservers(c)}})),a._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){if(!a._customMeshSet){var t=e.pickInfo&&-1!=a._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?a._hoverMaterial:a._coloredMaterial;a._rootMesh.getChildMeshes().forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))}}));var h=i._getSharedGizmoLight();return h.includedOnlyMeshes=h.includedOnlyMeshes.concat(a._rootMesh.getChildMeshes(!1)),a}return Object(No.d)(t,e),t._CreateArrow=function(e,t){var n=new as("arrow",e),r=_d.CreateCylinder("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375,tessellation:96},e),i=_d.CreateCylinder("cylinder",{diameterTop:.005,height:.275,diameterBottom:.005,tessellation:96},e);return i.material=t,r.parent=n,i.parent=n,r.material=t,r.rotation.x=Math.PI/2,r.position.z+=.3,i.position.z+=.1375,i.rotation.x=Math.PI/2,n},t._CreateArrowInstance=function(e,t){for(var n=new as("arrow",e),r=0,i=t.getChildMeshes();r0;)f.unshift(f.pop()),g.unshift(g.pop()),d--;for(;h>0;)m.unshift(m.pop()),b.unshift(b.pop()),h--;f=f.flat(),m=m.flat(),p=p.concat(f).concat(m),n.push(g[0],g[2],g[3],g[0],g[1],g[2]),n.push(b[0],b[2],b[3],b[0],b[1],b[2])}var v=[o/2,a/2,s/2];t=p.reduce((function(e,t,n){return e.concat(t*v[n%3])}),[]);for(var A=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,_=e.faceUV||new Array(6),y=e.faceColors,x=[],w=0;w<6;w++)void 0===_[w]&&(_[w]=new To(0,0,1,1)),y&&void 0===y[w]&&(y[w]=new ko(1,1,1,1));for(var E=0;E<6;E++)if(i.push(_[E].z,_[E].w),i.push(_[E].x,_[E].w),i.push(_[E].x,_[E].y),i.push(_[E].z,_[E].y),y)for(var C=0;C<4;C++)x.push(y[E].r,y[E].g,y[E].b,y[E].a);us._ComputeSides(A,t,n,r,i,e.frontUVs,e.backUVs);var S=new us;if(S.indices=n,S.positions=t,S.normals=r,S.uvs=i,y){var T=A===us.DOUBLESIDE?x.concat(x):x;S.colors=T}return S},Pl.CreateBox=function(e,t,n,r,i){void 0===n&&(n=null);var o={size:t,sideOrientation:i,updatable:r};return Vd.CreateBox(e,o,n)};var Vd=function(){function e(){}return e.CreateBox=function(e,t,n){void 0===n&&(n=null);var r=new Pl(e,n);return t.sideOrientation=Pl._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,us.CreateBox(t).applyToMesh(r,t.updatable),r},e}();us.CreateSphere=function(e){for(var t=e.segments||32,n=e.diameterX||e.diameter||1,r=e.diameterY||e.diameter||1,i=e.diameterZ||e.diameter||1,o=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,a=e.slice&&e.slice<=0?1:e.slice||1,s=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,l=new So(n/2,r/2,i/2),c=2+t,u=2*c,d=[],h=[],p=[],f=[],m=0;m<=c;m++){for(var g=m/c,b=g*Math.PI*a,v=0;v<=u;v++){var A=v/u,_=A*Math.PI*2*o,y=Oo.RotationZ(-b),x=Oo.RotationY(_),w=So.TransformCoordinates(So.Up(),y),E=So.TransformCoordinates(w,x),C=E.multiply(l),S=E.divide(l).normalize();h.push(C.x,C.y,C.z),p.push(S.x,S.y,S.z),f.push(A,g)}if(m>0)for(var T=h.length/3,P=T-2*(u+1);P+u+2100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=Po.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new Po),this._options.mass=void 0===n.mass?0:n.mass,this._options.friction=void 0===n.friction?.2:n.friction,this._options.restitution=void 0===n.restitution?.2:n.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=void 0===n.pressure?200:n.pressure,this._options.stiffness=void 0===n.stiffness?1:n.stiffness,this._options.velocityIterations=void 0===n.velocityIterations?20:n.velocityIterations,this._options.positionIterations=void 0===n.positionIterations?20:n.positionIterations,this._options.fixedPoints=void 0===n.fixedPoints?0:n.fixedPoints,this._options.margin=void 0===n.margin?0:n.margin,this._options.damping=void 0===n.damping?0:n.damping,this._options.path=void 0===n.path?null:n.path,this._options.shape=void 0===n.shape?null:n.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&jo.a.Warn("You must affect impostors to children before affecting impostor to parent.")):jo.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):jo.a.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mass",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(e){this.setMass(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"friction",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"restitution",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pressure",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.setBodyPressure?e.getBodyPressure(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPressure&&t.setBodyPressure(this,e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stiffness",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyStiffness?e.getBodyStiffness(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyStiffness&&t.setBodyStiffness(this,e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"velocityIterations",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyVelocityIterations?e.getBodyVelocityIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyVelocityIterations&&t.setBodyVelocityIterations(this,e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"positionIterations",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyPositionIterations?e.getBodyPositionIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPositionIterations&&t.setBodyPositionIterations(this,e)}},enumerable:!0,configurable:!0}),e.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))},e.prototype._getPhysicsParent=function(){return this.object.parent instanceof ws?this.object.parent.physicsImpostor:null},e.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&!this._parent},e.prototype.setScalingUpdated=function(){this.forceUpdate()},e.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(e.prototype,"physicsBody",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(e){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(e){this._parent=e},enumerable:!0,configurable:!0}),e.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},e.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion;this.object.rotationQuaternion=e.IDENTITY_QUATERNION,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);var n=this.object.getBoundingInfo().boundingBox.extendSizeWorld.scale(2);return this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),n}return e.DEFAULT_OBJECT_SIZE},e.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},e.prototype.getParam=function(e){return this._options[e]},e.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},e.prototype.setMass=function(e){this.getParam("mass")!==e&&this.setParam("mass",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},e.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):So.Zero()},e.prototype.setLinearVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},e.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):So.Zero()},e.prototype.setAngularVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},e.prototype.executeNativeFunction=function(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},e.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},e.prototype.unregisterBeforePhysicsStep=function(e){var t=this._onBeforePhysicsStepCallbacks.indexOf(e);t>-1?this._onBeforePhysicsStepCallbacks.splice(t,1):jo.a.Warn("Function to remove was not found")},e.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},e.prototype.unregisterAfterPhysicsStep=function(e){var t=this._onAfterPhysicsStepCallbacks.indexOf(e);t>-1?this._onAfterPhysicsStepCallbacks.splice(t,1):jo.a.Warn("Function to remove was not found")},e.prototype.registerOnPhysicsCollide=function(e,t){var n=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:n})},e.prototype.unregisterOnPhysicsCollide=function(e,t){var n=e instanceof Array?e:[e],r=-1;this._onPhysicsCollideCallbacks.some((function(e,i){if(e.callback===t&&e.otherImpostors.length===n.length){var o=e.otherImpostors.every((function(e){return n.indexOf(e)>-1}));return o&&(r=i),o}return!1}))?this._onPhysicsCollideCallbacks.splice(r,1):jo.a.Warn("Function to remove was not found")},e.prototype.getParentsRotation=function(){var e=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);e;)e.rotationQuaternion?this._tmpQuat2.copyFrom(e.rotationQuaternion):Po.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,e.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),e=e.parent;return this._tmpQuat},e.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},e.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},e.prototype.createJoint=function(e,t,n){var r=new jd(t,n);return this.addJoint(e,r),this},e.prototype.addJoint=function(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this},e.prototype.addAnchor=function(e,t,n,r,i){if(!this._physicsEngine)return this;var o=this._physicsEngine.getPhysicsPlugin();return o.appendAnchor?(this._physicsEngine&&o.appendAnchor(this,e,t,n,r,i),this):this},e.prototype.addHook=function(e,t,n,r){if(!this._physicsEngine)return this;var i=this._physicsEngine.getPhysicsPlugin();return i.appendAnchor?(this._physicsEngine&&i.appendHook(this,e,t,n,r),this):this},e.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},e.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},e.prototype.clone=function(t){return t?new e(t,this.type,this._options,this._scene):null},e.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine&&e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},e.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},e.prototype.setDeltaRotation=function(e){this._deltaRotation||(this._deltaRotation=new Po),this._deltaRotation.copyFrom(e),this._deltaRotationConjugated=this._deltaRotation.conjugate()},e.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},e.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},e.prototype.syncBoneWithImpostor=function(t,n,r,i,o){var a=e._tmpVecs[0],s=this.object;if(s.rotationQuaternion)if(o){var l=e._tmpQuat;s.rotationQuaternion.multiplyToRef(o,l),t.setRotationQuaternion(l,es.WORLD,n)}else t.setRotationQuaternion(s.rotationQuaternion,es.WORLD,n);a.x=0,a.y=0,a.z=0,r&&(a.x=r.x,a.y=r.y,a.z=r.z,t.getDirectionToRef(a,n,a),null==i&&(i=r.length()),a.x*=i,a.y*=i,a.z*=i),t.getParent()?(a.addInPlace(s.getAbsolutePosition()),t.setAbsolutePosition(a,n)):(n.setAbsolutePosition(s.getAbsolutePosition()),n.position.x-=a.x,n.position.y-=a.y,n.position.z-=a.z)},e.prototype.syncImpostorWithBone=function(t,n,r,i,o,a){var s=this.object;if(s.rotationQuaternion)if(o){var l=e._tmpQuat;t.getRotationQuaternionToRef(es.WORLD,n,l),l.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(es.WORLD,n,s.rotationQuaternion);var c=e._tmpVecs[0],u=e._tmpVecs[1];a||((a=e._tmpVecs[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,n,u),t.getAbsolutePositionToRef(n,c),null==i&&r&&(i=r.length()),null!=i&&(c.x+=u.x*i,c.y+=u.y*i,c.z+=u.z*i),s.setAbsolutePosition(c)},e.DEFAULT_OBJECT_SIZE=new So(1,1,1),e.IDENTITY_QUATERNION=Po.Identity(),e._tmpVecs=wo.BuildArray(3,So.Zero),e._tmpQuat=Po.Identity(),e.NoImpostor=0,e.SphereImpostor=1,e.BoxImpostor=2,e.PlaneImpostor=3,e.MeshImpostor=4,e.CapsuleImpostor=6,e.CylinderImpostor=7,e.ParticleImpostor=8,e.HeightmapImpostor=9,e.ConvexHullImpostor=10,e.CustomImpostor=100,e.RopeImpostor=101,e.ClothImpostor=102,e.SoftbodyImpostor=103,e}();!function(){function e(e){this._impostors=[],this._meshes=[],this._numMeshes=0,this._debugMeshMeshes=new Array,this._scene=e||Zo.a.LastCreatedScene;var t=this._scene.getPhysicsEngine();t&&(this._physicsEnginePlugin=t.getPhysicsPlugin()),this._utilityLayer=new Fd(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0}e.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t-1&&this._debugMeshMeshes.splice(o,1),this._numMeshes--,this._numMeshes>0?(this._meshes[r]=this._meshes[this._numMeshes],this._impostors[r]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)}},e.prototype._getDebugMaterial=function(e){return this._debugMaterial||(this._debugMaterial=new hd("",e),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=Io.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=Vd.CreateBox("physicsBodyBoxViewMesh",{size:1},e),this._debugBoxMesh.rotationQuaternion=Po.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(e),this._debugBoxMesh.setEnabled(!1)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugSphereMesh=function(e){return this._debugSphereMesh||(this._debugSphereMesh=zd.CreateSphere("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=Po.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(e),this._debugSphereMesh.setEnabled(!1)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugCylinderMesh=function(e){return this._debugCylinderMesh||(this._debugCylinderMesh=_d.CreateCylinder("physicsBodyCylinderViewMesh",{diameterTop:1,diameterBottom:1,height:1},e),this._debugCylinderMesh.rotationQuaternion=Po.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(e),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugMeshMesh=function(e,t){var n=new Pl(e.name,t,null,e);return n.position=So.Zero(),n.setParent(e),n.material=this._getDebugMaterial(t),this._debugMeshMeshes.push(n),n},e.prototype._getDebugMesh=function(e,t){var n=this;if(!this._utilityLayer)return null;if(t&&t.parent&&t.parent.physicsImpostor)return null;var r=null,i=this._utilityLayer.utilityLayerScene;switch(e.type){case Hd.BoxImpostor:r=this._getDebugBoxMesh(i),e.getBoxSizeToRef(r.scaling);break;case Hd.SphereImpostor:r=this._getDebugSphereMesh(i);var o=e.getRadius();r.scaling.x=2*o,r.scaling.y=2*o,r.scaling.z=2*o;break;case Hd.MeshImpostor:t&&(r=this._getDebugMeshMesh(t,i));break;case Hd.NoImpostor:if(t)t.getChildMeshes().filter((function(e){return e.physicsImpostor?1:0})).forEach((function(e){n._getDebugBoxMesh(i).parent=e}));break;case Hd.CylinderImpostor:r=this._getDebugCylinderMesh(i);var a=e.object.getBoundingInfo();r.scaling.x=a.boundingBox.maximum.x-a.boundingBox.minimum.x,r.scaling.y=a.boundingBox.maximum.y-a.boundingBox.minimum.y,r.scaling.z=a.boundingBox.maximum.z-a.boundingBox.minimum.z}return r},e.prototype.dispose=function(){for(var e=this._numMeshes,t=0;t0!=this._getWorldMatrixDeterminant()>0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),t){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1},t.prototype._postActivate=function(){this._edgesRenderer&&this._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup&&this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)},t.prototype.getWorldMatrix=function(){if(this._currentLOD&&this._currentLOD.billboardMode!==as.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){var t=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,Mo.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),Mo.Matrix[0].copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(Mo.Vector3[7]),this._currentLOD._masterMesh=t,Mo.Matrix[0]}return e.prototype.getWorldMatrix.call(this)},Object.defineProperty(t.prototype,"isAnInstance",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.getLOD=function(e){if(!e)return this;var t=this.getBoundingInfo();return this._currentLOD=this.sourceMesh.getLOD(e,t.boundingSphere),this._currentLOD===this.sourceMesh?this.sourceMesh:this._currentLOD},t.prototype._preActivateForIntermediateRendering=function(e){return this.sourceMesh._preActivateForIntermediateRendering(e)},t.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e1&&(this._multiview=!0,i.push("#define MULTIVIEW"),-1!==this._options.uniforms.indexOf("viewProjection")&&-1===this._options.uniforms.push("viewProjectionR")&&this._options.uniforms.push("viewProjectionR"));for(var s=0;s4&&(o.push(cs.MatricesIndicesExtraKind),o.push(cs.MatricesWeightsExtraKind));var l=e.skeleton;i.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),a.addCPUSkinningFallback(0,e),l.isUsingTextureForMatrices?(i.push("#define BONETEXTURE"),-1===this._options.uniforms.indexOf("boneTextureWidth")&&this._options.uniforms.push("boneTextureWidth"),-1===this._options.samplers.indexOf("boneSampler")&&this._options.samplers.push("boneSampler")):(i.push("#define BonesPerMesh "+(l.bones.length+1)),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones"))}else i.push("#define NUM_BONE_INFLUENCERS 0");for(var c in this._textures)if(!this._textures[c].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&i.push("#define ALPHATEST");var u=this._effect,d=i.join("\n");return this._effect=r.createEffect(this._shaderPath,{attributes:o,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:d,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},r),!!this._effect.isReady()&&(u!==this._effect&&n.resetCachedMaterial(),this._renderId=n.getRenderId(),this._effect._wasPreviouslyReady=!0,!0)},t.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();this._effect&&(-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&(e.multiplyToRef(t.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),this._effect.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)))},t.prototype.bind=function(e,t){if(this.bindOnlyWorldMatrix(e),this._effect&&this.getScene().getCachedMaterial()!==this){var n;for(n in-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&(this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._multiview&&this._effect.setMatrix("viewProjectionR",this.getScene()._transformMatrixR)),this.getScene().activeCamera&&-1!==this._options.uniforms.indexOf("cameraPosition")&&this._effect.setVector3("cameraPosition",this.getScene().activeCamera.globalPosition),Cu.BindBonesParameters(t,this._effect),this._textures)this._effect.setTexture(n,this._textures[n]);for(n in this._textureArrays)this._effect.setTextureArray(n,this._textureArrays[n]);for(n in this._ints)this._effect.setInt(n,this._ints[n]);for(n in this._floats)this._effect.setFloat(n,this._floats[n]);for(n in this._floatsArrays)this._effect.setArray(n,this._floatsArrays[n]);for(n in this._colors3)this._effect.setColor3(n,this._colors3[n]);for(n in this._colors3Arrays)this._effect.setArray3(n,this._colors3Arrays[n]);for(n in this._colors4){var r=this._colors4[n];this._effect.setFloat4(n,r.r,r.g,r.b,r.a)}for(n in this._colors4Arrays)this._effect.setArray4(n,this._colors4Arrays[n]);for(n in this._vectors2)this._effect.setVector2(n,this._vectors2[n]);for(n in this._vectors3)this._effect.setVector3(n,this._vectors3[n]);for(n in this._vectors4)this._effect.setVector4(n,this._vectors4[n]);for(n in this._matrices)this._effect.setMatrix(n,this._matrices[n]);for(n in this._matrixArrays)this._effect.setMatrices(n,this._matrixArrays[n]);for(n in this._matrices3x3)this._effect.setMatrix3x3(n,this._matrices3x3[n]);for(n in this._matrices2x2)this._effect.setMatrix2x2(n,this._matrices2x2[n]);for(n in this._vectors2Arrays)this._effect.setArray2(n,this._vectors2Arrays[n]);for(n in this._vectors3Arrays)this._effect.setArray3(n,this._vectors3Arrays[n]);for(n in this._vectors4Arrays)this._effect.setArray4(n,this._vectors4Arrays[n])}this._afterBind(t)},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);for(var n in this._textures)t.push(this._textures[n]);for(var n in this._textureArrays)for(var r=this._textureArrays[n],i=0;i0&&(t.push(a-1),t.push(a)),a++}var d=new us;return d.indices=t,d.positions=n,i&&(d.colors=o),d},us.CreateDashedLines=function(e){var t,n,r=e.dashSize||3,i=e.gapSize||1,o=e.dashNb||200,a=e.points,s=new Array,l=new Array,c=So.Zero(),u=0,d=0,h=0,p=0,f=0;for(f=0;f=0;a--){var s=e[a],l=s.getParent();if(l){var c=this._debugLines[r];c||(c=[So.Zero(),So.Zero()],this._debugLines[r]=c),s.getAbsolutePositionToRef(i,c[0]),l.getAbsolutePositionToRef(i,c[1]),c[0].subtractInPlace(o),c[1].subtractInPlace(o),r++}}},e.prototype.update=function(){if(this._utilityLayer){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();var e=this.mesh._effectiveMesh;void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,e.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,e.getWorldMatrix());var t=this._utilityLayer.utilityLayerScene;this._debugMesh?Zd.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},t):(this._debugMesh=Zd.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:null},t),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color}},e.prototype.dispose=function(){this.isEnabled=!1,this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null),this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null)}}(),function(){function e(){}e.ALPHA_DISABLE=0,e.ALPHA_ADD=1,e.ALPHA_COMBINE=2,e.ALPHA_SUBTRACT=3,e.ALPHA_MULTIPLY=4,e.ALPHA_MAXIMIZED=5,e.ALPHA_ONEONE=6,e.ALPHA_PREMULTIPLIED=7,e.ALPHA_PREMULTIPLIED_PORTERDUFF=8,e.ALPHA_INTERPOLATE=9,e.ALPHA_SCREENMODE=10,e.ALPHA_ONEONE_ONEONE=11,e.ALPHA_ALPHATOCOLOR=12,e.ALPHA_REVERSEONEMINUS=13,e.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,e.ALPHA_ONEONE_ONEZERO=15,e.ALPHA_EXCLUSION=16,e.ALPHA_EQUATION_ADD=0,e.ALPHA_EQUATION_SUBSTRACT=1,e.ALPHA_EQUATION_REVERSE_SUBTRACT=2,e.ALPHA_EQUATION_MAX=3,e.ALPHA_EQUATION_MIN=4,e.ALPHA_EQUATION_DARKEN=5,e.DELAYLOADSTATE_NONE=0,e.DELAYLOADSTATE_LOADED=1,e.DELAYLOADSTATE_LOADING=2,e.DELAYLOADSTATE_NOTLOADED=4,e.NEVER=512,e.ALWAYS=519,e.LESS=513,e.EQUAL=514,e.LEQUAL=515,e.GREATER=516,e.GEQUAL=518,e.NOTEQUAL=517,e.KEEP=7680,e.REPLACE=7681,e.INCR=7682,e.DECR=7683,e.INVERT=5386,e.INCR_WRAP=34055,e.DECR_WRAP=34056,e.TEXTURE_CLAMP_ADDRESSMODE=0,e.TEXTURE_WRAP_ADDRESSMODE=1,e.TEXTURE_MIRROR_ADDRESSMODE=2,e.TEXTUREFORMAT_ALPHA=0,e.TEXTUREFORMAT_LUMINANCE=1,e.TEXTUREFORMAT_LUMINANCE_ALPHA=2,e.TEXTUREFORMAT_RGB=4,e.TEXTUREFORMAT_RGBA=5,e.TEXTUREFORMAT_RED=6,e.TEXTUREFORMAT_R=6,e.TEXTUREFORMAT_RG=7,e.TEXTUREFORMAT_RED_INTEGER=8,e.TEXTUREFORMAT_R_INTEGER=8,e.TEXTUREFORMAT_RG_INTEGER=9,e.TEXTUREFORMAT_RGB_INTEGER=10,e.TEXTUREFORMAT_RGBA_INTEGER=11,e.TEXTURETYPE_UNSIGNED_BYTE=0,e.TEXTURETYPE_UNSIGNED_INT=0,e.TEXTURETYPE_FLOAT=1,e.TEXTURETYPE_HALF_FLOAT=2,e.TEXTURETYPE_BYTE=3,e.TEXTURETYPE_SHORT=4,e.TEXTURETYPE_UNSIGNED_SHORT=5,e.TEXTURETYPE_INT=6,e.TEXTURETYPE_UNSIGNED_INTEGER=7,e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,e.TEXTURETYPE_UNSIGNED_INT_24_8=12,e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,e.TEXTURE_NEAREST_SAMPLINGMODE=1,e.TEXTURE_NEAREST_NEAREST=1,e.TEXTURE_BILINEAR_SAMPLINGMODE=2,e.TEXTURE_LINEAR_LINEAR=2,e.TEXTURE_TRILINEAR_SAMPLINGMODE=3,e.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,e.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,e.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,e.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,e.TEXTURE_NEAREST_LINEAR=7,e.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,e.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,e.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,e.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,e.TEXTURE_LINEAR_NEAREST=12,e.TEXTURE_EXPLICIT_MODE=0,e.TEXTURE_SPHERICAL_MODE=1,e.TEXTURE_PLANAR_MODE=2,e.TEXTURE_CUBIC_MODE=3,e.TEXTURE_PROJECTION_MODE=4,e.TEXTURE_SKYBOX_MODE=5,e.TEXTURE_INVCUBIC_MODE=6,e.TEXTURE_EQUIRECTANGULAR_MODE=7,e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,e.SCALEMODE_FLOOR=1,e.SCALEMODE_NEAREST=2,e.SCALEMODE_CEILING=3,e.MATERIAL_TextureDirtyFlag=1,e.MATERIAL_LightDirtyFlag=2,e.MATERIAL_FresnelDirtyFlag=4,e.MATERIAL_AttributesDirtyFlag=8,e.MATERIAL_MiscDirtyFlag=16,e.MATERIAL_AllDirtyFlag=31,e.MATERIAL_TriangleFillMode=0,e.MATERIAL_WireFrameFillMode=1,e.MATERIAL_PointFillMode=2,e.MATERIAL_PointListDrawMode=3,e.MATERIAL_LineListDrawMode=4,e.MATERIAL_LineLoopDrawMode=5,e.MATERIAL_LineStripDrawMode=6,e.MATERIAL_TriangleStripDrawMode=7,e.MATERIAL_TriangleFanDrawMode=8,e.MATERIAL_ClockWiseSideOrientation=0,e.MATERIAL_CounterClockWiseSideOrientation=1,e.ACTION_NothingTrigger=0,e.ACTION_OnPickTrigger=1,e.ACTION_OnLeftPickTrigger=2,e.ACTION_OnRightPickTrigger=3,e.ACTION_OnCenterPickTrigger=4,e.ACTION_OnPickDownTrigger=5,e.ACTION_OnDoublePickTrigger=6,e.ACTION_OnPickUpTrigger=7,e.ACTION_OnPickOutTrigger=16,e.ACTION_OnLongPressTrigger=8,e.ACTION_OnPointerOverTrigger=9,e.ACTION_OnPointerOutTrigger=10,e.ACTION_OnEveryFrameTrigger=11,e.ACTION_OnIntersectionEnterTrigger=12,e.ACTION_OnIntersectionExitTrigger=13,e.ACTION_OnKeyDownTrigger=14,e.ACTION_OnKeyUpTrigger=15,e.PARTICLES_BILLBOARDMODE_Y=2,e.PARTICLES_BILLBOARDMODE_ALL=7,e.PARTICLES_BILLBOARDMODE_STRETCHED=8,e.MESHES_CULLINGSTRATEGY_STANDARD=0,e.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,e.SCENELOADER_NO_LOGGING=0,e.SCENELOADER_MINIMAL_LOGGING=1,e.SCENELOADER_SUMMARY_LOGGING=2,e.SCENELOADER_DETAILED_LOGGING=3}(),n(134),function(){this._timeElapsedQueryEnded=!1}),$d=function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=ws.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=ws.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE};ss.a.prototype.createQuery=function(){return this._gl.createQuery()},ss.a.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},ss.a.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},ss.a.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},ss.a.prototype.beginOcclusionQuery=function(e,t){var n=this._getGlAlgorithmType(e);return this._gl.beginQuery(n,t),this},ss.a.prototype.endOcclusionQuery=function(e){var t=this._getGlAlgorithmType(e);return this._gl.endQuery(t),this},ss.a.prototype._createTimeQuery=function(){var e=this.getCaps().timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},ss.a.prototype._deleteTimeQuery=function(e){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(e):this.deleteQuery(e)},ss.a.prototype._getTimeQueryResult=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},ss.a.prototype._getTimeQueryAvailability=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},ss.a.prototype.startTimeQuery=function(){var e=this.getCaps(),t=e.timerQuery;if(!t)return null;var n=new Jd;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),e.canUseTimestampForTimerQuery)n._startTimeQuery=this._createTimeQuery(),t.queryCounterEXT(n._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;n._timeElapsedQuery=this._createTimeQuery(),t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,n._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,n._timeElapsedQuery),this._currentNonTimestampToken=n}return n},ss.a.prototype.endTimeQuery=function(e){var t=this.getCaps(),n=t.timerQuery;if(!n||!e)return-1;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery)return-1;e._endTimeQuery||(e._endTimeQuery=this._createTimeQuery(),n.queryCounterEXT(e._endTimeQuery,n.TIMESTAMP_EXT))}else if(!e._timeElapsedQueryEnded){if(!e._timeElapsedQuery)return-1;n.endQueryEXT?n.endQueryEXT(n.TIME_ELAPSED_EXT):this._gl.endQuery(n.TIME_ELAPSED_EXT),e._timeElapsedQueryEnded=!0}var r=this._gl.getParameter(n.GPU_DISJOINT_EXT),i=!1;if(e._endTimeQuery?i=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(i=this._getTimeQueryAvailability(e._timeElapsedQuery)),i&&!r){var o=0;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var a=this._getTimeQueryResult(e._startTimeQuery);o=this._getTimeQueryResult(e._endTimeQuery)-a,this._deleteTimeQuery(e._startTimeQuery),this._deleteTimeQuery(e._endTimeQuery),e._startTimeQuery=null,e._endTimeQuery=null}else{if(!e._timeElapsedQuery)return-1;o=this._getTimeQueryResult(e._timeElapsedQuery),this._deleteTimeQuery(e._timeElapsedQuery),e._timeElapsedQuery=null,e._timeElapsedQueryEnded=!1,this._currentNonTimestampToken=null}return o}return-1},ss.a.prototype._getGlAlgorithmType=function(e){return e===ws.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(ws.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},set:function(e){this._occlusionDataStorage.isOcclusionQueryInProgress=e},enumerable:!1,configurable:!0}),Object.defineProperty(ws.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new $d),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(ws.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(e){this._occlusionDataStorage.isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(ws.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(e){this._occlusionDataStorage.occlusionQueryAlgorithmType=e},enumerable:!0,configurable:!0}),Object.defineProperty(ws.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(e){this._occlusionDataStorage.occlusionType=e},enumerable:!0,configurable:!0}),Object.defineProperty(ws.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(e){this._occlusionDataStorage.occlusionRetryCount=e},enumerable:!0,configurable:!0}),ws.prototype._checkOcclusionQuery=function(){var e=this._occlusionDataStorage;if(e.occlusionType===ws.OCCLUSION_TYPE_NONE)return e.isOccluded=!1,!1;var t=this.getEngine();if(t.webGLVersion<2)return e.isOccluded=!1,!1;if(!t.isQueryResultAvailable)return e.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery)if(t.isQueryResultAvailable(this._occlusionQuery)){var n=t.getQueryResult(this._occlusionQuery);e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=1!==n}else{if(e.occlusionInternalRetryCounter++,!(-1!==e.occlusionRetryCount&&e.occlusionInternalRetryCounter>e.occlusionRetryCount))return!1;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==ws.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var r=this.getScene();if(r.getBoundingBoxRenderer){var i=r.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery),i.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}return e.isOccluded};ss.a.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},ss.a.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},ss.a.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},ss.a.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},ss.a.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},ss.a.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},ss.a.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e?e.underlyingResource:null)};ss.a.prototype.getInputElement=function(){return this.inputElement||this.getRenderingCanvas()},ss.a.prototype.registerView=function(e,t){var n=this;this.views||(this.views=[]);for(var r=0,i=this.views;r17)throw new Error("Exceeded maximum custom attributes");var i=bh[n];if(void 0===i)throw new Error("Can't find bgfx name mapping");return t=t.replace(n,i),this._replacements.push({searchValue:new RegExp("\\b"+n+"\\b","g"),replaceValue:""+i}),"layout(location="+r+") "+e.prototype.attributeProcessor.call(this,t)},t.prototype.varyingProcessor=function(t,n){var r;return n?r=this._varyingLocationMap[t]:(r=this._varyingLocationCount++,this._varyingLocationMap[t]=r),"layout(location="+r+") "+e.prototype.varyingProcessor.call(this,t,n)},t.prototype.uniformProcessor=function(e){var t=e.match(/uniform\s+([^\s]+)\s+([^\s]+)\s*(?:\[.+\])?\s*;/),n=t[1],r=t[2];switch(n){case"sampler2D":case"samplerCube":var i=n.substr(7),o=this._textureCount++;return this._replacements.push({searchValue:new RegExp("\\b"+r+"\\b"),replaceValue:"sampler"+i+"("+r+"Texture, "+r+")"}),"layout(binding="+o+") uniform texture"+i+" "+r+"Texture;\nlayout(binding="+o+") uniform sampler "+r+";";case"float":this._replacements.push({searchValue:new RegExp("\\b"+r+"\\b"),replaceValue:r+".x"}),e="uniform vec4 "+r+";";break;case"vec2":this._replacements.push({searchValue:new RegExp("\\b"+r+"\\b"),replaceValue:r+".xy"}),e="uniform vec4 "+r+";";break;case"vec3":this._replacements.push({searchValue:new RegExp("\\b"+r+"\\b"),replaceValue:r+".xyz"}),e="uniform vec4 "+r+";"}return this._uniforms.push(e),1===this._uniforms.length?"":""},t.prototype.preProcessor=function(e,t,n){return this._genericAttributeLocation=10,n||(this._varyingLocationCount=0,this._varyingLocationMap={}),this._replacements=[],this._textureCount=0,this._uniforms=[],e},t.prototype.postProcessor=function(t,n,r){return t=(t=(t=e.prototype.postProcessor.call(this,t,n,r)).replace("","layout(binding=0) uniform Frame {\n"+this._uniforms.join("\n")+"\n};")).replace("out vec4 glFragColor","layout(location=0) out vec4 glFragColor")},t}(eh.a),Ah=function(){function e(){this.isAsync=!1,this.isReady=!1}return e.prototype._handlesSpectorRebuildCallback=function(e){throw new Error("Not implemented")},e}(),_h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t}(th.a),yh=function(){function e(){}return e.POINT=0,e.MINPOINT_MAGPOINT_MIPPOINT=e.POINT,e.BILINEAR=1,e.MINLINEAR_MAGLINEAR_MIPPOINT=e.BILINEAR,e.TRILINEAR=2,e.MINLINEAR_MAGLINEAR_MIPLINEAR=e.TRILINEAR,e.ANISOTROPIC=3,e.POINT_COMPARE=4,e.TRILINEAR_COMPARE=5,e.MINBILINEAR_MAGPOINT=6,e.MINLINEAR_MAGPOINT_MIPLINEAR=e.MINBILINEAR_MAGPOINT,e.MINPOINT_MAGPOINT_MIPLINEAR=7,e.MINPOINT_MAGLINEAR_MIPPOINT=8,e.MINPOINT_MAGLINEAR_MIPLINEAR=9,e.MINLINEAR_MAGPOINT_MIPPOINT=10,e}(),xh=function(){function e(){}return e.CLEAR_COLOR=1,e.CLEAR_DEPTH=2,e.CLEAR_STENCIL=4,e}(),wh=function(){function e(){}return e.WRAP=0,e.MIRROR=1,e.CLAMP=2,e.BORDER=3,e.MIRROR_ONCE=4,e}(),Eh=function(){function e(){}return e.RGBA8=0,e.RGBA32F=1,e}(),Ch=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getInternalTexture=function(){return this},t.prototype.getViewCount=function(){return 1},t}(Kl.a),Sh=(function(e){function t(){var t=e.call(this,null)||this;return t._native=new _native.Engine,t.INVALID_HANDLE=65535,t._webGLVersion=2,t.disableUniformBuffers=!0,t._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,maxAnisotropy:16,uintIndices:!1,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},Ja.Log("Babylon Native (v"+ss.a.Version+") launched"),"undefined"==typeof URL&&(window.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(window.Blob=function(){}),t._shaderProcessor=new vh,t}Object(No.d)(t,e),t.prototype.getHardwareScalingLevel=function(){return 1},t.prototype._queueNewFrame=function(e,t){return t.requestAnimationFrame?t.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,t,n,r){void 0===r&&(r=!1);var i=0;t&&e&&(this._native.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),i|=xh.CLEAR_COLOR),n&&(this._native.clearDepth(1),i|=xh.CLEAR_DEPTH),r&&(this._native.clearStencil(0),i|=xh.CLEAR_STENCIL),this._native.clear(i)},t.prototype.createIndexBuffer=function(e){var t=this._normalizeIndexData(e),n=new _h;if(n.references=1,n.is32Bits=4===t.BYTES_PER_ELEMENT,n.nativeIndexBuffer=this._native.createIndexBuffer(t),n.nativeVertexBuffer===this.INVALID_HANDLE)throw new Error("Could not create a native index buffer.");return n},t.prototype.createVertexBuffer=function(e){var t=new _h;if(t.references=1,t.nativeVertexBuffer=this._native.createVertexBuffer(ArrayBuffer.isView(e)?e:new Float32Array(e)),t.nativeVertexBuffer===this.INVALID_HANDLE)throw new Error("Could not create a native vertex buffer.");return t},t.prototype.recordVertexArrayObject=function(e,t,n){var r=this._native.createVertexArray();t&&this._native.recordIndexBuffer(r,t.nativeIndexBuffer);for(var i=n.getAttributesNames(),o=0;o=0){var s=e[i[o]];if(s){var l=s.getBuffer();l&&this._native.recordVertexBuffer(r,l.nativeVertexBuffer,a,s.byteOffset,s.byteStride,s.getSize(),s.type,s.normalized)}}}return r},t.prototype.bindVertexArrayObject=function(e){this._native.bindVertexArray(e)},t.prototype.releaseVertexArrayObject=function(e){this._native.deleteVertexArray(e)},t.prototype.getAttributes=function(e,t){var n=e;return this._native.getAttributes(n.nativeProgram,t)},t.prototype.drawElementsType=function(e,t,n,r){this._drawCalls.addCount(1,!1),this._native.drawIndexed(e,t,n)},t.prototype.drawArraysType=function(e,t,n,r){this._drawCalls.addCount(1,!1),this._native.draw(e,t,n)},t.prototype.createPipelineContext=function(){return new Ah},t.prototype._preparePipelineContext=function(e,t,n,r,i,o,a){var s=e;s.nativeProgram=r?this.createRawShaderProgram(e,t,n,void 0,a):this.createShaderProgram(e,t,n,o,void 0,a)},t.prototype._isRenderingStateCompiled=function(e){return!0},t.prototype._executeWhenRenderingStateIsCompiled=function(e,t){t()},t.prototype.createRawShaderProgram=function(e,t,n,r,i){throw void 0===i&&(i=null),new Error("Not Supported")},t.prototype.createShaderProgram=function(e,t,n,r,i,o){void 0===o&&(o=null),this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=this._native.createProgram(Va.a._ConcatenateShader(t,r),Va.a._ConcatenateShader(n,r));return this.onAfterShaderCompilationObservable.notifyObservers(this),a},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,t){var n=e;return this._native.getUniforms(n.nativeProgram,t)},t.prototype.bindUniformBlock=function(e,t,n){throw new Error("Not Implemented")},t.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.nativeProgram);for(var n=e.getSamplers(),r=0;r-1?p.substring(b).toLowerCase():""),A=null,_=0,y=ss.a._TextureLoaders;_-1?e.substring(f).toLowerCase():""))){if(n&&6===n.length)throw new Error("Multi-file loading not allowed on env files.");this._loadFile(e,(function(e){return function(e){var t=fh.GetEnvInfo(e);if(p.width=t.width,p.height=t.width,fh.UploadEnvSpherical(p,t),1!==t.version)throw new Error('Unsupported babylon environment map version "'+t.version+'"');var n=t.specular;if(!n)throw new Error("Nothing else parsed so far");p._lodGenerationScale=n.lodGenerationScale;var r=fh.CreateImageDataArrayBufferViews(e,t);if(p.format=5,p.type=0,p.generateMipMaps=!0,p.getEngine().updateTextureSamplingMode(Wl.TRILINEAR_SAMPLINGMODE,p),p._isRGBD=!0,p.invertY=!0,!h._native.loadEnvTexture(p._webGLTexture,r))throw new Error("Could not load a native cube texture.");p.isReady=!0,i&&i()}(new Uint8Array(e))}),void 0,void 0,!0,(function(e,t){o&&e&&o(e.status+" "+e.statusText,t)}))}else{if(!n||6!==n.length)throw new Error("Cannot load cubemap because 6 files were not defined");var m=[n[0],n[3],n[1],n[4],n[2],n[5]];Promise.all(m.map((function(e){return Ja.LoadFileAsync(e).then((function(e){return new Uint8Array(e)}))}))).then((function(e){h._native.loadCubeTexture(p._webGLTexture,e,!r)})).then((function(){p.isReady=!0,i&&i()}),(function(e){o&&o("Failed to load cubemap: "+e.message,e)}))}return this._internalTexturesCache.push(p),p},t.prototype._getSamplingFilter=function(e){switch(e){case 2:return yh.MINLINEAR_MAGLINEAR_MIPPOINT;case 3:return yh.MINLINEAR_MAGLINEAR_MIPLINEAR;case 1:return yh.MINPOINT_MAGPOINT_MIPLINEAR;case 4:return yh.MINPOINT_MAGPOINT_MIPPOINT;case 5:return yh.MINLINEAR_MAGPOINT_MIPPOINT;case 6:case 7:return yh.MINLINEAR_MAGPOINT_MIPLINEAR;case 1:return yh.MINPOINT_MAGPOINT_MIPPOINT;case 9:return yh.MINPOINT_MAGLINEAR_MIPPOINT;case 10:return yh.MINPOINT_MAGLINEAR_MIPLINEAR;case 2:return yh.MINLINEAR_MAGLINEAR_MIPLINEAR;case 12:return yh.MINPOINT_MAGLINEAR_MIPLINEAR;default:throw new Error("Unexpected sampling mode: "+e+".")}},t._GetNativeTextureFormat=function(e,t){if(5==e&&0==t)return Eh.RGBA8;if(5==e&&1==t)return Eh.RGBA32F;throw new Error("Unexpected texture format or type: format "+e+", type "+t+".")},t.prototype.createRenderTargetTexture=function(e,n){var r=new Kc.a;void 0!==n&&"object"==typeof n?(r.generateMipMaps=n.generateMipMaps,r.generateDepthBuffer=void 0===n.generateDepthBuffer||n.generateDepthBuffer,r.generateStencilBuffer=r.generateDepthBuffer&&n.generateStencilBuffer,r.type=void 0===n.type?0:n.type,r.samplingMode=void 0===n.samplingMode?3:n.samplingMode,r.format=void 0===n.format?5:n.format):(r.generateMipMaps=n,r.generateDepthBuffer=!0,r.generateStencilBuffer=!1,r.type=0,r.samplingMode=3,r.format=5),(1!==r.type||this._caps.textureFloatLinearFiltering)&&(2!==r.type||this._caps.textureHalfFloatLinearFiltering)||(r.samplingMode=1);var i=new Ch(this,Kl.b.RenderTarget),o=e.width||e,a=e.height||e;1!==r.type||this._caps.textureFloat||(r.type=0,jo.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var s=this._native.createFramebuffer(i._webGLTexture,o,a,t._GetNativeTextureFormat(r.format,r.type),r.samplingMode,!!r.generateStencilBuffer,r.generateDepthBuffer,!!r.generateMipMaps);return i._framebuffer=s,i.baseWidth=o,i.baseHeight=a,i.width=o,i.height=a,i.isReady=!0,i.samples=1,i.generateMipMaps=!!r.generateMipMaps,i.samplingMode=r.samplingMode,i.type=r.type,i.format=r.format,i._generateDepthBuffer=r.generateDepthBuffer,i._generateStencilBuffer=!!r.generateStencilBuffer,this._internalTexturesCache.push(i),i},t.prototype.updateTextureSamplingMode=function(e,t){if(t._webGLTexture){var n=this._getSamplingFilter(e);this._native.setTextureSampling(t._webGLTexture,n)}t.samplingMode=e},t.prototype.bindFramebuffer=function(e,t,n,r,i){if(t)throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");if(n||r)throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");if(i)throw new Error("forceFullscreenViewport for frame buffers not yet supported in NativeEngine.");this._bindUnboundFramebuffer(e._framebuffer)},t.prototype.unBindFramebuffer=function(e,t,n){void 0===t&&(t=!1),t&&jo.a.Warn("Disabling mipmap generation not yet supported in NativeEngine. Ignoring."),n&&n(),this._bindUnboundFramebuffer(null)},t.prototype.createDynamicVertexBuffer=function(e){throw new Error("createDynamicVertexBuffer not yet implemented.")},t.prototype.updateDynamicIndexBuffer=function(e,t,n){throw void 0===n&&(n=0),new Error("updateDynamicIndexBuffer not yet implemented.")},t.prototype.updateDynamicVertexBuffer=function(e,t,n,r){throw new Error("updateDynamicVertexBuffer not yet implemented.")},t.prototype._setTexture=function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var i,o=this._boundUniforms[e];if(!o)return!1;if(!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._native.setTexture(o,null)),!1;if(t.video)this._activeChannel=e,t.update();else if(4===t.delayLoadState)return t.delayLoad(),!1;return i=r?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,this._activeChannel=e,!(!i||!i._webGLTexture)&&(this._native.setTextureWrapMode(i._webGLTexture,this._getAddressMode(t.wrapU),this._getAddressMode(t.wrapV),this._getAddressMode(t.wrapR)),this._updateAnisotropicLevel(t),this._native.setTexture(o,i._webGLTexture),!0)},t.prototype._updateAnisotropicLevel=function(e){var t=e.getInternalTexture(),n=e.anisotropicFilteringLevel;t&&t._webGLTexture&&t._cachedAnisotropicFilteringLevel!==n&&(this._native.setTextureAnisotropicLevel(t._webGLTexture,n),t._cachedAnisotropicFilteringLevel=n)},t.prototype._getAddressMode=function(e){switch(e){case 1:return wh.WRAP;case 0:return wh.CLAMP;case 2:return wh.MIRROR;default:throw new Error("Unexpected wrap mode: "+e+".")}},t.prototype._bindTexture=function(e,t){throw new Error("_bindTexture not implemented.")},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,t,n,r,i,o,a){throw void 0===o&&(o=0),void 0===a&&(a=0),new Error("_uploadCompressedDataToTextureDirectly not implemented.")},t.prototype._uploadDataToTextureDirectly=function(e,t,n,r){throw void 0===n&&(n=0),void 0===r&&(r=0),new Error("_uploadDataToTextureDirectly not implemented.")},t.prototype._uploadArrayBufferViewToTexture=function(e,t,n,r){throw void 0===n&&(n=0),void 0===r&&(r=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._uploadImageToTexture=function(e,t,n,r){throw void 0===n&&(n=0),void 0===r&&(r=0),new Error("_uploadArrayBufferViewToTexture not implemented.")}}(ss.a),function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}()),Th=(function(){function e(e,t){this.type=e,this.event=t}e.GetTypeFromCharacter=function(e){switch(e){case 67:return Sh.COPY;case 86:return Sh.PASTE;case 88:return Sh.CUT;default:return-1}}}(),function(){function e(e,t,n){this.lengthComputable=e,this.loaded=t,this.total=n}return e.FromProgressEvent=function(t){return new e(t.lengthComputable,t.loaded,t.total)},e}());!function(e){e[e.Clean=0]="Clean",e[e.Stop=1]="Stop",e[e.Sync=2]="Sync",e[e.NoSync=3]="NoSync"}(mh||(mh={}));var Ph=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return Al.ForceFullSceneLoadingForIncremental},set:function(e){Al.ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return Al.ShowLoadingScreen},set:function(e){Al.ShowLoadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return Al.loggingLevel},set:function(e){Al.loggingLevel=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return Al.CleanBoneMatrixWeights},set:function(e){Al.CleanBoneMatrixWeights=e},enumerable:!0,configurable:!0}),e._getDefaultPlugin=function(){return e._registeredPlugins[".babylon"]},e._getPluginForExtension=function(t){var n=e._registeredPlugins[t];return n||(jo.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: http://doc.babylonjs.com/how_to/load_from_any_file_type"),e._getDefaultPlugin())},e._getPluginForDirectLoad=function(t){for(var n in e._registeredPlugins){var r=e._registeredPlugins[n].plugin;if(r.canDirectLoad&&r.canDirectLoad(t))return e._registeredPlugins[n]}return e._getDefaultPlugin()},e._getPluginForFilename=function(t){var n=t.indexOf("?");-1!==n&&(t=t.substring(0,n));var r=t.lastIndexOf("."),i=t.substring(r,t.length).toLowerCase();return e._getPluginForExtension(i)},e._getDirectLoad=function(e){return"data:"===e.substr(0,5)?e.substr(5):null},e._loadData=function(t,n,r,i,o,a,s){var l,c=e._getDirectLoad(t.name),u=s?e._getPluginForExtension(s):c?e._getPluginForDirectLoad(t.name):e._getPluginForFilename(t.name);if(!(l=u.plugin.createPlugin?u.plugin.createPlugin():u.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(e.OnPluginActivatedObservable.notifyObservers(l),c)return r(l,l.directLoad?l.directLoad(n,c):c),l;var d=u.isBinary,h=function(e,t){n.isDisposed?o("Scene has been disposed"):r(l,e,t)},p=null,f=!1,m=l.onDisposeObservable;m&&m.add((function(){f=!0,p&&(p.abort(),p=null),a()}));var g=i?function(e){i(Th.FromProgressEvent(e))}:void 0,b=function(){if(!f){var e=function(e,t){h(e,t?t.responseURL:void 0)},r=function(e){o(e.message,e)};p=l.requestFile?l.requestFile(n,t.url,e,g,d,r):n._requestFile(t.url,e,g,!0,d,r)}},v=t.file||Na.FilesToLoad[t.name.toLowerCase()];if(-1===t.rootUrl.indexOf("file:")||-1!==t.rootUrl.indexOf("file:")&&!v){var A=n.getEngine(),_=A.enableOfflineSupport;if(_){for(var y=!1,x=0,w=n.disableOfflineSupportExceptionRules;xo.snapDistance?(i=Math.floor(Math.abs(l)/o.snapDistance),l<0&&(i*=-1),l%=o.snapDistance,c.scaleToRef(o.snapDistance*i,c),r=!0):c.scaleInPlace(0)),o.attachedMesh.scaling.addInPlace(c),r&&(u.snapDistance=o.snapDistance*i,o.onSnapObservable.notifyObservers(u))}})),o._pointerObserver=r.utilityLayerScene.onPointerObservable.add((function(e){if(!o._customMeshSet){var t=e.pickInfo&&-1!=o._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?o._hoverMaterial:o._coloredMaterial;o._rootMesh.getChildMeshes().forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))}}));var d=r._getSharedGizmoLight();return d.includedOnlyMeshes=d.includedOnlyMeshes.concat(o._rootMesh.getChildMeshes()),o}return Object(No.d)(t,e),t.prototype._attachedMeshChanged=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.attachedMesh=null},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._arrow&&this._arrow.dispose(),[this._coloredMaterial,this._hoverMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t.prototype.setCustomMesh=function(t,n){var r=this;void 0===n&&(n=!1),e.prototype.setCustomMesh.call(this,t),n&&(this._rootMesh.getChildMeshes().forEach((function(e){e.material=r._coloredMaterial,e.color&&(e.color=r._coloredMaterial.diffuseColor)})),this._customMeshSet=!1)},t}(Nd),Nh=function(e){function t(t,n){void 0===t&&(t=Io.Gray()),void 0===n&&(n=Fd.DefaultKeepDepthUtilityLayer);var r=e.call(this,n)||this;r._boundingDimensions=new So(1,1,1),r._renderObserver=null,r._pointerObserver=null,r._scaleDragSpeed=.2,r._tmpQuaternion=new Po,r._tmpVector=new So(0,0,0),r._tmpRotationMatrix=new Oo,r.ignoreChildren=!1,r.includeChildPredicate=null,r.rotationSphereSize=.1,r.scaleBoxSize=.1,r.fixedDragMeshScreenSize=!1,r.fixedDragMeshScreenSizeDistanceFactor=10,r.onDragStartObservable=new yo.a,r.onScaleBoxDragObservable=new yo.a,r.onScaleBoxDragEndObservable=new yo.a,r.onRotationSphereDragObservable=new yo.a,r.onRotationSphereDragEndObservable=new yo.a,r.scalePivot=null,r._existingMeshScale=new So,r._dragMesh=null,r.pointerDragBehavior=new Gl,r.updateScale=!1,r._anchorMesh=new ws("anchor",n.utilityLayerScene),r.coloredMaterial=new hd("",n.utilityLayerScene),r.coloredMaterial.disableLighting=!0,r.hoverColoredMaterial=new hd("",n.utilityLayerScene),r.hoverColoredMaterial.disableLighting=!0,r._lineBoundingBox=new ws("",n.utilityLayerScene),r._lineBoundingBox.rotationQuaternion=new Po;var i=[];i.push(Zd.CreateLines("lines",{points:[new So(0,0,0),new So(r._boundingDimensions.x,0,0)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,0,0),new So(0,r._boundingDimensions.y,0)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,0,0),new So(0,0,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,0,0),new So(r._boundingDimensions.x,r._boundingDimensions.y,0)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,0,0),new So(r._boundingDimensions.x,0,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,r._boundingDimensions.y,0),new So(r._boundingDimensions.x,r._boundingDimensions.y,0)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,r._boundingDimensions.y,0),new So(0,r._boundingDimensions.y,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,0,r._boundingDimensions.z),new So(r._boundingDimensions.x,0,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,0,r._boundingDimensions.z),new So(0,r._boundingDimensions.y,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,r._boundingDimensions.y,r._boundingDimensions.z),new So(0,r._boundingDimensions.y,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,r._boundingDimensions.y,r._boundingDimensions.z),new So(r._boundingDimensions.x,0,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,r._boundingDimensions.y,r._boundingDimensions.z),new So(r._boundingDimensions.x,r._boundingDimensions.y,0)]},n.utilityLayerScene)),i.forEach((function(e){e.color=t,e.position.addInPlace(new So(-r._boundingDimensions.x/2,-r._boundingDimensions.y/2,-r._boundingDimensions.z/2)),e.isPickable=!1,r._lineBoundingBox.addChild(e)})),r._rootMesh.addChild(r._lineBoundingBox),r.setColor(t),r._rotateSpheresParent=new ws("",n.utilityLayerScene),r._rotateSpheresParent.rotationQuaternion=new Po;for(var o=function(e){var t=zd.CreateSphere("",{diameter:1},n.utilityLayerScene);t.rotationQuaternion=new Po,t.material=a.coloredMaterial,(u=new Gl({})).moveAttached=!1,u.updateDragPlane=!1,t.addBehavior(u);var i=new So(1,0,0),o=0;u.onDragStartObservable.add((function(){i.copyFrom(t.forward),o=0})),u.onDragObservable.add((function(t){if(r.onRotationSphereDragObservable.notifyObservers({}),r.attachedMesh){var n=r.attachedMesh.parent;if(n&&n.scaling&&n.scaling.isNonUniformWithinEpsilon(.001))return void jo.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");zl._RemoveAndStorePivotPoint(r.attachedMesh);var a=i,s=t.dragPlaneNormal.scale(So.Dot(t.dragPlaneNormal,a)),l=a.subtract(s).normalizeToNew(),c=So.Dot(l,t.delta)<0?Math.abs(t.delta.length()):-Math.abs(t.delta.length());c=c/r._boundingDimensions.length()*r._anchorMesh.scaling.length(),r.attachedMesh.rotationQuaternion||(r.attachedMesh.rotationQuaternion=Po.RotationYawPitchRoll(r.attachedMesh.rotation.y,r.attachedMesh.rotation.x,r.attachedMesh.rotation.z)),r._anchorMesh.rotationQuaternion||(r._anchorMesh.rotationQuaternion=Po.RotationYawPitchRoll(r._anchorMesh.rotation.y,r._anchorMesh.rotation.x,r._anchorMesh.rotation.z)),o+=c,Math.abs(o)<=2*Math.PI&&(e>=8?Po.RotationYawPitchRollToRef(0,0,c,r._tmpQuaternion):e>=4?Po.RotationYawPitchRollToRef(c,0,0,r._tmpQuaternion):Po.RotationYawPitchRollToRef(0,c,0,r._tmpQuaternion),r._anchorMesh.addChild(r.attachedMesh),r._anchorMesh.rotationQuaternion.multiplyToRef(r._tmpQuaternion,r._anchorMesh.rotationQuaternion),r._anchorMesh.removeChild(r.attachedMesh),r.attachedMesh.setParent(n)),r.updateBoundingBox(),zl._RestorePivotPoint(r.attachedMesh)}r._updateDummy()})),u.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({}),r._selectNode(t)})),u.onDragEndObservable.add((function(){r.onRotationSphereDragEndObservable.notifyObservers({}),r._selectNode(null),r._updateDummy()})),a._rotateSpheresParent.addChild(t)},a=this,s=0;s<12;s++)o(s);r._rootMesh.addChild(r._rotateSpheresParent),r._scaleBoxesParent=new ws("",n.utilityLayerScene),r._scaleBoxesParent.rotationQuaternion=new Po;for(var l=0;l<2;l++)for(var c=0;c<2;c++)for(var u,d=function(){var e=Vd.CreateBox("",{size:1},n.utilityLayerScene);e.material=h.coloredMaterial;var t=new So(0==l?-1:1,0==c?-1:1,0==p?-1:1);(u=new Gl({dragAxis:t})).moveAttached=!1,e.addBehavior(u),u.onDragObservable.add((function(t){if(r.onScaleBoxDragObservable.notifyObservers({}),r.attachedMesh){var n=r.attachedMesh.parent;if(n&&n.scaling&&n.scaling.isNonUniformWithinEpsilon(.001))return void jo.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");zl._RemoveAndStorePivotPoint(r.attachedMesh);var i=t.dragDistance/r._boundingDimensions.length()*r._anchorMesh.scaling.length(),o=new So(i,i,i);o.scaleInPlace(r._scaleDragSpeed),r.updateBoundingBox(),r.scalePivot?(r.attachedMesh.getWorldMatrix().getRotationMatrixToRef(r._tmpRotationMatrix),r._boundingDimensions.scaleToRef(.5,r._tmpVector),So.TransformCoordinatesToRef(r._tmpVector,r._tmpRotationMatrix,r._tmpVector),r._anchorMesh.position.subtractInPlace(r._tmpVector),r._boundingDimensions.multiplyToRef(r.scalePivot,r._tmpVector),So.TransformCoordinatesToRef(r._tmpVector,r._tmpRotationMatrix,r._tmpVector),r._anchorMesh.position.addInPlace(r._tmpVector)):(e.absolutePosition.subtractToRef(r._anchorMesh.position,r._tmpVector),r._anchorMesh.position.subtractInPlace(r._tmpVector)),r._anchorMesh.addChild(r.attachedMesh),r._anchorMesh.scaling.addInPlace(o),(r._anchorMesh.scaling.x<0||r._anchorMesh.scaling.y<0||r._anchorMesh.scaling.z<0)&&r._anchorMesh.scaling.subtractInPlace(o),r._anchorMesh.removeChild(r.attachedMesh),r.attachedMesh.setParent(n),zl._RestorePivotPoint(r.attachedMesh)}r._updateDummy()})),u.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({}),r._selectNode(e)})),u.onDragEndObservable.add((function(){r.onScaleBoxDragEndObservable.notifyObservers({}),r._selectNode(null),r._updateDummy()})),h._scaleBoxesParent.addChild(e)},h=this,p=0;p<2;p++)d();r._rootMesh.addChild(r._scaleBoxesParent);var f=new Array;return r._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){f[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=f[e.event.pointerId]&&(f[e.event.pointerId].material=r.coloredMaterial,delete f[e.event.pointerId]):r._rotateSpheresParent.getChildMeshes().concat(r._scaleBoxesParent.getChildMeshes()).forEach((function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(f[e.event.pointerId]=t,t.material=r.hoverColoredMaterial)}))})),r._renderObserver=r.gizmoLayer.originalScene.onBeforeRenderObservable.add((function(){r.attachedMesh&&!r._existingMeshScale.equals(r.attachedMesh.scaling)?r.updateBoundingBox():r.fixedDragMeshScreenSize&&(r._updateRotationSpheres(),r._updateScaleBoxes()),r._dragMesh&&r.attachedMesh&&r.pointerDragBehavior.dragging&&(r._lineBoundingBox.position.rotateByQuaternionToRef(r._rootMesh.rotationQuaternion,r._tmpVector),r.attachedMesh.setAbsolutePosition(r._dragMesh.position.add(r._tmpVector.scale(-1))))})),r.updateBoundingBox(),r}return Object(No.d)(t,e),t.prototype.setColor=function(e){this.coloredMaterial.emissiveColor=e,this.hoverColoredMaterial.emissiveColor=e.clone().add(new Io(.3,.3,.3)),this._lineBoundingBox.getChildren().forEach((function(t){t.color&&(t.color=e)}))},t.prototype._attachedMeshChanged=function(e){var t=this;if(e){zl._RemoveAndStorePivotPoint(e);var n=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(n),zl._RestorePivotPoint(e),this.updateBoundingBox(),e.getChildMeshes(!1).forEach((function(e){e.markAsDirty("scaling")})),this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce((function(){t._updateDummy()}))}},t.prototype._selectNode=function(e){this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach((function(t){t.isVisible=!e||t==e}))},t.prototype.updateBoundingBox=function(){if(this.attachedMesh){zl._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null);var t=null;this.attachedMesh.skeleton&&(t=this.attachedMesh.skeleton.overrideMesh,this.attachedMesh.skeleton.overrideMesh=null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=Po.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=Po.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 n=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);n.max.subtractToRef(n.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((n.max.x+n.min.x)/2,(n.max.y+n.min.y)/2,(n.max.z+n.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=t)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),zl._RestorePivotPoint(this.attachedMesh))},t.prototype._updateRotationSpheres=function(){for(var e=this._rotateSpheresParent.getChildMeshes(),t=0;t<3;t++)for(var n=0;n<2;n++)for(var r=0;r<2;r++){var i=4*t+2*n+r;if(0==t&&(e[i].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*n,this._boundingDimensions.z*r),e[i].position.addInPlace(new So(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[i].lookAt(So.Cross(e[i].position.normalizeToNew(),So.Right()).normalizeToNew().add(e[i].position))),1==t&&(e[i].position.set(this._boundingDimensions.x*n,this._boundingDimensions.y/2,this._boundingDimensions.z*r),e[i].position.addInPlace(new So(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[i].lookAt(So.Cross(e[i].position.normalizeToNew(),So.Up()).normalizeToNew().add(e[i].position))),2==t&&(e[i].position.set(this._boundingDimensions.x*n,this._boundingDimensions.y*r,this._boundingDimensions.z/2),e[i].position.addInPlace(new So(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[i].lookAt(So.Cross(e[i].position.normalizeToNew(),So.Forward()).normalizeToNew().add(e[i].position))),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[i].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var o=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[i].scaling.set(o,o,o)}else e[i].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}},t.prototype._updateScaleBoxes=function(){for(var e=this._scaleBoxesParent.getChildMeshes(),t=0;t<2;t++)for(var n=0;n<2;n++)for(var r=0;r<2;r++){var i=4*t+2*n+r;if(e[i])if(e[i].position.set(this._boundingDimensions.x*t,this._boundingDimensions.y*n,this._boundingDimensions.z*r),e[i].position.addInPlace(new So(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[i].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var o=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[i].scaling.set(o,o,o)}else e[i].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize)}},t.prototype.setEnabledRotationAxis=function(e){this._rotateSpheresParent.getChildMeshes().forEach((function(t,n){n<4?t.setEnabled(-1!=e.indexOf("x")):n<8?t.setEnabled(-1!=e.indexOf("y")):t.setEnabled(-1!=e.indexOf("z"))}))},t.prototype.setEnabledScaling=function(e){this._scaleBoxesParent.getChildMeshes().forEach((function(t,n){t.setEnabled(e)}))},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=Pl.CreateBox("dummy",1,this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new Po,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(),e.prototype.dispose.call(this)},t.MakeNotPickableAndWrapInBoundingBox=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach((function(e){t(e)}))};t(e),e.rotationQuaternion||(e.rotationQuaternion=Po.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var n=e.position.clone(),r=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var i=Vd.CreateBox("box",{size:1},e.getScene()),o=e.getHierarchyBoundingVectors();return o.max.subtractToRef(o.min,i.scaling),0===i.scaling.y&&(i.scaling.y=.001),0===i.scaling.x&&(i.scaling.x=.001),0===i.scaling.z&&(i.scaling.z=.001),i.position.set((o.max.x+o.min.x)/2,(o.max.y+o.min.y)/2,(o.max.z+o.min.z)/2),e.addChild(i),e.rotationQuaternion.copyFrom(r),e.position.copyFrom(n),e.removeChild(i),i.addChild(e),i.visibility=0,i},t.prototype.setCustomMesh=function(e){jo.a.Error("Custom meshes are not supported on this gizmo")},t}(Nd),Lh=function(e){function t(t,n,r,i,o,a){void 0===n&&(n=Io.Gray()),void 0===r&&(r=Fd.DefaultUtilityLayer),void 0===i&&(i=32),void 0===o&&(o=null),void 0===a&&(a=!1);var s=e.call(this,r)||this;s._pointerObserver=null,s.snapDistance=0,s.onSnapObservable=new yo.a,s._isEnabled=!0,s._parent=null,s._parent=o;var l=new hd("",r.utilityLayerScene);l.diffuseColor=n,l.specularColor=n.subtract(new Io(.1,.1,.1));var c=new hd("",r.utilityLayerScene);c.diffuseColor=n.add(new Io(.3,.3,.3));var u=new ws("",r.utilityLayerScene),d=Pl.CreateTorus("",.6,.03,i,r.utilityLayerScene);d.visibility=0;var h=Pl.CreateTorus("",.6,.005,i,r.utilityLayerScene);h.material=l,h.rotation.x=Math.PI/2,d.rotation.x=Math.PI/2,u.addChild(h),u.addChild(d),u.lookAt(s._rootMesh.position.add(t)),s._rootMesh.addChild(u),u.scaling.scaleInPlace(1/3),s.dragBehavior=new Gl({dragPlaneNormal:t}),s.dragBehavior.moveAttached=!1,s.dragBehavior.maxDragAngle=9*Math.PI/20,s.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,s._rootMesh.addBehavior(s.dragBehavior);var p=new So;s.dragBehavior.onDragStartObservable.add((function(e){s.attachedMesh&&p.copyFrom(e.dragPlanePoint)}));var f=new Oo,m=new So,g=new So,b={snapDistance:0},v=0,A=new Oo,_=new So,y=new Po;s.dragBehavior.onDragObservable.add((function(e){if(s.attachedMesh){s.attachedMesh.rotationQuaternion&&!a||(s.attachedMesh.rotationQuaternion=Po.RotationYawPitchRoll(s.attachedMesh.rotation.y,s.attachedMesh.rotation.x,s.attachedMesh.rotation.z));var n=s.attachedMesh.parent;n&&s.attachedMesh.setParent(null);var i=e.dragPlanePoint.subtract(s.attachedMesh.absolutePosition).normalize(),o=p.subtract(s.attachedMesh.absolutePosition).normalize(),l=So.Cross(i,o),c=So.Dot(i,o),u=Math.atan2(l.length(),c);if(m.copyFrom(t),g.copyFrom(t),s.updateGizmoRotationToMatchAttachedMesh&&(s.attachedMesh.rotationQuaternion.toRotationMatrix(f),g=So.TransformCoordinates(m,f)),r.utilityLayerScene.activeCamera){var d=r.utilityLayerScene.activeCamera.position.subtract(s.attachedMesh.position);So.Dot(d,g)>0&&(m.scaleInPlace(-1),g.scaleInPlace(-1))}So.Dot(g,l)>0&&(u=-u);var h=!1;if(0!=s.snapDistance)if(v+=u,Math.abs(v)>s.snapDistance){var x=Math.floor(Math.abs(v)/s.snapDistance);v<0&&(x*=-1),v%=s.snapDistance,u=s.snapDistance*x,h=!0}else u=0;A.reset(),s.attachedMesh.parent&&(s.attachedMesh.parent.computeWorldMatrix().invertToRef(A),A.getRotationMatrixToRef(A),So.TransformCoordinatesToRef(m,A,m));var w=Math.sin(u/2);y.set(m.x*w,m.y*w,m.z*w,Math.cos(u/2)),A.determinant()>0&&(y.toEulerAnglesToRef(_),Po.RotationYawPitchRollToRef(_.y,-_.x,-_.z,y)),s.updateGizmoRotationToMatchAttachedMesh?s.attachedMesh.rotationQuaternion.multiplyToRef(y,s.attachedMesh.rotationQuaternion):y.multiplyToRef(s.attachedMesh.rotationQuaternion,s.attachedMesh.rotationQuaternion),a&&(s.attachedMesh.rotationQuaternion.toEulerAnglesToRef(_),s.attachedMesh.rotationQuaternion=null,s.attachedMesh.rotation.copyFrom(_)),p.copyFrom(e.dragPlanePoint),h&&(b.snapDistance=u,s.onSnapObservable.notifyObservers(b)),n&&s.attachedMesh.setParent(n)}})),s._pointerObserver=r.utilityLayerScene.onPointerObservable.add((function(e){if(!s._customMeshSet){var t=e.pickInfo&&-1!=s._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?c:l;s._rootMesh.getChildMeshes().forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))}}));var x=r._getSharedGizmoLight();return x.includedOnlyMeshes=x.includedOnlyMeshes.concat(s._rootMesh.getChildMeshes(!1)),s}return Object(No.d)(t,e),t.prototype._attachedMeshChanged=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.attachedMesh=null},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this)},t}(Nd),Uh=function(e){function t(t,n,r){void 0===t&&(t=Fd.DefaultUtilityLayer),void 0===n&&(n=32),void 0===r&&(r=!1);var i=e.call(this,t)||this;return i.onDragStartObservable=new yo.a,i.onDragEndObservable=new yo.a,i.xGizmo=new Lh(new So(1,0,0),Io.Red().scale(.5),t,n,i,r),i.yGizmo=new Lh(new So(0,1,0),Io.Green().scale(.5),t,n,i,r),i.zGizmo=new Lh(new So(0,0,1),Io.Blue().scale(.5),t,n,i,r),[i.xGizmo,i.yGizmo,i.zGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){i.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){i.onDragEndObservable.notifyObservers({})}))})),i.attachedMesh=null,i}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!0,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:!0,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:!0,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:!0,configurable:!0}),t.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){jo.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}(Nd),Vh=function(e){function t(n,r,i,o){void 0===r&&(r=Io.Gray()),void 0===i&&(i=Fd.DefaultUtilityLayer),void 0===o&&(o=null);var a=e.call(this,i)||this;a._pointerObserver=null,a.snapDistance=0,a.onSnapObservable=new yo.a,a._isEnabled=!1,a._parent=null,a._parent=o,a._coloredMaterial=new hd("",i.utilityLayerScene),a._coloredMaterial.diffuseColor=r,a._coloredMaterial.specularColor=r.subtract(new Io(.1,.1,.1)),a._hoverMaterial=new hd("",i.utilityLayerScene),a._hoverMaterial.diffuseColor=r.add(new Io(.3,.3,.3)),a._plane=t._CreatePlane(i.utilityLayerScene,a._coloredMaterial),a._plane.lookAt(a._rootMesh.position.add(n)),a._plane.scaling.scaleInPlace(1/3),a._plane.parent=a._rootMesh;var s=0,l=new So,c={snapDistance:0};a.dragBehavior=new Gl({dragPlaneNormal:n}),a.dragBehavior.moveAttached=!1,a._rootMesh.addBehavior(a.dragBehavior);var u=new So,d=new Oo;a.dragBehavior.onDragObservable.add((function(e){if(a.attachedMesh)if(a.attachedMesh.parent?(a.attachedMesh.parent.computeWorldMatrix().invertToRef(d),d.setTranslationFromFloats(0,0,0),So.TransformCoordinatesToRef(e.delta,d,u)):u.copyFrom(e.delta),0==a.snapDistance)a.attachedMesh.position.addInPlace(u);else if(s+=e.dragDistance,Math.abs(s)>a.snapDistance){var t=Math.floor(Math.abs(s)/a.snapDistance);s%=a.snapDistance,u.normalizeToRef(l),l.scaleInPlace(a.snapDistance*t),a.attachedMesh.position.addInPlace(l),c.snapDistance=a.snapDistance*t,a.onSnapObservable.notifyObservers(c)}})),a._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){if(!a._customMeshSet){var t=e.pickInfo&&-1!=a._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?a._hoverMaterial:a._coloredMaterial;a._rootMesh.getChildMeshes().forEach((function(e){e.material=t}))}}));var h=i._getSharedGizmoLight();return h.includedOnlyMeshes=h.includedOnlyMeshes.concat(a._rootMesh.getChildMeshes(!1)),a}return Object(No.d)(t,e),t._CreatePlane=function(e,t){var n=new as("plane",e),r=jl.CreatePlane("dragPlane",{width:.1375,height:.1375,sideOrientation:2},e);return r.material=t,r.parent=n,r.material=t,n},t._CreateArrowInstance=function(e,t){for(var n=new as("arrow",e),r=0,i=t.getChildMeshes();r=t.length)?0:e.type||0,c=e.size,u=e.sizeX||c||1,d=e.sizeY||c||1,h=e.sizeZ||c||1,p=e.custom||t[l],f=p.face.length,m=e.faceUV||new Array(f),g=e.faceColors,b=void 0===e.flat||e.flat,v=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,A=new Array,_=new Array,y=new Array,x=new Array,w=new Array,E=0,C=0,S=new Array,T=0,P=0;if(b)for(P=0;P0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,n)},t.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(e){var t=this.getScene().activeCamera;t&&Oo.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:t.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:t.maxZ,e)},t.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,t,n){var r=this.getScene().activeCamera;if(r){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var i=So.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var o=Number.MAX_VALUE,a=Number.MIN_VALUE,s=0;sthis._orthoRight&&(this._orthoRight=i.x),i.y>this._orthoTop&&(this._orthoTop=i.y),this.autoCalcShadowZBounds&&(i.za&&(a=i.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=o,this._shadowMaxZ=a)}var d=this._orthoRight-this._orthoLeft,h=this._orthoTop-this._orthoBottom;Oo.OrthoOffCenterLHToRef(this._orthoLeft-d*this.shadowOrthoScale,this._orthoRight+d*this.shadowOrthoScale,this._orthoBottom-h*this.shadowOrthoScale,this._orthoTop+h*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.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,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},t.prototype.transferToNodeMaterialEffect=function(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,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,t){e["DIRLIGHT"+t]=!0},Object(No.c)([ha()],t.prototype,"shadowFrustumSize",null),Object(No.c)([ha()],t.prototype,"shadowOrthoScale",null),Object(No.c)([ha()],t.prototype,"autoUpdateExtends",void 0),Object(No.c)([ha()],t.prototype,"autoCalcShadowZBounds",void 0),t}(Hh);Pl.CreateHemisphere=function(e,t,n,r){var i={segments:t,diameter:n};return Wh.CreateHemisphere(e,i,r)};var Wh=function(){function e(){}return e.CreateHemisphere=function(e,t,n){t.diameter||(t.diameter=1),t.segments||(t.segments=16);var r=zd.CreateSphere("",{slice:.5,diameter:t.diameter,segments:t.segments},n),i=Pl.CreateDisc("",t.diameter/2,3*t.segments+(4-t.segments),n);i.rotation.x=-Math.PI/2,i.parent=r;var o=Pl.MergeMeshes([i,r],!0);return o.name=e,o},e}();wa.AddNodeConstructor("Light_Type_2",(function(e,t){return function(){return new Kh(e,So.Zero(),So.Zero(),0,0,t)}}));var Kh=function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,a)||this;return s._innerAngle=0,s._projectionTextureMatrix=Oo.Zero(),s._projectionTextureLightNear=1e-6,s._projectionTextureLightFar=1e3,s._projectionTextureUpDirection=So.Up(),s._projectionTextureViewLightDirty=!0,s._projectionTextureProjectionLightDirty=!0,s._projectionTextureDirty=!0,s._projectionTextureViewTargetVector=So.Zero(),s._projectionTextureViewLightMatrix=Oo.Zero(),s._projectionTextureProjectionLightMatrix=Oo.Zero(),s._projectionTextureScalingMatrix=Oo.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),s.position=n,s.direction=r,s.angle=i,s.exponent=o,s}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._cosHalfAngle=Math.cos(.5*e),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){var t=this;if(this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady())){var n=this._projectionTexture;n.onLoadObservable&&n.onLoadObservable.addOnce((function(){t._markMeshesAsLightDirty()}))}},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"SpotLight"},t.prototype.getTypeID=function(){return Ds.LIGHTTYPEID_SPOTLIGHT},t.prototype._setDirection=function(t){e.prototype._setDirection.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setPosition=function(t){e.prototype._setPosition.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,n){var r=this.getScene().activeCamera;if(r){this._shadowAngleScale=this._shadowAngleScale||1;var i=this._shadowAngleScale*this._angle;Oo.PerspectiveFovLHToRef(i,1,this.getDepthMinZ(r),this.getDepthMaxZ(r),e)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),Oo.LookAtLHToRef(this.position,this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)},t.prototype._computeProjectionTextureProjectionLightMatrix=function(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;var e=this.projectionTextureLightFar,t=this.projectionTextureLightNear,n=e/(e-t),r=-n*t,i=1/Math.tan(this._angle/2);Oo.FromValuesToRef(i/1,0,0,0,0,i,0,0,0,0,n,1,0,0,r,0,this._projectionTextureProjectionLightMatrix)},t.prototype._computeProjectionTextureMatrix=function(){if(this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTexture instanceof Wl){var e=this._projectionTexture.uScale/2,t=this._projectionTexture.vScale/2;Oo.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,.5,0,.5,.5,.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(.001,Math.cos(.5*this._innerAngle)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale},t.prototype.transferTexturesToEffect=function(e,t){return this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix("textureProjectionMatrix"+t,this._projectionTextureMatrix),e.setTexture("projectionLightSampler"+t,this.projectionTexture)),this},t.prototype.transferToEffect=function(e,t){var n;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,t),n=So.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,t),n=So.Normalize(this.direction)),this.getScene().useRightHandedSystem?this._uniformBuffer.updateFloat4("vLightDirection",-n.x,-n.y,-n.z,this._cosHalfAngle,t):this._uniformBuffer.updateFloat4("vLightDirection",n.x,n.y,n.z,this._cosHalfAngle,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,t),this},t.prototype.transferToNodeMaterialEffect=function(e,t){var n;return n=this.computeTransformedInformation()?So.Normalize(this.transformedDirection):So.Normalize(this.direction),this.getScene().useRightHandedSystem?e.setFloat3(t,-n.x,-n.y,-n.z):e.setFloat3(t,n.x,n.y,n.z),this},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._projectionTexture&&this._projectionTexture.dispose()},t.prototype.prepareLightSpecificDefines=function(e,t){e["SPOTLIGHT"+t]=!0,e["PROJECTEDLIGHTTEXTURE"+t]=!(!this.projectionTexture||!this.projectionTexture.isReady())},Object(No.c)([ha()],t.prototype,"angle",null),Object(No.c)([ha()],t.prototype,"innerAngle",null),Object(No.c)([ha()],t.prototype,"shadowAngleScale",null),Object(No.c)([ha()],t.prototype,"exponent",void 0),Object(No.c)([ha()],t.prototype,"projectionTextureLightNear",null),Object(No.c)([ha()],t.prototype,"projectionTextureLightFar",null),Object(No.c)([ha()],t.prototype,"projectionTextureUpDirection",null),Object(No.c)([pa("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}(Hh);!function(e){function t(t){var n=e.call(this,t)||this;return n._cachedPosition=new So,n._cachedForward=new So(0,0,1),n._light=null,n.attachedMesh=new ws("",n.gizmoLayer.utilityLayerScene),n._attachedMeshParent=new as("parent",n.gizmoLayer.originalScene),n.attachedMesh.parent=n._attachedMeshParent,n._material=new hd("light",n.gizmoLayer.originalScene),n._material.diffuseColor=new Io(.5,.5,.5),n._material.specularColor=new Io(.1,.1,.1),n}Object(No.d)(t,e),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(),this._lightMesh=e instanceof yu?t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Qh?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Kh?t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene):t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),this._lightMesh.getChildMeshes(!1).forEach((function(e){e.material=n._material})),this._lightMesh.parent=this._rootMesh;var r=this.gizmoLayer._getSharedGizmoLight();r.includedOnlyMeshes=r.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),this._lightMesh.rotationQuaternion=new Po,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!0,configurable:!0}),t.prototype._update=function(){e.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&&(So.DistanceSquared(this.attachedMesh.forward,this._cachedForward)>1e-4?(this._light.direction.copyFrom(this.attachedMesh.forward),this._cachedForward.copyFrom(this.attachedMesh.forward)):So.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))),this._light.isEnabled()?this._material.diffuseColor.set(this._light.diffuse.r/3,this._light.diffuse.g/3,this._light.diffuse.b/3):this._material.diffuseColor.set(0,0,0))},t.prototype.dispose=function(){this._material.dispose(),e.prototype.dispose.call(this),this._attachedMeshParent.dispose()},t._CreateHemisphericLightMesh=function(e){var n=new Pl("hemisphereLight",e),r=Wh.CreateHemisphere(n.name,{segments:10,diameter:1},e);r.position.z=-.15,r.rotation.x=Math.PI/2,r.parent=n;var i=this._CreateLightLines(3,e);return i.parent=n,i.position.z,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreatePointLightMesh=function(e){var n=new Pl("pointLight",e),r=zd.CreateSphere(n.name,{segments:10,diameter:1},e);return r.rotation.x=Math.PI/2,r.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 Pl("spotLight",e);zd.CreateSphere(n.name,{segments:10,diameter:1},e).parent=n;var r=Wh.CreateHemisphere(n.name,{segments:10,diameter:2},e);return r.parent=n,r.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 Pl("directionalLight",e),r=new Pl(n.name,e);r.parent=n,zd.CreateSphere(n.name,{diameter:1.2,segments:10},e).parent=r;var i=Pl.CreateCylinder(n.name,6,.3,.3,6,1,e);i.parent=r,(o=i.clone(n.name)).scaling.y=.5,o.position.x+=1.25,(a=i.clone(n.name)).scaling.y=.5,a.position.x+=-1.25;var o,a,s=Pl.CreateCylinder(n.name,1,0,.6,6,1,e);return s.position.y+=3,s.parent=r,(o=s.clone(n.name)).position.y=1.5,o.position.x+=1.25,(a=s.clone(n.name)).position.y=1.5,a.position.x+=-1.25,r.scaling.scaleInPlace(t._Scale),r.rotation.z=Math.PI/2,r.rotation.y=Math.PI/2,n},t._Scale=.007,t._CreateLightLines=function(e,t){var n=new Pl("root",t);n.rotation.x=Math.PI/2;var r=new Pl("linePivot",t);r.parent=n;var i=Pl.CreateCylinder("line",2,.2,.3,6,1,t);if(i.position.y=i.scaling.y/2+1.2,i.parent=r,e<2)return r;for(var o=0;o<4;o++){(a=r.clone("lineParentClone")).rotation.z=Math.PI/4,a.rotation.y=Math.PI/2+Math.PI/2*o,a.getChildMeshes()[0].scaling.y=.5,a.getChildMeshes()[0].scaling.x=a.getChildMeshes()[0].scaling.z=.8,a.getChildMeshes()[0].position.y=a.getChildMeshes()[0].scaling.y/2+1.2}if(e<3)return n;for(o=0;o<4;o++){(a=r.clone("linePivotClone")).rotation.z=Math.PI/2,a.rotation.y=Math.PI/2*o}if(e<4)return n;for(o=0;o<4;o++){var a;(a=r.clone("linePivotClone")).rotation.z=Math.PI+Math.PI/4,a.rotation.y=Math.PI/2+Math.PI/2*o,a.getChildMeshes()[0].scaling.y=.5,a.getChildMeshes()[0].scaling.x=a.getChildMeshes()[0].scaling.z=.8,a.getChildMeshes()[0].position.y=a.getChildMeshes()[0].scaling.y/2+1.2}return e<5||((a=r.clone("linePivotClone")).rotation.z=Math.PI),n}}(Nd);Qc.a.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";var Xh="vec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}";Qc.a.IncludesShadersStore.packingFunctions=Xh;var Yh="#ifdef DOF\nfactor=sampleCoC(sampleCoord{X});\ncomputedWeight=KERNEL_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\n#endif";Qc.a.IncludesShadersStore.kernelBlurFragment=Yh;var qh="#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});\ncomputedWeight=KERNEL_DEP_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\n#endif";Qc.a.IncludesShadersStore.kernelBlurFragment2=qh;var Zh="\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(const in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g;\nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;\n}\nfloat sampleCoC(const in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r;\nreturn coc;\n}\n#endif\n#include[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include\n#endif\nvoid main(void)\n{\nfloat computedWeight=0.0;\n#ifdef PACKEDFLOAT\nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT;\nfloat factor=0.0;\n\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include[0..varyingCount]\n#include[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}";Qc.a.ShadersStore.kernelBlurPixelShader=Zh;Qc.a.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var Jh="\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nsampleCenter=(position*madd+madd);\n#include[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n}";Qc.a.ShadersStore.kernelBlurVertexShader=Jh;var $h=function(e){function t(t,n,r,i,o,a,s,l,c,u,d){void 0===a&&(a=Wl.BILINEAR_SAMPLINGMODE),void 0===c&&(c=0),void 0===u&&(u=""),void 0===d&&(d=!1);var h=e.call(this,t,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],i,o,a,s,l,null,c,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return h.direction=n,h.blockCompilation=d,h._packedFloat=!1,h._staticDefines="",h._staticDefines=u,h.onApplyObservable.add((function(e){h._outputTexture?e.setFloat2("delta",1/h._outputTexture.width*h.direction.x,1/h._outputTexture.height*h.direction.y):e.setFloat2("delta",1/h.width*h.direction.x,1/h.height*h.direction.y)})),h.kernel=r,h}return Object(No.d)(t,e),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:!0,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:!0,configurable:!0}),t.prototype.updateEffect=function(e,t,n,r,i,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null),this._updateParameters(i,o)},t.prototype._updateParameters=function(t,n){for(var r=this._kernel,i=(r-1)/2,o=[],a=[],s=0,l=0;l0)return Math.max(i,3)}return Math.max(t,3)},t.prototype._gaussianWeight=function(e){var t=-e*e/(1/3*2*(1/3));return 1/(Math.sqrt(2*Math.PI)*(1/3))*Math.exp(t)},t.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},t}(Xc),ep=function(e){function t(t,n,r,i,o,a,s){void 0===o&&(o=0),void 0===a&&(a=Wl.BILINEAR_SAMPLINGMODE),void 0===s&&(s=!0);var l=e.call(this,t,n,r,i,!0,o,!1,a,s)||this;return l.scene=r,l.mirrorPlane=new Cs(0,1,0,1),l._transformMatrix=Oo.Zero(),l._mirrorMatrix=Oo.Zero(),l._adaptiveBlurKernel=0,l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.ignoreCameraViewport=!0,l._updateGammaSpace(),l._imageProcessingConfigChangeObserver=r.imageProcessingConfiguration.onUpdateParameters.add((function(){l._updateGammaSpace})),l.onBeforeRenderObservable.add((function(){Oo.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=r.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),r.setTransformMatrix(l._transformMatrix,r.getProjectionMatrix()),r.clipPlane=l.mirrorPlane,r.getEngine().cullBackFaces=!1,r._mirroredCameraPosition=So.TransformCoordinates(r.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){r.setTransformMatrix(l._savedViewMatrix,r.getProjectionMatrix()),r.getEngine().cullBackFaces=!0,r._mirroredCameraPosition=null,r.clipPlane=null})),l}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),t.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),n=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*n},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(),t=e.getCaps().textureFloatRender?1:2;this._blurX=new $h("horizontal blur",new Co(1,0),this._blurKernelX,this._blurRatio,null,Wl.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2&&this._texture?this._blurX.inputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new $h("vertical blur",new Co(0,1),this._blurKernelY,this._blurRatio,null,Wl.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,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(),r=new t(this.name,n.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(r.renderList=this.renderList.slice(0)),r},t.prototype.serialize=function(){if(!this.name)return null;var t=e.prototype.serialize.call(this);return t.mirrorPlane=this.mirrorPlane.asArray(),t},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver)},t}(mu);Wl._CreateMirror=function(e,t,n,r){return new ep(e,t,n,r)},Va.a.prototype._createDepthStencilCubeTexture=function(e,t){var n=new Kl.a(this,Kl.b.Unknown);if(n.isCube=!0,1===this.webGLVersion)return jo.a.Error("Depth cube texture is not supported by WebGL 1."),n;var r=Object(No.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),i=this._gl;this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,n,!0),this._setupDepthStencilTexture(n,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction);for(var o=0;o<6;o++)r.generateStencil?i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,i.DEPTH24_STENCIL8,e,e,0,i.DEPTH_STENCIL,i.UNSIGNED_INT_24_8,null):i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,i.DEPTH_COMPONENT24,e,e,0,i.DEPTH_COMPONENT,i.UNSIGNED_INT,null);return this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null),n},Va.a.prototype._partialLoadFile=function(e,t,n,r,i){void 0===i&&(i=null);this._loadFile(e,(function(e){n[t]=e,n._internalCount++,6===n._internalCount&&r(n)}),void 0,void 0,!0,(function(e,t){i&&e&&i(e.status+" "+e.statusText,t)}))},Va.a.prototype._cascadeLoadFiles=function(e,t,n,r){void 0===r&&(r=null);var i=[];i._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(n[o],o,i,t,r)},Va.a.prototype._cascadeLoadImgs=function(e,t,n,r,i){void 0===r&&(r=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)this._partialLoadImg(n[a],a,o,e,t,r,i)},Va.a.prototype._partialLoadImg=function(e,t,n,r,i,o,a){var s;void 0===o&&(o=null);s=Qa.LoadImage(e,(function(){s&&(n[t]=s,n._internalCount++,r&&r._removePendingData(s)),6===n._internalCount&&i(n)}),(function(e,t){r&&r._removePendingData(s),o&&o(e,t)}),r?r.offlineProvider:null,a),r&&s&&r._addPendingData(s)},Va.a.prototype._setCubeMapTextureParams=function(e){var t=this._gl;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,e?t.LINEAR_MIPMAP_LINEAR:t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)},Va.a.prototype.createCubeTexture=function(e,t,n,r,i,o,a,s,l,c,u,d){var h=this;void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=!1),void 0===c&&(c=0),void 0===u&&(u=0),void 0===d&&(d=null);var p=this._gl,f=d||new Kl.a(this,Kl.b.Cube);f.isCube=!0,f.url=e,f.generateMipMaps=!r,f._lodGenerationScale=c,f._lodGenerationOffset=u,this._doNotHandleContextLost||(f._extension=s,f._files=n);for(var m=e.lastIndexOf("."),g=s||(m>-1?e.substring(m).toLowerCase():""),b=null,v=0,A=Va.a._TextureLoaders;v-1?t.substring(g).toLowerCase():""),v=".dds"===b,A=".env"===b;if(A?(m.gammaSpace=!1,m._prefiltered=!1,m.anisotropicFilteringLevel=1):(m._prefiltered=c,c&&(m.gammaSpace=!1,m.anisotropicFilteringLevel=1)),m._texture=m._getFromCache(t,i),!o&&(A||v||r||(r=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),o=[],r))for(var _=0;_0,o.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,o.LODINREFLECTIONALPHA=s.lodLevelInAlpha,o.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,o.REFLECTIONBGR=this.switchToBGR,s.coordinatesMode===Wl.INVCUBIC_MODE&&(o.INVERTCUBICMAP=!0),o.REFLECTIONMAP_3D=s.isCube,s.coordinatesMode){case Wl.EXPLICIT_MODE:o.REFLECTIONMAP_EXPLICIT=!0;break;case Wl.PLANAR_MODE:o.REFLECTIONMAP_PLANAR=!0;break;case Wl.PROJECTION_MODE:o.REFLECTIONMAP_PROJECTION=!0;break;case Wl.SKYBOX_MODE:o.REFLECTIONMAP_SKYBOX=!0;break;case Wl.SPHERICAL_MODE:o.REFLECTIONMAP_SPHERICAL=!0;break;case Wl.EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Wl.FIXED_EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Wl.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Wl.CUBIC_MODE:case Wl.INVCUBIC_MODE:default:o.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(o.REFLECTIONFRESNEL=!0,o.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):(o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1)}else o.REFLECTION=!1,o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1,o.REFLECTIONBLUR=!1,o.REFLECTIONMAP_3D=!1,o.REFLECTIONMAP_SPHERICAL=!1,o.REFLECTIONMAP_PLANAR=!1,o.REFLECTIONMAP_CUBIC=!1,o.REFLECTIONMAP_PROJECTION=!1,o.REFLECTIONMAP_SKYBOX=!1,o.REFLECTIONMAP_EXPLICIT=!1,o.REFLECTIONMAP_EQUIRECTANGULAR=!1,o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,o.INVERTCUBICMAP=!1,o.REFLECTIONMAP_OPPOSITEZ=!1,o.LODINREFLECTIONALPHA=!1,o.GAMMAREFLECTION=!1,o.RGBDREFLECTION=!1}o.PREMULTIPLYALPHA=7===this.alphaMode||8===this.alphaMode,o.USERGBCOLOR=this._useRGBColor,o.NOISE=this._enableNoise}if(o._areLightsDirty&&(o.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel)),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o)}if(Cu.PrepareDefinesForMisc(e,i,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),Cu.PrepareDefinesForFrameBoundValues(i,a,o,n),Cu.PrepareDefinesForAttributes(e,o,!1,!0,!1)&&e&&(i.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(cs.NormalKind)||(e.createNormals(!0),jo.a.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),o.isDirty){o.markAsProcessed(),i.resetCachedMaterial();var l=new ud;o.FOG&&l.addFallback(0,"FOG"),o.POINTSIZE&&l.addFallback(1,"POINTSIZE"),o.MULTIVIEW&&l.addFallback(0,"MULTIVIEW"),Cu.HandleFallbacksForShadows(o,l,this._maxSimultaneousLights);var c=[cs.PositionKind];o.NORMAL&&c.push(cs.NormalKind),o.UV1&&c.push(cs.UVKind),o.UV2&&c.push(cs.UV2Kind),Cu.PrepareAttributesForBones(c,e,o,l),Cu.PrepareAttributesForInstances(c,o);var u=["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"],d=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],h=["Material","Scene"];Ms&&(Ms.PrepareUniforms(u,o),Ms.PrepareSamplers(d,o)),Cu.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:h,samplers:d,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var p=o.toString();t.setEffect(i.getEngine().createEffect("background",{attributes:c,uniformsNames:u,uniformBuffersNames:h,samplers:d,defines:p,fallbacks:l,onCompiled:function(e){r.onCompiled&&r.onCompiled(e),r.bindSceneUniformBuffer(e,i.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},a),o),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(o._renderId=i.getRenderId(),t.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(){0===this._primaryColorShadowLevel&&0===this._primaryColorHighlightLevel||(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),e.prototype.unbind.call(this)},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},t.prototype.bindForSubMesh=function(e,t,n){var r=this.getScene(),i=n._materialDefines;if(i){var o=n.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),Cu.BindBonesParameters(t,this._activeEffect);var a=this._mustRebind(r,o,t.visibility);if(a){this._uniformBuffer.bindToEffect(o,"Material"),this.bindViewProjection(o);var s=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(r.texturesEnabled&&(this._diffuseTexture&&Su.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),Cu.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),s&&Su.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",s.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",s.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),i.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),r.texturesEnabled&&(this._diffuseTexture&&Su.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),s&&Su.ReflectionTextureEnabled&&(i.REFLECTIONBLUR&&i.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",s):i.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",s._lodTextureMid||s),this._uniformBuffer.setTexture("reflectionSamplerLow",s._lodTextureLow||s),this._uniformBuffer.setTexture("reflectionSamplerHigh",s._lodTextureHigh||s)):this._uniformBuffer.setTexture("reflectionSampler",s),i.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)))),Cu.BindClipPlane(this._activeEffect,r),Cu.BindEyePosition(o,r)}!a&&this.isFrozen||(r.lightsEnabled&&Cu.BindLights(r,t,this._activeEffect,i,this._maxSimultaneousLights,!1),this.bindView(o),Cu.BindFogParameters(r,t,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}}},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._reflectionTexture===t||this._diffuseTexture===t)},t.prototype.dispose=function(t,n){void 0===t&&(t=!1),void 0===n&&(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),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var n=this;return ya.Clone((function(){return new t(e,n.getScene())}),this)},t.prototype.serialize=function(){var e=ya.Serialize(this);return e.customType="BABYLON.BackgroundMaterial",e},t.prototype.getClassName=function(){return"BackgroundMaterial"},t.Parse=function(e,n,r){return ya.Parse((function(){return new t(e.name,n)}),e,n,r)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,Object(No.c)([fa()],t.prototype,"_primaryColor",void 0),Object(No.c)([da("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),Object(No.c)([fa()],t.prototype,"__perceptualColor",void 0),Object(No.c)([ha()],t.prototype,"_primaryColorShadowLevel",void 0),Object(No.c)([ha()],t.prototype,"_primaryColorHighlightLevel",void 0),Object(No.c)([da("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),Object(No.c)([pa()],t.prototype,"_reflectionTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(No.c)([ha()],t.prototype,"_reflectionBlur",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),Object(No.c)([pa()],t.prototype,"_diffuseTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),Object(No.c)([ha()],t.prototype,"_shadowLevel",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),Object(No.c)([ga()],t.prototype,"_sceneCenter",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),Object(No.c)([ha()],t.prototype,"_opacityFresnel",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),Object(No.c)([ha()],t.prototype,"_reflectionFresnel",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),Object(No.c)([ha()],t.prototype,"_reflectionFalloffDistance",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),Object(No.c)([ha()],t.prototype,"_reflectionAmount",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),Object(No.c)([ha()],t.prototype,"_reflectionReflectance0",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),Object(No.c)([ha()],t.prototype,"_reflectionReflectance90",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),Object(No.c)([ha()],t.prototype,"_useRGBColor",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),Object(No.c)([ha()],t.prototype,"_enableNoise",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),Object(No.c)([ha()],t.prototype,"_maxSimultaneousLights",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(No.c)([Aa()],t.prototype,"_imageProcessingConfiguration",void 0),t}(Eu);Eo.RegisteredTypes["BABYLON.BackgroundMaterial"]=lp;var cp=function(){function e(t,n){var r=this;this._errorHandler=function(e,t){r.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=Object(No.a)(Object(No.a)({},e._getDefaultOptions()),t),this._scene=n,this.onErrorObservable=new yo.a,this._setupBackground(),this._setupImageProcessing()}return e._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new Io(.2,.2,.3).toLinearSpace().scale(3),groundOpacity:.9,enableGroundShadow:!0,groundShadowLevel:.5,enableGroundMirror:!1,groundMirrorSizeRatio:.3,groundMirrorBlurKernel:64,groundMirrorAmount:1,groundMirrorFresnelWeight:1,groundMirrorFallOffDistance:0,groundMirrorTextureType:0,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new Io(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:So.Zero(),setupImageProcessing:!0,environmentTexture:this._environmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(e.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skybox",{get:function(){return this._skybox},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ground",{get:function(){return this._ground},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!0,configurable:!0}),e.prototype.updateOptions=function(e){var t=Object(No.a)(Object(No.a)({},this._options),e);this._ground&&!t.createGround&&(this._ground.dispose(),this._ground=null),this._groundMaterial&&!t.createGround&&(this._groundMaterial.dispose(),this._groundMaterial=null),this._groundTexture&&this._options.groundTexture!=t.groundTexture&&(this._groundTexture.dispose(),this._groundTexture=null),this._skybox&&!t.createSkybox&&(this._skybox.dispose(),this._skybox=null),this._skyboxMaterial&&!t.createSkybox&&(this._skyboxMaterial.dispose(),this._skyboxMaterial=null),this._skyboxTexture&&this._options.skyboxTexture!=t.skyboxTexture&&(this._skyboxTexture.dispose(),this._skyboxTexture=null),this._groundMirror&&!t.enableGroundMirror&&(this._groundMirror.dispose(),this._groundMirror=null),this._scene.environmentTexture&&this._options.environmentTexture!=t.environmentTexture&&this._scene.environmentTexture.dispose(),this._options=t,this._setupBackground(),this._setupImageProcessing()},e.prototype.setMainColor=function(e){this.groundMaterial&&(this.groundMaterial.primaryColor=e),this.skyboxMaterial&&(this.skyboxMaterial.primaryColor=e),this.groundMirror&&(this.groundMirror.clearColor=new ko(e.r,e.g,e.b,1))},e.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())},e.prototype._setupEnvironmentTexture=function(){if(!this._scene.environmentTexture)if(this._options.environmentTexture instanceof Ql)this._scene.environmentTexture=this._options.environmentTexture;else{var e=tp.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new Pl("BackgroundHelper",this._scene)),this._rootMesh.rotation.y=this._options.backgroundYRotation;var e=this._getSceneSize();this._options.createGround&&(this._setupGround(e),this._setupGroundMaterial(),this._setupGroundDiffuseTexture(),this._options.enableGroundMirror&&this._setupGroundMirrorTexture(e),this._setupMirrorInGroundMaterial()),this._options.createSkybox&&(this._setupSkybox(e),this._setupSkyboxMaterial(),this._setupSkyboxReflectionTexture()),this._rootMesh.position.x=e.rootPosition.x,this._rootMesh.position.z=e.rootPosition.z,this._rootMesh.position.y=e.rootPosition.y},e.prototype._getSceneSize=function(){var e=this,t=this._options.groundSize,n=this._options.skyboxSize,r=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:t,skyboxSize:n,rootPosition:r};var i=this._scene.getWorldExtends((function(t){return t!==e._ground&&t!==e._rootMesh&&t!==e._skybox})),o=i.max.subtract(i.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof Sc&&this._scene.activeCamera.upperRadiusLimit&&(n=t=2*this._scene.activeCamera.upperRadiusLimit);var a=o.length();a>t&&(n=t=2*a),t*=1.1,n*=1.5,(r=i.min.add(o.scale(.5))).y=i.min.y-this._options.groundYBias}return{groundSize:t,skyboxSize:n,rootPosition:r}},e.prototype._setupGround=function(e){var t=this;this._ground&&!this._ground.isDisposed()||(this._ground=Pl.CreatePlane("BackgroundPlane",e.groundSize,this._scene),this._ground.rotation.x=Math.PI/2,this._ground.parent=this._rootMesh,this._ground.onDisposeObservable.add((function(){t._ground=null}))),this._ground.receiveShadows=this._options.enableGroundShadow},e.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new lp("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=8,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)},e.prototype._setupGroundDiffuseTexture=function(){if(this._groundMaterial&&!this._groundTexture)if(this._options.groundTexture instanceof Ql)this._groundMaterial.diffuseTexture=this._options.groundTexture;else{var e=new Wl(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler);e.gammaSpace=!1,e.hasAlpha=!0,this._groundMaterial.diffuseTexture=e}},e.prototype._setupGroundMirrorTexture=function(e){var t=Wl.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new ep("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Wl.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new Cs(0,-1,0,e.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=t,this._groundMirror.wrapV=t,this._groundMirror.gammaSpace=!1,this._groundMirror.renderList))for(var n=0;n0&&e.push(this._texture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)},e.prototype.dispose=function(e){e&&(this._texture&&this._texture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._tintTexture&&this._tintTexture.dispose())},e.prototype.getClassName=function(){return"PBRClearCoatConfiguration"},e.AddFallbacks=function(e,t,n){return e.CLEARCOAT_BUMP&&t.addFallback(n++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(n++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(n++,"CLEARCOAT"),n},e.AddUniforms=function(e){e.push("vClearCoatTangentSpaceParams","vClearCoatParams","vClearCoatRefractionParams","vClearCoatTintParams","clearCoatColorAtDistance","clearCoatMatrix","clearCoatBumpMatrix","clearCoatTintMatrix","vClearCoatInfos","vClearCoatBumpInfos","vClearCoatTintInfos")},e.AddSamplers=function(e){e.push("clearCoatSampler","clearCoatBumpSampler","clearCoatTintSampler")},e.PrepareUniformBuffer=function(e){e.addUniform("vClearCoatParams",2),e.addUniform("vClearCoatRefractionParams",4),e.addUniform("vClearCoatInfos",2),e.addUniform("clearCoatMatrix",16),e.addUniform("vClearCoatBumpInfos",2),e.addUniform("vClearCoatTangentSpaceParams",2),e.addUniform("clearCoatBumpMatrix",16),e.addUniform("vClearCoatTintParams",4),e.addUniform("clearCoatColorAtDistance",1),e.addUniform("vClearCoatTintInfos",2),e.addUniform("clearCoatTintMatrix",16)},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},e._DefaultIndexOfRefraction=1.5,Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(No.c)([ha()],e.prototype,"intensity",void 0),Object(No.c)([ha()],e.prototype,"roughness",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indexOfRefraction",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"bumpTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTintEnabled",void 0),Object(No.c)([fa()],e.prototype,"tintColor",void 0),Object(No.c)([ha()],e.prototype,"tintColorAtDistance",void 0),Object(No.c)([ha()],e.prototype,"tintThickness",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"tintTexture",void 0),e}(),pp=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new Co(1,0),this._texture=null,this.texture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e}var t;return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){return!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&Su.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},e.prototype.prepareDefines=function(e,t,n){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!t.isVerticesDataPresent(cs.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&Su.AnisotropicTextureEnabled?Cu.PrepareDefinesForMergedUV(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1)},e.prototype.bindForSubMesh=function(e,t,n){e.useUbo&&n&&e.isSync||(this._texture&&Su.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),Cu.BindTextureMatrix(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&Su.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},e.prototype.getClassName=function(){return"PBRAnisotropicConfiguration"},e.AddFallbacks=function(e,t,n){return e.ANISOTROPIC&&t.addFallback(n++,"ANISOTROPIC"),n},e.AddUniforms=function(e){e.push("vAnisotropy","vAnisotropyInfos","anisotropyMatrix")},e.PrepareUniformBuffer=function(e){e.addUniform("vAnisotropy",3),e.addUniform("vAnisotropyInfos",2),e.addUniform("anisotropyMatrix",16)},e.AddSamplers=function(e){e.push("anisotropySampler")},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(No.c)([ha()],e.prototype,"intensity",void 0),Object(No.c)([ua(4,t)],e.prototype,"direction",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),e}(),fp=function(){function e(t){this._useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._internalMarkAllSubMeshesAsMiscDirty=t}return e.prototype._markAllSubMeshesAsMiscDirty=function(){this._internalMarkAllSubMeshesAsMiscDirty()},e.prototype.prepareDefines=function(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation},e.prototype.getClassName=function(){return"PBRBRDFConfiguration"},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},e.DEFAULT_USE_ENERGY_CONSERVATION=!0,e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0,e.DEFAULT_USE_SPHERICAL_HARMONICS=!0,e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0,Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],e.prototype,"useEnergyConservation",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSmithVisibilityHeightCorrelated",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSphericalHarmonics",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSpecularGlossinessInputEnergyConservation",void 0),e}(),mp=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=Io.White(),this._texture=null,this.texture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){return!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&Su.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())},e.prototype.prepareDefines=function(e,t){this._isEnabled?(e.SHEEN=this._isEnabled,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&Su.SheenTextureEnabled?Cu.PrepareDefinesForMergedUV(this._texture,e,"SHEEN_TEXTURE"):e.SHEEN_TEXTURE=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_LINKWITHALBEDO=!1)},e.prototype.bindForSubMesh=function(e,t,n){e.useUbo&&n&&e.isSync||(this._texture&&Su.SheenTextureEnabled&&(e.updateFloat2("vSheenInfos",this._texture.coordinatesIndex,this._texture.level),Cu.BindTextureMatrix(this._texture,e,"sheen")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity)),t.texturesEnabled&&this._texture&&Su.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture)},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},e.prototype.getClassName=function(){return"PBRSheenConfiguration"},e.AddFallbacks=function(e,t,n){return e.SHEEN&&t.addFallback(n++,"SHEEN"),n},e.AddUniforms=function(e){e.push("vSheenColor","vSheenInfos","sheenMatrix")},e.PrepareUniformBuffer=function(e){e.addUniform("vSheenColor",4),e.addUniform("vSheenInfos",2),e.addUniform("sheenMatrix",16)},e.AddSamplers=function(e){e.push("sheenSampler")},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkSheenWithAlbedo",void 0),Object(No.c)([ha()],e.prototype,"intensity",void 0),Object(No.c)([fa()],e.prototype,"color",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),e}(),gp=function(){function e(e){this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isScatteringEnabled=!1,this.refractionIntensity=1,this.translucencyIntensity=1,this.scatteringIntensity=1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1,this.indexOfRefraction=1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.tintColor=Io.White(),this.tintColorAtDistance=1,this.diffusionDistance=Io.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&Su.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var n=this._getRefractionTexture(t);if(n&&Su.RefractionTextureEnabled&&!n.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(e,t){if(e._areTexturesDirty&&(e.SUBSURFACE=!1,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_SCATERRING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE=!1,e.SS_REFRACTION=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled)&&(e.SUBSURFACE=!0,e._areTexturesDirty&&t.texturesEnabled&&this._thicknessTexture&&Su.ThicknessTextureEnabled&&Cu.PrepareDefinesForMergedUV(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),e.SS_MASK_FROM_THICKNESS_TEXTURE=this._useMaskFromThicknessTexture),this._isRefractionEnabled&&t.texturesEnabled)){var n=this._getRefractionTexture(t);n&&Su.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=n.isCube,e.SS_GAMMAREFRACTION=n.gammaSpace,e.SS_RGBDREFRACTION=n.isRGBD,e.SS_LINEARSPECULARREFRACTION=n.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=n.invertZ,e.SS_LODINREFRACTIONALPHA=n.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency)}},e.prototype.bindForSubMesh=function(e,t,n,r,i){var o=this._getRefractionTexture(t);if(!e.useUbo||!r||!e.isSync){if(this._thicknessTexture&&Su.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),Cu.BindTextureMatrix(this._thicknessTexture,e,"thickness")),e.updateFloat2("vThicknessParam",this.minimumThickness,this.maximumThickness-this.minimumThickness),o&&Su.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",o.getReflectionTextureMatrix());var a=1;o.isCube||o.depth&&(a=o.depth),e.updateFloat4("vRefractionInfos",o.level,1/this._indexOfRefraction,a,this._invertRefractionY?-1:1),e.updateFloat3("vRefractionMicrosurfaceInfos",o.getSize().width,o.lodGenerationScale,o.lodGenerationOffset)}e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,this.tintColorAtDistance),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,this.scatteringIntensity)}t.texturesEnabled&&(this._thicknessTexture&&Su.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),o&&Su.RefractionTextureEnabled&&(i?e.setTexture("refractionSampler",o):(e.setTexture("refractionSampler",o._lodTextureMid||o),e.setTexture("refractionSamplerLow",o._lodTextureLow||o),e.setTexture("refractionSamplerHigh",o._lodTextureHigh||o))))},e.prototype.unbind=function(e){return!(!this._refractionTexture||!this._refractionTexture.isRenderTarget)&&(e.setTexture("refractionSampler",null),!0)},e.prototype._getRefractionTexture=function(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null},Object.defineProperty(e.prototype,"disableAlphaBlending",{get:function(){return this.isRefractionEnabled&&this._linkRefractionWithTransparency},enumerable:!0,configurable:!0}),e.prototype.fillRenderTargetTextures=function(e){Su.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)},e.prototype.hasTexture=function(e){return this._thicknessTexture===e||this._refractionTexture===e},e.prototype.hasRenderTargetTextures=function(){return!!(Su.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},e.prototype.getActiveTextures=function(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture)},e.prototype.getAnimatables=function(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture)},e.prototype.dispose=function(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose())},e.prototype.getClassName=function(){return"PBRSubSurfaceConfiguration"},e.AddFallbacks=function(e,t,n){return e.SS_SCATERRING&&t.addFallback(n++,"SS_SCATERRING"),e.SS_TRANSLUCENCY&&t.addFallback(n++,"SS_TRANSLUCENCY"),n},e.AddUniforms=function(e){e.push("vDiffusionDistance","vTintColor","vSubSurfaceIntensity","vRefractionMicrosurfaceInfos","vRefractionInfos","vThicknessInfos","vThicknessParam","refractionMatrix","thicknessMatrix")},e.AddSamplers=function(e){e.push("thicknessSampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh")},e.PrepareUniformBuffer=function(e){e.addUniform("vRefractionMicrosurfaceInfos",3),e.addUniform("vRefractionInfos",4),e.addUniform("refractionMatrix",16),e.addUniform("vThicknessInfos",2),e.addUniform("thicknessMatrix",16),e.addUniform("vThicknessParam",2),e.addUniform("vDiffusionDistance",3),e.addUniform("vTintColor",4),e.addUniform("vSubSurfaceIntensity",3)},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isRefractionEnabled",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTranslucencyEnabled",void 0),Object(No.c)([ha()],e.prototype,"refractionIntensity",void 0),Object(No.c)([ha()],e.prototype,"translucencyIntensity",void 0),Object(No.c)([ha()],e.prototype,"scatteringIntensity",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"thicknessTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"refractionTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indexOfRefraction",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"invertRefractionY",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkRefractionWithTransparency",void 0),Object(No.c)([ha()],e.prototype,"minimumThickness",void 0),Object(No.c)([ha()],e.prototype,"maximumThickness",void 0),Object(No.c)([fa()],e.prototype,"tintColor",void 0),Object(No.c)([ha()],e.prototype,"tintColorAtDistance",void 0),Object(No.c)([fa()],e.prototype,"diffusionDistance",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useMaskFromThicknessTexture",void 0),e}(),bp="uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n#endif";Qc.a.IncludesShadersStore.pbrFragmentDeclaration=bp;var vp="layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float pointSize;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";Qc.a.IncludesShadersStore.pbrUboDeclaration=vp;var Ap="uniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif";Qc.a.IncludesShadersStore.pbrFragmentExtraDeclaration=Ap;var _p="#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform samplerCube irradianceSampler;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform sampler2D reflectionSamplerLow;\nuniform sampler2D reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform sampler2D irradianceSampler;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\n#ifdef SS_REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\n#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1\n#define vThicknessUV vMainUV1\n#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2\n#define vThicknessUV vMainUV2\n#else\nvarying vec2 vThicknessUV;\n#endif\nuniform sampler2D thicknessSampler;\n#endif\n#endif";Qc.a.IncludesShadersStore.pbrFragmentSamplersDeclaration=_p;var yp="\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\n\n\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n\n\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\n\n\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\n\n\n\nvec3 cocaLambert(vec3 alpha,float distance) {\nreturn exp(-alpha*distance);\n}\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n\n\n\n\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif";Qc.a.IncludesShadersStore.pbrHelperFunctions=yp;var xp="#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n\n\n\n\n\n\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nreturn vSphericalL00\n+vSphericalL1_1*(normal.y)\n+vSphericalL10*(normal.z)\n+vSphericalL11*(normal.x)\n+vSphericalL2_2*(normal.y*normal.x)\n+vSphericalL2_1*(normal.y*normal.z)\n+vSphericalL20*((3.0*normal.z*normal.z)-1.0)\n+vSphericalL21*(normal.z*normal.x)\n+vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));\n}\n#else\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\n}\n#endif\n#endif";Qc.a.IncludesShadersStore.harmonicsFunctions=xp;var wp="\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotLUnclamped;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\nresult.NdotLUnclamped=result.NdotL;\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";Qc.a.IncludesShadersStore.pbrDirectLightingSetupFunctions=wp;var Ep="float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/maxEps(lightDistanceSquared);\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=saturate(1.0-factor*factor);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}";Qc.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions=Ep;var Cp="\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n\n\n\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec4 brdfLookup=texture2D(environmentBrdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(REFLECTION)\n\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\n\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\n\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n\n\n\n\n#ifdef BRDF_V_HEIGHT_CORRELATED\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n#endif\n#ifdef SHEEN\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n#endif\n\n\n\n\n\n\n\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n#ifdef SS_TRANSLUCENCY\n\n\nvec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {\nvec3 S=1./maxEps(diffusionDistance);\nvec3 temp=exp((-0.333333333*thickness)*S);\nreturn tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);\n}\n\n\nfloat computeWrappedDiffuseNdotL(float NdotL,float w) {\nfloat t=1.0+w;\nfloat invt2=1.0/square(t);\nreturn saturate((NdotL+w)*invt2);\n}\n#endif\n";Qc.a.IncludesShadersStore.pbrBRDFFunctions=Cp;var Sp="#define CLEARCOATREFLECTANCE90 1.0\n\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\n\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SS_TRANSLUCENCY\nvec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {\nfloat NdotL=absEps(info.NdotLUnclamped);\n\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\n\nfloat trAdapt=step(0.,info.NdotLUnclamped);\nvec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);\nfloat diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;\n}\n#endif\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat kelemenVisibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*kelemenVisibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n\nfloat fresnel=1.;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\nfloat ashikhminvisibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\nfloat sheenTerm=fresnel*distribution*ashikhminvisibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";Qc.a.IncludesShadersStore.pbrDirectLightingFunctions=Sp;var Tp="#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {\nfloat lod=log2(cubeMapDimensionPixels)*roughness;\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,normal));\nreturn square(temp);\n}\n#endif\n\n\n\n\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif";Qc.a.IncludesShadersStore.pbrIBLFunctions=Tp;var Pp="#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w=1)&&e.prototype.needAlphaBlendingForMesh.call(this,t)},t.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this.subSurface.disableAlphaBlending&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&(null==this._transparencyMode||this._transparencyMode===t.PBRMATERIAL_ALPHATEST))},t.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==t.PBRMATERIAL_OPAQUE},t.prototype.getAlphaTestTexture=function(){return this._albedoTexture},t.prototype.isReadyForSubMesh=function(e,t,n){if(t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new Ip);var r=t._materialDefines;if(!this.checkReadyOnEveryCall&&t.effect&&r._renderId===this.getScene().getRenderId())return!0;var i=this.getScene(),o=i.getEngine();if(r._areTexturesDirty&&i.texturesEnabled){if(this._albedoTexture&&Su.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&Su.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&Su.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var a=this._getReflectionTexture();if(a&&Su.ReflectionTextureEnabled){if(!a.isReadyOrNotBlocking())return!1;if(a.irradianceTexture&&!a.irradianceTexture.isReadyOrNotBlocking())return!1}if(this._lightmapTexture&&Su.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&Su.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(Su.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&Su.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;if(this._environmentBRDFTexture&&Su.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(!(this.subSurface.isReadyForSubMesh(r,i)&&this.clearCoat.isReadyForSubMesh(r,i,o,this._disableBumpMap)&&this.sheen.isReadyForSubMesh(r,i)&&this.anisotropy.isReadyForSubMesh(r,i)))return!1;if(r._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;o.getCaps().standardDerivatives||e.isVerticesDataPresent(cs.NormalKind)||(e.createNormals(!0),jo.a.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var s=t.effect,l=r._areLightsDisposed,c=this._prepareEffect(e,r,this.onCompiled,this.onError,n);if(c)if(this.allowShaderHotSwapping&&s&&!c.isReady()){if(c=s,this._rebuildInParallel=!0,r.markAsUnprocessed(),l)return r._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,i.resetCachedMaterial(),t.setEffect(c,r),this.buildUniformLayout();return!(!t.effect||!t.effect.isReady())&&(r._renderId=i.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.isMetallicWorkflow=function(){return!(null==this._metallic&&null==this._roughness&&!this._metallicTexture)},t.prototype._prepareEffect=function(e,t,n,r,i,o){if(void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=null),this._prepareDefines(e,t,i,o),!t.isDirty)return null;t.markAsProcessed();var a=this.getScene().getEngine(),s=new ud,l=0;t.USESPHERICALINVERTEX&&s.addFallback(l++,"USESPHERICALINVERTEX"),t.FOG&&s.addFallback(l,"FOG"),t.SPECULARAA&&s.addFallback(l,"SPECULARAA"),t.POINTSIZE&&s.addFallback(l,"POINTSIZE"),t.LOGARITHMICDEPTH&&s.addFallback(l,"LOGARITHMICDEPTH"),t.PARALLAX&&s.addFallback(l,"PARALLAX"),t.PARALLAXOCCLUSION&&s.addFallback(l++,"PARALLAXOCCLUSION"),l=pp.AddFallbacks(t,s,l),l=pp.AddFallbacks(t,s,l),l=gp.AddFallbacks(t,s,l),l=mp.AddFallbacks(t,s,l),t.ENVIRONMENTBRDF&&s.addFallback(l++,"ENVIRONMENTBRDF"),t.TANGENT&&s.addFallback(l++,"TANGENT"),t.BUMP&&s.addFallback(l++,"BUMP"),l=Cu.HandleFallbacksForShadows(t,s,this._maxSimultaneousLights,l++),t.SPECULARTERM&&s.addFallback(l++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&s.addFallback(l++,"USESPHERICALFROMREFLECTIONMAP"),t.USEIRRADIANCEMAP&&s.addFallback(l++,"USEIRRADIANCEMAP"),t.LIGHTMAP&&s.addFallback(l++,"LIGHTMAP"),t.NORMAL&&s.addFallback(l++,"NORMAL"),t.AMBIENT&&s.addFallback(l++,"AMBIENT"),t.EMISSIVE&&s.addFallback(l++,"EMISSIVE"),t.VERTEXCOLOR&&s.addFallback(l++,"VERTEXCOLOR"),t.MORPHTARGETS&&s.addFallback(l++,"MORPHTARGETS"),t.MULTIVIEW&&s.addFallback(0,"MULTIVIEW");var c=[cs.PositionKind];t.NORMAL&&c.push(cs.NormalKind),t.TANGENT&&c.push(cs.TangentKind),t.UV1&&c.push(cs.UVKind),t.UV2&&c.push(cs.UV2Kind),t.VERTEXCOLOR&&c.push(cs.ColorKind),Cu.PrepareAttributesForBones(c,e,t,s),Cu.PrepareAttributesForInstances(c,t),Cu.PrepareAttributesForMorphTargets(c,e,t);var u="pbr",d=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","visibility","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","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"],h=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","microSurfaceSampler","environmentBrdfSampler","boneSampler"],p=["Material","Scene"];gp.AddUniforms(d),gp.AddSamplers(h),hp.AddUniforms(d),hp.AddSamplers(h),pp.AddUniforms(d),pp.AddSamplers(h),mp.AddUniforms(d),mp.AddSamplers(h),Ms&&(Ms.PrepareUniforms(d,t),Ms.PrepareSamplers(h,t)),Cu.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:h,defines:t,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,d,p,h,t));var f=t.toString();return a.createEffect(u,{attributes:c,uniformsNames:d,uniformBuffersNames:p,samplers:h,defines:f,fallbacks:s,onCompiled:n,onError:r,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS}},a)},t.prototype._prepareDefines=function(e,n,r,i){void 0===r&&(r=null),void 0===i&&(i=null);var o=this.getScene(),a=o.getEngine();if(Cu.PrepareDefinesForLights(o,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._needNormals=!0,Cu.PrepareDefinesForMultiview(o,n),n.METALLICWORKFLOW=this.isMetallicWorkflow(),n._areTexturesDirty){if(n._needUVs=!1,o.texturesEnabled){o.getEngine().getCaps().textureLOD&&(n.LODBASEDMICROSFURACE=!0),this._albedoTexture&&Su.DiffuseTextureEnabled?(Cu.PrepareDefinesForMergedUV(this._albedoTexture,n,"ALBEDO"),n.GAMMAALBEDO=this._albedoTexture.gammaSpace):n.ALBEDO=!1,this._ambientTexture&&Su.AmbientTextureEnabled?(Cu.PrepareDefinesForMergedUV(this._ambientTexture,n,"AMBIENT"),n.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):n.AMBIENT=!1,this._opacityTexture&&Su.OpacityTextureEnabled?(Cu.PrepareDefinesForMergedUV(this._opacityTexture,n,"OPACITY"),n.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):n.OPACITY=!1;var s=this._getReflectionTexture();if(s&&Su.ReflectionTextureEnabled){switch(n.REFLECTION=!0,n.GAMMAREFLECTION=s.gammaSpace,n.RGBDREFLECTION=s.isRGBD,n.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,n.LODINREFLECTIONALPHA=s.lodLevelInAlpha,n.LINEARSPECULARREFLECTION=s.linearSpecularLOD,s.coordinatesMode===Wl.INVCUBIC_MODE&&(n.INVERTCUBICMAP=!0),n.REFLECTIONMAP_3D=s.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,s.coordinatesMode){case Wl.EXPLICIT_MODE:n.REFLECTIONMAP_EXPLICIT=!0;break;case Wl.PLANAR_MODE:n.REFLECTIONMAP_PLANAR=!0;break;case Wl.PROJECTION_MODE:n.REFLECTIONMAP_PROJECTION=!0;break;case Wl.SKYBOX_MODE:n.REFLECTIONMAP_SKYBOX=!0;break;case Wl.SPHERICAL_MODE:n.REFLECTIONMAP_SPHERICAL=!0;break;case Wl.EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Wl.FIXED_EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Wl.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Wl.CUBIC_MODE:case Wl.INVCUBIC_MODE:default:n.REFLECTIONMAP_CUBIC=!0,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!!s.boundingBoxSize}s.coordinatesMode!==Wl.SKYBOX_MODE&&(s.irradianceTexture?(n.USEIRRADIANCEMAP=!0,n.USESPHERICALFROMREFLECTIONMAP=!1):s.isCube&&(n.USESPHERICALFROMREFLECTIONMAP=!0,n.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||o.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&&Su.LightmapTextureEnabled?(Cu.PrepareDefinesForMergedUV(this._lightmapTexture,n,"LIGHTMAP"),n.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,n.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,n.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):n.LIGHTMAP=!1,this._emissiveTexture&&Su.EmissiveTextureEnabled?Cu.PrepareDefinesForMergedUV(this._emissiveTexture,n,"EMISSIVE"):n.EMISSIVE=!1,Su.SpecularTextureEnabled?(this._metallicTexture?(Cu.PrepareDefinesForMergedUV(this._metallicTexture,n,"REFLECTIVITY"),n.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,n.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,n.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,n.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,n.METALLICF0FACTORFROMMETALLICMAP=this._useMetallicF0FactorFromMetallicTexture):this._reflectivityTexture?(Cu.PrepareDefinesForMergedUV(this._reflectivityTexture,n,"REFLECTIVITY"),n.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,n.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):n.REFLECTIVITY=!1,this._microSurfaceTexture?Cu.PrepareDefinesForMergedUV(this._microSurfaceTexture,n,"MICROSURFACEMAP"):n.MICROSURFACEMAP=!1):(n.REFLECTIVITY=!1,n.MICROSURFACEMAP=!1),o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&Su.BumpTextureEnabled&&!this._disableBumpMap?(Cu.PrepareDefinesForMergedUV(this._bumpTexture,n,"BUMP"),this._useParallax&&this._albedoTexture&&Su.DiffuseTextureEnabled?(n.PARALLAX=!0,n.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):n.PARALLAX=!1,n.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):n.BUMP=!1,this._environmentBRDFTexture&&Su.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=o.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(n._areTexturesDirty||n._areMiscDirty)&&(n.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?".":""),n.PREMULTIPLYALPHA=7===this.alphaMode||8===this.alphaMode,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&&(Cu.PrepareDefinesForMisc(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,n),n.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(cs.NormalKind),n.DEBUGMODE=this._debugMode),this.subSurface.prepareDefines(n,o),this.clearCoat.prepareDefines(n,o),this.anisotropy.prepareDefines(n,e,o),this.brdf.prepareDefines(n),this.sheen.prepareDefines(n,o),Cu.PrepareDefinesForFrameBoundValues(o,a,n,!!r,i),Cu.PrepareDefinesForAttributes(e,n,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE)},t.prototype.forceCompilation=function(e,t,n){var r=this,i=Object(No.a)({clipPlane:!1,useInstances:!1},n),o=new Ip,a=this._prepareEffect(e,o,void 0,void 0,i.useInstances,i.clipPlane);a.isReady()?t&&t(this):a.onCompileObservable.add((function(){t&&t(r)}))},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("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),hp.PrepareUniformBuffer(e),pp.PrepareUniformBuffer(e),mp.PrepareUniformBuffer(e),gp.PrepareUniformBuffer(e),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),t=!0),this.subSurface.unbind(this._activeEffect)&&(t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,t,n){var r=this.getScene(),i=n._materialDefines;if(i){var o=n.effect;if(o){this._activeEffect=o,i.INSTANCES||this.bindOnlyWorldMatrix(e),i.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var a=this._mustRebind(r,o,t.visibility);Cu.BindBonesParameters(t,this._activeEffect);var s=null,l=this._uniformBuffer;if(a){var c=r.getEngine();if(l.bindToEffect(o,"Material"),this.bindViewProjection(o),s=this._getReflectionTexture(),!l.useUbo||!this.isFrozen||!l.isSync){if(r.texturesEnabled){if(this._albedoTexture&&Su.DiffuseTextureEnabled&&(l.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),Cu.BindTextureMatrix(this._albedoTexture,l,"albedo")),this._ambientTexture&&Su.AmbientTextureEnabled&&(l.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),Cu.BindTextureMatrix(this._ambientTexture,l,"ambient")),this._opacityTexture&&Su.OpacityTextureEnabled&&(l.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),Cu.BindTextureMatrix(this._opacityTexture,l,"opacity")),s&&Su.ReflectionTextureEnabled){if(l.updateMatrix("reflectionMatrix",s.getReflectionTextureMatrix()),l.updateFloat2("vReflectionInfos",s.level,0),s.boundingBoxSize){var u=s;l.updateVector3("vReflectionPosition",u.boundingBoxPosition),l.updateVector3("vReflectionSize",u.boundingBoxSize)}if(!i.USEIRRADIANCEMAP){var d=s.sphericalPolynomial;if(i.USESPHERICALFROMREFLECTIONMAP&&d)if(i.SPHERICAL_HARMONICS){var h=d.preScaledHarmonics;this._activeEffect.setVector3("vSphericalL00",h.l00),this._activeEffect.setVector3("vSphericalL1_1",h.l1_1),this._activeEffect.setVector3("vSphericalL10",h.l10),this._activeEffect.setVector3("vSphericalL11",h.l11),this._activeEffect.setVector3("vSphericalL2_2",h.l2_2),this._activeEffect.setVector3("vSphericalL2_1",h.l2_1),this._activeEffect.setVector3("vSphericalL20",h.l20),this._activeEffect.setVector3("vSphericalL21",h.l21),this._activeEffect.setVector3("vSphericalL22",h.l22)}else this._activeEffect.setFloat3("vSphericalX",d.x.x,d.x.y,d.x.z),this._activeEffect.setFloat3("vSphericalY",d.y.x,d.y.y,d.y.z),this._activeEffect.setFloat3("vSphericalZ",d.z.x,d.z.y,d.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",d.xx.x-d.zz.x,d.xx.y-d.zz.y,d.xx.z-d.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",d.yy.x-d.zz.x,d.yy.y-d.zz.y,d.yy.z-d.zz.z),this._activeEffect.setFloat3("vSphericalZZ",d.zz.x,d.zz.y,d.zz.z),this._activeEffect.setFloat3("vSphericalXY",d.xy.x,d.xy.y,d.xy.z),this._activeEffect.setFloat3("vSphericalYZ",d.yz.x,d.yz.y,d.yz.z),this._activeEffect.setFloat3("vSphericalZX",d.zx.x,d.zx.y,d.zx.z)}l.updateFloat3("vReflectionMicrosurfaceInfos",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset)}this._emissiveTexture&&Su.EmissiveTextureEnabled&&(l.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),Cu.BindTextureMatrix(this._emissiveTexture,l,"emissive")),this._lightmapTexture&&Su.LightmapTextureEnabled&&(l.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),Cu.BindTextureMatrix(this._lightmapTexture,l,"lightmap")),Su.SpecularTextureEnabled&&(this._metallicTexture?(l.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),Cu.BindTextureMatrix(this._metallicTexture,l,"reflectivity")):this._reflectivityTexture&&(l.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),Cu.BindTextureMatrix(this._reflectivityTexture,l,"reflectivity")),this._microSurfaceTexture&&(l.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),Cu.BindTextureMatrix(this._microSurfaceTexture,l,"microSurfaceSampler"))),this._bumpTexture&&c.getCaps().standardDerivatives&&Su.BumpTextureEnabled&&!this._disableBumpMap&&(l.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),Cu.BindTextureMatrix(this._bumpTexture,l,"bump"),r._mirroredCameraPosition?l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&l.updateFloat("pointSize",this.pointSize),i.METALLICWORKFLOW){Do.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,Do.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness;var p=.08*this._metallicF0Factor;l.updateColor4("vReflectivityColor",Do.Color3[0],p)}else l.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);l.updateColor3("vEmissiveColor",Su.EmissiveTextureEnabled?this._emissiveColor:Io.BlackReadOnly),l.updateColor3("vReflectionColor",this._reflectionColor),!i.SS_REFRACTION&&this.subSurface.linkRefractionWithTransparency?l.updateColor4("vAlbedoColor",this._albedoColor,1):l.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),l.updateFloat("visibility",t.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*r.environmentIntensity,this._lightingInfos.w=this._specularIntensity,l.updateVector4("vLightingIntensity",this._lightingInfos)}r.texturesEnabled&&(this._albedoTexture&&Su.DiffuseTextureEnabled&&l.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&Su.AmbientTextureEnabled&&l.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&Su.OpacityTextureEnabled&&l.setTexture("opacitySampler",this._opacityTexture),s&&Su.ReflectionTextureEnabled&&(i.LODBASEDMICROSFURACE?l.setTexture("reflectionSampler",s):(l.setTexture("reflectionSampler",s._lodTextureMid||s),l.setTexture("reflectionSamplerLow",s._lodTextureLow||s),l.setTexture("reflectionSamplerHigh",s._lodTextureHigh||s)),i.USEIRRADIANCEMAP&&l.setTexture("irradianceSampler",s.irradianceTexture)),i.ENVIRONMENTBRDF&&l.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&Su.EmissiveTextureEnabled&&l.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&Su.LightmapTextureEnabled&&l.setTexture("lightmapSampler",this._lightmapTexture),Su.SpecularTextureEnabled&&(this._metallicTexture?l.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&l.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&l.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&c.getCaps().standardDerivatives&&Su.BumpTextureEnabled&&!this._disableBumpMap&&l.setTexture("bumpSampler",this._bumpTexture)),this.subSurface.bindForSubMesh(l,r,c,this.isFrozen,i.LODBASEDMICROSFURACE),this.clearCoat.bindForSubMesh(l,r,c,this._disableBumpMap,this.isFrozen,this._invertNormalMapX,this._invertNormalMapY),this.anisotropy.bindForSubMesh(l,r,this.isFrozen),this.sheen.bindForSubMesh(l,r,this.isFrozen),Cu.BindClipPlane(this._activeEffect,r),r.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var f=r._forcedViewPosition?r._forcedViewPosition:r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.globalPosition,m=r.useRightHandedSystem===(null!=r._mirroredCameraPosition);o.setFloat4("vEyePosition",f.x,f.y,f.z,m?-1:1),o.setColor3("vAmbientColor",this._globalAmbientColor),o.setFloat2("vDebugMode",this.debugLimit,this.debugFactor)}!a&&this.isFrozen||(r.lightsEnabled&&!this._disableLighting&&Cu.BindLights(r,t,this._activeEffect,i,this._maxSimultaneousLights,this._rebuildInParallel),(r.fogEnabled&&t.applyFog&&r.fogMode!==nl.FOGMODE_NONE||s)&&this.bindView(o),Cu.BindFogParameters(r,t,this._activeEffect,!0),i.NUM_MORPH_INFLUENCERS&&Cu.BindMorphTargetParameters(t,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),Cu.BindLogDepth(i,this._activeEffect,r)),l.update(),this._afterBind(t,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.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 t=e.prototype.getActiveTextures.call(this);return this._albedoTexture&&t.push(this._albedoTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._reflectivityTexture&&t.push(this._reflectivityTexture),this._metallicTexture&&t.push(this._metallicTexture),this._microSurfaceTexture&&t.push(this._microSurfaceTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this.subSurface.getActiveTextures(t),this.clearCoat.getActiveTextures(t),this.sheen.getActiveTextures(t),this.anisotropy.getActiveTextures(t),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._albedoTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._reflectivityTexture===t||(this._metallicTexture===t||(this._microSurfaceTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||(this.subSurface.hasTexture(t)||this.clearCoat.hasTexture(t)||this.sheen.hasTexture(t)||this.anisotropy.hasTexture(t)))))))))))},t.prototype.dispose=function(t,n){n&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose()),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),e.prototype.dispose.call(this,t,n)},t.PBRMATERIAL_OPAQUE=0,t.PBRMATERIAL_ALPHATEST=1,t.PBRMATERIAL_ALPHABLEND=2,t.PBRMATERIAL_ALPHATESTANDBLEND=3,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,Object(No.c)([Aa()],t.prototype,"_imageProcessingConfiguration",void 0),Object(No.c)([da("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),Object(No.c)([ha()],t.prototype,"useLogarithmicDepth",null),Object(No.c)([ha()],t.prototype,"transparencyMode",null),t}(Eu),Dp=function(e){function t(n,r){var i=e.call(this,n,r)||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=.5,i.useMetallicF0FactorFromMetallicTexture=!1,i.ambientColor=new Io(0,0,0),i.albedoColor=new Io(1,1,1),i.reflectivityColor=new Io(1,1,1),i.reflectionColor=new Io(1,1,1),i.emissiveColor=new Io(0,0,0),i.microSurface=1,i.useLightmapAsShadowmap=!1,i.useAlphaFromAlbedoTexture=!1,i.forceAlphaTest=!1,i.alphaCutOff=.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=.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=dp.GetEnvironmentBRDFTexture(r),i}return Object(No.d)(t,e),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:!0,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return 1/this.subSurface.indexOfRefraction},set:function(e){this.subSurface.indexOfRefraction=1/e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"invertRefractionY",{get:function(){return this.subSurface.invertRefractionY},set:function(e){this.subSurface.invertRefractionY=e},enumerable:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===kp.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?kp.LIGHTFALLOFF_PHYSICAL:kp.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===kp.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?kp.LIGHTFALLOFF_GLTF:kp.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"PBRMaterial"},t.prototype.clone=function(e){var n=this,r=ya.Clone((function(){return new t(e,n.getScene())}),this);return r.id=e,r.name=e,this.clearCoat.copyTo(r.clearCoat),this.anisotropy.copyTo(r.anisotropy),this.brdf.copyTo(r.brdf),this.sheen.copyTo(r.sheen),this.subSurface.copyTo(r.subSurface),r},t.prototype.serialize=function(){var e=ya.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,r){var i=ya.Parse((function(){return new t(e.name,n)}),e,n,r);return e.clearCoat&&i.clearCoat.parse(e.clearCoat,n,r),e.anisotropy&&i.anisotropy.parse(e.anisotropy,n,r),e.brdf&&i.brdf.parse(e.brdf,n,r),e.sheen&&i.sheen.parse(e.sheen,n,r),e.subSurface&&i.subSurface.parse(e.subSurface,n,r),i},t.PBRMATERIAL_OPAQUE=kp.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=kp.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=kp.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=kp.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=kp.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicF0Factor",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallicF0FactorFromMetallicTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),Object(No.c)([fa("ambient"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),Object(No.c)([fa("albedo"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),Object(No.c)([fa("reflectivity"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),Object(No.c)([fa("reflection"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),Object(No.c)([fa("emissive"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),Object(No.c)([ha()],t.prototype,"usePhysicalLightFalloff",null),Object(No.c)([ha()],t.prototype,"useGLTFLightFalloff",null),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),t}(kp);Eo.RegisteredTypes["BABYLON.PBRMaterial"]=Dp;function Bp(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var Fp=Bp("DXT1"),Np=Bp("DXT3"),Lp=Bp("DXT5"),Up=Bp("DX10"),Vp=function(){function e(){}return e.GetDDSInfo=function(e){var t=new Int32Array(e.buffer,e.byteOffset,31),n=new Int32Array(e.buffer,e.byteOffset,35),r=1;131072&t[2]&&(r=Math.max(1,t[7]));var i=t[21],o=i===Up?n[32]:0,a=0;switch(i){case 113:a=2;break;case 116:a=1;break;case Up:if(10===o){a=2;break}if(2===o){a=1;break}}return{width:t[4],height:t[3],mipmapCount:r,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:131072==(131072&t[20]),isCube:512==(512&t[28]),isCompressed:i===Fp||i===Np||i===Lp,dxgiFormat:o,textureType:a}},e._ToHalfFloat=function(t){e._FloatView||(e._FloatView=new Float32Array(1),e._Int32View=new Int32Array(e._FloatView.buffer)),e._FloatView[0]=t;var n=e._Int32View[0],r=n>>16&32768,i=n>>12&2047,o=n>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&n):o<113?r|=((i|=2048)>>114-o)+(i>>113-o&1):(r|=o-112<<10|i>>1,r+=1&i)},e._FromHalfFloat=function(e){var t=(32768&e)>>15,n=(31744&e)>>10,r=1023&e;return 0===n?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==n?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,n-15)*(1+r/Math.pow(2,10))},e._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,n,r,i,o,a){for(var s=new Float32Array(i),l=new Uint16Array(o,r),c=0,u=0;u>8)},e._GetRGBArrayBuffer=function(e,t,n,r,i,o,a,s){for(var l=new Uint8Array(r),c=new Uint8Array(i,n),u=0,d=0;d>8&255,w>>16&255,w>>24&255)))}var S=e._ExtractLongWordOrder(v[23]),T=e._ExtractLongWordOrder(v[24]),P=e._ExtractLongWordOrder(v[25]),O=e._ExtractLongWordOrder(v[26]);E&&(_=t._getRGBABufferInternalSizedFormat(i.textureType)),m=1,131072&v[2]&&!1!==o&&(m=Math.max(1,v[7]));for(var R=l||0;R0?i.sphericalPolynomial=ch.ConvertCubeMapToSphericalPolynomial({size:v[4],right:c[0],left:c[1],up:c[2],down:c[3],front:c[4],back:c[5],format:5,type:1,gammaSpace:!1}):i.sphericalPolynomial=void 0}else jo.a.Error("Compressed textures are not supported on this platform.");else jo.a.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else jo.a.Error("Invalid magic number in DDS header")},e.StoreLODInAlphaChannel=!1,e}();Va.a.prototype.createPrefilteredCubeTexture=function(e,t,n,r,i,o,a,s,l){var c=this;void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=!0);return this.createCubeTexture(e,t,null,!1,(function(e){if(e){var o=e.texture;if(l?e.info.sphericalPolynomial&&(o._sphericalPolynomial=e.info.sphericalPolynomial):o._sphericalPolynomial=new sh,o._source=Kl.b.CubePrefiltered,c.getCaps().textureLOD)i&&i(o);else{var a=c._gl,s=e.width;if(s){for(var u=[],d=0;d<3;d++){var h=1-d/2,p=r,f=xo.Log2(s)*n+r,m=p+(f-p)*h,g=Math.round(Math.min(Math.max(m,0),f)),b=new Kl.a(c,Kl.b.Temp);if(b.type=o.type,b.format=o.format,b.width=Math.pow(2,Math.max(xo.Log2(s)-g,0)),b.height=b.width,b.isCube=!0,c._bindTextureDirectly(a.TEXTURE_CUBE_MAP,b,!0),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),e.isDDS){var v=e.info,A=e.data;c._unpackFlipY(v.isCompressed),Vp.UploadDDSLevels(c,b,A,v,!0,6,g)}else jo.a.Warn("DDS is the only prefiltered cube map supported so far.");c._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var _=new Ql(t);_.isCube=!0,_._texture=b,b.isReady=!0,u.push(_)}o._lodTextureHigh=u[2],o._lodTextureMid=u[1],o._lodTextureLow=u[0],i&&i(o)}}}else i&&i(null)}),o,a,s,l,n,r)};var zp=function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e){return Jo.a.EndsWith(e,".dds")},e.prototype.loadCubeData=function(e,t,n,r,i){var o,a=t.getEngine(),s=!1;if(Array.isArray(e))for(var l=0;l1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Vp.UploadDDSLevels(a,t,c,o,s,6,-1,l),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t)}else{var u=e;o=Vp.GetDDSInfo(u),t.width=o.width,t.height=o.height,n&&(o.sphericalPolynomial=new sh),s=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Vp.UploadDDSLevels(a,t,u,o,s,6),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t,!1)}a._setCubeMapTextureParams(s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r({isDDS:!0,width:t.width,info:o,data:e,texture:t})},e.prototype.loadData=function(e,t,n){var r=Vp.GetDDSInfo(e),i=(r.isRGB||r.isLuminance||r.mipmapCount>1)&&t.generateMipMaps&&r.width>>r.mipmapCount-1==1;n(r.width,r.height,i,r.isFourCC,(function(){Vp.UploadDDSLevels(t.getEngine(),t,e,r,i,1)}))},e}();ss.a._TextureLoaders.push(new zp);var jp=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return Jo.a.EndsWith(e,".env")},e.prototype.loadCubeData=function(e,t,n,r,i){if(!Array.isArray(e)){var o=fh.GetEnvInfo(e);o?(t.width=o.width,t.height=o.width,fh.UploadEnvSpherical(t,o),fh.UploadEnvLevelsAsync(t,e,o).then((function(){t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}))):i&&i("Can not parse the environment file",null)}},e.prototype.loadData=function(e,t,n){throw".env not supported in 2d."},e}();ss.a._TextureLoaders.push(new jp);var Gp=function(){function e(t,n,r,i){if(this.data=t,this.isInvalid=!1,!e.IsValid(t))return this.isInvalid=!0,void jo.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=67305985===a.getUint32(0,!0);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),0===this.glType?(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0!==this.pixelHeight&&0===this.pixelDepth?0===this.numberOfArrayElements?this.numberOfFaces===n?this.loadType=e.COMPRESSED_2D:jo.a.Error("number of faces expected"+n+", but found "+this.numberOfFaces):jo.a.Error("texture arrays not currently supported"):jo.a.Error("only 2D textures currently supported")):jo.a.Error("only compressed formats currently supported")}return e.prototype.uploadLevels=function(t,n){switch(this.loadType){case e.COMPRESSED_2D:this._upload2DCompressedLevels(t,n);break;case e.TEX_2D:case e.COMPRESSED_3D:case e.TEX_3D:}},e.prototype._upload2DCompressedLevels=function(t,n){for(var r=e.HEADER_LEN+this.bytesOfKeyValueData,i=this.pixelWidth,o=this.pixelHeight,a=n?this.numberOfMipmapLevels:1,s=0;s=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e.HEADER_LEN=64,e.COMPRESSED_2D=0,e.COMPRESSED_3D=1,e.TEX_2D=2,e.TEX_3D=3,e}(),Hp=function(){function e(t){var n=this;e._ModulePromise||(e._ModulePromise=new Promise((function(r){LIBKTX().then((function(i){i.GL.makeContextCurrent(i.GL.registerContext(t._gl,{majorVersion:t._webGLVersion})),e._TranscodeFormat=n._determineTranscodeFormat(i.TranscodeTarget,t.getCaps()),r({module:i})}))})))}return e.prototype.uploadAsync=function(t,n){return e._ModulePromise.then((function(r){var i=new r.module.ktxTexture(t);try{i.isBasisSupercompressed&&i.transcodeBasis(e._TranscodeFormat,0),n.width=n.baseWidth=i.baseWidth,n.height=n.baseHeight=i.baseHeight,n.generateMipMaps=!1;var o=i.glUpload();if(0!==o.error)throw new Error("Failed to upload: "+o.error);n._webGLTexture=o.texture,n.isReady=!0}finally{i.delete()}}))},e.prototype._determineTranscodeFormat=function(e,t){if(t.s3tc)return e.BC1_OR_3;if(t.etc2)return e.ETC;throw new Error("No compatible format available")},e.IsValid=function(e){if(e.byteLength>=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&50===t[5]&&48===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e}(),Qp=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return Jo.a.EndsWith(e,".ktx")||Jo.a.EndsWith(e,".ktx2")},e.prototype.loadCubeData=function(e,t,n,r,i){if(!Array.isArray(e)){t._invertVScale=!t.invertY;var o=t.getEngine(),a=new Gp(e,6),s=a.numberOfMipmapLevels>1&&t.generateMipMaps;o._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,o._setCubeMapTextureParams(s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}},e.prototype.loadData=function(e,t,n){if(Gp.IsValid(e)){t._invertVScale=!t.invertY;var r=new Gp(e,1);n(r.pixelWidth,r.pixelHeight,t.generateMipMaps,!0,(function(){r.uploadLevels(t,t.generateMipMaps)}),r.isInvalid)}else if(Hp.IsValid(e)){new Hp(t.getEngine()).uploadAsync(e,t).then((function(){n(t.width,t.height,!1,!0,(function(){}),!1)}),(function(e){jo.a.Warn("Failed to load KTX2 texture data: "+e.message),n(0,0,!1,!1,(function(){}),!0)}))}else n(0,0,!1,!1,(function(){}),!0)},e}();ss.a._TextureLoaders.unshift(new Qp);var Wp=function(e){function t(t,n,r){var i=e.call(this,t,So.Zero(),n)||this;return i._xrSessionManager=r,i._firstFrame=!1,i._referenceQuaternion=Po.Identity(),i._referencedPosition=new So,i._xrInvPositionCache=new So,i._xrInvQuaternionCache=Po.Identity(),i.compensateOnFirstFrame=!0,i.minZ=.1,i.rotationQuaternion=new Po,i.cameraRigMode=Ts.RIG_MODE_CUSTOM,i.updateUpVectorFromRotation=!0,i._updateNumberOfRigCameras(1),i._xrSessionManager.onXRSessionInit.add((function(){i._referencedPosition.copyFromFloats(0,0,0),i._referenceQuaternion.copyFromFloats(0,0,0,1),i._firstFrame=i.compensateOnFirstFrame})),i._xrSessionManager.onXRFrameObservable.add((function(e){i._firstFrame&&i._updateFromXRSession(),i._updateReferenceSpace(),i._updateFromXRSession()}),void 0,!0),i}return Object(No.d)(t,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:!0,configurable:!0}),t.prototype._updateForDualEyeDebugging=function(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new Es(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new Es(.5,0,.5,1),this.rigCameras[1].outputRenderTarget=null},t.prototype.setTransformationFromNonVRCamera=function(e,t){(void 0===e&&(e=this.getScene().activeCamera),void 0===t&&(t=!0),e&&e!==this)&&(e.computeWorldMatrix().decompose(void 0,this.rotationQuaternion,this.position),this.position.y=0,Po.FromEulerAnglesToRef(0,this.rotationQuaternion.toEulerAngles().y,0,this.rotationQuaternion),this._firstFrame=!0,t&&this._xrSessionManager.resetReferenceSpace())},t.prototype.getClassName=function(){return"WebXRCamera"},t.prototype._updateFromXRSession=function(){var e=this,t=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);t&&(t.transform&&(this._referencedPosition.copyFrom(t.transform.position),this._referenceQuaternion.copyFrom(t.transform.orientation),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!==t.views.length&&this._updateNumberOfRigCameras(t.views.length),t.views.forEach((function(t,n){var r=e.rigCameras[n];if(r.isLeftCamera||r.isRightCamera||("right"===t.eye?r._isRightCamera=!0:"left"===t.eye&&(r._isLeftCamera=!0)),t.transform.position?(r.position.copyFrom(t.transform.position),r.rotationQuaternion.copyFrom(t.transform.orientation),e._scene.useRightHandedSystem||(r.position.z*=-1,r.rotationQuaternion.z*=-1,r.rotationQuaternion.w*=-1)):(Oo.FromFloat32ArrayToRefScaled(t.transform.matrix,0,1,r._computedViewMatrix),e._scene.useRightHandedSystem||r._computedViewMatrix.toggleModelMatrixHandInPlace()),Oo.FromFloat32ArrayToRefScaled(t.projectionMatrix,0,1,r._projectionMatrix),e._scene.useRightHandedSystem||r._projectionMatrix.toggleProjectionMatrixHandInPlace(),e._xrSessionManager.session.renderState.baseLayer){var i=e._xrSessionManager.session.renderState.baseLayer.getViewport(t),o=e._xrSessionManager.session.renderState.baseLayer.framebufferWidth,a=e._xrSessionManager.session.renderState.baseLayer.framebufferHeight;r.viewport.width=i.width/o,r.viewport.height=i.height/a,r.viewport.x=i.x/o,r.viewport.y=i.y/a}r.outputRenderTarget=e._xrSessionManager.getRenderTargetTextureForEye(t.eye)})))},t.prototype._updateNumberOfRigCameras=function(e){for(void 0===e&&(e=1);this.rigCameras.lengthe;){var n=this.rigCameras.pop();n&&n.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,t,n){if(void 0===n&&(n=!1),this._xrSessionManager.referenceSpace&&this._xrSessionManager.currentFrame){this._xrInvPositionCache.copyFrom(e),t?this._xrInvQuaternionCache.copyFrom(t):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),n&&(this._xrInvPositionCache.y=0);var r=new XRRigidTransform(Object(No.a)({},this._xrInvPositionCache),Object(No.a)({},this._xrInvQuaternionCache)),i=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(r),o=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(i);if(o){var a=new So;a.copyFrom(o.transform.position),this._scene.useRightHandedSystem||(a.z*=-1),this.position.subtractToRef(a,a),this._scene.useRightHandedSystem||(a.z*=-1),a.negateInPlace();var s=new XRRigidTransform(Object(No.a)({},a));this._xrSessionManager.referenceSpace=i.getOffsetReferenceSpace(s)}}},t}(Ec),Kp=function(){function e(){}return e.ANCHOR_SYSTEM="xr-anchor-system",e.BACKGROUND_REMOVER="xr-background-remover",e.HIT_TEST="xr-hit-test",e.PHYSICS_CONTROLLERS="xr-physics-controller",e.PLANE_DETECTION="xr-plane-detection",e.POINTER_SELECTION="xr-controller-pointer-selection",e.TELEPORTATION="xr-controller-teleportation",e}(),Xp=function(){function e(e){var t=this;this._xrSessionManager=e,this._features={},this._xrSessionManager.onXRSessionInit.add((function(){t.getEnabledFeatures().forEach((function(e){var n=t._features[e];!n.enabled||n.featureImplementation.attached||n.featureImplementation.disableAutoAttach||t.attachFeature(e)}))})),this._xrSessionManager.onXRSessionEnded.add((function(){t.getEnabledFeatures().forEach((function(e){var n=t._features[e];n.enabled&&n.featureImplementation.attached&&t.detachFeature(e)}))}))}return e.AddWebXRFeature=function(e,t,n,r){void 0===n&&(n=1),void 0===r&&(r=!1),this._AvailableFeatures[e]=this._AvailableFeatures[e]||{latest:n},n>this._AvailableFeatures[e].latest&&(this._AvailableFeatures[e].latest=n),r&&(this._AvailableFeatures[e].stable=n),this._AvailableFeatures[e][n]=t},e.ConstructFeature=function(e,t,n,r){void 0===t&&(t=1);var i=this._AvailableFeatures[e][t];if(!i)throw new Error("feature not found");return i(n,r)},e.GetAvailableFeatures=function(){return Object.keys(this._AvailableFeatures)},e.GetAvailableVersions=function(e){return Object.keys(this._AvailableFeatures[e])},e.GetLatestVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].latest||-1},e.GetStableVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].stable||-1},e.prototype.attachFeature=function(e){var t=this._features[e];t&&t.enabled&&!t.featureImplementation.attached&&t.featureImplementation.attach()},e.prototype.detachFeature=function(e){var t=this._features[e];t&&t.featureImplementation.attached&&t.featureImplementation.detach()},e.prototype.disableFeature=function(e){var t="string"==typeof e?e:e.Name,n=this._features[t];return!(!n||!n.enabled)&&(n.enabled=!1,this.detachFeature(t),n.featureImplementation.dispose(),!0)},e.prototype.dispose=function(){var e=this;this.getEnabledFeatures().forEach((function(t){e.disableFeature(t),e._features[t].featureImplementation.dispose()}))},e.prototype.enableFeature=function(t,n,r,i){void 0===n&&(n="latest"),void 0===r&&(r={}),void 0===i&&(i=!0);var o="string"==typeof t?t:t.Name,a=0;if("string"==typeof n){if(!n)throw new Error("Error in provided version - "+o+" ("+n+")");if(-1===(a="stable"===n?e.GetStableVersionOfFeature(o):"latest"===n?e.GetLatestVersionOfFeature(o):+n)||isNaN(a))throw new Error("feature not found - "+o+" ("+n+")")}else a=n;var s=this._features[o],l=e.ConstructFeature(o,a,this._xrSessionManager,r);if(!l)throw new Error("feature not found - "+o);return s&&this.disableFeature(o),this._features[o]={featureImplementation:l(),enabled:!0,version:a},i?this._xrSessionManager.session&&!s.featureImplementation.attached&&this.attachFeature(o):this._features[o].featureImplementation.disableAutoAttach=!0,this._features[o].featureImplementation},e.prototype.getEnabledFeature=function(e){return this._features[e]&&this._features[e].featureImplementation},e.prototype.getEnabledFeatures=function(){return Object.keys(this._features)},e._AvailableFeatures={},e}(),Yp=function(){function e(e){var t=this;this.scene=e,this._nonVRCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this.onInitialXRPoseSetObservable=new yo.a,this.onStateChangedObservable=new yo.a,this.state=Ad.NOT_IN_XR,this.sessionManager=new wd(e),this.camera=new Wp("",e,this.sessionManager),this.featuresManager=new Xp(this.sessionManager),e.onDisposeObservable.add((function(){t.exitXRAsync()}))}return e.CreateAsync=function(t){var n=new e(t);return n.sessionManager.initializeAsync().then((function(){return n._supported=!0,n})).catch((function(e){throw n._setState(Ad.NOT_IN_XR),n.dispose(),e}))},e.prototype.dispose=function(){this.camera.dispose(),this.onStateChangedObservable.clear(),this.onInitialXRPoseSetObservable.clear(),this.sessionManager.dispose(),this._nonVRCamera&&(this.scene.activeCamera=this._nonVRCamera)},e.prototype.enterXRAsync=function(e,t,n){var r=this;if(void 0===n&&(n=this.sessionManager.getWebXRRenderTarget()),!this._supported)throw"WebXR not supported in this browser or environment";this._setState(Ad.ENTERING_XR);var i={optionalFeatures:"viewer"!==t&&"local"!==t?[t]:[]};return"immersive-ar"===e&&"local"!==t&&jo.a.Warn("We recommend using 'local' reference space type when using 'immersive-ar' session mode"),this.sessionManager.isSessionSupportedAsync(e).then((function(t){if(!t)throw new Error('Session mode "'+e+'" not supported in browser');return r.sessionManager.initializeSessionAsync(e,i)})).then((function(){return r.sessionManager.setReferenceSpaceTypeAsync(t)})).then((function(){return n.initializeXRLayerAsync(r.sessionManager.session)})).then((function(){return r.sessionManager.updateRenderStateAsync({depthFar:r.camera.maxZ,depthNear:r.camera.minZ,baseLayer:n.xrLayer})})).then((function(){return r.sessionManager.runXRRenderLoop(),r._originalSceneAutoClear=r.scene.autoClear,r._nonVRCamera=r.scene.activeCamera,r.scene.autoClear=!1,r.scene.activeCamera=r.camera,"immersive-ar"!==e?r._nonXRToXRCamera():r.camera.compensateOnFirstFrame=!1,r.sessionManager.onXRSessionEnded.addOnce((function(){r.camera.rigCameras.forEach((function(e){e.outputRenderTarget=null})),r.scene.autoClear=r._originalSceneAutoClear,r.scene.activeCamera=r._nonVRCamera,"immersive-ar"!==e&&r.camera.compensateOnFirstFrame&&(r._nonVRCamera.setPosition?r._nonVRCamera.setPosition(r.camera.position):r._nonVRCamera.position.copyFrom(r.camera.position)),r._setState(Ad.NOT_IN_XR)})),r.sessionManager.onXRFrameObservable.addOnce((function(){r._setState(Ad.IN_XR)})),r.sessionManager})).catch((function(e){throw console.log(e),console.log(e.message),r._setState(Ad.NOT_IN_XR),e}))},e.prototype.exitXRAsync=function(){return this._setState(Ad.EXITING_XR),this.sessionManager.exitXRAsync()},e.prototype._nonXRToXRCamera=function(){this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),this.onInitialXRPoseSetObservable.notifyObservers(this.camera)},e.prototype._setState=function(e){this.state!==e&&(this.state=e,this.onStateChangedObservable.notifyObservers(this.state))},e}(),qp=function(){function e(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=[]),this.id=e,this.type=t,this._buttonIndex=n,this._axesIndices=r,this._axes={x:0,y:0},this._changes={},this._currentValue=0,this._hasChanges=!1,this._pressed=!1,this._touched=!1,this.onAxisValueChangedObservable=new yo.a,this.onButtonStateChangedObservable=new yo.a}return Object.defineProperty(e.prototype,"axes",{get:function(){return this._axes},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"changes",{get:function(){return this._changes},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasChanges",{get:function(){return this._hasChanges},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pressed",{get:function(){return this._pressed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"touched",{get:function(){return this._touched},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._currentValue},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.onAxisValueChangedObservable.clear(),this.onButtonStateChangedObservable.clear()},e.prototype.isAxes=function(){return 0!==this._axesIndices.length},e.prototype.isButton=function(){return-1!==this._buttonIndex},e.prototype.update=function(e){var t=!1,n=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){var r=e.buttons[this._buttonIndex];if(!r)return;this._currentValue!==r.value&&(this.changes.value={current:r.value,previous:this._currentValue},t=!0,this._currentValue=r.value),this._touched!==r.touched&&(this.changes.touched={current:r.touched,previous:this._touched},t=!0,this._touched=r.touched),this._pressed!==r.pressed&&(this.changes.pressed={current:r.pressed,previous:this._pressed},t=!0,this._pressed=r.pressed)}this.isAxes()&&(this._axes.x!==e.axes[this._axesIndices[0]]&&(this.changes.axes={current:{x:e.axes[this._axesIndices[0]],y:this._axes.y},previous:{x:this._axes.x,y:this._axes.y}},this._axes.x=e.axes[this._axesIndices[0]],n=!0),this._axes.y!==e.axes[this._axesIndices[1]]&&(this.changes.axes?this.changes.axes.current.y=e.axes[this._axesIndices[1]]:this.changes.axes={current:{x:this._axes.x,y:e.axes[this._axesIndices[1]]},previous:{x:this._axes.x,y:this._axes.y}},this._axes.y=e.axes[this._axesIndices[1]],n=!0)),t&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),n&&(this._hasChanges=!0,this.onAxisValueChangedObservable.notifyObservers(this._axes))},e.BUTTON_TYPE="button",e.SQUEEZE_TYPE="squeeze",e.THUMBSTICK_TYPE="thumbstick",e.TOUCHPAD_TYPE="touchpad",e.TRIGGER_TYPE="trigger",e}(),Zp=function(){function e(e,t,n,r,i){var o=this;void 0===i&&(i=!1),this.scene=e,this.layout=t,this.gamepadObject=n,this.handness=r,this._initComponent=function(e){if(e){var t=o.layout.components[e],n=t.type,r=t.gamepadIndices.button,i=[];void 0!==t.gamepadIndices.xAxis&&void 0!==t.gamepadIndices.yAxis&&i.push(t.gamepadIndices.xAxis,t.gamepadIndices.yAxis),o.components[e]=new qp(e,n,r,i)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new yo.a,t.components&&Object.keys(t.components).forEach(this._initComponent)}return e.prototype.dispose=function(){var e=this;this.getComponentIds().forEach((function(t){return e.getComponent(t).dispose()})),this.rootMesh&&this.rootMesh.dispose()},e.prototype.getAllComponentsOfType=function(e){var t=this;return this.getComponentIds().map((function(e){return t.components[e]})).filter((function(t){return t.type===e}))},e.prototype.getComponent=function(e){return this.components[e]},e.prototype.getComponentIds=function(){return Object.keys(this.components)},e.prototype.getComponentOfType=function(e){return this.getAllComponentsOfType(e)[0]||null},e.prototype.getMainComponent=function(){return this.getComponent(this.layout.selectComponentId)},e.prototype.loadModel=function(){return Object(No.b)(this,void 0,void 0,(function(){var e,t,n=this;return Object(No.e)(this,(function(r){return e=!this._getModelLoadingConstraints(),t=this._getGenericFilenameAndPath(),e?jo.a.Warn("Falling back to generic models"):t=this._getFilenameAndPath(),[2,new Promise((function(r,i){Ph.ImportMesh("",t.path,t.filename,n.scene,(function(t){e?n._getGenericParentMesh(t):n._setRootMesh(t),n._processLoadedModel(t),n._modelReady=!0,n.onModelLoadedObservable.notifyObservers(n),r(!0)}),null,(function(e,r){jo.a.Log(r),jo.a.Warn("Failed to retrieve controller model of type "+n.profileId+" from the remote server: "+t.path+t.filename),i(r)}))}))]}))}))},e.prototype.updateFromXRFrame=function(e){var t=this;this.getComponentIds().forEach((function(e){return t.getComponent(e).update(t.gamepadObject)})),this.updateModel(e)},e.prototype._getChildByName=function(e,t){return e.getChildren((function(e){return e.name===t}),!1)[0]},e.prototype._getImmediateChildByName=function(e,t){return e.getChildren((function(e){return e.name==t}),!0)[0]},e.prototype._lerpTransform=function(e,t,n){if(e.minMesh&&e.maxMesh&&e.minMesh.rotationQuaternion&&e.maxMesh.rotationQuaternion&&e.valueMesh.rotationQuaternion){var r=n?.5*t+.5:t;Po.SlerpToRef(e.minMesh.rotationQuaternion,e.maxMesh.rotationQuaternion,r,e.valueMesh.rotationQuaternion),So.LerpToRef(e.minMesh.position,e.maxMesh.position,r,e.valueMesh.position)}},e.prototype.updateModel=function(e){this._modelReady&&this._updateModel(e)},e.prototype._getGenericFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},e.prototype._getGenericParentMesh=function(e){var t=this;this.rootMesh=new Pl(this.profileId+" "+this.handness,this.scene),e.forEach((function(e){e.parent||(e.isPickable=!1,e.setParent(t.rootMesh))})),this.rootMesh.rotationQuaternion=Po.FromEulerAngles(0,Math.PI,0)},e}(),Jp=function(e){function t(n,r,i){var o=e.call(this,n,$p[i],r,i)||this;return o.profileId=t.ProfileId,o}return Object(No.d)(t,e),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 t=this;this.rootMesh=new Pl(this.profileId+" "+this.handness,this.scene),e.forEach((function(e){e.isPickable=!1,e.parent||e.setParent(t.rootMesh)})),this.rootMesh.rotationQuaternion=Po.FromEulerAngles(0,Math.PI,0)},t.prototype._updateModel=function(){},t.ProfileId="generic-trigger",t}(Zp),$p={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"}},ef=function(e){function t(t,n,r,i){var o=e.call(this,t,r.layouts[n.handedness||"none"],n.gamepad,n.handedness)||this;return o._repositoryUrl=i,o._buttonMeshMapping={},o._touchDots={},o.profileId=r.profileId,o}return Object(No.d)(t,e),t.prototype.dispose=function(){var t=this;e.prototype.dispose.call(this),Object.keys(this._touchDots).forEach((function(e){t._touchDots[e].dispose()}))},t.prototype._getFilenameAndPath=function(){return{filename:this.layout.assetPath,path:this._repositoryUrl+"/profiles/"+this.profileId+"/"}},t.prototype._getModelLoadingConstraints=function(){var e=Ph.IsPluginForExtensionAvailable(".glb");return e||jo.a.Warn("glTF / glb loaded was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var t=this;this.getComponentIds().forEach((function(e){var n=t.layout.components[e];t._buttonMeshMapping[e]={mainMesh:t._getChildByName(t.rootMesh,n.rootNodeName),states:{}},Object.keys(n.visualResponses).forEach((function(r){var i=n.visualResponses[r];if("transform"===i.valueNodeProperty)t._buttonMeshMapping[e].states[r]={valueMesh:t._getChildByName(t.rootMesh,i.valueNodeName),minMesh:t._getChildByName(t.rootMesh,i.minNodeName),maxMesh:t._getChildByName(t.rootMesh,i.maxNodeName)};else{var o=n.type===qp.TOUCHPAD_TYPE&&n.touchPointNodeName?n.touchPointNodeName:i.valueNodeName;if(t._buttonMeshMapping[e].states[r]={valueMesh:t._getChildByName(t.rootMesh,o)},n.type===qp.TOUCHPAD_TYPE&&!t._touchDots[r]){var a=zd.CreateSphere(r+"dot",{diameter:.0015,segments:8},t.scene);a.material=new hd(r+"mat",t.scene),a.material.diffuseColor=Io.Red(),a.parent=t._buttonMeshMapping[e].states[r].valueMesh,a.isVisible=!1,t._touchDots[r]=a}}}))}))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new Pl(this.profileId+"-"+this.handness,this.scene),this.rootMesh.isPickable=!1;for(var n=0;nr/10&&(a.isVisible=!0),(s+=t._scene.getEngine().getDeltaTime())>=r)t._scene.simulatePointerDown(n.pick,{pointerId:n.id}),l=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(n.pick,{pointerId:n.id}),a.isVisible=!1;else{var e=1-s/r;a.scaling.set(e,e,e)}else l=!1,s=0;t._scene.simulatePointerMove(n.pick,{pointerId:n.id}),o=n.pick}})),void 0!==this._options.renderingGroupId&&(a.renderingGroupId=this._options.renderingGroupId),e.onDisposeObservable.addOnce((function(){n.pick&&!t._options.disablePointerUpOnTouchOut&&l&&t._scene.simulatePointerUp(n.pick,{pointerId:n.id}),a.dispose()}))},t.prototype._attachScreenRayMode=function(e){var t=this,n=this._controllers[e.uniqueId],r=!1;n.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){!n.pick||t._options.disablePointerUpOnTouchOut&&r||(r?t._scene.simulatePointerMove(n.pick,{pointerId:n.id}):(t._scene.simulatePointerDown(n.pick,{pointerId:n.id}),r=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(n.pick,{pointerId:n.id})))})),e.onDisposeObservable.addOnce((function(){n.pick&&r&&!t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(n.pick,{pointerId:n.id})}))},t.prototype._attachTrackedPointerRayMode=function(e){var t=this;e.onMotionControllerInitObservable.add((function(n){if(t._options.forceGazeMode)return t._attachGazeMode(e);var r=t._controllers[e.uniqueId];t._options.overrideButtonId&&(r.selectionComponent=n.getComponent(t._options.overrideButtonId)),r.selectionComponent||(r.selectionComponent=n.getMainComponent()),r.onFrameObserver=t._xrSessionManager.onXRFrameObservable.add((function(){r.selectionComponent&&r.selectionComponent.pressed?(r.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,r.laserPointer.material.emissiveColor=t.laserPointerPickedColor):(r.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,r.laserPointer.material.emissiveColor=t.lasterPointerDefaultColor),r.laserPointer.isVisible=t.displayLaserPointer,r.laserPointer.material.disableLighting=t.disablePointerLighting,r.selectionMesh.material.disableLighting=t.disableSelectionMeshLighting,r.pick&&t._scene.simulatePointerMove(r.pick,{pointerId:r.id})})),r.onButtonChangedObserver=r.selectionComponent.onButtonStateChangedObservable.add((function(e){if(e.changes.pressed){var n=e.changes.pressed.current;r.pick&&(n?t._scene.simulatePointerDown(r.pick,{pointerId:r.id}):t._scene.simulatePointerUp(r.pick,{pointerId:r.id}))}}))}))},t.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(So.Dot(e,t.direction))r},t.prototype._updatePointerDistance=function(e,t){void 0===t&&(t=100),e.scaling.y=t,e.position.z=t/2+.05},t._idCounter=0,t.Name=Kp.POINTER_SELECTION,t.Version=1,t}(af);Xp.AddWebXRFeature(sf.Name,(function(e,t){return function(){return new sf(e,t)}}),sf.Version,!0);var lf=function(){function e(e,t,n){this.element=e,this.sessionMode=t,this.referenceSpaceType=n}return e.prototype.update=function(e){},e}(),cf=function(){function e(e,t){var n=this;if(this.scene=e,this.options=t,this._activeButton=null,this._buttons=[],this.activeButtonChangedObservable=new yo.a,this._overlay=document.createElement("div"),this._overlay.style.cssText="z-index:11;position: absolute; right: 20px;bottom: 50px;",t.customButtons)this._buttons=t.customButtons;else{var r=t.sessionMode||"immersive-vr",i=t.referenceSpaceType||"local-floor",o=".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("+(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) }";o+='.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';var a=document.createElement("style");a.appendChild(document.createTextNode(o)),document.getElementsByTagName("head")[0].appendChild(a);var s=document.createElement("button");s.className="babylonVRicon",s.title=r+" - "+i,this._buttons.push(new lf(s,r,i)),this._buttons[this._buttons.length-1].update=function(e){this.element.style.display=null===e||e===this?"":"none",s.className="babylonVRicon"+(e===this?" vrdisplaypresenting":"")},this._updateButtons(null)}var l=e.getEngine().getInputElement();l&&l.parentNode&&(l.parentNode.appendChild(this._overlay),e.onDisposeObservable.addOnce((function(){n.dispose()})))}return e.CreateAsync=function(t,n,r){var i=this,o=new e(t,r),a=o._buttons.map((function(e){return n.sessionManager.isSessionSupportedAsync(e.sessionMode)}));return n.onStateChangedObservable.add((function(e){e==Ad.NOT_IN_XR&&o._updateButtons(null)})),Promise.all(a).then((function(e){return e.forEach((function(e,t){e&&(o._overlay.appendChild(o._buttons[t].element),o._buttons[t].element.onclick=function(){return Object(No.b)(i,void 0,void 0,(function(){var e,i;return Object(No.e)(this,(function(a){switch(a.label){case 0:return n.state!=Ad.IN_XR?[3,2]:[4,n.exitXRAsync()];case 1:return a.sent(),o._updateButtons(null),[3,6];case 2:if(n.state!=Ad.NOT_IN_XR)return[3,6];if(!r.renderTarget)return[3,6];a.label=3;case 3:return a.trys.push([3,5,,6]),[4,n.enterXRAsync(o._buttons[t].sessionMode,o._buttons[t].referenceSpaceType,r.renderTarget)];case 4:return a.sent(),o._updateButtons(o._buttons[t]),[3,6];case 5:return a.sent(),o._updateButtons(null),e=o._buttons[t].element,i=e.title,e.title="Error entering XR session : "+i,e.classList.add("xr-error"),[3,6];case 6:return[2]}}))}))})})),o}))},e.prototype.dispose=function(){var e=this.scene.getEngine().getInputElement();e&&e.parentNode&&e.parentNode.contains(this._overlay)&&e.parentNode.removeChild(this._overlay),this.activeButtonChangedObservable.clear()},e.prototype._updateButtons=function(e){var t=this;this._activeButton=e,this._buttons.forEach((function(e){e.update(t._activeButton)})),this.activeButtonChangedObservable.notifyObservers(this._activeButton)},e}(),uf=function(e){function t(t,n){var r=e.call(this,t)||this;return r._options=n,r._controllers={},r._snappedToPoint=!1,r._tmpRay=new Vl(new So,new So),r._tmpVector=new So,r.backwardsMovementEnabled=!0,r.backwardsTeleportationDistance=.7,r.parabolicCheckRadius=5,r.parabolicRayEnabled=!0,r.rotationAngle=Math.PI/8,r.rotationEnabled=!0,r._attachController=function(e){if(!r._controllers[e.uniqueId]){r._controllers[e.uniqueId]={xrController:e,teleportationState:{forward:!1,backwards:!1,rotating:!1,currentRotation:0,baseRotation:0}};var t=r._controllers[e.uniqueId];e.onMotionControllerInitObservable.addOnce((function(){if(e.motionController){var n=e.motionController.getComponentOfType(qp.THUMBSTICK_TYPE)||e.motionController.getComponentOfType(qp.TOUCHPAD_TYPE);if(!n||r._options.useMainComponentOnly){var i=e.motionController.getMainComponent();if(!i)return;t.onButtonChangedObserver=i.onButtonStateChangedObservable.add((function(){if(i.changes.pressed)if(i.changes.pressed.current){t.teleportationState.forward=!0,r._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0;var n=r._options.timeToTeleport||3e3,o=0,a=r._xrSessionManager.onXRFrameObservable.add((function(){i.pressed?((o+=r._xrSessionManager.scene.getEngine().getDeltaTime())>=n&&r._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&r._teleportForward(e.uniqueId),o>=n&&r._xrSessionManager.onXRFrameObservable.remove(a)):r._xrSessionManager.onXRFrameObservable.remove(a)}))}else t.teleportationState.forward=!1,r._currentTeleportationControllerId=""}))}else t.onButtonChangedObserver=n.onButtonStateChangedObservable.add((function(){r._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&!n.touched&&r._teleportForward(e.uniqueId)})),t.onAxisChangedObserver=n.onAxisValueChangedObservable.add((function(e){if(e.y<=.7&&t.teleportationState.backwards&&(t.teleportationState.backwards=!1),e.y>.7&&!t.teleportationState.forward&&r.backwardsMovementEnabled&&!r.snapPointsOnly&&!t.teleportationState.backwards){t.teleportationState.backwards=!0,r._tmpVector.set(0,0,r.backwardsTeleportationDistance),r._tmpVector.rotateByQuaternionToRef(r._options.xrInput.xrCamera.rotationQuaternion,r._tmpVector),r._tmpVector.addInPlace(r._options.xrInput.xrCamera.position),r._options.xrInput.xrCamera.position.subtractToRef(r._tmpVector,r._tmpVector),r._tmpRay.origin.copyFrom(r._tmpVector),r._tmpRay.direction.set(0,-1,0);var n=r._xrSessionManager.scene.pickWithRay(r._tmpRay,(function(e){return-1!==r._floorMeshes.indexOf(e)}));n&&n.pickedPoint&&r._options.xrInput.xrCamera.position.addInPlace(n.pickedPoint)}if(e.y<-.7&&!r._currentTeleportationControllerId&&!t.teleportationState.rotating&&(t.teleportationState.forward=!0,r._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),e.x){if(t.teleportationState.forward)r._currentTeleportationControllerId===t.xrController.uniqueId&&(r.rotationEnabled?setTimeout((function(){t.teleportationState.currentRotation=Math.atan2(e.x,-e.y)})):t.teleportationState.currentRotation=0);else if(!t.teleportationState.rotating&&Math.abs(e.x)>.7){t.teleportationState.rotating=!0;var i=r.rotationAngle*(e.x>0?1:-1);r._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(Po.FromEulerAngles(0,i,0))}}else t.teleportationState.rotating=!1}))}}))}},r._options.teleportationTargetMesh||r._createDefaultTargetMesh(),r._floorMeshes=r._options.floorMeshes||[],r._snapToPositions=r._options.snapPositions||[],r._setTargetMeshVisibility(!1),r}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"snapPointsOnly",{get:function(){return!!this._options.snapPointsOnly},set:function(e){this._options.snapPointsOnly=e},enumerable:!0,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 t=this;return!!e.prototype.attach.call(this)&&(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,(function(e){t._detachController(e.uniqueId)})),!0)},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach((function(e){t._detachController(e)})),this._setTargetMeshVisibility(!1),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.dispose(!1,!0)},t.prototype.removeFloorMesh=function(e){var t=this._floorMeshes.indexOf(e);-1!==t&&this._floorMeshes.splice(t,1)},t.prototype.removeFloorMeshByName=function(e){var t=this._xrSessionManager.scene.getMeshByName(e);t&&this.removeFloorMesh(t)},t.prototype.removeSnapPoint=function(e){var t=this._snapToPositions.indexOf(e);if(-1===t)for(var n=0;n=l.video.HAVE_CURRENT_DATA;return!s.poster||s.autoPlay&&c?c&&l._createInternalTexture():(l._texture=l._engine.createTexture(s.poster,!1,!l.invertY,r),l._displayingPosterTexture=!0),l}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new yo.a),this._onUserActionRequestedObservable},enumerable:!0,configurable:!0}),t.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:"object"==typeof e?e.toString():e},t.prototype._getVideo=function(e){if(e instanceof HTMLVideoElement)return Ja.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement("video");return"string"==typeof e?(Ja.SetCorsBehavior(e,t),t.src=e):(Ja.SetCorsBehavior(e[0],t),e.forEach((function(e){var n=document.createElement("source");n.src=e,t.appendChild(n)}))),t},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(){e.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 r=document.createElement("video");return r.setAttribute("autoplay",""),r.setAttribute("muted","true"),r.setAttribute("playsinline",""),r.muted=!0,void 0!==r.mozSrcObject?r.mozSrcObject=n:"object"==typeof r.srcObject?r.srcObject=n:(window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,r.src=window.URL&&window.URL.createObjectURL(n)),new Promise((function(n){var i=function(){n(new t("video",r,e,!0,!0)),r.removeEventListener("playing",i)};r.addEventListener("playing",i),r.play()}))},t.CreateFromWebCamAsync=function(e,t,n){var r,i=this;return void 0===n&&(n=!1),t&&t.deviceId&&(r={exact:t.deviceId}),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:t,audio:n}).then((function(t){return i.CreateFromStreamAsync(e,t)})):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:r,width:{min:t&&t.minWidth||256,max:t&&t.maxWidth||640},height:{min:t&&t.minHeight||256,max:t&&t.maxHeight||480}},audio:n},(function(t){return i.CreateFromStreamAsync(e,t)}),(function(e){jo.a.Error(e.name)})),Promise.reject("No support for userMedia on this device"))},t.CreateFromWebCam=function(e,t,n,r){void 0===r&&(r=!1),this.CreateFromWebCamAsync(e,n,r).then((function(e){t&&t(e)})).catch((function(e){jo.a.Error(e.name)}))},t}(Wl),pf=function(){function e(e,t){void 0===e&&(e=So.Zero()),void 0===t&&(t=So.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}(),ff=(function(){function e(e,t,n){void 0===e&&(e=So.Zero()),void 0===t&&(t=So.Up()),void 0===n&&(n=Co.Zero()),this.position=e,this.normal=t,this.uv=n}e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())}}(),function(e){function t(n,r,i,o){var a=e.call(this,n,o)||this;a._halfDome=!1,a._useDirectMapping=!1,a._videoMode=t.MODE_MONOSCOPIC,a._onBeforeCameraRenderObserver=null,o=a.getScene(),n=n||"videoDome",i.resolution=0|Math.abs(i.resolution)||32,i.clickToPlay=Boolean(i.clickToPlay),i.autoPlay=void 0===i.autoPlay||Boolean(i.autoPlay),i.loop=void 0===i.loop||Boolean(i.loop),i.size=Math.abs(i.size)||(o.activeCamera?.48*o.activeCamera.maxZ:1e3),void 0===i.useDirectMapping?a._useDirectMapping=!0:a._useDirectMapping=i.useDirectMapping,void 0===i.faceForward&&(i.faceForward=!0),a._setReady(!1);var s={loop:i.loop,autoPlay:i.autoPlay,autoUpdateTexture:!0,poster:i.poster},l=a._material=new lp(n+"_material",o),c=a._videoTexture=new hf(n+"_texture",r,o,!1,a._useDirectMapping,Wl.TRILINEAR_SAMPLINGMODE,s);if(a._mesh=Pl.CreateSphere(n+"_mesh",i.resolution,i.size,o,!1,Pl.BACKSIDE),c.anisotropicFilteringLevel=1,c.onLoadObservable.addOnce((function(){a._setReady(!0)})),l.useEquirectangularFOV=!0,l.fovMultiplier=1,l.opacityFresnel=!1,a._useDirectMapping?(c.wrapU=Wl.CLAMP_ADDRESSMODE,c.wrapV=Wl.CLAMP_ADDRESSMODE,l.diffuseTexture=c):(c.coordinatesMode=Wl.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,c.wrapV=Wl.CLAMP_ADDRESSMODE,l.reflectionTexture=c),a._mesh.material=l,a._mesh.parent=a,a._halfDomeMask=zd.CreateSphere("",{slice:.5,diameter:.99*i.size,segments:i.resolution,sideOrientation:Pl.BACKSIDE},o),a._halfDomeMask.rotate(os.X,-Math.PI/2),a._halfDomeMask.parent=a._mesh,a._halfDome=!!i.halfDomeMode,a._halfDomeMask.setEnabled(a._halfDome),i.clickToPlay&&(o.onPointerUp=function(){a._videoTexture.video.play()}),i.faceForward&&o.activeCamera){var u=o.activeCamera,d=So.Forward(),h=So.TransformNormal(d,u.getViewMatrix());h.normalize(),a.rotation.y=Math.acos(So.Dot(d,h))}return a}Object(No.d)(t,e),Object.defineProperty(t.prototype,"videoTexture",{get:function(){return this._videoTexture},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"videoMode",{get:function(){return this._videoMode},set:function(e){this._videoMode!==e&&this._changeVideoMode(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"halfDome",{get:function(){return this._halfDome},set:function(e){this._halfDome=e,this._halfDomeMask.setEnabled(e)},enumerable:!0,configurable:!0}),t.prototype._changeVideoMode=function(e){var n=this;switch(this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._videoMode=e,this._videoTexture.uScale=1,this._videoTexture.vScale=1,this._videoTexture.uOffset=0,this._videoTexture.vOffset=0,e){case t.MODE_SIDEBYSIDE:this._videoTexture.uScale=this._halfDome?.99999:.5;var r=this._halfDome?0:.5,i=this._halfDome?.5:0;this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add((function(e){n._videoTexture.uOffset=e.isRightCamera?r:i}));break;case t.MODE_TOPBOTTOM:this._videoTexture.vScale=this._halfDome?.99999:.5,this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add((function(e){n._videoTexture.vOffset=e.isRightCamera?.5:0}))}},t.prototype.dispose=function(t,n){void 0===n&&(n=!1),this._videoTexture.dispose(),this._mesh.dispose(),this._material.dispose(),this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),e.prototype.dispose.call(this,t,n)},t.MODE_MONOSCOPIC=0,t.MODE_TOPBOTTOM=1,t.MODE_SIDEBYSIDE=2}(as),function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._gpuFrameTime=new el.a,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new el.a,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}Object.defineProperty(e.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(e){var t=this;e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,e?(this._onBeginFrameObserver=this.engine.onBeginFrameObservable.add((function(){t._gpuFrameTimeToken||(t._gpuFrameTimeToken=t.engine.startTimeQuery())})),this._onEndFrameObserver=this.engine.onEndFrameObservable.add((function(){if(t._gpuFrameTimeToken){var e=t.engine.endTimeQuery(t._gpuFrameTimeToken);e>-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}}))):(this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureShaderCompilationTime",{get:function(){return this._captureShaderCompilationTime},set:function(e){var t=this;e!==this._captureShaderCompilationTime&&(this._captureShaderCompilationTime=e,e?(this._onBeforeShaderCompilationObserver=this.engine.onBeforeShaderCompilationObservable.add((function(){t._shaderCompilationTime.fetchNewFrame(),t._shaderCompilationTime.beginMonitoring()})),this._onAfterShaderCompilationObserver=this.engine.onAfterShaderCompilationObservable.add((function(){t._shaderCompilationTime.endMonitoring()}))):(this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null))},enumerable:!0,configurable:!0}),e.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}}(),function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new el.a,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new el.a,this._captureFrameTime=!1,this._frameTime=new el.a,this._captureRenderTime=!1,this._renderTime=new el.a,this._captureInterFrameTime=!1,this._interFrameTime=new el.a,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new el.a,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new el.a,this._capturePhysicsTime=!1,this._physicsTime=new el.a,this._captureAnimationsTime=!1,this._animationsTime=new el.a,this._captureCameraRenderTime=!1,this._cameraRenderTime=new el.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=e.onBeforeAnimationsObservable.add((function(){t._captureActiveMeshesEvaluationTime&&t._activeMeshesEvaluationTime.fetchNewFrame(),t._captureRenderTargetsRenderTime&&t._renderTargetsRenderTime.fetchNewFrame(),t._captureFrameTime&&(Ja.StartPerformanceCounter("Scene rendering"),t._frameTime.beginMonitoring()),t._captureInterFrameTime&&t._interFrameTime.endMonitoring(),t._captureParticlesRenderTime&&t._particlesRenderTime.fetchNewFrame(),t._captureSpritesRenderTime&&t._spritesRenderTime.fetchNewFrame(),t._captureAnimationsTime&&t._animationsTime.beginMonitoring(),t.scene.getEngine()._drawCalls.fetchNewFrame()})),this._onAfterRenderObserver=e.onAfterRenderObservable.add((function(){t._captureFrameTime&&(Ja.EndPerformanceCounter("Scene rendering"),t._frameTime.endMonitoring()),t._captureRenderTime&&t._renderTime.endMonitoring(!1),t._captureInterFrameTime&&t._interFrameTime.beginMonitoring()}))}Object.defineProperty(e.prototype,"activeMeshesEvaluationTimeCounter",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureActiveMeshesEvaluationTime",{get:function(){return this._captureActiveMeshesEvaluationTime},set:function(e){var t=this;e!==this._captureActiveMeshesEvaluationTime&&(this._captureActiveMeshesEvaluationTime=e,e?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add((function(){Ja.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){Ja.EndPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.endMonitoring()}))):(this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTargetsRenderTime",{get:function(){return this._captureRenderTargetsRenderTime},set:function(e){var t=this;e!==this._captureRenderTargetsRenderTime&&(this._captureRenderTargetsRenderTime=e,e?(this._onBeforeRenderTargetsRenderObserver=this.scene.onBeforeRenderTargetsRenderObservable.add((function(){Ja.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){Ja.EndPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureParticlesRenderTime",{get:function(){return this._captureParticlesRenderTime},set:function(e){var t=this;e!==this._captureParticlesRenderTime&&(this._captureParticlesRenderTime=e,e?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add((function(){Ja.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){Ja.EndPerformanceCounter("Particles"),t._particlesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureSpritesRenderTime",{get:function(){return this._captureSpritesRenderTime},set:function(e){var t=this;e!==this._captureSpritesRenderTime&&(this._captureSpritesRenderTime=e,this.scene.spriteManagers&&(e?(this._onBeforeSpritesRenderingObserver=this.scene.onBeforeSpritesRenderingObservable.add((function(){Ja.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){Ja.EndPerformanceCounter("Sprites"),t._spritesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"capturePhysicsTime",{get:function(){return this._capturePhysicsTime},set:function(e){var t=this;e!==this._capturePhysicsTime&&this.scene.onBeforePhysicsObservable&&(this._capturePhysicsTime=e,e?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add((function(){Ja.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){Ja.EndPerformanceCounter("Physics"),t._physicsTime.endMonitoring()}))):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureAnimationsTime",{get:function(){return this._captureAnimationsTime},set:function(e){var t=this;e!==this._captureAnimationsTime&&(this._captureAnimationsTime=e,e?this._onAfterAnimationsObserver=this.scene.onAfterAnimationsObservable.add((function(){t._animationsTime.endMonitoring()})):(this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(e){var t=this;e!==this._captureRenderTime&&(this._captureRenderTime=e,e?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add((function(){t._renderTime.beginMonitoring(),Ja.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),Ja.EndPerformanceCounter("Main render")}))):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cameraRenderTimeCounter",{get:function(){return this._cameraRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureCameraRenderTime",{get:function(){return this._captureCameraRenderTime},set:function(e){var t=this;e!==this._captureCameraRenderTime&&(this._captureCameraRenderTime=e,e?(this._onBeforeCameraRenderObserver=this.scene.onBeforeCameraRenderObservable.add((function(e){t._cameraRenderTime.beginMonitoring(),Ja.StartPerformanceCounter("Rendering camera "+e.name)})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),Ja.EndPerformanceCounter("Rendering camera "+e.name)}))):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!0,configurable:!0}),e.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}}(),"#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform sampler2D opacitySampler;\nuniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;\nvoid main(void)\n{\nvec4 finalColor=glowColor;\n\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a4&&(o.push(cs.MatricesIndicesExtraKind),o.push(cs.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers);var f=a.skeleton;f&&f.isUsingTextureForMatrices?i.push("#define BONETEXTURE"):i.push("#define BonesPerMesh "+(f?f.bones.length+1:0)),a.numBoneInfluencers>0&&p.addCPUSkinningFallback(0,a)}else i.push("#define NUM_BONE_INFLUENCERS 0");var m=a.morphTargetManager,g=0;m&&m.numInfluencers>0&&(i.push("#define MORPHTARGETS"),g=m.numInfluencers,i.push("#define NUM_MORPH_INFLUENCERS "+g),Cu.PrepareAttributesForMorphTargetsInfluencers(o,a,g)),t&&(i.push("#define INSTANCES"),Cu.PushAttributesForInstances(o)),this._addCustomEffectDefines(i);var b=i.join("\n");return this._cachedDefines!==b&&(this._cachedDefines=b,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","glowColor","morphTargetInfluences","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity"],["diffuseSampler","emissiveSampler","opacitySampler","boneSampler"],b,p,void 0,void 0,{maxSimultaneousMorphTargets:g})),this._effectLayerMapGenerationEffect.isReady()},e.prototype.render=function(){var e=this._mergeEffect;if(e.isReady()){for(var t=0;t-1&&this._scene.effectLayers.splice(t,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()},e.prototype.getClassName=function(){return"EffectLayer"},e.Parse=function(e,t,n){return Ja.Instantiate(e.customType).Parse(e,t,n)},e._SceneComponentInitialization=function(e){throw oa.a.WarnImport("EffectLayerSceneComponent")},Object(No.c)([ha()],e.prototype,"name",void 0),Object(No.c)([va()],e.prototype,"neutralColor",void 0),Object(No.c)([ha()],e.prototype,"isEnabled",void 0),Object(No.c)([ua(11,t)],e.prototype,"camera",null),Object(No.c)([ha()],e.prototype,"renderingGroupId",null),e}();Ao.AddParser(Gs.NAME_EFFECTLAYER,(function(e,t,n,r){if(e.effectLayers){n.effectLayers||(n.effectLayers=new Array);for(var i=0;i0){this._previousStencilState=this._engine.getStencilBuffer();for(var r=0,i=n;r-1)){this._renderEffects=!0,this._needStencil=this._needStencil||o.needStencil();var a=o._mainTexture;a._shouldRender()&&(this.scene.incrementRenderId(),a.render(!1,!1),t=!0)}}this.scene.incrementRenderId()}return t},e.prototype._setStencil=function(){this._needStencil&&this._engine.setStencilBuffer(!0)},e.prototype._setStencilBack=function(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},e.prototype._draw=function(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var t=this.scene.effectLayers,n=0;n-1},t.prototype.referenceMeshToUseItsOwnMaterial=function(e){this._meshesUsingTheirOwnMaterials.push(e.uniqueId)},t.prototype.unReferenceMeshFromUsingItsOwnMaterial=function(e){for(var t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);t>0;)this._meshesUsingTheirOwnMaterials.slice(t,t+1),t=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,t=ya.Serialize(this);if(t.customType="BABYLON.GlowLayer",t.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e0&&e.isBackground===t&&e.renderTargetTextures.indexOf(r)>-1&&0!=(e.layerMask&n)},e.prototype._drawRenderTargetBackground=function(e){var t=this;this._draw((function(n){return t._drawRenderTargetPredicate(n,!0,t.scene.activeCamera.layerMask,e)}))},e.prototype._drawRenderTargetForeground=function(e){var t=this;this._draw((function(n){return t._drawRenderTargetPredicate(n,!1,t.scene.activeCamera.layerMask,e)}))},e.prototype.addFromContainer=function(e){var t=this;e.layers&&e.layers.forEach((function(e){t.scene.layers.push(e)}))},e.prototype.removeFromContainer=function(e,t){var n=this;void 0===t&&(t=!1),e.layers&&e.layers.forEach((function(e){var r=n.scene.layers.indexOf(e);-1!==r&&n.scene.layers.splice(r,1),t&&e.dispose()}))},e}(),Cf="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\n\n#include\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef LINEAR\nbaseColor.rgb=toGammaSpace(baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}";Qc.a.ShadersStore.layerPixelShader=Cf;var Sf="\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n}";Qc.a.ShadersStore.layerVertexShader=Sf;!function(){function e(e,t,n,r,i){this.name=e,this.scale=new Co(1,1),this.offset=new Co(0,0),this.alphaBlendingMode=2,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this._vertexBuffers={},this.onDisposeObservable=new yo.a,this.onBeforeRenderObservable=new yo.a,this.onAfterRenderObservable=new yo.a,this.texture=t?new Wl(t,n,!0):null,this.isBackground=void 0===r||r,this.color=void 0===i?new ko(1,1,1,1):i,this._scene=n||Zo.a.LastCreatedScene;var o=this._scene._getComponent(Gs.NAME_LAYER);o||(o=new Ef(this._scene),this._scene._addComponent(o)),this._scene.layers.push(this);var a=this._scene.getEngine(),s=[];s.push(1,1),s.push(-1,1),s.push(-1,-1),s.push(1,-1);var l=new cs(a,s,cs.PositionKind,!1,!1,2);this._vertexBuffers[cs.PositionKind]=l,this._createIndexBuffer()}Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),e.prototype._createIndexBuffer=function(){var e=this._scene.getEngine(),t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},e.prototype._rebuild=function(){var e=this._vertexBuffers[cs.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.render=function(){var e=this._scene.getEngine(),t="";this.alphaTest&&(t="#define ALPHATEST"),this.texture&&!this.texture.gammaSpace&&(t+="\r\n#define LINEAR"),this._previousDefines!==t&&(this._previousDefines=t,this._effect=e.createEffect("layer",[cs.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],t));var n=this._effect;if(n&&n.isReady()&&this.texture&&this.texture.isReady()){e=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),e.enableEffect(n),e.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),e.bindBuffers(this._vertexBuffers,this._indexBuffer,n),this.alphaTest?e.drawElementsType(Ls.TriangleFillMode,0,6):(e.setAlphaMode(this.alphaBlendingMode),e.drawElementsType(Ls.TriangleFillMode,0,6),e.setAlphaMode(0)),this.onAfterRenderObservable.notifyObservers(this)}},e.prototype.dispose=function(){var e=this._vertexBuffers[cs.PositionKind];e&&(e.dispose(),this._vertexBuffers[cs.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null),this.renderTargetTextures=[];var t=this._scene.layers.indexOf(this);this._scene.layers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()}}();var Tf=function(){function e(e,t,n,r,i){this.size=e,this.position=t,this.alphaMode=6,this.color=n||new Io(1,1,1),this.texture=r?new Wl(r,i.getScene(),!0):null,this._system=i,i.lensFlares.push(this)}return e.AddFlare=function(t,n,r,i,o){return new e(t,n,r,i,o)},e.prototype.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},e}(),Pf="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}";Qc.a.ShadersStore.lensFlarePixelShader=Pf;var Of="\nattribute vec2 position;\n\nuniform mat4 viewportMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n}";Qc.a.ShadersStore.lensFlareVertexShader=Of;var Rf=function(){function e(t,n,r){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=r||Zo.a.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._emitter=n,this.id=t,r.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return r.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&r.activeCamera.layerMask)};var i=r.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[cs.PositionKind]=new cs(i,o,cs.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",[cs.PositionKind],["color","viewportMatrix"],["textureSampler"],"")}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEmitter=function(){return this._emitter},e.prototype.setEmitter=function(e){this._emitter=e},e.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},e.prototype.computeEffectivePosition=function(e){var t=this.getEmitterPosition();return t=So.Project(t,Oo.Identity(),this._scene.getTransformMatrix(),e),this._positionX=t.x,this._positionY=t.y,t=So.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix()),this.viewportBorder>0&&(e.x-=this.viewportBorder,e.y-=this.viewportBorder,e.width+=2*this.viewportBorder,e.height+=2*this.viewportBorder,t.x+=this.viewportBorder,t.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),t.z>0&&(this._positionX>e.x&&this._positionXe.y&&(this._positionY,e.y,e.height),!0)},e.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var e=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),t=e.length();e.normalize();var n=new Vl(this._scene.activeCamera.globalPosition,e),r=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!r||!r.hit||r.distance>t},e.prototype.render=function(){if(!this._effect.isReady()||!this._scene.activeCamera)return!1;var e,t,n=this._scene.getEngine(),r=this._scene.activeCamera.viewport.toGlobal(n.getRenderWidth(!0),n.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var i=(e=this._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0)>(t=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0)?e:t;(i-=this.viewportBorder)>this.borderLimit&&(i=this.borderLimit);var o=1-xo.Clamp(i/this.borderLimit,0,1);if(o<0)return!1;o>1&&(o=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var a=r.x+r.width/2,s=r.y+r.height/2,l=a-this._positionX,c=s-this._positionY;n.enableEffect(this._effect),n.setState(!1),n.setDepthBuffer(!1),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var u=0;u0);for(var n=0,r=t;n0)}},e}();Rf._SceneComponentInitialization=function(e){var t=e._getComponent(Gs.NAME_LENSFLARESYSTEM);t||(t=new Mf(e),e._addComponent(t))};var If="#ifndef FLOAT\n#include\n#endif\nvarying float vDepthMetric;\n#ifdef USEDISTANCE\nuniform vec3 lightData;\nvarying vec3 vPositionW;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\n#ifdef DEPTHCLAMP\nvarying float z;\n#endif\n#include\nvoid main(void)\n{\n#include\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef DEPTHCLAMP\n#ifdef USEDISTANCE\ndepth=clamp(((length(vPositionW-lightData)+depthValues.x)/(depthValues.y))+biasAndScale.x,0.0,1.0);\n#else\ndepth=clamp(((z+depthValues.x)/(depthValues.y))+biasAndScale.x,0.0,1.0);\n#endif\ngl_FragDepth=depth;\n#elif defined(USEDISTANCE)\ndepth=(length(vPositionW-lightData)+depthValues.x)/(depthValues.y)+biasAndScale.x;\n#endif\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.z*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}";Qc.a.ShadersStore.shadowMapPixelShader=If;var kf="\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\nuniform vec3 lightData;\n#endif\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n\n#include\n#include\nuniform mat4 viewProjection;\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef USEDISTANCE\nvarying vec3 vPositionW;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#ifdef DEPTHCLAMP\nvarying float z;\n#endif\n#include\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvec3 worldNor=normalize(normalWorld*normal);\n#ifdef DIRECTIONINLIGHTDATA\nvec3 worldLightDir=normalize(-lightData.xyz);\n#else\nvec3 directionToLight=lightData.xyz-worldPos.xyz;\nvec3 worldLightDir=normalize(directionToLight);\n#endif\nfloat ndl=dot(worldNor,worldLightDir);\nfloat sinNL=sqrt(1.0-ndl*ndl);\nfloat normalBias=biasAndScale.y*sinNL;\nworldPos.xyz-=worldNor*normalBias;\n#endif\n#ifdef USEDISTANCE\nvPositionW=worldPos.xyz;\n#endif\n\ngl_Position=viewProjection*worldPos;\n#ifdef DEPTHTEXTURE\n\ngl_Position.z+=biasAndScale.x*gl_Position.w;\n#endif\n#ifdef DEPTHCLAMP\nz=gl_Position.z;\ngl_Position.z=0.0;\n#elif !defined(USEDISTANCE)\n\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#endif\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}";Qc.a.ShadersStore.shadowMapVertexShader=kf;var Df="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}";Qc.a.ShadersStore.depthBoxBlurPixelShader=Df;var Bf=function(){function e(t,n,r){this.onBeforeShadowMapRenderObservable=new yo.a,this.onAfterShadowMapRenderObservable=new yo.a,this.onBeforeShadowMapRenderMeshObservable=new yo.a,this.onAfterShadowMapRenderMeshObservable=new yo.a,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=e.FILTER_NONE,this._filteringQuality=e.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=So.Zero(),this._viewMatrix=Oo.Zero(),this._projectionMatrix=Oo.Zero(),this._transformMatrix=Oo.Zero(),this._cachedPosition=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=Oo.Identity(),this._mapSize=t,this._light=n,this._scene=n.getScene(),n._shadowGenerator=this,e._SceneComponentInitialization(this._scene);var i=this._scene.getEngine().getCaps();r?i.textureFloatRender&&i.textureFloatLinearFiltering?this._textureType=1:i.textureHalfFloatRender&&i.textureHalfFloatLinearFiltering?this._textureType=2:this._textureType=0:i.textureHalfFloatRender&&i.textureHalfFloatLinearFiltering?this._textureType=2:i.textureFloatRender&&i.textureFloatLinearFiltering?this._textureType=1:this._textureType=0,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(e.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"normalBias",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),e.prototype._validateFilter=function(e){return e},Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},set:function(t){if(t=this._validateFilter(t),this._light.needCube()){if(t===e.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(t===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(t===e.FILTER_PCF||t===e.FILTER_PCSS)return void(this.usePoissonSampling=!0)}t!==e.FILTER_PCF&&t!==e.FILTER_PCSS||1!==this._scene.getEngine().webGLVersion?this._filter!==t&&(this._filter=t,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usePoissonSampling",{get:function(){return this.filter===e.FILTER_POISSONSAMPLING},set:function(t){var n=this._validateFilter(e.FILTER_POISSONSAMPLING);(t||this.filter===e.FILTER_POISSONSAMPLING)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useExponentialShadowMap",{get:function(){return this.filter===e.FILTER_EXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_EXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_BLUREXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_CLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===e.FILTER_PCF},set:function(t){var n=this._validateFilter(e.FILTER_PCF);(t||this.filter===e.FILTER_PCF)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useContactHardeningShadow",{get:function(){return this.filter===e.FILTER_PCSS},set:function(t){var n=this._validateFilter(e.FILTER_PCSS);(t||this.filter===e.FILTER_PCSS)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"darkness",{get:function(){return this._darkness},set:function(e){this.setDarkness(e)},enumerable:!0,configurable:!0}),e.prototype.getDarkness=function(){return this._darkness},e.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},Object.defineProperty(e.prototype,"transparencyShadow",{get:function(){return this._transparencyShadow},set:function(e){this.setTransparencyShadow(e)},enumerable:!0,configurable:!0}),e.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},e.prototype.getShadowMap=function(){return this._shadowMap},e.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},e.prototype.getClassName=function(){return e.CLASSNAME},e.prototype.addShadowCaster=function(e,t){var n;return void 0===t&&(t=!0),this._shadowMap?(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(e),t&&(n=this._shadowMap.renderList).push.apply(n,e.getChildMeshes()),this):this},e.prototype.removeShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var n=this._shadowMap.renderList.indexOf(e);if(-1!==n&&this._shadowMap.renderList.splice(n,1),t)for(var r=0,i=e.getChildren();r1?(this._shadowMap=new mu(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture(513,!0)):this._shadowMap=new mu(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())},e.prototype._initializeShadowMap=function(){var t=this;if(this._createTargetRenderTexture(),null!==this._shadowMap){this._shadowMap.wrapU=Wl.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=Wl.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(Wl.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this);var n=this._scene.getEngine();this._shadowMap.onBeforeRenderObservable.add((function(r){t._currentFaceIndex=r,t._filter===e.FILTER_PCF&&n.setColorWrite(!1)})),this._shadowMap.onAfterUnbindObservable.add((function(){if(t._filter===e.FILTER_PCF&&n.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var r=t.getShadowMapForRendering();r&&t._scene.postProcessManager.directRender(t._blurPostProcesses,r.getInternalTexture(),!0)}}));var r=new ko(0,0,0,0),i=new ko(1,1,1,1);this._shadowMap.onClearObservable.add((function(n){t._filter===e.FILTER_PCF?n.clear(i,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?n.clear(r,!0,!0,!1):n.clear(i,!0,!0,!1)})),this._shadowMap.onResizeObservable.add((function(e){t._storedUniqueId=t._shadowMap.uniqueId,t._mapSize=e.getRenderSize(),t._light._markMeshesAsLightDirty(),t.recreateShadowMap()}));for(var o=js.MIN_RENDERINGGROUPS;o=a.length)return void(e&&e(n));setTimeout(d,16)}};d()}else e&&e(this)}else e&&e(this)}else e&&e(this)},e.prototype.forceCompilationAsync=function(e){var t=this;return new Promise((function(n){t.forceCompilation((function(){n()}),e)}))},e.prototype._isReadyCustomDefines=function(e,t,n){},e.prototype.isReady=function(e,t){var n=[];0!==this._textureType&&n.push("#define FLOAT"),this.useExponentialShadowMap||this.useBlurExponentialShadowMap?n.push("#define ESM"):(this.usePercentageCloserFiltering||this.useContactHardeningShadow)&&n.push("#define DEPTHTEXTURE");var r=[cs.PositionKind],i=e.getMesh(),o=e.getMaterial();if(this.normalBias&&i.isVerticesDataPresent(cs.NormalKind)&&(r.push(cs.NormalKind),n.push("#define NORMAL"),i.nonUniformScaling&&n.push("#define NONUNIFORMSCALING"),this.getLight().getTypeID()===Ds.LIGHTTYPEID_DIRECTIONALLIGHT&&n.push("#define DIRECTIONINLIGHTDATA")),o&&o.needAlphaTesting()){var a=o.getAlphaTestTexture();a&&(n.push("#define ALPHATEST"),i.isVerticesDataPresent(cs.UVKind)&&(r.push(cs.UVKind),n.push("#define UV1")),i.isVerticesDataPresent(cs.UV2Kind)&&1===a.coordinatesIndex&&(r.push(cs.UV2Kind),n.push("#define UV2")))}var s=new ud;if(i.useBones&&i.computeBonesUsingShaders&&i.skeleton){r.push(cs.MatricesIndicesKind),r.push(cs.MatricesWeightsKind),i.numBoneInfluencers>4&&(r.push(cs.MatricesIndicesExtraKind),r.push(cs.MatricesWeightsExtraKind));var l=i.skeleton;n.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),i.numBoneInfluencers>0&&s.addCPUSkinningFallback(0,i),l.isUsingTextureForMatrices?n.push("#define BONETEXTURE"):n.push("#define BonesPerMesh "+(l.bones.length+1))}else n.push("#define NUM_BONE_INFLUENCERS 0");var c=i.morphTargetManager,u=0;c&&c.numInfluencers>0&&(n.push("#define MORPHTARGETS"),u=c.numInfluencers,n.push("#define NUM_MORPH_INFLUENCERS "+u),Cu.PrepareAttributesForMorphTargetsInfluencers(r,i,u));var d=this._scene;if(d.clipPlane&&n.push("#define CLIPPLANE"),d.clipPlane2&&n.push("#define CLIPPLANE2"),d.clipPlane3&&n.push("#define CLIPPLANE3"),d.clipPlane4&&n.push("#define CLIPPLANE4"),d.clipPlane5&&n.push("#define CLIPPLANE5"),d.clipPlane6&&n.push("#define CLIPPLANE6"),t&&(n.push("#define INSTANCES"),Cu.PushAttributesForInstances(r)),this.customShaderOptions&&this.customShaderOptions.defines)for(var h=0,p=this.customShaderOptions.defines;h4&&(i.push(cs.MatricesIndicesExtraKind),i.push(cs.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0");var a=o.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,r.push("#define MORPHTARGETS"),r.push("#define NUM_MORPH_INFLUENCERS "+s),Cu.PrepareAttributesForMorphTargetsInfluencers(i,o,s)),t&&(r.push("#define INSTANCES"),Cu.PushAttributesForInstances(i)),this._storeNonLinearDepth&&r.push("#define NONLINEARDEPTH"),this.isPacked&&r.push("#define PACKED");var l=r.join("\n");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this._scene.getEngine().createEffect("depth",i,["world","mBones","viewProjection","diffuseMatrix","depthValues","morphTargetInfluences"],["diffuseSampler"],l,void 0,void 0,void 0,{maxSimultaneousMorphTargets:s})),this._effect.isReady()},e.prototype.getDepthMap=function(){return this._depthMap},e.prototype.dispose=function(){this._depthMap.dispose()},e._SceneComponentInitialization=function(e){throw oa.a.WarnImport("DepthRendererSceneComponent")},e}(),Uf="attribute vec2 vUV;\nuniform sampler2D textureSampler;\n#if defined(INITIAL)\nuniform sampler2D sourceTexture;\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nfloat f1=texelFetch(sourceTexture,coord,0).r;\nfloat f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;\nfloat f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;\nfloat f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;\nfloat minz=min(min(min(f1,f2),f3),f4);\n#ifdef DEPTH_REDUX\nfloat maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);\n#else\nfloat maxz=max(max(max(f1,f2),f3),f4);\n#endif\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(MAIN)\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nvec2 f1=texelFetch(textureSampler,coord,0).rg;\nvec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;\nvec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;\nvec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;\nfloat minz=min(min(min(f1.x,f2.x),f3.x),f4.x);\nfloat maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(ONEBEFORELAST)\nuniform ivec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*vec2(texSize-1));\nvec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;\nvec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;\nvec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;\nvec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;\nfloat minz=min(f1.x,f2.x);\nfloat maxz=max(f1.y,f2.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(LAST)\nvoid main(void)\n{\ndiscard;\nglFragColor=vec4(0.);\n}\n#endif\n";Qc.a.ShadersStore.minmaxReduxPixelShader=Uf;var Vf=function(e){function t(t){return e.call(this,t)||this}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"depthRenderer",{get:function(){return this._depthRenderer},enumerable:!0,configurable:!0}),t.prototype.setDepthRenderer=function(t,n,r){void 0===t&&(t=null),void 0===n&&(n=2),void 0===r&&(r=!0);var i=this._camera.getScene();this._depthRenderer&&(delete i._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null),null===t&&(i._depthRenderer||(i._depthRenderer={}),(t=this._depthRenderer=new Lf(i,n,this._camera,!1)).enabled=!1,this._depthRendererId="minmax"+this._camera.id,i._depthRenderer[this._depthRendererId]=t),e.prototype.setSourceTexture.call(this,t.getDepthMap(),!0,n,r)},t.prototype.setSourceTexture=function(t,n,r,i){void 0===r&&(r=2),void 0===i&&(i=!0),e.prototype.setSourceTexture.call(this,t,n,r,i)},t.prototype.activate=function(){this._depthRenderer&&(this._depthRenderer.enabled=!0),e.prototype.activate.call(this)},t.prototype.deactivate=function(){e.prototype.deactivate.call(this),this._depthRenderer&&(this._depthRenderer.enabled=!1)},t.prototype.dispose=function(t){var n;void 0===t&&(t=!0),e.prototype.dispose.call(this,t),this._depthRenderer&&t&&(null===(n=this._depthRenderer.getDepthMap().getScene())||void 0===n||n._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null)},t}(function(){function e(e){this.onAfterReductionPerformed=new yo.a,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new Us(e.getScene())}return Object.defineProperty(e.prototype,"sourceTexture",{get:function(){return this._sourceTexture},enumerable:!0,configurable:!0}),e.prototype.setSourceTexture=function(e,t,n,r){var i=this;if(void 0===n&&(n=2),void 0===r&&(r=!0),e!==this._sourceTexture){this.dispose(!1),this._sourceTexture=e,this._reductionSteps=[],this._forceFullscreenViewport=r;var o=this._camera.getScene(),a=new Xc("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,1,o.getEngine(),!1,"#define INITIAL"+(t?"\n#define DEPTH_REDUX":""),n,void 0,void 0,void 0,7);a.autoClear=!1,a.forceFullscreenViewport=r;var s=this._sourceTexture.getRenderWidth(),l=this._sourceTexture.getRenderHeight();a.onApply=function(e,t){return function(n){n.setTexture("sourceTexture",i._sourceTexture),n.setFloatArray2("texSize",new Float32Array([e,t]))}}(s,l),this._reductionSteps.push(a);for(var c=1;s>1||l>1;){s=Math.max(Math.round(s/2),1),l=Math.max(Math.round(l/2),1);var u=new Xc("Reduction phase "+c,"minmaxRedux",["texSize"],null,{width:s,height:l},null,1,o.getEngine(),!1,"#define "+(1==s&&1==l?"LAST":1==s||1==l?"ONEBEFORELAST":"MAIN"),n,void 0,void 0,void 0,7);if(u.autoClear=!1,u.forceFullscreenViewport=r,u.onApply=function(e,t){return function(n){1==e||1==t?n.setIntArray2("texSize",new Int32Array([e,t])):n.setFloatArray2("texSize",new Float32Array([e,t]))}}(s,l),this._reductionSteps.push(u),c++,1==s&&1==l){u.onAfterRenderObservable.add(function(e,t,n){var r=new Float32Array(4*e*t),a={min:0,max:0};return function(){o.getEngine()._readTexturePixels(n.inputTexture,e,t,-1,0,r),a.min=r[0],a.max=r[1],i.onAfterReductionPerformed.notifyObservers(a)}}(s,l,u))}}}},Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._sourceTexture?this._sourceTexture.refreshRate:-1},set:function(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activated",{get:function(){return this._activated},enumerable:!0,configurable:!0}),e.prototype.activate=function(){var e=this;!this._onAfterUnbindObserver&&this._sourceTexture&&(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add((function(){e._reductionSteps[0].activate(e._camera),e._postProcessManager.directRender(e._reductionSteps,e._reductionSteps[0].inputTexture,e._forceFullscreenViewport),e._camera.getScene().getEngine().unBindFramebuffer(e._reductionSteps[0].inputTexture,!1)})),this._activated=!0)},e.prototype.deactivate=function(){this._onAfterUnbindObserver&&this._sourceTexture&&(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)},e.prototype.dispose=function(e){if(void 0===e&&(e=!0),e&&this.onAfterReductionPerformed.clear(),this.deactivate(),this._reductionSteps){for(var t=0;tt&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)},Object.defineProperty(t.prototype,"minDistance",{get:function(){return this._minDistance},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxDistance",{get:function(){return this._maxDistance},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return t.CLASSNAME},t.prototype.getCascadeMinExtents=function(e){return e>=0&&e=0&&ethis._scene.activeCamera.maxZ||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug=e,this._light._markMeshesAsLightDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthClamp",{get:function(){return this._depthClamp},set:function(e){this._depthClamp=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cascadeBlendPercentage",{get:function(){return this._cascadeBlendPercentage},set:function(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lambda",{get:function(){return this._lambda},set:function(e){var t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.getCascadeViewMatrix=function(e){return e>=0&&e=0&&e=0&&e=r&&(n=0,r=1),n==t._minDistance&&r==t._maxDistance||t.setMinMaxDistance(n,r)})),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoCalcDepthBoundsRefreshRate",{get:function(){var e,t,n;return null!=(n=null===(t=null===(e=this._depthReducer)||void 0===e?void 0:e.depthRenderer)||void 0===t?void 0:t.getDepthMap().refreshRate)?n:-1},set:function(e){var t;(null===(t=this._depthReducer)||void 0===t?void 0:t.depthRenderer)&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)},enumerable:!0,configurable:!0}),t.prototype.splitFrustum=function(){this._breaksAreDirty=!0},t.prototype._splitFrustum=function(){var e=this._scene.activeCamera;if(e){for(var t=e.minZ,n=e.maxZ,r=n-t,i=this._minDistance,o=t+i*r,a=t+(this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(n-t),this._maxDistance):this._maxDistance)*r,s=a-o,l=a/o,c=0;cMath.PI;)i-=2*Math.PI;var a=i/Math.PI,s=o/Math.PI;a=.5*a+.5;var l=Math.round(a*n);l<0?l=0:l>=n&&(l=n-1);var c=Math.round(s*r);c<0?c=0:c>=r&&(c=r-1);var u=r-c-1;return{r:t[u*n*3+3*l+0],g:t[u*n*3+3*l+1],b:t[u*n*3+3*l+2]}},e.FACE_FRONT=[new So(-1,-1,-1),new So(1,-1,-1),new So(-1,1,-1),new So(1,1,-1)],e.FACE_BACK=[new So(1,-1,1),new So(-1,-1,1),new So(1,1,1),new So(-1,1,1)],e.FACE_RIGHT=[new So(1,-1,-1),new So(1,-1,1),new So(1,1,-1),new So(1,1,1)],e.FACE_LEFT=[new So(-1,-1,1),new So(-1,-1,-1),new So(-1,1,1),new So(-1,1,-1)],e.FACE_DOWN=[new So(-1,1,-1),new So(1,1,-1),new So(-1,1,1),new So(1,1,1)],e.FACE_UP=[new So(-1,-1,1),new So(1,-1,1),new So(-1,-1,-1),new So(1,-1,-1)],e}(),Zf=function(){function e(){}return e.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},e.Rgbe2float=function(e,t,n,r,i,o){i>0?(i=this.Ldexp(1,i-136),e[o+0]=t*i,e[o+1]=n*i,e[o+2]=r*i):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},e.readStringLine=function(e,t){for(var n="",r="",i=t;i32767)throw"HDR Bad header format, unsupported size";return{height:t,width:n,dataPosition:a+=r.length+1}},e.GetCubeMapTextureData=function(e,t){var n=new Uint8Array(e),r=this.RGBE_ReadHeader(n),i=this.RGBE_ReadPixels_RLE(n,r);return qf.ConvertPanoramaToCubemap(i,r.width,r.height,t)},e.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},e.RGBE_ReadPixels_RLE=function(e,t){for(var n,r,i,o,a,s=t.height,l=t.width,c=t.dataPosition,u=0,d=0,h=0,p=new ArrayBuffer(4*l),f=new Uint8Array(p),m=new ArrayBuffer(t.width*t.height*4*3),g=new Float32Array(m);s>0;){if(n=e[c++],r=e[c++],i=e[c++],o=e[c++],2!=n||2!=r||128&i)throw"HDR Bad header format, not RLE";if((i<<8|o)!=l)throw"HDR Bad header format, wrong scan line width";for(u=0,h=0;h<4;h++)for(d=(h+1)*l;u128){if(0==(a=n-128)||a>d-u)throw"HDR Bad Format, bad scanline data (run)";for(;a-- >0;)f[u++]=r}else{if(0==(a=n)||a>d-u)throw"HDR Bad Format, bad scanline data (non-run)";if(f[u++]=r,--a>0)for(var b=0;b255){var g=255/m;h*=g,p*=g,f*=g}s[3*d+0]=h,s[3*d+1]=p,s[3*d+2]=f}s?a.push(s):a.push(u)}return a}),null,this._onLoad,this._onError))},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=new t(this.url,e,this._size,this._noMipmap,this._generateHarmonics,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.prototype.delayLoad=function(){4===this.delayLoadState&&(this.delayLoadState=1,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 t=this;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&this.getScene().markAllMaterialsAsDirty(1,(function(e){return-1!==e.getActiveTextures().indexOf(t)}))},t.Parse=function(e,n,r){var i=null;return e.name&&!e.isRenderTarget&&((i=new t(r+e.name,n,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name=e.name,i.hasAlpha=e.hasAlpha,i.level=e.level,i.coordinatesMode=e.coordinatesMode,i.isBlocking=e.isBlocking),i&&(e.boundingBoxPosition&&(i.boundingBoxPosition=So.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(i.boundingBoxSize=So.FromArray(e.boundingBoxSize)),e.rotationY&&(i.rotationY=e.rotationY)),i},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}(Ql);Eo.RegisteredTypes["BABYLON.HDRCubeTexture"]=Jf;var $f=function(){function e(e,t,n){void 0===t&&(t=0),void 0===n&&(n=null),this.name=e,this.animations=new Array,this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new yo.a,this._onDataLayoutChanged=new yo.a,this._animationPropertiesOverride=null,this._scene=n||Zo.a.LastCreatedScene,this.influence=t,this._scene&&(this._uniqueId=this._scene.getUniqueId())}return Object.defineProperty(e.prototype,"influence",{get:function(){return this._influence},set:function(e){if(this._influence!==e){var t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasPositions",{get:function(){return!!this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasNormals",{get:function(){return!!this._normals},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasTangents",{get:function(){return!!this._tangents},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasUVs",{get:function(){return!!this._uvs},enumerable:!0,configurable:!0}),e.prototype.setPositions=function(e){var t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getPositions=function(){return this._positions},e.prototype.setNormals=function(e){var t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getNormals=function(){return this._normals},e.prototype.setTangents=function(e){var t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getTangents=function(){return this._tangents},e.prototype.setUVs=function(e){var t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getUVs=function(){return this._uvs},e.prototype.clone=function(){var t=this,n=ya.Clone((function(){return new e(t.name,t.influence,t._scene)}),this);return n._positions=this._positions,n._normals=this._normals,n._tangents=this._tangents,n._uvs=this._uvs,n},e.prototype.serialize=function(){var e={};return e.name=this.name,e.influence=this.influence,e.positions=Array.prototype.slice.call(this.getPositions()),null!=this.id&&(e.id=this.id),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),ya.AppendSerializedAnimations(this,e),e},e.prototype.getClassName=function(){return"MorphTarget"},e.Parse=function(t){var n=new e(t.name,t.influence);if(n.setPositions(t.positions),null!=t.id&&(n.id=t.id),t.normals&&n.setNormals(t.normals),t.tangents&&n.setTangents(t.tangents),t.uvs&&n.setUVs(t.uvs),t.animations)for(var r=0;r=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._syncActiveTargets(!0))},e.prototype.clone=function(){for(var t=new e(this._scene),n=0,r=this._targets;n-1&&(this._impostors.splice(t,1).length&&this.getPhysicsPlugin().removePhysicsBody(e))},e.prototype.addJoint=function(e,t,n){var r={mainImpostor:e,connectedImpostor:t,joint:n};n.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},e.prototype.removeJoint=function(e,t,n){var r=this._joints.filter((function(r){return r.connectedImpostor===t&&r.joint===n&&r.mainImpostor===e}));r.length&&this._physicsPlugin.removeJoint(r[0])},e.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},e.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},e.prototype.getImpostors=function(){return this._impostors},e.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;t0&&(this._physicsBodysToRemoveAfterStep.forEach((function(t){e.world.remove(t)})),this._physicsBodysToRemoveAfterStep=[])},e.prototype.applyImpulse=function(e,t,n){var r=new this.BJSCANNON.Vec3(n.x,n.y,n.z),i=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(i,r)},e.prototype.applyForce=function(e,t,n){var r=new this.BJSCANNON.Vec3(n.x,n.y,n.z),i=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(i,r)},e.prototype.generatePhysicsBody=function(e){if(this._removeMarkedPhysicsBodiesFromWorld(),e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var t=this._createShape(e),n=e.physicsBody;n&&this.removePhysicsBody(e);var r=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),i={mass:e.getParam("mass"),material:r},o=e.getParam("nativeOptions");for(var a in o)o.hasOwnProperty(a)&&(i[a]=o[a]);e.physicsBody=new this.BJSCANNON.Body(i),e.physicsBody.addEventListener("collide",e.onCollide),this.world.addEventListener("preStep",e.beforeStep),this.world.addEventListener("postStep",e.afterStep),e.physicsBody.addShape(t),this.world.add(e.physicsBody),n&&["force","torque","velocity","angularVelocity"].forEach((function(t){e.physicsBody[t].copy(n[t])})),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)}},e.prototype._processChildMeshes=function(e){var t=this,n=e.object.getChildMeshes?e.object.getChildMeshes(!0):[],r=e.object.rotationQuaternion;if(n.length){var i=function(n,o){if(r&&o.rotationQuaternion){var a=o.getPhysicsImpostor();if(a)if(a.parent!==e){var s=o.position.clone(),l=o.rotationQuaternion.multiply(Po.Inverse(r));a.physicsBody&&(t.removePhysicsBody(a),a.physicsBody=null),a.parent=e,a.resetUpdateFlags(),e.physicsBody.addShape(t._createShape(a),new t.BJSCANNON.Vec3(s.x,s.y,s.z),new t.BJSCANNON.Quaternion(l.x,l.y,l.z,l.w)),e.physicsBody.mass+=a.getParam("mass")}r.multiplyInPlace(o.rotationQuaternion),o.getChildMeshes(!0).filter((function(e){return!!e.physicsImpostor})).forEach(i.bind(t,o.getAbsolutePosition()))}};n.filter((function(e){return!!e.physicsImpostor})).forEach(i.bind(this,e.object.getAbsolutePosition()))}},e.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),-1===this._physicsBodysToRemoveAfterStep.indexOf(e.physicsBody)&&this._physicsBodysToRemoveAfterStep.push(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,n=e.connectedImpostor.physicsBody;if(t&&n){var r,i=e.joint.jointData,o={pivotA:i.mainPivot?(new this.BJSCANNON.Vec3).copy(i.mainPivot):null,pivotB:i.connectedPivot?(new this.BJSCANNON.Vec3).copy(i.connectedPivot):null,axisA:i.mainAxis?(new this.BJSCANNON.Vec3).copy(i.mainAxis):null,axisB:i.connectedAxis?(new this.BJSCANNON.Vec3).copy(i.connectedAxis):null,maxForce:i.nativeParams.maxForce,collideConnected:!!i.collision};switch(e.joint.type){case jd.HingeJoint:case jd.Hinge2Joint:r=new this.BJSCANNON.HingeConstraint(t,n,o);break;case jd.DistanceJoint:r=new this.BJSCANNON.DistanceConstraint(t,n,i.maxDistance||2);break;case jd.SpringJoint:var a=i;r=new this.BJSCANNON.Spring(t,n,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:o.pivotA,localAnchorB:o.pivotB});break;case jd.LockJoint:r=new this.BJSCANNON.LockConstraint(t,n,o);break;case jd.PointToPointJoint:case jd.BallAndSocketJoint:default:r=new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,n,o.pivotB,o.maxForce)}r.collideConnected=!!i.collision,e.joint.physicsJoint=r,e.joint.type!==jd.SpringJoint?this.world.addConstraint(r):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){r.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},e.prototype.removeJoint=function(e){e.joint.type!==jd.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},e.prototype._addMaterial=function(e,t,n){var r,i;for(r=0;r1e3*n));s++);this.time+=r;for(var l=this.time%n/n,c=e,u=this.bodies,d=0;d!==u.length;d++){var h=u[d];h.type!==t.Body.STATIC&&h.sleepState!==t.Body.SLEEPING?(h.position.vsub(h.previousPosition,c),c.scale(l,c),h.position.vadd(c,h.interpolatedPosition)):(h.interpolatedPosition.copy(h.position),h.interpolatedQuaternion.copy(h.quaternion))}}}},e.prototype.raycast=function(e,t){return this._cannonRaycastResult.reset(),this.world.raycastClosest(e,t,{},this._cannonRaycastResult),this._raycastResult.reset(e,t),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},e}();tm.DefaultPluginFactory=function(){return new rm};var im=function(){function e(e,t){void 0===t&&(t=OIMO),this.name="OimoJSPlugin",this._tmpImpostorsArray=[],this._tmpPositionVector=So.Zero(),this.BJSOIMO=t,this.world=new this.BJSOIMO.World({iterations:e}),this.world.clear(),this._raycastResult=new nm}return e.prototype.setGravity=function(e){this.world.gravity.copy(e)},e.prototype.setTimeStep=function(e){this.world.timeStep=e},e.prototype.getTimeStep=function(){return this.world.timeStep},e.prototype.executeStep=function(e,t){var n=this;t.forEach((function(e){e.beforeStep()})),this.world.step(),t.forEach((function(e){e.afterStep(),n._tmpImpostorsArray[e.uniqueId]=e}));for(var r=this.world.contacts;null!==r;)if(!r.touching||r.body1.sleeping||r.body2.sleeping){var i=this._tmpImpostorsArray[+r.body1.name],o=this._tmpImpostorsArray[+r.body2.name];i&&o?(i.onCollide({body:o.physicsBody}),o.onCollide({body:i.physicsBody}),r=r.next):r=r.next}else r=r.next},e.prototype.applyImpulse=function(e,t,n){var r=e.physicsBody.mass;e.physicsBody.applyImpulse(n.scale(this.world.invScale),t.scale(this.world.invScale*r))},e.prototype.applyForce=function(e,t,n){jo.a.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(e,t,n)},e.prototype.generatePhysicsBody=function(e){var t=this;if(e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var n={name:e.uniqueId,config:[e.getParam("mass")||.001,e.getParam("friction"),e.getParam("restitution")],size:[],type:[],pos:[],posShape:[],rot:[],rotShape:[],move:0!==e.getParam("mass"),density:e.getParam("mass"),friction:e.getParam("friction"),restitution:e.getParam("restitution"),world:this.world},r=[e];(a=e.object).getChildMeshes&&a.getChildMeshes().forEach((function(e){e.physicsImpostor&&r.push(e.physicsImpostor)}));var i=function(e){return Math.max(e,tm.Epsilon)},o=new Po;r.forEach((function(r){if(r.object.rotationQuaternion){var a=r.object.rotationQuaternion;o=a.clone(),r.object.rotationQuaternion.set(0,0,0,1),r.object.computeWorldMatrix(!0);var s=a.toEulerAngles(),l=r.getObjectExtendSize();if(r===e){var c=e.getObjectCenter();e.object.getAbsolutePivotPoint().subtractToRef(c,t._tmpPositionVector),t._tmpPositionVector.divideInPlace(e.object.scaling),n.pos.push(c.x),n.pos.push(c.y),n.pos.push(c.z),n.posShape.push(0,0,0),n.rotShape.push(0,0,0)}else{var u=r.object.position.clone();n.posShape.push(u.x),n.posShape.push(u.y),n.posShape.push(u.z),n.rotShape.push(57.29577951308232*s.x),n.rotShape.push(57.29577951308232*s.y),n.rotShape.push(57.29577951308232*s.z)}switch(r.object.rotationQuaternion.copyFrom(o),r.type){case Hd.ParticleImpostor:jo.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case Hd.SphereImpostor:var d=l.x,h=l.y,p=l.z,f=Math.max(i(d),i(h),i(p))/2;n.type.push("sphere"),n.size.push(f),n.size.push(f),n.size.push(f);break;case Hd.CylinderImpostor:var m=i(l.x)/2,g=i(l.y);n.type.push("cylinder"),n.size.push(m),n.size.push(g),n.size.push(g);break;case Hd.PlaneImpostor:case Hd.BoxImpostor:default:m=i(l.x),g=i(l.y);var b=i(l.z);n.type.push("box"),n.size.push(m),n.size.push(g),n.size.push(b)}r.object.rotationQuaternion=a}})),e.physicsBody=this.world.add(n),e.physicsBody.resetQuaternion(o),e.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);var a;e.setDeltaPosition(this._tmpPositionVector)}},e.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,n=e.connectedImpostor.physicsBody;if(t&&n){var r,i=e.joint.jointData,o=i.nativeParams||{},a={body1:t,body2:n,axe1:o.axe1||(i.mainAxis?i.mainAxis.asArray():null),axe2:o.axe2||(i.connectedAxis?i.connectedAxis.asArray():null),pos1:o.pos1||(i.mainPivot?i.mainPivot.asArray():null),pos2:o.pos2||(i.connectedPivot?i.connectedPivot.asArray():null),min:o.min,max:o.max,collision:o.collision||i.collision,spring:o.spring,world:this.world};switch(e.joint.type){case jd.BallAndSocketJoint:r="jointBall";break;case jd.SpringJoint:jo.a.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var s=i;a.min=s.length||a.min,a.max=Math.max(a.min,a.max);case jd.DistanceJoint:r="jointDistance",a.max=i.maxDistance;break;case jd.PrismaticJoint:r="jointPrisme";break;case jd.SliderJoint:r="jointSlide";break;case jd.WheelJoint:r="jointWheel";break;case jd.HingeJoint:default:r="jointHinge"}a.type=r,e.joint.physicsJoint=this.world.add(a)}},e.prototype.removeJoint=function(e){try{this.world.removeJoint(e.joint.physicsJoint)}catch(e){jo.a.Warn(e)}},e.prototype.isSupported=function(){return void 0!==this.BJSOIMO},e.prototype.setTransformationFromPhysicsBody=function(e){if(!e.physicsBody.sleeping){if(e.physicsBody.shapes.next){for(var t=e.physicsBody.shapes;t.next;)t=t.next;e.object.position.copyFrom(t.position)}else e.object.position.copyFrom(e.physicsBody.getPosition());e.object.rotationQuaternion&&e.object.rotationQuaternion.copyFrom(e.physicsBody.getQuaternion())}},e.prototype.setPhysicsBodyTransformation=function(e,t,n){var r=e.physicsBody;e.physicsBody.shapes.next||(r.position.copy(t),r.orientation.copy(n),r.syncShapes(),r.awake())},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.copy(t)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.linearVelocity;return t?new So(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new So(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){var n=0===t;e.physicsBody.shapes.density=n?1:t,e.physicsBody.setupMass(n?2:1)},e.prototype.getBodyMass=function(e){return e.physicsBody.shapes.density},e.prototype.getBodyFriction=function(e){return e.physicsBody.shapes.friction},e.prototype.setBodyFriction=function(e,t){e.physicsBody.shapes.friction=t},e.prototype.getBodyRestitution=function(e){return e.physicsBody.shapes.restitution},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.shapes.restitution=t},e.prototype.sleepBody=function(e){e.physicsBody.sleep()},e.prototype.wakeUpBody=function(e){e.physicsBody.awake()},e.prototype.updateDistanceJoint=function(e,t,n){e.physicsJoint.limitMotor.upperLimit=t,void 0!==n&&(e.physicsJoint.limitMotor.lowerLimit=n)},e.prototype.setMotor=function(e,t,n,r){void 0!==n?jo.a.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter"):n=1e6,t*=-1;var i=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;i&&i.setMotor(t,n)},e.prototype.setLimit=function(e,t,n,r){var i=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;i&&i.setLimit(t,void 0===n?-t:n)},e.prototype.syncMeshWithImpostor=function(e,t){var n=t.physicsBody;e.position.x=n.position.x,e.position.y=n.position.y,e.position.z=n.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=n.orientation.x,e.rotationQuaternion.y=n.orientation.y,e.rotationQuaternion.z=n.orientation.z,e.rotationQuaternion.w=n.orientation.s)},e.prototype.getRadius=function(e){return e.physicsBody.shapes.radius},e.prototype.getBoxSizeToRef=function(e,t){var n=e.physicsBody.shapes;t.x=2*n.halfWidth,t.y=2*n.halfHeight,t.z=2*n.halfDepth},e.prototype.dispose=function(){this.world.clear()},e.prototype.raycast=function(e,t){return jo.a.Warn("raycast is not currently supported by the Oimo physics plugin"),this._raycastResult.reset(e,t),this._raycastResult},e}();us.CreateRibbon=function(e){var t=e.pathArray,n=e.closeArray||!1,r=e.closePath||!1,i=e.invertUV||!1,o=Math.floor(t[0].length/2),a=e.offset||o;a=a>o?o:Math.floor(a);var s,l,c,u,d=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,h=e.uvs,p=e.colors,f=[],m=[],g=[],b=[],v=[],A=[],_=[],y=[],x=[],w=[];if(t.length<2){var E=[],C=[];for(c=0;c0&&(P=S[u].subtract(S[u-1]).length()+_[l],v[l].push(P),_[l]=P),u++;r&&(u--,f.push(S[0].x,S[0].y,S[0].z),P=S[u].subtract(S[0]).length()+_[l],v[l].push(P),_[l]=P),x[l]=T+I,w[l]=M,M+=T+I}var k,D,B=null,F=null;for(c=0;c3?0:c,u);var x=om.CreateRibbon(e,{pathArray:A,closeArray:s,closePath:l,updatable:h,sideOrientation:p,invertUV:m,frontUVs:g||void 0,backUVs:b||void 0},d);return x._creationDataStorage.pathArray=A,x._creationDataStorage.path3D=v,x._creationDataStorage.cap=c,x},e}(),sm=function(){function e(e,t,n){var r=this;void 0===e&&(e=!0),void 0===t&&(t=Ammo),void 0===n&&(n=null),this._useDeltaForWorldStep=e,this.bjsAMMO={},this.name="AmmoJSPlugin",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new Po,this._tmpContactCallbackResult=!1,this._tmpVector=new So,this._tmpMatrix=new Oo,"function"==typeof t?t(this.bjsAMMO):this.bjsAMMO=t,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(){r._tmpContactCallbackResult=!0},this._raycastResult=new nm,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)):jo.a.Error("AmmoJS is not available. Please make sure you included the js file.")}return e.prototype.setGravity=function(e){this._tmpAmmoVectorA.setValue(e.x,e.y,e.z),this.world.setGravity(this._tmpAmmoVectorA),this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA)},e.prototype.setTimeStep=function(e){this._timeStep=e},e.prototype.setFixedTimeStep=function(e){this._fixedTimeStep=e},e.prototype.setMaxSteps=function(e){this._maxSteps=e},e.prototype.getTimeStep=function(){return this._timeStep},e.prototype._isImpostorInContact=function(e){return this._tmpContactCallbackResult=!1,this.world.contactTest(e.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._isImpostorPairInContact=function(e,t){return this._tmpContactCallbackResult=!1,this.world.contactPairTest(e.physicsBody,t.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._stepSimulation=function(e,t,n){if(void 0===e&&(e=1/60),void 0===t&&(t=10),void 0===n&&(n=1/60),0==t)this.world.stepSimulation(e,0);else for(;t>0&&e>0;)e-n0&&this._isImpostorInContact(s))for(var l=0,c=s._onPhysicsCollideCallbacks;l3?3:s;var l=(new this.bjsAMMO.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,n-1,s);return l.get_m_cfg().set_collisions(17),l},e.prototype._createCustom=function(e){var t=null;return this.onCreateCustomShape&&(t=this.onCreateCustomShape(e)),null==t&&(t=new this.bjsAMMO.btCompoundShape),t},e.prototype._addHullVerts=function(e,t,n){var r=this,i=0;if(n&&n.getIndices&&n.getWorldMatrix&&n.getChildMeshes){var o=n.getIndices();o||(o=[]);var a=n.getVerticesData(cs.PositionKind);a||(a=[]),n.computeWorldMatrix(!1);for(var s=o.length/3,l=0;l0){if(e.type!=Hd.NoImpostor){var l=this._createShape(e,!0);l&&(this._tmpAmmoTransform.getOrigin().setValue(0,0,0),this._tmpAmmoQuaternion.setValue(0,0,0,1),this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),r.addChildShape(this._tmpAmmoTransform,l))}return r}this.bjsAMMO.destroy(r),r=null}switch(e.type){case Hd.SphereImpostor:if(xo.WithinEpsilon(o.x,o.y,1e-4)&&xo.WithinEpsilon(o.x,o.z,1e-4))r=new this.bjsAMMO.btSphereShape(o.x/2);else{var c=[new this.bjsAMMO.btVector3(0,0,0)];(r=new this.bjsAMMO.btMultiSphereShape(c,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x/2,o.y/2,o.z/2))}break;case Hd.CapsuleImpostor:r=new this.bjsAMMO.btCapsuleShape(o.x/2,o.y/2);break;case Hd.CylinderImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),r=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case Hd.PlaneImpostor:case Hd.BoxImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),r=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case Hd.MeshImpostor:if(0==e.getParam("mass")){var u=new this.bjsAMMO.btTriangleMesh;e._pluginData.toDispose.push(u);var d=this._addMeshVerts(u,i,i);r=0==d?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(u);break}case Hd.ConvexHullImpostor:var h=new this.bjsAMMO.btConvexHullShape;0==(d=this._addHullVerts(h,i,i))?(e._pluginData.toDispose.push(h),r=new this.bjsAMMO.btCompoundShape):r=h;break;case Hd.NoImpostor:r=new this.bjsAMMO.btSphereShape(o.x/2);break;case Hd.CustomImpostor:r=this._createCustom(e);break;case Hd.SoftbodyImpostor:r=this._createSoftbody(e);break;case Hd.ClothImpostor:r=this._createCloth(e);break;case Hd.RopeImpostor:r=this._createRope(e);break;default:jo.a.Warn("The impostor type is not currently supported by the ammo plugin.")}return r},e.prototype.setTransformationFromPhysicsBody=function(e){e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.object.position.set(this._tmpAmmoTransform.getOrigin().x(),this._tmpAmmoTransform.getOrigin().y(),this._tmpAmmoTransform.getOrigin().z()),e.object.rotationQuaternion?e.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()):e.object.rotation&&(this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()),this._tmpQuaternion.toEulerAnglesToRef(e.object.rotation))},e.prototype.setPhysicsBodyTransformation=function(e,t,n){var r=e.physicsBody.getWorldTransform();if(r.getOrigin().x()!=t.x||r.getOrigin().y()!=t.y||r.getOrigin().z()!=t.z||r.getRotation().x()!=n.x||r.getRotation().y()!=n.y||r.getRotation().z()!=n.z||r.getRotation().w()!=n.w)if(this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),r.setOrigin(this._tmpAmmoVectorA),this._tmpAmmoQuaternion.setValue(n.x,n.y,n.z,n.w),r.setRotation(this._tmpAmmoQuaternion),e.physicsBody.setWorldTransform(r),0==e.mass){var i=e.physicsBody.getMotionState();i&&i.setWorldTransform(r)}else e.physicsBody.activate()},e.prototype.isSupported=function(){return void 0!==this.bjsAMMO},e.prototype.setLinearVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.soft?e.physicsBody.linearVelocity(this._tmpAmmoVectorA):e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)},e.prototype.setAngularVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.soft?e.physicsBody.angularVelocity(this._tmpAmmoVectorA):e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)},e.prototype.getLinearVelocity=function(e){if(e.soft)var t=e.physicsBody.linearVelocity();else t=e.physicsBody.getLinearVelocity();if(!t)return null;var n=new So(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),n},e.prototype.getAngularVelocity=function(e){if(e.soft)var t=e.physicsBody.angularVelocity();else t=e.physicsBody.getAngularVelocity();if(!t)return null;var n=new So(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),n},e.prototype.setBodyMass=function(e,t){e.soft?e.physicsBody.setTotalMass(t,!1):e.physicsBody.setMassProps(t),e._pluginData.mass=t},e.prototype.getBodyMass=function(e){return e._pluginData.mass||0},e.prototype.getBodyFriction=function(e){return e._pluginData.friction||0},e.prototype.setBodyFriction=function(e,t){e.soft?e.physicsBody.get_m_cfg().set_kDF(t):e.physicsBody.setFriction(t),e._pluginData.friction=t},e.prototype.getBodyRestitution=function(e){return e._pluginData.restitution||0},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.setRestitution(t),e._pluginData.restitution=t},e.prototype.getBodyPressure=function(e){return e.soft?e._pluginData.pressure||0:(jo.a.Warn("Pressure is not a property of a rigid body"),0)},e.prototype.setBodyPressure=function(e,t){e.soft?e.type===Hd.SoftbodyImpostor?(e.physicsBody.get_m_cfg().set_kPR(t),e._pluginData.pressure=t):(e.physicsBody.get_m_cfg().set_kPR(0),e._pluginData.pressure=0):jo.a.Warn("Pressure can only be applied to a softbody")},e.prototype.getBodyStiffness=function(e){return e.soft?e._pluginData.stiffness||0:(jo.a.Warn("Stiffness is not a property of a rigid body"),0)},e.prototype.setBodyStiffness=function(e,t){e.soft?(t=(t=t<0?0:t)>1?1:t,e.physicsBody.get_m_materials().at(0).set_m_kLST(t),e._pluginData.stiffness=t):jo.a.Warn("Stiffness cannot be applied to a rigid body")},e.prototype.getBodyVelocityIterations=function(e){return e.soft?e._pluginData.velocityIterations||0:(jo.a.Warn("Velocity iterations is not a property of a rigid body"),0)},e.prototype.setBodyVelocityIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_viterations(t),e._pluginData.velocityIterations=t):jo.a.Warn("Velocity iterations cannot be applied to a rigid body")},e.prototype.getBodyPositionIterations=function(e){return e.soft?e._pluginData.positionIterations||0:(jo.a.Warn("Position iterations is not a property of a rigid body"),0)},e.prototype.setBodyPositionIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_piterations(t),e._pluginData.positionIterations=t):jo.a.Warn("Position iterations cannot be applied to a rigid body")},e.prototype.appendAnchor=function(e,t,n,r,i,o){void 0===i&&(i=1),void 0===o&&(o=!1);var a=e.segments,s=Math.round((a-1)*n)+a*(a-1-Math.round((a-1)*r));e.physicsBody.appendAnchor(s,t.physicsBody,o,i)},e.prototype.appendHook=function(e,t,n,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var o=Math.round(e.segments*n);e.physicsBody.appendAnchor(o,t.physicsBody,i,r)},e.prototype.sleepBody=function(e){jo.a.Warn("sleepBody is not currently supported by the Ammo physics plugin")},e.prototype.wakeUpBody=function(e){e.physicsBody.activate()},e.prototype.updateDistanceJoint=function(e,t,n){jo.a.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")},e.prototype.setMotor=function(e,t,n,r){e.physicsJoint.enableAngularMotor(!0,t,n)},e.prototype.setLimit=function(e,t,n){jo.a.Warn("setLimit is not currently supported by the Ammo physics plugin")},e.prototype.syncMeshWithImpostor=function(e,t){t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.position.x=this._tmpAmmoTransform.getOrigin().x(),e.position.y=this._tmpAmmoTransform.getOrigin().y(),e.position.z=this._tmpAmmoTransform.getOrigin().z(),e.rotationQuaternion&&(e.rotationQuaternion.x=this._tmpAmmoTransform.getRotation().x(),e.rotationQuaternion.y=this._tmpAmmoTransform.getRotation().y(),e.rotationQuaternion.z=this._tmpAmmoTransform.getRotation().z(),e.rotationQuaternion.w=this._tmpAmmoTransform.getRotation().w())},e.prototype.getRadius=function(e){return e.getObjectExtendSize().x/2},e.prototype.getBoxSizeToRef=function(e,t){var n=e.getObjectExtendSize();t.x=n.x,t.y=n.y,t.z=n.z},e.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},e.prototype.raycast=function(e,t){this._tmpAmmoVectorRCA=new this.bjsAMMO.btVector3(e.x,e.y,e.z),this._tmpAmmoVectorRCB=new this.bjsAMMO.btVector3(t.x,t.y,t.z);var n=new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);return this.world.rayTest(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB,n),this._raycastResult.reset(e,t),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},e.DISABLE_COLLISION_FLAG=4,e.KINEMATIC_FLAG=2,e.DISABLE_DEACTIVATION_FLAG=4,e}();Ao.prototype.removeReflectionProbe=function(e){if(!this.reflectionProbes)return-1;var t=this.reflectionProbes.indexOf(e);return-1!==t&&this.reflectionProbes.splice(t,1),t},Ao.prototype.addReflectionProbe=function(e){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(e)};var lm=function(){function e(e,t,n,r,i){var o=this;void 0===r&&(r=!0),void 0===i&&(i=!1),this.name=e,this._viewMatrix=Oo.Identity(),this._target=So.Zero(),this._add=So.Zero(),this._invertYAxis=!1,this.position=So.Zero(),this._scene=n,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this),this._renderTargetTexture=new mu(e,t,n,r,!0,i?1:0,!0),this._renderTargetTexture.onBeforeRenderObservable.add((function(e){switch(e){case 0:o._add.copyFromFloats(1,0,0);break;case 1:o._add.copyFromFloats(-1,0,0);break;case 2:o._add.copyFromFloats(0,o._invertYAxis?1:-1,0);break;case 3:o._add.copyFromFloats(0,o._invertYAxis?-1:1,0);break;case 4:o._add.copyFromFloats(0,0,1);break;case 5:o._add.copyFromFloats(0,0,-1)}o._attachedMesh&&o.position.copyFrom(o._attachedMesh.getAbsolutePosition()),o.position.addToRef(o._add,o._target),Oo.LookAtLHToRef(o.position,o._target,So.Up(),o._viewMatrix),n.activeCamera&&(o._projectionMatrix=Oo.PerspectiveFovLH(Math.PI/2,1,n.activeCamera.minZ,n.activeCamera.maxZ),n.setTransformMatrix(o._viewMatrix,o._projectionMatrix)),n._forcedViewPosition=o.position})),this._renderTargetTexture.onAfterUnbindObservable.add((function(){n._forcedViewPosition=null,n.updateTransformMatrix(!0)}))}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._renderTargetTexture.samples},set:function(e){this._renderTargetTexture.samples=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},enumerable:!0,configurable:!0}),e.prototype.attachToMesh=function(e){this._attachedMesh=e},e.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderTargetTexture.setRenderingAutoClearDepthStencil(e,t)},e.prototype.dispose=function(){var e=this._scene.reflectionProbes.indexOf(this);-1!==e&&this._scene.reflectionProbes.splice(e,1),this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null)},e.prototype.toString=function(e){var t="Name: "+this.name;return e&&(t+=", position: "+this.position.toString(),this._attachedMesh&&(t+=", attached mesh: "+this._attachedMesh.name)),t},e.prototype.getClassName=function(){return"ReflectionProbe"},e.prototype.serialize=function(){var e=ya.Serialize(this,this._renderTargetTexture.serialize());return e.isReflectionProbe=!0,e},e.Parse=function(t,n,r){var i=null;if(n.reflectionProbes)for(var o=0;o0){var r=t._waitingData.lods.ids,i=n.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=r.length){var a=o.length>r.length?o[o.length-1]:0;n.setEnabled(!1);for(var s=0;s0&&n.addLODLevel(a,null),!0===i&&n.setEnabled(!0)}else Ja.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},fm=function(e,t,n,r,i){void 0===i&&(i=!1);var o=new Ml(e),a="importScene has failed JSON parse";try{var s=JSON.parse(t);a="";var l,c,u=Ph.loggingLevel===Ph.DETAILED_LOGGING;if(void 0!==s.environmentTexture&&null!==s.environmentTexture){var d=void 0===s.isPBR||s.isPBR;if(s.environmentTextureType&&"BABYLON.HDRCubeTexture"===s.environmentTextureType){var h=s.environmentTextureSize?s.environmentTextureSize:128,p=new Jf((s.environmentTexture.match(/https?:\/\//g)?"":n)+s.environmentTexture,e,h,!0,!d);s.environmentTextureRotationY&&(p.rotationY=s.environmentTextureRotationY),e.environmentTexture=p}else if(Jo.a.EndsWith(s.environmentTexture,".env")){var f=new tp((s.environmentTexture.match(/https?:\/\//g)?"":n)+s.environmentTexture,e);s.environmentTextureRotationY&&(f.rotationY=s.environmentTextureRotationY),e.environmentTexture=f}else{var m=tp.CreateFromPrefilteredData((s.environmentTexture.match(/https?:\/\//g)?"":n)+s.environmentTexture,e);s.environmentTextureRotationY&&(m.rotationY=s.environmentTextureRotationY),e.environmentTexture=m}if(!0===s.createDefaultSkybox){var g=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,b=s.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,d,g,b)}o.environmentTexture=e.environmentTexture}if(void 0!==s.environmentIntensity&&null!==s.environmentIntensity&&(e.environmentIntensity=s.environmentIntensity),void 0!==s.lights&&null!==s.lights)for(l=0,c=s.lights.length;l0){for(var q=0;q0){for(var J=0;J-1&&void 0!==c.skeletons&&null!==c.skeletons)if(!1===m.indexOf(b.skeletonId)>-1)for(var P=0,O=c.skeletons.length;P1,r.wrapU=0,r.wrapV=0,r.wrapR=0,r.anisotropicFilteringLevel=1,r._texture=r._getFromCache(t,!0),r._texture||(n.useDelayedTextureLoading?r.delayLoadState=4:r.loadTexture()),r):r}return Object(No.d)(t,e),t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype.load3dlTexture=function(){var e,n=this._engine;e=1===n.webGLVersion?n.createRawTexture(null,1,1,5,!1,!1,2,null,0):n.createRawTexture3D(null,1,1,1,5,!1,!1,2,null,0),this._texture=e;var r=function(r){if("string"==typeof r){for(var i,o=null,a=null,s=r.split("\n"),l=0,c=0,u=0,d=0,h=0,p=0;p0&&(p+1)%4==0)o[p]=255;else{var A=a[p];o[p]=A/h*255}e.is3D?(e.updateSize(l,l,l),n.updateRawTexture3D(e,o,5,!1)):(e.updateSize(l*l,l),n.updateRawTexture(e,o,5,!1))}},i=this.getScene();return i?i._loadFile(this.url,r):this._engine._loadFile(this.url,r),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());return e.level=this.level,e},t.prototype.delayLoad=function(){4===this.delayLoadState&&(this.delayLoadState=1,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},t.Parse=function(e,n){var r=null;return e.name&&!e.isRenderTarget&&((r=new t(e.name,n)).name=e.name,r.level=e.level),r},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}(Ql);Eo.RegisteredTypes["BABYLON.ColorGradingTexture"]=Am;var _m=function(e){function t(t,n,r,i,o,a,s){void 0===i&&(i=!1),void 0===o&&(o=!0),void 0===a&&(a=null),void 0===s&&(s=null);var l=e.call(this,n)||this;if(l._onLoad=null,l._onError=null,l.coordinatesMode=Wl.CUBIC_MODE,!t)throw new Error("Image url is not set");return l.name=t,l.url=t,l._size=r,l._noMipmap=i,l.gammaSpace=o,l._onLoad=a,l._onError=s,l.hasAlpha=!1,l.isCube=!0,l._texture=l._getFromCache(t,l._noMipmap),l._texture?a&&(l._texture.isReady?Ja.SetImmediate((function(){return a()})):l._texture.onLoadedObservable.add(a)):n.useDelayedTextureLoading?l.delayLoadState=4:l.loadImage(l.loadTexture.bind(l),l._onError),l}return Object(No.d)(t,e),t.prototype.loadImage=function(e,t){var n=this,r=document.createElement("canvas"),i=new Image;i.addEventListener("load",(function(){n._width=i.width,n._height=i.height,r.width=n._width,r.height=n._height;var t=r.getContext("2d");t.drawImage(i,0,0);var o=t.getImageData(0,0,i.width,i.height);n._buffer=o.data.buffer,r.remove(),e()})),i.addEventListener("error",(function(e){t&&t(n.getClassName()+" could not be loaded",e)})),i.src=this.url},t.prototype.loadTexture=function(){var e=this,n=this.getScene();n&&(this._texture=n.getEngine().createRawCubeTextureFromUrl(this.url,n,this._size,4,n.getEngine().getCaps().textureFloat?1:7,this._noMipmap,(function(){for(var n=e.getFloat32ArrayFromArrayBuffer(e._buffer),r=qf.ConvertPanoramaToCubemap(n,e._width,e._height,e._size),i=[],o=0;o<6;o++){var a=r[t._FacesMapping[o]];i.push(a)}return i}),null,this._onLoad,this._onError))},t.prototype.getFloat32ArrayFromArrayBuffer=function(e){for(var t=new DataView(e),n=new Float32Array(3*e.byteLength/4),r=0,i=0;in.length)jo.a.Error("Unable to load TGA file - Not enough data");else{r+=i.id_length;var o,a=!1,s=!1,l=!1;switch(i.image_type){case e._TYPE_RLE_INDEXED:a=!0;case e._TYPE_INDEXED:s=!0;break;case e._TYPE_RLE_RGB:a=!0;case e._TYPE_RGB:break;case e._TYPE_RLE_GREY:a=!0;case e._TYPE_GREY:l=!0}var c,u,d,h,p,f,m,g=i.pixel_size>>3,b=i.width*i.height*g;if(s&&(c=n.subarray(r,r+=i.colormap_length*(i.colormap_size>>3))),a){var v,A,_;o=new Uint8Array(b);for(var y=0,x=new Uint8Array(g);r>e._ORIGIN_SHIFT){default:case e._ORIGIN_UL:u=0,h=1,m=i.width,d=0,p=1,f=i.height;break;case e._ORIGIN_BL:u=0,h=1,m=i.width,d=i.height-1,p=-1,f=-1;break;case e._ORIGIN_UR:u=i.width-1,h=-1,m=-1,d=0,p=1,f=i.height;break;case e._ORIGIN_BR:u=i.width-1,h=-1,m=-1,d=i.height-1,p=-1,f=-1}var w=e["_getImageData"+(l?"Grey":"")+i.pixel_size+"bits"](i,c,o,d,p,f,u,h,m);t.getEngine()._uploadDataToTextureDirectly(t,w)}}},e._getImageData8bits=function(e,t,n,r,i,o,a,s,l){var c,u,d,h=n,p=t,f=e.width,m=e.height,g=0,b=new Uint8Array(f*m*4);for(d=r;d!==o;d+=i)for(u=a;u!==l;u+=s,g++)c=h[g],b[4*(u+f*d)+3]=255,b[4*(u+f*d)+2]=p[3*c+0],b[4*(u+f*d)+1]=p[3*c+1],b[4*(u+f*d)+0]=p[3*c+2];return b},e._getImageData16bits=function(e,t,n,r,i,o,a,s,l){var c,u,d,h=n,p=e.width,f=e.height,m=0,g=new Uint8Array(p*f*4);for(d=r;d!==o;d+=i)for(u=a;u!==l;u+=s,m+=2){var b=255*((31744&(c=h[m+0]+(h[m+1]<<8)))>>10)/31|0,v=255*((992&c)>>5)/31|0,A=255*(31&c)/31|0;g[4*(u+p*d)+0]=b,g[4*(u+p*d)+1]=v,g[4*(u+p*d)+2]=A,g[4*(u+p*d)+3]=32768&c?0:255}return g},e._getImageData24bits=function(e,t,n,r,i,o,a,s,l){var c,u,d=n,h=e.width,p=e.height,f=0,m=new Uint8Array(h*p*4);for(u=r;u!==o;u+=i)for(c=a;c!==l;c+=s,f+=3)m[4*(c+h*u)+3]=255,m[4*(c+h*u)+2]=d[f+0],m[4*(c+h*u)+1]=d[f+1],m[4*(c+h*u)+0]=d[f+2];return m},e._getImageData32bits=function(e,t,n,r,i,o,a,s,l){var c,u,d=n,h=e.width,p=e.height,f=0,m=new Uint8Array(h*p*4);for(u=r;u!==o;u+=i)for(c=a;c!==l;c+=s,f+=4)m[4*(c+h*u)+2]=d[f+0],m[4*(c+h*u)+1]=d[f+1],m[4*(c+h*u)+0]=d[f+2],m[4*(c+h*u)+3]=d[f+3];return m},e._getImageDataGrey8bits=function(e,t,n,r,i,o,a,s,l){var c,u,d,h=n,p=e.width,f=e.height,m=0,g=new Uint8Array(p*f*4);for(d=r;d!==o;d+=i)for(u=a;u!==l;u+=s,m++)c=h[m],g[4*(u+p*d)+0]=c,g[4*(u+p*d)+1]=c,g[4*(u+p*d)+2]=c,g[4*(u+p*d)+3]=255;return g},e._getImageDataGrey16bits=function(e,t,n,r,i,o,a,s,l){var c,u,d=n,h=e.width,p=e.height,f=0,m=new Uint8Array(h*p*4);for(u=r;u!==o;u+=i)for(c=a;c!==l;c+=s,f+=2)m[4*(c+h*u)+0]=d[f+0],m[4*(c+h*u)+1]=d[f+0],m[4*(c+h*u)+2]=d[f+0],m[4*(c+h*u)+3]=d[f+1];return m},e._TYPE_INDEXED=1,e._TYPE_RGB=2,e._TYPE_GREY=3,e._TYPE_RLE_INDEXED=9,e._TYPE_RLE_RGB=10,e._TYPE_RLE_GREY=11,e._ORIGIN_MASK=48,e._ORIGIN_SHIFT=4,e._ORIGIN_BL=0,e._ORIGIN_BR=1,e._ORIGIN_UL=2,e._ORIGIN_UR=3,e}(),xm=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return Jo.a.EndsWith(e,".tga")},e.prototype.loadCubeData=function(e,t,n,r,i){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,n){var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=ym.GetTGAHeader(r);n(i.width,i.height,t.generateMipMaps,!1,(function(){ym.UploadContent(t,r)}))},e}();ss.a._TextureLoaders.push(new xm);var wm;!function(e){e[e.cTFETC1=0]="cTFETC1",e[e.cTFBC1=1]="cTFBC1",e[e.cTFBC4=2]="cTFBC4",e[e.cTFPVRTC1_4_OPAQUE_ONLY=3]="cTFPVRTC1_4_OPAQUE_ONLY",e[e.cTFBC7_M6_OPAQUE_ONLY=4]="cTFBC7_M6_OPAQUE_ONLY",e[e.cTFETC2=5]="cTFETC2",e[e.cTFBC3=6]="cTFBC3",e[e.cTFBC5=7]="cTFBC5"}(wm||(wm={}));var Em=function(){function e(){}return e.GetInternalFormatFromBasisFormat=function(e){if(e===wm.cTFETC1)return 36196;if(e===wm.cTFBC1)return 33776;if(e===wm.cTFBC3)return 33779;throw"The chosen Basis transcoder format is not currently supported"},e._CreateWorkerAsync=function(){var t=this;return this._WorkerPromise||(this._WorkerPromise=new Promise((function(n){t._Worker?n(t._Worker):Ja.LoadFileAsync(e.WasmModuleURL).then((function(r){var i=URL.createObjectURL(new Blob(["("+Cm+")()"],{type:"application/javascript"}));t._Worker=new Worker(i);var o=function(e){"init"===e.data.action&&(t._Worker.removeEventListener("message",o),n(t._Worker))};t._Worker.addEventListener("message",o),t._Worker.postMessage({action:"init",url:e.JSModuleURL,wasmBinary:r})}))}))),this._WorkerPromise},e.TranscodeAsync=function(e,t){var n=this,r=e instanceof ArrayBuffer?new Uint8Array(e):e;return new Promise((function(e,i){n._CreateWorkerAsync().then((function(){var o=n._actionId++,a=function(t){"transcode"===t.data.action&&t.data.id===o&&(n._Worker.removeEventListener("message",a),t.data.success?e(t.data):i("Transcode is not supported on this device"))};n._Worker.addEventListener("message",a);var s=new Uint8Array(r.byteLength);s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),n._Worker.postMessage({action:"transcode",id:o,imageData:s,config:t,ignoreSupportedFormats:n._IgnoreSupportedFormats},[s.buffer])}))}))},e.LoadTextureFromTranscodeResult=function(t,n){for(var r,i=t.getEngine(),o=function(){if(r=n.fileInfo.images[a].levels[0],t._invertVScale=t.invertY,-1===n.format)if(t.type=10,t.format=4,i.webGLVersion<2&&(xo.Log2(r.width)%1!=0||xo.Log2(r.height)%1!=0)){var o=new Kl.a(i,Kl.b.Temp);t._invertVScale=t.invertY,o.type=10,o.format=4,o.width=r.width+3&-4,o.height=r.height+3&-4,i._bindTextureDirectly(i._gl.TEXTURE_2D,o,!0),i._uploadDataToTextureDirectly(o,r.transcodedPixels,a,0,4,!0),i._rescaleTexture(o,t,i.scenes[0],i._getInternalFormat(4),(function(){i._releaseTexture(o),i._bindTextureDirectly(i._gl.TEXTURE_2D,t,!0)}))}else t._invertVScale=!t.invertY,t.width=r.width+3&-4,t.height=r.height+3&-4,i._uploadDataToTextureDirectly(t,r.transcodedPixels,a,0,4,!0);else t.width=r.width,t.height=r.height,n.fileInfo.images[a].levels.forEach((function(r,o){i._uploadCompressedDataToTextureDirectly(t,e.GetInternalFormatFromBasisFormat(n.format),r.width,r.height,r.transcodedPixels,a,o)})),i.webGLVersion<2&&(xo.Log2(t.width)%1!=0||xo.Log2(t.height)%1!=0)&&(Ja.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=Wl.CLAMP_ADDRESSMODE,t._cachedWrapV=Wl.CLAMP_ADDRESSMODE)},a=0;a>2&3],o[p++]=i[h>>4&3],o[p++]=i[h>>6&3]}}return o}(a,0,e.getImageWidth(t,n)+3&-4,e.getImageHeight(t,n)+3&-4));return a}onmessage=function(a){if("init"===a.data.action)i||(Module={wasmBinary:a.data.wasmBinary},importScripts(a.data.url),i=new Promise((function(e){Module.onRuntimeInitialized=function(){Module.initializeBasis(),e()}}))),i.then((function(){postMessage({action:"init"})}));else if("transcode"===a.data.action){var s=a.data.config,l=a.data.imageData,c=new Module.BasisFile(l),u=function(e){for(var t=e.getHasAlpha(),n=e.getNumImages(),r=[],i=0;i1&&t.generateMipMaps;Em.LoadTextureFromTranscodeResult(t,e),t.getEngine()._setCubeMapTextureParams(n),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()})).catch((function(e){Ja.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),t.isReady=!0}))}},e.prototype.loadData=function(e,t,n){var r=t.getEngine().getCaps(),i={supportedCompressionFormats:{etc1:!!r.etc1,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2}};Em.TranscodeAsync(e,i).then((function(e){var r=e.fileInfo.images[0].levels[0],i=e.fileInfo.images[0].levels.length>1&&t.generateMipMaps;n(r.width,r.height,i,-1!==e.format,(function(){Em.LoadTextureFromTranscodeResult(t,e)}))})).catch((function(e){Ja.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),n(0,0,!1,!1,(function(){}))}))},e}();ss.a._TextureLoaders.push(new Sm),Va.a.prototype.unBindMultiColorAttachmentFramebuffer=function(e,t,n){void 0===t&&(t=!1),this._currentRenderTarget=null;var r=this._gl;if(e[0]._MSAAFramebuffer){r.bindFramebuffer(r.READ_FRAMEBUFFER,e[0]._MSAAFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e[0]._framebuffer);var i=e[0]._attachments;i||(i=new Array(e.length),e[0]._attachments=i);for(var o=0;o1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"],r.readBuffer(i[o]),r.drawBuffers(i),r.blitFramebuffer(0,0,a.width,a.height,0,0,a.width,a.height,r.COLOR_BUFFER_BIT,r.NEAREST)}for(o=0;o1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"];r.drawBuffers(i)}for(o=0;o1?"COLOR_ATTACHMENT"+g:"COLOR_ATTACHMENT"+g+"_WEBGL"];p.push(_),f.push(y),c.activeTexture(c["TEXTURE"+g]),c.bindTexture(c.TEXTURE_2D,_._webGLTexture),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,A.mag),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,A.min),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texImage2D(c.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(v),d,h,0,c.RGBA,this._getWebGLTextureType(v),null),c.framebufferTexture2D(c.DRAW_FRAMEBUFFER,y,c.TEXTURE_2D,_._webGLTexture,0),n&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(c.TEXTURE_2D,null),_._framebuffer=u,_._depthStencilBuffer=m,_.baseWidth=d,_.baseHeight=h,_.width=d,_.height=h,_.isReady=!0,_.samples=1,_.generateMipMaps=n,_.samplingMode=b,_.type=v,_._generateDepthBuffer=r,_._generateStencilBuffer=i,_._attachments=f,this._internalTexturesCache.push(_)}if(o&&this._caps.depthTextureExtension){var x=new Kl.a(this,Kl.b.MultiRenderTarget);c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,x._webGLTexture),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texImage2D(c.TEXTURE_2D,0,this.webGLVersion<2?c.DEPTH_COMPONENT:c.DEPTH_COMPONENT16,d,h,0,c.DEPTH_COMPONENT,c.UNSIGNED_SHORT,null),c.framebufferTexture2D(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.TEXTURE_2D,x._webGLTexture,0),x._framebuffer=u,x.baseWidth=d,x.baseHeight=h,x.width=d,x.height=h,x.isReady=!0,x.samples=1,x.generateMipMaps=n,x.samplingMode=c.NEAREST,x._generateDepthBuffer=r,x._generateStencilBuffer=i,p.push(x),this._internalTexturesCache.push(x)}return c.drawBuffers(f),this._bindUnboundFramebuffer(null),this.resetTextureCache(),p},Va.a.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e||0==e.length)return 1;if(e[0].samples===t)return t;var n=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e[0]._depthStencilBuffer&&(n.deleteRenderbuffer(e[0]._depthStencilBuffer),e[0]._depthStencilBuffer=null),e[0]._MSAAFramebuffer&&(n.deleteFramebuffer(e[0]._MSAAFramebuffer),e[0]._MSAAFramebuffer=null);for(var r=0;r1&&n.renderbufferStorageMultisample){var i=n.createFramebuffer();if(!i)throw new Error("Unable to create multi sampled framebuffer");this._bindUnboundFramebuffer(i);var o=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),a=[];for(r=0;r1?"COLOR_ATTACHMENT"+r:"COLOR_ATTACHMENT"+r+"_WEBGL"],c=n.createRenderbuffer();if(!c)throw new Error("Unable to create multi sampled framebuffer");n.bindRenderbuffer(n.RENDERBUFFER,c),n.renderbufferStorageMultisample(n.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(s.type),s.width,s.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,l,n.RENDERBUFFER,c),s._MSAAFramebuffer=i,s._MSAARenderBuffer=c,s.samples=t,s._depthStencilBuffer=o,n.bindRenderbuffer(n.RENDERBUFFER,null),a.push(l)}n.drawBuffers(a)}else this._bindUnboundFramebuffer(e[0]._framebuffer);return this._bindUnboundFramebuffer(null),t};var Tm=function(e){function t(t,n,r,i,o){var a=this,s=!(!o||!o.generateMipMaps)&&o.generateMipMaps,l=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,c=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio;if((a=e.call(this,t,n,i,s,c)||this)._engine=i.getEngine(),a.isSupported){for(var u=[],d=[],h=0;h1||this._engine.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wrapU",{set:function(e){if(this._textures)for(var t=0;t=0;e--)void 0!==this._internalTextures[e]&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},t}(mu),Pm=function(){function e(e){this.name=Gs.NAME_PROCEDURALTEXTURE,this.scene=e,this.scene.proceduralTextures=new Array}return e.prototype.register=function(){this.scene._beforeClearStage.registerStep(Gs.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){Ja.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(var e=0;e0)}},e}(),Om="\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}";Qc.a.ShadersStore.proceduralVertexShader=Om;var Rm=function(e){function t(t,n,r,i,o,a,s){void 0===o&&(o=null),void 0===a&&(a=!0),void 0===s&&(s=!1);var l=e.call(this,null,i,!a)||this;l.isCube=s,l.isEnabled=!0,l.autoClear=!0,l.onGeneratedObservable=new yo.a,l._textures={},l._currentRefreshId=-1,l._frameId=-1,l._refreshRate=1,l._vertexBuffers={},l._uniforms=new Array,l._samplers=new Array,l._floats={},l._ints={},l._floatsArrays={},l._colors3={},l._colors4={},l._vectors2={},l._vectors3={},l._matrices={},l._fallbackTextureUsed=!1,l._cachedDefines="",l._contentUpdateId=-1;var c=(i=l.getScene())._getComponent(Gs.NAME_PROCEDURALTEXTURE);c||(c=new Pm(i),i._addComponent(c)),i.proceduralTextures.push(l),l._engine=i.getEngine(),l.name=t,l.isRenderTarget=!0,l._size=n,l._generateMipMaps=a,l.setFragment(r),l._fallbackTexture=o,s?(l._texture=l._engine.createRenderTargetCubeTexture(n,{generateMipMaps:a,generateDepthBuffer:!1,generateStencilBuffer:!1}),l.setFloat("face",0)):l._texture=l._engine.createRenderTargetTexture(n,{generateMipMaps:a,generateDepthBuffer:!1,generateStencilBuffer:!1});var u=[];return u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1),l._vertexBuffers[cs.PositionKind]=new cs(l._engine,u,cs.PositionKind,!1,!1,2),l._createIndexBuffer(),l}return Object(No.d)(t,e),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._engine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},t.prototype._rebuild=function(){var e=this._vertexBuffers[cs.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===mu.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=mu.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){void 0!==this._effect&&this._effect.dispose()},t.prototype._getDefines=function(){return""},t.prototype.isReady=function(){var e,t=this,n=this._engine;if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;var r=this._getDefines();return!(!this._effect||r!==this._cachedDefines||!this._effect.isReady())||(e=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._cachedDefines=r,this._effect=n.createEffect(e,[cs.PositionKind],this._uniforms,this._samplers,r,void 0,void 0,(function(){t.releaseInternalTexture(),t._fallbackTexture&&(t._texture=t._fallbackTexture._texture,t._texture&&t._texture.incrementReferences()),t._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:!0,configurable:!0}),t.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(-1===this._currentRefreshId||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,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this._engine.createRenderTargetTexture(e,t),this._size=e,this._generateMipMaps=t)},t.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},t.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},t.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},t.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},t.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},t.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},t.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},t.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},t.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},t.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},t.prototype.render=function(e){var t=this.getScene();if(t){var n=this._engine;for(var r in n.enableEffect(this._effect),n.setState(!1),this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._ints)this._effect.setInt(r,this._ints[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var i=this._colors4[r];this._effect.setFloat4(r,i.r,i.g,i.b,i.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(this._texture){if(this.isCube)for(var o=0;o<6;o++)n.bindFramebuffer(this._texture,o,void 0,void 0,!0),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),this.autoClear&&n.clear(t.clearColor,!0,!1,!1),n.drawElementsType(Ls.TriangleFillMode,0,6),5===o&&n.generateMipMapsForCubemap(this._texture);else n.bindFramebuffer(this._texture,0,void 0,void 0,!0),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.autoClear&&n.clear(t.clearColor,!0,!1,!1),n.drawElementsType(Ls.TriangleFillMode,0,6);n.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 t=this.getScene();if(t){var n=t.proceduralTextures.indexOf(this);n>=0&&t.proceduralTextures.splice(n,1);var r=this._vertexBuffers[cs.PositionKind];r&&(r.dispose(),this._vertexBuffers[cs.PositionKind]=null),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),e.prototype.dispose.call(this)}},Object(No.c)([ha()],t.prototype,"isEnabled",void 0),Object(No.c)([ha()],t.prototype,"autoClear",void 0),Object(No.c)([ha()],t.prototype,"_generateMipMaps",void 0),Object(No.c)([ha()],t.prototype,"_size",void 0),Object(No.c)([ha()],t.prototype,"refreshRate",null),t}(Wl),Mm=(function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,r,null,i,o,a)||this;return s._animate=!0,s._time=0,s._texturePath=n,s._loadJson(n),s.refreshRate=1,s}Object(No.d)(t,e),t.prototype._loadJson=function(e){var t=this,n=function(){jo.a.Log("No config file found in "+e+" trying to use ShadersStore or DOM element");try{t.setFragment(t._texturePath)}catch(e){jo.a.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},r=e+"/config.json",i=new Fa;i.open("GET",r),i.addEventListener("load",(function(){if(200===i.status||i.responseText&&i.responseText.length>0)try{t._config=JSON.parse(i.response),t.updateShaderUniforms(),t.updateTextures(),t.setFragment(t._texturePath+"/custom"),t._animate=t._config.animate,t.refreshRate=t._config.refreshrate}catch(e){n()}else n()}),!1),i.addEventListener("error",(function(){n()}),!1);try{i.send()}catch(e){jo.a.Error("CustomProceduralTexture: Error on XHR send request.")}},t.prototype.isReady=function(){if(!e.prototype.isReady.call(this))return!1;for(var t in this._textures){if(!this._textures[t].isReady())return!1}return!0},t.prototype.render=function(t){var n=this.getScene();this._animate&&n&&(this._time+=.03*n.getAnimationRatio(),this.updateShaderUniforms()),e.prototype.render.call(this,t)},t.prototype.updateTextures=function(){for(var e=0;e0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isConnectedInVertexShader",{get:function(){if(this.target===km.Vertex)return!0;if(!this.hasEndpoints)return!1;for(var e=0,t=this._endpoints;e=this._outputs.length?null:this._outputs[t+1]},e.prototype.connectTo=function(e,t){if(0!==this._outputs.length){for(var n=t&&t.output?this.getOutputByName(t.output):this.getFirstAvailableOutput(e),r=!0;r;){var i=t&&t.input?e.getInputByName(t.input):e.getFirstAvailableInput(n);if(n&&i&&n.canConnectTo(i))n.connectTo(i),r=!1;else{if(!n)throw"Unable to find a compatible match";n=this.getSiblingOutput(n)}}return this}},e.prototype._buildBlock=function(e){},e.prototype.updateUniformsAndSamples=function(e,t,n,r){},e.prototype.provideFallbacks=function(e,t){},e.prototype.initializeDefines=function(e,t,n,r){void 0===r&&(r=!1)},e.prototype.prepareDefines=function(e,t,n,r){void 0===r&&(r=!1)},e.prototype.autoConfigure=function(e){},e.prototype.replaceRepeatableContent=function(e,t,n,r){},e.prototype.isReady=function(e,t,n,r){return void 0===r&&(r=!1),!0},e.prototype._linkConnectionTypes=function(e,t){this._inputs[e]._linkedConnectionSource=this._inputs[t],this._inputs[t]._linkedConnectionSource=this._inputs[e]},e.prototype._processBuild=function(e,t,n,r){e.build(t,r);var i=null!=t._vertexState,o=e._buildTarget===km.Vertex&&e.target!==km.VertexAndFragment;if(i&&(0==(e.target&e._buildTarget)||0==(e.target&n.target)||this.target!==km.VertexAndFragment&&o)&&(!e.isInput&&t.target!==e._buildTarget||e.isInput&&e.isAttribute)){var a=n.connectedPoint;t._vertexState._emitVaryingFromString("v_"+a.associatedVariableName,t._getGLType(a.type))&&(t._vertexState.compilationString+="v_"+a.associatedVariableName+" = "+a.associatedVariableName+";\r\n"),n.associatedVariableName="v_"+a.associatedVariableName,n._enforceAssociatedVariableName=!0}},e.prototype.build=function(e,t){if(this._buildId===e.sharedData.buildId)return!0;if(!this.isInput)for(var n=0,r=this._outputs;n[0.."+n.repeatKey+"]\r\n";var r=Qc.a.IncludesShadersStore[e]+"\r\n";if(this.sharedData.emitComments&&(r=t+"\r\n"+r),!n)return r;if(n.replaceStrings)for(var i=0;i[0.."+n.repeatKey+"]\r\n":this.functions[i]="#include<"+e+">\r\n",void(this.sharedData.emitComments&&(this.functions[i]=t+"\r\n"+this.functions[i]));if(this.functions[i]=Qc.a.IncludesShadersStore[e],this.sharedData.emitComments&&(this.functions[i]=t+"\r\n"+this.functions[i]),n.removeIfDef&&(this.functions[i]=this.functions[i].replace(/^\s*?#ifdef.+$/gm,""),this.functions[i]=this.functions[i].replace(/^\s*?#endif.*$/gm,""),this.functions[i]=this.functions[i].replace(/^\s*?#else.*$/gm,""),this.functions[i]=this.functions[i].replace(/^\s*?#elif.*$/gm,"")),n.removeAttributes&&(this.functions[i]=this.functions[i].replace(/^\s*?attribute.+$/gm,"")),n.removeUniforms&&(this.functions[i]=this.functions[i].replace(/^\s*?uniform.+$/gm,"")),n.removeVaryings&&(this.functions[i]=this.functions[i].replace(/^\s*?varying.+$/gm,"")),n.replaceStrings)for(var o=0;o-1))return this._optimizers.push(e),this},t.prototype.unregisterOptimizer=function(e){var t=this._optimizers.indexOf(e);if(-1!==t)return this._optimizers.splice(t,1),this},t.prototype.addOutputNode=function(e){if(null===e.target)throw"This node is not meant to be an output node. You may want to explicitly set its target value.";return 0!=(e.target&km.Vertex)&&this._addVertexOutputNode(e),0!=(e.target&km.Fragment)&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return null===e.target||(0!=(e.target&km.Vertex)&&this._removeVertexOutputNode(e),0!=(e.target&km.Fragment)&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(-1===this._vertexOutputNodes.indexOf(e))return e.target=km.Vertex,this._vertexOutputNodes.push(e),this},t.prototype._removeVertexOutputNode=function(e){var t=this._vertexOutputNodes.indexOf(e);if(-1!==t)return this._vertexOutputNodes.splice(t,1),this},t.prototype._addFragmentOutputNode=function(e){if(-1===this._fragmentOutputNodes.indexOf(e))return e.target=km.Fragment,this._fragmentOutputNodes.push(e),this},t.prototype._removeFragmentOutputNode=function(e){var t=this._fragmentOutputNodes.indexOf(e);if(-1!==t)return this._fragmentOutputNodes.splice(t,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,t,n){if(e.initialize(t),e.autoConfigure(this),e._preparationId=this._buildId,-1===this.attachedBlocks.indexOf(e)){if(e.isUnique)for(var r=e.getClassName(),i=0,o=this.attachedBlocks;i-1&&this.attachedBlocks.splice(t,1),e.isFinalMerger&&this.removeOutputNode(e)},t.prototype.build=function(e){void 0===e&&(e=!1),this._buildWasSuccessful=!1;var n=this.getScene().getEngine();if(0===this._vertexOutputNodes.length)throw"You must define at least one vertexOutputNode";if(0===this._fragmentOutputNodes.length)throw"You must define at least one fragmentOutputNode";this._vertexCompilationState=new jm,this._vertexCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._vertexCompilationState.target=km.Vertex,this._fragmentCompilationState=new jm,this._fragmentCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._fragmentCompilationState.target=km.Fragment,this._sharedData=new Gm,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();for(var r=[],i=[],o=0,a=this._vertexOutputNodes;o0&&Cu.BindMorphTargetParameters(n,e)},t.prototype.replaceRepeatableContent=function(e,t,n,r){for(var i=this.position,o=this.normal,a=this.tangent,s=this.uv,l=this.positionOutput,c=this.normalOutput,u=this.tangentOutput,d=this.uvOutput,h=e,p=r.NUM_MORPH_INFLUENCERS,f=n.morphTargetManager,m=f&&f.supportsNormals&&r.NORMAL,g=f&&f.supportsTangents&&r.TANGENT,b=f&&f.supportsUVs&&r.UV1,v="",A=0;A0)for(A=0;A1&&i!=e.length-1?n._getNextFrameBuffer():t,n.setViewport(),n.applyEffectWrapper(r),o&&n.engine.bindFramebuffer(o.getInternalTexture()),n.draw(),o&&n.engine.unBindFramebuffer(o.getInternalTexture())}))},e.prototype.dispose=function(){this._ringScreenBuffer&&(this._ringScreenBuffer.forEach((function(e){e.dispose()})),this._ringScreenBuffer=null);var e=this._vertexBuffers[cs.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[cs.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer)},e._DefaultOptions={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]}}(),function(){function e(e){var t,n=this;this.onApplyObservable=new yo.a;var r=e.uniformNames||[];e.vertexShader?t={fragmentSource:e.fragmentShader,vertexSource:e.vertexShader,spectorName:e.name||"effectWrapper"}:(r.push("scale"),t={fragmentSource:e.fragmentShader,vertex:"postprocess",spectorName:e.name||"effectWrapper"},this.onApplyObservable.add((function(){n.effect.setFloat2("scale",1,1)}))),this.effect=new Qc.a(t,e.attributeNames||["position"],r,e.samplerNames,e.engine)}e.prototype.dispose=function(){this.effect.dispose()}}();var tb=function(){function e(e){this._pendingActions=new Array,this._workerInfos=e.map((function(e){return{worker:e,active:!1}}))}return e.prototype.dispose=function(){for(var e=0,t=this._workerInfos;ee.EPSILON?1:0;l|=u,c.push(u)}switch(l){case 0:(So.Dot(this.normal,t.plane.normal)>0?n:r).push(t);break;case 1:i.push(t);break;case 2:o.push(t);break;case 3:var d,h=[],p=[];for(a=0;a=3&&(d=new cb(h,t.shared)).plane&&i.push(d),p.length>=3&&(d=new cb(p,t.shared)).plane&&o.push(d)}},e.EPSILON=1e-5,e}(),cb=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=lb.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map((function(e){return e.clone()})),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map((function(e){e.flip()})),this.plane.flip()},e}(),ub=function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=new Array,e&&this.build(e)}return e.prototype.clone=function(){var t=new e;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},e.prototype.invert=function(){for(var e=0;e1)?1:e.arc||1,l=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE;t.push(0,0,0),i.push(.5,.5);for(var c=2*Math.PI*s,u=c/a,d=0;dt.x&&(t.x=n.x),n.yt.y&&(t.y=n.y)})),{min:e,max:t,width:t.x-e.x,height:t.y-e.y}},e}(),gb=(function(){function e(){}e.Rectangle=function(e,t,n,r){return[new Co(e,t),new Co(n,t),new Co(n,r),new Co(e,r)]},e.Circle=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=32);for(var i=new Array,o=0,a=2*Math.PI/r,s=0;s0){var u=i.length/3;this._points.elements.forEach((function(t){r.push(0,-1,0),i.push(t.x,-e,t.y),o.push(1-(t.x-a.min.x)/a.width,1-(t.y-a.min.y)/a.height)}));var d=s.length;for(c=0;co.elements.length-1?o.elements[0]:o.elements[u+1],e.push(h.x,0,h.y),e.push(h.x,-a,h.y),e.push(d.x,0,d.y),e.push(d.x,-a,d.y);var p=new So(h.x,0,h.y),f=new So(d.x,0,d.y).subtract(p),m=new So(0,1,0),g=So.Cross(f,m);g=g.normalize(),n.push(c/i.width,0),n.push(c/i.width,1),c+=f.length(),n.push(c/i.width,0),n.push(c/i.width,1),s?(t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),r.push(l),r.push(l+2),r.push(l+1),r.push(l+1),r.push(l+2),r.push(l+3)):(t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),r.push(l),r.push(l+1),r.push(l+2),r.push(l+1),r.push(l+3),r.push(l+2)),l+=4}},e}());us.CreatePolygon=function(e,t,n,r,i,o){for(var a=n||new Array(3),s=r,l=[],c=0;c<3;c++)void 0===a[c]&&(a[c]=new To(0,0,1,1)),s&&void 0===s[c]&&(s[c]=new ko(1,1,1,1));for(var u=e.getVerticesData(cs.PositionKind),d=e.getVerticesData(cs.NormalKind),h=e.getVerticesData(cs.UVKind),p=e.getIndices(),f=0,m=0,g=0;g1?1:t.arc:1,o=void 0===t.closed||t.closed,a=t.shape,s=t.radius||1,l=t.tessellation||64,c=t.clip||0,u=t.updatable,d=Pl._GetDefaultSideOrientation(t.sideOrientation),h=t.cap||Pl.NO_CAP,p=2*Math.PI,f=new Array,m=t.invertUV||!1,g=0,b=0,v=p/l*i,A=new Array;for(g=0;g<=l-c;g++){A=[];for(h!=Pl.CAP_START&&h!=Pl.CAP_ALL||(A.push(new So(0,a[0].y,0)),A.push(new So(Math.cos(g*v)*a[0].x*s,a[0].y,Math.sin(g*v)*a[0].x*s))),b=0;b0||d>0){g=-h,b=-p;v=h,A=p;switch(i){case Pl.CENTER:g-=l/=2,v+=l;break;case Pl.LEFT:v+=l,f=-l/2;break;case Pl.RIGHT:g-=l,f=l/2}switch(o){case Pl.CENTER:b-=d/=2,A+=d;break;case Pl.BOTTOM:A+=d,m=-d/2;break;case Pl.TOP:b-=d,m=d/2}}var _=[],y=[],x=[];x[0]=[0,0,1,0,1,1,0,1],x[1]=[0,0,1,0,1,1,0,1],t!==Pl.ROTATE_TILE&&t!==Pl.ROTATE_ROW||(x[1]=[1,1,0,1,0,0,1,0]),t!==Pl.FLIP_TILE&&t!==Pl.FLIP_ROW||(x[1]=[1,0,0,0,0,1,1,1]),t!==Pl.FLIP_N_ROTATE_TILE&&t!==Pl.FLIP_N_ROTATE_ROW||(x[1]=[0,1,1,1,1,0,0,0]);for(var w=[],E=[],C=[],S=0,T=0;T0||d>0){var O,R,M,I,k=d>0&&(o===Pl.CENTER||o===Pl.TOP),D=d>0&&(o===Pl.CENTER||o===Pl.BOTTOM),B=l>0&&(i===Pl.CENTER||i===Pl.RIGHT),F=l>0&&(i===Pl.CENTER||i===Pl.LEFT),N=[];if(k&&B&&(_.push(g+f,b+m,0),_.push(-h+f,b+m,0),_.push(-h+f,b+d+m,0),_.push(g+f,b+d+m,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,N=[O=1-l/n,R=1-d/r,M=1,R,M,I=1,O,I],t===Pl.ROTATE_ROW&&(N=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),t===Pl.FLIP_ROW&&(N=[1-O,R,1-M,R,1-M,I,1-O,I]),t===Pl.FLIP_N_ROTATE_ROW&&(N=[O,1-R,M,1-R,M,1-I,O,1-I]),w=w.concat(N),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),y.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),k&&F&&(_.push(h+f,b+m,0),_.push(v+f,b+m,0),_.push(v+f,b+d+m,0),_.push(h+f,b+d+m,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,N=[O=0,R=1-d/r,M=l/n,R,M,I=1,O,I],(t===Pl.ROTATE_ROW||t===Pl.ROTATE_TILE&&s%2==0)&&(N=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),(t===Pl.FLIP_ROW||t===Pl.FLIP_TILE&&s%2==0)&&(N=[1-O,R,1-M,R,1-M,I,1-O,I]),(t===Pl.FLIP_N_ROTATE_ROW||t===Pl.FLIP_N_ROTATE_TILE&&s%2==0)&&(N=[O,1-R,M,1-R,M,1-I,O,1-I]),w=w.concat(N),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),y.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),D&&B&&(_.push(g+f,p+m,0),_.push(-h+f,p+m,0),_.push(-h+f,A+m,0),_.push(g+f,A+m,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,N=[O=1-l/n,R=0,M=1,R,M,I=d/r,O,I],(t===Pl.ROTATE_ROW&&u%2==1||t===Pl.ROTATE_TILE&&u%1==0)&&(N=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),(t===Pl.FLIP_ROW&&u%2==1||t===Pl.FLIP_TILE&&u%2==0)&&(N=[1-O,R,1-M,R,1-M,I,1-O,I]),(t===Pl.FLIP_N_ROTATE_ROW&&u%2==1||t===Pl.FLIP_N_ROTATE_TILE&&u%2==0)&&(N=[O,1-R,M,1-R,M,1-I,O,1-I]),w=w.concat(N),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),y.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),D&&F&&(_.push(h+f,p+m,0),_.push(v+f,p+m,0),_.push(v+f,A+m,0),_.push(h+f,A+m,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,N=[O=0,R=0,M=l/n,R,M,I=d/r,O,I],(t===Pl.ROTATE_ROW&&u%2==1||t===Pl.ROTATE_TILE&&(u+s)%2==1)&&(N=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),(t===Pl.FLIP_ROW&&u%2==1||t===Pl.FLIP_TILE&&(u+s)%2==1)&&(N=[1-O,R,1-M,R,1-M,I,1-O,I]),(t===Pl.FLIP_N_ROTATE_ROW&&u%2==1||t===Pl.FLIP_N_ROTATE_TILE&&(u+s)%2==1)&&(N=[O,1-R,M,1-R,M,1-I,O,1-I]),w=w.concat(N),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),y.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),k){var L=[];O=0,R=1-d/r,M=1,I=1,L[0]=[O,R,M,R,M,I,O,I],L[1]=[O,R,M,R,M,I,O,I],t!==Pl.ROTATE_TILE&&t!==Pl.ROTATE_ROW||(L[1]=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),t!==Pl.FLIP_TILE&&t!==Pl.FLIP_ROW||(L[1]=[1-O,R,1-M,R,1-M,I,1-O,I]),t!==Pl.FLIP_N_ROTATE_TILE&&t!==Pl.FLIP_N_ROTATE_ROW||(L[1]=[O,1-R,M,1-R,M,1-I,O,1-I]);for(P=0;P1)?1:t.arc||1;var h,p,f=function(e,t,n,r,i,o,a,s){for(var l,c,u,d,h=t.getTangents(),p=t.getNormals(),f=t.getDistances(),m=2*Math.PI/i*s,g=o||function(){return r},b=Mo.Matrix[0],v=a===Pl.NO_CAP||a===Pl.CAP_END?0:2,A=0;A3?0:l,t.arc);var b=om.CreateRibbon(e,{pathArray:p,closePath:!0,closeArray:!1,updatable:u,sideOrientation:d,invertUV:c,frontUVs:t.frontUVs,backUVs:t.backUVs},n);return b._creationDataStorage.pathArray=p,b._creationDataStorage.path3D=h,b._creationDataStorage.tessellation=a,b._creationDataStorage.cap=l,b._creationDataStorage.arc=t.arc,b._creationDataStorage.radius=o,b},e}();us.CreateIcoSphere=function(e){var t,n=e.sideOrientation||us.DEFAULTSIDE,r=e.radius||1,i=void 0===e.flat||e.flat,o=e.subdivisions||4,a=e.radiusX||r,s=e.radiusY||r,l=e.radiusZ||r,c=(1+Math.sqrt(5))/2,u=[-1,c,-0,1,c,0,-1,-c,0,1,-c,0,0,-1,-c,0,1,-c,0,-1,c,0,1,c,c,0,1,c,0,-1,-c,0,1,-c,0,-1],d=[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],h=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],p=[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],m=new Array,g=new Array,b=new Array,v=new Array,A=0,_=new Array(3),y=new Array(3);for(t=0;t<3;t++)_[t]=So.Zero(),y[t]=Co.Zero();for(var x=0;x<20;x++){for(t=0;t<3;t++){var w=d[3*x+t];_[t].copyFromFloats(u[3*h[w]],u[3*h[w]+1],u[3*h[w]+2]),_[t].normalize().scaleInPlace(r),y[t].copyFromFloats(p[2*w]*(138/1024)+60/1024+f[x]*(-40/1024),p[2*w+1]*(239/1024)+26/1024+f[x]*(20/1024))}for(var E=function(e,t,n,r){var c,u=So.Lerp(_[0],_[2],t/o),d=So.Lerp(_[1],_[2],t/o),h=o===t?_[2]:So.Lerp(u,d,e/(o-t));if(h.normalize(),i){var p=So.Lerp(_[0],_[2],r/o),f=So.Lerp(_[1],_[2],r/o);c=So.Lerp(p,f,n/(o-r))}else c=new So(h.x,h.y,h.z);c.x/=a,c.y/=s,c.z/=l,c.normalize();var x=Co.Lerp(y[0],y[2],t/o),w=Co.Lerp(y[1],y[2],t/o),E=o===t?y[2]:Co.Lerp(x,w,e/(o-t));g.push(h.x*a,h.y*s,h.z*l),b.push(c.x,c.y,c.z),v.push(E.x,E.y),m.push(A),A++},C=0;C0)?1:0)+((s=So.Dot(e[o+1].position,t)-n>0)?1:0)+((c=So.Dot(e[o+2].position,t)-n>0)?1:0)){case 0:i.push(e[o]),i.push(e[o+1]),i.push(e[o+2]);break;case 1:if(a&&(u=e[o+1],d=e[o+2],h=r(e[o],u),p=r(e[o],d)),s){u=e[o],d=e[o+2],h=r(e[o+1],u),p=r(e[o+1],d),i.push(h),i.push(d.clone()),i.push(u.clone()),i.push(d.clone()),i.push(h.clone()),i.push(p);break}c&&(u=e[o],d=e[o+1],h=r(e[o+2],u),p=r(e[o+2],d)),u&&d&&h&&p&&(i.push(u.clone()),i.push(d.clone()),i.push(h),i.push(p),i.push(h.clone()),i.push(d.clone()));break;case 2:a||(d=r(u=e[o].clone(),e[o+1]),h=r(u,e[o+2]),i.push(u),i.push(d),i.push(h)),s||(d=r(u=e[o+1].clone(),e[o+2]),h=r(u,e[o]),i.push(u),i.push(d),i.push(h)),c||(d=r(u=e[o+2].clone(),e[o]),h=r(u,e[o+1]),i.push(u),i.push(d),i.push(h))}}return i},w=0;ws||n.deleted||n.isDirty))for(var i=0;i<3;++i)if(n.error[i]>0,(function(e){if(i){var t=e+a.verticesStart,o=So.FromArray(i,3*t),l=function(e){if(n)for(var t=0;t0&&this._reconstructedMesh.setVerticesData(cs.UVKind,s),l.length>0&&this._reconstructedMesh.setVerticesData(cs.ColorKind,l);var A=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],g.forEach((function(e){Ns.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),Ns.AddToMesh(A.materialIndex,m,h,f,3*i.length,this._reconstructedMesh))},e.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new Pl(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},e.prototype.isFlipped=function(e,t,n,r,i){for(var o=0;o.999)return!0;var h=So.Cross(u,d).normalize();if(r[o]=!1,So.Dot(h,a.normal)<.2)return!0}else r[o]=!0,i.push(a)}}return!1},e.prototype.updateTriangles=function(e,t,n,r){for(var i=r,o=0;o-1&&(this.agents.splice(t,1),this.transforms.splice(t,1))},e.prototype.getAgents=function(){return this.agents},e.prototype.update=function(e){this.recastCrowd.update(e);for(var t=0;t=400&&o?o(c):n()}),!1),c.addEventListener("error",(function(){jo.a.Error("error on XHR request."),n()}),!1),c.send()}else jo.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),n()},e._ValidateXHRData=function(e,t){void 0===t&&(t=7);try{if(1&t){if(e.responseText&&e.responseText.length>0)return!0;if(1===t)return!1}if(2&t){var n=ym.GetTGAHeader(e.response);if(n.width&&n.height&&n.width>0&&n.height>0)return!0;if(2===t)return!1}if(4&t){var r=new Uint8Array(e.response,0,3);return 68===r[0]&&68===r[1]&&83===r[2]}}catch(e){}return!1},e.IsUASupportingBlobStorage=!0,e.IDBStorageEnabled=!1,e._ParseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),n=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(n,0))},e._ReturnFullUrlLocation=function(t){return-1===t.indexOf("http:/")&&-1===t.indexOf("https:/")?e._ParseURL(window.location.href)+t:t},e}(),Bb=function(){function e(){this.direction1=new So(0,1,0),this.direction2=new So(0,1,0),this.minEmitBox=new So(-.5,-.5,-.5),this.maxEmitBox=new So(.5,.5,.5)}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=xo.RandomRange(this.direction1.x,this.direction2.x),o=xo.RandomRange(this.direction1.y,this.direction2.y),a=xo.RandomRange(this.direction1.z,this.direction2.z);if(r)return t.x=i,t.y=o,void(t.z=a);So.TransformNormalFromFloatsToRef(i,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=xo.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),o=xo.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),a=xo.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);if(r)return t.x=i,t.y=o,void(t.z=a);So.TransformCoordinatesFromFloatsToRef(i,o,a,e,t)},e.prototype.clone=function(){var t=new e;return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2),e.setVector3("minEmitBox",this.minEmitBox),e.setVector3("maxEmitBox",this.maxEmitBox)},e.prototype.getEffectDefines=function(){return"#define BOXEMITTER"},e.prototype.getClassName=function(){return"BoxParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e.minEmitBox=this.minEmitBox.asArray(),e.maxEmitBox=this.maxEmitBox.asArray(),e},e.prototype.parse=function(e){So.FromArrayToRef(e.direction1,0,this.direction1),So.FromArrayToRef(e.direction2,0,this.direction2),So.FromArrayToRef(e.minEmitBox,0,this.minEmitBox),So.FromArrayToRef(e.maxEmitBox,0,this.maxEmitBox)},e}(),Fb=function(){function e(e,t,n){void 0===e&&(e=1),void 0===t&&(t=Math.PI),void 0===n&&(n=0),this.directionRandomizer=n,this.radiusRange=1,this.heightRange=1,this.emitFromSpawnPointOnly=!1,this.angle=t,this.radius=e}return Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._buildHeight()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._buildHeight()},enumerable:!0,configurable:!0}),e.prototype._buildHeight=function(){0!==this._angle?this._height=this._radius/Math.tan(this._angle/2):this._height=1},e.prototype.startDirectionFunction=function(e,t,n,r){if(1===Math.abs(Math.cos(this._angle))){if(r)return t.x=0,t.y=1,void(t.z=0);So.TransformNormalFromFloatsToRef(0,1,0,e,t)}else{var i=n.position.subtract(e.getTranslation()).normalize(),o=xo.RandomRange(0,this.directionRandomizer),a=xo.RandomRange(0,this.directionRandomizer),s=xo.RandomRange(0,this.directionRandomizer);if(i.x+=o,i.y+=a,i.z+=s,i.normalize(),r)return void t.copyFrom(i);So.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)}},e.prototype.startPositionFunction=function(e,t,n,r){var i,o=xo.RandomRange(0,2*Math.PI);i=this.emitFromSpawnPointOnly?1e-4:1-(i=xo.RandomRange(0,this.heightRange))*i;var a=this._radius-xo.RandomRange(0,this._radius*this.radiusRange),s=(a*=i)*Math.sin(o),l=a*Math.cos(o),c=i*this._height;if(r)return t.x=s,t.y=c,void(t.z=l);So.TransformCoordinatesFromFloatsToRef(s,c,l,e,t)},e.prototype.clone=function(){var t=new e(this._radius,this._angle,this.directionRandomizer);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat2("radius",this._radius,this.radiusRange),e.setFloat("coneAngle",this._angle),e.setFloat2("height",this._height,this.heightRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){var e="#define CONEEMITTER";return this.emitFromSpawnPointOnly&&(e+="\n#define CONEEMITTERSPAWNPOINT"),e},e.prototype.getClassName=function(){return"ConeParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this._radius,e.angle=this._angle,e.directionRandomizer=this.directionRandomizer,e.radiusRange=this.radiusRange,e.heightRange=this.heightRange,e.emitFromSpawnPointOnly=this.emitFromSpawnPointOnly,e},e.prototype.parse=function(e){this.radius=e.radius,this.angle=e.angle,this.directionRandomizer=e.directionRandomizer,this.radiusRange=e.radiusRange,this.heightRange=e.heightRange,this.emitFromSpawnPointOnly=e.emitFromSpawnPointOnly},e}(),Nb=function(){function e(e,t,n,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=0),this.radius=e,this.height=t,this.radiusRange=n,this.directionRandomizer=r}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=n.position.subtract(e.getTranslation()).normalize(),o=xo.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),a=Math.atan2(i.x,i.z);a+=xo.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,i.y=o,i.x=Math.sin(a),i.z=Math.cos(a),i.normalize(),r?t.copyFrom(i):So.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=xo.RandomRange(-this.height/2,this.height/2),o=xo.RandomRange(0,2*Math.PI),a=xo.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),s=Math.sqrt(a)*this.radius,l=s*Math.cos(o),c=s*Math.sin(o);r?t.copyFromFloats(l,i,c):So.TransformCoordinatesFromFloatsToRef(l,i,c,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER"},e.prototype.getClassName=function(){return"CylinderParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.height=this.height,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.height=e.height,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Lb=function(e){function t(t,n,r,i,o){void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=new So(0,1,0)),void 0===o&&(o=new So(0,1,0));var a=e.call(this,t,n,r)||this;return a.direction1=i,a.direction2=o,a}return Object(No.d)(t,e),t.prototype.startDirectionFunction=function(e,t,n){var r=xo.RandomRange(this.direction1.x,this.direction2.x),i=xo.RandomRange(this.direction1.y,this.direction2.y),o=xo.RandomRange(this.direction1.z,this.direction2.z);So.TransformNormalFromFloatsToRef(r,i,o,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return ea.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\n#define DIRECTEDCYLINDEREMITTER"},t.prototype.getClassName=function(){return"CylinderDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(Nb),Ub=function(){function e(e,t,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=n}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=n.position.subtract(e.getTranslation()).normalize(),o=xo.RandomRange(0,this.directionRandomizer),a=xo.RandomRange(0,this.directionRandomizer),s=xo.RandomRange(0,this.directionRandomizer);i.x+=o,i.y+=a,i.z+=s,i.normalize(),r?t.copyFrom(i):So.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=this.radius-xo.RandomRange(0,this.radius*this.radiusRange),o=xo.RandomRange(0,1),a=xo.RandomRange(0,2*Math.PI),s=Math.acos(2*o-1),l=i*Math.cos(a)*Math.sin(s),c=i*Math.cos(s),u=i*Math.sin(a)*Math.sin(s);r?t.copyFromFloats(l,Math.abs(c),u):So.TransformCoordinatesFromFloatsToRef(l,Math.abs(c),u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define HEMISPHERICEMITTER"},e.prototype.getClassName=function(){return"HemisphericParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Vb=function(){function e(){this.direction1=new So(0,1,0),this.direction2=new So(0,1,0)}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=xo.RandomRange(this.direction1.x,this.direction2.x),o=xo.RandomRange(this.direction1.y,this.direction2.y),a=xo.RandomRange(this.direction1.z,this.direction2.z);r?t.copyFromFloats(i,o,a):So.TransformNormalFromFloatsToRef(i,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){r?t.copyFromFloats(0,0,0):So.TransformCoordinatesFromFloatsToRef(0,0,0,e,t)},e.prototype.clone=function(){var t=new e;return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},e.prototype.getEffectDefines=function(){return"#define POINTEMITTER"},e.prototype.getClassName=function(){return"PointParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},e.prototype.parse=function(e){So.FromArrayToRef(e.direction1,0,this.direction1),So.FromArrayToRef(e.direction2,0,this.direction2)},e}(),zb=function(){function e(e,t,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=n}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=n.position.subtract(e.getTranslation()).normalize(),o=xo.RandomRange(0,this.directionRandomizer),a=xo.RandomRange(0,this.directionRandomizer),s=xo.RandomRange(0,this.directionRandomizer);i.x+=o,i.y+=a,i.z+=s,i.normalize(),r?t.copyFrom(i):So.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=this.radius-xo.RandomRange(0,this.radius*this.radiusRange),o=xo.RandomRange(0,1),a=xo.RandomRange(0,2*Math.PI),s=Math.acos(2*o-1),l=i*Math.cos(a)*Math.sin(s),c=i*Math.cos(s),u=i*Math.sin(a)*Math.sin(s);r?t.copyFromFloats(l,c,u):So.TransformCoordinatesFromFloatsToRef(l,c,u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER"},e.prototype.getClassName=function(){return"SphereParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),jb=function(e){function t(t,n,r){void 0===t&&(t=1),void 0===n&&(n=new So(0,1,0)),void 0===r&&(r=new So(0,1,0));var i=e.call(this,t)||this;return i.direction1=n,i.direction2=r,i}return Object(No.d)(t,e),t.prototype.startDirectionFunction=function(e,t,n){var r=xo.RandomRange(this.direction1.x,this.direction2.x),i=xo.RandomRange(this.direction1.y,this.direction2.y),o=xo.RandomRange(this.direction1.z,this.direction2.z);So.TransformNormalFromFloatsToRef(r,i,o,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return ea.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\n#define DIRECTEDSPHEREEMITTER"},t.prototype.getClassName=function(){return"SphereDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(zb),Gb=function(){function e(){this.particlePositionGenerator=function(){},this.particleDestinationGenerator=function(){}}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=Mo.Vector3[0];if(this.particleDestinationGenerator){this.particleDestinationGenerator(-1,n,i);var o=Mo.Vector3[1];i.subtractToRef(n.position,o),o.scaleToRef(1/n.lifeTime,i)}else i.set(0,0,0);r?t.copyFrom(i):So.TransformNormalToRef(i,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=Mo.Vector3[0];this.particlePositionGenerator?this.particlePositionGenerator(-1,n,i):i.set(0,0,0),r?t.copyFrom(i):So.TransformCoordinatesToRef(i,e,t)},e.prototype.clone=function(){var t=new e;return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){},e.prototype.getEffectDefines=function(){return"#define CUSTOMEMITTER"},e.prototype.getClassName=function(){return"CustomParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e},e.prototype.parse=function(e){},e}(),Hb=(function(){function e(e){this.mesh=e,this._indices=null,this._positions=null,this._normals=null,this._storedNormal=So.Zero(),this.direction1=new So(0,1,0),this.direction2=new So(0,1,0),this.useMeshNormalsForDirection=!0,e&&(this._indices=e.getIndices(),this._positions=e.getVerticesData(cs.PositionKind),this._normals=e.getVerticesData(cs.NormalKind))}e.prototype.startDirectionFunction=function(e,t,n,r){if(this.useMeshNormalsForDirection&&this._normals)So.TransformNormalToRef(this._storedNormal,e,t);else{var i=xo.RandomRange(this.direction1.x,this.direction2.x),o=xo.RandomRange(this.direction1.y,this.direction2.y),a=xo.RandomRange(this.direction1.z,this.direction2.z);r?t.copyFromFloats(i,o,a):So.TransformNormalFromFloatsToRef(i,o,a,e,t)}},e.prototype.startPositionFunction=function(e,t,n,r){if(this._indices&&this._positions){var i=3*Math.random()*(this._indices.length/3)|0,o=Math.random(),a=Math.random()*(1-o),s=1-o-a,l=this._indices[i],c=this._indices[i+1],u=this._indices[i+2],d=Mo.Vector3[0],h=Mo.Vector3[1],p=Mo.Vector3[2],f=Mo.Vector3[3];So.FromArrayToRef(this._positions,3*l,d),So.FromArrayToRef(this._positions,3*c,h),So.FromArrayToRef(this._positions,3*u,p),f.x=o*d.x+a*h.x+s*p.x,f.y=o*d.y+a*h.y+s*p.y,f.z=o*d.z+a*h.z+s*p.z,r?t.copyFromFloats(f.x,f.y,f.z):So.TransformCoordinatesFromFloatsToRef(f.x,f.y,f.z,e,t),this.useMeshNormalsForDirection&&this._normals&&(So.FromArrayToRef(this._normals,3*l,d),So.FromArrayToRef(this._normals,3*c,h),So.FromArrayToRef(this._normals,3*u,p),this._storedNormal.x=o*d.x+a*h.x+s*p.x,this._storedNormal.y=o*d.y+a*h.y+s*p.y,this._storedNormal.z=o*d.z+a*h.z+s*p.z)}},e.prototype.clone=function(){var t=new e(this.mesh);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},e.prototype.getEffectDefines=function(){return""},e.prototype.getClassName=function(){return"MeshParticleEmitter"},e.prototype.serialize=function(){var e,t={};return t.type=this.getClassName(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.meshId=null===(e=this.mesh)||void 0===e?void 0:e.id,t.useMeshNormalsForDirection=this.useMeshNormalsForDirection,t},e.prototype.parse=function(e,t){So.FromArrayToRef(e.direction1,0,this.direction1),So.FromArrayToRef(e.direction2,0,this.direction2),e.meshId&&(this.mesh=t.getLastMeshByID(e.meshId)||void 0),this.useMeshNormalsForDirection=e.useMeshNormalsForDirection}}(),function(){function e(t){this.animations=[],this.renderingGroupId=0,this.emitter=So.Zero(),this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.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 So(10,10,10),this.onAnimationEnd=null,this.blendMode=e.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 Co(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.worldOffset=new So(0,0,0),this.gravity=So.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=.4,this.color1=new ko(1,1,1,1),this.color2=new ko(1,1,1,1),this.colorDead=new ko(0,0,0,1),this.textureMask=new ko(1,1,1,1),this._isSubEmitter=!1,this.billboardMode=7,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new Rs,this.id=t,this.name=t}return Object.defineProperty(e.prototype,"noiseTexture",{get:function(){return this._noiseTexture},set:function(e){this._noiseTexture!==e&&(this._noiseTexture=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},set:function(e){this._isAnimationSheetEnabled!=e&&(this._isAnimationSheetEnabled=e,this._reset())},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype._hasTargetStopDurationDependantGradient=function(){return this._startSizeGradients&&this._startSizeGradients.length>0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},e.prototype.getDragGradients=function(){return this._dragGradients},e.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},e.prototype.getColorGradients=function(){return this._colorGradients},e.prototype.getSizeGradients=function(){return this._sizeGradients},e.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},e.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},e.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},e.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},e.prototype.getVelocityGradients=function(){return this._velocityGradients},e.prototype.getStartSizeGradients=function(){return this._startSizeGradients},e.prototype.getEmitRateGradients=function(){return this._emitRateGradients},Object.defineProperty(e.prototype,"direction1",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:So.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:So.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:So.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:So.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration=e||this._scene.imageProcessingConfiguration)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,n){if(!t)return this;for(var r=0,i=0,o=t;i=i.gradient&&e<=o.gradient)return void n(i,o,(e-i.gradient)/(o.gradient-i.gradient))}var a=t.length-1;n(t[a],t[a],1)},e}(),Yb=function(){function e(t){this.particleSystem=t,this.position=So.Zero(),this.direction=So.Zero(),this.color=new ko(0,0,0,0),this.colorStep=new ko(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new Co(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new ko(0,0,0,0),this._currentColor2=new ko(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=e._Count++,this.particleSystem.isAnimationSheetEnabled&&this.updateCellInfoFromSystem()}return e.prototype.updateCellInfoFromSystem=function(){this.cellIndex=this.particleSystem.startSpriteCellID},e.prototype.updateCellIndex=function(){var e=this.age,t=this.particleSystem.spriteCellChangeSpeed;this.particleSystem.spriteRandomStartCell&&(void 0===this._randomCellOffset&&(this._randomCellOffset=Math.random()*this.lifeTime),0===t?(t=1,e=this._randomCellOffset):e+=this._randomCellOffset);var n=this._initialEndSpriteCellID-this._initialStartSpriteCellID,r=xo.Clamp(e*t%this.lifeTime/this.lifeTime);this.cellIndex=this._initialStartSpriteCellID+r*n|0},e.prototype._inheritParticleInfoToSubEmitter=function(e){if(e.particleSystem.emitter.position){var t=e.particleSystem.emitter;t.position.copyFrom(this.position),e.inheritDirection&&t.setDirection(this.direction.normalize(),0,Math.PI/2)}else{e.particleSystem.emitter.copyFrom(this.position)}this.direction.scaleToRef(e.inheritedVelocityAmount/2,Mo.Vector3[0]),e.particleSystem._inheritedVelocityOffset.copyFrom(Mo.Vector3[0])},e.prototype._inheritParticleInfoToSubEmitters=function(){var e=this;this._attachedSubEmitters&&this._attachedSubEmitters.length>0&&this._attachedSubEmitters.forEach((function(t){e._inheritParticleInfoToSubEmitter(t)}))},e.prototype._reset=function(){this.age=0,this.id=e._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},e.prototype.copyTo=function(e){e.position.copyFrom(this.position),this._initialDirection?e._initialDirection?e._initialDirection.copyFrom(this._initialDirection):e._initialDirection=this._initialDirection.clone():e._initialDirection=null,e.direction.copyFrom(this.direction),this._localPosition&&(e._localPosition?e._localPosition.copyFrom(this._localPosition):e._localPosition=this._localPosition.clone()),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e._randomCellOffset=this._randomCellOffset,e.size=this.size,e.scale.copyFrom(this.scale),e.angle=this.angle,e.angularSpeed=this.angularSpeed,e.particleSystem=this.particleSystem,e.cellIndex=this.cellIndex,e.id=this.id,e._attachedSubEmitters=this._attachedSubEmitters,this._currentColorGradient&&(e._currentColorGradient=this._currentColorGradient,e._currentColor1.copyFrom(this._currentColor1),e._currentColor2.copyFrom(this._currentColor2)),this._currentSizeGradient&&(e._currentSizeGradient=this._currentSizeGradient,e._currentSize1=this._currentSize1,e._currentSize2=this._currentSize2),this._currentAngularSpeedGradient&&(e._currentAngularSpeedGradient=this._currentAngularSpeedGradient,e._currentAngularSpeed1=this._currentAngularSpeed1,e._currentAngularSpeed2=this._currentAngularSpeed2),this._currentVelocityGradient&&(e._currentVelocityGradient=this._currentVelocityGradient,e._currentVelocity1=this._currentVelocity1,e._currentVelocity2=this._currentVelocity2),this._currentLimitVelocityGradient&&(e._currentLimitVelocityGradient=this._currentLimitVelocityGradient,e._currentLimitVelocity1=this._currentLimitVelocity1,e._currentLimitVelocity2=this._currentLimitVelocity2),this._currentDragGradient&&(e._currentDragGradient=this._currentDragGradient,e._currentDrag1=this._currentDrag1,e._currentDrag2=this._currentDrag2),this.particleSystem.isAnimationSheetEnabled&&(e._initialStartSpriteCellID=this._initialStartSpriteCellID,e._initialEndSpriteCellID=this._initialEndSpriteCellID),this.particleSystem.useRampGradients&&e.remapData.copyFrom(this.remapData),this._randomNoiseCoordinates1&&(e._randomNoiseCoordinates1?(e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)):(e._randomNoiseCoordinates1=this._randomNoiseCoordinates1.clone(),e._randomNoiseCoordinates2=this._randomNoiseCoordinates2.clone()))},e._Count=0,e}();!function(e){e[e.ATTACHED=0]="ATTACHED",e[e.END=1]="END"}(kb||(kb={}));var qb=function(){function e(e){this.particleSystem=e,this.type=kb.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,e.emitter&&e.emitter.dispose||(e.emitter=new ws("SubemitterSystemEmitter",e.getScene())),e.onDisposeObservable.add((function(){e.emitter&&e.emitter.dispose&&e.emitter.dispose()}))}return e.prototype.clone=function(){var t=this.particleSystem.emitter;t?t instanceof So?t=t.clone():t instanceof ws&&((t=new Pl("",t.getScene())).isVisible=!1):t=new So;var n=new e(this.particleSystem.clone("",t));return n.particleSystem.name+="Clone",n.type=this.type,n.inheritDirection=this.inheritDirection,n.inheritedVelocityAmount=this.inheritedVelocityAmount,n.particleSystem._disposeEmitterOnDispose=!0,n.particleSystem.disposeOnStop=!0,n},e.prototype.serialize=function(){var e={};return e.type=this.type,e.inheritDirection=this.inheritDirection,e.inheritedVelocityAmount=this.inheritedVelocityAmount,e.particleSystem=this.particleSystem.serialize(),e},e._ParseParticleSystem=function(e,t,n){throw oa.a.WarnImport("ParseParticle")},e.Parse=function(t,n,r){var i=t.particleSystem,o=new e(e._ParseParticleSystem(i,n,r));return o.type=t.type,o.inheritDirection=t.inheritDirection,o.inheritedVelocityAmount=t.inheritedVelocityAmount,o.particleSystem._isSubEmitter=!0,o},e.prototype.dispose=function(){this.particleSystem.dispose()},e}(),Zb="\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#include\n#include\n#include\n#include\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\nuniform sampler2D rampSampler;\n#endif\nvoid main(void) {\n#include\nvec4 textureColor=texture2D(diffuseSampler,vUV);\nvec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n#ifdef RAMPGRADIENT\nfloat alpha=baseColor.a;\nfloat remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);\nvec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));\nbaseColor.rgb*=rampColor.rgb;\n\nfloat finalAlpha=baseColor.a;\nbaseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);\n#endif\n#ifdef BLENDMULTIPLYMODE\nfloat sourceAlpha=vColor.a*textureColor.a;\nbaseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);\n#endif\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\nbaseColor=applyImageProcessing(baseColor);\n#endif\n#endif\ngl_FragColor=baseColor;\n}";Qc.a.ShadersStore.particlesPixelShader=Zb;var Jb="\nattribute vec3 position;\nattribute vec4 color;\nattribute float angle;\nattribute vec2 size;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\n#ifndef BILLBOARD\nattribute vec3 direction;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\n#endif\nattribute vec2 offset;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n#ifdef ANIMATESHEET\nuniform vec3 particlesInfos;\n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nuniform mat4 invView;\n#endif\n#include\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\nvoid main(void) {\nvec2 cornerPos;\ncornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;\n#ifdef BILLBOARD\n\nvec3 rotatedCorner;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz;\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz;\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;\n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\n\ngl_Position=projection*vec4(viewPos,1.0);\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=normalize(direction);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(worldPos,1.0);\n#endif\nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/particlesInfos.z);\nfloat columnOffset=cellIndex-rowOffset*particlesInfos.z;\nvec2 uvScale=particlesInfos.xy;\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=invView*vec4(viewPos,1.0);\n#endif\n#include\n}";Qc.a.ShadersStore.particlesVertexShader=Jb;var $b=function(e){function t(t,n,r,i,o,a){void 0===i&&(i=null),void 0===o&&(o=!1),void 0===a&&(a=.01);var s=e.call(this,t)||this;return s._inheritedVelocityOffset=new So,s.onDisposeObservable=new yo.a,s._particles=new Array,s._stockParticles=new Array,s._newPartsExcess=0,s._vertexBuffers={},s._scaledColorStep=new ko(0,0,0,0),s._colorDiff=new ko(0,0,0,0),s._scaledDirection=So.Zero(),s._scaledGravity=So.Zero(),s._currentRenderId=-1,s._useInstancing=!1,s._started=!1,s._stopped=!1,s._actualFrame=0,s._currentEmitRate1=0,s._currentEmitRate2=0,s._currentStartSize1=0,s._currentStartSize2=0,s._rawTextureWidth=256,s._useRampGradients=!1,s._disposeEmitterOnDispose=!1,s.isLocal=!1,s.recycleParticle=function(e){var t=s._particles.pop();t!==e&&t.copyTo(e),s._stockParticles.push(t)},s._createParticle=function(){var e;if(0!==s._stockParticles.length?(e=s._stockParticles.pop())._reset():e=new Yb(s),s._subEmitters&&s._subEmitters.length>0){var t=s._subEmitters[Math.floor(Math.random()*s._subEmitters.length)];e._attachedSubEmitters=[],t.forEach((function(t){if(t.type===kb.ATTACHED){var n=t.clone();e._attachedSubEmitters.push(n),n.particleSystem.start()}}))}return e},s._emitFromParticle=function(e){if(s._subEmitters&&0!==s._subEmitters.length){var t=Math.floor(Math.random()*s._subEmitters.length);s._subEmitters[t].forEach((function(t){if(t.type===kb.END){var n=t.clone();e._inheritParticleInfoToSubEmitter(n),n.particleSystem._rootParticleSystem=s,s.activeSubSystems.push(n.particleSystem),n.particleSystem.start()}}))}},s._capacity=n,s._epsilon=a,s._isAnimationSheetEnabled=o,s._scene=r||Zo.a.LastCreatedScene,s._attachImageProcessingConfiguration(null),s._customEffect=i,s._scene.particleSystems.push(s),s._useInstancing=s._scene.getEngine().getCaps().instancedArrays,s._createIndexBuffer(),s._createVertexBuffers(),s.particleEmitterType=new Bb,s.updateFunction=function(e){var t=null,n=null;s.noiseTexture&&(t=s.noiseTexture.getSize(),n=s.noiseTexture.getContent());for(var r,i=function(){r=e[o];var i=s._scaledUpdateSpeed,a=r.age;if(r.age+=i,r.age>r.lifeTime){var l=r.age-a;i=(r.lifeTime-a)*i/l,r.age=r.lifeTime}var c=r.age/r.lifeTime;s._colorGradients&&s._colorGradients.length>0?Xb.GetCurrentGradient(c,s._colorGradients,(function(e,t,n){e!==r._currentColorGradient&&(r._currentColor1.copyFrom(r._currentColor2),t.getColorToRef(r._currentColor2),r._currentColorGradient=e),ko.LerpToRef(r._currentColor1,r._currentColor2,n,r.color)})):(r.colorStep.scaleToRef(i,s._scaledColorStep),r.color.addInPlace(s._scaledColorStep),r.color.a<0&&(r.color.a=0)),s._angularSpeedGradients&&s._angularSpeedGradients.length>0&&Xb.GetCurrentGradient(c,s._angularSpeedGradients,(function(e,t,n){e!==r._currentAngularSpeedGradient&&(r._currentAngularSpeed1=r._currentAngularSpeed2,r._currentAngularSpeed2=t.getFactor(),r._currentAngularSpeedGradient=e),r.angularSpeed=xo.Lerp(r._currentAngularSpeed1,r._currentAngularSpeed2,n)})),r.angle+=r.angularSpeed*i;var u=i;if(s._velocityGradients&&s._velocityGradients.length>0&&Xb.GetCurrentGradient(c,s._velocityGradients,(function(e,t,n){e!==r._currentVelocityGradient&&(r._currentVelocity1=r._currentVelocity2,r._currentVelocity2=t.getFactor(),r._currentVelocityGradient=e),u*=xo.Lerp(r._currentVelocity1,r._currentVelocity2,n)})),r.direction.scaleToRef(u,s._scaledDirection),s._limitVelocityGradients&&s._limitVelocityGradients.length>0&&Xb.GetCurrentGradient(c,s._limitVelocityGradients,(function(e,t,n){e!==r._currentLimitVelocityGradient&&(r._currentLimitVelocity1=r._currentLimitVelocity2,r._currentLimitVelocity2=t.getFactor(),r._currentLimitVelocityGradient=e);var i=xo.Lerp(r._currentLimitVelocity1,r._currentLimitVelocity2,n);r.direction.length()>i&&r.direction.scaleInPlace(s.limitVelocityDamping)})),s._dragGradients&&s._dragGradients.length>0&&Xb.GetCurrentGradient(c,s._dragGradients,(function(e,t,n){e!==r._currentDragGradient&&(r._currentDrag1=r._currentDrag2,r._currentDrag2=t.getFactor(),r._currentDragGradient=e);var i=xo.Lerp(r._currentDrag1,r._currentDrag2,n);s._scaledDirection.scaleInPlace(1-i)})),s.isLocal?(r._localPosition.addInPlace(s._scaledDirection),So.TransformCoordinatesToRef(r._localPosition,s._emitterWorldMatrix,r.position)):r.position.addInPlace(s._scaledDirection),n&&t&&r._randomNoiseCoordinates1){var d=s._fetchR(r._randomNoiseCoordinates1.x,r._randomNoiseCoordinates1.y,t.width,t.height,n),h=s._fetchR(r._randomNoiseCoordinates1.z,r._randomNoiseCoordinates2.x,t.width,t.height,n),p=s._fetchR(r._randomNoiseCoordinates2.y,r._randomNoiseCoordinates2.z,t.width,t.height,n),f=Mo.Vector3[0],m=Mo.Vector3[1];f.copyFromFloats((2*d-1)*s.noiseStrength.x,(2*h-1)*s.noiseStrength.y,(2*p-1)*s.noiseStrength.z),f.scaleToRef(i,m),r.direction.addInPlace(m)}if(s.gravity.scaleToRef(i,s._scaledGravity),r.direction.addInPlace(s._scaledGravity),s._sizeGradients&&s._sizeGradients.length>0&&Xb.GetCurrentGradient(c,s._sizeGradients,(function(e,t,n){e!==r._currentSizeGradient&&(r._currentSize1=r._currentSize2,r._currentSize2=t.getFactor(),r._currentSizeGradient=e),r.size=xo.Lerp(r._currentSize1,r._currentSize2,n)})),s._useRampGradients&&(s._colorRemapGradients&&s._colorRemapGradients.length>0&&Xb.GetCurrentGradient(c,s._colorRemapGradients,(function(e,t,n){var i=xo.Lerp(e.factor1,t.factor1,n),o=xo.Lerp(e.factor2,t.factor2,n);r.remapData.x=i,r.remapData.y=o-i})),s._alphaRemapGradients&&s._alphaRemapGradients.length>0&&Xb.GetCurrentGradient(c,s._alphaRemapGradients,(function(e,t,n){var i=xo.Lerp(e.factor1,t.factor1,n),o=xo.Lerp(e.factor2,t.factor2,n);r.remapData.z=i,r.remapData.w=o-i}))),s._isAnimationSheetEnabled&&r.updateCellIndex(),r._inheritParticleInfoToSubEmitters(),r.age>=r.lifeTime)return s._emitFromParticle(r),r._attachedSubEmitters&&(r._attachedSubEmitters.forEach((function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()})),r._attachedSubEmitters=null),s.recycleParticle(r),o--,"continue"},o=0;ot.gradient?1:0}))},t.prototype._removeFactorGradient=function(e,t){if(e)for(var n=0,r=0,i=e;rt.gradient?1:0})),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture(),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,t,n){this._colorGradients||(this._colorGradients=[]);var r=new Qb;return r.gradient=e,r.color1=t,r.color2=n,this._colorGradients.push(r),this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var t=0,n=0,r=this._colorGradients;n0&&(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){this.emitter instanceof ws&&this.emitter.computeWorldMatrix(!0);var n=this.noiseTexture;if(n&&n.onGeneratedObservable)n.onGeneratedObservable.addOnce((function(){setTimeout((function(){for(var e=0;e0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped=!0,e&&this._stopSubEmitters()},t.prototype.reset=function(){this._stockParticles=[],this._particles=[]},t.prototype._appendParticleVertex=function(e,n,r,i){var o=e*this._vertexBufferSize;if(this._vertexData[o++]=n.position.x+this.worldOffset.x,this._vertexData[o++]=n.position.y+this.worldOffset.y,this._vertexData[o++]=n.position.z+this.worldOffset.z,this._vertexData[o++]=n.color.r,this._vertexData[o++]=n.color.g,this._vertexData[o++]=n.color.b,this._vertexData[o++]=n.color.a,this._vertexData[o++]=n.angle,this._vertexData[o++]=n.scale.x*n.size,this._vertexData[o++]=n.scale.y*n.size,this._isAnimationSheetEnabled&&(this._vertexData[o++]=n.cellIndex),this._isBillboardBased)this.billboardMode===t.BILLBOARDMODE_STRETCHED&&(this._vertexData[o++]=n.direction.x,this._vertexData[o++]=n.direction.y,this._vertexData[o++]=n.direction.z);else if(n._initialDirection){var a=n._initialDirection;this.isLocal&&(So.TransformNormalToRef(a,this._emitterWorldMatrix,Mo.Vector3[0]),a=Mo.Vector3[0]),0===a.x&&0===a.z&&(a.x=.001),this._vertexData[o++]=a.x,this._vertexData[o++]=a.y,this._vertexData[o++]=a.z}else{var s=n.direction;this.isLocal&&(So.TransformNormalToRef(s,this._emitterWorldMatrix,Mo.Vector3[0]),s=Mo.Vector3[0]),0===s.x&&0===s.z&&(s.x=.001),this._vertexData[o++]=s.x,this._vertexData[o++]=s.y,this._vertexData[o++]=s.z}this._useRampGradients&&(this._vertexData[o++]=n.remapData.x,this._vertexData[o++]=n.remapData.y,this._vertexData[o++]=n.remapData.z,this._vertexData[o++]=n.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),0===i?i=this._epsilon:1===i&&(i=1-this._epsilon)),this._vertexData[o++]=r,this._vertexData[o++]=i)},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);-1!==e&&this._rootParticleSystem.activeSubSystems.splice(e,1),this._rootParticleSystem=null}},t.prototype._update=function(e){var t,n=this;if(this._alive=this._particles.length>0,this.emitter.position){var r=this.emitter;this._emitterWorldMatrix=r.getWorldMatrix()}else{var i=this.emitter;this._emitterWorldMatrix=Oo.Translation(i.x,i.y,i.z)}this.updateFunction(this._particles);for(var o,a=function(){if(s._particles.length===s._capacity)return"break";if(t=s._createParticle(),s._particles.push(t),s.targetStopDuration&&s._lifeTimeGradients&&s._lifeTimeGradients.length>0){var e=xo.Clamp(s._actualFrame/s.targetStopDuration);Xb.GetCurrentGradient(e,s._lifeTimeGradients,(function(n,r){var i=n,o=r,a=i.getFactor(),s=o.getFactor(),l=(e-i.gradient)/(o.gradient-i.gradient);t.lifeTime=xo.Lerp(a,s,l)}))}else t.lifeTime=xo.RandomRange(s.minLifeTime,s.maxLifeTime);var r=xo.RandomRange(s.minEmitPower,s.maxEmitPower);if(s.startPositionFunction?s.startPositionFunction(s._emitterWorldMatrix,t.position,t,s.isLocal):s.particleEmitterType.startPositionFunction(s._emitterWorldMatrix,t.position,t,s.isLocal),s.isLocal&&(t._localPosition?t._localPosition.copyFrom(t.position):t._localPosition=t.position.clone(),So.TransformCoordinatesToRef(t._localPosition,s._emitterWorldMatrix,t.position)),s.startDirectionFunction?s.startDirectionFunction(s._emitterWorldMatrix,t.direction,t,s.isLocal):s.particleEmitterType.startDirectionFunction(s._emitterWorldMatrix,t.direction,t,s.isLocal),0===r?t._initialDirection?t._initialDirection.copyFrom(t.direction):t._initialDirection=t.direction.clone():t._initialDirection=null,t.direction.scaleInPlace(r),s._sizeGradients&&0!==s._sizeGradients.length?(t._currentSizeGradient=s._sizeGradients[0],t._currentSize1=t._currentSizeGradient.getFactor(),t.size=t._currentSize1,s._sizeGradients.length>1?t._currentSize2=s._sizeGradients[1].getFactor():t._currentSize2=t._currentSize1):t.size=xo.RandomRange(s.minSize,s.maxSize),t.scale.copyFromFloats(xo.RandomRange(s.minScaleX,s.maxScaleX),xo.RandomRange(s.minScaleY,s.maxScaleY)),s._startSizeGradients&&s._startSizeGradients[0]&&s.targetStopDuration){var i=s._actualFrame/s.targetStopDuration;Xb.GetCurrentGradient(i,s._startSizeGradients,(function(e,r,i){e!==n._currentStartSizeGradient&&(n._currentStartSize1=n._currentStartSize2,n._currentStartSize2=r.getFactor(),n._currentStartSizeGradient=e);var o=xo.Lerp(n._currentStartSize1,n._currentStartSize2,i);t.scale.scaleInPlace(o)}))}s._angularSpeedGradients&&0!==s._angularSpeedGradients.length?(t._currentAngularSpeedGradient=s._angularSpeedGradients[0],t.angularSpeed=t._currentAngularSpeedGradient.getFactor(),t._currentAngularSpeed1=t.angularSpeed,s._angularSpeedGradients.length>1?t._currentAngularSpeed2=s._angularSpeedGradients[1].getFactor():t._currentAngularSpeed2=t._currentAngularSpeed1):t.angularSpeed=xo.RandomRange(s.minAngularSpeed,s.maxAngularSpeed),t.angle=xo.RandomRange(s.minInitialRotation,s.maxInitialRotation),s._velocityGradients&&s._velocityGradients.length>0&&(t._currentVelocityGradient=s._velocityGradients[0],t._currentVelocity1=t._currentVelocityGradient.getFactor(),s._velocityGradients.length>1?t._currentVelocity2=s._velocityGradients[1].getFactor():t._currentVelocity2=t._currentVelocity1),s._limitVelocityGradients&&s._limitVelocityGradients.length>0&&(t._currentLimitVelocityGradient=s._limitVelocityGradients[0],t._currentLimitVelocity1=t._currentLimitVelocityGradient.getFactor(),s._limitVelocityGradients.length>1?t._currentLimitVelocity2=s._limitVelocityGradients[1].getFactor():t._currentLimitVelocity2=t._currentLimitVelocity1),s._dragGradients&&s._dragGradients.length>0&&(t._currentDragGradient=s._dragGradients[0],t._currentDrag1=t._currentDragGradient.getFactor(),s._dragGradients.length>1?t._currentDrag2=s._dragGradients[1].getFactor():t._currentDrag2=t._currentDrag1),s._colorGradients&&0!==s._colorGradients.length?(t._currentColorGradient=s._colorGradients[0],t._currentColorGradient.getColorToRef(t.color),t._currentColor1.copyFrom(t.color),s._colorGradients.length>1?s._colorGradients[1].getColorToRef(t._currentColor2):t._currentColor2.copyFrom(t.color)):(o=xo.RandomRange(0,1),ko.LerpToRef(s.color1,s.color2,o,t.color),s.colorDead.subtractToRef(t.color,s._colorDiff),s._colorDiff.scaleToRef(1/t.lifeTime,t.colorStep)),s._isAnimationSheetEnabled&&(t._initialStartSpriteCellID=s.startSpriteCellID,t._initialEndSpriteCellID=s.endSpriteCellID),t.direction.addInPlace(s._inheritedVelocityOffset),s._useRampGradients&&(t.remapData=new To(0,1,0,1)),s.noiseTexture&&(t._randomNoiseCoordinates1?(t._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(t._randomNoiseCoordinates1=new So(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2=new So(Math.random(),Math.random(),Math.random()))),t._inheritParticleInfoToSubEmitters()},s=this,l=0;l-1)n=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var r=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var i=this._actualFrame/this.targetStopDuration;Xb.GetCurrentGradient(i,this._emitRateGradients,(function(e,n,i){e!==t._currentEmitRateGradient&&(t._currentEmitRate1=t._currentEmitRate2,t._currentEmitRate2=n.getFactor(),t._currentEmitRateGradient=e),r=xo.Lerp(t._currentEmitRate1,t._currentEmitRate2,i)}))}n=r*this._scaledUpdateSpeed>>0,this._newPartsExcess+=r*this._scaledUpdateSpeed-n}if(this._newPartsExcess>1&&(n+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?n=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(n),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this))),!e){for(var o=0,a=0;a-1&&this._scene.particleSystems.splice(t,1),this._scene._activeParticleSystems.dispose(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.reset()},t.prototype.clone=function(e,n){var r=null,i=null;if(null!=this.customShader){var o=(i=this.customShader).shaderOptions.defines.length>0?i.shaderOptions.defines.join("\n"):"";r=this._scene.getEngine().createEffectForParticles(i.shaderPath.fragmentElement,i.shaderOptions.uniforms,i.shaderOptions.samplers,o)}else this._customEffect&&(r=this._customEffect);var a=new t(e,this._capacity,this._scene,r);(a.customShader=i,ea.DeepCopy(this,a,["particles","customShader","noiseTexture","particleTexture","onDisposeObservable"]),void 0===n&&(n=this.emitter),a.noiseTexture=this.noiseTexture,a.emitter=n,this.particleTexture)&&(this.particleTexture instanceof pd?(a.particleTexture=this.particleTexture.clone(),a.particleTexture.getContext().drawImage(this.particleTexture.getContext().canvas,0,0),a.particleTexture.update()):a.particleTexture=new Wl(this.particleTexture.url,this._scene));return this._colorGradients&&this._colorGradients.forEach((function(e){a.addColorGradient(e.gradient,e.color1,e.color2)})),this._dragGradients&&this._dragGradients.forEach((function(e){a.addDragGradient(e.gradient,e.factor1,e.factor2)})),this._angularSpeedGradients&&this._angularSpeedGradients.forEach((function(e){a.addAngularSpeedGradient(e.gradient,e.factor1,e.factor2)})),this._emitRateGradients&&this._emitRateGradients.forEach((function(e){a.addEmitRateGradient(e.gradient,e.factor1,e.factor2)})),this._lifeTimeGradients&&this._lifeTimeGradients.forEach((function(e){a.addLifeTimeGradient(e.gradient,e.factor1,e.factor2)})),this._limitVelocityGradients&&this._limitVelocityGradients.forEach((function(e){a.addLimitVelocityGradient(e.gradient,e.factor1,e.factor2)})),this._sizeGradients&&this._sizeGradients.forEach((function(e){a.addSizeGradient(e.gradient,e.factor1,e.factor2)})),this._startSizeGradients&&this._startSizeGradients.forEach((function(e){a.addStartSizeGradient(e.gradient,e.factor1,e.factor2)})),this._velocityGradients&&this._velocityGradients.forEach((function(e){a.addVelocityGradient(e.gradient,e.factor1,e.factor2)})),this._rampGradients&&this._rampGradients.forEach((function(e){a.addRampGradient(e.gradient,e.color)})),this._colorRemapGradients&&this._colorRemapGradients.forEach((function(e){a.addColorRemapGradient(e.gradient,e.factor1,e.factor2)})),this._alphaRemapGradients&&this._alphaRemapGradients.forEach((function(e){a.addAlphaRemapGradient(e.gradient,e.factor1,e.factor2)})),this.preventAutoStart||a.start(),a},t.prototype.serialize=function(){var e={};if(t._Serialize(e,this),e.textureMask=this.textureMask.asArray(),e.customShader=this.customShader,e.preventAutoStart=this.preventAutoStart,this.subEmitters){e.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var n=0,r=this._subEmitters;n0?s.shaderOptions.defines.join("\n"):"";a=n.getEngine().createEffectForParticles(s.shaderPath.fragmentElement,s.shaderOptions.uniforms,s.shaderOptions.samplers,l)}var c=new t(o,e.capacity,n,a,e.isAnimationSheetEnabled);if(c.customShader=s,e.id&&(c.id=e.id),e.subEmitters){c.subEmitters=[];for(var u=0,d=e.subEmitters;u1},enumerable:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLocal",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0}),t.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&this._imageProcessingConfiguration.isReady()&&this._renderEffect.isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.start=function(e){var t=this;if(void 0===e&&(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(){t.start(0)}),e):(this._started=!0,this._stopped=!1,this._preWarmDone=!1,this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){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._removeGradientAndTexture=function(t,n,r){return e.prototype._removeGradientAndTexture.call(this,t,n,r),this._releaseBuffers(),this},t.prototype.addColorGradient=function(e,t,n){this._colorGradients||(this._colorGradients=[]);var r=new Qb;return r.gradient=e,r.color1=t,this._colorGradients.push(r),this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype._addFactorGradient=function(e,t,n){var r=new Kb;r.gradient=t,r.factor1=n,e.push(r),e.sort((function(e,t){return e.gradientt.gradient?1:0})),this._releaseBuffers()},t.prototype.addSizeGradient=function(e,t){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},t.prototype.addAngularSpeedGradient=function(e,t){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),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,t){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),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,t){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),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,t){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),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,t,n){return this},t.prototype.removeEmitRateGradient=function(e){return this},t.prototype.addStartSizeGradient=function(e,t,n){return this},t.prototype.removeStartSizeGradient=function(e){return this},t.prototype.addColorRemapGradient=function(e,t,n){return this},t.prototype.removeColorRemapGradient=function(){return this},t.prototype.addAlphaRemapGradient=function(e,t,n){return this},t.prototype.removeAlphaRemapGradient=function(){return this},t.prototype.addRampGradient=function(e,t){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:!0,configurable:!0}),t.prototype.addLifeTimeGradient=function(e,t,n){return this},t.prototype.removeLifeTimeGradient=function(e){return this},t.prototype._reset=function(){this._releaseBuffers()},t.prototype._createUpdateVAO=function(e){var t={};t.position=e.createVertexBuffer("position",0,3);var n=3;this.particleEmitterType instanceof Gb&&(t.initialPosition=e.createVertexBuffer("initialPosition",n,3),n+=3),t.age=e.createVertexBuffer("age",n,1),n+=1,t.life=e.createVertexBuffer("life",n,1),n+=1,t.seed=e.createVertexBuffer("seed",n,4),n+=4,t.size=e.createVertexBuffer("size",n,3),n+=3,this._colorGradientsTexture||(t.color=e.createVertexBuffer("color",n,4),n+=4),t.direction=e.createVertexBuffer("direction",n,3),n+=3,this._isBillboardBased||(t.initialDirection=e.createVertexBuffer("initialDirection",n,3),n+=3),this._angularSpeedGradientsTexture?(t.angle=e.createVertexBuffer("angle",n,1),n+=1):(t.angle=e.createVertexBuffer("angle",n,2),n+=2),this._isAnimationSheetEnabled&&(t.cellIndex=e.createVertexBuffer("cellIndex",n,1),n+=1,this.spriteRandomStartCell&&(t.cellStartOffset=e.createVertexBuffer("cellStartOffset",n,1),n+=1)),this.noiseTexture&&(t.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",n,3),n+=3,t.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",n,3),n+=3);var r=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),r},t.prototype._createRenderVAO=function(e,t){var n={};n.position=e.createVertexBuffer("position",0,3,this._attributesStrideSize,!0);var r=3;this.particleEmitterType instanceof Gb&&(r+=3),n.age=e.createVertexBuffer("age",r,1,this._attributesStrideSize,!0),r+=1,n.life=e.createVertexBuffer("life",r,1,this._attributesStrideSize,!0),r+=5,n.size=e.createVertexBuffer("size",r,3,this._attributesStrideSize,!0),r+=3,this._colorGradientsTexture||(n.color=e.createVertexBuffer("color",r,4,this._attributesStrideSize,!0),r+=4),this.billboardMode===$b.BILLBOARDMODE_STRETCHED&&(n.direction=e.createVertexBuffer("direction",r,3,this._attributesStrideSize,!0)),r+=3,this._isBillboardBased||(n.initialDirection=e.createVertexBuffer("initialDirection",r,3,this._attributesStrideSize,!0),r+=3),n.angle=e.createVertexBuffer("angle",r,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?r++:r+=2,this._isAnimationSheetEnabled&&(n.cellIndex=e.createVertexBuffer("cellIndex",r,1,this._attributesStrideSize,!0),r+=1,this.spriteRandomStartCell&&(n.cellStartOffset=e.createVertexBuffer("cellStartOffset",r,1,this._attributesStrideSize,!0),r+=1)),this.noiseTexture&&(n.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",r,3,this._attributesStrideSize,!0),r+=3,n.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",r,3,this._attributesStrideSize,!0),r+=3),n.offset=t.createVertexBuffer("offset",0,2),n.uv=t.createVertexBuffer("uv",2,2);var i=this._engine.recordVertexArrayObject(n,null,this._renderEffect);return this._engine.bindArrayBuffer(null),i},t.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._scene.getEngine(),n=new Array;this._attributesStrideSize=21,this._targetIndex=0,this.particleEmitterType instanceof Gb&&(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 r=this.particleEmitterType instanceof Gb,i=Mo.Vector3[0],o=0;o=this.targetStopDuration&&this.stop()},t.prototype._createFactorGradientTexture=function(e,t){var n=this[t];if(e&&e.length&&!n){for(var r=new Float32Array(this._rawTextureWidth),i=0;i1){var n=0|this._accumulatedCount;this._accumulatedCount-=n,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+n)}if(!this._currentActiveCount)return 0;var r;if(this._engine.enableEffect(this._updateEffect),this._engine.setState(!1),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){r=this.emitter.getWorldMatrix()}else{var i=this.emitter;r=Oo.Translation(i.x,i.y,i.z)}if(this._updateEffect.setMatrix("emitterWM",r),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),this._engine.setRasterizerState(!1),this._engine.beginTransformFeedback(!0),this._engine.drawArraysType(Ls.PointListDrawMode,0,this._currentActiveCount),this._engine.endTransformFeedback(),this._engine.setRasterizerState(!0),this._engine.bindTransformFeedbackBuffer(null),!e){this._engine.enableEffect(this._renderEffect);var o=this._scene.getViewMatrix();if(this._renderEffect.setMatrix("view",o),this._renderEffect.setMatrix("projection",this._scene.getProjectionMatrix()),this._renderEffect.setTexture("textureSampler",this.particleTexture),this._renderEffect.setVector2("translationPivot",this.translationPivot),this._renderEffect.setVector3("worldOffset",this.worldOffset),this._colorGradientsTexture?this._renderEffect.setTexture("colorGradientSampler",this._colorGradientsTexture):this._renderEffect.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var a=this.particleTexture.getBaseSize();this._renderEffect.setFloat3("sheetInfos",this.spriteCellWidth/a.width,this.spriteCellHeight/a.height,a.width/this.spriteCellWidth)}if(this._isBillboardBased){var s=this._scene.activeCamera;this._renderEffect.setVector3("eyePosition",s.globalPosition)}if(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4||this._scene.clipPlane5||this._scene.clipPlane6){var l=o.clone();l.invert(),this._renderEffect.setMatrix("invView",l),Cu.BindClipPlane(this._renderEffect,this._scene)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._renderEffect),this.blendMode){case $b.BLENDMODE_ADD:this._engine.setAlphaMode(1);break;case $b.BLENDMODE_ONEONE:this._engine.setAlphaMode(6);break;case $b.BLENDMODE_STANDARD:this._engine.setAlphaMode(2);break;case $b.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(4)}this.forceDepthWrite&&this._engine.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._engine.drawArraysType(Ls.TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(0)}this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var c=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=c,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-1&&this._scene.particleSystems.splice(t,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.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,n){var r=new t(e,{capacity:this._capacity,randomTextureSize:this._randomTextureSize},this._scene);return ea.DeepCopy(this,r,["particles","customShader","noiseTexture","particleTexture","onDisposeObservable"]),void 0===n&&(n=this.emitter),r.emitter=n,this.particleTexture&&(r.particleTexture=new Wl(this.particleTexture.url,this._scene)),r.noiseTexture=this.noiseTexture,this._colorGradients&&this._colorGradients.forEach((function(e){r.addColorGradient(e.gradient,e.color1,e.color2)})),this._dragGradients&&this._dragGradients.forEach((function(e){r.addDragGradient(e.gradient,e.factor1)})),this._angularSpeedGradients&&this._angularSpeedGradients.forEach((function(e){r.addAngularSpeedGradient(e.gradient,e.factor1)})),this._emitRateGradients&&this._emitRateGradients.forEach((function(e){r.addEmitRateGradient(e.gradient,e.factor1,e.factor2)})),this._lifeTimeGradients&&this._lifeTimeGradients.forEach((function(e){r.addLifeTimeGradient(e.gradient,e.factor1,e.factor2)})),this._limitVelocityGradients&&this._limitVelocityGradients.forEach((function(e){r.addLimitVelocityGradient(e.gradient,e.factor1)})),this._sizeGradients&&this._sizeGradients.forEach((function(e){r.addSizeGradient(e.gradient,e.factor1)})),this._startSizeGradients&&this._startSizeGradients.forEach((function(e){r.addStartSizeGradient(e.gradient,e.factor1,e.factor2)})),this._velocityGradients&&this._velocityGradients.forEach((function(e){r.addVelocityGradient(e.gradient,e.factor1)})),this._rampGradients&&this._rampGradients.forEach((function(e){r.addRampGradient(e.gradient,e.color)})),this._colorRemapGradients&&this._colorRemapGradients.forEach((function(e){r.addColorRemapGradient(e.gradient,e.factor1,e.factor2)})),this._alphaRemapGradients&&this._alphaRemapGradients.forEach((function(e){r.addAlphaRemapGradient(e.gradient,e.factor1,e.factor2)})),r},t.prototype.serialize=function(){var e={};return $b._Serialize(e,this),e.activeParticleCount=this.activeParticleCount,e},t.Parse=function(e,n,r,i){void 0===i&&(i=!1);var o=new t(e.name,{capacity:e.capacity,randomTextureSize:e.randomTextureSize},n);return e.activeParticleCount&&(o.activeParticleCount=e.activeParticleCount),$b._Parse(e,o,n,r),e.preventAutoStart&&(o.preventAutoStart=e.preventAutoStart),i||o.preventAutoStart||o.start(),o},t}(Hb),av=function(){function e(){this.systems=new Array}return Object.defineProperty(e.prototype,"emitterNode",{get:function(){return this._emitterNode},enumerable:!0,configurable:!0}),e.prototype.setEmitterAsSphere=function(e,t,n){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:"Sphere",options:e,renderingGroupId:t};var r=zd.CreateSphere("emitterSphere",{diameter:e.diameter,segments:e.segments},n);r.renderingGroupId=t;var i=new hd("emitterSphereMaterial",n);i.emissiveColor=e.color,r.material=i;for(var o=0,a=this.systems;o0&&n.set(this._uvs32,cs.UVKind),this._colors32.length>0&&n.set(this._colors32,cs.ColorKind),n.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,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},e.prototype.digest=function(e,t){var n=t&&t.facetNb||1,r=t&&t.number||0,i=t&&t.delta||0,o=e.getVerticesData(cs.PositionKind),a=e.getIndices(),s=e.getVerticesData(cs.UVKind),l=e.getVerticesData(cs.ColorKind),c=e.getVerticesData(cs.NormalKind),u=t&&t.storage?t.storage:null,d=0,h=a.length/3;r?(r=r>h?h:r,n=Math.round(h/r),i=0):n=n>h?h:n;for(var p=[],f=[],m=[],g=[],b=[],v=So.Zero(),A=n;dh-(n=A+Math.floor((1+i)*Math.random()))&&(n=h-d),p.length=0,f.length=0,m.length=0,g.length=0,b.length=0;for(var _=0,y=3*d;y<3*(d+n);y++){m.push(_);var x=a[y],w=3*x;if(p.push(o[w],o[w+1],o[w+2]),f.push(c[w],c[w+1],c[w+2]),s){var E=2*x;g.push(s[E],s[E+1])}if(l){var C=4*x;b.push(l[C],l[C+1],l[C+2],l[C+3])}_++}var S,T=this.nbParticles,P=this._posToShape(p),O=this._uvsToShapeUV(g),R=Array.from(m),M=Array.from(b),I=Array.from(f);for(v.copyFromFloats(0,0,0),S=0;S65535&&(this._needs32Bits=!0)}if(this._pickable){var D=i.length/3;for(g=0;g=this.nbParticles||!this._updatable)return[];var r=this.particles,i=this.nbParticles;if(t=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var O=this.mesh._boundingInfo;O&&(b.copyFrom(O.minimum),v.copyFrom(O.maximum))}var R=(w=this.particles[e]._pos)/3|0;C=4*R,T=2*R;for(var M=e;M<=t;M++){var I=this.particles[M];this.updateParticle(I);var k=I._model._shape,D=I._model._shapeUV,B=I._rotationMatrix,F=I.position,N=I.rotation,L=I.scaling,U=I._globalPosition;if(this._depthSort&&this._depthSortParticles){var V=this.depthSortedParticles[M];V.ind=I._ind,V.indicesLength=I._model._indicesLength,V.sqDistance=So.DistanceSquared(I.position,A)}if(!I.alive||I._stillInvisible&&!I.isVisible)w+=3*(P=k.length),C+=4*P,T+=2*P;else{if(I.isVisible){I._stillInvisible=!1;var z=p[12];if(I.pivot.multiplyToRef(L,z),this.billboard&&(N.x=0,N.y=0),(this._computeParticleRotation||this.billboard)&&I.getRotationMatrix(r),null!==I.parentId){var j=this.getParticleById(I.parentId);if(j){var G=j._rotationMatrix,H=j._globalPosition,Q=F.x*G[1]+F.y*G[4]+F.z*G[7],W=F.x*G[0]+F.y*G[3]+F.z*G[6],K=F.x*G[2]+F.y*G[5]+F.z*G[8];if(U.x=H.x+W,U.y=H.y+Q,U.z=H.z+K,this._computeParticleRotation||this.billboard){var X=r.m;B[0]=X[0]*G[0]+X[1]*G[3]+X[2]*G[6],B[1]=X[0]*G[1]+X[1]*G[4]+X[2]*G[7],B[2]=X[0]*G[2]+X[1]*G[5]+X[2]*G[8],B[3]=X[4]*G[0]+X[5]*G[3]+X[6]*G[6],B[4]=X[4]*G[1]+X[5]*G[4]+X[6]*G[7],B[5]=X[4]*G[2]+X[5]*G[5]+X[6]*G[8],B[6]=X[8]*G[0]+X[9]*G[3]+X[10]*G[6],B[7]=X[8]*G[1]+X[9]*G[4]+X[10]*G[7],B[8]=X[8]*G[2]+X[9]*G[5]+X[10]*G[8]}}else I.parentId=null}else if(U.x=F.x,U.y=F.y,U.z=F.z,this._computeParticleRotation||this.billboard){X=r.m;B[0]=X[0],B[1]=X[1],B[2]=X[2],B[3]=X[4],B[4]=X[5],B[5]=X[6],B[6]=X[8],B[7]=X[9],B[8]=X[10]}var Y=p[11];for(I.translateFromPivot?Y.setAll(0):Y.copyFrom(z),P=0;P0)for(var t=0;t0&&e.set(this._uvs32,cs.UVKind);var t=0;this._colors32.length>0&&(t=1,e.set(this._colors32,cs.ColorKind));var n=new Pl(this.name,this._scene);e.applyToMesh(n,this._updatable),this.mesh=n,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);var r=new hd("point cloud material",this._scene);return r.emissiveColor=new Io(t,t,t),r.disableLighting=!0,r.pointsCloud=!0,r.pointSize=this._size,n.material=r,new Promise((function(e){return e(n)}))},e.prototype._addParticle=function(e,t,n,r){var i=new dv(e,t,n,r,this);return this.particles.push(i),i},e.prototype._randomUnitVector=function(e){e.position=new So(Math.random(),Math.random(),Math.random()),e.color=new ko(1,1,1,1)},e.prototype._getColorIndicesForCoord=function(e,t,n,r){var i=e._groupImageData,o=n*(4*r)+4*t,a=[o,o+1,o+2,o+3],s=a[1],l=a[2],c=a[3],u=i[a[0]],d=i[s],h=i[l],p=i[c];return new ko(u/255,d/255,h/255,p)},e.prototype._setPointsColorOrUV=function(e,t,n,r,i,o,a){n&&e.updateFacetData();var s=2*e.getBoundingInfo().boundingSphere.radius,l=e.getVerticesData(cs.PositionKind),c=e.getIndices(),u=e.getVerticesData(cs.UVKind),d=e.getVerticesData(cs.ColorKind),h=So.Zero();e.computeWorldMatrix();var p=e.getWorldMatrix();if(!p.isIdentity())for(var f=0;f1&&(Pe=1),(Oe=Re.b+Se)<0&&(Oe=0),Oe>1&&(Oe=1),Io.HSVtoRGBToRef(Te,Pe,Oe,De),pe.set(De.r,De.g,De.b,1)):pe=oe.set(Math.random(),Math.random(),Math.random(),1),Ie.color=new ko(pe.x,pe.y,pe.z,pe.w),this._colors.push(pe.x,pe.y,pe.z,pe.w))}},e.prototype._colorFromTexture=function(e,t,n){var r=this;if(null===e.material)return jo.a.Warn(e.name+"has no material."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,n,!0,!1);var i=e.material.getActiveTextures();if(0===i.length)return jo.a.Warn(e.name+"has no useable texture."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,n,!0,!1);var o=e.clone();o.setEnabled(!1),this._promises.push(new Promise((function(e){Ql.WhenAllReady(i,(function(){var a=t._textureNb;return a<0&&(a=0),a>i.length-1&&(a=i.length-1),t._groupImageData=i[a].readPixels(),t._groupImgWidth=i[a].getSize().width,t._groupImgHeight=i[a].getSize().height,r._setPointsColorOrUV(o,t,n,!0,!0),o.dispose(),e()}))})))},e.prototype._calculateDensity=function(e,t,n){for(var r,i,o,a,s,l,c,u,d,h,p,f,m,g,b,v,A,_=new Array,y=So.Zero(),x=So.Zero(),w=So.Zero(),E=So.Zero(),C=So.Zero(),S=So.Zero(),T=new Array,P=0,O=n.length/3,R=0;R0&&(_=_.map((function(e){return e+k})));for(R=0;R3)&&(o=sv.Random);var a=e.getVerticesData(cs.PositionKind),s=e.getIndices();this._groups.push(this._groupCounter);var l=new hv(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,s),o===sv.Color?l._textureNb=r||0:r=r||new ko(1,1,1,1),o){case sv.Color:this._colorFromTexture(e,l,!1);break;case sv.UV:this._setPointsColorOrUV(e,l,!1,!1,!1);break;case sv.Random:this._setPointsColorOrUV(e,l,!1);break;case sv.Stated:this._setPointsColorOrUV(e,l,!1,void 0,void 0,r,i)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.addVolumePoints=function(e,t,n,r,i){var o=n||sv.Random;(isNaN(o)||o<0||o>3)&&(o=sv.Random);var a=e.getVerticesData(cs.PositionKind),s=e.getIndices();this._groups.push(this._groupCounter);var l=new hv(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,s),o===sv.Color?l._textureNb=r||0:r=r||new ko(1,1,1,1),o){case sv.Color:this._colorFromTexture(e,l,!0);break;case sv.UV:this._setPointsColorOrUV(e,l,!0,!1,!1);break;case sv.Random:this._setPointsColorOrUV(e,l,!0);break;case sv.Stated:this._setPointsColorOrUV(e,l,!0,void 0,void 0,r,i)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.setParticles=function(e,t,n){if(void 0===e&&(e=0),void 0===t&&(t=this.nbParticles-1),void 0===n&&(n=!0),!this._updatable||!this._isReady)return this;this.beforeUpdateParticles(e,t,n);var r=Mo.Matrix[0],i=this.mesh,o=this._colors32,a=this._positions32,s=this._uvs32,l=Mo.Vector3,c=l[5].copyFromFloats(1,0,0),u=l[6].copyFromFloats(0,1,0),d=l[7].copyFromFloats(0,0,1),h=l[8].setAll(Number.MAX_VALUE),p=l[9].setAll(-Number.MAX_VALUE);Oo.IdentityToRef(r);var f=0;if(this.mesh.isFacetDataEnabled&&(this._computeBoundingBox=!0),t=t>=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var m=this.mesh._boundingInfo;m&&(h.copyFrom(m.minimum),p.copyFrom(m.maximum))}f=0;for(var g=0,b=0,v=0,A=e;A<=t;A++){var _=this.particles[A];g=3*(f=_.idx),b=4*f,v=2*f,this.updateParticle(_);var y=_._rotationMatrix,x=_.position,w=_._globalPosition;if(this._computeParticleRotation&&_.getRotationMatrix(r),null!==_.parentId){var E=this.particles[_.parentId],C=E._rotationMatrix,S=E._globalPosition,T=x.x*C[1]+x.y*C[4]+x.z*C[7],P=x.x*C[0]+x.y*C[3]+x.z*C[6],O=x.x*C[2]+x.y*C[5]+x.z*C[8];if(w.x=S.x+P,w.y=S.y+T,w.z=S.z+O,this._computeParticleRotation){var R=r.m;y[0]=R[0]*C[0]+R[1]*C[3]+R[2]*C[6],y[1]=R[0]*C[1]+R[1]*C[4]+R[2]*C[7],y[2]=R[0]*C[2]+R[1]*C[5]+R[2]*C[8],y[3]=R[4]*C[0]+R[5]*C[3]+R[6]*C[6],y[4]=R[4]*C[1]+R[5]*C[4]+R[6]*C[7],y[5]=R[4]*C[2]+R[5]*C[5]+R[6]*C[8],y[6]=R[8]*C[0]+R[9]*C[3]+R[10]*C[6],y[7]=R[8]*C[1]+R[9]*C[4]+R[10]*C[7],y[8]=R[8]*C[2]+R[9]*C[5]+R[10]*C[8]}}else if(w.x=0,w.y=0,w.z=0,this._computeParticleRotation){R=r.m;y[0]=R[0],y[1]=R[1],y[2]=R[2],y[3]=R[4],y[4]=R[5],y[5]=R[6],y[6]=R[8],y[7]=R[9],y[8]=R[10]}var M=l[11];_.translateFromPivot?M.setAll(0):M.copyFrom(_.pivot);var I=l[0];I.copyFrom(_.position);var k=I.x-_.pivot.x,D=I.y-_.pivot.y,B=I.z-_.pivot.z,F=k*y[0]+D*y[3]+B*y[6],N=k*y[1]+D*y[4]+B*y[7],L=k*y[2]+D*y[5]+B*y[8];F+=M.x,N+=M.y,L+=M.z;var U=a[g]=w.x+c.x*F+u.x*N+d.x*L,V=a[g+1]=w.y+c.y*F+u.y*N+d.y*L,z=a[g+2]=w.z+c.z*F+u.z*N+d.z*L;if(this._computeBoundingBox&&(h.minimizeInPlaceFromFloats(U,V,z),p.maximizeInPlaceFromFloats(U,V,z)),this._computeParticleColor&&_.color){var j=_.color,G=this._colors32;G[b]=j.r,G[b+1]=j.g,G[b+2]=j.b,G[b+3]=j.a}if(this._computeParticleTexture&&_.uv){var H=_.uv,Q=this._uvs32;Q[v]=H.x,Q[v+1]=H.y}}return n&&(this._computeParticleColor&&i.updateVerticesData(cs.ColorKind,o,!1,!1),this._computeParticleTexture&&i.updateVerticesData(cs.UVKind,s,!1,!1),i.updateVerticesData(cs.PositionKind,a,!1,!1)),this._computeBoundingBox&&(i._boundingInfo?i._boundingInfo.reConstruct(h,p,i._worldMatrix):i._boundingInfo=new vs(h,p,i._worldMatrix)),this.afterUpdateParticles(e,t,n),this},e.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},e.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},e.prototype.setVisibilityBox=function(e){var t=e/2;this.mesh._boundingInfo=new vs(new So(-t,-t,-t),new So(t,t,t))},Object.defineProperty(e.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleRotation",{set:function(e){this._computeParticleRotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!0,configurable:!0}),e.prototype.initParticles=function(){},e.prototype.recycleParticle=function(e){return e},e.prototype.updateParticle=function(e){return e},e.prototype.beforeUpdateParticles=function(e,t,n){},e.prototype.afterUpdateParticles=function(e,t,n){}}();nl.prototype.getPhysicsEngine=function(){return this._physicsEngine},nl.prototype.enablePhysics=function(e,t){if(void 0===e&&(e=null),this._physicsEngine)return!0;var n=this._getComponent(Gs.NAME_PHYSICSENGINE);n||(n=new mv(this),this._addComponent(n));try{return this._physicsEngine=new tm(e,t),this._physicsTimeAccumulator=0,!0}catch(e){return jo.a.Error(e.message),!1}},nl.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},nl.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},nl.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},nl.prototype._advancePhysicsEngineStep=function(e){if(this._physicsEngine){var t=this._physicsEngine.getSubTimeStep();if(t>0)for(this._physicsTimeAccumulator+=e;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(e/1e3),this.onAfterPhysicsObservable.notifyObservers(this)}},Object.defineProperty(ws.prototype,"physicsImpostor",{get:function(){return this._physicsImpostor},set:function(e){var t=this;this._physicsImpostor!==e&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),this._physicsImpostor=e,e&&(this._disposePhysicsObserver=this.onDisposeObservable.add((function(){t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)}))))},enumerable:!0,configurable:!0}),ws.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},ws.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},ws.prototype.setPhysicsLinkWith=function(e,t,n,r){return this.physicsImpostor&&e.physicsImpostor?(this.physicsImpostor.createJoint(e.physicsImpostor,jd.HingeJoint,{mainPivot:t,connectedPivot:n,nativeParams:r}),this):this};var pv,fv,mv=function(){function e(e){var t=this;this.name=Gs.NAME_PHYSICSENGINE,this.scene=e,this.scene.onBeforePhysicsObservable=new yo.a,this.scene.onAfterPhysicsObservable=new yo.a,this.scene.getDeterministicFrameTime=function(){return t.scene._physicsEngine?1e3*t.scene._physicsEngine.getTimeStep():1e3/60}}return e.prototype.register=function(){},e.prototype.rebuild=function(){},e.prototype.dispose=function(){this.scene.onBeforePhysicsObservable.clear(),this.scene.onAfterPhysicsObservable.clear(),this.scene._physicsEngine&&this.scene.disablePhysicsEngine()},e}(),gv=(function(){function e(e){this._scene=e,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||jo.a.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}e.prototype.applyRadialExplosionImpulse=function(e,t,n,r){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;var i=this._physicsEngine.getImpostors();if(0===i.length)return null;"number"==typeof t&&((t=new _v).radius=t,t.strength=n||t.strength,t.falloff=r||t.falloff);var o=new gv(this._scene,t),a=Array();return i.forEach((function(t){var n=o.getImpostorHitData(t,e);n&&(t.applyImpulse(n.force,n.contactPoint),a.push({impostor:t,hitData:n}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.applyRadialExplosionForce=function(e,t,n,r){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;var i=this._physicsEngine.getImpostors();if(0===i.length)return null;"number"==typeof t&&((t=new _v).radius=t,t.strength=n||t.strength,t.falloff=r||t.falloff);var o=new gv(this._scene,t),a=Array();return i.forEach((function(t){var n=o.getImpostorHitData(t,e);n&&(t.applyForce(n.force,n.contactPoint),a.push({impostor:t,hitData:n}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.gravitationalField=function(e,t,n,r){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;"number"==typeof t&&((t=new _v).radius=t,t.strength=n||t.strength,t.falloff=r||t.falloff);var i=new bv(this,this._scene,e,t);return i.dispose(!1),i},e.prototype.updraft=function(e,t,n,r,i){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;"number"==typeof t&&((t=new yv).radius=t,t.strength=n||t.strength,t.height=r||t.height,t.updraftMode=i||t.updraftMode);var o=new vv(this._scene,e,t);return o.dispose(!1),o},e.prototype.vortex=function(e,t,n,r){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;"number"==typeof t&&((t=new xv).radius=t,t.strength=n||t.strength,t.height=r||t.height);var i=new Av(this._scene,e,t);return i.dispose(!1),i}}(),function(){function e(e,t){this._scene=e,this._options=t,this._dataFetched=!1,this._options=Object(No.a)(Object(No.a)({},new _v),this._options)}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.getImpostorHitData=function(e,t){if(0===e.mass)return null;if(!this._intersectsWithSphere(e,t,this._options.radius))return null;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return null;var n=e.getObjectCenter().subtract(t),r=new Vl(t,n,this._options.radius).intersectsMesh(e.object).pickedPoint;if(!r)return null;var i=So.Distance(t,r);if(i>this._options.radius)return null;var o=this._options.falloff===pv.Constant?this._options.strength:this._options.strength*(1-i/this._options.radius);return{force:n.multiplyByFloats(o,o,o),contactPoint:r,distanceFromOrigin:i}},e.prototype.triggerAffectedImpostorsCallback=function(e){this._options.affectedImpostorsCallback&&this._options.affectedImpostorsCallback(e)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout((function(){t._dataFetched||t._sphere.dispose()}),0)},e.prototype._prepareSphere=function(){this._sphere||(this._sphere=zd.CreateSphere("radialExplosionEventSphere",this._options.sphere,this._scene),this._sphere.isVisible=!1)},e.prototype._intersectsWithSphere=function(e,t,n){var r=e.object;return this._prepareSphere(),this._sphere.position=t,this._sphere.scaling=new So(2*n,2*n,2*n),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(r,!0)},e}()),bv=function(){function e(e,t,n,r){this._physicsHelper=e,this._scene=t,this._origin=n,this._options=r,this._dataFetched=!1,this._options=Object(No.a)(Object(No.a)({},new _v),this._options),this._tickCallback=this._tick.bind(this),this._options.strength=-1*this._options.strength}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout((function(){t._dataFetched||t._sphere.dispose()}),0)},e.prototype._tick=function(){if(this._sphere)this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);else{var e=this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);e&&(this._sphere=e.getData().sphere.clone("radialExplosionEventSphereClone"))}},e}(),vv=function(){function e(e,t,n){this._scene=e,this._origin=t,this._options=n,this._originTop=So.Zero(),this._originDirection=So.Zero(),this._cylinderPosition=So.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(No.a)(Object(No.a)({},new yv),this._options),this._origin.addToRef(new So(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new So(0,this._options.height,0),this._originTop),this._options.updraftMode===fv.Perpendicular&&(this._originDirection=this._origin.subtract(this._originTop).normalize()),this._tickCallback=this._tick.bind(this),this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),this._cylinder&&(e?this._cylinder.dispose():setTimeout((function(){t._dataFetched||t._cylinder.dispose()}),0))},e.prototype.getImpostorHitData=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;var t=e.getObjectCenter();if(this._options.updraftMode===fv.Perpendicular)var n=this._originDirection;else n=t.subtract(this._originTop);var r=So.Distance(this._origin,t),i=-1*this._options.strength;return{force:n.multiplyByFloats(i,i,i),contactPoint:t,distanceFromOrigin:r}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var n=e.getImpostorHitData(t);n&&t.applyForce(n.force,n.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=_d.CreateCylinder("updraftEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}(),Av=function(){function e(e,t,n){this._scene=e,this._origin=t,this._options=n,this._originTop=So.Zero(),this._cylinderPosition=So.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(No.a)(Object(No.a)({},new xv),this._options),this._origin.addToRef(new So(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new So(0,this._options.height,0),this._originTop),this._tickCallback=this._tick.bind(this),this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._cylinder.dispose():setTimeout((function(){t._dataFetched||t._cylinder.dispose()}),0)},e.prototype.getImpostorHitData=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return null;var t=e.getObjectCenter(),n=new So(this._origin.x,t.y,this._origin.z),r=t.subtract(n),i=new Vl(n,r,this._options.radius).intersectsMesh(e.object),o=i.pickedPoint;if(!o)return null;var a=i.distance/this._options.radius,s=o.normalize();if(a>this._options.centripetalForceThreshold&&(s=s.negate()),a>this._options.centripetalForceThreshold)var l=s.x*this._options.centripetalForceMultiplier,c=s.y*this._options.updraftForceMultiplier,u=s.z*this._options.centripetalForceMultiplier;else{var d=So.Cross(n,t).normalize();l=(d.x+s.x)*this._options.centrifugalForceMultiplier,c=this._originTop.y*this._options.updraftForceMultiplier,u=(d.z+s.z)*this._options.centrifugalForceMultiplier}var h=new So(l,c,u);return{force:h=h.multiplyByFloats(this._options.strength,this._options.strength,this._options.strength),contactPoint:t,distanceFromOrigin:a}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var n=e.getImpostorHitData(t);n&&t.applyForce(n.force,n.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=_d.CreateCylinder("vortexEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}(),_v=function(){this.radius=5,this.strength=10,this.falloff=pv.Constant,this.sphere={segments:32,diameter:1}},yv=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=fv.Center},xv=function(){this.radius=5,this.strength=10,this.height=10,this.centripetalForceThreshold=.7,this.centripetalForceMultiplier=5,this.centrifugalForceMultiplier=.5,this.updraftForceMultiplier=.02};!function(e){e[e.Constant=0]="Constant",e[e.Linear=1]="Linear"}(pv||(pv={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(fv||(fv={}));var wv="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\nvoid main(void)\n{\nvec3 color=texture2D(textureSampler,vUV).rgb;\nfloat luminance=dot(color,vec3(0.3,0.59,0.11));\nvec3 blackAndWhite=vec3(luminance,luminance,luminance);\ngl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);\n}";Qc.a.ShadersStore.blackAndWhitePixelShader=wv;!function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,"blackAndWhite",["degree"],null,n,r,i,o,a)||this;return s.degree=1,s.onApplyObservable.add((function(e){e.setFloat("degree",s.degree)})),s}Object(No.d)(t,e)}(Xc);var Ev=function(){function e(e,t,n,r){this._name=t,this._singleInstance=r||!0,this._getPostProcesses=n,this._cameras={},this._indicesForCamera={},this._postProcesses={}}return Object.defineProperty(e.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(this._postProcesses.hasOwnProperty(e))for(var t=this._postProcesses[e],n=0;n-1?"#define MALI 1\n":null},t}(Xc),Wv="#include\n\nuniform sampler2D textureSampler;\n\nuniform float intensity;\nuniform float animatedSeed;\n\nvarying vec2 vUV;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec2 seed=vUV*(animatedSeed);\nfloat grain=dither(seed,intensity);\n\nfloat lum=getLuminance(gl_FragColor.rgb);\nfloat grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;\ngl_FragColor.rgb+=grain*grainAmount;\ngl_FragColor.rgb=max(gl_FragColor.rgb,0.0);\n}";Qc.a.ShadersStore.grainPixelShader=Wv;var Kv=function(e){function t(t,n,r,i,o,a,s,l){void 0===s&&(s=0),void 0===l&&(l=!1);var c=e.call(this,t,"grain",["intensity","animatedSeed"],[],n,r,i,o,a,null,s,void 0,null,l)||this;return c.intensity=30,c.animated=!1,c.onApplyObservable.add((function(e){e.setFloat("intensity",c.intensity),e.setFloat("animatedSeed",c.animated?Math.random()+1:1)})),c}return Object(No.d)(t,e),t}(Xc),Xv="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvoid main(void)\n{\nvec4 tex=texture2D(textureSampler,vUV);\nvec3 c=tex.rgb;\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\n\n\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a);\n}";Qc.a.ShadersStore.highlightsPixelShader=Xv;!function(e){function t(t,n,r,i,o,a,s){return void 0===s&&(s=0),e.call(this,t,"highlights",null,null,n,r,i,o,a,null,s)||this}Object(No.d)(t,e)}(Xc);Qc.a.IncludesShadersStore.mrtFragmentDeclaration="#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";var Yv="#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\nprecision highp int;\n#ifdef BUMP\nvarying mat4 vWorldView;\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef REFLECTIVITY\nvarying vec2 vReflectivityUV;\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef ALPHATEST\nuniform sampler2D diffuseSampler;\n#endif\n#include[RENDER_TARGET_COUNT]\n#include\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include\ngl_FragData[1]=vec4(normalize(vec3(vWorldView*vec4(normalW,0.0))),1.0);\n#else\ngl_FragData[1]=vec4(normalize(vNormalV),1.0);\n#endif\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef REFLECTIVITY\n#ifdef HAS_SPECULAR\n\nvec4 reflectivity=texture2D(reflectivitySampler,vReflectivityUV);\n#elif HAS_REFLECTIVITY\n\nvec4 reflectivity=vec4(texture2D(reflectivitySampler,vReflectivityUV).rgb,1.0);\n#else\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\n#endif\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\n#endif\n}";Qc.a.ShadersStore.geometryPixelShader=Yv;var qv="precision highp float;\nprecision highp int;\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef NEED_UV\nvarying vec2 vUV;\n#ifdef ALPHATEST\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef BUMP\nuniform mat4 bumpMatrix;\nvarying vec2 vBumpUV;\n#endif\n#ifdef REFLECTIVITY\nuniform mat4 reflectivityMatrix;\nvarying vec2 vReflectivityUV;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef BUMP\nvarying mat4 vWorldView;\n#endif\n#ifdef BUMP\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousWorld;\nuniform mat4 previousViewProjection;\n#ifdef BONES_VELOCITY_ENABLED\n#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#endif\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#include\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#include\nvec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));\n#ifdef BUMP\nvWorldView=view*finalWorld;\nvNormalW=normalUpdated;\n#else\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\n#endif\nvViewPos=view*pos;\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n#if defined(POSITION) || defined(BUMP)\nvPositionW=pos.xyz/pos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#ifdef NEED_UV\n#ifdef UV1\n#ifdef ALPHATEST\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#else\nvUV=uv;\n#endif\n#ifdef BUMP\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef UV2\n#ifdef ALPHATEST\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#else\nvUV=uv2;\n#endif\n#ifdef BUMP\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#endif\n#include\n}\n";Qc.a.ShadersStore.geometryVertexShader=qv;var Zv=function(){function e(t,n){void 0===n&&(n=1),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._scene=t,this._ratio=n,e._SceneComponentInitialization(this._scene),this._createRenderTargets()}return Object.defineProperty(e.prototype,"renderList",{set:function(e){this._multiRenderTarget.renderList=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!0,configurable:!0}),e.prototype.getTextureIndex=function(t){switch(t){case e.POSITION_TEXTURE_TYPE:return this._positionIndex;case e.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case e.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;default:return-1}},Object.defineProperty(e.prototype,"enablePosition",{get:function(){return this._enablePosition},set:function(e){this._enablePosition=e,this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableVelocity",{get:function(){return this._enableVelocity},set:function(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableReflectivity",{get:function(){return this._enableReflectivity},set:function(e){this._enableReflectivity=e,this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ratio",{get:function(){return this._ratio},enumerable:!0,configurable:!0}),e.prototype.isReady=function(e,t){var n=e.getMaterial();if(n&&n.disableDepthWrite)return!1;var r=[],i=[cs.PositionKind,cs.NormalKind],o=e.getMesh();if(n){var a=!1;n.needAlphaBlending()&&(r.push("#define ALPHATEST"),a=!0),n.bumpTexture&&hd.BumpTextureEnabled&&(r.push("#define BUMP"),a=!0),this._enableReflectivity&&(n instanceof hd&&n.specularTexture?(r.push("#define HAS_SPECULAR"),a=!0):n instanceof Dp&&n.reflectivityTexture&&(r.push("#define HAS_REFLECTIVITY"),a=!0)),a&&(r.push("#define NEED_UV"),o.isVerticesDataPresent(cs.UVKind)&&(i.push(cs.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(cs.UV2Kind)&&(i.push(cs.UV2Kind),r.push("#define UV2")))}this._enablePosition&&(r.push("#define POSITION"),r.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(r.push("#define VELOCITY"),r.push("#define VELOCITY_INDEX "+this._velocityIndex),-1===this.excludedSkinnedMeshesFromVelocity.indexOf(o)&&r.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(r.push("#define REFLECTIVITY"),r.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),o.useBones&&o.computeBonesUsingShaders?(i.push(cs.MatricesIndicesKind),i.push(cs.MatricesWeightsKind),o.numBoneInfluencers>4&&(i.push(cs.MatricesIndicesExtraKind),i.push(cs.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0");var s=o.morphTargetManager,l=0;s&&s.numInfluencers>0&&(l=s.numInfluencers,r.push("#define MORPHTARGETS"),r.push("#define NUM_MORPH_INFLUENCERS "+l),Cu.PrepareAttributesForMorphTargetsInfluencers(i,o,l)),t&&(r.push("#define INSTANCES"),Cu.PushAttributesForInstances(i)),r.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length);var c=r.join("\n");return this._cachedDefines!==c&&(this._cachedDefines=c,this._effect=this._scene.getEngine().createEffect("geometry",i,["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","morphTargetInfluences","bumpMatrix","reflectivityMatrix","vTangentSpaceParams","vBumpInfos"],["diffuseSampler","bumpSampler","reflectivitySampler"],c,void 0,void 0,void 0,{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:l})),this._effect.isReady()},e.prototype.getGBuffer=function(){return this._multiRenderTarget},Object.defineProperty(e.prototype,"samples",{get:function(){return this._multiRenderTarget.samples},set:function(e){this._multiRenderTarget.samples=e},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.getGBuffer().dispose()},e.prototype._createRenderTargets=function(){var e=this,t=this._scene.getEngine(),n=2;if(this._enablePosition&&(this._positionIndex=n,n++),this._enableVelocity&&(this._velocityIndex=n,n++),this._enableReflectivity&&(this._reflectivityIndex=n,n++),this._multiRenderTarget=new Tm("gBuffer",{width:t.getRenderWidth()*this._ratio,height:t.getRenderHeight()*this._ratio},n,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:1}),this.isSupported){this._multiRenderTarget.wrapU=Wl.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Wl.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(e){e.clear(new ko(0,0,0,1),!0,!0,!0)}));var r=function(t){var n=t.getRenderingMesh(),r=e._scene,i=r.getEngine(),o=t.getMaterial();if(o){if(n._internalAbstractMeshDataInfo._isActiveIntermediate=!1,e._enableVelocity&&!e._previousTransformationMatrices[n.uniqueId]&&(e._previousTransformationMatrices[n.uniqueId]={world:Oo.Identity(),viewProjection:r.getTransformMatrix()},n.skeleton)){var a=n.skeleton.getTransformMatrices(n);e._previousBonesTransformationMatrices[n.uniqueId]=e._copyBonesTransformationMatrices(a,new Float32Array(a.length))}i.setState(o.backFaceCulling,0,!1,r.useRightHandedSystem);var s=n._getInstancesRenderList(t._id);if(!s.mustReturn){var l=i.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(e.isReady(t,l)){if(i.enableEffect(e._effect),n._bind(t,e._effect,o.fillMode),e._effect.setMatrix("viewProjection",r.getTransformMatrix()),e._effect.setMatrix("view",r.getViewMatrix()),o){if(o.needAlphaTesting()){var c=o.getAlphaTestTexture();c&&(e._effect.setTexture("diffuseSampler",c),e._effect.setMatrix("diffuseMatrix",c.getTextureMatrix()))}o.bumpTexture&&r.getEngine().getCaps().standardDerivatives&&hd.BumpTextureEnabled&&(e._effect.setFloat3("vBumpInfos",o.bumpTexture.coordinatesIndex,1/o.bumpTexture.level,o.parallaxScaleBias),e._effect.setMatrix("bumpMatrix",o.bumpTexture.getTextureMatrix()),e._effect.setTexture("bumpSampler",o.bumpTexture),e._effect.setFloat2("vTangentSpaceParams",o.invertNormalMapX?-1:1,o.invertNormalMapY?-1:1)),e._enableReflectivity&&(o instanceof hd&&o.specularTexture?(e._effect.setMatrix("reflectivityMatrix",o.specularTexture.getTextureMatrix()),e._effect.setTexture("reflectivitySampler",o.specularTexture)):o instanceof Dp&&o.reflectivityTexture&&(e._effect.setMatrix("reflectivityMatrix",o.reflectivityTexture.getTextureMatrix()),e._effect.setTexture("reflectivitySampler",o.reflectivityTexture)))}n.useBones&&n.computeBonesUsingShaders&&n.skeleton&&(e._effect.setMatrices("mBones",n.skeleton.getTransformMatrices(n)),e._enableVelocity&&e._effect.setMatrices("mPreviousBones",e._previousBonesTransformationMatrices[n.uniqueId])),Cu.BindMorphTargetParameters(n,e._effect),e._enableVelocity&&(e._effect.setMatrix("previousWorld",e._previousTransformationMatrices[n.uniqueId].world),e._effect.setMatrix("previousViewProjection",e._previousTransformationMatrices[n.uniqueId].viewProjection)),n._processRendering(t,e._effect,o.fillMode,s,l,(function(t,n){return e._effect.setMatrix("world",n)}))}e._enableVelocity&&(e._previousTransformationMatrices[n.uniqueId].world=n.getWorldMatrix().clone(),e._previousTransformationMatrices[n.uniqueId].viewProjection=e._scene.getTransformMatrix().clone(),n.skeleton&&e._copyBonesTransformationMatrices(n.skeleton.getTransformMatrices(n),e._previousBonesTransformationMatrices[n.uniqueId]))}}};this._multiRenderTarget.customRenderFunction=function(n,i,o,a){var s;if(a.length){for(t.setColorWrite(!1),s=0;s0){var n=this._renderEffects[t[0]].getPostProcesses();n&&(n[0].samples=e)}return!0},e.prototype.dispose=function(){},Object(No.c)([ha()],e.prototype,"_name",void 0),e}(),oA=function(){function e(){this._renderPipelines={}}return Object.defineProperty(e.prototype,"supportedPipelines",{get:function(){var e=[];for(var t in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(t)){var n=this._renderPipelines[t];n.isSupported&&e.push(n)}return e},enumerable:!0,configurable:!0}),e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,n){void 0===n&&(n=!1);var r=this._renderPipelines[e];r&&r._attachCameras(t,n)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var n=this._renderPipelines[e];n&&n._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,n){var r=this._renderPipelines[e];r&&r._enableEffect(t,n)},e.prototype.disableEffectInPipeline=function(e,t,n){var r=this._renderPipelines[e];r&&r._disableEffect(t,n)},e.prototype.update=function(){for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e.prototype._rebuild=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e]._rebuild()}},e.prototype.dispose=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e].dispose()}},e}();Object.defineProperty(nl.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var e=this._getComponent(Gs.NAME_POSTPROCESSRENDERPIPELINEMANAGER);e||(e=new aA(this),this._addComponent(e)),this._postProcessRenderPipelineManager=new oA}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var aA=function(){function e(e){this.name=Gs.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Gs.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER,this,this._gatherRenderTargets)},e.prototype.rebuild=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager._rebuild()},e.prototype.dispose=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.dispose()},e.prototype._gatherRenderTargets=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()},e}(),sA=function(e){function t(t,n,r,i,o){void 0===t&&(t=""),void 0===n&&(n=!0),void 0===r&&(r=Zo.a.LastCreatedScene),void 0===o&&(o=!0);var a=e.call(this,r.getEngine(),t)||this;a._camerasToBeAttached=[],a.SharpenPostProcessId="SharpenPostProcessEffect",a.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",a.FxaaPostProcessId="FxaaPostProcessEffect",a.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",a.GrainPostProcessId="GrainPostProcessEffect",a._glowLayer=null,a.animations=[],a._imageProcessingConfigurationObserver=null,a._sharpenEnabled=!1,a._bloomEnabled=!1,a._depthOfFieldEnabled=!1,a._depthOfFieldBlurLevel=Lv.Low,a._fxaaEnabled=!1,a._imageProcessingEnabled=!0,a._bloomScale=.5,a._chromaticAberrationEnabled=!1,a._grainEnabled=!1,a._buildAllowed=!0,a._resizeObserver=null,a._hardwareScaleLevel=1,a._bloomKernel=64,a._bloomWeight=.15,a._bloomThreshold=.9,a._samples=1,a._hasCleared=!1,a._prevPostProcess=null,a._prevPrevPostProcess=null,a._depthOfFieldSceneObserver=null,a._cameras=i||r.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._buildAllowed=o,a._scene=r;var s=a._scene.getEngine().getCaps();a._hdr=n&&(s.textureHalfFloatRender||s.textureFloatRender),a._hdr?s.textureHalfFloatRender?a._defaultPipelineTextureType=2:s.textureFloatRender&&(a._defaultPipelineTextureType=1):a._defaultPipelineTextureType=0,r.postProcessRenderPipelineManager.addPipeline(a);var l=a._scene.getEngine();return a.sharpen=new rA("sharpen",1,null,Wl.BILINEAR_SAMPLINGMODE,l,!1,a._defaultPipelineTextureType,!0),a._sharpenEffect=new Ev(l,a.SharpenPostProcessId,(function(){return a.sharpen}),!0),a.depthOfField=new Vv(a._scene,null,a._depthOfFieldBlurLevel,a._defaultPipelineTextureType,!0),a.bloom=new Ov(a._scene,a._bloomScale,a._bloomWeight,a.bloomKernel,a._defaultPipelineTextureType,!0),a.chromaticAberration=new Mv("ChromaticAberration",l.getRenderWidth(),l.getRenderHeight(),1,null,Wl.BILINEAR_SAMPLINGMODE,l,!1,a._defaultPipelineTextureType,!0),a._chromaticAberrationEffect=new Ev(l,a.ChromaticAberrationPostProcessId,(function(){return a.chromaticAberration}),!0),a.grain=new Kv("Grain",1,null,Wl.BILINEAR_SAMPLINGMODE,l,!1,a._defaultPipelineTextureType,!0),a._grainEffect=new Ev(l,a.GrainPostProcessId,(function(){return a.grain}),!0),a._resizeObserver=l.onResizeObservable.add((function(){a._hardwareScaleLevel=l.getHardwareScalingLevel(),a.bloomKernel=a.bloomKernel})),a._imageProcessingConfigurationObserver=a._scene.imageProcessingConfiguration.onUpdateParameters.add((function(){a.bloom._downscale._exposure=a._scene.imageProcessingConfiguration.exposure})),a._buildPipeline(),a}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!0,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:!0,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:!0,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:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),t.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new Ov(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var t=0;t1){for(var n=0,r=this._cameras;n-1&&(e.depthOfField.depthTexture=t.enableDepthRenderer(t.activeCamera).getDepthMap())}))}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);var o=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=o.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 md("imageProcessing",1,null,Wl.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new Ev(t,this.ImageProcessingPostProcessId,(function(){return e.imageProcessing}),!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1),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 Qv("fxaa",1,null,Wl.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new Ev(t,this.FxaaPostProcessId,(function(){return e.fxaa}),!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&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&&jo.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")}},t.prototype._disposePostProcesses=function(e){void 0===e&&(e=!1);for(var t=0;t0?n._ssaoCombinePostProcess.width:n._originalColorPostProcess.width),e.setFloat("near",n._scene.activeCamera.minZ),e.setFloat("far",n._scene.activeCamera.maxZ),e.setFloat("radius",n.radius),e.setTexture("depthSampler",n._depthTexture),e.setArray("samplerOffsets",n._samplerOffsets))},this._blurVPostProcess=new Xc("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],t,null,Wl.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(r?"1":"0")+"\n"),this._blurVPostProcess.onApply=function(e){n._scene.activeCamera&&(e.setFloat("outSize",n._ssaoCombinePostProcess.height>0?n._ssaoCombinePostProcess.height:n._originalColorPostProcess.height),e.setFloat("near",n._scene.activeCamera.minZ),e.setFloat("far",n._scene.activeCamera.maxZ),e.setFloat("radius",n.radius),e.setTexture("depthSampler",n._depthTexture),e.setArray("samplerOffsets",n._samplerOffsets))},this._blurHPostProcess.samples=this.textureSamples,this._blurVPostProcess.samples=this.textureSamples},t.prototype._rebuild=function(){e.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,2.3283064365386963e-10*this._bits[0]},t.prototype._hammersley=function(e,t){return[e/t,this._radicalInverse_VdC(e)]},t.prototype._hemisphereSample_uniform=function(e,t){var n=2*t*Math.PI,r=1-(.85*e+.15),i=Math.sqrt(1-r*r);return new So(Math.cos(n)*i,Math.sin(n)*i,r)},t.prototype._generateHemisphere=function(){for(var e,t=this.samples,n=[],r=0;r>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join("\n"))},Object(No.c)([ha()],t.prototype,"threshold",void 0),Object(No.c)([ha()],t.prototype,"strength",void 0),Object(No.c)([ha()],t.prototype,"reflectionSpecularFalloffExponent",void 0),Object(No.c)([ha()],t.prototype,"step",void 0),Object(No.c)([ha()],t.prototype,"roughnessFactor",void 0),Object(No.c)([ha()],t.prototype,"enableSmoothReflections",null),Object(No.c)([ha()],t.prototype,"reflectionSamples",null),Object(No.c)([ha()],t.prototype,"smoothSteps",null),t}(Xc),gA="uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminanceshadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\n#include\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\n#ifndef AUTO_EXPOSURE\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\n#endif\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n";Qc.a.ShadersStore.standardPixelShader=gA;var bA=function(e){function t(t,n,r,i,o){void 0===i&&(i=null);var a=e.call(this,n.getEngine(),t)||this;return a.downSampleX4PostProcess=null,a.brightPassPostProcess=null,a.blurHPostProcesses=[],a.blurVPostProcesses=[],a.textureAdderPostProcess=null,a.volumetricLightPostProcess=null,a.volumetricLightSmoothXPostProcess=null,a.volumetricLightSmoothYPostProcess=null,a.volumetricLightMergePostProces=null,a.volumetricLightFinalPostProcess=null,a.luminancePostProcess=null,a.luminanceDownSamplePostProcesses=[],a.hdrPostProcess=null,a.textureAdderFinalPostProcess=null,a.lensFlareFinalPostProcess=null,a.hdrFinalPostProcess=null,a.lensFlarePostProcess=null,a.lensFlareComposePostProcess=null,a.motionBlurPostProcess=null,a.depthOfFieldPostProcess=null,a.fxaaPostProcess=null,a.screenSpaceReflectionPostProcess=null,a.brightThreshold=1,a.blurWidth=512,a.horizontalBlur=!1,a.lensTexture=null,a.volumetricLightCoefficient=.2,a.volumetricLightPower=4,a.volumetricLightBlurScale=64,a.sourceLight=null,a.hdrMinimumLuminance=1,a.hdrDecreaseRate=.5,a.hdrIncreaseRate=.5,a.lensColorTexture=null,a.lensFlareStrength=20,a.lensFlareGhostDispersal=1.4,a.lensFlareHaloWidth=.7,a.lensFlareDistortionStrength=16,a.lensFlareBlurWidth=512,a.lensStarTexture=null,a.lensFlareDirtTexture=null,a.depthOfFieldDistance=10,a.depthOfFieldBlurWidth=64,a.animations=[],a._currentDepthOfFieldSource=null,a._fixedExposure=1,a._currentExposure=1,a._hdrAutoExposure=!1,a._hdrCurrentLuminance=1,a._motionStrength=1,a._isObjectBasedMotionBlur=!1,a._camerasToBeAttached=[],a._bloomEnabled=!1,a._depthOfFieldEnabled=!1,a._vlsEnabled=!1,a._lensFlareEnabled=!1,a._hdrEnabled=!1,a._motionBlurEnabled=!1,a._fxaaEnabled=!1,a._screenSpaceReflectionsEnabled=!1,a._motionBlurSamples=64,a._volumetricLightStepsCount=50,a._samples=1,a._cameras=o||n.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._scene=n,a._basePostProcess=i,a._ratio=r,a._floatTextureType=n.getEngine().getCaps().textureFloatRender?1:2,n.postProcessRenderPipelineManager.addPipeline(a),a._buildPipeline(),a}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"exposure",{get:function(){return this._fixedExposure},set:function(e){this._fixedExposure=e,this._currentExposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hdrAutoExposure",{get:function(){return this._hdrAutoExposure},set:function(e){if(this._hdrAutoExposure=e,this.hdrPostProcess){var t=["#define HDR"];e&&t.push("#define AUTO_EXPOSURE"),this.hdrPostProcess.updateEffect(t.join("\n"))}},enumerable:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"objectBasedMotionBlur",{get:function(){return this._isObjectBasedMotionBlur},set:function(e){var t=this._isObjectBasedMotionBlur!==e;this._isObjectBasedMotionBlur=e,t&&this._buildPipeline()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"VLSEnabled",{get:function(){return this._vlsEnabled},set:function(e){if(this._vlsEnabled!==e){if(e)if(!this._scene.enableGeometryBufferRenderer())return void jo.a.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");this._vlsEnabled=e,this._buildPipeline()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"MotionBlurEnabled",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"screenSpaceReflectionsEnabled",{get:function(){return this._screenSpaceReflectionsEnabled},set:function(e){this._screenSpaceReflectionsEnabled!==e&&(this._screenSpaceReflectionsEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"volumetricLightStepsCount",{get:function(){return this._volumetricLightStepsCount},set:function(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS "+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!0,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\n#define MAX_MOTION_SAMPLES "+e.toFixed(1))),this._motionBlurSamples=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!0,configurable:!0}),t.prototype._buildPipeline=function(){var e=this,t=this._ratio,n=this._scene;this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._screenSpaceReflectionsEnabled&&(this.screenSpaceReflectionPostProcess=new mA("HDRPass",n,t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.screenSpaceReflectionPostProcess})),this.addEffect(new Ev(n.getEngine(),"HDRScreenSpaceReflections",(function(){return e.screenSpaceReflectionPostProcess}),!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new Xc("HDRPass","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.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 Ev(n.getEngine(),"HDRPassPostProcess",(function(){return e.originalPostProcess}),!0)),this._bloomEnabled&&(this._createDownSampleX4PostProcess(n,t/4),this._createBrightPassPostProcess(n,t/4),this._createBlurPostProcesses(n,t/4,1),this._createTextureAdderPostProcess(n,t),this.textureAdderFinalPostProcess=new Xc("HDRDepthOfFieldSource","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Ev(n.getEngine(),"HDRBaseDepthOfFieldSource",(function(){return e.textureAdderFinalPostProcess}),!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(n,t),this.volumetricLightFinalPostProcess=new Xc("HDRVLSFinal","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Ev(n.getEngine(),"HDRVLSFinal",(function(){return e.volumetricLightFinalPostProcess}),!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(n,t),this.lensFlareFinalPostProcess=new Xc("HDRPostLensFlareDepthOfFieldSource","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Ev(n.getEngine(),"HDRPostLensFlareDepthOfFieldSource",(function(){return e.lensFlareFinalPostProcess}),!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(n,this._floatTextureType),this._createHdrPostProcess(n,t),this.hdrFinalPostProcess=new Xc("HDRPostHDReDepthOfFieldSource","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Ev(n.getEngine(),"HDRPostHDReDepthOfFieldSource",(function(){return e.hdrFinalPostProcess}),!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(n,t/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(n,t)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(n,t),this._fxaaEnabled&&(this.fxaaPostProcess=new Qv("fxaa",1,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,0),this.addEffect(new Ev(n.getEngine(),"HDRFxaa",(function(){return e.fxaaPostProcess}),!0))),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this._samples)&&this._samples>1&&jo.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")},t.prototype._createDownSampleX4PostProcess=function(e,t){var n=this,r=new Array(32);this.downSampleX4PostProcess=new Xc("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,i=n.downSampleX4PostProcess.width,o=n.downSampleX4PostProcess.height,a=-2;a<2;a++)for(var s=-2;s<2;s++)r[t]=(a+.5)*(1/i),r[t+1]=(s+.5)*(1/o),t+=2;e.setArray2("dsOffsets",r)},this.addEffect(new Ev(e.getEngine(),"HDRDownSampleX4",(function(){return n.downSampleX4PostProcess}),!0))},t.prototype._createBrightPassPostProcess=function(e,t){var n=this,r=new Array(8);this.brightPassPostProcess=new Xc("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),this.brightPassPostProcess.onApply=function(e){var t=1/n.brightPassPostProcess.width,i=1/n.brightPassPostProcess.height;r[0]=-.5*t,r[1]=.5*i,r[2]=.5*t,r[3]=.5*i,r[4]=-.5*t,r[5]=-.5*i,r[6]=.5*t,r[7]=-.5*i,e.setArray2("dsOffsets",r),e.setFloat("brightThreshold",n.brightThreshold)},this.addEffect(new Ev(e.getEngine(),"HDRBrightPass",(function(){return n.brightPassPostProcess}),!0))},t.prototype._createBlurPostProcesses=function(e,t,n,r){var i=this;void 0===r&&(r="blurWidth");var o=e.getEngine(),a=new $h("HDRBlurH_"+n,new Co(1,0),this[r],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),s=new $h("HDRBlurV_"+n,new Co(0,1),this[r],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);a.onActivateObservable.add((function(){var e=a.width/o.getRenderWidth();a.kernel=i[r]*e})),s.onActivateObservable.add((function(){var e=s.height/o.getRenderHeight();s.kernel=i.horizontalBlur?64*e:i[r]*e})),this.addEffect(new Ev(e.getEngine(),"HDRBlurH"+n,(function(){return a}),!0)),this.addEffect(new Ev(e.getEngine(),"HDRBlurV"+n,(function(){return s}),!0)),this.blurHPostProcesses.push(a),this.blurVPostProcesses.push(s)},t.prototype._createTextureAdderPostProcess=function(e,t){var n=this;this.textureAdderPostProcess=new Xc("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",n._vlsEnabled?n._currentDepthOfFieldSource:n.originalPostProcess),e.setTexture("lensSampler",n.lensTexture),e.setFloat("exposure",n._currentExposure),n._currentDepthOfFieldSource=n.textureAdderFinalPostProcess},this.addEffect(new Ev(e.getEngine(),"HDRTextureAdder",(function(){return n.textureAdderPostProcess}),!0))},t.prototype._createVolumetricLightPostProcess=function(e,t){var n=this,r=e.enableGeometryBufferRenderer();r.enablePosition=!0;var i=r.getGBuffer();this.volumetricLightPostProcess=new Xc("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var o=Co.Zero();this.volumetricLightPostProcess.onApply=function(e){if(n.sourceLight&&n.sourceLight.getShadowGenerator()&&n._scene.activeCamera){var t=n.sourceLight.getShadowGenerator();e.setTexture("shadowMapSampler",t.getShadowMap()),e.setTexture("positionSampler",i.textures[2]),e.setColor3("sunColor",n.sourceLight.diffuse),e.setVector3("sunDirection",n.sourceLight.getShadowDirection()),e.setVector3("cameraPosition",n._scene.activeCamera.globalPosition),e.setMatrix("shadowViewProjection",t.getTransformMatrix()),e.setFloat("scatteringCoefficient",n.volumetricLightCoefficient),e.setFloat("scatteringPower",n.volumetricLightPower),o.x=n.sourceLight.getDepthMinZ(n._scene.activeCamera),o.y=n.sourceLight.getDepthMaxZ(n._scene.activeCamera),e.setVector2("depthValues",o)}},this.addEffect(new Ev(e.getEngine(),"HDRVLS",(function(){return n.volumetricLightPostProcess}),!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new Xc("HDRVLSMerge","standard",[],["originalSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(e){e.setTextureFromPostProcess("originalSampler",n._bloomEnabled?n.textureAdderFinalPostProcess:n.originalPostProcess),n._currentDepthOfFieldSource=n.volumetricLightFinalPostProcess},this.addEffect(new Ev(e.getEngine(),"HDRVLSMerge",(function(){return n.volumetricLightMergePostProces}),!0))},t.prototype._createLuminancePostProcesses=function(e,n){var r=this,i=Math.pow(3,t.LuminanceSteps);this.luminancePostProcess=new Xc("HDRLuminance","standard",["lumOffsets"],[],{width:i,height:i},null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",n);var o=[];this.luminancePostProcess.onApply=function(e){var t=1/r.luminancePostProcess.width,n=1/r.luminancePostProcess.height;o[0]=-.5*t,o[1]=.5*n,o[2]=.5*t,o[3]=.5*n,o[4]=-.5*t,o[5]=-.5*n,o[6]=.5*t,o[7]=-.5*n,e.setArray2("lumOffsets",o)},this.addEffect(new Ev(e.getEngine(),"HDRLuminance",(function(){return r.luminancePostProcess}),!0));for(var a=t.LuminanceSteps-1;a>=0;a--){i=Math.pow(3,a);var s="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(s+="#define FINAL_DOWN_SAMPLER");var l=new Xc("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:i,height:i},null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,s,n);this.luminanceDownSamplePostProcesses.push(l)}var c=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(t,n){var i=new Array(18);t.onApply=function(e){if(c){for(var o=0,a=-1;a<2;a++)for(var s=-1;s<2;s++)i[o]=a/c.width,i[o+1]=s/c.height,o+=2;e.setArray2("dsOffsets",i),e.setFloat("halfDestPixelSize",.5/c.width),c=n===r.luminanceDownSamplePostProcesses.length-1?r.luminancePostProcess:t}},n===r.luminanceDownSamplePostProcesses.length-1&&(t.onAfterRender=function(){var t=e.getEngine().readPixels(0,0,1,1),n=new To(1/16581375,1/65025,1/255,1);r._hdrCurrentLuminance=(t[0]*n.x+t[1]*n.y+t[2]*n.z+t[3]*n.w)/100}),r.addEffect(new Ev(e.getEngine(),"HDRLuminanceDownSample"+n,(function(){return t}),!0))}))},t.prototype._createHdrPostProcess=function(e,t){var n=this,r=["#define HDR"];this._hdrAutoExposure&&r.push("#define AUTO_EXPOSURE"),this.hdrPostProcess=new Xc("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r.join("\n"),0);var i=1,o=0,a=0;this.hdrPostProcess.onApply=function(t){if(t.setTextureFromPostProcess("textureAdderSampler",n._currentDepthOfFieldSource),o+=e.getEngine().getDeltaTime(),i<0)i=n._hdrCurrentLuminance;else{var r=(a-o)/1e3;n._hdrCurrentLuminancei-n.hdrIncreaseRate*r?i-=n.hdrIncreaseRate*r:i=n._hdrCurrentLuminance}n.hdrAutoExposure?n._currentExposure=n._fixedExposure/i:(i=xo.Clamp(i,n.hdrMinimumLuminance,1e20),t.setFloat("averageLuminance",i)),a=o,n._currentDepthOfFieldSource=n.hdrFinalPostProcess},this.addEffect(new Ev(e.getEngine(),"HDR",(function(){return n.hdrPostProcess}),!0))},t.prototype._createLensFlarePostProcess=function(e,t){var n=this;this.lensFlarePostProcess=new Xc("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",0),this.addEffect(new Ev(e.getEngine(),"HDRLensFlare",(function(){return n.lensFlarePostProcess}),!0)),this._createBlurPostProcesses(e,t/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new Xc("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",0),this.addEffect(new Ev(e.getEngine(),"HDRLensFlareCompose",(function(){return n.lensFlareComposePostProcess}),!0));var r=new Co(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",n._bloomEnabled?n.blurHPostProcesses[0]:n.originalPostProcess),e.setTexture("lensColorSampler",n.lensColorTexture),e.setFloat("strength",n.lensFlareStrength),e.setFloat("ghostDispersal",n.lensFlareGhostDispersal),e.setFloat("haloWidth",n.lensFlareHaloWidth),r.x=n.lensFlarePostProcess.width,r.y=n.lensFlarePostProcess.height,e.setVector2("resolution",r),e.setFloat("distortionStrength",n.lensFlareDistortionStrength)};var i=Oo.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),o=Oo.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(e){if(n._scene.activeCamera){e.setTextureFromPostProcess("otherSampler",n.lensFlarePostProcess),e.setTexture("lensDirtSampler",n.lensFlareDirtTexture),e.setTexture("lensStarSampler",n.lensStarTexture);var t=n._scene.activeCamera.getViewMatrix().getRow(0),r=n._scene.activeCamera.getViewMatrix().getRow(2),a=So.Dot(t.toVector3(),new So(1,0,0))+So.Dot(r.toVector3(),new So(0,0,1));a*=4;var s=Oo.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),l=o.multiply(s).multiply(i);e.setMatrix("lensStarMatrix",l),n._currentDepthOfFieldSource=n.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,t){var n=this;this.depthOfFieldPostProcess=new Xc("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",0),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",n._currentDepthOfFieldSource),e.setTexture("depthSampler",n._getDepthTexture()),e.setFloat("distance",n.depthOfFieldDistance)},this.addEffect(new Ev(e.getEngine(),"HDRDepthOfField",(function(){return n.depthOfFieldPostProcess}),!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var n=this;if(this._isObjectBasedMotionBlur){var r=new eA("HDRMotionBlur",e,t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,0);r.motionStrength=this.motionStrength,r.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=r}else{this.motionBlurPostProcess=new Xc("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),0);var i=0,o=Oo.Identity(),a=Oo.Identity(),s=Oo.Identity(),l=Co.Zero();this.motionBlurPostProcess.onApply=function(t){(s=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(a),t.setMatrix("inverseViewProjection",a),t.setMatrix("prevViewProjection",o),o=s,l.x=n.motionBlurPostProcess.width,l.y=n.motionBlurPostProcess.height,t.setVector2("screenSize",l),i=e.getEngine().getFps()/60,t.setFloat("motionScale",i),t.setFloat("motionStrength",n.motionStrength),t.setTexture("depthSampler",n._getDepthTexture())}}this.addEffect(new Ev(e.getEngine(),"HDRMotionBlur",(function(){return n.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;e0&&-1!==this.excludedMeshes.indexOf(e)},t.prototype._createPass=function(e,t){var n=this,r=e.getEngine();this._volumetricLightScatteringRTT=new mu("volumetricLightScatteringMap",{width:r.getRenderWidth()*t,height:r.getRenderHeight()*t},e,!1,!0,0),this._volumetricLightScatteringRTT.wrapU=Wl.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Wl.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var i=this.getCamera();i?i.customRenderTargets.push(this._volumetricLightScatteringRTT):e.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,a=function(e){var t=e.getRenderingMesh();if(!n._meshExcluded(t)){t._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var r=e.getMaterial();if(r){var i=t.getScene(),o=i.getEngine();o.setState(r.backFaceCulling);var a=t._getInstancesRenderList(e._id);if(!a.mustReturn){var s=o.getCaps().instancedArrays&&null!==a.visibleInstances[e._id];if(n._isReady(e,s)){var l=n._volumetricLightScatteringPass;if(t===n.mesh&&(l=e.effect?e.effect:r.getEffect()),o.enableEffect(l),t._bind(e,l,r.fillMode),t===n.mesh)r.bind(t.getWorldMatrix(),t);else{if(n._volumetricLightScatteringPass.setMatrix("viewProjection",i.getTransformMatrix()),r&&r.needAlphaTesting()){var c=r.getAlphaTestTexture();n._volumetricLightScatteringPass.setTexture("diffuseSampler",c),c&&n._volumetricLightScatteringPass.setMatrix("diffuseMatrix",c.getTextureMatrix())}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&n._volumetricLightScatteringPass.setMatrices("mBones",t.skeleton.getTransformMatrices(t))}t._processRendering(e,n._volumetricLightScatteringPass,Ls.TriangleFillMode,a,s,(function(e,t){return l.setMatrix("world",t)}))}}}}},s=new ko(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=e.clearColor,e.clearColor=s})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){e.clearColor=o})),this._volumetricLightScatteringRTT.customRenderFunction=function(t,n,r,i){var o,s=e.getEngine();if(i.length){for(s.setColorWrite(!1),o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),s.setAlphaMode(2),o=0;o\nvoid main(void) {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include\ngl_FragColor=color;\n}";Qc.a.ShadersStore.outlinePixelShader=RA;var MA="\nattribute vec3 position;\nattribute vec3 normal;\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n\nuniform float offset;\n#include\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include[0..maxSimultaneousMorphTargets]\nvec3 offsetPosition=positionUpdated+(normalUpdated*offset);\n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}\n";Qc.a.ShadersStore.outlineVertexShader=MA;nl.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new IA(this)),this._outlineRenderer},Object.defineProperty(Pl.prototype,"renderOutline",{get:function(){return this._renderOutline},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOutline=e},enumerable:!0,configurable:!0}),Object.defineProperty(Pl.prototype,"renderOverlay",{get:function(){return this._renderOverlay},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOverlay=e},enumerable:!0,configurable:!0});var IA=function(){function e(e){this.name=Gs.NAME_OUTLINERENDERER,this.zOffset=1,this.scene=e,this._engine=e.getEngine(),this.scene._addComponent(this)}return e.prototype.register=function(){this.scene._beforeRenderingMeshStage.registerStep(Gs.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(Gs.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype.render=function(e,t,n){var r=this;void 0===n&&(n=!1);var i=this.scene,o=i.getEngine(),a=o.getCaps().instancedArrays&&null!==t.visibleInstances[e._id]&&void 0!==t.visibleInstances[e._id];if(this.isReady(e,a)){var s=e.getRenderingMesh(),l=e.getMaterial();if(l&&i.activeCamera){if(o.enableEffect(this._effect),l.useLogarithmicDepth&&this._effect.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2)),this._effect.setFloat("offset",n?0:s.outlineWidth),this._effect.setColor4("color",n?s.overlayColor:s.outlineColor,n?s.overlayAlpha:l.alpha),this._effect.setMatrix("viewProjection",i.getTransformMatrix()),s.useBones&&s.computeBonesUsingShaders&&s.skeleton&&this._effect.setMatrices("mBones",s.skeleton.getTransformMatrices(s)),Cu.BindMorphTargetParameters(s,this._effect),s._bind(e,this._effect,l.fillMode),l&&l.needAlphaTesting()){var c=l.getAlphaTestTexture();c&&(this._effect.setTexture("diffuseSampler",c),this._effect.setMatrix("diffuseMatrix",c.getTextureMatrix()))}o.setZOffset(-this.zOffset),s._processRendering(e,this._effect,l.fillMode,t,a,(function(e,t){r._effect.setMatrix("world",t)})),o.setZOffset(0)}}},e.prototype.isReady=function(e,t){var n=[],r=[cs.PositionKind,cs.NormalKind],i=e.getMesh(),o=e.getMaterial();o&&(o.needAlphaTesting()&&(n.push("#define ALPHATEST"),i.isVerticesDataPresent(cs.UVKind)&&(r.push(cs.UVKind),n.push("#define UV1")),i.isVerticesDataPresent(cs.UV2Kind)&&(r.push(cs.UV2Kind),n.push("#define UV2"))),o.useLogarithmicDepth&&n.push("#define LOGARITHMICDEPTH")),i.useBones&&i.computeBonesUsingShaders?(r.push(cs.MatricesIndicesKind),r.push(cs.MatricesWeightsKind),i.numBoneInfluencers>4&&(r.push(cs.MatricesIndicesExtraKind),r.push(cs.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),n.push("#define BonesPerMesh "+(i.skeleton?i.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0");var a=i.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,n.push("#define MORPHTARGETS"),n.push("#define NUM_MORPH_INFLUENCERS "+s),Cu.PrepareAttributesForMorphTargetsInfluencers(r,i,s)),t&&(n.push("#define INSTANCES"),Cu.PushAttributesForInstances(r));var l=n.join("\n");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this.scene.getEngine().createEffect("outline",r,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences"],["diffuseSampler"],l,void 0,void 0,void 0,{maxSimultaneousMorphTargets:s})),this._effect.isReady()},e.prototype._beforeRenderingMesh=function(t,n,r){if(this._savedDepthWrite=this._engine.getDepthWrite(),t.renderOutline){var i=n.getMaterial();i&&i.needAlphaBlending()&&(this._engine.cacheStencilState(),this._engine.setDepthWrite(!1),this._engine.setColorWrite(!1),this._engine.setStencilBuffer(!0),this._engine.setStencilOperationPass(7681),this._engine.setStencilFunction(519),this._engine.setStencilMask(e._StencilReference),this._engine.setStencilFunctionReference(e._StencilReference),this.render(n,r,!0),this._engine.setColorWrite(!0),this._engine.setStencilFunction(517)),this._engine.setDepthWrite(!1),this.render(n,r),this._engine.setDepthWrite(this._savedDepthWrite),i&&i.needAlphaBlending()&&this._engine.restoreStencilState()}},e.prototype._afterRenderingMesh=function(e,t,n){if(e.renderOverlay){var r=this._engine.getAlphaMode(),i=this._engine.alphaState.alphaBlend;this._engine.setAlphaMode(2),this.render(t,n,!0),this._engine.setAlphaMode(r),this._engine.setDepthWrite(this._savedDepthWrite),this._engine.alphaState.alphaBlend=i}e.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(t,n),this._engine.setColorWrite(!0))},e._StencilReference=4,e}();!function(){function e(e,t){this.name=e,this.color=new ko(1,1,1,1),this.width=1,this.height=1,this.angle=0,this.invertU=0,this.invertV=0,this.animations=new Array,this.isPickable=!1,this._animationStarted=!1,this._loopAnimation=!1,this._fromIndex=0,this._toIndex=0,this._delay=0,this._direction=1,this._time=0,this.isVisible=!0,this._manager=t,this._manager.sprites.push(this),this.position=So.Zero()}Object.defineProperty(e.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!0,configurable:!0}),e.prototype.playAnimation=function(e,t,n,r,i){this._fromIndex=e,this._toIndex=t,this._loopAnimation=n,this._delay=r,this._animationStarted=!0,ethis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,(this._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex0?this._fromIndex:this._toIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},e.prototype.dispose=function(){for(var e=0;e0)for(var o=0;o=i.distance))&&(i=s,n))break}}return i||new ds},nl.prototype._internalMultiPickSprites=function(e,t,n){if(!ds)return null;var r=new Array;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}if(this.spriteManagers.length>0)for(var i=0;i0&&(n=i.pickSprite(e,t,this._spritePredicate,!1,i.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite&&n.pickedSprite.actionManager){switch(i._pickedDownSprite=n.pickedSprite,r.button){case 0:n.pickedSprite.actionManager.processTrigger(2,Fo.CreateNewFromSprite(n.pickedSprite,i,r));break;case 1:n.pickedSprite.actionManager.processTrigger(4,Fo.CreateNewFromSprite(n.pickedSprite,i,r));break;case 2:n.pickedSprite.actionManager.processTrigger(3,Fo.CreateNewFromSprite(n.pickedSprite,i,r))}n.pickedSprite.actionManager&&n.pickedSprite.actionManager.processTrigger(5,Fo.CreateNewFromSprite(n.pickedSprite,i,r))}return n},e.prototype._pointerUp=function(e,t,n,r){var i=this.scene;if(i.spriteManagers.length>0){var o=i.pickSprite(e,t,this._spritePredicate,!1,i.cameraToUseForPointers||void 0);o&&(o.hit&&o.pickedSprite&&o.pickedSprite.actionManager&&(o.pickedSprite.actionManager.processTrigger(7,Fo.CreateNewFromSprite(o.pickedSprite,i,r)),o.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||o.pickedSprite.actionManager.processTrigger(1,Fo.CreateNewFromSprite(o.pickedSprite,i,r)))),i._pickedDownSprite&&i._pickedDownSprite.actionManager&&i._pickedDownSprite!==o.pickedSprite&&i._pickedDownSprite.actionManager.processTrigger(16,Fo.CreateNewFromSprite(i._pickedDownSprite,i,r)))}return n},e}(),DA="uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest)\n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\ngl_FragColor=color;\n}";Qc.a.ShadersStore.spritesPixelShader=DA;var BA="\nattribute vec4 position;\nattribute vec4 options;\nattribute vec2 inverts;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include\nvoid main(void) {\nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;\nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0);\n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));\nvec2 uvPlace=cellInfo.xy;\nvec2 uvSize=cellInfo.zw;\nvUV.x=uvPlace.x+uvSize.x*uvOffset.x;\nvUV.y=uvPlace.y+uvSize.y*uvOffset.y;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}";Qc.a.ShadersStore.spritesVertexShader=BA;var FA=function(){function e(e,t,n,r,i,o,a,s,l){if(void 0===o&&(o=.01),void 0===a&&(a=Wl.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=!1),void 0===l&&(l=null),this.name=e,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.fogEnabled=!0,this.isPickable=!1,this._packedAndReady=!1,this.onDisposeObservable=new yo.a,this._vertexBuffers={},this._blendMode=2,this.disableDepthWrite=!1,i._getComponent(Gs.NAME_SPRITE)||i._addComponent(new kA(i)),this._capacity=n,this._fromPacked=s,this._spriteTexture=new Wl(t,i,!0,!1,a),this._spriteTexture.wrapU=Wl.CLAMP_ADDRESSMODE,this._spriteTexture.wrapV=Wl.CLAMP_ADDRESSMODE,r.width&&r.height)this.cellWidth=r.width,this.cellHeight=r.height;else{if(void 0===r)return;this.cellWidth=r,this.cellHeight=r}this._epsilon=o,this._scene=i,this._scene.spriteManagers.push(this);for(var c=[],u=0,d=0;d0);var u=e.substring(0,c-1)+".json",d=new XMLHttpRequest;d.open("GET",u,!0),d.onerror=function(){jo.a.Error("JSON ERROR: Unable to load JSON file."),n._fromPacked=!1,n._packedAndReady=!1},d.onload=function(){try{var e=JSON.parse(d.response),t=Reflect.ownKeys(e.frames);n._spriteMap=t,n._packedAndReady=!0,n._cellData=e.frames}catch(e){throw n._fromPacked=!1,n._packedAndReady=!1,new Error("Invalid JSON format. Please check documentation for format specifications.")}},d.send()}},e.prototype._appendSpriteVertex=function(e,t,n,r,i){var o=18*e;if(0===n?n=this._epsilon:1===n&&(n=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),this._vertexData[o]=t.position.x,this._vertexData[o+1]=t.position.y,this._vertexData[o+2]=t.position.z,this._vertexData[o+3]=t.angle,this._vertexData[o+4]=t.width,this._vertexData[o+5]=t.height,this._vertexData[o+6]=n,this._vertexData[o+7]=r,this._vertexData[o+8]=t.invertU?1:0,this._vertexData[o+9]=t.invertV?1:0,this._packedAndReady){t.cellRef||(t.cellIndex=0);var a=t.cellIndex;"number"==typeof a&&isFinite(a)&&Math.floor(a)===a&&(t.cellRef=this._spriteMap[t.cellIndex]),this._vertexData[o+10]=this._cellData[t.cellRef].frame.x/i.width,this._vertexData[o+11]=this._cellData[t.cellRef].frame.y/i.height,this._vertexData[o+12]=this._cellData[t.cellRef].frame.w/i.width,this._vertexData[o+13]=this._cellData[t.cellRef].frame.h/i.height}else{t.cellIndex||(t.cellIndex=0);var s=i.width/this.cellWidth,l=t.cellIndex/s>>0;this._vertexData[o+10]=(t.cellIndex-l*s)*this.cellWidth/i.width,this._vertexData[o+11]=l*this.cellHeight/i.height,this._vertexData[o+12]=this.cellWidth/i.width,this._vertexData[o+13]=this.cellHeight/i.height}this._vertexData[o+14]=t.color.r,this._vertexData[o+15]=t.color.g,this._vertexData[o+16]=t.color.b,this._vertexData[o+17]=t.color.a},e.prototype.intersects=function(e,t,n,r){for(var i=Math.min(this._capacity,this.sprites.length),o=So.Zero(),a=So.Zero(),s=Number.MAX_VALUE,l=null,c=Mo.Vector3[0],u=Mo.Vector3[1],d=t.getViewMatrix(),h=0;hf&&(s=f,l=p,r))break}}}if(l){var m=new ds;d.invertToRef(Mo.Matrix[0]),m.hit=!0,m.pickedSprite=l,m.distance=s;var g=Mo.Vector3[2];return g.copyFrom(e.direction),g.normalize(),g.scaleInPlace(s),e.origin.addToRef(g,c),m.pickedPoint=So.TransformCoordinates(c,Mo.Matrix[0]),m}return null},e.prototype.multiIntersects=function(e,t,n){for(var r,i=Math.min(this._capacity,this.sprites.length),o=So.Zero(),a=So.Zero(),s=[],l=Mo.Vector3[0].copyFromFloats(0,0,0),c=Mo.Vector3[1].copyFromFloats(0,0,0),u=t.getViewMatrix(),d=0;d0.) {\nmt=mod(time*animationData.z,1.0);\nfor(float f=0.; fmt){\nframeID=animationData.x;\nbreak;\n}\nanimationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);\n}\n}\n\nmat4 frameData=getFrameData(frameID+0.5);\nvec2 frameSize=(frameData[0].wz)/spriteMapSize;\nvec2 offset=frameData[0].xy*sheetUnits;\nvec2 ratio=frameData[2].xy/frameData[0].wz;\n\nif (frameData[2].z == 1.){\ntileUV.xy=tileUV.yx;\n}\nif (i == 0){\ncolor=texture2D(spriteSheet,tileUV*frameSize+offset);\n} else {\nvec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);\nfloat alpha=min(color.a+nc.a,1.0);\nvec3 mixed=mix(color.xyz,nc.xyz,nc.a);\ncolor=vec4(mixed,alpha);\n}\n}\ncolor.xyz*=colorMul;\ngl_FragColor=color;\n}";Qc.a.ShadersStore.spriteMapPixelShader=NA;var LA="precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nvarying vec3 vPosition;\nvarying vec2 vUV;\nvarying vec2 tUV;\nvarying vec2 stageUnits;\nvarying vec2 levelUnits;\nvarying vec2 tileID;\n\nuniform float time;\nuniform mat4 worldViewProjection;\nuniform vec2 outputSize;\nuniform vec2 stageSize;\nuniform vec2 spriteMapSize;\nuniform float stageScale;\nvoid main() {\nvec4 p=vec4( position,1. );\nvPosition=p.xyz;\nvUV=uv;\ntUV=uv*stageSize;\ngl_Position=worldViewProjection*p;\n}";Qc.a.ShadersStore.spriteMapVertexShader=LA;var UA;(function(){function e(e,t,n,r,i){var o=this;this.name=e,this.sprites=[],this.atlasJSON=t,this.sprites=this.atlasJSON.frames,this.spriteSheet=n,this.options=r,r.stageSize=r.stageSize||new Co(1,1),r.outputSize=r.outputSize||r.stageSize,r.outputPosition=r.outputPosition||So.Zero(),r.outputRotation=r.outputRotation||So.Zero(),r.layerCount=r.layerCount||1,r.maxAnimationFrames=r.maxAnimationFrames||0,r.baseTile=r.baseTile||0,r.flipU=r.flipU||!1,r.colorMultiply=r.colorMultiply||new So(1,1,1),this._scene=i,this._frameMap=this._createFrameBuffer(),this._tileMaps=new Array;for(var a=0;a0&&(e+="\n\r"),e+=this._tileMaps[t]._texture._bufferView.toString();var n=document.createElement("a");n.href="data:octet/stream;charset=utf-8,"+encodeURI(e),n.target="_blank",n.download=this.name+".tilemaps",n.click(),n.remove()},e.prototype.loadTileMaps=function(e){var t=this,n=new XMLHttpRequest;n.open("GET",e);var r=this.options.layerCount||0;n.onload=function(){for(var e=n.response.split("\n\r"),i=0;i-1&&this._tasks.splice(t,1)},e.prototype._decreaseWaitingTasksCount=function(e){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,e),this.onProgressObservable.notifyObservers(new jA(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){jo.a.Error("Error running progress callbacks."),console.log(e)}if(0===this._waitingTasksCount){try{var t=this._tasks.slice();this.onFinish&&this.onFinish(t);for(var n=0,r=t;n-1&&this._tasks.splice(i,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(e){jo.a.Error("Error running tasks-done callbacks."),console.log(e)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}},e.prototype._runTask=function(e){var t=this,n=function(n,r){e._setErrorObject(n,r),t.onTaskError&&t.onTaskError(e),t.onTaskErrorObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)};e.run(this._scene,(function(){try{t.onTaskSuccess&&t.onTaskSuccess(e),t.onTaskSuccessObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)}catch(e){n("Error executing task success callbacks",e)}}),n)},e.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},e.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,0===this._waitingTasksCount)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e=0&&this._meshes.splice(n,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var r=0;r0&&this._textureLoadingCallback(e)}this._currentScene.render()}},e.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},e.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},e.prototype._traverseFolder=function(e,t,n,r){var i=this,o=e.createReader(),a=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");o.readEntries((function(e){n.count+=e.length;for(var o=0,s=e;o0)){for(var n=new Array,r=[],i=e.dataTransfer?e.dataTransfer.items:null,o=0;o0&&jo.a.ClearLogCache(),this._engine.stopRenderLoop()),Ph.LoadAsync("file:",this._sceneFileToLoad,this._engine,(function(t){e._progressCallback&&e._progressCallback(t)})).then((function(t){e._currentScene&&e._currentScene.dispose(),e._currentScene=t,e._sceneLoadedCallback&&e._sceneLoadedCallback(e._sceneFileToLoad,e._currentScene),e._currentScene.executeWhenReady((function(){e._engine.runRenderLoop((function(){e.renderFunction()}))}))})).catch((function(t){e._errorCallback&&e._errorCallback(e._sceneFileToLoad,e._currentScene,t.message)}))):jo.a.Error("Please provide a valid .babylon file.")}}(),n(82),function(){function e(e){void 0===e&&(e=0),this.priority=e}return e.prototype.getDescription=function(){return""},e.prototype.apply=function(e,t){return!0},e}()),$A=function(e){function t(t,n,r){void 0===t&&(t=0),void 0===n&&(n=1024),void 0===r&&(r=.5);var i=e.call(this,t)||this;return i.priority=t,i.maximumSize=n,i.step=r,i}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,t){for(var n=!0,r=0;rthis.maximumSize&&(i.scale(this.step),n=!1)}}return n},t}(JA),e_=function(e){function t(t,n,r){void 0===t&&(t=0),void 0===n&&(n=2),void 0===r&&(r=.25);var i=e.call(this,t)||this;return i.priority=t,i.maximumScale=n,i.step=r,i._currentScale=-1,i._directionOffset=1,i}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},t.prototype.apply=function(e,t){return-1===this._currentScale&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),1===this._directionOffset?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(JA),t_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0},t}(JA),n_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning post-processes on/off"},t.prototype.apply=function(e,t){return e.postProcessesEnabled=t.isInImprovementMode,!0},t}(JA),r_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning lens flares on/off"},t.prototype.apply=function(e,t){return e.lensFlaresEnabled=t.isInImprovementMode,!0},t}(JA),i_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"},t.prototype.apply=function(e,t){return!this.onApply||this.onApply(e,t)},t}(JA),o_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,t){return e.particlesEnabled=t.isInImprovementMode,!0},t}(JA),a_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0},t}(JA),s_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof Pl))return!1;var t=e;return!t.isDisposed()&&(!(!t.isVisible||!t.isEnabled())&&(!(t.instances.length>0)&&(!t.skeleton&&!t.hasLODLevels)))},t}return Object(No.d)(t,e),Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,n,r){for(var i=e.meshes.slice(0),o=i.length,a=0;a=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var r=!0,i=!0,o=0;o0){o.animationGroups=[];for(var d=0;d0)for(o.reflectionProbes=[],n=0;n0&&setTimeout((function(){n.stopRecording()}),1e3*t),this._fileName=e,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise((function(e,t){n._resolve=e,n._reject=t}))},e.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},e.prototype._handleDataAvailable=function(e){e.data.size>0&&this._recordedChunks.push(e.data)},e.prototype._handleError=function(e){if(this.stopRecording(),!this._reject)throw new e.error;this._reject(e.error)},e.prototype._handleStop=function(){this.stopRecording();var e=new Blob(this._recordedChunks);this._resolve&&this._resolve(e),window.URL.createObjectURL(e),this._fileName&&Ja.Download(e,this._fileName)},e._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3}}(),function(){function e(){}return e.CreateScreenshot=function(t,n,r,i,o){void 0===o&&(o="image/png");var a=e._getScreenshotSize(t,n,r),s=a.height,l=a.width;if(s&&l){Ja._ScreenshotCanvas||(Ja._ScreenshotCanvas=document.createElement("canvas")),Ja._ScreenshotCanvas.width=l,Ja._ScreenshotCanvas.height=s;var c=Ja._ScreenshotCanvas.getContext("2d"),u=t.getRenderWidth()/t.getRenderHeight(),d=l,h=d/u;h>s&&(d=(h=s)*u);var p=Math.max(0,l-d)/2,f=Math.max(0,s-h)/2,m=t.getRenderingCanvas();c&&m&&c.drawImage(m,p,f,d,h),Ja.EncodeScreenshotCanvasData(i,o)}else jo.a.Error("Invalid 'size' parameter !")},e.CreateScreenshotAsync=function(t,n,r,i){return void 0===i&&(i="image/png"),new Promise((function(o,a){e.CreateScreenshot(t,n,r,(function(e){void 0!==e?o(e):a(new Error("Data is undefined"))}),i)}))},e.CreateScreenshotUsingRenderTarget=function(t,n,r,i,o,a,s,l,c){void 0===o&&(o="image/png"),void 0===a&&(a=1),void 0===s&&(s=!1),void 0===c&&(c=!1);var u=e._getScreenshotSize(t,n,r),d=u.height,h=u.width,p={width:h,height:d};if(d&&h){var f=n.getScene(),m=null;f.activeCamera!==n&&(m=f.activeCamera,f.activeCamera=n);var g=t.getRenderingCanvas();if(g){var b={width:g.width,height:g.height};t.setSize(h,d),f.render();var v=new mu("screenShot",p,f,!1,!1,0,!1,Wl.NEAREST_SAMPLINGMODE);v.renderList=null,v.samples=a,v.renderSprites=c,v.onAfterRenderObservable.add((function(){Ja.DumpFramebuffer(h,d,t,i,o,l)}));var A=function(){f.incrementRenderId(),f.resetCachedMaterial(),v.render(!0),v.dispose(),m&&(f.activeCamera=m),t.setSize(b.width,b.height),n.getProjectionMatrix(!0)};if(s){var _=new Qv("antialiasing",1,f.activeCamera);v.addPostProcess(_),_.getEffect().isReady()?A():_.getEffect().onCompiled=function(){A()}}else A()}else jo.a.Error("No rendering canvas found !")}else jo.a.Error("Invalid 'size' parameter !")},e.CreateScreenshotUsingRenderTargetAsync=function(t,n,r,i,o,a,s,l){return void 0===i&&(i="image/png"),void 0===o&&(o=1),void 0===a&&(a=!1),void 0===l&&(l=!1),new Promise((function(c,u){e.CreateScreenshotUsingRenderTarget(t,n,r,(function(e){void 0!==e?c(e):u(new Error("Data is undefined"))}),i,o,a,s,l)}))},e._getScreenshotSize=function(e,t,n){var r=0,i=0;if("object"==typeof n){var o=n.precision?Math.abs(n.precision):1;n.width&&n.height?(r=n.height*o,i=n.width*o):n.width&&!n.height?(i=n.width*o,r=Math.round(i/e.getAspectRatio(t))):n.height&&!n.width?(r=n.height*o,i=Math.round(r*e.getAspectRatio(t))):(i=Math.round(e.getRenderWidth()*o),r=Math.round(i/e.getAspectRatio(t)))}else isNaN(n)||(r=n,i=n);return i&&(i=Math.floor(i)),r&&(r=Math.floor(r)),{height:0|r,width:0|i}},e}());Ja.CreateScreenshot=h_.CreateScreenshot,Ja.CreateScreenshotAsync=h_.CreateScreenshotAsync,Ja.CreateScreenshotUsingRenderTarget=h_.CreateScreenshotUsingRenderTarget,Ja.CreateScreenshotUsingRenderTargetAsync=h_.CreateScreenshotUsingRenderTargetAsync,function(e){e[e.Checkbox=0]="Checkbox",e[e.Slider=1]="Slider",e[e.Vector3=2]="Vector3",e[e.Quaternion=3]="Quaternion",e[e.Color3=4]="Color3",e[e.String=5]="String"}(VA||(VA={}));var p_=function(){function e(e){this.byteOffset=0,this.buffer=e}return e.prototype.loadAsync=function(e){var t=this;return delete this._dataView,delete this._dataByteOffset,this.buffer.readAsync(this.byteOffset,e).then((function(e){t._dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),t._dataByteOffset=0}))},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,e},e.prototype.readUint8Array=function(e){var t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,e);return this._dataByteOffset+=e,this.byteOffset+=e,t},e.prototype.readString=function(e){return Jo.a.Decode(this.readUint8Array(e))},e.prototype.skipBytes=function(e){this._dataByteOffset+=e,this.byteOffset+=e},e}(),f_=function(e){function t(n,r){void 0===r&&(r={});var i=e.call(this,n)||this;return i.options=r,i._direction=new So(0,0,-1),i._mat=new Oo,i._onSelectEnabled=!1,i._origin=new So(0,0,0),i.lastNativeXRHitResults=[],i.onHitTestResultObservable=new yo.a,i._onHitTestResults=function(e){var t=e.map((function(e){var t=Oo.FromArray(e.hitMatrix);return i._xrSessionManager.scene.useRightHandedSystem||t.toggleModelMatrixHandInPlace(),i.options.worldParentNode&&t.multiplyToRef(i.options.worldParentNode.getWorldMatrix(),t),{xrHitResult:e,transformationMatrix:t}}));i.lastNativeXRHitResults=e,i.onHitTestResultObservable.notifyObservers(t)},i._onSelect=function(e){i._onSelectEnabled&&t.XRHitTestWithSelectEvent(e,i._xrSessionManager.referenceSpace)},i}return Object(No.d)(t,e),t.XRHitTestWithRay=function(e,t,n,r){return e.requestHitTest(t,n).then((function(e){var t=r||function(e){return!!e.hitMatrix};return e.filter(t)}))},t.XRHitTestWithSelectEvent=function(e,t){var n=e.frame.getPose(e.inputSource.targetRaySpace,t);if(!n)return Promise.resolve([]);var r=new XRRay(n.transform);return this.XRHitTestWithRay(e.frame.session,r,t)},t.prototype.attach=function(){return!!e.prototype.attach.call(this)&&(this.options.testOnPointerDownOnly&&this._xrSessionManager.session.addEventListener("select",this._onSelect,!1),!0)},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._onSelectEnabled=!1,this._xrSessionManager.session.removeEventListener("select",this._onSelect),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){if(this.attached&&!this.options.testOnPointerDownOnly){var n=e.getViewerPose(this._xrSessionManager.referenceSpace);if(n){Oo.FromArrayToRef(n.transform.matrix,0,this._mat),So.TransformCoordinatesFromFloatsToRef(0,0,0,this._mat,this._origin),So.TransformCoordinatesFromFloatsToRef(0,0,-1,this._mat,this._direction),this._direction.subtractInPlace(this._origin),this._direction.normalize();var r=new XRRay({x:this._origin.x,y:this._origin.y,z:this._origin.z,w:0},{x:this._direction.x,y:this._direction.y,z:this._direction.z,w:0});t.XRHitTestWithRay(this._xrSessionManager.session,r,this._xrSessionManager.referenceSpace).then(this._onHitTestResults)}}},t.Name=Kp.HIT_TEST,t.Version=1,t}(af);Xp.AddWebXRFeature(f_.Name,(function(e,t){return function(){return new f_(e,t)}}),f_.Version,!0);var m_=0,g_=(function(e){function t(t,n){void 0===n&&(n={});var r=e.call(this,t)||this;return r._options=n,r._enabled=!1,r._lastFrameDetected=new Set,r._onSelect=function(e){if(r._options.addAnchorOnSelect){var t=function(e){if(e.length){var t=e[0],n=new XRRigidTransform(t.hitMatrix);r.addAnchorAtRigidTransformation(n)}};r._hitTestModule&&!r._hitTestModule.options.testOnPointerDownOnly&&t(r._hitTestModule.lastNativeXRHitResults),f_.XRHitTestWithSelectEvent(e,r._xrSessionManager.referenceSpace).then(t),r._planeDetector}},r._trackedAnchors=[],r.onAnchorAddedObservable=new yo.a,r.onAnchorRemovedObservable=new yo.a,r.onAnchorUpdatedObservable=new yo.a,r}Object(No.d)(t,e),t.prototype.addAnchorAtRigidTransformation=function(e,t){return(t||this._xrSessionManager.session).createAnchor(e,this._xrSessionManager.referenceSpace)},t.prototype.attach=function(){return!!e.prototype.attach.call(this)&&(this._options.addAnchorOnSelect&&this._xrSessionManager.session.addEventListener("select",this._onSelect,!1),!0)},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._xrSessionManager.session.removeEventListener("select",this._onSelect),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onAnchorAddedObservable.clear(),this.onAnchorRemovedObservable.clear(),this.onAnchorUpdatedObservable.clear()},t.prototype.setHitTestModule=function(e){this._hitTestModule=e},t.prototype.setPlaneDetector=function(e,t){void 0===t&&(t=!0),this._planeDetector=e,this._options.usePlaneDetection=t},t.prototype._onXRFrame=function(e){var t=this;if(this.attached&&this._enabled&&e){var n=e.trackedAnchors;n&&n.size&&(this._trackedAnchors.filter((function(e){return!n.has(e.xrAnchor)})).map((function(e){var n=t._trackedAnchors.indexOf(e);t._trackedAnchors.splice(n,1),t.onAnchorRemovedObservable.notifyObservers(e)})),n.forEach((function(n){if(t._lastFrameDetected.has(n)){if(n.lastChangedTime===t._xrSessionManager.currentTimestamp){var r=t._findIndexInAnchorArray(n),i=t._trackedAnchors[r];t._updateAnchorWithXRFrame(n,i,e),t.onAnchorUpdatedObservable.notifyObservers(i)}}else{var o={id:m_++,xrAnchor:n},a=t._updateAnchorWithXRFrame(n,o,e);t._trackedAnchors.push(a),t.onAnchorAddedObservable.notifyObservers(a)}})),this._lastFrameDetected=n)}},t.prototype._findIndexInAnchorArray=function(e){for(var t=0;t0)throw new Error("Incompatible minimum version: "+n.minVersion)}var o={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!o)throw new Error("Unsupported version: "+n.version);return o(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: "+e.length);var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new Error("Unexpected magic: "+n);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: "+r);var i,o=e.readUint32();if(0!=e.buffer.byteLength&&o!==e.buffer.byteLength)throw new Error("Length in header does not match actual data length: "+o+" != "+e.buffer.byteLength);switch(r){case 1:i=t._unpackBinaryV1Async(e,o);break;case 2:i=t._unpackBinaryV2Async(e,o);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),i}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: "+r);var i=t-e.byteOffset,o={json:this._parseJson(e.readString(n)),bin:null};if(0!==i){var a=e.byteOffset;o.bin={readAsync:function(t,n){return e.buffer.readAsync(a+t,n)},byteLength:i}}return Promise.resolve(o)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,i=5130562,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},s=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case i:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(s):Promise.resolve(a)};return s()}))},e._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},e._compareVersion=function(e,t){return e.major>t.major?1:e.majort.minor?1:e.minor "+R_[R_.READY],i=R_[R_.LOADING]+" => "+R_[R_.COMPLETE];n._parent._startPerformanceCounter(r),n._parent._startPerformanceCounter(i),n._setState(R_.LOADING),n._extensionsOnLoading();var o=new Array,a=n._babylonScene.blockMaterialDirtyMechanism;if(n._babylonScene.blockMaterialDirtyMechanism=!0,e)o.push(n.loadSceneAsync("/nodes",{nodes:e,index:-1}));else if(null!=n._gltf.scene||n._gltf.scenes&&n._gltf.scenes[0]){var s=k_.Get("/scene",n._gltf.scenes,n._gltf.scene||0);o.push(n.loadSceneAsync("/scenes/"+s.index,s))}n._babylonScene.blockMaterialDirtyMechanism=a,n._parent.compileMaterials&&o.push(n._compileMaterialsAsync()),n._parent.compileShadowGenerators&&o.push(n._compileShadowGeneratorsAsync());var l=Promise.all(o).then((function(){return n._rootBabylonMesh&&n._rootBabylonMesh.setEnabled(!0),n._setState(R_.READY),n._extensionsOnReady(),n._startAnimations(),t()}));return l.then((function(){n._parent._endPerformanceCounter(r),Ja.SetImmediate((function(){n._disposed||Promise.all(n._completePromises).then((function(){n._parent._endPerformanceCounter(i),n._setState(R_.COMPLETE),n._parent.onCompleteObservable.notifyObservers(void 0),n._parent.onCompleteObservable.clear(),n.dispose()}),(function(e){n._parent.onErrorObservable.notifyObservers(e),n._parent.onErrorObservable.clear(),n.dispose()}))}))})),l}),(function(e){throw n._disposed||(n._parent.onErrorObservable.notifyObservers(e),n._parent.onErrorObservable.clear(),n.dispose()),e}))},e.prototype._loadData=function(e){if(this._gltf=e.json,this._setupData(),e.bin){var t=this._gltf.buffers;if(t&&t[0]&&!t[0].uri){var n=t[0];(n.byteLengthe.bin.byteLength)&&jo.a.Warn("Binary buffer length ("+n.byteLength+") from JSON does not match chunk length ("+e.bin.byteLength+")"),this._bin=e.bin}else jo.a.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(k_.Assign(this._gltf.accessors),k_.Assign(this._gltf.animations),k_.Assign(this._gltf.buffers),k_.Assign(this._gltf.bufferViews),k_.Assign(this._gltf.cameras),k_.Assign(this._gltf.images),k_.Assign(this._gltf.materials),k_.Assign(this._gltf.meshes),k_.Assign(this._gltf.nodes),k_.Assign(this._gltf.samplers),k_.Assign(this._gltf.scenes),k_.Assign(this._gltf.skins),k_.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t=2)throw new Error(t+"/texCoord: Invalid value ("+n.texCoord+")");var a=k_.Get(t+"/index",this._gltf.textures,n.index),s=this._loadTextureAsync("/textures/"+n.index,a,(function(o){o.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(o,t),i._parent.onTextureLoadedObservable.notifyObservers(o),r(o)}));return this.logClose(),s},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var i=this._extensionsLoadTextureAsync(t,n,r);if(i)return i;this.logOpen(t+" "+(n.name||""));var o=null==n.sampler?e.DefaultSampler:k_.Get(t+"/sampler",this._gltf.samplers,n.sampler),a=k_.Get(t+"/source",this._gltf.images,n.source),s=this._createTextureAsync(t,o,a,r);return this.logClose(),s},e.prototype._createTextureAsync=function(e,t,n,r){var i=this;void 0===r&&(r=function(){});var o=this._loadSampler("/samplers/"+t.index,t),a=new Array,s=new ZA;this._babylonScene._blockEntityCollection=this._forAssetContainer;var l=new Wl(null,this._babylonScene,o.noMipMaps,!1,o.samplingMode,(function(){i._disposed||s.resolve()}),(function(t,n){i._disposed||s.reject(new Error(e+": "+(n&&n.message?n.message:t||"Failed to load texture")))}),void 0,void 0,void 0,n.mimeType);return this._babylonScene._blockEntityCollection=!1,a.push(s.promise),a.push(this.loadImageAsync("/images/"+n.index,n).then((function(e){var t=n.uri||i._fileName+"#image"+n.index,r="data:"+i._uniqueRootUrl+t;l.updateURL(r,e)}))),l.wrapU=o.wrapU,l.wrapV=o.wrapV,r(l),Promise.all(a).then((function(){return l}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode(t+"/wrapS",n.wrapS),wrapV:e._GetTextureWrapMode(t+"/wrapT",n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen(e+" "+(t.name||"")),t.uri)t._data=this.loadUriAsync(e+"/uri",t,t.uri);else{var n=k_.Get(e+"/bufferView",this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/"+n.index,n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,r){var i=this,o=this._extensionsLoadUriAsync(t,n,r);if(o)return o;if(!e._ValidateUri(r))throw new Error(t+": '"+r+"' is invalid");if(Ja.IsBase64(r)){var a=new Uint8Array(Ja.DecodeBase64(r));return this.log("Decoded "+r.substr(0,64)+"... ("+a.length+" bytes)"),Promise.resolve(a)}return this.log("Loading "+r),this._parent.preprocessUrlAsync(this._rootUrl+r).then((function(e){return new Promise((function(n,o){if(!i._disposed){var a=Ja.LoadFile(e,(function(e){if(!i._disposed){var t=new Uint8Array(e);i.log("Loaded "+r+" ("+t.length+" bytes)"),n(t)}}),(function(e){if(!i._disposed&&(a&&(a._lengthComputable=e.lengthComputable,a._loaded=e.loaded,a._total=e.total),i._state===R_.LOADING))try{i._onProgress()}catch(e){o(e)}}),i._babylonScene.offlineProvider,!0,(function(e,n){i._disposed||o(new ja(t+": Failed to load '"+r+"'"+(e?": "+e.status+" "+e.statusText:""),e))}));i._requests.push(a)}}))}))},e.prototype._onProgress=function(){if(this._progressCallback){for(var e=!0,t=0,n=0,r=0,i=this._requests;r=c?e?"":void 0:(o=s.charCodeAt(l))<55296||o>56319||l+1===c||(a=s.charCodeAt(l+1))<56320||a>57343?e?s.charAt(l):o:e?s.slice(l,l+2):a-56320+(o-55296<<10)+65536}}},function(e,t,n){"use strict";var r=n(103),i=n(68),o=n(104),a={};n(59)(a,n(37)("iterator"),(function(){return this})),e.exports=function(e,t,n){e.prototype=r(a,{next:i(1,n)}),o(e,t+" Iterator")}},function(e,t,n){var r=n(49),i=n(60),o=n(73);e.exports=n(50)?Object.defineProperties:function(e,t){i(e);for(var n,a=o(t),s=a.length,l=0;s>l;)r.f(e,n=a[l++],t[n]);return e}},function(e,t,n){var r=n(48).document;e.exports=r&&r.documentElement},function(e,t,n){n(207);for(var r=n(48),i=n(59),o=n(70),a=n(37)("toStringTag"),s="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),l=0;l=e.length?(this._t=void 0,i(1)):i(0,"keys"==t?n:"values"==t?e[n]:[n,e[n]])}),"values"),o.Arguments=o.Array,r("keys"),r("values"),r("entries")},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){e.exports={default:n(211),__esModule:!0}},function(e,t,n){n(212),n(217),n(218),n(219),e.exports=n(32).Symbol},function(e,t,n){"use strict";var r=n(48),i=n(53),o=n(50),a=n(47),s=n(131),l=n(213).KEY,c=n(62),u=n(99),d=n(104),h=n(75),p=n(37),f=n(105),m=n(106),g=n(214),b=n(215),v=n(60),A=n(61),_=n(69),y=n(54),x=n(94),w=n(68),E=n(103),C=n(216),S=n(107),T=n(101),P=n(49),O=n(73),R=S.f,M=P.f,I=C.f,k=r.Symbol,D=r.JSON,B=D&&D.stringify,F=p("_hidden"),N=p("toPrimitive"),L={}.propertyIsEnumerable,U=u("symbol-registry"),V=u("symbols"),z=u("op-symbols"),j=Object.prototype,G="function"==typeof k&&!!T.f,H=r.QObject,Q=!H||!H.prototype||!H.prototype.findChild,W=o&&c((function(){return 7!=E(M({},"a",{get:function(){return M(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=R(j,t);r&&delete j[t],M(e,t,n),r&&e!==j&&M(j,t,r)}:M,K=function(e){var t=V[e]=E(k.prototype);return t._k=e,t},X=G&&"symbol"==typeof k.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof k},Y=function(e,t,n){return e===j&&Y(z,t,n),v(e),t=x(t,!0),v(n),i(V,t)?(n.enumerable?(i(e,F)&&e[F][t]&&(e[F][t]=!1),n=E(n,{enumerable:w(0,!1)})):(i(e,F)||M(e,F,w(1,{})),e[F][t]=!0),W(e,t,n)):M(e,t,n)},q=function(e,t){v(e);for(var n,r=g(t=y(t)),i=0,o=r.length;o>i;)Y(e,n=r[i++],t[n]);return e},Z=function(e){var t=L.call(this,e=x(e,!0));return!(this===j&&i(V,e)&&!i(z,e))&&(!(t||!i(this,e)||!i(V,e)||i(this,F)&&this[F][e])||t)},J=function(e,t){if(e=y(e),t=x(t,!0),e!==j||!i(V,t)||i(z,t)){var n=R(e,t);return!n||!i(V,t)||i(e,F)&&e[F][t]||(n.enumerable=!0),n}},$=function(e){for(var t,n=I(y(e)),r=[],o=0;n.length>o;)i(V,t=n[o++])||t==F||t==l||r.push(t);return r},ee=function(e){for(var t,n=e===j,r=I(n?z:y(e)),o=[],a=0;r.length>a;)!i(V,t=r[a++])||n&&!i(j,t)||o.push(V[t]);return o};G||(s((k=function(){if(this instanceof k)throw TypeError("Symbol is not a constructor!");var e=h(arguments.length>0?arguments[0]:void 0),t=function(n){this===j&&t.call(z,n),i(this,F)&&i(this[F],e)&&(this[F][e]=!1),W(this,e,w(1,n))};return o&&Q&&W(j,e,{configurable:!0,set:t}),K(e)}).prototype,"toString",(function(){return this._k})),S.f=J,P.f=Y,n(133).f=C.f=$,n(76).f=Z,T.f=ee,o&&!n(74)&&s(j,"propertyIsEnumerable",Z,!0),f.f=function(e){return K(p(e))}),a(a.G+a.W+a.F*!G,{Symbol:k});for(var te="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),ne=0;te.length>ne;)p(te[ne++]);for(var re=O(p.store),ie=0;re.length>ie;)m(re[ie++]);a(a.S+a.F*!G,"Symbol",{for:function(e){return i(U,e+="")?U[e]:U[e]=k(e)},keyFor:function(e){if(!X(e))throw TypeError(e+" is not a symbol!");for(var t in U)if(U[t]===e)return t},useSetter:function(){Q=!0},useSimple:function(){Q=!1}}),a(a.S+a.F*!G,"Object",{create:function(e,t){return void 0===t?E(e):q(E(e),t)},defineProperty:Y,defineProperties:q,getOwnPropertyDescriptor:J,getOwnPropertyNames:$,getOwnPropertySymbols:ee});var oe=c((function(){T.f(1)}));a(a.S+a.F*oe,"Object",{getOwnPropertySymbols:function(e){return T.f(_(e))}}),D&&a(a.S+a.F*(!G||c((function(){var e=k();return"[null]"!=B([e])||"{}"!=B({a:e})||"{}"!=B(Object(e))}))),"JSON",{stringify:function(e){for(var t,n,r=[e],i=1;arguments.length>i;)r.push(arguments[i++]);if(n=t=r[1],(A(t)||void 0!==e)&&!X(e))return b(t)||(t=function(e,t){if("function"==typeof n&&(t=n.call(this,e,t)),!X(t))return t}),r[1]=t,B.apply(D,r)}}),k.prototype[N]||n(59)(k.prototype,N,k.prototype.valueOf),d(k,"Symbol"),d(Math,"Math",!0),d(r.JSON,"JSON",!0)},function(e,t,n){var r=n(75)("meta"),i=n(61),o=n(53),a=n(49).f,s=0,l=Object.isExtensible||function(){return!0},c=!n(62)((function(){return l(Object.preventExtensions({}))})),u=function(e){a(e,r,{value:{i:"O"+ ++s,w:{}}})},d=e.exports={KEY:r,NEED:!1,fastKey:function(e,t){if(!i(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!o(e,r)){if(!l(e))return"F";if(!t)return"E";u(e)}return e[r].i},getWeak:function(e,t){if(!o(e,r)){if(!l(e))return!0;if(!t)return!1;u(e)}return e[r].w},onFreeze:function(e){return c&&d.NEED&&l(e)&&!o(e,r)&&u(e),e}}},function(e,t,n){var r=n(73),i=n(101),o=n(76);e.exports=function(e){var t=r(e),n=i.f;if(n)for(var a,s=n(e),l=o.f,c=0;s.length>c;)l.call(e,a=s[c++])&&t.push(a);return t}},function(e,t,n){var r=n(95);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,n){var r=n(54),i=n(133).f,o={}.toString,a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.f=function(e){return a&&"[object Window]"==o.call(e)?function(e){try{return i(e)}catch(e){return a.slice()}}(e):i(r(e))}},function(e,t){},function(e,t,n){n(106)("asyncIterator")},function(e,t,n){n(106)("observable")},function(e,t,n){e.exports={default:n(221),__esModule:!0}},function(e,t,n){n(222),e.exports=n(32).Object.setPrototypeOf},function(e,t,n){var r=n(47);r(r.S,"Object",{setPrototypeOf:n(223).set})},function(e,t,n){var r=n(61),i=n(60),o=function(e,t){if(i(e),!r(t)&&null!==t)throw TypeError(t+": can't set as prototype!")};e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,r){try{(r=n(93)(Function.call,n(107).f(Object.prototype,"__proto__").set,2))(e,[]),t=!(e instanceof Array)}catch(e){t=!0}return function(e,n){return o(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:o}},function(e,t,n){e.exports={default:n(225),__esModule:!0}},function(e,t,n){n(226);var r=n(32).Object;e.exports=function(e,t){return r.create(e,t)}},function(e,t,n){var r=n(47);r(r.S,"Object",{create:n(103)})},function(e,t,n){"use strict";var r=n(228);function i(){}function o(){}o.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,o,a){if(a!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:i};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(230)),o=r(n(91)),a=["altKey","bubbles","cancelable","ctrlKey","currentTarget","eventPhase","metaKey","shiftKey","target","timeStamp","view","type"];function s(e){return null==e}var l=[{reg:/^key/,props:["char","charCode","key","keyCode","which"],fix:function(e,t){s(e.which)&&(e.which=s(t.charCode)?t.keyCode:t.charCode),void 0===e.metaKey&&(e.metaKey=e.ctrlKey)}},{reg:/^touch/,props:["touches","changedTouches","targetTouches"]},{reg:/^hashchange$/,props:["newURL","oldURL"]},{reg:/^gesturechange$/i,props:["rotation","scale"]},{reg:/^(mousewheel|DOMMouseScroll)$/,props:[],fix:function(e,t){var n=void 0,r=void 0,i=void 0,o=t.wheelDelta,a=t.axis,s=t.wheelDeltaY,l=t.wheelDeltaX,c=t.detail;o&&(i=o/120),c&&(i=0-(c%3==0?c/3:c)),void 0!==a&&(a===e.HORIZONTAL_AXIS?(r=0,n=0-i):a===e.VERTICAL_AXIS&&(n=0,r=i)),void 0!==s&&(r=s/120),void 0!==l&&(n=-1*l/120),n||r||(r=i),void 0!==n&&(e.deltaX=n),void 0!==r&&(e.deltaY=r),void 0!==i&&(e.delta=i)}},{reg:/^mouse|contextmenu|click|mspointer|(^DOMMouseScroll$)/i,props:["buttons","clientX","clientY","button","offsetX","relatedTarget","which","fromElement","toElement","offsetY","pageX","pageY","screenX","screenY"],fix:function(e,t){var n=void 0,r=void 0,i=void 0,o=e.target,a=t.button;return o&&s(e.pageX)&&!s(t.clientX)&&(r=(n=o.ownerDocument||document).documentElement,i=n.body,e.pageX=t.clientX+(r&&r.scrollLeft||i&&i.scrollLeft||0)-(r&&r.clientLeft||i&&i.clientLeft||0),e.pageY=t.clientY+(r&&r.scrollTop||i&&i.scrollTop||0)-(r&&r.clientTop||i&&i.clientTop||0)),e.which||void 0===a||(e.which=1&a?1:2&a?3:4&a?2:0),!e.relatedTarget&&e.fromElement&&(e.relatedTarget=e.fromElement===o?e.toElement:e.fromElement),e}}];function c(){return!0}function u(){return!1}function d(e){var t=e.type,n="function"==typeof e.stopPropagation||"boolean"==typeof e.cancelBubble;i.default.call(this),this.nativeEvent=e;var r=u;"defaultPrevented"in e?r=e.defaultPrevented?c:u:"getPreventDefault"in e?r=e.getPreventDefault()?c:u:"returnValue"in e&&(r=!1===e.returnValue?c:u),this.isDefaultPrevented=r;var o=[],s=void 0,d=void 0,h=a.concat();for(l.forEach((function(e){t.match(e.reg)&&(h=h.concat(e.props),e.fix&&o.push(e.fix))})),s=h.length;s;)this[d=h[--s]]=e[d];for(!this.target&&n&&(this.target=e.srcElement||document),this.target&&3===this.target.nodeType&&(this.target=this.target.parentNode),s=o.length;s;)(0,o[--s])(this,e);this.timeStamp=e.timeStamp||Date.now()}var h=i.default.prototype;(0,o.default)(d.prototype,h,{constructor:d,preventDefault:function(){var e=this.nativeEvent;e.preventDefault?e.preventDefault():e.returnValue=!1,h.preventDefault.call(this)},stopPropagation:function(){var e=this.nativeEvent;e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,h.stopPropagation.call(this)}}),t.default=d,e.exports=t.default},function(e,t,n){"use strict";function r(){return!1}function i(){return!0}function o(){this.timeStamp=Date.now(),this.target=void 0,this.currentTarget=void 0}Object.defineProperty(t,"__esModule",{value:!0}),o.prototype={isEventObject:1,constructor:o,isDefaultPrevented:r,isPropagationStopped:r,isImmediatePropagationStopped:r,preventDefault:function(){this.isDefaultPrevented=i},stopPropagation:function(){this.isPropagationStopped=i},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=i,this.stopPropagation()},halt:function(e){e?this.stopImmediatePropagation():this.stopPropagation(),this.preventDefault()}},t.default=o,e.exports=t.default},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(232)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="CloseCircleFilled";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"close-circle",theme:"filled",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(234)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="LoadingOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"loading",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(236)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="SearchOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"search",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(238)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="DownOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"down",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(240)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="CheckOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"check",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 00-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(242)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="CloseOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"close",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"}}]}}},function(e,t){e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(245)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="FileOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"file",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(247)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="MinusSquareOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"minus-square",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M328 544h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(249)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="PlusSquareOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"plus-square",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(251)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="CaretDownFilled";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"caret-down",theme:"filled",icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"}}]}}},function(e,t,n){var r=n(136);e.exports=function(){return r.Date.now()}},function(e,t,n){(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(58))},function(e,t,n){var r=n(135),i=n(255),o=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(r(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=r(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var n=s.test(e);return n||l.test(e)?c(e.slice(2),n?2:8):a.test(e)?NaN:+e}},function(e,t,n){var r=n(256),i=n(259);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==r(e)}},function(e,t,n){var r=n(137),i=n(257),o=n(258),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?i(e):o(e)}},function(e,t,n){var r=n(137),i=Object.prototype,o=i.hasOwnProperty,a=i.toString,s=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,s),n=e[s];try{e[s]=void 0;var r=!0}catch(e){}var i=a.call(e);return r&&(t?e[s]=n:delete e[s]),i}},function(e,t){var n=Object.prototype.toString;e.exports=function(e){return n.call(e)}},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(261)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="FolderOpenOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"folder-open",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 00-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z"}}]}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n(1)),o=s(n(263)),a=s(n(27));function s(e){return e&&e.__esModule?e:{default:e}}function l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}var c=function(e,t){return i.createElement(a.default,Object.assign({},e,{ref:t,icon:o.default}))};c.displayName="FolderOutlined";var u=i.forwardRef(c);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={name:"folder",theme:"outlined",icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"}}]}}},function(e,t,n){e.exports={default:n(265),__esModule:!0}},function(e,t,n){n(266),e.exports=n(32).Object.getPrototypeOf},function(e,t,n){var r=n(69),i=n(132);n(138)("getPrototypeOf",(function(){return function(e){return i(r(e))}}))},function(e,t,n){e.exports={default:n(268),__esModule:!0}},function(e,t,n){n(269);var r=n(32).Object;e.exports=function(e,t){return r.getOwnPropertyDescriptor(e,t)}},function(e,t,n){var r=n(54),i=n(107).f;n(138)("getOwnPropertyDescriptor",(function(){return function(e,t){return i(r(e),t)}}))},function(e,t,n){e.exports={default:n(271),__esModule:!0}},function(e,t,n){n(129),n(272),e.exports=n(32).Array.from},function(e,t,n){"use strict";var r=n(93),i=n(47),o=n(69),a=n(273),s=n(274),l=n(125),c=n(275),u=n(276);i(i.S+i.F*!n(278)((function(e){Array.from(e)})),"Array",{from:function(e){var t,n,i,d,h=o(e),p="function"==typeof this?this:Array,f=arguments.length,m=f>1?arguments[1]:void 0,g=void 0!==m,b=0,v=u(h);if(g&&(m=r(m,f>2?arguments[2]:void 0,2)),null==v||p==Array&&s(v))for(n=new p(t=l(h.length));t>b;b++)c(n,b,g?m(h[b],b):h[b]);else for(d=v.call(h),n=new p;!(i=d.next()).done;b++)c(n,b,g?a(d,m,[i.value,b],!0):i.value);return n.length=b,n}})},function(e,t,n){var r=n(60);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var o=e.return;throw void 0!==o&&r(o.call(e)),t}}},function(e,t,n){var r=n(70),i=n(37)("iterator"),o=Array.prototype;e.exports=function(e){return void 0!==e&&(r.Array===e||o[i]===e)}},function(e,t,n){"use strict";var r=n(49),i=n(68);e.exports=function(e,t,n){t in e?r.f(e,t,i(0,n)):e[t]=n}},function(e,t,n){var r=n(277),i=n(37)("iterator"),o=n(70);e.exports=n(32).getIteratorMethod=function(e){if(null!=e)return e[i]||e["@@iterator"]||o[r(e)]}},function(e,t,n){var r=n(95),i=n(37)("toStringTag"),o="Arguments"==r(function(){return arguments}());e.exports=function(e){var t,n,a;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),i))?n:o?r(t):"Object"==(a=r(t))&&"function"==typeof t.callee?"Arguments":a}},function(e,t,n){var r=n(37)("iterator"),i=!1;try{var o=[7][r]();o.return=function(){i=!0},Array.from(o,(function(){throw 2}))}catch(e){}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var o=[7],a=o[r]();a.next=function(){return{done:n=!0}},o[r]=function(){return a},e(o)}catch(e){}return n}},function(e,t){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CloseIcon=t.InfoIcon=t.FlameIcon=t.CheckIcon=t.AlertIcon=void 0;var r,i=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:p.NOOP;return function(){t(e),r.remove(e)}},r.add=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p.NOOP,o=t.id||(0,p.generateUEID)(),a=function(){return n(o)};if(!r.has(o))return r.setState((function(n){var r=i({content:e,id:o},t);return{toasts:[].concat(f(n.toasts),[r])}}),a),o},r.remove=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p.NOOP,n=function(){return t(e)};r.has(e)&&r.setState((function(t){return{toasts:t.toasts.filter((function(t){return t.id!==e}))}}),n)},r.removeAll=function(){r.state.toasts.length&&r.state.toasts.forEach((function(e){return r.remove(e.id)}))},r.update=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p.NOOP,o=function(){return n(e)};r.has(e)&&r.setState((function(n){var r=n.toasts,o=r.findIndex((function(t){return t.id===e})),a=i({},r[o],t);return{toasts:[].concat(f(r.slice(0,o)),[a],f(r.slice(o+1)))}}),o)},g(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"render",value:function(){var e=this,t=this.props,n=t.autoDismiss,r=t.autoDismissTimeout,o=t.children,a=t.components,d=t.placement,h=t.transitionDuration,p=i({},b,a),f=p.Toast,m=p.ToastContainer,g=this.add,v=this.remove,A=this.removeAll,x=this.update,w=Object.freeze(this.state.toasts),E=Boolean(w.length),C=y?document.body:null;return s.default.createElement(_,{value:{add:g,remove:v,removeAll:A,update:x,toasts:w}},o,C?(0,l.createPortal)(s.default.createElement(m,{placement:d,hasToasts:E},s.default.createElement(c.TransitionGroup,{component:null},w.map((function(t){var o=t.appearance,a=t.autoDismiss,l=t.content,p=t.id,m=t.onDismiss,g=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(t,["appearance","autoDismiss","content","id","onDismiss"]);return s.default.createElement(c.Transition,{appear:!0,key:p,mountOnEnter:!0,timeout:h,unmountOnExit:!0},(function(t){return s.default.createElement(u.ToastController,i({appearance:o,autoDismiss:void 0!==a?a:n,autoDismissTimeout:r,component:f,key:p,onDismiss:e.onDismiss(p,m),placement:d,transitionDuration:h,transitionState:t},g),l)}))})))),C):s.default.createElement(m,{placement:d,hasToasts:E}))}}]),t}(a.Component)).defaultProps={autoDismiss:!1,autoDismissTimeout:5e3,components:b,placement:"top-right",transitionDuration:220};var x=t.ToastConsumer=function(e){var t=e.children;return s.default.createElement(A,null,(function(e){return t(e)}))};t.withToastManager=function(e){return s.default.forwardRef((function(t,n){return s.default.createElement(x,null,(function(r){return s.default.createElement(e,i({toastManager:r},t,{ref:n}))}))}))},t.useToasts=function(){var e=(0,a.useContext)(v);if(!e)throw Error("The `useToasts` hook must be called from a descendent of the `ToastProvider`.");return{addToast:e.add,removeToast:e.remove,removeAllToasts:e.removeAll,updateToast:e.update,toastStack:e.toasts}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ToastController=void 0;var r,i=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["autoDismiss","autoDismissTimeout","component"]),a=this.state.isRunning,c=t?this.onMouseEnter:l.NOOP,u=t?this.onMouseLeave:l.NOOP;return s.default.createElement(r,i({autoDismiss:t,autoDismissTimeout:n,isRunning:a,onMouseEnter:c,onMouseLeave:u},o))}}]),t}(a.Component)).defaultProps={autoDismiss:!1}},function(e,t,n){const{defaultArgs:r,baseOptions:i}=n(285),{setLogging:o,setCustomLogger:a,log:s}=n(140),l=n(286),c=n(287),{defaultOptions:u,getCreateFFmpegCore:d}=n(141),{version:h}=n(142),p=Error("ffmpeg.wasm is not ready, make sure you have completed load().");e.exports=(e={})=>{const{log:t,logger:n,progress:f,...m}={...i,...u,...e};let g=null,b=null,v=null,A=!1,_=f;const y=({type:e,message:t})=>{s(e,t),l(t,_),(e=>{"FFMPEG_END"===e&&null!==v&&(v(),v=null,A=!1)})(t)};return o(t),a(n),s("info",`use ffmpeg.wasm v${h}`),{setProgress:e=>{_=e},setLogger:e=>{a(e)},setLogging:o,load:async()=>{if(s("info","load ffmpeg-core"),null!==g)throw Error("ffmpeg.wasm was loaded, you should not load it again, use ffmpeg.isLoaded() to check next time.");{s("info","loading ffmpeg-core");const{createFFmpegCore:e,corePath:t,workerPath:n,wasmPath:r}=await d(m);g=await e({mainScriptUrlOrBlob:t,printErr:e=>y({type:"fferr",message:e}),print:e=>y({type:"ffout",message:e}),locateFile:(e,t)=>{if("undefined"!=typeof window){if(void 0!==r&&e.endsWith("ffmpeg-core.wasm"))return r;if(void 0!==n&&e.endsWith("ffmpeg-core.worker.js"))return n}return t+e}}),b=g.cwrap("proxy_main","number",["number","number"]),s("info","ffmpeg-core loaded")}},isLoaded:()=>null!==g,run:(...e)=>{if(s("info",`run ffmpeg command: ${e.join(" ")}`),null===g)throw p;if(A)throw Error("ffmpeg.wasm can only run one command at a time");return A=!0,new Promise(t=>{const n=[...r,...e].filter(e=>0!==e.length);v=t,b(...c(g,n))})},FS:(e,...t)=>{if(s("info",`run FS.${e} ${t.map(e=>"string"==typeof e?e:`<${e.length} bytes binary file>`).join(" ")}`),null===g)throw p;{let n=null;try{n=g.FS[e](...t)}catch(n){throw"readdir"===e?Error(`ffmpeg.FS('readdir', '${t[0]}') error. Check if the path exists, ex: ffmpeg.FS('readdir', '/')`):"readFile"===e?Error(`ffmpeg.FS('readFile', '${t[0]}') error. Check if the path exists`):Error("Oops, something went wrong in FS operation.")}return n}}}}},function(e,t){e.exports={defaultArgs:["./ffmpeg","-nostdin","-y"],baseOptions:{log:!1,logger:()=>{},progress:()=>{},corePath:""}}},function(e,t){let n=0;const r=e=>{const[t,n,r]=e.split(":");return 60*parseFloat(t)*60+60*parseFloat(n)+parseFloat(r)};e.exports=(e,t)=>{if("string"==typeof e)if(e.startsWith(" Duration")){const t=e.split(", ")[0].split(": ")[1],i=r(t);(0===n||n>i)&&(n=i)}else if(e.startsWith("frame")){const i=e.split("time=")[1].split(" ")[0];t({ratio:r(i)/n})}else e.startsWith("video:")&&(t({ratio:1}),n=0)}},function(e,t){e.exports=(e,t)=>{const n=e._malloc(t.length*Uint32Array.BYTES_PER_ELEMENT);return t.forEach((t,r)=>{const i=e._malloc(t.length+1);e.writeAsciiToMemory(t,i),e.setValue(n+Uint32Array.BYTES_PER_ELEMENT*r,i,"i32")}),[t.length,n]}},function(e,t,n){(function(t){const r=n(110),{devDependencies:i}=n(142);e.exports={corePath:void 0!==t&&"development"===t.env.FFMPEG_ENV?r("/node_modules/@ffmpeg/core/dist/ffmpeg-core.js"):`https://unpkg.com/@ffmpeg/core@${i["@ffmpeg/core"].substring(1)}/dist/ffmpeg-core.js`}}).call(this,n(92))},function(e,t,n){const r=n(110),{log:i}=n(140),o=async(e,t)=>{i("info",`fetch ${e}`);const n=await(await fetch(e)).arrayBuffer();i("info",`${e} file size = ${n.byteLength} bytes`);const r=new Blob([n],{type:t}),o=URL.createObjectURL(r);return i("info",`${e} blob URL = ${o}`),o};e.exports=async({corePath:e})=>{if("string"!=typeof e)throw Error("corePath should be a string!");const t=r(e),n=await o(t,"application/javascript"),a=await o(t.replace("ffmpeg-core.js","ffmpeg-core.wasm"),"application/wasm"),s=await o(t.replace("ffmpeg-core.js","ffmpeg-core.worker.js"),"application/javascript");return"undefined"==typeof createFFmpegCore?new Promise(e=>{const t=document.createElement("script"),r=()=>{t.removeEventListener("load",r),i("info","ffmpeg-core.js script loaded"),e({createFFmpegCore:createFFmpegCore,corePath:n,wasmPath:a,workerPath:s})};t.src=n,t.type="text/javascript",t.addEventListener("load",r),document.getElementsByTagName("head")[0].appendChild(t)}):(i("info","ffmpeg-core.js script is loaded already"),Promise.resolve({createFFmpegCore:createFFmpegCore,corePath:n,wasmPath:a,workerPath:s}))}},function(e,t,n){const r=n(110);e.exports=async e=>{let t=e;if(void 0===e)return new Uint8Array;if("string"==typeof e)if(/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(e))t=atob(e.split(",")[1]).split("").map(e=>e.charCodeAt(0));else{const n=await fetch(r(e));t=await n.arrayBuffer()}else(e instanceof File||e instanceof Blob)&&(t=await(n=e,new Promise((e,t)=>{const r=new FileReader;r.onload=()=>{e(r.result)},r.onerror=({target:{error:{code:e}}})=>{t(Error(`File could not be read! Code=${e}`))},r.readAsArrayBuffer(n)})));var n;return new Uint8Array(t)}},function(e,t,n){"use strict";n.r(t);n(171),n(120);var r=n(1),i=n.n(r),o=n(21),a=n.n(o),s=n(20),l=n(6),c=n(23);function u(e){return"/"===e.charAt(0)}function d(e,t){for(var n=t,r=n+1,i=e.length;r=0;h--){var p=i[h];"."===p?d(i,h):".."===p?(d(i,h),c++):c&&(d(i,h),c--)}if(!s)for(;c--;c)i.unshift("..");!s||""===i[0]||i[0]&&u(i[0])||i.unshift("");var f=i.join("/");return n&&"/"!==f.substr(-1)&&(f+="/"),f};var p=function(e,t){if(!e)throw new Error("Invariant failed")};function f(e){return"/"===e.charAt(0)?e:"/"+e}function m(e){return"/"===e.charAt(0)?e.substr(1):e}function g(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function b(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function v(e){var t=e.pathname,n=e.search,r=e.hash,i=t||"/";return n&&"?"!==n&&(i+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(i+="#"===r.charAt(0)?r:"#"+r),i}function A(e,t,n,r){var i;"string"==typeof e?(i=function(e){var t=e||"/",n="",r="",i=t.indexOf("#");-1!==i&&(r=t.substr(i),t=t.substr(0,i));var o=t.indexOf("?");return-1!==o&&(n=t.substr(o),t=t.substr(0,o)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e)).state=t:(void 0===(i=Object(c.a)({},e)).pathname&&(i.pathname=""),i.search?"?"!==i.search.charAt(0)&&(i.search="?"+i.search):i.search="",i.hash?"#"!==i.hash.charAt(0)&&(i.hash="#"+i.hash):i.hash="",void 0!==t&&void 0===i.state&&(i.state=t));try{i.pathname=decodeURI(i.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+i.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return n&&(i.key=n),r?i.pathname?"/"!==i.pathname.charAt(0)&&(i.pathname=h(i.pathname,r.pathname)):i.pathname=r.pathname:i.pathname||(i.pathname="/"),i}function _(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,i){if(null!=e){var o="function"==typeof e?e(t,n):e;"string"==typeof o?"function"==typeof r?r(o,i):i(!0):i(!1!==o)}else i(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;rt?n.splice(t,n.length-t,r):n.push(r),d({action:"PUSH",location:r,index:t,entries:n})}}))},replace:function(e,t){var r=A(e,t,h(),b.location);u.confirmTransitionTo(r,"REPLACE",n,(function(e){e&&(b.entries[b.index]=r,d({action:"REPLACE",location:r}))}))},go:g,goBack:function(){g(-1)},goForward:function(){g(1)},canGo:function(e){var t=b.index+e;return t>=0&&t0)){t.next=19;break}if(!n._flushStream[e]){t.next=13;break}return n._flushStream[e]=!1,n._stateQueues[e].length=0,t.abrupt("continue",8);case 13:return i=n._stateQueues[e].shift(),o=[i.current_elapsed_time,i.total_elapsed_time],t.next=17,[i.state,o];case 17:t.next=8;break;case 19:t.next=24;break;case 21:return t.next=23,de(n._obtainStream(e,n._stateQueues[e],n._maxRetries));case 23:n._sockets[e]=t.sent;case 24:if(!(re.length)&&(t=e.length);for(var n=0,r=new Array(t);n0),qe(n,"".concat(a,"-rtl"),"rtl"===i),n),s);return r.createElement(lt.Provider,{value:{siderHook:e.getSiderHook()}},r.createElement(u,Ze({className:h},d),l))},e}return et(n,[{key:"getSiderHook",value:function(){var e=this;return{addSider:function(t){e.setState((function(e){return{siders:[].concat(Xe(e.siders),[t])}}))},removeSider:function(t){e.setState((function(e){return{siders:e.siders.filter((function(e){return e!==t}))}}))}}}},{key:"render",value:function(){return r.createElement(We,null,this.renderComponent)}}]),n}(r.Component),ht=ct({suffixCls:"layout",tagName:"section",displayName:"Layout"})(dt),pt=ct({suffixCls:"layout-header",tagName:"header",displayName:"Header"})(ut),ft=ct({suffixCls:"layout-footer",tagName:"footer",displayName:"Footer"})(ut),mt=ct({suffixCls:"layout-content",tagName:"main",displayName:"Content"})(ut);ht.Header=pt,ht.Footer=ft,ht.Content=mt;var gt=ht,bt=n(12),vt=n.n(bt);var At=function(e,t){for(var n=vt()({},e),r=0;r0&&void 0!==arguments[0]?arguments[0]:"";return Ut+=1,"".concat(e).concat(Ut)}),Ht=function(e){kt(n,e);var t=Bt(n);function n(e){var i,o,a;return Rt(this,n),(i=t.call(this,e)).responsiveHandler=function(e){i.setState({below:e.matches});var t=i.props.onBreakpoint;t&&t(e.matches),i.state.collapsed!==e.matches&&i.setCollapsed(e.matches,"responsive")},i.setCollapsed=function(e,t){"collapsed"in i.props||i.setState({collapsed:e});var n=i.props.onCollapse;n&&n(e,t)},i.toggle=function(){var e=!i.state.collapsed;i.setCollapsed(e,"clickTrigger")},i.belowShowChange=function(){i.setState((function(e){return{belowShow:!e.belowShow}}))},i.renderSider=function(e){var t,n=e.getPrefixCls,o=i.props,a=o.prefixCls,s=o.className,l=o.theme,c=o.collapsible,u=o.reverseArrow,d=o.trigger,h=o.style,p=o.width,f=o.collapsedWidth,m=o.zeroWidthTriggerStyle,g=Vt(o,["prefixCls","className","theme","collapsible","reverseArrow","trigger","style","width","collapsedWidth","zeroWidthTriggerStyle"]),b=n("layout-sider",a),v=At(g,["collapsed","defaultCollapsed","onCollapse","breakpoint","onBreakpoint","siderHook","zeroWidthTriggerStyle"]),A=i.state.collapsed?f:p,_=St(A)?"".concat(A,"px"):String(A),y=0===parseFloat(String(f||0))?r.createElement("span",{onClick:i.toggle,className:"".concat(b,"-zero-width-trigger ").concat(b,"-zero-width-trigger-").concat(u?"right":"left"),style:m},r.createElement(yt.a,null)):null,x={expanded:u?r.createElement(wt.a,null):r.createElement(Ct.a,null),collapsed:u?r.createElement(Ct.a,null):r.createElement(wt.a,null)}[i.state.collapsed?"collapsed":"expanded"],w=null!==d?y||r.createElement("div",{className:"".concat(b,"-trigger"),onClick:i.toggle,style:{width:_}},d||x):null,E=Ot(Ot({},h),{flex:"0 0 ".concat(_),maxWidth:_,minWidth:_,width:_}),C=_e()(s,b,"".concat(b,"-").concat(l),(Pt(t={},"".concat(b,"-collapsed"),!!i.state.collapsed),Pt(t,"".concat(b,"-has-trigger"),c&&null!==d&&!y),Pt(t,"".concat(b,"-below"),!!i.state.below),Pt(t,"".concat(b,"-zero-width"),0===parseFloat(_)),t));return r.createElement("aside",Ot({className:C},v,{style:E}),r.createElement("div",{className:"".concat(b,"-children")},i.props.children),c||i.state.below&&y?w:null)},i.uniqueId=Gt("ant-sider-"),"undefined"!=typeof window&&(o=window.matchMedia),o&&e.breakpoint&&e.breakpoint in zt&&(i.mql=o("(max-width: ".concat(zt[e.breakpoint],")"))),a="collapsed"in e?e.collapsed:e.defaultCollapsed,i.state={collapsed:a,below:!1},i}return It(n,[{key:"componentDidMount",value:function(){this.mql&&(this.mql.addListener(this.responsiveHandler),this.responsiveHandler(this.mql)),this.props.siderHook&&this.props.siderHook.addSider(this.uniqueId)}},{key:"componentWillUnmount",value:function(){this.mql&&this.mql.removeListener(this.responsiveHandler),this.props.siderHook&&this.props.siderHook.removeSider(this.uniqueId)}},{key:"render",value:function(){var e=this.state.collapsed,t=this.props.collapsedWidth;return r.createElement(jt.Provider,{value:{siderCollapsed:e,collapsedWidth:t}},r.createElement(We,null,this.renderSider))}}],[{key:"getDerivedStateFromProps",value:function(e){return"collapsed"in e?{collapsed:e.collapsed}:null}}]),n}(r.Component);Ht.defaultProps={collapsible:!1,defaultCollapsed:!1,reverseArrow:!1,width:200,collapsedWidth:80,style:{},theme:"dark"};var Qt=function(e){kt(n,e);var t=Bt(n);function n(){return Rt(this,n),t.apply(this,arguments)}return It(n,[{key:"render",value:function(){var e=this;return(r.createElement(lt.Consumer,null,(function(t){return r.createElement(Ht,Ot({},t,e.props))})))}}]),n}(r.Component);gt.Sider=Qt;var Wt=gt,Kt=n(18),Xt=n(146),Yt=n(86),qt=n(55);function Zt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jt(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function $t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return en(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return en(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function en(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&void 0!==arguments[1]?arguments[1]:1,n=x.length,r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function pn(e){var t=e.key,n=e.props,r=n.children,i=n.value;return un({key:t,value:void 0!==i?i:t,children:r},hn(n,["children","value"]))}function fn(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Object(ln.a)(e).map((function(e,n){if(!r.isValidElement(e)||!e.type)return null;var i=e.type.isSelectOptGroup,o=e.key,a=e.props,s=a.children,l=hn(a,["children"]);return t||!i?pn(e):un({key:"__RC_SELECT_GRP__".concat(null===o?n:o,"__"),label:o},l,{options:fn(s)})})).filter((function(e){return e}))}var mn=n(46),gn=n(168),bn=n(17),vn=n(34);function An(e){return(An="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var _n=function(e){var t=e.mode,n=e.options,r=e.children,o=e.backfill,a=e.allowClear,s=e.placeholder,l=e.getInputElement,c=e.showSearch,u=e.onSearch,d=e.defaultOpen,h=e.autoFocus,p=e.labelInValue,f=e.value,m=e.inputValue,g=e.optionLabelProp,b="multiple"===t||"tags"===t,v=void 0!==c?c:b||"combobox"===t,A=n||fn(r);if(Object(bn.a)("tags"!==t||A.every((function(e){return!e.disabled})),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),"tags"===t||"combobox"===t){var _=A.some((function(e){return e.options?e.options.some((function(e){return"number"==typeof("value"in e?e.value:e.key)})):"number"==typeof("value"in e?e.value:e.key)}));Object(bn.a)(!_,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(bn.a)("combobox"!==t||!g,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(bn.a)("combobox"===t||!o,"`backfill` only works with `combobox` mode."),Object(bn.a)("combobox"===t||!l,"`getInputElement` only work with `combobox` mode."),Object(bn.b)("combobox"!==t||!l||!a||!s,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),u&&!v&&"combobox"!==t&&"tags"!==t&&Object(bn.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(bn.b)(!d||h,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),null!=f){var y=Object(vn.d)(f);Object(bn.a)(!p||y.every((function(e){return"object"===An(e)&&("key"in e||"value"in e)})),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(bn.a)(!b||Array.isArray(f),"`value` should be array when `mode` is `multiple` or `tags`")}if(r){var x=null;Object(ln.a)(r).some((function(e){if(!i.a.isValidElement(e)||!e.type)return!1;var t=e.type;return!t.isSelectOption&&(t.isSelectOptGroup?!Object(ln.a)(e.props.children).every((function(t){return!(i.a.isValidElement(t)&&e.type&&!t.type.isSelectOption)||(x=t.type,!1)})):(x=t,!0))})),x&&Object(bn.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(x.displayName||x.name||x,"`.")),Object(bn.a)(void 0===m,"`inputValue` is deprecated, please use `searchValue` instead.")}};function yn(e){return(yn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function xn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wn(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:1,n=hr++,r=t;function i(){(r-=1)<=0?(e(),delete pr[n]):pr[n]=dr()(i)}return pr[n]=dr()(i),n}function mr(e){return(mr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function gr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function br(e,t){for(var n=0;n=0)){var r=e.props.insertExtraNode;e.extraNode=document.createElement("div");var i=_r(e).extraNode;i.className="ant-click-animating-node";var o=e.getAttributeName();t.setAttribute(o,"true"),or=or||document.createElement("style"),n&&"#ffffff"!==n&&"rgb(255, 255, 255)"!==n&&Er(n)&&!/rgba\((?:\d*, ){3}0\)/.test(n)&&"transparent"!==n&&(e.csp&&e.csp.nonce&&(or.nonce=e.csp.nonce),i.style.borderColor=n,or.innerHTML="\n [ant-click-animating-without-extra-node='true']::after, .ant-click-animating-node {\n --antd-wave-shadow-color: ".concat(n,";\n }"),document.body.contains(or)||document.body.appendChild(or)),r&&t.appendChild(i),cr.a.addStartEventListener(t,e.onTransitionStart),cr.a.addEndEventListener(t,e.onTransitionEnd)}},e.onTransitionStart=function(t){if(!e.destroyed){var n=Object(o.findDOMNode)(_r(e));t&&t.target===n&&!e.animationStart&&e.resetEffect(n)}},e.onTransitionEnd=function(t){t&&"fadeEffect"===t.animationName&&e.resetEffect(t.target)},e.bindAnimationEvent=function(t){if(t&&t.getAttribute&&!t.getAttribute("disabled")&&!(t.className.indexOf("disabled")>=0)){var n=function(n){if("INPUT"!==n.target.tagName&&!wr(n.target)){e.resetEffect(t);var r=getComputedStyle(t).getPropertyValue("border-top-color")||getComputedStyle(t).getPropertyValue("border-color")||getComputedStyle(t).getPropertyValue("background-color");e.clickWaveTimeoutId=window.setTimeout((function(){return e.onClick(t,r)}),0),fr.cancel(e.animationStartId),e.animationStart=!0,e.animationStartId=fr((function(){e.animationStart=!1}),10)}};return t.addEventListener("click",n,!0),{cancel:function(){t.removeEventListener("click",n,!0)}}}},e.renderWave=function(t){var n=t.csp,r=e.props.children;return e.csp=n,r},e}return n=l,(i=[{key:"componentDidMount",value:function(){var e=Object(o.findDOMNode)(this);e&&1===e.nodeType&&(this.instance=this.bindAnimationEvent(e))}},{key:"componentWillUnmount",value:function(){this.instance&&this.instance.cancel(),this.clickWaveTimeoutId&&clearTimeout(this.clickWaveTimeoutId),this.destroyed=!0}},{key:"getAttributeName",value:function(){return this.props.insertExtraNode?"ant-click-animating":"ant-click-animating-without-extra-node"}},{key:"resetEffect",value:function(e){if(e&&e!==this.extraNode&&e instanceof Element){var t=this.props.insertExtraNode,n=this.getAttributeName();e.setAttribute(n,"false"),or&&(or.innerHTML=""),t&&this.extraNode&&e.contains(this.extraNode)&&e.removeChild(this.extraNode),cr.a.removeStartEventListener(e,this.onTransitionStart),cr.a.removeEndEventListener(e,this.onTransitionEnd)}}},{key:"render",value:function(){return r.createElement(We,null,this.renderWave)}}])&&br(n.prototype,i),a&&br(n,a),l}(r.Component),Sr=function(){for(var e=arguments.length,t=new Array(e),n=0;n2),"Button","`icon` is using ReactNode instead of string naming in v4. Please check `".concat(m,"` at https://ant.design/components/icon"));var x=n("btn",l),w=!1!==i,E="";switch(h||t){case"large":E="lg";break;case"small":E="sm"}var C=_?"loading":m,S=_e()(x,p,(kr(a={},"".concat(x,"-").concat(c),c),kr(a,"".concat(x,"-").concat(d),d),kr(a,"".concat(x,"-").concat(E),E),kr(a,"".concat(x,"-icon-only"),!f&&0!==f&&C),kr(a,"".concat(x,"-background-ghost"),g),kr(a,"".concat(x,"-loading"),_),kr(a,"".concat(x,"-two-chinese-chars"),y&&w),kr(a,"".concat(x,"-block"),b),kr(a,"".concat(x,"-dangerous"),!!u),kr(a,"".concat(x,"-rtl"),"rtl"===o),a)),T=m&&!_?m:r.createElement(Mr,{existIcon:!!m,prefixCls:x,loading:_}),P=f||0===f?Gr(f,e.isNeedInserted()&&w):null,O=At(v,["htmlType","loading"]);if(void 0!==O.href)return r.createElement("a",Ir({},O,{className:S,onClick:e.handleClick,ref:e.saveButtonRef}),T,P);var R=v,M=R.htmlType,I=Vr(R,["htmlType"]),k=r.createElement("button",Ir({},At(I,["loading"]),{type:M,className:S,onClick:e.handleClick,ref:e.saveButtonRef}),T,P);return"link"===c?k:r.createElement(Cr,null,k)}))}}])&&Dr(n.prototype,i),o&&Dr(n,o),s}(r.Component);Hr.__ANT_BUTTON=!0,Hr.contextType=Qe,Hr.defaultProps={loading:!1,ghost:!1,block:!1,htmlType:"button"};var Qr=Hr;var Wr=function e(t){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new Error("unreachable case: ".concat(JSON.stringify(t)))};function Kr(){return(Kr=Object.assign||function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(g=t.getOptions().map((function(e){return r.createElement(Di,{prefixCls:p,key:e.value.toString(),disabled:"disabled"in e?e.disabled:a.disabled,value:e.value,checked:-1!==s.value.indexOf(e.value),onChange:e.onChange,className:"".concat(f,"-item"),style:e.style},e.label)})));var b,v,A,_={toggleOption:t.toggleOption,value:t.state.value,disabled:t.props.disabled,name:t.props.name,registerValue:t.registerValue,cancelValue:t.cancelValue},y=_e()(f,c,(b={},v="".concat(f,"-rtl"),A="rtl"===i,v in b?Object.defineProperty(b,v,{value:A,enumerable:!0,configurable:!0,writable:!0}):b[v]=A,b));return r.createElement("div",ci({className:y,style:u},m),r.createElement(Ai.Provider,{value:_},g))},t.state={value:e.value||e.defaultValue||[],registeredValues:[]},t}return n=s,o=[{key:"getDerivedStateFromProps",value:function(e){return"value"in e?{value:e.value||[]}:null}}],(i=[{key:"getOptions",value:function(){return this.props.options.map((function(e){return"string"==typeof e?{label:e,value:e}:e}))}},{key:"render",value:function(){return r.createElement(We,null,this.renderGroup)}}])&&hi(n.prototype,i),o&&hi(n,o),s}(r.PureComponent);_i.defaultProps={options:[]},_i.propTypes={defaultValue:l.array,value:l.array,options:l.array.isRequired,onChange:l.func};var yi=_i;function xi(e){return(xi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function wi(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ei(){return(Ei=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};return Object.keys(e).reduce((function(t,n){var r=e[n];switch(n){case"class":t.className=r,delete t.class;break;default:t[n]=r}return t}),{})}function Qi(e){return Object(Ni.generate)(e)[0]}function Wi(e){return e?Array.isArray(e)?e:[e]:[]}var Ki="\n.anticon {\n display: inline-block;\n color: inherit;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -0.125em;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.anticon > * {\n line-height: 1;\n}\n\n.anticon svg {\n display: inline-block;\n}\n\n.anticon::before {\n display: none;\n}\n\n.anticon .anticon-icon {\n display: block;\n}\n\n.anticon[tabindex] {\n cursor: pointer;\n}\n\n.anticon-spin::before,\n.anticon-spin {\n display: inline-block;\n -webkit-animation: loadingCircle 1s infinite linear;\n animation: loadingCircle 1s infinite linear;\n}\n\n@-webkit-keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n",Xi=!1;function Yi(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function qi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Zi(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:Ki;Object(r.useEffect)((function(){Xi||(Object(Li.insertCss)(e,{prepend:!0}),Xi=!0)}),[])}(),t=Gi(o),n="icon should be icon definiton, but got ".concat(o),Object(bn.a)(t,"[@ant-design/icons] ".concat(n)),!Gi(o))return null;var p=o;return p&&"function"==typeof p.icon&&(p=Zi({},p,{icon:p.icon(h.primaryColor,h.secondaryColor)})),function e(t,n,r){return r?i.a.createElement(t.tag,Vi({key:n},Hi(t.attrs),{},r),(t.children||[]).map((function(r,i){return e(r,"".concat(n,"-").concat(t.tag,"-").concat(i))}))):i.a.createElement(t.tag,Vi({key:n},Hi(t.attrs)),(t.children||[]).map((function(r,i){return e(r,"".concat(n,"-").concat(t.tag,"-").concat(i))})))}(p.icon,"svg-".concat(p.name),Zi({className:a,onClick:s,style:l,"data-icon":p.name,width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true"},d))};eo.displayName="IconReact",eo.getTwoToneColors=function(){return Zi({},$i)},eo.setTwoToneColors=function(e){var t=e.primaryColor,n=e.secondaryColor;$i.primaryColor=t,$i.secondaryColor=n||Qi(t),$i.calculated=!!n};var to=eo;function no(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return ro(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ro(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ro(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}io("#1890ff");var lo=r.forwardRef((function(e,t){var n,i,o,a=e.className,s=e.icon,l=e.spin,c=e.rotate,u=e.tabIndex,d=e.onClick,h=e.twoToneColor,p=so(e,["className","icon","spin","rotate","tabIndex","onClick","twoToneColor"]),f=_e()("anticon",(n={},i="anticon-".concat(s.name),o=Boolean(s.name),i in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o,n),a),m=_e()({"anticon-spin":!!l||"loading"===s.name}),g=u;void 0===g&&d&&(g=-1);var b=c?{msTransform:"rotate(".concat(c,"deg)"),transform:"rotate(".concat(c,"deg)")}:void 0,v=oo(Wi(h),2),A=v[0],_=v[1];return r.createElement("span",Object.assign({role:"img","aria-label":s.name},p,{ref:t,tabIndex:g,onClick:d,className:f}),r.createElement(to,{className:m,icon:s,primaryColor:A,secondaryColor:_,style:b}))}));lo.displayName="AntdIcon",lo.getTwoToneColor=function(){var e=to.getTwoToneColors();return e.calculated?[e.primaryColor,e.secondaryColor]:e.primaryColor},lo.setTwoToneColor=io;var co=lo,uo=function(e,t){return r.createElement(co,Object.assign({},e,{ref:t,icon:Fi}))};uo.displayName="LoadingOutlined";var ho=r.forwardRef(uo);function po(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return fo(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fo(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=1&&n<=7)return!0}return!1},enumerable:!0,configurable:!0}),e.HasSpecificTrigger=function(t){for(var n in e.Triggers){if(e.Triggers.hasOwnProperty(n))if(parseInt(n)===t)return!0}return!1},e.Triggers={},e}(),yo=n(2),xo=function(){function e(){}return e.WithinEpsilon=function(e,t,n){void 0===n&&(n=1401298e-51);var r=e-t;return-n<=r&&r<=n},e.ToHex=function(e){var t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()},e.Sign=function(e){return 0===(e=+e)||isNaN(e)?e:e>0?1:-1},e.Clamp=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),Math.min(n,Math.max(t,e))},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,n){return(e-t)/(n-t)},e.Denormalize=function(e,t,n){return e*(n-t)+t},e.DeltaAngle=function(t,n){var r=e.Repeat(n-t,360);return r>180&&(r-=360),r},e.PingPong=function(t,n){var r=e.Repeat(t,2*n);return n-Math.abs(r-n)},e.SmoothStep=function(t,n,r){var i=e.Clamp(r);return n*(i=-2*i*i*i+3*i*i)+t*(1-i)},e.MoveTowards=function(t,n,r){return Math.abs(n-t)<=r?n:t+e.Sign(n-t)*r},e.MoveTowardsAngle=function(t,n,r){var i=e.DeltaAngle(t,n),o=0;return-r180&&(i-=360),t+i*e.Clamp(r)},e.InverseLerp=function(t,n,r){return t!=n?e.Clamp((r-t)/(n-t)):0},e.Hermite=function(e,t,n,r,i){var o=i*i,a=i*o;return e*(2*a-3*o+1)+n*(-2*a+3*o)+t*(a-2*o+i)+r*(a-o)},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,n){return(e-t)/(n-t)},e.PercentToRange=function(e,t,n){return(n-t)*e+t},e.NormalizeRadians=function(t){return t-=e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.TwoPi=2*Math.PI,e}(),wo=function(){function e(){}return e.BuildArray=function(e,t){for(var n=[],r=0;rr.x?r.x:i)r.y?r.y:o)n.x?t.x:n.x,t.y>n.y?t.y:n.y)},e.Transform=function(t,n){var r=e.Zero();return e.TransformToRef(t,n,r),r},e.TransformToRef=function(e,t,n){var r=t.m,i=e.x*r[0]+e.y*r[4]+r[12],o=e.x*r[1]+e.y*r[5]+r[13];n.x=i,n.y=o},e.PointInTriangle=function(e,t,n,r){var i=.5*(-n.y*r.x+t.y*(-n.x+r.x)+t.x*(n.y-r.y)+n.x*r.y),o=i<0?-1:1,a=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,s=(t.x*n.y-t.y*n.x+(t.y-n.y)*e.x+(n.x-t.x)*e.y)*o;return a>0&&s>0&&a+s<2*i*o},e.Distance=function(t,n){return Math.sqrt(e.DistanceSquared(t,n))},e.DistanceSquared=function(e,t){var n=e.x-t.x,r=e.y-t.y;return n*n+r*r},e.Center=function(e,t){var n=e.add(t);return n.scaleInPlace(.5),n},e.DistanceOfPointFromSegment=function(t,n,r){var i=e.DistanceSquared(n,r);if(0===i)return e.Distance(t,n);var o=r.subtract(n),a=Math.max(0,Math.min(1,e.Dot(t.subtract(n),o)/i)),s=n.add(o.multiplyByFloats(a,a));return e.Distance(t,s)},e}(),So=function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this.x=e,this.y=t,this.z=n}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},e.prototype.getClassName=function(){return"Vector3"},e.prototype.getHashCode=function(){var e=0|this.x;return e=397*(e=397*e^(0|this.y))^(0|this.z)},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,this},e.prototype.toQuaternion=function(){return Po.RotationYawPitchRoll(this.y,this.x,this.z)},e.prototype.addInPlace=function(e){return this.addInPlaceFromFloats(e.x,e.y,e.z)},e.prototype.addInPlaceFromFloats=function(e,t,n){return this.x+=e,this.y+=t,this.z+=n,this},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z)},e.prototype.addToRef=function(e,t){return t.copyFromFloats(this.x+e.x,this.y+e.y,this.z+e.z)},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z)},e.prototype.subtractToRef=function(e,t){return this.subtractFromFloatsToRef(e.x,e.y,e.z,t)},e.prototype.subtractFromFloats=function(t,n,r){return new e(this.x-t,this.y-n,this.z-r)},e.prototype.subtractFromFloatsToRef=function(e,t,n,r){return r.copyFromFloats(this.x-e,this.y-t,this.z-n)},e.prototype.negate=function(){return new e(-this.x,-this.y,-this.z)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this.x,-1*this.y,-1*this.z)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t)},e.prototype.scaleToRef=function(e,t){return t.copyFromFloats(this.x*e,this.y*e,this.z*e)},e.prototype.scaleAndAddToRef=function(e,t){return t.addInPlaceFromFloats(this.x*e,this.y*e,this.z*e)},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=.001),e&&xo.WithinEpsilon(this.x,e.x,t)&&xo.WithinEpsilon(this.y,e.y,t)&&xo.WithinEpsilon(this.z,e.z,t)},e.prototype.equalsToFloats=function(e,t,n){return this.x===e&&this.y===t&&this.z===n},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},e.prototype.multiply=function(e){return this.multiplyByFloats(e.x,e.y,e.z)},e.prototype.multiplyToRef=function(e,t){return t.copyFromFloats(this.x*e.x,this.y*e.y,this.z*e.z)},e.prototype.multiplyByFloats=function(t,n,r){return new e(this.x*t,this.y*n,this.z*r)},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y,this.z/t.z)},e.prototype.divideToRef=function(e,t){return t.copyFromFloats(this.x/e.x,this.y/e.y,this.z/e.z)},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.minimizeInPlace=function(e){return this.minimizeInPlaceFromFloats(e.x,e.y,e.z)},e.prototype.maximizeInPlace=function(e){return this.maximizeInPlaceFromFloats(e.x,e.y,e.z)},e.prototype.minimizeInPlaceFromFloats=function(e,t,n){return ethis.x&&(this.x=e),t>this.y&&(this.y=t),n>this.z&&(this.z=n),this},e.prototype.isNonUniformWithinEpsilon=function(e){var t=Math.abs(this.x),n=Math.abs(this.y);if(!xo.WithinEpsilon(t,n,e))return!0;var r=Math.abs(this.z);return!xo.WithinEpsilon(t,r,e)||!xo.WithinEpsilon(n,r,e)},Object.defineProperty(e.prototype,"isNonUniform",{get:function(){var e=Math.abs(this.x),t=Math.abs(this.y);if(e!==t)return!0;var n=Math.abs(this.z);return e!==n||t!==n},enumerable:!0,configurable:!0}),e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},e.prototype.normalize=function(){return this.normalizeFromLength(this.length())},e.prototype.reorderInPlace=function(e){var t=this;return"xyz"===(e=e.toLowerCase())||(Ro.Vector3[0].copyFrom(this),["x","y","z"].forEach((function(n,r){t[n]=Ro.Vector3[0][e[r]]}))),this},e.prototype.rotateByQuaternionToRef=function(t,n){return t.toRotationMatrix(Ro.Matrix[0]),e.TransformCoordinatesToRef(this,Ro.Matrix[0],n),n},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,n){return this.subtractToRef(t,Ro.Vector3[0]),Ro.Vector3[0].rotateByQuaternionToRef(e,Ro.Vector3[0]),t.addToRef(Ro.Vector3[0],n),n},e.prototype.cross=function(t){return e.Cross(this,t)},e.prototype.normalizeFromLength=function(e){return 0===e||1===e?this:this.scaleInPlace(1/e)},e.prototype.normalizeToNew=function(){var t=new e(0,0,0);return this.normalizeToRef(t),t},e.prototype.normalizeToRef=function(e){var t=this.length();return 0===t||1===t?e.copyFromFloats(this.x,this.y,this.z):this.scaleToRef(1/t,e)},e.prototype.clone=function(){return new e(this.x,this.y,this.z)},e.prototype.copyFrom=function(e){return this.copyFromFloats(e.x,e.y,e.z)},e.prototype.copyFromFloats=function(e,t,n){return this.x=e,this.y=t,this.z=n,this},e.prototype.set=function(e,t,n){return this.copyFromFloats(e,t,n)},e.prototype.setAll=function(e){return this.x=this.y=this.z=e,this},e.GetClipFactor=function(t,n,r,i){var o=e.Dot(t,r)-i;return o/(o-(e.Dot(n,r)-i))},e.GetAngleBetweenVectors=function(t,n,r){var i=t.normalizeToRef(Ro.Vector3[1]),o=n.normalizeToRef(Ro.Vector3[2]),a=e.Dot(i,o),s=Ro.Vector3[3];return e.CrossToRef(i,o,s),e.Dot(s,r)>0?Math.acos(a):-Math.acos(a)},e.FromArray=function(t,n){return void 0===n&&(n=0),new e(t[n],t[n+1],t[n+2])},e.FromFloatArray=function(t,n){return e.FromArray(t,n)},e.FromArrayToRef=function(e,t,n){n.x=e[t],n.y=e[t+1],n.z=e[t+2]},e.FromFloatArrayToRef=function(t,n,r){return e.FromArrayToRef(t,n,r)},e.FromFloatsToRef=function(e,t,n,r){r.copyFromFloats(e,t,n)},e.Zero=function(){return new e(0,0,0)},e.One=function(){return new e(1,1,1)},e.Up=function(){return new e(0,1,0)},Object.defineProperty(e,"UpReadOnly",{get:function(){return e._UpReadOnly},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ZeroReadOnly",{get:function(){return e._ZeroReadOnly},enumerable:!0,configurable:!0}),e.Down=function(){return new e(0,-1,0)},e.Forward=function(){return new e(0,0,1)},e.Backward=function(){return new e(0,0,-1)},e.Right=function(){return new e(1,0,0)},e.Left=function(){return new e(-1,0,0)},e.TransformCoordinates=function(t,n){var r=e.Zero();return e.TransformCoordinatesToRef(t,n,r),r},e.TransformCoordinatesToRef=function(t,n,r){e.TransformCoordinatesFromFloatsToRef(t.x,t.y,t.z,n,r)},e.TransformCoordinatesFromFloatsToRef=function(e,t,n,r,i){var o=r.m,a=e*o[0]+t*o[4]+n*o[8]+o[12],s=e*o[1]+t*o[5]+n*o[9]+o[13],l=e*o[2]+t*o[6]+n*o[10]+o[14],c=1/(e*o[3]+t*o[7]+n*o[11]+o[15]);i.x=a*c,i.y=s*c,i.z=l*c},e.TransformNormal=function(t,n){var r=e.Zero();return e.TransformNormalToRef(t,n,r),r},e.TransformNormalToRef=function(e,t,n){this.TransformNormalFromFloatsToRef(e.x,e.y,e.z,t,n)},e.TransformNormalFromFloatsToRef=function(e,t,n,r,i){var o=r.m;i.x=e*o[0]+t*o[4]+n*o[8],i.y=e*o[1]+t*o[5]+n*o[9],i.z=e*o[2]+t*o[6]+n*o[10]},e.CatmullRom=function(t,n,r,i,o){var a=o*o,s=o*a;return new e(.5*(2*n.x+(-t.x+r.x)*o+(2*t.x-5*n.x+4*r.x-i.x)*a+(-t.x+3*n.x-3*r.x+i.x)*s),.5*(2*n.y+(-t.y+r.y)*o+(2*t.y-5*n.y+4*r.y-i.y)*a+(-t.y+3*n.y-3*r.y+i.y)*s),.5*(2*n.z+(-t.z+r.z)*o+(2*t.z-5*n.z+4*r.z-i.z)*a+(-t.z+3*n.z-3*r.z+i.z)*s))},e.Clamp=function(t,n,r){var i=new e;return e.ClampToRef(t,n,r,i),i},e.ClampToRef=function(e,t,n,r){var i=e.x;i=(i=i>n.x?n.x:i)n.y?n.y:o)n.z?n.z:a)this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.prototype.normalize=function(){var e=this.length();return 0===e?this:this.scaleInPlace(1/e)},e.prototype.toVector3=function(){return new So(this.x,this.y,this.z)},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this},e.prototype.set=function(e,t,n,r){return this.copyFromFloats(e,t,n,r)},e.prototype.setAll=function(e){return this.x=this.y=this.z=this.w=e,this},e.FromArray=function(t,n){return n||(n=0),new e(t[n],t[n+1],t[n+2],t[n+3])},e.FromArrayToRef=function(e,t,n){n.x=e[t],n.y=e[t+1],n.z=e[t+2],n.w=e[t+3]},e.FromFloatArrayToRef=function(t,n,r){e.FromArrayToRef(t,n,r)},e.FromFloatsToRef=function(e,t,n,r,i){i.x=e,i.y=t,i.z=n,i.w=r},e.Zero=function(){return new e(0,0,0,0)},e.One=function(){return new e(1,1,1,1)},e.Normalize=function(t){var n=e.Zero();return e.NormalizeToRef(t,n),n},e.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},e.Minimize=function(e,t){var n=e.clone();return n.minimizeInPlace(t),n},e.Maximize=function(e,t){var n=e.clone();return n.maximizeInPlace(t),n},e.Distance=function(t,n){return Math.sqrt(e.DistanceSquared(t,n))},e.DistanceSquared=function(e,t){var n=e.x-t.x,r=e.y-t.y,i=e.z-t.z,o=e.w-t.w;return n*n+r*r+i*i+o*o},e.Center=function(e,t){var n=e.add(t);return n.scaleInPlace(.5),n},e.TransformNormal=function(t,n){var r=e.Zero();return e.TransformNormalToRef(t,n,r),r},e.TransformNormalToRef=function(e,t,n){var r=t.m,i=e.x*r[0]+e.y*r[4]+e.z*r[8],o=e.x*r[1]+e.y*r[5]+e.z*r[9],a=e.x*r[2]+e.y*r[6]+e.z*r[10];n.x=i,n.y=o,n.z=a,n.w=e.w},e.TransformNormalFromFloatsToRef=function(e,t,n,r,i,o){var a=i.m;o.x=e*a[0]+t*a[4]+n*a[8],o.y=e*a[1]+t*a[5]+n*a[9],o.z=e*a[2]+t*a[6]+n*a[10],o.w=r},e.FromVector3=function(t,n){return void 0===n&&(n=0),new e(t.x,t.y,t.z,n)},e}(),Po=function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=n,this.w=r}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=0|this.x;return e=397*(e=397*(e=397*e^(0|this.y))^(0|this.z))^(0|this.w)},e.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=.001),e&&xo.WithinEpsilon(this.x,e.x,t)&&xo.WithinEpsilon(this.y,e.y,t)&&xo.WithinEpsilon(this.z,e.z,t)&&xo.WithinEpsilon(this.w,e.w,t)},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this},e.prototype.set=function(e,t,n,r){return this.copyFromFloats(e,t,n,r)},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t,this.w*t)},e.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e,this},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,t.z+=this.z*e,t.w+=this.w*e,this},e.prototype.multiply=function(t){var n=new e(0,0,0,1);return this.multiplyToRef(t,n),n},e.prototype.multiplyToRef=function(e,t){var n=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,i=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,o=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(n,r,i,o),this},e.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},e.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},e.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.conjugate=function(){return new e(-this.x,-this.y,-this.z,this.w)},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=So.Zero();return this.toEulerAnglesToRef(t),t},e.prototype.toEulerAnglesToRef=function(e){var t=this.z,n=this.x,r=this.y,i=this.w,o=i*i,a=t*t,s=n*n,l=r*r,c=r*t-n*i;return c<-.4999999?(e.y=2*Math.atan2(r,i),e.x=Math.PI/2,e.z=0):c>.4999999?(e.y=2*Math.atan2(r,i),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(n*r+t*i),-a-s+l+o),e.x=Math.asin(-2*(t*r-n*i)),e.y=Math.atan2(2*(t*n+r*i),a-s-l+o)),this},e.prototype.toRotationMatrix=function(e){return Oo.FromQuaternionToRef(this,e),this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var n=new e;return e.FromRotationMatrixToRef(t,n),n},e.FromRotationMatrixToRef=function(e,t){var n,r=e.m,i=r[0],o=r[4],a=r[8],s=r[1],l=r[5],c=r[9],u=r[2],d=r[6],h=r[10],p=i+l+h;p>0?(n=.5/Math.sqrt(p+1),t.w=.25/n,t.x=(d-c)*n,t.y=(a-u)*n,t.z=(s-o)*n):i>l&&i>h?(n=2*Math.sqrt(1+i-l-h),t.w=(d-c)/n,t.x=.25*n,t.y=(o+s)/n,t.z=(a+u)/n):l>h?(n=2*Math.sqrt(1+l-i-h),t.w=(a-u)/n,t.x=(o+s)/n,t.y=.25*n,t.z=(c+d)/n):(n=2*Math.sqrt(1+h-i-l),t.w=(s-o)/n,t.x=(a+u)/n,t.y=(c+d)/n,t.z=.25*n)},e.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},e.AreClose=function(t,n){return e.Dot(t,n)>=0},e.Zero=function(){return new e(0,0,0,0)},e.Inverse=function(t){return new e(-t.x,-t.y,-t.z,t.w)},e.InverseToRef=function(e,t){return t.set(-e.x,-e.y,-e.z,e.w),t},e.Identity=function(){return new e(0,0,0,1)},e.IsIdentity=function(e){return e&&0===e.x&&0===e.y&&0===e.z&&1===e.w},e.RotationAxis=function(t,n){return e.RotationAxisToRef(t,n,new e)},e.RotationAxisToRef=function(e,t,n){var r=Math.sin(t/2);return e.normalize(),n.w=Math.cos(t/2),n.x=e.x*r,n.y=e.y*r,n.z=e.z*r,n},e.FromArray=function(t,n){return n||(n=0),new e(t[n],t[n+1],t[n+2],t[n+3])},e.FromEulerAngles=function(t,n,r){var i=new e;return e.RotationYawPitchRollToRef(n,t,r,i),i},e.FromEulerAnglesToRef=function(t,n,r,i){return e.RotationYawPitchRollToRef(n,t,r,i),i},e.FromEulerVector=function(t){var n=new e;return e.RotationYawPitchRollToRef(t.y,t.x,t.z,n),n},e.FromEulerVectorToRef=function(t,n){return e.RotationYawPitchRollToRef(t.y,t.x,t.z,n),n},e.RotationYawPitchRoll=function(t,n,r){var i=new e;return e.RotationYawPitchRollToRef(t,n,r,i),i},e.RotationYawPitchRollToRef=function(e,t,n,r){var i=.5*n,o=.5*t,a=.5*e,s=Math.sin(i),l=Math.cos(i),c=Math.sin(o),u=Math.cos(o),d=Math.sin(a),h=Math.cos(a);r.x=h*c*l+d*u*s,r.y=d*u*l-h*c*s,r.z=h*u*s-d*c*l,r.w=h*u*l+d*c*s},e.RotationAlphaBetaGamma=function(t,n,r){var i=new e;return e.RotationAlphaBetaGammaToRef(t,n,r,i),i},e.RotationAlphaBetaGammaToRef=function(e,t,n,r){var i=.5*(n+e),o=.5*(n-e),a=.5*t;r.x=Math.cos(o)*Math.sin(a),r.y=Math.sin(o)*Math.sin(a),r.z=Math.sin(i)*Math.cos(a),r.w=Math.cos(i)*Math.cos(a)},e.RotationQuaternionFromAxis=function(t,n,r){var i=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,n,r,i),i},e.RotationQuaternionFromAxisToRef=function(t,n,r,i){var o=Ro.Matrix[0];Oo.FromXYZAxesToRef(t.normalize(),n.normalize(),r.normalize(),o),e.FromRotationMatrixToRef(o,i)},e.Slerp=function(t,n,r){var i=e.Identity();return e.SlerpToRef(t,n,r,i),i},e.SlerpToRef=function(e,t,n,r){var i,o,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,s=!1;if(a<0&&(s=!0,a=-a),a>.999999)o=1-n,i=s?-n:n;else{var l=Math.acos(a),c=1/Math.sin(l);o=Math.sin((1-n)*l)*c,i=s?-Math.sin(n*l)*c:Math.sin(n*l)*c}r.x=o*e.x+i*t.x,r.y=o*e.y+i*t.y,r.z=o*e.z+i*t.z,r.w=o*e.w+i*t.w},e.Hermite=function(t,n,r,i,o){var a=o*o,s=o*a,l=2*s-3*a+1,c=-2*s+3*a,u=s-2*a+o,d=s-a;return new e(t.x*l+r.x*c+n.x*u+i.x*d,t.y*l+r.y*c+n.y*u+i.y*d,t.z*l+r.z*c+n.z*u+i.z*d,t.w*l+r.w*c+n.w*u+i.w*d)},e}(),Oo=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,this._m=new Float32Array(16),this._updateIdentityStatus(!1)}return Object.defineProperty(e.prototype,"m",{get:function(){return this._m},enumerable:!0,configurable:!0}),e.prototype._markAsUpdated=function(){this.updateFlag=e._updateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0},e.prototype._updateIdentityStatus=function(t,n,r,i){void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===i&&(i=!0),this.updateFlag=e._updateFlagSeed++,this._isIdentity=t,this._isIdentity3x2=t||r,this._isIdentityDirty=!this._isIdentity&&n,this._isIdentity3x2Dirty=!this._isIdentity3x2&&i},e.prototype.isIdentity=function(){if(this._isIdentityDirty){this._isIdentityDirty=!1;var e=this._m;this._isIdentity=1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity},e.prototype.isIdentityAs3x2=function(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]||0!==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]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2},e.prototype.determinant=function(){if(!0===this._isIdentity)return 1;var e=this._m,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],p=e[12],f=e[13],m=e[14],g=e[15],b=d*g-m*h,v=u*g-f*h,A=u*m-f*d,_=c*g-p*h,y=c*m-d*p,x=c*f-p*u;return t*+(a*b-s*v+l*A)+n*-(o*b-s*_+l*y)+r*+(o*v-a*_+l*x)+i*-(o*A-a*y+s*x)},e.prototype.toArray=function(){return this._m},e.prototype.asArray=function(){return this._m},e.prototype.invert=function(){return this.invertToRef(this),this},e.prototype.reset=function(){return e.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this},e.prototype.add=function(t){var n=new e;return this.addToRef(t,n),n},e.prototype.addToRef=function(e,t){for(var n=this._m,r=t._m,i=e.m,o=0;o<16;o++)r[o]=n[o]+i[o];return t._markAsUpdated(),this},e.prototype.addToSelf=function(e){for(var t=this._m,n=e.m,r=0;r<16;r++)t[r]+=n[r];return this._markAsUpdated(),this},e.prototype.invertToRef=function(t){if(!0===this._isIdentity)return e.IdentityToRef(t),this;var n=this._m,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],c=n[6],u=n[7],d=n[8],h=n[9],p=n[10],f=n[11],m=n[12],g=n[13],b=n[14],v=n[15],A=p*v-b*f,_=h*v-g*f,y=h*b-g*p,x=d*v-m*f,w=d*b-p*m,E=d*g-m*h,C=+(l*A-c*_+u*y),S=-(s*A-c*x+u*w),T=+(s*_-l*x+u*E),P=-(s*y-l*w+c*E),O=r*C+i*S+o*T+a*P;if(0===O)return t.copyFrom(this),this;var R=1/O,M=c*v-b*u,I=l*v-g*u,k=l*b-g*c,D=s*v-m*u,B=s*b-m*c,F=s*g-m*l,N=c*f-p*u,L=l*f-h*u,U=l*p-h*c,V=s*f-d*u,z=s*p-d*c,j=s*h-d*l,G=-(i*A-o*_+a*y),H=+(r*A-o*x+a*w),Q=-(r*_-i*x+a*E),W=+(r*y-i*w+o*E),K=+(i*M-o*I+a*k),X=-(r*M-o*D+a*B),Y=+(r*I-i*D+a*F),q=-(r*k-i*B+o*F),Z=-(i*N-o*L+a*U),J=+(r*N-o*V+a*z),$=-(r*L-i*V+a*j),ee=+(r*U-i*z+o*j);return e.FromValuesToRef(C*R,G*R,K*R,Z*R,S*R,H*R,X*R,J*R,T*R,Q*R,Y*R,$*R,P*R,W*R,q*R,ee*R,t),this},e.prototype.addAtIndex=function(e,t){return this._m[e]+=t,this._markAsUpdated(),this},e.prototype.multiplyAtIndex=function(e,t){return this._m[e]*=t,this._markAsUpdated(),this},e.prototype.setTranslationFromFloats=function(e,t,n){return this._m[12]=e,this._m[13]=t,this._m[14]=n,this._markAsUpdated(),this},e.prototype.addTranslationFromFloats=function(e,t,n){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=n,this._markAsUpdated(),this},e.prototype.setTranslation=function(e){return this.setTranslationFromFloats(e.x,e.y,e.z)},e.prototype.getTranslation=function(){return new So(this._m[12],this._m[13],this._m[14])},e.prototype.getTranslationToRef=function(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],this},e.prototype.removeRotationAndScaling=function(){var t=this.m;return e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t[12],t[13],t[14],t[15],this),this._updateIdentityStatus(0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]),this},e.prototype.multiply=function(t){var n=new e;return this.multiplyToRef(t,n),n},e.prototype.copyFrom=function(e){e.copyToArray(this._m);var t=e;return this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);var n=this._m;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],this},e.prototype.multiplyToRef=function(e,t){return this._isIdentity?(t.copyFrom(e),this):e._isIdentity?(t.copyFrom(this),this):(this.multiplyToArray(e,t._m,0),t._markAsUpdated(),this)},e.prototype.multiplyToArray=function(e,t,n){var r=this._m,i=e.m,o=r[0],a=r[1],s=r[2],l=r[3],c=r[4],u=r[5],d=r[6],h=r[7],p=r[8],f=r[9],m=r[10],g=r[11],b=r[12],v=r[13],A=r[14],_=r[15],y=i[0],x=i[1],w=i[2],E=i[3],C=i[4],S=i[5],T=i[6],P=i[7],O=i[8],R=i[9],M=i[10],I=i[11],k=i[12],D=i[13],B=i[14],F=i[15];return t[n]=o*y+a*C+s*O+l*k,t[n+1]=o*x+a*S+s*R+l*D,t[n+2]=o*w+a*T+s*M+l*B,t[n+3]=o*E+a*P+s*I+l*F,t[n+4]=c*y+u*C+d*O+h*k,t[n+5]=c*x+u*S+d*R+h*D,t[n+6]=c*w+u*T+d*M+h*B,t[n+7]=c*E+u*P+d*I+h*F,t[n+8]=p*y+f*C+m*O+g*k,t[n+9]=p*x+f*S+m*R+g*D,t[n+10]=p*w+f*T+m*M+g*B,t[n+11]=p*E+f*P+m*I+g*F,t[n+12]=b*y+v*C+A*O+_*k,t[n+13]=b*x+v*S+A*R+_*D,t[n+14]=b*w+v*T+A*M+_*B,t[n+15]=b*E+v*P+A*I+_*F,this},e.prototype.equals=function(e){var t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;var n=this.m,r=t.m;return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3]&&n[4]===r[4]&&n[5]===r[5]&&n[6]===r[6]&&n[7]===r[7]&&n[8]===r[8]&&n[9]===r[9]&&n[10]===r[10]&&n[11]===r[11]&&n[12]===r[12]&&n[13]===r[13]&&n[14]===r[14]&&n[15]===r[15]},e.prototype.clone=function(){var t=new e;return t.copyFrom(this),t},e.prototype.getClassName=function(){return"Matrix"},e.prototype.getHashCode=function(){for(var e=0|this._m[0],t=1;t<16;t++)e=397*e^(0|this._m[t]);return e},e.prototype.decompose=function(t,n,r){if(this._isIdentity)return r&&r.setAll(0),t&&t.setAll(1),n&&n.copyFromFloats(0,0,0,1),!0;var i=this._m;if(r&&r.copyFromFloats(i[12],i[13],i[14]),(t=t||Ro.Vector3[0]).x=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),t.y=Math.sqrt(i[4]*i[4]+i[5]*i[5]+i[6]*i[6]),t.z=Math.sqrt(i[8]*i[8]+i[9]*i[9]+i[10]*i[10]),this.determinant()<=0&&(t.y*=-1),0===t.x||0===t.y||0===t.z)return n&&n.copyFromFloats(0,0,0,1),!1;if(n){var o=1/t.x,a=1/t.y,s=1/t.z;e.FromValuesToRef(i[0]*o,i[1]*o,i[2]*o,0,i[4]*a,i[5]*a,i[6]*a,0,i[8]*s,i[9]*s,i[10]*s,0,0,0,0,1,Ro.Matrix[0]),Po.FromRotationMatrixToRef(Ro.Matrix[0],n)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new To(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])},e.prototype.setRow=function(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)},e.prototype.transpose=function(){return e.Transpose(this)},e.prototype.transposeToRef=function(t){return e.TransposeToRef(this,t),this},e.prototype.setRowFromFloats=function(e,t,n,r,i){if(e<0||e>3)return this;var o=4*e;return this._m[o+0]=t,this._m[o+1]=n,this._m[o+2]=r,this._m[o+3]=i,this._markAsUpdated(),this},e.prototype.scale=function(t){var n=new e;return this.scaleToRef(t,n),n},e.prototype.scaleToRef=function(e,t){for(var n=0;n<16;n++)t._m[n]=this._m[n]*e;return t._markAsUpdated(),this},e.prototype.scaleAndAddToRef=function(e,t){for(var n=0;n<16;n++)t._m[n]+=this._m[n]*e;return t._markAsUpdated(),this},e.prototype.toNormalMatrix=function(t){var n=Ro.Matrix[0];this.invertToRef(n),n.transposeToRef(t);var r=t._m;e.FromValuesToRef(r[0],r[1],r[2],0,r[4],r[5],r[6],0,r[8],r[9],r[10],0,0,0,0,1,t)},e.prototype.getRotationMatrix=function(){var t=new e;return this.getRotationMatrixToRef(t),t},e.prototype.getRotationMatrixToRef=function(t){var n=Ro.Vector3[0];if(!this.decompose(n))return e.IdentityToRef(t),this;var r=this._m,i=1/n.x,o=1/n.y,a=1/n.z;return e.FromValuesToRef(r[0]*i,r[1]*i,r[2]*i,0,r[4]*o,r[5]*o,r[6]*o,0,r[8]*a,r[9]*a,r[10]*a,0,0,0,0,1,t),this},e.prototype.toggleModelMatrixHandInPlace=function(){var e=this._m;e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this._markAsUpdated()},e.prototype.toggleProjectionMatrixHandInPlace=function(){var e=this._m;e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this._markAsUpdated()},e.FromArray=function(t,n){void 0===n&&(n=0);var r=new e;return e.FromArrayToRef(t,n,r),r},e.FromArrayToRef=function(e,t,n){for(var r=0;r<16;r++)n._m[r]=e[r+t];n._markAsUpdated()},e.FromFloat32ArrayToRefScaled=function(e,t,n,r){for(var i=0;i<16;i++)r._m[i]=e[i+t]*n;r._markAsUpdated()},Object.defineProperty(e,"IdentityReadOnly",{get:function(){return e._identityReadOnly},enumerable:!0,configurable:!0}),e.FromValuesToRef=function(e,t,n,r,i,o,a,s,l,c,u,d,h,p,f,m,g){var b=g._m;b[0]=e,b[1]=t,b[2]=n,b[3]=r,b[4]=i,b[5]=o,b[6]=a,b[7]=s,b[8]=l,b[9]=c,b[10]=u,b[11]=d,b[12]=h,b[13]=p,b[14]=f,b[15]=m,g._markAsUpdated()},e.FromValues=function(t,n,r,i,o,a,s,l,c,u,d,h,p,f,m,g){var b=new e,v=b._m;return v[0]=t,v[1]=n,v[2]=r,v[3]=i,v[4]=o,v[5]=a,v[6]=s,v[7]=l,v[8]=c,v[9]=u,v[10]=d,v[11]=h,v[12]=p,v[13]=f,v[14]=m,v[15]=g,b._markAsUpdated(),b},e.Compose=function(t,n,r){var i=new e;return e.ComposeToRef(t,n,r,i),i},e.ComposeToRef=function(e,t,n,r){var i=r._m,o=t.x,a=t.y,s=t.z,l=t.w,c=o+o,u=a+a,d=s+s,h=o*c,p=o*u,f=o*d,m=a*u,g=a*d,b=s*d,v=l*c,A=l*u,_=l*d,y=e.x,x=e.y,w=e.z;i[0]=(1-(m+b))*y,i[1]=(p+_)*y,i[2]=(f-A)*y,i[3]=0,i[4]=(p-_)*x,i[5]=(1-(h+b))*x,i[6]=(g+v)*x,i[7]=0,i[8]=(f+A)*w,i[9]=(g-v)*w,i[10]=(1-(h+m))*w,i[11]=0,i[12]=n.x,i[13]=n.y,i[14]=n.z,i[15]=1,r._markAsUpdated()},e.Identity=function(){var t=e.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return t._updateIdentityStatus(!0),t},e.IdentityToRef=function(t){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(!0)},e.Zero=function(){var t=e.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return t._updateIdentityStatus(!1),t},e.RotationX=function(t){var n=new e;return e.RotationXToRef(t,n),n},e.Invert=function(t){var n=new e;return t.invertToRef(n),n},e.RotationXToRef=function(t,n){var r=Math.sin(t),i=Math.cos(t);e.FromValuesToRef(1,0,0,0,0,i,r,0,0,-r,i,0,0,0,0,1,n),n._updateIdentityStatus(1===i&&0===r)},e.RotationY=function(t){var n=new e;return e.RotationYToRef(t,n),n},e.RotationYToRef=function(t,n){var r=Math.sin(t),i=Math.cos(t);e.FromValuesToRef(i,0,-r,0,0,1,0,0,r,0,i,0,0,0,0,1,n),n._updateIdentityStatus(1===i&&0===r)},e.RotationZ=function(t){var n=new e;return e.RotationZToRef(t,n),n},e.RotationZToRef=function(t,n){var r=Math.sin(t),i=Math.cos(t);e.FromValuesToRef(i,r,0,0,-r,i,0,0,0,0,1,0,0,0,0,1,n),n._updateIdentityStatus(1===i&&0===r)},e.RotationAxis=function(t,n){var r=new e;return e.RotationAxisToRef(t,n,r),r},e.RotationAxisToRef=function(e,t,n){var r=Math.sin(-t),i=Math.cos(-t),o=1-i;e.normalize();var a=n._m;a[0]=e.x*e.x*o+i,a[1]=e.x*e.y*o-e.z*r,a[2]=e.x*e.z*o+e.y*r,a[3]=0,a[4]=e.y*e.x*o+e.z*r,a[5]=e.y*e.y*o+i,a[6]=e.y*e.z*o-e.x*r,a[7]=0,a[8]=e.z*e.x*o-e.y*r,a[9]=e.z*e.y*o+e.x*r,a[10]=e.z*e.z*o+i,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,n._markAsUpdated()},e.RotationAlignToRef=function(e,t,n){var r=So.Cross(t,e),i=So.Dot(t,e),o=1/(1+i),a=n._m;a[0]=r.x*r.x*o+i,a[1]=r.y*r.x*o-r.z,a[2]=r.z*r.x*o+r.y,a[3]=0,a[4]=r.x*r.y*o+r.z,a[5]=r.y*r.y*o+i,a[6]=r.z*r.y*o-r.x,a[7]=0,a[8]=r.x*r.z*o-r.y,a[9]=r.y*r.z*o+r.x,a[10]=r.z*r.z*o+i,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,n._markAsUpdated()},e.RotationYawPitchRoll=function(t,n,r){var i=new e;return e.RotationYawPitchRollToRef(t,n,r,i),i},e.RotationYawPitchRollToRef=function(e,t,n,r){Po.RotationYawPitchRollToRef(e,t,n,Ro.Quaternion[0]),Ro.Quaternion[0].toRotationMatrix(r)},e.Scaling=function(t,n,r){var i=new e;return e.ScalingToRef(t,n,r,i),i},e.ScalingToRef=function(t,n,r,i){e.FromValuesToRef(t,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1,i),i._updateIdentityStatus(1===t&&1===n&&1===r)},e.Translation=function(t,n,r){var i=new e;return e.TranslationToRef(t,n,r,i),i},e.TranslationToRef=function(t,n,r,i){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,n,r,1,i),i._updateIdentityStatus(0===t&&0===n&&0===r)},e.Lerp=function(t,n,r){var i=new e;return e.LerpToRef(t,n,r,i),i},e.LerpToRef=function(e,t,n,r){for(var i=r._m,o=e.m,a=t.m,s=0;s<16;s++)i[s]=o[s]*(1-n)+a[s]*n;r._markAsUpdated()},e.DecomposeLerp=function(t,n,r){var i=new e;return e.DecomposeLerpToRef(t,n,r,i),i},e.DecomposeLerpToRef=function(t,n,r,i){var o=Ro.Vector3[0],a=Ro.Quaternion[0],s=Ro.Vector3[1];t.decompose(o,a,s);var l=Ro.Vector3[2],c=Ro.Quaternion[1],u=Ro.Vector3[3];n.decompose(l,c,u);var d=Ro.Vector3[4];So.LerpToRef(o,l,r,d);var h=Ro.Quaternion[2];Po.SlerpToRef(a,c,r,h);var p=Ro.Vector3[5];So.LerpToRef(s,u,r,p),e.ComposeToRef(d,h,p,i)},e.LookAtLH=function(t,n,r){var i=new e;return e.LookAtLHToRef(t,n,r,i),i},e.LookAtLHToRef=function(t,n,r,i){var o=Ro.Vector3[0],a=Ro.Vector3[1],s=Ro.Vector3[2];n.subtractToRef(t,s),s.normalize(),So.CrossToRef(r,s,o);var l=o.lengthSquared();0===l?o.x=1:o.normalizeFromLength(Math.sqrt(l)),So.CrossToRef(s,o,a),a.normalize();var c=-So.Dot(o,t),u=-So.Dot(a,t),d=-So.Dot(s,t);e.FromValuesToRef(o.x,a.x,s.x,0,o.y,a.y,s.y,0,o.z,a.z,s.z,0,c,u,d,1,i)},e.LookAtRH=function(t,n,r){var i=new e;return e.LookAtRHToRef(t,n,r,i),i},e.LookAtRHToRef=function(t,n,r,i){var o=Ro.Vector3[0],a=Ro.Vector3[1],s=Ro.Vector3[2];t.subtractToRef(n,s),s.normalize(),So.CrossToRef(r,s,o);var l=o.lengthSquared();0===l?o.x=1:o.normalizeFromLength(Math.sqrt(l)),So.CrossToRef(s,o,a),a.normalize();var c=-So.Dot(o,t),u=-So.Dot(a,t),d=-So.Dot(s,t);e.FromValuesToRef(o.x,a.x,s.x,0,o.y,a.y,s.y,0,o.z,a.z,s.z,0,c,u,d,1,i)},e.OrthoLH=function(t,n,r,i){var o=new e;return e.OrthoLHToRef(t,n,r,i,o),o},e.OrthoLHToRef=function(t,n,r,i,o){var a=2/t,s=2/n,l=2/(i-r),c=-(i+r)/(i-r);e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,l,0,0,0,c,1,o),o._updateIdentityStatus(1===a&&1===s&&1===l&&0===c)},e.OrthoOffCenterLH=function(t,n,r,i,o,a){var s=new e;return e.OrthoOffCenterLHToRef(t,n,r,i,o,a,s),s},e.OrthoOffCenterLHToRef=function(t,n,r,i,o,a,s){var l=2/(n-t),c=2/(i-r),u=2/(a-o),d=-(a+o)/(a-o),h=(t+n)/(t-n),p=(i+r)/(r-i);e.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,u,0,h,p,d,1,s),s._markAsUpdated()},e.OrthoOffCenterRH=function(t,n,r,i,o,a){var s=new e;return e.OrthoOffCenterRHToRef(t,n,r,i,o,a,s),s},e.OrthoOffCenterRHToRef=function(t,n,r,i,o,a,s){e.OrthoOffCenterLHToRef(t,n,r,i,o,a,s),s._m[10]*=-1},e.PerspectiveLH=function(t,n,r,i){var o=new e,a=2*r/t,s=2*r/n,l=(i+r)/(i-r),c=-2*i*r/(i-r);return e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,l,1,0,0,c,0,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovLH=function(t,n,r,i){var o=new e;return e.PerspectiveFovLHToRef(t,n,r,i,o),o},e.PerspectiveFovLHToRef=function(t,n,r,i,o,a){void 0===a&&(a=!0);var s=r,l=i,c=1/Math.tan(.5*t),u=a?c/n:c,d=a?c:c*n,h=(l+s)/(l-s),p=-2*l*s/(l-s);e.FromValuesToRef(u,0,0,0,0,d,0,0,0,0,h,1,0,0,p,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseLHToRef=function(t,n,r,i,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),l=a?s/n:s,c=a?s:s*n;e.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,-r,1,0,0,1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovRH=function(t,n,r,i){var o=new e;return e.PerspectiveFovRHToRef(t,n,r,i,o),o},e.PerspectiveFovRHToRef=function(t,n,r,i,o,a){void 0===a&&(a=!0);var s=r,l=i,c=1/Math.tan(.5*t),u=a?c/n:c,d=a?c:c*n,h=-(l+s)/(l-s),p=-2*l*s/(l-s);e.FromValuesToRef(u,0,0,0,0,d,0,0,0,0,h,-1,0,0,p,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseRHToRef=function(t,n,r,i,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),l=a?s/n:s,c=a?s:s*n;e.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,-r,-1,0,0,-1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovWebVRToRef=function(e,t,n,r,i){void 0===i&&(i=!1);var o=i?-1:1,a=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),l=Math.tan(e.leftDegrees*Math.PI/180),c=Math.tan(e.rightDegrees*Math.PI/180),u=2/(l+c),d=2/(a+s),h=r._m;h[0]=u,h[1]=h[2]=h[3]=h[4]=0,h[5]=d,h[6]=h[7]=0,h[8]=(l-c)*u*.5,h[9]=-(a-s)*d*.5,h[10]=-n/(t-n),h[11]=1*o,h[12]=h[13]=h[15]=0,h[14]=-2*n*t/(n-t),r._markAsUpdated()},e.GetFinalMatrix=function(t,n,r,i,o,a){var s=t.width,l=t.height,c=t.x,u=t.y,d=e.FromValues(s/2,0,0,0,0,-l/2,0,0,0,0,a-o,0,c+s/2,l/2+u,o,1),h=Ro.Matrix[0];return n.multiplyToRef(r,h),h.multiplyToRef(i,h),h.multiply(d)},e.GetAsMatrix2x2=function(e){var t=e.m;return new Float32Array([t[0],t[1],t[4],t[5]])},e.GetAsMatrix3x3=function(e){var t=e.m;return new Float32Array([t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]])},e.Transpose=function(t){var n=new e;return e.TransposeToRef(t,n),n},e.TransposeToRef=function(e,t){var n=t._m,r=e.m;n[0]=r[0],n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=r[1],n[5]=r[5],n[6]=r[9],n[7]=r[13],n[8]=r[2],n[9]=r[6],n[10]=r[10],n[11]=r[14],n[12]=r[3],n[13]=r[7],n[14]=r[11],n[15]=r[15],t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty)},e.Reflection=function(t){var n=new e;return e.ReflectionToRef(t,n),n},e.ReflectionToRef=function(t,n){t.normalize();var r=t.normal.x,i=t.normal.y,o=t.normal.z,a=-2*r,s=-2*i,l=-2*o;e.FromValuesToRef(a*r+1,s*r,l*r,0,a*i,s*i+1,l*i,0,a*o,s*o,l*o+1,0,a*t.d,s*t.d,l*t.d,1,n)},e.FromXYZAxesToRef=function(t,n,r,i){e.FromValuesToRef(t.x,t.y,t.z,0,n.x,n.y,n.z,0,r.x,r.y,r.z,0,0,0,0,1,i)},e.FromQuaternionToRef=function(e,t){var n=e.x*e.x,r=e.y*e.y,i=e.z*e.z,o=e.x*e.y,a=e.z*e.w,s=e.z*e.x,l=e.y*e.w,c=e.y*e.z,u=e.x*e.w;t._m[0]=1-2*(r+i),t._m[1]=2*(o+a),t._m[2]=2*(s-l),t._m[3]=0,t._m[4]=2*(o-a),t._m[5]=1-2*(i+n),t._m[6]=2*(c+u),t._m[7]=0,t._m[8]=2*(s+l),t._m[9]=2*(c-u),t._m[10]=1-2*(r+n),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t._markAsUpdated()},e._updateFlagSeed=0,e._identityReadOnly=e.Identity(),e}(),Ro=function(){function e(){}return e.Vector3=wo.BuildArray(6,So.Zero),e.Matrix=wo.BuildArray(2,Oo.Identity),e.Quaternion=wo.BuildArray(3,Po.Zero),e}(),Mo=function(){function e(){}return e.Vector2=wo.BuildArray(3,Co.Zero),e.Vector3=wo.BuildArray(13,So.Zero),e.Vector4=wo.BuildArray(3,To.Zero),e.Quaternion=wo.BuildArray(2,Po.Zero),e.Matrix=wo.BuildArray(8,Oo.Identity),e}();Eo.RegisteredTypes["BABYLON.Vector2"]=Co,Eo.RegisteredTypes["BABYLON.Vector3"]=So,Eo.RegisteredTypes["BABYLON.Vector4"]=To,Eo.RegisteredTypes["BABYLON.Matrix"]=Oo;var Io=function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this.r=e,this.g=t,this.b=n}return e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},e.prototype.getClassName=function(){return"Color3"},e.prototype.getHashCode=function(){var e=255*this.r|0;return e=397*(e=397*e^(255*this.g|0))^(255*this.b|0)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},e.prototype.toColor4=function(e){return void 0===e&&(e=1),new ko(this.r,this.g,this.b,e)},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},e.prototype.equalsFloats=function(e,t,n){return this.r===e&&this.g===t&&this.b===n},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this},e.prototype.clampToRef=function(e,t,n){return void 0===e&&(e=0),void 0===t&&(t=1),n.r=xo.Clamp(this.r,e,t),n.g=xo.Clamp(this.g,e,t),n.b=xo.Clamp(this.b,e,t),this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b)},e.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},e.prototype.clone=function(){return new e(this.r,this.g,this.b)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},e.prototype.copyFromFloats=function(e,t,n){return this.r=e,this.g=t,this.b=n,this},e.prototype.set=function(e,t,n){return this.copyFromFloats(e,t,n)},e.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,n=255*this.b|0;return"#"+xo.ToHex(e)+xo.ToHex(t)+xo.ToHex(n)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toHSV=function(){var t=new e;return this.toHSVToRef(t),t},e.prototype.toHSVToRef=function(e){var t=this.r,n=this.g,r=this.b,i=Math.max(t,n,r),o=Math.min(t,n,r),a=0,s=0,l=i,c=i-o;0!==i&&(s=c/i),i!=o&&(i==t?(a=(n-r)/c,n=0&&o<=1?(s=i,l=a):o>=1&&o<=2?(s=a,l=i):o>=2&&o<=3?(l=i,c=a):o>=3&&o<=4?(l=a,c=i):o>=4&&o<=5?(s=a,c=i):o>=5&&o<=6&&(s=i,c=a);var u=n-i;r.set(s+u,l+u,c+u)},e.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new e(0,0,0);var n=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),i=parseInt(t.substring(5,7),16);return e.FromInts(n,r,i)},e.FromArray=function(t,n){return void 0===n&&(n=0),new e(t[n],t[n+1],t[n+2])},e.FromInts=function(t,n,r){return new e(t/255,n/255,r/255)},e.Lerp=function(t,n,r){var i=new e(0,0,0);return e.LerpToRef(t,n,r,i),i},e.LerpToRef=function(e,t,n,r){r.r=e.r+(t.r-e.r)*n,r.g=e.g+(t.g-e.g)*n,r.b=e.b+(t.b-e.b)*n},e.Red=function(){return new e(1,0,0)},e.Green=function(){return new e(0,1,0)},e.Blue=function(){return new e(0,0,1)},e.Black=function(){return new e(0,0,0)},Object.defineProperty(e,"BlackReadOnly",{get:function(){return e._BlackReadOnly},enumerable:!0,configurable:!0}),e.White=function(){return new e(1,1,1)},e.Purple=function(){return new e(.5,0,.5)},e.Magenta=function(){return new e(1,0,1)},e.Yellow=function(){return new e(1,1,0)},e.Gray=function(){return new e(.5,.5,.5)},e.Teal=function(){return new e(0,1,1)},e.Random=function(){return new e(Math.random(),Math.random(),Math.random())},e._BlackReadOnly=e.Black(),e}(),ko=function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1),this.r=e,this.g=t,this.b=n,this.a=r}return e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t,this.a*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,this},e.prototype.clampToRef=function(e,t,n){return void 0===e&&(e=0),void 0===t&&(t=1),n.r=xo.Clamp(this.r,e,t),n.g=xo.Clamp(this.g,e,t),n.b=xo.Clamp(this.b,e,t),n.a=xo.Clamp(this.a,e,t),this},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},e.prototype.getClassName=function(){return"Color4"},e.prototype.getHashCode=function(){var e=255*this.r|0;return e=397*(e=397*(e=397*e^(255*this.g|0))^(255*this.b|0))^(255*this.a|0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.copyFromFloats=function(e,t,n,r){return this.r=e,this.g=t,this.b=n,this.a=r,this},e.prototype.set=function(e,t,n,r){return this.copyFromFloats(e,t,n,r)},e.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,n=255*this.b|0,r=255*this.a|0;return"#"+xo.ToHex(e)+xo.ToHex(t)+xo.ToHex(n)+xo.ToHex(r)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,2.2),e.g=Math.pow(this.g,2.2),e.b=Math.pow(this.b,2.2),e.a=this.a,this},e.prototype.toGammaSpace=function(){var t=new e;return this.toGammaSpaceToRef(t),t},e.prototype.toGammaSpaceToRef=function(e){return e.r=Math.pow(this.r,1/2.2),e.g=Math.pow(this.g,1/2.2),e.b=Math.pow(this.b,1/2.2),e.a=this.a,this},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var n=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),i=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(n,r,i,o)},e.Lerp=function(t,n,r){var i=new e(0,0,0,0);return e.LerpToRef(t,n,r,i),i},e.LerpToRef=function(e,t,n,r){r.r=e.r+(t.r-e.r)*n,r.g=e.g+(t.g-e.g)*n,r.b=e.b+(t.b-e.b)*n,r.a=e.a+(t.a-e.a)*n},e.FromColor3=function(t,n){return void 0===n&&(n=1),new e(t.r,t.g,t.b,n)},e.FromArray=function(t,n){return void 0===n&&(n=0),new e(t[n],t[n+1],t[n+2],t[n+3])},e.FromInts=function(t,n,r,i){return new e(t/255,n/255,r/255,i/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var n=[],r=0;rthis.value;case t.IsLesser:return this._effectiveTarget[this._property]0)if("object"==typeof o[0])for(var s=0;s-1&&this._scene.actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTriggers2=function(e,t){for(var n=0;n=t.OnPickTrigger&&n.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t.OnPickTrigger&&n.trigger<=t.OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(jo.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-1!==n&&(this.actions.splice(n,1),t.Triggers[e.trigger]-=1,0===t.Triggers[e.trigger]&&delete t.Triggers[e.trigger],delete e._actionManager,!0)},t.prototype.processTrigger=function(e,n){for(var r=0;r0;if(2===e.type?u.push(i):u.push(n),p){for(var f=new Array,m=0;m0){var u=c.properties[0].value,d=null===c.properties[0].targetType?u:r.getMeshByName(u);d._meshId&&(d.mesh=r.getMeshByID(d._meshId)),l={trigger:t[c.name],parameter:d}}else l=t[c.name];for(var h=0;h1)for(var l=0;l=0;o--)this._keys[o].frame>=r&&this._keys[o].frame<=i&&this._keys.splice(o,1);this._ranges[e]=null}},e.prototype.getRange=function(e){return this._ranges[e]},e.prototype.getKeys=function(){return this._keys},e.prototype.getHighestFrame=function(){for(var e=0,t=0,n=this._keys.length;t0)return n.highLimitValue.clone?n.highLimitValue.clone():n.highLimitValue;var r=this._keys;if(1===r.length)return this._getKeyValue(r[0].value);var i=n.key;if(r[i].frame>=t)for(;i-1>=0&&r[i].frame>=t;)i--;for(var o=i;o=t){n.key=o;var s=r[o],l=this._getKeyValue(s.value);if(s.interpolation===_a.STEP)return l;var c=this._getKeyValue(a.value),u=void 0!==s.outTangent&&void 0!==a.inTangent,d=a.frame-s.frame,h=(t-s.frame)/d,p=this.getEasingFunction();switch(null!=p&&(h=p.ease(h)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var f=u?this.floatInterpolateFunctionWithTangents(l,s.outTangent*d,c,a.inTangent*d,h):this.floatInterpolateFunction(l,c,h);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return f;case e.ANIMATIONLOOPMODE_RELATIVE:return n.offsetValue*n.repeatCount+f}break;case e.ANIMATIONTYPE_QUATERNION:var m=u?this.quaternionInterpolateFunctionWithTangents(l,s.outTangent.scale(d),c,a.inTangent.scale(d),h):this.quaternionInterpolateFunction(l,c,h);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return m;case e.ANIMATIONLOOPMODE_RELATIVE:return m.addInPlace(n.offsetValue.scale(n.repeatCount))}return m;case e.ANIMATIONTYPE_VECTOR3:var g=u?this.vector3InterpolateFunctionWithTangents(l,s.outTangent.scale(d),c,a.inTangent.scale(d),h):this.vector3InterpolateFunction(l,c,h);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return g;case e.ANIMATIONLOOPMODE_RELATIVE:return g.add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_VECTOR2:var b=u?this.vector2InterpolateFunctionWithTangents(l,s.outTangent.scale(d),c,a.inTangent.scale(d),h):this.vector2InterpolateFunction(l,c,h);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return b;case e.ANIMATIONLOOPMODE_RELATIVE:return b.add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_SIZE:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(l,c,h);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(l,c,h).add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_COLOR3:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(l,c,h);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(l,c,h).add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_COLOR4:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color4InterpolateFunction(l,c,h);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color4InterpolateFunction(l,c,h).add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_MATRIX:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:if(e.AllowMatricesInterpolation)return this.matrixInterpolateFunction(l,c,h,n.workValue);case e.ANIMATIONLOOPMODE_RELATIVE:return l}}break}}return this._getKeyValue(r[r.length-1].value)},e.prototype.matrixInterpolateFunction=function(t,n,r,i){return e.AllowMatrixDecomposeForInterpolation?i?(Oo.DecomposeLerpToRef(t,n,r,i),i):Oo.DecomposeLerp(t,n,r):i?(Oo.LerpToRef(t,n,r,i),i):Oo.Lerp(t,n,r)},e.prototype.clone=function(){var t=new e(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 n in t._ranges={},this._ranges){var r=this._ranges[n];r&&(t._ranges[n]=r.clone())}return t},e.prototype.setKeys=function(e){this._keys=e.slice(0)},e.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 n=this.dataType;t.keys=[];for(var r=this.getKeys(),i=0;i=1&&(s=c.values[1]),c.values.length>=2&&(l=c.values[2]);break;case e.ANIMATIONTYPE_QUATERNION:if(n=Po.FromArray(c.values),c.values.length>=8){var u=Po.FromArray(c.values.slice(4,8));u.equals(Po.Zero())||(s=u)}if(c.values.length>=12){var d=Po.FromArray(c.values.slice(8,12));d.equals(Po.Zero())||(l=d)}break;case e.ANIMATIONTYPE_MATRIX:n=Oo.FromArray(c.values);break;case e.ANIMATIONTYPE_COLOR3:n=Io.FromArray(c.values);break;case e.ANIMATIONTYPE_COLOR4:n=ko.FromArray(c.values);break;case e.ANIMATIONTYPE_VECTOR3:default:n=So.FromArray(c.values)}var h={};h.frame=c.frame,h.value=n,null!=s&&(h.inTangent=s),null!=l&&(h.outTangent=l),a.push(h)}if(i.setKeys(a),t.ranges)for(r=0;r0&&u.forEach((function(e){i._events.push(e._clone())})),this._enableBlending=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending}return Object.defineProperty(e.prototype,"currentFrame",{get:function(){return this._currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._currentActiveTarget},enumerable:!0,configurable:!0}),e.prototype._preparePath=function(e,t){void 0===t&&(t=0);var n=this._animation.targetPropertyPath;if(n.length>1){for(var r=e[n[0]],i=1;i-1&&this._animation.runtimeAnimations.splice(e,1)},e.prototype.setValue=function(e,t){if(this._targetIsArray)for(var n=0;nt[t.length-1].frame&&(e=t[t.length-1].frame);var n=this._events;if(n.length)for(var r=0;rthis._maxFrame)&&(t=this._minFrame),(nthis._maxFrame)&&(n=this._maxFrame);var c,u,d=n-t,h=e*(a.framePerSecond*i)/1e3+this._ratioOffset,p=0;if(this._previousDelay=e,this._previousRatio=h,!r&&n>=t&&h>=d)l=!1,p=a._getKeyValue(this._maxValue);else if(!r&&t>=n&&h<=d)l=!1,p=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==Ca.ANIMATIONLOOPMODE_CYCLE){var f=n.toString()+t.toString();if(!this._offsetsCache[f]){this._animationState.repeatCount=0,this._animationState.loopMode=Ca.ANIMATIONLOOPMODE_CYCLE;var m=a._interpolate(t,this._animationState),g=a._interpolate(n,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case Ca.ANIMATIONTYPE_FLOAT:this._offsetsCache[f]=g-m;break;case Ca.ANIMATIONTYPE_QUATERNION:this._offsetsCache[f]=g.subtract(m);break;case Ca.ANIMATIONTYPE_VECTOR3:this._offsetsCache[f]=g.subtract(m);case Ca.ANIMATIONTYPE_VECTOR2:this._offsetsCache[f]=g.subtract(m);case Ca.ANIMATIONTYPE_SIZE:this._offsetsCache[f]=g.subtract(m);case Ca.ANIMATIONTYPE_COLOR3:this._offsetsCache[f]=g.subtract(m)}this._highLimitsCache[f]=g}p=this._highLimitsCache[f],c=this._offsetsCache[f]}if(void 0===c)switch(a.dataType){case Ca.ANIMATIONTYPE_FLOAT:c=0;break;case Ca.ANIMATIONTYPE_QUATERNION:c=Pa;break;case Ca.ANIMATIONTYPE_VECTOR3:c=Oa;break;case Ca.ANIMATIONTYPE_VECTOR2:c=Ra;break;case Ca.ANIMATIONTYPE_SIZE:c=Ma;break;case Ca.ANIMATIONTYPE_COLOR3:c=Ia}if(this._host&&this._host.syncRoot){var b=this._host.syncRoot;u=t+(n-t)*((b.masterFrame-b.fromFrame)/(b.toFrame-b.fromFrame))}else u=l&&0!==d?t+h%d:n;var v=this._events;if((d>0&&this.currentFrame>u||d<0&&this.currentFrame>0,this._animationState.highLimitValue=p,this._animationState.offsetValue=c;var _=a._interpolate(u,this._animationState);if(this.setValue(_,o),v.length)for(A=0;A0&&u>=v[A].frame&&v[A].frame>=t||d<0&&u<=v[A].frame&&v[A].frame<=t){var y=v[A];y.isDone||(y.onlyOnce&&(v.splice(A,1),A--),y.isDone=!0,y.action(u))}return l||(this._stopped=!0),l},e}(),Da=n(16),Ba=n(24),Fa=function(){function e(){this._xhr=new XMLHttpRequest}return e.prototype._injectCustomRequestHeaders=function(){for(var t in e.CustomRequestHeaders){var n=e.CustomRequestHeaders[t];n&&this._xhr.setRequestHeader(t,n)}},Object.defineProperty(e.prototype,"onprogress",{get:function(){return this._xhr.onprogress},set:function(e){this._xhr.onprogress=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._xhr.readyState},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._xhr.status},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"statusText",{get:function(){return this._xhr.statusText},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"response",{get:function(){return this._xhr.response},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"responseURL",{get:function(){return this._xhr.responseURL},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"responseText",{get:function(){return this._xhr.responseText},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"responseType",{get:function(){return this._xhr.responseType},set:function(e){this._xhr.responseType=e},enumerable:!0,configurable:!0}),e.prototype.addEventListener=function(e,t,n){this._xhr.addEventListener(e,t,n)},e.prototype.removeEventListener=function(e,t,n){this._xhr.removeEventListener(e,t,n)},e.prototype.abort=function(){this._xhr.abort()},e.prototype.send=function(t){e.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(t)},e.prototype.open=function(t,n){for(var r=0,i=e.CustomRequestModifiers;r=e||-1!==n.indexOf("file:")?-1:Math.pow(2,i)*t}},e}(),Ua=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t}(Error),Va=n(11),za=n(71),ja=function(e){function t(n,r){var i=e.call(this,n)||this;return i.name="LoadFileError",Ua._setPrototypeOf(i,t.prototype),r instanceof Fa?i.request=r:i.file=r,i}return Object(No.d)(t,e),t}(Ua),Ga=function(e){function t(n,r){var i=e.call(this,n)||this;return i.request=r,i.name="RequestFileError",Ua._setPrototypeOf(i,t.prototype),i}return Object(No.d)(t,e),t}(Ua),Ha=function(e){function t(n,r){var i=e.call(this,n)||this;return i.file=r,i.name="ReadFileError",Ua._setPrototypeOf(i,t.prototype),i}return Object(No.d)(t,e),t}(Ua),Qa=function(){function e(){}return e._CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},e.SetCorsBehavior=function(t,n){if((!t||0!==t.indexOf("data:"))&&e.CorsBehavior)if("string"==typeof e.CorsBehavior||this.CorsBehavior instanceof String)n.crossOrigin=e.CorsBehavior;else{var r=e.CorsBehavior(t);r&&(n.crossOrigin=r)}},e.LoadImage=function(t,n,r,i,o){var a;void 0===o&&(o="");var s=!1;if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)?"undefined"!=typeof Blob?(a=URL.createObjectURL(new Blob([t],{type:o})),s=!0):a="data:"+o+";base64,"+Jo.a.EncodeArrayBufferToBase64(t):t instanceof Blob?(a=URL.createObjectURL(t),s=!0):(a=e._CleanUrl(t),a=e.PreprocessUrl(t)),"undefined"==typeof Image)return e.LoadFile(a,(function(e){createImageBitmap(new Blob([e],{type:o})).then((function(e){n(e),s&&URL.revokeObjectURL(a)})).catch((function(e){r&&r("Error while trying to load image: "+t,e)}))}),void 0,i||void 0,!0,(function(e,n){r&&r("Error while trying to load image: "+t,n)})),null;var l=new Image;e.SetCorsBehavior(a,l);var c=function(){l.removeEventListener("load",c),l.removeEventListener("error",u),n(l),s&&l.src&&URL.revokeObjectURL(l.src)},u=function(e){l.removeEventListener("load",c),l.removeEventListener("error",u),r&&r("Error while trying to load image: "+t,e),s&&l.src&&URL.revokeObjectURL(l.src)};l.addEventListener("load",c),l.addEventListener("error",u);var d=function(){l.src=a};if("data:"!==a.substr(0,5)&&i&&i.enableTexturesOffline)i.open((function(){i&&i.loadImage(a,l)}),d);else{if(-1!==a.indexOf("file:")){var h=decodeURIComponent(a.substring(5).toLowerCase());if(Na.FilesToLoad[h]){try{var p;try{p=URL.createObjectURL(Na.FilesToLoad[h])}catch(e){p=URL.createObjectURL(Na.FilesToLoad[h])}l.src=p,s=!0}catch(e){l.src=""}return l}}d()}return l},e.ReadFile=function(e,t,n,r,i){var o=new FileReader,a={onCompleteObservable:new yo.a,abort:function(){return o.abort()}};return o.onloadend=function(e){return a.onCompleteObservable.notifyObservers(a)},i&&(o.onerror=function(t){i(new Ha("Unable to read "+e.name,e))}),o.onload=function(e){t(e.target.result)},n&&(o.onprogress=n),r?o.readAsArrayBuffer(e):o.readAsText(e),a},e.LoadFile=function(t,n,r,i,o,a){if(-1!==t.indexOf("file:")){var s=decodeURIComponent(t.substring(5).toLowerCase());0===s.indexOf("./")&&(s=s.substring(2));var l=Na.FilesToLoad[s];if(l)return e.ReadFile(l,n,r,o,a?function(e){return a(void 0,new ja(e.message,e.file))}:void 0)}return e.RequestFile(t,(function(e,t){n(e,t?t.responseURL:void 0)}),r,i,o,a?function(e){a(e.request,new ja(e.message,e.request))}:void 0)},e.RequestFile=function(t,n,r,i,o,a,s){t=e._CleanUrl(t),t=e.PreprocessUrl(t);var l=e.BaseUrl+t,c=!1,u={onCompleteObservable:new yo.a,abort:function(){return c=!0}},d=function(){var t=new Fa,i=null;u.abort=function(){c=!0,t.readyState!==(XMLHttpRequest.DONE||4)&&t.abort(),null!==i&&(clearTimeout(i),i=null)};var d=function(h){t.open("GET",l),s&&s(t),o&&(t.responseType="arraybuffer"),r&&t.addEventListener("progress",r);var p=function(){t.removeEventListener("loadend",p),u.onCompleteObservable.notifyObservers(u),u.onCompleteObservable.clear()};t.addEventListener("loadend",p);var f=function(){if(!c&&t.readyState===(XMLHttpRequest.DONE||4)){if(t.removeEventListener("readystatechange",f),t.status>=200&&t.status<300||0===t.status&&(!Da.a.IsWindowObjectExist()||e.IsFileURL()))return void n(o?t.response:t.responseText,t);var r=e.DefaultRetryStrategy;if(r){var s=r(l,t,h);if(-1!==s)return t.removeEventListener("loadend",p),t=new Fa,void(i=setTimeout((function(){return d(h+1)}),s))}var u=new Ga("Error status: "+t.status+" "+t.statusText+" - Unable to load "+l,t);a&&a(u)}};t.addEventListener("readystatechange",f),t.send()};d(0)};if(i&&i.enableSceneOffline){var h=function(e){e&&e.status>400?a&&a(e):d()};i.open((function(){i&&i.loadFile(e.BaseUrl+t,(function(e){c||n(e),u.onCompleteObservable.notifyObservers(u)}),r?function(e){c||r(e)}:void 0,h,o)}),h)}else d();return u},e.IsFileURL=function(){return"file:"===location.protocol},e.DefaultRetryStrategy=La.ExponentialBackoff(),e.BaseUrl="",e.CorsBehavior="anonymous",e.PreprocessUrl=function(e){return e},e}();Va.a._FileToolsLoadImage=Qa.LoadImage.bind(Qa),Va.a._FileToolsLoadFile=Qa.LoadFile.bind(Qa),za.a._FileToolsLoadFile=Qa.LoadFile.bind(Qa),function(e){e[e.Pending=0]="Pending",e[e.Fulfilled=1]="Fulfilled",e[e.Rejected=2]="Rejected"}(Ta||(Ta={}));var Wa=function(){this.count=0,this.target=0,this.results=[]},Ka=function(){function e(e){var t=this;if(this._state=Ta.Pending,this._children=new Array,this._rejectWasConsumed=!1,e)try{e((function(e){t._resolve(e)}),(function(e){t._reject(e)}))}catch(e){this._reject(e)}}return Object.defineProperty(e.prototype,"_result",{get:function(){return this._resultValue},set:function(e){this._resultValue=e,this._parent&&void 0===this._parent._result&&(this._parent._result=e)},enumerable:!0,configurable:!0}),e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.then=function(t,n){var r=this,i=new e;return i._onFulfilled=t,i._onRejected=n,this._children.push(i),i._parent=this,this._state!==Ta.Pending&&setTimeout((function(){if(r._state===Ta.Fulfilled||r._rejectWasConsumed){var e=i._resolve(r._result);if(null!=e)if(void 0!==e._state){var t=e;i._children.push(t),t._parent=i,i=t}else i._result=e}else i._reject(r._reason)})),i},e.prototype._moveChildren=function(e){var t,n=this;if((t=this._children).push.apply(t,e.splice(0,e.length)),this._children.forEach((function(e){e._parent=n})),this._state===Ta.Fulfilled)for(var r=0,i=this._children;r=t)break;if(r(a),o&&o()){e.breakLoop();break}}e.executeNext()}),a)}),i)},e}();Zo.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",Xa.Apply();var es,ts,ns=function(){function e(t){this.length=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)},e.prototype.forEach=function(e){for(var t=0;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e.prototype.contains=function(e){return-1!==this.indexOf(e)},e._GlobalId=0,e}(),rs=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return Object(No.d)(t,e),t.prototype.push=function(t){e.prototype.push.call(this,t),t.__smartArrayFlags||(t.__smartArrayFlags={}),t.__smartArrayFlags[this._id]=this._duplicateId},t.prototype.pushNoDuplicate=function(e){return(!e.__smartArrayFlags||e.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(e),!0)},t.prototype.reset=function(){e.prototype.reset.call(this),this._duplicateId++},t.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;tr.bbSize.y?r.bbSize.x:r.bbSize.y;J=J>r.bbSize.z?J:r.bbSize.z,I=r.subDiv.X*O/r.bbSize.x,k=r.subDiv.Y*O/r.bbSize.y,D=r.subDiv.Z*O/r.bbSize.z,B=r.subDiv.max*r.subDiv.max,r.facetPartitioning.length=0}for(i=0;ic-r)&&(!(s-u<-.001||-.001>u-i)&&!(l-d<-.001||-.001>d-o))},e.prototype.intersectsSphere=function(t){return e.IntersectsSphere(this.minimumWorld,this.maximumWorld,t.centerWorld,t.radiusWorld)},e.prototype.intersectsMinMax=function(e,t){var n=this.minimumWorld,r=this.maximumWorld,i=n.x,o=n.y,a=n.z,s=r.x,l=r.y,c=r.z,u=e.x,d=e.y,h=e.z,p=t.x,f=t.y,m=t.z;return!(sp)&&(!(lf)&&!(cm))},e.Intersects=function(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)},e.IntersectsSphere=function(t,n,r,i){var o=e.TmpVector3[0];return So.ClampToRef(r,t,n,o),So.DistanceSquared(r,o)<=i*i},e.IsCompletelyInFrustum=function(e,t){for(var n=0;n<6;++n)for(var r=t[n],i=0;i<8;++i)if(r.dotCoordinate(e[i])<0)return!1;return!0},e.IsInFrustum=function(e,t){for(var n=0;n<6;++n){for(var r=!0,i=t[n],o=0;o<8;++o)if(i.dotCoordinate(e[o])>=0){r=!1;break}if(r)return!1}return!0},e.TmpVector3=wo.BuildArray(3,So.Zero),e}(),ps=function(){function e(e,t,n){this.center=So.Zero(),this.centerWorld=So.Zero(),this.minimum=So.Zero(),this.maximum=So.Zero(),this.reConstruct(e,t,n)}return e.prototype.reConstruct=function(e,t,n){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var r=So.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*r,this._update(n||Oo.IdentityReadOnly)},e.prototype.scale=function(t){var n=this.radius*t,r=e.TmpVector3,i=r[0].setAll(n),o=this.center.subtractToRef(i,r[1]),a=this.center.addToRef(i,r[2]);return this.reConstruct(o,a,this._worldMatrix),this},e.prototype.getWorldMatrix=function(){return this._worldMatrix},e.prototype._update=function(t){if(t.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{So.TransformCoordinatesToRef(this.center,t,this.centerWorld);var n=e.TmpVector3[0];So.TransformNormalFromFloatsToRef(1,1,1,t,n),this.radiusWorld=Math.max(Math.abs(n.x),Math.abs(n.y),Math.abs(n.z))*this.radius}},e.prototype.isInFrustum=function(e){for(var t=this.centerWorld,n=this.radiusWorld,r=0;r<6;r++)if(e[r].dotCoordinate(t)<=-n)return!1;return!0},e.prototype.isCenterInFrustum=function(e){for(var t=this.centerWorld,n=0;n<6;n++)if(e[n].dotCoordinate(t)<0)return!1;return!0},e.prototype.intersectsPoint=function(e){var t=So.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorldms.max||ms.min>fs.max)},vs=function(){function e(e,t,n){this._isLocked=!1,this.boundingBox=new hs(e,t,n),this.boundingSphere=new ps(e,t,n)}return e.prototype.reConstruct=function(e,t,n){this.boundingBox.reConstruct(e,t,n),this.boundingSphere.reConstruct(e,t,n)},Object.defineProperty(e.prototype,"minimum",{get:function(){return this.boundingBox.minimum},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!0,configurable:!0}),e.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},e.prototype.centerOn=function(t,n){var r=e.TmpVector3[0].copyFrom(t).subtractInPlace(n),i=e.TmpVector3[1].copyFrom(t).addInPlace(n);return this.boundingBox.reConstruct(r,i,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(r,i,this.boundingBox.getWorldMatrix()),this},e.prototype.scale=function(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this},e.prototype.isInFrustum=function(e,t){return void 0===t&&(t=0),!(2!==t&&3!==t||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(1!==t&&3!==t)||this.boundingBox.isInFrustum(e))},Object.defineProperty(e.prototype,"diagonalLength",{get:function(){var t=this.boundingBox;return t.maximumWorld.subtractToRef(t.minimumWorld,e.TmpVector3[0]).length()},enumerable:!0,configurable:!0}),e.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},e.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},e.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},e.prototype.intersects=function(e,t){if(!ps.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!hs.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var n=this.boundingBox,r=e.boundingBox;return!!bs(n.directions[0],n,r)&&(!!bs(n.directions[1],n,r)&&(!!bs(n.directions[2],n,r)&&(!!bs(r.directions[0],n,r)&&(!!bs(r.directions[1],n,r)&&(!!bs(r.directions[2],n,r)&&(!!bs(So.Cross(n.directions[0],r.directions[0]),n,r)&&(!!bs(So.Cross(n.directions[0],r.directions[1]),n,r)&&(!!bs(So.Cross(n.directions[0],r.directions[2]),n,r)&&(!!bs(So.Cross(n.directions[1],r.directions[0]),n,r)&&(!!bs(So.Cross(n.directions[1],r.directions[1]),n,r)&&(!!bs(So.Cross(n.directions[1],r.directions[2]),n,r)&&(!!bs(So.Cross(n.directions[2],r.directions[0]),n,r)&&(!!bs(So.Cross(n.directions[2],r.directions[1]),n,r)&&!!bs(So.Cross(n.directions[2],r.directions[2]),n,r))))))))))))))},e.TmpVector3=wo.BuildArray(2,So.Zero),e}(),As=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._collider=null,this._oldPositionForCollisions=new So(0,0,0),this._diffPositionForCollisions=new So(0,0,0)};function _s(e,t,n,r,i){void 0===r&&(r=null);var o=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new So(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);i||(i=3);for(var s=t,l=t*i;sss.a.CollisionsEpsilon&&i.position.addInPlace(i._meshCollisionData._diffPositionForCollisions),n&&i.onCollideObservable.notifyObservers(n),i.onCollisionPositionChangeObservable.notifyObservers(i.position)},i.getScene().addMesh(i),i._resyncLightSources(),i}return Object(No.d)(t,e),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return as.BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return as.BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return as.BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return as.BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return as.BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_USE_POSITION",{get:function(){return as.BILLBOARDMODE_USE_POSITION},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!0,configurable:!0}),t.prototype._updateNonUniformScalingState=function(t){return!!e.prototype._updateNonUniformScalingState.call(this,t)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(t.prototype,"onCollide",{set:function(e){this._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver),this._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onCollisionPositionChange",{set:function(e){this._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver),this._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(e){this._internalAbstractMeshDataInfo._visibility!==e&&(this._internalAbstractMeshDataInfo._visibility=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},set:function(e){this._material!==e&&(this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&this._unBindEffect())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasVertexAlpha",{get:function(){return this._internalAbstractMeshDataInfo._hasVertexAlpha},set:function(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVertexColors",{get:function(){return this._internalAbstractMeshDataInfo._useVertexColors},set:function(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numBoneInfluencers",{get:function(){return this._internalAbstractMeshDataInfo._numBoneInfluencers},set:function(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"applyFog",{get:function(){return this._internalAbstractMeshDataInfo._applyFog},set:function(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"layerMask",{get:function(){return this._internalAbstractMeshDataInfo._layerMask},set:function(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._meshCollisionData._collisionMask},set:function(e){this._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collisionGroup",{get:function(){return this._meshCollisionData._collisionGroup},set:function(e){this._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_positions",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"skeleton",{get:function(){return this._internalAbstractMeshDataInfo._skeleton},set:function(e){var t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"AbstractMesh"},t.prototype.toString=function(e){var t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);var n=this._internalAbstractMeshDataInfo._skeleton;return n&&(t+=", skeleton: "+n.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t},t.prototype._getEffectiveParent=function(){return this._masterMesh&&this.billboardMode!==as.BILLBOARDMODE_NONE?this._masterMesh:e.prototype._getEffectiveParent.call(this)},t.prototype._getActionManagerForTrigger=function(e,t){if(void 0===t&&(t=!0),this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null},t.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var e=0,t=this.subMeshes;e4,o=i?this.getVerticesData(cs.MatricesIndicesExtraKind):null,a=i?this.getVerticesData(cs.MatricesWeightsExtraKind):null;this.skeleton.prepare();for(var s=this.skeleton.getTransformMatrices(this),l=Mo.Vector3[0],c=Mo.Matrix[0],u=Mo.Matrix[1],d=0,h=0;h0&&(Oo.FromFloat32ArrayToRefScaled(s,Math.floor(16*n[d+p]),f,u),c.addToSelf(u));if(i)for(p=0;p<4;p++)(f=a[d+p])>0&&(Oo.FromFloat32ArrayToRefScaled(s,Math.floor(16*o[d+p]),f,u),c.addToSelf(u));So.TransformCoordinatesFromFloatsToRef(t[h],t[h+1],t[h+2],c,l),l.toArray(t,h),this._positions&&this._positions[h/3].copyFrom(l)}}}return t},t.prototype._updateBoundingInfo=function(){var e=this._effectiveMesh;return this._boundingInfo?this._boundingInfo.update(e.worldMatrixFromCache):this._boundingInfo=new vs(this.absolutePosition,this.absolutePosition,e.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(e.worldMatrixFromCache),this},t.prototype._updateSubMeshesBoundingInfo=function(e){if(!this.subMeshes)return this;for(var t=this.subMeshes.length,n=0;n1||!r.IsGlobal)&&r.updateBoundingInfo(e)}return this},t.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||this._updateBoundingInfo()},Object.defineProperty(t.prototype,"_effectiveMesh",{get:function(){return this.skeleton&&this.skeleton.overrideMesh||this},enumerable:!0,configurable:!0}),t.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e,this.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isCompletelyInFrustum(e)},t.prototype.intersectsMesh=function(e,t,n){if(void 0===t&&(t=!1),!this._boundingInfo||!e._boundingInfo)return!1;if(this._boundingInfo.intersects(e._boundingInfo,t))return!0;if(n)for(var r=0,i=this.getChildMeshes();r1&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},t.prototype._checkCollision=function(e){if(!this._boundingInfo||!this._boundingInfo._checkCollision(e))return this;var t=Mo.Matrix[0],n=Mo.Matrix[1];return Oo.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,n),this._processCollisionsForSubMeshes(e,n),this},t.prototype._generatePointsArray=function(){return!1},t.prototype.intersects=function(e,t,n){var r=new ds,i="InstancedLinesMesh"===this.getClassName()||"LinesMesh"===this.getClassName()?this.intersectionThreshold:0,o=this._boundingInfo;if(!(this.subMeshes&&o&&e.intersectsSphere(o.boundingSphere,i)&&e.intersectsBox(o.boundingBox,i)))return r;if(!this._generatePointsArray())return r;for(var a=null,s=this._scene.getIntersectingSubMeshCandidates(this,e),l=s.length,c=0;c1)||u.canIntersects(e)){var d=u.intersects(e,this._positions,this.getIndices(),t,n);if(d&&(t||!a||d.distance65535){o=!0;break}e.depthSortedIndices=o?new Uint32Array(n):new Uint16Array(n)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){var s=this.getScene().activeCamera;e.facetDepthSortFrom=s?s.position:So.Zero()}e.depthSortedFacets=[];for(var l=0;l.001?i.maximum.x-i.minimum.x:.001,e.bbSize.y=i.maximum.y-i.minimum.y>.001?i.maximum.y-i.minimum.y:.001,e.bbSize.z=i.maximum.z-i.minimum.z>.001?i.maximum.z-i.minimum.z:.001;var u=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(u=u>e.bbSize.z?u:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/u),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/u),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/u),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=i,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),So.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,us.ComputeNormals(t,n,r,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var d=e.depthSortedIndices.length/3|0;for(l=0;li.subDiv.max||a<0||a>i.subDiv.max||s<0||s>i.subDiv.max?null:i.facetPartitioning[o+i.subDiv.max*a+i.subDiv.max*i.subDiv.max*s]},t.prototype.getClosestFacetAtCoordinates=function(e,t,n,r,i,o){void 0===i&&(i=!1),void 0===o&&(o=!0);var a=this.getWorldMatrix(),s=Mo.Matrix[5];a.invertToRef(s);var l=Mo.Vector3[8];So.TransformCoordinatesFromFloatsToRef(e,t,n,s,l);var c=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,r,i,o);return r&&So.TransformCoordinatesFromFloatsToRef(r.x,r.y,r.z,a,r),c},t.prototype.getClosestFacetAtLocalCoordinates=function(e,t,n,r,i,o){void 0===i&&(i=!1),void 0===o&&(o=!0);var a=null,s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),b=this.getFacetsAtLocalCoordinates(e,t,n);if(!b)return null;for(var v,A,_,y=Number.MAX_VALUE,x=y,w=0;w=0||i&&!o&&u<=0)&&(u=A.x*_.x+A.y*_.y+A.z*_.z,d=-(A.x*e+A.y*t+A.z*n-u)/(A.x*A.x+A.y*A.y+A.z*A.z),(x=(s=(h=e+A.x*d)-e)*s+(l=(p=t+A.y*d)-t)*l+(c=(f=n+A.z*d)-n)*c)-1?(jo.a.Error("You're trying to reuse a post process not defined as reusable."),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(e))},t.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._cascadePostProcessesToRigCams()},t.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},t.prototype._getViewMatrix=function(){return Oo.Identity()},t.prototype.getViewMatrix=function(e){return!e&&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},t.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},t.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},t.prototype.getProjectionMatrix=function(e){if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var n=this.getEngine(),r=this.getScene();if(this.mode===t.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=n.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1);var i=n.useReverseDepthBuffer;(r.useRightHandedSystem?i?Oo.PerspectiveFovReverseRHToRef:Oo.PerspectiveFovRHToRef:i?Oo.PerspectiveFovReverseLHToRef:Oo.PerspectiveFovLHToRef)(this.fov,n.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED)}else{var o=n.getRenderWidth()/2,a=n.getRenderHeight()/2;r.useRightHandedSystem?Oo.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-a,this.orthoTop||a,this.minZ,this.maxZ,this._projectionMatrix):Oo.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-a,this.orthoTop||a,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=n.getRenderWidth(),this._cache.renderHeight=n.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},t.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},t.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?Ss.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Ss.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},t.prototype.isInFrustum=function(e,t){if(void 0===t&&(t=!1),this._updateFrustumPlanes(),t&&this.rigCameras.length>0){var n=!1;return this.rigCameras.forEach((function(t){t._updateFrustumPlanes(),n=n||e.isInFrustum(t._frustumPlanes)})),n}return e.isInFrustum(this._frustumPlanes)},t.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},t.prototype.getForwardRay=function(e,t,n){throw void 0===e&&(e=100),oa.a.WarnImport("Ray")},t.prototype.dispose=function(n,r){for(void 0===r&&(r=!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 i=this._rigCameras.pop();i&&i.dispose()}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==t.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var o=this._postProcesses.length;--o>=0;){var a=this._postProcesses[o];a&&a.dispose(this)}for(o=this.customRenderTargets.length;--o>=0;)this.customRenderTargets[o].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),e.prototype.dispose.call(this,n,r)},Object.defineProperty(t.prototype,"isLeftCamera",{get:function(){return this._isLeftCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRightCamera",{get:function(){return this._isRightCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!0,configurable:!0}),t.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},t.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},t.prototype.setCameraRigMode=function(e,n){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){var r=this._rigCameras.pop();r&&r.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=n.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=Ja.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==t.RIG_MODE_NONE){var i=this.createRigCamera(this.name+"_L",0);i&&(i._isLeftCamera=!0);var o=this.createRigCamera(this.name+"_R",1);o&&(o._isRightCamera=!0),i&&o&&(this._rigCameras.push(i),this._rigCameras.push(o))}switch(this.cameraRigMode){case t.RIG_MODE_STEREOSCOPIC_ANAGLYPH:t._setStereoscopicAnaglyphRigMode(this);break;case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case t.RIG_MODE_STEREOSCOPIC_OVERUNDER:case t.RIG_MODE_STEREOSCOPIC_INTERLACED:t._setStereoscopicRigMode(this);break;case t.RIG_MODE_VR:t._setVRRigMode(this,n);break;case t.RIG_MODE_WEBVR:t._setWebVRRigMode(this,n)}this._cascadePostProcessesToRigCams(),this.update()}},t._setStereoscopicRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode"},t._setStereoscopicAnaglyphRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode"},t._setVRRigMode=function(e,t){throw"Import Cameras/RigModes/vrRigMode before using VR rig mode"},t._setWebVRRigMode=function(e,t){throw"Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode"},t.prototype._getVRProjectionMatrix=function(){return Oo.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},t.prototype._updateCameraRotationMatrix=function(){},t.prototype._updateWebVRCameraRotationMatrix=function(){},t.prototype._getWebVRProjectionMatrix=function(){return Oo.Identity()},t.prototype._getWebVRViewMatrix=function(){return Oo.Identity()},t.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=Ja.ToRadians(t/.0637))},t.prototype.createRigCamera=function(e,t){return null},t.prototype._updateRigCameras=function(){for(var e=0;e0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},t.CompareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},t.prototype.dispose=function(t,n){void 0===n&&(n=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var r=0,i=this.getScene().meshes;r0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach((function(t){e.excludedMeshesIds.push(t.id)}))),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(t){e.includedOnlyMeshesIds.push(t.id)}))),ya.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},t.GetConstructorFromName=function(e,t,n){var r=wa.Construct("Light_Type_"+e,t,n);return r||null},t.Parse=function(e,n){var r=t.GetConstructorFromName(e.type,e.name,n);if(!r)return null;var i=ya.Parse(r,e,n);if(e.excludedMeshesIds&&(i._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(i._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId&&(i._waitingParentId=e.parentId),void 0!==e.falloffType&&(i.falloffType=e.falloffType),void 0!==e.lightmapMode&&(i.lightmapMode=e.lightmapMode),e.animations){for(var o=0;os&&(s=u)}return new t(e,a,s-a+1,n,r,i,o)},t}(Fs),Ls=function(){function e(t,n,r){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 yo.a,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=2,this._needDepthPrePass=!1,this.disableDepthWrite=!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._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this.name=t,this.id=t||Ja.RandomId(),this._scene=n||Zo.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.useRightHandedSystem?this.sideOrientation=e.ClockWiseSideOrientation:this.sideOrientation=e.CounterClockWiseSideOrientation,this._uniformBuffer=new ks(this._scene.getEngine()),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,r||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={})}return Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alpha=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(t){this._backFaceCulling!==t&&(this._backFaceCulling=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasRenderTargetTextures",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new yo.a),this._onBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new yo.a),this._onUnBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaMode",{get:function(){return this._alphaMode},set:function(t){this._alphaMode!==t&&(this._alphaMode=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"needDepthPrePass",{get:function(){return this._needDepthPrePass},set:function(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(t){this._fogEnabled!==t&&(this._fogEnabled=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!0,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(t){this.fillMode=t?e.WireFrameFillMode:e.TriangleFillMode},enumerable:!0,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(t){this.fillMode=t?e.PointFillMode:e.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fillMode",{get:function(){return this._fillMode},set:function(t){this._fillMode!==t&&(this._fillMode=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!0,configurable:!0}),e.prototype.toString=function(e){return"Name: "+this.name},e.prototype.getClassName=function(){return"Material"},Object.defineProperty(e.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),e.prototype.freeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!0},e.prototype.unfreeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!1},e.prototype.isReady=function(e,t){return!0},e.prototype.isReadyForSubMesh=function(e,t,n){return!1},e.prototype.getEffect=function(){return this._effect},e.prototype.getScene=function(){return this._scene},e.prototype.needAlphaBlending=function(){return this.alpha<1},e.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()||e.visibility<1||e.hasVertexAlpha},e.prototype.needAlphaTesting=function(){return!1},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.markDirty=function(){for(var e=0,t=this.getScene().meshes;en._alphaIndex?1:t._alphaIndext._distanceToCamera?-1:0},e.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},e.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},e.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},e.prototype.dispatch=function(e,t,n){void 0===t&&(t=e.getMesh()),void 0===n&&(n=e.getMaterial()),null!=n&&(n.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):n.needAlphaTesting()?(n.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(n.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t._edgesRenderer.isEnabled&&this._edgesRenderers.push(t._edgesRenderer))},e.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},e.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},e.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var n=0;ne.LongPressDelay&&!r._isPointerSwiping()&&(r._startingPointerTime=0,o.processTrigger(8,Fo.CreateNew(t.pickedMesh,n)))}),e.LongPressDelay)}}else for(var a=0,s=i._pointerDownStage;ae.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>e.DragMovementThreshold},e.prototype.simulatePointerUp=function(e,t,n){var r=new PointerEvent("pointerup",t),i=new Js;n?i.doubleClick=!0:i.singleClick=!0,this._checkPrePointerObservable(e,r,Qs.POINTERUP)||this._processPointerUp(e,r,i)},e.prototype._processPointerUp=function(e,t,n){var r=this._scene;if(e&&e&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(r.onPointerPick&&r.onPointerPick(t,e),n.singleClick&&!n.ignore&&r.onPointerObservable.hasObservers())){var i=Qs.POINTERPICK,o=new Xs(i,t,e);this._setRayOnPointerInfo(o),r.onPointerObservable.notifyObservers(o,i)}var a=e.pickedMesh._getActionManagerForTrigger();if(a&&!n.ignore){a.processTrigger(7,Fo.CreateNew(e.pickedMesh,t)),!n.hasSwiped&&n.singleClick&&a.processTrigger(1,Fo.CreateNew(e.pickedMesh,t));var s=e.pickedMesh._getActionManagerForTrigger(6);n.doubleClick&&s&&s.processTrigger(6,Fo.CreateNew(e.pickedMesh,t))}}else if(!n.ignore)for(var l=0,c=r._pointerUpStage;le.DoubleClickDelay&&!o._doubleClickOccured||t!==o._previousButtonPressed)&&(o._doubleClickOccured=!1,n.singleClick=!0,n.ignore=!1,r(n,o._currentPickResult))},this._initClickEvent=function(t,n,r,i){var a=new Js;o._currentPickResult=null;var s=null,l=t.hasSpecificMask(Qs.POINTERPICK)||n.hasSpecificMask(Qs.POINTERPICK)||t.hasSpecificMask(Qs.POINTERTAP)||n.hasSpecificMask(Qs.POINTERTAP)||t.hasSpecificMask(Qs.POINTERDOUBLETAP)||n.hasSpecificMask(Qs.POINTERDOUBLETAP);!l&&_o&&(s=o._initActionManager(s,a))&&(l=s.hasPickTriggers);var c=!1;if(l){var u=r.button;if(a.hasSwiped=o._isPointerSwiping(),!a.hasSwiped){var d=!e.ExclusiveDoubleClickMode;d||(d=!t.hasSpecificMask(Qs.POINTERDOUBLETAP)&&!n.hasSpecificMask(Qs.POINTERDOUBLETAP))&&!_o.HasSpecificTrigger(6)&&(s=o._initActionManager(s,a))&&(d=!s.hasSpecificTrigger(6)),d?(Date.now()-o._previousStartingPointerTime>e.DoubleClickDelay||u!==o._previousButtonPressed)&&(a.singleClick=!0,i(a,o._currentPickResult),c=!0):(o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,o._delayedSimpleClickTimeout=window.setTimeout(o._delayedSimpleClick.bind(o,u,a,i),e.DoubleClickDelay));var h=t.hasSpecificMask(Qs.POINTERDOUBLETAP)||n.hasSpecificMask(Qs.POINTERDOUBLETAP);!h&&_o.HasSpecificTrigger(6)&&(s=o._initActionManager(s,a))&&(h=s.hasSpecificTrigger(6)),h&&(u===o._previousButtonPressed&&Date.now()-o._previousStartingPointerTime0){for(var e=0,t=this._transientComponents;e0)return!1;for(e=0;e0,i=0,o=this._isReadyForMeshStage;i0)for(var a=0,s=this.activeCameras;a0},enumerable:!0,configurable:!0}),t.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},t.prototype.whenReadyAsync=function(){var e=this;return new Promise((function(t){e.executeWhenReady((function(){t()}))}))},t.prototype._checkIsReady=function(){var e=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(){e._checkIsReady()}),150))},Object.defineProperty(t.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),t.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=Ba.a.Now},t.prototype.getViewMatrix=function(){return this._viewMatrix},t.prototype.getProjectionMatrix=function(){return this._projectionMatrix},t.prototype.getTransformMatrix=function(){return this._transformMatrix},t.prototype.setTransformMatrix=function(e,t,n,r){this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag||(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?Ss.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Ss.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(n,r):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.update()))},t.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},t.prototype.getUniqueId=function(){return tl.UniqueId},t.prototype.addMesh=function(e,t){var n=this;void 0===t&&(t=!1),this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),this.onNewMeshAddedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){n.addMesh(e)})))},t.prototype.removeMesh=function(e,t){var n=this;void 0===t&&(t=!1);var r=this.meshes.indexOf(e);return-1!==r&&(this.meshes[r]=this.meshes[this.meshes.length-1],this.meshes.pop(),e.parent||e._removeFromSceneRootNodes()),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){n.removeMesh(e)})),r},t.prototype.addTransformNode=function(e){this._blockEntityCollection||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))},t.prototype.removeTransformNode=function(e){var t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){var n=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=n,n._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t},t.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e)),t},t.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},t.prototype.removeLight=function(e){var t=this.lights.indexOf(e);if(-1!==t){for(var n=0,r=this.meshes;n0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},t.prototype.removeParticleSystem=function(e){var t=this.particleSystems.indexOf(e);return-1!==t&&this.particleSystems.splice(t,1),t},t.prototype.removeAnimation=function(e){var t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t},t.prototype.stopAnimation=function(e,t,n){},t.prototype.removeAnimationGroup=function(e){var t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t},t.prototype.removeMultiMaterial=function(e){var t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),t},t.prototype.removeMaterial=function(e){var t=e._indexInSceneMaterialArray;if(-1!==t&&t=0;t--)if(this.materials[t].id===e)return this.materials[t];return null},t.prototype.getMaterialByName=function(e){for(var t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},t.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},t.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var n=this.getTransformNodeByID(e);if(n)return n;var r=this.getLightByID(e);if(r)return r;var i=this.getCameraByID(e);if(i)return i;var o=this.getBoneByID(e);return o||null},t.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var n=this.getTransformNodeByName(e);if(n)return n;var r=this.getLightByName(e);if(r)return r;var i=this.getCameraByName(e);if(i)return i;var o=this.getBoneByName(e);return o||null},t.prototype.getMeshByName=function(e){for(var t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},t.prototype.getSkeletonByUniqueId=function(e){for(var t=0;t0&&0!=(a.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||a.alwaysSelectAsActiveMesh||a.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(a),this.activeCamera._activeMeshes.push(a),s!==a&&s._activate(this._renderId,!1),a._activate(this._renderId,!1)&&(a.isAnInstance?a._internalAbstractMeshDataInfo._actAsRegularMesh&&(s=a):s._internalAbstractMeshDataInfo._onlyForInstances=!1,s._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(a,s)),a._postActivate()))}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var l=0;l0)for(var i=this.getActiveSubMeshCandidates(t),o=i.length,a=0;a1)this.activeCamera.outputRenderTarget._bindFrameBuffer();else{var e=this.activeCamera.outputRenderTarget.getInternalTexture();e?this.getEngine().bindFramebuffer(e):jo.a.Error("Camera contains invalid customDefaultRenderTarget")}}else this.getEngine().restoreDefaultFramebuffer()},t.prototype._renderForCamera=function(e,t){if(!e||!e._skipRendering){var n=this._engine;if(this._activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");n.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.getEngine().getCaps().multiview&&e.outputRenderTarget&&e.outputRenderTarget.getViewCount()>1?this.setTransformMatrix(e._rigCameras[0].getViewMatrix(),e._rigCameras[0].getProjectionMatrix(),e._rigCameras[1].getViewMatrix(),e._rigCameras[1].getProjectionMatrix()):this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var r=0;r0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets);for(var o=0,a=this._gatherActiveCameraRenderTargetsStage;o0){Ja.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var l=0;l0),this._renderId++}for(var d=0,h=this._cameraDrawRenderTargetStage;d1&&this.getEngine().getCaps().multiview)return this._renderForCamera(e),void this.onAfterRenderCameraObservable.notifyObservers(e);if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else for(var t=0;t-1&&(13===r.trigger&&r._executeCurrent(Fo.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(13,(function(e){var t=e instanceof ws?e:e.mesh;return o===t}))&&13!==r.trigger||t._intersectionsInProgress.splice(s,1))}}}},t.prototype._advancePhysicsEngineStep=function(e){},t.prototype._animate=function(){},t.prototype.animate=function(){if(this._engine.isDeterministicLockStep()){var e=Math.max(t.MinDeltaTime,Math.min(this._engine.getDeltaTime(),t.MaxDeltaTime))+this._timeAccumulator,n=this._engine.getTimeStep(),r=1e3/n/1e3,i=0,o=this._engine.getLockstepMaxSteps(),a=Math.floor(e/n);for(a=Math.min(a,o);e>0&&i0)for(var i=0;i0),this._intermediateRendering=!0;for(var c=0;c0),this._intermediateRendering=!1,this._renderId++}this.activeCamera=l,this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var d=0,h=this._beforeClearStage;d0)for(i=0;i0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[i]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var m=0,g=this._afterRenderStage;m-1&&this._engine.scenes.splice(i,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),t.prototype.clearCachedVertexData=function(){for(var e=0;e-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this},e.prototype.getAnimations=function(){return this._runtimeAnimations},e.prototype.appendAnimations=function(e,t){for(var n=this,r=0;r-1){for(var r=(o=this._runtimeAnimations).length-1;r>=0;r--){var i=o[r];e&&i.animation.name!=e||(t&&!t(i.target)||(i.dispose(),o.splice(r,1)))}0==o.length&&(this._scene._activeAnimatables.splice(n,1),this._raiseOnAnimationEnd())}}else{if((r=this._scene._activeAnimatables.indexOf(this))>-1){this._scene._activeAnimatables.splice(r,1);var o=this._runtimeAnimations;for(r=0;r0)return;this._animationTimeLast=e}this.deltaTime=this.useConstantAnimationDeltaTime?16:(e-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=e;var t=this._activeAnimatables;if(0!==t.length){this._animationTime+=this.deltaTime;for(var n=this._animationTime,r=0;rn&&i>0&&(i*=-1),s&&this.stopAnimation(e,void 0,l),a||(a=new il(this,e,t,n,r,i,o,void 0,c));var u=!l||l(e);if(e.animations&&u&&a.appendAnimations(e,e.animations),e.getAnimatables)for(var d=e.getAnimatables(),h=0;hr&&o>0&&(o*=-1),new il(this,e,n,r,i,o,a,t,s)},nl.prototype.beginDirectHierarchyAnimation=function(e,t,n,r,i,o,a,s,l){var c=e.getDescendants(t),u=[];u.push(this.beginDirectAnimation(e,n,r,i,o,a,s,l));for(var d=0,h=c;d=c&&a.frame<=u&&(r?(l=a.value.clone(),m?(s=l.getTranslation(),l.setTranslation(s.scaleInPlace(g))):b&&i?(s=l.getTranslation(),l.setTranslation(s.multiplyInPlace(i))):l=a.value):l=a.value,v.push({frame:a.frame+n,value:l}));return this.animations[0].createRange(t,c+n,u+n),!0};var ol,al=function(){function e(){}return e.prototype.serialize=function(){var e={};return e.animation=this.animation.serialize(),e.targetId=this.target.id,e},e}(),sl=function(){function e(e,t){void 0===t&&(t=null),this.name=e,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.onAnimationEndObservable=new yo.a,this.onAnimationLoopObservable=new yo.a,this.onAnimationGroupLoopObservable=new yo.a,this.onAnimationGroupEndObservable=new yo.a,this.onAnimationGroupPauseObservable=new yo.a,this.onAnimationGroupPlayObservable=new yo.a,this._scene=t||Zo.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.animationGroups.push(this)}return Object.defineProperty(e.prototype,"from",{get:function(){return this._from},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"to",{get:function(){return this._to},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isPlaying",{get:function(){return this._isStarted&&!this._isPaused},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(e){if(this._speedRatio!==e){this._speedRatio=e;for(var t=0;tr[0].frame&&(this._from=r[0].frame),this._toe){var a={frame:e,value:i.value,inTangent:i.inTangent,outTangent:i.outTangent,interpolation:i.interpolation};r.splice(0,0,a)}if(o.framer&&this._speedRatio>0&&(this._speedRatio=-t);return this._isStarted=!0,this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this},e.prototype.pause=function(){if(!this._isStarted)return this;this._isPaused=!0;for(var e=0;e-1&&this._scene.animationGroups.splice(e,1),this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear(),this.onAnimationGroupLoopObservable.clear()},e.prototype._checkAnimationGroupEnded=function(e){var t=this._animatables.indexOf(e);t>-1&&this._animatables.splice(t,1),0===this._animatables.length&&(this._isStarted=!1,this.onAnimationGroupEndObservable.notifyObservers(this))},e.prototype.clone=function(t,n){for(var r=new e(t||this.name,this._scene),i=0,o=this._targetedAnimations;i180&&(l-=360),l-s<-180&&(l+=360),c-l>180&&(c-=360),c-l<-180&&(c+=360),this.orientation=l-s<0?ol.CW:ol.CCW,this.angle=cl.FromDegrees(this.orientation===ol.CW?s-c:c-s)},dl=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new Co(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var n=new Co(e,t),r=this._points[this._points.length-1];return this._points.push(n),this._length+=n.subtract(r).length(),this},e.prototype.addArcTo=function(e,t,n,r,i){if(void 0===i&&(i=36),this.closed)return this;var o=this._points[this._points.length-1],a=new Co(e,t),s=new Co(n,r),l=new ul(o,a,s),c=l.angle.radians()/i;l.orientation===ol.CW&&(c*=-1);for(var u=l.startAngle.radians()+c,d=0;d1)return Co.Zero();for(var t=e*this.length(),n=0,r=0;r=n&&t<=s){var l=a.normalize(),c=t-n;return new Co(o.x+l.x*c,o.y+l.y*c)}n=s}return Co.Zero()},e.StartingAt=function(t,n){return new e(t,n)},e}(),hl=function(){function e(e,t,n,r){void 0===t&&(t=null),void 0===r&&(r=!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:So.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:Oo.Identity()};for(var i=0;in){var r=t;t=n,n=r}var i=this.getCurve(),o=this.getPointAt(t),a=this.getPreviousPointIndexAt(t),s=this.getPointAt(n),l=this.getPreviousPointIndexAt(n)+1,c=[];return 0!==t&&(a++,c.push(o)),c.push.apply(c,i.slice(a,l)),1===n&&1!==t||c.push(s),new e(c,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)},e.prototype.update=function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);for(var r=0;rt+1;)t++,n=this._curve[e].subtract(this._curve[e-t]);return n},e.prototype._normalVector=function(e,t){var n,r,i=e.length();(0===i&&(i=1),null==t)?(r=xo.WithinEpsilon(Math.abs(e.y)/i,1,.001)?xo.WithinEpsilon(Math.abs(e.x)/i,1,.001)?xo.WithinEpsilon(Math.abs(e.z)/i,1,.001)?So.Zero():new So(0,0,1):new So(1,0,0):new So(0,-1,0),n=So.Cross(e,r)):(n=So.Cross(e,t),So.CrossToRef(n,e,n));return n.normalize(),n},e.prototype._updatePointAtData=function(e,t){if(void 0===t&&(t=!1),this._pointAtData.id===e)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=e;var n=this.getPoints();if(e<=0)return this._setPointAtData(0,0,n[0],0,t);if(e>=1)return this._setPointAtData(1,1,n[n.length-1],n.length-1,t);for(var r,i=n[0],o=0,a=e*this.length(),s=1;sa){var c=(o-a)/l,u=i.subtract(r),d=r.add(u.scaleInPlace(c));return this._setPointAtData(e,1-c,d,s-1,t)}i=r}return this._pointAtData},e.prototype._setPointAtData=function(e,t,n,r,i){return this._pointAtData.point=n,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=r,this._pointAtData.interpolateReady=i,i&&this._updateInterpolationMatrix(),this._pointAtData},e.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=Oo.Identity();var e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){var t=e+1,n=this._tangents[e].clone(),r=this._normals[e].clone(),i=this._binormals[e].clone(),o=this._tangents[t].clone(),a=this._normals[t].clone(),s=this._binormals[t].clone(),l=Po.RotationQuaternionFromAxis(r,i,n),c=Po.RotationQuaternionFromAxis(a,s,o);Po.Slerp(l,c,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},e}(),pl=function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,n,r,i){i=i>2?i:3;for(var o=new Array,a=function(e,t,n,r){return(1-e)*(1-e)*t+2*e*(1-e)*n+e*e*r},s=0;s<=i;s++)o.push(new So(a(s/i,t.x,n.x,r.x),a(s/i,t.y,n.y,r.y),a(s/i,t.z,n.z,r.z)));return new e(o)},e.CreateCubicBezier=function(t,n,r,i,o){o=o>3?o:4;for(var a=new Array,s=function(e,t,n,r,i){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*n+3*e*e*(1-e)*r+e*e*e*i},l=0;l<=o;l++)a.push(new So(s(l/o,t.x,n.x,r.x,i.x),s(l/o,t.y,n.y,r.y,i.y),s(l/o,t.z,n.z,r.z,i.z)));return new e(a)},e.CreateHermiteSpline=function(t,n,r,i,o){for(var a=new Array,s=1/o,l=0;l<=o;l++)a.push(So.Hermite(t,n,r,i,l*s));return new e(a)},e.CreateCatmullRomSpline=function(t,n,r){var i=new Array,o=1/n,a=0;if(r){for(var s=t.length,l=0;l=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e.EASINGMODE_EASEIN=0,e.EASINGMODE_EASEOUT=1,e.EASINGMODE_EASEINOUT=2,e}(),ml=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(fl),gl=function(e){function t(t){void 0===t&&(t=1);var n=e.call(this)||this;return n.amplitude=t,n}return Object(No.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t}(fl),bl=(function(e){function t(t,n){void 0===t&&(t=3),void 0===n&&(n=2);var r=e.call(this)||this;return r.bounces=t,r.bounciness=n,r}Object(No.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),n=this.bounciness;n<=1&&(n=1.001);var r=Math.pow(n,t),i=1-n,o=(1-r)/i+.5*r,a=e*o,s=Math.log(-a*(1-n)+1)/Math.log(n),l=Math.floor(s),c=l+1,u=(1-Math.pow(n,l))/(i*o),d=.5*(u+(1-Math.pow(n,c))/(i*o)),h=e-d,p=d-u;return-Math.pow(1/n,t-l)/(p*p)*(h-p)*(h+p)}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e}}(fl),function(e){function t(t,n){void 0===t&&(t=3),void 0===n&&(n=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=n,r}Object(No.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),n=Math.max(0,this.springiness);return(0==n?e:(Math.exp(n*e)-1)/(Math.exp(n)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)}}(fl),function(e){function t(t){void 0===t&&(t=2);var n=e.call(this)||this;return n.exponent=t,n}return Object(No.d)(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(fl)),vl=(function(e){function t(t){void 0===t&&(t=2);var n=e.call(this)||this;return n.power=t,n}Object(No.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e*e}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e}}(fl),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(fl)),Al=(function(e){function t(t,n,r,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===i&&(i=1);var o=e.call(this)||this;return o.x1=t,o.y1=n,o.x2=r,o.y2=i,o}Object(No.d)(t,e),t.prototype.easeInCore=function(e){return ll.Interpolate(e,this.x1,this.y1,this.x2,this.y2)}}(fl),function(){function e(e,t,n){this.frame=e,this.action=t,this.onlyOnce=n,this.isDone=!1}e.prototype._clone=function(){return new e(this.frame,this.action,this.onlyOnce)}}(),function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return e._ForceFullSceneLoadingForIncremental},set:function(t){e._ForceFullSceneLoadingForIncremental=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return e._ShowLoadingScreen},set:function(t){e._ShowLoadingScreen=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return e._loggingLevel},set:function(t){e._loggingLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return e._CleanBoneMatrixWeights},set:function(t){e._CleanBoneMatrixWeights=t},enumerable:!0,configurable:!0}),e._ForceFullSceneLoadingForIncremental=!1,e._ShowLoadingScreen=!0,e._CleanBoneMatrixWeights=!1,e._loggingLevel=0,e}()),_l=function(){function e(e,t,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=null),this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this.id=e,this.uniqueId=t.getUniqueId(),this._engine=t.getEngine(),this._meshes=[],this._scene=t,this._vertexBuffers={},this._indices=[],this._updatable=r,n?this.setAllVerticesData(n,r):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),i&&(this.applyToMesh(i),i.computeWorldMatrix(!0))}return Object.defineProperty(e.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(e){this._boundingBias?this._boundingBias.copyFrom(e):this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null)},enumerable:!0,configurable:!0}),e.CreateGeometryForMesh=function(t){var n=new e(e.RandomId(),t.getScene());return n.applyToMesh(t),n},Object.defineProperty(e.prototype,"extend",{get:function(){return this._extend},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._engine},e.prototype.isReady=function(){return 1===this.delayLoadState||0===this.delayLoadState},Object.defineProperty(e.prototype,"doNotSerialize",{get:function(){for(var e=0;e0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=t),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()},e.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,n=this._meshes;t0){for(var t=0;t0){for(t=0;t0){for(t=0;t0){var s=new Float32Array(t,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);n.setVerticesData(cs.PositionKind,s,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var l=new Float32Array(t,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);n.setVerticesData(cs.NormalKind,l,!1)}if(a.tangetsAttrDesc&&a.tangetsAttrDesc.count>0){var c=new Float32Array(t,a.tangetsAttrDesc.offset,a.tangetsAttrDesc.count);n.setVerticesData(cs.TangentKind,c,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var u=new Float32Array(t,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);n.setVerticesData(cs.UVKind,u,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var d=new Float32Array(t,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);n.setVerticesData(cs.UV2Kind,d,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var h=new Float32Array(t,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);n.setVerticesData(cs.UV3Kind,h,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var p=new Float32Array(t,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);n.setVerticesData(cs.UV4Kind,p,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var f=new Float32Array(t,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);n.setVerticesData(cs.UV5Kind,f,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var m=new Float32Array(t,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);n.setVerticesData(cs.UV6Kind,m,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var g=new Float32Array(t,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);n.setVerticesData(cs.ColorKind,g,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){for(var b=new Int32Array(t,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count),v=[],A=0;A>8),v.push((16711680&_)>>16),v.push(_>>24)}n.setVerticesData(cs.MatricesIndicesKind,v,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var y=new Float32Array(t,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);n.setVerticesData(cs.MatricesWeightsKind,y,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var x=new Int32Array(t,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);n.setIndices(x,null)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var w=new Int32Array(t,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);n.subMeshes=[];for(A=0;A>8),v.push((16711680&O)>>16),v.push(O>>24)}n.setVerticesData(cs.MatricesIndicesKind,v,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,n.setVerticesData(cs.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(v=[],A=0;A>8),v.push((16711680&O)>>16),v.push(O>>24)}n.setVerticesData(cs.MatricesIndicesExtraKind,v,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,n),n.setVerticesData(cs.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&n.setVerticesData(cs.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),n.setIndices(t.indices,null)}if(t.subMeshes){n.subMeshes=[];for(var R=0;R-1){var r=t.getScene().getLastSkeletonByID(e.skeletonId);if(r){n=r.bones.length;for(var i=t.getVerticesData(cs.MatricesIndicesKind),o=t.getVerticesData(cs.MatricesIndicesExtraKind),a=e.matricesWeights,s=e.matricesWeightsExtra,l=e.numBoneInfluencer,c=a.length,u=0;ul-1)&&(h=l-1),d>.001){var m=1/d;for(p=0;p<4;p++)a[u+p]*=m;if(s)for(p=0;p<4;p++)s[u+p]*=m}else h>=4?(s[u+h-4]=1-d,o[u+h-4]=n):(a[u+h]=1-d,i[u+h]=n)}t.setVerticesData(cs.MatricesIndicesKind,i),e.matricesWeightsExtra&&t.setVerticesData(cs.MatricesIndicesExtraKind,o)}}}},e.Parse=function(t,n,r){if(n.getGeometryByID(t.id))return null;var i=new e(t.id,n,void 0,t.updatable);return ia&&ia.AddTagsTo(i,t.tags),t.delayLoadingFile?(i.delayLoadState=4,i.delayLoadingFile=r+t.delayLoadingFile,i._boundingInfo=new vs(So.FromArray(t.boundingBoxMinimum),So.FromArray(t.boundingBoxMaximum)),i._delayInfo=[],t.hasUVs&&i._delayInfo.push(cs.UVKind),t.hasUVs2&&i._delayInfo.push(cs.UV2Kind),t.hasUVs3&&i._delayInfo.push(cs.UV3Kind),t.hasUVs4&&i._delayInfo.push(cs.UV4Kind),t.hasUVs5&&i._delayInfo.push(cs.UV5Kind),t.hasUVs6&&i._delayInfo.push(cs.UV6Kind),t.hasColors&&i._delayInfo.push(cs.ColorKind),t.hasMatricesIndices&&i._delayInfo.push(cs.MatricesIndicesKind),t.hasMatricesWeights&&i._delayInfo.push(cs.MatricesWeightsKind),i._delayLoadingFunction=us.ImportVertexData):us.ImportVertexData(t,i),n.pushGeometry(i,!0),i},e}(),yl=function(e){function t(t,n){var r=e.call(this,t,n,!0)||this;return n.multiMaterials.push(r),r.subMaterials=new Array,r._storeEffectOnSubMeshes=!0,r}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),t.prototype.getChildren=function(){return this.subMaterials},t.prototype._hookArray=function(e){var t=this,n=e.push;e.push=function(){for(var r=[],i=0;i=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},t.prototype.getActiveTextures=function(){var t;return(t=e.prototype.getActiveTextures.call(this)).concat.apply(t,this.subMaterials.map((function(e){return e?e.getActiveTextures():[]})))},t.prototype.getClassName=function(){return"MultiMaterial"},t.prototype.isReadyForSubMesh=function(e,t,n){for(var r=0;r=0&&i.multiMaterials.splice(o,1),e.prototype.dispose.call(this,t,n)}},t.ParseMultiMaterial=function(e,n){var r=new t(e.name,n);r.id=e.id,ia&&ia.AddTagsTo(r,e.tags);for(var i=0;i0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"morphTargetManager",{get:function(){return this._internalMeshDataInfo._morphTargetManager},set:function(e){this._internalMeshDataInfo._morphTargetManager!==e&&(this._internalMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._internalMeshDataInfo._source},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"worldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"manualUpdateOfWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.manualUpdate},set:function(e){this._instanceDataStorage.manualUpdate=e},enumerable:!0,configurable:!0}),t.prototype.instantiateHierarchy=function(e,t,n){void 0===e&&(e=null);var r=!(this.getTotalVertices()>0)||t&&t.doNotInstantiate?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));r&&(r.parent=e||this.parent,r.position=this.position.clone(),r.scaling=this.scaling.clone(),this.rotationQuaternion?r.rotationQuaternion=this.rotationQuaternion.clone():r.rotation=this.rotation.clone(),n&&n(this,r));for(var i=0,o=this.getChildTransformNodes(!0);i0},enumerable:!0,configurable:!0}),t.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},t.prototype._sortLODLevels=function(){this._internalMeshDataInfo._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},t.prototype.addLODLevel=function(e,t){if(t&&t._masterMesh)return jo.a.Warn("You cannot use a mesh as LOD level twice"),this;var n=new xl(e,t);return this._internalMeshDataInfo._LODLevels.push(n),t&&(t._masterMesh=this),this._sortLODLevels(),this},t.prototype.getLODLevelAtDistance=function(e){for(var t=this._internalMeshDataInfo,n=0;ni)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this),this;for(var o=0;o0;this.computeWorldMatrix();var a=this.material||i.defaultMaterial;if(a)if(a._storeEffectOnSubMeshes)for(var s=0,l=this.subMeshes;s0){var n=this.getIndices();if(!n)return null;var r=n.length,i=!1;if(e)i=!0;else for(var o=0,a=this.subMeshes;o=r){i=!0;break}if(s.verticesStart+s.verticesCount>=t){i=!0;break}}if(!i)return this.subMeshes[0]}return this.releaseSubMeshes(),new Ns(0,0,t,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),n=t/e|0,r=0;n%3!=0;)n++;this.releaseSubMeshes();for(var i=0;i=t);i++)Ns.CreateFromIndices(0,r,Math.min(n,t-r),this),r+=n;this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,t,n,r){if(void 0===n&&(n=!1),this._geometry)this._geometry.setVerticesData(e,t,n,r);else{var i=new us;i.set(t,e);var o=this.getScene();new _l(_l.RandomId(),o,i,n,this)}return this},t.prototype.removeVerticesData=function(e){this._geometry&&this._geometry.removeVerticesData(e)},t.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0);var n=this.getVertexBuffer(e);n&&n.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},t.prototype.setVerticesBuffer=function(e){return this._geometry||(this._geometry=_l.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e),this},t.prototype.updateVerticesData=function(e,t,n,r){return this._geometry?(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,n,!1)):this._geometry.updateVerticesData(e,t,n),this):this},t.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var n=this.getVerticesData(cs.PositionKind);if(!n)return this;if(e(n),this.updateVerticesData(cs.PositionKind,n,!1,!1),t){var r=this.getIndices(),i=this.getVerticesData(cs.NormalKind);if(!i)return this;us.ComputeNormals(n,r,i),this.updateVerticesData(cs.NormalKind,i,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;var e=this._geometry,t=this._geometry.copy(_l.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},t.prototype.setIndices=function(e,t,n){if(void 0===t&&(t=null),void 0===n&&(n=!1),this._geometry)this._geometry.setIndices(e,t,n);else{var r=new us;r.indices=e;var i=this.getScene();new _l(_l.RandomId(),i,r,n,this)}return this},t.prototype.updateIndices=function(e,t,n){return void 0===n&&(n=!1),this._geometry?(this._geometry.updateIndices(e,t,n),this):this},t.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},t.prototype._bind=function(e,t,n){if(!this._geometry)return this;var r,i=this.getScene().getEngine();if(this._unIndexed)r=null;else switch(n){case Ls.PointFillMode:r=null;break;case Ls.WireFrameFillMode:r=e._getLinesIndexBuffer(this.getIndices(),i);break;default:case Ls.TriangleFillMode:r=this._geometry.getIndexBuffer()}return this._geometry._bind(t,r),this},t.prototype._draw=function(e,t,n){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var r=this.getScene().getEngine();return this._unIndexed||t==Ls.PointFillMode?r.drawArraysType(t,e.verticesStart,e.verticesCount,n):t==Ls.WireFrameFillMode?r.drawElementsType(t,0,e._linesIndexCount,n):r.drawElementsType(t,e.indexStart,e.indexCount,n),this},t.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},t.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},t.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},t.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},t.prototype._getInstancesRenderList=function(e,t){if(void 0===t&&(t=!1),this._instanceDataStorage.isFrozen&&this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch;var n=this.getScene(),r=n._isInIntermediateRendering(),i=r?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=this._instanceDataStorage.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!i&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){var a=this._instanceDataStorage.visibleInstances,s=n.getRenderId(),l=r?a.intermediateDefaultRenderId:a.defaultRenderId;o.visibleInstances[e]=a[s],!o.visibleInstances[e]&&l&&(o.visibleInstances[e]=a[l])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==o.visibleInstances[e]&&void 0!==o.visibleInstances[e],this._instanceDataStorage.previousBatch=o,o},t.prototype._renderWithInstances=function(e,t,n,r,i){var o=n.visibleInstances[e._id];if(!o)return this;for(var a=this._instanceDataStorage,s=a.instancesBufferSize,l=a.instancesBuffer,c=16*(o.length+1)*4;a.instancesBufferSizeu&&r++,0!==f&&h++,d+=f,u=f}if(l[h]++,h>o&&(o=h),0===d)i++;else{var m=1/d,g=0;for(p=0;p.001&&a++}}var b=this.skeleton.bones.length,v=this.getVerticesData(cs.MatricesIndicesKind),A=this.getVerticesData(cs.MatricesIndicesExtraKind),_=0;for(c=0;c=b||y<0)&&_++}return{skinned:!0,valid:0===i&&0===a&&0===_,report:"Number of Weights = "+n/4+"\nMaximum influences = "+o+"\nMissing Weights = "+i+"\nNot Sorted = "+r+"\nNot Normalized = "+a+"\nWeightCounts = ["+l+"]\nNumber of bones = "+b+"\nBad Bone Indices = "+_}},t.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):4===this.delayLoadState&&(this.delayLoadState=2,this._queueLoad(e)),this},t.prototype._queueLoad=function(e){var t=this;e._addPendingData(this);var n=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return Ja.LoadFile(this.delayLoadingFile,(function(n){n instanceof ArrayBuffer?t._delayLoadingFunction(n,t):t._delayLoadingFunction(JSON.parse(n),t),t.instances.forEach((function(e){e.refreshBoundingInfo(),e._syncSubMeshes()})),t.delayLoadState=1,e._removePendingData(t)}),(function(){}),e.offlineProvider,n),this},t.prototype.isInFrustum=function(t){return 2!==this.delayLoadState&&(!!e.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},t.prototype.setMaterialByID=function(e){var t,n=this.getScene().materials;for(t=n.length-1;t>-1;t--)if(n[t].id===e)return this.material=n[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},t.prototype.getAnimatables=function(){var e=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},t.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(cs.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var n,r=this.getVerticesData(cs.PositionKind),i=new Array;for(n=0;n-1&&(i.morphTargetManager=n.getMorphTargetManagerById(e.morphTargetManagerId)),e.skeletonId>-1&&(i.skeleton=n.getLastSkeletonByID(e.skeletonId),e.numBoneInfluencers&&(i.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o4,c=l?this.getVerticesData(cs.MatricesIndicesExtraKind):null,u=l?this.getVerticesData(cs.MatricesWeightsExtraKind):null,d=e.getTransformMatrices(this),h=So.Zero(),p=new Oo,f=new Oo,m=0,g=0;g0&&(Oo.FromFloat32ArrayToRefScaled(d,Math.floor(16*o[m+s]),b,f),p.addToSelf(f));if(l)for(s=0;s<4;s++)(b=u[m+s])>0&&(Oo.FromFloat32ArrayToRefScaled(d,Math.floor(16*c[m+s]),b,f),p.addToSelf(f));So.TransformCoordinatesFromFloatsToRef(t._sourcePositions[g],t._sourcePositions[g+1],t._sourcePositions[g+2],p,h),h.toArray(r,g),So.TransformNormalFromFloatsToRef(t._sourceNormals[g],t._sourceNormals[g+1],t._sourceNormals[g+2],p,h),h.toArray(i,g),p.reset()}return this.updateVerticesData(cs.PositionKind,r),this.updateVerticesData(cs.NormalKind,i),this},t.MinMax=function(e){var t=null,n=null;return e.forEach((function(e){var r=e.getBoundingInfo().boundingBox;t&&n?(t.minimizeInPlace(r.minimumWorld),n.maximizeInPlace(r.maximumWorld)):(t=r.minimumWorld,n=r.maximumWorld)})),t&&n?{min:t,max:n}:{min:So.Zero(),max:So.Zero()}},t.Center=function(e){var n=e instanceof Array?t.MinMax(e):e;return So.Center(n.min,n.max)},t.MergeMeshes=function(e,n,r,i,o,a){var s;if(void 0===n&&(n=!0),!r){var l=0;for(s=0;s=65536)return jo.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(a){var c,u,d=null;o=!1}var h,p=new Array,f=new Array,m=null,g=new Array,b=null;for(s=0;s-1&&t.animations.splice(o,1)}},i=0,o=e.animations;i0&&(c=!0,this._soundLoaded(n));break;case"String":l.push(n);case"Array":0===l.length&&(l=n);for(var u=0;u0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if(ss.a.audioEngine.audioContext&&this._soundSource){var n=e?ss.a.audioEngine.audioContext.currentTime+e:ss.a.audioEngine.audioContext.currentTime;this._soundSource.stop(n),this._soundSource.onended=function(){t.isPlaying=!1},this.isPaused||(this._startOffset=0)}},e.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect():ss.a.audioEngine.audioContext&&(this.stop(0),this._startOffset+=ss.a.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){ss.a.audioEngine.canUseWebAudio&&this._soundGain&&(t&&ss.a.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(ss.a.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,ss.a.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,ss.a.audioEngine.audioContext.currentTime+t)):this._soundGain.gain.value=e),this._volume=e},e.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},e.prototype.getVolume=function(){return this._volume},e.prototype.attachToMesh=function(e){var t=this;this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedTransformNode=e,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(e){return t._onRegisterAfterWorldMatrixUpdate(e)},this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)},e.prototype.detachFromMesh=function(){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedTransformNode=null)},e.prototype._onRegisterAfterWorldMatrixUpdate=function(e){if(e.getBoundingInfo){var t=e;if(this._positionInEmitterSpace)t.worldMatrixFromCache.invertToRef(Mo.Matrix[0]),this.setPosition(Mo.Matrix[0].getTranslation());else{var n=t.getBoundingInfo();this.setPosition(n.boundingSphere.centerWorld)}ss.a.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()}},e.prototype.clone=function(){var t=this;if(this._streaming)return null;var n=function(){t._isReadyToPlay?(i._audioBuffer=t.getAudioBuffer(),i._isReadyToPlay=!0,i.autoplay&&i.play(0,t._offset,t._length)):window.setTimeout(n,300)},r={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 e(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&i.setAttenuationFunction(this._customAttenuationFunction),i.setPosition(this._position),i.setPlaybackRate(this._playbackRate),n(),i},e.prototype.getAudioBuffer=function(){return this._audioBuffer},e.prototype.serialize=function(){var e={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};return this.spatialSound&&(this._connectedTransformNode&&(e.connectedMeshId=this._connectedTransformNode.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},e.Parse=function(t,n,r,i){var o,a=t.name;o=t.url?r+t.url:r+a;var s,l={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 c=function(){i._isReadyToPlay?(s._audioBuffer=i.getAudioBuffer(),s._isReadyToPlay=!0,s.autoplay&&s.play(0,s._offset,s._length)):window.setTimeout(c,300)};s=new e(a,new ArrayBuffer(0),n,null,l),c()}else s=new e(a,o,n,(function(){n._removePendingData(s)}),l),n._addPendingData(s);if(t.position){var u=So.FromArray(t.position);s.setPosition(u)}if(t.isDirectional&&(s.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var d=So.FromArray(t.localDirectionToMesh);s.setLocalDirectionToMesh(d)}if(t.connectedMeshId){var h=n.getMeshByID(t.connectedMeshId);h&&s.attachToMesh(h)}return s},e._SceneComponentInitialization=function(e){throw oa.a.WarnImport("AudioSceneComponent")},e}(),Dl=function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,!this._options.mainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return e.prototype._initializeSoundTrackAudioGraph=function(){ss.a.audioEngine.canUseWebAudio&&ss.a.audioEngine.audioContext&&(this._outputAudioNode=ss.a.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(ss.a.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},e.prototype.dispose=function(){if(ss.a.audioEngine&&ss.a.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},e.prototype.AddSound=function(e){this._isInitialized||this._initializeSoundTrackAudioGraph(),ss.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&e.connectToSoundTrackAudioNode(this._outputAudioNode),e.soundTrackId&&(-1===e.soundTrackId?this._scene.mainSoundTrack.RemoveSound(e):this._scene.soundTracks&&this._scene.soundTracks[e.soundTrackId].RemoveSound(e)),this.soundCollection.push(e),e.soundTrackId=this.id},e.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},e.prototype.setVolume=function(e){ss.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){if(ss.a.audioEngine.canUseWebAudio)for(var e=0;e0?t.activeCameras[0]:t.activeCamera){this._cachedCameraPosition.equals(i.globalPosition)||(this._cachedCameraPosition.copyFrom(i.globalPosition),n.audioContext.listener.setPosition(i.globalPosition.x,i.globalPosition.y,i.globalPosition.z)),i.rigCameras&&i.rigCameras.length>0&&(i=i.rigCameras[0]);var o=Oo.Invert(i.getViewMatrix()),a=So.TransformNormal(new So(0,0,-1),o);a.normalize(),isNaN(a.x)||isNaN(a.y)||isNaN(a.z)||this._cachedCameraDirection.equals(a)||(this._cachedCameraDirection.copyFrom(a),n.audioContext.listener.setOrientation(a.x,a.y,a.z,0,1,0))}else n.audioContext.listener.setPosition(0,0,0)}var s;for(s=0;s0?1/i:0,l=0;l0},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e;var n=this._attachedCamera.getScene();this._onPrePointerObservableObserver=n.onPrePointerObservable.add((function(e){e.type!==Qs.POINTERDOWN?e.type===Qs.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){var e=Ba.a.Now,n=0;null!=t._lastFrameTime&&(n=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var r=e-t._lastInteractionTime-t._idleRotationWaitTime,i=Math.max(Math.min(r/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*i,t._attachedCamera&&(t._attachedCamera.alpha-=t._cameraRotationSpeed*(n/1e3))}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},e.prototype._userIsZooming=function(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset},e.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},e.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=Ba.a.Now)},e.prototype._userIsMoving=function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},e}(),Nl=function(){function e(){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(e.prototype,"name",{get:function(){return"Bouncing"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var n=this._attachedCamera;n&&(e?this._onMeshTargetChangedObserver=n.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var n=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*n,t.upperRadiusTransitionRange=.05*n}})):this._onMeshTargetChangedObserver&&n.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))}))},e.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},e.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)},e.prototype._applyBoundRadiusAnimation=function(t){var n=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=Ca.CreateAnimation("radius",Ca.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var r=Ca.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return n._clearAnimationLocks()}));r&&this._animatables.push(r)}},e.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},e.EasingFunction=new gl(.3),e.EasingMode=fl.EASINGMODE_EASEOUT,e}(),Ll=function(){function e(){this._mode=e.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.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(e.prototype,"name",{get:function(){return"Framing"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var n=this;this._attachedCamera=t;var r=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=r.onPrePointerObservable.add((function(e){e.type!==Qs.POINTERDOWN?e.type===Qs.POINTERUP&&(n._isPointerDown=!1):n._isPointerDown=!0})),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){e&&n.zoomOnMesh(e)})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){n._applyUserInteraction(),n._maintainCameraAboveGround()}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},e.prototype.zoomOnMesh=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null),e.computeWorldMatrix(!0);var r=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(r.minimumWorld,r.maximumWorld,t,n)},e.prototype.zoomOnMeshHierarchy=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null),e.computeWorldMatrix(!0);var r=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(r.min,r.max,t,n)},e.prototype.zoomOnMeshesHierarchy=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null);for(var r=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new So(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o=0;oc.upperRadiusLimit?c.upperRadiusLimit:l),l):0},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var n=Ba.a.Now-this._lastInteractionTime,r=.5*Math.PI-this._defaultElevation,i=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>i&&n>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=Ca.CreateAnimation("beta",Ca.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=Ca.TransitionTo("beta",r,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(function(){t._clearAnimationLocks(),t.stopAllAnimations()}));o&&this._animatables.push(o)}}},e.prototype._getFrustumSlope=function(){var e=this._attachedCamera;if(!e)return Co.Zero();var t=e.getScene().getEngine().getAspectRatio(e),n=Math.tan(e.fov/2);return new Co(n*t,n)},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=Ba.a.Now,this.stopAllAnimations(),this._clearAnimationLocks())},e.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(e.prototype,"isUserIsMoving",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!0,configurable:!0}),e.EasingFunction=new bl,e.EasingMode=fl.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),Ul=function(e,t,n,r){void 0===t&&(t=new So),void 0===n&&(n=0),void 0===r&&(r=!1),this.direction=e,this.rotatedDirection=t,this.diff=n,this.ignore=r},Vl=(function(){function e(e){this.ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new Ul(So.Up()),new Ul(So.Down()),new Ul(So.Left()),new Ul(So.Right()),new Ul(So.Forward()),new Ul(So.Forward().scaleInPlace(-1))],this._tmpMatrix=new Oo,this._tmpVector=new So,this._zeroVector=So.Zero(),this._lookAtTmpMatrix=new Oo}e.prototype.init=function(){},e.prototype._closestFace=function(e){var t=this;return this._faceVectors.forEach((function(n){t._target.rotationQuaternion||(t._target.rotationQuaternion=Po.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),So.TransformCoordinatesToRef(n.direction,t._tmpMatrix,n.rotatedDirection),n.diff=So.GetAngleBetweenVectors(n.rotatedDirection,e,So.Cross(n.rotatedDirection,e))})),this._faceVectors.reduce((function(e,t){return e.ignore?t:t.ignore||e.diff1)return e._setAllVisibility(e._ownerNode,1),void(e._hoverValue=e.fadeInTime+e.delay);if(e._ownerNode.visibility<0&&(e._setAllVisibility(e._ownerNode,0),e._hoverValue<0))return void(e._hoverValue=0);setTimeout(e._update,e._millisecondsPerFrame)}}}Object.defineProperty(e.prototype,"name",{get:function(){return"FadeInOut"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this._ownerNode=e,this._setAllVisibility(this._ownerNode,0)},e.prototype.detach=function(){this._ownerNode=null},e.prototype.fadeIn=function(e){this._hovered=e,this._update()},e.prototype._setAllVisibility=function(e,t){var n=this;e.visibility=t,e.getChildMeshes().forEach((function(e){n._setAllVisibility(e,t)}))}}(),function(){function e(e,t,n){void 0===n&&(n=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=n}return e.prototype.intersectsBoxMinMax=function(t,n,r){void 0===r&&(r=0);var i,o,a,s,l=e.TmpVector3[0].copyFromFloats(t.x-r,t.y-r,t.z-r),c=e.TmpVector3[1].copyFromFloats(n.x+r,n.y+r,n.z+r),u=0,d=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xc.x)return!1}else if(i=1/this.direction.x,o=(l.x-this.origin.x)*i,(a=(c.x-this.origin.x)*i)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(d=Math.min(a,d)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yc.y)return!1}else if(i=1/this.direction.y,o=(l.y-this.origin.y)*i,(a=(c.y-this.origin.y)*i)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(d=Math.min(a,d)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zc.z)return!1}else if(i=1/this.direction.z,o=(l.z-this.origin.z)*i,(a=(c.z-this.origin.z)*i)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(d=Math.min(a,d)))return!1;return!0},e.prototype.intersectsBox=function(e,t){return void 0===t&&(t=0),this.intersectsBoxMinMax(e.minimum,e.maximum,t)},e.prototype.intersectsSphere=function(e,t){void 0===t&&(t=0);var n=e.center.x-this.origin.x,r=e.center.y-this.origin.y,i=e.center.z-this.origin.z,o=n*n+r*r+i*i,a=e.radius+t,s=a*a;if(o<=s)return!0;var l=n*this.direction.x+r*this.direction.y+i*this.direction.z;return!(l<0)&&o-l*l<=s},e.prototype.intersectsTriangle=function(t,n,r){var i=e.TmpVector3[0],o=e.TmpVector3[1],a=e.TmpVector3[2],s=e.TmpVector3[3],l=e.TmpVector3[4];n.subtractToRef(t,i),r.subtractToRef(t,o),So.CrossToRef(this.direction,o,a);var c=So.Dot(i,a);if(0===c)return null;var u=1/c;this.origin.subtractToRef(t,s);var d=So.Dot(s,a)*u;if(d<0||d>1)return null;So.CrossToRef(s,i,l);var h=So.Dot(this.direction,l)*u;if(h<0||d+h>1)return null;var p=So.Dot(o,l)*u;return p>this.length?null:new Bs(1-d-h,d,p)},e.prototype.intersectsPlane=function(e){var t,n=So.Dot(e.normal,this.direction);if(Math.abs(n)<9.99999997475243e-7)return null;var r=So.Dot(e.normal,this.origin);return(t=(-e.d-r)/n)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsAxis=function(e,t){switch(void 0===t&&(t=0),e){case"y":return(n=(this.origin.y-t)/this.direction.y)>0?null:new So(this.origin.x+this.direction.x*-n,t,this.origin.z+this.direction.z*-n);case"x":return(n=(this.origin.x-t)/this.direction.x)>0?null:new So(t,this.origin.y+this.direction.y*-n,this.origin.z+this.direction.z*-n);case"z":var n;return(n=(this.origin.z-t)/this.direction.z)>0?null:new So(this.origin.x+this.direction.x*-n,this.origin.y+this.direction.y*-n,t);default:return null}},e.prototype.intersectsMesh=function(t,n){var r=Mo.Matrix[0];return t.getWorldMatrix().invertToRef(r),this._tmpRay?e.TransformToRef(this,r,this._tmpRay):this._tmpRay=e.Transform(this,r),t.intersects(this._tmpRay,n)},e.prototype.intersectsMeshes=function(e,t,n){n?n.length=0:n=[];for(var r=0;rt.distance?1:0},e.prototype.intersectionSegment=function(t,n,r){var i=this.origin,o=Mo.Vector3[0],a=Mo.Vector3[1],s=Mo.Vector3[2],l=Mo.Vector3[3];n.subtractToRef(t,o),this.direction.scaleToRef(e.rayl,s),i.addToRef(s,a),t.subtractToRef(i,l);var c,u,d,h,p=So.Dot(o,o),f=So.Dot(o,s),m=So.Dot(s,s),g=So.Dot(o,l),b=So.Dot(s,l),v=p*m-f*f,A=v,_=v;vA&&(u=A,h=b+f,_=m)),h<0?(h=0,-g<0?u=0:-g>p?u=A:(u=-g,A=p)):h>_&&(h=_,-g+f<0?u=0:-g+f>p?u=A:(u=-g+f,A=p)),c=Math.abs(u)0&&d<=this.length&&w.lengthSquared()=i.distance))&&(i=l,n)))break}return i||new ds},nl.prototype._internalMultiPick=function(e,t,n){if(!ds)return null;for(var r=new Array,i=0;i1)throw"Multiple drag modes specified in dragBehavior options. Only one expected"}return Object.defineProperty(e.prototype,"options",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t,n){var r=this;this._scene=t.getScene(),this.attachedNode=t,e._planeScene||(this._debugMode?e._planeScene=this._scene:(e._planeScene=new nl(this._scene.getEngine(),{virtual:!0}),e._planeScene.detachControl(),this._scene.onDisposeObservable.addOnce((function(){e._planeScene.dispose(),e._planeScene=null})))),this._dragPlane=Pl.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,e._planeScene,!1,Pl.DOUBLESIDE),this.lastDragPosition=new So(0,0,0);var i=n||function(e){return r.attachedNode==e||e.isDescendantOf(r.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add((function(t,n){if(r.enabled)if(t.type==Qs.POINTERDOWN)r.startAndReleaseDragOnPointerEvents&&!r.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.pickedPoint&&t.pickInfo.ray&&i(t.pickInfo.pickedMesh)&&r._startDrag(t.event.pointerId,t.pickInfo.ray,t.pickInfo.pickedPoint);else if(t.type==Qs.POINTERUP)r.startAndReleaseDragOnPointerEvents&&r.currentDraggingPointerID==t.event.pointerId&&r.releaseDrag();else if(t.type==Qs.POINTERMOVE){var o=t.event.pointerId;r.currentDraggingPointerID===e._AnyMouseID&&o!==e._AnyMouseID&&"mouse"==t.event.pointerType&&(r._lastPointerRay[r.currentDraggingPointerID]&&(r._lastPointerRay[o]=r._lastPointerRay[r.currentDraggingPointerID],delete r._lastPointerRay[r.currentDraggingPointerID]),r.currentDraggingPointerID=o),r._lastPointerRay[o]||(r._lastPointerRay[o]=new Vl(new So,new So)),t.pickInfo&&t.pickInfo.ray&&(r._lastPointerRay[o].origin.copyFrom(t.pickInfo.ray.origin),r._lastPointerRay[o].direction.copyFrom(t.pickInfo.ray.direction),r.currentDraggingPointerID==o&&r.dragging&&r._moveDrag(t.pickInfo.ray))}})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){r._moving&&r.moveAttached&&(zl._RemoveAndStorePivotPoint(r.attachedNode),r._targetPosition.subtractToRef(r.attachedNode.absolutePosition,r._tmpVector),r._tmpVector.scaleInPlace(r.dragDeltaRatio),r.attachedNode.getAbsolutePosition().addToRef(r._tmpVector,r._tmpVector),r.validateDrag(r._tmpVector)&&r.attachedNode.setAbsolutePosition(r._tmpVector),zl._RestorePivotPoint(r.attachedNode))}))},e.prototype.releaseDrag=function(){this.dragging&&(this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerID}),this.dragging=!1),this.currentDraggingPointerID=-1,this._moving=!1,this.detachCameraControls&&this._attachedElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera&&this._scene.activeCamera.attachControl(this._attachedElement,!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault)},e.prototype.startDrag=function(t,n,r){void 0===t&&(t=e._AnyMouseID),this._startDrag(t,n,r);var i=this._lastPointerRay[t];t===e._AnyMouseID&&(i=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),i&&this._moveDrag(i)},e.prototype._startDrag=function(e,t,n){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){zl._RemoveAndStorePivotPoint(this.attachedNode),t?(this._startDragRay.direction.copyFrom(t.direction),this._startDragRay.origin.copyFrom(t.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,n||this._tmpVector);var r=this._pickWithRayOnDragPlane(this._startDragRay);r&&(this.dragging=!0,this.currentDraggingPointerID=e,this.lastDragPosition.copyFrom(r),this.onDragStartObservable.notifyObservers({dragPlanePoint:r,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.attachedElement?(this._attachedElement=this._scene.activeCamera.inputs.attachedElement,this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement)):this._attachedElement=null)),zl._RestorePivotPoint(this.attachedNode)}},e.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){this.updateDragPlane&&this._updateDragPlanePosition(e,t);var n=0;this._options.dragAxis?(this.useObjectOrientationForDragging?So.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),n=So.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(n,this._dragDelta)):(n=this._dragDelta.length(),t.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:n,delta:this._dragDelta,dragPlanePoint:t,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerID}),this.lastDragPosition.copyFrom(t)}},e.prototype._pickWithRayOnDragPlane=function(t){var n=this;if(!t)return null;var r=Math.acos(So.Dot(this._dragPlane.forward,t.direction));if(r>Math.PI/2&&(r=Math.PI-r),this.maxDragAngle>0&&r>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*So.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var i=So.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-i,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),this._alternatePickedPoint}return null}var o=e._planeScene.pickWithRay(t,(function(e){return e==n._dragPlane}));return o&&o.hit&&o.pickedMesh&&o.pickedPoint?o.pickedPoint:null},e.prototype._updateDragPlanePosition=function(e,t){this._pointA.copyFrom(t),this._options.dragAxis?(this.useObjectOrientationForDragging?So.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),this._pointA.addToRef(this._localAxis,this._pointB),e.origin.subtractToRef(this._pointA,this._pointC),this._pointA.addToRef(this._pointC.normalize(),this._pointC),this._pointB.subtractToRef(this._pointA,this._lineA),this._pointC.subtractToRef(this._pointA,this._lineB),So.CrossToRef(this._lineA,this._lineB,this._lookAt),So.CrossToRef(this._lineA,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?So.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(e.origin)),this._dragPlane.position.copyFrom(this.attachedNode.absolutePosition),this._dragPlane.computeWorldMatrix(!0)},e.prototype.detach=function(){this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this.releaseDrag()},e._AnyMouseID=-2,e}(),Hl=(function(){function e(){this._startDistance=0,this._initialScale=new So(0,0,0),this._targetScale=new So(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new Gl({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new Gl({}),this._dragBehaviorB.moveAttached=!1}Object.defineProperty(e.prototype,"name",{get:function(){return"MultiPointerScale"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype._getCurrentDistance=function(){return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()},e.prototype.attach=function(e){var t=this;this._ownerNode=e,this._dragBehaviorA.onDragStartObservable.add((function(n){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorA.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),this._dragBehaviorB.onDragStartObservable.add((function(n){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorB.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(e){e.onDragObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var e=t._getCurrentDistance()/t._startDistance;t._initialScale.scaleToRef(e,t._targetScale)}}))})),e.addBehavior(this._dragBehaviorA),e.addBehavior(this._dragBehaviorB),this._sceneRenderObserver=e.getScene().onBeforeRenderObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var n=t._targetScale.subtract(e.scaling).scaleInPlace(.1);n.length()>.01&&e.scaling.addInPlace(n)}}))},e.prototype.detach=function(){var e=this;this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(t){t.onDragStartObservable.clear(),t.onDragObservable.clear(),e._ownerNode.removeBehavior(t)}))}}(),function(){function e(){this._sceneRenderObserver=null,this._targetPosition=new So(0,0,0),this._moving=!1,this._startingOrientation=new Po,this.zDragFactor=3,this.rotateDraggedObject=!0,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new yo.a,this.onDragEndObservable=new yo.a}return Object.defineProperty(e.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},Object.defineProperty(e.prototype,"_pointerCamera",{get:function(){return this._scene.cameraToUseForPointers?this._scene.cameraToUseForPointers:this._scene.activeCamera},enumerable:!0,configurable:!0}),e.prototype.attach=function(t){var n=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),e._virtualScene||(e._virtualScene=new nl(this._scene.getEngine()),e._virtualScene.detachControl(),this._scene.getEngine().scenes.pop());var r=null,i=new So(0,0,0);this._virtualOriginMesh=new ws("",e._virtualScene),this._virtualOriginMesh.rotationQuaternion=new Po,this._virtualDragMesh=new ws("",e._virtualScene),this._virtualDragMesh.rotationQuaternion=new Po;var o=null;this._pointerObserver=this._scene.onPointerObservable.add((function(e,t){if(e.type==Qs.POINTERDOWN){if(!n.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.ray&&(u=e.pickInfo.pickedMesh,n._ownerNode==u||u.isDescendantOf(n._ownerNode))){n._pointerCamera&&n._pointerCamera.cameraRigMode==Ts.RIG_MODE_NONE&&e.pickInfo.ray.origin.copyFrom(n._pointerCamera.globalPosition),r=n._ownerNode,zl._RemoveAndStorePivotPoint(r),i.copyFrom(e.pickInfo.ray.origin),n._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),n._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),n._virtualOriginMesh.removeChild(n._virtualDragMesh),r.computeWorldMatrix(),n._virtualDragMesh.position.copyFrom(r.absolutePosition),r.rotationQuaternion||(r.rotationQuaternion=Po.RotationYawPitchRoll(r.rotation.y,r.rotation.x,r.rotation.z));var a=r.parent;r.setParent(null),n._virtualDragMesh.rotationQuaternion.copyFrom(r.rotationQuaternion),r.setParent(a),n._virtualOriginMesh.addChild(n._virtualDragMesh),n._targetPosition.copyFrom(n._virtualDragMesh.absolutePosition),n.dragging=!0,n.currentDraggingPointerID=e.event.pointerId,n.detachCameraControls&&n._pointerCamera&&!n._pointerCamera.leftCamera&&(n._pointerCamera.inputs.attachedElement?(o=n._pointerCamera.inputs.attachedElement,n._pointerCamera.detachControl(n._pointerCamera.inputs.attachedElement)):o=null),zl._RestorePivotPoint(r),n.onDragStartObservable.notifyObservers({})}}else if(e.type==Qs.POINTERUP)n.currentDraggingPointerID==e.event.pointerId&&(n.dragging=!1,n._moving=!1,n.currentDraggingPointerID=-1,r=null,n._virtualOriginMesh.removeChild(n._virtualDragMesh),n.detachCameraControls&&o&&n._pointerCamera&&!n._pointerCamera.leftCamera&&n._pointerCamera.attachControl(o,!0),n.onDragEndObservable.notifyObservers({}));else if(e.type==Qs.POINTERMOVE&&n.currentDraggingPointerID==e.event.pointerId&&n.dragging&&e.pickInfo&&e.pickInfo.ray&&r){var s=n.zDragFactor;n._pointerCamera&&n._pointerCamera.cameraRigMode==Ts.RIG_MODE_NONE&&(e.pickInfo.ray.origin.copyFrom(n._pointerCamera.globalPosition),s=0);var l=e.pickInfo.ray.origin.subtract(i);i.copyFrom(e.pickInfo.ray.origin);var c=-So.Dot(l,e.pickInfo.ray.direction);n._virtualOriginMesh.addChild(n._virtualDragMesh),n._virtualDragMesh.position.z-=n._virtualDragMesh.position.z<1?c*n.zDragFactor:c*s*n._virtualDragMesh.position.z,n._virtualDragMesh.position.z<0&&(n._virtualDragMesh.position.z=0),n._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),n._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),n._virtualOriginMesh.removeChild(n._virtualDragMesh),n._targetPosition.copyFrom(n._virtualDragMesh.absolutePosition),r.parent&&So.TransformCoordinatesToRef(n._targetPosition,Oo.Invert(r.parent.getWorldMatrix()),n._targetPosition),n._moving||n._startingOrientation.copyFrom(n._virtualDragMesh.rotationQuaternion),n._moving=!0}var u}));var a=new Po;this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(n.dragging&&n._moving&&r){if(zl._RemoveAndStorePivotPoint(r),r.position.addInPlace(n._targetPosition.subtract(r.position).scale(n.dragDeltaRatio)),n.rotateDraggedObject){a.copyFrom(n._startingOrientation),a.x=-a.x,a.y=-a.y,a.z=-a.z,n._virtualDragMesh.rotationQuaternion.multiplyToRef(a,a),Po.RotationYawPitchRollToRef(a.toEulerAngles("xyz").y,0,0,a),a.multiplyToRef(n._startingOrientation,a);var e=r.parent;(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&(r.setParent(null),Po.SlerpToRef(r.rotationQuaternion,a,n.dragDeltaRatio,r.rotationQuaternion),r.setParent(e))}zl._RestorePivotPoint(r)}}))},e.prototype.detach=function(){this._scene&&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.onDragStartObservable.clear()},e}()),Ql=(function(){function e(e,t,n){if(this.targetPosition=So.Zero(),this.poleTargetPosition=So.Zero(),this.poleTargetLocalOffset=So.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=Po.Identity(),this._bone1Mat=Oo.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=So.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=t,this._bone1=t.getParent(),this._bone1){this.mesh=e;var r=t.getPosition();if(t.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,r.x>r.y&&r.x>r.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var i=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*i.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){e.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(e),s=this._bone2.getAbsolutePosition(e),l=this._bone1.getAbsolutePosition(e);this._bone1Length=So.Distance(a,s),this._bone2Length=So.Distance(s,l)}this._bone1.getRotationMatrixToRef(es.WORLD,e,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))}}Object.defineProperty(e.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),e.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||null==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,n=this._bone2Length;this._maxReach=Math.sqrt(t*t+n*n-2*t*n*Math.cos(e))},e.prototype.update=function(){var t=this._bone1;if(t){var n=this.targetPosition,r=this.poleTargetPosition,i=e._tmpMats[0],o=e._tmpMats[1];this.targetMesh&&n.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,r):this.poleTargetMesh&&So.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),r);var a=e._tmpVecs[0],s=e._tmpVecs[1],l=e._tmpVecs[2],c=e._tmpVecs[3],u=e._tmpVecs[4],d=e._tmpQuat;t.getAbsolutePositionToRef(this.mesh,a),r.subtractToRef(a,u),0==u.x&&0==u.y&&0==u.z?u.y=1:u.normalize(),n.subtractToRef(a,c),c.normalize(),So.CrossToRef(c,u,s),s.normalize(),So.CrossToRef(c,s,l),l.normalize(),Oo.FromXYZAxesToRef(l,c,s,i);var h=this._bone1Length,p=this._bone2Length,f=So.Distance(a,n);this._maxReach>0&&(f=Math.min(this._maxReach,f));var m=(p*p+f*f-h*h)/(2*p*f),g=(f*f+h*h-p*p)/(2*f*h);m>1&&(m=1),g>1&&(g=1),m<-1&&(m=-1),g<-1&&(g=-1);var b=Math.acos(m),v=Math.acos(g),A=-b-v;if(this._rightHandedSystem)Oo.RotationYawPitchRollToRef(0,0,this._adjustRoll,o),o.multiplyToRef(i,i),Oo.RotationAxisToRef(this._bendAxis,v,o),o.multiplyToRef(i,i);else{var _=e._tmpVecs[5];_.copyFrom(this._bendAxis),_.x*=-1,Oo.RotationAxisToRef(_,-v,o),o.multiplyToRef(i,i)}this.poleAngle&&(Oo.RotationAxisToRef(c,this.poleAngle,o),i.multiplyToRef(o,i)),this._bone1&&(this.slerpAmount<1?(this._slerping||Po.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),Po.FromRotationMatrixToRef(i,d),Po.SlerpToRef(this._bone1Quat,d,this.slerpAmount,this._bone1Quat),A=this._bone2Ang*(1-this.slerpAmount)+A*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,es.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(i,es.WORLD,this.mesh),this._bone1Mat.copyFrom(i),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,A,es.LOCAL),this._bone2Ang=A}},e._tmpVecs=[So.Zero(),So.Zero(),So.Zero(),So.Zero(),So.Zero(),So.Zero()],e._tmpQuat=Po.Identity(),e._tmpMats=[Oo.Identity(),Oo.Identity()]}(),function(){function e(e,t,n,r){if(this.upAxis=So.Up(),this.upAxisSpace=es.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=Po.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=So.Forward(),this.mesh=e,this.bone=t,this.target=n,r&&(r.adjustYaw&&(this.adjustYaw=r.adjustYaw),r.adjustPitch&&(this.adjustPitch=r.adjustPitch),r.adjustRoll&&(this.adjustRoll=r.adjustRoll),null!=r.maxYaw?this.maxYaw=r.maxYaw:this.maxYaw=Math.PI,null!=r.minYaw?this.minYaw=r.minYaw:this.minYaw=-Math.PI,null!=r.maxPitch?this.maxPitch=r.maxPitch:this.maxPitch=Math.PI,null!=r.minPitch?this.minPitch=r.minPitch:this.minPitch=-Math.PI,null!=r.slerpAmount&&(this.slerpAmount=r.slerpAmount),null!=r.upAxis&&(this.upAxis=r.upAxis),null!=r.upAxisSpace&&(this.upAxisSpace=r.upAxisSpace),null!=r.yawAxis||null!=r.pitchAxis)){var i=os.Y,o=os.X;null!=r.yawAxis&&(i=r.yawAxis.clone()).normalize(),null!=r.pitchAxis&&(o=r.pitchAxis.clone()).normalize();var a=So.Cross(o,i);this._transformYawPitch=Oo.Identity(),Oo.FromXYZAxesToRef(o,i,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}t.getParent()||this.upAxisSpace!=es.BONE||(this.upAxisSpace=es.LOCAL)}Object.defineProperty(e.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),e.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var t=this.bone,n=e._tmpVecs[0];t.getAbsolutePositionToRef(this.mesh,n);var r=this.target,i=e._tmpMats[0],o=e._tmpMats[1],a=this.mesh,s=t.getParent(),l=e._tmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==es.BONE&&s?(this._transformYawPitch&&So.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),s.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==es.LOCAL&&(a.getDirectionToRef(l,l),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||l.normalize());var c=!1,u=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(c=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(u=!0),c||u){var d=e._tmpMats[2],h=e._tmpMats[3];if(this.upAxisSpace==es.BONE&&1==l.y&&s)s.getRotationMatrixToRef(es.WORLD,this.mesh,d);else if(this.upAxisSpace!=es.LOCAL||1!=l.y||s){(f=e._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&So.TransformCoordinatesToRef(f,this._transformYawPitchInv,f),s?s.getDirectionToRef(f,this.mesh,f):a.getDirectionToRef(f,f);var p=So.Cross(l,f);p.normalize();var f=So.Cross(p,l);Oo.FromXYZAxesToRef(p,l,f,d)}else d.copyFrom(a.getWorldMatrix());d.invertToRef(h);var m=null;if(u){var g=e._tmpVecs[3];r.subtractToRef(n,g),So.TransformCoordinatesToRef(g,h,g),m=Math.sqrt(g.x*g.x+g.z*g.z);var b=Math.atan2(g.y,m),v=b;b>this._maxPitch?(g.y=this._maxPitchTan*m,v=this._maxPitch):bthis._maxYaw||AMath.PI?this._isAngleBetween(A,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,_=this._maxYaw):this._isAngleBetween(A,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*m,g.x=this._minYawSin*m,_=this._minYaw):A>this._maxYaw?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,_=this._maxYaw):AMath.PI){var y=e._tmpVecs[8];y.copyFrom(os.Z),this._transformYawPitch&&So.TransformCoordinatesToRef(y,this._transformYawPitchInv,y);var x=e._tmpMats[4];this._boneQuat.toRotationMatrix(x),this.mesh.getWorldMatrix().multiplyToRef(x,x),So.TransformCoordinatesToRef(y,x,y),So.TransformCoordinatesToRef(y,h,y);var w=Math.atan2(y.x,y.z);if(this._getAngleBetween(w,A)>this._getAngleBetween(w,this._midYawConstraint)){null==m&&(m=Math.sqrt(g.x*g.x+g.z*g.z));var E=this._getAngleBetween(w,this._maxYaw);this._getAngleBetween(w,this._minYaw)Math.PI?n-=2*Math.PI:n<-Math.PI&&(n+=2*Math.PI),n},e.prototype._getAngleBetween=function(e,t){var n=0;return(n=(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)?t-e:e-t)>Math.PI&&(n=2*Math.PI-n),n},e.prototype._isAngleBetween=function(e,t,n){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(n=(n%=2*Math.PI)<0?n+2*Math.PI:n)){if(e>t&&en&&e=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this)}void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())},e.prototype.serialize=function(){if(!this.name)return null;var e=ya.Serialize(this);return ya.AppendSerializedAnimations(this,e),e},e.WhenAllReady=function(e,t){var n=e.length;if(0!==n)for(var r,i,o=function(){if((r=e[a]).isReady())0==--n&&t();else if(i=r.onLoadObservable){var o=function(){i.removeCallback(o),0==--n&&t()};i.add(o)}},a=0;a>v,_=0;_<6;_++){var y=b[v][_];g&&(y=h._convertRGBtoRGBATextureData(y,A,A,i)),p.texImage2D(_,v,m,A,A,0,u,c,y)}h._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else h.updateRawCubeTexture(f,o,r,i,d);f.isReady=!0,t._removePendingData(f),l&&l()}}(e)}),void 0,t.offlineProvider,!0,(function(e,n){t._removePendingData(f),c&&e&&c(e.status+" "+e.statusText,n)})),f},ss.a.prototype.createRawTexture2DArray=Xl(!1),ss.a.prototype.createRawTexture3D=Xl(!0),ss.a.prototype.updateRawTexture2DArray=Yl(!1),ss.a.prototype.updateRawTexture3D=Yl(!0);var ql=function(e){function t(t,n,r,i,o,a,s,l,c){void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===l&&(l=3),void 0===c&&(c=0);var u=e.call(this,null,o,!a,s)||this;return u.format=i,u._engine=o.getEngine(),u._texture=o.getEngine().createRawTexture(t,n,r,i,a,s,l,null,c),u.wrapU=Wl.CLAMP_ADDRESSMODE,u.wrapV=Wl.CLAMP_ADDRESSMODE,u}return Object(No.d)(t,e),t.prototype.update=function(e){this._engine.updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t.CreateLuminanceTexture=function(e,n,r,i,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),new t(e,n,r,1,i,o,a,s)},t.CreateLuminanceAlphaTexture=function(e,n,r,i,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),new t(e,n,r,2,i,o,a,s)},t.CreateAlphaTexture=function(e,n,r,i,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),new t(e,n,r,0,i,o,a,s)},t.CreateRGBTexture=function(e,n,r,i,o,a,s,l){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),void 0===l&&(l=0),new t(e,n,r,4,i,o,a,s,l)},t.CreateRGBATexture=function(e,n,r,i,o,a,s,l){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=3),void 0===l&&(l=0),new t(e,n,r,5,i,o,a,s,l)},t.CreateRTexture=function(e,n,r,i,o,a,s,l){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=Wl.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=1),new t(e,n,r,6,i,o,a,s,l)},t}(Wl),Zl=function(){function e(e,t,n){this.name=e,this.id=t,this.bones=new Array,this.needInitialSkinMatrix=!1,this.overrideMesh=null,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=Oo.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new yo.a,this.bones=[],this._scene=n||Zo.a.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;var r=this._scene.getEngine().getCaps();this._canUseTextureForBones=r.textureFloat&&r.maxVertexTextureImageUnits>0}return Object.defineProperty(e.prototype,"useTextureToStoreBoneMatrices",{get:function(){return this._useTextureToStoreBoneMatrices},set:function(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTextureForMatrices",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"Skeleton"},e.prototype.getChildren=function(){return this.bones.filter((function(e){return!e.getParent()}))},e.prototype.getTransformMatrices=function(e){return this.needInitialSkinMatrix&&e._bonesTransformMatrices?e._bonesTransformMatrices:(this._transformMatrices||this.prepare(),this._transformMatrices)},e.prototype.getTransformMatrixTexture=function(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture:this._transformMatrixTexture},e.prototype.getScene=function(){return this._scene},e.prototype.toString=function(e){var t="Name: "+this.name+", nBones: "+this.bones.length;if(t+=", nAnimationRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var n=!0;for(var r in this._ranges)n&&(t+=", ",n=!1),t+=r;t+="}"}return t},e.prototype.getBoneIndexByName=function(e){for(var t=0,n=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)},e.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var n=0;n0)for(var e=0,t=this.bones;e0&&(i.animation=n.animations[0].serialize()),e.ranges=[],this._ranges){var a=this._ranges[o];if(a){var s={};s.name=o,s.from=a.from,s.to=a.to,e.ranges.push(s)}}}return e},e.Parse=function(t,n){var r,i=new e(t.name,t.id,n);for(t.dimensionsAtRest&&(i.dimensionsAtRest=So.FromArray(t.dimensionsAtRest)),i.needInitialSkinMatrix=t.needInitialSkinMatrix,r=0;r-1&&(a=i.bones[o.parentBoneIndex]);var s=o.rest?Oo.FromArray(o.rest):null,l=new rl(o.name,i,a,Oo.FromArray(o.matrix),s);void 0!==o.id&&null!==o.id&&(l.id=o.id),o.length&&(l.length=o.length),o.metadata&&(l.metadata=o.metadata),o.animation&&l.animations.push(Ca.Parse(o.animation)),void 0!==o.linkedTransformNodeId&&null!==o.linkedTransformNodeId&&(i._hasWaitingData=!0,l._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(r=0;r0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},e.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),n=0;n=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(e.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!0,configurable:!0}),e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.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]})},e.prototype.dispose=function(){},e.GAMEPAD=0,e.GENERIC=1,e.XBOX=2,e.POSE_ENABLED=3,e.DUALSHOCK=4,e}(),tc=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i.onButtonDownObservable=new yo.a,i.onButtonUpObservable=new yo.a,i.type=ec.GENERIC,i._buttons=new Array(r.buttons.length),i}return Object(No.d)(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,n){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(n),this.onButtonDownObservable.notifyObservers(n)),0===e&&(this._onbuttonup&&this._onbuttonup(n),this.onButtonUpObservable.notifyObservers(n))),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t.005&&(e.inertialAlphaOffset+=n)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility*this._yAxisScale;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var i=this.gamepad.leftStick;if(i&&0!=i.y){var o=i.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},e.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},Object(No.c)([ha()],e.prototype,"gamepadRotationSensibility",void 0),Object(No.c)([ha()],e.prototype,"gamepadMoveSensibility",void 0),e}();Jl.ArcRotateCameraGamepadInput=nc;var rc=function(){function e(){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=.01,this._keys=new Array}return e.prototype.attachControl=function(e,t){var n=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){n._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(e){var r,i=e.event;i.metaKey||(e.type===Ys.KEYDOWN?(n._ctrlPressed=i.ctrlKey,n._altPressed=i.altKey,(-1!==n.keysUp.indexOf(i.keyCode)||-1!==n.keysDown.indexOf(i.keyCode)||-1!==n.keysLeft.indexOf(i.keyCode)||-1!==n.keysRight.indexOf(i.keyCode)||-1!==n.keysReset.indexOf(i.keyCode))&&(-1===(r=n._keys.indexOf(i.keyCode))&&n._keys.push(i.keyCode),i.preventDefault&&(t||i.preventDefault()))):-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)&&-1===n.keysReset.indexOf(i.keyCode)||((r=n._keys.indexOf(i.keyCode))>=0&&n._keys.splice(r,1),i.preventDefault&&(t||i.preventDefault())))})))},e.prototype.detachControl=function(e){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=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t0?n/(1+this.wheelDeltaPercentage):n*(1+this.wheelDeltaPercentage)},e.prototype.attachControl=function(e,t){var n=this;this._wheel=function(e,r){if(e.type===Qs.POINTERWHEEL){var i=e.event,o=0,a=i,s=0;if(s=a.wheelDelta?a.wheelDelta:60*-(i.deltaY||i.detail),n.wheelDeltaPercentage){if((o=n.computeDeltaFromMouseWheelLegacyEvent(s,n.camera.radius))>0){for(var l=n.camera.radius,c=n.camera.inertialRadiusOffset+o,u=0;u<20&&Math.abs(c)>.001;u++)l-=c,c*=n.camera.inertia;l=xo.Clamp(l,0,Number.MAX_VALUE),o=n.computeDeltaFromMouseWheelLegacyEvent(s,l)}}else o=s/(40*n.wheelPrecision);o&&(n.camera.inertialRadiusOffset+=o),i.preventDefault&&(t||i.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Qs.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},Object(No.c)([ha()],e.prototype,"wheelPrecision",void 0),Object(No.c)([ha()],e.prototype,"wheelDeltaPercentage",void 0),e}();Jl.ArcRotateCameraMouseWheelInput=ic;var oc=function(){function e(){this.buttons=[0,1,2]}return e.prototype.attachControl=function(e,t){var n=this,r=this.camera.getEngine(),i=0,o=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(a,s){var l=a.event,c="touch"===l.pointerType;if(!r.isInVRExclusivePointerMode&&(a.type===Qs.POINTERMOVE||-1!==n.buttons.indexOf(l.button))){var u=l.srcElement||l.target;if(n._altKey=l.altKey,n._ctrlKey=l.ctrlKey,n._metaKey=l.metaKey,n._shiftKey=l.shiftKey,n._buttonsPressed=l.buttons,r.isPointerLock){var d=l.movementX||l.mozMovementX||l.webkitMovementX||l.msMovementX||0,h=l.movementY||l.mozMovementY||l.webkitMovementY||l.msMovementY||0;n.onTouch(null,d,h),n.pointA=null,n.pointB=null}else if(a.type===Qs.POINTERDOWN&&u){try{u.setPointerCapture(l.pointerId)}catch(e){}null===n.pointA?n.pointA={x:l.clientX,y:l.clientY,pointerId:l.pointerId,type:l.pointerType}:null===n.pointB&&(n.pointB={x:l.clientX,y:l.clientY,pointerId:l.pointerId,type:l.pointerType}),n.onButtonDown(l),t||(l.preventDefault(),e.focus())}else if(a.type===Qs.POINTERDOUBLETAP)n.onDoubleTap(l.pointerType);else if(a.type===Qs.POINTERUP&&u){try{u.releasePointerCapture(l.pointerId)}catch(e){}c||(n.pointB=null),r._badOS?n.pointA=n.pointB=null:n.pointB&&n.pointA&&n.pointA.pointerId==l.pointerId?(n.pointA=n.pointB,n.pointB=null):n.pointA&&n.pointB&&n.pointB.pointerId==l.pointerId?n.pointB=null:n.pointA=n.pointB=null,(0!==i||o)&&(n.onMultiTouch(n.pointA,n.pointB,i,0,o,null),i=0,o=null),n.onButtonUp(l),t||l.preventDefault()}else if(a.type===Qs.POINTERMOVE)if(t||l.preventDefault(),n.pointA&&null===n.pointB){d=l.clientX-n.pointA.x,h=l.clientY-n.pointA.y;n.onTouch(n.pointA,d,h),n.pointA.x=l.clientX,n.pointA.y=l.clientY}else if(n.pointA&&n.pointB){var p=n.pointA.pointerId===l.pointerId?n.pointA:n.pointB;p.x=l.clientX,p.y=l.clientY;var f=n.pointA.x-n.pointB.x,m=n.pointA.y-n.pointB.y,g=f*f+m*m,b={x:(n.pointA.x+n.pointB.x)/2,y:(n.pointA.y+n.pointB.y)/2,pointerId:l.pointerId,type:a.type};n.onMultiTouch(n.pointA,n.pointB,i,g,o,b),o=b,i=g}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Qs.POINTERDOWN|Qs.POINTERUP|Qs.POINTERMOVE),this._onLostFocus=function(){n.pointA=n.pointB=null,i=0,o=null,n.onLostFocus()},e.addEventListener("contextmenu",this.onContextMenu.bind(this),!1);var a=this.camera.getScene().getEngine().getHostWindow();a&&Ja.RegisterTopRootEvents(a,[{name:"blur",handler:this._onLostFocus}])},e.prototype.detachControl=function(e){if(this._onLostFocus){var t=this.camera.getScene().getEngine().getHostWindow();t&&Ja.UnregisterTopRootEvents(t,[{name:"blur",handler:this._onLostFocus}])}e&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this.onContextMenu&&e.removeEventListener("contextmenu",this.onContextMenu),this._onLostFocus=null),this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0},e.prototype.getClassName=function(){return"BaseCameraPointersInput"},e.prototype.getSimpleName=function(){return"pointers"},e.prototype.onDoubleTap=function(e){},e.prototype.onTouch=function(e,t,n){},e.prototype.onMultiTouch=function(e,t,n,r,i,o){},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.onButtonDown=function(e){},e.prototype.onButtonUp=function(e){},e.prototype.onLostFocus=function(){},Object(No.c)([ha()],e.prototype,"buttons",void 0),e}(),ac=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.buttons=[0,1,2],t.angularSensibilityX=1e3,t.angularSensibilityY=1e3,t.pinchPrecision=12,t.pinchDeltaPercentage=0,t.useNaturalPinchZoom=!1,t.panningSensibility=1e3,t.multiTouchPanning=!0,t.multiTouchPanAndZoom=!0,t.pinchInwards=!0,t._isPanClick=!1,t._twoFingerActivityCount=0,t._isPinching=!1,t}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype.onTouch=function(e,t,n){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=n/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=n/this.angularSensibilityY)},t.prototype.onDoubleTap=function(e){this.camera.useInputToRestoreState&&this.camera.restoreState()},t.prototype.onMultiTouch=function(e,t,n,r,i,o){if(!(0===n&&null===i||0===r&&null===o)){var a=this.pinchInwards?1:-1;if(this.multiTouchPanAndZoom){if(this.useNaturalPinchZoom?this.camera.radius=this.camera.radius*Math.sqrt(n)/Math.sqrt(r):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(r-n)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(r-n)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),0!==this.panningSensibility&&i&&o){var s=o.x-i.x,l=o.y-i.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=l/this.panningSensibility}}else{this._twoFingerActivityCount++;var c=Math.sqrt(n),u=Math.sqrt(r);if(this._isPinching||this._twoFingerActivityCount<20&&Math.abs(u-c)>this.camera.pinchToPanMaxDistance)this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(r-n)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(r-n)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),this._isPinching=!0;else if(0!==this.panningSensibility&&this.multiTouchPanning&&o&&i){s=o.x-i.x,l=o.y-i.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=l/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(No.c)([ha()],t.prototype,"buttons",void 0),Object(No.c)([ha()],t.prototype,"angularSensibilityX",void 0),Object(No.c)([ha()],t.prototype,"angularSensibilityY",void 0),Object(No.c)([ha()],t.prototype,"pinchPrecision",void 0),Object(No.c)([ha()],t.prototype,"pinchDeltaPercentage",void 0),Object(No.c)([ha()],t.prototype,"useNaturalPinchZoom",void 0),Object(No.c)([ha()],t.prototype,"panningSensibility",void 0),Object(No.c)([ha()],t.prototype,"multiTouchPanning",void 0),Object(No.c)([ha()],t.prototype,"multiTouchPanAndZoom",void 0),t}(oc);Jl.ArcRotateCameraPointersInput=ac;var sc=function(e){function t(t){return e.call(this,t)||this}return Object(No.d)(t,e),t.prototype.addMouseWheel=function(){return this.add(new ic),this},t.prototype.addPointers=function(){return this.add(new ac),this},t.prototype.addKeyboard=function(){return this.add(new rc),this},t}($l);sc.prototype.addVRDeviceOrientation=function(){return this.add(new lc),this};var lc=function(){function e(){this.alphaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){var n=this;this.camera.attachControl(e,t);var r=this.camera.getScene().getEngine().getHostWindow();r&&("undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?r.addEventListener("deviceorientation",n._deviceOrientationHandler):Ja.Warn("Permission not granted.")})).catch((function(e){Ja.Error(e)})):r.addEventListener("deviceorientation",this._deviceOrientationHandler))},e.prototype._onOrientationEvent=function(e){null!==e.alpha&&(this._alpha=(0|+e.alpha)*this.alphaCorrection),null!==e.gamma&&(this._gamma=(0|+e.gamma)*this.gammaCorrection),this._dirty=!0},e.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)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e}();Jl.ArcRotateCameraVRDeviceOrientationInput=lc;var cc=function(){function e(){this.keysForward=[87],this.keysBackward=[83],this.keysUp=[69],this.keysDown=[81],this.keysRight=[68],this.keysLeft=[65],this._keys=new Array}return e.prototype.attachControl=function(e,t){var n=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){n._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(e){var r,i=e.event;e.type===Ys.KEYDOWN?-1===n.keysForward.indexOf(i.keyCode)&&-1===n.keysBackward.indexOf(i.keyCode)&&-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||(-1===(r=n._keys.indexOf(i.keyCode))&&n._keys.push(i.keyCode),t||i.preventDefault()):-1===n.keysForward.indexOf(i.keyCode)&&-1===n.keysBackward.indexOf(i.keyCode)&&-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||((r=n._keys.indexOf(i.keyCode))>=0&&n._keys.splice(r,1),t||i.preventDefault())})))},e.prototype.detachControl=function(e){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=[]},e.prototype.getClassName=function(){return"FlyCameraKeyboardInput"},e.prototype._onLostFocus=function(e){this._keys=[]},e.prototype.getSimpleName=function(){return"keyboard"},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t=0&&n._keys.splice(r,1),i.preventDefault&&(t||i.preventDefault())))})))},e.prototype.detachControl=function(e){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=[]},e.prototype.checkInputs=function(){var e=this;this._onKeyboardObserver&&this._keys.forEach((function(t){-1!==e.keysHeightOffsetIncr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset+=e.heightSensibility:-1!==e.keysHeightOffsetDecr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset-=e.heightSensibility:-1!==e.keysRotationOffsetIncr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset+=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRotationOffsetDecr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset-=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRadiusIncr.indexOf(t)&&e._modifierRadius()?e.camera.radius+=e.radiusSensibility:-1!==e.keysRadiusDecr.indexOf(t)&&e._modifierRadius()&&(e.camera.radius-=e.radiusSensibility)}))},e.prototype.getClassName=function(){return"FollowCameraKeyboardMoveInput"},e.prototype.getSimpleName=function(){return"keyboard"},e.prototype._modifierHeightOffset=function(){return this.keysHeightOffsetModifierAlt===this._altPressed&&this.keysHeightOffsetModifierCtrl===this._ctrlPressed&&this.keysHeightOffsetModifierShift===this._shiftPressed},e.prototype._modifierRotationOffset=function(){return this.keysRotationOffsetModifierAlt===this._altPressed&&this.keysRotationOffsetModifierCtrl===this._ctrlPressed&&this.keysRotationOffsetModifierShift===this._shiftPressed},e.prototype._modifierRadius=function(){return this.keysRadiusModifierAlt===this._altPressed&&this.keysRadiusModifierCtrl===this._ctrlPressed&&this.keysRadiusModifierShift===this._shiftPressed},Object(No.c)([ha()],e.prototype,"keysHeightOffsetIncr",void 0),Object(No.c)([ha()],e.prototype,"keysHeightOffsetDecr",void 0),Object(No.c)([ha()],e.prototype,"keysHeightOffsetModifierAlt",void 0),Object(No.c)([ha()],e.prototype,"keysHeightOffsetModifierCtrl",void 0),Object(No.c)([ha()],e.prototype,"keysHeightOffsetModifierShift",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetIncr",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetDecr",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetModifierAlt",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetModifierCtrl",void 0),Object(No.c)([ha()],e.prototype,"keysRotationOffsetModifierShift",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusIncr",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusDecr",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusModifierAlt",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusModifierCtrl",void 0),Object(No.c)([ha()],e.prototype,"keysRadiusModifierShift",void 0),Object(No.c)([ha()],e.prototype,"heightSensibility",void 0),Object(No.c)([ha()],e.prototype,"rotationSensibility",void 0),Object(No.c)([ha()],e.prototype,"radiusSensibility",void 0),e}();Jl.FollowCameraKeyboardMoveInput=dc;var hc=function(){function e(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e,t){var n=this;this._wheel=function(e,r){if(e.type===Qs.POINTERWHEEL){var i=e.event,o=0,a=Math.max(-1,Math.min(1,i.deltaY||i.wheelDelta||-i.detail));n.wheelDeltaPercentage?(console.assert(n.axisControlRadius+n.axisControlHeight+n.axisControlRotation<=1,"wheelDeltaPercentage only usable when mouse wheel controlls ONE axis. Currently enabled: axisControlRadius: "+n.axisControlRadius+", axisControlHeightOffset: "+n.axisControlHeight+", axisControlRotationOffset: "+n.axisControlRotation),n.axisControlRadius?o=.01*a*n.wheelDeltaPercentage*n.camera.radius:n.axisControlHeight?o=.01*a*n.wheelDeltaPercentage*n.camera.heightOffset:n.axisControlRotation&&(o=.01*a*n.wheelDeltaPercentage*n.camera.rotationOffset)):o=a*n.wheelPrecision,o&&(n.axisControlRadius?n.camera.radius+=o:n.axisControlHeight?n.camera.heightOffset-=o:n.axisControlRotation&&(n.camera.rotationOffset-=o)),i.preventDefault&&(t||i.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Qs.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},Object(No.c)([ha()],e.prototype,"axisControlRadius",void 0),Object(No.c)([ha()],e.prototype,"axisControlHeight",void 0),Object(No.c)([ha()],e.prototype,"axisControlRotation",void 0),Object(No.c)([ha()],e.prototype,"wheelPrecision",void 0),Object(No.c)([ha()],e.prototype,"wheelDeltaPercentage",void 0),e}();Jl.FollowCameraMouseWheelInput=hc;var pc=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.angularSensibilityX=1,t.angularSensibilityY=1,t.pinchPrecision=1e4,t.pinchDeltaPercentage=0,t.axisXControlRadius=!1,t.axisXControlHeight=!1,t.axisXControlRotation=!0,t.axisYControlRadius=!1,t.axisYControlHeight=!0,t.axisYControlRotation=!1,t.axisPinchControlRadius=!0,t.axisPinchControlHeight=!1,t.axisPinchControlRotation=!1,t.warningEnable=!0,t._warningCounter=0,t}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"FollowCameraPointersInput"},t.prototype.onTouch=function(e,t,n){this._warning(),this.axisXControlRotation?this.camera.rotationOffset+=t/this.angularSensibilityX:this.axisYControlRotation&&(this.camera.rotationOffset+=n/this.angularSensibilityX),this.axisXControlHeight?this.camera.heightOffset+=t/this.angularSensibilityY:this.axisYControlHeight&&(this.camera.heightOffset+=n/this.angularSensibilityY),this.axisXControlRadius?this.camera.radius-=t/this.angularSensibilityY:this.axisYControlRadius&&(this.camera.radius-=n/this.angularSensibilityY)},t.prototype.onMultiTouch=function(e,t,n,r,i,o){if(!(0===n&&null===i||0===r&&null===o)){var a=(r-n)/(this.pinchPrecision*(this.angularSensibilityX+this.angularSensibilityY)/2);this.pinchDeltaPercentage?(a*=.01*this.pinchDeltaPercentage,this.axisPinchControlRotation&&(this.camera.rotationOffset+=a*this.camera.rotationOffset),this.axisPinchControlHeight&&(this.camera.heightOffset+=a*this.camera.heightOffset),this.axisPinchControlRadius&&(this.camera.radius-=a*this.camera.radius)):(this.axisPinchControlRotation&&(this.camera.rotationOffset+=a),this.axisPinchControlHeight&&(this.camera.heightOffset+=a),this.axisPinchControlRadius&&(this.camera.radius-=a))}},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(No.c)([ha()],t.prototype,"angularSensibilityX",void 0),Object(No.c)([ha()],t.prototype,"angularSensibilityY",void 0),Object(No.c)([ha()],t.prototype,"pinchPrecision",void 0),Object(No.c)([ha()],t.prototype,"pinchDeltaPercentage",void 0),Object(No.c)([ha()],t.prototype,"axisXControlRadius",void 0),Object(No.c)([ha()],t.prototype,"axisXControlHeight",void 0),Object(No.c)([ha()],t.prototype,"axisXControlRotation",void 0),Object(No.c)([ha()],t.prototype,"axisYControlRadius",void 0),Object(No.c)([ha()],t.prototype,"axisYControlHeight",void 0),Object(No.c)([ha()],t.prototype,"axisYControlRotation",void 0),Object(No.c)([ha()],t.prototype,"axisPinchControlRadius",void 0),Object(No.c)([ha()],t.prototype,"axisPinchControlHeight",void 0),Object(No.c)([ha()],t.prototype,"axisPinchControlRotation",void 0),t}(oc);Jl.FollowCameraPointersInput=pc;var fc=function(){function e(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this._keys=new Array}return e.prototype.attachControl=function(e,t){var n=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){n._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(e){var r,i=e.event;i.metaKey||(e.type===Ys.KEYDOWN?-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||(-1===(r=n._keys.indexOf(i.keyCode))&&n._keys.push(i.keyCode),t||i.preventDefault()):-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||((r=n._keys.indexOf(i.keyCode))>=0&&n._keys.splice(r,1),t||i.preventDefault()))})))},e.prototype.detachControl=function(e){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=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t1)e.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var t=e._computeLocalCameraSpeed(),n=new So(0,0,t*this._offsetY/this.touchMoveSensibility);Oo.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(So.TransformCoordinates(n,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},Object(No.c)([ha()],e.prototype,"touchAngularSensibility",void 0),Object(No.c)([ha()],e.prototype,"touchMoveSensibility",void 0),e}();Jl.FreeCameraTouchInput=gc;var bc=function(e){function t(t){var n=e.call(this,t)||this;return n._mouseInput=null,n}return Object(No.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new fc),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this._mouseInput||(this._mouseInput=new mc(e),this.add(this._mouseInput)),this},t.prototype.removeMouse=function(){return this._mouseInput&&this.remove(this._mouseInput),this},t.prototype.addTouch=function(){return this.add(new gc),this},t.prototype.clear=function(){e.prototype.clear.call(this),this._mouseInput=null},t}($l);bc.prototype.addDeviceOrientation=function(){return this._deviceOrientationInput||(this._deviceOrientationInput=new vc,this.add(this._deviceOrientationInput)),this};var vc=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new Po,this._alpha=0,this._beta=0,this._gamma=0,this._onDeviceOrientationChangedObservable=new yo.a,this._orientationChanged=function(){e._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,e._screenOrientationAngle=-Ja.ToRadians(e._screenOrientationAngle/2),e._screenQuaternion.copyFromFloats(0,Math.sin(e._screenOrientationAngle),0,Math.cos(e._screenOrientationAngle))},this._deviceOrientation=function(t){e._alpha=null!==t.alpha?t.alpha:0,e._beta=null!==t.beta?t.beta:0,e._gamma=null!==t.gamma?t.gamma:0,null!==t.alpha&&e._onDeviceOrientationChangedObservable.notifyObservers()},this._constantTranform=new Po(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return e.WaitForOrientationChangeAsync=function(e){return new Promise((function(t,n){var r=!1,i=function(){window.removeEventListener("deviceorientation",i),r=!0,t()};e&&setTimeout((function(){r||(window.removeEventListener("deviceorientation",i),n("WaitForOrientationChangeAsync timed out"))}),e),"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e?window.addEventListener("deviceorientation",i):Ja.Warn("Permission not granted.")})).catch((function(e){Ja.Error(e)})):window.addEventListener("deviceorientation",i)}))},Object.defineProperty(e.prototype,"camera",{get:function(){return this._camera},set:function(e){var t=this;this._camera=e,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new Po),this._camera&&this._camera.onDisposeObservable.add((function(){t._onDeviceOrientationChangedObservable.clear()}))},enumerable:!0,configurable:!0}),e.prototype.attachControl=function(e,t){var n=this,r=this.camera.getScene().getEngine().getHostWindow();if(r){var i=function(){r.addEventListener("orientationchange",n._orientationChanged),r.addEventListener("deviceorientation",n._deviceOrientation),n._orientationChanged()};"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?i():Ja.Warn("Permission not granted.")})).catch((function(e){Ja.Error(e)})):i()}},e.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation),this._alpha=0},e.prototype.checkInputs=function(){this._alpha&&(Po.RotationYawPitchRollToRef(Ja.ToRadians(this._alpha),Ja.ToRadians(this._beta),-Ja.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)},e.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"deviceOrientation"},e}();Jl.FreeCameraDeviceOrientationInput=vc;var Ac,_c=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._yAxisScale=1,this._cameraTransform=Oo.Identity(),this._deltaTransform=So.Zero(),this._vector3=So.Zero(),this._vector2=Co.Zero()}return Object.defineProperty(e.prototype,"invertYAxis",{get:function(){return 1!==this._yAxisScale},set:function(e){this._yAxisScale=e?-1:1},enumerable:!0,configurable:!0}),e.prototype.attachControl=function(e,t){var n=this,r=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=r.onGamepadConnectedObservable.add((function(e){e.type!==ec.POSE_ENABLED&&(n.gamepad&&e.type!==ec.XBOX||(n.gamepad=e))})),this._onGamepadDisconnectedObserver=r.onGamepadDisconnectedObservable.add((function(e){n.gamepad===e&&(n.gamepad=null)})),this.gamepad=r.getGamepadByType(ec.XBOX)},e.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var e=this.camera,t=this.gamepad.leftStick,n=t.x/this.gamepadMoveSensibility,r=t.y/this.gamepadMoveSensibility;t.x=Math.abs(n)>.005?0+n:0,t.y=Math.abs(r)>.005?0+r:0;var i=this.gamepad.rightStick;if(i){var o=i.x/this.gamepadAngularSensibility,a=i.y/this.gamepadAngularSensibility*this._yAxisScale;i.x=Math.abs(o)>.001?0+o:0,i.y=Math.abs(a)>.001?0+a:0}else i={x:0,y:0};e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):Oo.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var s=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*s,0,-t.y*s),So.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(i.y,i.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},Object(No.c)([ha()],e.prototype,"gamepadAngularSensibility",void 0),Object(No.c)([ha()],e.prototype,"gamepadMoveSensibility",void 0),e}();Jl.FreeCameraGamepadInput=_c,function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(Ac||(Ac={}));var yc=function(){function e(t){var n=this;if(this._leftJoystick=!!t,e._globalJoystickIndex++,this._axisTargetedByLeftAndRight=Ac.X,this._axisTargetedByUpAndDown=Ac.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new is,this.deltaPosition=So.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(t){e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas&&(e.Canvas.width=e.vjCanvasWidth,e.Canvas.height=e.vjCanvasHeight),e.halfWidth=e.vjCanvasWidth/2},!e.Canvas){window.addEventListener("resize",this._onResize,!1),e.Canvas=document.createElement("canvas"),e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas.width=window.innerWidth,e.Canvas.height=window.innerHeight,e.Canvas.style.width="100%",e.Canvas.style.height="100%",e.Canvas.style.position="absolute",e.Canvas.style.backgroundColor="transparent",e.Canvas.style.top="0px",e.Canvas.style.left="0px",e.Canvas.style.zIndex="5",e.Canvas.style.msTouchAction="none",e.Canvas.setAttribute("touch-action","none");var r=e.Canvas.getContext("2d");if(!r)throw new Error("Unable to create canvas for virtual joystick");e.vjCanvasContext=r,e.vjCanvasContext.strokeStyle="#ffffff",e.vjCanvasContext.lineWidth=2,document.body.appendChild(e.Canvas)}e.halfWidth=e.Canvas.width/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new Co(0,0),this._joystickPreviousPointerPos=new Co(0,0),this._joystickPointerStartPos=new Co(0,0),this._deltaJoystickVector=new Co(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){n._onPointerUp(e)},e.Canvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),e.Canvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),e.Canvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("contextmenu",(function(e){e.preventDefault()}),!1),requestAnimationFrame((function(){n._drawVirtualJoystick()}))}return e.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},e.prototype._onPointerDown=function(t){t.preventDefault(),(!0===this._leftJoystick?t.clientXe.halfWidth)&&this._joystickPointerID<0?(this._joystickPointerID=t.pointerId,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)):e._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(t.pointerId.toString(),{x:t.clientX,y:t.clientY,prevX:t.clientX,prevY:t.clientY}))},e.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var t=(this.reverseLeftRight?-1:1)*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case Ac.X:this.deltaPosition.x=Math.min(1,Math.max(-1,t));break;case Ac.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,t));break;case Ac.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,t))}var n=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case Ac.X:this.deltaPosition.x=Math.min(1,Math.max(-1,n));break;case Ac.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,n));break;case Ac.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,n))}}else{var r=this._touches.get(e.pointerId.toString());r&&(r.x=e.clientX,r.y=e.clientY)}},e.prototype._onPointerUp=function(t){if(this._joystickPointerID==t.pointerId)e.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),e.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var n=this._touches.get(t.pointerId.toString());n&&e.vjCanvasContext.clearRect(n.prevX-44,n.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(t.pointerId.toString())},e.prototype.setJoystickColor=function(e){this._joystickColor=e},e.prototype.setActionOnTouch=function(e){this._action=e},e.prototype.setAxisForLeftRight=function(e){switch(e){case Ac.X:case Ac.Y:case Ac.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=Ac.X}},e.prototype.setAxisForUpDown=function(e){switch(e){case Ac.X:case Ac.Y:case Ac.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=Ac.Y}},e.prototype._drawVirtualJoystick=function(){var t=this;this.pressed&&this._touches.forEach((function(n,r){r.pointerId===t._joystickPointerID?(e.vjCanvasContext.clearRect(t._joystickPointerStartPos.x-64,t._joystickPointerStartPos.y-64,128,128),e.vjCanvasContext.clearRect(t._joystickPreviousPointerPos.x-42,t._joystickPreviousPointerPos.y-42,84,84),e.vjCanvasContext.beginPath(),e.vjCanvasContext.lineWidth=6,e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.arc(t._joystickPointerStartPos.x,t._joystickPointerStartPos.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.lineWidth=2,e.vjCanvasContext.arc(t._joystickPointerStartPos.x,t._joystickPointerStartPos.y,60,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.arc(t._joystickPointerPos.x,t._joystickPointerPos.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),t._joystickPreviousPointerPos=t._joystickPointerPos.clone()):(e.vjCanvasContext.clearRect(r.prevX-44,r.prevY-44,88,88),e.vjCanvasContext.beginPath(),e.vjCanvasContext.fillStyle="white",e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle="red",e.vjCanvasContext.lineWidth=6,e.vjCanvasContext.arc(r.x,r.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.y)})),requestAnimationFrame((function(){t._drawVirtualJoystick()}))},e.prototype.releaseCanvas=function(){e.Canvas&&(e.Canvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),e.Canvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),e.Canvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),e.Canvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(e.Canvas),e.Canvas=null)},e._globalJoystickIndex=0,e}();bc.prototype.addVirtualJoystick=function(){return this.add(new xc),this};var xc=function(){function e(){}return e.prototype.getLeftJoystick=function(){return this._leftjoystick},e.prototype.getRightJoystick=function(){return this._rightjoystick},e.prototype.checkInputs=function(){if(this._leftjoystick){var e=this.camera,t=50*e._computeLocalCameraSpeed(),n=Oo.RotationYawPitchRoll(e.rotation.y,e.rotation.x,0),r=So.TransformCoordinates(new So(this._leftjoystick.deltaPosition.x*t,this._leftjoystick.deltaPosition.y*t,this._leftjoystick.deltaPosition.z*t),n);e.cameraDirection=e.cameraDirection.add(r),e.cameraRotation=e.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},e.prototype.attachControl=function(e,t){this._leftjoystick=new yc(!0),this._leftjoystick.setAxisForUpDown(Ac.Z),this._leftjoystick.setAxisForLeftRight(Ac.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new yc(!1),this._rightjoystick.setAxisForUpDown(Ac.X),this._rightjoystick.setAxisForLeftRight(Ac.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},e.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},e.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},e.prototype.getSimpleName=function(){return"virtualJoystick"},e}();Jl.FreeCameraVirtualJoystickInput=xc;var wc=function(e){function t(t,n,r,i){void 0===i&&(i=!0);var o=e.call(this,t,n,r,i)||this;return o.cameraDirection=new So(0,0,0),o.cameraRotation=new Co(0,0),o.updateUpVectorFromRotation=!1,o._tmpQuaternion=new Po,o.rotation=new So(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=So.Zero(),o._initialFocalDistance=1,o._viewMatrix=Oo.Zero(),o._camMatrix=Oo.Zero(),o._cameraTransformMatrix=Oo.Zero(),o._cameraRotationMatrix=Oo.Zero(),o._referencePoint=new So(0,0,1),o._transformedReferencePoint=So.Zero(),o._globalCurrentTarget=So.Zero(),o._globalCurrentUpVector=So.Zero(),o._defaultUp=So.Up(),o._cachedRotationZ=0,o._cachedQuaternionRotationZ=0,o}return Object(No.d)(t,e),t.prototype.getFrontPosition=function(e){this.getWorldMatrix();var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},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()),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.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(){e.prototype._initCache.call(this),this._cache.lockedTarget=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new Po(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},t.prototype._updateCache=function(t){t||e.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(!e.prototype._isSynchronizedViewMatrix.call(this))return!1;var t=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(t):!t)&&(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+=.001),Oo.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 t=e.subtract(this.position);t.x>=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.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&&Po.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},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(Mo.Matrix[0]),So.TransformNormalToRef(this.cameraDirection,Mo.Matrix[0],Mo.Vector3[0]),void this.position.addInPlace(Mo.Vector3[0]);this.position.addInPlace(this.cameraDirection)},t.prototype._checkInputs=function(){var t=this._decideIfNeedsToMove(),n=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(t&&this._updatePosition(),n){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion)this.rotation.lengthSquared()&&Po.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion);if(!this.noRotationConstraint){this.rotation.x>1.570796&&(this.rotation.x=1.570796),this.rotation.x<-1.570796&&(this.rotation.x=-1.570796)}}t&&(Math.abs(this.cameraDirection.x)<.001*this.speed&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<.001*this.speed&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<.001*this.speed&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),n&&(Math.abs(this.cameraRotation.x)<.001*this.speed&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<.001*this.speed&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),e.prototype._checkInputs.call(this)},t.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):Oo.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},t.prototype._rotateUpVectorWithCameraRotationMatrix=function(){return So.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),So.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?os.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(Po.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),os.Y.rotateByQuaternionToRef(this._tmpQuaternion,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix},t.prototype._computeViewMatrix=function(e,t,n){if(this.parent){var r=this.parent.getWorldMatrix();So.TransformCoordinatesToRef(e,r,this._globalPosition),So.TransformCoordinatesToRef(t,r,this._globalCurrentTarget),So.TransformNormalToRef(n,r,this._globalCurrentUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._globalCurrentTarget.copyFrom(t),this._globalCurrentUpVector.copyFrom(n);this.getScene().useRightHandedSystem?Oo.LookAtRHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix):Oo.LookAtLHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix)},t.prototype.createRigCamera=function(e,n){if(this.cameraRigMode!==Ts.RIG_MODE_NONE){var r=new t(e,this.position.clone(),this.getScene());return r.isRigCamera=!0,r.rigParent=this,this.cameraRigMode!==Ts.RIG_MODE_VR&&this.cameraRigMode!==Ts.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new Po),r._cameraRigParams={},r.rotationQuaternion=new Po),r}return null},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],n=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ts.RIG_MODE_STEREOSCOPIC_INTERLACED:var r=this.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,i=this.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*r,t),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*i,n);break;case Ts.RIG_MODE_VR:t.rotationQuaternion?(t.rotationQuaternion.copyFrom(this.rotationQuaternion),n.rotationQuaternion.copyFrom(this.rotationQuaternion)):(t.rotation.copyFrom(this.rotation),n.rotation.copyFrom(this.rotation)),t.position.copyFrom(this.position),n.position.copyFrom(this.position)}e.prototype._updateRigCameras.call(this)},t.prototype._getRigCamPositionAndTarget=function(e,n){this.getTarget().subtractToRef(this.position,t._TargetFocalPoint),t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);var r=t._TargetFocalPoint.addInPlace(this.position);Oo.TranslationToRef(-r.x,-r.y,-r.z,t._TargetTransformMatrix),t._TargetTransformMatrix.multiplyToRef(Oo.RotationY(e),t._RigCamTransformMatrix),Oo.TranslationToRef(r.x,r.y,r.z,t._TargetTransformMatrix),t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix,t._RigCamTransformMatrix),So.TransformCoordinatesToRef(this.position,t._RigCamTransformMatrix,n.position),n.setTarget(r)},t.prototype.getClassName=function(){return"TargetCamera"},t._RigCamTransformMatrix=new Oo,t._TargetTransformMatrix=new Oo,t._TargetFocalPoint=new So,Object(No.c)([ga()],t.prototype,"rotation",void 0),Object(No.c)([ha()],t.prototype,"speed",void 0),Object(No.c)([ba("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(Ts),Ec=function(e){function t(t,n,r,i){void 0===i&&(i=!0);var o=e.call(this,t,n,r,i)||this;return o.ellipsoid=new So(.5,1,.5),o.ellipsoidOffset=new So(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o._needMoveForGravity=!1,o._oldPosition=So.Zero(),o._diffPosition=So.Zero(),o._newPosition=So.Zero(),o._collisionMask=-1,o._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null);var r;r=t,o._newPosition.copyFrom(r),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>ss.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&n&&o.onCollide(n))},o.inputs=new bc(o),o.inputs.addKeyboard().addMouse(),o}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this.cameraDirection=new So(0,0,0),this.cameraRotation=new Co(0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?So.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var n=e;this.applyGravity&&(n=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,n,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=So.Zero(),this._transformedDirection=So.Zero()),this.inputs.checkInputs(),e.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):e.prototype._updatePosition.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FreeCamera"},Object(No.c)([ga()],t.prototype,"ellipsoid",void 0),Object(No.c)([ga()],t.prototype,"ellipsoidOffset",void 0),Object(No.c)([ha()],t.prototype,"checkCollisions",void 0),Object(No.c)([ha()],t.prototype,"applyGravity",void 0),t}(wc);wa.AddNodeConstructor("TouchCamera",(function(e,t){return function(){return new Cc(e,So.Zero(),t)}}));var Cc=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i.inputs.addTouch(),i._setupInputs(),i}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t}(Ec);wa.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new Sc(e,0,0,1,So.Zero(),t)}}));var Sc=function(e){function t(t,n,r,i,o,a,s){void 0===s&&(s=!0);var l=e.call(this,t,So.Zero(),a,s)||this;return l._upVector=So.Up(),l.inertialAlphaOffset=0,l.inertialBetaOffset=0,l.inertialRadiusOffset=0,l.lowerAlphaLimit=null,l.upperAlphaLimit=null,l.lowerBetaLimit=.01,l.upperBetaLimit=Math.PI-.01,l.lowerRadiusLimit=null,l.upperRadiusLimit=null,l.inertialPanningX=0,l.inertialPanningY=0,l.pinchToPanMaxDistance=20,l.panningDistanceLimit=null,l.panningOriginTarget=So.Zero(),l.panningInertia=.9,l.zoomOnFactor=1,l.targetScreenOffset=Co.Zero(),l.allowUpsideDown=!0,l.useInputToRestoreState=!0,l._viewMatrix=new Oo,l.panningAxis=new So(1,1,0),l.onMeshTargetChangedObservable=new yo.a,l.checkCollisions=!1,l.collisionRadius=new So(.5,.5,.5),l._previousPosition=So.Zero(),l._collisionVelocity=So.Zero(),l._newPosition=So.Zero(),l._computationVector=So.Zero(),l._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null),n?(l.setPosition(t),l.onCollide&&l.onCollide(n)):l._previousPosition.copyFrom(l._position);var r=Math.cos(l.alpha),i=Math.sin(l.alpha),o=Math.cos(l.beta),a=Math.sin(l.beta);0===a&&(a=1e-4);var s=l._getTargetPosition();l._computationVector.copyFromFloats(l.radius*r*a,l.radius*o,l.radius*i*a),s.addToRef(l._computationVector,l._newPosition),l._position.copyFrom(l._newPosition);var c=l.upVector;l.allowUpsideDown&&l.beta<0&&(c=(c=c.clone()).negate()),l._computeViewMatrix(l._position,s,c),l._viewMatrix.addAtIndex(12,l.targetScreenOffset.x),l._viewMatrix.addAtIndex(13,l.targetScreenOffset.y),l._collisionTriggered=!1},l._target=So.Zero(),o&&l.setTarget(o),l.alpha=n,l.beta=r,l.radius=i,l.getViewMatrix(),l.inputs=new sc(l),l.inputs.addKeyboard().addMouseWheel().addPointers(),l}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this.setPosition(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upToYMatrix||(this._YToUpMatrix=new Oo,this._upToYMatrix=new Oo,this._upVector=So.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!0,configurable:!0}),t.prototype.setMatUp=function(){Oo.RotationAlignToRef(So.UpReadOnly,this._upVector,this._YToUpMatrix),Oo.RotationAlignToRef(this._upVector,So.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 t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pinchDeltaPercentage",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useNaturalPinchZoom",{get:function(){var e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom},set:function(e){var t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wheelDeltaPercentage",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new Nl,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new Ll,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new Fl,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!0,configurable:!0}),t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache._target=new So(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=Co.Zero()},t.prototype._updateCache=function(t){t||e.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 t=this._getLockedTargetPosition();return t||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(),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.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!!e.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,t,n,r){var i=this;void 0===n&&(n=!0),void 0===r&&(r=2),this._useCtrlForPanning=n,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){i.inertialAlphaOffset=0,i.inertialBetaOffset=0,i.inertialRadiusOffset=0,i.inertialPanningX=0,i.inertialPanningY=0}},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},t.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){var t=this.inertialAlphaOffset;this.beta<=0&&(t*=-1),this.getScene().useRightHandedSystem&&(t*=-1),this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(t*=-1),this.alpha+=t,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<.001&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<.001&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<.001*this.speed&&(this.inertialRadiusOffset=0)}if(0!==this.inertialPanningX||0!==this.inertialPanningY){if(this._localDirection||(this._localDirection=So.Zero(),this._transformedDirection=So.Zero()),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),So.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),So.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else this._target.addInPlace(this._transformedDirection);this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<.001*this.speed&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<.001*this.speed&&(this.inertialPanningY=0)}this._checkLimits(),e.prototype._checkInputs.call(this)}},t.prototype._checkLimits=function(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)},t.prototype.rebuildAnglesAndRadius=function(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||So.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4),0===this._computationVector.x&&0===this._computationVector.z?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),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,t,n){if(void 0===t&&(t=!1),void 0===n&&(n=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var r=e,i=this._getTargetPosition();if(i&&!n&&i.equals(r))return;this._targetHost=null,this._target=r,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}this.rebuildAnglesAndRadius()},t.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),t=Math.sin(this.alpha),n=Math.cos(this.beta),r=Math.sin(this.beta);0===r&&(r=1e-4);var i=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*r,this.radius*n,this.radius*t*r),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||So.TransformCoordinatesToRef(this._computationVector,this._YToUpMatrix,this._computationVector),i.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){var o=this.getScene().collisionCoordinator;this._collider||(this._collider=o.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,o.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);var a=this.upVector;this.allowUpsideDown&&r<0&&(a=a.negate()),this._computeViewMatrix(this._position,i,a),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=i,this._viewMatrix},t.prototype.zoomOn=function(e,t){void 0===t&&(t=!1),e=e||this.getScene().meshes;var n=Pl.MinMax(e),r=So.Distance(n.min,n.max);this.radius=r*this.zoomOnFactor,this.focusOn({min:n.min,max:n.max,distance:r},t)},t.prototype.focusOn=function(e,t){var n,r;if(void 0===t&&(t=!1),void 0===e.min){var i=e||this.getScene().meshes;n=Pl.MinMax(i),r=So.Distance(n.min,n.max)}else{n=e,r=e.distance}this._target=Pl.Center(n),t||(this.maxZ=2*r)},t.prototype.createRigCamera=function(e,n){var r=0;switch(this.cameraRigMode){case Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ts.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ts.RIG_MODE_VR:r=this._cameraRigParams.stereoHalfAngle*(0===n?1:-1);break;case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:r=this._cameraRigParams.stereoHalfAngle*(0===n?-1:1)}var i=new t(e,this.alpha+r,this.beta,this.radius,this._target,this.getScene());return i._cameraRigParams={},i.isRigCamera=!0,i.rigParent=this,i},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],n=this._rigCameras[1];switch(t.beta=n.beta=this.beta,this.cameraRigMode){case Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ts.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ts.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,n.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,n.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}e.prototype._updateRigCameras.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"ArcRotateCamera"},Object(No.c)([ha()],t.prototype,"alpha",void 0),Object(No.c)([ha()],t.prototype,"beta",void 0),Object(No.c)([ha()],t.prototype,"radius",void 0),Object(No.c)([ga("target")],t.prototype,"_target",void 0),Object(No.c)([ga("upVector")],t.prototype,"_upVector",void 0),Object(No.c)([ha()],t.prototype,"inertialAlphaOffset",void 0),Object(No.c)([ha()],t.prototype,"inertialBetaOffset",void 0),Object(No.c)([ha()],t.prototype,"inertialRadiusOffset",void 0),Object(No.c)([ha()],t.prototype,"lowerAlphaLimit",void 0),Object(No.c)([ha()],t.prototype,"upperAlphaLimit",void 0),Object(No.c)([ha()],t.prototype,"lowerBetaLimit",void 0),Object(No.c)([ha()],t.prototype,"upperBetaLimit",void 0),Object(No.c)([ha()],t.prototype,"lowerRadiusLimit",void 0),Object(No.c)([ha()],t.prototype,"upperRadiusLimit",void 0),Object(No.c)([ha()],t.prototype,"inertialPanningX",void 0),Object(No.c)([ha()],t.prototype,"inertialPanningY",void 0),Object(No.c)([ha()],t.prototype,"pinchToPanMaxDistance",void 0),Object(No.c)([ha()],t.prototype,"panningDistanceLimit",void 0),Object(No.c)([ga()],t.prototype,"panningOriginTarget",void 0),Object(No.c)([ha()],t.prototype,"panningInertia",void 0),Object(No.c)([ha()],t.prototype,"zoomOnFactor",void 0),Object(No.c)([ha()],t.prototype,"targetScreenOffset",void 0),Object(No.c)([ha()],t.prototype,"allowUpsideDown",void 0),Object(No.c)([ha()],t.prototype,"useInputToRestoreState",void 0),t}(wc);wa.AddNodeConstructor("DeviceOrientationCamera",(function(e,t){return function(){return new Tc(e,So.Zero(),t)}}));var Tc=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i._tmpDragQuaternion=new Po,i._disablePointerInputWhenUsingDeviceOrientation=!0,i._dragFactor=0,i._quaternionCache=new Po,i.inputs.addDeviceOrientation(),i.inputs._deviceOrientationInput&&i.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce((function(){i._disablePointerInputWhenUsingDeviceOrientation&&i.inputs._mouseInput&&(i.inputs._mouseInput._allowCameraRotation=!1,i.inputs._mouseInput.onPointerMovedObservable.add((function(e){0!=i._dragFactor&&(i._initialQuaternion||(i._initialQuaternion=new Po),Po.FromEulerAnglesToRef(0,e.offsetX*i._dragFactor,0,i._tmpDragQuaternion),i._initialQuaternion.multiplyToRef(i._tmpDragQuaternion,i._initialQuaternion))})))})),i}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"disablePointerInputWhenUsingDeviceOrientation",{get:function(){return this._disablePointerInputWhenUsingDeviceOrientation},set:function(e){this._disablePointerInputWhenUsingDeviceOrientation=e},enumerable:!0,configurable:!0}),t.prototype.enableHorizontalDragging=function(e){void 0===e&&(e=1/300),this._dragFactor=e},t.prototype.getClassName=function(){return"DeviceOrientationCamera"},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._quaternionCache.copyFrom(this.rotationQuaternion),this._initialQuaternion&&this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)},t.prototype.resetToCurrentRotation=function(e){var t=this;void 0===e&&(e=os.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new Po),this._initialQuaternion.copyFrom(this._quaternionCache||this.rotationQuaternion),["x","y","z"].forEach((function(n){e[n]?t._initialQuaternion[n]*=-1:t._initialQuaternion[n]=0})),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},t}(Ec),Pc=function(e){function t(t){return e.call(this,t)||this}return Object(No.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new cc),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new uc(e)),this},t}($l),Oc=(function(e){function t(t,n,r,i){void 0===i&&(i=!0);var o=e.call(this,t,n,r,i)||this;return o.ellipsoid=new So(1,1,1),o.ellipsoidOffset=new So(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o.cameraDirection=So.Zero(),o._trackRoll=0,o.rollCorrect=100,o.bankedTurn=!1,o.bankedTurnLimit=Math.PI/2,o.bankedTurnMultiplier=1,o._needMoveForGravity=!1,o._oldPosition=So.Zero(),o._diffPosition=So.Zero(),o._newPosition=So.Zero(),o._collisionMask=-1,o._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null);var r;r=t,o._newPosition.copyFrom(r),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>ss.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&n&&o.onCollide(n))},o.inputs=new Pc(o),o.inputs.addKeyboard().addMouse(),o}Object(No.d)(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysForward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysForward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysForward=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysBackward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysBackward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysBackward=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this.cameraDirection=new So(0,0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?So.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var n=e;this.applyGravity&&(n=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,n,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=So.Zero(),this._transformedDirection=So.Zero()),this.inputs.checkInputs(),e.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):e.prototype._updatePosition.call(this)},t.prototype.restoreRoll=function(e){var t=this._trackRoll,n=t-this.rotation.z;Math.abs(n)>=.001&&(this.rotation.z+=n/e,Math.abs(t-this.rotation.z)<=.001&&(this.rotation.z=t))},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FlyCamera"},Object(No.c)([ga()],t.prototype,"ellipsoid",void 0),Object(No.c)([ga()],t.prototype,"ellipsoidOffset",void 0),Object(No.c)([ha()],t.prototype,"checkCollisions",void 0),Object(No.c)([ha()],t.prototype,"applyGravity",void 0)}(wc),function(e){function t(t){return e.call(this,t)||this}return Object(No.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new dc),this},t.prototype.addMouseWheel=function(){return this.add(new hc),this},t.prototype.addPointers=function(){return this.add(new pc),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}($l));wa.AddNodeConstructor("FollowCamera",(function(e,t){return function(){return new Mc(e,So.Zero(),t)}})),wa.AddNodeConstructor("ArcFollowCamera",(function(e,t){return function(){return new Ic(e,0,0,1,null,t)}}));var Rc,Mc=function(e){function t(t,n,r,i){void 0===i&&(i=null);var o=e.call(this,t,n,r)||this;return o.radius=12,o.lowerRadiusLimit=null,o.upperRadiusLimit=null,o.rotationOffset=0,o.lowerRotationOffsetLimit=null,o.upperRotationOffsetLimit=null,o.heightOffset=4,o.lowerHeightOffsetLimit=null,o.upperHeightOffsetLimit=null,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=i,o.inputs=new Oc(o),o.inputs.addKeyboard().addMouseWheel().addPointers(),o}return Object(No.d)(t,e),t.prototype._follow=function(e){if(e){var t;if(e.rotationQuaternion){var n=new Oo;e.rotationQuaternion.toRotationMatrix(n),t=Math.atan2(n.m[8],n.m[10])}else t=e.rotation.y;var r=Ja.ToRadians(this.rotationOffset)+t,i=e.getAbsolutePosition(),o=i.x+Math.sin(r)*this.radius,a=i.z+Math.cos(r)*this.radius,s=o-this.position.x,l=i.y+this.heightOffset-this.position.y,c=a-this.position.z,u=s*this.cameraAcceleration*2,d=l*this.cameraAcceleration,h=c*this.cameraAcceleration*2;(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new So(this.position.x+u,this.position.y+d,this.position.z+h),this.setTarget(i)}},t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t),this._reset=function(){}},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},t.prototype._checkInputs=function(){this.inputs.checkInputs(),this._checkLimits(),e.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},t.prototype._checkLimits=function(){null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),null!==this.lowerHeightOffsetLimit&&this.heightOffsetthis.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),null!==this.lowerRotationOffsetLimit&&this.rotationOffsetthis.upperRotationOffsetLimit&&(this.rotationOffset=this.upperRotationOffsetLimit)},t.prototype.getClassName=function(){return"FollowCamera"},Object(No.c)([ha()],t.prototype,"radius",void 0),Object(No.c)([ha()],t.prototype,"lowerRadiusLimit",void 0),Object(No.c)([ha()],t.prototype,"upperRadiusLimit",void 0),Object(No.c)([ha()],t.prototype,"rotationOffset",void 0),Object(No.c)([ha()],t.prototype,"lowerRotationOffsetLimit",void 0),Object(No.c)([ha()],t.prototype,"upperRotationOffsetLimit",void 0),Object(No.c)([ha()],t.prototype,"heightOffset",void 0),Object(No.c)([ha()],t.prototype,"lowerHeightOffsetLimit",void 0),Object(No.c)([ha()],t.prototype,"upperHeightOffsetLimit",void 0),Object(No.c)([ha()],t.prototype,"cameraAcceleration",void 0),Object(No.c)([ha()],t.prototype,"maxCameraSpeed",void 0),Object(No.c)([ba("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(wc),Ic=function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,So.Zero(),a)||this;return s.alpha=n,s.beta=r,s.radius=i,s.target=o,s._cartesianCoordinates=So.Zero(),s._follow(),s}return Object(No.d)(t,e),t.prototype._follow=function(){if(this.target){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.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._follow()},t.prototype.getClassName=function(){return"ArcFollowCamera"},t}(wc);!function(e){e[e.VIVE=0]="VIVE",e[e.OCULUS=1]="OCULUS",e[e.WINDOWS=2]="WINDOWS",e[e.GEAR_VR=3]="GEAR_VR",e[e.DAYDREAM=4]="DAYDREAM",e[e.GENERIC=5]="GENERIC"}(Rc||(Rc={}));var kc,Dc,Bc=function(){function e(){}return e.InitiateController=function(e){for(var t=0,n=this._ControllerFactories;tthis._maxRotationDistFromHeadset){var r=n-(n<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=r;var i=Math.sin(-r),o=Math.cos(-r);this._calculatedPosition.x=this._calculatedPosition.x*o-this._calculatedPosition.z*i,this._calculatedPosition.z=this._calculatedPosition.x*i+this._calculatedPosition.z*o}}So.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),Po.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 t=this.rawPose;e.orientation&&t.orientation&&4===t.orientation.length&&(this._deviceRoomRotationQuaternion.copyFromFloats(t.orientation[0],t.orientation[1],-t.orientation[2],-t.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 Po),!this.isXR&&(this._updatePoseAndMesh(),this._pointingPoseNode)){for(var t=[],n=this._pointingPoseNode;n.parent;)t.push(n.parent),n=n.parent;t.reverse().forEach((function(e){e.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,e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},enumerable:!0,configurable:!0}),t.prototype.getForwardRay=function(e){if(void 0===e&&(e=100),!this.mesh)return new Vl(So.Zero(),new So(0,0,1),e);var t=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),n=t.getTranslation(),r=new So(0,0,-1),i=So.TransformNormal(r,t),o=So.Normalize(i);return new Vl(n,o,e)},t.POINTING_POSE="POINTING_POSE",t}(ec);!function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.LB=4]="LB",e[e.RB=5]="RB",e[e.Back=8]="Back",e[e.Start=9]="Start",e[e.LeftStick=10]="LeftStick",e[e.RightStick=11]="RightStick"}(kc||(kc={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Dc||(Dc={}));var Nc,Lc,Uc=function(e){function t(t,n,r,i){void 0===i&&(i=!1);var o=e.call(this,t,n,r,0,1,2,3)||this;return o._leftTrigger=0,o._rightTrigger=0,o.onButtonDownObservable=new yo.a,o.onButtonUpObservable=new yo.a,o.onPadDownObservable=new yo.a,o.onPadUpObservable=new yo.a,o._buttonA=0,o._buttonB=0,o._buttonX=0,o._buttonY=0,o._buttonBack=0,o._buttonStart=0,o._buttonLB=0,o._buttonRB=0,o._buttonLeftStick=0,o._buttonRightStick=0,o._dPadUp=0,o._dPadDown=0,o._dPadLeft=0,o._dPadRight=0,o._isXboxOnePad=!1,o.type=ec.XBOX,o._isXboxOnePad=i,o}return Object(No.d)(t,e),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:!0,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:!0,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,t,n){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(n),this.onButtonDownObservable.notifyObservers(n)),0===e&&(this._onbuttonup&&this._onbuttonup(n),this.onButtonUpObservable.notifyObservers(n))),e},t.prototype._setDPadValue=function(e,t,n){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(n),this.onPadDownObservable.notifyObservers(n)),0===e&&(this._ondpadup&&this._ondpadup(n),this.onPadUpObservable.notifyObservers(n))),e},Object.defineProperty(t.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,kc.A)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,kc.B)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,kc.X)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,kc.Y)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,kc.Start)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,kc.Back)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,kc.LB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,kc.RB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,kc.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,kc.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Dc.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Dc.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Dc.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Dc.Right)},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.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(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(ec);!function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.Share=8]="Share",e[e.Options=9]="Options",e[e.LeftStick=10]="LeftStick",e[e.RightStick=11]="RightStick"}(Nc||(Nc={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Lc||(Lc={}));var Vc=function(e){function t(t,n,r){var i=e.call(this,t.replace("STANDARD GAMEPAD","SONY PLAYSTATION DUALSHOCK"),n,r,0,1,2,3)||this;return i._leftTrigger=0,i._rightTrigger=0,i.onButtonDownObservable=new yo.a,i.onButtonUpObservable=new yo.a,i.onPadDownObservable=new yo.a,i.onPadUpObservable=new yo.a,i._buttonCross=0,i._buttonCircle=0,i._buttonSquare=0,i._buttonTriangle=0,i._buttonShare=0,i._buttonOptions=0,i._buttonL1=0,i._buttonR1=0,i._buttonLeftStick=0,i._buttonRightStick=0,i._dPadUp=0,i._dPadDown=0,i._dPadLeft=0,i._dPadRight=0,i.type=ec.DUALSHOCK,i}return Object(No.d)(t,e),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:!0,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:!0,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,t,n){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(n),this.onButtonDownObservable.notifyObservers(n)),0===e&&(this._onbuttonup&&this._onbuttonup(n),this.onButtonUpObservable.notifyObservers(n))),e},t.prototype._setDPadValue=function(e,t,n){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(n),this.onPadDownObservable.notifyObservers(n)),0===e&&(this._ondpadup&&this._ondpadup(n),this.onPadUpObservable.notifyObservers(n))),e},Object.defineProperty(t.prototype,"buttonCross",{get:function(){return this._buttonCross},set:function(e){this._buttonCross=this._setButtonValue(e,this._buttonCross,Nc.Cross)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonCircle",{get:function(){return this._buttonCircle},set:function(e){this._buttonCircle=this._setButtonValue(e,this._buttonCircle,Nc.Circle)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonSquare",{get:function(){return this._buttonSquare},set:function(e){this._buttonSquare=this._setButtonValue(e,this._buttonSquare,Nc.Square)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonTriangle",{get:function(){return this._buttonTriangle},set:function(e){this._buttonTriangle=this._setButtonValue(e,this._buttonTriangle,Nc.Triangle)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonOptions",{get:function(){return this._buttonOptions},set:function(e){this._buttonOptions=this._setButtonValue(e,this._buttonOptions,Nc.Options)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonShare",{get:function(){return this._buttonShare},set:function(e){this._buttonShare=this._setButtonValue(e,this._buttonShare,Nc.Share)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonL1",{get:function(){return this._buttonL1},set:function(e){this._buttonL1=this._setButtonValue(e,this._buttonL1,Nc.L1)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonR1",{get:function(){return this._buttonR1},set:function(e){this._buttonR1=this._setButtonValue(e,this._buttonR1,Nc.R1)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Nc.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Nc.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Lc.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Lc.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Lc.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Lc.Right)},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.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(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(ec),zc=function(){function e(e){var t=this;if(this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new yo.a,Da.a.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new yo.a((function(e){for(var n in t._babylonGamepads){var r=t._babylonGamepads[n];r&&r._isConnected&&t.onGamepadConnectedObservable.notifyObserver(e,r)}})),this._onGamepadConnectedEvent=function(e){var n,r=e.gamepad;r.index in t._babylonGamepads&&t._babylonGamepads[r.index].isConnected||(t._babylonGamepads[r.index]?((n=t._babylonGamepads[r.index]).browserGamepad=r,n._isConnected=!0):n=t._addNewGamepad(r),t.onGamepadConnectedObservable.notifyObservers(n),t._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var n=e.gamepad;for(var r in t._babylonGamepads)if(t._babylonGamepads[r].index===n.index){var i=t._babylonGamepads[r];i._isConnected=!1,t.onGamepadDisconnectedObservable.notifyObservers(i),i.dispose&&i.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(e.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!0,configurable:!0}),e.prototype.getGamepadByType=function(e){void 0===e&&(e=ec.XBOX);for(var t=0,n=this._babylonGamepads;t1&&(c=a.generateStencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24),o.is2DArray?n.texImage3D(i,0,c,o.width,o.height,r,0,l,s,null):n.texImage2D(i,0,c,o.width,o.height,0,l,s,null),this._bindTextureDirectly(i,null),o};var Xc=function(){function e(e,t,n,r,i,o,a,s,l,c,u,d,h,p,f){void 0===a&&(a=1),void 0===c&&(c=null),void 0===u&&(u=0),void 0===d&&(d="postprocess"),void 0===p&&(p=!1),void 0===f&&(f=5),this.name=e,this.width=-1,this.height=-1,this._outputTexture=null,this.autoClear=!0,this.alphaMode=0,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=1,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new ns(2),this._currentRenderTextureInd=0,this._scaleRatio=new Co(1,1),this._texelSize=Co.Zero(),this.onActivateObservable=new yo.a,this.onSizeChangedObservable=new yo.a,this.onApplyObservable=new yo.a,this.onBeforeRenderObservable=new yo.a,this.onAfterRenderObservable=new yo.a,null!=o?(this._camera=o,this._scene=o.getScene(),o.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):s&&(this._engine=s,this._engine.postProcesses.push(this)),this._options=i,this.renderTargetSamplingMode=a||1,this._reusable=l||!1,this._textureType=u,this._textureFormat=f,this._samplers=r||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=d,this._parameters=n||[],this._parameters.push("scale"),this._indexParameters=h,p||this.updateEffect(c)}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._samples},set:function(e){var t=this;this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach((function(e){e.samples!==t._samples&&t._engine.updateRenderTargetTextureSampleCount(e,t._samples)}))},enumerable:!0,configurable:!0}),e.prototype.getEffectName=function(){return this._fragmentUrl},Object.defineProperty(e.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),e.prototype.getCamera=function(){return this._camera},Object.defineProperty(e.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:!0,configurable:!0}),e.prototype.getClassName=function(){return"PostProcess"},e.prototype.getEngine=function(){return this._engine},e.prototype.getEffect=function(){return this._effect},e.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},e.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new ns(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(e,t,n,r,i,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null),this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,n||this._samplers,null!==e?e:"",void 0,i,o,r||this._indexParameters)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype.activate=function(e,t,n){var r=this;void 0===t&&(t=null);var i=(e=e||this._camera).getScene(),o=i.getEngine(),a=o.getCaps().maxTextureSize,s=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,l=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0,c=e.parent;!c||c.leftCamera!=e&&c.rightCamera!=e||(s/=2);var u,d=this._options.width||s,h=this._options.height||l,p=7!==this.renderTargetSamplingMode&&1!==this.renderTargetSamplingMode&&2!==this.renderTargetSamplingMode;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var f=o.currentViewport;f&&(d*=f.width,h*=f.height)}if((p||this.alwaysForcePOT)&&(this._options.width||(d=o.needPOTTextures?ss.a.GetExponentOfTwo(d,a,this.scaleMode):d),this._options.height||(h=o.needPOTTextures?ss.a.GetExponentOfTwo(h,a,this.scaleMode):h)),this.width!==d||this.height!==h){if(this._textures.length>0){for(var m=0;m0)for(var e=0;e0){var r=this._camera._getFirstPostProcess();r&&r.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e}(),Yc="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";Qc.a.ShadersStore.passPixelShader=Yc;var qc="\nvarying vec2 vUV;\nuniform samplerCube textureSampler;\nvoid main(void)\n{\nvec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\n#endif\n}";Qc.a.ShadersStore.passCubePixelShader=qc;var Zc=function(e){function t(t,n,r,i,o,a,s,l){return void 0===r&&(r=null),void 0===s&&(s=0),void 0===l&&(l=!1),e.call(this,t,"pass",null,null,n,r,i,o,a,void 0,s,void 0,null,l)||this}return Object(No.d)(t,e),t}(Xc);!function(e){function t(t,n,r,i,o,a,s,l){void 0===r&&(r=null),void 0===s&&(s=0),void 0===l&&(l=!1);var c=e.call(this,t,"passCube",null,null,n,r,i,o,a,"#define POSITIVEX",s,void 0,null,l)||this;return c._face=0,c}Object(No.d)(t,e),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:!0,configurable:!0})}(Xc);ss.a._RescalePostProcessFactory=function(e){return new Zc("rescale",1,null,2,e,!1,0)};var Jc="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}";Qc.a.ShadersStore.anaglyphPixelShader=Jc;var $c=function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,"anaglyph",null,["leftSampler"],n,r[1],i,o,a)||this;return s._passedProcess=r[0]._rigPostProcess,s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",s._passedProcess)})),s}return Object(No.d)(t,e),t}(Xc);Ts._setStereoscopicAnaglyphRigMode=function(e){e._rigCameras[0]._rigPostProcess=new Zc(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new $c(e.name+"_anaglyph",1,e._rigCameras)},wa.AddNodeConstructor("AnaglyphArcRotateCamera",(function(e,t,n){return function(){return new eu(e,0,0,1,So.Zero(),n.interaxial_distance,t)}}));var eu=function(e){function t(t,n,r,i,o,a,s){var l=e.call(this,t,n,r,i,o,s)||this;return l.interaxialDistance=a,l.setCameraRigMode(Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a}),l}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(Sc);wa.AddNodeConstructor("AnaglyphFreeCamera",(function(e,t,n){return function(){return new tu(e,So.Zero(),n.interaxial_distance,t)}}));var tu=function(e){function t(t,n,r,i){var o=e.call(this,t,n,i)||this;return o.interaxialDistance=r,o.setCameraRigMode(Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(Ec);wa.AddNodeConstructor("AnaglyphGamepadCamera",(function(e,t,n){return function(){return new nu(e,So.Zero(),n.interaxial_distance,t)}}));var nu=function(e){function t(t,n,r,i){var o=e.call(this,t,n,i)||this;return o.interaxialDistance=r,o.setCameraRigMode(Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(Hc);wa.AddNodeConstructor("AnaglyphUniversalCamera",(function(e,t,n){return function(){return new ru(e,So.Zero(),n.interaxial_distance,t)}}));var ru=function(e){function t(t,n,r,i){var o=e.call(this,t,n,i)||this;return o.interaxialDistance=r,o.setCameraRigMode(Ts.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(Gc),iu="const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\nvoid main(void)\n{\nbool useCamA;\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\n#ifdef IS_STEREOSCOPIC_INTERLACED\nfloat rowNum=floor(vUV.y/stepSize.y);\nuseCamA=mod(rowNum,2.0) == 1.0;\nuseCamB=mod(rowNum,2.0) == 0.0;\ntexCoord1=vec2(vUV.x,vUV.y);\ntexCoord2=vec2(vUV.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n#endif\n\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else if (useCamA){\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}else {\ndiscard;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}\n";Qc.a.ShadersStore.stereoscopicInterlacePixelShader=iu;var ou=function(e){function t(t,n,r,i,o,a,s){var l=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],o,a,s,i?"#define IS_STEREOSCOPIC_INTERLACED 1":r?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return l._passedProcess=n[0]._rigPostProcess,l._stepSize=new Co(1/l.width,1/l.height),l.onSizeChangedObservable.add((function(){l._stepSize=new Co(1/l.width,1/l.height)})),l.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",l._passedProcess),e.setFloat2("stepSize",l._stepSize.x,l._stepSize.y)})),l}return Object(No.d)(t,e),t}(Xc);!function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],i,o,a,r?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return s._passedProcess=n[0]._rigPostProcess,s._stepSize=new Co(1/s.width,1/s.height),s.onSizeChangedObservable.add((function(){s._stepSize=new Co(1/s.width,1/s.height)})),s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",s._passedProcess),e.setFloat2("stepSize",s._stepSize.x,s._stepSize.y)})),s}Object(No.d)(t,e)}(Xc);Ts._setStereoscopicRigMode=function(e){var t=e.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,n=e.cameraRigMode===Ts.RIG_MODE_STEREOSCOPIC_INTERLACED;e._rigCameras[0]._rigPostProcess=new Zc(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new ou(e.name+"_stereoInterlace",e._rigCameras,t,n)},wa.AddNodeConstructor("StereoscopicArcRotateCamera",(function(e,t,n){return function(){return new au(e,0,0,1,So.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var au=function(e){function t(t,n,r,i,o,a,s,l){var c=e.call(this,t,n,r,i,o,l)||this;return c.interaxialDistance=a,c.isStereoscopicSideBySide=s,c.setCameraRigMode(s?Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),c}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(Sc);wa.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,n){return function(){return new su(e,So.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var su=function(e){function t(t,n,r,i,o){var a=e.call(this,t,n,o)||this;return a.interaxialDistance=r,a.isStereoscopicSideBySide=i,a.setCameraRigMode(i?Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(Ec);wa.AddNodeConstructor("StereoscopicGamepadCamera",(function(e,t,n){return function(){return new lu(e,So.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var lu=function(e){function t(t,n,r,i,o){var a=e.call(this,t,n,o)||this;return a.interaxialDistance=r,a.isStereoscopicSideBySide=i,a.setCameraRigMode(i?Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(Hc);wa.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,n){return function(){return new cu(e,So.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var cu=function(e){function t(t,n,r,i,o){var a=e.call(this,t,n,o)||this;return a.interaxialDistance=r,a.isStereoscopicSideBySide=i,a.setCameraRigMode(i?Ts.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ts.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),a}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(Gc);wa.AddNodeConstructor("VirtualJoysticksCamera",(function(e,t){return function(){return new uu(e,So.Zero(),t)}}));var uu=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i.inputs.addVirtualJoystick(),i}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t}(Ec),du=function(){function e(){this.compensateDistortion=!0,this.multiviewEnabled=!1}return Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return Oo.Translation(e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return Oo.Translation(-e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftPreViewMatrix",{get:function(){return Oo.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightPreViewMatrix",{get:function(){return Oo.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),e.GetDefault=function(){var t=new e;return t.hResolution=1280,t.vResolution=800,t.hScreenSize=.149759993,t.vScreenSize=.0935999975,t.vScreenCenter=.0467999987,t.eyeToScreenDistance=.0410000011,t.lensSeparationDistance=.063500002,t.interpupillaryDistance=.064000003,t.distortionK=[1,.219999999,.239999995,0],t.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],t.postProcessScaleFactor=1.714605507808412,t.lensCenterOffset=.151976421,t},e}(),hu="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn;\nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\nelse{\ngl_FragColor=texture2D(textureSampler,tc);\n}\n}";Qc.a.ShadersStore.vrDistortionCorrectionPixelShader=hu;var pu=function(e){function t(t,n,r,i){var o=e.call(this,t,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,i.postProcessScaleFactor,n,Wl.BILINEAR_SAMPLINGMODE)||this;return o._isRightEye=r,o._distortionFactors=i.distortionK,o._postProcessScaleFactor=i.postProcessScaleFactor,o._lensCenterOffset=i.lensCenterOffset,o.adaptScaleToCurrentViewport=!0,o.onSizeChangedObservable.add((function(){o._scaleIn=new Co(2,2/o.aspectRatio),o._scaleFactor=new Co(1/o._postProcessScaleFactor*.5,1/o._postProcessScaleFactor*.5*o.aspectRatio),o._lensCenter=new Co(o._isRightEye?.5-.5*o._lensCenterOffset:.5+.5*o._lensCenterOffset,.5)})),o.onApplyObservable.add((function(e){e.setFloat2("LensCenter",o._lensCenter.x,o._lensCenter.y),e.setFloat2("Scale",o._scaleFactor.x,o._scaleFactor.y),e.setFloat2("ScaleIn",o._scaleIn.x,o._scaleIn.y),e.setFloat4("HmdWarpParam",o._distortionFactors[0],o._distortionFactors[1],o._distortionFactors[2],o._distortionFactors[3])})),o}return Object(No.d)(t,e),t}(Xc),fu="precision mediump sampler2DArray;\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\nvoid main(void)\n{\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\n}";Qc.a.ShadersStore.vrMultiviewToSingleviewPixelShader=fu;Va.a.prototype.createRenderTargetCubeTexture=function(e,t){var n=Object(No.a)({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:0,samplingMode:3,format:5},t);n.generateStencilBuffer=n.generateDepthBuffer&&n.generateStencilBuffer,(1!==n.type||this._caps.textureFloatLinearFiltering)&&(2!==n.type||this._caps.textureHalfFloatLinearFiltering)||(n.samplingMode=1);var r=this._gl,i=new Kl.a(this,Kl.b.RenderTarget);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,i,!0);var o=this._getSamplingParameters(n.samplingMode,n.generateMipMaps);1!==n.type||this._caps.textureFloat||(n.type=0,jo.a.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,o.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,o.min),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);for(var a=0;a<6;a++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,this._getRGBABufferInternalSizedFormat(n.type,n.format),e,e,0,this._getInternalFormat(n.format),this._getWebGLTextureType(n.type),null);var s=r.createFramebuffer();return this._bindUnboundFramebuffer(s),i._depthStencilBuffer=this._setupFramebufferDepthAttachments(n.generateStencilBuffer,n.generateDepthBuffer,e,e),n.generateMipMaps&&r.generateMipmap(r.TEXTURE_CUBE_MAP),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),i._framebuffer=s,i.width=e,i.height=e,i.isReady=!0,i.isCube=!0,i.samples=1,i.generateMipMaps=n.generateMipMaps,i.samplingMode=n.samplingMode,i.type=n.type,i.format=n.format,i._generateDepthBuffer=n.generateDepthBuffer,i._generateStencilBuffer=n.generateStencilBuffer,this._internalTexturesCache.push(i),i};var mu=function(e){function t(t,n,r,i,o,a,s,l,c,u,d,h,p){void 0===o&&(o=!0),void 0===a&&(a=0),void 0===s&&(s=!1),void 0===l&&(l=Wl.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=!0),void 0===u&&(u=!1),void 0===d&&(d=!1),void 0===h&&(h=5),void 0===p&&(p=!1);var f=e.call(this,null,r,!i)||this;return f.isCube=s,f.renderParticles=!0,f.renderSprites=!1,f.coordinatesMode=Wl.PROJECTION_MODE,f.ignoreCameraViewport=!1,f.onBeforeBindObservable=new yo.a,f.onAfterUnbindObservable=new yo.a,f.onBeforeRenderObservable=new yo.a,f.onAfterRenderObservable=new yo.a,f.onClearObservable=new yo.a,f.onResizeObservable=new yo.a,f._currentRefreshId=-1,f._refreshRate=1,f._samples=1,f.boundingBoxPosition=So.Zero(),(r=f.getScene())?(f.renderList=new Array,f._engine=r.getEngine(),f.name=t,f.isRenderTarget=!0,f._initialSizeParameter=n,f._processSizeParameter(n),f._resizeObserver=f.getScene().getEngine().onResizeObservable.add((function(){})),f._generateMipMaps=!!i,f._doNotChangeAspectRatio=o,f._renderingManager=new js(r),f._renderingManager._useSceneAutoClearSetup=!0,d||(f._renderTargetOptions={generateMipMaps:i,type:a,format:h,samplingMode:l,generateDepthBuffer:c,generateStencilBuffer:u},l===Wl.NEAREST_SAMPLINGMODE&&(f.wrapU=Wl.CLAMP_ADDRESSMODE,f.wrapV=Wl.CLAMP_ADDRESSMODE),p||(s?(f._texture=r.getEngine().createRenderTargetCubeTexture(f.getRenderSize(),f._renderTargetOptions),f.coordinatesMode=Wl.INVCUBIC_MODE,f._textureMatrix=Oo.Identity()):f._texture=r.getEngine().createRenderTargetTexture(f._size,f._renderTargetOptions))),f):f}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"renderList",{get:function(){return this._renderList},set:function(e){this._renderList=e,this._renderList&&this._hookArray(this._renderList)},enumerable:!0,configurable:!0}),t.prototype._hookArray=function(e){var t=this,n=e.push;e.push=function(){for(var r=[],i=0;i0&&(this._postProcesses[0].autoClear=!1))}},t.prototype._shouldRender=function(){return-1===this._currentRefreshId||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:!0,configurable:!0}),t.prototype.scale=function(e){var t=Math.max(1,this.getRenderSize()*e);this.resize(t)},t.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:e.prototype.getReflectionTextureMatrix.call(this)},t.prototype.resize=function(e){var t=this.isCube;this.releaseInternalTexture();var n=this.getScene();n&&(this._processSizeParameter(e),this._texture=t?n.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):n.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},t.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),s=this.getScene()){var n,r=s.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var i=0;i1||this.activeCamera&&this.activeCamera!==s.activeCamera)&&s.setTransformMatrix(s.activeCamera.getViewMatrix(),s.activeCamera.getProjectionMatrix(!0)),r.setViewport(s.activeCamera.viewport)),s.resetCachedMaterial()}},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var n=e*t,r=ss.a.NearestPOT(n+16384/(128+n));return Math.min(ss.a.FloorPOT(e),r)},t.prototype._prepareRenderingManager=function(e,t,n,r){var i=this.getScene();if(i){this._renderingManager.reset();for(var o=i.getRenderId(),a=0;a=0&&this._renderingManager.dispatchParticles(h))}}},t.prototype._bindFrameBuffer=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0);var n=this.getScene();if(n){var r=n.getEngine();this._texture&&r.bindFramebuffer(this._texture,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}},t.prototype.unbindFrameBuffer=function(e,t){var n=this;this._texture&&e.unBindFramebuffer(this._texture,this.isCube,(function(){n.onAfterRenderObservable.notifyObservers(t)}))},t.prototype.renderToTarget=function(e,t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=null);var o=this.getScene();if(o){var a=o.getEngine();if(this._texture){this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):t&&o.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(e,r),this.is2DArray?this.onBeforeRenderObservable.notifyObservers(r):this.onBeforeRenderObservable.notifyObservers(e);var s=null,l=this.renderList?this.renderList:o.getActiveMeshes().data,c=this.renderList?this.renderList.length:o.getActiveMeshes().length;this.getCustomRenderList&&(s=this.getCustomRenderList(this.is2DArray?r:e,l,c)),s?this._prepareRenderingManager(s,s.length,i,!1):(this._defaultRenderListPrepared||(this._prepareRenderingManager(l,c,i,!this.renderList),this._defaultRenderListPrepared=!0),s=l),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(a):a.clear(this.clearColor||o.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0);for(var u=0,d=o._beforeRenderTargetDrawStage;u=0&&t.customRenderTargets.splice(n,1);for(var r=0,i=t.cameras;r=0&&o.customRenderTargets.splice(n,1)}this.depthStencilTexture&&this.getScene().getEngine()._releaseTexture(this.depthStencilTexture),e.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}(Wl);Wl._CreateRenderTargetTexture=function(e,t,n,r){return new mu(e,t,n,r)};var gu=function(e){function t(t,n){void 0===n&&(n=512);var r=e.call(this,"multiview rtt",n,t,!1,!0,Kl.b.Unknown,!1,void 0,!1,!1,!0,void 0,!0)||this,i=t.getEngine().createMultiviewRenderTargetTexture(r.getRenderWidth(),r.getRenderHeight());return i.isMultiview=!0,i.format=5,r._texture=i,r.samples=r._engine.getCaps().maxSamples||r.samples,r}return Object(No.d)(t,e),t.prototype._bindFrameBuffer=function(e){void 0===e&&(e=0),this._texture&&this.getScene().getEngine().bindMultiviewFramebuffer(this._texture)},t.prototype.getViewCount=function(){return 2},t}(mu);ss.a.prototype.createMultiviewRenderTargetTexture=function(e,t){var n=this._gl;if(!this.getCaps().multiview)throw"Multiview is not supported";var r=new Kl.a(this,Kl.b.Unknown,!0);return r.width=e,r.height=t,r._framebuffer=n.createFramebuffer(),r._colorTextureArray=n.createTexture(),n.bindTexture(n.TEXTURE_2D_ARRAY,r._colorTextureArray),n.texStorage3D(n.TEXTURE_2D_ARRAY,1,n.RGBA8,e,t,2),r._depthStencilTextureArray=n.createTexture(),n.bindTexture(n.TEXTURE_2D_ARRAY,r._depthStencilTextureArray),n.texStorage3D(n.TEXTURE_2D_ARRAY,1,n.DEPTH32F_STENCIL8,e,t,2),r.isReady=!0,r},ss.a.prototype.bindMultiviewFramebuffer=function(e){var t=this._gl,n=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(e,void 0,void 0,void 0,!0),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,e._framebuffer),!e._colorTextureArray||!e._depthStencilTextureArray)throw"Invalid multiview frame buffer";this.getCaps().oculusMultiview?(n.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,e.samples,0,2),n.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,e.samples,0,2)):(n.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,0,2),n.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,0,2))},Ts.prototype._useMultiviewToSingleView=!1,Ts.prototype._multiviewTexture=null,Ts.prototype._resizeOrCreateMultiviewTexture=function(e,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==e&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new gu(this.getScene(),{width:e,height:t})):this._multiviewTexture=new gu(this.getScene(),{width:e,height:t})},nl.prototype._transformMatrixR=Oo.Zero(),nl.prototype._multiviewSceneUbo=null,nl.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=new ks(this.getEngine(),void 0,!0),this._multiviewSceneUbo.addUniform("viewProjection",16),this._multiviewSceneUbo.addUniform("viewProjectionR",16),this._multiviewSceneUbo.addUniform("view",16)},nl.prototype._updateMultiviewUbo=function(e,t){e&&t&&e.multiplyToRef(t,this._transformMatrixR),e&&t&&(e.multiplyToRef(t,Mo.Matrix[0]),Ss.GetRightPlaneToRef(Mo.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())},nl.prototype._renderMultiviewToSingleView=function(e){e._resizeOrCreateMultiviewTexture(e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.width>0?e._rigPostProcess.width:this.getEngine().getRenderWidth(!0),e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.height>0?e._rigPostProcess.height:this.getEngine().getRenderHeight(!0)),this._multiviewSceneUbo||this._createMultiviewUbo(),e.outputRenderTarget=e._multiviewTexture,this._renderForCamera(e),e.outputRenderTarget=null;for(var t=0;t=2&&e.onControllersAttachedObservable.notifyObservers(e.controllers)}}}))},t}(Ec),wu=function(e){function t(t){var n=e.call(this,t)||this;return n.onTriggerStateChangedObservable=new yo.a,n.onMainButtonStateChangedObservable=new yo.a,n.onSecondaryButtonStateChangedObservable=new yo.a,n.onPadStateChangedObservable=new yo.a,n.onPadValuesChangedObservable=new yo.a,n.pad={x:0,y:0},n._changes={pressChanged:!1,touchChanged:!1,valueChanged:!1,changed:!1},n._buttons=new Array(t.buttons.length),n.hand=t.hand,n}return Object(No.d)(t,e),t.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(t.prototype,"defaultModel",{get:function(){return this._defaultModel},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t0,t.NUM_MORPH_INFLUENCERS=n.numInfluencers):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)},e.PrepareDefinesForAttributes=function(e,t,n,r,i,o){if(void 0===i&&(i=!1),void 0===o&&(o=!0),!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;if(t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent(cs.NormalKind),t._needNormals&&e.isVerticesDataPresent(cs.TangentKind)&&(t.TANGENT=!0),t._needUVs?(t.UV1=e.isVerticesDataPresent(cs.UVKind),t.UV2=e.isVerticesDataPresent(cs.UV2Kind)):(t.UV1=!1,t.UV2=!1),n){var a=e.useVertexColors&&e.isVerticesDataPresent(cs.ColorKind);t.VERTEXCOLOR=a,t.VERTEXALPHA=e.hasVertexAlpha&&a&&o}return r&&this.PrepareDefinesForBones(e,t),i&&this.PrepareDefinesForMorphTargets(e,t),!0},e.PrepareDefinesForMultiview=function(e,t){if(e.activeCamera){var n=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=n&&t.markAsUnprocessed()}},e.PrepareDefinesForLight=function(e,t,n,r,i,o,a){switch(a.needNormals=!0,void 0===i["LIGHT"+r]&&(a.needRebuild=!0),i["LIGHT"+r]=!0,i["SPOTLIGHT"+r]=!1,i["HEMILIGHT"+r]=!1,i["POINTLIGHT"+r]=!1,i["DIRLIGHT"+r]=!1,n.prepareLightSpecificDefines(i,r),i["LIGHT_FALLOFF_PHYSICAL"+r]=!1,i["LIGHT_FALLOFF_GLTF"+r]=!1,i["LIGHT_FALLOFF_STANDARD"+r]=!1,n.falloffType){case Ds.FALLOFF_GLTF:i["LIGHT_FALLOFF_GLTF"+r]=!0;break;case Ds.FALLOFF_PHYSICAL:i["LIGHT_FALLOFF_PHYSICAL"+r]=!0;break;case Ds.FALLOFF_STANDARD:i["LIGHT_FALLOFF_STANDARD"+r]=!0}if(o&&!n.specular.equalsFloats(0,0,0)&&(a.specularEnabled=!0),i["SHADOW"+r]=!1,i["SHADOWCSM"+r]=!1,i["SHADOWCSMDEBUG"+r]=!1,i["SHADOWCSMNUM_CASCADES"+r]=!1,i["SHADOWCSMUSESHADOWMAXZ"+r]=!1,i["SHADOWCSMNOBLEND"+r]=!1,i["SHADOWCSM_RIGHTHANDED"+r]=!1,i["SHADOWPCF"+r]=!1,i["SHADOWPCSS"+r]=!1,i["SHADOWPOISSON"+r]=!1,i["SHADOWESM"+r]=!1,i["SHADOWCUBE"+r]=!1,i["SHADOWLOWQUALITY"+r]=!1,i["SHADOWMEDIUMQUALITY"+r]=!1,t&&t.receiveShadows&&e.shadowsEnabled&&n.shadowEnabled){var s=n.getShadowGenerator();if(s){var l=s.getShadowMap();l&&l.renderList&&l.renderList.length>0&&(a.shadowEnabled=!0,s.prepareDefines(i,r))}}n.lightmapMode!=Ds.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,i["LIGHTMAPEXCLUDED"+r]=!0,i["LIGHTMAPNOSPECULAR"+r]=n.lightmapMode==Ds.LIGHTMAP_SHADOWSONLY):(i["LIGHTMAPEXCLUDED"+r]=!1,i["LIGHTMAPNOSPECULAR"+r]=!1)},e.PrepareDefinesForLights=function(e,t,n,r,i,o){if(void 0===i&&(i=4),void 0===o&&(o=!1),!n._areLightsDirty)return n._needNormals;var a=0,s={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!o)for(var l=0,c=t.lightSources;l0&&(i=r+o,t.addFallback(i,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(r,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(r,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(r,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(r,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(r,"SHADOWESM"+o));return i++},e.PrepareAttributesForMorphTargetsInfluencers=function(e,t,n){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=n,this.PrepareAttributesForMorphTargets(e,t,this._TmpMorphInfluencers)},e.PrepareAttributesForMorphTargets=function(e,t,n){var r=n.NUM_MORPH_INFLUENCERS;if(r>0&&Zo.a.LastCreatedEngine)for(var i=Zo.a.LastCreatedEngine.getCaps().maxVertexAttribs,o=t.morphTargetManager,a=o&&o.supportsNormals&&n.NORMAL,s=o&&o.supportsTangents&&n.TANGENT,l=o&&o.supportsUVs&&n.UV1,c=0;ci&&jo.a.Error("Cannot add more vertex attributes for mesh "+t.name)},e.PrepareAttributesForBones=function(e,t,n,r){n.NUM_BONE_INFLUENCERS>0&&(r.addCPUSkinningFallback(0,t),e.push(cs.MatricesIndicesKind),e.push(cs.MatricesWeightsKind),n.NUM_BONE_INFLUENCERS>4&&(e.push(cs.MatricesIndicesExtraKind),e.push(cs.MatricesWeightsExtraKind)))},e.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&this.PushAttributesForInstances(e)},e.PushAttributesForInstances=function(e){e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3")},e.BindLightProperties=function(e,t,n){e.transferToEffect(t,n+"")},e.BindLight=function(e,t,n,r,i,o){void 0===o&&(o=!1),e._bindLight(t,n,r,i,o)},e.BindLights=function(e,t,n,r,i,o){void 0===i&&(i=4),void 0===o&&(o=!1);for(var a=Math.min(t.lightSources.length,i),s=0;s-1){var r=n.getTransformMatrixTexture(e);t.setTexture("boneSampler",r),t.setFloat("boneTextureWidth",4*(n.bones.length+1))}else{var i=n.getTransformMatrices(e);i&&t.setMatrices("mBones",i)}}},e.BindMorphTargetParameters=function(e,t){var n=e.morphTargetManager;e&&n&&t.setFloatArray("morphTargetInfluences",n.influences)},e.BindLogDepth=function(e,t,n){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(n.activeCamera.maxZ+1)/Math.LN2))},e.BindClipPlane=function(e,t){if(t.clipPlane){var n=t.clipPlane;e.setFloat4("vClipPlane",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane2){n=t.clipPlane2;e.setFloat4("vClipPlane2",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane3){n=t.clipPlane3;e.setFloat4("vClipPlane3",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane4){n=t.clipPlane4;e.setFloat4("vClipPlane4",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane5){n=t.clipPlane5;e.setFloat4("vClipPlane5",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane6){n=t.clipPlane6;e.setFloat4("vClipPlane6",n.normal.x,n.normal.y,n.normal.z,n.d)}},e._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},e._tempFogColor=Io.Black(),e}(),Su=function(){function e(){}return Object.defineProperty(e,"DiffuseTextureEnabled",{get:function(){return this._DiffuseTextureEnabled},set:function(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AmbientTextureEnabled",{get:function(){return this._AmbientTextureEnabled},set:function(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OpacityTextureEnabled",{get:function(){return this._OpacityTextureEnabled},set:function(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ReflectionTextureEnabled",{get:function(){return this._ReflectionTextureEnabled},set:function(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EmissiveTextureEnabled",{get:function(){return this._EmissiveTextureEnabled},set:function(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"SpecularTextureEnabled",{get:function(){return this._SpecularTextureEnabled},set:function(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"BumpTextureEnabled",{get:function(){return this._BumpTextureEnabled},set:function(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"LightmapTextureEnabled",{get:function(){return this._LightmapTextureEnabled},set:function(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RefractionTextureEnabled",{get:function(){return this._RefractionTextureEnabled},set:function(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ColorGradingTextureEnabled",{get:function(){return this._ColorGradingTextureEnabled},set:function(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"FresnelEnabled",{get:function(){return this._FresnelEnabled},set:function(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,ss.a.MarkAllMaterialsAsDirty(4))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ClearCoatTextureEnabled",{get:function(){return this._ClearCoatTextureEnabled},set:function(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ClearCoatBumpTextureEnabled",{get:function(){return this._ClearCoatBumpTextureEnabled},set:function(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ClearCoatTintTextureEnabled",{get:function(){return this._ClearCoatTintTextureEnabled},set:function(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"SheenTextureEnabled",{get:function(){return this._SheenTextureEnabled},set:function(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AnisotropicTextureEnabled",{get:function(){return this._AnisotropicTextureEnabled},set:function(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ThicknessTextureEnabled",{get:function(){return this._ThicknessTextureEnabled},set:function(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,ss.a.MarkAllMaterialsAsDirty(1))},enumerable:!0,configurable:!0}),e._DiffuseTextureEnabled=!0,e._AmbientTextureEnabled=!0,e._OpacityTextureEnabled=!0,e._ReflectionTextureEnabled=!0,e._EmissiveTextureEnabled=!0,e._SpecularTextureEnabled=!0,e._BumpTextureEnabled=!0,e._LightmapTextureEnabled=!0,e._RefractionTextureEnabled=!0,e._ColorGradingTextureEnabled=!0,e._FresnelEnabled=!0,e._ClearCoatTextureEnabled=!0,e._ClearCoatBumpTextureEnabled=!0,e._ClearCoatTintTextureEnabled=!0,e._SheenTextureEnabled=!0,e._AnisotropicTextureEnabled=!0,e._ThicknessTextureEnabled=!0,e}(),Tu="uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";Qc.a.IncludesShadersStore.defaultFragmentDeclaration=Tu;var Pu="layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nfloat visibility;\nvec4 vDiffuseColor;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};\n";Qc.a.IncludesShadersStore.defaultUboDeclaration=Pu;var Ou="const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat toGammaSpace(float color)\n{\nreturn pow(color,GammaEncodePowerApprox);\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}\n";Qc.a.IncludesShadersStore.helperFunctions=Ou;var Ru="#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#endif";Qc.a.IncludesShadersStore.lightFragmentDeclaration=Ru;var Mu="#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif";Qc.a.IncludesShadersStore.lightUboDeclaration=Mu;var Iu="\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn textureColor;\n}";Qc.a.IncludesShadersStore.lightsFragmentFunctions=Iu;var ku="#ifdef SHADOWS\n#ifndef SHADOWFLOAT\n\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\n#endif\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n#define GREATEST_LESS_THAN_ONE 0.99999994\n\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat shadow=texture(shadowSampler,uvDepthLayer);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; ithis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"hasMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;for(var n=this._mesh.getScene(),r=0;r0&&(i.computeBonesUsingShaders=!1)}}else{var s=this._defines[this._currentRank];if(s)for(r=0;r0,o.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,o.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===Wl.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case Wl.EXPLICIT_MODE:o.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case Wl.PLANAR_MODE:o.setReflectionMode("REFLECTIONMAP_PLANAR");break;case Wl.PROJECTION_MODE:o.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case Wl.SKYBOX_MODE:o.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case Wl.SPHERICAL_MODE:o.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case Wl.EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case Wl.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case Wl.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case Wl.CUBIC_MODE:case Wl.INVCUBIC_MODE:default:o.setReflectionMode("REFLECTIONMAP_CUBIC")}o.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else o.REFLECTION=!1;if(this._emissiveTexture&&t.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;Cu.PrepareDefinesForMergedUV(this._emissiveTexture,o,"EMISSIVE")}else o.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;Cu.PrepareDefinesForMergedUV(this._lightmapTexture,o,"LIGHTMAP"),o.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else o.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;Cu.PrepareDefinesForMergedUV(this._specularTexture,o,"SPECULAR"),o.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else o.SPECULAR=!1;if(i.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;Cu.PrepareDefinesForMergedUV(this._bumpTexture,o,"BUMP"),o.PARALLAX=this._useParallax,o.PARALLAXOCCLUSION=this._useParallaxOcclusion,o.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else o.BUMP=!1;if(this._refractionTexture&&t.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;o._needUVs=!0,o.REFRACTION=!0,o.REFRACTIONMAP_3D=this._refractionTexture.isCube}else o.REFRACTION=!1;o.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else o.DIFFUSE=!1,o.AMBIENT=!1,o.OPACITY=!1,o.REFLECTION=!1,o.EMISSIVE=!1,o.LIGHTMAP=!1,o.BUMP=!1,o.REFRACTION=!1;o.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),o.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,o.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,o.SPECULAROVERALPHA=this._useSpecularOverAlpha,o.PREMULTIPLYALPHA=7===this.alphaMode||8===this.alphaMode}if(o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(o._areFresnelDirty&&(t.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(o.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,o.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,o.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,o.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,o.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,o.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,o._needNormals=!0,o.FRESNEL=!0):o.FRESNEL=!1),Cu.PrepareDefinesForMisc(e,i,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),Cu.PrepareDefinesForAttributes(e,o,!0,!0,!0),Cu.PrepareDefinesForFrameBoundValues(i,a,o,r),o.isDirty){var s=o._areLightsDisposed;o.markAsProcessed();var l=new ud;o.REFLECTION&&l.addFallback(0,"REFLECTION"),o.SPECULAR&&l.addFallback(0,"SPECULAR"),o.BUMP&&l.addFallback(0,"BUMP"),o.PARALLAX&&l.addFallback(1,"PARALLAX"),o.PARALLAXOCCLUSION&&l.addFallback(0,"PARALLAXOCCLUSION"),o.SPECULAROVERALPHA&&l.addFallback(0,"SPECULAROVERALPHA"),o.FOG&&l.addFallback(1,"FOG"),o.POINTSIZE&&l.addFallback(0,"POINTSIZE"),o.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),Cu.HandleFallbacksForShadows(o,l,this._maxSimultaneousLights),o.SPECULARTERM&&l.addFallback(0,"SPECULARTERM"),o.DIFFUSEFRESNEL&&l.addFallback(1,"DIFFUSEFRESNEL"),o.OPACITYFRESNEL&&l.addFallback(2,"OPACITYFRESNEL"),o.REFLECTIONFRESNEL&&l.addFallback(3,"REFLECTIONFRESNEL"),o.EMISSIVEFRESNEL&&l.addFallback(4,"EMISSIVEFRESNEL"),o.FRESNEL&&l.addFallback(4,"FRESNEL"),o.MULTIVIEW&&l.addFallback(0,"MULTIVIEW");var c=[cs.PositionKind];o.NORMAL&&c.push(cs.NormalKind),o.UV1&&c.push(cs.UVKind),o.UV2&&c.push(cs.UV2Kind),o.VERTEXCOLOR&&c.push(cs.ColorKind),Cu.PrepareAttributesForBones(c,e,o,l),Cu.PrepareAttributesForInstances(c,o),Cu.PrepareAttributesForMorphTargets(c,e,o);var u="default",d=["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"],h=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler"],p=["Material","Scene"];Ms&&(Ms.PrepareUniforms(d,o),Ms.PrepareSamplers(h,o)),Cu.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:h,defines:o,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,d,p,h,o));var f=o.toString(),m=n.effect,g=i.getEngine().createEffect(u,{attributes:c,uniformsNames:d,uniformBuffersNames:p,samplers:h,defines:f,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS}},a);if(g)if(this.allowShaderHotSwapping&&m&&!g.isReady()){if(g=m,this._rebuildInParallel=!0,o.markAsUnprocessed(),s)return o._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,i.resetCachedMaterial(),n.setEffect(g,o),this.buildUniformLayout()}return!(!n.effect||!n.effect.isReady())&&(o._renderId=i.getRenderId(),n.effect._wasPreviouslyReady=!0,!0)},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("reflectionMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("visibility",1),e.addUniform("vDiffuseColor",4),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),t=!0),this._refractionTexture&&this._refractionTexture.isRenderTarget&&(this._activeEffect.setTexture("refraction2DSampler",null),t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,n,r){var i=this.getScene(),o=r._materialDefines;if(o){var a=r.effect;if(a){this._activeEffect=a,o.INSTANCES||this.bindOnlyWorldMatrix(e),o.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var s=this._mustRebind(i,a,n.visibility);Cu.BindBonesParameters(n,a);var l=this._uniformBuffer;if(s){if(l.bindToEffect(a,"Material"),this.bindViewProjection(a),!l.useUbo||!this.isFrozen||!l.isSync){if(t.FresnelEnabled&&o.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(l.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),l.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&l.updateColor4("opacityParts",new Io(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(l.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),l.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(l.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),l.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(l.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),l.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),i.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(l.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),Cu.BindTextureMatrix(this._diffuseTexture,l,"diffuse"),this._diffuseTexture.hasAlpha&&a.setFloat("alphaCutOff",this.alphaCutOff)),this._ambientTexture&&t.AmbientTextureEnabled&&(l.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),Cu.BindTextureMatrix(this._ambientTexture,l,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(l.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),Cu.BindTextureMatrix(this._opacityTexture,l,"opacity")),this._reflectionTexture&&t.ReflectionTextureEnabled&&(l.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),l.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var c=this._reflectionTexture;l.updateVector3("vReflectionPosition",c.boundingBoxPosition),l.updateVector3("vReflectionSize",c.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(l.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),Cu.BindTextureMatrix(this._emissiveTexture,l,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(l.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),Cu.BindTextureMatrix(this._lightmapTexture,l,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(l.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),Cu.BindTextureMatrix(this._specularTexture,l,"specular")),this._bumpTexture&&i.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(l.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),Cu.BindTextureMatrix(this._bumpTexture,l,"bump"),i._mirroredCameraPosition?l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.RefractionTextureEnabled){var u=1;this._refractionTexture.isCube||(l.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(u=this._refractionTexture.depth)),l.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,u,this.invertRefractionY?-1:1)}}this.pointsCloud&&l.updateFloat("pointSize",this.pointSize),o.SPECULARTERM&&l.updateColor4("vSpecularColor",this.specularColor,this.specularPower),l.updateColor3("vEmissiveColor",t.EmissiveTextureEnabled?this.emissiveColor:Io.BlackReadOnly),l.updateFloat("visibility",n.visibility),l.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha)}if(i.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&i.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled)){u=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}Cu.BindClipPlane(a,i),i.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),Cu.BindEyePosition(a,i),a.setColor3("vAmbientColor",this._globalAmbientColor)}!s&&this.isFrozen||(i.lightsEnabled&&!this._disableLighting&&Cu.BindLights(i,n,a,o,this._maxSimultaneousLights,this._rebuildInParallel),(i.fogEnabled&&n.applyFog&&i.fogMode!==nl.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),Cu.BindFogParameters(i,n,a),o.NUM_MORPH_INFLUENCERS&&Cu.BindMorphTargetParameters(n,a),this.useLogarithmicDepth&&Cu.BindLogDepth(o,a,i),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),l.update(),this._afterBind(n,this._activeEffect)}}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),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._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),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._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._specularTexture&&t.push(this._specularTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this._refractionTexture&&t.push(this._refractionTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._emissiveTexture===t||(this._specularTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||this._refractionTexture===t))))))))},t.prototype.dispose=function(t,n){n&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,n)},t.prototype.clone=function(e){var n=this,r=ya.Clone((function(){return new t(e,n.getScene())}),this);return r.name=e,r.id=e,r},t.prototype.serialize=function(){return ya.Serialize(this)},t.Parse=function(e,n,r){return ya.Parse((function(){return new t(e.name,n)}),e,n,r)},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return Su.DiffuseTextureEnabled},set:function(e){Su.DiffuseTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return Su.AmbientTextureEnabled},set:function(e){Su.AmbientTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return Su.OpacityTextureEnabled},set:function(e){Su.OpacityTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return Su.ReflectionTextureEnabled},set:function(e){Su.ReflectionTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return Su.EmissiveTextureEnabled},set:function(e){Su.EmissiveTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return Su.SpecularTextureEnabled},set:function(e){Su.SpecularTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return Su.BumpTextureEnabled},set:function(e){Su.BumpTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return Su.LightmapTextureEnabled},set:function(e){Su.LightmapTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return Su.RefractionTextureEnabled},set:function(e){Su.RefractionTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return Su.ColorGradingTextureEnabled},set:function(e){Su.ColorGradingTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return Su.FresnelEnabled},set:function(e){Su.FresnelEnabled=e},enumerable:!0,configurable:!0}),Object(No.c)([pa("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),Object(No.c)([pa("ambientTexture")],t.prototype,"_ambientTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(No.c)([pa("opacityTexture")],t.prototype,"_opacityTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(No.c)([pa("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(No.c)([pa("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(No.c)([pa("specularTexture")],t.prototype,"_specularTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),Object(No.c)([pa("bumpTexture")],t.prototype,"_bumpTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(No.c)([pa("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),Object(No.c)([pa("refractionTexture")],t.prototype,"_refractionTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),Object(No.c)([fa("ambient")],t.prototype,"ambientColor",void 0),Object(No.c)([fa("diffuse")],t.prototype,"diffuseColor",void 0),Object(No.c)([fa("specular")],t.prototype,"specularColor",void 0),Object(No.c)([fa("emissive")],t.prototype,"emissiveColor",void 0),Object(No.c)([ha()],t.prototype,"specularPower",void 0),Object(No.c)([ha("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),Object(No.c)([ha("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),Object(No.c)([ha("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),Object(No.c)([ha("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(No.c)([ha("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),Object(No.c)([ha("disableLighting")],t.prototype,"_disableLighting",void 0),Object(No.c)([da("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(No.c)([ha("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(No.c)([ha("useParallax")],t.prototype,"_useParallax",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(No.c)([ha("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(No.c)([ha()],t.prototype,"parallaxScaleBias",void 0),Object(No.c)([ha("roughness")],t.prototype,"_roughness",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(No.c)([ha()],t.prototype,"indexOfRefraction",void 0),Object(No.c)([ha()],t.prototype,"invertRefractionY",void 0),Object(No.c)([ha()],t.prototype,"alphaCutOff",void 0),Object(No.c)([ha("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(No.c)([ma("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),Object(No.c)([ma("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),Object(No.c)([ma("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),Object(No.c)([ma("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),Object(No.c)([ma("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),Object(No.c)([ha("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),Object(No.c)([da("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),Object(No.c)([ha("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),Object(No.c)([ha("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(No.c)([da("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(No.c)([ha("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(No.c)([ha("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(No.c)([ha("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(No.c)([ha()],t.prototype,"useLogarithmicDepth",null),t}(Eu);Eo.RegisteredTypes["BABYLON.StandardMaterial"]=hd,nl.DefaultMaterialFactory=function(e){return new hd("default material",e)},Va.a.prototype.createDynamicTexture=function(e,t,n,r){var i=new Kl.a(this,Kl.b.Dynamic);return i.baseWidth=e,i.baseHeight=t,n&&(e=this.needPOTTextures?Va.a.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?Va.a.GetExponentOfTwo(t,this._caps.maxTextureSize):t),i.width=e,i.height=t,i.isReady=!1,i.generateMipMaps=n,i.samplingMode=r,this.updateTextureSamplingMode(r,i),this._internalTexturesCache.push(i),i},Va.a.prototype.updateDynamicTexture=function(e,t,n,r,i,o){if(void 0===r&&(r=!1),void 0===o&&(o=!1),e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0,o),this._unpackFlipY(n),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var a=i?this._getInternalFormat(i):this._gl.RGBA;this._gl.texImage2D(this._gl.TEXTURE_2D,0,a,a,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}};var pd=function(e){function t(t,n,r,i,o,a){void 0===r&&(r=null),void 0===o&&(o=3),void 0===a&&(a=5);var s=e.call(this,null,r,!i,void 0,o,void 0,void 0,void 0,void 0,a)||this;s.name=t,s._engine=s.getScene().getEngine(),s.wrapU=Wl.CLAMP_ADDRESSMODE,s.wrapV=Wl.CLAMP_ADDRESSMODE,s._generateMipMaps=i,n.getContext?(s._canvas=n,s._texture=s._engine.createDynamicTexture(n.width,n.height,i,o)):(s._canvas=wl.a.CreateCanvas(1,1),n.width||0===n.width?s._texture=s._engine.createDynamicTexture(n.width,n.height,i,o):s._texture=s._engine.createDynamicTexture(n,n,i,o));var l=s.getSize();return s._canvas.width=l.width,s._canvas.height=l.height,s._context=s._canvas.getContext("2d"),s}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"DynamicTexture"},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._engine.createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)},t.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},t.prototype.scaleTo=function(e,t){var n=this.getSize();n.width=e,n.height=t,this._recreate(n)},t.prototype.getContext=function(){return this._context},t.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},t.prototype.update=function(e,t){void 0===t&&(t=!1),this._engine.updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0)},t.prototype.drawText=function(e,t,n,r,i,o,a,s){void 0===s&&(s=!0);var l=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,l.width,l.height)),this._context.font=r,null==t){var c=this._context.measureText(e);t=(l.width-c.width)/2}if(null==n){var u=parseInt(r.replace(/\D/g,""));n=l.height/2+u/3.65}this._context.fillStyle=i,this._context.fillText(e,t,n),s&&this.update(a)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=this.getSize(),r=new t(this.name,n,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.wrapU=this.wrapU,r.wrapV=this.wrapV,r},t.prototype.serialize=function(){var t=this.getScene();t&&!t.isReady()&&jo.a.Warn("The scene must be ready before serializing the dynamic texture");var n=e.prototype.serialize.call(this);return this._canvas.toDataURL&&(n.base64String=this._canvas.toDataURL()),n.invertY=this._invertY,n.samplingMode=this.samplingMode,n},t.prototype._rebuild=function(){this.update()},t}(Wl),fd="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include\n#include\n#include\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\n\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}";Qc.a.ShadersStore.imageProcessingPixelShader=fd;var md=function(e){function t(t,n,r,i,o,a,s,l){void 0===r&&(r=null),void 0===s&&(s=0);var c=e.call(this,t,"imageProcessing",[],[],n,r,i,o,a,null,s,"postprocess",null,!0)||this;return c._fromLinearSpace=!0,c._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},l?(l.applyByPostProcess=!0,c._attachImageProcessingConfiguration(l,!0),c.fromLinearSpace=!1):(c._attachImageProcessingConfiguration(null,!0),c.imageProcessingConfiguration.applyByPostProcess=!0),c.onApply=function(e){c.imageProcessingConfiguration.bind(e,c.aspectRatio)},c}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e,t){var n=this;if(void 0===t&&(t=!1),e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{var r=null,i=this.getEngine(),o=this.getCamera();if(o)r=o.getScene();else if(i&&i.scenes){var a=i.scenes;r=a[a.length-1]}else r=Zo.a.LastCreatedScene;this._imageProcessingConfiguration=r.imageProcessingConfiguration}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){n._updateParameters()}))),t||this._updateParameters()}},Object.defineProperty(t.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingType",{get:function(){return this._imageProcessingConfiguration.toneMappingType},set:function(e){this._imageProcessingConfiguration.toneMappingType=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!0,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 t in this._defines)this._defines[t]&&(e+="#define "+t+";\r\n");var n=["textureSampler"],r=["scale"];Ms&&(Ms.PrepareSamplers(n,this._defines),Ms.PrepareUniforms(r,this._defines)),this.updateEffect(e,r,n)},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)},Object(No.c)([ha()],t.prototype,"_fromLinearSpace",void 0),t}(Xc);Pl._GroundMeshParser=function(e,t){return gd.Parse(e,t)};var gd=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.generateOctree=!1,r}return Object(No.d)(t,e),t.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(t.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!0,configurable:!0}),t.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)},t.prototype.getHeightAtCoordinates=function(e,t){var n=this.getWorldMatrix(),r=Mo.Matrix[5];n.invertToRef(r);var i=Mo.Vector3[8];if(So.TransformCoordinatesFromFloatsToRef(e,0,t,r,i),e=i.x,t=i.z,ethis._maxX||tthis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var o=this._getFacetAt(e,t),a=-(o.x*e+o.z*t+o.w)/o.y;return So.TransformCoordinatesFromFloatsToRef(0,a,0,n,i),i.y},t.prototype.getNormalAtCoordinates=function(e,t){var n=new So(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,n),n},t.prototype.getNormalAtCoordinatesToRef=function(e,t,n){var r=this.getWorldMatrix(),i=Mo.Matrix[5];r.invertToRef(i);var o=Mo.Vector3[8];if(So.TransformCoordinatesFromFloatsToRef(e,0,t,i,o),e=o.x,t=o.z,ethis._maxX||tthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(e,t);return So.TransformNormalFromFloatsToRef(a.x,a.y,a.z,r,n),this},t.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},t.prototype._getFacetAt=function(e,t){var n=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),i=this._heightQuads[r*this._subdivisionsX+n];return te.maxHeight){c=!0;var u=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=u}for(t=0;t<=e.subdivisions;t++)for(n=0;n<=e.subdivisions;n++){var d=new So(n*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),h=4*(((d.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(d.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),p=e.buffer[h]/255,f=e.buffer[h+1]/255,m=e.buffer[h+2]/255,g=e.buffer[h+3]/255;c&&(p=1-p,f=1-f,m=1-m);var b=p*s.r+f*s.g+m*s.b;d.y=g>=l?e.minHeight+(e.maxHeight-e.minHeight)*b:e.minHeight-.001,i.push(d.x,d.y,d.z),o.push(0,0,0),a.push(n/e.subdivisions,1-t/e.subdivisions)}for(t=0;t=e.minHeight,w=i[3*A+1]>=e.minHeight,E=i[3*_+1]>=e.minHeight;x&&w&&E&&(r.push(v),r.push(A),r.push(_)),i[3*y+1]>=e.minHeight&&x&&E&&(r.push(y),r.push(v),r.push(_))}us.ComputeNormals(i,r,o);var C=new us;return C.indices=r,C.positions=i,C.normals=o,C.uvs=a,C},Pl.CreateGround=function(e,t,n,r,i,o){var a={width:t,height:n,subdivisions:r,updatable:o};return bd.CreateGround(e,a,i)},Pl.CreateTiledGround=function(e,t,n,r,i,o,a,s,l){var c={xmin:t,zmin:n,xmax:r,zmax:i,subdivisions:o,precision:a,updatable:l};return bd.CreateTiledGround(e,c,s)},Pl.CreateGroundFromHeightMap=function(e,t,n,r,i,o,a,s,l,c,u){var d={width:n,height:r,subdivisions:i,minHeight:o,maxHeight:a,updatable:l,onReady:c,alphaFilter:u};return bd.CreateGroundFromHeightMap(e,t,d,s)};var bd=function(){function e(){}return e.CreateGround=function(e,t,n){var r=new gd(e,n);return r._setReady(!1),r._subdivisionsX=t.subdivisionsX||t.subdivisions||1,r._subdivisionsY=t.subdivisionsY||t.subdivisions||1,r._width=t.width||1,r._height=t.height||1,r._maxX=r._width/2,r._maxZ=r._height/2,r._minX=-r._maxX,r._minZ=-r._maxZ,us.CreateGround(t).applyToMesh(r,t.updatable),r._setReady(!0),r},e.CreateTiledGround=function(e,t,n){void 0===n&&(n=null);var r=new Pl(e,n);return us.CreateTiledGround(t).applyToMesh(r,t.updatable),r},e.CreateGroundFromHeightMap=function(e,t,n,r){void 0===r&&(r=null);var i=n.width||10,o=n.height||10,a=n.subdivisions||1,s=n.minHeight||0,l=n.maxHeight||1,c=n.colorFilter||new Io(.3,.59,.11),u=n.alphaFilter||0,d=n.updatable,h=n.onReady;r=r||Zo.a.LastCreatedScene;var p=new gd(e,r);p._subdivisionsX=a,p._subdivisionsY=a,p._width=i,p._height=o,p._maxX=p._width/2,p._maxZ=p._height/2,p._minX=-p._maxX,p._minZ=-p._maxZ,p._setReady(!1);return Ja.LoadImage(t,(function(e){var t=e.width,n=e.height,f=wl.a.CreateCanvas(t,n).getContext("2d");if(!f)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!r.isDisposed){f.drawImage(e,0,0);var m=f.getImageData(0,0,t,n).data;us.CreateGroundFromHeightMap({width:i,height:o,subdivisions:a,minHeight:s,maxHeight:l,colorFilter:c,buffer:m,bufferWidth:t,bufferHeight:n,alphaFilter:u}).applyToMesh(p,d),h&&h(p),p._setReady(!0)}}),(function(){}),r.offlineProvider),p},e}();us.CreateTorus=function(e){for(var t=[],n=[],r=[],i=[],o=e.diameter||1,a=e.thickness||.5,s=e.tessellation||16,l=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,c=s+1,u=0;u<=s;u++)for(var d=u/s,h=u*Math.PI*2/s-Math.PI/2,p=Oo.Translation(o/2,0,0).multiply(Oo.RotationY(h)),f=0;f<=s;f++){var m=1-f/s,g=f*Math.PI*2/s+Math.PI,b=Math.cos(g),v=Math.sin(g),A=new So(b,v,0),_=A.scale(a/2),y=new Co(d,m);_=So.TransformCoordinates(_,p),A=So.TransformNormal(A,p),n.push(_.x,_.y,_.z),r.push(A.x,A.y,A.z),i.push(y.x,y.y);var x=(u+1)%c,w=(f+1)%c;t.push(u*c+f),t.push(u*c+w),t.push(x*c+f),t.push(u*c+w),t.push(x*c+w),t.push(x*c+f)}us._ComputeSides(l,n,t,r,i,e.frontUVs,e.backUVs);var E=new us;return E.indices=t,E.positions=n,E.normals=r,E.uvs=i,E},Pl.CreateTorus=function(e,t,n,r,i,o,a){var s={diameter:t,thickness:n,tessellation:r,sideOrientation:a,updatable:o};return vd.CreateTorus(e,s,i)};var vd=function(){function e(){}return e.CreateTorus=function(e,t,n){var r=new Pl(e,n);return t.sideOrientation=Pl._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,us.CreateTorus(t).applyToMesh(r,t.updatable),r},e}();us.CreateCylinder=function(e){var t=e.height||2,n=0===e.diameterTop?0:e.diameterTop||e.diameter||1,r=0===e.diameterBottom?0:e.diameterBottom||e.diameter||1;n=n||1e-5,r=r||1e-5;var i,o=e.tessellation||24,a=e.subdivisions||1,s=!!e.hasRings,l=!!e.enclose,c=0===e.cap?0:e.cap||Pl.CAP_ALL,u=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,d=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,h=e.faceUV||new Array(3),p=e.faceColors,f=2+(1+(1!==u&&l?2:0))*(s?a:1);for(i=0;i=0){r=n[i],this.webVRController._pointingPoseNode=r;break}this._laserPointer.parent=r},t.prototype._updatePointerDistance=function(e){void 0===e&&(e=100),this._laserPointer.scaling.y=e,this._laserPointer.position.z=-e/2},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._laserPointer.dispose(),this._meshAttachedObserver&&this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)},t}(Cd),Td=function(e){function t(t,n){var r=e.call(this,n)||this;return r.getCamera=t,r}return Object(No.d)(t,e),t.prototype._getForwardRay=function(e){var t=this.getCamera();return t?t.getForwardRay(e):new Vl(So.Zero(),So.Forward())},t}(Cd),Pd=function(){function e(t,n){var r=this;if(void 0===n&&(n={}),this.webVROptions=n,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.enableGazeEvenWhenNoPointerLock=!1,this.exitVROnDoubleTap=!0,this.onEnteringVRObservable=new yo.a,this.onAfterEnteringVRObservable=new yo.a,this.onExitingVRObservable=new yo.a,this.onControllerMeshLoadedObservable=new yo.a,this._useCustomVRButton=!1,this._teleportationRequested=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._teleportationMode=e.TELEPORTATIONMODE_CONSTANTTIME,this._teleportationTime=122,this._teleportationSpeed=20,this._rotationAllowed=!0,this._teleportBackwardsVector=new So(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new So(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this._gazeColor=new Io(.7,.7,.7),this._laserColor=new Io(.7,.7,.7),this._pickedLaserColor=new Io(.2,.2,1),this._pickedGazeColor=new Io(0,0,1),this.onNewMeshSelected=new yo.a,this.onMeshSelectedWithController=new yo.a,this.onNewMeshPicked=new yo.a,this.onBeforeCameraTeleport=new yo.a,this.onAfterCameraTeleport=new yo.a,this.onSelectedMeshUnselected=new yo.a,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(){r.moveButtonToBottomRight(),r._fullscreenVRpresenting&&r._webVRready&&r.exitVR()},this._onFullscreenChange=function(){var e=document;void 0!==e.fullscreen?r._fullscreenVRpresenting=document.fullscreen:void 0!==e.mozFullScreen?r._fullscreenVRpresenting=e.mozFullScreen:void 0!==e.webkitIsFullScreen?r._fullscreenVRpresenting=e.webkitIsFullScreen:void 0!==e.msIsFullScreen?r._fullscreenVRpresenting=e.msIsFullScreen:void 0!==document.msFullscreenElement&&(r._fullscreenVRpresenting=document.msFullscreenElement),!r._fullscreenVRpresenting&&r._inputElement&&(r.exitVR(),!r._useCustomVRButton&&r._btnVR&&(r._btnVR.style.top=r._inputElement.offsetTop+r._inputElement.offsetHeight-70+"px",r._btnVR.style.left=r._inputElement.offsetLeft+r._inputElement.offsetWidth-100+"px",r.updateButtonVisibility()))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this.beforeRender=function(){r._leftController&&r._leftController._activePointer&&r._castRayAndSelectObject(r._leftController),r._rightController&&r._rightController._activePointer&&r._castRayAndSelectObject(r._rightController),r._noControllerIsActive&&(r._scene.getEngine().isPointerLock||r.enableGazeEvenWhenNoPointerLock)?r._castRayAndSelectObject(r._cameraGazer):r._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(e){if(e.type!==ec.POSE_ENABLED)e.leftStick&&e.onleftstickchanged((function(e){r._teleportationInitialized&&r.teleportationEnabled&&(!r._leftController&&!r._rightController||r._leftController&&!r._leftController._activePointer&&r._rightController&&!r._rightController._activePointer)&&(r._checkTeleportWithRay(e,r._cameraGazer),r._checkTeleportBackwards(e,r._cameraGazer))})),e.rightStick&&e.onrightstickchanged((function(e){r._teleportationInitialized&&r._checkRotate(e,r._cameraGazer)})),e.type===ec.XBOX&&(e.onbuttondown((function(e){r._interactionsEnabled&&e===kc.A&&r._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){r._interactionsEnabled&&e===kc.A&&r._cameraGazer._selectionPointerUp()})));else{var t=e,n=new Sd(t,r._scene,r._cameraGazer._gazeTracker);"right"===t.hand||r._leftController&&r._leftController.webVRController!=t?r._rightController=n:r._leftController=n,r._tryEnableInteractionOnController(n)}},this._tryEnableInteractionOnController=function(e){r._interactionsRequested&&!e._interactionsEnabled&&r._enableInteractionOnController(e),r._teleportationRequested&&!e._teleportationEnabled&&r._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(e){e instanceof wu&&("left"===e.hand&&null!=r._leftController&&(r._leftController.dispose(),r._leftController=null),"right"===e.hand&&null!=r._rightController&&(r._rightController.dispose(),r._rightController=null))},this._workingVector=So.Zero(),this._workingQuaternion=Po.Identity(),this._workingMatrix=Oo.Identity(),this._scene=t,this._inputElement=t.getEngine().getInputElement(),"getVRDisplays"in navigator||(n.useXR=!0),void 0===n.createFallbackVRDeviceOrientationFreeCamera&&(n.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===n.createDeviceOrientationCamera&&(n.createDeviceOrientationCamera=!0),void 0===n.laserToggle&&(n.laserToggle=!0),void 0===n.defaultHeight&&(n.defaultHeight=1.7),n.useCustomVRButton&&(this._useCustomVRButton=!0,n.customVRButton&&(this._btnVR=n.customVRButton)),n.rayLength&&(this._rayLength=n.rayLength),this._defaultHeight=n.defaultHeight,n.positionScale&&(this._rayLength*=n.positionScale,this._defaultHeight*=n.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new So(0,this._defaultHeight,0),n.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new Tc("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 wc&&this._scene.activeCamera.rotation)){var i=this._scene.activeCamera;i.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(i.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(Po.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(this._inputElement)}else this._existingCamera=this._scene.activeCamera;this.webVROptions.useXR&&navigator.xr?wd.IsSessionSupportedAsync("immersive-vr").then((function(e){e?(jo.a.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),t.createDefaultXRExperienceAsync({floorMeshes:n.floorMeshes||[]}).then((function(e){r.xr=e,r.xrTestDone=!0,r._cameraGazer=new Td((function(){return r.xr.baseExperience.camera}),t),r.xr.baseExperience.onStateChangedObservable.add((function(e){switch(e){case Ad.ENTERING_XR:r.onEnteringVRObservable.notifyObservers(r),r._interactionsEnabled||r.xr.pointerSelection.detach(),r.xr.pointerSelection.displayLaserPointer=r._displayLaserPointer;break;case Ad.EXITING_XR:r.onExitingVRObservable.notifyObservers(r),r._scene.getEngine().resize();break;case Ad.IN_XR:r._hasEnteredVR=!0;break;case Ad.NOT_IN_XR:r._hasEnteredVR=!1}}))}))):r.completeVRInit(t,n)})):this.completeVRInit(t,n)}return Object.defineProperty(e.prototype,"onEnteringVR",{get:function(){return this.onEnteringVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onExitingVR",{get:function(){return this.onExitingVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onControllerMeshLoaded",{get:function(){return this.onControllerMeshLoadedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"teleportationTarget",{get:function(){return this._teleportationTarget},set:function(e){e&&(e.name="teleportationTarget",this._isDefaultTeleportationTarget=!1,this._teleportationTarget=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gazeTrackerMesh",{get:function(){return this._cameraGazer._gazeTracker},set:function(e){e&&(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=e,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:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftControllerGazeTrackerMesh",{get:function(){return this._leftController?this._leftController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightControllerGazeTrackerMesh",{get:function(){return this._rightController?this._rightController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayGaze",{get:function(){return this._displayGaze},set:function(e){this._displayGaze=e,e||(this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayLaserPointer",{get:function(){return this._displayLaserPointer},set:function(e){this._displayLaserPointer=e,e?(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:!0,configurable:!0}),Object.defineProperty(e.prototype,"deviceOrientationCamera",{get:function(){return this._deviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentVRCamera",{get:function(){return this._webVRready?this._webVRCamera:this._scene.activeCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"webVRCamera",{get:function(){return this._webVRCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vrDeviceOrientationCamera",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vrButton",{get:function(){return this._btnVR},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_teleportationRequestInitiated",{get:function(){return this._cameraGazer._teleportationRequestInitiated||null!==this._leftController&&this._leftController._teleportationRequestInitiated||null!==this._rightController&&this._rightController._teleportationRequestInitiated},enumerable:!0,configurable:!0}),e.prototype.completeVRInit=function(e,t){var n=this;if(this.xrTestDone=!0,t.createFallbackVRDeviceOrientationFreeCamera&&(t.useMultiview&&(t.vrDeviceOrientationCameraMetrics||(t.vrDeviceOrientationCameraMetrics=du.GetDefault()),t.vrDeviceOrientationCameraMetrics.multiviewEnabled=!0),this._vrDeviceOrientationCamera=new Au("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new xu("WebVRHelper",this._position,this._scene,t),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new Td((function(){return n.currentVRCamera}),e),!this._useCustomVRButton){this._btnVR=document.createElement("BUTTON"),this._btnVR.className="babylonVRicon",this._btnVR.id="babylonVRiconbtn",this._btnVR.title="Click to switch to VR";var r=".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) }";r+=".babylonVRicon.vrdisplaypresenting { display: none; }";var i=document.createElement("style");i.appendChild(document.createTextNode(r)),document.getElementsByTagName("head")[0].appendChild(i),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",(function(){n.isInVRMode?n._scene.getEngine().disableVR():n.enterVR()}));var o=this._scene.getEngine().getHostWindow();o&&(o.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,t.createFallbackVRDeviceOrientationFreeCamera?this.displayVRButton():this._scene.getEngine().onVRDisplayChangedObservable.add((function(e){e.vrDisplay&&n.displayVRButton()})),this._onKeyDown=function(e){27===e.keyCode&&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())}),Qs.POINTERDOUBLETAP,!1),this._onVRDisplayChanged=function(e){return n.onVRDisplayChanged(e)},this._onVrDisplayPresentChange=function(){return n.onVrDisplayPresentChange()},this._onVRRequestPresentStart=function(){n._webVRrequesting=!0,n.updateButtonVisibility()},this._onVRRequestPresentComplete=function(){n._webVRrequesting=!1,n.updateButtonVisibility()},e.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged),e.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),e.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),o.addEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),e.onDisposeObservable.add((function(){n.dispose()})),this._webVRCamera.onControllerMeshLoadedObservable.add((function(e){return n._onDefaultMeshLoaded(e)})),this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),this.updateButtonVisibility(),this._circleEase=new ml,this._circleEase.setEasingMode(fl.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,e.onPointerObservable.add((function(t){n._interactionsEnabled&&e.activeCamera===n.vrDeviceOrientationCamera&&"mouse"===t.event.pointerType&&(t.type===Qs.POINTERDOWN?n._cameraGazer._selectionPointerDown():t.type===Qs.POINTERUP&&n._cameraGazer._selectionPointerUp())})),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes}))},e.prototype._onDefaultMeshLoaded=function(e){this._leftController&&this._leftController.webVRController==e&&e.mesh&&this._leftController._setLaserPointerParent(e.mesh),this._rightController&&this._rightController.webVRController==e&&e.mesh&&this._rightController._setLaserPointerParent(e.mesh);try{this.onControllerMeshLoadedObservable.notifyObservers(e)}catch(e){jo.a.Warn("Error in your custom logic onControllerMeshLoaded: "+e)}},Object.defineProperty(e.prototype,"isInVRMode",{get:function(){return this.xr&&this.webVROptions.useXR&&this.xr.baseExperience.state===Ad.IN_XR||this._webVRpresenting||this._fullscreenVRpresenting},enumerable:!0,configurable:!0}),e.prototype.onVrDisplayPresentChange=function(){var e=this._scene.getEngine().getVRDevice();if(e){var t=this._webVRpresenting;this._webVRpresenting=e.isPresenting,t&&!this._webVRpresenting&&this.exitVR()}else jo.a.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");this.updateButtonVisibility()},e.prototype.onVRDisplayChanged=function(e){this._webVRsupported=e.vrSupported,this._webVRready=!!e.vrDisplay,this._webVRpresenting=e.vrDisplay&&e.vrDisplay.isPresenting,this.updateButtonVisibility()},e.prototype.moveButtonToBottomRight=function(){if(this._inputElement&&!this._useCustomVRButton&&this._btnVR){var e=this._inputElement.getBoundingClientRect();this._btnVR.style.top=e.top+e.height-70+"px",this._btnVR.style.left=e.left+e.width-100+"px"}},e.prototype.displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||!this._btnVR||(document.body.appendChild(this._btnVR),this._btnVRDisplayed=!0)},e.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")))},e.prototype.enterVR=function(){var e=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(e){jo.a.Warn("Error in your custom logic onEnteringVR: "+e)}if(this._scene.activeCamera){if(this._position=this._scene.activeCamera.position.clone(),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.rotation=Po.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this.webVRCamera){var t=this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y,n=Po.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y-t,r=this.webVRCamera.rotationQuaternion.toEulerAngles().y;this.webVRCamera.rotationQuaternion=Po.FromEulerAngles(0,r+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(t){e.onAfterEnteringVRObservable.notifyObservers({success:t})})),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(){e.onAfterEnteringVRObservable.notifyObservers({success:!0})}))),this._scene.activeCamera&&this._inputElement&&this._scene.activeCamera.attachControl(this._inputElement),this._interactionsEnabled&&this._scene.registerBeforeRender(this.beforeRender),this._displayLaserPointer&&[this._leftController,this._rightController].forEach((function(e){e&&e._activatePointer()})),this._hasEnteredVR=!0)}},e.prototype.exitVR=function(){if(this.xr)this.xr.baseExperience.exitXRAsync();else if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(e){jo.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._inputElement),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 e=this._scene.getEngine();e._onVrDisplayPresentChange&&e._onVrDisplayPresentChange()}},Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._scene.activeCamera&&(this._scene.activeCamera.position=e)},enumerable:!0,configurable:!0}),e.prototype.enableInteractions=function(){var e=this;if(!this._interactionsEnabled){if(this._interactionsRequested=!0,this.xr)return void(this.xr.baseExperience.state===Ad.IN_XR&&this.xr.pointerSelection.attach());this._leftController&&this._enableInteractionOnController(this._leftController),this._rightController&&this._enableInteractionOnController(this._rightController),this.raySelectionPredicate=function(t){return t.isVisible&&(t.isPickable||t.name===e._floorMeshName)},this.meshSelectionPredicate=function(){return!0},this._raySelectionPredicate=function(t){return!!(e._isTeleportationFloor(t)||-1===t.name.indexOf("gazeTracker")&&-1===t.name.indexOf("teleportationTarget")&&-1===t.name.indexOf("torusTeleportation"))&&e.raySelectionPredicate(t)},this._interactionsEnabled=!0}},Object.defineProperty(e.prototype,"_noControllerIsActive",{get:function(){return!(this._leftController&&this._leftController._activePointer||this._rightController&&this._rightController._activePointer)},enumerable:!0,configurable:!0}),e.prototype._isTeleportationFloor=function(e){for(var t=0;t-1||this._floorMeshesCollection.push(e))},e.prototype.removeFloorMesh=function(e){if(this._floorMeshesCollection){var t=this._floorMeshesCollection.indexOf(e);-1!==t&&this._floorMeshesCollection.splice(t,1)}},e.prototype.enableTeleportation=function(e){var t=this;if(void 0===e&&(e={}),!this._teleportationInitialized){if(this._teleportationRequested=!0,this.enableInteractions(),this.webVROptions.useXR&&(e.floorMeshes||e.floorMeshName)){var n=e.floorMeshes||[];if(!n.length){var r=this._scene.getMeshByName(e.floorMeshName);r&&n.push(r)}if(this.xr)return n.forEach((function(e){t.xr.teleportation.addFloorMesh(e)})),void(this.xr.teleportation.attached||this.xr.teleportation.attach());if(!this.xrTestDone){var i=function(){t.xrTestDone&&(t._scene.unregisterBeforeRender(i),t.xr?t.xr.teleportation.attached||t.xr.teleportation.attach():t.enableTeleportation(e))};return void this._scene.registerBeforeRender(i)}}e.floorMeshName&&(this._floorMeshName=e.floorMeshName),e.floorMeshes&&(this._floorMeshesCollection=e.floorMeshes),e.teleportationMode&&(this._teleportationMode=e.teleportationMode),e.teleportationTime&&e.teleportationTime>0&&(this._teleportationTime=e.teleportationTime),e.teleportationSpeed&&e.teleportationSpeed>0&&(this._teleportationSpeed=e.teleportationSpeed),void 0!==e.easingFunction&&(this._teleportationEasing=e.easingFunction),null!=this._leftController&&this._enableTeleportationOnController(this._leftController),null!=this._rightController&&this._enableTeleportationOnController(this._rightController);var o=new Ms;o.vignetteColor=new ko(0,0,0,0),o.vignetteEnabled=!0,this._postProcessMove=new md("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,o),this._webVRCamera.detachPostProcess(this._postProcessMove),this._teleportationInitialized=!0,this._isDefaultTeleportationTarget&&(this._createTeleportationCircles(),this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))}},e.prototype._enableInteractionOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled=!0,this.isInVRMode&&this._displayLaserPointer&&e._activatePointer(),this.webVROptions.laserToggle&&e.webVRController.onMainButtonStateChangedObservable.add((function(n){t._displayLaserPointer&&1===n.value&&(e._activePointer?e._deactivatePointer():e._activatePointer(),t.displayGaze&&(e._gazeTracker.isVisible=e._activePointer))})),e.webVRController.onTriggerStateChangedObservable.add((function(n){var r=e;t._noControllerIsActive&&(r=t._cameraGazer),r._pointerDownOnMeshAsked?n.valuet._padSensibilityUp&&r._selectionPointerDown()})))},e.prototype._checkTeleportWithRay=function(e,t){this._teleportationRequestInitiated&&!t._teleportationRequestInitiated||(t._teleportationRequestInitiated?Math.sqrt(e.y*e.y+e.x*e.x)-this._padSensibilityDown&&(t._rotationLeftAsked=!1):e.x<-this._padSensibilityUp&&t._dpadPressed&&(t._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),t._rotationRightAsked?e.xthis._padSensibilityUp&&t._dpadPressed&&(t._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},e.prototype._checkTeleportBackwards=function(e,t){if(!t._teleportationRequestInitiated)if(e.y>this._padSensibilityUp&&t._dpadPressed){if(!t._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var n=Po.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),r=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(n=this.currentVRCamera.deviceRotationQuaternion,r=this.currentVRCamera.devicePosition),n.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,Po.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),So.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var i=new Vl(r,this._workingVector),o=this._scene.pickWithRay(i,this._raySelectionPredicate);o&&o.pickedPoint&&o.pickedMesh&&this._isTeleportationFloor(o.pickedMesh)&&o.distance<5&&this.teleportCamera(o.pickedPoint),t._teleportationBackRequestInitiated=!0}}else t._teleportationBackRequestInitiated=!1},e.prototype._enableTeleportationOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled||this._enableInteractionOnController(e),e._interactionsEnabled=!0,e._teleportationEnabled=!0,e.webVRController.controllerType===Rc.VIVE&&(e._dpadPressed=!1,e.webVRController.onPadStateChangedObservable.add((function(t){e._dpadPressed=t.pressed,e._dpadPressed||(e._rotationLeftAsked=!1,e._rotationRightAsked=!1,e._teleportationBackRequestInitiated=!1)}))),e.webVRController.onPadValuesChangedObservable.add((function(n){t.teleportationEnabled&&(t._checkTeleportBackwards(n,e),t._checkTeleportWithRay(n,e)),t._checkRotate(n,e)})))},e.prototype._createTeleportationCircles=function(){this._teleportationTarget=Pl.CreateGround("teleportationTarget",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var e=new pd("DynamicTexture",512,this._scene,!0);e.hasAlpha=!0;var t=e.getContext();t.beginPath(),t.arc(256,256,200,0,2*Math.PI,!1),t.fillStyle=this._teleportationFillColor,t.fill(),t.lineWidth=10,t.strokeStyle=this._teleportationBorderColor,t.stroke(),t.closePath(),e.update();var n=new hd("TextPlaneMaterial",this._scene);n.diffuseTexture=e,this._teleportationTarget.material=n;var r=Pl.CreateTorus("torusTeleportation",.75,.1,25,this._scene,!1);r.isPickable=!1,r.parent=this._teleportationTarget;var i=new Ca("animationInnerCircle","position.y",30,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:0}),o.push({frame:30,value:.4}),o.push({frame:60,value:0}),i.setKeys(o);var a=new vl;a.setEasingMode(fl.EASINGMODE_EASEINOUT),i.setEasingFunction(a),r.animations=[],r.animations.push(i),this._scene.beginAnimation(r,0,60,!0),this._hideTeleportationTarget()},e.prototype._displayTeleportationTarget=function(){this._teleportActive=!0,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!0,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!0))},e.prototype._hideTeleportationTarget=function(){this._teleportActive=!1,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!1,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!1))},e.prototype._rotateCamera=function(e){var t=this;if(this.currentVRCamera instanceof Ec){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var n=Po.FromRotationMatrix(Oo.RotationY(Math.PI/4*this._rotationAngle)),r=new Ca("animationRotation","rotationQuaternion",90,Ca.ANIMATIONTYPE_QUATERNION,Ca.ANIMATIONLOOPMODE_CONSTANT),i=[];i.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),i.push({frame:6,value:n}),r.setKeys(i),r.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(r),this._postProcessMove.animations=[];var o=new Ca("animationPP","vignetteWeight",90,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CONSTANT),a=[];a.push({frame:0,value:0}),a.push({frame:3,value:4}),a.push({frame:6,value:0}),o.setKeys(a),o.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(o);var s=new Ca("animationPP2","vignetteStretch",90,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CONSTANT),l=[];l.push({frame:0,value:0}),l.push({frame:3,value:10}),l.push({frame:6,value:0}),s.setKeys(l),s.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(s),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(){t._webVRCamera.detachPostProcess(t._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},e.prototype._moveTeleportationSelectorTo=function(e,t,n){if(e.pickedPoint){t._teleportationRequestInitiated&&(this._displayTeleportationTarget(),this._haloCenter.copyFrom(e.pickedPoint),this._teleportationTarget.position.copyFrom(e.pickedPoint));var r=this._convertNormalToDirectionOfRay(e.getNormal(!0,!1),n);if(r){var i=So.Cross(os.Y,r),o=So.Cross(r,i);So.RotationFromAxisToRef(o,r,i,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},e.prototype.teleportCamera=function(t){var n=this;if(this.currentVRCamera instanceof Ec){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 r,i;if(this._teleportationMode==e.TELEPORTATIONMODE_CONSTANTSPEED){i=90;var o=So.Distance(this.currentVRCamera.position,this._workingVector);r=this._teleportationSpeed/o}else i=Math.round(90*this._teleportationTime/1e3),r=1;this.currentVRCamera.animations=[];var a=new Ca("animationCameraTeleportation","position",90,Ca.ANIMATIONTYPE_VECTOR3,Ca.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 l=Math.round(i/2),c=new Ca("animationPP","vignetteWeight",90,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CONSTANT),u=[];u.push({frame:0,value:0}),u.push({frame:l,value:8}),u.push({frame:i,value:0}),c.setKeys(u),this._postProcessMove.animations.push(c);var d=new Ca("animationPP2","vignetteStretch",90,Ca.ANIMATIONTYPE_FLOAT,Ca.ANIMATIONLOOPMODE_CONSTANT),h=[];h.push({frame:0,value:0}),h.push({frame:l,value:10}),h.push({frame:i,value:0}),d.setKeys(h),this._postProcessMove.animations.push(d),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,i,!1,r,(function(){n._webVRCamera.detachPostProcess(n._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,i,!1,r,(function(){n.onAfterCameraTeleport.notifyObservers(n._workingVector)})),this._hideTeleportationTarget()}},e.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(So.Dot(e,t.direction))s){var l=s;s=a,a=l}return a>0&&a0&&s=0))},e.prototype._canDoCollision=function(e,t,n,r){var i=So.Distance(this._basePointWorld,e),o=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(i>this._velocityWorldLength+o+t)&&!!function(e,t,n,r){return!(e.x>n.x+r)&&(!(n.x-r>t.x)&&(!(e.y>n.y+r)&&(!(n.y-r>t.y)&&(!(e.z>n.z+r)&&!(n.z-r>t.z)))))}(n,r,this._basePointWorld,this._velocityWorldLength+o)},e.prototype._testTriangle=function(e,t,n,r,i,o,a){var s,l=!1;t||(t=[]),t[e]||(t[e]=new Cs(0,0,0,0),t[e].copyFromPoints(n,r,i));var c=t[e];if(o||c.isFrontFacingTo(this._normalizedVelocity,0)){var u=c.signedDistanceTo(this._basePoint),d=So.Dot(c.normal,this._velocity);if(0==d){if(Math.abs(u)>=1)return;l=!0,s=0}else{var h=(1-u)/d;if((s=(-1-u)/d)>h){var p=h;h=s,s=p}if(s>1||h<0)return;s<0&&(s=0),s>1&&(s=1)}this._collisionPoint.copyFromFloats(0,0,0);var f=!1,m=1;if(l||(this._basePoint.subtractToRef(c.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(s,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,r,i,c.normal)&&(f=!0,m=s,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!f){var g=this._velocity.lengthSquared(),b=g;this._basePoint.subtractToRef(n,this._tempVector);var v=2*So.Dot(this._velocity,this._tempVector),A=this._tempVector.lengthSquared()-1,_=Od(b,v,A,m);_.found&&(m=_.root,f=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(r,this._tempVector),v=2*So.Dot(this._velocity,this._tempVector),A=this._tempVector.lengthSquared()-1,(_=Od(b,v,A,m)).found&&(m=_.root,f=!0,this._collisionPoint.copyFrom(r)),this._basePoint.subtractToRef(i,this._tempVector),v=2*So.Dot(this._velocity,this._tempVector),A=this._tempVector.lengthSquared()-1,(_=Od(b,v,A,m)).found&&(m=_.root,f=!0,this._collisionPoint.copyFrom(i)),r.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex);var y=this._edge.lengthSquared(),x=So.Dot(this._edge,this._velocity),w=So.Dot(this._edge,this._baseToVertex);if(b=y*-g+x*x,v=y*(2*So.Dot(this._velocity,this._baseToVertex))-2*x*w,A=y*(1-this._baseToVertex.lengthSquared())+w*w,(_=Od(b,v,A,m)).found){var E=(x*_.root-w)/y;E>=0&&E<=1&&(m=_.root,f=!0,this._edge.scaleInPlace(E),n.addToRef(this._edge,this._collisionPoint))}i.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex),y=this._edge.lengthSquared(),x=So.Dot(this._edge,this._velocity),w=So.Dot(this._edge,this._baseToVertex),b=y*-g+x*x,v=y*(2*So.Dot(this._velocity,this._baseToVertex))-2*x*w,A=y*(1-this._baseToVertex.lengthSquared())+w*w,(_=Od(b,v,A,m)).found&&(E=(x*_.root-w)/y)>=0&&E<=1&&(m=_.root,f=!0,this._edge.scaleInPlace(E),r.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex),y=this._edge.lengthSquared(),x=So.Dot(this._edge,this._velocity),w=So.Dot(this._edge,this._baseToVertex),b=y*-g+x*x,v=y*(2*So.Dot(this._velocity,this._baseToVertex))-2*x*w,A=y*(1-this._baseToVertex.lengthSquared())+w*w,(_=Od(b,v,A,m)).found&&(E=(x*_.root-w)/y)>=0&&E<=1&&(m=_.root,f=!0,this._edge.scaleInPlace(E),i.addToRef(this._edge,this._collisionPoint))}if(f){var C=m*this._velocity.length();(!this.collisionFound||C=r)i.copyFrom(e);else{var s=o?o.collisionMask:n.collisionMask;n._initialize(e,t,a);for(var l=0;lthis.capacity&&this._depth-1&&this.entries.splice(n,1)}},e.prototype.addEntries=function(e){for(var t=0;t0)):!n._pointerCaptures[s.pointerId]&&o.distance>a.distance&&(n.mainSceneTrackerPredicate&&n.mainSceneTrackerPredicate(a.pickedMesh)?(n._notifyObservers(t,a,s),t.skipOnPointerObservable=!0):n._lastPointerEvents[s.pointerId]&&(n.onPointerOutObservable.notifyObservers(s.pointerId),delete n._lastPointerEvents[s.pointerId])),t.type===Qs.POINTERUP&&n._pointerCaptures[s.pointerId]&&(n._pointerCaptures[s.pointerId]=!1))}}}})),this._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterCameraRenderObservable.add((function(e){n.shouldRender&&e==n.getRenderCamera()&&n.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add((function(){n.dispose()})),this._updateCamera()}return e.prototype.getRenderCamera=function(e){if(this._renderCamera)return this._renderCamera;var t=void 0;return t=this.originalScene.activeCameras.length>1?this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:this.originalScene.activeCamera,e&&t&&t.isRigCamera?t.rigParent:t},e.prototype.setRenderCamera=function(e){this._renderCamera=e},e.prototype._getSharedGizmoLight=function(){return this._sharedGizmoLight||(this._sharedGizmoLight=new yu("shared gizmo light",new So(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=Io.Gray()),this._sharedGizmoLight},Object.defineProperty(e,"DefaultUtilityLayer",{get:function(){return null==e._DefaultUtilityLayer&&(e._DefaultUtilityLayer=new e(Zo.a.LastCreatedScene),e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultUtilityLayer=null}))),e._DefaultUtilityLayer},enumerable:!0,configurable:!0}),Object.defineProperty(e,"DefaultKeepDepthUtilityLayer",{get:function(){return null==e._DefaultKeepDepthUtilityLayer&&(e._DefaultKeepDepthUtilityLayer=new e(Zo.a.LastCreatedScene),e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultKeepDepthUtilityLayer=null}))),e._DefaultKeepDepthUtilityLayer},enumerable:!0,configurable:!0}),e.prototype._notifyObservers=function(e,t,n){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new Xs(e.type,e.event,t)),this._lastPointerEvents[n.pointerId]=!0)},e.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var e=this.utilityLayerScene.activeCamera.getScene(),t=this.utilityLayerScene.activeCamera;t._scene=this.utilityLayerScene,t.leftCamera&&(t.leftCamera._scene=this.utilityLayerScene),t.rightCamera&&(t.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),t._scene=e,t.leftCamera&&(t.leftCamera._scene=e),t.rightCamera&&(t.rightCamera._scene=e)}},e.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()},e.prototype._updateCamera=function(){this.utilityLayerScene.cameraToUseForPointers=this.getRenderCamera(),this.utilityLayerScene.activeCamera=this.getRenderCamera()},e._DefaultUtilityLayer=null,e._DefaultKeepDepthUtilityLayer=null,e}(),Nd=function(){function e(e){var t=this;void 0===e&&(e=Fd.DefaultUtilityLayer),this.gizmoLayer=e,this._attachedMesh=null,this.scaleRatio=1,this._customMeshSet=!1,this.updateGizmoRotationToMatchAttachedMesh=!0,this.updateGizmoPositionToMatchAttachedMesh=!0,this.updateScale=!0,this._interactionsEnabled=!0,this._tempVector=new So,this._rootMesh=new Pl("gizmoRootNode",e.utilityLayerScene),this._rootMesh.rotationQuaternion=Po.Identity(),this._beforeRenderObserver=this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add((function(){t._update()}))}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e,this._rootMesh.setEnabled(!!e),this._attachedMeshChanged(e)},enumerable:!0,configurable:!0}),e.prototype.setCustomMesh=function(e){if(e.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(e){e.dispose()})),e.parent=this._rootMesh,this._customMeshSet=!0},e.prototype._attachedMeshChanged=function(e){},e.prototype._update=function(){if(this.attachedMesh){var e=this.attachedMesh._effectiveMesh||this.attachedMesh;if(this.updateGizmoPositionToMatchAttachedMesh&&this._rootMesh.position.copyFrom(e.absolutePosition),this.updateGizmoRotationToMatchAttachedMesh?e.getWorldMatrix().decompose(void 0,this._rootMesh.rotationQuaternion):this._rootMesh.rotationQuaternion.set(0,0,0,1),this.updateScale){var t=this.gizmoLayer.utilityLayerScene.activeCamera,n=t.globalPosition;t.devicePosition&&(n=t.devicePosition),this._rootMesh.position.subtractToRef(n,this._tempVector);var r=this._tempVector.length()*this.scaleRatio;this._rootMesh.scaling.set(r,r,r),e._getWorldMatrixDeterminant()<0&&(this._rootMesh.scaling.y*=-1)}else this._rootMesh.scaling.setAll(this.scaleRatio)}},e.prototype.dispose=function(){this._rootMesh.dispose(),this._beforeRenderObserver&&this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},e}(),Ld=function(e){function t(n,r,i,o){void 0===r&&(r=Io.Gray()),void 0===i&&(i=Fd.DefaultUtilityLayer),void 0===o&&(o=null);var a=e.call(this,i)||this;a._pointerObserver=null,a.snapDistance=0,a.onSnapObservable=new yo.a,a._isEnabled=!0,a._parent=null,a._parent=o,a._coloredMaterial=new hd("",i.utilityLayerScene),a._coloredMaterial.diffuseColor=r,a._coloredMaterial.specularColor=r.subtract(new Io(.1,.1,.1)),a._hoverMaterial=new hd("",i.utilityLayerScene),a._hoverMaterial.diffuseColor=r.add(new Io(.3,.3,.3)),a._arrow=t._CreateArrow(i.utilityLayerScene,a._coloredMaterial),a._arrow.lookAt(a._rootMesh.position.add(n)),a._arrow.scaling.scaleInPlace(1/3),a._arrow.parent=a._rootMesh;var s=0,l=new So,c={snapDistance:0};a.dragBehavior=new Gl({dragAxis:n}),a.dragBehavior.moveAttached=!1,a._rootMesh.addBehavior(a.dragBehavior);var u=new So,d=new Oo;a.dragBehavior.onDragObservable.add((function(e){if(a.attachedMesh)if(a.attachedMesh.parent?(a.attachedMesh.parent.computeWorldMatrix().invertToRef(d),d.setTranslationFromFloats(0,0,0),So.TransformCoordinatesToRef(e.delta,d,u)):u.copyFrom(e.delta),0==a.snapDistance)a.attachedMesh.position.addInPlace(u);else if(s+=e.dragDistance,Math.abs(s)>a.snapDistance){var t=Math.floor(Math.abs(s)/a.snapDistance);s%=a.snapDistance,u.normalizeToRef(l),l.scaleInPlace(a.snapDistance*t),a.attachedMesh.position.addInPlace(l),c.snapDistance=a.snapDistance*t,a.onSnapObservable.notifyObservers(c)}})),a._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){if(!a._customMeshSet){var t=e.pickInfo&&-1!=a._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?a._hoverMaterial:a._coloredMaterial;a._rootMesh.getChildMeshes().forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))}}));var h=i._getSharedGizmoLight();return h.includedOnlyMeshes=h.includedOnlyMeshes.concat(a._rootMesh.getChildMeshes(!1)),a}return Object(No.d)(t,e),t._CreateArrow=function(e,t){var n=new as("arrow",e),r=_d.CreateCylinder("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375,tessellation:96},e),i=_d.CreateCylinder("cylinder",{diameterTop:.005,height:.275,diameterBottom:.005,tessellation:96},e);return i.material=t,r.parent=n,i.parent=n,r.material=t,r.rotation.x=Math.PI/2,r.position.z+=.3,i.position.z+=.1375,i.rotation.x=Math.PI/2,n},t._CreateArrowInstance=function(e,t){for(var n=new as("arrow",e),r=0,i=t.getChildMeshes();r0;)f.unshift(f.pop()),g.unshift(g.pop()),d--;for(;h>0;)m.unshift(m.pop()),b.unshift(b.pop()),h--;f=f.flat(),m=m.flat(),p=p.concat(f).concat(m),n.push(g[0],g[2],g[3],g[0],g[1],g[2]),n.push(b[0],b[2],b[3],b[0],b[1],b[2])}var v=[o/2,a/2,s/2];t=p.reduce((function(e,t,n){return e.concat(t*v[n%3])}),[]);for(var A=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,_=e.faceUV||new Array(6),y=e.faceColors,x=[],w=0;w<6;w++)void 0===_[w]&&(_[w]=new To(0,0,1,1)),y&&void 0===y[w]&&(y[w]=new ko(1,1,1,1));for(var E=0;E<6;E++)if(i.push(_[E].z,_[E].w),i.push(_[E].x,_[E].w),i.push(_[E].x,_[E].y),i.push(_[E].z,_[E].y),y)for(var C=0;C<4;C++)x.push(y[E].r,y[E].g,y[E].b,y[E].a);us._ComputeSides(A,t,n,r,i,e.frontUVs,e.backUVs);var S=new us;if(S.indices=n,S.positions=t,S.normals=r,S.uvs=i,y){var T=A===us.DOUBLESIDE?x.concat(x):x;S.colors=T}return S},Pl.CreateBox=function(e,t,n,r,i){void 0===n&&(n=null);var o={size:t,sideOrientation:i,updatable:r};return Vd.CreateBox(e,o,n)};var Vd=function(){function e(){}return e.CreateBox=function(e,t,n){void 0===n&&(n=null);var r=new Pl(e,n);return t.sideOrientation=Pl._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,us.CreateBox(t).applyToMesh(r,t.updatable),r},e}();us.CreateSphere=function(e){for(var t=e.segments||32,n=e.diameterX||e.diameter||1,r=e.diameterY||e.diameter||1,i=e.diameterZ||e.diameter||1,o=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,a=e.slice&&e.slice<=0?1:e.slice||1,s=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,l=new So(n/2,r/2,i/2),c=2+t,u=2*c,d=[],h=[],p=[],f=[],m=0;m<=c;m++){for(var g=m/c,b=g*Math.PI*a,v=0;v<=u;v++){var A=v/u,_=A*Math.PI*2*o,y=Oo.RotationZ(-b),x=Oo.RotationY(_),w=So.TransformCoordinates(So.Up(),y),E=So.TransformCoordinates(w,x),C=E.multiply(l),S=E.divide(l).normalize();h.push(C.x,C.y,C.z),p.push(S.x,S.y,S.z),f.push(A,g)}if(m>0)for(var T=h.length/3,P=T-2*(u+1);P+u+2100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=Po.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new Po),this._options.mass=void 0===n.mass?0:n.mass,this._options.friction=void 0===n.friction?.2:n.friction,this._options.restitution=void 0===n.restitution?.2:n.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=void 0===n.pressure?200:n.pressure,this._options.stiffness=void 0===n.stiffness?1:n.stiffness,this._options.velocityIterations=void 0===n.velocityIterations?20:n.velocityIterations,this._options.positionIterations=void 0===n.positionIterations?20:n.positionIterations,this._options.fixedPoints=void 0===n.fixedPoints?0:n.fixedPoints,this._options.margin=void 0===n.margin?0:n.margin,this._options.damping=void 0===n.damping?0:n.damping,this._options.path=void 0===n.path?null:n.path,this._options.shape=void 0===n.shape?null:n.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&jo.a.Warn("You must affect impostors to children before affecting impostor to parent.")):jo.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):jo.a.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mass",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(e){this.setMass(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"friction",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"restitution",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pressure",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.setBodyPressure?e.getBodyPressure(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPressure&&t.setBodyPressure(this,e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stiffness",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyStiffness?e.getBodyStiffness(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyStiffness&&t.setBodyStiffness(this,e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"velocityIterations",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyVelocityIterations?e.getBodyVelocityIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyVelocityIterations&&t.setBodyVelocityIterations(this,e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"positionIterations",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyPositionIterations?e.getBodyPositionIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPositionIterations&&t.setBodyPositionIterations(this,e)}},enumerable:!0,configurable:!0}),e.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))},e.prototype._getPhysicsParent=function(){return this.object.parent instanceof ws?this.object.parent.physicsImpostor:null},e.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&!this._parent},e.prototype.setScalingUpdated=function(){this.forceUpdate()},e.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(e.prototype,"physicsBody",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(e){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(e){this._parent=e},enumerable:!0,configurable:!0}),e.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},e.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion;this.object.rotationQuaternion=e.IDENTITY_QUATERNION,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);var n=this.object.getBoundingInfo().boundingBox.extendSizeWorld.scale(2);return this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),n}return e.DEFAULT_OBJECT_SIZE},e.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},e.prototype.getParam=function(e){return this._options[e]},e.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},e.prototype.setMass=function(e){this.getParam("mass")!==e&&this.setParam("mass",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},e.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):So.Zero()},e.prototype.setLinearVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},e.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):So.Zero()},e.prototype.setAngularVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},e.prototype.executeNativeFunction=function(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},e.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},e.prototype.unregisterBeforePhysicsStep=function(e){var t=this._onBeforePhysicsStepCallbacks.indexOf(e);t>-1?this._onBeforePhysicsStepCallbacks.splice(t,1):jo.a.Warn("Function to remove was not found")},e.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},e.prototype.unregisterAfterPhysicsStep=function(e){var t=this._onAfterPhysicsStepCallbacks.indexOf(e);t>-1?this._onAfterPhysicsStepCallbacks.splice(t,1):jo.a.Warn("Function to remove was not found")},e.prototype.registerOnPhysicsCollide=function(e,t){var n=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:n})},e.prototype.unregisterOnPhysicsCollide=function(e,t){var n=e instanceof Array?e:[e],r=-1;this._onPhysicsCollideCallbacks.some((function(e,i){if(e.callback===t&&e.otherImpostors.length===n.length){var o=e.otherImpostors.every((function(e){return n.indexOf(e)>-1}));return o&&(r=i),o}return!1}))?this._onPhysicsCollideCallbacks.splice(r,1):jo.a.Warn("Function to remove was not found")},e.prototype.getParentsRotation=function(){var e=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);e;)e.rotationQuaternion?this._tmpQuat2.copyFrom(e.rotationQuaternion):Po.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,e.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),e=e.parent;return this._tmpQuat},e.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},e.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},e.prototype.createJoint=function(e,t,n){var r=new jd(t,n);return this.addJoint(e,r),this},e.prototype.addJoint=function(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this},e.prototype.addAnchor=function(e,t,n,r,i){if(!this._physicsEngine)return this;var o=this._physicsEngine.getPhysicsPlugin();return o.appendAnchor?(this._physicsEngine&&o.appendAnchor(this,e,t,n,r,i),this):this},e.prototype.addHook=function(e,t,n,r){if(!this._physicsEngine)return this;var i=this._physicsEngine.getPhysicsPlugin();return i.appendAnchor?(this._physicsEngine&&i.appendHook(this,e,t,n,r),this):this},e.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},e.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},e.prototype.clone=function(t){return t?new e(t,this.type,this._options,this._scene):null},e.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine&&e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},e.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},e.prototype.setDeltaRotation=function(e){this._deltaRotation||(this._deltaRotation=new Po),this._deltaRotation.copyFrom(e),this._deltaRotationConjugated=this._deltaRotation.conjugate()},e.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},e.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},e.prototype.syncBoneWithImpostor=function(t,n,r,i,o){var a=e._tmpVecs[0],s=this.object;if(s.rotationQuaternion)if(o){var l=e._tmpQuat;s.rotationQuaternion.multiplyToRef(o,l),t.setRotationQuaternion(l,es.WORLD,n)}else t.setRotationQuaternion(s.rotationQuaternion,es.WORLD,n);a.x=0,a.y=0,a.z=0,r&&(a.x=r.x,a.y=r.y,a.z=r.z,t.getDirectionToRef(a,n,a),null==i&&(i=r.length()),a.x*=i,a.y*=i,a.z*=i),t.getParent()?(a.addInPlace(s.getAbsolutePosition()),t.setAbsolutePosition(a,n)):(n.setAbsolutePosition(s.getAbsolutePosition()),n.position.x-=a.x,n.position.y-=a.y,n.position.z-=a.z)},e.prototype.syncImpostorWithBone=function(t,n,r,i,o,a){var s=this.object;if(s.rotationQuaternion)if(o){var l=e._tmpQuat;t.getRotationQuaternionToRef(es.WORLD,n,l),l.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(es.WORLD,n,s.rotationQuaternion);var c=e._tmpVecs[0],u=e._tmpVecs[1];a||((a=e._tmpVecs[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,n,u),t.getAbsolutePositionToRef(n,c),null==i&&r&&(i=r.length()),null!=i&&(c.x+=u.x*i,c.y+=u.y*i,c.z+=u.z*i),s.setAbsolutePosition(c)},e.DEFAULT_OBJECT_SIZE=new So(1,1,1),e.IDENTITY_QUATERNION=Po.Identity(),e._tmpVecs=wo.BuildArray(3,So.Zero),e._tmpQuat=Po.Identity(),e.NoImpostor=0,e.SphereImpostor=1,e.BoxImpostor=2,e.PlaneImpostor=3,e.MeshImpostor=4,e.CapsuleImpostor=6,e.CylinderImpostor=7,e.ParticleImpostor=8,e.HeightmapImpostor=9,e.ConvexHullImpostor=10,e.CustomImpostor=100,e.RopeImpostor=101,e.ClothImpostor=102,e.SoftbodyImpostor=103,e}();!function(){function e(e){this._impostors=[],this._meshes=[],this._numMeshes=0,this._debugMeshMeshes=new Array,this._scene=e||Zo.a.LastCreatedScene;var t=this._scene.getPhysicsEngine();t&&(this._physicsEnginePlugin=t.getPhysicsPlugin()),this._utilityLayer=new Fd(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0}e.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t-1&&this._debugMeshMeshes.splice(o,1),this._numMeshes--,this._numMeshes>0?(this._meshes[r]=this._meshes[this._numMeshes],this._impostors[r]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)}},e.prototype._getDebugMaterial=function(e){return this._debugMaterial||(this._debugMaterial=new hd("",e),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=Io.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=Vd.CreateBox("physicsBodyBoxViewMesh",{size:1},e),this._debugBoxMesh.rotationQuaternion=Po.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(e),this._debugBoxMesh.setEnabled(!1)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugSphereMesh=function(e){return this._debugSphereMesh||(this._debugSphereMesh=zd.CreateSphere("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=Po.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(e),this._debugSphereMesh.setEnabled(!1)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugCylinderMesh=function(e){return this._debugCylinderMesh||(this._debugCylinderMesh=_d.CreateCylinder("physicsBodyCylinderViewMesh",{diameterTop:1,diameterBottom:1,height:1},e),this._debugCylinderMesh.rotationQuaternion=Po.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(e),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugMeshMesh=function(e,t){var n=new Pl(e.name,t,null,e);return n.position=So.Zero(),n.setParent(e),n.material=this._getDebugMaterial(t),this._debugMeshMeshes.push(n),n},e.prototype._getDebugMesh=function(e,t){var n=this;if(!this._utilityLayer)return null;if(t&&t.parent&&t.parent.physicsImpostor)return null;var r=null,i=this._utilityLayer.utilityLayerScene;switch(e.type){case Hd.BoxImpostor:r=this._getDebugBoxMesh(i),e.getBoxSizeToRef(r.scaling);break;case Hd.SphereImpostor:r=this._getDebugSphereMesh(i);var o=e.getRadius();r.scaling.x=2*o,r.scaling.y=2*o,r.scaling.z=2*o;break;case Hd.MeshImpostor:t&&(r=this._getDebugMeshMesh(t,i));break;case Hd.NoImpostor:if(t)t.getChildMeshes().filter((function(e){return e.physicsImpostor?1:0})).forEach((function(e){n._getDebugBoxMesh(i).parent=e}));break;case Hd.CylinderImpostor:r=this._getDebugCylinderMesh(i);var a=e.object.getBoundingInfo();r.scaling.x=a.boundingBox.maximum.x-a.boundingBox.minimum.x,r.scaling.y=a.boundingBox.maximum.y-a.boundingBox.minimum.y,r.scaling.z=a.boundingBox.maximum.z-a.boundingBox.minimum.z}return r},e.prototype.dispose=function(){for(var e=this._numMeshes,t=0;t0!=this._getWorldMatrixDeterminant()>0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),t){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1},t.prototype._postActivate=function(){this._edgesRenderer&&this._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup&&this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)},t.prototype.getWorldMatrix=function(){if(this._currentLOD&&this._currentLOD.billboardMode!==as.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){var t=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,Mo.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),Mo.Matrix[0].copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(Mo.Vector3[7]),this._currentLOD._masterMesh=t,Mo.Matrix[0]}return e.prototype.getWorldMatrix.call(this)},Object.defineProperty(t.prototype,"isAnInstance",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.getLOD=function(e){if(!e)return this;var t=this.getBoundingInfo();return this._currentLOD=this.sourceMesh.getLOD(e,t.boundingSphere),this._currentLOD===this.sourceMesh?this.sourceMesh:this._currentLOD},t.prototype._preActivateForIntermediateRendering=function(e){return this.sourceMesh._preActivateForIntermediateRendering(e)},t.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e1&&(this._multiview=!0,i.push("#define MULTIVIEW"),-1!==this._options.uniforms.indexOf("viewProjection")&&-1===this._options.uniforms.push("viewProjectionR")&&this._options.uniforms.push("viewProjectionR"));for(var s=0;s4&&(o.push(cs.MatricesIndicesExtraKind),o.push(cs.MatricesWeightsExtraKind));var l=e.skeleton;i.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),a.addCPUSkinningFallback(0,e),l.isUsingTextureForMatrices?(i.push("#define BONETEXTURE"),-1===this._options.uniforms.indexOf("boneTextureWidth")&&this._options.uniforms.push("boneTextureWidth"),-1===this._options.samplers.indexOf("boneSampler")&&this._options.samplers.push("boneSampler")):(i.push("#define BonesPerMesh "+(l.bones.length+1)),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones"))}else i.push("#define NUM_BONE_INFLUENCERS 0");for(var c in this._textures)if(!this._textures[c].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&i.push("#define ALPHATEST");var u=this._effect,d=i.join("\n");return this._effect=r.createEffect(this._shaderPath,{attributes:o,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:d,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},r),!!this._effect.isReady()&&(u!==this._effect&&n.resetCachedMaterial(),this._renderId=n.getRenderId(),this._effect._wasPreviouslyReady=!0,!0)},t.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();this._effect&&(-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&(e.multiplyToRef(t.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),this._effect.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)))},t.prototype.bind=function(e,t){if(this.bindOnlyWorldMatrix(e),this._effect&&this.getScene().getCachedMaterial()!==this){var n;for(n in-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&(this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._multiview&&this._effect.setMatrix("viewProjectionR",this.getScene()._transformMatrixR)),this.getScene().activeCamera&&-1!==this._options.uniforms.indexOf("cameraPosition")&&this._effect.setVector3("cameraPosition",this.getScene().activeCamera.globalPosition),Cu.BindBonesParameters(t,this._effect),this._textures)this._effect.setTexture(n,this._textures[n]);for(n in this._textureArrays)this._effect.setTextureArray(n,this._textureArrays[n]);for(n in this._ints)this._effect.setInt(n,this._ints[n]);for(n in this._floats)this._effect.setFloat(n,this._floats[n]);for(n in this._floatsArrays)this._effect.setArray(n,this._floatsArrays[n]);for(n in this._colors3)this._effect.setColor3(n,this._colors3[n]);for(n in this._colors3Arrays)this._effect.setArray3(n,this._colors3Arrays[n]);for(n in this._colors4){var r=this._colors4[n];this._effect.setFloat4(n,r.r,r.g,r.b,r.a)}for(n in this._colors4Arrays)this._effect.setArray4(n,this._colors4Arrays[n]);for(n in this._vectors2)this._effect.setVector2(n,this._vectors2[n]);for(n in this._vectors3)this._effect.setVector3(n,this._vectors3[n]);for(n in this._vectors4)this._effect.setVector4(n,this._vectors4[n]);for(n in this._matrices)this._effect.setMatrix(n,this._matrices[n]);for(n in this._matrixArrays)this._effect.setMatrices(n,this._matrixArrays[n]);for(n in this._matrices3x3)this._effect.setMatrix3x3(n,this._matrices3x3[n]);for(n in this._matrices2x2)this._effect.setMatrix2x2(n,this._matrices2x2[n]);for(n in this._vectors2Arrays)this._effect.setArray2(n,this._vectors2Arrays[n]);for(n in this._vectors3Arrays)this._effect.setArray3(n,this._vectors3Arrays[n]);for(n in this._vectors4Arrays)this._effect.setArray4(n,this._vectors4Arrays[n])}this._afterBind(t)},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);for(var n in this._textures)t.push(this._textures[n]);for(var n in this._textureArrays)for(var r=this._textureArrays[n],i=0;i0&&(t.push(a-1),t.push(a)),a++}var d=new us;return d.indices=t,d.positions=n,i&&(d.colors=o),d},us.CreateDashedLines=function(e){var t,n,r=e.dashSize||3,i=e.gapSize||1,o=e.dashNb||200,a=e.points,s=new Array,l=new Array,c=So.Zero(),u=0,d=0,h=0,p=0,f=0;for(f=0;f=0;a--){var s=e[a],l=s.getParent();if(l){var c=this._debugLines[r];c||(c=[So.Zero(),So.Zero()],this._debugLines[r]=c),s.getAbsolutePositionToRef(i,c[0]),l.getAbsolutePositionToRef(i,c[1]),c[0].subtractInPlace(o),c[1].subtractInPlace(o),r++}}},e.prototype.update=function(){if(this._utilityLayer){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();var e=this.mesh._effectiveMesh;void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,e.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,e.getWorldMatrix());var t=this._utilityLayer.utilityLayerScene;this._debugMesh?Zd.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},t):(this._debugMesh=Zd.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:null},t),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color}},e.prototype.dispose=function(){this.isEnabled=!1,this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null),this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null)}}(),function(){function e(){}e.ALPHA_DISABLE=0,e.ALPHA_ADD=1,e.ALPHA_COMBINE=2,e.ALPHA_SUBTRACT=3,e.ALPHA_MULTIPLY=4,e.ALPHA_MAXIMIZED=5,e.ALPHA_ONEONE=6,e.ALPHA_PREMULTIPLIED=7,e.ALPHA_PREMULTIPLIED_PORTERDUFF=8,e.ALPHA_INTERPOLATE=9,e.ALPHA_SCREENMODE=10,e.ALPHA_ONEONE_ONEONE=11,e.ALPHA_ALPHATOCOLOR=12,e.ALPHA_REVERSEONEMINUS=13,e.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,e.ALPHA_ONEONE_ONEZERO=15,e.ALPHA_EXCLUSION=16,e.ALPHA_EQUATION_ADD=0,e.ALPHA_EQUATION_SUBSTRACT=1,e.ALPHA_EQUATION_REVERSE_SUBTRACT=2,e.ALPHA_EQUATION_MAX=3,e.ALPHA_EQUATION_MIN=4,e.ALPHA_EQUATION_DARKEN=5,e.DELAYLOADSTATE_NONE=0,e.DELAYLOADSTATE_LOADED=1,e.DELAYLOADSTATE_LOADING=2,e.DELAYLOADSTATE_NOTLOADED=4,e.NEVER=512,e.ALWAYS=519,e.LESS=513,e.EQUAL=514,e.LEQUAL=515,e.GREATER=516,e.GEQUAL=518,e.NOTEQUAL=517,e.KEEP=7680,e.REPLACE=7681,e.INCR=7682,e.DECR=7683,e.INVERT=5386,e.INCR_WRAP=34055,e.DECR_WRAP=34056,e.TEXTURE_CLAMP_ADDRESSMODE=0,e.TEXTURE_WRAP_ADDRESSMODE=1,e.TEXTURE_MIRROR_ADDRESSMODE=2,e.TEXTUREFORMAT_ALPHA=0,e.TEXTUREFORMAT_LUMINANCE=1,e.TEXTUREFORMAT_LUMINANCE_ALPHA=2,e.TEXTUREFORMAT_RGB=4,e.TEXTUREFORMAT_RGBA=5,e.TEXTUREFORMAT_RED=6,e.TEXTUREFORMAT_R=6,e.TEXTUREFORMAT_RG=7,e.TEXTUREFORMAT_RED_INTEGER=8,e.TEXTUREFORMAT_R_INTEGER=8,e.TEXTUREFORMAT_RG_INTEGER=9,e.TEXTUREFORMAT_RGB_INTEGER=10,e.TEXTUREFORMAT_RGBA_INTEGER=11,e.TEXTURETYPE_UNSIGNED_BYTE=0,e.TEXTURETYPE_UNSIGNED_INT=0,e.TEXTURETYPE_FLOAT=1,e.TEXTURETYPE_HALF_FLOAT=2,e.TEXTURETYPE_BYTE=3,e.TEXTURETYPE_SHORT=4,e.TEXTURETYPE_UNSIGNED_SHORT=5,e.TEXTURETYPE_INT=6,e.TEXTURETYPE_UNSIGNED_INTEGER=7,e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,e.TEXTURETYPE_UNSIGNED_INT_24_8=12,e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,e.TEXTURE_NEAREST_SAMPLINGMODE=1,e.TEXTURE_NEAREST_NEAREST=1,e.TEXTURE_BILINEAR_SAMPLINGMODE=2,e.TEXTURE_LINEAR_LINEAR=2,e.TEXTURE_TRILINEAR_SAMPLINGMODE=3,e.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,e.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,e.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,e.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,e.TEXTURE_NEAREST_LINEAR=7,e.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,e.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,e.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,e.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,e.TEXTURE_LINEAR_NEAREST=12,e.TEXTURE_EXPLICIT_MODE=0,e.TEXTURE_SPHERICAL_MODE=1,e.TEXTURE_PLANAR_MODE=2,e.TEXTURE_CUBIC_MODE=3,e.TEXTURE_PROJECTION_MODE=4,e.TEXTURE_SKYBOX_MODE=5,e.TEXTURE_INVCUBIC_MODE=6,e.TEXTURE_EQUIRECTANGULAR_MODE=7,e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,e.SCALEMODE_FLOOR=1,e.SCALEMODE_NEAREST=2,e.SCALEMODE_CEILING=3,e.MATERIAL_TextureDirtyFlag=1,e.MATERIAL_LightDirtyFlag=2,e.MATERIAL_FresnelDirtyFlag=4,e.MATERIAL_AttributesDirtyFlag=8,e.MATERIAL_MiscDirtyFlag=16,e.MATERIAL_AllDirtyFlag=31,e.MATERIAL_TriangleFillMode=0,e.MATERIAL_WireFrameFillMode=1,e.MATERIAL_PointFillMode=2,e.MATERIAL_PointListDrawMode=3,e.MATERIAL_LineListDrawMode=4,e.MATERIAL_LineLoopDrawMode=5,e.MATERIAL_LineStripDrawMode=6,e.MATERIAL_TriangleStripDrawMode=7,e.MATERIAL_TriangleFanDrawMode=8,e.MATERIAL_ClockWiseSideOrientation=0,e.MATERIAL_CounterClockWiseSideOrientation=1,e.ACTION_NothingTrigger=0,e.ACTION_OnPickTrigger=1,e.ACTION_OnLeftPickTrigger=2,e.ACTION_OnRightPickTrigger=3,e.ACTION_OnCenterPickTrigger=4,e.ACTION_OnPickDownTrigger=5,e.ACTION_OnDoublePickTrigger=6,e.ACTION_OnPickUpTrigger=7,e.ACTION_OnPickOutTrigger=16,e.ACTION_OnLongPressTrigger=8,e.ACTION_OnPointerOverTrigger=9,e.ACTION_OnPointerOutTrigger=10,e.ACTION_OnEveryFrameTrigger=11,e.ACTION_OnIntersectionEnterTrigger=12,e.ACTION_OnIntersectionExitTrigger=13,e.ACTION_OnKeyDownTrigger=14,e.ACTION_OnKeyUpTrigger=15,e.PARTICLES_BILLBOARDMODE_Y=2,e.PARTICLES_BILLBOARDMODE_ALL=7,e.PARTICLES_BILLBOARDMODE_STRETCHED=8,e.MESHES_CULLINGSTRATEGY_STANDARD=0,e.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,e.SCENELOADER_NO_LOGGING=0,e.SCENELOADER_MINIMAL_LOGGING=1,e.SCENELOADER_SUMMARY_LOGGING=2,e.SCENELOADER_DETAILED_LOGGING=3}(),n(134),function(){this._timeElapsedQueryEnded=!1}),$d=function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=ws.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=ws.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE};ss.a.prototype.createQuery=function(){return this._gl.createQuery()},ss.a.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},ss.a.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},ss.a.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},ss.a.prototype.beginOcclusionQuery=function(e,t){var n=this._getGlAlgorithmType(e);return this._gl.beginQuery(n,t),this},ss.a.prototype.endOcclusionQuery=function(e){var t=this._getGlAlgorithmType(e);return this._gl.endQuery(t),this},ss.a.prototype._createTimeQuery=function(){var e=this.getCaps().timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},ss.a.prototype._deleteTimeQuery=function(e){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(e):this.deleteQuery(e)},ss.a.prototype._getTimeQueryResult=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},ss.a.prototype._getTimeQueryAvailability=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},ss.a.prototype.startTimeQuery=function(){var e=this.getCaps(),t=e.timerQuery;if(!t)return null;var n=new Jd;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),e.canUseTimestampForTimerQuery)n._startTimeQuery=this._createTimeQuery(),t.queryCounterEXT(n._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;n._timeElapsedQuery=this._createTimeQuery(),t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,n._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,n._timeElapsedQuery),this._currentNonTimestampToken=n}return n},ss.a.prototype.endTimeQuery=function(e){var t=this.getCaps(),n=t.timerQuery;if(!n||!e)return-1;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery)return-1;e._endTimeQuery||(e._endTimeQuery=this._createTimeQuery(),n.queryCounterEXT(e._endTimeQuery,n.TIMESTAMP_EXT))}else if(!e._timeElapsedQueryEnded){if(!e._timeElapsedQuery)return-1;n.endQueryEXT?n.endQueryEXT(n.TIME_ELAPSED_EXT):this._gl.endQuery(n.TIME_ELAPSED_EXT),e._timeElapsedQueryEnded=!0}var r=this._gl.getParameter(n.GPU_DISJOINT_EXT),i=!1;if(e._endTimeQuery?i=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(i=this._getTimeQueryAvailability(e._timeElapsedQuery)),i&&!r){var o=0;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var a=this._getTimeQueryResult(e._startTimeQuery);o=this._getTimeQueryResult(e._endTimeQuery)-a,this._deleteTimeQuery(e._startTimeQuery),this._deleteTimeQuery(e._endTimeQuery),e._startTimeQuery=null,e._endTimeQuery=null}else{if(!e._timeElapsedQuery)return-1;o=this._getTimeQueryResult(e._timeElapsedQuery),this._deleteTimeQuery(e._timeElapsedQuery),e._timeElapsedQuery=null,e._timeElapsedQueryEnded=!1,this._currentNonTimestampToken=null}return o}return-1},ss.a.prototype._getGlAlgorithmType=function(e){return e===ws.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(ws.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},set:function(e){this._occlusionDataStorage.isOcclusionQueryInProgress=e},enumerable:!1,configurable:!0}),Object.defineProperty(ws.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new $d),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(ws.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(e){this._occlusionDataStorage.isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(ws.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(e){this._occlusionDataStorage.occlusionQueryAlgorithmType=e},enumerable:!0,configurable:!0}),Object.defineProperty(ws.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(e){this._occlusionDataStorage.occlusionType=e},enumerable:!0,configurable:!0}),Object.defineProperty(ws.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(e){this._occlusionDataStorage.occlusionRetryCount=e},enumerable:!0,configurable:!0}),ws.prototype._checkOcclusionQuery=function(){var e=this._occlusionDataStorage;if(e.occlusionType===ws.OCCLUSION_TYPE_NONE)return e.isOccluded=!1,!1;var t=this.getEngine();if(t.webGLVersion<2)return e.isOccluded=!1,!1;if(!t.isQueryResultAvailable)return e.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery)if(t.isQueryResultAvailable(this._occlusionQuery)){var n=t.getQueryResult(this._occlusionQuery);e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=1!==n}else{if(e.occlusionInternalRetryCounter++,!(-1!==e.occlusionRetryCount&&e.occlusionInternalRetryCounter>e.occlusionRetryCount))return!1;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==ws.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var r=this.getScene();if(r.getBoundingBoxRenderer){var i=r.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery),i.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}return e.isOccluded};ss.a.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},ss.a.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},ss.a.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},ss.a.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},ss.a.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},ss.a.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},ss.a.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e?e.underlyingResource:null)};ss.a.prototype.getInputElement=function(){return this.inputElement||this.getRenderingCanvas()},ss.a.prototype.registerView=function(e,t){var n=this;this.views||(this.views=[]);for(var r=0,i=this.views;r17)throw new Error("Exceeded maximum custom attributes");var i=bh[n];if(void 0===i)throw new Error("Can't find bgfx name mapping");return t=t.replace(n,i),this._replacements.push({searchValue:new RegExp("\\b"+n+"\\b","g"),replaceValue:""+i}),"layout(location="+r+") "+e.prototype.attributeProcessor.call(this,t)},t.prototype.varyingProcessor=function(t,n){var r;return n?r=this._varyingLocationMap[t]:(r=this._varyingLocationCount++,this._varyingLocationMap[t]=r),"layout(location="+r+") "+e.prototype.varyingProcessor.call(this,t,n)},t.prototype.uniformProcessor=function(e){var t=e.match(/uniform\s+([^\s]+)\s+([^\s]+)\s*(?:\[.+\])?\s*;/),n=t[1],r=t[2];switch(n){case"sampler2D":case"samplerCube":var i=n.substr(7),o=this._textureCount++;return this._replacements.push({searchValue:new RegExp("\\b"+r+"\\b"),replaceValue:"sampler"+i+"("+r+"Texture, "+r+")"}),"layout(binding="+o+") uniform texture"+i+" "+r+"Texture;\nlayout(binding="+o+") uniform sampler "+r+";";case"float":this._replacements.push({searchValue:new RegExp("\\b"+r+"\\b"),replaceValue:r+".x"}),e="uniform vec4 "+r+";";break;case"vec2":this._replacements.push({searchValue:new RegExp("\\b"+r+"\\b"),replaceValue:r+".xy"}),e="uniform vec4 "+r+";";break;case"vec3":this._replacements.push({searchValue:new RegExp("\\b"+r+"\\b"),replaceValue:r+".xyz"}),e="uniform vec4 "+r+";"}return this._uniforms.push(e),1===this._uniforms.length?"":""},t.prototype.preProcessor=function(e,t,n){return this._genericAttributeLocation=10,n||(this._varyingLocationCount=0,this._varyingLocationMap={}),this._replacements=[],this._textureCount=0,this._uniforms=[],e},t.prototype.postProcessor=function(t,n,r){return t=(t=(t=e.prototype.postProcessor.call(this,t,n,r)).replace("","layout(binding=0) uniform Frame {\n"+this._uniforms.join("\n")+"\n};")).replace("out vec4 glFragColor","layout(location=0) out vec4 glFragColor")},t}(eh.a),Ah=function(){function e(){this.isAsync=!1,this.isReady=!1}return e.prototype._handlesSpectorRebuildCallback=function(e){throw new Error("Not implemented")},e}(),_h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t}(th.a),yh=function(){function e(){}return e.POINT=0,e.MINPOINT_MAGPOINT_MIPPOINT=e.POINT,e.BILINEAR=1,e.MINLINEAR_MAGLINEAR_MIPPOINT=e.BILINEAR,e.TRILINEAR=2,e.MINLINEAR_MAGLINEAR_MIPLINEAR=e.TRILINEAR,e.ANISOTROPIC=3,e.POINT_COMPARE=4,e.TRILINEAR_COMPARE=5,e.MINBILINEAR_MAGPOINT=6,e.MINLINEAR_MAGPOINT_MIPLINEAR=e.MINBILINEAR_MAGPOINT,e.MINPOINT_MAGPOINT_MIPLINEAR=7,e.MINPOINT_MAGLINEAR_MIPPOINT=8,e.MINPOINT_MAGLINEAR_MIPLINEAR=9,e.MINLINEAR_MAGPOINT_MIPPOINT=10,e}(),xh=function(){function e(){}return e.CLEAR_COLOR=1,e.CLEAR_DEPTH=2,e.CLEAR_STENCIL=4,e}(),wh=function(){function e(){}return e.WRAP=0,e.MIRROR=1,e.CLAMP=2,e.BORDER=3,e.MIRROR_ONCE=4,e}(),Eh=function(){function e(){}return e.RGBA8=0,e.RGBA32F=1,e}(),Ch=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getInternalTexture=function(){return this},t.prototype.getViewCount=function(){return 1},t}(Kl.a),Sh=(function(e){function t(){var t=e.call(this,null)||this;return t._native=new _native.Engine,t.INVALID_HANDLE=65535,t._webGLVersion=2,t.disableUniformBuffers=!0,t._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,maxAnisotropy:16,uintIndices:!1,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},Ja.Log("Babylon Native (v"+ss.a.Version+") launched"),"undefined"==typeof URL&&(window.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(window.Blob=function(){}),t._shaderProcessor=new vh,t}Object(No.d)(t,e),t.prototype.getHardwareScalingLevel=function(){return 1},t.prototype._queueNewFrame=function(e,t){return t.requestAnimationFrame?t.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,t,n,r){void 0===r&&(r=!1);var i=0;t&&e&&(this._native.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),i|=xh.CLEAR_COLOR),n&&(this._native.clearDepth(1),i|=xh.CLEAR_DEPTH),r&&(this._native.clearStencil(0),i|=xh.CLEAR_STENCIL),this._native.clear(i)},t.prototype.createIndexBuffer=function(e){var t=this._normalizeIndexData(e),n=new _h;if(n.references=1,n.is32Bits=4===t.BYTES_PER_ELEMENT,n.nativeIndexBuffer=this._native.createIndexBuffer(t),n.nativeVertexBuffer===this.INVALID_HANDLE)throw new Error("Could not create a native index buffer.");return n},t.prototype.createVertexBuffer=function(e){var t=new _h;if(t.references=1,t.nativeVertexBuffer=this._native.createVertexBuffer(ArrayBuffer.isView(e)?e:new Float32Array(e)),t.nativeVertexBuffer===this.INVALID_HANDLE)throw new Error("Could not create a native vertex buffer.");return t},t.prototype.recordVertexArrayObject=function(e,t,n){var r=this._native.createVertexArray();t&&this._native.recordIndexBuffer(r,t.nativeIndexBuffer);for(var i=n.getAttributesNames(),o=0;o=0){var s=e[i[o]];if(s){var l=s.getBuffer();l&&this._native.recordVertexBuffer(r,l.nativeVertexBuffer,a,s.byteOffset,s.byteStride,s.getSize(),s.type,s.normalized)}}}return r},t.prototype.bindVertexArrayObject=function(e){this._native.bindVertexArray(e)},t.prototype.releaseVertexArrayObject=function(e){this._native.deleteVertexArray(e)},t.prototype.getAttributes=function(e,t){var n=e;return this._native.getAttributes(n.nativeProgram,t)},t.prototype.drawElementsType=function(e,t,n,r){this._drawCalls.addCount(1,!1),this._native.drawIndexed(e,t,n)},t.prototype.drawArraysType=function(e,t,n,r){this._drawCalls.addCount(1,!1),this._native.draw(e,t,n)},t.prototype.createPipelineContext=function(){return new Ah},t.prototype._preparePipelineContext=function(e,t,n,r,i,o,a){var s=e;s.nativeProgram=r?this.createRawShaderProgram(e,t,n,void 0,a):this.createShaderProgram(e,t,n,o,void 0,a)},t.prototype._isRenderingStateCompiled=function(e){return!0},t.prototype._executeWhenRenderingStateIsCompiled=function(e,t){t()},t.prototype.createRawShaderProgram=function(e,t,n,r,i){throw void 0===i&&(i=null),new Error("Not Supported")},t.prototype.createShaderProgram=function(e,t,n,r,i,o){void 0===o&&(o=null),this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=this._native.createProgram(Va.a._ConcatenateShader(t,r),Va.a._ConcatenateShader(n,r));return this.onAfterShaderCompilationObservable.notifyObservers(this),a},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,t){var n=e;return this._native.getUniforms(n.nativeProgram,t)},t.prototype.bindUniformBlock=function(e,t,n){throw new Error("Not Implemented")},t.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.nativeProgram);for(var n=e.getSamplers(),r=0;r-1?p.substring(b).toLowerCase():""),A=null,_=0,y=ss.a._TextureLoaders;_-1?e.substring(f).toLowerCase():""))){if(n&&6===n.length)throw new Error("Multi-file loading not allowed on env files.");this._loadFile(e,(function(e){return function(e){var t=fh.GetEnvInfo(e);if(p.width=t.width,p.height=t.width,fh.UploadEnvSpherical(p,t),1!==t.version)throw new Error('Unsupported babylon environment map version "'+t.version+'"');var n=t.specular;if(!n)throw new Error("Nothing else parsed so far");p._lodGenerationScale=n.lodGenerationScale;var r=fh.CreateImageDataArrayBufferViews(e,t);if(p.format=5,p.type=0,p.generateMipMaps=!0,p.getEngine().updateTextureSamplingMode(Wl.TRILINEAR_SAMPLINGMODE,p),p._isRGBD=!0,p.invertY=!0,!h._native.loadEnvTexture(p._webGLTexture,r))throw new Error("Could not load a native cube texture.");p.isReady=!0,i&&i()}(new Uint8Array(e))}),void 0,void 0,!0,(function(e,t){o&&e&&o(e.status+" "+e.statusText,t)}))}else{if(!n||6!==n.length)throw new Error("Cannot load cubemap because 6 files were not defined");var m=[n[0],n[3],n[1],n[4],n[2],n[5]];Promise.all(m.map((function(e){return Ja.LoadFileAsync(e).then((function(e){return new Uint8Array(e)}))}))).then((function(e){h._native.loadCubeTexture(p._webGLTexture,e,!r)})).then((function(){p.isReady=!0,i&&i()}),(function(e){o&&o("Failed to load cubemap: "+e.message,e)}))}return this._internalTexturesCache.push(p),p},t.prototype._getSamplingFilter=function(e){switch(e){case 2:return yh.MINLINEAR_MAGLINEAR_MIPPOINT;case 3:return yh.MINLINEAR_MAGLINEAR_MIPLINEAR;case 1:return yh.MINPOINT_MAGPOINT_MIPLINEAR;case 4:return yh.MINPOINT_MAGPOINT_MIPPOINT;case 5:return yh.MINLINEAR_MAGPOINT_MIPPOINT;case 6:case 7:return yh.MINLINEAR_MAGPOINT_MIPLINEAR;case 1:return yh.MINPOINT_MAGPOINT_MIPPOINT;case 9:return yh.MINPOINT_MAGLINEAR_MIPPOINT;case 10:return yh.MINPOINT_MAGLINEAR_MIPLINEAR;case 2:return yh.MINLINEAR_MAGLINEAR_MIPLINEAR;case 12:return yh.MINPOINT_MAGLINEAR_MIPLINEAR;default:throw new Error("Unexpected sampling mode: "+e+".")}},t._GetNativeTextureFormat=function(e,t){if(5==e&&0==t)return Eh.RGBA8;if(5==e&&1==t)return Eh.RGBA32F;throw new Error("Unexpected texture format or type: format "+e+", type "+t+".")},t.prototype.createRenderTargetTexture=function(e,n){var r=new Kc.a;void 0!==n&&"object"==typeof n?(r.generateMipMaps=n.generateMipMaps,r.generateDepthBuffer=void 0===n.generateDepthBuffer||n.generateDepthBuffer,r.generateStencilBuffer=r.generateDepthBuffer&&n.generateStencilBuffer,r.type=void 0===n.type?0:n.type,r.samplingMode=void 0===n.samplingMode?3:n.samplingMode,r.format=void 0===n.format?5:n.format):(r.generateMipMaps=n,r.generateDepthBuffer=!0,r.generateStencilBuffer=!1,r.type=0,r.samplingMode=3,r.format=5),(1!==r.type||this._caps.textureFloatLinearFiltering)&&(2!==r.type||this._caps.textureHalfFloatLinearFiltering)||(r.samplingMode=1);var i=new Ch(this,Kl.b.RenderTarget),o=e.width||e,a=e.height||e;1!==r.type||this._caps.textureFloat||(r.type=0,jo.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var s=this._native.createFramebuffer(i._webGLTexture,o,a,t._GetNativeTextureFormat(r.format,r.type),r.samplingMode,!!r.generateStencilBuffer,r.generateDepthBuffer,!!r.generateMipMaps);return i._framebuffer=s,i.baseWidth=o,i.baseHeight=a,i.width=o,i.height=a,i.isReady=!0,i.samples=1,i.generateMipMaps=!!r.generateMipMaps,i.samplingMode=r.samplingMode,i.type=r.type,i.format=r.format,i._generateDepthBuffer=r.generateDepthBuffer,i._generateStencilBuffer=!!r.generateStencilBuffer,this._internalTexturesCache.push(i),i},t.prototype.updateTextureSamplingMode=function(e,t){if(t._webGLTexture){var n=this._getSamplingFilter(e);this._native.setTextureSampling(t._webGLTexture,n)}t.samplingMode=e},t.prototype.bindFramebuffer=function(e,t,n,r,i){if(t)throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");if(n||r)throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");if(i)throw new Error("forceFullscreenViewport for frame buffers not yet supported in NativeEngine.");this._bindUnboundFramebuffer(e._framebuffer)},t.prototype.unBindFramebuffer=function(e,t,n){void 0===t&&(t=!1),t&&jo.a.Warn("Disabling mipmap generation not yet supported in NativeEngine. Ignoring."),n&&n(),this._bindUnboundFramebuffer(null)},t.prototype.createDynamicVertexBuffer=function(e){throw new Error("createDynamicVertexBuffer not yet implemented.")},t.prototype.updateDynamicIndexBuffer=function(e,t,n){throw void 0===n&&(n=0),new Error("updateDynamicIndexBuffer not yet implemented.")},t.prototype.updateDynamicVertexBuffer=function(e,t,n,r){throw new Error("updateDynamicVertexBuffer not yet implemented.")},t.prototype._setTexture=function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var i,o=this._boundUniforms[e];if(!o)return!1;if(!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._native.setTexture(o,null)),!1;if(t.video)this._activeChannel=e,t.update();else if(4===t.delayLoadState)return t.delayLoad(),!1;return i=r?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,this._activeChannel=e,!(!i||!i._webGLTexture)&&(this._native.setTextureWrapMode(i._webGLTexture,this._getAddressMode(t.wrapU),this._getAddressMode(t.wrapV),this._getAddressMode(t.wrapR)),this._updateAnisotropicLevel(t),this._native.setTexture(o,i._webGLTexture),!0)},t.prototype._updateAnisotropicLevel=function(e){var t=e.getInternalTexture(),n=e.anisotropicFilteringLevel;t&&t._webGLTexture&&t._cachedAnisotropicFilteringLevel!==n&&(this._native.setTextureAnisotropicLevel(t._webGLTexture,n),t._cachedAnisotropicFilteringLevel=n)},t.prototype._getAddressMode=function(e){switch(e){case 1:return wh.WRAP;case 0:return wh.CLAMP;case 2:return wh.MIRROR;default:throw new Error("Unexpected wrap mode: "+e+".")}},t.prototype._bindTexture=function(e,t){throw new Error("_bindTexture not implemented.")},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,t,n,r,i,o,a){throw void 0===o&&(o=0),void 0===a&&(a=0),new Error("_uploadCompressedDataToTextureDirectly not implemented.")},t.prototype._uploadDataToTextureDirectly=function(e,t,n,r){throw void 0===n&&(n=0),void 0===r&&(r=0),new Error("_uploadDataToTextureDirectly not implemented.")},t.prototype._uploadArrayBufferViewToTexture=function(e,t,n,r){throw void 0===n&&(n=0),void 0===r&&(r=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._uploadImageToTexture=function(e,t,n,r){throw void 0===n&&(n=0),void 0===r&&(r=0),new Error("_uploadArrayBufferViewToTexture not implemented.")}}(ss.a),function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}()),Th=(function(){function e(e,t){this.type=e,this.event=t}e.GetTypeFromCharacter=function(e){switch(e){case 67:return Sh.COPY;case 86:return Sh.PASTE;case 88:return Sh.CUT;default:return-1}}}(),function(){function e(e,t,n){this.lengthComputable=e,this.loaded=t,this.total=n}return e.FromProgressEvent=function(t){return new e(t.lengthComputable,t.loaded,t.total)},e}());!function(e){e[e.Clean=0]="Clean",e[e.Stop=1]="Stop",e[e.Sync=2]="Sync",e[e.NoSync=3]="NoSync"}(mh||(mh={}));var Ph=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return Al.ForceFullSceneLoadingForIncremental},set:function(e){Al.ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return Al.ShowLoadingScreen},set:function(e){Al.ShowLoadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return Al.loggingLevel},set:function(e){Al.loggingLevel=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return Al.CleanBoneMatrixWeights},set:function(e){Al.CleanBoneMatrixWeights=e},enumerable:!0,configurable:!0}),e._getDefaultPlugin=function(){return e._registeredPlugins[".babylon"]},e._getPluginForExtension=function(t){var n=e._registeredPlugins[t];return n||(jo.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: http://doc.babylonjs.com/how_to/load_from_any_file_type"),e._getDefaultPlugin())},e._getPluginForDirectLoad=function(t){for(var n in e._registeredPlugins){var r=e._registeredPlugins[n].plugin;if(r.canDirectLoad&&r.canDirectLoad(t))return e._registeredPlugins[n]}return e._getDefaultPlugin()},e._getPluginForFilename=function(t){var n=t.indexOf("?");-1!==n&&(t=t.substring(0,n));var r=t.lastIndexOf("."),i=t.substring(r,t.length).toLowerCase();return e._getPluginForExtension(i)},e._getDirectLoad=function(e){return"data:"===e.substr(0,5)?e.substr(5):null},e._loadData=function(t,n,r,i,o,a,s){var l,c=e._getDirectLoad(t.name),u=s?e._getPluginForExtension(s):c?e._getPluginForDirectLoad(t.name):e._getPluginForFilename(t.name);if(!(l=u.plugin.createPlugin?u.plugin.createPlugin():u.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(e.OnPluginActivatedObservable.notifyObservers(l),c)return r(l,l.directLoad?l.directLoad(n,c):c),l;var d=u.isBinary,h=function(e,t){n.isDisposed?o("Scene has been disposed"):r(l,e,t)},p=null,f=!1,m=l.onDisposeObservable;m&&m.add((function(){f=!0,p&&(p.abort(),p=null),a()}));var g=i?function(e){i(Th.FromProgressEvent(e))}:void 0,b=function(){if(!f){var e=function(e,t){h(e,t?t.responseURL:void 0)},r=function(e){o(e.message,e)};p=l.requestFile?l.requestFile(n,t.url,e,g,d,r):n._requestFile(t.url,e,g,!0,d,r)}},v=t.file||Na.FilesToLoad[t.name.toLowerCase()];if(-1===t.rootUrl.indexOf("file:")||-1!==t.rootUrl.indexOf("file:")&&!v){var A=n.getEngine(),_=A.enableOfflineSupport;if(_){for(var y=!1,x=0,w=n.disableOfflineSupportExceptionRules;xo.snapDistance?(i=Math.floor(Math.abs(l)/o.snapDistance),l<0&&(i*=-1),l%=o.snapDistance,c.scaleToRef(o.snapDistance*i,c),r=!0):c.scaleInPlace(0)),o.attachedMesh.scaling.addInPlace(c),r&&(u.snapDistance=o.snapDistance*i,o.onSnapObservable.notifyObservers(u))}})),o._pointerObserver=r.utilityLayerScene.onPointerObservable.add((function(e){if(!o._customMeshSet){var t=e.pickInfo&&-1!=o._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?o._hoverMaterial:o._coloredMaterial;o._rootMesh.getChildMeshes().forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))}}));var d=r._getSharedGizmoLight();return d.includedOnlyMeshes=d.includedOnlyMeshes.concat(o._rootMesh.getChildMeshes()),o}return Object(No.d)(t,e),t.prototype._attachedMeshChanged=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.attachedMesh=null},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._arrow&&this._arrow.dispose(),[this._coloredMaterial,this._hoverMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t.prototype.setCustomMesh=function(t,n){var r=this;void 0===n&&(n=!1),e.prototype.setCustomMesh.call(this,t),n&&(this._rootMesh.getChildMeshes().forEach((function(e){e.material=r._coloredMaterial,e.color&&(e.color=r._coloredMaterial.diffuseColor)})),this._customMeshSet=!1)},t}(Nd),Nh=function(e){function t(t,n){void 0===t&&(t=Io.Gray()),void 0===n&&(n=Fd.DefaultKeepDepthUtilityLayer);var r=e.call(this,n)||this;r._boundingDimensions=new So(1,1,1),r._renderObserver=null,r._pointerObserver=null,r._scaleDragSpeed=.2,r._tmpQuaternion=new Po,r._tmpVector=new So(0,0,0),r._tmpRotationMatrix=new Oo,r.ignoreChildren=!1,r.includeChildPredicate=null,r.rotationSphereSize=.1,r.scaleBoxSize=.1,r.fixedDragMeshScreenSize=!1,r.fixedDragMeshScreenSizeDistanceFactor=10,r.onDragStartObservable=new yo.a,r.onScaleBoxDragObservable=new yo.a,r.onScaleBoxDragEndObservable=new yo.a,r.onRotationSphereDragObservable=new yo.a,r.onRotationSphereDragEndObservable=new yo.a,r.scalePivot=null,r._existingMeshScale=new So,r._dragMesh=null,r.pointerDragBehavior=new Gl,r.updateScale=!1,r._anchorMesh=new ws("anchor",n.utilityLayerScene),r.coloredMaterial=new hd("",n.utilityLayerScene),r.coloredMaterial.disableLighting=!0,r.hoverColoredMaterial=new hd("",n.utilityLayerScene),r.hoverColoredMaterial.disableLighting=!0,r._lineBoundingBox=new ws("",n.utilityLayerScene),r._lineBoundingBox.rotationQuaternion=new Po;var i=[];i.push(Zd.CreateLines("lines",{points:[new So(0,0,0),new So(r._boundingDimensions.x,0,0)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,0,0),new So(0,r._boundingDimensions.y,0)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,0,0),new So(0,0,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,0,0),new So(r._boundingDimensions.x,r._boundingDimensions.y,0)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,0,0),new So(r._boundingDimensions.x,0,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,r._boundingDimensions.y,0),new So(r._boundingDimensions.x,r._boundingDimensions.y,0)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,r._boundingDimensions.y,0),new So(0,r._boundingDimensions.y,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,0,r._boundingDimensions.z),new So(r._boundingDimensions.x,0,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(0,0,r._boundingDimensions.z),new So(0,r._boundingDimensions.y,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,r._boundingDimensions.y,r._boundingDimensions.z),new So(0,r._boundingDimensions.y,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,r._boundingDimensions.y,r._boundingDimensions.z),new So(r._boundingDimensions.x,0,r._boundingDimensions.z)]},n.utilityLayerScene)),i.push(Zd.CreateLines("lines",{points:[new So(r._boundingDimensions.x,r._boundingDimensions.y,r._boundingDimensions.z),new So(r._boundingDimensions.x,r._boundingDimensions.y,0)]},n.utilityLayerScene)),i.forEach((function(e){e.color=t,e.position.addInPlace(new So(-r._boundingDimensions.x/2,-r._boundingDimensions.y/2,-r._boundingDimensions.z/2)),e.isPickable=!1,r._lineBoundingBox.addChild(e)})),r._rootMesh.addChild(r._lineBoundingBox),r.setColor(t),r._rotateSpheresParent=new ws("",n.utilityLayerScene),r._rotateSpheresParent.rotationQuaternion=new Po;for(var o=function(e){var t=zd.CreateSphere("",{diameter:1},n.utilityLayerScene);t.rotationQuaternion=new Po,t.material=a.coloredMaterial,(u=new Gl({})).moveAttached=!1,u.updateDragPlane=!1,t.addBehavior(u);var i=new So(1,0,0),o=0;u.onDragStartObservable.add((function(){i.copyFrom(t.forward),o=0})),u.onDragObservable.add((function(t){if(r.onRotationSphereDragObservable.notifyObservers({}),r.attachedMesh){var n=r.attachedMesh.parent;if(n&&n.scaling&&n.scaling.isNonUniformWithinEpsilon(.001))return void jo.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");zl._RemoveAndStorePivotPoint(r.attachedMesh);var a=i,s=t.dragPlaneNormal.scale(So.Dot(t.dragPlaneNormal,a)),l=a.subtract(s).normalizeToNew(),c=So.Dot(l,t.delta)<0?Math.abs(t.delta.length()):-Math.abs(t.delta.length());c=c/r._boundingDimensions.length()*r._anchorMesh.scaling.length(),r.attachedMesh.rotationQuaternion||(r.attachedMesh.rotationQuaternion=Po.RotationYawPitchRoll(r.attachedMesh.rotation.y,r.attachedMesh.rotation.x,r.attachedMesh.rotation.z)),r._anchorMesh.rotationQuaternion||(r._anchorMesh.rotationQuaternion=Po.RotationYawPitchRoll(r._anchorMesh.rotation.y,r._anchorMesh.rotation.x,r._anchorMesh.rotation.z)),o+=c,Math.abs(o)<=2*Math.PI&&(e>=8?Po.RotationYawPitchRollToRef(0,0,c,r._tmpQuaternion):e>=4?Po.RotationYawPitchRollToRef(c,0,0,r._tmpQuaternion):Po.RotationYawPitchRollToRef(0,c,0,r._tmpQuaternion),r._anchorMesh.addChild(r.attachedMesh),r._anchorMesh.rotationQuaternion.multiplyToRef(r._tmpQuaternion,r._anchorMesh.rotationQuaternion),r._anchorMesh.removeChild(r.attachedMesh),r.attachedMesh.setParent(n)),r.updateBoundingBox(),zl._RestorePivotPoint(r.attachedMesh)}r._updateDummy()})),u.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({}),r._selectNode(t)})),u.onDragEndObservable.add((function(){r.onRotationSphereDragEndObservable.notifyObservers({}),r._selectNode(null),r._updateDummy()})),a._rotateSpheresParent.addChild(t)},a=this,s=0;s<12;s++)o(s);r._rootMesh.addChild(r._rotateSpheresParent),r._scaleBoxesParent=new ws("",n.utilityLayerScene),r._scaleBoxesParent.rotationQuaternion=new Po;for(var l=0;l<2;l++)for(var c=0;c<2;c++)for(var u,d=function(){var e=Vd.CreateBox("",{size:1},n.utilityLayerScene);e.material=h.coloredMaterial;var t=new So(0==l?-1:1,0==c?-1:1,0==p?-1:1);(u=new Gl({dragAxis:t})).moveAttached=!1,e.addBehavior(u),u.onDragObservable.add((function(t){if(r.onScaleBoxDragObservable.notifyObservers({}),r.attachedMesh){var n=r.attachedMesh.parent;if(n&&n.scaling&&n.scaling.isNonUniformWithinEpsilon(.001))return void jo.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");zl._RemoveAndStorePivotPoint(r.attachedMesh);var i=t.dragDistance/r._boundingDimensions.length()*r._anchorMesh.scaling.length(),o=new So(i,i,i);o.scaleInPlace(r._scaleDragSpeed),r.updateBoundingBox(),r.scalePivot?(r.attachedMesh.getWorldMatrix().getRotationMatrixToRef(r._tmpRotationMatrix),r._boundingDimensions.scaleToRef(.5,r._tmpVector),So.TransformCoordinatesToRef(r._tmpVector,r._tmpRotationMatrix,r._tmpVector),r._anchorMesh.position.subtractInPlace(r._tmpVector),r._boundingDimensions.multiplyToRef(r.scalePivot,r._tmpVector),So.TransformCoordinatesToRef(r._tmpVector,r._tmpRotationMatrix,r._tmpVector),r._anchorMesh.position.addInPlace(r._tmpVector)):(e.absolutePosition.subtractToRef(r._anchorMesh.position,r._tmpVector),r._anchorMesh.position.subtractInPlace(r._tmpVector)),r._anchorMesh.addChild(r.attachedMesh),r._anchorMesh.scaling.addInPlace(o),(r._anchorMesh.scaling.x<0||r._anchorMesh.scaling.y<0||r._anchorMesh.scaling.z<0)&&r._anchorMesh.scaling.subtractInPlace(o),r._anchorMesh.removeChild(r.attachedMesh),r.attachedMesh.setParent(n),zl._RestorePivotPoint(r.attachedMesh)}r._updateDummy()})),u.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({}),r._selectNode(e)})),u.onDragEndObservable.add((function(){r.onScaleBoxDragEndObservable.notifyObservers({}),r._selectNode(null),r._updateDummy()})),h._scaleBoxesParent.addChild(e)},h=this,p=0;p<2;p++)d();r._rootMesh.addChild(r._scaleBoxesParent);var f=new Array;return r._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){f[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=f[e.event.pointerId]&&(f[e.event.pointerId].material=r.coloredMaterial,delete f[e.event.pointerId]):r._rotateSpheresParent.getChildMeshes().concat(r._scaleBoxesParent.getChildMeshes()).forEach((function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(f[e.event.pointerId]=t,t.material=r.hoverColoredMaterial)}))})),r._renderObserver=r.gizmoLayer.originalScene.onBeforeRenderObservable.add((function(){r.attachedMesh&&!r._existingMeshScale.equals(r.attachedMesh.scaling)?r.updateBoundingBox():r.fixedDragMeshScreenSize&&(r._updateRotationSpheres(),r._updateScaleBoxes()),r._dragMesh&&r.attachedMesh&&r.pointerDragBehavior.dragging&&(r._lineBoundingBox.position.rotateByQuaternionToRef(r._rootMesh.rotationQuaternion,r._tmpVector),r.attachedMesh.setAbsolutePosition(r._dragMesh.position.add(r._tmpVector.scale(-1))))})),r.updateBoundingBox(),r}return Object(No.d)(t,e),t.prototype.setColor=function(e){this.coloredMaterial.emissiveColor=e,this.hoverColoredMaterial.emissiveColor=e.clone().add(new Io(.3,.3,.3)),this._lineBoundingBox.getChildren().forEach((function(t){t.color&&(t.color=e)}))},t.prototype._attachedMeshChanged=function(e){var t=this;if(e){zl._RemoveAndStorePivotPoint(e);var n=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(n),zl._RestorePivotPoint(e),this.updateBoundingBox(),e.getChildMeshes(!1).forEach((function(e){e.markAsDirty("scaling")})),this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce((function(){t._updateDummy()}))}},t.prototype._selectNode=function(e){this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach((function(t){t.isVisible=!e||t==e}))},t.prototype.updateBoundingBox=function(){if(this.attachedMesh){zl._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null);var t=null;this.attachedMesh.skeleton&&(t=this.attachedMesh.skeleton.overrideMesh,this.attachedMesh.skeleton.overrideMesh=null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=Po.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=Po.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 n=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);n.max.subtractToRef(n.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((n.max.x+n.min.x)/2,(n.max.y+n.min.y)/2,(n.max.z+n.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=t)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),zl._RestorePivotPoint(this.attachedMesh))},t.prototype._updateRotationSpheres=function(){for(var e=this._rotateSpheresParent.getChildMeshes(),t=0;t<3;t++)for(var n=0;n<2;n++)for(var r=0;r<2;r++){var i=4*t+2*n+r;if(0==t&&(e[i].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*n,this._boundingDimensions.z*r),e[i].position.addInPlace(new So(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[i].lookAt(So.Cross(e[i].position.normalizeToNew(),So.Right()).normalizeToNew().add(e[i].position))),1==t&&(e[i].position.set(this._boundingDimensions.x*n,this._boundingDimensions.y/2,this._boundingDimensions.z*r),e[i].position.addInPlace(new So(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[i].lookAt(So.Cross(e[i].position.normalizeToNew(),So.Up()).normalizeToNew().add(e[i].position))),2==t&&(e[i].position.set(this._boundingDimensions.x*n,this._boundingDimensions.y*r,this._boundingDimensions.z/2),e[i].position.addInPlace(new So(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[i].lookAt(So.Cross(e[i].position.normalizeToNew(),So.Forward()).normalizeToNew().add(e[i].position))),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[i].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var o=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[i].scaling.set(o,o,o)}else e[i].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}},t.prototype._updateScaleBoxes=function(){for(var e=this._scaleBoxesParent.getChildMeshes(),t=0;t<2;t++)for(var n=0;n<2;n++)for(var r=0;r<2;r++){var i=4*t+2*n+r;if(e[i])if(e[i].position.set(this._boundingDimensions.x*t,this._boundingDimensions.y*n,this._boundingDimensions.z*r),e[i].position.addInPlace(new So(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[i].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var o=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[i].scaling.set(o,o,o)}else e[i].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize)}},t.prototype.setEnabledRotationAxis=function(e){this._rotateSpheresParent.getChildMeshes().forEach((function(t,n){n<4?t.setEnabled(-1!=e.indexOf("x")):n<8?t.setEnabled(-1!=e.indexOf("y")):t.setEnabled(-1!=e.indexOf("z"))}))},t.prototype.setEnabledScaling=function(e){this._scaleBoxesParent.getChildMeshes().forEach((function(t,n){t.setEnabled(e)}))},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=Pl.CreateBox("dummy",1,this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new Po,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(),e.prototype.dispose.call(this)},t.MakeNotPickableAndWrapInBoundingBox=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach((function(e){t(e)}))};t(e),e.rotationQuaternion||(e.rotationQuaternion=Po.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var n=e.position.clone(),r=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var i=Vd.CreateBox("box",{size:1},e.getScene()),o=e.getHierarchyBoundingVectors();return o.max.subtractToRef(o.min,i.scaling),0===i.scaling.y&&(i.scaling.y=.001),0===i.scaling.x&&(i.scaling.x=.001),0===i.scaling.z&&(i.scaling.z=.001),i.position.set((o.max.x+o.min.x)/2,(o.max.y+o.min.y)/2,(o.max.z+o.min.z)/2),e.addChild(i),e.rotationQuaternion.copyFrom(r),e.position.copyFrom(n),e.removeChild(i),i.addChild(e),i.visibility=0,i},t.prototype.setCustomMesh=function(e){jo.a.Error("Custom meshes are not supported on this gizmo")},t}(Nd),Lh=function(e){function t(t,n,r,i,o,a){void 0===n&&(n=Io.Gray()),void 0===r&&(r=Fd.DefaultUtilityLayer),void 0===i&&(i=32),void 0===o&&(o=null),void 0===a&&(a=!1);var s=e.call(this,r)||this;s._pointerObserver=null,s.snapDistance=0,s.onSnapObservable=new yo.a,s._isEnabled=!0,s._parent=null,s._parent=o;var l=new hd("",r.utilityLayerScene);l.diffuseColor=n,l.specularColor=n.subtract(new Io(.1,.1,.1));var c=new hd("",r.utilityLayerScene);c.diffuseColor=n.add(new Io(.3,.3,.3));var u=new ws("",r.utilityLayerScene),d=Pl.CreateTorus("",.6,.03,i,r.utilityLayerScene);d.visibility=0;var h=Pl.CreateTorus("",.6,.005,i,r.utilityLayerScene);h.material=l,h.rotation.x=Math.PI/2,d.rotation.x=Math.PI/2,u.addChild(h),u.addChild(d),u.lookAt(s._rootMesh.position.add(t)),s._rootMesh.addChild(u),u.scaling.scaleInPlace(1/3),s.dragBehavior=new Gl({dragPlaneNormal:t}),s.dragBehavior.moveAttached=!1,s.dragBehavior.maxDragAngle=9*Math.PI/20,s.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,s._rootMesh.addBehavior(s.dragBehavior);var p=new So;s.dragBehavior.onDragStartObservable.add((function(e){s.attachedMesh&&p.copyFrom(e.dragPlanePoint)}));var f=new Oo,m=new So,g=new So,b={snapDistance:0},v=0,A=new Oo,_=new So,y=new Po;s.dragBehavior.onDragObservable.add((function(e){if(s.attachedMesh){s.attachedMesh.rotationQuaternion&&!a||(s.attachedMesh.rotationQuaternion=Po.RotationYawPitchRoll(s.attachedMesh.rotation.y,s.attachedMesh.rotation.x,s.attachedMesh.rotation.z));var n=s.attachedMesh.parent;n&&s.attachedMesh.setParent(null);var i=e.dragPlanePoint.subtract(s.attachedMesh.absolutePosition).normalize(),o=p.subtract(s.attachedMesh.absolutePosition).normalize(),l=So.Cross(i,o),c=So.Dot(i,o),u=Math.atan2(l.length(),c);if(m.copyFrom(t),g.copyFrom(t),s.updateGizmoRotationToMatchAttachedMesh&&(s.attachedMesh.rotationQuaternion.toRotationMatrix(f),g=So.TransformCoordinates(m,f)),r.utilityLayerScene.activeCamera){var d=r.utilityLayerScene.activeCamera.position.subtract(s.attachedMesh.position);So.Dot(d,g)>0&&(m.scaleInPlace(-1),g.scaleInPlace(-1))}So.Dot(g,l)>0&&(u=-u);var h=!1;if(0!=s.snapDistance)if(v+=u,Math.abs(v)>s.snapDistance){var x=Math.floor(Math.abs(v)/s.snapDistance);v<0&&(x*=-1),v%=s.snapDistance,u=s.snapDistance*x,h=!0}else u=0;A.reset(),s.attachedMesh.parent&&(s.attachedMesh.parent.computeWorldMatrix().invertToRef(A),A.getRotationMatrixToRef(A),So.TransformCoordinatesToRef(m,A,m));var w=Math.sin(u/2);y.set(m.x*w,m.y*w,m.z*w,Math.cos(u/2)),A.determinant()>0&&(y.toEulerAnglesToRef(_),Po.RotationYawPitchRollToRef(_.y,-_.x,-_.z,y)),s.updateGizmoRotationToMatchAttachedMesh?s.attachedMesh.rotationQuaternion.multiplyToRef(y,s.attachedMesh.rotationQuaternion):y.multiplyToRef(s.attachedMesh.rotationQuaternion,s.attachedMesh.rotationQuaternion),a&&(s.attachedMesh.rotationQuaternion.toEulerAnglesToRef(_),s.attachedMesh.rotationQuaternion=null,s.attachedMesh.rotation.copyFrom(_)),p.copyFrom(e.dragPlanePoint),h&&(b.snapDistance=u,s.onSnapObservable.notifyObservers(b)),n&&s.attachedMesh.setParent(n)}})),s._pointerObserver=r.utilityLayerScene.onPointerObservable.add((function(e){if(!s._customMeshSet){var t=e.pickInfo&&-1!=s._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?c:l;s._rootMesh.getChildMeshes().forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))}}));var x=r._getSharedGizmoLight();return x.includedOnlyMeshes=x.includedOnlyMeshes.concat(s._rootMesh.getChildMeshes(!1)),s}return Object(No.d)(t,e),t.prototype._attachedMeshChanged=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.attachedMesh=null},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this)},t}(Nd),Uh=function(e){function t(t,n,r){void 0===t&&(t=Fd.DefaultUtilityLayer),void 0===n&&(n=32),void 0===r&&(r=!1);var i=e.call(this,t)||this;return i.onDragStartObservable=new yo.a,i.onDragEndObservable=new yo.a,i.xGizmo=new Lh(new So(1,0,0),Io.Red().scale(.5),t,n,i,r),i.yGizmo=new Lh(new So(0,1,0),Io.Green().scale(.5),t,n,i,r),i.zGizmo=new Lh(new So(0,0,1),Io.Blue().scale(.5),t,n,i,r),[i.xGizmo,i.yGizmo,i.zGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){i.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){i.onDragEndObservable.notifyObservers({})}))})),i.attachedMesh=null,i}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!0,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:!0,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:!0,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:!0,configurable:!0}),t.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){jo.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}(Nd),Vh=function(e){function t(n,r,i,o){void 0===r&&(r=Io.Gray()),void 0===i&&(i=Fd.DefaultUtilityLayer),void 0===o&&(o=null);var a=e.call(this,i)||this;a._pointerObserver=null,a.snapDistance=0,a.onSnapObservable=new yo.a,a._isEnabled=!1,a._parent=null,a._parent=o,a._coloredMaterial=new hd("",i.utilityLayerScene),a._coloredMaterial.diffuseColor=r,a._coloredMaterial.specularColor=r.subtract(new Io(.1,.1,.1)),a._hoverMaterial=new hd("",i.utilityLayerScene),a._hoverMaterial.diffuseColor=r.add(new Io(.3,.3,.3)),a._plane=t._CreatePlane(i.utilityLayerScene,a._coloredMaterial),a._plane.lookAt(a._rootMesh.position.add(n)),a._plane.scaling.scaleInPlace(1/3),a._plane.parent=a._rootMesh;var s=0,l=new So,c={snapDistance:0};a.dragBehavior=new Gl({dragPlaneNormal:n}),a.dragBehavior.moveAttached=!1,a._rootMesh.addBehavior(a.dragBehavior);var u=new So,d=new Oo;a.dragBehavior.onDragObservable.add((function(e){if(a.attachedMesh)if(a.attachedMesh.parent?(a.attachedMesh.parent.computeWorldMatrix().invertToRef(d),d.setTranslationFromFloats(0,0,0),So.TransformCoordinatesToRef(e.delta,d,u)):u.copyFrom(e.delta),0==a.snapDistance)a.attachedMesh.position.addInPlace(u);else if(s+=e.dragDistance,Math.abs(s)>a.snapDistance){var t=Math.floor(Math.abs(s)/a.snapDistance);s%=a.snapDistance,u.normalizeToRef(l),l.scaleInPlace(a.snapDistance*t),a.attachedMesh.position.addInPlace(l),c.snapDistance=a.snapDistance*t,a.onSnapObservable.notifyObservers(c)}})),a._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){if(!a._customMeshSet){var t=e.pickInfo&&-1!=a._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?a._hoverMaterial:a._coloredMaterial;a._rootMesh.getChildMeshes().forEach((function(e){e.material=t}))}}));var h=i._getSharedGizmoLight();return h.includedOnlyMeshes=h.includedOnlyMeshes.concat(a._rootMesh.getChildMeshes(!1)),a}return Object(No.d)(t,e),t._CreatePlane=function(e,t){var n=new as("plane",e),r=jl.CreatePlane("dragPlane",{width:.1375,height:.1375,sideOrientation:2},e);return r.material=t,r.parent=n,r.material=t,n},t._CreateArrowInstance=function(e,t){for(var n=new as("arrow",e),r=0,i=t.getChildMeshes();r=t.length)?0:e.type||0,c=e.size,u=e.sizeX||c||1,d=e.sizeY||c||1,h=e.sizeZ||c||1,p=e.custom||t[l],f=p.face.length,m=e.faceUV||new Array(f),g=e.faceColors,b=void 0===e.flat||e.flat,v=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,A=new Array,_=new Array,y=new Array,x=new Array,w=new Array,E=0,C=0,S=new Array,T=0,P=0;if(b)for(P=0;P0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,n)},t.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(e){var t=this.getScene().activeCamera;t&&Oo.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:t.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:t.maxZ,e)},t.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,t,n){var r=this.getScene().activeCamera;if(r){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var i=So.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var o=Number.MAX_VALUE,a=Number.MIN_VALUE,s=0;sthis._orthoRight&&(this._orthoRight=i.x),i.y>this._orthoTop&&(this._orthoTop=i.y),this.autoCalcShadowZBounds&&(i.za&&(a=i.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=o,this._shadowMaxZ=a)}var d=this._orthoRight-this._orthoLeft,h=this._orthoTop-this._orthoBottom;Oo.OrthoOffCenterLHToRef(this._orthoLeft-d*this.shadowOrthoScale,this._orthoRight+d*this.shadowOrthoScale,this._orthoBottom-h*this.shadowOrthoScale,this._orthoTop+h*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.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,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},t.prototype.transferToNodeMaterialEffect=function(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,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,t){e["DIRLIGHT"+t]=!0},Object(No.c)([ha()],t.prototype,"shadowFrustumSize",null),Object(No.c)([ha()],t.prototype,"shadowOrthoScale",null),Object(No.c)([ha()],t.prototype,"autoUpdateExtends",void 0),Object(No.c)([ha()],t.prototype,"autoCalcShadowZBounds",void 0),t}(Hh);Pl.CreateHemisphere=function(e,t,n,r){var i={segments:t,diameter:n};return Wh.CreateHemisphere(e,i,r)};var Wh=function(){function e(){}return e.CreateHemisphere=function(e,t,n){t.diameter||(t.diameter=1),t.segments||(t.segments=16);var r=zd.CreateSphere("",{slice:.5,diameter:t.diameter,segments:t.segments},n),i=Pl.CreateDisc("",t.diameter/2,3*t.segments+(4-t.segments),n);i.rotation.x=-Math.PI/2,i.parent=r;var o=Pl.MergeMeshes([i,r],!0);return o.name=e,o},e}();wa.AddNodeConstructor("Light_Type_2",(function(e,t){return function(){return new Kh(e,So.Zero(),So.Zero(),0,0,t)}}));var Kh=function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,a)||this;return s._innerAngle=0,s._projectionTextureMatrix=Oo.Zero(),s._projectionTextureLightNear=1e-6,s._projectionTextureLightFar=1e3,s._projectionTextureUpDirection=So.Up(),s._projectionTextureViewLightDirty=!0,s._projectionTextureProjectionLightDirty=!0,s._projectionTextureDirty=!0,s._projectionTextureViewTargetVector=So.Zero(),s._projectionTextureViewLightMatrix=Oo.Zero(),s._projectionTextureProjectionLightMatrix=Oo.Zero(),s._projectionTextureScalingMatrix=Oo.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),s.position=n,s.direction=r,s.angle=i,s.exponent=o,s}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._cosHalfAngle=Math.cos(.5*e),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){var t=this;if(this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady())){var n=this._projectionTexture;n.onLoadObservable&&n.onLoadObservable.addOnce((function(){t._markMeshesAsLightDirty()}))}},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"SpotLight"},t.prototype.getTypeID=function(){return Ds.LIGHTTYPEID_SPOTLIGHT},t.prototype._setDirection=function(t){e.prototype._setDirection.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setPosition=function(t){e.prototype._setPosition.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,n){var r=this.getScene().activeCamera;if(r){this._shadowAngleScale=this._shadowAngleScale||1;var i=this._shadowAngleScale*this._angle;Oo.PerspectiveFovLHToRef(i,1,this.getDepthMinZ(r),this.getDepthMaxZ(r),e)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),Oo.LookAtLHToRef(this.position,this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)},t.prototype._computeProjectionTextureProjectionLightMatrix=function(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;var e=this.projectionTextureLightFar,t=this.projectionTextureLightNear,n=e/(e-t),r=-n*t,i=1/Math.tan(this._angle/2);Oo.FromValuesToRef(i/1,0,0,0,0,i,0,0,0,0,n,1,0,0,r,0,this._projectionTextureProjectionLightMatrix)},t.prototype._computeProjectionTextureMatrix=function(){if(this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTexture instanceof Wl){var e=this._projectionTexture.uScale/2,t=this._projectionTexture.vScale/2;Oo.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,.5,0,.5,.5,.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(.001,Math.cos(.5*this._innerAngle)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale},t.prototype.transferTexturesToEffect=function(e,t){return this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix("textureProjectionMatrix"+t,this._projectionTextureMatrix),e.setTexture("projectionLightSampler"+t,this.projectionTexture)),this},t.prototype.transferToEffect=function(e,t){var n;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,t),n=So.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,t),n=So.Normalize(this.direction)),this.getScene().useRightHandedSystem?this._uniformBuffer.updateFloat4("vLightDirection",-n.x,-n.y,-n.z,this._cosHalfAngle,t):this._uniformBuffer.updateFloat4("vLightDirection",n.x,n.y,n.z,this._cosHalfAngle,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,t),this},t.prototype.transferToNodeMaterialEffect=function(e,t){var n;return n=this.computeTransformedInformation()?So.Normalize(this.transformedDirection):So.Normalize(this.direction),this.getScene().useRightHandedSystem?e.setFloat3(t,-n.x,-n.y,-n.z):e.setFloat3(t,n.x,n.y,n.z),this},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._projectionTexture&&this._projectionTexture.dispose()},t.prototype.prepareLightSpecificDefines=function(e,t){e["SPOTLIGHT"+t]=!0,e["PROJECTEDLIGHTTEXTURE"+t]=!(!this.projectionTexture||!this.projectionTexture.isReady())},Object(No.c)([ha()],t.prototype,"angle",null),Object(No.c)([ha()],t.prototype,"innerAngle",null),Object(No.c)([ha()],t.prototype,"shadowAngleScale",null),Object(No.c)([ha()],t.prototype,"exponent",void 0),Object(No.c)([ha()],t.prototype,"projectionTextureLightNear",null),Object(No.c)([ha()],t.prototype,"projectionTextureLightFar",null),Object(No.c)([ha()],t.prototype,"projectionTextureUpDirection",null),Object(No.c)([pa("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}(Hh);!function(e){function t(t){var n=e.call(this,t)||this;return n._cachedPosition=new So,n._cachedForward=new So(0,0,1),n._light=null,n.attachedMesh=new ws("",n.gizmoLayer.utilityLayerScene),n._attachedMeshParent=new as("parent",n.gizmoLayer.originalScene),n.attachedMesh.parent=n._attachedMeshParent,n._material=new hd("light",n.gizmoLayer.originalScene),n._material.diffuseColor=new Io(.5,.5,.5),n._material.specularColor=new Io(.1,.1,.1),n}Object(No.d)(t,e),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(),this._lightMesh=e instanceof yu?t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Qh?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Kh?t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene):t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),this._lightMesh.getChildMeshes(!1).forEach((function(e){e.material=n._material})),this._lightMesh.parent=this._rootMesh;var r=this.gizmoLayer._getSharedGizmoLight();r.includedOnlyMeshes=r.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),this._lightMesh.rotationQuaternion=new Po,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!0,configurable:!0}),t.prototype._update=function(){e.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&&(So.DistanceSquared(this.attachedMesh.forward,this._cachedForward)>1e-4?(this._light.direction.copyFrom(this.attachedMesh.forward),this._cachedForward.copyFrom(this.attachedMesh.forward)):So.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))),this._light.isEnabled()?this._material.diffuseColor.set(this._light.diffuse.r/3,this._light.diffuse.g/3,this._light.diffuse.b/3):this._material.diffuseColor.set(0,0,0))},t.prototype.dispose=function(){this._material.dispose(),e.prototype.dispose.call(this),this._attachedMeshParent.dispose()},t._CreateHemisphericLightMesh=function(e){var n=new Pl("hemisphereLight",e),r=Wh.CreateHemisphere(n.name,{segments:10,diameter:1},e);r.position.z=-.15,r.rotation.x=Math.PI/2,r.parent=n;var i=this._CreateLightLines(3,e);return i.parent=n,i.position.z,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreatePointLightMesh=function(e){var n=new Pl("pointLight",e),r=zd.CreateSphere(n.name,{segments:10,diameter:1},e);return r.rotation.x=Math.PI/2,r.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 Pl("spotLight",e);zd.CreateSphere(n.name,{segments:10,diameter:1},e).parent=n;var r=Wh.CreateHemisphere(n.name,{segments:10,diameter:2},e);return r.parent=n,r.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 Pl("directionalLight",e),r=new Pl(n.name,e);r.parent=n,zd.CreateSphere(n.name,{diameter:1.2,segments:10},e).parent=r;var i=Pl.CreateCylinder(n.name,6,.3,.3,6,1,e);i.parent=r,(o=i.clone(n.name)).scaling.y=.5,o.position.x+=1.25,(a=i.clone(n.name)).scaling.y=.5,a.position.x+=-1.25;var o,a,s=Pl.CreateCylinder(n.name,1,0,.6,6,1,e);return s.position.y+=3,s.parent=r,(o=s.clone(n.name)).position.y=1.5,o.position.x+=1.25,(a=s.clone(n.name)).position.y=1.5,a.position.x+=-1.25,r.scaling.scaleInPlace(t._Scale),r.rotation.z=Math.PI/2,r.rotation.y=Math.PI/2,n},t._Scale=.007,t._CreateLightLines=function(e,t){var n=new Pl("root",t);n.rotation.x=Math.PI/2;var r=new Pl("linePivot",t);r.parent=n;var i=Pl.CreateCylinder("line",2,.2,.3,6,1,t);if(i.position.y=i.scaling.y/2+1.2,i.parent=r,e<2)return r;for(var o=0;o<4;o++){(a=r.clone("lineParentClone")).rotation.z=Math.PI/4,a.rotation.y=Math.PI/2+Math.PI/2*o,a.getChildMeshes()[0].scaling.y=.5,a.getChildMeshes()[0].scaling.x=a.getChildMeshes()[0].scaling.z=.8,a.getChildMeshes()[0].position.y=a.getChildMeshes()[0].scaling.y/2+1.2}if(e<3)return n;for(o=0;o<4;o++){(a=r.clone("linePivotClone")).rotation.z=Math.PI/2,a.rotation.y=Math.PI/2*o}if(e<4)return n;for(o=0;o<4;o++){var a;(a=r.clone("linePivotClone")).rotation.z=Math.PI+Math.PI/4,a.rotation.y=Math.PI/2+Math.PI/2*o,a.getChildMeshes()[0].scaling.y=.5,a.getChildMeshes()[0].scaling.x=a.getChildMeshes()[0].scaling.z=.8,a.getChildMeshes()[0].position.y=a.getChildMeshes()[0].scaling.y/2+1.2}return e<5||((a=r.clone("linePivotClone")).rotation.z=Math.PI),n}}(Nd);Qc.a.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";var Xh="vec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}";Qc.a.IncludesShadersStore.packingFunctions=Xh;var Yh="#ifdef DOF\nfactor=sampleCoC(sampleCoord{X});\ncomputedWeight=KERNEL_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\n#endif";Qc.a.IncludesShadersStore.kernelBlurFragment=Yh;var qh="#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});\ncomputedWeight=KERNEL_DEP_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\n#endif";Qc.a.IncludesShadersStore.kernelBlurFragment2=qh;var Zh="\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(const in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g;\nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;\n}\nfloat sampleCoC(const in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r;\nreturn coc;\n}\n#endif\n#include[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include\n#endif\nvoid main(void)\n{\nfloat computedWeight=0.0;\n#ifdef PACKEDFLOAT\nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT;\nfloat factor=0.0;\n\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include[0..varyingCount]\n#include[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}";Qc.a.ShadersStore.kernelBlurPixelShader=Zh;Qc.a.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var Jh="\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nsampleCenter=(position*madd+madd);\n#include[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n}";Qc.a.ShadersStore.kernelBlurVertexShader=Jh;var $h=function(e){function t(t,n,r,i,o,a,s,l,c,u,d){void 0===a&&(a=Wl.BILINEAR_SAMPLINGMODE),void 0===c&&(c=0),void 0===u&&(u=""),void 0===d&&(d=!1);var h=e.call(this,t,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],i,o,a,s,l,null,c,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return h.direction=n,h.blockCompilation=d,h._packedFloat=!1,h._staticDefines="",h._staticDefines=u,h.onApplyObservable.add((function(e){h._outputTexture?e.setFloat2("delta",1/h._outputTexture.width*h.direction.x,1/h._outputTexture.height*h.direction.y):e.setFloat2("delta",1/h.width*h.direction.x,1/h.height*h.direction.y)})),h.kernel=r,h}return Object(No.d)(t,e),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:!0,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:!0,configurable:!0}),t.prototype.updateEffect=function(e,t,n,r,i,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null),this._updateParameters(i,o)},t.prototype._updateParameters=function(t,n){for(var r=this._kernel,i=(r-1)/2,o=[],a=[],s=0,l=0;l0)return Math.max(i,3)}return Math.max(t,3)},t.prototype._gaussianWeight=function(e){var t=-e*e/(1/3*2*(1/3));return 1/(Math.sqrt(2*Math.PI)*(1/3))*Math.exp(t)},t.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},t}(Xc),ep=function(e){function t(t,n,r,i,o,a,s){void 0===o&&(o=0),void 0===a&&(a=Wl.BILINEAR_SAMPLINGMODE),void 0===s&&(s=!0);var l=e.call(this,t,n,r,i,!0,o,!1,a,s)||this;return l.scene=r,l.mirrorPlane=new Cs(0,1,0,1),l._transformMatrix=Oo.Zero(),l._mirrorMatrix=Oo.Zero(),l._adaptiveBlurKernel=0,l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.ignoreCameraViewport=!0,l._updateGammaSpace(),l._imageProcessingConfigChangeObserver=r.imageProcessingConfiguration.onUpdateParameters.add((function(){l._updateGammaSpace})),l.onBeforeRenderObservable.add((function(){Oo.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=r.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),r.setTransformMatrix(l._transformMatrix,r.getProjectionMatrix()),r.clipPlane=l.mirrorPlane,r.getEngine().cullBackFaces=!1,r._mirroredCameraPosition=So.TransformCoordinates(r.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){r.setTransformMatrix(l._savedViewMatrix,r.getProjectionMatrix()),r.getEngine().cullBackFaces=!0,r._mirroredCameraPosition=null,r.clipPlane=null})),l}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),t.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),n=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*n},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(),t=e.getCaps().textureFloatRender?1:2;this._blurX=new $h("horizontal blur",new Co(1,0),this._blurKernelX,this._blurRatio,null,Wl.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2&&this._texture?this._blurX.inputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new $h("vertical blur",new Co(0,1),this._blurKernelY,this._blurRatio,null,Wl.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,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(),r=new t(this.name,n.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(r.renderList=this.renderList.slice(0)),r},t.prototype.serialize=function(){if(!this.name)return null;var t=e.prototype.serialize.call(this);return t.mirrorPlane=this.mirrorPlane.asArray(),t},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver)},t}(mu);Wl._CreateMirror=function(e,t,n,r){return new ep(e,t,n,r)},Va.a.prototype._createDepthStencilCubeTexture=function(e,t){var n=new Kl.a(this,Kl.b.Unknown);if(n.isCube=!0,1===this.webGLVersion)return jo.a.Error("Depth cube texture is not supported by WebGL 1."),n;var r=Object(No.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),i=this._gl;this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,n,!0),this._setupDepthStencilTexture(n,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction);for(var o=0;o<6;o++)r.generateStencil?i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,i.DEPTH24_STENCIL8,e,e,0,i.DEPTH_STENCIL,i.UNSIGNED_INT_24_8,null):i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,i.DEPTH_COMPONENT24,e,e,0,i.DEPTH_COMPONENT,i.UNSIGNED_INT,null);return this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null),n},Va.a.prototype._partialLoadFile=function(e,t,n,r,i){void 0===i&&(i=null);this._loadFile(e,(function(e){n[t]=e,n._internalCount++,6===n._internalCount&&r(n)}),void 0,void 0,!0,(function(e,t){i&&e&&i(e.status+" "+e.statusText,t)}))},Va.a.prototype._cascadeLoadFiles=function(e,t,n,r){void 0===r&&(r=null);var i=[];i._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(n[o],o,i,t,r)},Va.a.prototype._cascadeLoadImgs=function(e,t,n,r,i){void 0===r&&(r=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)this._partialLoadImg(n[a],a,o,e,t,r,i)},Va.a.prototype._partialLoadImg=function(e,t,n,r,i,o,a){var s;void 0===o&&(o=null);s=Qa.LoadImage(e,(function(){s&&(n[t]=s,n._internalCount++,r&&r._removePendingData(s)),6===n._internalCount&&i(n)}),(function(e,t){r&&r._removePendingData(s),o&&o(e,t)}),r?r.offlineProvider:null,a),r&&s&&r._addPendingData(s)},Va.a.prototype._setCubeMapTextureParams=function(e){var t=this._gl;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,e?t.LINEAR_MIPMAP_LINEAR:t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)},Va.a.prototype.createCubeTexture=function(e,t,n,r,i,o,a,s,l,c,u,d){var h=this;void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=!1),void 0===c&&(c=0),void 0===u&&(u=0),void 0===d&&(d=null);var p=this._gl,f=d||new Kl.a(this,Kl.b.Cube);f.isCube=!0,f.url=e,f.generateMipMaps=!r,f._lodGenerationScale=c,f._lodGenerationOffset=u,this._doNotHandleContextLost||(f._extension=s,f._files=n);for(var m=e.lastIndexOf("."),g=s||(m>-1?e.substring(m).toLowerCase():""),b=null,v=0,A=Va.a._TextureLoaders;v-1?t.substring(g).toLowerCase():""),v=".dds"===b,A=".env"===b;if(A?(m.gammaSpace=!1,m._prefiltered=!1,m.anisotropicFilteringLevel=1):(m._prefiltered=c,c&&(m.gammaSpace=!1,m.anisotropicFilteringLevel=1)),m._texture=m._getFromCache(t,i),!o&&(A||v||r||(r=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),o=[],r))for(var _=0;_0,o.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,o.LODINREFLECTIONALPHA=s.lodLevelInAlpha,o.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,o.REFLECTIONBGR=this.switchToBGR,s.coordinatesMode===Wl.INVCUBIC_MODE&&(o.INVERTCUBICMAP=!0),o.REFLECTIONMAP_3D=s.isCube,s.coordinatesMode){case Wl.EXPLICIT_MODE:o.REFLECTIONMAP_EXPLICIT=!0;break;case Wl.PLANAR_MODE:o.REFLECTIONMAP_PLANAR=!0;break;case Wl.PROJECTION_MODE:o.REFLECTIONMAP_PROJECTION=!0;break;case Wl.SKYBOX_MODE:o.REFLECTIONMAP_SKYBOX=!0;break;case Wl.SPHERICAL_MODE:o.REFLECTIONMAP_SPHERICAL=!0;break;case Wl.EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Wl.FIXED_EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Wl.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Wl.CUBIC_MODE:case Wl.INVCUBIC_MODE:default:o.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(o.REFLECTIONFRESNEL=!0,o.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):(o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1)}else o.REFLECTION=!1,o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1,o.REFLECTIONBLUR=!1,o.REFLECTIONMAP_3D=!1,o.REFLECTIONMAP_SPHERICAL=!1,o.REFLECTIONMAP_PLANAR=!1,o.REFLECTIONMAP_CUBIC=!1,o.REFLECTIONMAP_PROJECTION=!1,o.REFLECTIONMAP_SKYBOX=!1,o.REFLECTIONMAP_EXPLICIT=!1,o.REFLECTIONMAP_EQUIRECTANGULAR=!1,o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,o.INVERTCUBICMAP=!1,o.REFLECTIONMAP_OPPOSITEZ=!1,o.LODINREFLECTIONALPHA=!1,o.GAMMAREFLECTION=!1,o.RGBDREFLECTION=!1}o.PREMULTIPLYALPHA=7===this.alphaMode||8===this.alphaMode,o.USERGBCOLOR=this._useRGBColor,o.NOISE=this._enableNoise}if(o._areLightsDirty&&(o.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel)),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o)}if(Cu.PrepareDefinesForMisc(e,i,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),Cu.PrepareDefinesForFrameBoundValues(i,a,o,n),Cu.PrepareDefinesForAttributes(e,o,!1,!0,!1)&&e&&(i.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(cs.NormalKind)||(e.createNormals(!0),jo.a.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),o.isDirty){o.markAsProcessed(),i.resetCachedMaterial();var l=new ud;o.FOG&&l.addFallback(0,"FOG"),o.POINTSIZE&&l.addFallback(1,"POINTSIZE"),o.MULTIVIEW&&l.addFallback(0,"MULTIVIEW"),Cu.HandleFallbacksForShadows(o,l,this._maxSimultaneousLights);var c=[cs.PositionKind];o.NORMAL&&c.push(cs.NormalKind),o.UV1&&c.push(cs.UVKind),o.UV2&&c.push(cs.UV2Kind),Cu.PrepareAttributesForBones(c,e,o,l),Cu.PrepareAttributesForInstances(c,o);var u=["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"],d=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],h=["Material","Scene"];Ms&&(Ms.PrepareUniforms(u,o),Ms.PrepareSamplers(d,o)),Cu.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:h,samplers:d,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var p=o.toString();t.setEffect(i.getEngine().createEffect("background",{attributes:c,uniformsNames:u,uniformBuffersNames:h,samplers:d,defines:p,fallbacks:l,onCompiled:function(e){r.onCompiled&&r.onCompiled(e),r.bindSceneUniformBuffer(e,i.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},a),o),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(o._renderId=i.getRenderId(),t.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(){0===this._primaryColorShadowLevel&&0===this._primaryColorHighlightLevel||(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),e.prototype.unbind.call(this)},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},t.prototype.bindForSubMesh=function(e,t,n){var r=this.getScene(),i=n._materialDefines;if(i){var o=n.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),Cu.BindBonesParameters(t,this._activeEffect);var a=this._mustRebind(r,o,t.visibility);if(a){this._uniformBuffer.bindToEffect(o,"Material"),this.bindViewProjection(o);var s=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(r.texturesEnabled&&(this._diffuseTexture&&Su.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),Cu.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),s&&Su.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",s.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",s.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),i.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),r.texturesEnabled&&(this._diffuseTexture&&Su.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),s&&Su.ReflectionTextureEnabled&&(i.REFLECTIONBLUR&&i.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",s):i.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",s._lodTextureMid||s),this._uniformBuffer.setTexture("reflectionSamplerLow",s._lodTextureLow||s),this._uniformBuffer.setTexture("reflectionSamplerHigh",s._lodTextureHigh||s)):this._uniformBuffer.setTexture("reflectionSampler",s),i.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)))),Cu.BindClipPlane(this._activeEffect,r),Cu.BindEyePosition(o,r)}!a&&this.isFrozen||(r.lightsEnabled&&Cu.BindLights(r,t,this._activeEffect,i,this._maxSimultaneousLights,!1),this.bindView(o),Cu.BindFogParameters(r,t,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}}},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._reflectionTexture===t||this._diffuseTexture===t)},t.prototype.dispose=function(t,n){void 0===t&&(t=!1),void 0===n&&(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),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var n=this;return ya.Clone((function(){return new t(e,n.getScene())}),this)},t.prototype.serialize=function(){var e=ya.Serialize(this);return e.customType="BABYLON.BackgroundMaterial",e},t.prototype.getClassName=function(){return"BackgroundMaterial"},t.Parse=function(e,n,r){return ya.Parse((function(){return new t(e.name,n)}),e,n,r)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,Object(No.c)([fa()],t.prototype,"_primaryColor",void 0),Object(No.c)([da("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),Object(No.c)([fa()],t.prototype,"__perceptualColor",void 0),Object(No.c)([ha()],t.prototype,"_primaryColorShadowLevel",void 0),Object(No.c)([ha()],t.prototype,"_primaryColorHighlightLevel",void 0),Object(No.c)([da("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),Object(No.c)([pa()],t.prototype,"_reflectionTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(No.c)([ha()],t.prototype,"_reflectionBlur",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),Object(No.c)([pa()],t.prototype,"_diffuseTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),Object(No.c)([ha()],t.prototype,"_shadowLevel",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),Object(No.c)([ga()],t.prototype,"_sceneCenter",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),Object(No.c)([ha()],t.prototype,"_opacityFresnel",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),Object(No.c)([ha()],t.prototype,"_reflectionFresnel",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),Object(No.c)([ha()],t.prototype,"_reflectionFalloffDistance",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),Object(No.c)([ha()],t.prototype,"_reflectionAmount",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),Object(No.c)([ha()],t.prototype,"_reflectionReflectance0",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),Object(No.c)([ha()],t.prototype,"_reflectionReflectance90",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),Object(No.c)([ha()],t.prototype,"_useRGBColor",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),Object(No.c)([ha()],t.prototype,"_enableNoise",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),Object(No.c)([ha()],t.prototype,"_maxSimultaneousLights",void 0),Object(No.c)([da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(No.c)([Aa()],t.prototype,"_imageProcessingConfiguration",void 0),t}(Eu);Eo.RegisteredTypes["BABYLON.BackgroundMaterial"]=lp;var cp=function(){function e(t,n){var r=this;this._errorHandler=function(e,t){r.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=Object(No.a)(Object(No.a)({},e._getDefaultOptions()),t),this._scene=n,this.onErrorObservable=new yo.a,this._setupBackground(),this._setupImageProcessing()}return e._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new Io(.2,.2,.3).toLinearSpace().scale(3),groundOpacity:.9,enableGroundShadow:!0,groundShadowLevel:.5,enableGroundMirror:!1,groundMirrorSizeRatio:.3,groundMirrorBlurKernel:64,groundMirrorAmount:1,groundMirrorFresnelWeight:1,groundMirrorFallOffDistance:0,groundMirrorTextureType:0,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new Io(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:So.Zero(),setupImageProcessing:!0,environmentTexture:this._environmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(e.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skybox",{get:function(){return this._skybox},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ground",{get:function(){return this._ground},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!0,configurable:!0}),e.prototype.updateOptions=function(e){var t=Object(No.a)(Object(No.a)({},this._options),e);this._ground&&!t.createGround&&(this._ground.dispose(),this._ground=null),this._groundMaterial&&!t.createGround&&(this._groundMaterial.dispose(),this._groundMaterial=null),this._groundTexture&&this._options.groundTexture!=t.groundTexture&&(this._groundTexture.dispose(),this._groundTexture=null),this._skybox&&!t.createSkybox&&(this._skybox.dispose(),this._skybox=null),this._skyboxMaterial&&!t.createSkybox&&(this._skyboxMaterial.dispose(),this._skyboxMaterial=null),this._skyboxTexture&&this._options.skyboxTexture!=t.skyboxTexture&&(this._skyboxTexture.dispose(),this._skyboxTexture=null),this._groundMirror&&!t.enableGroundMirror&&(this._groundMirror.dispose(),this._groundMirror=null),this._scene.environmentTexture&&this._options.environmentTexture!=t.environmentTexture&&this._scene.environmentTexture.dispose(),this._options=t,this._setupBackground(),this._setupImageProcessing()},e.prototype.setMainColor=function(e){this.groundMaterial&&(this.groundMaterial.primaryColor=e),this.skyboxMaterial&&(this.skyboxMaterial.primaryColor=e),this.groundMirror&&(this.groundMirror.clearColor=new ko(e.r,e.g,e.b,1))},e.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())},e.prototype._setupEnvironmentTexture=function(){if(!this._scene.environmentTexture)if(this._options.environmentTexture instanceof Ql)this._scene.environmentTexture=this._options.environmentTexture;else{var e=tp.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new Pl("BackgroundHelper",this._scene)),this._rootMesh.rotation.y=this._options.backgroundYRotation;var e=this._getSceneSize();this._options.createGround&&(this._setupGround(e),this._setupGroundMaterial(),this._setupGroundDiffuseTexture(),this._options.enableGroundMirror&&this._setupGroundMirrorTexture(e),this._setupMirrorInGroundMaterial()),this._options.createSkybox&&(this._setupSkybox(e),this._setupSkyboxMaterial(),this._setupSkyboxReflectionTexture()),this._rootMesh.position.x=e.rootPosition.x,this._rootMesh.position.z=e.rootPosition.z,this._rootMesh.position.y=e.rootPosition.y},e.prototype._getSceneSize=function(){var e=this,t=this._options.groundSize,n=this._options.skyboxSize,r=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:t,skyboxSize:n,rootPosition:r};var i=this._scene.getWorldExtends((function(t){return t!==e._ground&&t!==e._rootMesh&&t!==e._skybox})),o=i.max.subtract(i.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof Sc&&this._scene.activeCamera.upperRadiusLimit&&(n=t=2*this._scene.activeCamera.upperRadiusLimit);var a=o.length();a>t&&(n=t=2*a),t*=1.1,n*=1.5,(r=i.min.add(o.scale(.5))).y=i.min.y-this._options.groundYBias}return{groundSize:t,skyboxSize:n,rootPosition:r}},e.prototype._setupGround=function(e){var t=this;this._ground&&!this._ground.isDisposed()||(this._ground=Pl.CreatePlane("BackgroundPlane",e.groundSize,this._scene),this._ground.rotation.x=Math.PI/2,this._ground.parent=this._rootMesh,this._ground.onDisposeObservable.add((function(){t._ground=null}))),this._ground.receiveShadows=this._options.enableGroundShadow},e.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new lp("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=8,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)},e.prototype._setupGroundDiffuseTexture=function(){if(this._groundMaterial&&!this._groundTexture)if(this._options.groundTexture instanceof Ql)this._groundMaterial.diffuseTexture=this._options.groundTexture;else{var e=new Wl(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler);e.gammaSpace=!1,e.hasAlpha=!0,this._groundMaterial.diffuseTexture=e}},e.prototype._setupGroundMirrorTexture=function(e){var t=Wl.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new ep("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Wl.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new Cs(0,-1,0,e.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=t,this._groundMirror.wrapV=t,this._groundMirror.gammaSpace=!1,this._groundMirror.renderList))for(var n=0;n0&&e.push(this._texture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)},e.prototype.dispose=function(e){e&&(this._texture&&this._texture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._tintTexture&&this._tintTexture.dispose())},e.prototype.getClassName=function(){return"PBRClearCoatConfiguration"},e.AddFallbacks=function(e,t,n){return e.CLEARCOAT_BUMP&&t.addFallback(n++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(n++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(n++,"CLEARCOAT"),n},e.AddUniforms=function(e){e.push("vClearCoatTangentSpaceParams","vClearCoatParams","vClearCoatRefractionParams","vClearCoatTintParams","clearCoatColorAtDistance","clearCoatMatrix","clearCoatBumpMatrix","clearCoatTintMatrix","vClearCoatInfos","vClearCoatBumpInfos","vClearCoatTintInfos")},e.AddSamplers=function(e){e.push("clearCoatSampler","clearCoatBumpSampler","clearCoatTintSampler")},e.PrepareUniformBuffer=function(e){e.addUniform("vClearCoatParams",2),e.addUniform("vClearCoatRefractionParams",4),e.addUniform("vClearCoatInfos",2),e.addUniform("clearCoatMatrix",16),e.addUniform("vClearCoatBumpInfos",2),e.addUniform("vClearCoatTangentSpaceParams",2),e.addUniform("clearCoatBumpMatrix",16),e.addUniform("vClearCoatTintParams",4),e.addUniform("clearCoatColorAtDistance",1),e.addUniform("vClearCoatTintInfos",2),e.addUniform("clearCoatTintMatrix",16)},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},e._DefaultIndexOfRefraction=1.5,Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(No.c)([ha()],e.prototype,"intensity",void 0),Object(No.c)([ha()],e.prototype,"roughness",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indexOfRefraction",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"bumpTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTintEnabled",void 0),Object(No.c)([fa()],e.prototype,"tintColor",void 0),Object(No.c)([ha()],e.prototype,"tintColorAtDistance",void 0),Object(No.c)([ha()],e.prototype,"tintThickness",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"tintTexture",void 0),e}(),pp=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new Co(1,0),this._texture=null,this.texture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e}var t;return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){return!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&Su.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},e.prototype.prepareDefines=function(e,t,n){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!t.isVerticesDataPresent(cs.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&Su.AnisotropicTextureEnabled?Cu.PrepareDefinesForMergedUV(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1)},e.prototype.bindForSubMesh=function(e,t,n){e.useUbo&&n&&e.isSync||(this._texture&&Su.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),Cu.BindTextureMatrix(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&Su.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},e.prototype.getClassName=function(){return"PBRAnisotropicConfiguration"},e.AddFallbacks=function(e,t,n){return e.ANISOTROPIC&&t.addFallback(n++,"ANISOTROPIC"),n},e.AddUniforms=function(e){e.push("vAnisotropy","vAnisotropyInfos","anisotropyMatrix")},e.PrepareUniformBuffer=function(e){e.addUniform("vAnisotropy",3),e.addUniform("vAnisotropyInfos",2),e.addUniform("anisotropyMatrix",16)},e.AddSamplers=function(e){e.push("anisotropySampler")},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(No.c)([ha()],e.prototype,"intensity",void 0),Object(No.c)([ua(4,t)],e.prototype,"direction",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),e}(),fp=function(){function e(t){this._useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._internalMarkAllSubMeshesAsMiscDirty=t}return e.prototype._markAllSubMeshesAsMiscDirty=function(){this._internalMarkAllSubMeshesAsMiscDirty()},e.prototype.prepareDefines=function(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation},e.prototype.getClassName=function(){return"PBRBRDFConfiguration"},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},e.DEFAULT_USE_ENERGY_CONSERVATION=!0,e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0,e.DEFAULT_USE_SPHERICAL_HARMONICS=!0,e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0,Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],e.prototype,"useEnergyConservation",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSmithVisibilityHeightCorrelated",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSphericalHarmonics",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSpecularGlossinessInputEnergyConservation",void 0),e}(),mp=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=Io.White(),this._texture=null,this.texture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){return!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&Su.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())},e.prototype.prepareDefines=function(e,t){this._isEnabled?(e.SHEEN=this._isEnabled,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&Su.SheenTextureEnabled?Cu.PrepareDefinesForMergedUV(this._texture,e,"SHEEN_TEXTURE"):e.SHEEN_TEXTURE=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_LINKWITHALBEDO=!1)},e.prototype.bindForSubMesh=function(e,t,n){e.useUbo&&n&&e.isSync||(this._texture&&Su.SheenTextureEnabled&&(e.updateFloat2("vSheenInfos",this._texture.coordinatesIndex,this._texture.level),Cu.BindTextureMatrix(this._texture,e,"sheen")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity)),t.texturesEnabled&&this._texture&&Su.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture)},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},e.prototype.getClassName=function(){return"PBRSheenConfiguration"},e.AddFallbacks=function(e,t,n){return e.SHEEN&&t.addFallback(n++,"SHEEN"),n},e.AddUniforms=function(e){e.push("vSheenColor","vSheenInfos","sheenMatrix")},e.PrepareUniformBuffer=function(e){e.addUniform("vSheenColor",4),e.addUniform("vSheenInfos",2),e.addUniform("sheenMatrix",16)},e.AddSamplers=function(e){e.push("sheenSampler")},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkSheenWithAlbedo",void 0),Object(No.c)([ha()],e.prototype,"intensity",void 0),Object(No.c)([fa()],e.prototype,"color",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),e}(),gp=function(){function e(e){this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isScatteringEnabled=!1,this.refractionIntensity=1,this.translucencyIntensity=1,this.scatteringIntensity=1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1,this.indexOfRefraction=1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.tintColor=Io.White(),this.tintColorAtDistance=1,this.diffusionDistance=Io.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&Su.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var n=this._getRefractionTexture(t);if(n&&Su.RefractionTextureEnabled&&!n.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(e,t){if(e._areTexturesDirty&&(e.SUBSURFACE=!1,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_SCATERRING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE=!1,e.SS_REFRACTION=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled)&&(e.SUBSURFACE=!0,e._areTexturesDirty&&t.texturesEnabled&&this._thicknessTexture&&Su.ThicknessTextureEnabled&&Cu.PrepareDefinesForMergedUV(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),e.SS_MASK_FROM_THICKNESS_TEXTURE=this._useMaskFromThicknessTexture),this._isRefractionEnabled&&t.texturesEnabled)){var n=this._getRefractionTexture(t);n&&Su.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=n.isCube,e.SS_GAMMAREFRACTION=n.gammaSpace,e.SS_RGBDREFRACTION=n.isRGBD,e.SS_LINEARSPECULARREFRACTION=n.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=n.invertZ,e.SS_LODINREFRACTIONALPHA=n.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency)}},e.prototype.bindForSubMesh=function(e,t,n,r,i){var o=this._getRefractionTexture(t);if(!e.useUbo||!r||!e.isSync){if(this._thicknessTexture&&Su.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),Cu.BindTextureMatrix(this._thicknessTexture,e,"thickness")),e.updateFloat2("vThicknessParam",this.minimumThickness,this.maximumThickness-this.minimumThickness),o&&Su.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",o.getReflectionTextureMatrix());var a=1;o.isCube||o.depth&&(a=o.depth),e.updateFloat4("vRefractionInfos",o.level,1/this._indexOfRefraction,a,this._invertRefractionY?-1:1),e.updateFloat3("vRefractionMicrosurfaceInfos",o.getSize().width,o.lodGenerationScale,o.lodGenerationOffset)}e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,this.tintColorAtDistance),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,this.scatteringIntensity)}t.texturesEnabled&&(this._thicknessTexture&&Su.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),o&&Su.RefractionTextureEnabled&&(i?e.setTexture("refractionSampler",o):(e.setTexture("refractionSampler",o._lodTextureMid||o),e.setTexture("refractionSamplerLow",o._lodTextureLow||o),e.setTexture("refractionSamplerHigh",o._lodTextureHigh||o))))},e.prototype.unbind=function(e){return!(!this._refractionTexture||!this._refractionTexture.isRenderTarget)&&(e.setTexture("refractionSampler",null),!0)},e.prototype._getRefractionTexture=function(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null},Object.defineProperty(e.prototype,"disableAlphaBlending",{get:function(){return this.isRefractionEnabled&&this._linkRefractionWithTransparency},enumerable:!0,configurable:!0}),e.prototype.fillRenderTargetTextures=function(e){Su.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)},e.prototype.hasTexture=function(e){return this._thicknessTexture===e||this._refractionTexture===e},e.prototype.hasRenderTargetTextures=function(){return!!(Su.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},e.prototype.getActiveTextures=function(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture)},e.prototype.getAnimatables=function(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture)},e.prototype.dispose=function(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose())},e.prototype.getClassName=function(){return"PBRSubSurfaceConfiguration"},e.AddFallbacks=function(e,t,n){return e.SS_SCATERRING&&t.addFallback(n++,"SS_SCATERRING"),e.SS_TRANSLUCENCY&&t.addFallback(n++,"SS_TRANSLUCENCY"),n},e.AddUniforms=function(e){e.push("vDiffusionDistance","vTintColor","vSubSurfaceIntensity","vRefractionMicrosurfaceInfos","vRefractionInfos","vThicknessInfos","vThicknessParam","refractionMatrix","thicknessMatrix")},e.AddSamplers=function(e){e.push("thicknessSampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh")},e.PrepareUniformBuffer=function(e){e.addUniform("vRefractionMicrosurfaceInfos",3),e.addUniform("vRefractionInfos",4),e.addUniform("refractionMatrix",16),e.addUniform("vThicknessInfos",2),e.addUniform("thicknessMatrix",16),e.addUniform("vThicknessParam",2),e.addUniform("vDiffusionDistance",3),e.addUniform("vTintColor",4),e.addUniform("vSubSurfaceIntensity",3)},e.prototype.copyTo=function(e){ya.Clone((function(){return e}),this)},e.prototype.serialize=function(){return ya.Serialize(this)},e.prototype.parse=function(e,t,n){var r=this;ya.Parse((function(){return r}),e,t,n)},Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isRefractionEnabled",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTranslucencyEnabled",void 0),Object(No.c)([ha()],e.prototype,"refractionIntensity",void 0),Object(No.c)([ha()],e.prototype,"translucencyIntensity",void 0),Object(No.c)([ha()],e.prototype,"scatteringIntensity",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"thicknessTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"refractionTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indexOfRefraction",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"invertRefractionY",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkRefractionWithTransparency",void 0),Object(No.c)([ha()],e.prototype,"minimumThickness",void 0),Object(No.c)([ha()],e.prototype,"maximumThickness",void 0),Object(No.c)([fa()],e.prototype,"tintColor",void 0),Object(No.c)([ha()],e.prototype,"tintColorAtDistance",void 0),Object(No.c)([fa()],e.prototype,"diffusionDistance",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useMaskFromThicknessTexture",void 0),e}(),bp="uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n#endif";Qc.a.IncludesShadersStore.pbrFragmentDeclaration=bp;var vp="layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float pointSize;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";Qc.a.IncludesShadersStore.pbrUboDeclaration=vp;var Ap="uniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif";Qc.a.IncludesShadersStore.pbrFragmentExtraDeclaration=Ap;var _p="#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform samplerCube irradianceSampler;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform sampler2D reflectionSamplerLow;\nuniform sampler2D reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform sampler2D irradianceSampler;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\n#ifdef SS_REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\n#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1\n#define vThicknessUV vMainUV1\n#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2\n#define vThicknessUV vMainUV2\n#else\nvarying vec2 vThicknessUV;\n#endif\nuniform sampler2D thicknessSampler;\n#endif\n#endif";Qc.a.IncludesShadersStore.pbrFragmentSamplersDeclaration=_p;var yp="\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\n\n\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n\n\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\n\n\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\n\n\n\nvec3 cocaLambert(vec3 alpha,float distance) {\nreturn exp(-alpha*distance);\n}\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n\n\n\n\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif";Qc.a.IncludesShadersStore.pbrHelperFunctions=yp;var xp="#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n\n\n\n\n\n\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nreturn vSphericalL00\n+vSphericalL1_1*(normal.y)\n+vSphericalL10*(normal.z)\n+vSphericalL11*(normal.x)\n+vSphericalL2_2*(normal.y*normal.x)\n+vSphericalL2_1*(normal.y*normal.z)\n+vSphericalL20*((3.0*normal.z*normal.z)-1.0)\n+vSphericalL21*(normal.z*normal.x)\n+vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));\n}\n#else\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\n}\n#endif\n#endif";Qc.a.IncludesShadersStore.harmonicsFunctions=xp;var wp="\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotLUnclamped;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\nresult.NdotLUnclamped=result.NdotL;\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";Qc.a.IncludesShadersStore.pbrDirectLightingSetupFunctions=wp;var Ep="float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/maxEps(lightDistanceSquared);\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=saturate(1.0-factor*factor);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}";Qc.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions=Ep;var Cp="\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n\n\n\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec4 brdfLookup=texture2D(environmentBrdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(REFLECTION)\n\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\n\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\n\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n\n\n\n\n#ifdef BRDF_V_HEIGHT_CORRELATED\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n#endif\n#ifdef SHEEN\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n#endif\n\n\n\n\n\n\n\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n#ifdef SS_TRANSLUCENCY\n\n\nvec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {\nvec3 S=1./maxEps(diffusionDistance);\nvec3 temp=exp((-0.333333333*thickness)*S);\nreturn tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);\n}\n\n\nfloat computeWrappedDiffuseNdotL(float NdotL,float w) {\nfloat t=1.0+w;\nfloat invt2=1.0/square(t);\nreturn saturate((NdotL+w)*invt2);\n}\n#endif\n";Qc.a.IncludesShadersStore.pbrBRDFFunctions=Cp;var Sp="#define CLEARCOATREFLECTANCE90 1.0\n\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\n\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SS_TRANSLUCENCY\nvec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {\nfloat NdotL=absEps(info.NdotLUnclamped);\n\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\n\nfloat trAdapt=step(0.,info.NdotLUnclamped);\nvec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);\nfloat diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;\n}\n#endif\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat kelemenVisibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*kelemenVisibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n\nfloat fresnel=1.;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\nfloat ashikhminvisibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\nfloat sheenTerm=fresnel*distribution*ashikhminvisibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";Qc.a.IncludesShadersStore.pbrDirectLightingFunctions=Sp;var Tp="#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {\nfloat lod=log2(cubeMapDimensionPixels)*roughness;\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,normal));\nreturn square(temp);\n}\n#endif\n\n\n\n\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif";Qc.a.IncludesShadersStore.pbrIBLFunctions=Tp;var Pp="#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w=1)&&e.prototype.needAlphaBlendingForMesh.call(this,t)},t.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this.subSurface.disableAlphaBlending&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&(null==this._transparencyMode||this._transparencyMode===t.PBRMATERIAL_ALPHATEST))},t.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==t.PBRMATERIAL_OPAQUE},t.prototype.getAlphaTestTexture=function(){return this._albedoTexture},t.prototype.isReadyForSubMesh=function(e,t,n){if(t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new Ip);var r=t._materialDefines;if(!this.checkReadyOnEveryCall&&t.effect&&r._renderId===this.getScene().getRenderId())return!0;var i=this.getScene(),o=i.getEngine();if(r._areTexturesDirty&&i.texturesEnabled){if(this._albedoTexture&&Su.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&Su.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&Su.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var a=this._getReflectionTexture();if(a&&Su.ReflectionTextureEnabled){if(!a.isReadyOrNotBlocking())return!1;if(a.irradianceTexture&&!a.irradianceTexture.isReadyOrNotBlocking())return!1}if(this._lightmapTexture&&Su.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&Su.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(Su.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&Su.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;if(this._environmentBRDFTexture&&Su.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(!(this.subSurface.isReadyForSubMesh(r,i)&&this.clearCoat.isReadyForSubMesh(r,i,o,this._disableBumpMap)&&this.sheen.isReadyForSubMesh(r,i)&&this.anisotropy.isReadyForSubMesh(r,i)))return!1;if(r._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;o.getCaps().standardDerivatives||e.isVerticesDataPresent(cs.NormalKind)||(e.createNormals(!0),jo.a.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var s=t.effect,l=r._areLightsDisposed,c=this._prepareEffect(e,r,this.onCompiled,this.onError,n);if(c)if(this.allowShaderHotSwapping&&s&&!c.isReady()){if(c=s,this._rebuildInParallel=!0,r.markAsUnprocessed(),l)return r._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,i.resetCachedMaterial(),t.setEffect(c,r),this.buildUniformLayout();return!(!t.effect||!t.effect.isReady())&&(r._renderId=i.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.isMetallicWorkflow=function(){return!(null==this._metallic&&null==this._roughness&&!this._metallicTexture)},t.prototype._prepareEffect=function(e,t,n,r,i,o){if(void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=null),this._prepareDefines(e,t,i,o),!t.isDirty)return null;t.markAsProcessed();var a=this.getScene().getEngine(),s=new ud,l=0;t.USESPHERICALINVERTEX&&s.addFallback(l++,"USESPHERICALINVERTEX"),t.FOG&&s.addFallback(l,"FOG"),t.SPECULARAA&&s.addFallback(l,"SPECULARAA"),t.POINTSIZE&&s.addFallback(l,"POINTSIZE"),t.LOGARITHMICDEPTH&&s.addFallback(l,"LOGARITHMICDEPTH"),t.PARALLAX&&s.addFallback(l,"PARALLAX"),t.PARALLAXOCCLUSION&&s.addFallback(l++,"PARALLAXOCCLUSION"),l=pp.AddFallbacks(t,s,l),l=pp.AddFallbacks(t,s,l),l=gp.AddFallbacks(t,s,l),l=mp.AddFallbacks(t,s,l),t.ENVIRONMENTBRDF&&s.addFallback(l++,"ENVIRONMENTBRDF"),t.TANGENT&&s.addFallback(l++,"TANGENT"),t.BUMP&&s.addFallback(l++,"BUMP"),l=Cu.HandleFallbacksForShadows(t,s,this._maxSimultaneousLights,l++),t.SPECULARTERM&&s.addFallback(l++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&s.addFallback(l++,"USESPHERICALFROMREFLECTIONMAP"),t.USEIRRADIANCEMAP&&s.addFallback(l++,"USEIRRADIANCEMAP"),t.LIGHTMAP&&s.addFallback(l++,"LIGHTMAP"),t.NORMAL&&s.addFallback(l++,"NORMAL"),t.AMBIENT&&s.addFallback(l++,"AMBIENT"),t.EMISSIVE&&s.addFallback(l++,"EMISSIVE"),t.VERTEXCOLOR&&s.addFallback(l++,"VERTEXCOLOR"),t.MORPHTARGETS&&s.addFallback(l++,"MORPHTARGETS"),t.MULTIVIEW&&s.addFallback(0,"MULTIVIEW");var c=[cs.PositionKind];t.NORMAL&&c.push(cs.NormalKind),t.TANGENT&&c.push(cs.TangentKind),t.UV1&&c.push(cs.UVKind),t.UV2&&c.push(cs.UV2Kind),t.VERTEXCOLOR&&c.push(cs.ColorKind),Cu.PrepareAttributesForBones(c,e,t,s),Cu.PrepareAttributesForInstances(c,t),Cu.PrepareAttributesForMorphTargets(c,e,t);var u="pbr",d=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","visibility","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","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"],h=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","microSurfaceSampler","environmentBrdfSampler","boneSampler"],p=["Material","Scene"];gp.AddUniforms(d),gp.AddSamplers(h),hp.AddUniforms(d),hp.AddSamplers(h),pp.AddUniforms(d),pp.AddSamplers(h),mp.AddUniforms(d),mp.AddSamplers(h),Ms&&(Ms.PrepareUniforms(d,t),Ms.PrepareSamplers(h,t)),Cu.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:h,defines:t,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,d,p,h,t));var f=t.toString();return a.createEffect(u,{attributes:c,uniformsNames:d,uniformBuffersNames:p,samplers:h,defines:f,fallbacks:s,onCompiled:n,onError:r,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS}},a)},t.prototype._prepareDefines=function(e,n,r,i){void 0===r&&(r=null),void 0===i&&(i=null);var o=this.getScene(),a=o.getEngine();if(Cu.PrepareDefinesForLights(o,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._needNormals=!0,Cu.PrepareDefinesForMultiview(o,n),n.METALLICWORKFLOW=this.isMetallicWorkflow(),n._areTexturesDirty){if(n._needUVs=!1,o.texturesEnabled){o.getEngine().getCaps().textureLOD&&(n.LODBASEDMICROSFURACE=!0),this._albedoTexture&&Su.DiffuseTextureEnabled?(Cu.PrepareDefinesForMergedUV(this._albedoTexture,n,"ALBEDO"),n.GAMMAALBEDO=this._albedoTexture.gammaSpace):n.ALBEDO=!1,this._ambientTexture&&Su.AmbientTextureEnabled?(Cu.PrepareDefinesForMergedUV(this._ambientTexture,n,"AMBIENT"),n.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):n.AMBIENT=!1,this._opacityTexture&&Su.OpacityTextureEnabled?(Cu.PrepareDefinesForMergedUV(this._opacityTexture,n,"OPACITY"),n.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):n.OPACITY=!1;var s=this._getReflectionTexture();if(s&&Su.ReflectionTextureEnabled){switch(n.REFLECTION=!0,n.GAMMAREFLECTION=s.gammaSpace,n.RGBDREFLECTION=s.isRGBD,n.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,n.LODINREFLECTIONALPHA=s.lodLevelInAlpha,n.LINEARSPECULARREFLECTION=s.linearSpecularLOD,s.coordinatesMode===Wl.INVCUBIC_MODE&&(n.INVERTCUBICMAP=!0),n.REFLECTIONMAP_3D=s.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,s.coordinatesMode){case Wl.EXPLICIT_MODE:n.REFLECTIONMAP_EXPLICIT=!0;break;case Wl.PLANAR_MODE:n.REFLECTIONMAP_PLANAR=!0;break;case Wl.PROJECTION_MODE:n.REFLECTIONMAP_PROJECTION=!0;break;case Wl.SKYBOX_MODE:n.REFLECTIONMAP_SKYBOX=!0;break;case Wl.SPHERICAL_MODE:n.REFLECTIONMAP_SPHERICAL=!0;break;case Wl.EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Wl.FIXED_EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Wl.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Wl.CUBIC_MODE:case Wl.INVCUBIC_MODE:default:n.REFLECTIONMAP_CUBIC=!0,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!!s.boundingBoxSize}s.coordinatesMode!==Wl.SKYBOX_MODE&&(s.irradianceTexture?(n.USEIRRADIANCEMAP=!0,n.USESPHERICALFROMREFLECTIONMAP=!1):s.isCube&&(n.USESPHERICALFROMREFLECTIONMAP=!0,n.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||o.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&&Su.LightmapTextureEnabled?(Cu.PrepareDefinesForMergedUV(this._lightmapTexture,n,"LIGHTMAP"),n.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,n.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,n.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):n.LIGHTMAP=!1,this._emissiveTexture&&Su.EmissiveTextureEnabled?Cu.PrepareDefinesForMergedUV(this._emissiveTexture,n,"EMISSIVE"):n.EMISSIVE=!1,Su.SpecularTextureEnabled?(this._metallicTexture?(Cu.PrepareDefinesForMergedUV(this._metallicTexture,n,"REFLECTIVITY"),n.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,n.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,n.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,n.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,n.METALLICF0FACTORFROMMETALLICMAP=this._useMetallicF0FactorFromMetallicTexture):this._reflectivityTexture?(Cu.PrepareDefinesForMergedUV(this._reflectivityTexture,n,"REFLECTIVITY"),n.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,n.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):n.REFLECTIVITY=!1,this._microSurfaceTexture?Cu.PrepareDefinesForMergedUV(this._microSurfaceTexture,n,"MICROSURFACEMAP"):n.MICROSURFACEMAP=!1):(n.REFLECTIVITY=!1,n.MICROSURFACEMAP=!1),o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&Su.BumpTextureEnabled&&!this._disableBumpMap?(Cu.PrepareDefinesForMergedUV(this._bumpTexture,n,"BUMP"),this._useParallax&&this._albedoTexture&&Su.DiffuseTextureEnabled?(n.PARALLAX=!0,n.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):n.PARALLAX=!1,n.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):n.BUMP=!1,this._environmentBRDFTexture&&Su.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=o.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(n._areTexturesDirty||n._areMiscDirty)&&(n.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?".":""),n.PREMULTIPLYALPHA=7===this.alphaMode||8===this.alphaMode,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&&(Cu.PrepareDefinesForMisc(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,n),n.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(cs.NormalKind),n.DEBUGMODE=this._debugMode),this.subSurface.prepareDefines(n,o),this.clearCoat.prepareDefines(n,o),this.anisotropy.prepareDefines(n,e,o),this.brdf.prepareDefines(n),this.sheen.prepareDefines(n,o),Cu.PrepareDefinesForFrameBoundValues(o,a,n,!!r,i),Cu.PrepareDefinesForAttributes(e,n,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE)},t.prototype.forceCompilation=function(e,t,n){var r=this,i=Object(No.a)({clipPlane:!1,useInstances:!1},n),o=new Ip,a=this._prepareEffect(e,o,void 0,void 0,i.useInstances,i.clipPlane);a.isReady()?t&&t(this):a.onCompileObservable.add((function(){t&&t(r)}))},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("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),hp.PrepareUniformBuffer(e),pp.PrepareUniformBuffer(e),mp.PrepareUniformBuffer(e),gp.PrepareUniformBuffer(e),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),t=!0),this.subSurface.unbind(this._activeEffect)&&(t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,t,n){var r=this.getScene(),i=n._materialDefines;if(i){var o=n.effect;if(o){this._activeEffect=o,i.INSTANCES||this.bindOnlyWorldMatrix(e),i.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var a=this._mustRebind(r,o,t.visibility);Cu.BindBonesParameters(t,this._activeEffect);var s=null,l=this._uniformBuffer;if(a){var c=r.getEngine();if(l.bindToEffect(o,"Material"),this.bindViewProjection(o),s=this._getReflectionTexture(),!l.useUbo||!this.isFrozen||!l.isSync){if(r.texturesEnabled){if(this._albedoTexture&&Su.DiffuseTextureEnabled&&(l.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),Cu.BindTextureMatrix(this._albedoTexture,l,"albedo")),this._ambientTexture&&Su.AmbientTextureEnabled&&(l.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),Cu.BindTextureMatrix(this._ambientTexture,l,"ambient")),this._opacityTexture&&Su.OpacityTextureEnabled&&(l.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),Cu.BindTextureMatrix(this._opacityTexture,l,"opacity")),s&&Su.ReflectionTextureEnabled){if(l.updateMatrix("reflectionMatrix",s.getReflectionTextureMatrix()),l.updateFloat2("vReflectionInfos",s.level,0),s.boundingBoxSize){var u=s;l.updateVector3("vReflectionPosition",u.boundingBoxPosition),l.updateVector3("vReflectionSize",u.boundingBoxSize)}if(!i.USEIRRADIANCEMAP){var d=s.sphericalPolynomial;if(i.USESPHERICALFROMREFLECTIONMAP&&d)if(i.SPHERICAL_HARMONICS){var h=d.preScaledHarmonics;this._activeEffect.setVector3("vSphericalL00",h.l00),this._activeEffect.setVector3("vSphericalL1_1",h.l1_1),this._activeEffect.setVector3("vSphericalL10",h.l10),this._activeEffect.setVector3("vSphericalL11",h.l11),this._activeEffect.setVector3("vSphericalL2_2",h.l2_2),this._activeEffect.setVector3("vSphericalL2_1",h.l2_1),this._activeEffect.setVector3("vSphericalL20",h.l20),this._activeEffect.setVector3("vSphericalL21",h.l21),this._activeEffect.setVector3("vSphericalL22",h.l22)}else this._activeEffect.setFloat3("vSphericalX",d.x.x,d.x.y,d.x.z),this._activeEffect.setFloat3("vSphericalY",d.y.x,d.y.y,d.y.z),this._activeEffect.setFloat3("vSphericalZ",d.z.x,d.z.y,d.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",d.xx.x-d.zz.x,d.xx.y-d.zz.y,d.xx.z-d.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",d.yy.x-d.zz.x,d.yy.y-d.zz.y,d.yy.z-d.zz.z),this._activeEffect.setFloat3("vSphericalZZ",d.zz.x,d.zz.y,d.zz.z),this._activeEffect.setFloat3("vSphericalXY",d.xy.x,d.xy.y,d.xy.z),this._activeEffect.setFloat3("vSphericalYZ",d.yz.x,d.yz.y,d.yz.z),this._activeEffect.setFloat3("vSphericalZX",d.zx.x,d.zx.y,d.zx.z)}l.updateFloat3("vReflectionMicrosurfaceInfos",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset)}this._emissiveTexture&&Su.EmissiveTextureEnabled&&(l.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),Cu.BindTextureMatrix(this._emissiveTexture,l,"emissive")),this._lightmapTexture&&Su.LightmapTextureEnabled&&(l.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),Cu.BindTextureMatrix(this._lightmapTexture,l,"lightmap")),Su.SpecularTextureEnabled&&(this._metallicTexture?(l.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),Cu.BindTextureMatrix(this._metallicTexture,l,"reflectivity")):this._reflectivityTexture&&(l.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),Cu.BindTextureMatrix(this._reflectivityTexture,l,"reflectivity")),this._microSurfaceTexture&&(l.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),Cu.BindTextureMatrix(this._microSurfaceTexture,l,"microSurfaceSampler"))),this._bumpTexture&&c.getCaps().standardDerivatives&&Su.BumpTextureEnabled&&!this._disableBumpMap&&(l.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),Cu.BindTextureMatrix(this._bumpTexture,l,"bump"),r._mirroredCameraPosition?l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&l.updateFloat("pointSize",this.pointSize),i.METALLICWORKFLOW){Do.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,Do.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness;var p=.08*this._metallicF0Factor;l.updateColor4("vReflectivityColor",Do.Color3[0],p)}else l.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);l.updateColor3("vEmissiveColor",Su.EmissiveTextureEnabled?this._emissiveColor:Io.BlackReadOnly),l.updateColor3("vReflectionColor",this._reflectionColor),!i.SS_REFRACTION&&this.subSurface.linkRefractionWithTransparency?l.updateColor4("vAlbedoColor",this._albedoColor,1):l.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),l.updateFloat("visibility",t.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*r.environmentIntensity,this._lightingInfos.w=this._specularIntensity,l.updateVector4("vLightingIntensity",this._lightingInfos)}r.texturesEnabled&&(this._albedoTexture&&Su.DiffuseTextureEnabled&&l.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&Su.AmbientTextureEnabled&&l.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&Su.OpacityTextureEnabled&&l.setTexture("opacitySampler",this._opacityTexture),s&&Su.ReflectionTextureEnabled&&(i.LODBASEDMICROSFURACE?l.setTexture("reflectionSampler",s):(l.setTexture("reflectionSampler",s._lodTextureMid||s),l.setTexture("reflectionSamplerLow",s._lodTextureLow||s),l.setTexture("reflectionSamplerHigh",s._lodTextureHigh||s)),i.USEIRRADIANCEMAP&&l.setTexture("irradianceSampler",s.irradianceTexture)),i.ENVIRONMENTBRDF&&l.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&Su.EmissiveTextureEnabled&&l.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&Su.LightmapTextureEnabled&&l.setTexture("lightmapSampler",this._lightmapTexture),Su.SpecularTextureEnabled&&(this._metallicTexture?l.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&l.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&l.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&c.getCaps().standardDerivatives&&Su.BumpTextureEnabled&&!this._disableBumpMap&&l.setTexture("bumpSampler",this._bumpTexture)),this.subSurface.bindForSubMesh(l,r,c,this.isFrozen,i.LODBASEDMICROSFURACE),this.clearCoat.bindForSubMesh(l,r,c,this._disableBumpMap,this.isFrozen,this._invertNormalMapX,this._invertNormalMapY),this.anisotropy.bindForSubMesh(l,r,this.isFrozen),this.sheen.bindForSubMesh(l,r,this.isFrozen),Cu.BindClipPlane(this._activeEffect,r),r.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var f=r._forcedViewPosition?r._forcedViewPosition:r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.globalPosition,m=r.useRightHandedSystem===(null!=r._mirroredCameraPosition);o.setFloat4("vEyePosition",f.x,f.y,f.z,m?-1:1),o.setColor3("vAmbientColor",this._globalAmbientColor),o.setFloat2("vDebugMode",this.debugLimit,this.debugFactor)}!a&&this.isFrozen||(r.lightsEnabled&&!this._disableLighting&&Cu.BindLights(r,t,this._activeEffect,i,this._maxSimultaneousLights,this._rebuildInParallel),(r.fogEnabled&&t.applyFog&&r.fogMode!==nl.FOGMODE_NONE||s)&&this.bindView(o),Cu.BindFogParameters(r,t,this._activeEffect,!0),i.NUM_MORPH_INFLUENCERS&&Cu.BindMorphTargetParameters(t,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),Cu.BindLogDepth(i,this._activeEffect,r)),l.update(),this._afterBind(t,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.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 t=e.prototype.getActiveTextures.call(this);return this._albedoTexture&&t.push(this._albedoTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._reflectivityTexture&&t.push(this._reflectivityTexture),this._metallicTexture&&t.push(this._metallicTexture),this._microSurfaceTexture&&t.push(this._microSurfaceTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this.subSurface.getActiveTextures(t),this.clearCoat.getActiveTextures(t),this.sheen.getActiveTextures(t),this.anisotropy.getActiveTextures(t),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._albedoTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._reflectivityTexture===t||(this._metallicTexture===t||(this._microSurfaceTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||(this.subSurface.hasTexture(t)||this.clearCoat.hasTexture(t)||this.sheen.hasTexture(t)||this.anisotropy.hasTexture(t)))))))))))},t.prototype.dispose=function(t,n){n&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose()),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),e.prototype.dispose.call(this,t,n)},t.PBRMATERIAL_OPAQUE=0,t.PBRMATERIAL_ALPHATEST=1,t.PBRMATERIAL_ALPHABLEND=2,t.PBRMATERIAL_ALPHATESTANDBLEND=3,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,Object(No.c)([Aa()],t.prototype,"_imageProcessingConfiguration",void 0),Object(No.c)([da("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),Object(No.c)([ha()],t.prototype,"useLogarithmicDepth",null),Object(No.c)([ha()],t.prototype,"transparencyMode",null),t}(Eu),Dp=function(e){function t(n,r){var i=e.call(this,n,r)||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=.5,i.useMetallicF0FactorFromMetallicTexture=!1,i.ambientColor=new Io(0,0,0),i.albedoColor=new Io(1,1,1),i.reflectivityColor=new Io(1,1,1),i.reflectionColor=new Io(1,1,1),i.emissiveColor=new Io(0,0,0),i.microSurface=1,i.useLightmapAsShadowmap=!1,i.useAlphaFromAlbedoTexture=!1,i.forceAlphaTest=!1,i.alphaCutOff=.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=.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=dp.GetEnvironmentBRDFTexture(r),i}return Object(No.d)(t,e),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:!0,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return 1/this.subSurface.indexOfRefraction},set:function(e){this.subSurface.indexOfRefraction=1/e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"invertRefractionY",{get:function(){return this.subSurface.invertRefractionY},set:function(e){this.subSurface.invertRefractionY=e},enumerable:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===kp.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?kp.LIGHTFALLOFF_PHYSICAL:kp.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===kp.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?kp.LIGHTFALLOFF_GLTF:kp.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"PBRMaterial"},t.prototype.clone=function(e){var n=this,r=ya.Clone((function(){return new t(e,n.getScene())}),this);return r.id=e,r.name=e,this.clearCoat.copyTo(r.clearCoat),this.anisotropy.copyTo(r.anisotropy),this.brdf.copyTo(r.brdf),this.sheen.copyTo(r.sheen),this.subSurface.copyTo(r.subSurface),r},t.prototype.serialize=function(){var e=ya.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,r){var i=ya.Parse((function(){return new t(e.name,n)}),e,n,r);return e.clearCoat&&i.clearCoat.parse(e.clearCoat,n,r),e.anisotropy&&i.anisotropy.parse(e.anisotropy,n,r),e.brdf&&i.brdf.parse(e.brdf,n,r),e.sheen&&i.sheen.parse(e.sheen,n,r),e.subSurface&&i.subSurface.parse(e.subSurface,n,r),i},t.PBRMATERIAL_OPAQUE=kp.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=kp.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=kp.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=kp.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=kp.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicF0Factor",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallicF0FactorFromMetallicTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),Object(No.c)([fa("ambient"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),Object(No.c)([fa("albedo"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),Object(No.c)([fa("reflectivity"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),Object(No.c)([fa("reflection"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),Object(No.c)([fa("emissive"),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),Object(No.c)([ha()],t.prototype,"usePhysicalLightFalloff",null),Object(No.c)([ha()],t.prototype,"useGLTFLightFalloff",null),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),Object(No.c)([pa(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),Object(No.c)([ha(),da("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),t}(kp);Eo.RegisteredTypes["BABYLON.PBRMaterial"]=Dp;function Bp(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var Fp=Bp("DXT1"),Np=Bp("DXT3"),Lp=Bp("DXT5"),Up=Bp("DX10"),Vp=function(){function e(){}return e.GetDDSInfo=function(e){var t=new Int32Array(e.buffer,e.byteOffset,31),n=new Int32Array(e.buffer,e.byteOffset,35),r=1;131072&t[2]&&(r=Math.max(1,t[7]));var i=t[21],o=i===Up?n[32]:0,a=0;switch(i){case 113:a=2;break;case 116:a=1;break;case Up:if(10===o){a=2;break}if(2===o){a=1;break}}return{width:t[4],height:t[3],mipmapCount:r,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:131072==(131072&t[20]),isCube:512==(512&t[28]),isCompressed:i===Fp||i===Np||i===Lp,dxgiFormat:o,textureType:a}},e._ToHalfFloat=function(t){e._FloatView||(e._FloatView=new Float32Array(1),e._Int32View=new Int32Array(e._FloatView.buffer)),e._FloatView[0]=t;var n=e._Int32View[0],r=n>>16&32768,i=n>>12&2047,o=n>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&n):o<113?r|=((i|=2048)>>114-o)+(i>>113-o&1):(r|=o-112<<10|i>>1,r+=1&i)},e._FromHalfFloat=function(e){var t=(32768&e)>>15,n=(31744&e)>>10,r=1023&e;return 0===n?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==n?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,n-15)*(1+r/Math.pow(2,10))},e._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,n,r,i,o,a){for(var s=new Float32Array(i),l=new Uint16Array(o,r),c=0,u=0;u>8)},e._GetRGBArrayBuffer=function(e,t,n,r,i,o,a,s){for(var l=new Uint8Array(r),c=new Uint8Array(i,n),u=0,d=0;d>8&255,w>>16&255,w>>24&255)))}var S=e._ExtractLongWordOrder(v[23]),T=e._ExtractLongWordOrder(v[24]),P=e._ExtractLongWordOrder(v[25]),O=e._ExtractLongWordOrder(v[26]);E&&(_=t._getRGBABufferInternalSizedFormat(i.textureType)),m=1,131072&v[2]&&!1!==o&&(m=Math.max(1,v[7]));for(var R=l||0;R0?i.sphericalPolynomial=ch.ConvertCubeMapToSphericalPolynomial({size:v[4],right:c[0],left:c[1],up:c[2],down:c[3],front:c[4],back:c[5],format:5,type:1,gammaSpace:!1}):i.sphericalPolynomial=void 0}else jo.a.Error("Compressed textures are not supported on this platform.");else jo.a.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else jo.a.Error("Invalid magic number in DDS header")},e.StoreLODInAlphaChannel=!1,e}();Va.a.prototype.createPrefilteredCubeTexture=function(e,t,n,r,i,o,a,s,l){var c=this;void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=!0);return this.createCubeTexture(e,t,null,!1,(function(e){if(e){var o=e.texture;if(l?e.info.sphericalPolynomial&&(o._sphericalPolynomial=e.info.sphericalPolynomial):o._sphericalPolynomial=new sh,o._source=Kl.b.CubePrefiltered,c.getCaps().textureLOD)i&&i(o);else{var a=c._gl,s=e.width;if(s){for(var u=[],d=0;d<3;d++){var h=1-d/2,p=r,f=xo.Log2(s)*n+r,m=p+(f-p)*h,g=Math.round(Math.min(Math.max(m,0),f)),b=new Kl.a(c,Kl.b.Temp);if(b.type=o.type,b.format=o.format,b.width=Math.pow(2,Math.max(xo.Log2(s)-g,0)),b.height=b.width,b.isCube=!0,c._bindTextureDirectly(a.TEXTURE_CUBE_MAP,b,!0),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),e.isDDS){var v=e.info,A=e.data;c._unpackFlipY(v.isCompressed),Vp.UploadDDSLevels(c,b,A,v,!0,6,g)}else jo.a.Warn("DDS is the only prefiltered cube map supported so far.");c._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var _=new Ql(t);_.isCube=!0,_._texture=b,b.isReady=!0,u.push(_)}o._lodTextureHigh=u[2],o._lodTextureMid=u[1],o._lodTextureLow=u[0],i&&i(o)}}}else i&&i(null)}),o,a,s,l,n,r)};var zp=function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e){return Jo.a.EndsWith(e,".dds")},e.prototype.loadCubeData=function(e,t,n,r,i){var o,a=t.getEngine(),s=!1;if(Array.isArray(e))for(var l=0;l1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Vp.UploadDDSLevels(a,t,c,o,s,6,-1,l),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t)}else{var u=e;o=Vp.GetDDSInfo(u),t.width=o.width,t.height=o.height,n&&(o.sphericalPolynomial=new sh),s=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Vp.UploadDDSLevels(a,t,u,o,s,6),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t,!1)}a._setCubeMapTextureParams(s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r({isDDS:!0,width:t.width,info:o,data:e,texture:t})},e.prototype.loadData=function(e,t,n){var r=Vp.GetDDSInfo(e),i=(r.isRGB||r.isLuminance||r.mipmapCount>1)&&t.generateMipMaps&&r.width>>r.mipmapCount-1==1;n(r.width,r.height,i,r.isFourCC,(function(){Vp.UploadDDSLevels(t.getEngine(),t,e,r,i,1)}))},e}();ss.a._TextureLoaders.push(new zp);var jp=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return Jo.a.EndsWith(e,".env")},e.prototype.loadCubeData=function(e,t,n,r,i){if(!Array.isArray(e)){var o=fh.GetEnvInfo(e);o?(t.width=o.width,t.height=o.width,fh.UploadEnvSpherical(t,o),fh.UploadEnvLevelsAsync(t,e,o).then((function(){t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}))):i&&i("Can not parse the environment file",null)}},e.prototype.loadData=function(e,t,n){throw".env not supported in 2d."},e}();ss.a._TextureLoaders.push(new jp);var Gp=function(){function e(t,n,r,i){if(this.data=t,this.isInvalid=!1,!e.IsValid(t))return this.isInvalid=!0,void jo.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=67305985===a.getUint32(0,!0);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),0===this.glType?(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0!==this.pixelHeight&&0===this.pixelDepth?0===this.numberOfArrayElements?this.numberOfFaces===n?this.loadType=e.COMPRESSED_2D:jo.a.Error("number of faces expected"+n+", but found "+this.numberOfFaces):jo.a.Error("texture arrays not currently supported"):jo.a.Error("only 2D textures currently supported")):jo.a.Error("only compressed formats currently supported")}return e.prototype.uploadLevels=function(t,n){switch(this.loadType){case e.COMPRESSED_2D:this._upload2DCompressedLevels(t,n);break;case e.TEX_2D:case e.COMPRESSED_3D:case e.TEX_3D:}},e.prototype._upload2DCompressedLevels=function(t,n){for(var r=e.HEADER_LEN+this.bytesOfKeyValueData,i=this.pixelWidth,o=this.pixelHeight,a=n?this.numberOfMipmapLevels:1,s=0;s=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e.HEADER_LEN=64,e.COMPRESSED_2D=0,e.COMPRESSED_3D=1,e.TEX_2D=2,e.TEX_3D=3,e}(),Hp=function(){function e(t){var n=this;e._ModulePromise||(e._ModulePromise=new Promise((function(r){LIBKTX().then((function(i){i.GL.makeContextCurrent(i.GL.registerContext(t._gl,{majorVersion:t._webGLVersion})),e._TranscodeFormat=n._determineTranscodeFormat(i.TranscodeTarget,t.getCaps()),r({module:i})}))})))}return e.prototype.uploadAsync=function(t,n){return e._ModulePromise.then((function(r){var i=new r.module.ktxTexture(t);try{i.isBasisSupercompressed&&i.transcodeBasis(e._TranscodeFormat,0),n.width=n.baseWidth=i.baseWidth,n.height=n.baseHeight=i.baseHeight,n.generateMipMaps=!1;var o=i.glUpload();if(0!==o.error)throw new Error("Failed to upload: "+o.error);n._webGLTexture=o.texture,n.isReady=!0}finally{i.delete()}}))},e.prototype._determineTranscodeFormat=function(e,t){if(t.s3tc)return e.BC1_OR_3;if(t.etc2)return e.ETC;throw new Error("No compatible format available")},e.IsValid=function(e){if(e.byteLength>=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&50===t[5]&&48===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e}(),Qp=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return Jo.a.EndsWith(e,".ktx")||Jo.a.EndsWith(e,".ktx2")},e.prototype.loadCubeData=function(e,t,n,r,i){if(!Array.isArray(e)){t._invertVScale=!t.invertY;var o=t.getEngine(),a=new Gp(e,6),s=a.numberOfMipmapLevels>1&&t.generateMipMaps;o._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,o._setCubeMapTextureParams(s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}},e.prototype.loadData=function(e,t,n){if(Gp.IsValid(e)){t._invertVScale=!t.invertY;var r=new Gp(e,1);n(r.pixelWidth,r.pixelHeight,t.generateMipMaps,!0,(function(){r.uploadLevels(t,t.generateMipMaps)}),r.isInvalid)}else if(Hp.IsValid(e)){new Hp(t.getEngine()).uploadAsync(e,t).then((function(){n(t.width,t.height,!1,!0,(function(){}),!1)}),(function(e){jo.a.Warn("Failed to load KTX2 texture data: "+e.message),n(0,0,!1,!1,(function(){}),!0)}))}else n(0,0,!1,!1,(function(){}),!0)},e}();ss.a._TextureLoaders.unshift(new Qp);var Wp=function(e){function t(t,n,r){var i=e.call(this,t,So.Zero(),n)||this;return i._xrSessionManager=r,i._firstFrame=!1,i._referenceQuaternion=Po.Identity(),i._referencedPosition=new So,i._xrInvPositionCache=new So,i._xrInvQuaternionCache=Po.Identity(),i.compensateOnFirstFrame=!0,i.minZ=.1,i.rotationQuaternion=new Po,i.cameraRigMode=Ts.RIG_MODE_CUSTOM,i.updateUpVectorFromRotation=!0,i._updateNumberOfRigCameras(1),i._xrSessionManager.onXRSessionInit.add((function(){i._referencedPosition.copyFromFloats(0,0,0),i._referenceQuaternion.copyFromFloats(0,0,0,1),i._firstFrame=i.compensateOnFirstFrame})),i._xrSessionManager.onXRFrameObservable.add((function(e){i._firstFrame&&i._updateFromXRSession(),i._updateReferenceSpace(),i._updateFromXRSession()}),void 0,!0),i}return Object(No.d)(t,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:!0,configurable:!0}),t.prototype._updateForDualEyeDebugging=function(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new Es(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new Es(.5,0,.5,1),this.rigCameras[1].outputRenderTarget=null},t.prototype.setTransformationFromNonVRCamera=function(e,t){(void 0===e&&(e=this.getScene().activeCamera),void 0===t&&(t=!0),e&&e!==this)&&(e.computeWorldMatrix().decompose(void 0,this.rotationQuaternion,this.position),this.position.y=0,Po.FromEulerAnglesToRef(0,this.rotationQuaternion.toEulerAngles().y,0,this.rotationQuaternion),this._firstFrame=!0,t&&this._xrSessionManager.resetReferenceSpace())},t.prototype.getClassName=function(){return"WebXRCamera"},t.prototype._updateFromXRSession=function(){var e=this,t=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);t&&(t.transform&&(this._referencedPosition.copyFrom(t.transform.position),this._referenceQuaternion.copyFrom(t.transform.orientation),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!==t.views.length&&this._updateNumberOfRigCameras(t.views.length),t.views.forEach((function(t,n){var r=e.rigCameras[n];if(r.isLeftCamera||r.isRightCamera||("right"===t.eye?r._isRightCamera=!0:"left"===t.eye&&(r._isLeftCamera=!0)),t.transform.position?(r.position.copyFrom(t.transform.position),r.rotationQuaternion.copyFrom(t.transform.orientation),e._scene.useRightHandedSystem||(r.position.z*=-1,r.rotationQuaternion.z*=-1,r.rotationQuaternion.w*=-1)):(Oo.FromFloat32ArrayToRefScaled(t.transform.matrix,0,1,r._computedViewMatrix),e._scene.useRightHandedSystem||r._computedViewMatrix.toggleModelMatrixHandInPlace()),Oo.FromFloat32ArrayToRefScaled(t.projectionMatrix,0,1,r._projectionMatrix),e._scene.useRightHandedSystem||r._projectionMatrix.toggleProjectionMatrixHandInPlace(),e._xrSessionManager.session.renderState.baseLayer){var i=e._xrSessionManager.session.renderState.baseLayer.getViewport(t),o=e._xrSessionManager.session.renderState.baseLayer.framebufferWidth,a=e._xrSessionManager.session.renderState.baseLayer.framebufferHeight;r.viewport.width=i.width/o,r.viewport.height=i.height/a,r.viewport.x=i.x/o,r.viewport.y=i.y/a}r.outputRenderTarget=e._xrSessionManager.getRenderTargetTextureForEye(t.eye)})))},t.prototype._updateNumberOfRigCameras=function(e){for(void 0===e&&(e=1);this.rigCameras.lengthe;){var n=this.rigCameras.pop();n&&n.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,t,n){if(void 0===n&&(n=!1),this._xrSessionManager.referenceSpace&&this._xrSessionManager.currentFrame){this._xrInvPositionCache.copyFrom(e),t?this._xrInvQuaternionCache.copyFrom(t):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),n&&(this._xrInvPositionCache.y=0);var r=new XRRigidTransform(Object(No.a)({},this._xrInvPositionCache),Object(No.a)({},this._xrInvQuaternionCache)),i=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(r),o=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(i);if(o){var a=new So;a.copyFrom(o.transform.position),this._scene.useRightHandedSystem||(a.z*=-1),this.position.subtractToRef(a,a),this._scene.useRightHandedSystem||(a.z*=-1),a.negateInPlace();var s=new XRRigidTransform(Object(No.a)({},a));this._xrSessionManager.referenceSpace=i.getOffsetReferenceSpace(s)}}},t}(Ec),Kp=function(){function e(){}return e.ANCHOR_SYSTEM="xr-anchor-system",e.BACKGROUND_REMOVER="xr-background-remover",e.HIT_TEST="xr-hit-test",e.PHYSICS_CONTROLLERS="xr-physics-controller",e.PLANE_DETECTION="xr-plane-detection",e.POINTER_SELECTION="xr-controller-pointer-selection",e.TELEPORTATION="xr-controller-teleportation",e}(),Xp=function(){function e(e){var t=this;this._xrSessionManager=e,this._features={},this._xrSessionManager.onXRSessionInit.add((function(){t.getEnabledFeatures().forEach((function(e){var n=t._features[e];!n.enabled||n.featureImplementation.attached||n.featureImplementation.disableAutoAttach||t.attachFeature(e)}))})),this._xrSessionManager.onXRSessionEnded.add((function(){t.getEnabledFeatures().forEach((function(e){var n=t._features[e];n.enabled&&n.featureImplementation.attached&&t.detachFeature(e)}))}))}return e.AddWebXRFeature=function(e,t,n,r){void 0===n&&(n=1),void 0===r&&(r=!1),this._AvailableFeatures[e]=this._AvailableFeatures[e]||{latest:n},n>this._AvailableFeatures[e].latest&&(this._AvailableFeatures[e].latest=n),r&&(this._AvailableFeatures[e].stable=n),this._AvailableFeatures[e][n]=t},e.ConstructFeature=function(e,t,n,r){void 0===t&&(t=1);var i=this._AvailableFeatures[e][t];if(!i)throw new Error("feature not found");return i(n,r)},e.GetAvailableFeatures=function(){return Object.keys(this._AvailableFeatures)},e.GetAvailableVersions=function(e){return Object.keys(this._AvailableFeatures[e])},e.GetLatestVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].latest||-1},e.GetStableVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].stable||-1},e.prototype.attachFeature=function(e){var t=this._features[e];t&&t.enabled&&!t.featureImplementation.attached&&t.featureImplementation.attach()},e.prototype.detachFeature=function(e){var t=this._features[e];t&&t.featureImplementation.attached&&t.featureImplementation.detach()},e.prototype.disableFeature=function(e){var t="string"==typeof e?e:e.Name,n=this._features[t];return!(!n||!n.enabled)&&(n.enabled=!1,this.detachFeature(t),n.featureImplementation.dispose(),!0)},e.prototype.dispose=function(){var e=this;this.getEnabledFeatures().forEach((function(t){e.disableFeature(t),e._features[t].featureImplementation.dispose()}))},e.prototype.enableFeature=function(t,n,r,i){void 0===n&&(n="latest"),void 0===r&&(r={}),void 0===i&&(i=!0);var o="string"==typeof t?t:t.Name,a=0;if("string"==typeof n){if(!n)throw new Error("Error in provided version - "+o+" ("+n+")");if(-1===(a="stable"===n?e.GetStableVersionOfFeature(o):"latest"===n?e.GetLatestVersionOfFeature(o):+n)||isNaN(a))throw new Error("feature not found - "+o+" ("+n+")")}else a=n;var s=this._features[o],l=e.ConstructFeature(o,a,this._xrSessionManager,r);if(!l)throw new Error("feature not found - "+o);return s&&this.disableFeature(o),this._features[o]={featureImplementation:l(),enabled:!0,version:a},i?this._xrSessionManager.session&&!s.featureImplementation.attached&&this.attachFeature(o):this._features[o].featureImplementation.disableAutoAttach=!0,this._features[o].featureImplementation},e.prototype.getEnabledFeature=function(e){return this._features[e]&&this._features[e].featureImplementation},e.prototype.getEnabledFeatures=function(){return Object.keys(this._features)},e._AvailableFeatures={},e}(),Yp=function(){function e(e){var t=this;this.scene=e,this._nonVRCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this.onInitialXRPoseSetObservable=new yo.a,this.onStateChangedObservable=new yo.a,this.state=Ad.NOT_IN_XR,this.sessionManager=new wd(e),this.camera=new Wp("",e,this.sessionManager),this.featuresManager=new Xp(this.sessionManager),e.onDisposeObservable.add((function(){t.exitXRAsync()}))}return e.CreateAsync=function(t){var n=new e(t);return n.sessionManager.initializeAsync().then((function(){return n._supported=!0,n})).catch((function(e){throw n._setState(Ad.NOT_IN_XR),n.dispose(),e}))},e.prototype.dispose=function(){this.camera.dispose(),this.onStateChangedObservable.clear(),this.onInitialXRPoseSetObservable.clear(),this.sessionManager.dispose(),this._nonVRCamera&&(this.scene.activeCamera=this._nonVRCamera)},e.prototype.enterXRAsync=function(e,t,n){var r=this;if(void 0===n&&(n=this.sessionManager.getWebXRRenderTarget()),!this._supported)throw"WebXR not supported in this browser or environment";this._setState(Ad.ENTERING_XR);var i={optionalFeatures:"viewer"!==t&&"local"!==t?[t]:[]};return"immersive-ar"===e&&"local"!==t&&jo.a.Warn("We recommend using 'local' reference space type when using 'immersive-ar' session mode"),this.sessionManager.isSessionSupportedAsync(e).then((function(t){if(!t)throw new Error('Session mode "'+e+'" not supported in browser');return r.sessionManager.initializeSessionAsync(e,i)})).then((function(){return r.sessionManager.setReferenceSpaceTypeAsync(t)})).then((function(){return n.initializeXRLayerAsync(r.sessionManager.session)})).then((function(){return r.sessionManager.updateRenderStateAsync({depthFar:r.camera.maxZ,depthNear:r.camera.minZ,baseLayer:n.xrLayer})})).then((function(){return r.sessionManager.runXRRenderLoop(),r._originalSceneAutoClear=r.scene.autoClear,r._nonVRCamera=r.scene.activeCamera,r.scene.autoClear=!1,r.scene.activeCamera=r.camera,"immersive-ar"!==e?r._nonXRToXRCamera():r.camera.compensateOnFirstFrame=!1,r.sessionManager.onXRSessionEnded.addOnce((function(){r.camera.rigCameras.forEach((function(e){e.outputRenderTarget=null})),r.scene.autoClear=r._originalSceneAutoClear,r.scene.activeCamera=r._nonVRCamera,"immersive-ar"!==e&&r.camera.compensateOnFirstFrame&&(r._nonVRCamera.setPosition?r._nonVRCamera.setPosition(r.camera.position):r._nonVRCamera.position.copyFrom(r.camera.position)),r._setState(Ad.NOT_IN_XR)})),r.sessionManager.onXRFrameObservable.addOnce((function(){r._setState(Ad.IN_XR)})),r.sessionManager})).catch((function(e){throw console.log(e),console.log(e.message),r._setState(Ad.NOT_IN_XR),e}))},e.prototype.exitXRAsync=function(){return this._setState(Ad.EXITING_XR),this.sessionManager.exitXRAsync()},e.prototype._nonXRToXRCamera=function(){this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),this.onInitialXRPoseSetObservable.notifyObservers(this.camera)},e.prototype._setState=function(e){this.state!==e&&(this.state=e,this.onStateChangedObservable.notifyObservers(this.state))},e}(),qp=function(){function e(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=[]),this.id=e,this.type=t,this._buttonIndex=n,this._axesIndices=r,this._axes={x:0,y:0},this._changes={},this._currentValue=0,this._hasChanges=!1,this._pressed=!1,this._touched=!1,this.onAxisValueChangedObservable=new yo.a,this.onButtonStateChangedObservable=new yo.a}return Object.defineProperty(e.prototype,"axes",{get:function(){return this._axes},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"changes",{get:function(){return this._changes},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasChanges",{get:function(){return this._hasChanges},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pressed",{get:function(){return this._pressed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"touched",{get:function(){return this._touched},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._currentValue},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.onAxisValueChangedObservable.clear(),this.onButtonStateChangedObservable.clear()},e.prototype.isAxes=function(){return 0!==this._axesIndices.length},e.prototype.isButton=function(){return-1!==this._buttonIndex},e.prototype.update=function(e){var t=!1,n=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){var r=e.buttons[this._buttonIndex];if(!r)return;this._currentValue!==r.value&&(this.changes.value={current:r.value,previous:this._currentValue},t=!0,this._currentValue=r.value),this._touched!==r.touched&&(this.changes.touched={current:r.touched,previous:this._touched},t=!0,this._touched=r.touched),this._pressed!==r.pressed&&(this.changes.pressed={current:r.pressed,previous:this._pressed},t=!0,this._pressed=r.pressed)}this.isAxes()&&(this._axes.x!==e.axes[this._axesIndices[0]]&&(this.changes.axes={current:{x:e.axes[this._axesIndices[0]],y:this._axes.y},previous:{x:this._axes.x,y:this._axes.y}},this._axes.x=e.axes[this._axesIndices[0]],n=!0),this._axes.y!==e.axes[this._axesIndices[1]]&&(this.changes.axes?this.changes.axes.current.y=e.axes[this._axesIndices[1]]:this.changes.axes={current:{x:this._axes.x,y:e.axes[this._axesIndices[1]]},previous:{x:this._axes.x,y:this._axes.y}},this._axes.y=e.axes[this._axesIndices[1]],n=!0)),t&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),n&&(this._hasChanges=!0,this.onAxisValueChangedObservable.notifyObservers(this._axes))},e.BUTTON_TYPE="button",e.SQUEEZE_TYPE="squeeze",e.THUMBSTICK_TYPE="thumbstick",e.TOUCHPAD_TYPE="touchpad",e.TRIGGER_TYPE="trigger",e}(),Zp=function(){function e(e,t,n,r,i){var o=this;void 0===i&&(i=!1),this.scene=e,this.layout=t,this.gamepadObject=n,this.handness=r,this._initComponent=function(e){if(e){var t=o.layout.components[e],n=t.type,r=t.gamepadIndices.button,i=[];void 0!==t.gamepadIndices.xAxis&&void 0!==t.gamepadIndices.yAxis&&i.push(t.gamepadIndices.xAxis,t.gamepadIndices.yAxis),o.components[e]=new qp(e,n,r,i)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new yo.a,t.components&&Object.keys(t.components).forEach(this._initComponent)}return e.prototype.dispose=function(){var e=this;this.getComponentIds().forEach((function(t){return e.getComponent(t).dispose()})),this.rootMesh&&this.rootMesh.dispose()},e.prototype.getAllComponentsOfType=function(e){var t=this;return this.getComponentIds().map((function(e){return t.components[e]})).filter((function(t){return t.type===e}))},e.prototype.getComponent=function(e){return this.components[e]},e.prototype.getComponentIds=function(){return Object.keys(this.components)},e.prototype.getComponentOfType=function(e){return this.getAllComponentsOfType(e)[0]||null},e.prototype.getMainComponent=function(){return this.getComponent(this.layout.selectComponentId)},e.prototype.loadModel=function(){return Object(No.b)(this,void 0,void 0,(function(){var e,t,n=this;return Object(No.e)(this,(function(r){return e=!this._getModelLoadingConstraints(),t=this._getGenericFilenameAndPath(),e?jo.a.Warn("Falling back to generic models"):t=this._getFilenameAndPath(),[2,new Promise((function(r,i){Ph.ImportMesh("",t.path,t.filename,n.scene,(function(t){e?n._getGenericParentMesh(t):n._setRootMesh(t),n._processLoadedModel(t),n._modelReady=!0,n.onModelLoadedObservable.notifyObservers(n),r(!0)}),null,(function(e,r){jo.a.Log(r),jo.a.Warn("Failed to retrieve controller model of type "+n.profileId+" from the remote server: "+t.path+t.filename),i(r)}))}))]}))}))},e.prototype.updateFromXRFrame=function(e){var t=this;this.getComponentIds().forEach((function(e){return t.getComponent(e).update(t.gamepadObject)})),this.updateModel(e)},e.prototype._getChildByName=function(e,t){return e.getChildren((function(e){return e.name===t}),!1)[0]},e.prototype._getImmediateChildByName=function(e,t){return e.getChildren((function(e){return e.name==t}),!0)[0]},e.prototype._lerpTransform=function(e,t,n){if(e.minMesh&&e.maxMesh&&e.minMesh.rotationQuaternion&&e.maxMesh.rotationQuaternion&&e.valueMesh.rotationQuaternion){var r=n?.5*t+.5:t;Po.SlerpToRef(e.minMesh.rotationQuaternion,e.maxMesh.rotationQuaternion,r,e.valueMesh.rotationQuaternion),So.LerpToRef(e.minMesh.position,e.maxMesh.position,r,e.valueMesh.position)}},e.prototype.updateModel=function(e){this._modelReady&&this._updateModel(e)},e.prototype._getGenericFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},e.prototype._getGenericParentMesh=function(e){var t=this;this.rootMesh=new Pl(this.profileId+" "+this.handness,this.scene),e.forEach((function(e){e.parent||(e.isPickable=!1,e.setParent(t.rootMesh))})),this.rootMesh.rotationQuaternion=Po.FromEulerAngles(0,Math.PI,0)},e}(),Jp=function(e){function t(n,r,i){var o=e.call(this,n,$p[i],r,i)||this;return o.profileId=t.ProfileId,o}return Object(No.d)(t,e),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 t=this;this.rootMesh=new Pl(this.profileId+" "+this.handness,this.scene),e.forEach((function(e){e.isPickable=!1,e.parent||e.setParent(t.rootMesh)})),this.rootMesh.rotationQuaternion=Po.FromEulerAngles(0,Math.PI,0)},t.prototype._updateModel=function(){},t.ProfileId="generic-trigger",t}(Zp),$p={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"}},ef=function(e){function t(t,n,r,i){var o=e.call(this,t,r.layouts[n.handedness||"none"],n.gamepad,n.handedness)||this;return o._repositoryUrl=i,o._buttonMeshMapping={},o._touchDots={},o.profileId=r.profileId,o}return Object(No.d)(t,e),t.prototype.dispose=function(){var t=this;e.prototype.dispose.call(this),Object.keys(this._touchDots).forEach((function(e){t._touchDots[e].dispose()}))},t.prototype._getFilenameAndPath=function(){return{filename:this.layout.assetPath,path:this._repositoryUrl+"/profiles/"+this.profileId+"/"}},t.prototype._getModelLoadingConstraints=function(){var e=Ph.IsPluginForExtensionAvailable(".glb");return e||jo.a.Warn("glTF / glb loaded was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var t=this;this.getComponentIds().forEach((function(e){var n=t.layout.components[e];t._buttonMeshMapping[e]={mainMesh:t._getChildByName(t.rootMesh,n.rootNodeName),states:{}},Object.keys(n.visualResponses).forEach((function(r){var i=n.visualResponses[r];if("transform"===i.valueNodeProperty)t._buttonMeshMapping[e].states[r]={valueMesh:t._getChildByName(t.rootMesh,i.valueNodeName),minMesh:t._getChildByName(t.rootMesh,i.minNodeName),maxMesh:t._getChildByName(t.rootMesh,i.maxNodeName)};else{var o=n.type===qp.TOUCHPAD_TYPE&&n.touchPointNodeName?n.touchPointNodeName:i.valueNodeName;if(t._buttonMeshMapping[e].states[r]={valueMesh:t._getChildByName(t.rootMesh,o)},n.type===qp.TOUCHPAD_TYPE&&!t._touchDots[r]){var a=zd.CreateSphere(r+"dot",{diameter:.0015,segments:8},t.scene);a.material=new hd(r+"mat",t.scene),a.material.diffuseColor=Io.Red(),a.parent=t._buttonMeshMapping[e].states[r].valueMesh,a.isVisible=!1,t._touchDots[r]=a}}}))}))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new Pl(this.profileId+"-"+this.handness,this.scene),this.rootMesh.isPickable=!1;for(var n=0;nr/10&&(a.isVisible=!0),(s+=t._scene.getEngine().getDeltaTime())>=r)t._scene.simulatePointerDown(n.pick,{pointerId:n.id}),l=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(n.pick,{pointerId:n.id}),a.isVisible=!1;else{var e=1-s/r;a.scaling.set(e,e,e)}else l=!1,s=0;t._scene.simulatePointerMove(n.pick,{pointerId:n.id}),o=n.pick}})),void 0!==this._options.renderingGroupId&&(a.renderingGroupId=this._options.renderingGroupId),e.onDisposeObservable.addOnce((function(){n.pick&&!t._options.disablePointerUpOnTouchOut&&l&&t._scene.simulatePointerUp(n.pick,{pointerId:n.id}),a.dispose()}))},t.prototype._attachScreenRayMode=function(e){var t=this,n=this._controllers[e.uniqueId],r=!1;n.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){!n.pick||t._options.disablePointerUpOnTouchOut&&r||(r?t._scene.simulatePointerMove(n.pick,{pointerId:n.id}):(t._scene.simulatePointerDown(n.pick,{pointerId:n.id}),r=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(n.pick,{pointerId:n.id})))})),e.onDisposeObservable.addOnce((function(){n.pick&&r&&!t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(n.pick,{pointerId:n.id})}))},t.prototype._attachTrackedPointerRayMode=function(e){var t=this;e.onMotionControllerInitObservable.add((function(n){if(t._options.forceGazeMode)return t._attachGazeMode(e);var r=t._controllers[e.uniqueId];t._options.overrideButtonId&&(r.selectionComponent=n.getComponent(t._options.overrideButtonId)),r.selectionComponent||(r.selectionComponent=n.getMainComponent()),r.onFrameObserver=t._xrSessionManager.onXRFrameObservable.add((function(){r.selectionComponent&&r.selectionComponent.pressed?(r.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,r.laserPointer.material.emissiveColor=t.laserPointerPickedColor):(r.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,r.laserPointer.material.emissiveColor=t.lasterPointerDefaultColor),r.laserPointer.isVisible=t.displayLaserPointer,r.laserPointer.material.disableLighting=t.disablePointerLighting,r.selectionMesh.material.disableLighting=t.disableSelectionMeshLighting,r.pick&&t._scene.simulatePointerMove(r.pick,{pointerId:r.id})})),r.onButtonChangedObserver=r.selectionComponent.onButtonStateChangedObservable.add((function(e){if(e.changes.pressed){var n=e.changes.pressed.current;r.pick&&(n?t._scene.simulatePointerDown(r.pick,{pointerId:r.id}):t._scene.simulatePointerUp(r.pick,{pointerId:r.id}))}}))}))},t.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(So.Dot(e,t.direction))r},t.prototype._updatePointerDistance=function(e,t){void 0===t&&(t=100),e.scaling.y=t,e.position.z=t/2+.05},t._idCounter=0,t.Name=Kp.POINTER_SELECTION,t.Version=1,t}(af);Xp.AddWebXRFeature(sf.Name,(function(e,t){return function(){return new sf(e,t)}}),sf.Version,!0);var lf=function(){function e(e,t,n){this.element=e,this.sessionMode=t,this.referenceSpaceType=n}return e.prototype.update=function(e){},e}(),cf=function(){function e(e,t){var n=this;if(this.scene=e,this.options=t,this._activeButton=null,this._buttons=[],this.activeButtonChangedObservable=new yo.a,this._overlay=document.createElement("div"),this._overlay.style.cssText="z-index:11;position: absolute; right: 20px;bottom: 50px;",t.customButtons)this._buttons=t.customButtons;else{var r=t.sessionMode||"immersive-vr",i=t.referenceSpaceType||"local-floor",o=".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("+(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) }";o+='.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';var a=document.createElement("style");a.appendChild(document.createTextNode(o)),document.getElementsByTagName("head")[0].appendChild(a);var s=document.createElement("button");s.className="babylonVRicon",s.title=r+" - "+i,this._buttons.push(new lf(s,r,i)),this._buttons[this._buttons.length-1].update=function(e){this.element.style.display=null===e||e===this?"":"none",s.className="babylonVRicon"+(e===this?" vrdisplaypresenting":"")},this._updateButtons(null)}var l=e.getEngine().getInputElement();l&&l.parentNode&&(l.parentNode.appendChild(this._overlay),e.onDisposeObservable.addOnce((function(){n.dispose()})))}return e.CreateAsync=function(t,n,r){var i=this,o=new e(t,r),a=o._buttons.map((function(e){return n.sessionManager.isSessionSupportedAsync(e.sessionMode)}));return n.onStateChangedObservable.add((function(e){e==Ad.NOT_IN_XR&&o._updateButtons(null)})),Promise.all(a).then((function(e){return e.forEach((function(e,t){e&&(o._overlay.appendChild(o._buttons[t].element),o._buttons[t].element.onclick=function(){return Object(No.b)(i,void 0,void 0,(function(){var e,i;return Object(No.e)(this,(function(a){switch(a.label){case 0:return n.state!=Ad.IN_XR?[3,2]:[4,n.exitXRAsync()];case 1:return a.sent(),o._updateButtons(null),[3,6];case 2:if(n.state!=Ad.NOT_IN_XR)return[3,6];if(!r.renderTarget)return[3,6];a.label=3;case 3:return a.trys.push([3,5,,6]),[4,n.enterXRAsync(o._buttons[t].sessionMode,o._buttons[t].referenceSpaceType,r.renderTarget)];case 4:return a.sent(),o._updateButtons(o._buttons[t]),[3,6];case 5:return a.sent(),o._updateButtons(null),e=o._buttons[t].element,i=e.title,e.title="Error entering XR session : "+i,e.classList.add("xr-error"),[3,6];case 6:return[2]}}))}))})})),o}))},e.prototype.dispose=function(){var e=this.scene.getEngine().getInputElement();e&&e.parentNode&&e.parentNode.contains(this._overlay)&&e.parentNode.removeChild(this._overlay),this.activeButtonChangedObservable.clear()},e.prototype._updateButtons=function(e){var t=this;this._activeButton=e,this._buttons.forEach((function(e){e.update(t._activeButton)})),this.activeButtonChangedObservable.notifyObservers(this._activeButton)},e}(),uf=function(e){function t(t,n){var r=e.call(this,t)||this;return r._options=n,r._controllers={},r._snappedToPoint=!1,r._tmpRay=new Vl(new So,new So),r._tmpVector=new So,r.backwardsMovementEnabled=!0,r.backwardsTeleportationDistance=.7,r.parabolicCheckRadius=5,r.parabolicRayEnabled=!0,r.rotationAngle=Math.PI/8,r.rotationEnabled=!0,r._attachController=function(e){if(!r._controllers[e.uniqueId]){r._controllers[e.uniqueId]={xrController:e,teleportationState:{forward:!1,backwards:!1,rotating:!1,currentRotation:0,baseRotation:0}};var t=r._controllers[e.uniqueId];e.onMotionControllerInitObservable.addOnce((function(){if(e.motionController){var n=e.motionController.getComponentOfType(qp.THUMBSTICK_TYPE)||e.motionController.getComponentOfType(qp.TOUCHPAD_TYPE);if(!n||r._options.useMainComponentOnly){var i=e.motionController.getMainComponent();if(!i)return;t.onButtonChangedObserver=i.onButtonStateChangedObservable.add((function(){if(i.changes.pressed)if(i.changes.pressed.current){t.teleportationState.forward=!0,r._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0;var n=r._options.timeToTeleport||3e3,o=0,a=r._xrSessionManager.onXRFrameObservable.add((function(){i.pressed?((o+=r._xrSessionManager.scene.getEngine().getDeltaTime())>=n&&r._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&r._teleportForward(e.uniqueId),o>=n&&r._xrSessionManager.onXRFrameObservable.remove(a)):r._xrSessionManager.onXRFrameObservable.remove(a)}))}else t.teleportationState.forward=!1,r._currentTeleportationControllerId=""}))}else t.onButtonChangedObserver=n.onButtonStateChangedObservable.add((function(){r._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&!n.touched&&r._teleportForward(e.uniqueId)})),t.onAxisChangedObserver=n.onAxisValueChangedObservable.add((function(e){if(e.y<=.7&&t.teleportationState.backwards&&(t.teleportationState.backwards=!1),e.y>.7&&!t.teleportationState.forward&&r.backwardsMovementEnabled&&!r.snapPointsOnly&&!t.teleportationState.backwards){t.teleportationState.backwards=!0,r._tmpVector.set(0,0,r.backwardsTeleportationDistance),r._tmpVector.rotateByQuaternionToRef(r._options.xrInput.xrCamera.rotationQuaternion,r._tmpVector),r._tmpVector.addInPlace(r._options.xrInput.xrCamera.position),r._options.xrInput.xrCamera.position.subtractToRef(r._tmpVector,r._tmpVector),r._tmpRay.origin.copyFrom(r._tmpVector),r._tmpRay.direction.set(0,-1,0);var n=r._xrSessionManager.scene.pickWithRay(r._tmpRay,(function(e){return-1!==r._floorMeshes.indexOf(e)}));n&&n.pickedPoint&&r._options.xrInput.xrCamera.position.addInPlace(n.pickedPoint)}if(e.y<-.7&&!r._currentTeleportationControllerId&&!t.teleportationState.rotating&&(t.teleportationState.forward=!0,r._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),e.x){if(t.teleportationState.forward)r._currentTeleportationControllerId===t.xrController.uniqueId&&(r.rotationEnabled?setTimeout((function(){t.teleportationState.currentRotation=Math.atan2(e.x,-e.y)})):t.teleportationState.currentRotation=0);else if(!t.teleportationState.rotating&&Math.abs(e.x)>.7){t.teleportationState.rotating=!0;var i=r.rotationAngle*(e.x>0?1:-1);r._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(Po.FromEulerAngles(0,i,0))}}else t.teleportationState.rotating=!1}))}}))}},r._options.teleportationTargetMesh||r._createDefaultTargetMesh(),r._floorMeshes=r._options.floorMeshes||[],r._snapToPositions=r._options.snapPositions||[],r._setTargetMeshVisibility(!1),r}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"snapPointsOnly",{get:function(){return!!this._options.snapPointsOnly},set:function(e){this._options.snapPointsOnly=e},enumerable:!0,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 t=this;return!!e.prototype.attach.call(this)&&(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,(function(e){t._detachController(e.uniqueId)})),!0)},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach((function(e){t._detachController(e)})),this._setTargetMeshVisibility(!1),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.dispose(!1,!0)},t.prototype.removeFloorMesh=function(e){var t=this._floorMeshes.indexOf(e);-1!==t&&this._floorMeshes.splice(t,1)},t.prototype.removeFloorMeshByName=function(e){var t=this._xrSessionManager.scene.getMeshByName(e);t&&this.removeFloorMesh(t)},t.prototype.removeSnapPoint=function(e){var t=this._snapToPositions.indexOf(e);if(-1===t)for(var n=0;n=l.video.HAVE_CURRENT_DATA;return!s.poster||s.autoPlay&&c?c&&l._createInternalTexture():(l._texture=l._engine.createTexture(s.poster,!1,!l.invertY,r),l._displayingPosterTexture=!0),l}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new yo.a),this._onUserActionRequestedObservable},enumerable:!0,configurable:!0}),t.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:"object"==typeof e?e.toString():e},t.prototype._getVideo=function(e){if(e instanceof HTMLVideoElement)return Ja.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement("video");return"string"==typeof e?(Ja.SetCorsBehavior(e,t),t.src=e):(Ja.SetCorsBehavior(e[0],t),e.forEach((function(e){var n=document.createElement("source");n.src=e,t.appendChild(n)}))),t},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(){e.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 r=document.createElement("video");return r.setAttribute("autoplay",""),r.setAttribute("muted","true"),r.setAttribute("playsinline",""),r.muted=!0,void 0!==r.mozSrcObject?r.mozSrcObject=n:"object"==typeof r.srcObject?r.srcObject=n:(window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,r.src=window.URL&&window.URL.createObjectURL(n)),new Promise((function(n){var i=function(){n(new t("video",r,e,!0,!0)),r.removeEventListener("playing",i)};r.addEventListener("playing",i),r.play()}))},t.CreateFromWebCamAsync=function(e,t,n){var r,i=this;return void 0===n&&(n=!1),t&&t.deviceId&&(r={exact:t.deviceId}),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:t,audio:n}).then((function(t){return i.CreateFromStreamAsync(e,t)})):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:r,width:{min:t&&t.minWidth||256,max:t&&t.maxWidth||640},height:{min:t&&t.minHeight||256,max:t&&t.maxHeight||480}},audio:n},(function(t){return i.CreateFromStreamAsync(e,t)}),(function(e){jo.a.Error(e.name)})),Promise.reject("No support for userMedia on this device"))},t.CreateFromWebCam=function(e,t,n,r){void 0===r&&(r=!1),this.CreateFromWebCamAsync(e,n,r).then((function(e){t&&t(e)})).catch((function(e){jo.a.Error(e.name)}))},t}(Wl),pf=function(){function e(e,t){void 0===e&&(e=So.Zero()),void 0===t&&(t=So.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}(),ff=(function(){function e(e,t,n){void 0===e&&(e=So.Zero()),void 0===t&&(t=So.Up()),void 0===n&&(n=Co.Zero()),this.position=e,this.normal=t,this.uv=n}e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())}}(),function(e){function t(n,r,i,o){var a=e.call(this,n,o)||this;a._halfDome=!1,a._useDirectMapping=!1,a._videoMode=t.MODE_MONOSCOPIC,a._onBeforeCameraRenderObserver=null,o=a.getScene(),n=n||"videoDome",i.resolution=0|Math.abs(i.resolution)||32,i.clickToPlay=Boolean(i.clickToPlay),i.autoPlay=void 0===i.autoPlay||Boolean(i.autoPlay),i.loop=void 0===i.loop||Boolean(i.loop),i.size=Math.abs(i.size)||(o.activeCamera?.48*o.activeCamera.maxZ:1e3),void 0===i.useDirectMapping?a._useDirectMapping=!0:a._useDirectMapping=i.useDirectMapping,void 0===i.faceForward&&(i.faceForward=!0),a._setReady(!1);var s={loop:i.loop,autoPlay:i.autoPlay,autoUpdateTexture:!0,poster:i.poster},l=a._material=new lp(n+"_material",o),c=a._videoTexture=new hf(n+"_texture",r,o,!1,a._useDirectMapping,Wl.TRILINEAR_SAMPLINGMODE,s);if(a._mesh=Pl.CreateSphere(n+"_mesh",i.resolution,i.size,o,!1,Pl.BACKSIDE),c.anisotropicFilteringLevel=1,c.onLoadObservable.addOnce((function(){a._setReady(!0)})),l.useEquirectangularFOV=!0,l.fovMultiplier=1,l.opacityFresnel=!1,a._useDirectMapping?(c.wrapU=Wl.CLAMP_ADDRESSMODE,c.wrapV=Wl.CLAMP_ADDRESSMODE,l.diffuseTexture=c):(c.coordinatesMode=Wl.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,c.wrapV=Wl.CLAMP_ADDRESSMODE,l.reflectionTexture=c),a._mesh.material=l,a._mesh.parent=a,a._halfDomeMask=zd.CreateSphere("",{slice:.5,diameter:.99*i.size,segments:i.resolution,sideOrientation:Pl.BACKSIDE},o),a._halfDomeMask.rotate(os.X,-Math.PI/2),a._halfDomeMask.parent=a._mesh,a._halfDome=!!i.halfDomeMode,a._halfDomeMask.setEnabled(a._halfDome),i.clickToPlay&&(o.onPointerUp=function(){a._videoTexture.video.play()}),i.faceForward&&o.activeCamera){var u=o.activeCamera,d=So.Forward(),h=So.TransformNormal(d,u.getViewMatrix());h.normalize(),a.rotation.y=Math.acos(So.Dot(d,h))}return a}Object(No.d)(t,e),Object.defineProperty(t.prototype,"videoTexture",{get:function(){return this._videoTexture},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"videoMode",{get:function(){return this._videoMode},set:function(e){this._videoMode!==e&&this._changeVideoMode(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"halfDome",{get:function(){return this._halfDome},set:function(e){this._halfDome=e,this._halfDomeMask.setEnabled(e)},enumerable:!0,configurable:!0}),t.prototype._changeVideoMode=function(e){var n=this;switch(this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._videoMode=e,this._videoTexture.uScale=1,this._videoTexture.vScale=1,this._videoTexture.uOffset=0,this._videoTexture.vOffset=0,e){case t.MODE_SIDEBYSIDE:this._videoTexture.uScale=this._halfDome?.99999:.5;var r=this._halfDome?0:.5,i=this._halfDome?.5:0;this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add((function(e){n._videoTexture.uOffset=e.isRightCamera?r:i}));break;case t.MODE_TOPBOTTOM:this._videoTexture.vScale=this._halfDome?.99999:.5,this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add((function(e){n._videoTexture.vOffset=e.isRightCamera?.5:0}))}},t.prototype.dispose=function(t,n){void 0===n&&(n=!1),this._videoTexture.dispose(),this._mesh.dispose(),this._material.dispose(),this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),e.prototype.dispose.call(this,t,n)},t.MODE_MONOSCOPIC=0,t.MODE_TOPBOTTOM=1,t.MODE_SIDEBYSIDE=2}(as),function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._gpuFrameTime=new el.a,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new el.a,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}Object.defineProperty(e.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(e){var t=this;e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,e?(this._onBeginFrameObserver=this.engine.onBeginFrameObservable.add((function(){t._gpuFrameTimeToken||(t._gpuFrameTimeToken=t.engine.startTimeQuery())})),this._onEndFrameObserver=this.engine.onEndFrameObservable.add((function(){if(t._gpuFrameTimeToken){var e=t.engine.endTimeQuery(t._gpuFrameTimeToken);e>-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}}))):(this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureShaderCompilationTime",{get:function(){return this._captureShaderCompilationTime},set:function(e){var t=this;e!==this._captureShaderCompilationTime&&(this._captureShaderCompilationTime=e,e?(this._onBeforeShaderCompilationObserver=this.engine.onBeforeShaderCompilationObservable.add((function(){t._shaderCompilationTime.fetchNewFrame(),t._shaderCompilationTime.beginMonitoring()})),this._onAfterShaderCompilationObserver=this.engine.onAfterShaderCompilationObservable.add((function(){t._shaderCompilationTime.endMonitoring()}))):(this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null))},enumerable:!0,configurable:!0}),e.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}}(),function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new el.a,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new el.a,this._captureFrameTime=!1,this._frameTime=new el.a,this._captureRenderTime=!1,this._renderTime=new el.a,this._captureInterFrameTime=!1,this._interFrameTime=new el.a,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new el.a,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new el.a,this._capturePhysicsTime=!1,this._physicsTime=new el.a,this._captureAnimationsTime=!1,this._animationsTime=new el.a,this._captureCameraRenderTime=!1,this._cameraRenderTime=new el.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=e.onBeforeAnimationsObservable.add((function(){t._captureActiveMeshesEvaluationTime&&t._activeMeshesEvaluationTime.fetchNewFrame(),t._captureRenderTargetsRenderTime&&t._renderTargetsRenderTime.fetchNewFrame(),t._captureFrameTime&&(Ja.StartPerformanceCounter("Scene rendering"),t._frameTime.beginMonitoring()),t._captureInterFrameTime&&t._interFrameTime.endMonitoring(),t._captureParticlesRenderTime&&t._particlesRenderTime.fetchNewFrame(),t._captureSpritesRenderTime&&t._spritesRenderTime.fetchNewFrame(),t._captureAnimationsTime&&t._animationsTime.beginMonitoring(),t.scene.getEngine()._drawCalls.fetchNewFrame()})),this._onAfterRenderObserver=e.onAfterRenderObservable.add((function(){t._captureFrameTime&&(Ja.EndPerformanceCounter("Scene rendering"),t._frameTime.endMonitoring()),t._captureRenderTime&&t._renderTime.endMonitoring(!1),t._captureInterFrameTime&&t._interFrameTime.beginMonitoring()}))}Object.defineProperty(e.prototype,"activeMeshesEvaluationTimeCounter",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureActiveMeshesEvaluationTime",{get:function(){return this._captureActiveMeshesEvaluationTime},set:function(e){var t=this;e!==this._captureActiveMeshesEvaluationTime&&(this._captureActiveMeshesEvaluationTime=e,e?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add((function(){Ja.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){Ja.EndPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.endMonitoring()}))):(this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTargetsRenderTime",{get:function(){return this._captureRenderTargetsRenderTime},set:function(e){var t=this;e!==this._captureRenderTargetsRenderTime&&(this._captureRenderTargetsRenderTime=e,e?(this._onBeforeRenderTargetsRenderObserver=this.scene.onBeforeRenderTargetsRenderObservable.add((function(){Ja.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){Ja.EndPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureParticlesRenderTime",{get:function(){return this._captureParticlesRenderTime},set:function(e){var t=this;e!==this._captureParticlesRenderTime&&(this._captureParticlesRenderTime=e,e?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add((function(){Ja.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){Ja.EndPerformanceCounter("Particles"),t._particlesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureSpritesRenderTime",{get:function(){return this._captureSpritesRenderTime},set:function(e){var t=this;e!==this._captureSpritesRenderTime&&(this._captureSpritesRenderTime=e,this.scene.spriteManagers&&(e?(this._onBeforeSpritesRenderingObserver=this.scene.onBeforeSpritesRenderingObservable.add((function(){Ja.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){Ja.EndPerformanceCounter("Sprites"),t._spritesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"capturePhysicsTime",{get:function(){return this._capturePhysicsTime},set:function(e){var t=this;e!==this._capturePhysicsTime&&this.scene.onBeforePhysicsObservable&&(this._capturePhysicsTime=e,e?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add((function(){Ja.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){Ja.EndPerformanceCounter("Physics"),t._physicsTime.endMonitoring()}))):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureAnimationsTime",{get:function(){return this._captureAnimationsTime},set:function(e){var t=this;e!==this._captureAnimationsTime&&(this._captureAnimationsTime=e,e?this._onAfterAnimationsObserver=this.scene.onAfterAnimationsObservable.add((function(){t._animationsTime.endMonitoring()})):(this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(e){var t=this;e!==this._captureRenderTime&&(this._captureRenderTime=e,e?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add((function(){t._renderTime.beginMonitoring(),Ja.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),Ja.EndPerformanceCounter("Main render")}))):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cameraRenderTimeCounter",{get:function(){return this._cameraRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureCameraRenderTime",{get:function(){return this._captureCameraRenderTime},set:function(e){var t=this;e!==this._captureCameraRenderTime&&(this._captureCameraRenderTime=e,e?(this._onBeforeCameraRenderObserver=this.scene.onBeforeCameraRenderObservable.add((function(e){t._cameraRenderTime.beginMonitoring(),Ja.StartPerformanceCounter("Rendering camera "+e.name)})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),Ja.EndPerformanceCounter("Rendering camera "+e.name)}))):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!0,configurable:!0}),e.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}}(),"#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform sampler2D opacitySampler;\nuniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;\nvoid main(void)\n{\nvec4 finalColor=glowColor;\n\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a4&&(o.push(cs.MatricesIndicesExtraKind),o.push(cs.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers);var f=a.skeleton;f&&f.isUsingTextureForMatrices?i.push("#define BONETEXTURE"):i.push("#define BonesPerMesh "+(f?f.bones.length+1:0)),a.numBoneInfluencers>0&&p.addCPUSkinningFallback(0,a)}else i.push("#define NUM_BONE_INFLUENCERS 0");var m=a.morphTargetManager,g=0;m&&m.numInfluencers>0&&(i.push("#define MORPHTARGETS"),g=m.numInfluencers,i.push("#define NUM_MORPH_INFLUENCERS "+g),Cu.PrepareAttributesForMorphTargetsInfluencers(o,a,g)),t&&(i.push("#define INSTANCES"),Cu.PushAttributesForInstances(o)),this._addCustomEffectDefines(i);var b=i.join("\n");return this._cachedDefines!==b&&(this._cachedDefines=b,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","glowColor","morphTargetInfluences","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity"],["diffuseSampler","emissiveSampler","opacitySampler","boneSampler"],b,p,void 0,void 0,{maxSimultaneousMorphTargets:g})),this._effectLayerMapGenerationEffect.isReady()},e.prototype.render=function(){var e=this._mergeEffect;if(e.isReady()){for(var t=0;t-1&&this._scene.effectLayers.splice(t,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()},e.prototype.getClassName=function(){return"EffectLayer"},e.Parse=function(e,t,n){return Ja.Instantiate(e.customType).Parse(e,t,n)},e._SceneComponentInitialization=function(e){throw oa.a.WarnImport("EffectLayerSceneComponent")},Object(No.c)([ha()],e.prototype,"name",void 0),Object(No.c)([va()],e.prototype,"neutralColor",void 0),Object(No.c)([ha()],e.prototype,"isEnabled",void 0),Object(No.c)([ua(11,t)],e.prototype,"camera",null),Object(No.c)([ha()],e.prototype,"renderingGroupId",null),e}();Ao.AddParser(Gs.NAME_EFFECTLAYER,(function(e,t,n,r){if(e.effectLayers){n.effectLayers||(n.effectLayers=new Array);for(var i=0;i0){this._previousStencilState=this._engine.getStencilBuffer();for(var r=0,i=n;r-1)){this._renderEffects=!0,this._needStencil=this._needStencil||o.needStencil();var a=o._mainTexture;a._shouldRender()&&(this.scene.incrementRenderId(),a.render(!1,!1),t=!0)}}this.scene.incrementRenderId()}return t},e.prototype._setStencil=function(){this._needStencil&&this._engine.setStencilBuffer(!0)},e.prototype._setStencilBack=function(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},e.prototype._draw=function(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var t=this.scene.effectLayers,n=0;n-1},t.prototype.referenceMeshToUseItsOwnMaterial=function(e){this._meshesUsingTheirOwnMaterials.push(e.uniqueId)},t.prototype.unReferenceMeshFromUsingItsOwnMaterial=function(e){for(var t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);t>0;)this._meshesUsingTheirOwnMaterials.slice(t,t+1),t=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,t=ya.Serialize(this);if(t.customType="BABYLON.GlowLayer",t.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e0&&e.isBackground===t&&e.renderTargetTextures.indexOf(r)>-1&&0!=(e.layerMask&n)},e.prototype._drawRenderTargetBackground=function(e){var t=this;this._draw((function(n){return t._drawRenderTargetPredicate(n,!0,t.scene.activeCamera.layerMask,e)}))},e.prototype._drawRenderTargetForeground=function(e){var t=this;this._draw((function(n){return t._drawRenderTargetPredicate(n,!1,t.scene.activeCamera.layerMask,e)}))},e.prototype.addFromContainer=function(e){var t=this;e.layers&&e.layers.forEach((function(e){t.scene.layers.push(e)}))},e.prototype.removeFromContainer=function(e,t){var n=this;void 0===t&&(t=!1),e.layers&&e.layers.forEach((function(e){var r=n.scene.layers.indexOf(e);-1!==r&&n.scene.layers.splice(r,1),t&&e.dispose()}))},e}(),Cf="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\n\n#include\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef LINEAR\nbaseColor.rgb=toGammaSpace(baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}";Qc.a.ShadersStore.layerPixelShader=Cf;var Sf="\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n}";Qc.a.ShadersStore.layerVertexShader=Sf;!function(){function e(e,t,n,r,i){this.name=e,this.scale=new Co(1,1),this.offset=new Co(0,0),this.alphaBlendingMode=2,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this._vertexBuffers={},this.onDisposeObservable=new yo.a,this.onBeforeRenderObservable=new yo.a,this.onAfterRenderObservable=new yo.a,this.texture=t?new Wl(t,n,!0):null,this.isBackground=void 0===r||r,this.color=void 0===i?new ko(1,1,1,1):i,this._scene=n||Zo.a.LastCreatedScene;var o=this._scene._getComponent(Gs.NAME_LAYER);o||(o=new Ef(this._scene),this._scene._addComponent(o)),this._scene.layers.push(this);var a=this._scene.getEngine(),s=[];s.push(1,1),s.push(-1,1),s.push(-1,-1),s.push(1,-1);var l=new cs(a,s,cs.PositionKind,!1,!1,2);this._vertexBuffers[cs.PositionKind]=l,this._createIndexBuffer()}Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),e.prototype._createIndexBuffer=function(){var e=this._scene.getEngine(),t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},e.prototype._rebuild=function(){var e=this._vertexBuffers[cs.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.render=function(){var e=this._scene.getEngine(),t="";this.alphaTest&&(t="#define ALPHATEST"),this.texture&&!this.texture.gammaSpace&&(t+="\r\n#define LINEAR"),this._previousDefines!==t&&(this._previousDefines=t,this._effect=e.createEffect("layer",[cs.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],t));var n=this._effect;if(n&&n.isReady()&&this.texture&&this.texture.isReady()){e=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),e.enableEffect(n),e.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),e.bindBuffers(this._vertexBuffers,this._indexBuffer,n),this.alphaTest?e.drawElementsType(Ls.TriangleFillMode,0,6):(e.setAlphaMode(this.alphaBlendingMode),e.drawElementsType(Ls.TriangleFillMode,0,6),e.setAlphaMode(0)),this.onAfterRenderObservable.notifyObservers(this)}},e.prototype.dispose=function(){var e=this._vertexBuffers[cs.PositionKind];e&&(e.dispose(),this._vertexBuffers[cs.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null),this.renderTargetTextures=[];var t=this._scene.layers.indexOf(this);this._scene.layers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()}}();var Tf=function(){function e(e,t,n,r,i){this.size=e,this.position=t,this.alphaMode=6,this.color=n||new Io(1,1,1),this.texture=r?new Wl(r,i.getScene(),!0):null,this._system=i,i.lensFlares.push(this)}return e.AddFlare=function(t,n,r,i,o){return new e(t,n,r,i,o)},e.prototype.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},e}(),Pf="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}";Qc.a.ShadersStore.lensFlarePixelShader=Pf;var Of="\nattribute vec2 position;\n\nuniform mat4 viewportMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n}";Qc.a.ShadersStore.lensFlareVertexShader=Of;var Rf=function(){function e(t,n,r){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=r||Zo.a.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._emitter=n,this.id=t,r.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return r.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&r.activeCamera.layerMask)};var i=r.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[cs.PositionKind]=new cs(i,o,cs.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",[cs.PositionKind],["color","viewportMatrix"],["textureSampler"],"")}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEmitter=function(){return this._emitter},e.prototype.setEmitter=function(e){this._emitter=e},e.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},e.prototype.computeEffectivePosition=function(e){var t=this.getEmitterPosition();return t=So.Project(t,Oo.Identity(),this._scene.getTransformMatrix(),e),this._positionX=t.x,this._positionY=t.y,t=So.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix()),this.viewportBorder>0&&(e.x-=this.viewportBorder,e.y-=this.viewportBorder,e.width+=2*this.viewportBorder,e.height+=2*this.viewportBorder,t.x+=this.viewportBorder,t.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),t.z>0&&(this._positionX>e.x&&this._positionXe.y&&(this._positionY,e.y,e.height),!0)},e.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var e=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),t=e.length();e.normalize();var n=new Vl(this._scene.activeCamera.globalPosition,e),r=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!r||!r.hit||r.distance>t},e.prototype.render=function(){if(!this._effect.isReady()||!this._scene.activeCamera)return!1;var e,t,n=this._scene.getEngine(),r=this._scene.activeCamera.viewport.toGlobal(n.getRenderWidth(!0),n.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var i=(e=this._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0)>(t=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0)?e:t;(i-=this.viewportBorder)>this.borderLimit&&(i=this.borderLimit);var o=1-xo.Clamp(i/this.borderLimit,0,1);if(o<0)return!1;o>1&&(o=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var a=r.x+r.width/2,s=r.y+r.height/2,l=a-this._positionX,c=s-this._positionY;n.enableEffect(this._effect),n.setState(!1),n.setDepthBuffer(!1),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var u=0;u0);for(var n=0,r=t;n0)}},e}();Rf._SceneComponentInitialization=function(e){var t=e._getComponent(Gs.NAME_LENSFLARESYSTEM);t||(t=new Mf(e),e._addComponent(t))};var If="#ifndef FLOAT\n#include\n#endif\nvarying float vDepthMetric;\n#ifdef USEDISTANCE\nuniform vec3 lightData;\nvarying vec3 vPositionW;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\n#ifdef DEPTHCLAMP\nvarying float z;\n#endif\n#include\nvoid main(void)\n{\n#include\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef DEPTHCLAMP\n#ifdef USEDISTANCE\ndepth=clamp(((length(vPositionW-lightData)+depthValues.x)/(depthValues.y))+biasAndScale.x,0.0,1.0);\n#else\ndepth=clamp(((z+depthValues.x)/(depthValues.y))+biasAndScale.x,0.0,1.0);\n#endif\ngl_FragDepth=depth;\n#elif defined(USEDISTANCE)\ndepth=(length(vPositionW-lightData)+depthValues.x)/(depthValues.y)+biasAndScale.x;\n#endif\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.z*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}";Qc.a.ShadersStore.shadowMapPixelShader=If;var kf="\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\nuniform vec3 lightData;\n#endif\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n\n#include\n#include\nuniform mat4 viewProjection;\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef USEDISTANCE\nvarying vec3 vPositionW;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#ifdef DEPTHCLAMP\nvarying float z;\n#endif\n#include\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvec3 worldNor=normalize(normalWorld*normal);\n#ifdef DIRECTIONINLIGHTDATA\nvec3 worldLightDir=normalize(-lightData.xyz);\n#else\nvec3 directionToLight=lightData.xyz-worldPos.xyz;\nvec3 worldLightDir=normalize(directionToLight);\n#endif\nfloat ndl=dot(worldNor,worldLightDir);\nfloat sinNL=sqrt(1.0-ndl*ndl);\nfloat normalBias=biasAndScale.y*sinNL;\nworldPos.xyz-=worldNor*normalBias;\n#endif\n#ifdef USEDISTANCE\nvPositionW=worldPos.xyz;\n#endif\n\ngl_Position=viewProjection*worldPos;\n#ifdef DEPTHTEXTURE\n\ngl_Position.z+=biasAndScale.x*gl_Position.w;\n#endif\n#ifdef DEPTHCLAMP\nz=gl_Position.z;\ngl_Position.z=0.0;\n#elif !defined(USEDISTANCE)\n\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#endif\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}";Qc.a.ShadersStore.shadowMapVertexShader=kf;var Df="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}";Qc.a.ShadersStore.depthBoxBlurPixelShader=Df;var Bf=function(){function e(t,n,r){this.onBeforeShadowMapRenderObservable=new yo.a,this.onAfterShadowMapRenderObservable=new yo.a,this.onBeforeShadowMapRenderMeshObservable=new yo.a,this.onAfterShadowMapRenderMeshObservable=new yo.a,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=e.FILTER_NONE,this._filteringQuality=e.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=So.Zero(),this._viewMatrix=Oo.Zero(),this._projectionMatrix=Oo.Zero(),this._transformMatrix=Oo.Zero(),this._cachedPosition=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new So(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=Oo.Identity(),this._mapSize=t,this._light=n,this._scene=n.getScene(),n._shadowGenerator=this,e._SceneComponentInitialization(this._scene);var i=this._scene.getEngine().getCaps();r?i.textureFloatRender&&i.textureFloatLinearFiltering?this._textureType=1:i.textureHalfFloatRender&&i.textureHalfFloatLinearFiltering?this._textureType=2:this._textureType=0:i.textureHalfFloatRender&&i.textureHalfFloatLinearFiltering?this._textureType=2:i.textureFloatRender&&i.textureFloatLinearFiltering?this._textureType=1:this._textureType=0,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(e.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"normalBias",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),e.prototype._validateFilter=function(e){return e},Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},set:function(t){if(t=this._validateFilter(t),this._light.needCube()){if(t===e.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(t===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(t===e.FILTER_PCF||t===e.FILTER_PCSS)return void(this.usePoissonSampling=!0)}t!==e.FILTER_PCF&&t!==e.FILTER_PCSS||1!==this._scene.getEngine().webGLVersion?this._filter!==t&&(this._filter=t,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usePoissonSampling",{get:function(){return this.filter===e.FILTER_POISSONSAMPLING},set:function(t){var n=this._validateFilter(e.FILTER_POISSONSAMPLING);(t||this.filter===e.FILTER_POISSONSAMPLING)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useExponentialShadowMap",{get:function(){return this.filter===e.FILTER_EXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_EXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_BLUREXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_CLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===e.FILTER_PCF},set:function(t){var n=this._validateFilter(e.FILTER_PCF);(t||this.filter===e.FILTER_PCF)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useContactHardeningShadow",{get:function(){return this.filter===e.FILTER_PCSS},set:function(t){var n=this._validateFilter(e.FILTER_PCSS);(t||this.filter===e.FILTER_PCSS)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"darkness",{get:function(){return this._darkness},set:function(e){this.setDarkness(e)},enumerable:!0,configurable:!0}),e.prototype.getDarkness=function(){return this._darkness},e.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},Object.defineProperty(e.prototype,"transparencyShadow",{get:function(){return this._transparencyShadow},set:function(e){this.setTransparencyShadow(e)},enumerable:!0,configurable:!0}),e.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},e.prototype.getShadowMap=function(){return this._shadowMap},e.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},e.prototype.getClassName=function(){return e.CLASSNAME},e.prototype.addShadowCaster=function(e,t){var n;return void 0===t&&(t=!0),this._shadowMap?(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(e),t&&(n=this._shadowMap.renderList).push.apply(n,e.getChildMeshes()),this):this},e.prototype.removeShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var n=this._shadowMap.renderList.indexOf(e);if(-1!==n&&this._shadowMap.renderList.splice(n,1),t)for(var r=0,i=e.getChildren();r1?(this._shadowMap=new mu(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture(513,!0)):this._shadowMap=new mu(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())},e.prototype._initializeShadowMap=function(){var t=this;if(this._createTargetRenderTexture(),null!==this._shadowMap){this._shadowMap.wrapU=Wl.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=Wl.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(Wl.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this);var n=this._scene.getEngine();this._shadowMap.onBeforeRenderObservable.add((function(r){t._currentFaceIndex=r,t._filter===e.FILTER_PCF&&n.setColorWrite(!1)})),this._shadowMap.onAfterUnbindObservable.add((function(){if(t._filter===e.FILTER_PCF&&n.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var r=t.getShadowMapForRendering();r&&t._scene.postProcessManager.directRender(t._blurPostProcesses,r.getInternalTexture(),!0)}}));var r=new ko(0,0,0,0),i=new ko(1,1,1,1);this._shadowMap.onClearObservable.add((function(n){t._filter===e.FILTER_PCF?n.clear(i,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?n.clear(r,!0,!0,!1):n.clear(i,!0,!0,!1)})),this._shadowMap.onResizeObservable.add((function(e){t._storedUniqueId=t._shadowMap.uniqueId,t._mapSize=e.getRenderSize(),t._light._markMeshesAsLightDirty(),t.recreateShadowMap()}));for(var o=js.MIN_RENDERINGGROUPS;o=a.length)return void(e&&e(n));setTimeout(d,16)}};d()}else e&&e(this)}else e&&e(this)}else e&&e(this)},e.prototype.forceCompilationAsync=function(e){var t=this;return new Promise((function(n){t.forceCompilation((function(){n()}),e)}))},e.prototype._isReadyCustomDefines=function(e,t,n){},e.prototype.isReady=function(e,t){var n=[];0!==this._textureType&&n.push("#define FLOAT"),this.useExponentialShadowMap||this.useBlurExponentialShadowMap?n.push("#define ESM"):(this.usePercentageCloserFiltering||this.useContactHardeningShadow)&&n.push("#define DEPTHTEXTURE");var r=[cs.PositionKind],i=e.getMesh(),o=e.getMaterial();if(this.normalBias&&i.isVerticesDataPresent(cs.NormalKind)&&(r.push(cs.NormalKind),n.push("#define NORMAL"),i.nonUniformScaling&&n.push("#define NONUNIFORMSCALING"),this.getLight().getTypeID()===Ds.LIGHTTYPEID_DIRECTIONALLIGHT&&n.push("#define DIRECTIONINLIGHTDATA")),o&&o.needAlphaTesting()){var a=o.getAlphaTestTexture();a&&(n.push("#define ALPHATEST"),i.isVerticesDataPresent(cs.UVKind)&&(r.push(cs.UVKind),n.push("#define UV1")),i.isVerticesDataPresent(cs.UV2Kind)&&1===a.coordinatesIndex&&(r.push(cs.UV2Kind),n.push("#define UV2")))}var s=new ud;if(i.useBones&&i.computeBonesUsingShaders&&i.skeleton){r.push(cs.MatricesIndicesKind),r.push(cs.MatricesWeightsKind),i.numBoneInfluencers>4&&(r.push(cs.MatricesIndicesExtraKind),r.push(cs.MatricesWeightsExtraKind));var l=i.skeleton;n.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),i.numBoneInfluencers>0&&s.addCPUSkinningFallback(0,i),l.isUsingTextureForMatrices?n.push("#define BONETEXTURE"):n.push("#define BonesPerMesh "+(l.bones.length+1))}else n.push("#define NUM_BONE_INFLUENCERS 0");var c=i.morphTargetManager,u=0;c&&c.numInfluencers>0&&(n.push("#define MORPHTARGETS"),u=c.numInfluencers,n.push("#define NUM_MORPH_INFLUENCERS "+u),Cu.PrepareAttributesForMorphTargetsInfluencers(r,i,u));var d=this._scene;if(d.clipPlane&&n.push("#define CLIPPLANE"),d.clipPlane2&&n.push("#define CLIPPLANE2"),d.clipPlane3&&n.push("#define CLIPPLANE3"),d.clipPlane4&&n.push("#define CLIPPLANE4"),d.clipPlane5&&n.push("#define CLIPPLANE5"),d.clipPlane6&&n.push("#define CLIPPLANE6"),t&&(n.push("#define INSTANCES"),Cu.PushAttributesForInstances(r)),this.customShaderOptions&&this.customShaderOptions.defines)for(var h=0,p=this.customShaderOptions.defines;h4&&(i.push(cs.MatricesIndicesExtraKind),i.push(cs.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0");var a=o.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,r.push("#define MORPHTARGETS"),r.push("#define NUM_MORPH_INFLUENCERS "+s),Cu.PrepareAttributesForMorphTargetsInfluencers(i,o,s)),t&&(r.push("#define INSTANCES"),Cu.PushAttributesForInstances(i)),this._storeNonLinearDepth&&r.push("#define NONLINEARDEPTH"),this.isPacked&&r.push("#define PACKED");var l=r.join("\n");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this._scene.getEngine().createEffect("depth",i,["world","mBones","viewProjection","diffuseMatrix","depthValues","morphTargetInfluences"],["diffuseSampler"],l,void 0,void 0,void 0,{maxSimultaneousMorphTargets:s})),this._effect.isReady()},e.prototype.getDepthMap=function(){return this._depthMap},e.prototype.dispose=function(){this._depthMap.dispose()},e._SceneComponentInitialization=function(e){throw oa.a.WarnImport("DepthRendererSceneComponent")},e}(),Uf="attribute vec2 vUV;\nuniform sampler2D textureSampler;\n#if defined(INITIAL)\nuniform sampler2D sourceTexture;\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nfloat f1=texelFetch(sourceTexture,coord,0).r;\nfloat f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;\nfloat f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;\nfloat f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;\nfloat minz=min(min(min(f1,f2),f3),f4);\n#ifdef DEPTH_REDUX\nfloat maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);\n#else\nfloat maxz=max(max(max(f1,f2),f3),f4);\n#endif\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(MAIN)\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nvec2 f1=texelFetch(textureSampler,coord,0).rg;\nvec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;\nvec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;\nvec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;\nfloat minz=min(min(min(f1.x,f2.x),f3.x),f4.x);\nfloat maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(ONEBEFORELAST)\nuniform ivec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*vec2(texSize-1));\nvec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;\nvec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;\nvec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;\nvec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;\nfloat minz=min(f1.x,f2.x);\nfloat maxz=max(f1.y,f2.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(LAST)\nvoid main(void)\n{\ndiscard;\nglFragColor=vec4(0.);\n}\n#endif\n";Qc.a.ShadersStore.minmaxReduxPixelShader=Uf;var Vf=function(e){function t(t){return e.call(this,t)||this}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"depthRenderer",{get:function(){return this._depthRenderer},enumerable:!0,configurable:!0}),t.prototype.setDepthRenderer=function(t,n,r){void 0===t&&(t=null),void 0===n&&(n=2),void 0===r&&(r=!0);var i=this._camera.getScene();this._depthRenderer&&(delete i._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null),null===t&&(i._depthRenderer||(i._depthRenderer={}),(t=this._depthRenderer=new Lf(i,n,this._camera,!1)).enabled=!1,this._depthRendererId="minmax"+this._camera.id,i._depthRenderer[this._depthRendererId]=t),e.prototype.setSourceTexture.call(this,t.getDepthMap(),!0,n,r)},t.prototype.setSourceTexture=function(t,n,r,i){void 0===r&&(r=2),void 0===i&&(i=!0),e.prototype.setSourceTexture.call(this,t,n,r,i)},t.prototype.activate=function(){this._depthRenderer&&(this._depthRenderer.enabled=!0),e.prototype.activate.call(this)},t.prototype.deactivate=function(){e.prototype.deactivate.call(this),this._depthRenderer&&(this._depthRenderer.enabled=!1)},t.prototype.dispose=function(t){var n;void 0===t&&(t=!0),e.prototype.dispose.call(this,t),this._depthRenderer&&t&&(null===(n=this._depthRenderer.getDepthMap().getScene())||void 0===n||n._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null)},t}(function(){function e(e){this.onAfterReductionPerformed=new yo.a,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new Us(e.getScene())}return Object.defineProperty(e.prototype,"sourceTexture",{get:function(){return this._sourceTexture},enumerable:!0,configurable:!0}),e.prototype.setSourceTexture=function(e,t,n,r){var i=this;if(void 0===n&&(n=2),void 0===r&&(r=!0),e!==this._sourceTexture){this.dispose(!1),this._sourceTexture=e,this._reductionSteps=[],this._forceFullscreenViewport=r;var o=this._camera.getScene(),a=new Xc("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,1,o.getEngine(),!1,"#define INITIAL"+(t?"\n#define DEPTH_REDUX":""),n,void 0,void 0,void 0,7);a.autoClear=!1,a.forceFullscreenViewport=r;var s=this._sourceTexture.getRenderWidth(),l=this._sourceTexture.getRenderHeight();a.onApply=function(e,t){return function(n){n.setTexture("sourceTexture",i._sourceTexture),n.setFloatArray2("texSize",new Float32Array([e,t]))}}(s,l),this._reductionSteps.push(a);for(var c=1;s>1||l>1;){s=Math.max(Math.round(s/2),1),l=Math.max(Math.round(l/2),1);var u=new Xc("Reduction phase "+c,"minmaxRedux",["texSize"],null,{width:s,height:l},null,1,o.getEngine(),!1,"#define "+(1==s&&1==l?"LAST":1==s||1==l?"ONEBEFORELAST":"MAIN"),n,void 0,void 0,void 0,7);if(u.autoClear=!1,u.forceFullscreenViewport=r,u.onApply=function(e,t){return function(n){1==e||1==t?n.setIntArray2("texSize",new Int32Array([e,t])):n.setFloatArray2("texSize",new Float32Array([e,t]))}}(s,l),this._reductionSteps.push(u),c++,1==s&&1==l){u.onAfterRenderObservable.add(function(e,t,n){var r=new Float32Array(4*e*t),a={min:0,max:0};return function(){o.getEngine()._readTexturePixels(n.inputTexture,e,t,-1,0,r),a.min=r[0],a.max=r[1],i.onAfterReductionPerformed.notifyObservers(a)}}(s,l,u))}}}},Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._sourceTexture?this._sourceTexture.refreshRate:-1},set:function(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activated",{get:function(){return this._activated},enumerable:!0,configurable:!0}),e.prototype.activate=function(){var e=this;!this._onAfterUnbindObserver&&this._sourceTexture&&(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add((function(){e._reductionSteps[0].activate(e._camera),e._postProcessManager.directRender(e._reductionSteps,e._reductionSteps[0].inputTexture,e._forceFullscreenViewport),e._camera.getScene().getEngine().unBindFramebuffer(e._reductionSteps[0].inputTexture,!1)})),this._activated=!0)},e.prototype.deactivate=function(){this._onAfterUnbindObserver&&this._sourceTexture&&(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)},e.prototype.dispose=function(e){if(void 0===e&&(e=!0),e&&this.onAfterReductionPerformed.clear(),this.deactivate(),this._reductionSteps){for(var t=0;tt&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)},Object.defineProperty(t.prototype,"minDistance",{get:function(){return this._minDistance},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxDistance",{get:function(){return this._maxDistance},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return t.CLASSNAME},t.prototype.getCascadeMinExtents=function(e){return e>=0&&e=0&&ethis._scene.activeCamera.maxZ||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug=e,this._light._markMeshesAsLightDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthClamp",{get:function(){return this._depthClamp},set:function(e){this._depthClamp=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cascadeBlendPercentage",{get:function(){return this._cascadeBlendPercentage},set:function(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lambda",{get:function(){return this._lambda},set:function(e){var t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.getCascadeViewMatrix=function(e){return e>=0&&e=0&&e=0&&e=r&&(n=0,r=1),n==t._minDistance&&r==t._maxDistance||t.setMinMaxDistance(n,r)})),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoCalcDepthBoundsRefreshRate",{get:function(){var e,t,n;return null!=(n=null===(t=null===(e=this._depthReducer)||void 0===e?void 0:e.depthRenderer)||void 0===t?void 0:t.getDepthMap().refreshRate)?n:-1},set:function(e){var t;(null===(t=this._depthReducer)||void 0===t?void 0:t.depthRenderer)&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)},enumerable:!0,configurable:!0}),t.prototype.splitFrustum=function(){this._breaksAreDirty=!0},t.prototype._splitFrustum=function(){var e=this._scene.activeCamera;if(e){for(var t=e.minZ,n=e.maxZ,r=n-t,i=this._minDistance,o=t+i*r,a=t+(this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(n-t),this._maxDistance):this._maxDistance)*r,s=a-o,l=a/o,c=0;cMath.PI;)i-=2*Math.PI;var a=i/Math.PI,s=o/Math.PI;a=.5*a+.5;var l=Math.round(a*n);l<0?l=0:l>=n&&(l=n-1);var c=Math.round(s*r);c<0?c=0:c>=r&&(c=r-1);var u=r-c-1;return{r:t[u*n*3+3*l+0],g:t[u*n*3+3*l+1],b:t[u*n*3+3*l+2]}},e.FACE_FRONT=[new So(-1,-1,-1),new So(1,-1,-1),new So(-1,1,-1),new So(1,1,-1)],e.FACE_BACK=[new So(1,-1,1),new So(-1,-1,1),new So(1,1,1),new So(-1,1,1)],e.FACE_RIGHT=[new So(1,-1,-1),new So(1,-1,1),new So(1,1,-1),new So(1,1,1)],e.FACE_LEFT=[new So(-1,-1,1),new So(-1,-1,-1),new So(-1,1,1),new So(-1,1,-1)],e.FACE_DOWN=[new So(-1,1,-1),new So(1,1,-1),new So(-1,1,1),new So(1,1,1)],e.FACE_UP=[new So(-1,-1,1),new So(1,-1,1),new So(-1,-1,-1),new So(1,-1,-1)],e}(),Zf=function(){function e(){}return e.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},e.Rgbe2float=function(e,t,n,r,i,o){i>0?(i=this.Ldexp(1,i-136),e[o+0]=t*i,e[o+1]=n*i,e[o+2]=r*i):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},e.readStringLine=function(e,t){for(var n="",r="",i=t;i32767)throw"HDR Bad header format, unsupported size";return{height:t,width:n,dataPosition:a+=r.length+1}},e.GetCubeMapTextureData=function(e,t){var n=new Uint8Array(e),r=this.RGBE_ReadHeader(n),i=this.RGBE_ReadPixels_RLE(n,r);return qf.ConvertPanoramaToCubemap(i,r.width,r.height,t)},e.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},e.RGBE_ReadPixels_RLE=function(e,t){for(var n,r,i,o,a,s=t.height,l=t.width,c=t.dataPosition,u=0,d=0,h=0,p=new ArrayBuffer(4*l),f=new Uint8Array(p),m=new ArrayBuffer(t.width*t.height*4*3),g=new Float32Array(m);s>0;){if(n=e[c++],r=e[c++],i=e[c++],o=e[c++],2!=n||2!=r||128&i)throw"HDR Bad header format, not RLE";if((i<<8|o)!=l)throw"HDR Bad header format, wrong scan line width";for(u=0,h=0;h<4;h++)for(d=(h+1)*l;u128){if(0==(a=n-128)||a>d-u)throw"HDR Bad Format, bad scanline data (run)";for(;a-- >0;)f[u++]=r}else{if(0==(a=n)||a>d-u)throw"HDR Bad Format, bad scanline data (non-run)";if(f[u++]=r,--a>0)for(var b=0;b255){var g=255/m;h*=g,p*=g,f*=g}s[3*d+0]=h,s[3*d+1]=p,s[3*d+2]=f}s?a.push(s):a.push(u)}return a}),null,this._onLoad,this._onError))},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=new t(this.url,e,this._size,this._noMipmap,this._generateHarmonics,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.prototype.delayLoad=function(){4===this.delayLoadState&&(this.delayLoadState=1,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 t=this;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&this.getScene().markAllMaterialsAsDirty(1,(function(e){return-1!==e.getActiveTextures().indexOf(t)}))},t.Parse=function(e,n,r){var i=null;return e.name&&!e.isRenderTarget&&((i=new t(r+e.name,n,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name=e.name,i.hasAlpha=e.hasAlpha,i.level=e.level,i.coordinatesMode=e.coordinatesMode,i.isBlocking=e.isBlocking),i&&(e.boundingBoxPosition&&(i.boundingBoxPosition=So.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(i.boundingBoxSize=So.FromArray(e.boundingBoxSize)),e.rotationY&&(i.rotationY=e.rotationY)),i},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}(Ql);Eo.RegisteredTypes["BABYLON.HDRCubeTexture"]=Jf;var $f=function(){function e(e,t,n){void 0===t&&(t=0),void 0===n&&(n=null),this.name=e,this.animations=new Array,this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new yo.a,this._onDataLayoutChanged=new yo.a,this._animationPropertiesOverride=null,this._scene=n||Zo.a.LastCreatedScene,this.influence=t,this._scene&&(this._uniqueId=this._scene.getUniqueId())}return Object.defineProperty(e.prototype,"influence",{get:function(){return this._influence},set:function(e){if(this._influence!==e){var t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasPositions",{get:function(){return!!this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasNormals",{get:function(){return!!this._normals},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasTangents",{get:function(){return!!this._tangents},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasUVs",{get:function(){return!!this._uvs},enumerable:!0,configurable:!0}),e.prototype.setPositions=function(e){var t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getPositions=function(){return this._positions},e.prototype.setNormals=function(e){var t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getNormals=function(){return this._normals},e.prototype.setTangents=function(e){var t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getTangents=function(){return this._tangents},e.prototype.setUVs=function(e){var t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getUVs=function(){return this._uvs},e.prototype.clone=function(){var t=this,n=ya.Clone((function(){return new e(t.name,t.influence,t._scene)}),this);return n._positions=this._positions,n._normals=this._normals,n._tangents=this._tangents,n._uvs=this._uvs,n},e.prototype.serialize=function(){var e={};return e.name=this.name,e.influence=this.influence,e.positions=Array.prototype.slice.call(this.getPositions()),null!=this.id&&(e.id=this.id),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),ya.AppendSerializedAnimations(this,e),e},e.prototype.getClassName=function(){return"MorphTarget"},e.Parse=function(t){var n=new e(t.name,t.influence);if(n.setPositions(t.positions),null!=t.id&&(n.id=t.id),t.normals&&n.setNormals(t.normals),t.tangents&&n.setTangents(t.tangents),t.uvs&&n.setUVs(t.uvs),t.animations)for(var r=0;r=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._syncActiveTargets(!0))},e.prototype.clone=function(){for(var t=new e(this._scene),n=0,r=this._targets;n-1&&(this._impostors.splice(t,1).length&&this.getPhysicsPlugin().removePhysicsBody(e))},e.prototype.addJoint=function(e,t,n){var r={mainImpostor:e,connectedImpostor:t,joint:n};n.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},e.prototype.removeJoint=function(e,t,n){var r=this._joints.filter((function(r){return r.connectedImpostor===t&&r.joint===n&&r.mainImpostor===e}));r.length&&this._physicsPlugin.removeJoint(r[0])},e.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},e.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},e.prototype.getImpostors=function(){return this._impostors},e.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;t0&&(this._physicsBodysToRemoveAfterStep.forEach((function(t){e.world.remove(t)})),this._physicsBodysToRemoveAfterStep=[])},e.prototype.applyImpulse=function(e,t,n){var r=new this.BJSCANNON.Vec3(n.x,n.y,n.z),i=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(i,r)},e.prototype.applyForce=function(e,t,n){var r=new this.BJSCANNON.Vec3(n.x,n.y,n.z),i=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(i,r)},e.prototype.generatePhysicsBody=function(e){if(this._removeMarkedPhysicsBodiesFromWorld(),e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var t=this._createShape(e),n=e.physicsBody;n&&this.removePhysicsBody(e);var r=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),i={mass:e.getParam("mass"),material:r},o=e.getParam("nativeOptions");for(var a in o)o.hasOwnProperty(a)&&(i[a]=o[a]);e.physicsBody=new this.BJSCANNON.Body(i),e.physicsBody.addEventListener("collide",e.onCollide),this.world.addEventListener("preStep",e.beforeStep),this.world.addEventListener("postStep",e.afterStep),e.physicsBody.addShape(t),this.world.add(e.physicsBody),n&&["force","torque","velocity","angularVelocity"].forEach((function(t){e.physicsBody[t].copy(n[t])})),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)}},e.prototype._processChildMeshes=function(e){var t=this,n=e.object.getChildMeshes?e.object.getChildMeshes(!0):[],r=e.object.rotationQuaternion;if(n.length){var i=function(n,o){if(r&&o.rotationQuaternion){var a=o.getPhysicsImpostor();if(a)if(a.parent!==e){var s=o.position.clone(),l=o.rotationQuaternion.multiply(Po.Inverse(r));a.physicsBody&&(t.removePhysicsBody(a),a.physicsBody=null),a.parent=e,a.resetUpdateFlags(),e.physicsBody.addShape(t._createShape(a),new t.BJSCANNON.Vec3(s.x,s.y,s.z),new t.BJSCANNON.Quaternion(l.x,l.y,l.z,l.w)),e.physicsBody.mass+=a.getParam("mass")}r.multiplyInPlace(o.rotationQuaternion),o.getChildMeshes(!0).filter((function(e){return!!e.physicsImpostor})).forEach(i.bind(t,o.getAbsolutePosition()))}};n.filter((function(e){return!!e.physicsImpostor})).forEach(i.bind(this,e.object.getAbsolutePosition()))}},e.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),-1===this._physicsBodysToRemoveAfterStep.indexOf(e.physicsBody)&&this._physicsBodysToRemoveAfterStep.push(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,n=e.connectedImpostor.physicsBody;if(t&&n){var r,i=e.joint.jointData,o={pivotA:i.mainPivot?(new this.BJSCANNON.Vec3).copy(i.mainPivot):null,pivotB:i.connectedPivot?(new this.BJSCANNON.Vec3).copy(i.connectedPivot):null,axisA:i.mainAxis?(new this.BJSCANNON.Vec3).copy(i.mainAxis):null,axisB:i.connectedAxis?(new this.BJSCANNON.Vec3).copy(i.connectedAxis):null,maxForce:i.nativeParams.maxForce,collideConnected:!!i.collision};switch(e.joint.type){case jd.HingeJoint:case jd.Hinge2Joint:r=new this.BJSCANNON.HingeConstraint(t,n,o);break;case jd.DistanceJoint:r=new this.BJSCANNON.DistanceConstraint(t,n,i.maxDistance||2);break;case jd.SpringJoint:var a=i;r=new this.BJSCANNON.Spring(t,n,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:o.pivotA,localAnchorB:o.pivotB});break;case jd.LockJoint:r=new this.BJSCANNON.LockConstraint(t,n,o);break;case jd.PointToPointJoint:case jd.BallAndSocketJoint:default:r=new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,n,o.pivotB,o.maxForce)}r.collideConnected=!!i.collision,e.joint.physicsJoint=r,e.joint.type!==jd.SpringJoint?this.world.addConstraint(r):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){r.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},e.prototype.removeJoint=function(e){e.joint.type!==jd.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},e.prototype._addMaterial=function(e,t,n){var r,i;for(r=0;r1e3*n));s++);this.time+=r;for(var l=this.time%n/n,c=e,u=this.bodies,d=0;d!==u.length;d++){var h=u[d];h.type!==t.Body.STATIC&&h.sleepState!==t.Body.SLEEPING?(h.position.vsub(h.previousPosition,c),c.scale(l,c),h.position.vadd(c,h.interpolatedPosition)):(h.interpolatedPosition.copy(h.position),h.interpolatedQuaternion.copy(h.quaternion))}}}},e.prototype.raycast=function(e,t){return this._cannonRaycastResult.reset(),this.world.raycastClosest(e,t,{},this._cannonRaycastResult),this._raycastResult.reset(e,t),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},e}();tm.DefaultPluginFactory=function(){return new rm};var im=function(){function e(e,t){void 0===t&&(t=OIMO),this.name="OimoJSPlugin",this._tmpImpostorsArray=[],this._tmpPositionVector=So.Zero(),this.BJSOIMO=t,this.world=new this.BJSOIMO.World({iterations:e}),this.world.clear(),this._raycastResult=new nm}return e.prototype.setGravity=function(e){this.world.gravity.copy(e)},e.prototype.setTimeStep=function(e){this.world.timeStep=e},e.prototype.getTimeStep=function(){return this.world.timeStep},e.prototype.executeStep=function(e,t){var n=this;t.forEach((function(e){e.beforeStep()})),this.world.step(),t.forEach((function(e){e.afterStep(),n._tmpImpostorsArray[e.uniqueId]=e}));for(var r=this.world.contacts;null!==r;)if(!r.touching||r.body1.sleeping||r.body2.sleeping){var i=this._tmpImpostorsArray[+r.body1.name],o=this._tmpImpostorsArray[+r.body2.name];i&&o?(i.onCollide({body:o.physicsBody}),o.onCollide({body:i.physicsBody}),r=r.next):r=r.next}else r=r.next},e.prototype.applyImpulse=function(e,t,n){var r=e.physicsBody.mass;e.physicsBody.applyImpulse(n.scale(this.world.invScale),t.scale(this.world.invScale*r))},e.prototype.applyForce=function(e,t,n){jo.a.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(e,t,n)},e.prototype.generatePhysicsBody=function(e){var t=this;if(e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var n={name:e.uniqueId,config:[e.getParam("mass")||.001,e.getParam("friction"),e.getParam("restitution")],size:[],type:[],pos:[],posShape:[],rot:[],rotShape:[],move:0!==e.getParam("mass"),density:e.getParam("mass"),friction:e.getParam("friction"),restitution:e.getParam("restitution"),world:this.world},r=[e];(a=e.object).getChildMeshes&&a.getChildMeshes().forEach((function(e){e.physicsImpostor&&r.push(e.physicsImpostor)}));var i=function(e){return Math.max(e,tm.Epsilon)},o=new Po;r.forEach((function(r){if(r.object.rotationQuaternion){var a=r.object.rotationQuaternion;o=a.clone(),r.object.rotationQuaternion.set(0,0,0,1),r.object.computeWorldMatrix(!0);var s=a.toEulerAngles(),l=r.getObjectExtendSize();if(r===e){var c=e.getObjectCenter();e.object.getAbsolutePivotPoint().subtractToRef(c,t._tmpPositionVector),t._tmpPositionVector.divideInPlace(e.object.scaling),n.pos.push(c.x),n.pos.push(c.y),n.pos.push(c.z),n.posShape.push(0,0,0),n.rotShape.push(0,0,0)}else{var u=r.object.position.clone();n.posShape.push(u.x),n.posShape.push(u.y),n.posShape.push(u.z),n.rotShape.push(57.29577951308232*s.x),n.rotShape.push(57.29577951308232*s.y),n.rotShape.push(57.29577951308232*s.z)}switch(r.object.rotationQuaternion.copyFrom(o),r.type){case Hd.ParticleImpostor:jo.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case Hd.SphereImpostor:var d=l.x,h=l.y,p=l.z,f=Math.max(i(d),i(h),i(p))/2;n.type.push("sphere"),n.size.push(f),n.size.push(f),n.size.push(f);break;case Hd.CylinderImpostor:var m=i(l.x)/2,g=i(l.y);n.type.push("cylinder"),n.size.push(m),n.size.push(g),n.size.push(g);break;case Hd.PlaneImpostor:case Hd.BoxImpostor:default:m=i(l.x),g=i(l.y);var b=i(l.z);n.type.push("box"),n.size.push(m),n.size.push(g),n.size.push(b)}r.object.rotationQuaternion=a}})),e.physicsBody=this.world.add(n),e.physicsBody.resetQuaternion(o),e.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);var a;e.setDeltaPosition(this._tmpPositionVector)}},e.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,n=e.connectedImpostor.physicsBody;if(t&&n){var r,i=e.joint.jointData,o=i.nativeParams||{},a={body1:t,body2:n,axe1:o.axe1||(i.mainAxis?i.mainAxis.asArray():null),axe2:o.axe2||(i.connectedAxis?i.connectedAxis.asArray():null),pos1:o.pos1||(i.mainPivot?i.mainPivot.asArray():null),pos2:o.pos2||(i.connectedPivot?i.connectedPivot.asArray():null),min:o.min,max:o.max,collision:o.collision||i.collision,spring:o.spring,world:this.world};switch(e.joint.type){case jd.BallAndSocketJoint:r="jointBall";break;case jd.SpringJoint:jo.a.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var s=i;a.min=s.length||a.min,a.max=Math.max(a.min,a.max);case jd.DistanceJoint:r="jointDistance",a.max=i.maxDistance;break;case jd.PrismaticJoint:r="jointPrisme";break;case jd.SliderJoint:r="jointSlide";break;case jd.WheelJoint:r="jointWheel";break;case jd.HingeJoint:default:r="jointHinge"}a.type=r,e.joint.physicsJoint=this.world.add(a)}},e.prototype.removeJoint=function(e){try{this.world.removeJoint(e.joint.physicsJoint)}catch(e){jo.a.Warn(e)}},e.prototype.isSupported=function(){return void 0!==this.BJSOIMO},e.prototype.setTransformationFromPhysicsBody=function(e){if(!e.physicsBody.sleeping){if(e.physicsBody.shapes.next){for(var t=e.physicsBody.shapes;t.next;)t=t.next;e.object.position.copyFrom(t.position)}else e.object.position.copyFrom(e.physicsBody.getPosition());e.object.rotationQuaternion&&e.object.rotationQuaternion.copyFrom(e.physicsBody.getQuaternion())}},e.prototype.setPhysicsBodyTransformation=function(e,t,n){var r=e.physicsBody;e.physicsBody.shapes.next||(r.position.copy(t),r.orientation.copy(n),r.syncShapes(),r.awake())},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.copy(t)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.linearVelocity;return t?new So(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new So(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){var n=0===t;e.physicsBody.shapes.density=n?1:t,e.physicsBody.setupMass(n?2:1)},e.prototype.getBodyMass=function(e){return e.physicsBody.shapes.density},e.prototype.getBodyFriction=function(e){return e.physicsBody.shapes.friction},e.prototype.setBodyFriction=function(e,t){e.physicsBody.shapes.friction=t},e.prototype.getBodyRestitution=function(e){return e.physicsBody.shapes.restitution},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.shapes.restitution=t},e.prototype.sleepBody=function(e){e.physicsBody.sleep()},e.prototype.wakeUpBody=function(e){e.physicsBody.awake()},e.prototype.updateDistanceJoint=function(e,t,n){e.physicsJoint.limitMotor.upperLimit=t,void 0!==n&&(e.physicsJoint.limitMotor.lowerLimit=n)},e.prototype.setMotor=function(e,t,n,r){void 0!==n?jo.a.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter"):n=1e6,t*=-1;var i=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;i&&i.setMotor(t,n)},e.prototype.setLimit=function(e,t,n,r){var i=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;i&&i.setLimit(t,void 0===n?-t:n)},e.prototype.syncMeshWithImpostor=function(e,t){var n=t.physicsBody;e.position.x=n.position.x,e.position.y=n.position.y,e.position.z=n.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=n.orientation.x,e.rotationQuaternion.y=n.orientation.y,e.rotationQuaternion.z=n.orientation.z,e.rotationQuaternion.w=n.orientation.s)},e.prototype.getRadius=function(e){return e.physicsBody.shapes.radius},e.prototype.getBoxSizeToRef=function(e,t){var n=e.physicsBody.shapes;t.x=2*n.halfWidth,t.y=2*n.halfHeight,t.z=2*n.halfDepth},e.prototype.dispose=function(){this.world.clear()},e.prototype.raycast=function(e,t){return jo.a.Warn("raycast is not currently supported by the Oimo physics plugin"),this._raycastResult.reset(e,t),this._raycastResult},e}();us.CreateRibbon=function(e){var t=e.pathArray,n=e.closeArray||!1,r=e.closePath||!1,i=e.invertUV||!1,o=Math.floor(t[0].length/2),a=e.offset||o;a=a>o?o:Math.floor(a);var s,l,c,u,d=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE,h=e.uvs,p=e.colors,f=[],m=[],g=[],b=[],v=[],A=[],_=[],y=[],x=[],w=[];if(t.length<2){var E=[],C=[];for(c=0;c0&&(P=S[u].subtract(S[u-1]).length()+_[l],v[l].push(P),_[l]=P),u++;r&&(u--,f.push(S[0].x,S[0].y,S[0].z),P=S[u].subtract(S[0]).length()+_[l],v[l].push(P),_[l]=P),x[l]=T+I,w[l]=M,M+=T+I}var k,D,B=null,F=null;for(c=0;c3?0:c,u);var x=om.CreateRibbon(e,{pathArray:A,closeArray:s,closePath:l,updatable:h,sideOrientation:p,invertUV:m,frontUVs:g||void 0,backUVs:b||void 0},d);return x._creationDataStorage.pathArray=A,x._creationDataStorage.path3D=v,x._creationDataStorage.cap=c,x},e}(),sm=function(){function e(e,t,n){var r=this;void 0===e&&(e=!0),void 0===t&&(t=Ammo),void 0===n&&(n=null),this._useDeltaForWorldStep=e,this.bjsAMMO={},this.name="AmmoJSPlugin",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new Po,this._tmpContactCallbackResult=!1,this._tmpVector=new So,this._tmpMatrix=new Oo,"function"==typeof t?t(this.bjsAMMO):this.bjsAMMO=t,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(){r._tmpContactCallbackResult=!0},this._raycastResult=new nm,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)):jo.a.Error("AmmoJS is not available. Please make sure you included the js file.")}return e.prototype.setGravity=function(e){this._tmpAmmoVectorA.setValue(e.x,e.y,e.z),this.world.setGravity(this._tmpAmmoVectorA),this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA)},e.prototype.setTimeStep=function(e){this._timeStep=e},e.prototype.setFixedTimeStep=function(e){this._fixedTimeStep=e},e.prototype.setMaxSteps=function(e){this._maxSteps=e},e.prototype.getTimeStep=function(){return this._timeStep},e.prototype._isImpostorInContact=function(e){return this._tmpContactCallbackResult=!1,this.world.contactTest(e.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._isImpostorPairInContact=function(e,t){return this._tmpContactCallbackResult=!1,this.world.contactPairTest(e.physicsBody,t.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._stepSimulation=function(e,t,n){if(void 0===e&&(e=1/60),void 0===t&&(t=10),void 0===n&&(n=1/60),0==t)this.world.stepSimulation(e,0);else for(;t>0&&e>0;)e-n0&&this._isImpostorInContact(s))for(var l=0,c=s._onPhysicsCollideCallbacks;l3?3:s;var l=(new this.bjsAMMO.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,n-1,s);return l.get_m_cfg().set_collisions(17),l},e.prototype._createCustom=function(e){var t=null;return this.onCreateCustomShape&&(t=this.onCreateCustomShape(e)),null==t&&(t=new this.bjsAMMO.btCompoundShape),t},e.prototype._addHullVerts=function(e,t,n){var r=this,i=0;if(n&&n.getIndices&&n.getWorldMatrix&&n.getChildMeshes){var o=n.getIndices();o||(o=[]);var a=n.getVerticesData(cs.PositionKind);a||(a=[]),n.computeWorldMatrix(!1);for(var s=o.length/3,l=0;l0){if(e.type!=Hd.NoImpostor){var l=this._createShape(e,!0);l&&(this._tmpAmmoTransform.getOrigin().setValue(0,0,0),this._tmpAmmoQuaternion.setValue(0,0,0,1),this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),r.addChildShape(this._tmpAmmoTransform,l))}return r}this.bjsAMMO.destroy(r),r=null}switch(e.type){case Hd.SphereImpostor:if(xo.WithinEpsilon(o.x,o.y,1e-4)&&xo.WithinEpsilon(o.x,o.z,1e-4))r=new this.bjsAMMO.btSphereShape(o.x/2);else{var c=[new this.bjsAMMO.btVector3(0,0,0)];(r=new this.bjsAMMO.btMultiSphereShape(c,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x/2,o.y/2,o.z/2))}break;case Hd.CapsuleImpostor:r=new this.bjsAMMO.btCapsuleShape(o.x/2,o.y/2);break;case Hd.CylinderImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),r=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case Hd.PlaneImpostor:case Hd.BoxImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),r=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case Hd.MeshImpostor:if(0==e.getParam("mass")){var u=new this.bjsAMMO.btTriangleMesh;e._pluginData.toDispose.push(u);var d=this._addMeshVerts(u,i,i);r=0==d?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(u);break}case Hd.ConvexHullImpostor:var h=new this.bjsAMMO.btConvexHullShape;0==(d=this._addHullVerts(h,i,i))?(e._pluginData.toDispose.push(h),r=new this.bjsAMMO.btCompoundShape):r=h;break;case Hd.NoImpostor:r=new this.bjsAMMO.btSphereShape(o.x/2);break;case Hd.CustomImpostor:r=this._createCustom(e);break;case Hd.SoftbodyImpostor:r=this._createSoftbody(e);break;case Hd.ClothImpostor:r=this._createCloth(e);break;case Hd.RopeImpostor:r=this._createRope(e);break;default:jo.a.Warn("The impostor type is not currently supported by the ammo plugin.")}return r},e.prototype.setTransformationFromPhysicsBody=function(e){e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.object.position.set(this._tmpAmmoTransform.getOrigin().x(),this._tmpAmmoTransform.getOrigin().y(),this._tmpAmmoTransform.getOrigin().z()),e.object.rotationQuaternion?e.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()):e.object.rotation&&(this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()),this._tmpQuaternion.toEulerAnglesToRef(e.object.rotation))},e.prototype.setPhysicsBodyTransformation=function(e,t,n){var r=e.physicsBody.getWorldTransform();if(r.getOrigin().x()!=t.x||r.getOrigin().y()!=t.y||r.getOrigin().z()!=t.z||r.getRotation().x()!=n.x||r.getRotation().y()!=n.y||r.getRotation().z()!=n.z||r.getRotation().w()!=n.w)if(this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),r.setOrigin(this._tmpAmmoVectorA),this._tmpAmmoQuaternion.setValue(n.x,n.y,n.z,n.w),r.setRotation(this._tmpAmmoQuaternion),e.physicsBody.setWorldTransform(r),0==e.mass){var i=e.physicsBody.getMotionState();i&&i.setWorldTransform(r)}else e.physicsBody.activate()},e.prototype.isSupported=function(){return void 0!==this.bjsAMMO},e.prototype.setLinearVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.soft?e.physicsBody.linearVelocity(this._tmpAmmoVectorA):e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)},e.prototype.setAngularVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.soft?e.physicsBody.angularVelocity(this._tmpAmmoVectorA):e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)},e.prototype.getLinearVelocity=function(e){if(e.soft)var t=e.physicsBody.linearVelocity();else t=e.physicsBody.getLinearVelocity();if(!t)return null;var n=new So(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),n},e.prototype.getAngularVelocity=function(e){if(e.soft)var t=e.physicsBody.angularVelocity();else t=e.physicsBody.getAngularVelocity();if(!t)return null;var n=new So(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),n},e.prototype.setBodyMass=function(e,t){e.soft?e.physicsBody.setTotalMass(t,!1):e.physicsBody.setMassProps(t),e._pluginData.mass=t},e.prototype.getBodyMass=function(e){return e._pluginData.mass||0},e.prototype.getBodyFriction=function(e){return e._pluginData.friction||0},e.prototype.setBodyFriction=function(e,t){e.soft?e.physicsBody.get_m_cfg().set_kDF(t):e.physicsBody.setFriction(t),e._pluginData.friction=t},e.prototype.getBodyRestitution=function(e){return e._pluginData.restitution||0},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.setRestitution(t),e._pluginData.restitution=t},e.prototype.getBodyPressure=function(e){return e.soft?e._pluginData.pressure||0:(jo.a.Warn("Pressure is not a property of a rigid body"),0)},e.prototype.setBodyPressure=function(e,t){e.soft?e.type===Hd.SoftbodyImpostor?(e.physicsBody.get_m_cfg().set_kPR(t),e._pluginData.pressure=t):(e.physicsBody.get_m_cfg().set_kPR(0),e._pluginData.pressure=0):jo.a.Warn("Pressure can only be applied to a softbody")},e.prototype.getBodyStiffness=function(e){return e.soft?e._pluginData.stiffness||0:(jo.a.Warn("Stiffness is not a property of a rigid body"),0)},e.prototype.setBodyStiffness=function(e,t){e.soft?(t=(t=t<0?0:t)>1?1:t,e.physicsBody.get_m_materials().at(0).set_m_kLST(t),e._pluginData.stiffness=t):jo.a.Warn("Stiffness cannot be applied to a rigid body")},e.prototype.getBodyVelocityIterations=function(e){return e.soft?e._pluginData.velocityIterations||0:(jo.a.Warn("Velocity iterations is not a property of a rigid body"),0)},e.prototype.setBodyVelocityIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_viterations(t),e._pluginData.velocityIterations=t):jo.a.Warn("Velocity iterations cannot be applied to a rigid body")},e.prototype.getBodyPositionIterations=function(e){return e.soft?e._pluginData.positionIterations||0:(jo.a.Warn("Position iterations is not a property of a rigid body"),0)},e.prototype.setBodyPositionIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_piterations(t),e._pluginData.positionIterations=t):jo.a.Warn("Position iterations cannot be applied to a rigid body")},e.prototype.appendAnchor=function(e,t,n,r,i,o){void 0===i&&(i=1),void 0===o&&(o=!1);var a=e.segments,s=Math.round((a-1)*n)+a*(a-1-Math.round((a-1)*r));e.physicsBody.appendAnchor(s,t.physicsBody,o,i)},e.prototype.appendHook=function(e,t,n,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var o=Math.round(e.segments*n);e.physicsBody.appendAnchor(o,t.physicsBody,i,r)},e.prototype.sleepBody=function(e){jo.a.Warn("sleepBody is not currently supported by the Ammo physics plugin")},e.prototype.wakeUpBody=function(e){e.physicsBody.activate()},e.prototype.updateDistanceJoint=function(e,t,n){jo.a.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")},e.prototype.setMotor=function(e,t,n,r){e.physicsJoint.enableAngularMotor(!0,t,n)},e.prototype.setLimit=function(e,t,n){jo.a.Warn("setLimit is not currently supported by the Ammo physics plugin")},e.prototype.syncMeshWithImpostor=function(e,t){t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.position.x=this._tmpAmmoTransform.getOrigin().x(),e.position.y=this._tmpAmmoTransform.getOrigin().y(),e.position.z=this._tmpAmmoTransform.getOrigin().z(),e.rotationQuaternion&&(e.rotationQuaternion.x=this._tmpAmmoTransform.getRotation().x(),e.rotationQuaternion.y=this._tmpAmmoTransform.getRotation().y(),e.rotationQuaternion.z=this._tmpAmmoTransform.getRotation().z(),e.rotationQuaternion.w=this._tmpAmmoTransform.getRotation().w())},e.prototype.getRadius=function(e){return e.getObjectExtendSize().x/2},e.prototype.getBoxSizeToRef=function(e,t){var n=e.getObjectExtendSize();t.x=n.x,t.y=n.y,t.z=n.z},e.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},e.prototype.raycast=function(e,t){this._tmpAmmoVectorRCA=new this.bjsAMMO.btVector3(e.x,e.y,e.z),this._tmpAmmoVectorRCB=new this.bjsAMMO.btVector3(t.x,t.y,t.z);var n=new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);return this.world.rayTest(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB,n),this._raycastResult.reset(e,t),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},e.DISABLE_COLLISION_FLAG=4,e.KINEMATIC_FLAG=2,e.DISABLE_DEACTIVATION_FLAG=4,e}();Ao.prototype.removeReflectionProbe=function(e){if(!this.reflectionProbes)return-1;var t=this.reflectionProbes.indexOf(e);return-1!==t&&this.reflectionProbes.splice(t,1),t},Ao.prototype.addReflectionProbe=function(e){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(e)};var lm=function(){function e(e,t,n,r,i){var o=this;void 0===r&&(r=!0),void 0===i&&(i=!1),this.name=e,this._viewMatrix=Oo.Identity(),this._target=So.Zero(),this._add=So.Zero(),this._invertYAxis=!1,this.position=So.Zero(),this._scene=n,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this),this._renderTargetTexture=new mu(e,t,n,r,!0,i?1:0,!0),this._renderTargetTexture.onBeforeRenderObservable.add((function(e){switch(e){case 0:o._add.copyFromFloats(1,0,0);break;case 1:o._add.copyFromFloats(-1,0,0);break;case 2:o._add.copyFromFloats(0,o._invertYAxis?1:-1,0);break;case 3:o._add.copyFromFloats(0,o._invertYAxis?-1:1,0);break;case 4:o._add.copyFromFloats(0,0,1);break;case 5:o._add.copyFromFloats(0,0,-1)}o._attachedMesh&&o.position.copyFrom(o._attachedMesh.getAbsolutePosition()),o.position.addToRef(o._add,o._target),Oo.LookAtLHToRef(o.position,o._target,So.Up(),o._viewMatrix),n.activeCamera&&(o._projectionMatrix=Oo.PerspectiveFovLH(Math.PI/2,1,n.activeCamera.minZ,n.activeCamera.maxZ),n.setTransformMatrix(o._viewMatrix,o._projectionMatrix)),n._forcedViewPosition=o.position})),this._renderTargetTexture.onAfterUnbindObservable.add((function(){n._forcedViewPosition=null,n.updateTransformMatrix(!0)}))}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._renderTargetTexture.samples},set:function(e){this._renderTargetTexture.samples=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},enumerable:!0,configurable:!0}),e.prototype.attachToMesh=function(e){this._attachedMesh=e},e.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderTargetTexture.setRenderingAutoClearDepthStencil(e,t)},e.prototype.dispose=function(){var e=this._scene.reflectionProbes.indexOf(this);-1!==e&&this._scene.reflectionProbes.splice(e,1),this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null)},e.prototype.toString=function(e){var t="Name: "+this.name;return e&&(t+=", position: "+this.position.toString(),this._attachedMesh&&(t+=", attached mesh: "+this._attachedMesh.name)),t},e.prototype.getClassName=function(){return"ReflectionProbe"},e.prototype.serialize=function(){var e=ya.Serialize(this,this._renderTargetTexture.serialize());return e.isReflectionProbe=!0,e},e.Parse=function(t,n,r){var i=null;if(n.reflectionProbes)for(var o=0;o0){var r=t._waitingData.lods.ids,i=n.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=r.length){var a=o.length>r.length?o[o.length-1]:0;n.setEnabled(!1);for(var s=0;s0&&n.addLODLevel(a,null),!0===i&&n.setEnabled(!0)}else Ja.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},fm=function(e,t,n,r,i){void 0===i&&(i=!1);var o=new Ml(e),a="importScene has failed JSON parse";try{var s=JSON.parse(t);a="";var l,c,u=Ph.loggingLevel===Ph.DETAILED_LOGGING;if(void 0!==s.environmentTexture&&null!==s.environmentTexture){var d=void 0===s.isPBR||s.isPBR;if(s.environmentTextureType&&"BABYLON.HDRCubeTexture"===s.environmentTextureType){var h=s.environmentTextureSize?s.environmentTextureSize:128,p=new Jf((s.environmentTexture.match(/https?:\/\//g)?"":n)+s.environmentTexture,e,h,!0,!d);s.environmentTextureRotationY&&(p.rotationY=s.environmentTextureRotationY),e.environmentTexture=p}else if(Jo.a.EndsWith(s.environmentTexture,".env")){var f=new tp((s.environmentTexture.match(/https?:\/\//g)?"":n)+s.environmentTexture,e);s.environmentTextureRotationY&&(f.rotationY=s.environmentTextureRotationY),e.environmentTexture=f}else{var m=tp.CreateFromPrefilteredData((s.environmentTexture.match(/https?:\/\//g)?"":n)+s.environmentTexture,e);s.environmentTextureRotationY&&(m.rotationY=s.environmentTextureRotationY),e.environmentTexture=m}if(!0===s.createDefaultSkybox){var g=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,b=s.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,d,g,b)}o.environmentTexture=e.environmentTexture}if(void 0!==s.environmentIntensity&&null!==s.environmentIntensity&&(e.environmentIntensity=s.environmentIntensity),void 0!==s.lights&&null!==s.lights)for(l=0,c=s.lights.length;l0){for(var q=0;q0){for(var J=0;J-1&&void 0!==c.skeletons&&null!==c.skeletons)if(!1===m.indexOf(b.skeletonId)>-1)for(var P=0,O=c.skeletons.length;P1,r.wrapU=0,r.wrapV=0,r.wrapR=0,r.anisotropicFilteringLevel=1,r._texture=r._getFromCache(t,!0),r._texture||(n.useDelayedTextureLoading?r.delayLoadState=4:r.loadTexture()),r):r}return Object(No.d)(t,e),t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype.load3dlTexture=function(){var e,n=this._engine;e=1===n.webGLVersion?n.createRawTexture(null,1,1,5,!1,!1,2,null,0):n.createRawTexture3D(null,1,1,1,5,!1,!1,2,null,0),this._texture=e;var r=function(r){if("string"==typeof r){for(var i,o=null,a=null,s=r.split("\n"),l=0,c=0,u=0,d=0,h=0,p=0;p0&&(p+1)%4==0)o[p]=255;else{var A=a[p];o[p]=A/h*255}e.is3D?(e.updateSize(l,l,l),n.updateRawTexture3D(e,o,5,!1)):(e.updateSize(l*l,l),n.updateRawTexture(e,o,5,!1))}},i=this.getScene();return i?i._loadFile(this.url,r):this._engine._loadFile(this.url,r),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());return e.level=this.level,e},t.prototype.delayLoad=function(){4===this.delayLoadState&&(this.delayLoadState=1,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},t.Parse=function(e,n){var r=null;return e.name&&!e.isRenderTarget&&((r=new t(e.name,n)).name=e.name,r.level=e.level),r},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}(Ql);Eo.RegisteredTypes["BABYLON.ColorGradingTexture"]=Am;var _m=function(e){function t(t,n,r,i,o,a,s){void 0===i&&(i=!1),void 0===o&&(o=!0),void 0===a&&(a=null),void 0===s&&(s=null);var l=e.call(this,n)||this;if(l._onLoad=null,l._onError=null,l.coordinatesMode=Wl.CUBIC_MODE,!t)throw new Error("Image url is not set");return l.name=t,l.url=t,l._size=r,l._noMipmap=i,l.gammaSpace=o,l._onLoad=a,l._onError=s,l.hasAlpha=!1,l.isCube=!0,l._texture=l._getFromCache(t,l._noMipmap),l._texture?a&&(l._texture.isReady?Ja.SetImmediate((function(){return a()})):l._texture.onLoadedObservable.add(a)):n.useDelayedTextureLoading?l.delayLoadState=4:l.loadImage(l.loadTexture.bind(l),l._onError),l}return Object(No.d)(t,e),t.prototype.loadImage=function(e,t){var n=this,r=document.createElement("canvas"),i=new Image;i.addEventListener("load",(function(){n._width=i.width,n._height=i.height,r.width=n._width,r.height=n._height;var t=r.getContext("2d");t.drawImage(i,0,0);var o=t.getImageData(0,0,i.width,i.height);n._buffer=o.data.buffer,r.remove(),e()})),i.addEventListener("error",(function(e){t&&t(n.getClassName()+" could not be loaded",e)})),i.src=this.url},t.prototype.loadTexture=function(){var e=this,n=this.getScene();n&&(this._texture=n.getEngine().createRawCubeTextureFromUrl(this.url,n,this._size,4,n.getEngine().getCaps().textureFloat?1:7,this._noMipmap,(function(){for(var n=e.getFloat32ArrayFromArrayBuffer(e._buffer),r=qf.ConvertPanoramaToCubemap(n,e._width,e._height,e._size),i=[],o=0;o<6;o++){var a=r[t._FacesMapping[o]];i.push(a)}return i}),null,this._onLoad,this._onError))},t.prototype.getFloat32ArrayFromArrayBuffer=function(e){for(var t=new DataView(e),n=new Float32Array(3*e.byteLength/4),r=0,i=0;in.length)jo.a.Error("Unable to load TGA file - Not enough data");else{r+=i.id_length;var o,a=!1,s=!1,l=!1;switch(i.image_type){case e._TYPE_RLE_INDEXED:a=!0;case e._TYPE_INDEXED:s=!0;break;case e._TYPE_RLE_RGB:a=!0;case e._TYPE_RGB:break;case e._TYPE_RLE_GREY:a=!0;case e._TYPE_GREY:l=!0}var c,u,d,h,p,f,m,g=i.pixel_size>>3,b=i.width*i.height*g;if(s&&(c=n.subarray(r,r+=i.colormap_length*(i.colormap_size>>3))),a){var v,A,_;o=new Uint8Array(b);for(var y=0,x=new Uint8Array(g);r>e._ORIGIN_SHIFT){default:case e._ORIGIN_UL:u=0,h=1,m=i.width,d=0,p=1,f=i.height;break;case e._ORIGIN_BL:u=0,h=1,m=i.width,d=i.height-1,p=-1,f=-1;break;case e._ORIGIN_UR:u=i.width-1,h=-1,m=-1,d=0,p=1,f=i.height;break;case e._ORIGIN_BR:u=i.width-1,h=-1,m=-1,d=i.height-1,p=-1,f=-1}var w=e["_getImageData"+(l?"Grey":"")+i.pixel_size+"bits"](i,c,o,d,p,f,u,h,m);t.getEngine()._uploadDataToTextureDirectly(t,w)}}},e._getImageData8bits=function(e,t,n,r,i,o,a,s,l){var c,u,d,h=n,p=t,f=e.width,m=e.height,g=0,b=new Uint8Array(f*m*4);for(d=r;d!==o;d+=i)for(u=a;u!==l;u+=s,g++)c=h[g],b[4*(u+f*d)+3]=255,b[4*(u+f*d)+2]=p[3*c+0],b[4*(u+f*d)+1]=p[3*c+1],b[4*(u+f*d)+0]=p[3*c+2];return b},e._getImageData16bits=function(e,t,n,r,i,o,a,s,l){var c,u,d,h=n,p=e.width,f=e.height,m=0,g=new Uint8Array(p*f*4);for(d=r;d!==o;d+=i)for(u=a;u!==l;u+=s,m+=2){var b=255*((31744&(c=h[m+0]+(h[m+1]<<8)))>>10)/31|0,v=255*((992&c)>>5)/31|0,A=255*(31&c)/31|0;g[4*(u+p*d)+0]=b,g[4*(u+p*d)+1]=v,g[4*(u+p*d)+2]=A,g[4*(u+p*d)+3]=32768&c?0:255}return g},e._getImageData24bits=function(e,t,n,r,i,o,a,s,l){var c,u,d=n,h=e.width,p=e.height,f=0,m=new Uint8Array(h*p*4);for(u=r;u!==o;u+=i)for(c=a;c!==l;c+=s,f+=3)m[4*(c+h*u)+3]=255,m[4*(c+h*u)+2]=d[f+0],m[4*(c+h*u)+1]=d[f+1],m[4*(c+h*u)+0]=d[f+2];return m},e._getImageData32bits=function(e,t,n,r,i,o,a,s,l){var c,u,d=n,h=e.width,p=e.height,f=0,m=new Uint8Array(h*p*4);for(u=r;u!==o;u+=i)for(c=a;c!==l;c+=s,f+=4)m[4*(c+h*u)+2]=d[f+0],m[4*(c+h*u)+1]=d[f+1],m[4*(c+h*u)+0]=d[f+2],m[4*(c+h*u)+3]=d[f+3];return m},e._getImageDataGrey8bits=function(e,t,n,r,i,o,a,s,l){var c,u,d,h=n,p=e.width,f=e.height,m=0,g=new Uint8Array(p*f*4);for(d=r;d!==o;d+=i)for(u=a;u!==l;u+=s,m++)c=h[m],g[4*(u+p*d)+0]=c,g[4*(u+p*d)+1]=c,g[4*(u+p*d)+2]=c,g[4*(u+p*d)+3]=255;return g},e._getImageDataGrey16bits=function(e,t,n,r,i,o,a,s,l){var c,u,d=n,h=e.width,p=e.height,f=0,m=new Uint8Array(h*p*4);for(u=r;u!==o;u+=i)for(c=a;c!==l;c+=s,f+=2)m[4*(c+h*u)+0]=d[f+0],m[4*(c+h*u)+1]=d[f+0],m[4*(c+h*u)+2]=d[f+0],m[4*(c+h*u)+3]=d[f+1];return m},e._TYPE_INDEXED=1,e._TYPE_RGB=2,e._TYPE_GREY=3,e._TYPE_RLE_INDEXED=9,e._TYPE_RLE_RGB=10,e._TYPE_RLE_GREY=11,e._ORIGIN_MASK=48,e._ORIGIN_SHIFT=4,e._ORIGIN_BL=0,e._ORIGIN_BR=1,e._ORIGIN_UL=2,e._ORIGIN_UR=3,e}(),xm=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return Jo.a.EndsWith(e,".tga")},e.prototype.loadCubeData=function(e,t,n,r,i){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,n){var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=ym.GetTGAHeader(r);n(i.width,i.height,t.generateMipMaps,!1,(function(){ym.UploadContent(t,r)}))},e}();ss.a._TextureLoaders.push(new xm);var wm;!function(e){e[e.cTFETC1=0]="cTFETC1",e[e.cTFBC1=1]="cTFBC1",e[e.cTFBC4=2]="cTFBC4",e[e.cTFPVRTC1_4_OPAQUE_ONLY=3]="cTFPVRTC1_4_OPAQUE_ONLY",e[e.cTFBC7_M6_OPAQUE_ONLY=4]="cTFBC7_M6_OPAQUE_ONLY",e[e.cTFETC2=5]="cTFETC2",e[e.cTFBC3=6]="cTFBC3",e[e.cTFBC5=7]="cTFBC5"}(wm||(wm={}));var Em=function(){function e(){}return e.GetInternalFormatFromBasisFormat=function(e){if(e===wm.cTFETC1)return 36196;if(e===wm.cTFBC1)return 33776;if(e===wm.cTFBC3)return 33779;throw"The chosen Basis transcoder format is not currently supported"},e._CreateWorkerAsync=function(){var t=this;return this._WorkerPromise||(this._WorkerPromise=new Promise((function(n){t._Worker?n(t._Worker):Ja.LoadFileAsync(e.WasmModuleURL).then((function(r){var i=URL.createObjectURL(new Blob(["("+Cm+")()"],{type:"application/javascript"}));t._Worker=new Worker(i);var o=function(e){"init"===e.data.action&&(t._Worker.removeEventListener("message",o),n(t._Worker))};t._Worker.addEventListener("message",o),t._Worker.postMessage({action:"init",url:e.JSModuleURL,wasmBinary:r})}))}))),this._WorkerPromise},e.TranscodeAsync=function(e,t){var n=this,r=e instanceof ArrayBuffer?new Uint8Array(e):e;return new Promise((function(e,i){n._CreateWorkerAsync().then((function(){var o=n._actionId++,a=function(t){"transcode"===t.data.action&&t.data.id===o&&(n._Worker.removeEventListener("message",a),t.data.success?e(t.data):i("Transcode is not supported on this device"))};n._Worker.addEventListener("message",a);var s=new Uint8Array(r.byteLength);s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),n._Worker.postMessage({action:"transcode",id:o,imageData:s,config:t,ignoreSupportedFormats:n._IgnoreSupportedFormats},[s.buffer])}))}))},e.LoadTextureFromTranscodeResult=function(t,n){for(var r,i=t.getEngine(),o=function(){if(r=n.fileInfo.images[a].levels[0],t._invertVScale=t.invertY,-1===n.format)if(t.type=10,t.format=4,i.webGLVersion<2&&(xo.Log2(r.width)%1!=0||xo.Log2(r.height)%1!=0)){var o=new Kl.a(i,Kl.b.Temp);t._invertVScale=t.invertY,o.type=10,o.format=4,o.width=r.width+3&-4,o.height=r.height+3&-4,i._bindTextureDirectly(i._gl.TEXTURE_2D,o,!0),i._uploadDataToTextureDirectly(o,r.transcodedPixels,a,0,4,!0),i._rescaleTexture(o,t,i.scenes[0],i._getInternalFormat(4),(function(){i._releaseTexture(o),i._bindTextureDirectly(i._gl.TEXTURE_2D,t,!0)}))}else t._invertVScale=!t.invertY,t.width=r.width+3&-4,t.height=r.height+3&-4,i._uploadDataToTextureDirectly(t,r.transcodedPixels,a,0,4,!0);else t.width=r.width,t.height=r.height,n.fileInfo.images[a].levels.forEach((function(r,o){i._uploadCompressedDataToTextureDirectly(t,e.GetInternalFormatFromBasisFormat(n.format),r.width,r.height,r.transcodedPixels,a,o)})),i.webGLVersion<2&&(xo.Log2(t.width)%1!=0||xo.Log2(t.height)%1!=0)&&(Ja.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=Wl.CLAMP_ADDRESSMODE,t._cachedWrapV=Wl.CLAMP_ADDRESSMODE)},a=0;a>2&3],o[p++]=i[h>>4&3],o[p++]=i[h>>6&3]}}return o}(a,0,e.getImageWidth(t,n)+3&-4,e.getImageHeight(t,n)+3&-4));return a}onmessage=function(a){if("init"===a.data.action)i||(Module={wasmBinary:a.data.wasmBinary},importScripts(a.data.url),i=new Promise((function(e){Module.onRuntimeInitialized=function(){Module.initializeBasis(),e()}}))),i.then((function(){postMessage({action:"init"})}));else if("transcode"===a.data.action){var s=a.data.config,l=a.data.imageData,c=new Module.BasisFile(l),u=function(e){for(var t=e.getHasAlpha(),n=e.getNumImages(),r=[],i=0;i1&&t.generateMipMaps;Em.LoadTextureFromTranscodeResult(t,e),t.getEngine()._setCubeMapTextureParams(n),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()})).catch((function(e){Ja.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),t.isReady=!0}))}},e.prototype.loadData=function(e,t,n){var r=t.getEngine().getCaps(),i={supportedCompressionFormats:{etc1:!!r.etc1,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2}};Em.TranscodeAsync(e,i).then((function(e){var r=e.fileInfo.images[0].levels[0],i=e.fileInfo.images[0].levels.length>1&&t.generateMipMaps;n(r.width,r.height,i,-1!==e.format,(function(){Em.LoadTextureFromTranscodeResult(t,e)}))})).catch((function(e){Ja.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),n(0,0,!1,!1,(function(){}))}))},e}();ss.a._TextureLoaders.push(new Sm),Va.a.prototype.unBindMultiColorAttachmentFramebuffer=function(e,t,n){void 0===t&&(t=!1),this._currentRenderTarget=null;var r=this._gl;if(e[0]._MSAAFramebuffer){r.bindFramebuffer(r.READ_FRAMEBUFFER,e[0]._MSAAFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e[0]._framebuffer);var i=e[0]._attachments;i||(i=new Array(e.length),e[0]._attachments=i);for(var o=0;o1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"],r.readBuffer(i[o]),r.drawBuffers(i),r.blitFramebuffer(0,0,a.width,a.height,0,0,a.width,a.height,r.COLOR_BUFFER_BIT,r.NEAREST)}for(o=0;o1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"];r.drawBuffers(i)}for(o=0;o1?"COLOR_ATTACHMENT"+g:"COLOR_ATTACHMENT"+g+"_WEBGL"];p.push(_),f.push(y),c.activeTexture(c["TEXTURE"+g]),c.bindTexture(c.TEXTURE_2D,_._webGLTexture),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,A.mag),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,A.min),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texImage2D(c.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(v),d,h,0,c.RGBA,this._getWebGLTextureType(v),null),c.framebufferTexture2D(c.DRAW_FRAMEBUFFER,y,c.TEXTURE_2D,_._webGLTexture,0),n&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(c.TEXTURE_2D,null),_._framebuffer=u,_._depthStencilBuffer=m,_.baseWidth=d,_.baseHeight=h,_.width=d,_.height=h,_.isReady=!0,_.samples=1,_.generateMipMaps=n,_.samplingMode=b,_.type=v,_._generateDepthBuffer=r,_._generateStencilBuffer=i,_._attachments=f,this._internalTexturesCache.push(_)}if(o&&this._caps.depthTextureExtension){var x=new Kl.a(this,Kl.b.MultiRenderTarget);c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,x._webGLTexture),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texImage2D(c.TEXTURE_2D,0,this.webGLVersion<2?c.DEPTH_COMPONENT:c.DEPTH_COMPONENT16,d,h,0,c.DEPTH_COMPONENT,c.UNSIGNED_SHORT,null),c.framebufferTexture2D(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.TEXTURE_2D,x._webGLTexture,0),x._framebuffer=u,x.baseWidth=d,x.baseHeight=h,x.width=d,x.height=h,x.isReady=!0,x.samples=1,x.generateMipMaps=n,x.samplingMode=c.NEAREST,x._generateDepthBuffer=r,x._generateStencilBuffer=i,p.push(x),this._internalTexturesCache.push(x)}return c.drawBuffers(f),this._bindUnboundFramebuffer(null),this.resetTextureCache(),p},Va.a.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e||0==e.length)return 1;if(e[0].samples===t)return t;var n=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e[0]._depthStencilBuffer&&(n.deleteRenderbuffer(e[0]._depthStencilBuffer),e[0]._depthStencilBuffer=null),e[0]._MSAAFramebuffer&&(n.deleteFramebuffer(e[0]._MSAAFramebuffer),e[0]._MSAAFramebuffer=null);for(var r=0;r1&&n.renderbufferStorageMultisample){var i=n.createFramebuffer();if(!i)throw new Error("Unable to create multi sampled framebuffer");this._bindUnboundFramebuffer(i);var o=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),a=[];for(r=0;r1?"COLOR_ATTACHMENT"+r:"COLOR_ATTACHMENT"+r+"_WEBGL"],c=n.createRenderbuffer();if(!c)throw new Error("Unable to create multi sampled framebuffer");n.bindRenderbuffer(n.RENDERBUFFER,c),n.renderbufferStorageMultisample(n.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(s.type),s.width,s.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,l,n.RENDERBUFFER,c),s._MSAAFramebuffer=i,s._MSAARenderBuffer=c,s.samples=t,s._depthStencilBuffer=o,n.bindRenderbuffer(n.RENDERBUFFER,null),a.push(l)}n.drawBuffers(a)}else this._bindUnboundFramebuffer(e[0]._framebuffer);return this._bindUnboundFramebuffer(null),t};var Tm=function(e){function t(t,n,r,i,o){var a=this,s=!(!o||!o.generateMipMaps)&&o.generateMipMaps,l=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,c=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio;if((a=e.call(this,t,n,i,s,c)||this)._engine=i.getEngine(),a.isSupported){for(var u=[],d=[],h=0;h1||this._engine.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wrapU",{set:function(e){if(this._textures)for(var t=0;t=0;e--)void 0!==this._internalTextures[e]&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},t}(mu),Pm=function(){function e(e){this.name=Gs.NAME_PROCEDURALTEXTURE,this.scene=e,this.scene.proceduralTextures=new Array}return e.prototype.register=function(){this.scene._beforeClearStage.registerStep(Gs.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){Ja.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(var e=0;e0)}},e}(),Om="\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}";Qc.a.ShadersStore.proceduralVertexShader=Om;var Rm=function(e){function t(t,n,r,i,o,a,s){void 0===o&&(o=null),void 0===a&&(a=!0),void 0===s&&(s=!1);var l=e.call(this,null,i,!a)||this;l.isCube=s,l.isEnabled=!0,l.autoClear=!0,l.onGeneratedObservable=new yo.a,l._textures={},l._currentRefreshId=-1,l._frameId=-1,l._refreshRate=1,l._vertexBuffers={},l._uniforms=new Array,l._samplers=new Array,l._floats={},l._ints={},l._floatsArrays={},l._colors3={},l._colors4={},l._vectors2={},l._vectors3={},l._matrices={},l._fallbackTextureUsed=!1,l._cachedDefines="",l._contentUpdateId=-1;var c=(i=l.getScene())._getComponent(Gs.NAME_PROCEDURALTEXTURE);c||(c=new Pm(i),i._addComponent(c)),i.proceduralTextures.push(l),l._engine=i.getEngine(),l.name=t,l.isRenderTarget=!0,l._size=n,l._generateMipMaps=a,l.setFragment(r),l._fallbackTexture=o,s?(l._texture=l._engine.createRenderTargetCubeTexture(n,{generateMipMaps:a,generateDepthBuffer:!1,generateStencilBuffer:!1}),l.setFloat("face",0)):l._texture=l._engine.createRenderTargetTexture(n,{generateMipMaps:a,generateDepthBuffer:!1,generateStencilBuffer:!1});var u=[];return u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1),l._vertexBuffers[cs.PositionKind]=new cs(l._engine,u,cs.PositionKind,!1,!1,2),l._createIndexBuffer(),l}return Object(No.d)(t,e),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._engine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},t.prototype._rebuild=function(){var e=this._vertexBuffers[cs.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===mu.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=mu.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){void 0!==this._effect&&this._effect.dispose()},t.prototype._getDefines=function(){return""},t.prototype.isReady=function(){var e,t=this,n=this._engine;if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;var r=this._getDefines();return!(!this._effect||r!==this._cachedDefines||!this._effect.isReady())||(e=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._cachedDefines=r,this._effect=n.createEffect(e,[cs.PositionKind],this._uniforms,this._samplers,r,void 0,void 0,(function(){t.releaseInternalTexture(),t._fallbackTexture&&(t._texture=t._fallbackTexture._texture,t._texture&&t._texture.incrementReferences()),t._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:!0,configurable:!0}),t.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(-1===this._currentRefreshId||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,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this._engine.createRenderTargetTexture(e,t),this._size=e,this._generateMipMaps=t)},t.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},t.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},t.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},t.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},t.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},t.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},t.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},t.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},t.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},t.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},t.prototype.render=function(e){var t=this.getScene();if(t){var n=this._engine;for(var r in n.enableEffect(this._effect),n.setState(!1),this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._ints)this._effect.setInt(r,this._ints[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var i=this._colors4[r];this._effect.setFloat4(r,i.r,i.g,i.b,i.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(this._texture){if(this.isCube)for(var o=0;o<6;o++)n.bindFramebuffer(this._texture,o,void 0,void 0,!0),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),this.autoClear&&n.clear(t.clearColor,!0,!1,!1),n.drawElementsType(Ls.TriangleFillMode,0,6),5===o&&n.generateMipMapsForCubemap(this._texture);else n.bindFramebuffer(this._texture,0,void 0,void 0,!0),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.autoClear&&n.clear(t.clearColor,!0,!1,!1),n.drawElementsType(Ls.TriangleFillMode,0,6);n.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 t=this.getScene();if(t){var n=t.proceduralTextures.indexOf(this);n>=0&&t.proceduralTextures.splice(n,1);var r=this._vertexBuffers[cs.PositionKind];r&&(r.dispose(),this._vertexBuffers[cs.PositionKind]=null),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),e.prototype.dispose.call(this)}},Object(No.c)([ha()],t.prototype,"isEnabled",void 0),Object(No.c)([ha()],t.prototype,"autoClear",void 0),Object(No.c)([ha()],t.prototype,"_generateMipMaps",void 0),Object(No.c)([ha()],t.prototype,"_size",void 0),Object(No.c)([ha()],t.prototype,"refreshRate",null),t}(Wl),Mm=(function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,r,null,i,o,a)||this;return s._animate=!0,s._time=0,s._texturePath=n,s._loadJson(n),s.refreshRate=1,s}Object(No.d)(t,e),t.prototype._loadJson=function(e){var t=this,n=function(){jo.a.Log("No config file found in "+e+" trying to use ShadersStore or DOM element");try{t.setFragment(t._texturePath)}catch(e){jo.a.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},r=e+"/config.json",i=new Fa;i.open("GET",r),i.addEventListener("load",(function(){if(200===i.status||i.responseText&&i.responseText.length>0)try{t._config=JSON.parse(i.response),t.updateShaderUniforms(),t.updateTextures(),t.setFragment(t._texturePath+"/custom"),t._animate=t._config.animate,t.refreshRate=t._config.refreshrate}catch(e){n()}else n()}),!1),i.addEventListener("error",(function(){n()}),!1);try{i.send()}catch(e){jo.a.Error("CustomProceduralTexture: Error on XHR send request.")}},t.prototype.isReady=function(){if(!e.prototype.isReady.call(this))return!1;for(var t in this._textures){if(!this._textures[t].isReady())return!1}return!0},t.prototype.render=function(t){var n=this.getScene();this._animate&&n&&(this._time+=.03*n.getAnimationRatio(),this.updateShaderUniforms()),e.prototype.render.call(this,t)},t.prototype.updateTextures=function(){for(var e=0;e0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isConnectedInVertexShader",{get:function(){if(this.target===km.Vertex)return!0;if(!this.hasEndpoints)return!1;for(var e=0,t=this._endpoints;e=this._outputs.length?null:this._outputs[t+1]},e.prototype.connectTo=function(e,t){if(0!==this._outputs.length){for(var n=t&&t.output?this.getOutputByName(t.output):this.getFirstAvailableOutput(e),r=!0;r;){var i=t&&t.input?e.getInputByName(t.input):e.getFirstAvailableInput(n);if(n&&i&&n.canConnectTo(i))n.connectTo(i),r=!1;else{if(!n)throw"Unable to find a compatible match";n=this.getSiblingOutput(n)}}return this}},e.prototype._buildBlock=function(e){},e.prototype.updateUniformsAndSamples=function(e,t,n,r){},e.prototype.provideFallbacks=function(e,t){},e.prototype.initializeDefines=function(e,t,n,r){void 0===r&&(r=!1)},e.prototype.prepareDefines=function(e,t,n,r){void 0===r&&(r=!1)},e.prototype.autoConfigure=function(e){},e.prototype.replaceRepeatableContent=function(e,t,n,r){},e.prototype.isReady=function(e,t,n,r){return void 0===r&&(r=!1),!0},e.prototype._linkConnectionTypes=function(e,t){this._inputs[e]._linkedConnectionSource=this._inputs[t],this._inputs[t]._linkedConnectionSource=this._inputs[e]},e.prototype._processBuild=function(e,t,n,r){e.build(t,r);var i=null!=t._vertexState,o=e._buildTarget===km.Vertex&&e.target!==km.VertexAndFragment;if(i&&(0==(e.target&e._buildTarget)||0==(e.target&n.target)||this.target!==km.VertexAndFragment&&o)&&(!e.isInput&&t.target!==e._buildTarget||e.isInput&&e.isAttribute)){var a=n.connectedPoint;t._vertexState._emitVaryingFromString("v_"+a.associatedVariableName,t._getGLType(a.type))&&(t._vertexState.compilationString+="v_"+a.associatedVariableName+" = "+a.associatedVariableName+";\r\n"),n.associatedVariableName="v_"+a.associatedVariableName,n._enforceAssociatedVariableName=!0}},e.prototype.build=function(e,t){if(this._buildId===e.sharedData.buildId)return!0;if(!this.isInput)for(var n=0,r=this._outputs;n[0.."+n.repeatKey+"]\r\n";var r=Qc.a.IncludesShadersStore[e]+"\r\n";if(this.sharedData.emitComments&&(r=t+"\r\n"+r),!n)return r;if(n.replaceStrings)for(var i=0;i[0.."+n.repeatKey+"]\r\n":this.functions[i]="#include<"+e+">\r\n",void(this.sharedData.emitComments&&(this.functions[i]=t+"\r\n"+this.functions[i]));if(this.functions[i]=Qc.a.IncludesShadersStore[e],this.sharedData.emitComments&&(this.functions[i]=t+"\r\n"+this.functions[i]),n.removeIfDef&&(this.functions[i]=this.functions[i].replace(/^\s*?#ifdef.+$/gm,""),this.functions[i]=this.functions[i].replace(/^\s*?#endif.*$/gm,""),this.functions[i]=this.functions[i].replace(/^\s*?#else.*$/gm,""),this.functions[i]=this.functions[i].replace(/^\s*?#elif.*$/gm,"")),n.removeAttributes&&(this.functions[i]=this.functions[i].replace(/^\s*?attribute.+$/gm,"")),n.removeUniforms&&(this.functions[i]=this.functions[i].replace(/^\s*?uniform.+$/gm,"")),n.removeVaryings&&(this.functions[i]=this.functions[i].replace(/^\s*?varying.+$/gm,"")),n.replaceStrings)for(var o=0;o-1))return this._optimizers.push(e),this},t.prototype.unregisterOptimizer=function(e){var t=this._optimizers.indexOf(e);if(-1!==t)return this._optimizers.splice(t,1),this},t.prototype.addOutputNode=function(e){if(null===e.target)throw"This node is not meant to be an output node. You may want to explicitly set its target value.";return 0!=(e.target&km.Vertex)&&this._addVertexOutputNode(e),0!=(e.target&km.Fragment)&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return null===e.target||(0!=(e.target&km.Vertex)&&this._removeVertexOutputNode(e),0!=(e.target&km.Fragment)&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(-1===this._vertexOutputNodes.indexOf(e))return e.target=km.Vertex,this._vertexOutputNodes.push(e),this},t.prototype._removeVertexOutputNode=function(e){var t=this._vertexOutputNodes.indexOf(e);if(-1!==t)return this._vertexOutputNodes.splice(t,1),this},t.prototype._addFragmentOutputNode=function(e){if(-1===this._fragmentOutputNodes.indexOf(e))return e.target=km.Fragment,this._fragmentOutputNodes.push(e),this},t.prototype._removeFragmentOutputNode=function(e){var t=this._fragmentOutputNodes.indexOf(e);if(-1!==t)return this._fragmentOutputNodes.splice(t,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,t,n){if(e.initialize(t),e.autoConfigure(this),e._preparationId=this._buildId,-1===this.attachedBlocks.indexOf(e)){if(e.isUnique)for(var r=e.getClassName(),i=0,o=this.attachedBlocks;i-1&&this.attachedBlocks.splice(t,1),e.isFinalMerger&&this.removeOutputNode(e)},t.prototype.build=function(e){void 0===e&&(e=!1),this._buildWasSuccessful=!1;var n=this.getScene().getEngine();if(0===this._vertexOutputNodes.length)throw"You must define at least one vertexOutputNode";if(0===this._fragmentOutputNodes.length)throw"You must define at least one fragmentOutputNode";this._vertexCompilationState=new jm,this._vertexCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._vertexCompilationState.target=km.Vertex,this._fragmentCompilationState=new jm,this._fragmentCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._fragmentCompilationState.target=km.Fragment,this._sharedData=new Gm,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();for(var r=[],i=[],o=0,a=this._vertexOutputNodes;o0&&Cu.BindMorphTargetParameters(n,e)},t.prototype.replaceRepeatableContent=function(e,t,n,r){for(var i=this.position,o=this.normal,a=this.tangent,s=this.uv,l=this.positionOutput,c=this.normalOutput,u=this.tangentOutput,d=this.uvOutput,h=e,p=r.NUM_MORPH_INFLUENCERS,f=n.morphTargetManager,m=f&&f.supportsNormals&&r.NORMAL,g=f&&f.supportsTangents&&r.TANGENT,b=f&&f.supportsUVs&&r.UV1,v="",A=0;A0)for(A=0;A1&&i!=e.length-1?n._getNextFrameBuffer():t,n.setViewport(),n.applyEffectWrapper(r),o&&n.engine.bindFramebuffer(o.getInternalTexture()),n.draw(),o&&n.engine.unBindFramebuffer(o.getInternalTexture())}))},e.prototype.dispose=function(){this._ringScreenBuffer&&(this._ringScreenBuffer.forEach((function(e){e.dispose()})),this._ringScreenBuffer=null);var e=this._vertexBuffers[cs.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[cs.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer)},e._DefaultOptions={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]}}(),function(){function e(e){var t,n=this;this.onApplyObservable=new yo.a;var r=e.uniformNames||[];e.vertexShader?t={fragmentSource:e.fragmentShader,vertexSource:e.vertexShader,spectorName:e.name||"effectWrapper"}:(r.push("scale"),t={fragmentSource:e.fragmentShader,vertex:"postprocess",spectorName:e.name||"effectWrapper"},this.onApplyObservable.add((function(){n.effect.setFloat2("scale",1,1)}))),this.effect=new Qc.a(t,e.attributeNames||["position"],r,e.samplerNames,e.engine)}e.prototype.dispose=function(){this.effect.dispose()}}();var tb=function(){function e(e){this._pendingActions=new Array,this._workerInfos=e.map((function(e){return{worker:e,active:!1}}))}return e.prototype.dispose=function(){for(var e=0,t=this._workerInfos;ee.EPSILON?1:0;l|=u,c.push(u)}switch(l){case 0:(So.Dot(this.normal,t.plane.normal)>0?n:r).push(t);break;case 1:i.push(t);break;case 2:o.push(t);break;case 3:var d,h=[],p=[];for(a=0;a=3&&(d=new cb(h,t.shared)).plane&&i.push(d),p.length>=3&&(d=new cb(p,t.shared)).plane&&o.push(d)}},e.EPSILON=1e-5,e}(),cb=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=lb.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map((function(e){return e.clone()})),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map((function(e){e.flip()})),this.plane.flip()},e}(),ub=function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=new Array,e&&this.build(e)}return e.prototype.clone=function(){var t=new e;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},e.prototype.invert=function(){for(var e=0;e1)?1:e.arc||1,l=0===e.sideOrientation?0:e.sideOrientation||us.DEFAULTSIDE;t.push(0,0,0),i.push(.5,.5);for(var c=2*Math.PI*s,u=c/a,d=0;dt.x&&(t.x=n.x),n.yt.y&&(t.y=n.y)})),{min:e,max:t,width:t.x-e.x,height:t.y-e.y}},e}(),gb=(function(){function e(){}e.Rectangle=function(e,t,n,r){return[new Co(e,t),new Co(n,t),new Co(n,r),new Co(e,r)]},e.Circle=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=32);for(var i=new Array,o=0,a=2*Math.PI/r,s=0;s0){var u=i.length/3;this._points.elements.forEach((function(t){r.push(0,-1,0),i.push(t.x,-e,t.y),o.push(1-(t.x-a.min.x)/a.width,1-(t.y-a.min.y)/a.height)}));var d=s.length;for(c=0;co.elements.length-1?o.elements[0]:o.elements[u+1],e.push(h.x,0,h.y),e.push(h.x,-a,h.y),e.push(d.x,0,d.y),e.push(d.x,-a,d.y);var p=new So(h.x,0,h.y),f=new So(d.x,0,d.y).subtract(p),m=new So(0,1,0),g=So.Cross(f,m);g=g.normalize(),n.push(c/i.width,0),n.push(c/i.width,1),c+=f.length(),n.push(c/i.width,0),n.push(c/i.width,1),s?(t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),r.push(l),r.push(l+2),r.push(l+1),r.push(l+1),r.push(l+2),r.push(l+3)):(t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),r.push(l),r.push(l+1),r.push(l+2),r.push(l+1),r.push(l+3),r.push(l+2)),l+=4}},e}());us.CreatePolygon=function(e,t,n,r,i,o){for(var a=n||new Array(3),s=r,l=[],c=0;c<3;c++)void 0===a[c]&&(a[c]=new To(0,0,1,1)),s&&void 0===s[c]&&(s[c]=new ko(1,1,1,1));for(var u=e.getVerticesData(cs.PositionKind),d=e.getVerticesData(cs.NormalKind),h=e.getVerticesData(cs.UVKind),p=e.getIndices(),f=0,m=0,g=0;g1?1:t.arc:1,o=void 0===t.closed||t.closed,a=t.shape,s=t.radius||1,l=t.tessellation||64,c=t.clip||0,u=t.updatable,d=Pl._GetDefaultSideOrientation(t.sideOrientation),h=t.cap||Pl.NO_CAP,p=2*Math.PI,f=new Array,m=t.invertUV||!1,g=0,b=0,v=p/l*i,A=new Array;for(g=0;g<=l-c;g++){A=[];for(h!=Pl.CAP_START&&h!=Pl.CAP_ALL||(A.push(new So(0,a[0].y,0)),A.push(new So(Math.cos(g*v)*a[0].x*s,a[0].y,Math.sin(g*v)*a[0].x*s))),b=0;b0||d>0){g=-h,b=-p;v=h,A=p;switch(i){case Pl.CENTER:g-=l/=2,v+=l;break;case Pl.LEFT:v+=l,f=-l/2;break;case Pl.RIGHT:g-=l,f=l/2}switch(o){case Pl.CENTER:b-=d/=2,A+=d;break;case Pl.BOTTOM:A+=d,m=-d/2;break;case Pl.TOP:b-=d,m=d/2}}var _=[],y=[],x=[];x[0]=[0,0,1,0,1,1,0,1],x[1]=[0,0,1,0,1,1,0,1],t!==Pl.ROTATE_TILE&&t!==Pl.ROTATE_ROW||(x[1]=[1,1,0,1,0,0,1,0]),t!==Pl.FLIP_TILE&&t!==Pl.FLIP_ROW||(x[1]=[1,0,0,0,0,1,1,1]),t!==Pl.FLIP_N_ROTATE_TILE&&t!==Pl.FLIP_N_ROTATE_ROW||(x[1]=[0,1,1,1,1,0,0,0]);for(var w=[],E=[],C=[],S=0,T=0;T0||d>0){var O,R,M,I,k=d>0&&(o===Pl.CENTER||o===Pl.TOP),D=d>0&&(o===Pl.CENTER||o===Pl.BOTTOM),B=l>0&&(i===Pl.CENTER||i===Pl.RIGHT),F=l>0&&(i===Pl.CENTER||i===Pl.LEFT),N=[];if(k&&B&&(_.push(g+f,b+m,0),_.push(-h+f,b+m,0),_.push(-h+f,b+d+m,0),_.push(g+f,b+d+m,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,N=[O=1-l/n,R=1-d/r,M=1,R,M,I=1,O,I],t===Pl.ROTATE_ROW&&(N=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),t===Pl.FLIP_ROW&&(N=[1-O,R,1-M,R,1-M,I,1-O,I]),t===Pl.FLIP_N_ROTATE_ROW&&(N=[O,1-R,M,1-R,M,1-I,O,1-I]),w=w.concat(N),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),y.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),k&&F&&(_.push(h+f,b+m,0),_.push(v+f,b+m,0),_.push(v+f,b+d+m,0),_.push(h+f,b+d+m,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,N=[O=0,R=1-d/r,M=l/n,R,M,I=1,O,I],(t===Pl.ROTATE_ROW||t===Pl.ROTATE_TILE&&s%2==0)&&(N=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),(t===Pl.FLIP_ROW||t===Pl.FLIP_TILE&&s%2==0)&&(N=[1-O,R,1-M,R,1-M,I,1-O,I]),(t===Pl.FLIP_N_ROTATE_ROW||t===Pl.FLIP_N_ROTATE_TILE&&s%2==0)&&(N=[O,1-R,M,1-R,M,1-I,O,1-I]),w=w.concat(N),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),y.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),D&&B&&(_.push(g+f,p+m,0),_.push(-h+f,p+m,0),_.push(-h+f,A+m,0),_.push(g+f,A+m,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,N=[O=1-l/n,R=0,M=1,R,M,I=d/r,O,I],(t===Pl.ROTATE_ROW&&u%2==1||t===Pl.ROTATE_TILE&&u%1==0)&&(N=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),(t===Pl.FLIP_ROW&&u%2==1||t===Pl.FLIP_TILE&&u%2==0)&&(N=[1-O,R,1-M,R,1-M,I,1-O,I]),(t===Pl.FLIP_N_ROTATE_ROW&&u%2==1||t===Pl.FLIP_N_ROTATE_TILE&&u%2==0)&&(N=[O,1-R,M,1-R,M,1-I,O,1-I]),w=w.concat(N),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),y.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),D&&F&&(_.push(h+f,p+m,0),_.push(v+f,p+m,0),_.push(v+f,A+m,0),_.push(h+f,A+m,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,N=[O=0,R=0,M=l/n,R,M,I=d/r,O,I],(t===Pl.ROTATE_ROW&&u%2==1||t===Pl.ROTATE_TILE&&(u+s)%2==1)&&(N=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),(t===Pl.FLIP_ROW&&u%2==1||t===Pl.FLIP_TILE&&(u+s)%2==1)&&(N=[1-O,R,1-M,R,1-M,I,1-O,I]),(t===Pl.FLIP_N_ROTATE_ROW&&u%2==1||t===Pl.FLIP_N_ROTATE_TILE&&(u+s)%2==1)&&(N=[O,1-R,M,1-R,M,1-I,O,1-I]),w=w.concat(N),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),y.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),k){var L=[];O=0,R=1-d/r,M=1,I=1,L[0]=[O,R,M,R,M,I,O,I],L[1]=[O,R,M,R,M,I,O,I],t!==Pl.ROTATE_TILE&&t!==Pl.ROTATE_ROW||(L[1]=[1-O,1-R,1-M,1-R,1-M,1-I,1-O,1-I]),t!==Pl.FLIP_TILE&&t!==Pl.FLIP_ROW||(L[1]=[1-O,R,1-M,R,1-M,I,1-O,I]),t!==Pl.FLIP_N_ROTATE_TILE&&t!==Pl.FLIP_N_ROTATE_ROW||(L[1]=[O,1-R,M,1-R,M,1-I,O,1-I]);for(P=0;P1)?1:t.arc||1;var h,p,f=function(e,t,n,r,i,o,a,s){for(var l,c,u,d,h=t.getTangents(),p=t.getNormals(),f=t.getDistances(),m=2*Math.PI/i*s,g=o||function(){return r},b=Mo.Matrix[0],v=a===Pl.NO_CAP||a===Pl.CAP_END?0:2,A=0;A3?0:l,t.arc);var b=om.CreateRibbon(e,{pathArray:p,closePath:!0,closeArray:!1,updatable:u,sideOrientation:d,invertUV:c,frontUVs:t.frontUVs,backUVs:t.backUVs},n);return b._creationDataStorage.pathArray=p,b._creationDataStorage.path3D=h,b._creationDataStorage.tessellation=a,b._creationDataStorage.cap=l,b._creationDataStorage.arc=t.arc,b._creationDataStorage.radius=o,b},e}();us.CreateIcoSphere=function(e){var t,n=e.sideOrientation||us.DEFAULTSIDE,r=e.radius||1,i=void 0===e.flat||e.flat,o=e.subdivisions||4,a=e.radiusX||r,s=e.radiusY||r,l=e.radiusZ||r,c=(1+Math.sqrt(5))/2,u=[-1,c,-0,1,c,0,-1,-c,0,1,-c,0,0,-1,-c,0,1,-c,0,-1,c,0,1,c,c,0,1,c,0,-1,-c,0,1,-c,0,-1],d=[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],h=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],p=[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],m=new Array,g=new Array,b=new Array,v=new Array,A=0,_=new Array(3),y=new Array(3);for(t=0;t<3;t++)_[t]=So.Zero(),y[t]=Co.Zero();for(var x=0;x<20;x++){for(t=0;t<3;t++){var w=d[3*x+t];_[t].copyFromFloats(u[3*h[w]],u[3*h[w]+1],u[3*h[w]+2]),_[t].normalize().scaleInPlace(r),y[t].copyFromFloats(p[2*w]*(138/1024)+60/1024+f[x]*(-40/1024),p[2*w+1]*(239/1024)+26/1024+f[x]*(20/1024))}for(var E=function(e,t,n,r){var c,u=So.Lerp(_[0],_[2],t/o),d=So.Lerp(_[1],_[2],t/o),h=o===t?_[2]:So.Lerp(u,d,e/(o-t));if(h.normalize(),i){var p=So.Lerp(_[0],_[2],r/o),f=So.Lerp(_[1],_[2],r/o);c=So.Lerp(p,f,n/(o-r))}else c=new So(h.x,h.y,h.z);c.x/=a,c.y/=s,c.z/=l,c.normalize();var x=Co.Lerp(y[0],y[2],t/o),w=Co.Lerp(y[1],y[2],t/o),E=o===t?y[2]:Co.Lerp(x,w,e/(o-t));g.push(h.x*a,h.y*s,h.z*l),b.push(c.x,c.y,c.z),v.push(E.x,E.y),m.push(A),A++},C=0;C0)?1:0)+((s=So.Dot(e[o+1].position,t)-n>0)?1:0)+((c=So.Dot(e[o+2].position,t)-n>0)?1:0)){case 0:i.push(e[o]),i.push(e[o+1]),i.push(e[o+2]);break;case 1:if(a&&(u=e[o+1],d=e[o+2],h=r(e[o],u),p=r(e[o],d)),s){u=e[o],d=e[o+2],h=r(e[o+1],u),p=r(e[o+1],d),i.push(h),i.push(d.clone()),i.push(u.clone()),i.push(d.clone()),i.push(h.clone()),i.push(p);break}c&&(u=e[o],d=e[o+1],h=r(e[o+2],u),p=r(e[o+2],d)),u&&d&&h&&p&&(i.push(u.clone()),i.push(d.clone()),i.push(h),i.push(p),i.push(h.clone()),i.push(d.clone()));break;case 2:a||(d=r(u=e[o].clone(),e[o+1]),h=r(u,e[o+2]),i.push(u),i.push(d),i.push(h)),s||(d=r(u=e[o+1].clone(),e[o+2]),h=r(u,e[o]),i.push(u),i.push(d),i.push(h)),c||(d=r(u=e[o+2].clone(),e[o]),h=r(u,e[o+1]),i.push(u),i.push(d),i.push(h))}}return i},w=0;ws||n.deleted||n.isDirty))for(var i=0;i<3;++i)if(n.error[i]>0,(function(e){if(i){var t=e+a.verticesStart,o=So.FromArray(i,3*t),l=function(e){if(n)for(var t=0;t0&&this._reconstructedMesh.setVerticesData(cs.UVKind,s),l.length>0&&this._reconstructedMesh.setVerticesData(cs.ColorKind,l);var A=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],g.forEach((function(e){Ns.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),Ns.AddToMesh(A.materialIndex,m,h,f,3*i.length,this._reconstructedMesh))},e.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new Pl(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},e.prototype.isFlipped=function(e,t,n,r,i){for(var o=0;o.999)return!0;var h=So.Cross(u,d).normalize();if(r[o]=!1,So.Dot(h,a.normal)<.2)return!0}else r[o]=!0,i.push(a)}}return!1},e.prototype.updateTriangles=function(e,t,n,r){for(var i=r,o=0;o-1&&(this.agents.splice(t,1),this.transforms.splice(t,1))},e.prototype.getAgents=function(){return this.agents},e.prototype.update=function(e){this.recastCrowd.update(e);for(var t=0;t=400&&o?o(c):n()}),!1),c.addEventListener("error",(function(){jo.a.Error("error on XHR request."),n()}),!1),c.send()}else jo.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),n()},e._ValidateXHRData=function(e,t){void 0===t&&(t=7);try{if(1&t){if(e.responseText&&e.responseText.length>0)return!0;if(1===t)return!1}if(2&t){var n=ym.GetTGAHeader(e.response);if(n.width&&n.height&&n.width>0&&n.height>0)return!0;if(2===t)return!1}if(4&t){var r=new Uint8Array(e.response,0,3);return 68===r[0]&&68===r[1]&&83===r[2]}}catch(e){}return!1},e.IsUASupportingBlobStorage=!0,e.IDBStorageEnabled=!1,e._ParseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),n=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(n,0))},e._ReturnFullUrlLocation=function(t){return-1===t.indexOf("http:/")&&-1===t.indexOf("https:/")?e._ParseURL(window.location.href)+t:t},e}(),Bb=function(){function e(){this.direction1=new So(0,1,0),this.direction2=new So(0,1,0),this.minEmitBox=new So(-.5,-.5,-.5),this.maxEmitBox=new So(.5,.5,.5)}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=xo.RandomRange(this.direction1.x,this.direction2.x),o=xo.RandomRange(this.direction1.y,this.direction2.y),a=xo.RandomRange(this.direction1.z,this.direction2.z);if(r)return t.x=i,t.y=o,void(t.z=a);So.TransformNormalFromFloatsToRef(i,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=xo.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),o=xo.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),a=xo.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);if(r)return t.x=i,t.y=o,void(t.z=a);So.TransformCoordinatesFromFloatsToRef(i,o,a,e,t)},e.prototype.clone=function(){var t=new e;return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2),e.setVector3("minEmitBox",this.minEmitBox),e.setVector3("maxEmitBox",this.maxEmitBox)},e.prototype.getEffectDefines=function(){return"#define BOXEMITTER"},e.prototype.getClassName=function(){return"BoxParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e.minEmitBox=this.minEmitBox.asArray(),e.maxEmitBox=this.maxEmitBox.asArray(),e},e.prototype.parse=function(e){So.FromArrayToRef(e.direction1,0,this.direction1),So.FromArrayToRef(e.direction2,0,this.direction2),So.FromArrayToRef(e.minEmitBox,0,this.minEmitBox),So.FromArrayToRef(e.maxEmitBox,0,this.maxEmitBox)},e}(),Fb=function(){function e(e,t,n){void 0===e&&(e=1),void 0===t&&(t=Math.PI),void 0===n&&(n=0),this.directionRandomizer=n,this.radiusRange=1,this.heightRange=1,this.emitFromSpawnPointOnly=!1,this.angle=t,this.radius=e}return Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._buildHeight()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._buildHeight()},enumerable:!0,configurable:!0}),e.prototype._buildHeight=function(){0!==this._angle?this._height=this._radius/Math.tan(this._angle/2):this._height=1},e.prototype.startDirectionFunction=function(e,t,n,r){if(1===Math.abs(Math.cos(this._angle))){if(r)return t.x=0,t.y=1,void(t.z=0);So.TransformNormalFromFloatsToRef(0,1,0,e,t)}else{var i=n.position.subtract(e.getTranslation()).normalize(),o=xo.RandomRange(0,this.directionRandomizer),a=xo.RandomRange(0,this.directionRandomizer),s=xo.RandomRange(0,this.directionRandomizer);if(i.x+=o,i.y+=a,i.z+=s,i.normalize(),r)return void t.copyFrom(i);So.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)}},e.prototype.startPositionFunction=function(e,t,n,r){var i,o=xo.RandomRange(0,2*Math.PI);i=this.emitFromSpawnPointOnly?1e-4:1-(i=xo.RandomRange(0,this.heightRange))*i;var a=this._radius-xo.RandomRange(0,this._radius*this.radiusRange),s=(a*=i)*Math.sin(o),l=a*Math.cos(o),c=i*this._height;if(r)return t.x=s,t.y=c,void(t.z=l);So.TransformCoordinatesFromFloatsToRef(s,c,l,e,t)},e.prototype.clone=function(){var t=new e(this._radius,this._angle,this.directionRandomizer);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat2("radius",this._radius,this.radiusRange),e.setFloat("coneAngle",this._angle),e.setFloat2("height",this._height,this.heightRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){var e="#define CONEEMITTER";return this.emitFromSpawnPointOnly&&(e+="\n#define CONEEMITTERSPAWNPOINT"),e},e.prototype.getClassName=function(){return"ConeParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this._radius,e.angle=this._angle,e.directionRandomizer=this.directionRandomizer,e.radiusRange=this.radiusRange,e.heightRange=this.heightRange,e.emitFromSpawnPointOnly=this.emitFromSpawnPointOnly,e},e.prototype.parse=function(e){this.radius=e.radius,this.angle=e.angle,this.directionRandomizer=e.directionRandomizer,this.radiusRange=e.radiusRange,this.heightRange=e.heightRange,this.emitFromSpawnPointOnly=e.emitFromSpawnPointOnly},e}(),Nb=function(){function e(e,t,n,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=0),this.radius=e,this.height=t,this.radiusRange=n,this.directionRandomizer=r}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=n.position.subtract(e.getTranslation()).normalize(),o=xo.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),a=Math.atan2(i.x,i.z);a+=xo.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,i.y=o,i.x=Math.sin(a),i.z=Math.cos(a),i.normalize(),r?t.copyFrom(i):So.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=xo.RandomRange(-this.height/2,this.height/2),o=xo.RandomRange(0,2*Math.PI),a=xo.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),s=Math.sqrt(a)*this.radius,l=s*Math.cos(o),c=s*Math.sin(o);r?t.copyFromFloats(l,i,c):So.TransformCoordinatesFromFloatsToRef(l,i,c,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER"},e.prototype.getClassName=function(){return"CylinderParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.height=this.height,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.height=e.height,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Lb=function(e){function t(t,n,r,i,o){void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=new So(0,1,0)),void 0===o&&(o=new So(0,1,0));var a=e.call(this,t,n,r)||this;return a.direction1=i,a.direction2=o,a}return Object(No.d)(t,e),t.prototype.startDirectionFunction=function(e,t,n){var r=xo.RandomRange(this.direction1.x,this.direction2.x),i=xo.RandomRange(this.direction1.y,this.direction2.y),o=xo.RandomRange(this.direction1.z,this.direction2.z);So.TransformNormalFromFloatsToRef(r,i,o,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return ea.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\n#define DIRECTEDCYLINDEREMITTER"},t.prototype.getClassName=function(){return"CylinderDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(Nb),Ub=function(){function e(e,t,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=n}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=n.position.subtract(e.getTranslation()).normalize(),o=xo.RandomRange(0,this.directionRandomizer),a=xo.RandomRange(0,this.directionRandomizer),s=xo.RandomRange(0,this.directionRandomizer);i.x+=o,i.y+=a,i.z+=s,i.normalize(),r?t.copyFrom(i):So.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=this.radius-xo.RandomRange(0,this.radius*this.radiusRange),o=xo.RandomRange(0,1),a=xo.RandomRange(0,2*Math.PI),s=Math.acos(2*o-1),l=i*Math.cos(a)*Math.sin(s),c=i*Math.cos(s),u=i*Math.sin(a)*Math.sin(s);r?t.copyFromFloats(l,Math.abs(c),u):So.TransformCoordinatesFromFloatsToRef(l,Math.abs(c),u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define HEMISPHERICEMITTER"},e.prototype.getClassName=function(){return"HemisphericParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Vb=function(){function e(){this.direction1=new So(0,1,0),this.direction2=new So(0,1,0)}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=xo.RandomRange(this.direction1.x,this.direction2.x),o=xo.RandomRange(this.direction1.y,this.direction2.y),a=xo.RandomRange(this.direction1.z,this.direction2.z);r?t.copyFromFloats(i,o,a):So.TransformNormalFromFloatsToRef(i,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){r?t.copyFromFloats(0,0,0):So.TransformCoordinatesFromFloatsToRef(0,0,0,e,t)},e.prototype.clone=function(){var t=new e;return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},e.prototype.getEffectDefines=function(){return"#define POINTEMITTER"},e.prototype.getClassName=function(){return"PointParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},e.prototype.parse=function(e){So.FromArrayToRef(e.direction1,0,this.direction1),So.FromArrayToRef(e.direction2,0,this.direction2)},e}(),zb=function(){function e(e,t,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=n}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=n.position.subtract(e.getTranslation()).normalize(),o=xo.RandomRange(0,this.directionRandomizer),a=xo.RandomRange(0,this.directionRandomizer),s=xo.RandomRange(0,this.directionRandomizer);i.x+=o,i.y+=a,i.z+=s,i.normalize(),r?t.copyFrom(i):So.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=this.radius-xo.RandomRange(0,this.radius*this.radiusRange),o=xo.RandomRange(0,1),a=xo.RandomRange(0,2*Math.PI),s=Math.acos(2*o-1),l=i*Math.cos(a)*Math.sin(s),c=i*Math.cos(s),u=i*Math.sin(a)*Math.sin(s);r?t.copyFromFloats(l,c,u):So.TransformCoordinatesFromFloatsToRef(l,c,u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER"},e.prototype.getClassName=function(){return"SphereParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),jb=function(e){function t(t,n,r){void 0===t&&(t=1),void 0===n&&(n=new So(0,1,0)),void 0===r&&(r=new So(0,1,0));var i=e.call(this,t)||this;return i.direction1=n,i.direction2=r,i}return Object(No.d)(t,e),t.prototype.startDirectionFunction=function(e,t,n){var r=xo.RandomRange(this.direction1.x,this.direction2.x),i=xo.RandomRange(this.direction1.y,this.direction2.y),o=xo.RandomRange(this.direction1.z,this.direction2.z);So.TransformNormalFromFloatsToRef(r,i,o,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return ea.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\n#define DIRECTEDSPHEREEMITTER"},t.prototype.getClassName=function(){return"SphereDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(zb),Gb=function(){function e(){this.particlePositionGenerator=function(){},this.particleDestinationGenerator=function(){}}return e.prototype.startDirectionFunction=function(e,t,n,r){var i=Mo.Vector3[0];if(this.particleDestinationGenerator){this.particleDestinationGenerator(-1,n,i);var o=Mo.Vector3[1];i.subtractToRef(n.position,o),o.scaleToRef(1/n.lifeTime,i)}else i.set(0,0,0);r?t.copyFrom(i):So.TransformNormalToRef(i,e,t)},e.prototype.startPositionFunction=function(e,t,n,r){var i=Mo.Vector3[0];this.particlePositionGenerator?this.particlePositionGenerator(-1,n,i):i.set(0,0,0),r?t.copyFrom(i):So.TransformCoordinatesToRef(i,e,t)},e.prototype.clone=function(){var t=new e;return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){},e.prototype.getEffectDefines=function(){return"#define CUSTOMEMITTER"},e.prototype.getClassName=function(){return"CustomParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e},e.prototype.parse=function(e){},e}(),Hb=(function(){function e(e){this.mesh=e,this._indices=null,this._positions=null,this._normals=null,this._storedNormal=So.Zero(),this.direction1=new So(0,1,0),this.direction2=new So(0,1,0),this.useMeshNormalsForDirection=!0,e&&(this._indices=e.getIndices(),this._positions=e.getVerticesData(cs.PositionKind),this._normals=e.getVerticesData(cs.NormalKind))}e.prototype.startDirectionFunction=function(e,t,n,r){if(this.useMeshNormalsForDirection&&this._normals)So.TransformNormalToRef(this._storedNormal,e,t);else{var i=xo.RandomRange(this.direction1.x,this.direction2.x),o=xo.RandomRange(this.direction1.y,this.direction2.y),a=xo.RandomRange(this.direction1.z,this.direction2.z);r?t.copyFromFloats(i,o,a):So.TransformNormalFromFloatsToRef(i,o,a,e,t)}},e.prototype.startPositionFunction=function(e,t,n,r){if(this._indices&&this._positions){var i=3*Math.random()*(this._indices.length/3)|0,o=Math.random(),a=Math.random()*(1-o),s=1-o-a,l=this._indices[i],c=this._indices[i+1],u=this._indices[i+2],d=Mo.Vector3[0],h=Mo.Vector3[1],p=Mo.Vector3[2],f=Mo.Vector3[3];So.FromArrayToRef(this._positions,3*l,d),So.FromArrayToRef(this._positions,3*c,h),So.FromArrayToRef(this._positions,3*u,p),f.x=o*d.x+a*h.x+s*p.x,f.y=o*d.y+a*h.y+s*p.y,f.z=o*d.z+a*h.z+s*p.z,r?t.copyFromFloats(f.x,f.y,f.z):So.TransformCoordinatesFromFloatsToRef(f.x,f.y,f.z,e,t),this.useMeshNormalsForDirection&&this._normals&&(So.FromArrayToRef(this._normals,3*l,d),So.FromArrayToRef(this._normals,3*c,h),So.FromArrayToRef(this._normals,3*u,p),this._storedNormal.x=o*d.x+a*h.x+s*p.x,this._storedNormal.y=o*d.y+a*h.y+s*p.y,this._storedNormal.z=o*d.z+a*h.z+s*p.z)}},e.prototype.clone=function(){var t=new e(this.mesh);return ea.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},e.prototype.getEffectDefines=function(){return""},e.prototype.getClassName=function(){return"MeshParticleEmitter"},e.prototype.serialize=function(){var e,t={};return t.type=this.getClassName(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.meshId=null===(e=this.mesh)||void 0===e?void 0:e.id,t.useMeshNormalsForDirection=this.useMeshNormalsForDirection,t},e.prototype.parse=function(e,t){So.FromArrayToRef(e.direction1,0,this.direction1),So.FromArrayToRef(e.direction2,0,this.direction2),e.meshId&&(this.mesh=t.getLastMeshByID(e.meshId)||void 0),this.useMeshNormalsForDirection=e.useMeshNormalsForDirection}}(),function(){function e(t){this.animations=[],this.renderingGroupId=0,this.emitter=So.Zero(),this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.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 So(10,10,10),this.onAnimationEnd=null,this.blendMode=e.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 Co(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.worldOffset=new So(0,0,0),this.gravity=So.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=.4,this.color1=new ko(1,1,1,1),this.color2=new ko(1,1,1,1),this.colorDead=new ko(0,0,0,1),this.textureMask=new ko(1,1,1,1),this._isSubEmitter=!1,this.billboardMode=7,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new Rs,this.id=t,this.name=t}return Object.defineProperty(e.prototype,"noiseTexture",{get:function(){return this._noiseTexture},set:function(e){this._noiseTexture!==e&&(this._noiseTexture=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},set:function(e){this._isAnimationSheetEnabled!=e&&(this._isAnimationSheetEnabled=e,this._reset())},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype._hasTargetStopDurationDependantGradient=function(){return this._startSizeGradients&&this._startSizeGradients.length>0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},e.prototype.getDragGradients=function(){return this._dragGradients},e.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},e.prototype.getColorGradients=function(){return this._colorGradients},e.prototype.getSizeGradients=function(){return this._sizeGradients},e.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},e.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},e.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},e.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},e.prototype.getVelocityGradients=function(){return this._velocityGradients},e.prototype.getStartSizeGradients=function(){return this._startSizeGradients},e.prototype.getEmitRateGradients=function(){return this._emitRateGradients},Object.defineProperty(e.prototype,"direction1",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:So.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:So.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:So.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:So.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration=e||this._scene.imageProcessingConfiguration)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,n){if(!t)return this;for(var r=0,i=0,o=t;i=i.gradient&&e<=o.gradient)return void n(i,o,(e-i.gradient)/(o.gradient-i.gradient))}var a=t.length-1;n(t[a],t[a],1)},e}(),Yb=function(){function e(t){this.particleSystem=t,this.position=So.Zero(),this.direction=So.Zero(),this.color=new ko(0,0,0,0),this.colorStep=new ko(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new Co(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new ko(0,0,0,0),this._currentColor2=new ko(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=e._Count++,this.particleSystem.isAnimationSheetEnabled&&this.updateCellInfoFromSystem()}return e.prototype.updateCellInfoFromSystem=function(){this.cellIndex=this.particleSystem.startSpriteCellID},e.prototype.updateCellIndex=function(){var e=this.age,t=this.particleSystem.spriteCellChangeSpeed;this.particleSystem.spriteRandomStartCell&&(void 0===this._randomCellOffset&&(this._randomCellOffset=Math.random()*this.lifeTime),0===t?(t=1,e=this._randomCellOffset):e+=this._randomCellOffset);var n=this._initialEndSpriteCellID-this._initialStartSpriteCellID,r=xo.Clamp(e*t%this.lifeTime/this.lifeTime);this.cellIndex=this._initialStartSpriteCellID+r*n|0},e.prototype._inheritParticleInfoToSubEmitter=function(e){if(e.particleSystem.emitter.position){var t=e.particleSystem.emitter;t.position.copyFrom(this.position),e.inheritDirection&&t.setDirection(this.direction.normalize(),0,Math.PI/2)}else{e.particleSystem.emitter.copyFrom(this.position)}this.direction.scaleToRef(e.inheritedVelocityAmount/2,Mo.Vector3[0]),e.particleSystem._inheritedVelocityOffset.copyFrom(Mo.Vector3[0])},e.prototype._inheritParticleInfoToSubEmitters=function(){var e=this;this._attachedSubEmitters&&this._attachedSubEmitters.length>0&&this._attachedSubEmitters.forEach((function(t){e._inheritParticleInfoToSubEmitter(t)}))},e.prototype._reset=function(){this.age=0,this.id=e._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},e.prototype.copyTo=function(e){e.position.copyFrom(this.position),this._initialDirection?e._initialDirection?e._initialDirection.copyFrom(this._initialDirection):e._initialDirection=this._initialDirection.clone():e._initialDirection=null,e.direction.copyFrom(this.direction),this._localPosition&&(e._localPosition?e._localPosition.copyFrom(this._localPosition):e._localPosition=this._localPosition.clone()),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e._randomCellOffset=this._randomCellOffset,e.size=this.size,e.scale.copyFrom(this.scale),e.angle=this.angle,e.angularSpeed=this.angularSpeed,e.particleSystem=this.particleSystem,e.cellIndex=this.cellIndex,e.id=this.id,e._attachedSubEmitters=this._attachedSubEmitters,this._currentColorGradient&&(e._currentColorGradient=this._currentColorGradient,e._currentColor1.copyFrom(this._currentColor1),e._currentColor2.copyFrom(this._currentColor2)),this._currentSizeGradient&&(e._currentSizeGradient=this._currentSizeGradient,e._currentSize1=this._currentSize1,e._currentSize2=this._currentSize2),this._currentAngularSpeedGradient&&(e._currentAngularSpeedGradient=this._currentAngularSpeedGradient,e._currentAngularSpeed1=this._currentAngularSpeed1,e._currentAngularSpeed2=this._currentAngularSpeed2),this._currentVelocityGradient&&(e._currentVelocityGradient=this._currentVelocityGradient,e._currentVelocity1=this._currentVelocity1,e._currentVelocity2=this._currentVelocity2),this._currentLimitVelocityGradient&&(e._currentLimitVelocityGradient=this._currentLimitVelocityGradient,e._currentLimitVelocity1=this._currentLimitVelocity1,e._currentLimitVelocity2=this._currentLimitVelocity2),this._currentDragGradient&&(e._currentDragGradient=this._currentDragGradient,e._currentDrag1=this._currentDrag1,e._currentDrag2=this._currentDrag2),this.particleSystem.isAnimationSheetEnabled&&(e._initialStartSpriteCellID=this._initialStartSpriteCellID,e._initialEndSpriteCellID=this._initialEndSpriteCellID),this.particleSystem.useRampGradients&&e.remapData.copyFrom(this.remapData),this._randomNoiseCoordinates1&&(e._randomNoiseCoordinates1?(e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)):(e._randomNoiseCoordinates1=this._randomNoiseCoordinates1.clone(),e._randomNoiseCoordinates2=this._randomNoiseCoordinates2.clone()))},e._Count=0,e}();!function(e){e[e.ATTACHED=0]="ATTACHED",e[e.END=1]="END"}(kb||(kb={}));var qb=function(){function e(e){this.particleSystem=e,this.type=kb.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,e.emitter&&e.emitter.dispose||(e.emitter=new ws("SubemitterSystemEmitter",e.getScene())),e.onDisposeObservable.add((function(){e.emitter&&e.emitter.dispose&&e.emitter.dispose()}))}return e.prototype.clone=function(){var t=this.particleSystem.emitter;t?t instanceof So?t=t.clone():t instanceof ws&&((t=new Pl("",t.getScene())).isVisible=!1):t=new So;var n=new e(this.particleSystem.clone("",t));return n.particleSystem.name+="Clone",n.type=this.type,n.inheritDirection=this.inheritDirection,n.inheritedVelocityAmount=this.inheritedVelocityAmount,n.particleSystem._disposeEmitterOnDispose=!0,n.particleSystem.disposeOnStop=!0,n},e.prototype.serialize=function(){var e={};return e.type=this.type,e.inheritDirection=this.inheritDirection,e.inheritedVelocityAmount=this.inheritedVelocityAmount,e.particleSystem=this.particleSystem.serialize(),e},e._ParseParticleSystem=function(e,t,n){throw oa.a.WarnImport("ParseParticle")},e.Parse=function(t,n,r){var i=t.particleSystem,o=new e(e._ParseParticleSystem(i,n,r));return o.type=t.type,o.inheritDirection=t.inheritDirection,o.inheritedVelocityAmount=t.inheritedVelocityAmount,o.particleSystem._isSubEmitter=!0,o},e.prototype.dispose=function(){this.particleSystem.dispose()},e}(),Zb="\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#include\n#include\n#include\n#include\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\nuniform sampler2D rampSampler;\n#endif\nvoid main(void) {\n#include\nvec4 textureColor=texture2D(diffuseSampler,vUV);\nvec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n#ifdef RAMPGRADIENT\nfloat alpha=baseColor.a;\nfloat remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);\nvec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));\nbaseColor.rgb*=rampColor.rgb;\n\nfloat finalAlpha=baseColor.a;\nbaseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);\n#endif\n#ifdef BLENDMULTIPLYMODE\nfloat sourceAlpha=vColor.a*textureColor.a;\nbaseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);\n#endif\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\nbaseColor=applyImageProcessing(baseColor);\n#endif\n#endif\ngl_FragColor=baseColor;\n}";Qc.a.ShadersStore.particlesPixelShader=Zb;var Jb="\nattribute vec3 position;\nattribute vec4 color;\nattribute float angle;\nattribute vec2 size;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\n#ifndef BILLBOARD\nattribute vec3 direction;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\n#endif\nattribute vec2 offset;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n#ifdef ANIMATESHEET\nuniform vec3 particlesInfos;\n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nuniform mat4 invView;\n#endif\n#include\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\nvoid main(void) {\nvec2 cornerPos;\ncornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;\n#ifdef BILLBOARD\n\nvec3 rotatedCorner;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz;\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz;\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;\n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\n\ngl_Position=projection*vec4(viewPos,1.0);\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=normalize(direction);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(worldPos,1.0);\n#endif\nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/particlesInfos.z);\nfloat columnOffset=cellIndex-rowOffset*particlesInfos.z;\nvec2 uvScale=particlesInfos.xy;\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=invView*vec4(viewPos,1.0);\n#endif\n#include\n}";Qc.a.ShadersStore.particlesVertexShader=Jb;var $b=function(e){function t(t,n,r,i,o,a){void 0===i&&(i=null),void 0===o&&(o=!1),void 0===a&&(a=.01);var s=e.call(this,t)||this;return s._inheritedVelocityOffset=new So,s.onDisposeObservable=new yo.a,s._particles=new Array,s._stockParticles=new Array,s._newPartsExcess=0,s._vertexBuffers={},s._scaledColorStep=new ko(0,0,0,0),s._colorDiff=new ko(0,0,0,0),s._scaledDirection=So.Zero(),s._scaledGravity=So.Zero(),s._currentRenderId=-1,s._useInstancing=!1,s._started=!1,s._stopped=!1,s._actualFrame=0,s._currentEmitRate1=0,s._currentEmitRate2=0,s._currentStartSize1=0,s._currentStartSize2=0,s._rawTextureWidth=256,s._useRampGradients=!1,s._disposeEmitterOnDispose=!1,s.isLocal=!1,s.recycleParticle=function(e){var t=s._particles.pop();t!==e&&t.copyTo(e),s._stockParticles.push(t)},s._createParticle=function(){var e;if(0!==s._stockParticles.length?(e=s._stockParticles.pop())._reset():e=new Yb(s),s._subEmitters&&s._subEmitters.length>0){var t=s._subEmitters[Math.floor(Math.random()*s._subEmitters.length)];e._attachedSubEmitters=[],t.forEach((function(t){if(t.type===kb.ATTACHED){var n=t.clone();e._attachedSubEmitters.push(n),n.particleSystem.start()}}))}return e},s._emitFromParticle=function(e){if(s._subEmitters&&0!==s._subEmitters.length){var t=Math.floor(Math.random()*s._subEmitters.length);s._subEmitters[t].forEach((function(t){if(t.type===kb.END){var n=t.clone();e._inheritParticleInfoToSubEmitter(n),n.particleSystem._rootParticleSystem=s,s.activeSubSystems.push(n.particleSystem),n.particleSystem.start()}}))}},s._capacity=n,s._epsilon=a,s._isAnimationSheetEnabled=o,s._scene=r||Zo.a.LastCreatedScene,s._attachImageProcessingConfiguration(null),s._customEffect=i,s._scene.particleSystems.push(s),s._useInstancing=s._scene.getEngine().getCaps().instancedArrays,s._createIndexBuffer(),s._createVertexBuffers(),s.particleEmitterType=new Bb,s.updateFunction=function(e){var t=null,n=null;s.noiseTexture&&(t=s.noiseTexture.getSize(),n=s.noiseTexture.getContent());for(var r,i=function(){r=e[o];var i=s._scaledUpdateSpeed,a=r.age;if(r.age+=i,r.age>r.lifeTime){var l=r.age-a;i=(r.lifeTime-a)*i/l,r.age=r.lifeTime}var c=r.age/r.lifeTime;s._colorGradients&&s._colorGradients.length>0?Xb.GetCurrentGradient(c,s._colorGradients,(function(e,t,n){e!==r._currentColorGradient&&(r._currentColor1.copyFrom(r._currentColor2),t.getColorToRef(r._currentColor2),r._currentColorGradient=e),ko.LerpToRef(r._currentColor1,r._currentColor2,n,r.color)})):(r.colorStep.scaleToRef(i,s._scaledColorStep),r.color.addInPlace(s._scaledColorStep),r.color.a<0&&(r.color.a=0)),s._angularSpeedGradients&&s._angularSpeedGradients.length>0&&Xb.GetCurrentGradient(c,s._angularSpeedGradients,(function(e,t,n){e!==r._currentAngularSpeedGradient&&(r._currentAngularSpeed1=r._currentAngularSpeed2,r._currentAngularSpeed2=t.getFactor(),r._currentAngularSpeedGradient=e),r.angularSpeed=xo.Lerp(r._currentAngularSpeed1,r._currentAngularSpeed2,n)})),r.angle+=r.angularSpeed*i;var u=i;if(s._velocityGradients&&s._velocityGradients.length>0&&Xb.GetCurrentGradient(c,s._velocityGradients,(function(e,t,n){e!==r._currentVelocityGradient&&(r._currentVelocity1=r._currentVelocity2,r._currentVelocity2=t.getFactor(),r._currentVelocityGradient=e),u*=xo.Lerp(r._currentVelocity1,r._currentVelocity2,n)})),r.direction.scaleToRef(u,s._scaledDirection),s._limitVelocityGradients&&s._limitVelocityGradients.length>0&&Xb.GetCurrentGradient(c,s._limitVelocityGradients,(function(e,t,n){e!==r._currentLimitVelocityGradient&&(r._currentLimitVelocity1=r._currentLimitVelocity2,r._currentLimitVelocity2=t.getFactor(),r._currentLimitVelocityGradient=e);var i=xo.Lerp(r._currentLimitVelocity1,r._currentLimitVelocity2,n);r.direction.length()>i&&r.direction.scaleInPlace(s.limitVelocityDamping)})),s._dragGradients&&s._dragGradients.length>0&&Xb.GetCurrentGradient(c,s._dragGradients,(function(e,t,n){e!==r._currentDragGradient&&(r._currentDrag1=r._currentDrag2,r._currentDrag2=t.getFactor(),r._currentDragGradient=e);var i=xo.Lerp(r._currentDrag1,r._currentDrag2,n);s._scaledDirection.scaleInPlace(1-i)})),s.isLocal?(r._localPosition.addInPlace(s._scaledDirection),So.TransformCoordinatesToRef(r._localPosition,s._emitterWorldMatrix,r.position)):r.position.addInPlace(s._scaledDirection),n&&t&&r._randomNoiseCoordinates1){var d=s._fetchR(r._randomNoiseCoordinates1.x,r._randomNoiseCoordinates1.y,t.width,t.height,n),h=s._fetchR(r._randomNoiseCoordinates1.z,r._randomNoiseCoordinates2.x,t.width,t.height,n),p=s._fetchR(r._randomNoiseCoordinates2.y,r._randomNoiseCoordinates2.z,t.width,t.height,n),f=Mo.Vector3[0],m=Mo.Vector3[1];f.copyFromFloats((2*d-1)*s.noiseStrength.x,(2*h-1)*s.noiseStrength.y,(2*p-1)*s.noiseStrength.z),f.scaleToRef(i,m),r.direction.addInPlace(m)}if(s.gravity.scaleToRef(i,s._scaledGravity),r.direction.addInPlace(s._scaledGravity),s._sizeGradients&&s._sizeGradients.length>0&&Xb.GetCurrentGradient(c,s._sizeGradients,(function(e,t,n){e!==r._currentSizeGradient&&(r._currentSize1=r._currentSize2,r._currentSize2=t.getFactor(),r._currentSizeGradient=e),r.size=xo.Lerp(r._currentSize1,r._currentSize2,n)})),s._useRampGradients&&(s._colorRemapGradients&&s._colorRemapGradients.length>0&&Xb.GetCurrentGradient(c,s._colorRemapGradients,(function(e,t,n){var i=xo.Lerp(e.factor1,t.factor1,n),o=xo.Lerp(e.factor2,t.factor2,n);r.remapData.x=i,r.remapData.y=o-i})),s._alphaRemapGradients&&s._alphaRemapGradients.length>0&&Xb.GetCurrentGradient(c,s._alphaRemapGradients,(function(e,t,n){var i=xo.Lerp(e.factor1,t.factor1,n),o=xo.Lerp(e.factor2,t.factor2,n);r.remapData.z=i,r.remapData.w=o-i}))),s._isAnimationSheetEnabled&&r.updateCellIndex(),r._inheritParticleInfoToSubEmitters(),r.age>=r.lifeTime)return s._emitFromParticle(r),r._attachedSubEmitters&&(r._attachedSubEmitters.forEach((function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()})),r._attachedSubEmitters=null),s.recycleParticle(r),o--,"continue"},o=0;ot.gradient?1:0}))},t.prototype._removeFactorGradient=function(e,t){if(e)for(var n=0,r=0,i=e;rt.gradient?1:0})),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture(),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,t,n){this._colorGradients||(this._colorGradients=[]);var r=new Qb;return r.gradient=e,r.color1=t,r.color2=n,this._colorGradients.push(r),this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var t=0,n=0,r=this._colorGradients;n0&&(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){this.emitter instanceof ws&&this.emitter.computeWorldMatrix(!0);var n=this.noiseTexture;if(n&&n.onGeneratedObservable)n.onGeneratedObservable.addOnce((function(){setTimeout((function(){for(var e=0;e0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped=!0,e&&this._stopSubEmitters()},t.prototype.reset=function(){this._stockParticles=[],this._particles=[]},t.prototype._appendParticleVertex=function(e,n,r,i){var o=e*this._vertexBufferSize;if(this._vertexData[o++]=n.position.x+this.worldOffset.x,this._vertexData[o++]=n.position.y+this.worldOffset.y,this._vertexData[o++]=n.position.z+this.worldOffset.z,this._vertexData[o++]=n.color.r,this._vertexData[o++]=n.color.g,this._vertexData[o++]=n.color.b,this._vertexData[o++]=n.color.a,this._vertexData[o++]=n.angle,this._vertexData[o++]=n.scale.x*n.size,this._vertexData[o++]=n.scale.y*n.size,this._isAnimationSheetEnabled&&(this._vertexData[o++]=n.cellIndex),this._isBillboardBased)this.billboardMode===t.BILLBOARDMODE_STRETCHED&&(this._vertexData[o++]=n.direction.x,this._vertexData[o++]=n.direction.y,this._vertexData[o++]=n.direction.z);else if(n._initialDirection){var a=n._initialDirection;this.isLocal&&(So.TransformNormalToRef(a,this._emitterWorldMatrix,Mo.Vector3[0]),a=Mo.Vector3[0]),0===a.x&&0===a.z&&(a.x=.001),this._vertexData[o++]=a.x,this._vertexData[o++]=a.y,this._vertexData[o++]=a.z}else{var s=n.direction;this.isLocal&&(So.TransformNormalToRef(s,this._emitterWorldMatrix,Mo.Vector3[0]),s=Mo.Vector3[0]),0===s.x&&0===s.z&&(s.x=.001),this._vertexData[o++]=s.x,this._vertexData[o++]=s.y,this._vertexData[o++]=s.z}this._useRampGradients&&(this._vertexData[o++]=n.remapData.x,this._vertexData[o++]=n.remapData.y,this._vertexData[o++]=n.remapData.z,this._vertexData[o++]=n.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),0===i?i=this._epsilon:1===i&&(i=1-this._epsilon)),this._vertexData[o++]=r,this._vertexData[o++]=i)},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);-1!==e&&this._rootParticleSystem.activeSubSystems.splice(e,1),this._rootParticleSystem=null}},t.prototype._update=function(e){var t,n=this;if(this._alive=this._particles.length>0,this.emitter.position){var r=this.emitter;this._emitterWorldMatrix=r.getWorldMatrix()}else{var i=this.emitter;this._emitterWorldMatrix=Oo.Translation(i.x,i.y,i.z)}this.updateFunction(this._particles);for(var o,a=function(){if(s._particles.length===s._capacity)return"break";if(t=s._createParticle(),s._particles.push(t),s.targetStopDuration&&s._lifeTimeGradients&&s._lifeTimeGradients.length>0){var e=xo.Clamp(s._actualFrame/s.targetStopDuration);Xb.GetCurrentGradient(e,s._lifeTimeGradients,(function(n,r){var i=n,o=r,a=i.getFactor(),s=o.getFactor(),l=(e-i.gradient)/(o.gradient-i.gradient);t.lifeTime=xo.Lerp(a,s,l)}))}else t.lifeTime=xo.RandomRange(s.minLifeTime,s.maxLifeTime);var r=xo.RandomRange(s.minEmitPower,s.maxEmitPower);if(s.startPositionFunction?s.startPositionFunction(s._emitterWorldMatrix,t.position,t,s.isLocal):s.particleEmitterType.startPositionFunction(s._emitterWorldMatrix,t.position,t,s.isLocal),s.isLocal&&(t._localPosition?t._localPosition.copyFrom(t.position):t._localPosition=t.position.clone(),So.TransformCoordinatesToRef(t._localPosition,s._emitterWorldMatrix,t.position)),s.startDirectionFunction?s.startDirectionFunction(s._emitterWorldMatrix,t.direction,t,s.isLocal):s.particleEmitterType.startDirectionFunction(s._emitterWorldMatrix,t.direction,t,s.isLocal),0===r?t._initialDirection?t._initialDirection.copyFrom(t.direction):t._initialDirection=t.direction.clone():t._initialDirection=null,t.direction.scaleInPlace(r),s._sizeGradients&&0!==s._sizeGradients.length?(t._currentSizeGradient=s._sizeGradients[0],t._currentSize1=t._currentSizeGradient.getFactor(),t.size=t._currentSize1,s._sizeGradients.length>1?t._currentSize2=s._sizeGradients[1].getFactor():t._currentSize2=t._currentSize1):t.size=xo.RandomRange(s.minSize,s.maxSize),t.scale.copyFromFloats(xo.RandomRange(s.minScaleX,s.maxScaleX),xo.RandomRange(s.minScaleY,s.maxScaleY)),s._startSizeGradients&&s._startSizeGradients[0]&&s.targetStopDuration){var i=s._actualFrame/s.targetStopDuration;Xb.GetCurrentGradient(i,s._startSizeGradients,(function(e,r,i){e!==n._currentStartSizeGradient&&(n._currentStartSize1=n._currentStartSize2,n._currentStartSize2=r.getFactor(),n._currentStartSizeGradient=e);var o=xo.Lerp(n._currentStartSize1,n._currentStartSize2,i);t.scale.scaleInPlace(o)}))}s._angularSpeedGradients&&0!==s._angularSpeedGradients.length?(t._currentAngularSpeedGradient=s._angularSpeedGradients[0],t.angularSpeed=t._currentAngularSpeedGradient.getFactor(),t._currentAngularSpeed1=t.angularSpeed,s._angularSpeedGradients.length>1?t._currentAngularSpeed2=s._angularSpeedGradients[1].getFactor():t._currentAngularSpeed2=t._currentAngularSpeed1):t.angularSpeed=xo.RandomRange(s.minAngularSpeed,s.maxAngularSpeed),t.angle=xo.RandomRange(s.minInitialRotation,s.maxInitialRotation),s._velocityGradients&&s._velocityGradients.length>0&&(t._currentVelocityGradient=s._velocityGradients[0],t._currentVelocity1=t._currentVelocityGradient.getFactor(),s._velocityGradients.length>1?t._currentVelocity2=s._velocityGradients[1].getFactor():t._currentVelocity2=t._currentVelocity1),s._limitVelocityGradients&&s._limitVelocityGradients.length>0&&(t._currentLimitVelocityGradient=s._limitVelocityGradients[0],t._currentLimitVelocity1=t._currentLimitVelocityGradient.getFactor(),s._limitVelocityGradients.length>1?t._currentLimitVelocity2=s._limitVelocityGradients[1].getFactor():t._currentLimitVelocity2=t._currentLimitVelocity1),s._dragGradients&&s._dragGradients.length>0&&(t._currentDragGradient=s._dragGradients[0],t._currentDrag1=t._currentDragGradient.getFactor(),s._dragGradients.length>1?t._currentDrag2=s._dragGradients[1].getFactor():t._currentDrag2=t._currentDrag1),s._colorGradients&&0!==s._colorGradients.length?(t._currentColorGradient=s._colorGradients[0],t._currentColorGradient.getColorToRef(t.color),t._currentColor1.copyFrom(t.color),s._colorGradients.length>1?s._colorGradients[1].getColorToRef(t._currentColor2):t._currentColor2.copyFrom(t.color)):(o=xo.RandomRange(0,1),ko.LerpToRef(s.color1,s.color2,o,t.color),s.colorDead.subtractToRef(t.color,s._colorDiff),s._colorDiff.scaleToRef(1/t.lifeTime,t.colorStep)),s._isAnimationSheetEnabled&&(t._initialStartSpriteCellID=s.startSpriteCellID,t._initialEndSpriteCellID=s.endSpriteCellID),t.direction.addInPlace(s._inheritedVelocityOffset),s._useRampGradients&&(t.remapData=new To(0,1,0,1)),s.noiseTexture&&(t._randomNoiseCoordinates1?(t._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(t._randomNoiseCoordinates1=new So(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2=new So(Math.random(),Math.random(),Math.random()))),t._inheritParticleInfoToSubEmitters()},s=this,l=0;l-1)n=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var r=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var i=this._actualFrame/this.targetStopDuration;Xb.GetCurrentGradient(i,this._emitRateGradients,(function(e,n,i){e!==t._currentEmitRateGradient&&(t._currentEmitRate1=t._currentEmitRate2,t._currentEmitRate2=n.getFactor(),t._currentEmitRateGradient=e),r=xo.Lerp(t._currentEmitRate1,t._currentEmitRate2,i)}))}n=r*this._scaledUpdateSpeed>>0,this._newPartsExcess+=r*this._scaledUpdateSpeed-n}if(this._newPartsExcess>1&&(n+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?n=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(n),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this))),!e){for(var o=0,a=0;a-1&&this._scene.particleSystems.splice(t,1),this._scene._activeParticleSystems.dispose(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.reset()},t.prototype.clone=function(e,n){var r=null,i=null;if(null!=this.customShader){var o=(i=this.customShader).shaderOptions.defines.length>0?i.shaderOptions.defines.join("\n"):"";r=this._scene.getEngine().createEffectForParticles(i.shaderPath.fragmentElement,i.shaderOptions.uniforms,i.shaderOptions.samplers,o)}else this._customEffect&&(r=this._customEffect);var a=new t(e,this._capacity,this._scene,r);(a.customShader=i,ea.DeepCopy(this,a,["particles","customShader","noiseTexture","particleTexture","onDisposeObservable"]),void 0===n&&(n=this.emitter),a.noiseTexture=this.noiseTexture,a.emitter=n,this.particleTexture)&&(this.particleTexture instanceof pd?(a.particleTexture=this.particleTexture.clone(),a.particleTexture.getContext().drawImage(this.particleTexture.getContext().canvas,0,0),a.particleTexture.update()):a.particleTexture=new Wl(this.particleTexture.url,this._scene));return this._colorGradients&&this._colorGradients.forEach((function(e){a.addColorGradient(e.gradient,e.color1,e.color2)})),this._dragGradients&&this._dragGradients.forEach((function(e){a.addDragGradient(e.gradient,e.factor1,e.factor2)})),this._angularSpeedGradients&&this._angularSpeedGradients.forEach((function(e){a.addAngularSpeedGradient(e.gradient,e.factor1,e.factor2)})),this._emitRateGradients&&this._emitRateGradients.forEach((function(e){a.addEmitRateGradient(e.gradient,e.factor1,e.factor2)})),this._lifeTimeGradients&&this._lifeTimeGradients.forEach((function(e){a.addLifeTimeGradient(e.gradient,e.factor1,e.factor2)})),this._limitVelocityGradients&&this._limitVelocityGradients.forEach((function(e){a.addLimitVelocityGradient(e.gradient,e.factor1,e.factor2)})),this._sizeGradients&&this._sizeGradients.forEach((function(e){a.addSizeGradient(e.gradient,e.factor1,e.factor2)})),this._startSizeGradients&&this._startSizeGradients.forEach((function(e){a.addStartSizeGradient(e.gradient,e.factor1,e.factor2)})),this._velocityGradients&&this._velocityGradients.forEach((function(e){a.addVelocityGradient(e.gradient,e.factor1,e.factor2)})),this._rampGradients&&this._rampGradients.forEach((function(e){a.addRampGradient(e.gradient,e.color)})),this._colorRemapGradients&&this._colorRemapGradients.forEach((function(e){a.addColorRemapGradient(e.gradient,e.factor1,e.factor2)})),this._alphaRemapGradients&&this._alphaRemapGradients.forEach((function(e){a.addAlphaRemapGradient(e.gradient,e.factor1,e.factor2)})),this.preventAutoStart||a.start(),a},t.prototype.serialize=function(){var e={};if(t._Serialize(e,this),e.textureMask=this.textureMask.asArray(),e.customShader=this.customShader,e.preventAutoStart=this.preventAutoStart,this.subEmitters){e.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var n=0,r=this._subEmitters;n0?s.shaderOptions.defines.join("\n"):"";a=n.getEngine().createEffectForParticles(s.shaderPath.fragmentElement,s.shaderOptions.uniforms,s.shaderOptions.samplers,l)}var c=new t(o,e.capacity,n,a,e.isAnimationSheetEnabled);if(c.customShader=s,e.id&&(c.id=e.id),e.subEmitters){c.subEmitters=[];for(var u=0,d=e.subEmitters;u1},enumerable:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLocal",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0}),t.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&this._imageProcessingConfiguration.isReady()&&this._renderEffect.isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.start=function(e){var t=this;if(void 0===e&&(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(){t.start(0)}),e):(this._started=!0,this._stopped=!1,this._preWarmDone=!1,this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){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._removeGradientAndTexture=function(t,n,r){return e.prototype._removeGradientAndTexture.call(this,t,n,r),this._releaseBuffers(),this},t.prototype.addColorGradient=function(e,t,n){this._colorGradients||(this._colorGradients=[]);var r=new Qb;return r.gradient=e,r.color1=t,this._colorGradients.push(r),this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype._addFactorGradient=function(e,t,n){var r=new Kb;r.gradient=t,r.factor1=n,e.push(r),e.sort((function(e,t){return e.gradientt.gradient?1:0})),this._releaseBuffers()},t.prototype.addSizeGradient=function(e,t){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},t.prototype.addAngularSpeedGradient=function(e,t){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),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,t){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),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,t){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),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,t){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),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,t,n){return this},t.prototype.removeEmitRateGradient=function(e){return this},t.prototype.addStartSizeGradient=function(e,t,n){return this},t.prototype.removeStartSizeGradient=function(e){return this},t.prototype.addColorRemapGradient=function(e,t,n){return this},t.prototype.removeColorRemapGradient=function(){return this},t.prototype.addAlphaRemapGradient=function(e,t,n){return this},t.prototype.removeAlphaRemapGradient=function(){return this},t.prototype.addRampGradient=function(e,t){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:!0,configurable:!0}),t.prototype.addLifeTimeGradient=function(e,t,n){return this},t.prototype.removeLifeTimeGradient=function(e){return this},t.prototype._reset=function(){this._releaseBuffers()},t.prototype._createUpdateVAO=function(e){var t={};t.position=e.createVertexBuffer("position",0,3);var n=3;this.particleEmitterType instanceof Gb&&(t.initialPosition=e.createVertexBuffer("initialPosition",n,3),n+=3),t.age=e.createVertexBuffer("age",n,1),n+=1,t.life=e.createVertexBuffer("life",n,1),n+=1,t.seed=e.createVertexBuffer("seed",n,4),n+=4,t.size=e.createVertexBuffer("size",n,3),n+=3,this._colorGradientsTexture||(t.color=e.createVertexBuffer("color",n,4),n+=4),t.direction=e.createVertexBuffer("direction",n,3),n+=3,this._isBillboardBased||(t.initialDirection=e.createVertexBuffer("initialDirection",n,3),n+=3),this._angularSpeedGradientsTexture?(t.angle=e.createVertexBuffer("angle",n,1),n+=1):(t.angle=e.createVertexBuffer("angle",n,2),n+=2),this._isAnimationSheetEnabled&&(t.cellIndex=e.createVertexBuffer("cellIndex",n,1),n+=1,this.spriteRandomStartCell&&(t.cellStartOffset=e.createVertexBuffer("cellStartOffset",n,1),n+=1)),this.noiseTexture&&(t.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",n,3),n+=3,t.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",n,3),n+=3);var r=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),r},t.prototype._createRenderVAO=function(e,t){var n={};n.position=e.createVertexBuffer("position",0,3,this._attributesStrideSize,!0);var r=3;this.particleEmitterType instanceof Gb&&(r+=3),n.age=e.createVertexBuffer("age",r,1,this._attributesStrideSize,!0),r+=1,n.life=e.createVertexBuffer("life",r,1,this._attributesStrideSize,!0),r+=5,n.size=e.createVertexBuffer("size",r,3,this._attributesStrideSize,!0),r+=3,this._colorGradientsTexture||(n.color=e.createVertexBuffer("color",r,4,this._attributesStrideSize,!0),r+=4),this.billboardMode===$b.BILLBOARDMODE_STRETCHED&&(n.direction=e.createVertexBuffer("direction",r,3,this._attributesStrideSize,!0)),r+=3,this._isBillboardBased||(n.initialDirection=e.createVertexBuffer("initialDirection",r,3,this._attributesStrideSize,!0),r+=3),n.angle=e.createVertexBuffer("angle",r,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?r++:r+=2,this._isAnimationSheetEnabled&&(n.cellIndex=e.createVertexBuffer("cellIndex",r,1,this._attributesStrideSize,!0),r+=1,this.spriteRandomStartCell&&(n.cellStartOffset=e.createVertexBuffer("cellStartOffset",r,1,this._attributesStrideSize,!0),r+=1)),this.noiseTexture&&(n.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",r,3,this._attributesStrideSize,!0),r+=3,n.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",r,3,this._attributesStrideSize,!0),r+=3),n.offset=t.createVertexBuffer("offset",0,2),n.uv=t.createVertexBuffer("uv",2,2);var i=this._engine.recordVertexArrayObject(n,null,this._renderEffect);return this._engine.bindArrayBuffer(null),i},t.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._scene.getEngine(),n=new Array;this._attributesStrideSize=21,this._targetIndex=0,this.particleEmitterType instanceof Gb&&(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 r=this.particleEmitterType instanceof Gb,i=Mo.Vector3[0],o=0;o=this.targetStopDuration&&this.stop()},t.prototype._createFactorGradientTexture=function(e,t){var n=this[t];if(e&&e.length&&!n){for(var r=new Float32Array(this._rawTextureWidth),i=0;i1){var n=0|this._accumulatedCount;this._accumulatedCount-=n,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+n)}if(!this._currentActiveCount)return 0;var r;if(this._engine.enableEffect(this._updateEffect),this._engine.setState(!1),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){r=this.emitter.getWorldMatrix()}else{var i=this.emitter;r=Oo.Translation(i.x,i.y,i.z)}if(this._updateEffect.setMatrix("emitterWM",r),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),this._engine.setRasterizerState(!1),this._engine.beginTransformFeedback(!0),this._engine.drawArraysType(Ls.PointListDrawMode,0,this._currentActiveCount),this._engine.endTransformFeedback(),this._engine.setRasterizerState(!0),this._engine.bindTransformFeedbackBuffer(null),!e){this._engine.enableEffect(this._renderEffect);var o=this._scene.getViewMatrix();if(this._renderEffect.setMatrix("view",o),this._renderEffect.setMatrix("projection",this._scene.getProjectionMatrix()),this._renderEffect.setTexture("textureSampler",this.particleTexture),this._renderEffect.setVector2("translationPivot",this.translationPivot),this._renderEffect.setVector3("worldOffset",this.worldOffset),this._colorGradientsTexture?this._renderEffect.setTexture("colorGradientSampler",this._colorGradientsTexture):this._renderEffect.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var a=this.particleTexture.getBaseSize();this._renderEffect.setFloat3("sheetInfos",this.spriteCellWidth/a.width,this.spriteCellHeight/a.height,a.width/this.spriteCellWidth)}if(this._isBillboardBased){var s=this._scene.activeCamera;this._renderEffect.setVector3("eyePosition",s.globalPosition)}if(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4||this._scene.clipPlane5||this._scene.clipPlane6){var l=o.clone();l.invert(),this._renderEffect.setMatrix("invView",l),Cu.BindClipPlane(this._renderEffect,this._scene)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._renderEffect),this.blendMode){case $b.BLENDMODE_ADD:this._engine.setAlphaMode(1);break;case $b.BLENDMODE_ONEONE:this._engine.setAlphaMode(6);break;case $b.BLENDMODE_STANDARD:this._engine.setAlphaMode(2);break;case $b.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(4)}this.forceDepthWrite&&this._engine.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._engine.drawArraysType(Ls.TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(0)}this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var c=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=c,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-1&&this._scene.particleSystems.splice(t,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.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,n){var r=new t(e,{capacity:this._capacity,randomTextureSize:this._randomTextureSize},this._scene);return ea.DeepCopy(this,r,["particles","customShader","noiseTexture","particleTexture","onDisposeObservable"]),void 0===n&&(n=this.emitter),r.emitter=n,this.particleTexture&&(r.particleTexture=new Wl(this.particleTexture.url,this._scene)),r.noiseTexture=this.noiseTexture,this._colorGradients&&this._colorGradients.forEach((function(e){r.addColorGradient(e.gradient,e.color1,e.color2)})),this._dragGradients&&this._dragGradients.forEach((function(e){r.addDragGradient(e.gradient,e.factor1)})),this._angularSpeedGradients&&this._angularSpeedGradients.forEach((function(e){r.addAngularSpeedGradient(e.gradient,e.factor1)})),this._emitRateGradients&&this._emitRateGradients.forEach((function(e){r.addEmitRateGradient(e.gradient,e.factor1,e.factor2)})),this._lifeTimeGradients&&this._lifeTimeGradients.forEach((function(e){r.addLifeTimeGradient(e.gradient,e.factor1,e.factor2)})),this._limitVelocityGradients&&this._limitVelocityGradients.forEach((function(e){r.addLimitVelocityGradient(e.gradient,e.factor1)})),this._sizeGradients&&this._sizeGradients.forEach((function(e){r.addSizeGradient(e.gradient,e.factor1)})),this._startSizeGradients&&this._startSizeGradients.forEach((function(e){r.addStartSizeGradient(e.gradient,e.factor1,e.factor2)})),this._velocityGradients&&this._velocityGradients.forEach((function(e){r.addVelocityGradient(e.gradient,e.factor1)})),this._rampGradients&&this._rampGradients.forEach((function(e){r.addRampGradient(e.gradient,e.color)})),this._colorRemapGradients&&this._colorRemapGradients.forEach((function(e){r.addColorRemapGradient(e.gradient,e.factor1,e.factor2)})),this._alphaRemapGradients&&this._alphaRemapGradients.forEach((function(e){r.addAlphaRemapGradient(e.gradient,e.factor1,e.factor2)})),r},t.prototype.serialize=function(){var e={};return $b._Serialize(e,this),e.activeParticleCount=this.activeParticleCount,e},t.Parse=function(e,n,r,i){void 0===i&&(i=!1);var o=new t(e.name,{capacity:e.capacity,randomTextureSize:e.randomTextureSize},n);return e.activeParticleCount&&(o.activeParticleCount=e.activeParticleCount),$b._Parse(e,o,n,r),e.preventAutoStart&&(o.preventAutoStart=e.preventAutoStart),i||o.preventAutoStart||o.start(),o},t}(Hb),av=function(){function e(){this.systems=new Array}return Object.defineProperty(e.prototype,"emitterNode",{get:function(){return this._emitterNode},enumerable:!0,configurable:!0}),e.prototype.setEmitterAsSphere=function(e,t,n){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:"Sphere",options:e,renderingGroupId:t};var r=zd.CreateSphere("emitterSphere",{diameter:e.diameter,segments:e.segments},n);r.renderingGroupId=t;var i=new hd("emitterSphereMaterial",n);i.emissiveColor=e.color,r.material=i;for(var o=0,a=this.systems;o0&&n.set(this._uvs32,cs.UVKind),this._colors32.length>0&&n.set(this._colors32,cs.ColorKind),n.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,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},e.prototype.digest=function(e,t){var n=t&&t.facetNb||1,r=t&&t.number||0,i=t&&t.delta||0,o=e.getVerticesData(cs.PositionKind),a=e.getIndices(),s=e.getVerticesData(cs.UVKind),l=e.getVerticesData(cs.ColorKind),c=e.getVerticesData(cs.NormalKind),u=t&&t.storage?t.storage:null,d=0,h=a.length/3;r?(r=r>h?h:r,n=Math.round(h/r),i=0):n=n>h?h:n;for(var p=[],f=[],m=[],g=[],b=[],v=So.Zero(),A=n;dh-(n=A+Math.floor((1+i)*Math.random()))&&(n=h-d),p.length=0,f.length=0,m.length=0,g.length=0,b.length=0;for(var _=0,y=3*d;y<3*(d+n);y++){m.push(_);var x=a[y],w=3*x;if(p.push(o[w],o[w+1],o[w+2]),f.push(c[w],c[w+1],c[w+2]),s){var E=2*x;g.push(s[E],s[E+1])}if(l){var C=4*x;b.push(l[C],l[C+1],l[C+2],l[C+3])}_++}var S,T=this.nbParticles,P=this._posToShape(p),O=this._uvsToShapeUV(g),R=Array.from(m),M=Array.from(b),I=Array.from(f);for(v.copyFromFloats(0,0,0),S=0;S65535&&(this._needs32Bits=!0)}if(this._pickable){var D=i.length/3;for(g=0;g=this.nbParticles||!this._updatable)return[];var r=this.particles,i=this.nbParticles;if(t=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var O=this.mesh._boundingInfo;O&&(b.copyFrom(O.minimum),v.copyFrom(O.maximum))}var R=(w=this.particles[e]._pos)/3|0;C=4*R,T=2*R;for(var M=e;M<=t;M++){var I=this.particles[M];this.updateParticle(I);var k=I._model._shape,D=I._model._shapeUV,B=I._rotationMatrix,F=I.position,N=I.rotation,L=I.scaling,U=I._globalPosition;if(this._depthSort&&this._depthSortParticles){var V=this.depthSortedParticles[M];V.ind=I._ind,V.indicesLength=I._model._indicesLength,V.sqDistance=So.DistanceSquared(I.position,A)}if(!I.alive||I._stillInvisible&&!I.isVisible)w+=3*(P=k.length),C+=4*P,T+=2*P;else{if(I.isVisible){I._stillInvisible=!1;var z=p[12];if(I.pivot.multiplyToRef(L,z),this.billboard&&(N.x=0,N.y=0),(this._computeParticleRotation||this.billboard)&&I.getRotationMatrix(r),null!==I.parentId){var j=this.getParticleById(I.parentId);if(j){var G=j._rotationMatrix,H=j._globalPosition,Q=F.x*G[1]+F.y*G[4]+F.z*G[7],W=F.x*G[0]+F.y*G[3]+F.z*G[6],K=F.x*G[2]+F.y*G[5]+F.z*G[8];if(U.x=H.x+W,U.y=H.y+Q,U.z=H.z+K,this._computeParticleRotation||this.billboard){var X=r.m;B[0]=X[0]*G[0]+X[1]*G[3]+X[2]*G[6],B[1]=X[0]*G[1]+X[1]*G[4]+X[2]*G[7],B[2]=X[0]*G[2]+X[1]*G[5]+X[2]*G[8],B[3]=X[4]*G[0]+X[5]*G[3]+X[6]*G[6],B[4]=X[4]*G[1]+X[5]*G[4]+X[6]*G[7],B[5]=X[4]*G[2]+X[5]*G[5]+X[6]*G[8],B[6]=X[8]*G[0]+X[9]*G[3]+X[10]*G[6],B[7]=X[8]*G[1]+X[9]*G[4]+X[10]*G[7],B[8]=X[8]*G[2]+X[9]*G[5]+X[10]*G[8]}}else I.parentId=null}else if(U.x=F.x,U.y=F.y,U.z=F.z,this._computeParticleRotation||this.billboard){X=r.m;B[0]=X[0],B[1]=X[1],B[2]=X[2],B[3]=X[4],B[4]=X[5],B[5]=X[6],B[6]=X[8],B[7]=X[9],B[8]=X[10]}var Y=p[11];for(I.translateFromPivot?Y.setAll(0):Y.copyFrom(z),P=0;P0)for(var t=0;t0&&e.set(this._uvs32,cs.UVKind);var t=0;this._colors32.length>0&&(t=1,e.set(this._colors32,cs.ColorKind));var n=new Pl(this.name,this._scene);e.applyToMesh(n,this._updatable),this.mesh=n,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);var r=new hd("point cloud material",this._scene);return r.emissiveColor=new Io(t,t,t),r.disableLighting=!0,r.pointsCloud=!0,r.pointSize=this._size,n.material=r,new Promise((function(e){return e(n)}))},e.prototype._addParticle=function(e,t,n,r){var i=new dv(e,t,n,r,this);return this.particles.push(i),i},e.prototype._randomUnitVector=function(e){e.position=new So(Math.random(),Math.random(),Math.random()),e.color=new ko(1,1,1,1)},e.prototype._getColorIndicesForCoord=function(e,t,n,r){var i=e._groupImageData,o=n*(4*r)+4*t,a=[o,o+1,o+2,o+3],s=a[1],l=a[2],c=a[3],u=i[a[0]],d=i[s],h=i[l],p=i[c];return new ko(u/255,d/255,h/255,p)},e.prototype._setPointsColorOrUV=function(e,t,n,r,i,o,a){n&&e.updateFacetData();var s=2*e.getBoundingInfo().boundingSphere.radius,l=e.getVerticesData(cs.PositionKind),c=e.getIndices(),u=e.getVerticesData(cs.UVKind),d=e.getVerticesData(cs.ColorKind),h=So.Zero();e.computeWorldMatrix();var p=e.getWorldMatrix();if(!p.isIdentity())for(var f=0;f1&&(Pe=1),(Oe=Re.b+Se)<0&&(Oe=0),Oe>1&&(Oe=1),Io.HSVtoRGBToRef(Te,Pe,Oe,De),pe.set(De.r,De.g,De.b,1)):pe=oe.set(Math.random(),Math.random(),Math.random(),1),Ie.color=new ko(pe.x,pe.y,pe.z,pe.w),this._colors.push(pe.x,pe.y,pe.z,pe.w))}},e.prototype._colorFromTexture=function(e,t,n){var r=this;if(null===e.material)return jo.a.Warn(e.name+"has no material."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,n,!0,!1);var i=e.material.getActiveTextures();if(0===i.length)return jo.a.Warn(e.name+"has no useable texture."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,n,!0,!1);var o=e.clone();o.setEnabled(!1),this._promises.push(new Promise((function(e){Ql.WhenAllReady(i,(function(){var a=t._textureNb;return a<0&&(a=0),a>i.length-1&&(a=i.length-1),t._groupImageData=i[a].readPixels(),t._groupImgWidth=i[a].getSize().width,t._groupImgHeight=i[a].getSize().height,r._setPointsColorOrUV(o,t,n,!0,!0),o.dispose(),e()}))})))},e.prototype._calculateDensity=function(e,t,n){for(var r,i,o,a,s,l,c,u,d,h,p,f,m,g,b,v,A,_=new Array,y=So.Zero(),x=So.Zero(),w=So.Zero(),E=So.Zero(),C=So.Zero(),S=So.Zero(),T=new Array,P=0,O=n.length/3,R=0;R0&&(_=_.map((function(e){return e+k})));for(R=0;R3)&&(o=sv.Random);var a=e.getVerticesData(cs.PositionKind),s=e.getIndices();this._groups.push(this._groupCounter);var l=new hv(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,s),o===sv.Color?l._textureNb=r||0:r=r||new ko(1,1,1,1),o){case sv.Color:this._colorFromTexture(e,l,!1);break;case sv.UV:this._setPointsColorOrUV(e,l,!1,!1,!1);break;case sv.Random:this._setPointsColorOrUV(e,l,!1);break;case sv.Stated:this._setPointsColorOrUV(e,l,!1,void 0,void 0,r,i)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.addVolumePoints=function(e,t,n,r,i){var o=n||sv.Random;(isNaN(o)||o<0||o>3)&&(o=sv.Random);var a=e.getVerticesData(cs.PositionKind),s=e.getIndices();this._groups.push(this._groupCounter);var l=new hv(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,s),o===sv.Color?l._textureNb=r||0:r=r||new ko(1,1,1,1),o){case sv.Color:this._colorFromTexture(e,l,!0);break;case sv.UV:this._setPointsColorOrUV(e,l,!0,!1,!1);break;case sv.Random:this._setPointsColorOrUV(e,l,!0);break;case sv.Stated:this._setPointsColorOrUV(e,l,!0,void 0,void 0,r,i)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.setParticles=function(e,t,n){if(void 0===e&&(e=0),void 0===t&&(t=this.nbParticles-1),void 0===n&&(n=!0),!this._updatable||!this._isReady)return this;this.beforeUpdateParticles(e,t,n);var r=Mo.Matrix[0],i=this.mesh,o=this._colors32,a=this._positions32,s=this._uvs32,l=Mo.Vector3,c=l[5].copyFromFloats(1,0,0),u=l[6].copyFromFloats(0,1,0),d=l[7].copyFromFloats(0,0,1),h=l[8].setAll(Number.MAX_VALUE),p=l[9].setAll(-Number.MAX_VALUE);Oo.IdentityToRef(r);var f=0;if(this.mesh.isFacetDataEnabled&&(this._computeBoundingBox=!0),t=t>=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var m=this.mesh._boundingInfo;m&&(h.copyFrom(m.minimum),p.copyFrom(m.maximum))}f=0;for(var g=0,b=0,v=0,A=e;A<=t;A++){var _=this.particles[A];g=3*(f=_.idx),b=4*f,v=2*f,this.updateParticle(_);var y=_._rotationMatrix,x=_.position,w=_._globalPosition;if(this._computeParticleRotation&&_.getRotationMatrix(r),null!==_.parentId){var E=this.particles[_.parentId],C=E._rotationMatrix,S=E._globalPosition,T=x.x*C[1]+x.y*C[4]+x.z*C[7],P=x.x*C[0]+x.y*C[3]+x.z*C[6],O=x.x*C[2]+x.y*C[5]+x.z*C[8];if(w.x=S.x+P,w.y=S.y+T,w.z=S.z+O,this._computeParticleRotation){var R=r.m;y[0]=R[0]*C[0]+R[1]*C[3]+R[2]*C[6],y[1]=R[0]*C[1]+R[1]*C[4]+R[2]*C[7],y[2]=R[0]*C[2]+R[1]*C[5]+R[2]*C[8],y[3]=R[4]*C[0]+R[5]*C[3]+R[6]*C[6],y[4]=R[4]*C[1]+R[5]*C[4]+R[6]*C[7],y[5]=R[4]*C[2]+R[5]*C[5]+R[6]*C[8],y[6]=R[8]*C[0]+R[9]*C[3]+R[10]*C[6],y[7]=R[8]*C[1]+R[9]*C[4]+R[10]*C[7],y[8]=R[8]*C[2]+R[9]*C[5]+R[10]*C[8]}}else if(w.x=0,w.y=0,w.z=0,this._computeParticleRotation){R=r.m;y[0]=R[0],y[1]=R[1],y[2]=R[2],y[3]=R[4],y[4]=R[5],y[5]=R[6],y[6]=R[8],y[7]=R[9],y[8]=R[10]}var M=l[11];_.translateFromPivot?M.setAll(0):M.copyFrom(_.pivot);var I=l[0];I.copyFrom(_.position);var k=I.x-_.pivot.x,D=I.y-_.pivot.y,B=I.z-_.pivot.z,F=k*y[0]+D*y[3]+B*y[6],N=k*y[1]+D*y[4]+B*y[7],L=k*y[2]+D*y[5]+B*y[8];F+=M.x,N+=M.y,L+=M.z;var U=a[g]=w.x+c.x*F+u.x*N+d.x*L,V=a[g+1]=w.y+c.y*F+u.y*N+d.y*L,z=a[g+2]=w.z+c.z*F+u.z*N+d.z*L;if(this._computeBoundingBox&&(h.minimizeInPlaceFromFloats(U,V,z),p.maximizeInPlaceFromFloats(U,V,z)),this._computeParticleColor&&_.color){var j=_.color,G=this._colors32;G[b]=j.r,G[b+1]=j.g,G[b+2]=j.b,G[b+3]=j.a}if(this._computeParticleTexture&&_.uv){var H=_.uv,Q=this._uvs32;Q[v]=H.x,Q[v+1]=H.y}}return n&&(this._computeParticleColor&&i.updateVerticesData(cs.ColorKind,o,!1,!1),this._computeParticleTexture&&i.updateVerticesData(cs.UVKind,s,!1,!1),i.updateVerticesData(cs.PositionKind,a,!1,!1)),this._computeBoundingBox&&(i._boundingInfo?i._boundingInfo.reConstruct(h,p,i._worldMatrix):i._boundingInfo=new vs(h,p,i._worldMatrix)),this.afterUpdateParticles(e,t,n),this},e.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},e.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},e.prototype.setVisibilityBox=function(e){var t=e/2;this.mesh._boundingInfo=new vs(new So(-t,-t,-t),new So(t,t,t))},Object.defineProperty(e.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleRotation",{set:function(e){this._computeParticleRotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!0,configurable:!0}),e.prototype.initParticles=function(){},e.prototype.recycleParticle=function(e){return e},e.prototype.updateParticle=function(e){return e},e.prototype.beforeUpdateParticles=function(e,t,n){},e.prototype.afterUpdateParticles=function(e,t,n){}}();nl.prototype.getPhysicsEngine=function(){return this._physicsEngine},nl.prototype.enablePhysics=function(e,t){if(void 0===e&&(e=null),this._physicsEngine)return!0;var n=this._getComponent(Gs.NAME_PHYSICSENGINE);n||(n=new mv(this),this._addComponent(n));try{return this._physicsEngine=new tm(e,t),this._physicsTimeAccumulator=0,!0}catch(e){return jo.a.Error(e.message),!1}},nl.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},nl.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},nl.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},nl.prototype._advancePhysicsEngineStep=function(e){if(this._physicsEngine){var t=this._physicsEngine.getSubTimeStep();if(t>0)for(this._physicsTimeAccumulator+=e;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(e/1e3),this.onAfterPhysicsObservable.notifyObservers(this)}},Object.defineProperty(ws.prototype,"physicsImpostor",{get:function(){return this._physicsImpostor},set:function(e){var t=this;this._physicsImpostor!==e&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),this._physicsImpostor=e,e&&(this._disposePhysicsObserver=this.onDisposeObservable.add((function(){t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)}))))},enumerable:!0,configurable:!0}),ws.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},ws.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},ws.prototype.setPhysicsLinkWith=function(e,t,n,r){return this.physicsImpostor&&e.physicsImpostor?(this.physicsImpostor.createJoint(e.physicsImpostor,jd.HingeJoint,{mainPivot:t,connectedPivot:n,nativeParams:r}),this):this};var pv,fv,mv=function(){function e(e){var t=this;this.name=Gs.NAME_PHYSICSENGINE,this.scene=e,this.scene.onBeforePhysicsObservable=new yo.a,this.scene.onAfterPhysicsObservable=new yo.a,this.scene.getDeterministicFrameTime=function(){return t.scene._physicsEngine?1e3*t.scene._physicsEngine.getTimeStep():1e3/60}}return e.prototype.register=function(){},e.prototype.rebuild=function(){},e.prototype.dispose=function(){this.scene.onBeforePhysicsObservable.clear(),this.scene.onAfterPhysicsObservable.clear(),this.scene._physicsEngine&&this.scene.disablePhysicsEngine()},e}(),gv=(function(){function e(e){this._scene=e,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||jo.a.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}e.prototype.applyRadialExplosionImpulse=function(e,t,n,r){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;var i=this._physicsEngine.getImpostors();if(0===i.length)return null;"number"==typeof t&&((t=new _v).radius=t,t.strength=n||t.strength,t.falloff=r||t.falloff);var o=new gv(this._scene,t),a=Array();return i.forEach((function(t){var n=o.getImpostorHitData(t,e);n&&(t.applyImpulse(n.force,n.contactPoint),a.push({impostor:t,hitData:n}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.applyRadialExplosionForce=function(e,t,n,r){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;var i=this._physicsEngine.getImpostors();if(0===i.length)return null;"number"==typeof t&&((t=new _v).radius=t,t.strength=n||t.strength,t.falloff=r||t.falloff);var o=new gv(this._scene,t),a=Array();return i.forEach((function(t){var n=o.getImpostorHitData(t,e);n&&(t.applyForce(n.force,n.contactPoint),a.push({impostor:t,hitData:n}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.gravitationalField=function(e,t,n,r){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;"number"==typeof t&&((t=new _v).radius=t,t.strength=n||t.strength,t.falloff=r||t.falloff);var i=new bv(this,this._scene,e,t);return i.dispose(!1),i},e.prototype.updraft=function(e,t,n,r,i){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;"number"==typeof t&&((t=new yv).radius=t,t.strength=n||t.strength,t.height=r||t.height,t.updraftMode=i||t.updraftMode);var o=new vv(this._scene,e,t);return o.dispose(!1),o},e.prototype.vortex=function(e,t,n,r){if(!this._physicsEngine)return jo.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;"number"==typeof t&&((t=new xv).radius=t,t.strength=n||t.strength,t.height=r||t.height);var i=new Av(this._scene,e,t);return i.dispose(!1),i}}(),function(){function e(e,t){this._scene=e,this._options=t,this._dataFetched=!1,this._options=Object(No.a)(Object(No.a)({},new _v),this._options)}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.getImpostorHitData=function(e,t){if(0===e.mass)return null;if(!this._intersectsWithSphere(e,t,this._options.radius))return null;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return null;var n=e.getObjectCenter().subtract(t),r=new Vl(t,n,this._options.radius).intersectsMesh(e.object).pickedPoint;if(!r)return null;var i=So.Distance(t,r);if(i>this._options.radius)return null;var o=this._options.falloff===pv.Constant?this._options.strength:this._options.strength*(1-i/this._options.radius);return{force:n.multiplyByFloats(o,o,o),contactPoint:r,distanceFromOrigin:i}},e.prototype.triggerAffectedImpostorsCallback=function(e){this._options.affectedImpostorsCallback&&this._options.affectedImpostorsCallback(e)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout((function(){t._dataFetched||t._sphere.dispose()}),0)},e.prototype._prepareSphere=function(){this._sphere||(this._sphere=zd.CreateSphere("radialExplosionEventSphere",this._options.sphere,this._scene),this._sphere.isVisible=!1)},e.prototype._intersectsWithSphere=function(e,t,n){var r=e.object;return this._prepareSphere(),this._sphere.position=t,this._sphere.scaling=new So(2*n,2*n,2*n),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(r,!0)},e}()),bv=function(){function e(e,t,n,r){this._physicsHelper=e,this._scene=t,this._origin=n,this._options=r,this._dataFetched=!1,this._options=Object(No.a)(Object(No.a)({},new _v),this._options),this._tickCallback=this._tick.bind(this),this._options.strength=-1*this._options.strength}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout((function(){t._dataFetched||t._sphere.dispose()}),0)},e.prototype._tick=function(){if(this._sphere)this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);else{var e=this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);e&&(this._sphere=e.getData().sphere.clone("radialExplosionEventSphereClone"))}},e}(),vv=function(){function e(e,t,n){this._scene=e,this._origin=t,this._options=n,this._originTop=So.Zero(),this._originDirection=So.Zero(),this._cylinderPosition=So.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(No.a)(Object(No.a)({},new yv),this._options),this._origin.addToRef(new So(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new So(0,this._options.height,0),this._originTop),this._options.updraftMode===fv.Perpendicular&&(this._originDirection=this._origin.subtract(this._originTop).normalize()),this._tickCallback=this._tick.bind(this),this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),this._cylinder&&(e?this._cylinder.dispose():setTimeout((function(){t._dataFetched||t._cylinder.dispose()}),0))},e.prototype.getImpostorHitData=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;var t=e.getObjectCenter();if(this._options.updraftMode===fv.Perpendicular)var n=this._originDirection;else n=t.subtract(this._originTop);var r=So.Distance(this._origin,t),i=-1*this._options.strength;return{force:n.multiplyByFloats(i,i,i),contactPoint:t,distanceFromOrigin:r}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var n=e.getImpostorHitData(t);n&&t.applyForce(n.force,n.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=_d.CreateCylinder("updraftEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}(),Av=function(){function e(e,t,n){this._scene=e,this._origin=t,this._options=n,this._originTop=So.Zero(),this._cylinderPosition=So.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(No.a)(Object(No.a)({},new xv),this._options),this._origin.addToRef(new So(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new So(0,this._options.height,0),this._originTop),this._tickCallback=this._tick.bind(this),this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._cylinder.dispose():setTimeout((function(){t._dataFetched||t._cylinder.dispose()}),0)},e.prototype.getImpostorHitData=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return null;var t=e.getObjectCenter(),n=new So(this._origin.x,t.y,this._origin.z),r=t.subtract(n),i=new Vl(n,r,this._options.radius).intersectsMesh(e.object),o=i.pickedPoint;if(!o)return null;var a=i.distance/this._options.radius,s=o.normalize();if(a>this._options.centripetalForceThreshold&&(s=s.negate()),a>this._options.centripetalForceThreshold)var l=s.x*this._options.centripetalForceMultiplier,c=s.y*this._options.updraftForceMultiplier,u=s.z*this._options.centripetalForceMultiplier;else{var d=So.Cross(n,t).normalize();l=(d.x+s.x)*this._options.centrifugalForceMultiplier,c=this._originTop.y*this._options.updraftForceMultiplier,u=(d.z+s.z)*this._options.centrifugalForceMultiplier}var h=new So(l,c,u);return{force:h=h.multiplyByFloats(this._options.strength,this._options.strength,this._options.strength),contactPoint:t,distanceFromOrigin:a}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var n=e.getImpostorHitData(t);n&&t.applyForce(n.force,n.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=_d.CreateCylinder("vortexEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}(),_v=function(){this.radius=5,this.strength=10,this.falloff=pv.Constant,this.sphere={segments:32,diameter:1}},yv=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=fv.Center},xv=function(){this.radius=5,this.strength=10,this.height=10,this.centripetalForceThreshold=.7,this.centripetalForceMultiplier=5,this.centrifugalForceMultiplier=.5,this.updraftForceMultiplier=.02};!function(e){e[e.Constant=0]="Constant",e[e.Linear=1]="Linear"}(pv||(pv={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(fv||(fv={}));var wv="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\nvoid main(void)\n{\nvec3 color=texture2D(textureSampler,vUV).rgb;\nfloat luminance=dot(color,vec3(0.3,0.59,0.11));\nvec3 blackAndWhite=vec3(luminance,luminance,luminance);\ngl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);\n}";Qc.a.ShadersStore.blackAndWhitePixelShader=wv;!function(e){function t(t,n,r,i,o,a){var s=e.call(this,t,"blackAndWhite",["degree"],null,n,r,i,o,a)||this;return s.degree=1,s.onApplyObservable.add((function(e){e.setFloat("degree",s.degree)})),s}Object(No.d)(t,e)}(Xc);var Ev=function(){function e(e,t,n,r){this._name=t,this._singleInstance=r||!0,this._getPostProcesses=n,this._cameras={},this._indicesForCamera={},this._postProcesses={}}return Object.defineProperty(e.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(this._postProcesses.hasOwnProperty(e))for(var t=this._postProcesses[e],n=0;n-1?"#define MALI 1\n":null},t}(Xc),Wv="#include\n\nuniform sampler2D textureSampler;\n\nuniform float intensity;\nuniform float animatedSeed;\n\nvarying vec2 vUV;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec2 seed=vUV*(animatedSeed);\nfloat grain=dither(seed,intensity);\n\nfloat lum=getLuminance(gl_FragColor.rgb);\nfloat grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;\ngl_FragColor.rgb+=grain*grainAmount;\ngl_FragColor.rgb=max(gl_FragColor.rgb,0.0);\n}";Qc.a.ShadersStore.grainPixelShader=Wv;var Kv=function(e){function t(t,n,r,i,o,a,s,l){void 0===s&&(s=0),void 0===l&&(l=!1);var c=e.call(this,t,"grain",["intensity","animatedSeed"],[],n,r,i,o,a,null,s,void 0,null,l)||this;return c.intensity=30,c.animated=!1,c.onApplyObservable.add((function(e){e.setFloat("intensity",c.intensity),e.setFloat("animatedSeed",c.animated?Math.random()+1:1)})),c}return Object(No.d)(t,e),t}(Xc),Xv="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvoid main(void)\n{\nvec4 tex=texture2D(textureSampler,vUV);\nvec3 c=tex.rgb;\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\n\n\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a);\n}";Qc.a.ShadersStore.highlightsPixelShader=Xv;!function(e){function t(t,n,r,i,o,a,s){return void 0===s&&(s=0),e.call(this,t,"highlights",null,null,n,r,i,o,a,null,s)||this}Object(No.d)(t,e)}(Xc);Qc.a.IncludesShadersStore.mrtFragmentDeclaration="#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";var Yv="#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\nprecision highp int;\n#ifdef BUMP\nvarying mat4 vWorldView;\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef REFLECTIVITY\nvarying vec2 vReflectivityUV;\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef ALPHATEST\nuniform sampler2D diffuseSampler;\n#endif\n#include[RENDER_TARGET_COUNT]\n#include\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include\ngl_FragData[1]=vec4(normalize(vec3(vWorldView*vec4(normalW,0.0))),1.0);\n#else\ngl_FragData[1]=vec4(normalize(vNormalV),1.0);\n#endif\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef REFLECTIVITY\n#ifdef HAS_SPECULAR\n\nvec4 reflectivity=texture2D(reflectivitySampler,vReflectivityUV);\n#elif HAS_REFLECTIVITY\n\nvec4 reflectivity=vec4(texture2D(reflectivitySampler,vReflectivityUV).rgb,1.0);\n#else\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\n#endif\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\n#endif\n}";Qc.a.ShadersStore.geometryPixelShader=Yv;var qv="precision highp float;\nprecision highp int;\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef NEED_UV\nvarying vec2 vUV;\n#ifdef ALPHATEST\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef BUMP\nuniform mat4 bumpMatrix;\nvarying vec2 vBumpUV;\n#endif\n#ifdef REFLECTIVITY\nuniform mat4 reflectivityMatrix;\nvarying vec2 vReflectivityUV;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef BUMP\nvarying mat4 vWorldView;\n#endif\n#ifdef BUMP\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousWorld;\nuniform mat4 previousViewProjection;\n#ifdef BONES_VELOCITY_ENABLED\n#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#endif\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#include\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#include\nvec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));\n#ifdef BUMP\nvWorldView=view*finalWorld;\nvNormalW=normalUpdated;\n#else\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\n#endif\nvViewPos=view*pos;\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n#if defined(POSITION) || defined(BUMP)\nvPositionW=pos.xyz/pos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#ifdef NEED_UV\n#ifdef UV1\n#ifdef ALPHATEST\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#else\nvUV=uv;\n#endif\n#ifdef BUMP\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef UV2\n#ifdef ALPHATEST\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#else\nvUV=uv2;\n#endif\n#ifdef BUMP\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#endif\n#include\n}\n";Qc.a.ShadersStore.geometryVertexShader=qv;var Zv=function(){function e(t,n){void 0===n&&(n=1),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._scene=t,this._ratio=n,e._SceneComponentInitialization(this._scene),this._createRenderTargets()}return Object.defineProperty(e.prototype,"renderList",{set:function(e){this._multiRenderTarget.renderList=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!0,configurable:!0}),e.prototype.getTextureIndex=function(t){switch(t){case e.POSITION_TEXTURE_TYPE:return this._positionIndex;case e.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case e.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;default:return-1}},Object.defineProperty(e.prototype,"enablePosition",{get:function(){return this._enablePosition},set:function(e){this._enablePosition=e,this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableVelocity",{get:function(){return this._enableVelocity},set:function(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableReflectivity",{get:function(){return this._enableReflectivity},set:function(e){this._enableReflectivity=e,this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ratio",{get:function(){return this._ratio},enumerable:!0,configurable:!0}),e.prototype.isReady=function(e,t){var n=e.getMaterial();if(n&&n.disableDepthWrite)return!1;var r=[],i=[cs.PositionKind,cs.NormalKind],o=e.getMesh();if(n){var a=!1;n.needAlphaBlending()&&(r.push("#define ALPHATEST"),a=!0),n.bumpTexture&&hd.BumpTextureEnabled&&(r.push("#define BUMP"),a=!0),this._enableReflectivity&&(n instanceof hd&&n.specularTexture?(r.push("#define HAS_SPECULAR"),a=!0):n instanceof Dp&&n.reflectivityTexture&&(r.push("#define HAS_REFLECTIVITY"),a=!0)),a&&(r.push("#define NEED_UV"),o.isVerticesDataPresent(cs.UVKind)&&(i.push(cs.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(cs.UV2Kind)&&(i.push(cs.UV2Kind),r.push("#define UV2")))}this._enablePosition&&(r.push("#define POSITION"),r.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(r.push("#define VELOCITY"),r.push("#define VELOCITY_INDEX "+this._velocityIndex),-1===this.excludedSkinnedMeshesFromVelocity.indexOf(o)&&r.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(r.push("#define REFLECTIVITY"),r.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),o.useBones&&o.computeBonesUsingShaders?(i.push(cs.MatricesIndicesKind),i.push(cs.MatricesWeightsKind),o.numBoneInfluencers>4&&(i.push(cs.MatricesIndicesExtraKind),i.push(cs.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0");var s=o.morphTargetManager,l=0;s&&s.numInfluencers>0&&(l=s.numInfluencers,r.push("#define MORPHTARGETS"),r.push("#define NUM_MORPH_INFLUENCERS "+l),Cu.PrepareAttributesForMorphTargetsInfluencers(i,o,l)),t&&(r.push("#define INSTANCES"),Cu.PushAttributesForInstances(i)),r.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length);var c=r.join("\n");return this._cachedDefines!==c&&(this._cachedDefines=c,this._effect=this._scene.getEngine().createEffect("geometry",i,["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","morphTargetInfluences","bumpMatrix","reflectivityMatrix","vTangentSpaceParams","vBumpInfos"],["diffuseSampler","bumpSampler","reflectivitySampler"],c,void 0,void 0,void 0,{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:l})),this._effect.isReady()},e.prototype.getGBuffer=function(){return this._multiRenderTarget},Object.defineProperty(e.prototype,"samples",{get:function(){return this._multiRenderTarget.samples},set:function(e){this._multiRenderTarget.samples=e},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.getGBuffer().dispose()},e.prototype._createRenderTargets=function(){var e=this,t=this._scene.getEngine(),n=2;if(this._enablePosition&&(this._positionIndex=n,n++),this._enableVelocity&&(this._velocityIndex=n,n++),this._enableReflectivity&&(this._reflectivityIndex=n,n++),this._multiRenderTarget=new Tm("gBuffer",{width:t.getRenderWidth()*this._ratio,height:t.getRenderHeight()*this._ratio},n,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:1}),this.isSupported){this._multiRenderTarget.wrapU=Wl.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Wl.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(e){e.clear(new ko(0,0,0,1),!0,!0,!0)}));var r=function(t){var n=t.getRenderingMesh(),r=e._scene,i=r.getEngine(),o=t.getMaterial();if(o){if(n._internalAbstractMeshDataInfo._isActiveIntermediate=!1,e._enableVelocity&&!e._previousTransformationMatrices[n.uniqueId]&&(e._previousTransformationMatrices[n.uniqueId]={world:Oo.Identity(),viewProjection:r.getTransformMatrix()},n.skeleton)){var a=n.skeleton.getTransformMatrices(n);e._previousBonesTransformationMatrices[n.uniqueId]=e._copyBonesTransformationMatrices(a,new Float32Array(a.length))}i.setState(o.backFaceCulling,0,!1,r.useRightHandedSystem);var s=n._getInstancesRenderList(t._id);if(!s.mustReturn){var l=i.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(e.isReady(t,l)){if(i.enableEffect(e._effect),n._bind(t,e._effect,o.fillMode),e._effect.setMatrix("viewProjection",r.getTransformMatrix()),e._effect.setMatrix("view",r.getViewMatrix()),o){if(o.needAlphaTesting()){var c=o.getAlphaTestTexture();c&&(e._effect.setTexture("diffuseSampler",c),e._effect.setMatrix("diffuseMatrix",c.getTextureMatrix()))}o.bumpTexture&&r.getEngine().getCaps().standardDerivatives&&hd.BumpTextureEnabled&&(e._effect.setFloat3("vBumpInfos",o.bumpTexture.coordinatesIndex,1/o.bumpTexture.level,o.parallaxScaleBias),e._effect.setMatrix("bumpMatrix",o.bumpTexture.getTextureMatrix()),e._effect.setTexture("bumpSampler",o.bumpTexture),e._effect.setFloat2("vTangentSpaceParams",o.invertNormalMapX?-1:1,o.invertNormalMapY?-1:1)),e._enableReflectivity&&(o instanceof hd&&o.specularTexture?(e._effect.setMatrix("reflectivityMatrix",o.specularTexture.getTextureMatrix()),e._effect.setTexture("reflectivitySampler",o.specularTexture)):o instanceof Dp&&o.reflectivityTexture&&(e._effect.setMatrix("reflectivityMatrix",o.reflectivityTexture.getTextureMatrix()),e._effect.setTexture("reflectivitySampler",o.reflectivityTexture)))}n.useBones&&n.computeBonesUsingShaders&&n.skeleton&&(e._effect.setMatrices("mBones",n.skeleton.getTransformMatrices(n)),e._enableVelocity&&e._effect.setMatrices("mPreviousBones",e._previousBonesTransformationMatrices[n.uniqueId])),Cu.BindMorphTargetParameters(n,e._effect),e._enableVelocity&&(e._effect.setMatrix("previousWorld",e._previousTransformationMatrices[n.uniqueId].world),e._effect.setMatrix("previousViewProjection",e._previousTransformationMatrices[n.uniqueId].viewProjection)),n._processRendering(t,e._effect,o.fillMode,s,l,(function(t,n){return e._effect.setMatrix("world",n)}))}e._enableVelocity&&(e._previousTransformationMatrices[n.uniqueId].world=n.getWorldMatrix().clone(),e._previousTransformationMatrices[n.uniqueId].viewProjection=e._scene.getTransformMatrix().clone(),n.skeleton&&e._copyBonesTransformationMatrices(n.skeleton.getTransformMatrices(n),e._previousBonesTransformationMatrices[n.uniqueId]))}}};this._multiRenderTarget.customRenderFunction=function(n,i,o,a){var s;if(a.length){for(t.setColorWrite(!1),s=0;s0){var n=this._renderEffects[t[0]].getPostProcesses();n&&(n[0].samples=e)}return!0},e.prototype.dispose=function(){},Object(No.c)([ha()],e.prototype,"_name",void 0),e}(),oA=function(){function e(){this._renderPipelines={}}return Object.defineProperty(e.prototype,"supportedPipelines",{get:function(){var e=[];for(var t in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(t)){var n=this._renderPipelines[t];n.isSupported&&e.push(n)}return e},enumerable:!0,configurable:!0}),e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,n){void 0===n&&(n=!1);var r=this._renderPipelines[e];r&&r._attachCameras(t,n)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var n=this._renderPipelines[e];n&&n._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,n){var r=this._renderPipelines[e];r&&r._enableEffect(t,n)},e.prototype.disableEffectInPipeline=function(e,t,n){var r=this._renderPipelines[e];r&&r._disableEffect(t,n)},e.prototype.update=function(){for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e.prototype._rebuild=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e]._rebuild()}},e.prototype.dispose=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e].dispose()}},e}();Object.defineProperty(nl.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var e=this._getComponent(Gs.NAME_POSTPROCESSRENDERPIPELINEMANAGER);e||(e=new aA(this),this._addComponent(e)),this._postProcessRenderPipelineManager=new oA}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var aA=function(){function e(e){this.name=Gs.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Gs.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER,this,this._gatherRenderTargets)},e.prototype.rebuild=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager._rebuild()},e.prototype.dispose=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.dispose()},e.prototype._gatherRenderTargets=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()},e}(),sA=function(e){function t(t,n,r,i,o){void 0===t&&(t=""),void 0===n&&(n=!0),void 0===r&&(r=Zo.a.LastCreatedScene),void 0===o&&(o=!0);var a=e.call(this,r.getEngine(),t)||this;a._camerasToBeAttached=[],a.SharpenPostProcessId="SharpenPostProcessEffect",a.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",a.FxaaPostProcessId="FxaaPostProcessEffect",a.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",a.GrainPostProcessId="GrainPostProcessEffect",a._glowLayer=null,a.animations=[],a._imageProcessingConfigurationObserver=null,a._sharpenEnabled=!1,a._bloomEnabled=!1,a._depthOfFieldEnabled=!1,a._depthOfFieldBlurLevel=Lv.Low,a._fxaaEnabled=!1,a._imageProcessingEnabled=!0,a._bloomScale=.5,a._chromaticAberrationEnabled=!1,a._grainEnabled=!1,a._buildAllowed=!0,a._resizeObserver=null,a._hardwareScaleLevel=1,a._bloomKernel=64,a._bloomWeight=.15,a._bloomThreshold=.9,a._samples=1,a._hasCleared=!1,a._prevPostProcess=null,a._prevPrevPostProcess=null,a._depthOfFieldSceneObserver=null,a._cameras=i||r.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._buildAllowed=o,a._scene=r;var s=a._scene.getEngine().getCaps();a._hdr=n&&(s.textureHalfFloatRender||s.textureFloatRender),a._hdr?s.textureHalfFloatRender?a._defaultPipelineTextureType=2:s.textureFloatRender&&(a._defaultPipelineTextureType=1):a._defaultPipelineTextureType=0,r.postProcessRenderPipelineManager.addPipeline(a);var l=a._scene.getEngine();return a.sharpen=new rA("sharpen",1,null,Wl.BILINEAR_SAMPLINGMODE,l,!1,a._defaultPipelineTextureType,!0),a._sharpenEffect=new Ev(l,a.SharpenPostProcessId,(function(){return a.sharpen}),!0),a.depthOfField=new Vv(a._scene,null,a._depthOfFieldBlurLevel,a._defaultPipelineTextureType,!0),a.bloom=new Ov(a._scene,a._bloomScale,a._bloomWeight,a.bloomKernel,a._defaultPipelineTextureType,!0),a.chromaticAberration=new Mv("ChromaticAberration",l.getRenderWidth(),l.getRenderHeight(),1,null,Wl.BILINEAR_SAMPLINGMODE,l,!1,a._defaultPipelineTextureType,!0),a._chromaticAberrationEffect=new Ev(l,a.ChromaticAberrationPostProcessId,(function(){return a.chromaticAberration}),!0),a.grain=new Kv("Grain",1,null,Wl.BILINEAR_SAMPLINGMODE,l,!1,a._defaultPipelineTextureType,!0),a._grainEffect=new Ev(l,a.GrainPostProcessId,(function(){return a.grain}),!0),a._resizeObserver=l.onResizeObservable.add((function(){a._hardwareScaleLevel=l.getHardwareScalingLevel(),a.bloomKernel=a.bloomKernel})),a._imageProcessingConfigurationObserver=a._scene.imageProcessingConfiguration.onUpdateParameters.add((function(){a.bloom._downscale._exposure=a._scene.imageProcessingConfiguration.exposure})),a._buildPipeline(),a}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!0,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:!0,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:!0,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:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),t.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new Ov(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var t=0;t1){for(var n=0,r=this._cameras;n-1&&(e.depthOfField.depthTexture=t.enableDepthRenderer(t.activeCamera).getDepthMap())}))}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);var o=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=o.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 md("imageProcessing",1,null,Wl.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new Ev(t,this.ImageProcessingPostProcessId,(function(){return e.imageProcessing}),!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1),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 Qv("fxaa",1,null,Wl.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new Ev(t,this.FxaaPostProcessId,(function(){return e.fxaa}),!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&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&&jo.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")}},t.prototype._disposePostProcesses=function(e){void 0===e&&(e=!1);for(var t=0;t0?n._ssaoCombinePostProcess.width:n._originalColorPostProcess.width),e.setFloat("near",n._scene.activeCamera.minZ),e.setFloat("far",n._scene.activeCamera.maxZ),e.setFloat("radius",n.radius),e.setTexture("depthSampler",n._depthTexture),e.setArray("samplerOffsets",n._samplerOffsets))},this._blurVPostProcess=new Xc("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],t,null,Wl.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(r?"1":"0")+"\n"),this._blurVPostProcess.onApply=function(e){n._scene.activeCamera&&(e.setFloat("outSize",n._ssaoCombinePostProcess.height>0?n._ssaoCombinePostProcess.height:n._originalColorPostProcess.height),e.setFloat("near",n._scene.activeCamera.minZ),e.setFloat("far",n._scene.activeCamera.maxZ),e.setFloat("radius",n.radius),e.setTexture("depthSampler",n._depthTexture),e.setArray("samplerOffsets",n._samplerOffsets))},this._blurHPostProcess.samples=this.textureSamples,this._blurVPostProcess.samples=this.textureSamples},t.prototype._rebuild=function(){e.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,2.3283064365386963e-10*this._bits[0]},t.prototype._hammersley=function(e,t){return[e/t,this._radicalInverse_VdC(e)]},t.prototype._hemisphereSample_uniform=function(e,t){var n=2*t*Math.PI,r=1-(.85*e+.15),i=Math.sqrt(1-r*r);return new So(Math.cos(n)*i,Math.sin(n)*i,r)},t.prototype._generateHemisphere=function(){for(var e,t=this.samples,n=[],r=0;r>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join("\n"))},Object(No.c)([ha()],t.prototype,"threshold",void 0),Object(No.c)([ha()],t.prototype,"strength",void 0),Object(No.c)([ha()],t.prototype,"reflectionSpecularFalloffExponent",void 0),Object(No.c)([ha()],t.prototype,"step",void 0),Object(No.c)([ha()],t.prototype,"roughnessFactor",void 0),Object(No.c)([ha()],t.prototype,"enableSmoothReflections",null),Object(No.c)([ha()],t.prototype,"reflectionSamples",null),Object(No.c)([ha()],t.prototype,"smoothSteps",null),t}(Xc),gA="uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminanceshadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\n#include\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\n#ifndef AUTO_EXPOSURE\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\n#endif\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n";Qc.a.ShadersStore.standardPixelShader=gA;var bA=function(e){function t(t,n,r,i,o){void 0===i&&(i=null);var a=e.call(this,n.getEngine(),t)||this;return a.downSampleX4PostProcess=null,a.brightPassPostProcess=null,a.blurHPostProcesses=[],a.blurVPostProcesses=[],a.textureAdderPostProcess=null,a.volumetricLightPostProcess=null,a.volumetricLightSmoothXPostProcess=null,a.volumetricLightSmoothYPostProcess=null,a.volumetricLightMergePostProces=null,a.volumetricLightFinalPostProcess=null,a.luminancePostProcess=null,a.luminanceDownSamplePostProcesses=[],a.hdrPostProcess=null,a.textureAdderFinalPostProcess=null,a.lensFlareFinalPostProcess=null,a.hdrFinalPostProcess=null,a.lensFlarePostProcess=null,a.lensFlareComposePostProcess=null,a.motionBlurPostProcess=null,a.depthOfFieldPostProcess=null,a.fxaaPostProcess=null,a.screenSpaceReflectionPostProcess=null,a.brightThreshold=1,a.blurWidth=512,a.horizontalBlur=!1,a.lensTexture=null,a.volumetricLightCoefficient=.2,a.volumetricLightPower=4,a.volumetricLightBlurScale=64,a.sourceLight=null,a.hdrMinimumLuminance=1,a.hdrDecreaseRate=.5,a.hdrIncreaseRate=.5,a.lensColorTexture=null,a.lensFlareStrength=20,a.lensFlareGhostDispersal=1.4,a.lensFlareHaloWidth=.7,a.lensFlareDistortionStrength=16,a.lensFlareBlurWidth=512,a.lensStarTexture=null,a.lensFlareDirtTexture=null,a.depthOfFieldDistance=10,a.depthOfFieldBlurWidth=64,a.animations=[],a._currentDepthOfFieldSource=null,a._fixedExposure=1,a._currentExposure=1,a._hdrAutoExposure=!1,a._hdrCurrentLuminance=1,a._motionStrength=1,a._isObjectBasedMotionBlur=!1,a._camerasToBeAttached=[],a._bloomEnabled=!1,a._depthOfFieldEnabled=!1,a._vlsEnabled=!1,a._lensFlareEnabled=!1,a._hdrEnabled=!1,a._motionBlurEnabled=!1,a._fxaaEnabled=!1,a._screenSpaceReflectionsEnabled=!1,a._motionBlurSamples=64,a._volumetricLightStepsCount=50,a._samples=1,a._cameras=o||n.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._scene=n,a._basePostProcess=i,a._ratio=r,a._floatTextureType=n.getEngine().getCaps().textureFloatRender?1:2,n.postProcessRenderPipelineManager.addPipeline(a),a._buildPipeline(),a}return Object(No.d)(t,e),Object.defineProperty(t.prototype,"exposure",{get:function(){return this._fixedExposure},set:function(e){this._fixedExposure=e,this._currentExposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hdrAutoExposure",{get:function(){return this._hdrAutoExposure},set:function(e){if(this._hdrAutoExposure=e,this.hdrPostProcess){var t=["#define HDR"];e&&t.push("#define AUTO_EXPOSURE"),this.hdrPostProcess.updateEffect(t.join("\n"))}},enumerable:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"objectBasedMotionBlur",{get:function(){return this._isObjectBasedMotionBlur},set:function(e){var t=this._isObjectBasedMotionBlur!==e;this._isObjectBasedMotionBlur=e,t&&this._buildPipeline()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"VLSEnabled",{get:function(){return this._vlsEnabled},set:function(e){if(this._vlsEnabled!==e){if(e)if(!this._scene.enableGeometryBufferRenderer())return void jo.a.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");this._vlsEnabled=e,this._buildPipeline()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"MotionBlurEnabled",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"screenSpaceReflectionsEnabled",{get:function(){return this._screenSpaceReflectionsEnabled},set:function(e){this._screenSpaceReflectionsEnabled!==e&&(this._screenSpaceReflectionsEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"volumetricLightStepsCount",{get:function(){return this._volumetricLightStepsCount},set:function(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS "+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!0,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\n#define MAX_MOTION_SAMPLES "+e.toFixed(1))),this._motionBlurSamples=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!0,configurable:!0}),t.prototype._buildPipeline=function(){var e=this,t=this._ratio,n=this._scene;this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._screenSpaceReflectionsEnabled&&(this.screenSpaceReflectionPostProcess=new mA("HDRPass",n,t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.screenSpaceReflectionPostProcess})),this.addEffect(new Ev(n.getEngine(),"HDRScreenSpaceReflections",(function(){return e.screenSpaceReflectionPostProcess}),!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new Xc("HDRPass","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.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 Ev(n.getEngine(),"HDRPassPostProcess",(function(){return e.originalPostProcess}),!0)),this._bloomEnabled&&(this._createDownSampleX4PostProcess(n,t/4),this._createBrightPassPostProcess(n,t/4),this._createBlurPostProcesses(n,t/4,1),this._createTextureAdderPostProcess(n,t),this.textureAdderFinalPostProcess=new Xc("HDRDepthOfFieldSource","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Ev(n.getEngine(),"HDRBaseDepthOfFieldSource",(function(){return e.textureAdderFinalPostProcess}),!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(n,t),this.volumetricLightFinalPostProcess=new Xc("HDRVLSFinal","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Ev(n.getEngine(),"HDRVLSFinal",(function(){return e.volumetricLightFinalPostProcess}),!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(n,t),this.lensFlareFinalPostProcess=new Xc("HDRPostLensFlareDepthOfFieldSource","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Ev(n.getEngine(),"HDRPostLensFlareDepthOfFieldSource",(function(){return e.lensFlareFinalPostProcess}),!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(n,this._floatTextureType),this._createHdrPostProcess(n,t),this.hdrFinalPostProcess=new Xc("HDRPostHDReDepthOfFieldSource","standard",[],[],t,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Ev(n.getEngine(),"HDRPostHDReDepthOfFieldSource",(function(){return e.hdrFinalPostProcess}),!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(n,t/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(n,t)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(n,t),this._fxaaEnabled&&(this.fxaaPostProcess=new Qv("fxaa",1,null,Wl.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,0),this.addEffect(new Ev(n.getEngine(),"HDRFxaa",(function(){return e.fxaaPostProcess}),!0))),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this._samples)&&this._samples>1&&jo.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")},t.prototype._createDownSampleX4PostProcess=function(e,t){var n=this,r=new Array(32);this.downSampleX4PostProcess=new Xc("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,i=n.downSampleX4PostProcess.width,o=n.downSampleX4PostProcess.height,a=-2;a<2;a++)for(var s=-2;s<2;s++)r[t]=(a+.5)*(1/i),r[t+1]=(s+.5)*(1/o),t+=2;e.setArray2("dsOffsets",r)},this.addEffect(new Ev(e.getEngine(),"HDRDownSampleX4",(function(){return n.downSampleX4PostProcess}),!0))},t.prototype._createBrightPassPostProcess=function(e,t){var n=this,r=new Array(8);this.brightPassPostProcess=new Xc("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),this.brightPassPostProcess.onApply=function(e){var t=1/n.brightPassPostProcess.width,i=1/n.brightPassPostProcess.height;r[0]=-.5*t,r[1]=.5*i,r[2]=.5*t,r[3]=.5*i,r[4]=-.5*t,r[5]=-.5*i,r[6]=.5*t,r[7]=-.5*i,e.setArray2("dsOffsets",r),e.setFloat("brightThreshold",n.brightThreshold)},this.addEffect(new Ev(e.getEngine(),"HDRBrightPass",(function(){return n.brightPassPostProcess}),!0))},t.prototype._createBlurPostProcesses=function(e,t,n,r){var i=this;void 0===r&&(r="blurWidth");var o=e.getEngine(),a=new $h("HDRBlurH_"+n,new Co(1,0),this[r],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),s=new $h("HDRBlurV_"+n,new Co(0,1),this[r],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);a.onActivateObservable.add((function(){var e=a.width/o.getRenderWidth();a.kernel=i[r]*e})),s.onActivateObservable.add((function(){var e=s.height/o.getRenderHeight();s.kernel=i.horizontalBlur?64*e:i[r]*e})),this.addEffect(new Ev(e.getEngine(),"HDRBlurH"+n,(function(){return a}),!0)),this.addEffect(new Ev(e.getEngine(),"HDRBlurV"+n,(function(){return s}),!0)),this.blurHPostProcesses.push(a),this.blurVPostProcesses.push(s)},t.prototype._createTextureAdderPostProcess=function(e,t){var n=this;this.textureAdderPostProcess=new Xc("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",n._vlsEnabled?n._currentDepthOfFieldSource:n.originalPostProcess),e.setTexture("lensSampler",n.lensTexture),e.setFloat("exposure",n._currentExposure),n._currentDepthOfFieldSource=n.textureAdderFinalPostProcess},this.addEffect(new Ev(e.getEngine(),"HDRTextureAdder",(function(){return n.textureAdderPostProcess}),!0))},t.prototype._createVolumetricLightPostProcess=function(e,t){var n=this,r=e.enableGeometryBufferRenderer();r.enablePosition=!0;var i=r.getGBuffer();this.volumetricLightPostProcess=new Xc("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var o=Co.Zero();this.volumetricLightPostProcess.onApply=function(e){if(n.sourceLight&&n.sourceLight.getShadowGenerator()&&n._scene.activeCamera){var t=n.sourceLight.getShadowGenerator();e.setTexture("shadowMapSampler",t.getShadowMap()),e.setTexture("positionSampler",i.textures[2]),e.setColor3("sunColor",n.sourceLight.diffuse),e.setVector3("sunDirection",n.sourceLight.getShadowDirection()),e.setVector3("cameraPosition",n._scene.activeCamera.globalPosition),e.setMatrix("shadowViewProjection",t.getTransformMatrix()),e.setFloat("scatteringCoefficient",n.volumetricLightCoefficient),e.setFloat("scatteringPower",n.volumetricLightPower),o.x=n.sourceLight.getDepthMinZ(n._scene.activeCamera),o.y=n.sourceLight.getDepthMaxZ(n._scene.activeCamera),e.setVector2("depthValues",o)}},this.addEffect(new Ev(e.getEngine(),"HDRVLS",(function(){return n.volumetricLightPostProcess}),!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new Xc("HDRVLSMerge","standard",[],["originalSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(e){e.setTextureFromPostProcess("originalSampler",n._bloomEnabled?n.textureAdderFinalPostProcess:n.originalPostProcess),n._currentDepthOfFieldSource=n.volumetricLightFinalPostProcess},this.addEffect(new Ev(e.getEngine(),"HDRVLSMerge",(function(){return n.volumetricLightMergePostProces}),!0))},t.prototype._createLuminancePostProcesses=function(e,n){var r=this,i=Math.pow(3,t.LuminanceSteps);this.luminancePostProcess=new Xc("HDRLuminance","standard",["lumOffsets"],[],{width:i,height:i},null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",n);var o=[];this.luminancePostProcess.onApply=function(e){var t=1/r.luminancePostProcess.width,n=1/r.luminancePostProcess.height;o[0]=-.5*t,o[1]=.5*n,o[2]=.5*t,o[3]=.5*n,o[4]=-.5*t,o[5]=-.5*n,o[6]=.5*t,o[7]=-.5*n,e.setArray2("lumOffsets",o)},this.addEffect(new Ev(e.getEngine(),"HDRLuminance",(function(){return r.luminancePostProcess}),!0));for(var a=t.LuminanceSteps-1;a>=0;a--){i=Math.pow(3,a);var s="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(s+="#define FINAL_DOWN_SAMPLER");var l=new Xc("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:i,height:i},null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,s,n);this.luminanceDownSamplePostProcesses.push(l)}var c=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(t,n){var i=new Array(18);t.onApply=function(e){if(c){for(var o=0,a=-1;a<2;a++)for(var s=-1;s<2;s++)i[o]=a/c.width,i[o+1]=s/c.height,o+=2;e.setArray2("dsOffsets",i),e.setFloat("halfDestPixelSize",.5/c.width),c=n===r.luminanceDownSamplePostProcesses.length-1?r.luminancePostProcess:t}},n===r.luminanceDownSamplePostProcesses.length-1&&(t.onAfterRender=function(){var t=e.getEngine().readPixels(0,0,1,1),n=new To(1/16581375,1/65025,1/255,1);r._hdrCurrentLuminance=(t[0]*n.x+t[1]*n.y+t[2]*n.z+t[3]*n.w)/100}),r.addEffect(new Ev(e.getEngine(),"HDRLuminanceDownSample"+n,(function(){return t}),!0))}))},t.prototype._createHdrPostProcess=function(e,t){var n=this,r=["#define HDR"];this._hdrAutoExposure&&r.push("#define AUTO_EXPOSURE"),this.hdrPostProcess=new Xc("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r.join("\n"),0);var i=1,o=0,a=0;this.hdrPostProcess.onApply=function(t){if(t.setTextureFromPostProcess("textureAdderSampler",n._currentDepthOfFieldSource),o+=e.getEngine().getDeltaTime(),i<0)i=n._hdrCurrentLuminance;else{var r=(a-o)/1e3;n._hdrCurrentLuminancei-n.hdrIncreaseRate*r?i-=n.hdrIncreaseRate*r:i=n._hdrCurrentLuminance}n.hdrAutoExposure?n._currentExposure=n._fixedExposure/i:(i=xo.Clamp(i,n.hdrMinimumLuminance,1e20),t.setFloat("averageLuminance",i)),a=o,n._currentDepthOfFieldSource=n.hdrFinalPostProcess},this.addEffect(new Ev(e.getEngine(),"HDR",(function(){return n.hdrPostProcess}),!0))},t.prototype._createLensFlarePostProcess=function(e,t){var n=this;this.lensFlarePostProcess=new Xc("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",0),this.addEffect(new Ev(e.getEngine(),"HDRLensFlare",(function(){return n.lensFlarePostProcess}),!0)),this._createBlurPostProcesses(e,t/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new Xc("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",0),this.addEffect(new Ev(e.getEngine(),"HDRLensFlareCompose",(function(){return n.lensFlareComposePostProcess}),!0));var r=new Co(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",n._bloomEnabled?n.blurHPostProcesses[0]:n.originalPostProcess),e.setTexture("lensColorSampler",n.lensColorTexture),e.setFloat("strength",n.lensFlareStrength),e.setFloat("ghostDispersal",n.lensFlareGhostDispersal),e.setFloat("haloWidth",n.lensFlareHaloWidth),r.x=n.lensFlarePostProcess.width,r.y=n.lensFlarePostProcess.height,e.setVector2("resolution",r),e.setFloat("distortionStrength",n.lensFlareDistortionStrength)};var i=Oo.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),o=Oo.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(e){if(n._scene.activeCamera){e.setTextureFromPostProcess("otherSampler",n.lensFlarePostProcess),e.setTexture("lensDirtSampler",n.lensFlareDirtTexture),e.setTexture("lensStarSampler",n.lensStarTexture);var t=n._scene.activeCamera.getViewMatrix().getRow(0),r=n._scene.activeCamera.getViewMatrix().getRow(2),a=So.Dot(t.toVector3(),new So(1,0,0))+So.Dot(r.toVector3(),new So(0,0,1));a*=4;var s=Oo.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),l=o.multiply(s).multiply(i);e.setMatrix("lensStarMatrix",l),n._currentDepthOfFieldSource=n.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,t){var n=this;this.depthOfFieldPostProcess=new Xc("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",0),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",n._currentDepthOfFieldSource),e.setTexture("depthSampler",n._getDepthTexture()),e.setFloat("distance",n.depthOfFieldDistance)},this.addEffect(new Ev(e.getEngine(),"HDRDepthOfField",(function(){return n.depthOfFieldPostProcess}),!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var n=this;if(this._isObjectBasedMotionBlur){var r=new eA("HDRMotionBlur",e,t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,0);r.motionStrength=this.motionStrength,r.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=r}else{this.motionBlurPostProcess=new Xc("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,Wl.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),0);var i=0,o=Oo.Identity(),a=Oo.Identity(),s=Oo.Identity(),l=Co.Zero();this.motionBlurPostProcess.onApply=function(t){(s=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(a),t.setMatrix("inverseViewProjection",a),t.setMatrix("prevViewProjection",o),o=s,l.x=n.motionBlurPostProcess.width,l.y=n.motionBlurPostProcess.height,t.setVector2("screenSize",l),i=e.getEngine().getFps()/60,t.setFloat("motionScale",i),t.setFloat("motionStrength",n.motionStrength),t.setTexture("depthSampler",n._getDepthTexture())}}this.addEffect(new Ev(e.getEngine(),"HDRMotionBlur",(function(){return n.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;e0&&-1!==this.excludedMeshes.indexOf(e)},t.prototype._createPass=function(e,t){var n=this,r=e.getEngine();this._volumetricLightScatteringRTT=new mu("volumetricLightScatteringMap",{width:r.getRenderWidth()*t,height:r.getRenderHeight()*t},e,!1,!0,0),this._volumetricLightScatteringRTT.wrapU=Wl.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Wl.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var i=this.getCamera();i?i.customRenderTargets.push(this._volumetricLightScatteringRTT):e.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,a=function(e){var t=e.getRenderingMesh();if(!n._meshExcluded(t)){t._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var r=e.getMaterial();if(r){var i=t.getScene(),o=i.getEngine();o.setState(r.backFaceCulling);var a=t._getInstancesRenderList(e._id);if(!a.mustReturn){var s=o.getCaps().instancedArrays&&null!==a.visibleInstances[e._id];if(n._isReady(e,s)){var l=n._volumetricLightScatteringPass;if(t===n.mesh&&(l=e.effect?e.effect:r.getEffect()),o.enableEffect(l),t._bind(e,l,r.fillMode),t===n.mesh)r.bind(t.getWorldMatrix(),t);else{if(n._volumetricLightScatteringPass.setMatrix("viewProjection",i.getTransformMatrix()),r&&r.needAlphaTesting()){var c=r.getAlphaTestTexture();n._volumetricLightScatteringPass.setTexture("diffuseSampler",c),c&&n._volumetricLightScatteringPass.setMatrix("diffuseMatrix",c.getTextureMatrix())}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&n._volumetricLightScatteringPass.setMatrices("mBones",t.skeleton.getTransformMatrices(t))}t._processRendering(e,n._volumetricLightScatteringPass,Ls.TriangleFillMode,a,s,(function(e,t){return l.setMatrix("world",t)}))}}}}},s=new ko(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=e.clearColor,e.clearColor=s})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){e.clearColor=o})),this._volumetricLightScatteringRTT.customRenderFunction=function(t,n,r,i){var o,s=e.getEngine();if(i.length){for(s.setColorWrite(!1),o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),s.setAlphaMode(2),o=0;o\nvoid main(void) {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include\ngl_FragColor=color;\n}";Qc.a.ShadersStore.outlinePixelShader=RA;var MA="\nattribute vec3 position;\nattribute vec3 normal;\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n\nuniform float offset;\n#include\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include[0..maxSimultaneousMorphTargets]\nvec3 offsetPosition=positionUpdated+(normalUpdated*offset);\n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}\n";Qc.a.ShadersStore.outlineVertexShader=MA;nl.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new IA(this)),this._outlineRenderer},Object.defineProperty(Pl.prototype,"renderOutline",{get:function(){return this._renderOutline},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOutline=e},enumerable:!0,configurable:!0}),Object.defineProperty(Pl.prototype,"renderOverlay",{get:function(){return this._renderOverlay},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOverlay=e},enumerable:!0,configurable:!0});var IA=function(){function e(e){this.name=Gs.NAME_OUTLINERENDERER,this.zOffset=1,this.scene=e,this._engine=e.getEngine(),this.scene._addComponent(this)}return e.prototype.register=function(){this.scene._beforeRenderingMeshStage.registerStep(Gs.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(Gs.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype.render=function(e,t,n){var r=this;void 0===n&&(n=!1);var i=this.scene,o=i.getEngine(),a=o.getCaps().instancedArrays&&null!==t.visibleInstances[e._id]&&void 0!==t.visibleInstances[e._id];if(this.isReady(e,a)){var s=e.getRenderingMesh(),l=e.getMaterial();if(l&&i.activeCamera){if(o.enableEffect(this._effect),l.useLogarithmicDepth&&this._effect.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2)),this._effect.setFloat("offset",n?0:s.outlineWidth),this._effect.setColor4("color",n?s.overlayColor:s.outlineColor,n?s.overlayAlpha:l.alpha),this._effect.setMatrix("viewProjection",i.getTransformMatrix()),s.useBones&&s.computeBonesUsingShaders&&s.skeleton&&this._effect.setMatrices("mBones",s.skeleton.getTransformMatrices(s)),Cu.BindMorphTargetParameters(s,this._effect),s._bind(e,this._effect,l.fillMode),l&&l.needAlphaTesting()){var c=l.getAlphaTestTexture();c&&(this._effect.setTexture("diffuseSampler",c),this._effect.setMatrix("diffuseMatrix",c.getTextureMatrix()))}o.setZOffset(-this.zOffset),s._processRendering(e,this._effect,l.fillMode,t,a,(function(e,t){r._effect.setMatrix("world",t)})),o.setZOffset(0)}}},e.prototype.isReady=function(e,t){var n=[],r=[cs.PositionKind,cs.NormalKind],i=e.getMesh(),o=e.getMaterial();o&&(o.needAlphaTesting()&&(n.push("#define ALPHATEST"),i.isVerticesDataPresent(cs.UVKind)&&(r.push(cs.UVKind),n.push("#define UV1")),i.isVerticesDataPresent(cs.UV2Kind)&&(r.push(cs.UV2Kind),n.push("#define UV2"))),o.useLogarithmicDepth&&n.push("#define LOGARITHMICDEPTH")),i.useBones&&i.computeBonesUsingShaders?(r.push(cs.MatricesIndicesKind),r.push(cs.MatricesWeightsKind),i.numBoneInfluencers>4&&(r.push(cs.MatricesIndicesExtraKind),r.push(cs.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),n.push("#define BonesPerMesh "+(i.skeleton?i.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0");var a=i.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,n.push("#define MORPHTARGETS"),n.push("#define NUM_MORPH_INFLUENCERS "+s),Cu.PrepareAttributesForMorphTargetsInfluencers(r,i,s)),t&&(n.push("#define INSTANCES"),Cu.PushAttributesForInstances(r));var l=n.join("\n");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this.scene.getEngine().createEffect("outline",r,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences"],["diffuseSampler"],l,void 0,void 0,void 0,{maxSimultaneousMorphTargets:s})),this._effect.isReady()},e.prototype._beforeRenderingMesh=function(t,n,r){if(this._savedDepthWrite=this._engine.getDepthWrite(),t.renderOutline){var i=n.getMaterial();i&&i.needAlphaBlending()&&(this._engine.cacheStencilState(),this._engine.setDepthWrite(!1),this._engine.setColorWrite(!1),this._engine.setStencilBuffer(!0),this._engine.setStencilOperationPass(7681),this._engine.setStencilFunction(519),this._engine.setStencilMask(e._StencilReference),this._engine.setStencilFunctionReference(e._StencilReference),this.render(n,r,!0),this._engine.setColorWrite(!0),this._engine.setStencilFunction(517)),this._engine.setDepthWrite(!1),this.render(n,r),this._engine.setDepthWrite(this._savedDepthWrite),i&&i.needAlphaBlending()&&this._engine.restoreStencilState()}},e.prototype._afterRenderingMesh=function(e,t,n){if(e.renderOverlay){var r=this._engine.getAlphaMode(),i=this._engine.alphaState.alphaBlend;this._engine.setAlphaMode(2),this.render(t,n,!0),this._engine.setAlphaMode(r),this._engine.setDepthWrite(this._savedDepthWrite),this._engine.alphaState.alphaBlend=i}e.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(t,n),this._engine.setColorWrite(!0))},e._StencilReference=4,e}();!function(){function e(e,t){this.name=e,this.color=new ko(1,1,1,1),this.width=1,this.height=1,this.angle=0,this.invertU=0,this.invertV=0,this.animations=new Array,this.isPickable=!1,this._animationStarted=!1,this._loopAnimation=!1,this._fromIndex=0,this._toIndex=0,this._delay=0,this._direction=1,this._time=0,this.isVisible=!0,this._manager=t,this._manager.sprites.push(this),this.position=So.Zero()}Object.defineProperty(e.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!0,configurable:!0}),e.prototype.playAnimation=function(e,t,n,r,i){this._fromIndex=e,this._toIndex=t,this._loopAnimation=n,this._delay=r,this._animationStarted=!0,ethis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,(this._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex0?this._fromIndex:this._toIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},e.prototype.dispose=function(){for(var e=0;e0)for(var o=0;o=i.distance))&&(i=s,n))break}}return i||new ds},nl.prototype._internalMultiPickSprites=function(e,t,n){if(!ds)return null;var r=new Array;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}if(this.spriteManagers.length>0)for(var i=0;i0&&(n=i.pickSprite(e,t,this._spritePredicate,!1,i.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite&&n.pickedSprite.actionManager){switch(i._pickedDownSprite=n.pickedSprite,r.button){case 0:n.pickedSprite.actionManager.processTrigger(2,Fo.CreateNewFromSprite(n.pickedSprite,i,r));break;case 1:n.pickedSprite.actionManager.processTrigger(4,Fo.CreateNewFromSprite(n.pickedSprite,i,r));break;case 2:n.pickedSprite.actionManager.processTrigger(3,Fo.CreateNewFromSprite(n.pickedSprite,i,r))}n.pickedSprite.actionManager&&n.pickedSprite.actionManager.processTrigger(5,Fo.CreateNewFromSprite(n.pickedSprite,i,r))}return n},e.prototype._pointerUp=function(e,t,n,r){var i=this.scene;if(i.spriteManagers.length>0){var o=i.pickSprite(e,t,this._spritePredicate,!1,i.cameraToUseForPointers||void 0);o&&(o.hit&&o.pickedSprite&&o.pickedSprite.actionManager&&(o.pickedSprite.actionManager.processTrigger(7,Fo.CreateNewFromSprite(o.pickedSprite,i,r)),o.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||o.pickedSprite.actionManager.processTrigger(1,Fo.CreateNewFromSprite(o.pickedSprite,i,r)))),i._pickedDownSprite&&i._pickedDownSprite.actionManager&&i._pickedDownSprite!==o.pickedSprite&&i._pickedDownSprite.actionManager.processTrigger(16,Fo.CreateNewFromSprite(i._pickedDownSprite,i,r)))}return n},e}(),DA="uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest)\n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\ngl_FragColor=color;\n}";Qc.a.ShadersStore.spritesPixelShader=DA;var BA="\nattribute vec4 position;\nattribute vec4 options;\nattribute vec2 inverts;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include\nvoid main(void) {\nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;\nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0);\n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));\nvec2 uvPlace=cellInfo.xy;\nvec2 uvSize=cellInfo.zw;\nvUV.x=uvPlace.x+uvSize.x*uvOffset.x;\nvUV.y=uvPlace.y+uvSize.y*uvOffset.y;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}";Qc.a.ShadersStore.spritesVertexShader=BA;var FA=function(){function e(e,t,n,r,i,o,a,s,l){if(void 0===o&&(o=.01),void 0===a&&(a=Wl.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=!1),void 0===l&&(l=null),this.name=e,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.fogEnabled=!0,this.isPickable=!1,this._packedAndReady=!1,this.onDisposeObservable=new yo.a,this._vertexBuffers={},this._blendMode=2,this.disableDepthWrite=!1,i._getComponent(Gs.NAME_SPRITE)||i._addComponent(new kA(i)),this._capacity=n,this._fromPacked=s,this._spriteTexture=new Wl(t,i,!0,!1,a),this._spriteTexture.wrapU=Wl.CLAMP_ADDRESSMODE,this._spriteTexture.wrapV=Wl.CLAMP_ADDRESSMODE,r.width&&r.height)this.cellWidth=r.width,this.cellHeight=r.height;else{if(void 0===r)return;this.cellWidth=r,this.cellHeight=r}this._epsilon=o,this._scene=i,this._scene.spriteManagers.push(this);for(var c=[],u=0,d=0;d0);var u=e.substring(0,c-1)+".json",d=new XMLHttpRequest;d.open("GET",u,!0),d.onerror=function(){jo.a.Error("JSON ERROR: Unable to load JSON file."),n._fromPacked=!1,n._packedAndReady=!1},d.onload=function(){try{var e=JSON.parse(d.response),t=Reflect.ownKeys(e.frames);n._spriteMap=t,n._packedAndReady=!0,n._cellData=e.frames}catch(e){throw n._fromPacked=!1,n._packedAndReady=!1,new Error("Invalid JSON format. Please check documentation for format specifications.")}},d.send()}},e.prototype._appendSpriteVertex=function(e,t,n,r,i){var o=18*e;if(0===n?n=this._epsilon:1===n&&(n=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),this._vertexData[o]=t.position.x,this._vertexData[o+1]=t.position.y,this._vertexData[o+2]=t.position.z,this._vertexData[o+3]=t.angle,this._vertexData[o+4]=t.width,this._vertexData[o+5]=t.height,this._vertexData[o+6]=n,this._vertexData[o+7]=r,this._vertexData[o+8]=t.invertU?1:0,this._vertexData[o+9]=t.invertV?1:0,this._packedAndReady){t.cellRef||(t.cellIndex=0);var a=t.cellIndex;"number"==typeof a&&isFinite(a)&&Math.floor(a)===a&&(t.cellRef=this._spriteMap[t.cellIndex]),this._vertexData[o+10]=this._cellData[t.cellRef].frame.x/i.width,this._vertexData[o+11]=this._cellData[t.cellRef].frame.y/i.height,this._vertexData[o+12]=this._cellData[t.cellRef].frame.w/i.width,this._vertexData[o+13]=this._cellData[t.cellRef].frame.h/i.height}else{t.cellIndex||(t.cellIndex=0);var s=i.width/this.cellWidth,l=t.cellIndex/s>>0;this._vertexData[o+10]=(t.cellIndex-l*s)*this.cellWidth/i.width,this._vertexData[o+11]=l*this.cellHeight/i.height,this._vertexData[o+12]=this.cellWidth/i.width,this._vertexData[o+13]=this.cellHeight/i.height}this._vertexData[o+14]=t.color.r,this._vertexData[o+15]=t.color.g,this._vertexData[o+16]=t.color.b,this._vertexData[o+17]=t.color.a},e.prototype.intersects=function(e,t,n,r){for(var i=Math.min(this._capacity,this.sprites.length),o=So.Zero(),a=So.Zero(),s=Number.MAX_VALUE,l=null,c=Mo.Vector3[0],u=Mo.Vector3[1],d=t.getViewMatrix(),h=0;hf&&(s=f,l=p,r))break}}}if(l){var m=new ds;d.invertToRef(Mo.Matrix[0]),m.hit=!0,m.pickedSprite=l,m.distance=s;var g=Mo.Vector3[2];return g.copyFrom(e.direction),g.normalize(),g.scaleInPlace(s),e.origin.addToRef(g,c),m.pickedPoint=So.TransformCoordinates(c,Mo.Matrix[0]),m}return null},e.prototype.multiIntersects=function(e,t,n){for(var r,i=Math.min(this._capacity,this.sprites.length),o=So.Zero(),a=So.Zero(),s=[],l=Mo.Vector3[0].copyFromFloats(0,0,0),c=Mo.Vector3[1].copyFromFloats(0,0,0),u=t.getViewMatrix(),d=0;d0.) {\nmt=mod(time*animationData.z,1.0);\nfor(float f=0.; fmt){\nframeID=animationData.x;\nbreak;\n}\nanimationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);\n}\n}\n\nmat4 frameData=getFrameData(frameID+0.5);\nvec2 frameSize=(frameData[0].wz)/spriteMapSize;\nvec2 offset=frameData[0].xy*sheetUnits;\nvec2 ratio=frameData[2].xy/frameData[0].wz;\n\nif (frameData[2].z == 1.){\ntileUV.xy=tileUV.yx;\n}\nif (i == 0){\ncolor=texture2D(spriteSheet,tileUV*frameSize+offset);\n} else {\nvec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);\nfloat alpha=min(color.a+nc.a,1.0);\nvec3 mixed=mix(color.xyz,nc.xyz,nc.a);\ncolor=vec4(mixed,alpha);\n}\n}\ncolor.xyz*=colorMul;\ngl_FragColor=color;\n}";Qc.a.ShadersStore.spriteMapPixelShader=NA;var LA="precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nvarying vec3 vPosition;\nvarying vec2 vUV;\nvarying vec2 tUV;\nvarying vec2 stageUnits;\nvarying vec2 levelUnits;\nvarying vec2 tileID;\n\nuniform float time;\nuniform mat4 worldViewProjection;\nuniform vec2 outputSize;\nuniform vec2 stageSize;\nuniform vec2 spriteMapSize;\nuniform float stageScale;\nvoid main() {\nvec4 p=vec4( position,1. );\nvPosition=p.xyz;\nvUV=uv;\ntUV=uv*stageSize;\ngl_Position=worldViewProjection*p;\n}";Qc.a.ShadersStore.spriteMapVertexShader=LA;var UA;(function(){function e(e,t,n,r,i){var o=this;this.name=e,this.sprites=[],this.atlasJSON=t,this.sprites=this.atlasJSON.frames,this.spriteSheet=n,this.options=r,r.stageSize=r.stageSize||new Co(1,1),r.outputSize=r.outputSize||r.stageSize,r.outputPosition=r.outputPosition||So.Zero(),r.outputRotation=r.outputRotation||So.Zero(),r.layerCount=r.layerCount||1,r.maxAnimationFrames=r.maxAnimationFrames||0,r.baseTile=r.baseTile||0,r.flipU=r.flipU||!1,r.colorMultiply=r.colorMultiply||new So(1,1,1),this._scene=i,this._frameMap=this._createFrameBuffer(),this._tileMaps=new Array;for(var a=0;a0&&(e+="\n\r"),e+=this._tileMaps[t]._texture._bufferView.toString();var n=document.createElement("a");n.href="data:octet/stream;charset=utf-8,"+encodeURI(e),n.target="_blank",n.download=this.name+".tilemaps",n.click(),n.remove()},e.prototype.loadTileMaps=function(e){var t=this,n=new XMLHttpRequest;n.open("GET",e);var r=this.options.layerCount||0;n.onload=function(){for(var e=n.response.split("\n\r"),i=0;i-1&&this._tasks.splice(t,1)},e.prototype._decreaseWaitingTasksCount=function(e){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,e),this.onProgressObservable.notifyObservers(new jA(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){jo.a.Error("Error running progress callbacks."),console.log(e)}if(0===this._waitingTasksCount){try{var t=this._tasks.slice();this.onFinish&&this.onFinish(t);for(var n=0,r=t;n-1&&this._tasks.splice(i,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(e){jo.a.Error("Error running tasks-done callbacks."),console.log(e)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}},e.prototype._runTask=function(e){var t=this,n=function(n,r){e._setErrorObject(n,r),t.onTaskError&&t.onTaskError(e),t.onTaskErrorObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)};e.run(this._scene,(function(){try{t.onTaskSuccess&&t.onTaskSuccess(e),t.onTaskSuccessObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)}catch(e){n("Error executing task success callbacks",e)}}),n)},e.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},e.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,0===this._waitingTasksCount)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e=0&&this._meshes.splice(n,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var r=0;r0&&this._textureLoadingCallback(e)}this._currentScene.render()}},e.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},e.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},e.prototype._traverseFolder=function(e,t,n,r){var i=this,o=e.createReader(),a=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");o.readEntries((function(e){n.count+=e.length;for(var o=0,s=e;o0)){for(var n=new Array,r=[],i=e.dataTransfer?e.dataTransfer.items:null,o=0;o0&&jo.a.ClearLogCache(),this._engine.stopRenderLoop()),Ph.LoadAsync("file:",this._sceneFileToLoad,this._engine,(function(t){e._progressCallback&&e._progressCallback(t)})).then((function(t){e._currentScene&&e._currentScene.dispose(),e._currentScene=t,e._sceneLoadedCallback&&e._sceneLoadedCallback(e._sceneFileToLoad,e._currentScene),e._currentScene.executeWhenReady((function(){e._engine.runRenderLoop((function(){e.renderFunction()}))}))})).catch((function(t){e._errorCallback&&e._errorCallback(e._sceneFileToLoad,e._currentScene,t.message)}))):jo.a.Error("Please provide a valid .babylon file.")}}(),n(82),function(){function e(e){void 0===e&&(e=0),this.priority=e}return e.prototype.getDescription=function(){return""},e.prototype.apply=function(e,t){return!0},e}()),$A=function(e){function t(t,n,r){void 0===t&&(t=0),void 0===n&&(n=1024),void 0===r&&(r=.5);var i=e.call(this,t)||this;return i.priority=t,i.maximumSize=n,i.step=r,i}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,t){for(var n=!0,r=0;rthis.maximumSize&&(i.scale(this.step),n=!1)}}return n},t}(JA),e_=function(e){function t(t,n,r){void 0===t&&(t=0),void 0===n&&(n=2),void 0===r&&(r=.25);var i=e.call(this,t)||this;return i.priority=t,i.maximumScale=n,i.step=r,i._currentScale=-1,i._directionOffset=1,i}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},t.prototype.apply=function(e,t){return-1===this._currentScale&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),1===this._directionOffset?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(JA),t_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0},t}(JA),n_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning post-processes on/off"},t.prototype.apply=function(e,t){return e.postProcessesEnabled=t.isInImprovementMode,!0},t}(JA),r_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning lens flares on/off"},t.prototype.apply=function(e,t){return e.lensFlaresEnabled=t.isInImprovementMode,!0},t}(JA),i_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"},t.prototype.apply=function(e,t){return!this.onApply||this.onApply(e,t)},t}(JA),o_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,t){return e.particlesEnabled=t.isInImprovementMode,!0},t}(JA),a_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(No.d)(t,e),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0},t}(JA),s_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof Pl))return!1;var t=e;return!t.isDisposed()&&(!(!t.isVisible||!t.isEnabled())&&(!(t.instances.length>0)&&(!t.skeleton&&!t.hasLODLevels)))},t}return Object(No.d)(t,e),Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,n,r){for(var i=e.meshes.slice(0),o=i.length,a=0;a=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var r=!0,i=!0,o=0;o0){o.animationGroups=[];for(var d=0;d0)for(o.reflectionProbes=[],n=0;n0&&setTimeout((function(){n.stopRecording()}),1e3*t),this._fileName=e,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise((function(e,t){n._resolve=e,n._reject=t}))},e.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},e.prototype._handleDataAvailable=function(e){e.data.size>0&&this._recordedChunks.push(e.data)},e.prototype._handleError=function(e){if(this.stopRecording(),!this._reject)throw new e.error;this._reject(e.error)},e.prototype._handleStop=function(){this.stopRecording();var e=new Blob(this._recordedChunks);this._resolve&&this._resolve(e),window.URL.createObjectURL(e),this._fileName&&Ja.Download(e,this._fileName)},e._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3}}(),function(){function e(){}return e.CreateScreenshot=function(t,n,r,i,o){void 0===o&&(o="image/png");var a=e._getScreenshotSize(t,n,r),s=a.height,l=a.width;if(s&&l){Ja._ScreenshotCanvas||(Ja._ScreenshotCanvas=document.createElement("canvas")),Ja._ScreenshotCanvas.width=l,Ja._ScreenshotCanvas.height=s;var c=Ja._ScreenshotCanvas.getContext("2d"),u=t.getRenderWidth()/t.getRenderHeight(),d=l,h=d/u;h>s&&(d=(h=s)*u);var p=Math.max(0,l-d)/2,f=Math.max(0,s-h)/2,m=t.getRenderingCanvas();c&&m&&c.drawImage(m,p,f,d,h),Ja.EncodeScreenshotCanvasData(i,o)}else jo.a.Error("Invalid 'size' parameter !")},e.CreateScreenshotAsync=function(t,n,r,i){return void 0===i&&(i="image/png"),new Promise((function(o,a){e.CreateScreenshot(t,n,r,(function(e){void 0!==e?o(e):a(new Error("Data is undefined"))}),i)}))},e.CreateScreenshotUsingRenderTarget=function(t,n,r,i,o,a,s,l,c){void 0===o&&(o="image/png"),void 0===a&&(a=1),void 0===s&&(s=!1),void 0===c&&(c=!1);var u=e._getScreenshotSize(t,n,r),d=u.height,h=u.width,p={width:h,height:d};if(d&&h){var f=n.getScene(),m=null;f.activeCamera!==n&&(m=f.activeCamera,f.activeCamera=n);var g=t.getRenderingCanvas();if(g){var b={width:g.width,height:g.height};t.setSize(h,d),f.render();var v=new mu("screenShot",p,f,!1,!1,0,!1,Wl.NEAREST_SAMPLINGMODE);v.renderList=null,v.samples=a,v.renderSprites=c,v.onAfterRenderObservable.add((function(){Ja.DumpFramebuffer(h,d,t,i,o,l)}));var A=function(){f.incrementRenderId(),f.resetCachedMaterial(),v.render(!0),v.dispose(),m&&(f.activeCamera=m),t.setSize(b.width,b.height),n.getProjectionMatrix(!0)};if(s){var _=new Qv("antialiasing",1,f.activeCamera);v.addPostProcess(_),_.getEffect().isReady()?A():_.getEffect().onCompiled=function(){A()}}else A()}else jo.a.Error("No rendering canvas found !")}else jo.a.Error("Invalid 'size' parameter !")},e.CreateScreenshotUsingRenderTargetAsync=function(t,n,r,i,o,a,s,l){return void 0===i&&(i="image/png"),void 0===o&&(o=1),void 0===a&&(a=!1),void 0===l&&(l=!1),new Promise((function(c,u){e.CreateScreenshotUsingRenderTarget(t,n,r,(function(e){void 0!==e?c(e):u(new Error("Data is undefined"))}),i,o,a,s,l)}))},e._getScreenshotSize=function(e,t,n){var r=0,i=0;if("object"==typeof n){var o=n.precision?Math.abs(n.precision):1;n.width&&n.height?(r=n.height*o,i=n.width*o):n.width&&!n.height?(i=n.width*o,r=Math.round(i/e.getAspectRatio(t))):n.height&&!n.width?(r=n.height*o,i=Math.round(r*e.getAspectRatio(t))):(i=Math.round(e.getRenderWidth()*o),r=Math.round(i/e.getAspectRatio(t)))}else isNaN(n)||(r=n,i=n);return i&&(i=Math.floor(i)),r&&(r=Math.floor(r)),{height:0|r,width:0|i}},e}());Ja.CreateScreenshot=h_.CreateScreenshot,Ja.CreateScreenshotAsync=h_.CreateScreenshotAsync,Ja.CreateScreenshotUsingRenderTarget=h_.CreateScreenshotUsingRenderTarget,Ja.CreateScreenshotUsingRenderTargetAsync=h_.CreateScreenshotUsingRenderTargetAsync,function(e){e[e.Checkbox=0]="Checkbox",e[e.Slider=1]="Slider",e[e.Vector3=2]="Vector3",e[e.Quaternion=3]="Quaternion",e[e.Color3=4]="Color3",e[e.String=5]="String"}(VA||(VA={}));var p_=function(){function e(e){this.byteOffset=0,this.buffer=e}return e.prototype.loadAsync=function(e){var t=this;return delete this._dataView,delete this._dataByteOffset,this.buffer.readAsync(this.byteOffset,e).then((function(e){t._dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),t._dataByteOffset=0}))},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,e},e.prototype.readUint8Array=function(e){var t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,e);return this._dataByteOffset+=e,this.byteOffset+=e,t},e.prototype.readString=function(e){return Jo.a.Decode(this.readUint8Array(e))},e.prototype.skipBytes=function(e){this._dataByteOffset+=e,this.byteOffset+=e},e}(),f_=function(e){function t(n,r){void 0===r&&(r={});var i=e.call(this,n)||this;return i.options=r,i._direction=new So(0,0,-1),i._mat=new Oo,i._onSelectEnabled=!1,i._origin=new So(0,0,0),i.lastNativeXRHitResults=[],i.onHitTestResultObservable=new yo.a,i._onHitTestResults=function(e){var t=e.map((function(e){var t=Oo.FromArray(e.hitMatrix);return i._xrSessionManager.scene.useRightHandedSystem||t.toggleModelMatrixHandInPlace(),i.options.worldParentNode&&t.multiplyToRef(i.options.worldParentNode.getWorldMatrix(),t),{xrHitResult:e,transformationMatrix:t}}));i.lastNativeXRHitResults=e,i.onHitTestResultObservable.notifyObservers(t)},i._onSelect=function(e){i._onSelectEnabled&&t.XRHitTestWithSelectEvent(e,i._xrSessionManager.referenceSpace)},i}return Object(No.d)(t,e),t.XRHitTestWithRay=function(e,t,n,r){return e.requestHitTest(t,n).then((function(e){var t=r||function(e){return!!e.hitMatrix};return e.filter(t)}))},t.XRHitTestWithSelectEvent=function(e,t){var n=e.frame.getPose(e.inputSource.targetRaySpace,t);if(!n)return Promise.resolve([]);var r=new XRRay(n.transform);return this.XRHitTestWithRay(e.frame.session,r,t)},t.prototype.attach=function(){return!!e.prototype.attach.call(this)&&(this.options.testOnPointerDownOnly&&this._xrSessionManager.session.addEventListener("select",this._onSelect,!1),!0)},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._onSelectEnabled=!1,this._xrSessionManager.session.removeEventListener("select",this._onSelect),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){if(this.attached&&!this.options.testOnPointerDownOnly){var n=e.getViewerPose(this._xrSessionManager.referenceSpace);if(n){Oo.FromArrayToRef(n.transform.matrix,0,this._mat),So.TransformCoordinatesFromFloatsToRef(0,0,0,this._mat,this._origin),So.TransformCoordinatesFromFloatsToRef(0,0,-1,this._mat,this._direction),this._direction.subtractInPlace(this._origin),this._direction.normalize();var r=new XRRay({x:this._origin.x,y:this._origin.y,z:this._origin.z,w:0},{x:this._direction.x,y:this._direction.y,z:this._direction.z,w:0});t.XRHitTestWithRay(this._xrSessionManager.session,r,this._xrSessionManager.referenceSpace).then(this._onHitTestResults)}}},t.Name=Kp.HIT_TEST,t.Version=1,t}(af);Xp.AddWebXRFeature(f_.Name,(function(e,t){return function(){return new f_(e,t)}}),f_.Version,!0);var m_=0,g_=(function(e){function t(t,n){void 0===n&&(n={});var r=e.call(this,t)||this;return r._options=n,r._enabled=!1,r._lastFrameDetected=new Set,r._onSelect=function(e){if(r._options.addAnchorOnSelect){var t=function(e){if(e.length){var t=e[0],n=new XRRigidTransform(t.hitMatrix);r.addAnchorAtRigidTransformation(n)}};r._hitTestModule&&!r._hitTestModule.options.testOnPointerDownOnly&&t(r._hitTestModule.lastNativeXRHitResults),f_.XRHitTestWithSelectEvent(e,r._xrSessionManager.referenceSpace).then(t),r._planeDetector}},r._trackedAnchors=[],r.onAnchorAddedObservable=new yo.a,r.onAnchorRemovedObservable=new yo.a,r.onAnchorUpdatedObservable=new yo.a,r}Object(No.d)(t,e),t.prototype.addAnchorAtRigidTransformation=function(e,t){return(t||this._xrSessionManager.session).createAnchor(e,this._xrSessionManager.referenceSpace)},t.prototype.attach=function(){return!!e.prototype.attach.call(this)&&(this._options.addAnchorOnSelect&&this._xrSessionManager.session.addEventListener("select",this._onSelect,!1),!0)},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._xrSessionManager.session.removeEventListener("select",this._onSelect),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onAnchorAddedObservable.clear(),this.onAnchorRemovedObservable.clear(),this.onAnchorUpdatedObservable.clear()},t.prototype.setHitTestModule=function(e){this._hitTestModule=e},t.prototype.setPlaneDetector=function(e,t){void 0===t&&(t=!0),this._planeDetector=e,this._options.usePlaneDetection=t},t.prototype._onXRFrame=function(e){var t=this;if(this.attached&&this._enabled&&e){var n=e.trackedAnchors;n&&n.size&&(this._trackedAnchors.filter((function(e){return!n.has(e.xrAnchor)})).map((function(e){var n=t._trackedAnchors.indexOf(e);t._trackedAnchors.splice(n,1),t.onAnchorRemovedObservable.notifyObservers(e)})),n.forEach((function(n){if(t._lastFrameDetected.has(n)){if(n.lastChangedTime===t._xrSessionManager.currentTimestamp){var r=t._findIndexInAnchorArray(n),i=t._trackedAnchors[r];t._updateAnchorWithXRFrame(n,i,e),t.onAnchorUpdatedObservable.notifyObservers(i)}}else{var o={id:m_++,xrAnchor:n},a=t._updateAnchorWithXRFrame(n,o,e);t._trackedAnchors.push(a),t.onAnchorAddedObservable.notifyObservers(a)}})),this._lastFrameDetected=n)}},t.prototype._findIndexInAnchorArray=function(e){for(var t=0;t0)throw new Error("Incompatible minimum version: "+n.minVersion)}var o={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!o)throw new Error("Unsupported version: "+n.version);return o(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: "+e.length);var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new Error("Unexpected magic: "+n);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: "+r);var i,o=e.readUint32();if(0!=e.buffer.byteLength&&o!==e.buffer.byteLength)throw new Error("Length in header does not match actual data length: "+o+" != "+e.buffer.byteLength);switch(r){case 1:i=t._unpackBinaryV1Async(e,o);break;case 2:i=t._unpackBinaryV2Async(e,o);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),i}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: "+r);var i=t-e.byteOffset,o={json:this._parseJson(e.readString(n)),bin:null};if(0!==i){var a=e.byteOffset;o.bin={readAsync:function(t,n){return e.buffer.readAsync(a+t,n)},byteLength:i}}return Promise.resolve(o)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,i=5130562,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},s=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case i:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(s):Promise.resolve(a)};return s()}))},e._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},e._compareVersion=function(e,t){return e.major>t.major?1:e.majort.minor?1:e.minor "+R_[R_.READY],i=R_[R_.LOADING]+" => "+R_[R_.COMPLETE];n._parent._startPerformanceCounter(r),n._parent._startPerformanceCounter(i),n._setState(R_.LOADING),n._extensionsOnLoading();var o=new Array,a=n._babylonScene.blockMaterialDirtyMechanism;if(n._babylonScene.blockMaterialDirtyMechanism=!0,e)o.push(n.loadSceneAsync("/nodes",{nodes:e,index:-1}));else if(null!=n._gltf.scene||n._gltf.scenes&&n._gltf.scenes[0]){var s=k_.Get("/scene",n._gltf.scenes,n._gltf.scene||0);o.push(n.loadSceneAsync("/scenes/"+s.index,s))}n._babylonScene.blockMaterialDirtyMechanism=a,n._parent.compileMaterials&&o.push(n._compileMaterialsAsync()),n._parent.compileShadowGenerators&&o.push(n._compileShadowGeneratorsAsync());var l=Promise.all(o).then((function(){return n._rootBabylonMesh&&n._rootBabylonMesh.setEnabled(!0),n._setState(R_.READY),n._extensionsOnReady(),n._startAnimations(),t()}));return l.then((function(){n._parent._endPerformanceCounter(r),Ja.SetImmediate((function(){n._disposed||Promise.all(n._completePromises).then((function(){n._parent._endPerformanceCounter(i),n._setState(R_.COMPLETE),n._parent.onCompleteObservable.notifyObservers(void 0),n._parent.onCompleteObservable.clear(),n.dispose()}),(function(e){n._parent.onErrorObservable.notifyObservers(e),n._parent.onErrorObservable.clear(),n.dispose()}))}))})),l}),(function(e){throw n._disposed||(n._parent.onErrorObservable.notifyObservers(e),n._parent.onErrorObservable.clear(),n.dispose()),e}))},e.prototype._loadData=function(e){if(this._gltf=e.json,this._setupData(),e.bin){var t=this._gltf.buffers;if(t&&t[0]&&!t[0].uri){var n=t[0];(n.byteLengthe.bin.byteLength)&&jo.a.Warn("Binary buffer length ("+n.byteLength+") from JSON does not match chunk length ("+e.bin.byteLength+")"),this._bin=e.bin}else jo.a.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(k_.Assign(this._gltf.accessors),k_.Assign(this._gltf.animations),k_.Assign(this._gltf.buffers),k_.Assign(this._gltf.bufferViews),k_.Assign(this._gltf.cameras),k_.Assign(this._gltf.images),k_.Assign(this._gltf.materials),k_.Assign(this._gltf.meshes),k_.Assign(this._gltf.nodes),k_.Assign(this._gltf.samplers),k_.Assign(this._gltf.scenes),k_.Assign(this._gltf.skins),k_.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t=2)throw new Error(t+"/texCoord: Invalid value ("+n.texCoord+")");var a=k_.Get(t+"/index",this._gltf.textures,n.index),s=this._loadTextureAsync("/textures/"+n.index,a,(function(o){o.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(o,t),i._parent.onTextureLoadedObservable.notifyObservers(o),r(o)}));return this.logClose(),s},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var i=this._extensionsLoadTextureAsync(t,n,r);if(i)return i;this.logOpen(t+" "+(n.name||""));var o=null==n.sampler?e.DefaultSampler:k_.Get(t+"/sampler",this._gltf.samplers,n.sampler),a=k_.Get(t+"/source",this._gltf.images,n.source),s=this._createTextureAsync(t,o,a,r);return this.logClose(),s},e.prototype._createTextureAsync=function(e,t,n,r){var i=this;void 0===r&&(r=function(){});var o=this._loadSampler("/samplers/"+t.index,t),a=new Array,s=new ZA;this._babylonScene._blockEntityCollection=this._forAssetContainer;var l=new Wl(null,this._babylonScene,o.noMipMaps,!1,o.samplingMode,(function(){i._disposed||s.resolve()}),(function(t,n){i._disposed||s.reject(new Error(e+": "+(n&&n.message?n.message:t||"Failed to load texture")))}),void 0,void 0,void 0,n.mimeType);return this._babylonScene._blockEntityCollection=!1,a.push(s.promise),a.push(this.loadImageAsync("/images/"+n.index,n).then((function(e){var t=n.uri||i._fileName+"#image"+n.index,r="data:"+i._uniqueRootUrl+t;l.updateURL(r,e)}))),l.wrapU=o.wrapU,l.wrapV=o.wrapV,r(l),Promise.all(a).then((function(){return l}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode(t+"/wrapS",n.wrapS),wrapV:e._GetTextureWrapMode(t+"/wrapT",n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen(e+" "+(t.name||"")),t.uri)t._data=this.loadUriAsync(e+"/uri",t,t.uri);else{var n=k_.Get(e+"/bufferView",this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/"+n.index,n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,r){var i=this,o=this._extensionsLoadUriAsync(t,n,r);if(o)return o;if(!e._ValidateUri(r))throw new Error(t+": '"+r+"' is invalid");if(Ja.IsBase64(r)){var a=new Uint8Array(Ja.DecodeBase64(r));return this.log("Decoded "+r.substr(0,64)+"... ("+a.length+" bytes)"),Promise.resolve(a)}return this.log("Loading "+r),this._parent.preprocessUrlAsync(this._rootUrl+r).then((function(e){return new Promise((function(n,o){if(!i._disposed){var a=Ja.LoadFile(e,(function(e){if(!i._disposed){var t=new Uint8Array(e);i.log("Loaded "+r+" ("+t.length+" bytes)"),n(t)}}),(function(e){if(!i._disposed&&(a&&(a._lengthComputable=e.lengthComputable,a._loaded=e.loaded,a._total=e.total),i._state===R_.LOADING))try{i._onProgress()}catch(e){o(e)}}),i._babylonScene.offlineProvider,!0,(function(e,n){i._disposed||o(new ja(t+": Failed to load '"+r+"'"+(e?": "+e.status+" "+e.statusText:""),e))}));i._requests.push(a)}}))}))},e.prototype._onProgress=function(){if(this._progressCallback){for(var e=!0,t=0,n=0,r=0,i=this._requests;re.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}(i.current);try{for(r.s();!(e=r.n()).done;){e.value.dispose(!1,!0)}}catch(e){r.e(e)}finally{r.f()}var o=n.bubbles.map((function(e,r){var i=e.map((function(e){return new So(e[0],0,e[1])})),o=Eb.CreatePolygon("bubble-".concat(r),{sideOrientation:Pl.DOUBLESIDE,shape:i,depth:5},t);o.position.y=4;var a=new hd("bubble-".concat(r,"-material"),t);return a.diffuseColor=N_(ko,V_(n.scene_colors.bubble_line)),a.specularColor=new Io(0,0,0),a.alpha=n.scene_colors.bubble_line[3],o.material=a,o}));i.current=o}),[t,JSON.stringify(n.bubbles)]),null}function H_(e){var t=e.scene,n=e.roadNetworkBbox,i=e.egoView;if(null==t)return null;var o=Object(r.useRef)(),a=Object(r.useRef)(),s=t.getEngine().getRenderingCanvas();if(!o.current){var l=new as("ego-camera-root");l.position=new So.Zero,new Gc("ego-camera",new So(0,5,-15),t).parent=l,o.current=l}if(!a.current){var c=new Sc("third-person-camera",-Math.PI/2,0,200,new So(0,0,0),t);c.attachControl(s,!0),c.panningSensibility=50,c.lowerRadiusLimit=5,t.activeCamera=c,a.current=c}return Object(r.useEffect)((function(){if(4==n.length){var e=[(n[0]+n[2])/2,(n[1]+n[3])/2],t=a.current;t.target.x=e[0],t.target.z=e[1],t.radius=Math.max(Math.abs(n[0]-n[2]),Math.abs(n[1]-n[3]))}}),[JSON.stringify(n)]),Object(r.useEffect)((function(){var e=o.current,n=a.current;if(i){var r=e.getChildren()[0];t.activeCamera=r,n.detachControl(s)}else n.attachControl(s,!0),t.activeCamera=n}),[i]),null}var Q_=Object.freeze({SOCIAL_VEHICLE:"social_vehicle",SOCIAL_AGENT:"social_agent",AGENT:"agent"}),W_=Object.freeze({BUS:"bus",COACH:"coach",TRUCK:"truck",TRAILER:"trailer",CAR:"car"});function K_(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(!e)return;if("string"==typeof e)return X_(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return X_(e,t)}(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function X_(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function iy(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||oy(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function oy(e,t){if(e){if("string"==typeof e)return ay(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ay(e,t):void 0}}function ay(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function xy(e,t){if(e){if("string"==typeof e)return wy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wy(e,t):void 0}}function wy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function My(e,t){if(e){if("string"==typeof e)return Iy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Iy(e,t):void 0}}function Iy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}(a.current);try{for(r.s();!(e=r.n()).done;){e.value.dispose()}}catch(e){r.e(e)}finally{r.f()}var o=i.map((function(e,r){var i=e.map((function(e){return new So(e[0],.1,e[1])})),o=Eb.CreateDashedLines("lane-divider-".concat(r),{points:i,updatable:!1,dashSize:1,gapSize:2},t);return o.color=Dy(ko,Ny(n.scene_colors.lane_divider)),o}));a.current=o}}),[t,JSON.stringify(i)]),Object(r.useEffect)((function(){if(0!=o.length){null!=s.current&&s.current.dispose();var e=o.map((function(e){return e.map((function(e){return new So(e[0],.1,e[1])}))})),r=Eb.CreateLineSystem("edge-dividers",{lines:e,updatable:!1},t);r.color=Dy(ko,Ny(n.scene_colors.edge_divider)),s.current=r}}),[t,JSON.stringify(o)]),null}var zy,jy=n(119),Gy=n(161),Hy=n.n(Gy),Qy=n(19),Wy=n(15),Ky=n(83),Xy=n.n(Ky),Yy=n(162),qy=n.n(Yy),Zy=n(163),Jy=n.n(Zy);function $y(e){return function(e){if(Array.isArray(e))return ex(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return ex(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ex(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ex(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function sw(e){return function(e){if(Array.isArray(e))return dw(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||uw(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lw(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function cw(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||uw(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function uw(e,t){if(e){if("string"==typeof e)return dw(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dw(e,t):void 0}}function dw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0,"`Slider[step]` should be a positive number in order to make Slider[dots] work.");var a=Object.keys(t).map(parseFloat).sort((function(e,t){return e-t}));if(n&&r)for(var s=i;s<=o;s+=r)-1===a.indexOf(s)&&a.push(s);return a}(0,o,a,s,h,d).map((function(e){var o,a=Math.abs(e-h)/m*100+"%",s=!l&&e===u||l&&e<=u&&e>=c,d=n?vt()({},p,Aw()({},r?"top":"bottom",a)):vt()({},p,Aw()({},r?"right":"left",a));s&&(d=vt()({},d,f));var g=_e()((o={},Aw()(o,t+"-dot",!0),Aw()(o,t+"-dot-active",s),Aw()(o,t+"-dot-reverse",r),o));return i.a.createElement("span",{className:g,style:d,key:e})}));return i.a.createElement("div",{className:t+"-step"},g)},Cw=function(e){var t=e.className,n=e.vertical,r=e.reverse,o=e.marks,a=e.included,s=e.upperBound,l=e.lowerBound,c=e.max,u=e.min,d=e.onClickLabel,h=Object.keys(o),p=c-u,f=h.map(parseFloat).sort((function(e,t){return e-t})).map((function(e){var c,h=o[e],f="object"==typeof h&&!i.a.isValidElement(h),m=f?h.label:h;if(!m&&0!==m)return null;var g=!a&&e===s||a&&e<=s&&e>=l,b=_e()((c={},Aw()(c,t+"-text",!0),Aw()(c,t+"-text-active",g),c)),v=Aw()({marginBottom:"-50%"},r?"top":"bottom",(e-u)/p*100+"%"),A=Aw()({transform:"translateX("+(r?"50%":"-50%")+")",msTransform:"translateX("+(r?"50%":"-50%")+")"},r?"right":"left",(e-u)/p*100+"%"),_=n?v:A,y=f?vt()({},_,h.style):_;return i.a.createElement("span",{className:b,style:y,key:e,onMouseDown:function(t){return d(t,e)},onTouchStart:function(t){return d(t,e)}},m)}));return i.a.createElement("div",{className:t},f)},Sw=function(e){function t(){var e,n,r,i;ti()(this,t);for(var o=arguments.length,a=Array(o),s=0;sr}function Mw(e){return e.touches.length>1||"touchend"===e.type.toLowerCase()&&e.touches.length>0}function Iw(e,t){var n=t.marks,r=t.step,i=t.min,o=t.max,a=Object.keys(n).map(parseFloat);if(null!==r){var s=Math.floor((o-i)/r),l=Math.min((e-i)/r,s),c=Math.round(l)*r+i;a.push(c)}var u=a.map((function(t){return Math.abs(e-t)}));return a[u.indexOf(Math.min.apply(Math,Pw()(u)))]}function kw(e,t){return e?t.clientY:t.pageX}function Dw(e,t){return e?t.touches[0].clientY:t.touches[0].pageX}function Bw(e,t){var n=t.getBoundingClientRect();return e?n.top+.5*n.height:window.pageXOffset+n.left+.5*n.width}function Fw(e,t){var n=t.max,r=t.min;return e<=r?r:e>=n?n:e}function Nw(e,t){var n=t.step,r=isFinite(Iw(e,t))?Iw(e,t):0;return null===n?r:parseFloat(r.toFixed(function(e){var t=e.toString(),n=0;return t.indexOf(".")>=0&&(n=t.length-t.indexOf(".")-1),n}(n)))}function Lw(e){e.stopPropagation(),e.preventDefault()}function Uw(e,t,n){var r="increase";switch(e.keyCode){case Kt.a.UP:r=t&&n?"decrease":"increase";break;case Kt.a.RIGHT:r=!t&&n?"decrease":"increase";break;case Kt.a.DOWN:r=t&&n?"increase":"decrease";break;case Kt.a.LEFT:r=!t&&n?"increase":"decrease";break;case Kt.a.END:return function(e,t){return t.max};case Kt.a.HOME:return function(e,t){return t.min};case Kt.a.PAGE_UP:return function(e,t){return e+2*t.step};case Kt.a.PAGE_DOWN:return function(e,t){return e-2*t.step};default:return}return function(e,t){return function(e,t,n){var r={increase:function(e,t){return e+t},decrease:function(e,t){return e-t}},i=r[e](Object.keys(n.marks).indexOf(JSON.stringify(t)),1),o=Object.keys(n.marks)[i];return n.step?r[e](t,n.step):Object.keys(n.marks).length&&n.marks[o]?n.marks[o]:t}(r,e,t)}}function Vw(){}function zw(e){var t,n;return n=t=function(e){function t(e){ti()(this,t);var n=ri()(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));n.onMouseDown=function(e){if(0===e.button){var t=n.props.vertical,r=kw(t,e);if(Ow(e,n.handlesRefs)){var i=Bw(t,e.target);n.dragOffset=r-i,r=i}else n.dragOffset=0;n.removeDocumentEvents(),n.onStart(r),n.addDocumentMouseEvents()}},n.onTouchStart=function(e){if(!Mw(e)){var t=n.props.vertical,r=Dw(t,e);if(Ow(e,n.handlesRefs)){var i=Bw(t,e.target);n.dragOffset=r-i,r=i}else n.dragOffset=0;n.onStart(r),n.addDocumentTouchEvents(),Lw(e)}},n.onFocus=function(e){var t=n.props,r=t.onFocus,i=t.vertical;if(Ow(e,n.handlesRefs)){var o=Bw(i,e.target);n.dragOffset=0,n.onStart(o),Lw(e),r&&r(e)}},n.onBlur=function(e){var t=n.props.onBlur;n.onEnd(),t&&t(e)},n.onMouseUp=function(){n.handlesRefs[n.prevMovedHandleIndex]&&n.handlesRefs[n.prevMovedHandleIndex].clickFocus()},n.onMouseMove=function(e){if(n.sliderRef){var t=kw(n.props.vertical,e);n.onMove(e,t-n.dragOffset)}else n.onEnd()},n.onTouchMove=function(e){if(!Mw(e)&&n.sliderRef){var t=Dw(n.props.vertical,e);n.onMove(e,t-n.dragOffset)}else n.onEnd()},n.onKeyDown=function(e){n.sliderRef&&Ow(e,n.handlesRefs)&&n.onKeyboard(e)},n.onClickMarkLabel=function(e,t){e.stopPropagation(),n.onChange({value:t}),n.setState({value:t},(function(){return n.onEnd(!0)}))},n.saveSlider=function(e){n.sliderRef=e};var r=e.step,i=e.max,o=e.min,a=!isFinite(i-o)||(i-o)%r==0;return bw()(!r||Math.floor(r)!==r||a,"Slider[max] - Slider[min] (%s) should be a multiple of Slider[step] (%s)",i-o,r),n.handlesRefs={},n}return oi()(t,e),mw()(t,[{key:"componentDidMount",value:function(){this.document=this.sliderRef&&this.sliderRef.ownerDocument;var e=this.props,t=e.autoFocus,n=e.disabled;t&&!n&&this.focus()}},{key:"componentWillUnmount",value:function(){xw()(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"componentWillUnmount",this)&&xw()(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"componentWillUnmount",this).call(this),this.removeDocumentEvents()}},{key:"getSliderStart",value:function(){var e=this.sliderRef,t=this.props,n=t.vertical,r=t.reverse,i=e.getBoundingClientRect();return n?r?i.bottom:i.top:window.pageXOffset+(r?i.right:i.left)}},{key:"getSliderLength",value:function(){var e=this.sliderRef;if(!e)return 0;var t=e.getBoundingClientRect();return this.props.vertical?t.height:t.width}},{key:"addDocumentTouchEvents",value:function(){this.onTouchMoveListener=Object(ww.a)(this.document,"touchmove",this.onTouchMove),this.onTouchUpListener=Object(ww.a)(this.document,"touchend",this.onEnd)}},{key:"addDocumentMouseEvents",value:function(){this.onMouseMoveListener=Object(ww.a)(this.document,"mousemove",this.onMouseMove),this.onMouseUpListener=Object(ww.a)(this.document,"mouseup",this.onEnd)}},{key:"removeDocumentEvents",value:function(){this.onTouchMoveListener&&this.onTouchMoveListener.remove(),this.onTouchUpListener&&this.onTouchUpListener.remove(),this.onMouseMoveListener&&this.onMouseMoveListener.remove(),this.onMouseUpListener&&this.onMouseUpListener.remove()}},{key:"focus",value:function(){this.props.disabled||this.handlesRefs[0].focus()}},{key:"blur",value:function(){var e=this;this.props.disabled||Object.keys(this.handlesRefs).forEach((function(t){e.handlesRefs[t]&&e.handlesRefs[t].blur&&e.handlesRefs[t].blur()}))}},{key:"calcValue",value:function(e){var t=this.props,n=t.vertical,r=t.min,i=t.max,o=Math.abs(Math.max(e,0)/this.getSliderLength());return n?(1-o)*(i-r)+r:o*(i-r)+r}},{key:"calcValueByPos",value:function(e){var t=(this.props.reverse?-1:1)*(e-this.getSliderStart());return this.trimAlignValue(this.calcValue(t))}},{key:"calcOffset",value:function(e){var t=this.props,n=t.min,r=(e-n)/(t.max-n);return Math.max(0,100*r)}},{key:"saveHandle",value:function(e,t){this.handlesRefs[e]=t}},{key:"render",value:function(){var e,n=this.props,r=n.prefixCls,o=n.className,a=n.marks,s=n.dots,l=n.step,c=n.included,u=n.disabled,d=n.vertical,h=n.reverse,p=n.min,f=n.max,m=n.children,g=n.maximumTrackStyle,b=n.style,v=n.railStyle,A=n.dotStyle,_=n.activeDotStyle,y=xw()(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"render",this).call(this),x=y.tracks,w=y.handles,E=_e()(r,(e={},Aw()(e,r+"-with-marks",Object.keys(a).length),Aw()(e,r+"-disabled",u),Aw()(e,r+"-vertical",d),Aw()(e,o,o),e));return i.a.createElement("div",{ref:this.saveSlider,className:E,onTouchStart:u?Vw:this.onTouchStart,onMouseDown:u?Vw:this.onMouseDown,onMouseUp:u?Vw:this.onMouseUp,onKeyDown:u?Vw:this.onKeyDown,onFocus:u?Vw:this.onFocus,onBlur:u?Vw:this.onBlur,style:b},i.a.createElement("div",{className:r+"-rail",style:vt()({},g,v)}),x,i.a.createElement(Ew,{prefixCls:r,vertical:d,reverse:h,marks:a,dots:s,step:l,included:c,lowerBound:this.getLowerBound(),upperBound:this.getUpperBound(),max:f,min:p,dotStyle:A,activeDotStyle:_}),w,i.a.createElement(Cw,{className:r+"-mark",onClickLabel:u?Vw:this.onClickMarkLabel,vertical:d,marks:a,included:c,lowerBound:this.getLowerBound(),upperBound:this.getUpperBound(),max:f,min:p,reverse:h}),m)}}]),t}(e),t.displayName="ComponentEnhancer("+e.displayName+")",t.defaultProps=vt()({},e.defaultProps,{prefixCls:"rc-slider",className:"",min:0,max:100,step:1,marks:{},handle:function(e){var t=e.index,n=$r()(e,["index"]);return delete n.dragging,null===n.value?null:i.a.createElement(Sw,vt()({},n,{key:t}))},onBeforeChange:Vw,onChange:Vw,onAfterChange:Vw,included:!0,disabled:!1,dots:!1,vertical:!1,reverse:!1,trackStyle:[{}],handleStyle:[{}],railStyle:{},dotStyle:{},activeDotStyle:{}}),n}var jw=zw(function(e){function t(e){ti()(this,t);var n=ri()(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));n.onEnd=function(e){var t=n.state.dragging;n.removeDocumentEvents(),(t||e)&&n.props.onAfterChange(n.getValue()),n.setState({dragging:!1})};var r=void 0!==e.defaultValue?e.defaultValue:e.min,i=void 0!==e.value?e.value:r;return n.state={value:n.trimAlignValue(i),dragging:!1},bw()(!("minimumTrackStyle"in e),"minimumTrackStyle will be deprecated, please use trackStyle instead."),bw()(!("maximumTrackStyle"in e),"maximumTrackStyle will be deprecated, please use railStyle instead."),n}return oi()(t,e),mw()(t,[{key:"componentDidUpdate",value:function(e,t){if("value"in this.props||"min"in this.props||"max"in this.props){var n=this.props,r=n.value,i=n.onChange,o=void 0!==r?r:t.value,a=this.trimAlignValue(o,this.props);a!==t.value&&(this.setState({value:a}),Rw(o,this.props)&&i(a))}}},{key:"onChange",value:function(e){var t=this.props,n=!("value"in t),r=e.value>this.props.max?vt()({},e,{value:this.props.max}):e;n&&this.setState(r);var i=r.value;t.onChange(i)}},{key:"onStart",value:function(e){this.setState({dragging:!0});var t=this.props,n=this.getValue();t.onBeforeChange(n);var r=this.calcValueByPos(e);this.startValue=r,this.startPosition=e,r!==n&&(this.prevMovedHandleIndex=0,this.onChange({value:r}))}},{key:"onMove",value:function(e,t){Lw(e);var n=this.state.value,r=this.calcValueByPos(t);r!==n&&this.onChange({value:r})}},{key:"onKeyboard",value:function(e){var t=this.props,n=t.reverse,r=Uw(e,t.vertical,n);if(r){Lw(e);var i=this.state.value,o=r(i,this.props),a=this.trimAlignValue(o);if(a===i)return;this.onChange({value:a}),this.props.onAfterChange(a),this.onEnd()}}},{key:"getValue",value:function(){return this.state.value}},{key:"getLowerBound",value:function(){return this.props.min}},{key:"getUpperBound",value:function(){return this.state.value}},{key:"trimAlignValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null===e)return null;var n=vt()({},this.props,t),r=Fw(e,n);return Nw(r,n)}},{key:"render",value:function(){var e=this,t=this.props,n=t.prefixCls,r=t.vertical,o=t.included,a=t.disabled,s=t.minimumTrackStyle,l=t.trackStyle,c=t.handleStyle,u=t.tabIndex,d=t.ariaLabelForHandle,h=t.ariaLabelledByForHandle,p=t.ariaValueTextFormatterForHandle,f=t.min,m=t.max,g=t.startPoint,b=t.reverse,v=t.handle,A=this.state,_=A.value,y=A.dragging,x=this.calcOffset(_),w=v({className:n+"-handle",prefixCls:n,vertical:r,offset:x,value:_,dragging:y,disabled:a,min:f,max:m,reverse:b,index:0,tabIndex:u,ariaLabel:d,ariaLabelledBy:h,ariaValueTextFormatter:p,style:c[0]||c,ref:function(t){return e.saveHandle(0,t)}}),E=void 0!==g?this.calcOffset(g):0,C=l[0]||l;return{tracks:i.a.createElement(_w,{className:n+"-track",vertical:r,included:o,offset:E,reverse:b,length:x-E,style:vt()({},s,C)}),handles:w}}}]),t}(i.a.Component)),Gw=n(165),Hw=n.n(Gw),Qw=function(e){var t=e.value,n=e.handle,r=e.bounds,i=e.props,o=i.allowCross,a=i.pushable,s=Number(a),l=Fw(t,i),c=l;return o||null==n||void 0===r||(n>0&&l<=r[n-1]+s&&(c=r[n-1]+s),n=r[n+1]-s&&(c=r[n+1]-s)),Nw(c,i)},Ww=function(e){function t(e){ti()(this,t);var n=ri()(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));n.onEnd=function(e){var t=n.state.handle;n.removeDocumentEvents(),(null!==t||e)&&n.props.onAfterChange(n.getValue()),n.setState({handle:null})};var r=e.count,i=e.min,o=e.max,a=Array.apply(void 0,Pw()(Array(r+1))).map((function(){return i})),s="defaultValue"in e?e.defaultValue:a,l=(void 0!==e.value?e.value:s).map((function(t,n){return Qw({value:t,handle:n,props:e})})),c=l[0]===o?0:l.length-1;return n.state={handle:null,recent:c,bounds:l},n}return oi()(t,e),mw()(t,[{key:"componentDidUpdate",value:function(e,t){var n=this;if(("value"in this.props||"min"in this.props||"max"in this.props)&&(this.props.min!==e.min||this.props.max!==e.max||!Hw()(this.props.value,e.value))){var r=this.props,i=r.onChange,o=r.value||t.bounds;if(o.some((function(e){return Rw(e,n.props)})))i(o.map((function(e){return Fw(e,n.props)})))}}},{key:"onChange",value:function(e){var t=this.props;if(!("value"in t))this.setState(e);else{var n={};["handle","recent"].forEach((function(t){void 0!==e[t]&&(n[t]=e[t])})),Object.keys(n).length&&this.setState(n)}var r=vt()({},this.state,e).bounds;t.onChange(r)}},{key:"onStart",value:function(e){var t=this.props,n=this.state,r=this.getValue();t.onBeforeChange(r);var i=this.calcValueByPos(e);this.startValue=i,this.startPosition=e;var o=this.getClosestBound(i);if(this.prevMovedHandleIndex=this.getBoundNeedMoving(i,o),this.setState({handle:this.prevMovedHandleIndex,recent:this.prevMovedHandleIndex}),i!==r[this.prevMovedHandleIndex]){var a=[].concat(Pw()(n.bounds));a[this.prevMovedHandleIndex]=i,this.onChange({bounds:a})}}},{key:"onMove",value:function(e,t){Lw(e);var n=this.state,r=this.calcValueByPos(t);r!==n.bounds[n.handle]&&this.moveTo(r)}},{key:"onKeyboard",value:function(e){var t=this.props,n=t.reverse,r=Uw(e,t.vertical,n);if(r){Lw(e);var i=this.state,o=this.props,a=i.bounds,s=i.handle,l=a[null===s?i.recent:s],c=r(l,o),u=Qw({value:c,handle:s,bounds:i.bounds,props:o});if(u===l)return;this.moveTo(u,!0)}}},{key:"getValue",value:function(){return this.state.bounds}},{key:"getClosestBound",value:function(e){for(var t=this.state.bounds,n=0,r=1;r=t[r]&&(n=r);return Math.abs(t[n+1]-e)=r.length||i<0)return!1;var o=t+n,a=r[i],s=this.props.pushable,l=n*(e[o]-a);return!!this.pushHandle(e,o,n,s-l)&&(e[t]=a,!0)}},{key:"trimAlignValue",value:function(e){var t=this.state,n=t.handle,r=t.bounds;return Qw({value:e,handle:n,bounds:r,props:this.props})}},{key:"render",value:function(){var e=this,t=this.state,n=t.handle,r=t.bounds,o=this.props,a=o.prefixCls,s=o.vertical,l=o.included,c=o.disabled,u=o.min,d=o.max,h=o.reverse,p=o.handle,f=o.trackStyle,m=o.handleStyle,g=o.tabIndex,b=o.ariaLabelGroupForHandles,v=o.ariaLabelledByGroupForHandles,A=o.ariaValueTextFormatterGroupForHandles,_=r.map((function(t){return e.calcOffset(t)})),y=a+"-handle",x=r.map((function(t,r){var i,o=g[r]||0;(c||null===g[r])&&(o=null);var l=n===r;return p({className:_e()((i={},Aw()(i,y,!0),Aw()(i,y+"-"+(r+1),!0),Aw()(i,y+"-dragging",l),i)),prefixCls:a,vertical:s,dragging:l,offset:_[r],value:t,index:r,tabIndex:o,min:u,max:d,reverse:h,disabled:c,style:m[r],ref:function(t){return e.saveHandle(r,t)},ariaLabel:b[r],ariaLabelledBy:v[r],ariaValueTextFormatter:A[r]})}));return{tracks:r.slice(0,-1).map((function(e,t){var n,r=t+1,o=_e()((n={},Aw()(n,a+"-track",!0),Aw()(n,a+"-track-"+r,!0),n));return i.a.createElement(_w,{className:o,vertical:s,reverse:h,included:l,offset:_[r-1],length:_[r]-_[r-1],style:f[t],key:r})})),handles:x}}}],[{key:"getDerivedStateFromProps",value:function(e,t){if("value"in e||"min"in e||"max"in e){var n=(e.value||t.bounds).map((function(n,r){return Qw({value:n,handle:r,bounds:t.bounds,props:e})}));return n.length===t.bounds.length&&n.every((function(e,n){return e===t.bounds[n]}))?null:vt()({},t,{bounds:n})}return null}}]),t}(i.a.Component);Ww.displayName="Range",Ww.defaultProps={count:1,allowCross:!0,pushable:!1,tabIndex:[],ariaLabelGroupForHandles:[],ariaLabelledByGroupForHandles:[],ariaValueTextFormatterGroupForHandles:[]};var Kw=zw(Ww),Xw=n(85),Yw={adjustX:1,adjustY:1},qw=[0,0],Zw={left:{points:["cr","cl"],overflow:Yw,offset:[-4,0],targetOffset:qw},right:{points:["cl","cr"],overflow:Yw,offset:[4,0],targetOffset:qw},top:{points:["bc","tc"],overflow:Yw,offset:[0,-4],targetOffset:qw},bottom:{points:["tc","bc"],overflow:Yw,offset:[0,4],targetOffset:qw},topLeft:{points:["bl","tl"],overflow:Yw,offset:[0,-4],targetOffset:qw},leftTop:{points:["tr","tl"],overflow:Yw,offset:[-4,0],targetOffset:qw},topRight:{points:["br","tr"],overflow:Yw,offset:[0,-4],targetOffset:qw},rightTop:{points:["tl","tr"],overflow:Yw,offset:[4,0],targetOffset:qw},bottomRight:{points:["tr","br"],overflow:Yw,offset:[0,4],targetOffset:qw},rightBottom:{points:["bl","br"],overflow:Yw,offset:[4,0],targetOffset:qw},bottomLeft:{points:["tl","bl"],overflow:Yw,offset:[0,4],targetOffset:qw},leftBottom:{points:["br","bl"],overflow:Yw,offset:[-4,0],targetOffset:qw}},Jw=function(e){var t=e.overlay,n=e.prefixCls,r=e.id;return i.a.createElement("div",{className:"".concat(n,"-inner"),id:r,role:"tooltip"},"function"==typeof t?t():t)};function $w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function eE(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tE(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var nE=Object(r.forwardRef)((function(e,t){var n=e.overlayClassName,o=e.trigger,a=void 0===o?["hover"]:o,s=e.mouseEnterDelay,l=void 0===s?0:s,c=e.mouseLeaveDelay,u=void 0===c?.1:c,d=e.overlayStyle,h=e.prefixCls,p=void 0===h?"rc-tooltip":h,f=e.children,m=e.onVisibleChange,g=e.afterVisibleChange,b=e.transitionName,v=e.animation,A=e.placement,_=void 0===A?"right":A,y=e.align,x=void 0===y?{}:y,w=e.destroyTooltipOnHide,E=void 0!==w&&w,C=e.defaultVisible,S=e.getTooltipContainer,T=tE(e,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer"]),P=Object(r.useRef)(null);Object(r.useImperativeHandle)(t,(function(){return P.current}));var O=function(e){for(var t=1;t=0||i.indexOf("Bottom")>=0?a.top="".concat(o.height-n.offset[1],"px"):(i.indexOf("Top")>=0||i.indexOf("bottom")>=0)&&(a.top="".concat(-n.offset[1],"px")),i.indexOf("left")>=0||i.indexOf("Right")>=0?a.left="".concat(o.width-n.offset[0],"px"):(i.indexOf("right")>=0||i.indexOf("Left")>=0)&&(a.left="".concat(-n.offset[0],"px")),e.style.transformOrigin="".concat(a.left," ").concat(a.top)},t.renderTooltip=function(e){var n=e.getPopupContainer,i=e.getPrefixCls,o=e.direction,a=pE(t),s=a.props,l=a.state,c=s.prefixCls,u=s.openClassName,d=s.getPopupContainer,h=s.getTooltipContainer,p=s.overlayClassName,f=s.children,m=i("tooltip",c),g=l.visible;"visible"in s||!t.isNoTitle()||(g=!1);var b=bE(r.isValidElement(f)?f:r.createElement("span",null,f),m),v=b.props,A=_e()(v.className,cE({},u||"".concat(m,"-open"),!0)),_=_e()(p,cE({},"".concat(m,"-rtl"),"rtl"===o));return r.createElement(nE,gE({},t.props,{prefixCls:m,overlayClassName:_,getTooltipContainer:d||h||n,ref:t.saveTooltip,builtinPlacements:t.getPlacements(),overlay:t.getOverlay(),visible:g,onVisibleChange:t.onVisibleChange,onPopupAlign:t.onPopupAlign}),g?r.cloneElement(b,{className:A}):b)},t.state={visible:!!e.visible||!!e.defaultVisible},t}return n=s,o=[{key:"getDerivedStateFromProps",value:function(e){return"visible"in e?{visible:e.visible}:null}}],(i=[{key:"getPopupDomNode",value:function(){return this.tooltip.getPopupDomNode()}},{key:"getPlacements",value:function(){var e=this.props,t=e.builtinPlacements,n=e.arrowPointAtCenter,r=e.autoAdjustOverflow;return t||function(e){var t=e.arrowWidth,n=void 0===t?5:t,r=e.horizontalArrowShift,i=void 0===r?16:r,o=e.verticalArrowShift,a=void 0===o?8:o,s=e.autoAdjustOverflow,l={left:{points:["cr","cl"],offset:[-4,0]},right:{points:["cl","cr"],offset:[4,0]},top:{points:["bc","tc"],offset:[0,-4]},bottom:{points:["tc","bc"],offset:[0,4]},topLeft:{points:["bl","tc"],offset:[-(i+n),-4]},leftTop:{points:["tr","cl"],offset:[-4,-(a+n)]},topRight:{points:["br","tc"],offset:[i+n,-4]},rightTop:{points:["tl","cr"],offset:[4,-(a+n)]},bottomRight:{points:["tr","bc"],offset:[i+n,4]},rightBottom:{points:["bl","cr"],offset:[4,a+n]},bottomLeft:{points:["tl","bc"],offset:[-(i+n),4]},leftBottom:{points:["br","cl"],offset:[-4,a+n]}};return Object.keys(l).forEach((function(t){l[t]=e.arrowPointAtCenter?rE(rE({},l[t]),{overflow:sE(s),targetOffset:aE}):rE(rE({},Zw[t]),{overflow:sE(s)}),l[t].ignoreShake=!0})),l}({arrowPointAtCenter:n,autoAdjustOverflow:r})}},{key:"isNoTitle",value:function(){var e=this.props,t=e.title,n=e.overlay;return!t&&!n&&0!==t}},{key:"getOverlay",value:function(){var e=this.props,t=e.title,n=e.overlay;return 0===t?t:n||t||""}},{key:"render",value:function(){return r.createElement(We,null,this.renderTooltip)}}])&&uE(n.prototype,i),o&&uE(n,o),s}(r.Component);vE.defaultProps={placement:"top",transitionName:"zoom-big-fast",mouseEnterDelay:.1,mouseLeaveDelay:.1,arrowPointAtCenter:!1,autoAdjustOverflow:!0};var AE=vE;function _E(){return(_E=Object.assign||function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&void 0!==l[1]?l[1]:function(e){})("Loading transcoding library (FFMPEG)"),r=HE.a.createFFmpeg,i=r({log:!0}),e.next=6,i.load();case 6:return n("Transcoding video to MP4"),e.t0=Uint8Array,e.next=10,t.arrayBuffer();case 10:return e.t1=e.sent,o=new e.t0(e.t1),i.FS("writeFile","input.webm",o),e.next=15,i.run("-i","input.webm","-c:v","copy","output.mp4");case 15:return n("Transcoding complete"),a=i.FS("readFile","output.mp4"),s=new Blob([a.buffer],{type:"video/mp4"}),e.abrupt("return",s);case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function YE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function qE(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function ZE(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){qE(o,r,i,a,s,"next",e)}function s(e){qE(o,r,i,a,s,"throw",e)}a(void 0)}))}}function JE(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return eC(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eC(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eC(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(M&&t.includes(M)||O.push("/".concat(t[t.length-1]))),s(t);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),3e3);return function(){return clearInterval(e)}}),[]),i.a.createElement(Wt,{className:"layout",style:{width:"100%",height:"100%"}},i.a.createElement(vo,{simulationIds:a,matchedSimulationId:M,onSelectSimulation:function(e){O.push("/".concat(e))},onStartRecording:function(){return I.apply(this,arguments)},onStopRecording:function(){return k.apply(this,arguments)},onToggleShowControls:function(e){return u(e)},onToggleEgoView:function(e){return g(e)}}),i.a.createElement(tC,null,i.a.createElement(q,null,i.a.createElement(H,{exact:!0,path:"/all"},i.a.createElement(pw,{client:n,simulationIds:a,showControls:c,egoView:m})),i.a.createElement(H,{path:"/:simulation",render:function(){return i.a.createElement("div",{style:{display:"flex",width:"100%",height:"100%",flexDirection:"column"}},i.a.createElement("div",{style:{display:"flex",flex:1,flexDirection:"row"}},i.a.createElement(Xx,{showControls:c,toggleControlModes:D}),i.a.createElement(hw,{canvasRef:S,client:n,simulationId:M,showControls:c,controlModes:h,egoView:m,onElapsedTimesChanged:function(e,t){A(e),x(t)},style:{flex:"1"},playing:E})),i.a.createElement(zE,{currentTime:v,totalTime:y,onSeek:function(e){A(e),n.seek(M,e)},style:{height:"80px"},playing:E,setPlaying:C}))}}))))}).displayName||nC.name)+")",(iC=function(e){var t=e.wrappedComponentRef,n=Object(B.a)(e,["wrappedComponentRef"]);return i.a.createElement(U.Consumer,null,(function(e){return e||p(!1),i.a.createElement(nC,Object(c.a)({},n,e,{ref:t}))}))}).displayName=rC,iC.WrappedComponent=nC,N()(iC,nC));function aC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function sC(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}(i.current);try{for(r.s();!(e=r.n()).done;){e.value.dispose(!1,!0)}}catch(e){r.e(e)}finally{r.f()}var o=n.bubbles.map((function(e,r){var i=e.map((function(e){return new So(e[0],0,e[1])})),o=Eb.CreatePolygon("bubble-".concat(r),{sideOrientation:Pl.DOUBLESIDE,shape:i,depth:5},t);o.position.y=4;var a=new hd("bubble-".concat(r,"-material"),t);return a.diffuseColor=N_(ko,V_(n.scene_colors.bubble_line)),a.specularColor=new Io(0,0,0),a.alpha=n.scene_colors.bubble_line[3],o.material=a,o}));i.current=o}),[t,JSON.stringify(n.bubbles)]),null}function H_(e){var t=e.scene,n=e.roadNetworkBbox,i=e.egoView;if(null==t)return null;var o=Object(r.useRef)(),a=Object(r.useRef)(),s=t.getEngine().getRenderingCanvas();if(!o.current){var l=new as("ego-camera-root");l.position=new So.Zero,new Gc("ego-camera",new So(0,5,-15),t).parent=l,o.current=l}if(!a.current){var c=new Sc("third-person-camera",-Math.PI/2,0,200,new So(0,0,0),t);c.attachControl(s,!0),c.panningSensibility=50,c.lowerRadiusLimit=5,t.activeCamera=c,a.current=c}return Object(r.useEffect)((function(){if(4==n.length){var e=[(n[0]+n[2])/2,(n[1]+n[3])/2],t=a.current;t.target.x=e[0],t.target.z=e[1],t.radius=Math.max(Math.abs(n[0]-n[2]),Math.abs(n[1]-n[3]))}}),[JSON.stringify(n)]),Object(r.useEffect)((function(){var e=o.current,n=a.current;if(i){var r=e.getChildren()[0];t.activeCamera=r,n.detachControl(s)}else n.attachControl(s,!0),t.activeCamera=n}),[i]),null}var Q_=Object.freeze({SOCIAL_VEHICLE:"social_vehicle",SOCIAL_AGENT:"social_agent",AGENT:"agent"}),W_=Object.freeze({BUS:"bus",COACH:"coach",TRUCK:"truck",TRAILER:"trailer",CAR:"car"});function K_(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(!e)return;if("string"==typeof e)return X_(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return X_(e,t)}(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function X_(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function iy(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||oy(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function oy(e,t){if(e){if("string"==typeof e)return ay(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ay(e,t):void 0}}function ay(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function xy(e,t){if(e){if("string"==typeof e)return wy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wy(e,t):void 0}}function wy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function My(e,t){if(e){if("string"==typeof e)return Iy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Iy(e,t):void 0}}function Iy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}(a.current);try{for(r.s();!(e=r.n()).done;){e.value.dispose()}}catch(e){r.e(e)}finally{r.f()}var o=i.map((function(e,r){var i=e.map((function(e){return new So(e[0],.1,e[1])})),o=Eb.CreateDashedLines("lane-divider-".concat(r),{points:i,updatable:!1,dashSize:1,gapSize:2},t);return o.color=Dy(ko,Ny(n.scene_colors.lane_divider)),o}));a.current=o}}),[t,JSON.stringify(i)]),Object(r.useEffect)((function(){if(0!=o.length){null!=s.current&&s.current.dispose();var e=o.map((function(e){return e.map((function(e){return new So(e[0],.1,e[1])}))})),r=Eb.CreateLineSystem("edge-dividers",{lines:e,updatable:!1},t);r.color=Dy(ko,Ny(n.scene_colors.edge_divider)),s.current=r}}),[t,JSON.stringify(o)]),null}var zy,jy=n(119),Gy=n(161),Hy=n.n(Gy),Qy=n(19),Wy=n(15),Ky=n(83),Xy=n.n(Ky),Yy=n(162),qy=n.n(Yy),Zy=n(163),Jy=n.n(Zy);function $y(e){return function(e){if(Array.isArray(e))return ex(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return ex(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ex(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ex(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function sw(e){return function(e){if(Array.isArray(e))return dw(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||uw(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lw(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function cw(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||uw(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function uw(e,t){if(e){if("string"==typeof e)return dw(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dw(e,t):void 0}}function dw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0,"`Slider[step]` should be a positive number in order to make Slider[dots] work.");var a=Object.keys(t).map(parseFloat).sort((function(e,t){return e-t}));if(n&&r)for(var s=i;s<=o;s+=r)-1===a.indexOf(s)&&a.push(s);return a}(0,o,a,s,h,d).map((function(e){var o,a=Math.abs(e-h)/m*100+"%",s=!l&&e===u||l&&e<=u&&e>=c,d=n?vt()({},p,Aw()({},r?"top":"bottom",a)):vt()({},p,Aw()({},r?"right":"left",a));s&&(d=vt()({},d,f));var g=_e()((o={},Aw()(o,t+"-dot",!0),Aw()(o,t+"-dot-active",s),Aw()(o,t+"-dot-reverse",r),o));return i.a.createElement("span",{className:g,style:d,key:e})}));return i.a.createElement("div",{className:t+"-step"},g)},Cw=function(e){var t=e.className,n=e.vertical,r=e.reverse,o=e.marks,a=e.included,s=e.upperBound,l=e.lowerBound,c=e.max,u=e.min,d=e.onClickLabel,h=Object.keys(o),p=c-u,f=h.map(parseFloat).sort((function(e,t){return e-t})).map((function(e){var c,h=o[e],f="object"==typeof h&&!i.a.isValidElement(h),m=f?h.label:h;if(!m&&0!==m)return null;var g=!a&&e===s||a&&e<=s&&e>=l,b=_e()((c={},Aw()(c,t+"-text",!0),Aw()(c,t+"-text-active",g),c)),v=Aw()({marginBottom:"-50%"},r?"top":"bottom",(e-u)/p*100+"%"),A=Aw()({transform:"translateX("+(r?"50%":"-50%")+")",msTransform:"translateX("+(r?"50%":"-50%")+")"},r?"right":"left",(e-u)/p*100+"%"),_=n?v:A,y=f?vt()({},_,h.style):_;return i.a.createElement("span",{className:b,style:y,key:e,onMouseDown:function(t){return d(t,e)},onTouchStart:function(t){return d(t,e)}},m)}));return i.a.createElement("div",{className:t},f)},Sw=function(e){function t(){var e,n,r,i;ti()(this,t);for(var o=arguments.length,a=Array(o),s=0;sr}function Mw(e){return e.touches.length>1||"touchend"===e.type.toLowerCase()&&e.touches.length>0}function Iw(e,t){var n=t.marks,r=t.step,i=t.min,o=t.max,a=Object.keys(n).map(parseFloat);if(null!==r){var s=Math.floor((o-i)/r),l=Math.min((e-i)/r,s),c=Math.round(l)*r+i;a.push(c)}var u=a.map((function(t){return Math.abs(e-t)}));return a[u.indexOf(Math.min.apply(Math,Pw()(u)))]}function kw(e,t){return e?t.clientY:t.pageX}function Dw(e,t){return e?t.touches[0].clientY:t.touches[0].pageX}function Bw(e,t){var n=t.getBoundingClientRect();return e?n.top+.5*n.height:window.pageXOffset+n.left+.5*n.width}function Fw(e,t){var n=t.max,r=t.min;return e<=r?r:e>=n?n:e}function Nw(e,t){var n=t.step,r=isFinite(Iw(e,t))?Iw(e,t):0;return null===n?r:parseFloat(r.toFixed(function(e){var t=e.toString(),n=0;return t.indexOf(".")>=0&&(n=t.length-t.indexOf(".")-1),n}(n)))}function Lw(e){e.stopPropagation(),e.preventDefault()}function Uw(e,t,n){var r="increase";switch(e.keyCode){case Kt.a.UP:r=t&&n?"decrease":"increase";break;case Kt.a.RIGHT:r=!t&&n?"decrease":"increase";break;case Kt.a.DOWN:r=t&&n?"increase":"decrease";break;case Kt.a.LEFT:r=!t&&n?"increase":"decrease";break;case Kt.a.END:return function(e,t){return t.max};case Kt.a.HOME:return function(e,t){return t.min};case Kt.a.PAGE_UP:return function(e,t){return e+2*t.step};case Kt.a.PAGE_DOWN:return function(e,t){return e-2*t.step};default:return}return function(e,t){return function(e,t,n){var r={increase:function(e,t){return e+t},decrease:function(e,t){return e-t}},i=r[e](Object.keys(n.marks).indexOf(JSON.stringify(t)),1),o=Object.keys(n.marks)[i];return n.step?r[e](t,n.step):Object.keys(n.marks).length&&n.marks[o]?n.marks[o]:t}(r,e,t)}}function Vw(){}function zw(e){var t,n;return n=t=function(e){function t(e){ti()(this,t);var n=ri()(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));n.onMouseDown=function(e){if(0===e.button){var t=n.props.vertical,r=kw(t,e);if(Ow(e,n.handlesRefs)){var i=Bw(t,e.target);n.dragOffset=r-i,r=i}else n.dragOffset=0;n.removeDocumentEvents(),n.onStart(r),n.addDocumentMouseEvents()}},n.onTouchStart=function(e){if(!Mw(e)){var t=n.props.vertical,r=Dw(t,e);if(Ow(e,n.handlesRefs)){var i=Bw(t,e.target);n.dragOffset=r-i,r=i}else n.dragOffset=0;n.onStart(r),n.addDocumentTouchEvents(),Lw(e)}},n.onFocus=function(e){var t=n.props,r=t.onFocus,i=t.vertical;if(Ow(e,n.handlesRefs)){var o=Bw(i,e.target);n.dragOffset=0,n.onStart(o),Lw(e),r&&r(e)}},n.onBlur=function(e){var t=n.props.onBlur;n.onEnd(),t&&t(e)},n.onMouseUp=function(){n.handlesRefs[n.prevMovedHandleIndex]&&n.handlesRefs[n.prevMovedHandleIndex].clickFocus()},n.onMouseMove=function(e){if(n.sliderRef){var t=kw(n.props.vertical,e);n.onMove(e,t-n.dragOffset)}else n.onEnd()},n.onTouchMove=function(e){if(!Mw(e)&&n.sliderRef){var t=Dw(n.props.vertical,e);n.onMove(e,t-n.dragOffset)}else n.onEnd()},n.onKeyDown=function(e){n.sliderRef&&Ow(e,n.handlesRefs)&&n.onKeyboard(e)},n.onClickMarkLabel=function(e,t){e.stopPropagation(),n.onChange({value:t}),n.setState({value:t},(function(){return n.onEnd(!0)}))},n.saveSlider=function(e){n.sliderRef=e};var r=e.step,i=e.max,o=e.min,a=!isFinite(i-o)||(i-o)%r==0;return bw()(!r||Math.floor(r)!==r||a,"Slider[max] - Slider[min] (%s) should be a multiple of Slider[step] (%s)",i-o,r),n.handlesRefs={},n}return oi()(t,e),mw()(t,[{key:"componentDidMount",value:function(){this.document=this.sliderRef&&this.sliderRef.ownerDocument;var e=this.props,t=e.autoFocus,n=e.disabled;t&&!n&&this.focus()}},{key:"componentWillUnmount",value:function(){xw()(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"componentWillUnmount",this)&&xw()(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"componentWillUnmount",this).call(this),this.removeDocumentEvents()}},{key:"getSliderStart",value:function(){var e=this.sliderRef,t=this.props,n=t.vertical,r=t.reverse,i=e.getBoundingClientRect();return n?r?i.bottom:i.top:window.pageXOffset+(r?i.right:i.left)}},{key:"getSliderLength",value:function(){var e=this.sliderRef;if(!e)return 0;var t=e.getBoundingClientRect();return this.props.vertical?t.height:t.width}},{key:"addDocumentTouchEvents",value:function(){this.onTouchMoveListener=Object(ww.a)(this.document,"touchmove",this.onTouchMove),this.onTouchUpListener=Object(ww.a)(this.document,"touchend",this.onEnd)}},{key:"addDocumentMouseEvents",value:function(){this.onMouseMoveListener=Object(ww.a)(this.document,"mousemove",this.onMouseMove),this.onMouseUpListener=Object(ww.a)(this.document,"mouseup",this.onEnd)}},{key:"removeDocumentEvents",value:function(){this.onTouchMoveListener&&this.onTouchMoveListener.remove(),this.onTouchUpListener&&this.onTouchUpListener.remove(),this.onMouseMoveListener&&this.onMouseMoveListener.remove(),this.onMouseUpListener&&this.onMouseUpListener.remove()}},{key:"focus",value:function(){this.props.disabled||this.handlesRefs[0].focus()}},{key:"blur",value:function(){var e=this;this.props.disabled||Object.keys(this.handlesRefs).forEach((function(t){e.handlesRefs[t]&&e.handlesRefs[t].blur&&e.handlesRefs[t].blur()}))}},{key:"calcValue",value:function(e){var t=this.props,n=t.vertical,r=t.min,i=t.max,o=Math.abs(Math.max(e,0)/this.getSliderLength());return n?(1-o)*(i-r)+r:o*(i-r)+r}},{key:"calcValueByPos",value:function(e){var t=(this.props.reverse?-1:1)*(e-this.getSliderStart());return this.trimAlignValue(this.calcValue(t))}},{key:"calcOffset",value:function(e){var t=this.props,n=t.min,r=(e-n)/(t.max-n);return Math.max(0,100*r)}},{key:"saveHandle",value:function(e,t){this.handlesRefs[e]=t}},{key:"render",value:function(){var e,n=this.props,r=n.prefixCls,o=n.className,a=n.marks,s=n.dots,l=n.step,c=n.included,u=n.disabled,d=n.vertical,h=n.reverse,p=n.min,f=n.max,m=n.children,g=n.maximumTrackStyle,b=n.style,v=n.railStyle,A=n.dotStyle,_=n.activeDotStyle,y=xw()(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"render",this).call(this),x=y.tracks,w=y.handles,E=_e()(r,(e={},Aw()(e,r+"-with-marks",Object.keys(a).length),Aw()(e,r+"-disabled",u),Aw()(e,r+"-vertical",d),Aw()(e,o,o),e));return i.a.createElement("div",{ref:this.saveSlider,className:E,onTouchStart:u?Vw:this.onTouchStart,onMouseDown:u?Vw:this.onMouseDown,onMouseUp:u?Vw:this.onMouseUp,onKeyDown:u?Vw:this.onKeyDown,onFocus:u?Vw:this.onFocus,onBlur:u?Vw:this.onBlur,style:b},i.a.createElement("div",{className:r+"-rail",style:vt()({},g,v)}),x,i.a.createElement(Ew,{prefixCls:r,vertical:d,reverse:h,marks:a,dots:s,step:l,included:c,lowerBound:this.getLowerBound(),upperBound:this.getUpperBound(),max:f,min:p,dotStyle:A,activeDotStyle:_}),w,i.a.createElement(Cw,{className:r+"-mark",onClickLabel:u?Vw:this.onClickMarkLabel,vertical:d,marks:a,included:c,lowerBound:this.getLowerBound(),upperBound:this.getUpperBound(),max:f,min:p,reverse:h}),m)}}]),t}(e),t.displayName="ComponentEnhancer("+e.displayName+")",t.defaultProps=vt()({},e.defaultProps,{prefixCls:"rc-slider",className:"",min:0,max:100,step:1,marks:{},handle:function(e){var t=e.index,n=$r()(e,["index"]);return delete n.dragging,null===n.value?null:i.a.createElement(Sw,vt()({},n,{key:t}))},onBeforeChange:Vw,onChange:Vw,onAfterChange:Vw,included:!0,disabled:!1,dots:!1,vertical:!1,reverse:!1,trackStyle:[{}],handleStyle:[{}],railStyle:{},dotStyle:{},activeDotStyle:{}}),n}var jw=zw(function(e){function t(e){ti()(this,t);var n=ri()(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));n.onEnd=function(e){var t=n.state.dragging;n.removeDocumentEvents(),(t||e)&&n.props.onAfterChange(n.getValue()),n.setState({dragging:!1})};var r=void 0!==e.defaultValue?e.defaultValue:e.min,i=void 0!==e.value?e.value:r;return n.state={value:n.trimAlignValue(i),dragging:!1},bw()(!("minimumTrackStyle"in e),"minimumTrackStyle will be deprecated, please use trackStyle instead."),bw()(!("maximumTrackStyle"in e),"maximumTrackStyle will be deprecated, please use railStyle instead."),n}return oi()(t,e),mw()(t,[{key:"componentDidUpdate",value:function(e,t){if("value"in this.props||"min"in this.props||"max"in this.props){var n=this.props,r=n.value,i=n.onChange,o=void 0!==r?r:t.value,a=this.trimAlignValue(o,this.props);a!==t.value&&(this.setState({value:a}),Rw(o,this.props)&&i(a))}}},{key:"onChange",value:function(e){var t=this.props,n=!("value"in t),r=e.value>this.props.max?vt()({},e,{value:this.props.max}):e;n&&this.setState(r);var i=r.value;t.onChange(i)}},{key:"onStart",value:function(e){this.setState({dragging:!0});var t=this.props,n=this.getValue();t.onBeforeChange(n);var r=this.calcValueByPos(e);this.startValue=r,this.startPosition=e,r!==n&&(this.prevMovedHandleIndex=0,this.onChange({value:r}))}},{key:"onMove",value:function(e,t){Lw(e);var n=this.state.value,r=this.calcValueByPos(t);r!==n&&this.onChange({value:r})}},{key:"onKeyboard",value:function(e){var t=this.props,n=t.reverse,r=Uw(e,t.vertical,n);if(r){Lw(e);var i=this.state.value,o=r(i,this.props),a=this.trimAlignValue(o);if(a===i)return;this.onChange({value:a}),this.props.onAfterChange(a),this.onEnd()}}},{key:"getValue",value:function(){return this.state.value}},{key:"getLowerBound",value:function(){return this.props.min}},{key:"getUpperBound",value:function(){return this.state.value}},{key:"trimAlignValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null===e)return null;var n=vt()({},this.props,t),r=Fw(e,n);return Nw(r,n)}},{key:"render",value:function(){var e=this,t=this.props,n=t.prefixCls,r=t.vertical,o=t.included,a=t.disabled,s=t.minimumTrackStyle,l=t.trackStyle,c=t.handleStyle,u=t.tabIndex,d=t.ariaLabelForHandle,h=t.ariaLabelledByForHandle,p=t.ariaValueTextFormatterForHandle,f=t.min,m=t.max,g=t.startPoint,b=t.reverse,v=t.handle,A=this.state,_=A.value,y=A.dragging,x=this.calcOffset(_),w=v({className:n+"-handle",prefixCls:n,vertical:r,offset:x,value:_,dragging:y,disabled:a,min:f,max:m,reverse:b,index:0,tabIndex:u,ariaLabel:d,ariaLabelledBy:h,ariaValueTextFormatter:p,style:c[0]||c,ref:function(t){return e.saveHandle(0,t)}}),E=void 0!==g?this.calcOffset(g):0,C=l[0]||l;return{tracks:i.a.createElement(_w,{className:n+"-track",vertical:r,included:o,offset:E,reverse:b,length:x-E,style:vt()({},s,C)}),handles:w}}}]),t}(i.a.Component)),Gw=n(165),Hw=n.n(Gw),Qw=function(e){var t=e.value,n=e.handle,r=e.bounds,i=e.props,o=i.allowCross,a=i.pushable,s=Number(a),l=Fw(t,i),c=l;return o||null==n||void 0===r||(n>0&&l<=r[n-1]+s&&(c=r[n-1]+s),n=r[n+1]-s&&(c=r[n+1]-s)),Nw(c,i)},Ww=function(e){function t(e){ti()(this,t);var n=ri()(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));n.onEnd=function(e){var t=n.state.handle;n.removeDocumentEvents(),(null!==t||e)&&n.props.onAfterChange(n.getValue()),n.setState({handle:null})};var r=e.count,i=e.min,o=e.max,a=Array.apply(void 0,Pw()(Array(r+1))).map((function(){return i})),s="defaultValue"in e?e.defaultValue:a,l=(void 0!==e.value?e.value:s).map((function(t,n){return Qw({value:t,handle:n,props:e})})),c=l[0]===o?0:l.length-1;return n.state={handle:null,recent:c,bounds:l},n}return oi()(t,e),mw()(t,[{key:"componentDidUpdate",value:function(e,t){var n=this;if(("value"in this.props||"min"in this.props||"max"in this.props)&&(this.props.min!==e.min||this.props.max!==e.max||!Hw()(this.props.value,e.value))){var r=this.props,i=r.onChange,o=r.value||t.bounds;if(o.some((function(e){return Rw(e,n.props)})))i(o.map((function(e){return Fw(e,n.props)})))}}},{key:"onChange",value:function(e){var t=this.props;if(!("value"in t))this.setState(e);else{var n={};["handle","recent"].forEach((function(t){void 0!==e[t]&&(n[t]=e[t])})),Object.keys(n).length&&this.setState(n)}var r=vt()({},this.state,e).bounds;t.onChange(r)}},{key:"onStart",value:function(e){var t=this.props,n=this.state,r=this.getValue();t.onBeforeChange(r);var i=this.calcValueByPos(e);this.startValue=i,this.startPosition=e;var o=this.getClosestBound(i);if(this.prevMovedHandleIndex=this.getBoundNeedMoving(i,o),this.setState({handle:this.prevMovedHandleIndex,recent:this.prevMovedHandleIndex}),i!==r[this.prevMovedHandleIndex]){var a=[].concat(Pw()(n.bounds));a[this.prevMovedHandleIndex]=i,this.onChange({bounds:a})}}},{key:"onMove",value:function(e,t){Lw(e);var n=this.state,r=this.calcValueByPos(t);r!==n.bounds[n.handle]&&this.moveTo(r)}},{key:"onKeyboard",value:function(e){var t=this.props,n=t.reverse,r=Uw(e,t.vertical,n);if(r){Lw(e);var i=this.state,o=this.props,a=i.bounds,s=i.handle,l=a[null===s?i.recent:s],c=r(l,o),u=Qw({value:c,handle:s,bounds:i.bounds,props:o});if(u===l)return;this.moveTo(u,!0)}}},{key:"getValue",value:function(){return this.state.bounds}},{key:"getClosestBound",value:function(e){for(var t=this.state.bounds,n=0,r=1;r=t[r]&&(n=r);return Math.abs(t[n+1]-e)=r.length||i<0)return!1;var o=t+n,a=r[i],s=this.props.pushable,l=n*(e[o]-a);return!!this.pushHandle(e,o,n,s-l)&&(e[t]=a,!0)}},{key:"trimAlignValue",value:function(e){var t=this.state,n=t.handle,r=t.bounds;return Qw({value:e,handle:n,bounds:r,props:this.props})}},{key:"render",value:function(){var e=this,t=this.state,n=t.handle,r=t.bounds,o=this.props,a=o.prefixCls,s=o.vertical,l=o.included,c=o.disabled,u=o.min,d=o.max,h=o.reverse,p=o.handle,f=o.trackStyle,m=o.handleStyle,g=o.tabIndex,b=o.ariaLabelGroupForHandles,v=o.ariaLabelledByGroupForHandles,A=o.ariaValueTextFormatterGroupForHandles,_=r.map((function(t){return e.calcOffset(t)})),y=a+"-handle",x=r.map((function(t,r){var i,o=g[r]||0;(c||null===g[r])&&(o=null);var l=n===r;return p({className:_e()((i={},Aw()(i,y,!0),Aw()(i,y+"-"+(r+1),!0),Aw()(i,y+"-dragging",l),i)),prefixCls:a,vertical:s,dragging:l,offset:_[r],value:t,index:r,tabIndex:o,min:u,max:d,reverse:h,disabled:c,style:m[r],ref:function(t){return e.saveHandle(r,t)},ariaLabel:b[r],ariaLabelledBy:v[r],ariaValueTextFormatter:A[r]})}));return{tracks:r.slice(0,-1).map((function(e,t){var n,r=t+1,o=_e()((n={},Aw()(n,a+"-track",!0),Aw()(n,a+"-track-"+r,!0),n));return i.a.createElement(_w,{className:o,vertical:s,reverse:h,included:l,offset:_[r-1],length:_[r]-_[r-1],style:f[t],key:r})})),handles:x}}}],[{key:"getDerivedStateFromProps",value:function(e,t){if("value"in e||"min"in e||"max"in e){var n=(e.value||t.bounds).map((function(n,r){return Qw({value:n,handle:r,bounds:t.bounds,props:e})}));return n.length===t.bounds.length&&n.every((function(e,n){return e===t.bounds[n]}))?null:vt()({},t,{bounds:n})}return null}}]),t}(i.a.Component);Ww.displayName="Range",Ww.defaultProps={count:1,allowCross:!0,pushable:!1,tabIndex:[],ariaLabelGroupForHandles:[],ariaLabelledByGroupForHandles:[],ariaValueTextFormatterGroupForHandles:[]};var Kw=zw(Ww),Xw=n(85),Yw={adjustX:1,adjustY:1},qw=[0,0],Zw={left:{points:["cr","cl"],overflow:Yw,offset:[-4,0],targetOffset:qw},right:{points:["cl","cr"],overflow:Yw,offset:[4,0],targetOffset:qw},top:{points:["bc","tc"],overflow:Yw,offset:[0,-4],targetOffset:qw},bottom:{points:["tc","bc"],overflow:Yw,offset:[0,4],targetOffset:qw},topLeft:{points:["bl","tl"],overflow:Yw,offset:[0,-4],targetOffset:qw},leftTop:{points:["tr","tl"],overflow:Yw,offset:[-4,0],targetOffset:qw},topRight:{points:["br","tr"],overflow:Yw,offset:[0,-4],targetOffset:qw},rightTop:{points:["tl","tr"],overflow:Yw,offset:[4,0],targetOffset:qw},bottomRight:{points:["tr","br"],overflow:Yw,offset:[0,4],targetOffset:qw},rightBottom:{points:["bl","br"],overflow:Yw,offset:[4,0],targetOffset:qw},bottomLeft:{points:["tl","bl"],overflow:Yw,offset:[0,4],targetOffset:qw},leftBottom:{points:["br","bl"],overflow:Yw,offset:[-4,0],targetOffset:qw}},Jw=function(e){var t=e.overlay,n=e.prefixCls,r=e.id;return i.a.createElement("div",{className:"".concat(n,"-inner"),id:r,role:"tooltip"},"function"==typeof t?t():t)};function $w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function eE(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tE(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var nE=Object(r.forwardRef)((function(e,t){var n=e.overlayClassName,o=e.trigger,a=void 0===o?["hover"]:o,s=e.mouseEnterDelay,l=void 0===s?0:s,c=e.mouseLeaveDelay,u=void 0===c?.1:c,d=e.overlayStyle,h=e.prefixCls,p=void 0===h?"rc-tooltip":h,f=e.children,m=e.onVisibleChange,g=e.afterVisibleChange,b=e.transitionName,v=e.animation,A=e.placement,_=void 0===A?"right":A,y=e.align,x=void 0===y?{}:y,w=e.destroyTooltipOnHide,E=void 0!==w&&w,C=e.defaultVisible,S=e.getTooltipContainer,T=tE(e,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer"]),P=Object(r.useRef)(null);Object(r.useImperativeHandle)(t,(function(){return P.current}));var O=function(e){for(var t=1;t=0||i.indexOf("Bottom")>=0?a.top="".concat(o.height-n.offset[1],"px"):(i.indexOf("Top")>=0||i.indexOf("bottom")>=0)&&(a.top="".concat(-n.offset[1],"px")),i.indexOf("left")>=0||i.indexOf("Right")>=0?a.left="".concat(o.width-n.offset[0],"px"):(i.indexOf("right")>=0||i.indexOf("Left")>=0)&&(a.left="".concat(-n.offset[0],"px")),e.style.transformOrigin="".concat(a.left," ").concat(a.top)},t.renderTooltip=function(e){var n=e.getPopupContainer,i=e.getPrefixCls,o=e.direction,a=pE(t),s=a.props,l=a.state,c=s.prefixCls,u=s.openClassName,d=s.getPopupContainer,h=s.getTooltipContainer,p=s.overlayClassName,f=s.children,m=i("tooltip",c),g=l.visible;"visible"in s||!t.isNoTitle()||(g=!1);var b=bE(r.isValidElement(f)?f:r.createElement("span",null,f),m),v=b.props,A=_e()(v.className,cE({},u||"".concat(m,"-open"),!0)),_=_e()(p,cE({},"".concat(m,"-rtl"),"rtl"===o));return r.createElement(nE,gE({},t.props,{prefixCls:m,overlayClassName:_,getTooltipContainer:d||h||n,ref:t.saveTooltip,builtinPlacements:t.getPlacements(),overlay:t.getOverlay(),visible:g,onVisibleChange:t.onVisibleChange,onPopupAlign:t.onPopupAlign}),g?r.cloneElement(b,{className:A}):b)},t.state={visible:!!e.visible||!!e.defaultVisible},t}return n=s,o=[{key:"getDerivedStateFromProps",value:function(e){return"visible"in e?{visible:e.visible}:null}}],(i=[{key:"getPopupDomNode",value:function(){return this.tooltip.getPopupDomNode()}},{key:"getPlacements",value:function(){var e=this.props,t=e.builtinPlacements,n=e.arrowPointAtCenter,r=e.autoAdjustOverflow;return t||function(e){var t=e.arrowWidth,n=void 0===t?5:t,r=e.horizontalArrowShift,i=void 0===r?16:r,o=e.verticalArrowShift,a=void 0===o?8:o,s=e.autoAdjustOverflow,l={left:{points:["cr","cl"],offset:[-4,0]},right:{points:["cl","cr"],offset:[4,0]},top:{points:["bc","tc"],offset:[0,-4]},bottom:{points:["tc","bc"],offset:[0,4]},topLeft:{points:["bl","tc"],offset:[-(i+n),-4]},leftTop:{points:["tr","cl"],offset:[-4,-(a+n)]},topRight:{points:["br","tc"],offset:[i+n,-4]},rightTop:{points:["tl","cr"],offset:[4,-(a+n)]},bottomRight:{points:["tr","bc"],offset:[i+n,4]},rightBottom:{points:["bl","cr"],offset:[4,a+n]},bottomLeft:{points:["tl","bc"],offset:[-(i+n),4]},leftBottom:{points:["br","cl"],offset:[-4,a+n]}};return Object.keys(l).forEach((function(t){l[t]=e.arrowPointAtCenter?rE(rE({},l[t]),{overflow:sE(s),targetOffset:aE}):rE(rE({},Zw[t]),{overflow:sE(s)}),l[t].ignoreShake=!0})),l}({arrowPointAtCenter:n,autoAdjustOverflow:r})}},{key:"isNoTitle",value:function(){var e=this.props,t=e.title,n=e.overlay;return!t&&!n&&0!==t}},{key:"getOverlay",value:function(){var e=this.props,t=e.title,n=e.overlay;return 0===t?t:n||t||""}},{key:"render",value:function(){return r.createElement(We,null,this.renderTooltip)}}])&&uE(n.prototype,i),o&&uE(n,o),s}(r.Component);vE.defaultProps={placement:"top",transitionName:"zoom-big-fast",mouseEnterDelay:.1,mouseLeaveDelay:.1,arrowPointAtCenter:!1,autoAdjustOverflow:!0};var AE=vE;function _E(){return(_E=Object.assign||function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&void 0!==l[1]?l[1]:function(e){})("Loading transcoding library (FFMPEG)"),r=HE.a.createFFmpeg,i=r({log:!0}),e.next=6,i.load();case 6:return n("Transcoding video to MP4"),e.t0=Uint8Array,e.next=10,t.arrayBuffer();case 10:return e.t1=e.sent,o=new e.t0(e.t1),i.FS("writeFile","input.webm",o),e.next=15,i.run("-i","input.webm","-c:v","copy","output.mp4");case 15:return n("Transcoding complete"),a=i.FS("readFile","output.mp4"),s=new Blob([a.buffer],{type:"video/mp4"}),e.abrupt("return",s);case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function YE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function qE(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function ZE(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){qE(o,r,i,a,s,"next",e)}function s(e){qE(o,r,i,a,s,"throw",e)}a(void 0)}))}}function JE(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return eC(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eC(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eC(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(M&&t.includes(M)||O.push("/".concat(t[t.length-1]))),s(t);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),3e3);return function(){return clearInterval(e)}}),[M]),i.a.createElement(Wt,{className:"layout",style:{width:"100%",height:"100%"}},i.a.createElement(vo,{simulationIds:a,matchedSimulationId:M,onSelectSimulation:function(e){O.push("/".concat(e))},onStartRecording:function(){return I.apply(this,arguments)},onStopRecording:function(){return k.apply(this,arguments)},onToggleShowControls:function(e){return u(e)},onToggleEgoView:function(e){return g(e)}}),i.a.createElement(tC,null,i.a.createElement(q,null,i.a.createElement(H,{exact:!0,path:"/all"},i.a.createElement(pw,{client:n,simulationIds:a,showControls:c,egoView:m})),i.a.createElement(H,{path:"/:simulation",render:function(){return i.a.createElement("div",{style:{display:"flex",width:"100%",height:"100%",flexDirection:"column"}},i.a.createElement("div",{style:{display:"flex",flex:1,flexDirection:"row"}},i.a.createElement(Xx,{showControls:c,toggleControlModes:D}),i.a.createElement(hw,{canvasRef:S,client:n,simulationId:M,showControls:c,controlModes:h,egoView:m,onElapsedTimesChanged:function(e,t){A(e),x(t)},style:{flex:"1"},playing:E})),i.a.createElement(zE,{currentTime:v,totalTime:y,onSeek:function(e){A(e),n.seek(M,e)},style:{height:"80px"},playing:E,setPlaying:C}))}}))))}).displayName||nC.name)+")",(iC=function(e){var t=e.wrappedComponentRef,n=Object(B.a)(e,["wrappedComponentRef"]);return i.a.createElement(U.Consumer,null,(function(e){return e||p(!1),i.a.createElement(nC,Object(c.a)({},n,e,{ref:t}))}))}).displayName=rC,iC.WrappedComponent=nC,N()(iC,nC));function aC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function sC(e){for(var t=1;t= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react.production.min.js');\n} else {\n module.exports = require('./cjs/react.development.js');\n}\n","/**\r\n * A class serves as a medium between the observable and its observers\r\n */\r\nvar EventState = /** @class */ (function () {\r\n /**\r\n * Create a new EventState\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n */\r\n function EventState(mask, skipNextObservers, target, currentTarget) {\r\n if (skipNextObservers === void 0) { skipNextObservers = false; }\r\n this.initalize(mask, skipNextObservers, target, currentTarget);\r\n }\r\n /**\r\n * Initialize the current event state\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @returns the current event state\r\n */\r\n EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {\r\n if (skipNextObservers === void 0) { skipNextObservers = false; }\r\n this.mask = mask;\r\n this.skipNextObservers = skipNextObservers;\r\n this.target = target;\r\n this.currentTarget = currentTarget;\r\n return this;\r\n };\r\n return EventState;\r\n}());\r\nexport { EventState };\r\n/**\r\n * Represent an Observer registered to a given Observable object.\r\n */\r\nvar Observer = /** @class */ (function () {\r\n /**\r\n * Creates a new observer\r\n * @param callback defines the callback to call when the observer is notified\r\n * @param mask defines the mask of the observer (used to filter notifications)\r\n * @param scope defines the current scope used to restore the JS context\r\n */\r\n function Observer(\r\n /**\r\n * Defines the callback to call when the observer is notified\r\n */\r\n callback, \r\n /**\r\n * Defines the mask of the observer (used to filter notifications)\r\n */\r\n mask, \r\n /**\r\n * Defines the current scope used to restore the JS context\r\n */\r\n scope) {\r\n if (scope === void 0) { scope = null; }\r\n this.callback = callback;\r\n this.mask = mask;\r\n this.scope = scope;\r\n /** @hidden */\r\n this._willBeUnregistered = false;\r\n /**\r\n * Gets or sets a property defining that the observer as to be unregistered after the next notification\r\n */\r\n this.unregisterOnNextCall = false;\r\n }\r\n return Observer;\r\n}());\r\nexport { Observer };\r\n/**\r\n * Represent a list of observers registered to multiple Observables object.\r\n */\r\nvar MultiObserver = /** @class */ (function () {\r\n function MultiObserver() {\r\n }\r\n /**\r\n * Release associated resources\r\n */\r\n MultiObserver.prototype.dispose = function () {\r\n if (this._observers && this._observables) {\r\n for (var index = 0; index < this._observers.length; index++) {\r\n this._observables[index].remove(this._observers[index]);\r\n }\r\n }\r\n this._observers = null;\r\n this._observables = null;\r\n };\r\n /**\r\n * Raise a callback when one of the observable will notify\r\n * @param observables defines a list of observables to watch\r\n * @param callback defines the callback to call on notification\r\n * @param mask defines the mask used to filter notifications\r\n * @param scope defines the current scope used to restore the JS context\r\n * @returns the new MultiObserver\r\n */\r\n MultiObserver.Watch = function (observables, callback, mask, scope) {\r\n if (mask === void 0) { mask = -1; }\r\n if (scope === void 0) { scope = null; }\r\n var result = new MultiObserver();\r\n result._observers = new Array();\r\n result._observables = observables;\r\n for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {\r\n var observable = observables_1[_i];\r\n var observer = observable.add(callback, mask, false, scope);\r\n if (observer) {\r\n result._observers.push(observer);\r\n }\r\n }\r\n return result;\r\n };\r\n return MultiObserver;\r\n}());\r\nexport { MultiObserver };\r\n/**\r\n * The Observable class is a simple implementation of the Observable pattern.\r\n *\r\n * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.\r\n * This enable a more fine grained execution without having to rely on multiple different Observable objects.\r\n * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).\r\n * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.\r\n */\r\nvar Observable = /** @class */ (function () {\r\n /**\r\n * Creates a new observable\r\n * @param onObserverAdded defines a callback to call when a new observer is added\r\n */\r\n function Observable(onObserverAdded) {\r\n this._observers = new Array();\r\n this._eventState = new EventState(0);\r\n if (onObserverAdded) {\r\n this._onObserverAdded = onObserverAdded;\r\n }\r\n }\r\n Object.defineProperty(Observable.prototype, \"observers\", {\r\n /**\r\n * Gets the list of observers\r\n */\r\n get: function () {\r\n return this._observers;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Create a new Observer with the specified callback\r\n * @param callback the callback that will be executed for that Observer\r\n * @param mask the mask used to filter observers\r\n * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.\r\n * @param scope optional scope for the callback to be called from\r\n * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification\r\n * @returns the new observer created for the callback\r\n */\r\n Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {\r\n if (mask === void 0) { mask = -1; }\r\n if (insertFirst === void 0) { insertFirst = false; }\r\n if (scope === void 0) { scope = null; }\r\n if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }\r\n if (!callback) {\r\n return null;\r\n }\r\n var observer = new Observer(callback, mask, scope);\r\n observer.unregisterOnNextCall = unregisterOnFirstCall;\r\n if (insertFirst) {\r\n this._observers.unshift(observer);\r\n }\r\n else {\r\n this._observers.push(observer);\r\n }\r\n if (this._onObserverAdded) {\r\n this._onObserverAdded(observer);\r\n }\r\n return observer;\r\n };\r\n /**\r\n * Create a new Observer with the specified callback and unregisters after the next notification\r\n * @param callback the callback that will be executed for that Observer\r\n * @returns the new observer created for the callback\r\n */\r\n Observable.prototype.addOnce = function (callback) {\r\n return this.add(callback, undefined, undefined, undefined, true);\r\n };\r\n /**\r\n * Remove an Observer from the Observable object\r\n * @param observer the instance of the Observer to remove\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n Observable.prototype.remove = function (observer) {\r\n if (!observer) {\r\n return false;\r\n }\r\n var index = this._observers.indexOf(observer);\r\n if (index !== -1) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n return false;\r\n };\r\n /**\r\n * Remove a callback from the Observable object\r\n * @param callback the callback to remove\r\n * @param scope optional scope. If used only the callbacks with this scope will be removed\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n Observable.prototype.removeCallback = function (callback, scope) {\r\n for (var index = 0; index < this._observers.length; index++) {\r\n var observer = this._observers[index];\r\n if (observer._willBeUnregistered) {\r\n continue;\r\n }\r\n if (observer.callback === callback && (!scope || scope === observer.scope)) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n Observable.prototype._deferUnregister = function (observer) {\r\n var _this = this;\r\n observer.unregisterOnNextCall = false;\r\n observer._willBeUnregistered = true;\r\n setTimeout(function () {\r\n _this._remove(observer);\r\n }, 0);\r\n };\r\n // This should only be called when not iterating over _observers to avoid callback skipping.\r\n // Removes an observer from the _observer Array.\r\n Observable.prototype._remove = function (observer) {\r\n if (!observer) {\r\n return false;\r\n }\r\n var index = this._observers.indexOf(observer);\r\n if (index !== -1) {\r\n this._observers.splice(index, 1);\r\n return true;\r\n }\r\n return false;\r\n };\r\n /**\r\n * Moves the observable to the top of the observer list making it get called first when notified\r\n * @param observer the observer to move\r\n */\r\n Observable.prototype.makeObserverTopPriority = function (observer) {\r\n this._remove(observer);\r\n this._observers.unshift(observer);\r\n };\r\n /**\r\n * Moves the observable to the bottom of the observer list making it get called last when notified\r\n * @param observer the observer to move\r\n */\r\n Observable.prototype.makeObserverBottomPriority = function (observer) {\r\n this._remove(observer);\r\n this._observers.push(observer);\r\n };\r\n /**\r\n * Notify all Observers by calling their respective callback with the given data\r\n * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute\r\n * @param eventData defines the data to send to all observers\r\n * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)\r\n */\r\n Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {\r\n if (mask === void 0) { mask = -1; }\r\n if (!this._observers.length) {\r\n return true;\r\n }\r\n var state = this._eventState;\r\n state.mask = mask;\r\n state.target = target;\r\n state.currentTarget = currentTarget;\r\n state.skipNextObservers = false;\r\n state.lastReturnValue = eventData;\r\n for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {\r\n var obs = _a[_i];\r\n if (obs._willBeUnregistered) {\r\n continue;\r\n }\r\n if (obs.mask & mask) {\r\n if (obs.scope) {\r\n state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);\r\n }\r\n else {\r\n state.lastReturnValue = obs.callback(eventData, state);\r\n }\r\n if (obs.unregisterOnNextCall) {\r\n this._deferUnregister(obs);\r\n }\r\n }\r\n if (state.skipNextObservers) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n };\r\n /**\r\n * Calling this will execute each callback, expecting it to be a promise or return a value.\r\n * If at any point in the chain one function fails, the promise will fail and the execution will not continue.\r\n * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object\r\n * and it is crucial that all callbacks will be executed.\r\n * The order of the callbacks is kept, callbacks are not executed parallel.\r\n *\r\n * @param eventData The data to be sent to each callback\r\n * @param mask is used to filter observers defaults to -1\r\n * @param target defines the callback target (see EventState)\r\n * @param currentTarget defines he current object in the bubbling phase\r\n * @returns {Promise} will return a Promise than resolves when all callbacks executed successfully.\r\n */\r\n Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {\r\n var _this = this;\r\n if (mask === void 0) { mask = -1; }\r\n // create an empty promise\r\n var p = Promise.resolve(eventData);\r\n // no observers? return this promise.\r\n if (!this._observers.length) {\r\n return p;\r\n }\r\n var state = this._eventState;\r\n state.mask = mask;\r\n state.target = target;\r\n state.currentTarget = currentTarget;\r\n state.skipNextObservers = false;\r\n // execute one callback after another (not using Promise.all, the order is important)\r\n this._observers.forEach(function (obs) {\r\n if (state.skipNextObservers) {\r\n return;\r\n }\r\n if (obs._willBeUnregistered) {\r\n return;\r\n }\r\n if (obs.mask & mask) {\r\n if (obs.scope) {\r\n p = p.then(function (lastReturnedValue) {\r\n state.lastReturnValue = lastReturnedValue;\r\n return obs.callback.apply(obs.scope, [eventData, state]);\r\n });\r\n }\r\n else {\r\n p = p.then(function (lastReturnedValue) {\r\n state.lastReturnValue = lastReturnedValue;\r\n return obs.callback(eventData, state);\r\n });\r\n }\r\n if (obs.unregisterOnNextCall) {\r\n _this._deferUnregister(obs);\r\n }\r\n }\r\n });\r\n // return the eventData\r\n return p.then(function () { return eventData; });\r\n };\r\n /**\r\n * Notify a specific observer\r\n * @param observer defines the observer to notify\r\n * @param eventData defines the data to be sent to each callback\r\n * @param mask is used to filter observers defaults to -1\r\n */\r\n Observable.prototype.notifyObserver = function (observer, eventData, mask) {\r\n if (mask === void 0) { mask = -1; }\r\n var state = this._eventState;\r\n state.mask = mask;\r\n state.skipNextObservers = false;\r\n observer.callback(eventData, state);\r\n };\r\n /**\r\n * Gets a boolean indicating if the observable has at least one observer\r\n * @returns true is the Observable has at least one Observer registered\r\n */\r\n Observable.prototype.hasObservers = function () {\r\n return this._observers.length > 0;\r\n };\r\n /**\r\n * Clear the list of observers\r\n */\r\n Observable.prototype.clear = function () {\r\n this._observers = new Array();\r\n this._onObserverAdded = null;\r\n };\r\n /**\r\n * Clone the current observable\r\n * @returns a new observable\r\n */\r\n Observable.prototype.clone = function () {\r\n var result = new Observable();\r\n result._observers = this._observers.slice(0);\r\n return result;\r\n };\r\n /**\r\n * Does this observable handles observer registered with a given mask\r\n * @param mask defines the mask to be tested\r\n * @return whether or not one observer registered with the given mask is handeled\r\n **/\r\n Observable.prototype.hasSpecificMask = function (mask) {\r\n if (mask === void 0) { mask = -1; }\r\n for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {\r\n var obs = _a[_i];\r\n if (obs.mask & mask || obs.mask === mask) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n return Observable;\r\n}());\r\nexport { Observable };\r\n//# sourceMappingURL=observable.js.map","/**\r\n * Logger used througouht the application to allow configuration of\r\n * the log level required for the messages.\r\n */\r\nvar Logger = /** @class */ (function () {\r\n function Logger() {\r\n }\r\n Logger._AddLogEntry = function (entry) {\r\n Logger._LogCache = entry + Logger._LogCache;\r\n if (Logger.OnNewCacheEntry) {\r\n Logger.OnNewCacheEntry(entry);\r\n }\r\n };\r\n Logger._FormatMessage = function (message) {\r\n var padStr = function (i) { return (i < 10) ? \"0\" + i : \"\" + i; };\r\n var date = new Date();\r\n return \"[\" + padStr(date.getHours()) + \":\" + padStr(date.getMinutes()) + \":\" + padStr(date.getSeconds()) + \"]: \" + message;\r\n };\r\n Logger._LogDisabled = function (message) {\r\n // nothing to do\r\n };\r\n Logger._LogEnabled = function (message) {\r\n var formattedMessage = Logger._FormatMessage(message);\r\n console.log(\"BJS - \" + formattedMessage);\r\n var entry = \"
\" + formattedMessage + \"

\";\r\n Logger._AddLogEntry(entry);\r\n };\r\n Logger._WarnDisabled = function (message) {\r\n // nothing to do\r\n };\r\n Logger._WarnEnabled = function (message) {\r\n var formattedMessage = Logger._FormatMessage(message);\r\n console.warn(\"BJS - \" + formattedMessage);\r\n var entry = \"
\" + formattedMessage + \"

\";\r\n Logger._AddLogEntry(entry);\r\n };\r\n Logger._ErrorDisabled = function (message) {\r\n // nothing to do\r\n };\r\n Logger._ErrorEnabled = function (message) {\r\n Logger.errorsCount++;\r\n var formattedMessage = Logger._FormatMessage(message);\r\n console.error(\"BJS - \" + formattedMessage);\r\n var entry = \"
\" + formattedMessage + \"

\";\r\n Logger._AddLogEntry(entry);\r\n };\r\n Object.defineProperty(Logger, \"LogCache\", {\r\n /**\r\n * Gets current log cache (list of logs)\r\n */\r\n get: function () {\r\n return Logger._LogCache;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Clears the log cache\r\n */\r\n Logger.ClearLogCache = function () {\r\n Logger._LogCache = \"\";\r\n Logger.errorsCount = 0;\r\n };\r\n Object.defineProperty(Logger, \"LogLevels\", {\r\n /**\r\n * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)\r\n */\r\n set: function (level) {\r\n if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {\r\n Logger.Log = Logger._LogEnabled;\r\n }\r\n else {\r\n Logger.Log = Logger._LogDisabled;\r\n }\r\n if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {\r\n Logger.Warn = Logger._WarnEnabled;\r\n }\r\n else {\r\n Logger.Warn = Logger._WarnDisabled;\r\n }\r\n if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {\r\n Logger.Error = Logger._ErrorEnabled;\r\n }\r\n else {\r\n Logger.Error = Logger._ErrorDisabled;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * No log\r\n */\r\n Logger.NoneLogLevel = 0;\r\n /**\r\n * Only message logs\r\n */\r\n Logger.MessageLogLevel = 1;\r\n /**\r\n * Only warning logs\r\n */\r\n Logger.WarningLogLevel = 2;\r\n /**\r\n * Only error logs\r\n */\r\n Logger.ErrorLogLevel = 4;\r\n /**\r\n * All logs\r\n */\r\n Logger.AllLogLevel = 7;\r\n Logger._LogCache = \"\";\r\n /**\r\n * Gets a value indicating the number of loading errors\r\n * @ignorenaming\r\n */\r\n Logger.errorsCount = 0;\r\n /**\r\n * Log a message to the console\r\n */\r\n Logger.Log = Logger._LogEnabled;\r\n /**\r\n * Write a warning message to the console\r\n */\r\n Logger.Warn = Logger._WarnEnabled;\r\n /**\r\n * Write an error message to the console\r\n */\r\n Logger.Error = Logger._ErrorEnabled;\r\n return Logger;\r\n}());\r\nexport { Logger };\r\n//# sourceMappingURL=logger.js.map","import { Observable } from \"../Misc/observable\";\r\nimport { DomManagement } from \"../Misc/domManagement\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { ShaderProcessor } from '../Engines/Processors/shaderProcessor';\r\n/**\r\n * Effect containing vertex and fragment shader that can be executed on an object.\r\n */\r\nvar Effect = /** @class */ (function () {\r\n /**\r\n * Instantiates an effect.\r\n * An effect can be used to create/manage/execute vertex and fragment shaders.\r\n * @param baseName Name of the effect.\r\n * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.\r\n * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.\r\n * @param samplers List of sampler variables that will be passed to the shader.\r\n * @param engine Engine to be used to render the effect\r\n * @param defines Define statements to be added to the shader.\r\n * @param fallbacks Possible fallbacks for this effect to improve performance when needed.\r\n * @param onCompiled Callback that will be called when the shader is compiled.\r\n * @param onError Callback that will be called if an error occurs during shader compilation.\r\n * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})\r\n */\r\n function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {\r\n var _this = this;\r\n if (samplers === void 0) { samplers = null; }\r\n if (defines === void 0) { defines = null; }\r\n if (fallbacks === void 0) { fallbacks = null; }\r\n if (onCompiled === void 0) { onCompiled = null; }\r\n if (onError === void 0) { onError = null; }\r\n /**\r\n * Name of the effect.\r\n */\r\n this.name = null;\r\n /**\r\n * String container all the define statements that should be set on the shader.\r\n */\r\n this.defines = \"\";\r\n /**\r\n * Callback that will be called when the shader is compiled.\r\n */\r\n this.onCompiled = null;\r\n /**\r\n * Callback that will be called if an error occurs during shader compilation.\r\n */\r\n this.onError = null;\r\n /**\r\n * Callback that will be called when effect is bound.\r\n */\r\n this.onBind = null;\r\n /**\r\n * Unique ID of the effect.\r\n */\r\n this.uniqueId = 0;\r\n /**\r\n * Observable that will be called when the shader is compiled.\r\n * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.\r\n */\r\n this.onCompileObservable = new Observable();\r\n /**\r\n * Observable that will be called if an error occurs during shader compilation.\r\n */\r\n this.onErrorObservable = new Observable();\r\n /** @hidden */\r\n this._onBindObservable = null;\r\n /**\r\n * @hidden\r\n * Specifies if the effect was previously ready\r\n */\r\n this._wasPreviouslyReady = false;\r\n /** @hidden */\r\n this._bonesComputationForcedToCPU = false;\r\n this._uniformBuffersNames = {};\r\n this._samplers = {};\r\n this._isReady = false;\r\n this._compilationError = \"\";\r\n this._allFallbacksProcessed = false;\r\n this._uniforms = {};\r\n /**\r\n * Key for the effect.\r\n * @hidden\r\n */\r\n this._key = \"\";\r\n this._fallbacks = null;\r\n this._vertexSourceCode = \"\";\r\n this._fragmentSourceCode = \"\";\r\n this._vertexSourceCodeOverride = \"\";\r\n this._fragmentSourceCodeOverride = \"\";\r\n this._transformFeedbackVaryings = null;\r\n /**\r\n * Compiled shader to webGL program.\r\n * @hidden\r\n */\r\n this._pipelineContext = null;\r\n this._valueCache = {};\r\n this.name = baseName;\r\n if (attributesNamesOrOptions.attributes) {\r\n var options = attributesNamesOrOptions;\r\n this._engine = uniformsNamesOrEngine;\r\n this._attributesNames = options.attributes;\r\n this._uniformsNames = options.uniformsNames.concat(options.samplers);\r\n this._samplerList = options.samplers.slice();\r\n this.defines = options.defines;\r\n this.onError = options.onError;\r\n this.onCompiled = options.onCompiled;\r\n this._fallbacks = options.fallbacks;\r\n this._indexParameters = options.indexParameters;\r\n this._transformFeedbackVaryings = options.transformFeedbackVaryings || null;\r\n if (options.uniformBuffersNames) {\r\n for (var i = 0; i < options.uniformBuffersNames.length; i++) {\r\n this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;\r\n }\r\n }\r\n }\r\n else {\r\n this._engine = engine;\r\n this.defines = (defines == null ? \"\" : defines);\r\n this._uniformsNames = uniformsNamesOrEngine.concat(samplers);\r\n this._samplerList = samplers ? samplers.slice() : [];\r\n this._attributesNames = attributesNamesOrOptions;\r\n this.onError = onError;\r\n this.onCompiled = onCompiled;\r\n this._indexParameters = indexParameters;\r\n this._fallbacks = fallbacks;\r\n }\r\n this._attributeLocationByName = {};\r\n this.uniqueId = Effect._uniqueIdSeed++;\r\n var vertexSource;\r\n var fragmentSource;\r\n var hostDocument = DomManagement.IsWindowObjectExist() ? this._engine.getHostDocument() : null;\r\n if (baseName.vertexSource) {\r\n vertexSource = \"source:\" + baseName.vertexSource;\r\n }\r\n else if (baseName.vertexElement) {\r\n vertexSource = hostDocument ? hostDocument.getElementById(baseName.vertexElement) : null;\r\n if (!vertexSource) {\r\n vertexSource = baseName.vertexElement;\r\n }\r\n }\r\n else {\r\n vertexSource = baseName.vertex || baseName;\r\n }\r\n if (baseName.fragmentSource) {\r\n fragmentSource = \"source:\" + baseName.fragmentSource;\r\n }\r\n else if (baseName.fragmentElement) {\r\n fragmentSource = hostDocument ? hostDocument.getElementById(baseName.fragmentElement) : null;\r\n if (!fragmentSource) {\r\n fragmentSource = baseName.fragmentElement;\r\n }\r\n }\r\n else {\r\n fragmentSource = baseName.fragment || baseName;\r\n }\r\n var processorOptions = {\r\n defines: this.defines.split(\"\\n\"),\r\n indexParameters: this._indexParameters,\r\n isFragment: false,\r\n shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader,\r\n processor: this._engine._shaderProcessor,\r\n supportsUniformBuffers: this._engine.supportsUniformBuffers,\r\n shadersRepository: Effect.ShadersRepository,\r\n includesShadersStore: Effect.IncludesShadersStore,\r\n version: (this._engine.webGLVersion * 100).toString(),\r\n platformName: this._engine.webGLVersion >= 2 ? \"WEBGL2\" : \"WEBGL1\"\r\n };\r\n this._loadShader(vertexSource, \"Vertex\", \"\", function (vertexCode) {\r\n _this._loadShader(fragmentSource, \"Fragment\", \"Pixel\", function (fragmentCode) {\r\n ShaderProcessor.Process(vertexCode, processorOptions, function (migratedVertexCode) {\r\n processorOptions.isFragment = true;\r\n ShaderProcessor.Process(fragmentCode, processorOptions, function (migratedFragmentCode) {\r\n _this._useFinalCode(migratedVertexCode, migratedFragmentCode, baseName);\r\n });\r\n });\r\n });\r\n });\r\n }\r\n Object.defineProperty(Effect.prototype, \"onBindObservable\", {\r\n /**\r\n * Observable that will be called when effect is bound.\r\n */\r\n get: function () {\r\n if (!this._onBindObservable) {\r\n this._onBindObservable = new Observable();\r\n }\r\n return this._onBindObservable;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Effect.prototype._useFinalCode = function (migratedVertexCode, migratedFragmentCode, baseName) {\r\n if (baseName) {\r\n var vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;\r\n var fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;\r\n this._vertexSourceCode = \"#define SHADER_NAME vertex:\" + vertex + \"\\n\" + migratedVertexCode;\r\n this._fragmentSourceCode = \"#define SHADER_NAME fragment:\" + fragment + \"\\n\" + migratedFragmentCode;\r\n }\r\n else {\r\n this._vertexSourceCode = migratedVertexCode;\r\n this._fragmentSourceCode = migratedFragmentCode;\r\n }\r\n this._prepareEffect();\r\n };\r\n Object.defineProperty(Effect.prototype, \"key\", {\r\n /**\r\n * Unique key for this effect\r\n */\r\n get: function () {\r\n return this._key;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * If the effect has been compiled and prepared.\r\n * @returns if the effect is compiled and prepared.\r\n */\r\n Effect.prototype.isReady = function () {\r\n try {\r\n return this._isReadyInternal();\r\n }\r\n catch (_a) {\r\n return false;\r\n }\r\n };\r\n Effect.prototype._isReadyInternal = function () {\r\n if (this._isReady) {\r\n return true;\r\n }\r\n if (this._pipelineContext) {\r\n return this._pipelineContext.isReady;\r\n }\r\n return false;\r\n };\r\n /**\r\n * The engine the effect was initialized with.\r\n * @returns the engine.\r\n */\r\n Effect.prototype.getEngine = function () {\r\n return this._engine;\r\n };\r\n /**\r\n * The pipeline context for this effect\r\n * @returns the associated pipeline context\r\n */\r\n Effect.prototype.getPipelineContext = function () {\r\n return this._pipelineContext;\r\n };\r\n /**\r\n * The set of names of attribute variables for the shader.\r\n * @returns An array of attribute names.\r\n */\r\n Effect.prototype.getAttributesNames = function () {\r\n return this._attributesNames;\r\n };\r\n /**\r\n * Returns the attribute at the given index.\r\n * @param index The index of the attribute.\r\n * @returns The location of the attribute.\r\n */\r\n Effect.prototype.getAttributeLocation = function (index) {\r\n return this._attributes[index];\r\n };\r\n /**\r\n * Returns the attribute based on the name of the variable.\r\n * @param name of the attribute to look up.\r\n * @returns the attribute location.\r\n */\r\n Effect.prototype.getAttributeLocationByName = function (name) {\r\n return this._attributeLocationByName[name];\r\n };\r\n /**\r\n * The number of attributes.\r\n * @returns the numnber of attributes.\r\n */\r\n Effect.prototype.getAttributesCount = function () {\r\n return this._attributes.length;\r\n };\r\n /**\r\n * Gets the index of a uniform variable.\r\n * @param uniformName of the uniform to look up.\r\n * @returns the index.\r\n */\r\n Effect.prototype.getUniformIndex = function (uniformName) {\r\n return this._uniformsNames.indexOf(uniformName);\r\n };\r\n /**\r\n * Returns the attribute based on the name of the variable.\r\n * @param uniformName of the uniform to look up.\r\n * @returns the location of the uniform.\r\n */\r\n Effect.prototype.getUniform = function (uniformName) {\r\n return this._uniforms[uniformName];\r\n };\r\n /**\r\n * Returns an array of sampler variable names\r\n * @returns The array of sampler variable neames.\r\n */\r\n Effect.prototype.getSamplers = function () {\r\n return this._samplerList;\r\n };\r\n /**\r\n * The error from the last compilation.\r\n * @returns the error string.\r\n */\r\n Effect.prototype.getCompilationError = function () {\r\n return this._compilationError;\r\n };\r\n /**\r\n * Gets a boolean indicating that all fallbacks were used during compilation\r\n * @returns true if all fallbacks were used\r\n */\r\n Effect.prototype.allFallbacksProcessed = function () {\r\n return this._allFallbacksProcessed;\r\n };\r\n /**\r\n * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.\r\n * @param func The callback to be used.\r\n */\r\n Effect.prototype.executeWhenCompiled = function (func) {\r\n var _this = this;\r\n if (this.isReady()) {\r\n func(this);\r\n return;\r\n }\r\n this.onCompileObservable.add(function (effect) {\r\n func(effect);\r\n });\r\n if (!this._pipelineContext || this._pipelineContext.isAsync) {\r\n setTimeout(function () {\r\n _this._checkIsReady(null);\r\n }, 16);\r\n }\r\n };\r\n Effect.prototype._checkIsReady = function (previousPipelineContext) {\r\n var _this = this;\r\n try {\r\n if (this._isReadyInternal()) {\r\n return;\r\n }\r\n }\r\n catch (e) {\r\n this._processCompilationErrors(e, previousPipelineContext);\r\n return;\r\n }\r\n setTimeout(function () {\r\n _this._checkIsReady(previousPipelineContext);\r\n }, 16);\r\n };\r\n Effect.prototype._loadShader = function (shader, key, optionalKey, callback) {\r\n if (typeof (HTMLElement) !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n var shaderCode = DomManagement.GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n // Direct source ?\r\n if (shader.substr(0, 7) === \"source:\") {\r\n callback(shader.substr(7));\r\n return;\r\n }\r\n // Base64 encoded ?\r\n if (shader.substr(0, 7) === \"base64:\") {\r\n var shaderBinary = window.atob(shader.substr(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n // Is in local store ?\r\n if (Effect.ShadersStore[shader + key + \"Shader\"]) {\r\n callback(Effect.ShadersStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n if (optionalKey && Effect.ShadersStore[shader + optionalKey + \"Shader\"]) {\r\n callback(Effect.ShadersStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n var shaderUrl;\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n }\r\n else {\r\n shaderUrl = Effect.ShadersRepository + shader;\r\n }\r\n // Vertex shader\r\n this._engine._loadFile(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n };\r\n /**\r\n * Recompiles the webGL program\r\n * @param vertexSourceCode The source code for the vertex shader.\r\n * @param fragmentSourceCode The source code for the fragment shader.\r\n * @param onCompiled Callback called when completed.\r\n * @param onError Callback called on error.\r\n * @hidden\r\n */\r\n Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {\r\n var _this = this;\r\n this._isReady = false;\r\n this._vertexSourceCodeOverride = vertexSourceCode;\r\n this._fragmentSourceCodeOverride = fragmentSourceCode;\r\n this.onError = function (effect, error) {\r\n if (onError) {\r\n onError(error);\r\n }\r\n };\r\n this.onCompiled = function () {\r\n var scenes = _this.getEngine().scenes;\r\n if (scenes) {\r\n for (var i = 0; i < scenes.length; i++) {\r\n scenes[i].markAllMaterialsAsDirty(31);\r\n }\r\n }\r\n _this._pipelineContext._handlesSpectorRebuildCallback(onCompiled);\r\n };\r\n this._fallbacks = null;\r\n this._prepareEffect();\r\n };\r\n /**\r\n * Prepares the effect\r\n * @hidden\r\n */\r\n Effect.prototype._prepareEffect = function () {\r\n var _this = this;\r\n var attributesNames = this._attributesNames;\r\n var defines = this.defines;\r\n this._valueCache = {};\r\n var previousPipelineContext = this._pipelineContext;\r\n try {\r\n var engine_1 = this._engine;\r\n this._pipelineContext = engine_1.createPipelineContext();\r\n var rebuildRebind = this._rebuildProgram.bind(this);\r\n if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {\r\n engine_1._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, true, rebuildRebind, null, this._transformFeedbackVaryings);\r\n }\r\n else {\r\n engine_1._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, false, rebuildRebind, defines, this._transformFeedbackVaryings);\r\n }\r\n engine_1._executeWhenRenderingStateIsCompiled(this._pipelineContext, function () {\r\n if (engine_1.supportsUniformBuffers) {\r\n for (var name in _this._uniformBuffersNames) {\r\n _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);\r\n }\r\n }\r\n var uniforms = engine_1.getUniforms(_this._pipelineContext, _this._uniformsNames);\r\n uniforms.forEach(function (uniform, index) {\r\n _this._uniforms[_this._uniformsNames[index]] = uniform;\r\n });\r\n _this._attributes = engine_1.getAttributes(_this._pipelineContext, attributesNames);\r\n if (attributesNames) {\r\n for (var i = 0; i < attributesNames.length; i++) {\r\n var name_1 = attributesNames[i];\r\n _this._attributeLocationByName[name_1] = _this._attributes[i];\r\n }\r\n }\r\n var index;\r\n for (index = 0; index < _this._samplerList.length; index++) {\r\n var sampler = _this.getUniform(_this._samplerList[index]);\r\n if (sampler == null) {\r\n _this._samplerList.splice(index, 1);\r\n index--;\r\n }\r\n }\r\n _this._samplerList.forEach(function (name, index) {\r\n _this._samplers[name] = index;\r\n });\r\n engine_1.bindSamplers(_this);\r\n _this._compilationError = \"\";\r\n _this._isReady = true;\r\n if (_this.onCompiled) {\r\n _this.onCompiled(_this);\r\n }\r\n _this.onCompileObservable.notifyObservers(_this);\r\n _this.onCompileObservable.clear();\r\n // Unbind mesh reference in fallbacks\r\n if (_this._fallbacks) {\r\n _this._fallbacks.unBindMesh();\r\n }\r\n if (previousPipelineContext) {\r\n _this.getEngine()._deletePipelineContext(previousPipelineContext);\r\n }\r\n });\r\n if (this._pipelineContext.isAsync) {\r\n this._checkIsReady(previousPipelineContext);\r\n }\r\n }\r\n catch (e) {\r\n this._processCompilationErrors(e, previousPipelineContext);\r\n }\r\n };\r\n Effect.prototype._processCompilationErrors = function (e, previousPipelineContext) {\r\n if (previousPipelineContext === void 0) { previousPipelineContext = null; }\r\n this._compilationError = e.message;\r\n var attributesNames = this._attributesNames;\r\n var fallbacks = this._fallbacks;\r\n // Let's go through fallbacks then\r\n Logger.Error(\"Unable to compile effect:\");\r\n Logger.Error(\"Uniforms: \" + this._uniformsNames.map(function (uniform) {\r\n return \" \" + uniform;\r\n }));\r\n Logger.Error(\"Attributes: \" + attributesNames.map(function (attribute) {\r\n return \" \" + attribute;\r\n }));\r\n Logger.Error(\"Defines:\\r\\n\" + this.defines);\r\n Logger.Error(\"Error: \" + this._compilationError);\r\n if (previousPipelineContext) {\r\n this._pipelineContext = previousPipelineContext;\r\n this._isReady = true;\r\n if (this.onError) {\r\n this.onError(this, this._compilationError);\r\n }\r\n this.onErrorObservable.notifyObservers(this);\r\n }\r\n if (fallbacks) {\r\n this._pipelineContext = null;\r\n if (fallbacks.hasMoreFallbacks) {\r\n this._allFallbacksProcessed = false;\r\n Logger.Error(\"Trying next fallback.\");\r\n this.defines = fallbacks.reduce(this.defines, this);\r\n this._prepareEffect();\r\n }\r\n else { // Sorry we did everything we can\r\n this._allFallbacksProcessed = true;\r\n if (this.onError) {\r\n this.onError(this, this._compilationError);\r\n }\r\n this.onErrorObservable.notifyObservers(this);\r\n this.onErrorObservable.clear();\r\n // Unbind mesh reference in fallbacks\r\n if (this._fallbacks) {\r\n this._fallbacks.unBindMesh();\r\n }\r\n }\r\n }\r\n else {\r\n this._allFallbacksProcessed = true;\r\n }\r\n };\r\n Object.defineProperty(Effect.prototype, \"isSupported\", {\r\n /**\r\n * Checks if the effect is supported. (Must be called after compilation)\r\n */\r\n get: function () {\r\n return this._compilationError === \"\";\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Binds a texture to the engine to be used as output of the shader.\r\n * @param channel Name of the output variable.\r\n * @param texture Texture to bind.\r\n * @hidden\r\n */\r\n Effect.prototype._bindTexture = function (channel, texture) {\r\n this._engine._bindTexture(this._samplers[channel], texture);\r\n };\r\n /**\r\n * Sets a texture on the engine to be used in the shader.\r\n * @param channel Name of the sampler variable.\r\n * @param texture Texture to set.\r\n */\r\n Effect.prototype.setTexture = function (channel, texture) {\r\n this._engine.setTexture(this._samplers[channel], this._uniforms[channel], texture);\r\n };\r\n /**\r\n * Sets a depth stencil texture from a render target on the engine to be used in the shader.\r\n * @param channel Name of the sampler variable.\r\n * @param texture Texture to set.\r\n */\r\n Effect.prototype.setDepthStencilTexture = function (channel, texture) {\r\n this._engine.setDepthStencilTexture(this._samplers[channel], this._uniforms[channel], texture);\r\n };\r\n /**\r\n * Sets an array of textures on the engine to be used in the shader.\r\n * @param channel Name of the variable.\r\n * @param textures Textures to set.\r\n */\r\n Effect.prototype.setTextureArray = function (channel, textures) {\r\n var exName = channel + \"Ex\";\r\n if (this._samplerList.indexOf(exName + \"0\") === -1) {\r\n var initialPos = this._samplerList.indexOf(channel);\r\n for (var index = 1; index < textures.length; index++) {\r\n var currentExName = exName + (index - 1).toString();\r\n this._samplerList.splice(initialPos + index, 0, currentExName);\r\n }\r\n // Reset every channels\r\n var channelIndex = 0;\r\n for (var _i = 0, _a = this._samplerList; _i < _a.length; _i++) {\r\n var key = _a[_i];\r\n this._samplers[key] = channelIndex;\r\n channelIndex += 1;\r\n }\r\n }\r\n this._engine.setTextureArray(this._samplers[channel], this._uniforms[channel], textures);\r\n };\r\n /**\r\n * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)\r\n * @param channel Name of the sampler variable.\r\n * @param postProcess Post process to get the input texture from.\r\n */\r\n Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {\r\n this._engine.setTextureFromPostProcess(this._samplers[channel], postProcess);\r\n };\r\n /**\r\n * (Warning! setTextureFromPostProcessOutput may be desired instead)\r\n * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)\r\n * @param channel Name of the sampler variable.\r\n * @param postProcess Post process to get the output texture from.\r\n */\r\n Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {\r\n this._engine.setTextureFromPostProcessOutput(this._samplers[channel], postProcess);\r\n };\r\n /** @hidden */\r\n Effect.prototype._cacheMatrix = function (uniformName, matrix) {\r\n var cache = this._valueCache[uniformName];\r\n var flag = matrix.updateFlag;\r\n if (cache !== undefined && cache === flag) {\r\n return false;\r\n }\r\n this._valueCache[uniformName] = flag;\r\n return true;\r\n };\r\n /** @hidden */\r\n Effect.prototype._cacheFloat2 = function (uniformName, x, y) {\r\n var cache = this._valueCache[uniformName];\r\n if (!cache || cache.length !== 2) {\r\n cache = [x, y];\r\n this._valueCache[uniformName] = cache;\r\n return true;\r\n }\r\n var changed = false;\r\n if (cache[0] !== x) {\r\n cache[0] = x;\r\n changed = true;\r\n }\r\n if (cache[1] !== y) {\r\n cache[1] = y;\r\n changed = true;\r\n }\r\n return changed;\r\n };\r\n /** @hidden */\r\n Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {\r\n var cache = this._valueCache[uniformName];\r\n if (!cache || cache.length !== 3) {\r\n cache = [x, y, z];\r\n this._valueCache[uniformName] = cache;\r\n return true;\r\n }\r\n var changed = false;\r\n if (cache[0] !== x) {\r\n cache[0] = x;\r\n changed = true;\r\n }\r\n if (cache[1] !== y) {\r\n cache[1] = y;\r\n changed = true;\r\n }\r\n if (cache[2] !== z) {\r\n cache[2] = z;\r\n changed = true;\r\n }\r\n return changed;\r\n };\r\n /** @hidden */\r\n Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {\r\n var cache = this._valueCache[uniformName];\r\n if (!cache || cache.length !== 4) {\r\n cache = [x, y, z, w];\r\n this._valueCache[uniformName] = cache;\r\n return true;\r\n }\r\n var changed = false;\r\n if (cache[0] !== x) {\r\n cache[0] = x;\r\n changed = true;\r\n }\r\n if (cache[1] !== y) {\r\n cache[1] = y;\r\n changed = true;\r\n }\r\n if (cache[2] !== z) {\r\n cache[2] = z;\r\n changed = true;\r\n }\r\n if (cache[3] !== w) {\r\n cache[3] = w;\r\n changed = true;\r\n }\r\n return changed;\r\n };\r\n /**\r\n * Binds a buffer to a uniform.\r\n * @param buffer Buffer to bind.\r\n * @param name Name of the uniform variable to bind to.\r\n */\r\n Effect.prototype.bindUniformBuffer = function (buffer, name) {\r\n var bufferName = this._uniformBuffersNames[name];\r\n if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {\r\n return;\r\n }\r\n Effect._baseCache[bufferName] = buffer;\r\n this._engine.bindUniformBufferBase(buffer, bufferName);\r\n };\r\n /**\r\n * Binds block to a uniform.\r\n * @param blockName Name of the block to bind.\r\n * @param index Index to bind.\r\n */\r\n Effect.prototype.bindUniformBlock = function (blockName, index) {\r\n this._engine.bindUniformBlock(this._pipelineContext, blockName, index);\r\n };\r\n /**\r\n * Sets an interger value on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param value Value to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setInt = function (uniformName, value) {\r\n var cache = this._valueCache[uniformName];\r\n if (cache !== undefined && cache === value) {\r\n return this;\r\n }\r\n this._valueCache[uniformName] = value;\r\n this._engine.setInt(this._uniforms[uniformName], value);\r\n return this;\r\n };\r\n /**\r\n * Sets an int array on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setIntArray = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setIntArray(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setIntArray2 = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setIntArray2(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setIntArray3 = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setIntArray3(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setIntArray4 = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setIntArray4(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an float array on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setFloatArray = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setArray(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setFloatArray2 = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setArray2(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setFloatArray3 = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setArray3(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setFloatArray4 = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setArray4(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an array on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setArray = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setArray(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setArray2 = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setArray2(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setArray3 = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setArray3(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)\r\n * @param uniformName Name of the variable.\r\n * @param array array to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setArray4 = function (uniformName, array) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setArray4(this._uniforms[uniformName], array);\r\n return this;\r\n };\r\n /**\r\n * Sets matrices on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param matrices matrices to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setMatrices = function (uniformName, matrices) {\r\n if (!matrices) {\r\n return this;\r\n }\r\n this._valueCache[uniformName] = null;\r\n this._engine.setMatrices(this._uniforms[uniformName], matrices);\r\n return this;\r\n };\r\n /**\r\n * Sets matrix on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param matrix matrix to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setMatrix = function (uniformName, matrix) {\r\n if (this._cacheMatrix(uniformName, matrix)) {\r\n this._engine.setMatrices(this._uniforms[uniformName], matrix.toArray());\r\n }\r\n return this;\r\n };\r\n /**\r\n * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)\r\n * @param uniformName Name of the variable.\r\n * @param matrix matrix to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setMatrix3x3(this._uniforms[uniformName], matrix);\r\n return this;\r\n };\r\n /**\r\n * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)\r\n * @param uniformName Name of the variable.\r\n * @param matrix matrix to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {\r\n this._valueCache[uniformName] = null;\r\n this._engine.setMatrix2x2(this._uniforms[uniformName], matrix);\r\n return this;\r\n };\r\n /**\r\n * Sets a float on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param value value to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setFloat = function (uniformName, value) {\r\n var cache = this._valueCache[uniformName];\r\n if (cache !== undefined && cache === value) {\r\n return this;\r\n }\r\n this._valueCache[uniformName] = value;\r\n this._engine.setFloat(this._uniforms[uniformName], value);\r\n return this;\r\n };\r\n /**\r\n * Sets a boolean on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param bool value to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setBool = function (uniformName, bool) {\r\n var cache = this._valueCache[uniformName];\r\n if (cache !== undefined && cache === bool) {\r\n return this;\r\n }\r\n this._valueCache[uniformName] = bool;\r\n this._engine.setInt(this._uniforms[uniformName], bool ? 1 : 0);\r\n return this;\r\n };\r\n /**\r\n * Sets a Vector2 on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param vector2 vector2 to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setVector2 = function (uniformName, vector2) {\r\n if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {\r\n this._engine.setFloat2(this._uniforms[uniformName], vector2.x, vector2.y);\r\n }\r\n return this;\r\n };\r\n /**\r\n * Sets a float2 on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param x First float in float2.\r\n * @param y Second float in float2.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setFloat2 = function (uniformName, x, y) {\r\n if (this._cacheFloat2(uniformName, x, y)) {\r\n this._engine.setFloat2(this._uniforms[uniformName], x, y);\r\n }\r\n return this;\r\n };\r\n /**\r\n * Sets a Vector3 on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param vector3 Value to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setVector3 = function (uniformName, vector3) {\r\n if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {\r\n this._engine.setFloat3(this._uniforms[uniformName], vector3.x, vector3.y, vector3.z);\r\n }\r\n return this;\r\n };\r\n /**\r\n * Sets a float3 on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param x First float in float3.\r\n * @param y Second float in float3.\r\n * @param z Third float in float3.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setFloat3 = function (uniformName, x, y, z) {\r\n if (this._cacheFloat3(uniformName, x, y, z)) {\r\n this._engine.setFloat3(this._uniforms[uniformName], x, y, z);\r\n }\r\n return this;\r\n };\r\n /**\r\n * Sets a Vector4 on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param vector4 Value to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setVector4 = function (uniformName, vector4) {\r\n if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {\r\n this._engine.setFloat4(this._uniforms[uniformName], vector4.x, vector4.y, vector4.z, vector4.w);\r\n }\r\n return this;\r\n };\r\n /**\r\n * Sets a float4 on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param x First float in float4.\r\n * @param y Second float in float4.\r\n * @param z Third float in float4.\r\n * @param w Fourth float in float4.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {\r\n if (this._cacheFloat4(uniformName, x, y, z, w)) {\r\n this._engine.setFloat4(this._uniforms[uniformName], x, y, z, w);\r\n }\r\n return this;\r\n };\r\n /**\r\n * Sets a Color3 on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param color3 Value to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setColor3 = function (uniformName, color3) {\r\n if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {\r\n this._engine.setFloat3(this._uniforms[uniformName], color3.r, color3.g, color3.b);\r\n }\r\n return this;\r\n };\r\n /**\r\n * Sets a Color4 on a uniform variable.\r\n * @param uniformName Name of the variable.\r\n * @param color3 Value to be set.\r\n * @param alpha Alpha value to be set.\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setColor4 = function (uniformName, color3, alpha) {\r\n if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {\r\n this._engine.setFloat4(this._uniforms[uniformName], color3.r, color3.g, color3.b, alpha);\r\n }\r\n return this;\r\n };\r\n /**\r\n * Sets a Color4 on a uniform variable\r\n * @param uniformName defines the name of the variable\r\n * @param color4 defines the value to be set\r\n * @returns this effect.\r\n */\r\n Effect.prototype.setDirectColor4 = function (uniformName, color4) {\r\n if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {\r\n this._engine.setFloat4(this._uniforms[uniformName], color4.r, color4.g, color4.b, color4.a);\r\n }\r\n return this;\r\n };\r\n /** Release all associated resources */\r\n Effect.prototype.dispose = function () {\r\n this._engine._releaseEffect(this);\r\n };\r\n /**\r\n * This function will add a new shader to the shader store\r\n * @param name the name of the shader\r\n * @param pixelShader optional pixel shader content\r\n * @param vertexShader optional vertex shader content\r\n */\r\n Effect.RegisterShader = function (name, pixelShader, vertexShader) {\r\n if (pixelShader) {\r\n Effect.ShadersStore[name + \"PixelShader\"] = pixelShader;\r\n }\r\n if (vertexShader) {\r\n Effect.ShadersStore[name + \"VertexShader\"] = vertexShader;\r\n }\r\n };\r\n /**\r\n * Resets the cache of effects.\r\n */\r\n Effect.ResetCache = function () {\r\n Effect._baseCache = {};\r\n };\r\n /**\r\n * Gets or sets the relative url used to load shaders if using the engine in non-minified mode\r\n */\r\n Effect.ShadersRepository = \"src/Shaders/\";\r\n Effect._uniqueIdSeed = 0;\r\n Effect._baseCache = {};\r\n /**\r\n * Store of each shader (The can be looked up using effect.key)\r\n */\r\n Effect.ShadersStore = {};\r\n /**\r\n * Store of each included file for a shader (The can be looked up using effect.key)\r\n */\r\n Effect.IncludesShadersStore = {};\r\n return Effect;\r\n}());\r\nexport { Effect };\r\n//# sourceMappingURL=effect.js.map","import { ThinEngine } from \"../../Engines/thinEngine\";\r\nThinEngine.prototype.setAlphaConstants = function (r, g, b, a) {\r\n this._alphaState.setAlphaBlendConstants(r, g, b, a);\r\n};\r\nThinEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {\r\n if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }\r\n if (this._alphaMode === mode) {\r\n return;\r\n }\r\n switch (mode) {\r\n case 0:\r\n this._alphaState.alphaBlend = false;\r\n break;\r\n case 7:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 8:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 2:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 6:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 1:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 3:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 4:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 5:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 9:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 10:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 11:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ONE);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 12:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ZERO);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 13:\r\n 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);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 14:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 15:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ZERO);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n case 16:\r\n this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ZERO, this._gl.ONE);\r\n this._alphaState.alphaBlend = true;\r\n break;\r\n }\r\n if (!noDepthWriteChange) {\r\n this.depthCullingState.depthMask = (mode === 0);\r\n }\r\n this._alphaMode = mode;\r\n};\r\nThinEngine.prototype.getAlphaMode = function () {\r\n return this._alphaMode;\r\n};\r\nThinEngine.prototype.setAlphaEquation = function (equation) {\r\n if (this._alphaEquation === equation) {\r\n return;\r\n }\r\n switch (equation) {\r\n case 0:\r\n this._alphaState.setAlphaEquationParameters(this._gl.FUNC_ADD, this._gl.FUNC_ADD);\r\n break;\r\n case 1:\r\n this._alphaState.setAlphaEquationParameters(this._gl.FUNC_SUBTRACT, this._gl.FUNC_SUBTRACT);\r\n break;\r\n case 2:\r\n this._alphaState.setAlphaEquationParameters(this._gl.FUNC_REVERSE_SUBTRACT, this._gl.FUNC_REVERSE_SUBTRACT);\r\n break;\r\n case 3:\r\n this._alphaState.setAlphaEquationParameters(this._gl.MAX, this._gl.MAX);\r\n break;\r\n case 4:\r\n this._alphaState.setAlphaEquationParameters(this._gl.MIN, this._gl.MIN);\r\n break;\r\n case 5:\r\n this._alphaState.setAlphaEquationParameters(this._gl.MIN, this._gl.FUNC_ADD);\r\n break;\r\n }\r\n this._alphaEquation = equation;\r\n};\r\nThinEngine.prototype.getAlphaEquation = function () {\r\n return this._alphaEquation;\r\n};\r\n//# sourceMappingURL=engine.alpha.js.map","import { __extends } from \"tslib\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { DomManagement } from \"../Misc/domManagement\";\r\nimport { EngineStore } from \"./engineStore\";\r\nimport { _DevTools } from '../Misc/devTools';\r\nimport { ThinEngine } from './thinEngine';\r\nimport { PerformanceMonitor } from '../Misc/performanceMonitor';\r\nimport { PerfCounter } from '../Misc/perfCounter';\r\nimport { WebGLDataBuffer } from '../Meshes/WebGL/webGLDataBuffer';\r\nimport { Logger } from '../Misc/logger';\r\nimport \"./Extensions/engine.alpha\";\r\n/**\r\n * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio\r\n */\r\nvar Engine = /** @class */ (function (_super) {\r\n __extends(Engine, _super);\r\n /**\r\n * Creates a new engine\r\n * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context\r\n * @param antialias defines enable antialiasing (default: false)\r\n * @param options defines further options to be sent to the getContext() function\r\n * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)\r\n */\r\n function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {\r\n if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }\r\n var _this = _super.call(this, canvasOrContext, antialias, options, adaptToDeviceRatio) || this;\r\n // Members\r\n /**\r\n * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest\r\n **/\r\n _this.enableOfflineSupport = false;\r\n /**\r\n * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)\r\n **/\r\n _this.disableManifestCheck = false;\r\n /**\r\n * Gets the list of created scenes\r\n */\r\n _this.scenes = new Array();\r\n /**\r\n * Event raised when a new scene is created\r\n */\r\n _this.onNewSceneAddedObservable = new Observable();\r\n /**\r\n * Gets the list of created postprocesses\r\n */\r\n _this.postProcesses = new Array();\r\n /**\r\n * Gets a boolean indicating if the pointer is currently locked\r\n */\r\n _this.isPointerLock = false;\r\n // Observables\r\n /**\r\n * Observable event triggered each time the rendering canvas is resized\r\n */\r\n _this.onResizeObservable = new Observable();\r\n /**\r\n * Observable event triggered each time the canvas loses focus\r\n */\r\n _this.onCanvasBlurObservable = new Observable();\r\n /**\r\n * Observable event triggered each time the canvas gains focus\r\n */\r\n _this.onCanvasFocusObservable = new Observable();\r\n /**\r\n * Observable event triggered each time the canvas receives pointerout event\r\n */\r\n _this.onCanvasPointerOutObservable = new Observable();\r\n /**\r\n * Observable raised when the engine begins a new frame\r\n */\r\n _this.onBeginFrameObservable = new Observable();\r\n /**\r\n * If set, will be used to request the next animation frame for the render loop\r\n */\r\n _this.customAnimationFrameRequester = null;\r\n /**\r\n * Observable raised when the engine ends the current frame\r\n */\r\n _this.onEndFrameObservable = new Observable();\r\n /**\r\n * Observable raised when the engine is about to compile a shader\r\n */\r\n _this.onBeforeShaderCompilationObservable = new Observable();\r\n /**\r\n * Observable raised when the engine has jsut compiled a shader\r\n */\r\n _this.onAfterShaderCompilationObservable = new Observable();\r\n // Deterministic lockstepMaxSteps\r\n _this._deterministicLockstep = false;\r\n _this._lockstepMaxSteps = 4;\r\n _this._timeStep = 1 / 60;\r\n // FPS\r\n _this._fps = 60;\r\n _this._deltaTime = 0;\r\n /** @hidden */\r\n _this._drawCalls = new PerfCounter();\r\n /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */\r\n _this.canvasTabIndex = 1;\r\n /**\r\n * Turn this value on if you want to pause FPS computation when in background\r\n */\r\n _this.disablePerformanceMonitorInBackground = false;\r\n _this._performanceMonitor = new PerformanceMonitor();\r\n if (!canvasOrContext) {\r\n return _this;\r\n }\r\n options = _this._creationOptions;\r\n Engine.Instances.push(_this);\r\n if (canvasOrContext.getContext) {\r\n var canvas_1 = canvasOrContext;\r\n _this._onCanvasFocus = function () {\r\n _this.onCanvasFocusObservable.notifyObservers(_this);\r\n };\r\n _this._onCanvasBlur = function () {\r\n _this.onCanvasBlurObservable.notifyObservers(_this);\r\n };\r\n canvas_1.addEventListener(\"focus\", _this._onCanvasFocus);\r\n canvas_1.addEventListener(\"blur\", _this._onCanvasBlur);\r\n _this._onBlur = function () {\r\n if (_this.disablePerformanceMonitorInBackground) {\r\n _this._performanceMonitor.disable();\r\n }\r\n _this._windowIsBackground = true;\r\n };\r\n _this._onFocus = function () {\r\n if (_this.disablePerformanceMonitorInBackground) {\r\n _this._performanceMonitor.enable();\r\n }\r\n _this._windowIsBackground = false;\r\n };\r\n _this._onCanvasPointerOut = function (ev) {\r\n _this.onCanvasPointerOutObservable.notifyObservers(ev);\r\n };\r\n canvas_1.addEventListener(\"pointerout\", _this._onCanvasPointerOut);\r\n if (DomManagement.IsWindowObjectExist()) {\r\n var hostWindow = _this.getHostWindow();\r\n hostWindow.addEventListener(\"blur\", _this._onBlur);\r\n hostWindow.addEventListener(\"focus\", _this._onFocus);\r\n var anyDoc_1 = document;\r\n // Fullscreen\r\n _this._onFullscreenChange = function () {\r\n if (anyDoc_1.fullscreen !== undefined) {\r\n _this.isFullscreen = anyDoc_1.fullscreen;\r\n }\r\n else if (anyDoc_1.mozFullScreen !== undefined) {\r\n _this.isFullscreen = anyDoc_1.mozFullScreen;\r\n }\r\n else if (anyDoc_1.webkitIsFullScreen !== undefined) {\r\n _this.isFullscreen = anyDoc_1.webkitIsFullScreen;\r\n }\r\n else if (anyDoc_1.msIsFullScreen !== undefined) {\r\n _this.isFullscreen = anyDoc_1.msIsFullScreen;\r\n }\r\n // Pointer lock\r\n if (_this.isFullscreen && _this._pointerLockRequested && canvas_1) {\r\n Engine._RequestPointerlock(canvas_1);\r\n }\r\n };\r\n document.addEventListener(\"fullscreenchange\", _this._onFullscreenChange, false);\r\n document.addEventListener(\"mozfullscreenchange\", _this._onFullscreenChange, false);\r\n document.addEventListener(\"webkitfullscreenchange\", _this._onFullscreenChange, false);\r\n document.addEventListener(\"msfullscreenchange\", _this._onFullscreenChange, false);\r\n // Pointer lock\r\n _this._onPointerLockChange = function () {\r\n _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas_1 ||\r\n anyDoc_1.webkitPointerLockElement === canvas_1 ||\r\n anyDoc_1.msPointerLockElement === canvas_1 ||\r\n anyDoc_1.pointerLockElement === canvas_1);\r\n };\r\n document.addEventListener(\"pointerlockchange\", _this._onPointerLockChange, false);\r\n document.addEventListener(\"mspointerlockchange\", _this._onPointerLockChange, false);\r\n document.addEventListener(\"mozpointerlockchange\", _this._onPointerLockChange, false);\r\n document.addEventListener(\"webkitpointerlockchange\", _this._onPointerLockChange, false);\r\n // Create Audio Engine if needed.\r\n if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {\r\n Engine.audioEngine = Engine.AudioEngineFactory(_this.getRenderingCanvas());\r\n }\r\n }\r\n _this._connectVREvents();\r\n _this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;\r\n if (!options.doNotHandleTouchAction) {\r\n _this._disableTouchAction();\r\n }\r\n _this._deterministicLockstep = !!options.deterministicLockstep;\r\n _this._lockstepMaxSteps = options.lockstepMaxSteps || 0;\r\n _this._timeStep = options.timeStep || 1 / 60;\r\n }\r\n // Load WebVR Devices\r\n _this._prepareVRComponent();\r\n if (options.autoEnableWebVR) {\r\n _this.initWebVR();\r\n }\r\n return _this;\r\n }\r\n Object.defineProperty(Engine, \"NpmPackage\", {\r\n /**\r\n * Returns the current npm package of the sdk\r\n */\r\n // Not mixed with Version for tooling purpose.\r\n get: function () {\r\n return ThinEngine.NpmPackage;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Engine, \"Version\", {\r\n /**\r\n * Returns the current version of the framework\r\n */\r\n get: function () {\r\n return ThinEngine.Version;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Engine, \"Instances\", {\r\n /** Gets the list of created engines */\r\n get: function () {\r\n return EngineStore.Instances;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Engine, \"LastCreatedEngine\", {\r\n /**\r\n * Gets the latest created engine\r\n */\r\n get: function () {\r\n return EngineStore.LastCreatedEngine;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Engine, \"LastCreatedScene\", {\r\n /**\r\n * Gets the latest created scene\r\n */\r\n get: function () {\r\n return EngineStore.LastCreatedScene;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation\r\n * @param flag defines which part of the materials must be marked as dirty\r\n * @param predicate defines a predicate used to filter which materials should be affected\r\n */\r\n Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {\r\n for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {\r\n var engine = Engine.Instances[engineIndex];\r\n for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {\r\n engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);\r\n }\r\n }\r\n };\r\n /**\r\n * Method called to create the default loading screen.\r\n * This can be overriden in your own app.\r\n * @param canvas The rendering canvas element\r\n * @returns The loading screen\r\n */\r\n Engine.DefaultLoadingScreenFactory = function (canvas) {\r\n throw _DevTools.WarnImport(\"LoadingScreen\");\r\n };\r\n Object.defineProperty(Engine.prototype, \"_supportsHardwareTextureRescaling\", {\r\n get: function () {\r\n return !!Engine._RescalePostProcessFactory;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Engine.prototype, \"performanceMonitor\", {\r\n /**\r\n * Gets the performance monitor attached to this engine\r\n * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation\r\n */\r\n get: function () {\r\n return this._performanceMonitor;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n // Events\r\n /**\r\n * Gets the HTML element used to attach event listeners\r\n * @returns a HTML element\r\n */\r\n Engine.prototype.getInputElement = function () {\r\n return this._renderingCanvas;\r\n };\r\n /**\r\n * Gets current aspect ratio\r\n * @param viewportOwner defines the camera to use to get the aspect ratio\r\n * @param useScreen defines if screen size must be used (or the current render target if any)\r\n * @returns a number defining the aspect ratio\r\n */\r\n Engine.prototype.getAspectRatio = function (viewportOwner, useScreen) {\r\n if (useScreen === void 0) { useScreen = false; }\r\n var viewport = viewportOwner.viewport;\r\n return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);\r\n };\r\n /**\r\n * Gets current screen aspect ratio\r\n * @returns a number defining the aspect ratio\r\n */\r\n Engine.prototype.getScreenAspectRatio = function () {\r\n return (this.getRenderWidth(true)) / (this.getRenderHeight(true));\r\n };\r\n /**\r\n * Gets the client rect of the HTML canvas attached with the current webGL context\r\n * @returns a client rectanglee\r\n */\r\n Engine.prototype.getRenderingCanvasClientRect = function () {\r\n if (!this._renderingCanvas) {\r\n return null;\r\n }\r\n return this._renderingCanvas.getBoundingClientRect();\r\n };\r\n /**\r\n * Gets the client rect of the HTML element used for events\r\n * @returns a client rectanglee\r\n */\r\n Engine.prototype.getInputElementClientRect = function () {\r\n if (!this._renderingCanvas) {\r\n return null;\r\n }\r\n return this.getInputElement().getBoundingClientRect();\r\n };\r\n /**\r\n * Gets a boolean indicating that the engine is running in deterministic lock step mode\r\n * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep\r\n * @returns true if engine is in deterministic lock step mode\r\n */\r\n Engine.prototype.isDeterministicLockStep = function () {\r\n return this._deterministicLockstep;\r\n };\r\n /**\r\n * Gets the max steps when engine is running in deterministic lock step\r\n * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep\r\n * @returns the max steps\r\n */\r\n Engine.prototype.getLockstepMaxSteps = function () {\r\n return this._lockstepMaxSteps;\r\n };\r\n /**\r\n * Returns the time in ms between steps when using deterministic lock step.\r\n * @returns time step in (ms)\r\n */\r\n Engine.prototype.getTimeStep = function () {\r\n return this._timeStep * 1000;\r\n };\r\n /**\r\n * Force the mipmap generation for the given render target texture\r\n * @param texture defines the render target texture to use\r\n * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.\r\n */\r\n Engine.prototype.generateMipMapsForCubemap = function (texture, unbind) {\r\n if (unbind === void 0) { unbind = true; }\r\n if (texture.generateMipMaps) {\r\n var gl = this._gl;\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);\r\n gl.generateMipmap(gl.TEXTURE_CUBE_MAP);\r\n if (unbind) {\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);\r\n }\r\n }\r\n };\r\n /** States */\r\n /**\r\n * Set various states to the webGL context\r\n * @param culling defines backface culling state\r\n * @param zOffset defines the value to apply to zOffset (0 by default)\r\n * @param force defines if states must be applied even if cache is up to date\r\n * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)\r\n */\r\n Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {\r\n if (zOffset === void 0) { zOffset = 0; }\r\n if (reverseSide === void 0) { reverseSide = false; }\r\n // Culling\r\n if (this._depthCullingState.cull !== culling || force) {\r\n this._depthCullingState.cull = culling;\r\n }\r\n // Cull face\r\n var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;\r\n if (this._depthCullingState.cullFace !== cullFace || force) {\r\n this._depthCullingState.cullFace = cullFace;\r\n }\r\n // Z offset\r\n this.setZOffset(zOffset);\r\n // Front face\r\n var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;\r\n if (this._depthCullingState.frontFace !== frontFace || force) {\r\n this._depthCullingState.frontFace = frontFace;\r\n }\r\n };\r\n /**\r\n * Set the z offset to apply to current rendering\r\n * @param value defines the offset to apply\r\n */\r\n Engine.prototype.setZOffset = function (value) {\r\n this._depthCullingState.zOffset = value;\r\n };\r\n /**\r\n * Gets the current value of the zOffset\r\n * @returns the current zOffset state\r\n */\r\n Engine.prototype.getZOffset = function () {\r\n return this._depthCullingState.zOffset;\r\n };\r\n /**\r\n * Enable or disable depth buffering\r\n * @param enable defines the state to set\r\n */\r\n Engine.prototype.setDepthBuffer = function (enable) {\r\n this._depthCullingState.depthTest = enable;\r\n };\r\n /**\r\n * Gets a boolean indicating if depth writing is enabled\r\n * @returns the current depth writing state\r\n */\r\n Engine.prototype.getDepthWrite = function () {\r\n return this._depthCullingState.depthMask;\r\n };\r\n /**\r\n * Enable or disable depth writing\r\n * @param enable defines the state to set\r\n */\r\n Engine.prototype.setDepthWrite = function (enable) {\r\n this._depthCullingState.depthMask = enable;\r\n };\r\n /**\r\n * Gets a boolean indicating if stencil buffer is enabled\r\n * @returns the current stencil buffer state\r\n */\r\n Engine.prototype.getStencilBuffer = function () {\r\n return this._stencilState.stencilTest;\r\n };\r\n /**\r\n * Enable or disable the stencil buffer\r\n * @param enable defines if the stencil buffer must be enabled or disabled\r\n */\r\n Engine.prototype.setStencilBuffer = function (enable) {\r\n this._stencilState.stencilTest = enable;\r\n };\r\n /**\r\n * Gets the current stencil mask\r\n * @returns a number defining the new stencil mask to use\r\n */\r\n Engine.prototype.getStencilMask = function () {\r\n return this._stencilState.stencilMask;\r\n };\r\n /**\r\n * Sets the current stencil mask\r\n * @param mask defines the new stencil mask to use\r\n */\r\n Engine.prototype.setStencilMask = function (mask) {\r\n this._stencilState.stencilMask = mask;\r\n };\r\n /**\r\n * Gets the current stencil function\r\n * @returns a number defining the stencil function to use\r\n */\r\n Engine.prototype.getStencilFunction = function () {\r\n return this._stencilState.stencilFunc;\r\n };\r\n /**\r\n * Gets the current stencil reference value\r\n * @returns a number defining the stencil reference value to use\r\n */\r\n Engine.prototype.getStencilFunctionReference = function () {\r\n return this._stencilState.stencilFuncRef;\r\n };\r\n /**\r\n * Gets the current stencil mask\r\n * @returns a number defining the stencil mask to use\r\n */\r\n Engine.prototype.getStencilFunctionMask = function () {\r\n return this._stencilState.stencilFuncMask;\r\n };\r\n /**\r\n * Sets the current stencil function\r\n * @param stencilFunc defines the new stencil function to use\r\n */\r\n Engine.prototype.setStencilFunction = function (stencilFunc) {\r\n this._stencilState.stencilFunc = stencilFunc;\r\n };\r\n /**\r\n * Sets the current stencil reference\r\n * @param reference defines the new stencil reference to use\r\n */\r\n Engine.prototype.setStencilFunctionReference = function (reference) {\r\n this._stencilState.stencilFuncRef = reference;\r\n };\r\n /**\r\n * Sets the current stencil mask\r\n * @param mask defines the new stencil mask to use\r\n */\r\n Engine.prototype.setStencilFunctionMask = function (mask) {\r\n this._stencilState.stencilFuncMask = mask;\r\n };\r\n /**\r\n * Gets the current stencil operation when stencil fails\r\n * @returns a number defining stencil operation to use when stencil fails\r\n */\r\n Engine.prototype.getStencilOperationFail = function () {\r\n return this._stencilState.stencilOpStencilFail;\r\n };\r\n /**\r\n * Gets the current stencil operation when depth fails\r\n * @returns a number defining stencil operation to use when depth fails\r\n */\r\n Engine.prototype.getStencilOperationDepthFail = function () {\r\n return this._stencilState.stencilOpDepthFail;\r\n };\r\n /**\r\n * Gets the current stencil operation when stencil passes\r\n * @returns a number defining stencil operation to use when stencil passes\r\n */\r\n Engine.prototype.getStencilOperationPass = function () {\r\n return this._stencilState.stencilOpStencilDepthPass;\r\n };\r\n /**\r\n * Sets the stencil operation to use when stencil fails\r\n * @param operation defines the stencil operation to use when stencil fails\r\n */\r\n Engine.prototype.setStencilOperationFail = function (operation) {\r\n this._stencilState.stencilOpStencilFail = operation;\r\n };\r\n /**\r\n * Sets the stencil operation to use when depth fails\r\n * @param operation defines the stencil operation to use when depth fails\r\n */\r\n Engine.prototype.setStencilOperationDepthFail = function (operation) {\r\n this._stencilState.stencilOpDepthFail = operation;\r\n };\r\n /**\r\n * Sets the stencil operation to use when stencil passes\r\n * @param operation defines the stencil operation to use when stencil passes\r\n */\r\n Engine.prototype.setStencilOperationPass = function (operation) {\r\n this._stencilState.stencilOpStencilDepthPass = operation;\r\n };\r\n /**\r\n * Sets a boolean indicating if the dithering state is enabled or disabled\r\n * @param value defines the dithering state\r\n */\r\n Engine.prototype.setDitheringState = function (value) {\r\n if (value) {\r\n this._gl.enable(this._gl.DITHER);\r\n }\r\n else {\r\n this._gl.disable(this._gl.DITHER);\r\n }\r\n };\r\n /**\r\n * Sets a boolean indicating if the rasterizer state is enabled or disabled\r\n * @param value defines the rasterizer state\r\n */\r\n Engine.prototype.setRasterizerState = function (value) {\r\n if (value) {\r\n this._gl.disable(this._gl.RASTERIZER_DISCARD);\r\n }\r\n else {\r\n this._gl.enable(this._gl.RASTERIZER_DISCARD);\r\n }\r\n };\r\n /**\r\n * Gets the current depth function\r\n * @returns a number defining the depth function\r\n */\r\n Engine.prototype.getDepthFunction = function () {\r\n return this._depthCullingState.depthFunc;\r\n };\r\n /**\r\n * Sets the current depth function\r\n * @param depthFunc defines the function to use\r\n */\r\n Engine.prototype.setDepthFunction = function (depthFunc) {\r\n this._depthCullingState.depthFunc = depthFunc;\r\n };\r\n /**\r\n * Sets the current depth function to GREATER\r\n */\r\n Engine.prototype.setDepthFunctionToGreater = function () {\r\n this._depthCullingState.depthFunc = this._gl.GREATER;\r\n };\r\n /**\r\n * Sets the current depth function to GEQUAL\r\n */\r\n Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {\r\n this._depthCullingState.depthFunc = this._gl.GEQUAL;\r\n };\r\n /**\r\n * Sets the current depth function to LESS\r\n */\r\n Engine.prototype.setDepthFunctionToLess = function () {\r\n this._depthCullingState.depthFunc = this._gl.LESS;\r\n };\r\n /**\r\n * Sets the current depth function to LEQUAL\r\n */\r\n Engine.prototype.setDepthFunctionToLessOrEqual = function () {\r\n this._depthCullingState.depthFunc = this._gl.LEQUAL;\r\n };\r\n /**\r\n * Caches the the state of the stencil buffer\r\n */\r\n Engine.prototype.cacheStencilState = function () {\r\n this._cachedStencilBuffer = this.getStencilBuffer();\r\n this._cachedStencilFunction = this.getStencilFunction();\r\n this._cachedStencilMask = this.getStencilMask();\r\n this._cachedStencilOperationPass = this.getStencilOperationPass();\r\n this._cachedStencilOperationFail = this.getStencilOperationFail();\r\n this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail();\r\n this._cachedStencilReference = this.getStencilFunctionReference();\r\n };\r\n /**\r\n * Restores the state of the stencil buffer\r\n */\r\n Engine.prototype.restoreStencilState = function () {\r\n this.setStencilFunction(this._cachedStencilFunction);\r\n this.setStencilMask(this._cachedStencilMask);\r\n this.setStencilBuffer(this._cachedStencilBuffer);\r\n this.setStencilOperationPass(this._cachedStencilOperationPass);\r\n this.setStencilOperationFail(this._cachedStencilOperationFail);\r\n this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail);\r\n this.setStencilFunctionReference(this._cachedStencilReference);\r\n };\r\n /**\r\n * Directly set the WebGL Viewport\r\n * @param x defines the x coordinate of the viewport (in screen space)\r\n * @param y defines the y coordinate of the viewport (in screen space)\r\n * @param width defines the width of the viewport (in screen space)\r\n * @param height defines the height of the viewport (in screen space)\r\n * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state\r\n */\r\n Engine.prototype.setDirectViewport = function (x, y, width, height) {\r\n var currentViewport = this._cachedViewport;\r\n this._cachedViewport = null;\r\n this._viewport(x, y, width, height);\r\n return currentViewport;\r\n };\r\n /**\r\n * Executes a scissor clear (ie. a clear on a specific portion of the screen)\r\n * @param x defines the x-coordinate of the top left corner of the clear rectangle\r\n * @param y defines the y-coordinate of the corner of the clear rectangle\r\n * @param width defines the width of the clear rectangle\r\n * @param height defines the height of the clear rectangle\r\n * @param clearColor defines the clear color\r\n */\r\n Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {\r\n this.enableScissor(x, y, width, height);\r\n this.clear(clearColor, true, true, true);\r\n this.disableScissor();\r\n };\r\n /**\r\n * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)\r\n * @param x defines the x-coordinate of the top left corner of the clear rectangle\r\n * @param y defines the y-coordinate of the corner of the clear rectangle\r\n * @param width defines the width of the clear rectangle\r\n * @param height defines the height of the clear rectangle\r\n */\r\n Engine.prototype.enableScissor = function (x, y, width, height) {\r\n var gl = this._gl;\r\n // Change state\r\n gl.enable(gl.SCISSOR_TEST);\r\n gl.scissor(x, y, width, height);\r\n };\r\n /**\r\n * Disable previously set scissor test rectangle\r\n */\r\n Engine.prototype.disableScissor = function () {\r\n var gl = this._gl;\r\n gl.disable(gl.SCISSOR_TEST);\r\n };\r\n Engine.prototype._reportDrawCall = function () {\r\n this._drawCalls.addCount(1, false);\r\n };\r\n /**\r\n * Initializes a webVR display and starts listening to display change events\r\n * The onVRDisplayChangedObservable will be notified upon these changes\r\n * @returns The onVRDisplayChangedObservable\r\n */\r\n Engine.prototype.initWebVR = function () {\r\n throw _DevTools.WarnImport(\"WebVRCamera\");\r\n };\r\n /** @hidden */\r\n Engine.prototype._prepareVRComponent = function () {\r\n // Do nothing as the engine side effect will overload it\r\n };\r\n /** @hidden */\r\n Engine.prototype._connectVREvents = function (canvas, document) {\r\n // Do nothing as the engine side effect will overload it\r\n };\r\n /** @hidden */\r\n Engine.prototype._submitVRFrame = function () {\r\n // Do nothing as the engine side effect will overload it\r\n };\r\n /**\r\n * Call this function to leave webVR mode\r\n * Will do nothing if webVR is not supported or if there is no webVR device\r\n * @see http://doc.babylonjs.com/how_to/webvr_camera\r\n */\r\n Engine.prototype.disableVR = function () {\r\n // Do nothing as the engine side effect will overload it\r\n };\r\n /**\r\n * Gets a boolean indicating that the system is in VR mode and is presenting\r\n * @returns true if VR mode is engaged\r\n */\r\n Engine.prototype.isVRPresenting = function () {\r\n return false;\r\n };\r\n /** @hidden */\r\n Engine.prototype._requestVRFrame = function () {\r\n // Do nothing as the engine side effect will overload it\r\n };\r\n /** @hidden */\r\n Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {\r\n var _this = this;\r\n return new Promise(function (resolve, reject) {\r\n _this._loadFile(url, function (data) {\r\n resolve(data);\r\n }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {\r\n reject(exception);\r\n });\r\n });\r\n };\r\n /**\r\n * Gets the source code of the vertex shader associated with a specific webGL program\r\n * @param program defines the program to use\r\n * @returns a string containing the source code of the vertex shader associated with the program\r\n */\r\n Engine.prototype.getVertexShaderSource = function (program) {\r\n var shaders = this._gl.getAttachedShaders(program);\r\n if (!shaders) {\r\n return null;\r\n }\r\n return this._gl.getShaderSource(shaders[0]);\r\n };\r\n /**\r\n * Gets the source code of the fragment shader associated with a specific webGL program\r\n * @param program defines the program to use\r\n * @returns a string containing the source code of the fragment shader associated with the program\r\n */\r\n Engine.prototype.getFragmentShaderSource = function (program) {\r\n var shaders = this._gl.getAttachedShaders(program);\r\n if (!shaders) {\r\n return null;\r\n }\r\n return this._gl.getShaderSource(shaders[1]);\r\n };\r\n /**\r\n * Sets a depth stencil texture from a render target to the according uniform.\r\n * @param channel The texture channel\r\n * @param uniform The uniform to set\r\n * @param texture The render target texture containing the depth stencil texture to apply\r\n */\r\n Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {\r\n if (channel === undefined) {\r\n return;\r\n }\r\n if (uniform) {\r\n this._boundUniforms[channel] = uniform;\r\n }\r\n if (!texture || !texture.depthStencilTexture) {\r\n this._setTexture(channel, null);\r\n }\r\n else {\r\n this._setTexture(channel, texture, false, true);\r\n }\r\n };\r\n /**\r\n * Sets a texture to the webGL context from a postprocess\r\n * @param channel defines the channel to use\r\n * @param postProcess defines the source postprocess\r\n */\r\n Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {\r\n this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);\r\n };\r\n /**\r\n * Binds the output of the passed in post process to the texture channel specified\r\n * @param channel The channel the texture should be bound to\r\n * @param postProcess The post process which's output should be bound\r\n */\r\n Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {\r\n this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);\r\n };\r\n /** @hidden */\r\n Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {\r\n // Create new RGBA data container.\r\n var rgbaData;\r\n if (textureType === 1) {\r\n rgbaData = new Float32Array(width * height * 4);\r\n }\r\n else {\r\n rgbaData = new Uint32Array(width * height * 4);\r\n }\r\n // Convert each pixel.\r\n for (var x = 0; x < width; x++) {\r\n for (var y = 0; y < height; y++) {\r\n var index = (y * width + x) * 3;\r\n var newIndex = (y * width + x) * 4;\r\n // Map Old Value to new value.\r\n rgbaData[newIndex + 0] = rgbData[index + 0];\r\n rgbaData[newIndex + 1] = rgbData[index + 1];\r\n rgbaData[newIndex + 2] = rgbData[index + 2];\r\n // Add fully opaque alpha channel.\r\n rgbaData[newIndex + 3] = 1;\r\n }\r\n }\r\n return rgbaData;\r\n };\r\n Engine.prototype._rebuildBuffers = function () {\r\n // Index / Vertex\r\n for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {\r\n var scene = _a[_i];\r\n scene.resetCachedMaterial();\r\n scene._rebuildGeometries();\r\n scene._rebuildTextures();\r\n }\r\n _super.prototype._rebuildBuffers.call(this);\r\n };\r\n /** @hidden */\r\n Engine.prototype._renderFrame = function () {\r\n for (var index = 0; index < this._activeRenderLoops.length; index++) {\r\n var renderFunction = this._activeRenderLoops[index];\r\n renderFunction();\r\n }\r\n };\r\n Engine.prototype._renderLoop = function () {\r\n if (!this._contextWasLost) {\r\n var shouldRender = true;\r\n if (!this.renderEvenInBackground && this._windowIsBackground) {\r\n shouldRender = false;\r\n }\r\n if (shouldRender) {\r\n // Start new frame\r\n this.beginFrame();\r\n // Child canvases\r\n if (!this._renderViews()) {\r\n // Main frame\r\n this._renderFrame();\r\n }\r\n // Present\r\n this.endFrame();\r\n }\r\n }\r\n if (this._activeRenderLoops.length > 0) {\r\n // Register new frame\r\n if (this.customAnimationFrameRequester) {\r\n this.customAnimationFrameRequester.requestID = this._queueNewFrame(this.customAnimationFrameRequester.renderFunction || this._boundRenderFunction, this.customAnimationFrameRequester);\r\n this._frameHandler = this.customAnimationFrameRequester.requestID;\r\n }\r\n else if (this.isVRPresenting()) {\r\n this._requestVRFrame();\r\n }\r\n else {\r\n this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow());\r\n }\r\n }\r\n else {\r\n this._renderingQueueLaunched = false;\r\n }\r\n };\r\n /** @hidden */\r\n Engine.prototype._renderViews = function () {\r\n return false;\r\n };\r\n /**\r\n * Toggle full screen mode\r\n * @param requestPointerLock defines if a pointer lock should be requested from the user\r\n */\r\n Engine.prototype.switchFullscreen = function (requestPointerLock) {\r\n if (this.isFullscreen) {\r\n this.exitFullscreen();\r\n }\r\n else {\r\n this.enterFullscreen(requestPointerLock);\r\n }\r\n };\r\n /**\r\n * Enters full screen mode\r\n * @param requestPointerLock defines if a pointer lock should be requested from the user\r\n */\r\n Engine.prototype.enterFullscreen = function (requestPointerLock) {\r\n if (!this.isFullscreen) {\r\n this._pointerLockRequested = requestPointerLock;\r\n if (this._renderingCanvas) {\r\n Engine._RequestFullscreen(this._renderingCanvas);\r\n }\r\n }\r\n };\r\n /**\r\n * Exits full screen mode\r\n */\r\n Engine.prototype.exitFullscreen = function () {\r\n if (this.isFullscreen) {\r\n Engine._ExitFullscreen();\r\n }\r\n };\r\n /**\r\n * Enters Pointerlock mode\r\n */\r\n Engine.prototype.enterPointerlock = function () {\r\n if (this._renderingCanvas) {\r\n Engine._RequestPointerlock(this._renderingCanvas);\r\n }\r\n };\r\n /**\r\n * Exits Pointerlock mode\r\n */\r\n Engine.prototype.exitPointerlock = function () {\r\n Engine._ExitPointerlock();\r\n };\r\n /**\r\n * Begin a new frame\r\n */\r\n Engine.prototype.beginFrame = function () {\r\n this._measureFps();\r\n this.onBeginFrameObservable.notifyObservers(this);\r\n _super.prototype.beginFrame.call(this);\r\n };\r\n /**\r\n * Enf the current frame\r\n */\r\n Engine.prototype.endFrame = function () {\r\n _super.prototype.endFrame.call(this);\r\n this._submitVRFrame();\r\n this.onEndFrameObservable.notifyObservers(this);\r\n };\r\n Engine.prototype.resize = function () {\r\n // We're not resizing the size of the canvas while in VR mode & presenting\r\n if (this.isVRPresenting()) {\r\n return;\r\n }\r\n _super.prototype.resize.call(this);\r\n };\r\n /**\r\n * Force a specific size of the canvas\r\n * @param width defines the new canvas' width\r\n * @param height defines the new canvas' height\r\n */\r\n Engine.prototype.setSize = function (width, height) {\r\n if (!this._renderingCanvas) {\r\n return;\r\n }\r\n _super.prototype.setSize.call(this, width, height);\r\n if (this.scenes) {\r\n for (var index = 0; index < this.scenes.length; index++) {\r\n var scene = this.scenes[index];\r\n for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {\r\n var cam = scene.cameras[camIndex];\r\n cam._currentRenderId = 0;\r\n }\r\n }\r\n if (this.onResizeObservable.hasObservers) {\r\n this.onResizeObservable.notifyObservers(this);\r\n }\r\n }\r\n };\r\n /**\r\n * Updates a dynamic vertex buffer.\r\n * @param vertexBuffer the vertex buffer to update\r\n * @param data the data used to update the vertex buffer\r\n * @param byteOffset the byte offset of the data\r\n * @param byteLength the byte length of the data\r\n */\r\n Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {\r\n this.bindArrayBuffer(vertexBuffer);\r\n if (byteOffset === undefined) {\r\n byteOffset = 0;\r\n }\r\n var dataLength = data.length || data.byteLength;\r\n if (byteLength === undefined || byteLength >= dataLength && byteOffset === 0) {\r\n if (data instanceof Array) {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));\r\n }\r\n else {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);\r\n }\r\n }\r\n else {\r\n if (data instanceof Array) {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));\r\n }\r\n else {\r\n if (data instanceof ArrayBuffer) {\r\n data = new Uint8Array(data, byteOffset, byteLength);\r\n }\r\n else {\r\n data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);\r\n }\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);\r\n }\r\n }\r\n this._resetVertexBufferBinding();\r\n };\r\n Engine.prototype._deletePipelineContext = function (pipelineContext) {\r\n var webGLPipelineContext = pipelineContext;\r\n if (webGLPipelineContext && webGLPipelineContext.program) {\r\n if (webGLPipelineContext.transformFeedback) {\r\n this.deleteTransformFeedback(webGLPipelineContext.transformFeedback);\r\n webGLPipelineContext.transformFeedback = null;\r\n }\r\n }\r\n _super.prototype._deletePipelineContext.call(this, pipelineContext);\r\n };\r\n Engine.prototype.createShaderProgram = function (pipelineContext, vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {\r\n if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }\r\n context = context || this._gl;\r\n this.onBeforeShaderCompilationObservable.notifyObservers(this);\r\n var program = _super.prototype.createShaderProgram.call(this, pipelineContext, vertexCode, fragmentCode, defines, context, transformFeedbackVaryings);\r\n this.onAfterShaderCompilationObservable.notifyObservers(this);\r\n return program;\r\n };\r\n Engine.prototype._createShaderProgram = function (pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings) {\r\n if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }\r\n var shaderProgram = context.createProgram();\r\n pipelineContext.program = shaderProgram;\r\n if (!shaderProgram) {\r\n throw new Error(\"Unable to create program\");\r\n }\r\n context.attachShader(shaderProgram, vertexShader);\r\n context.attachShader(shaderProgram, fragmentShader);\r\n if (this.webGLVersion > 1 && transformFeedbackVaryings) {\r\n var transformFeedback = this.createTransformFeedback();\r\n this.bindTransformFeedback(transformFeedback);\r\n this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);\r\n pipelineContext.transformFeedback = transformFeedback;\r\n }\r\n context.linkProgram(shaderProgram);\r\n if (this.webGLVersion > 1 && transformFeedbackVaryings) {\r\n this.bindTransformFeedback(null);\r\n }\r\n pipelineContext.context = context;\r\n pipelineContext.vertexShader = vertexShader;\r\n pipelineContext.fragmentShader = fragmentShader;\r\n if (!pipelineContext.isParallelCompiled) {\r\n this._finalizePipelineContext(pipelineContext);\r\n }\r\n return shaderProgram;\r\n };\r\n Engine.prototype._releaseTexture = function (texture) {\r\n _super.prototype._releaseTexture.call(this, texture);\r\n // Set output texture of post process to null if the texture has been released/disposed\r\n this.scenes.forEach(function (scene) {\r\n scene.postProcesses.forEach(function (postProcess) {\r\n if (postProcess._outputTexture == texture) {\r\n postProcess._outputTexture = null;\r\n }\r\n });\r\n scene.cameras.forEach(function (camera) {\r\n camera._postProcesses.forEach(function (postProcess) {\r\n if (postProcess) {\r\n if (postProcess._outputTexture == texture) {\r\n postProcess._outputTexture = null;\r\n }\r\n }\r\n });\r\n });\r\n });\r\n };\r\n /**\r\n * @hidden\r\n * Rescales a texture\r\n * @param source input texutre\r\n * @param destination destination texture\r\n * @param scene scene to use to render the resize\r\n * @param internalFormat format to use when resizing\r\n * @param onComplete callback to be called when resize has completed\r\n */\r\n Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {\r\n var _this = this;\r\n this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR);\r\n this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR);\r\n this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE);\r\n this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE);\r\n var rtt = this.createRenderTargetTexture({\r\n width: destination.width,\r\n height: destination.height,\r\n }, {\r\n generateMipMaps: false,\r\n type: 0,\r\n samplingMode: 2,\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false\r\n });\r\n if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {\r\n this._rescalePostProcess = Engine._RescalePostProcessFactory(this);\r\n }\r\n this._rescalePostProcess.getEffect().executeWhenCompiled(function () {\r\n _this._rescalePostProcess.onApply = function (effect) {\r\n effect._bindTexture(\"textureSampler\", source);\r\n };\r\n var hostingScene = scene;\r\n if (!hostingScene) {\r\n hostingScene = _this.scenes[_this.scenes.length - 1];\r\n }\r\n hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);\r\n _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);\r\n _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);\r\n _this.unBindFramebuffer(rtt);\r\n _this._releaseTexture(rtt);\r\n if (onComplete) {\r\n onComplete();\r\n }\r\n });\r\n };\r\n // FPS\r\n /**\r\n * Gets the current framerate\r\n * @returns a number representing the framerate\r\n */\r\n Engine.prototype.getFps = function () {\r\n return this._fps;\r\n };\r\n /**\r\n * Gets the time spent between current and previous frame\r\n * @returns a number representing the delta time in ms\r\n */\r\n Engine.prototype.getDeltaTime = function () {\r\n return this._deltaTime;\r\n };\r\n Engine.prototype._measureFps = function () {\r\n this._performanceMonitor.sampleFrame();\r\n this._fps = this._performanceMonitor.averageFPS;\r\n this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;\r\n };\r\n /** @hidden */\r\n Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lod === void 0) { lod = 0; }\r\n var gl = this._gl;\r\n var textureType = this._getWebGLTextureType(texture.type);\r\n var format = this._getInternalFormat(texture.format);\r\n var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);\r\n var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;\r\n this._bindTextureDirectly(bindTarget, texture, true);\r\n this._unpackFlipY(texture.invertY);\r\n var target = gl.TEXTURE_2D;\r\n if (texture.isCube) {\r\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\r\n }\r\n gl.texImage2D(target, lod, internalFormat, format, textureType, image);\r\n this._bindTextureDirectly(bindTarget, null, true);\r\n };\r\n /**\r\n * Update a dynamic index buffer\r\n * @param indexBuffer defines the target index buffer\r\n * @param indices defines the data to update\r\n * @param offset defines the offset in the target index buffer where update should start\r\n */\r\n Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {\r\n if (offset === void 0) { offset = 0; }\r\n // Force cache update\r\n this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;\r\n this.bindIndexBuffer(indexBuffer);\r\n var arrayBuffer;\r\n if (indices instanceof Uint16Array || indices instanceof Uint32Array) {\r\n arrayBuffer = indices;\r\n }\r\n else {\r\n arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);\r\n }\r\n this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);\r\n this._resetIndexBufferBinding();\r\n };\r\n /**\r\n * Updates the sample count of a render target texture\r\n * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets\r\n * @param texture defines the texture to update\r\n * @param samples defines the sample count to set\r\n * @returns the effective sample count (could be 0 if multisample render targets are not supported)\r\n */\r\n Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {\r\n if (this.webGLVersion < 2 || !texture) {\r\n return 1;\r\n }\r\n if (texture.samples === samples) {\r\n return samples;\r\n }\r\n var gl = this._gl;\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n // Dispose previous render buffers\r\n if (texture._depthStencilBuffer) {\r\n gl.deleteRenderbuffer(texture._depthStencilBuffer);\r\n texture._depthStencilBuffer = null;\r\n }\r\n if (texture._MSAAFramebuffer) {\r\n gl.deleteFramebuffer(texture._MSAAFramebuffer);\r\n texture._MSAAFramebuffer = null;\r\n }\r\n if (texture._MSAARenderBuffer) {\r\n gl.deleteRenderbuffer(texture._MSAARenderBuffer);\r\n texture._MSAARenderBuffer = null;\r\n }\r\n if (samples > 1 && gl.renderbufferStorageMultisample) {\r\n var framebuffer = gl.createFramebuffer();\r\n if (!framebuffer) {\r\n throw new Error(\"Unable to create multi sampled framebuffer\");\r\n }\r\n texture._MSAAFramebuffer = framebuffer;\r\n this._bindUnboundFramebuffer(texture._MSAAFramebuffer);\r\n var colorRenderbuffer = gl.createRenderbuffer();\r\n if (!colorRenderbuffer) {\r\n throw new Error(\"Unable to create multi sampled framebuffer\");\r\n }\r\n gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);\r\n gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);\r\n texture._MSAARenderBuffer = colorRenderbuffer;\r\n }\r\n else {\r\n this._bindUnboundFramebuffer(texture._framebuffer);\r\n }\r\n texture.samples = samples;\r\n texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);\r\n this._bindUnboundFramebuffer(null);\r\n return samples;\r\n };\r\n /**\r\n * Updates a depth texture Comparison Mode and Function.\r\n * If the comparison Function is equal to 0, the mode will be set to none.\r\n * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.\r\n * @param texture The texture to set the comparison function for\r\n * @param comparisonFunction The comparison function to set, 0 if no comparison required\r\n */\r\n Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {\r\n if (this.webGLVersion === 1) {\r\n Logger.Error(\"WebGL 1 does not support texture comparison.\");\r\n return;\r\n }\r\n var gl = this._gl;\r\n if (texture.isCube) {\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);\r\n if (comparisonFunction === 0) {\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, 515);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);\r\n }\r\n else {\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);\r\n }\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\r\n }\r\n else {\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);\r\n if (comparisonFunction === 0) {\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, 515);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);\r\n }\r\n else {\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);\r\n }\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\r\n }\r\n texture._comparisonFunction = comparisonFunction;\r\n };\r\n /**\r\n * Creates a webGL buffer to use with instanciation\r\n * @param capacity defines the size of the buffer\r\n * @returns the webGL buffer\r\n */\r\n Engine.prototype.createInstancesBuffer = function (capacity) {\r\n var buffer = this._gl.createBuffer();\r\n if (!buffer) {\r\n throw new Error(\"Unable to create instance buffer\");\r\n }\r\n var result = new WebGLDataBuffer(buffer);\r\n result.capacity = capacity;\r\n this.bindArrayBuffer(result);\r\n this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);\r\n return result;\r\n };\r\n /**\r\n * Delete a webGL buffer used with instanciation\r\n * @param buffer defines the webGL buffer to delete\r\n */\r\n Engine.prototype.deleteInstancesBuffer = function (buffer) {\r\n this._gl.deleteBuffer(buffer);\r\n };\r\n Engine.prototype._clientWaitAsync = function (sync, flags, interval_ms) {\r\n if (flags === void 0) { flags = 0; }\r\n if (interval_ms === void 0) { interval_ms = 10; }\r\n var gl = this._gl;\r\n return new Promise(function (resolve, reject) {\r\n var check = function () {\r\n var res = gl.clientWaitSync(sync, flags, 0);\r\n if (res == gl.WAIT_FAILED) {\r\n reject();\r\n return;\r\n }\r\n if (res == gl.TIMEOUT_EXPIRED) {\r\n setTimeout(check, interval_ms);\r\n return;\r\n }\r\n resolve();\r\n };\r\n check();\r\n });\r\n };\r\n /** @hidden */\r\n Engine.prototype._readPixelsAsync = function (x, y, w, h, format, type, outputBuffer) {\r\n if (this._webGLVersion < 2) {\r\n throw new Error(\"_readPixelsAsync only work on WebGL2+\");\r\n }\r\n var gl = this._gl;\r\n var buf = gl.createBuffer();\r\n gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);\r\n gl.bufferData(gl.PIXEL_PACK_BUFFER, outputBuffer.byteLength, gl.STREAM_READ);\r\n gl.readPixels(x, y, w, h, format, type, 0);\r\n gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);\r\n var sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);\r\n if (!sync) {\r\n return null;\r\n }\r\n gl.flush();\r\n return this._clientWaitAsync(sync, 0, 10).then(function () {\r\n gl.deleteSync(sync);\r\n gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);\r\n gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, outputBuffer);\r\n gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);\r\n gl.deleteBuffer(buf);\r\n return outputBuffer;\r\n });\r\n };\r\n /** @hidden */\r\n Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {\r\n if (faceIndex === void 0) { faceIndex = -1; }\r\n if (level === void 0) { level = 0; }\r\n if (buffer === void 0) { buffer = null; }\r\n var gl = this._gl;\r\n if (!this._dummyFramebuffer) {\r\n var dummy = gl.createFramebuffer();\r\n if (!dummy) {\r\n throw new Error(\"Unable to create dummy framebuffer\");\r\n }\r\n this._dummyFramebuffer = dummy;\r\n }\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);\r\n if (faceIndex > -1) {\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);\r\n }\r\n else {\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);\r\n }\r\n var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;\r\n switch (readType) {\r\n case gl.UNSIGNED_BYTE:\r\n if (!buffer) {\r\n buffer = new Uint8Array(4 * width * height);\r\n }\r\n readType = gl.UNSIGNED_BYTE;\r\n break;\r\n default:\r\n if (!buffer) {\r\n buffer = new Float32Array(4 * width * height);\r\n }\r\n readType = gl.FLOAT;\r\n break;\r\n }\r\n gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);\r\n return buffer;\r\n };\r\n Engine.prototype.dispose = function () {\r\n this.hideLoadingUI();\r\n this.onNewSceneAddedObservable.clear();\r\n // Release postProcesses\r\n while (this.postProcesses.length) {\r\n this.postProcesses[0].dispose();\r\n }\r\n // Rescale PP\r\n if (this._rescalePostProcess) {\r\n this._rescalePostProcess.dispose();\r\n }\r\n // Release scenes\r\n while (this.scenes.length) {\r\n this.scenes[0].dispose();\r\n }\r\n // Release audio engine\r\n if (Engine.Instances.length === 1 && Engine.audioEngine) {\r\n Engine.audioEngine.dispose();\r\n }\r\n if (this._dummyFramebuffer) {\r\n this._gl.deleteFramebuffer(this._dummyFramebuffer);\r\n }\r\n //WebVR\r\n this.disableVR();\r\n // Events\r\n if (DomManagement.IsWindowObjectExist()) {\r\n window.removeEventListener(\"blur\", this._onBlur);\r\n window.removeEventListener(\"focus\", this._onFocus);\r\n if (this._renderingCanvas) {\r\n this._renderingCanvas.removeEventListener(\"focus\", this._onCanvasFocus);\r\n this._renderingCanvas.removeEventListener(\"blur\", this._onCanvasBlur);\r\n this._renderingCanvas.removeEventListener(\"pointerout\", this._onCanvasPointerOut);\r\n }\r\n document.removeEventListener(\"fullscreenchange\", this._onFullscreenChange);\r\n document.removeEventListener(\"mozfullscreenchange\", this._onFullscreenChange);\r\n document.removeEventListener(\"webkitfullscreenchange\", this._onFullscreenChange);\r\n document.removeEventListener(\"msfullscreenchange\", this._onFullscreenChange);\r\n document.removeEventListener(\"pointerlockchange\", this._onPointerLockChange);\r\n document.removeEventListener(\"mspointerlockchange\", this._onPointerLockChange);\r\n document.removeEventListener(\"mozpointerlockchange\", this._onPointerLockChange);\r\n document.removeEventListener(\"webkitpointerlockchange\", this._onPointerLockChange);\r\n }\r\n _super.prototype.dispose.call(this);\r\n // Remove from Instances\r\n var index = Engine.Instances.indexOf(this);\r\n if (index >= 0) {\r\n Engine.Instances.splice(index, 1);\r\n }\r\n // Observables\r\n this.onResizeObservable.clear();\r\n this.onCanvasBlurObservable.clear();\r\n this.onCanvasFocusObservable.clear();\r\n this.onCanvasPointerOutObservable.clear();\r\n this.onBeginFrameObservable.clear();\r\n this.onEndFrameObservable.clear();\r\n };\r\n Engine.prototype._disableTouchAction = function () {\r\n if (!this._renderingCanvas || !this._renderingCanvas.setAttribute) {\r\n return;\r\n }\r\n this._renderingCanvas.setAttribute(\"touch-action\", \"none\");\r\n this._renderingCanvas.style.touchAction = \"none\";\r\n this._renderingCanvas.style.msTouchAction = \"none\";\r\n };\r\n // Loading screen\r\n /**\r\n * Display the loading screen\r\n * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen\r\n */\r\n Engine.prototype.displayLoadingUI = function () {\r\n if (!DomManagement.IsWindowObjectExist()) {\r\n return;\r\n }\r\n var loadingScreen = this.loadingScreen;\r\n if (loadingScreen) {\r\n loadingScreen.displayLoadingUI();\r\n }\r\n };\r\n /**\r\n * Hide the loading screen\r\n * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen\r\n */\r\n Engine.prototype.hideLoadingUI = function () {\r\n if (!DomManagement.IsWindowObjectExist()) {\r\n return;\r\n }\r\n var loadingScreen = this._loadingScreen;\r\n if (loadingScreen) {\r\n loadingScreen.hideLoadingUI();\r\n }\r\n };\r\n Object.defineProperty(Engine.prototype, \"loadingScreen\", {\r\n /**\r\n * Gets the current loading screen object\r\n * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen\r\n */\r\n get: function () {\r\n if (!this._loadingScreen && this._renderingCanvas) {\r\n this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);\r\n }\r\n return this._loadingScreen;\r\n },\r\n /**\r\n * Sets the current loading screen object\r\n * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen\r\n */\r\n set: function (loadingScreen) {\r\n this._loadingScreen = loadingScreen;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Engine.prototype, \"loadingUIText\", {\r\n /**\r\n * Sets the current loading screen text\r\n * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen\r\n */\r\n set: function (text) {\r\n this.loadingScreen.loadingUIText = text;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Engine.prototype, \"loadingUIBackgroundColor\", {\r\n /**\r\n * Sets the current loading screen background color\r\n * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen\r\n */\r\n set: function (color) {\r\n this.loadingScreen.loadingUIBackgroundColor = color;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /** Pointerlock and fullscreen */\r\n /**\r\n * Ask the browser to promote the current element to pointerlock mode\r\n * @param element defines the DOM element to promote\r\n */\r\n Engine._RequestPointerlock = function (element) {\r\n element.requestPointerLock = element.requestPointerLock || element.msRequestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock;\r\n if (element.requestPointerLock) {\r\n element.requestPointerLock();\r\n }\r\n };\r\n /**\r\n * Asks the browser to exit pointerlock mode\r\n */\r\n Engine._ExitPointerlock = function () {\r\n var anyDoc = document;\r\n document.exitPointerLock = document.exitPointerLock || anyDoc.msExitPointerLock || anyDoc.mozExitPointerLock || anyDoc.webkitExitPointerLock;\r\n if (document.exitPointerLock) {\r\n document.exitPointerLock();\r\n }\r\n };\r\n /**\r\n * Ask the browser to promote the current element to fullscreen rendering mode\r\n * @param element defines the DOM element to promote\r\n */\r\n Engine._RequestFullscreen = function (element) {\r\n var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;\r\n if (!requestFunction) {\r\n return;\r\n }\r\n requestFunction.call(element);\r\n };\r\n /**\r\n * Asks the browser to exit fullscreen mode\r\n */\r\n Engine._ExitFullscreen = function () {\r\n var anyDoc = document;\r\n if (document.exitFullscreen) {\r\n document.exitFullscreen();\r\n }\r\n else if (anyDoc.mozCancelFullScreen) {\r\n anyDoc.mozCancelFullScreen();\r\n }\r\n else if (anyDoc.webkitCancelFullScreen) {\r\n anyDoc.webkitCancelFullScreen();\r\n }\r\n else if (anyDoc.msCancelFullScreen) {\r\n anyDoc.msCancelFullScreen();\r\n }\r\n };\r\n // Const statics\r\n /** Defines that alpha blending is disabled */\r\n Engine.ALPHA_DISABLE = 0;\r\n /** Defines that alpha blending to SRC ALPHA * SRC + DEST */\r\n Engine.ALPHA_ADD = 1;\r\n /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */\r\n Engine.ALPHA_COMBINE = 2;\r\n /** Defines that alpha blending to DEST - SRC * DEST */\r\n Engine.ALPHA_SUBTRACT = 3;\r\n /** Defines that alpha blending to SRC * DEST */\r\n Engine.ALPHA_MULTIPLY = 4;\r\n /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */\r\n Engine.ALPHA_MAXIMIZED = 5;\r\n /** Defines that alpha blending to SRC + DEST */\r\n Engine.ALPHA_ONEONE = 6;\r\n /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */\r\n Engine.ALPHA_PREMULTIPLIED = 7;\r\n /**\r\n * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST\r\n * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA\r\n */\r\n Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;\r\n /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */\r\n Engine.ALPHA_INTERPOLATE = 9;\r\n /**\r\n * Defines that alpha blending to SRC + (1 - SRC) * DEST\r\n * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA\r\n */\r\n Engine.ALPHA_SCREENMODE = 10;\r\n /** Defines that the ressource is not delayed*/\r\n Engine.DELAYLOADSTATE_NONE = 0;\r\n /** Defines that the ressource was successfully delay loaded */\r\n Engine.DELAYLOADSTATE_LOADED = 1;\r\n /** Defines that the ressource is currently delay loading */\r\n Engine.DELAYLOADSTATE_LOADING = 2;\r\n /** Defines that the ressource is delayed and has not started loading */\r\n Engine.DELAYLOADSTATE_NOTLOADED = 4;\r\n // Depht or Stencil test Constants.\r\n /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */\r\n Engine.NEVER = 512;\r\n /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */\r\n Engine.ALWAYS = 519;\r\n /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */\r\n Engine.LESS = 513;\r\n /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */\r\n Engine.EQUAL = 514;\r\n /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */\r\n Engine.LEQUAL = 515;\r\n /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */\r\n Engine.GREATER = 516;\r\n /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */\r\n Engine.GEQUAL = 518;\r\n /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */\r\n Engine.NOTEQUAL = 517;\r\n // Stencil Actions Constants.\r\n /** Passed to stencilOperation to specify that stencil value must be kept */\r\n Engine.KEEP = 7680;\r\n /** Passed to stencilOperation to specify that stencil value must be replaced */\r\n Engine.REPLACE = 7681;\r\n /** Passed to stencilOperation to specify that stencil value must be incremented */\r\n Engine.INCR = 7682;\r\n /** Passed to stencilOperation to specify that stencil value must be decremented */\r\n Engine.DECR = 7683;\r\n /** Passed to stencilOperation to specify that stencil value must be inverted */\r\n Engine.INVERT = 5386;\r\n /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */\r\n Engine.INCR_WRAP = 34055;\r\n /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */\r\n Engine.DECR_WRAP = 34056;\r\n /** Texture is not repeating outside of 0..1 UVs */\r\n Engine.TEXTURE_CLAMP_ADDRESSMODE = 0;\r\n /** Texture is repeating outside of 0..1 UVs */\r\n Engine.TEXTURE_WRAP_ADDRESSMODE = 1;\r\n /** Texture is repeating and mirrored */\r\n Engine.TEXTURE_MIRROR_ADDRESSMODE = 2;\r\n /** ALPHA */\r\n Engine.TEXTUREFORMAT_ALPHA = 0;\r\n /** LUMINANCE */\r\n Engine.TEXTUREFORMAT_LUMINANCE = 1;\r\n /** LUMINANCE_ALPHA */\r\n Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;\r\n /** RGB */\r\n Engine.TEXTUREFORMAT_RGB = 4;\r\n /** RGBA */\r\n Engine.TEXTUREFORMAT_RGBA = 5;\r\n /** RED */\r\n Engine.TEXTUREFORMAT_RED = 6;\r\n /** RED (2nd reference) */\r\n Engine.TEXTUREFORMAT_R = 6;\r\n /** RG */\r\n Engine.TEXTUREFORMAT_RG = 7;\r\n /** RED_INTEGER */\r\n Engine.TEXTUREFORMAT_RED_INTEGER = 8;\r\n /** RED_INTEGER (2nd reference) */\r\n Engine.TEXTUREFORMAT_R_INTEGER = 8;\r\n /** RG_INTEGER */\r\n Engine.TEXTUREFORMAT_RG_INTEGER = 9;\r\n /** RGB_INTEGER */\r\n Engine.TEXTUREFORMAT_RGB_INTEGER = 10;\r\n /** RGBA_INTEGER */\r\n Engine.TEXTUREFORMAT_RGBA_INTEGER = 11;\r\n /** UNSIGNED_BYTE */\r\n Engine.TEXTURETYPE_UNSIGNED_BYTE = 0;\r\n /** UNSIGNED_BYTE (2nd reference) */\r\n Engine.TEXTURETYPE_UNSIGNED_INT = 0;\r\n /** FLOAT */\r\n Engine.TEXTURETYPE_FLOAT = 1;\r\n /** HALF_FLOAT */\r\n Engine.TEXTURETYPE_HALF_FLOAT = 2;\r\n /** BYTE */\r\n Engine.TEXTURETYPE_BYTE = 3;\r\n /** SHORT */\r\n Engine.TEXTURETYPE_SHORT = 4;\r\n /** UNSIGNED_SHORT */\r\n Engine.TEXTURETYPE_UNSIGNED_SHORT = 5;\r\n /** INT */\r\n Engine.TEXTURETYPE_INT = 6;\r\n /** UNSIGNED_INT */\r\n Engine.TEXTURETYPE_UNSIGNED_INTEGER = 7;\r\n /** UNSIGNED_SHORT_4_4_4_4 */\r\n Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;\r\n /** UNSIGNED_SHORT_5_5_5_1 */\r\n Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;\r\n /** UNSIGNED_SHORT_5_6_5 */\r\n Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;\r\n /** UNSIGNED_INT_2_10_10_10_REV */\r\n Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;\r\n /** UNSIGNED_INT_24_8 */\r\n Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;\r\n /** UNSIGNED_INT_10F_11F_11F_REV */\r\n Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;\r\n /** UNSIGNED_INT_5_9_9_9_REV */\r\n Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;\r\n /** FLOAT_32_UNSIGNED_INT_24_8_REV */\r\n Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;\r\n /** nearest is mag = nearest and min = nearest and mip = linear */\r\n Engine.TEXTURE_NEAREST_SAMPLINGMODE = 1;\r\n /** Bilinear is mag = linear and min = linear and mip = nearest */\r\n Engine.TEXTURE_BILINEAR_SAMPLINGMODE = 2;\r\n /** Trilinear is mag = linear and min = linear and mip = linear */\r\n Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;\r\n /** nearest is mag = nearest and min = nearest and mip = linear */\r\n Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8;\r\n /** Bilinear is mag = linear and min = linear and mip = nearest */\r\n Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11;\r\n /** Trilinear is mag = linear and min = linear and mip = linear */\r\n Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;\r\n /** mag = nearest and min = nearest and mip = nearest */\r\n Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;\r\n /** mag = nearest and min = linear and mip = nearest */\r\n Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;\r\n /** mag = nearest and min = linear and mip = linear */\r\n Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;\r\n /** mag = nearest and min = linear and mip = none */\r\n Engine.TEXTURE_NEAREST_LINEAR = 7;\r\n /** mag = nearest and min = nearest and mip = none */\r\n Engine.TEXTURE_NEAREST_NEAREST = 1;\r\n /** mag = linear and min = nearest and mip = nearest */\r\n Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;\r\n /** mag = linear and min = nearest and mip = linear */\r\n Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;\r\n /** mag = linear and min = linear and mip = none */\r\n Engine.TEXTURE_LINEAR_LINEAR = 2;\r\n /** mag = linear and min = nearest and mip = none */\r\n Engine.TEXTURE_LINEAR_NEAREST = 12;\r\n /** Explicit coordinates mode */\r\n Engine.TEXTURE_EXPLICIT_MODE = 0;\r\n /** Spherical coordinates mode */\r\n Engine.TEXTURE_SPHERICAL_MODE = 1;\r\n /** Planar coordinates mode */\r\n Engine.TEXTURE_PLANAR_MODE = 2;\r\n /** Cubic coordinates mode */\r\n Engine.TEXTURE_CUBIC_MODE = 3;\r\n /** Projection coordinates mode */\r\n Engine.TEXTURE_PROJECTION_MODE = 4;\r\n /** Skybox coordinates mode */\r\n Engine.TEXTURE_SKYBOX_MODE = 5;\r\n /** Inverse Cubic coordinates mode */\r\n Engine.TEXTURE_INVCUBIC_MODE = 6;\r\n /** Equirectangular coordinates mode */\r\n Engine.TEXTURE_EQUIRECTANGULAR_MODE = 7;\r\n /** Equirectangular Fixed coordinates mode */\r\n Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;\r\n /** Equirectangular Fixed Mirrored coordinates mode */\r\n Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;\r\n // Texture rescaling mode\r\n /** Defines that texture rescaling will use a floor to find the closer power of 2 size */\r\n Engine.SCALEMODE_FLOOR = 1;\r\n /** Defines that texture rescaling will look for the nearest power of 2 size */\r\n Engine.SCALEMODE_NEAREST = 2;\r\n /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */\r\n Engine.SCALEMODE_CEILING = 3;\r\n /**\r\n * Method called to create the default rescale post process on each engine.\r\n */\r\n Engine._RescalePostProcessFactory = null;\r\n return Engine;\r\n}(ThinEngine));\r\nexport { Engine };\r\n//# sourceMappingURL=engine.js.map","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (process.env.NODE_ENV !== 'production') {\n var ReactIs = require('react-is');\n\n // By explicitly using `prop-types` you are opting into new development behavior.\n // http://fb.me/prop-types-in-prod\n var throwOnDirectAccess = true;\n module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess);\n} else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = require('./factoryWithThrowingShims')();\n}\n","/** @hidden */\r\nvar _DevTools = /** @class */ (function () {\r\n function _DevTools() {\r\n }\r\n _DevTools.WarnImport = function (name) {\r\n return name + \" needs to be imported before as it contains a side-effect required by your code.\";\r\n };\r\n return _DevTools;\r\n}());\r\nexport { _DevTools };\r\n//# sourceMappingURL=devTools.js.map","/**\r\n * The engine store class is responsible to hold all the instances of Engine and Scene created\r\n * during the life time of the application.\r\n */\r\nvar EngineStore = /** @class */ (function () {\r\n function EngineStore() {\r\n }\r\n Object.defineProperty(EngineStore, \"LastCreatedEngine\", {\r\n /**\r\n * Gets the latest created engine\r\n */\r\n get: function () {\r\n if (this.Instances.length === 0) {\r\n return null;\r\n }\r\n return this.Instances[this.Instances.length - 1];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(EngineStore, \"LastCreatedScene\", {\r\n /**\r\n * Gets the latest created scene\r\n */\r\n get: function () {\r\n return this._LastCreatedScene;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /** Gets the list of created engines */\r\n EngineStore.Instances = new Array();\r\n /** @hidden */\r\n EngineStore._LastCreatedScene = null;\r\n /**\r\n * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded\r\n * @ignorenaming\r\n */\r\n EngineStore.UseFallbackTexture = true;\r\n /**\r\n * Texture content used if a texture cannot loaded\r\n * @ignorenaming\r\n */\r\n EngineStore.FallbackTexture = \"\";\r\n return EngineStore;\r\n}());\r\nexport { EngineStore };\r\n//# sourceMappingURL=engineStore.js.map","/*!\n Copyright (c) 2017 Jed Watson.\n Licensed under the MIT License (MIT), see\n http://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg) && arg.length) {\n\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\tif (inner) {\n\t\t\t\t\tclasses.push(inner);\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import { Observable } from \"../../Misc/observable\";\r\nimport { RenderTargetCreationOptions } from \"../../Materials/Textures/renderTargetCreationOptions\";\r\nimport { _DevTools } from '../../Misc/devTools';\r\n/**\r\n * Defines the source of the internal texture\r\n */\r\nexport var InternalTextureSource;\r\n(function (InternalTextureSource) {\r\n /**\r\n * The source of the texture data is unknown\r\n */\r\n InternalTextureSource[InternalTextureSource[\"Unknown\"] = 0] = \"Unknown\";\r\n /**\r\n * Texture data comes from an URL\r\n */\r\n InternalTextureSource[InternalTextureSource[\"Url\"] = 1] = \"Url\";\r\n /**\r\n * Texture data is only used for temporary storage\r\n */\r\n InternalTextureSource[InternalTextureSource[\"Temp\"] = 2] = \"Temp\";\r\n /**\r\n * Texture data comes from raw data (ArrayBuffer)\r\n */\r\n InternalTextureSource[InternalTextureSource[\"Raw\"] = 3] = \"Raw\";\r\n /**\r\n * Texture content is dynamic (video or dynamic texture)\r\n */\r\n InternalTextureSource[InternalTextureSource[\"Dynamic\"] = 4] = \"Dynamic\";\r\n /**\r\n * Texture content is generated by rendering to it\r\n */\r\n InternalTextureSource[InternalTextureSource[\"RenderTarget\"] = 5] = \"RenderTarget\";\r\n /**\r\n * Texture content is part of a multi render target process\r\n */\r\n InternalTextureSource[InternalTextureSource[\"MultiRenderTarget\"] = 6] = \"MultiRenderTarget\";\r\n /**\r\n * Texture data comes from a cube data file\r\n */\r\n InternalTextureSource[InternalTextureSource[\"Cube\"] = 7] = \"Cube\";\r\n /**\r\n * Texture data comes from a raw cube data\r\n */\r\n InternalTextureSource[InternalTextureSource[\"CubeRaw\"] = 8] = \"CubeRaw\";\r\n /**\r\n * Texture data come from a prefiltered cube data file\r\n */\r\n InternalTextureSource[InternalTextureSource[\"CubePrefiltered\"] = 9] = \"CubePrefiltered\";\r\n /**\r\n * Texture content is raw 3D data\r\n */\r\n InternalTextureSource[InternalTextureSource[\"Raw3D\"] = 10] = \"Raw3D\";\r\n /**\r\n * Texture content is raw 2D array data\r\n */\r\n InternalTextureSource[InternalTextureSource[\"Raw2DArray\"] = 11] = \"Raw2DArray\";\r\n /**\r\n * Texture content is a depth texture\r\n */\r\n InternalTextureSource[InternalTextureSource[\"Depth\"] = 12] = \"Depth\";\r\n /**\r\n * Texture data comes from a raw cube data encoded with RGBD\r\n */\r\n InternalTextureSource[InternalTextureSource[\"CubeRawRGBD\"] = 13] = \"CubeRawRGBD\";\r\n})(InternalTextureSource || (InternalTextureSource = {}));\r\n/**\r\n * Class used to store data associated with WebGL texture data for the engine\r\n * This class should not be used directly\r\n */\r\nvar InternalTexture = /** @class */ (function () {\r\n /**\r\n * Creates a new InternalTexture\r\n * @param engine defines the engine to use\r\n * @param source defines the type of data that will be used\r\n * @param delayAllocation if the texture allocation should be delayed (default: false)\r\n */\r\n function InternalTexture(engine, source, delayAllocation) {\r\n if (delayAllocation === void 0) { delayAllocation = false; }\r\n /**\r\n * Defines if the texture is ready\r\n */\r\n this.isReady = false;\r\n /**\r\n * Defines if the texture is a cube texture\r\n */\r\n this.isCube = false;\r\n /**\r\n * Defines if the texture contains 3D data\r\n */\r\n this.is3D = false;\r\n /**\r\n * Defines if the texture contains 2D array data\r\n */\r\n this.is2DArray = false;\r\n /**\r\n * Defines if the texture contains multiview data\r\n */\r\n this.isMultiview = false;\r\n /**\r\n * Gets the URL used to load this texture\r\n */\r\n this.url = \"\";\r\n /**\r\n * Gets the sampling mode of the texture\r\n */\r\n this.samplingMode = -1;\r\n /**\r\n * Gets a boolean indicating if the texture needs mipmaps generation\r\n */\r\n this.generateMipMaps = false;\r\n /**\r\n * Gets the number of samples used by the texture (WebGL2+ only)\r\n */\r\n this.samples = 0;\r\n /**\r\n * Gets the type of the texture (int, float...)\r\n */\r\n this.type = -1;\r\n /**\r\n * Gets the format of the texture (RGB, RGBA...)\r\n */\r\n this.format = -1;\r\n /**\r\n * Observable called when the texture is loaded\r\n */\r\n this.onLoadedObservable = new Observable();\r\n /**\r\n * Gets the width of the texture\r\n */\r\n this.width = 0;\r\n /**\r\n * Gets the height of the texture\r\n */\r\n this.height = 0;\r\n /**\r\n * Gets the depth of the texture\r\n */\r\n this.depth = 0;\r\n /**\r\n * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n this.baseWidth = 0;\r\n /**\r\n * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n this.baseHeight = 0;\r\n /**\r\n * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n this.baseDepth = 0;\r\n /**\r\n * Gets a boolean indicating if the texture is inverted on Y axis\r\n */\r\n this.invertY = false;\r\n // Private\r\n /** @hidden */\r\n this._invertVScale = false;\r\n /** @hidden */\r\n this._associatedChannel = -1;\r\n /** @hidden */\r\n this._source = InternalTextureSource.Unknown;\r\n /** @hidden */\r\n this._buffer = null;\r\n /** @hidden */\r\n this._bufferView = null;\r\n /** @hidden */\r\n this._bufferViewArray = null;\r\n /** @hidden */\r\n this._bufferViewArrayArray = null;\r\n /** @hidden */\r\n this._size = 0;\r\n /** @hidden */\r\n this._extension = \"\";\r\n /** @hidden */\r\n this._files = null;\r\n /** @hidden */\r\n this._workingCanvas = null;\r\n /** @hidden */\r\n this._workingContext = null;\r\n /** @hidden */\r\n this._framebuffer = null;\r\n /** @hidden */\r\n this._depthStencilBuffer = null;\r\n /** @hidden */\r\n this._MSAAFramebuffer = null;\r\n /** @hidden */\r\n this._MSAARenderBuffer = null;\r\n /** @hidden */\r\n this._attachments = null;\r\n /** @hidden */\r\n this._cachedCoordinatesMode = null;\r\n /** @hidden */\r\n this._cachedWrapU = null;\r\n /** @hidden */\r\n this._cachedWrapV = null;\r\n /** @hidden */\r\n this._cachedWrapR = null;\r\n /** @hidden */\r\n this._cachedAnisotropicFilteringLevel = null;\r\n /** @hidden */\r\n this._isDisabled = false;\r\n /** @hidden */\r\n this._compression = null;\r\n /** @hidden */\r\n this._generateStencilBuffer = false;\r\n /** @hidden */\r\n this._generateDepthBuffer = false;\r\n /** @hidden */\r\n this._comparisonFunction = 0;\r\n /** @hidden */\r\n this._sphericalPolynomial = null;\r\n /** @hidden */\r\n this._lodGenerationScale = 0;\r\n /** @hidden */\r\n this._lodGenerationOffset = 0;\r\n // Multiview\r\n /** @hidden */\r\n this._colorTextureArray = null;\r\n /** @hidden */\r\n this._depthStencilTextureArray = null;\r\n // The following three fields helps sharing generated fixed LODs for texture filtering\r\n // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.\r\n // They are at the level of the gl texture to benefit from the cache.\r\n /** @hidden */\r\n this._lodTextureHigh = null;\r\n /** @hidden */\r\n this._lodTextureMid = null;\r\n /** @hidden */\r\n this._lodTextureLow = null;\r\n /** @hidden */\r\n this._isRGBD = false;\r\n /** @hidden */\r\n this._linearSpecularLOD = false;\r\n /** @hidden */\r\n this._irradianceTexture = null;\r\n /** @hidden */\r\n this._webGLTexture = null;\r\n /** @hidden */\r\n this._references = 1;\r\n this._engine = engine;\r\n this._source = source;\r\n if (!delayAllocation) {\r\n this._webGLTexture = engine._createTexture();\r\n }\r\n }\r\n /**\r\n * Gets the Engine the texture belongs to.\r\n * @returns The babylon engine\r\n */\r\n InternalTexture.prototype.getEngine = function () {\r\n return this._engine;\r\n };\r\n Object.defineProperty(InternalTexture.prototype, \"source\", {\r\n /**\r\n * Gets the data source type of the texture\r\n */\r\n get: function () {\r\n return this._source;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Increments the number of references (ie. the number of Texture that point to it)\r\n */\r\n InternalTexture.prototype.incrementReferences = function () {\r\n this._references++;\r\n };\r\n /**\r\n * Change the size of the texture (not the size of the content)\r\n * @param width defines the new width\r\n * @param height defines the new height\r\n * @param depth defines the new depth (1 by default)\r\n */\r\n InternalTexture.prototype.updateSize = function (width, height, depth) {\r\n if (depth === void 0) { depth = 1; }\r\n this.width = width;\r\n this.height = height;\r\n this.depth = depth;\r\n this.baseWidth = width;\r\n this.baseHeight = height;\r\n this.baseDepth = depth;\r\n this._size = width * height * depth;\r\n };\r\n /** @hidden */\r\n InternalTexture.prototype._rebuild = function () {\r\n var _this = this;\r\n var proxy;\r\n this.isReady = false;\r\n this._cachedCoordinatesMode = null;\r\n this._cachedWrapU = null;\r\n this._cachedWrapV = null;\r\n this._cachedAnisotropicFilteringLevel = null;\r\n switch (this.source) {\r\n case InternalTextureSource.Temp:\r\n return;\r\n case InternalTextureSource.Url:\r\n proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {\r\n proxy._swapAndDie(_this);\r\n _this.isReady = true;\r\n }, null, this._buffer, undefined, this.format);\r\n return;\r\n case InternalTextureSource.Raw:\r\n proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);\r\n proxy._swapAndDie(this);\r\n this.isReady = true;\r\n return;\r\n case InternalTextureSource.Raw3D:\r\n proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);\r\n proxy._swapAndDie(this);\r\n this.isReady = true;\r\n return;\r\n case InternalTextureSource.Raw2DArray:\r\n proxy = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);\r\n proxy._swapAndDie(this);\r\n this.isReady = true;\r\n return;\r\n case InternalTextureSource.Dynamic:\r\n proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);\r\n proxy._swapAndDie(this);\r\n this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);\r\n // The engine will make sure to update content so no need to flag it as isReady = true\r\n return;\r\n case InternalTextureSource.RenderTarget:\r\n var options = new RenderTargetCreationOptions();\r\n options.generateDepthBuffer = this._generateDepthBuffer;\r\n options.generateMipMaps = this.generateMipMaps;\r\n options.generateStencilBuffer = this._generateStencilBuffer;\r\n options.samplingMode = this.samplingMode;\r\n options.type = this.type;\r\n if (this.isCube) {\r\n proxy = this._engine.createRenderTargetCubeTexture(this.width, options);\r\n }\r\n else {\r\n var size_1 = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray ? this.depth : undefined\r\n };\r\n proxy = this._engine.createRenderTargetTexture(size_1, options);\r\n }\r\n proxy._swapAndDie(this);\r\n this.isReady = true;\r\n return;\r\n case InternalTextureSource.Depth:\r\n var depthTextureOptions = {\r\n bilinearFiltering: this.samplingMode !== 2,\r\n comparisonFunction: this._comparisonFunction,\r\n generateStencil: this._generateStencilBuffer,\r\n isCube: this.isCube\r\n };\r\n var size = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray ? this.depth : undefined\r\n };\r\n proxy = this._engine.createDepthStencilTexture(size, depthTextureOptions);\r\n proxy._swapAndDie(this);\r\n this.isReady = true;\r\n return;\r\n case InternalTextureSource.Cube:\r\n proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {\r\n proxy._swapAndDie(_this);\r\n _this.isReady = true;\r\n }, null, this.format, this._extension);\r\n return;\r\n case InternalTextureSource.CubeRaw:\r\n proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);\r\n proxy._swapAndDie(this);\r\n this.isReady = true;\r\n return;\r\n case InternalTextureSource.CubeRawRGBD:\r\n proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);\r\n InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {\r\n proxy._swapAndDie(_this);\r\n _this.isReady = true;\r\n });\r\n return;\r\n case InternalTextureSource.CubePrefiltered:\r\n proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {\r\n if (proxy) {\r\n proxy._swapAndDie(_this);\r\n }\r\n _this.isReady = true;\r\n }, null, this.format, this._extension);\r\n proxy._sphericalPolynomial = this._sphericalPolynomial;\r\n return;\r\n }\r\n };\r\n /** @hidden */\r\n InternalTexture.prototype._swapAndDie = function (target) {\r\n target._webGLTexture = this._webGLTexture;\r\n target._isRGBD = this._isRGBD;\r\n if (this._framebuffer) {\r\n target._framebuffer = this._framebuffer;\r\n }\r\n if (this._depthStencilBuffer) {\r\n target._depthStencilBuffer = this._depthStencilBuffer;\r\n }\r\n target._depthStencilTexture = this._depthStencilTexture;\r\n if (this._lodTextureHigh) {\r\n if (target._lodTextureHigh) {\r\n target._lodTextureHigh.dispose();\r\n }\r\n target._lodTextureHigh = this._lodTextureHigh;\r\n }\r\n if (this._lodTextureMid) {\r\n if (target._lodTextureMid) {\r\n target._lodTextureMid.dispose();\r\n }\r\n target._lodTextureMid = this._lodTextureMid;\r\n }\r\n if (this._lodTextureLow) {\r\n if (target._lodTextureLow) {\r\n target._lodTextureLow.dispose();\r\n }\r\n target._lodTextureLow = this._lodTextureLow;\r\n }\r\n if (this._irradianceTexture) {\r\n if (target._irradianceTexture) {\r\n target._irradianceTexture.dispose();\r\n }\r\n target._irradianceTexture = this._irradianceTexture;\r\n }\r\n var cache = this._engine.getLoadedTexturesCache();\r\n var index = cache.indexOf(this);\r\n if (index !== -1) {\r\n cache.splice(index, 1);\r\n }\r\n var index = cache.indexOf(target);\r\n if (index === -1) {\r\n cache.push(target);\r\n }\r\n };\r\n /**\r\n * Dispose the current allocated resources\r\n */\r\n InternalTexture.prototype.dispose = function () {\r\n if (!this._webGLTexture) {\r\n return;\r\n }\r\n this._references--;\r\n if (this._references === 0) {\r\n this._engine._releaseTexture(this);\r\n this._webGLTexture = null;\r\n }\r\n };\r\n /** @hidden */\r\n InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {\r\n throw _DevTools.WarnImport(\"environmentTextureTools\");\r\n };\r\n return InternalTexture;\r\n}());\r\nexport { InternalTexture };\r\n//# sourceMappingURL=internalTexture.js.map","import { EngineStore } from './engineStore';\r\nimport { Effect } from '../Materials/effect';\r\nimport { _DevTools } from '../Misc/devTools';\r\nimport { Observable } from '../Misc/observable';\r\nimport { DepthCullingState } from '../States/depthCullingState';\r\nimport { StencilState } from '../States/stencilState';\r\nimport { AlphaState } from '../States/alphaCullingState';\r\nimport { InternalTexture, InternalTextureSource } from '../Materials/Textures/internalTexture';\r\nimport { Logger } from '../Misc/logger';\r\nimport { DomManagement } from '../Misc/domManagement';\r\nimport { WebGL2ShaderProcessor } from './WebGL/webGL2ShaderProcessors';\r\nimport { WebGLDataBuffer } from '../Meshes/WebGL/webGLDataBuffer';\r\nimport { WebGLPipelineContext } from './WebGL/webGLPipelineContext';\r\nimport { CanvasGenerator } from '../Misc/canvasGenerator';\r\n/**\r\n * Keeps track of all the buffer info used in engine.\r\n */\r\nvar BufferPointer = /** @class */ (function () {\r\n function BufferPointer() {\r\n }\r\n return BufferPointer;\r\n}());\r\n/**\r\n * The base engine class (root of all engines)\r\n */\r\nvar ThinEngine = /** @class */ (function () {\r\n /**\r\n * Creates a new engine\r\n * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context\r\n * @param antialias defines enable antialiasing (default: false)\r\n * @param options defines further options to be sent to the getContext() function\r\n * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)\r\n */\r\n function ThinEngine(canvasOrContext, antialias, options, adaptToDeviceRatio) {\r\n var _this = this;\r\n if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }\r\n /**\r\n * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required\r\n */\r\n this.forcePOTTextures = false;\r\n /**\r\n * Gets a boolean indicating if the engine is currently rendering in fullscreen mode\r\n */\r\n this.isFullscreen = false;\r\n /**\r\n * Gets or sets a boolean indicating if back faces must be culled (true by default)\r\n */\r\n this.cullBackFaces = true;\r\n /**\r\n * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun\r\n */\r\n this.renderEvenInBackground = true;\r\n /**\r\n * Gets or sets a boolean indicating that cache can be kept between frames\r\n */\r\n this.preventCacheWipeBetweenFrames = false;\r\n /** Gets or sets a boolean indicating if the engine should validate programs after compilation */\r\n this.validateShaderPrograms = false;\r\n /**\r\n * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.\r\n * This can provide greater z depth for distant objects.\r\n */\r\n this.useReverseDepthBuffer = false;\r\n // Uniform buffers list\r\n /**\r\n * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported\r\n */\r\n this.disableUniformBuffers = false;\r\n /** @hidden */\r\n this._uniformBuffers = new Array();\r\n /** @hidden */\r\n this._webGLVersion = 1.0;\r\n this._windowIsBackground = false;\r\n this._highPrecisionShadersAllowed = true;\r\n /** @hidden */\r\n this._badOS = false;\r\n /** @hidden */\r\n this._badDesktopOS = false;\r\n this._renderingQueueLaunched = false;\r\n this._activeRenderLoops = new Array();\r\n // Lost context\r\n /**\r\n * Observable signaled when a context lost event is raised\r\n */\r\n this.onContextLostObservable = new Observable();\r\n /**\r\n * Observable signaled when a context restored event is raised\r\n */\r\n this.onContextRestoredObservable = new Observable();\r\n this._contextWasLost = false;\r\n /** @hidden */\r\n this._doNotHandleContextLost = false;\r\n /**\r\n * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported\r\n */\r\n this.disableVertexArrayObjects = false;\r\n // States\r\n /** @hidden */\r\n this._colorWrite = true;\r\n /** @hidden */\r\n this._colorWriteChanged = true;\r\n /** @hidden */\r\n this._depthCullingState = new DepthCullingState();\r\n /** @hidden */\r\n this._stencilState = new StencilState();\r\n /** @hidden */\r\n this._alphaState = new AlphaState();\r\n /** @hidden */\r\n this._alphaMode = 1;\r\n /** @hidden */\r\n this._alphaEquation = 0;\r\n // Cache\r\n /** @hidden */\r\n this._internalTexturesCache = new Array();\r\n /** @hidden */\r\n this._activeChannel = 0;\r\n this._currentTextureChannel = -1;\r\n /** @hidden */\r\n this._boundTexturesCache = {};\r\n this._compiledEffects = {};\r\n this._vertexAttribArraysEnabled = [];\r\n this._uintIndicesCurrentlySet = false;\r\n this._currentBoundBuffer = new Array();\r\n /** @hidden */\r\n this._currentFramebuffer = null;\r\n this._currentBufferPointers = new Array();\r\n this._currentInstanceLocations = new Array();\r\n this._currentInstanceBuffers = new Array();\r\n this._vaoRecordInProgress = false;\r\n this._mustWipeVertexAttributes = false;\r\n this._nextFreeTextureSlots = new Array();\r\n this._maxSimultaneousTextures = 0;\r\n this._activeRequests = new Array();\r\n // Hardware supported Compressed Textures\r\n this._texturesSupported = new Array();\r\n /**\r\n * Defines whether the engine has been created with the premultipliedAlpha option on or not.\r\n */\r\n this.premultipliedAlpha = true;\r\n /**\r\n * Observable event triggered before each texture is initialized\r\n */\r\n this.onBeforeTextureInitObservable = new Observable();\r\n this._viewportCached = { x: 0, y: 0, z: 0, w: 0 };\r\n this._unpackFlipYCached = null;\r\n /**\r\n * In case you are sharing the context with other applications, it might\r\n * be interested to not cache the unpack flip y state to ensure a consistent\r\n * value would be set.\r\n */\r\n this.enableUnpackFlipYCached = true;\r\n this._getDepthStencilBuffer = function (width, height, samples, internalFormat, msInternalFormat, attachment) {\r\n var gl = _this._gl;\r\n var depthStencilBuffer = gl.createRenderbuffer();\r\n gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);\r\n if (samples > 1 && gl.renderbufferStorageMultisample) {\r\n gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, msInternalFormat, width, height);\r\n }\r\n else {\r\n gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);\r\n }\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, depthStencilBuffer);\r\n gl.bindRenderbuffer(gl.RENDERBUFFER, null);\r\n return depthStencilBuffer;\r\n };\r\n this._boundUniforms = {};\r\n var canvas = null;\r\n if (!canvasOrContext) {\r\n return;\r\n }\r\n options = options || {};\r\n if (canvasOrContext.getContext) {\r\n canvas = canvasOrContext;\r\n this._renderingCanvas = canvas;\r\n if (antialias != null) {\r\n options.antialias = antialias;\r\n }\r\n if (options.deterministicLockstep === undefined) {\r\n options.deterministicLockstep = false;\r\n }\r\n if (options.lockstepMaxSteps === undefined) {\r\n options.lockstepMaxSteps = 4;\r\n }\r\n if (options.timeStep === undefined) {\r\n options.timeStep = 1 / 60;\r\n }\r\n if (options.preserveDrawingBuffer === undefined) {\r\n options.preserveDrawingBuffer = false;\r\n }\r\n if (options.audioEngine === undefined) {\r\n options.audioEngine = true;\r\n }\r\n if (options.stencil === undefined) {\r\n options.stencil = true;\r\n }\r\n if (options.premultipliedAlpha === false) {\r\n this.premultipliedAlpha = false;\r\n }\r\n this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;\r\n // Exceptions\r\n if (navigator && navigator.userAgent) {\r\n var ua = navigator.userAgent;\r\n for (var _i = 0, _a = ThinEngine.ExceptionList; _i < _a.length; _i++) {\r\n var exception = _a[_i];\r\n var key = exception.key;\r\n var targets = exception.targets;\r\n var check = new RegExp(key);\r\n if (check.test(ua)) {\r\n if (exception.capture && exception.captureConstraint) {\r\n var capture = exception.capture;\r\n var constraint = exception.captureConstraint;\r\n var regex = new RegExp(capture);\r\n var matches = regex.exec(ua);\r\n if (matches && matches.length > 0) {\r\n var capturedValue = parseInt(matches[matches.length - 1]);\r\n if (capturedValue >= constraint) {\r\n continue;\r\n }\r\n }\r\n }\r\n for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {\r\n var target = targets_1[_b];\r\n switch (target) {\r\n case \"uniformBuffer\":\r\n this.disableUniformBuffers = true;\r\n break;\r\n case \"vao\":\r\n this.disableVertexArrayObjects = true;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n // Context lost\r\n if (!this._doNotHandleContextLost) {\r\n this._onContextLost = function (evt) {\r\n evt.preventDefault();\r\n _this._contextWasLost = true;\r\n Logger.Warn(\"WebGL context lost.\");\r\n _this.onContextLostObservable.notifyObservers(_this);\r\n };\r\n this._onContextRestored = function () {\r\n // Adding a timeout to avoid race condition at browser level\r\n setTimeout(function () {\r\n // Rebuild gl context\r\n _this._initGLContext();\r\n // Rebuild effects\r\n _this._rebuildEffects();\r\n // Rebuild textures\r\n _this._rebuildInternalTextures();\r\n // Rebuild buffers\r\n _this._rebuildBuffers();\r\n // Cache\r\n _this.wipeCaches(true);\r\n Logger.Warn(\"WebGL context successfully restored.\");\r\n _this.onContextRestoredObservable.notifyObservers(_this);\r\n _this._contextWasLost = false;\r\n }, 0);\r\n };\r\n canvas.addEventListener(\"webglcontextlost\", this._onContextLost, false);\r\n canvas.addEventListener(\"webglcontextrestored\", this._onContextRestored, false);\r\n options.powerPreference = \"high-performance\";\r\n }\r\n // GL\r\n if (!options.disableWebGL2Support) {\r\n try {\r\n this._gl = (canvas.getContext(\"webgl2\", options) || canvas.getContext(\"experimental-webgl2\", options));\r\n if (this._gl) {\r\n this._webGLVersion = 2.0;\r\n // Prevent weird browsers to lie (yeah that happens!)\r\n if (!this._gl.deleteQuery) {\r\n this._webGLVersion = 1.0;\r\n }\r\n }\r\n }\r\n catch (e) {\r\n // Do nothing\r\n }\r\n }\r\n if (!this._gl) {\r\n if (!canvas) {\r\n throw new Error(\"The provided canvas is null or undefined.\");\r\n }\r\n try {\r\n this._gl = (canvas.getContext(\"webgl\", options) || canvas.getContext(\"experimental-webgl\", options));\r\n }\r\n catch (e) {\r\n throw new Error(\"WebGL not supported\");\r\n }\r\n }\r\n if (!this._gl) {\r\n throw new Error(\"WebGL not supported\");\r\n }\r\n }\r\n else {\r\n this._gl = canvasOrContext;\r\n this._renderingCanvas = this._gl.canvas;\r\n if (this._gl.renderbufferStorageMultisample) {\r\n this._webGLVersion = 2.0;\r\n }\r\n var attributes = this._gl.getContextAttributes();\r\n if (attributes) {\r\n options.stencil = attributes.stencil;\r\n }\r\n }\r\n // Ensures a consistent color space unpacking of textures cross browser.\r\n this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);\r\n if (options.useHighPrecisionFloats !== undefined) {\r\n this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;\r\n }\r\n // Viewport\r\n var devicePixelRatio = DomManagement.IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;\r\n var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;\r\n this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;\r\n this.resize();\r\n this._isStencilEnable = options.stencil ? true : false;\r\n this._initGLContext();\r\n // Prepare buffer pointers\r\n for (var i = 0; i < this._caps.maxVertexAttribs; i++) {\r\n this._currentBufferPointers[i] = new BufferPointer();\r\n }\r\n // Shader processor\r\n if (this.webGLVersion > 1) {\r\n this._shaderProcessor = new WebGL2ShaderProcessor();\r\n }\r\n // Detect if we are running on a faulty buggy OS.\r\n this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);\r\n // Detect if we are running on a faulty buggy desktop OS.\r\n this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\r\n this._creationOptions = options;\r\n console.log(\"Babylon.js v\" + ThinEngine.Version + \" - \" + this.description);\r\n }\r\n Object.defineProperty(ThinEngine, \"NpmPackage\", {\r\n /**\r\n * Returns the current npm package of the sdk\r\n */\r\n // Not mixed with Version for tooling purpose.\r\n get: function () {\r\n return \"babylonjs@4.1.0\";\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine, \"Version\", {\r\n /**\r\n * Returns the current version of the framework\r\n */\r\n get: function () {\r\n return \"4.1.0\";\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"description\", {\r\n /**\r\n * Returns a string describing the current engine\r\n */\r\n get: function () {\r\n var description = \"WebGL\" + this.webGLVersion;\r\n if (this._caps.parallelShaderCompile) {\r\n description += \" - Parallel shader compilation\";\r\n }\r\n return description;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine, \"ShadersRepository\", {\r\n /**\r\n * Gets or sets the relative url used to load shaders if using the engine in non-minified mode\r\n */\r\n get: function () {\r\n return Effect.ShadersRepository;\r\n },\r\n set: function (value) {\r\n Effect.ShadersRepository = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"supportsUniformBuffers\", {\r\n /**\r\n * Gets a boolean indicating that the engine supports uniform buffers\r\n * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets\r\n */\r\n get: function () {\r\n return this.webGLVersion > 1 && !this.disableUniformBuffers;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"_shouldUseHighPrecisionShader\", {\r\n /** @hidden */\r\n get: function () {\r\n return !!(this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"needPOTTextures\", {\r\n /**\r\n * Gets a boolean indicating that only power of 2 textures are supported\r\n * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them\r\n */\r\n get: function () {\r\n return this._webGLVersion < 2 || this.forcePOTTextures;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"doNotHandleContextLost\", {\r\n /**\r\n * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events\r\n * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost\r\n */\r\n get: function () {\r\n return this._doNotHandleContextLost;\r\n },\r\n set: function (value) {\r\n this._doNotHandleContextLost = value;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"_supportsHardwareTextureRescaling\", {\r\n get: function () {\r\n return false;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"framebufferDimensionsObject\", {\r\n /**\r\n * sets the object from which width and height will be taken from when getting render width and height\r\n * Will fallback to the gl object\r\n * @param dimensions the framebuffer width and height that will be used.\r\n */\r\n set: function (dimensions) {\r\n this._framebufferDimensionsObject = dimensions;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"texturesSupported\", {\r\n /**\r\n * Gets the list of texture formats supported\r\n */\r\n get: function () {\r\n return this._texturesSupported;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"textureFormatInUse\", {\r\n /**\r\n * Gets the list of texture formats in use\r\n */\r\n get: function () {\r\n return this._textureFormatInUse;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"currentViewport\", {\r\n /**\r\n * Gets the current viewport\r\n */\r\n get: function () {\r\n return this._cachedViewport;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"emptyTexture\", {\r\n /**\r\n * Gets the default empty texture\r\n */\r\n get: function () {\r\n if (!this._emptyTexture) {\r\n this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, 5, false, false, 1);\r\n }\r\n return this._emptyTexture;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"emptyTexture3D\", {\r\n /**\r\n * Gets the default empty 3D texture\r\n */\r\n get: function () {\r\n if (!this._emptyTexture3D) {\r\n this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, 5, false, false, 1);\r\n }\r\n return this._emptyTexture3D;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"emptyTexture2DArray\", {\r\n /**\r\n * Gets the default empty 2D array texture\r\n */\r\n get: function () {\r\n if (!this._emptyTexture2DArray) {\r\n this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, 5, false, false, 1);\r\n }\r\n return this._emptyTexture2DArray;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"emptyCubeTexture\", {\r\n /**\r\n * Gets the default empty cube texture\r\n */\r\n get: function () {\r\n if (!this._emptyCubeTexture) {\r\n var faceData = new Uint8Array(4);\r\n var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];\r\n this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, 5, 0, false, false, 1);\r\n }\r\n return this._emptyCubeTexture;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n ThinEngine.prototype._rebuildInternalTextures = function () {\r\n var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies\r\n for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {\r\n var internalTexture = currentState_1[_i];\r\n internalTexture._rebuild();\r\n }\r\n };\r\n ThinEngine.prototype._rebuildEffects = function () {\r\n for (var key in this._compiledEffects) {\r\n var effect = this._compiledEffects[key];\r\n effect._prepareEffect();\r\n }\r\n Effect.ResetCache();\r\n };\r\n /**\r\n * Gets a boolean indicating if all created effects are ready\r\n * @returns true if all effects are ready\r\n */\r\n ThinEngine.prototype.areAllEffectsReady = function () {\r\n for (var key in this._compiledEffects) {\r\n var effect = this._compiledEffects[key];\r\n if (!effect.isReady()) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n };\r\n ThinEngine.prototype._rebuildBuffers = function () {\r\n // Uniforms\r\n for (var _i = 0, _a = this._uniformBuffers; _i < _a.length; _i++) {\r\n var uniformBuffer = _a[_i];\r\n uniformBuffer._rebuild();\r\n }\r\n };\r\n ThinEngine.prototype._initGLContext = function () {\r\n // Caps\r\n this._caps = {\r\n maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),\r\n maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),\r\n maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),\r\n maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),\r\n maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1,\r\n maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),\r\n maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),\r\n maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),\r\n maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),\r\n maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),\r\n maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),\r\n parallelShaderCompile: this._gl.getExtension('KHR_parallel_shader_compile'),\r\n standardDerivatives: this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null),\r\n maxAnisotropy: 1,\r\n astc: this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc'),\r\n s3tc: this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc'),\r\n pvrtc: this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'),\r\n etc1: this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1'),\r\n etc2: this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||\r\n this._gl.getExtension('WEBGL_compressed_texture_es3_0'),\r\n textureAnisotropicFilterExtension: this._gl.getExtension('EXT_texture_filter_anisotropic') || this._gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic') || this._gl.getExtension('MOZ_EXT_texture_filter_anisotropic'),\r\n uintIndices: this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null,\r\n fragmentDepthSupported: this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null,\r\n highPrecisionShaderSupported: false,\r\n timerQuery: this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension(\"EXT_disjoint_timer_query\"),\r\n canUseTimestampForTimerQuery: false,\r\n drawBuffersExtension: false,\r\n maxMSAASamples: 1,\r\n colorBufferFloat: this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float'),\r\n textureFloat: (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false,\r\n textureHalfFloat: (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false,\r\n textureHalfFloatRender: false,\r\n textureFloatLinearFiltering: false,\r\n textureFloatRender: false,\r\n textureHalfFloatLinearFiltering: false,\r\n vertexArrayObject: false,\r\n instancedArrays: false,\r\n textureLOD: (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false,\r\n blendMinMax: false,\r\n multiview: this._gl.getExtension('OVR_multiview2'),\r\n oculusMultiview: this._gl.getExtension('OCULUS_multiview'),\r\n depthTextureExtension: false\r\n };\r\n // Infos\r\n this._glVersion = this._gl.getParameter(this._gl.VERSION);\r\n var rendererInfo = this._gl.getExtension(\"WEBGL_debug_renderer_info\");\r\n if (rendererInfo != null) {\r\n this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);\r\n this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);\r\n }\r\n if (!this._glVendor) {\r\n this._glVendor = \"Unknown vendor\";\r\n }\r\n if (!this._glRenderer) {\r\n this._glRenderer = \"Unknown renderer\";\r\n }\r\n // Constants\r\n this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).\r\n if (this._gl.RGBA16F !== 0x881A) {\r\n this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.\r\n }\r\n if (this._gl.RGBA32F !== 0x8814) {\r\n this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.\r\n }\r\n if (this._gl.DEPTH24_STENCIL8 !== 35056) {\r\n this._gl.DEPTH24_STENCIL8 = 35056;\r\n }\r\n // Extensions\r\n if (this._caps.timerQuery) {\r\n if (this._webGLVersion === 1) {\r\n this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);\r\n }\r\n this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;\r\n }\r\n this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;\r\n this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;\r\n this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;\r\n this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;\r\n // Checks if some of the format renders first to allow the use of webgl inspector.\r\n if (this._webGLVersion > 1) {\r\n this._gl.HALF_FLOAT_OES = 0x140B;\r\n }\r\n this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();\r\n // Draw buffers\r\n if (this._webGLVersion > 1) {\r\n this._caps.drawBuffersExtension = true;\r\n this._caps.maxMSAASamples = this._gl.getParameter(this._gl.MAX_SAMPLES);\r\n }\r\n else {\r\n var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');\r\n if (drawBuffersExtension !== null) {\r\n this._caps.drawBuffersExtension = true;\r\n this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);\r\n this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;\r\n for (var i = 0; i < 16; i++) {\r\n this._gl[\"COLOR_ATTACHMENT\" + i + \"_WEBGL\"] = drawBuffersExtension[\"COLOR_ATTACHMENT\" + i + \"_WEBGL\"];\r\n }\r\n }\r\n }\r\n // Depth Texture\r\n if (this._webGLVersion > 1) {\r\n this._caps.depthTextureExtension = true;\r\n }\r\n else {\r\n var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');\r\n if (depthTextureExtension != null) {\r\n this._caps.depthTextureExtension = true;\r\n this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;\r\n }\r\n }\r\n // Vertex array object\r\n if (this.disableVertexArrayObjects) {\r\n this._caps.vertexArrayObject = false;\r\n }\r\n else if (this._webGLVersion > 1) {\r\n this._caps.vertexArrayObject = true;\r\n }\r\n else {\r\n var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');\r\n if (vertexArrayObjectExtension != null) {\r\n this._caps.vertexArrayObject = true;\r\n this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);\r\n this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);\r\n this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);\r\n }\r\n }\r\n // Instances count\r\n if (this._webGLVersion > 1) {\r\n this._caps.instancedArrays = true;\r\n }\r\n else {\r\n var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');\r\n if (instanceExtension != null) {\r\n this._caps.instancedArrays = true;\r\n this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);\r\n this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);\r\n this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);\r\n }\r\n else {\r\n this._caps.instancedArrays = false;\r\n }\r\n }\r\n // Intelligently add supported compressed formats in order to check for.\r\n // Check for ASTC support first as it is most powerful and to be very cross platform.\r\n // Next PVRTC & DXT, which are probably superior to ETC1/2.\r\n // Likely no hardware which supports both PVR & DXT, so order matters little.\r\n // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.\r\n if (this._caps.astc) {\r\n this.texturesSupported.push('-astc.ktx');\r\n }\r\n if (this._caps.s3tc) {\r\n this.texturesSupported.push('-dxt.ktx');\r\n }\r\n if (this._caps.pvrtc) {\r\n this.texturesSupported.push('-pvrtc.ktx');\r\n }\r\n if (this._caps.etc2) {\r\n this.texturesSupported.push('-etc2.ktx');\r\n }\r\n if (this._caps.etc1) {\r\n this.texturesSupported.push('-etc1.ktx');\r\n }\r\n if (this._gl.getShaderPrecisionFormat) {\r\n var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);\r\n var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);\r\n if (vertex_highp && fragment_highp) {\r\n this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;\r\n }\r\n }\r\n if (this._webGLVersion > 1) {\r\n this._caps.blendMinMax = true;\r\n }\r\n else {\r\n var blendMinMaxExtension = this._gl.getExtension('EXT_blend_minmax');\r\n if (blendMinMaxExtension != null) {\r\n this._caps.blendMinMax = true;\r\n this._gl.MAX = blendMinMaxExtension.MAX_EXT;\r\n this._gl.MIN = blendMinMaxExtension.MIN_EXT;\r\n }\r\n }\r\n // Depth buffer\r\n this._depthCullingState.depthTest = true;\r\n this._depthCullingState.depthFunc = this._gl.LEQUAL;\r\n this._depthCullingState.depthMask = true;\r\n // Texture maps\r\n this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;\r\n for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {\r\n this._nextFreeTextureSlots.push(slot);\r\n }\r\n };\r\n Object.defineProperty(ThinEngine.prototype, \"webGLVersion\", {\r\n /**\r\n * Gets version of the current webGL context\r\n */\r\n get: function () {\r\n return this._webGLVersion;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Gets a string idenfifying the name of the class\r\n * @returns \"Engine\" string\r\n */\r\n ThinEngine.prototype.getClassName = function () {\r\n return \"ThinEngine\";\r\n };\r\n Object.defineProperty(ThinEngine.prototype, \"isStencilEnable\", {\r\n /**\r\n * Returns true if the stencil buffer has been enabled through the creation option of the context.\r\n */\r\n get: function () {\r\n return this._isStencilEnable;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /** @hidden */\r\n ThinEngine.prototype._prepareWorkingCanvas = function () {\r\n if (this._workingCanvas) {\r\n return;\r\n }\r\n this._workingCanvas = CanvasGenerator.CreateCanvas(1, 1);\r\n var context = this._workingCanvas.getContext(\"2d\");\r\n if (context) {\r\n this._workingContext = context;\r\n }\r\n };\r\n /**\r\n * Reset the texture cache to empty state\r\n */\r\n ThinEngine.prototype.resetTextureCache = function () {\r\n for (var key in this._boundTexturesCache) {\r\n if (!this._boundTexturesCache.hasOwnProperty(key)) {\r\n continue;\r\n }\r\n this._boundTexturesCache[key] = null;\r\n }\r\n this._currentTextureChannel = -1;\r\n };\r\n /**\r\n * Gets an object containing information about the current webGL context\r\n * @returns an object containing the vender, the renderer and the version of the current webGL context\r\n */\r\n ThinEngine.prototype.getGlInfo = function () {\r\n return {\r\n vendor: this._glVendor,\r\n renderer: this._glRenderer,\r\n version: this._glVersion\r\n };\r\n };\r\n /**\r\n * Defines the hardware scaling level.\r\n * By default the hardware scaling level is computed from the window device ratio.\r\n * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.\r\n * @param level defines the level to use\r\n */\r\n ThinEngine.prototype.setHardwareScalingLevel = function (level) {\r\n this._hardwareScalingLevel = level;\r\n this.resize();\r\n };\r\n /**\r\n * Gets the current hardware scaling level.\r\n * By default the hardware scaling level is computed from the window device ratio.\r\n * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.\r\n * @returns a number indicating the current hardware scaling level\r\n */\r\n ThinEngine.prototype.getHardwareScalingLevel = function () {\r\n return this._hardwareScalingLevel;\r\n };\r\n /**\r\n * Gets the list of loaded textures\r\n * @returns an array containing all loaded textures\r\n */\r\n ThinEngine.prototype.getLoadedTexturesCache = function () {\r\n return this._internalTexturesCache;\r\n };\r\n /**\r\n * Gets the object containing all engine capabilities\r\n * @returns the EngineCapabilities object\r\n */\r\n ThinEngine.prototype.getCaps = function () {\r\n return this._caps;\r\n };\r\n /**\r\n * stop executing a render loop function and remove it from the execution array\r\n * @param renderFunction defines the function to be removed. If not provided all functions will be removed.\r\n */\r\n ThinEngine.prototype.stopRenderLoop = function (renderFunction) {\r\n if (!renderFunction) {\r\n this._activeRenderLoops = [];\r\n return;\r\n }\r\n var index = this._activeRenderLoops.indexOf(renderFunction);\r\n if (index >= 0) {\r\n this._activeRenderLoops.splice(index, 1);\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._renderLoop = function () {\r\n if (!this._contextWasLost) {\r\n var shouldRender = true;\r\n if (!this.renderEvenInBackground && this._windowIsBackground) {\r\n shouldRender = false;\r\n }\r\n if (shouldRender) {\r\n // Start new frame\r\n this.beginFrame();\r\n for (var index = 0; index < this._activeRenderLoops.length; index++) {\r\n var renderFunction = this._activeRenderLoops[index];\r\n renderFunction();\r\n }\r\n // Present\r\n this.endFrame();\r\n }\r\n }\r\n if (this._activeRenderLoops.length > 0) {\r\n this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow());\r\n }\r\n else {\r\n this._renderingQueueLaunched = false;\r\n }\r\n };\r\n /**\r\n * Gets the HTML canvas attached with the current webGL context\r\n * @returns a HTML canvas\r\n */\r\n ThinEngine.prototype.getRenderingCanvas = function () {\r\n return this._renderingCanvas;\r\n };\r\n /**\r\n * Gets host window\r\n * @returns the host window object\r\n */\r\n ThinEngine.prototype.getHostWindow = function () {\r\n if (!DomManagement.IsWindowObjectExist()) {\r\n return null;\r\n }\r\n if (this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView) {\r\n return this._renderingCanvas.ownerDocument.defaultView;\r\n }\r\n return window;\r\n };\r\n /**\r\n * Gets the current render width\r\n * @param useScreen defines if screen size must be used (or the current render target if any)\r\n * @returns a number defining the current render width\r\n */\r\n ThinEngine.prototype.getRenderWidth = function (useScreen) {\r\n if (useScreen === void 0) { useScreen = false; }\r\n if (!useScreen && this._currentRenderTarget) {\r\n return this._currentRenderTarget.width;\r\n }\r\n return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth;\r\n };\r\n /**\r\n * Gets the current render height\r\n * @param useScreen defines if screen size must be used (or the current render target if any)\r\n * @returns a number defining the current render height\r\n */\r\n ThinEngine.prototype.getRenderHeight = function (useScreen) {\r\n if (useScreen === void 0) { useScreen = false; }\r\n if (!useScreen && this._currentRenderTarget) {\r\n return this._currentRenderTarget.height;\r\n }\r\n return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight;\r\n };\r\n /**\r\n * Can be used to override the current requestAnimationFrame requester.\r\n * @hidden\r\n */\r\n ThinEngine.prototype._queueNewFrame = function (bindedRenderFunction, requester) {\r\n return ThinEngine.QueueNewFrame(bindedRenderFunction, requester);\r\n };\r\n /**\r\n * Register and execute a render loop. The engine can have more than one render function\r\n * @param renderFunction defines the function to continuously execute\r\n */\r\n ThinEngine.prototype.runRenderLoop = function (renderFunction) {\r\n if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {\r\n return;\r\n }\r\n this._activeRenderLoops.push(renderFunction);\r\n if (!this._renderingQueueLaunched) {\r\n this._renderingQueueLaunched = true;\r\n this._boundRenderFunction = this._renderLoop.bind(this);\r\n this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow());\r\n }\r\n };\r\n /**\r\n * Clear the current render buffer or the current render target (if any is set up)\r\n * @param color defines the color to use\r\n * @param backBuffer defines if the back buffer must be cleared\r\n * @param depth defines if the depth buffer must be cleared\r\n * @param stencil defines if the stencil buffer must be cleared\r\n */\r\n ThinEngine.prototype.clear = function (color, backBuffer, depth, stencil) {\r\n if (stencil === void 0) { stencil = false; }\r\n this.applyStates();\r\n var mode = 0;\r\n if (backBuffer && color) {\r\n this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);\r\n mode |= this._gl.COLOR_BUFFER_BIT;\r\n }\r\n if (depth) {\r\n if (this.useReverseDepthBuffer) {\r\n this._depthCullingState.depthFunc = this._gl.GREATER;\r\n this._gl.clearDepth(0.0);\r\n }\r\n else {\r\n this._gl.clearDepth(1.0);\r\n }\r\n mode |= this._gl.DEPTH_BUFFER_BIT;\r\n }\r\n if (stencil) {\r\n this._gl.clearStencil(0);\r\n mode |= this._gl.STENCIL_BUFFER_BIT;\r\n }\r\n this._gl.clear(mode);\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._viewport = function (x, y, width, height) {\r\n if (x !== this._viewportCached.x ||\r\n y !== this._viewportCached.y ||\r\n width !== this._viewportCached.z ||\r\n height !== this._viewportCached.w) {\r\n this._viewportCached.x = x;\r\n this._viewportCached.y = y;\r\n this._viewportCached.z = width;\r\n this._viewportCached.w = height;\r\n this._gl.viewport(x, y, width, height);\r\n }\r\n };\r\n /**\r\n * Set the WebGL's viewport\r\n * @param viewport defines the viewport element to be used\r\n * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used\r\n * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used\r\n */\r\n ThinEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {\r\n var width = requiredWidth || this.getRenderWidth();\r\n var height = requiredHeight || this.getRenderHeight();\r\n var x = viewport.x || 0;\r\n var y = viewport.y || 0;\r\n this._cachedViewport = viewport;\r\n this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);\r\n };\r\n /**\r\n * Begin a new frame\r\n */\r\n ThinEngine.prototype.beginFrame = function () {\r\n };\r\n /**\r\n * Enf the current frame\r\n */\r\n ThinEngine.prototype.endFrame = function () {\r\n // Force a flush in case we are using a bad OS.\r\n if (this._badOS) {\r\n this.flushFramebuffer();\r\n }\r\n };\r\n /**\r\n * Resize the view according to the canvas' size\r\n */\r\n ThinEngine.prototype.resize = function () {\r\n var width;\r\n var height;\r\n if (DomManagement.IsWindowObjectExist()) {\r\n width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;\r\n height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;\r\n }\r\n else {\r\n width = this._renderingCanvas ? this._renderingCanvas.width : 100;\r\n height = this._renderingCanvas ? this._renderingCanvas.height : 100;\r\n }\r\n this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);\r\n };\r\n /**\r\n * Force a specific size of the canvas\r\n * @param width defines the new canvas' width\r\n * @param height defines the new canvas' height\r\n */\r\n ThinEngine.prototype.setSize = function (width, height) {\r\n if (!this._renderingCanvas) {\r\n return;\r\n }\r\n width = width | 0;\r\n height = height | 0;\r\n if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {\r\n return;\r\n }\r\n this._renderingCanvas.width = width;\r\n this._renderingCanvas.height = height;\r\n };\r\n /**\r\n * Binds the frame buffer to the specified texture.\r\n * @param texture The texture to render to or null for the default canvas\r\n * @param faceIndex The face of the texture to render to in case of cube texture\r\n * @param requiredWidth The width of the target to render to\r\n * @param requiredHeight The height of the target to render to\r\n * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true\r\n * @param lodLevel defines the lod level to bind to the frame buffer\r\n * @param layer defines the 2d array index to bind to frame buffer to\r\n */\r\n ThinEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, lodLevel, layer) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lodLevel === void 0) { lodLevel = 0; }\r\n if (layer === void 0) { layer = 0; }\r\n if (this._currentRenderTarget) {\r\n this.unBindFramebuffer(this._currentRenderTarget);\r\n }\r\n this._currentRenderTarget = texture;\r\n this._bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);\r\n var gl = this._gl;\r\n if (texture.is2DArray) {\r\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, texture._webGLTexture, lodLevel, layer);\r\n }\r\n else if (texture.isCube) {\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);\r\n }\r\n var depthStencilTexture = texture._depthStencilTexture;\r\n if (depthStencilTexture) {\r\n var attachment = (depthStencilTexture._generateStencilBuffer) ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;\r\n if (texture.is2DArray) {\r\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, depthStencilTexture._webGLTexture, lodLevel, layer);\r\n }\r\n else if (texture.isCube) {\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);\r\n }\r\n else {\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, lodLevel);\r\n }\r\n }\r\n if (this._cachedViewport && !forceFullscreenViewport) {\r\n this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);\r\n }\r\n else {\r\n if (!requiredWidth) {\r\n requiredWidth = texture.width;\r\n if (lodLevel) {\r\n requiredWidth = requiredWidth / Math.pow(2, lodLevel);\r\n }\r\n }\r\n if (!requiredHeight) {\r\n requiredHeight = texture.height;\r\n if (lodLevel) {\r\n requiredHeight = requiredHeight / Math.pow(2, lodLevel);\r\n }\r\n }\r\n this._viewport(0, 0, requiredWidth, requiredHeight);\r\n }\r\n this.wipeCaches();\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._bindUnboundFramebuffer = function (framebuffer) {\r\n if (this._currentFramebuffer !== framebuffer) {\r\n this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);\r\n this._currentFramebuffer = framebuffer;\r\n }\r\n };\r\n /**\r\n * Unbind the current render target texture from the webGL context\r\n * @param texture defines the render target texture to unbind\r\n * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated\r\n * @param onBeforeUnbind defines a function which will be called before the effective unbind\r\n */\r\n ThinEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {\r\n if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }\r\n this._currentRenderTarget = null;\r\n // If MSAA, we need to bitblt back to main texture\r\n var gl = this._gl;\r\n if (texture._MSAAFramebuffer) {\r\n gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);\r\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);\r\n gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);\r\n }\r\n if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {\r\n this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);\r\n gl.generateMipmap(gl.TEXTURE_2D);\r\n this._bindTextureDirectly(gl.TEXTURE_2D, null);\r\n }\r\n if (onBeforeUnbind) {\r\n if (texture._MSAAFramebuffer) {\r\n // Bind the correct framebuffer\r\n this._bindUnboundFramebuffer(texture._framebuffer);\r\n }\r\n onBeforeUnbind();\r\n }\r\n this._bindUnboundFramebuffer(null);\r\n };\r\n /**\r\n * Force a webGL flush (ie. a flush of all waiting webGL commands)\r\n */\r\n ThinEngine.prototype.flushFramebuffer = function () {\r\n this._gl.flush();\r\n };\r\n /**\r\n * Unbind the current render target and bind the default framebuffer\r\n */\r\n ThinEngine.prototype.restoreDefaultFramebuffer = function () {\r\n if (this._currentRenderTarget) {\r\n this.unBindFramebuffer(this._currentRenderTarget);\r\n }\r\n else {\r\n this._bindUnboundFramebuffer(null);\r\n }\r\n if (this._cachedViewport) {\r\n this.setViewport(this._cachedViewport);\r\n }\r\n this.wipeCaches();\r\n };\r\n // VBOs\r\n /** @hidden */\r\n ThinEngine.prototype._resetVertexBufferBinding = function () {\r\n this.bindArrayBuffer(null);\r\n this._cachedVertexBuffers = null;\r\n };\r\n /**\r\n * Creates a vertex buffer\r\n * @param data the data for the vertex buffer\r\n * @returns the new WebGL static buffer\r\n */\r\n ThinEngine.prototype.createVertexBuffer = function (data) {\r\n return this._createVertexBuffer(data, this._gl.STATIC_DRAW);\r\n };\r\n ThinEngine.prototype._createVertexBuffer = function (data, usage) {\r\n var vbo = this._gl.createBuffer();\r\n if (!vbo) {\r\n throw new Error(\"Unable to create vertex buffer\");\r\n }\r\n var dataBuffer = new WebGLDataBuffer(vbo);\r\n this.bindArrayBuffer(dataBuffer);\r\n if (data instanceof Array) {\r\n this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);\r\n }\r\n else {\r\n this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);\r\n }\r\n this._resetVertexBufferBinding();\r\n dataBuffer.references = 1;\r\n return dataBuffer;\r\n };\r\n /**\r\n * Creates a dynamic vertex buffer\r\n * @param data the data for the dynamic vertex buffer\r\n * @returns the new WebGL dynamic buffer\r\n */\r\n ThinEngine.prototype.createDynamicVertexBuffer = function (data) {\r\n return this._createVertexBuffer(data, this._gl.DYNAMIC_DRAW);\r\n };\r\n ThinEngine.prototype._resetIndexBufferBinding = function () {\r\n this.bindIndexBuffer(null);\r\n this._cachedIndexBuffer = null;\r\n };\r\n /**\r\n * Creates a new index buffer\r\n * @param indices defines the content of the index buffer\r\n * @param updatable defines if the index buffer must be updatable\r\n * @returns a new webGL buffer\r\n */\r\n ThinEngine.prototype.createIndexBuffer = function (indices, updatable) {\r\n var vbo = this._gl.createBuffer();\r\n var dataBuffer = new WebGLDataBuffer(vbo);\r\n if (!vbo) {\r\n throw new Error(\"Unable to create index buffer\");\r\n }\r\n this.bindIndexBuffer(dataBuffer);\r\n var data = this._normalizeIndexData(indices);\r\n this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, data, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);\r\n this._resetIndexBufferBinding();\r\n dataBuffer.references = 1;\r\n dataBuffer.is32Bits = (data.BYTES_PER_ELEMENT === 4);\r\n return dataBuffer;\r\n };\r\n ThinEngine.prototype._normalizeIndexData = function (indices) {\r\n if (indices instanceof Uint16Array) {\r\n return indices;\r\n }\r\n // Check 32 bit support\r\n if (this._caps.uintIndices) {\r\n if (indices instanceof Uint32Array) {\r\n return indices;\r\n }\r\n else {\r\n // number[] or Int32Array, check if 32 bit is necessary\r\n for (var index = 0; index < indices.length; index++) {\r\n if (indices[index] >= 65535) {\r\n return new Uint32Array(indices);\r\n }\r\n }\r\n return new Uint16Array(indices);\r\n }\r\n }\r\n // No 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)\r\n return new Uint16Array(indices);\r\n };\r\n /**\r\n * Bind a webGL buffer to the webGL context\r\n * @param buffer defines the buffer to bind\r\n */\r\n ThinEngine.prototype.bindArrayBuffer = function (buffer) {\r\n if (!this._vaoRecordInProgress) {\r\n this._unbindVertexArrayObject();\r\n }\r\n this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);\r\n };\r\n /**\r\n * Bind a specific block at a given index in a specific shader program\r\n * @param pipelineContext defines the pipeline context to use\r\n * @param blockName defines the block name\r\n * @param index defines the index where to bind the block\r\n */\r\n ThinEngine.prototype.bindUniformBlock = function (pipelineContext, blockName, index) {\r\n var program = pipelineContext.program;\r\n var uniformLocation = this._gl.getUniformBlockIndex(program, blockName);\r\n this._gl.uniformBlockBinding(program, uniformLocation, index);\r\n };\r\n ThinEngine.prototype.bindIndexBuffer = function (buffer) {\r\n if (!this._vaoRecordInProgress) {\r\n this._unbindVertexArrayObject();\r\n }\r\n this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);\r\n };\r\n ThinEngine.prototype.bindBuffer = function (buffer, target) {\r\n if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {\r\n this._gl.bindBuffer(target, buffer ? buffer.underlyingResource : null);\r\n this._currentBoundBuffer[target] = buffer;\r\n }\r\n };\r\n /**\r\n * update the bound buffer with the given data\r\n * @param data defines the data to update\r\n */\r\n ThinEngine.prototype.updateArrayBuffer = function (data) {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);\r\n };\r\n ThinEngine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {\r\n var pointer = this._currentBufferPointers[indx];\r\n var changed = false;\r\n if (!pointer.active) {\r\n changed = true;\r\n pointer.active = true;\r\n pointer.index = indx;\r\n pointer.size = size;\r\n pointer.type = type;\r\n pointer.normalized = normalized;\r\n pointer.stride = stride;\r\n pointer.offset = offset;\r\n pointer.buffer = buffer;\r\n }\r\n else {\r\n if (pointer.buffer !== buffer) {\r\n pointer.buffer = buffer;\r\n changed = true;\r\n }\r\n if (pointer.size !== size) {\r\n pointer.size = size;\r\n changed = true;\r\n }\r\n if (pointer.type !== type) {\r\n pointer.type = type;\r\n changed = true;\r\n }\r\n if (pointer.normalized !== normalized) {\r\n pointer.normalized = normalized;\r\n changed = true;\r\n }\r\n if (pointer.stride !== stride) {\r\n pointer.stride = stride;\r\n changed = true;\r\n }\r\n if (pointer.offset !== offset) {\r\n pointer.offset = offset;\r\n changed = true;\r\n }\r\n }\r\n if (changed || this._vaoRecordInProgress) {\r\n this.bindArrayBuffer(buffer);\r\n this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._bindIndexBufferWithCache = function (indexBuffer) {\r\n if (indexBuffer == null) {\r\n return;\r\n }\r\n if (this._cachedIndexBuffer !== indexBuffer) {\r\n this._cachedIndexBuffer = indexBuffer;\r\n this.bindIndexBuffer(indexBuffer);\r\n this._uintIndicesCurrentlySet = indexBuffer.is32Bits;\r\n }\r\n };\r\n ThinEngine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {\r\n var attributes = effect.getAttributesNames();\r\n if (!this._vaoRecordInProgress) {\r\n this._unbindVertexArrayObject();\r\n }\r\n this.unbindAllAttributes();\r\n for (var index = 0; index < attributes.length; index++) {\r\n var order = effect.getAttributeLocation(index);\r\n if (order >= 0) {\r\n var vertexBuffer = vertexBuffers[attributes[index]];\r\n if (!vertexBuffer) {\r\n continue;\r\n }\r\n this._gl.enableVertexAttribArray(order);\r\n if (!this._vaoRecordInProgress) {\r\n this._vertexAttribArraysEnabled[order] = true;\r\n }\r\n var buffer = vertexBuffer.getBuffer();\r\n if (buffer) {\r\n this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);\r\n if (vertexBuffer.getIsInstanced()) {\r\n this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());\r\n if (!this._vaoRecordInProgress) {\r\n this._currentInstanceLocations.push(order);\r\n this._currentInstanceBuffers.push(buffer);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n };\r\n /**\r\n * Records a vertex array object\r\n * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects\r\n * @param vertexBuffers defines the list of vertex buffers to store\r\n * @param indexBuffer defines the index buffer to store\r\n * @param effect defines the effect to store\r\n * @returns the new vertex array object\r\n */\r\n ThinEngine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {\r\n var vao = this._gl.createVertexArray();\r\n this._vaoRecordInProgress = true;\r\n this._gl.bindVertexArray(vao);\r\n this._mustWipeVertexAttributes = true;\r\n this._bindVertexBuffersAttributes(vertexBuffers, effect);\r\n this.bindIndexBuffer(indexBuffer);\r\n this._vaoRecordInProgress = false;\r\n this._gl.bindVertexArray(null);\r\n return vao;\r\n };\r\n /**\r\n * Bind a specific vertex array object\r\n * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects\r\n * @param vertexArrayObject defines the vertex array object to bind\r\n * @param indexBuffer defines the index buffer to bind\r\n */\r\n ThinEngine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {\r\n if (this._cachedVertexArrayObject !== vertexArrayObject) {\r\n this._cachedVertexArrayObject = vertexArrayObject;\r\n this._gl.bindVertexArray(vertexArrayObject);\r\n this._cachedVertexBuffers = null;\r\n this._cachedIndexBuffer = null;\r\n this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;\r\n this._mustWipeVertexAttributes = true;\r\n }\r\n };\r\n /**\r\n * Bind webGl buffers directly to the webGL context\r\n * @param vertexBuffer defines the vertex buffer to bind\r\n * @param indexBuffer defines the index buffer to bind\r\n * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer\r\n * @param vertexStrideSize defines the vertex stride of the vertex buffer\r\n * @param effect defines the effect associated with the vertex buffer\r\n */\r\n ThinEngine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {\r\n if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {\r\n this._cachedVertexBuffers = vertexBuffer;\r\n this._cachedEffectForVertexBuffers = effect;\r\n var attributesCount = effect.getAttributesCount();\r\n this._unbindVertexArrayObject();\r\n this.unbindAllAttributes();\r\n var offset = 0;\r\n for (var index = 0; index < attributesCount; index++) {\r\n if (index < vertexDeclaration.length) {\r\n var order = effect.getAttributeLocation(index);\r\n if (order >= 0) {\r\n this._gl.enableVertexAttribArray(order);\r\n this._vertexAttribArraysEnabled[order] = true;\r\n this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);\r\n }\r\n offset += vertexDeclaration[index] * 4;\r\n }\r\n }\r\n }\r\n this._bindIndexBufferWithCache(indexBuffer);\r\n };\r\n ThinEngine.prototype._unbindVertexArrayObject = function () {\r\n if (!this._cachedVertexArrayObject) {\r\n return;\r\n }\r\n this._cachedVertexArrayObject = null;\r\n this._gl.bindVertexArray(null);\r\n };\r\n /**\r\n * Bind a list of vertex buffers to the webGL context\r\n * @param vertexBuffers defines the list of vertex buffers to bind\r\n * @param indexBuffer defines the index buffer to bind\r\n * @param effect defines the effect associated with the vertex buffers\r\n */\r\n ThinEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {\r\n if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {\r\n this._cachedVertexBuffers = vertexBuffers;\r\n this._cachedEffectForVertexBuffers = effect;\r\n this._bindVertexBuffersAttributes(vertexBuffers, effect);\r\n }\r\n this._bindIndexBufferWithCache(indexBuffer);\r\n };\r\n /**\r\n * Unbind all instance attributes\r\n */\r\n ThinEngine.prototype.unbindInstanceAttributes = function () {\r\n var boundBuffer;\r\n for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {\r\n var instancesBuffer = this._currentInstanceBuffers[i];\r\n if (boundBuffer != instancesBuffer && instancesBuffer.references) {\r\n boundBuffer = instancesBuffer;\r\n this.bindArrayBuffer(instancesBuffer);\r\n }\r\n var offsetLocation = this._currentInstanceLocations[i];\r\n this._gl.vertexAttribDivisor(offsetLocation, 0);\r\n }\r\n this._currentInstanceBuffers.length = 0;\r\n this._currentInstanceLocations.length = 0;\r\n };\r\n /**\r\n * Release and free the memory of a vertex array object\r\n * @param vao defines the vertex array object to delete\r\n */\r\n ThinEngine.prototype.releaseVertexArrayObject = function (vao) {\r\n this._gl.deleteVertexArray(vao);\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._releaseBuffer = function (buffer) {\r\n buffer.references--;\r\n if (buffer.references === 0) {\r\n this._deleteBuffer(buffer);\r\n return true;\r\n }\r\n return false;\r\n };\r\n ThinEngine.prototype._deleteBuffer = function (buffer) {\r\n this._gl.deleteBuffer(buffer.underlyingResource);\r\n };\r\n /**\r\n * Update the content of a webGL buffer used with instanciation and bind it to the webGL context\r\n * @param instancesBuffer defines the webGL buffer to update and bind\r\n * @param data defines the data to store in the buffer\r\n * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer\r\n */\r\n ThinEngine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {\r\n this.bindArrayBuffer(instancesBuffer);\r\n if (data) {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);\r\n }\r\n if (offsetLocations[0].index !== undefined) {\r\n this.bindInstancesBuffer(instancesBuffer, offsetLocations, true);\r\n }\r\n else {\r\n for (var index = 0; index < 4; index++) {\r\n var offsetLocation = offsetLocations[index];\r\n if (!this._vertexAttribArraysEnabled[offsetLocation]) {\r\n this._gl.enableVertexAttribArray(offsetLocation);\r\n this._vertexAttribArraysEnabled[offsetLocation] = true;\r\n }\r\n this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);\r\n this._gl.vertexAttribDivisor(offsetLocation, 1);\r\n this._currentInstanceLocations.push(offsetLocation);\r\n this._currentInstanceBuffers.push(instancesBuffer);\r\n }\r\n }\r\n };\r\n /**\r\n * Bind the content of a webGL buffer used with instantiation\r\n * @param instancesBuffer defines the webGL buffer to bind\r\n * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer\r\n * @param computeStride defines Whether to compute the strides from the info or use the default 0\r\n */\r\n ThinEngine.prototype.bindInstancesBuffer = function (instancesBuffer, attributesInfo, computeStride) {\r\n if (computeStride === void 0) { computeStride = true; }\r\n this.bindArrayBuffer(instancesBuffer);\r\n var stride = 0;\r\n if (computeStride) {\r\n for (var i = 0; i < attributesInfo.length; i++) {\r\n var ai = attributesInfo[i];\r\n stride += ai.attributeSize * 4;\r\n }\r\n }\r\n for (var i = 0; i < attributesInfo.length; i++) {\r\n var ai = attributesInfo[i];\r\n if (ai.index === undefined) {\r\n ai.index = this._currentEffect.getAttributeLocationByName(ai.attributeName);\r\n }\r\n if (!this._vertexAttribArraysEnabled[ai.index]) {\r\n this._gl.enableVertexAttribArray(ai.index);\r\n this._vertexAttribArraysEnabled[ai.index] = true;\r\n }\r\n this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attributeType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);\r\n this._gl.vertexAttribDivisor(ai.index, ai.divisor === undefined ? 1 : ai.divisor);\r\n this._currentInstanceLocations.push(ai.index);\r\n this._currentInstanceBuffers.push(instancesBuffer);\r\n }\r\n };\r\n /**\r\n * Disable the instance attribute corresponding to the name in parameter\r\n * @param name defines the name of the attribute to disable\r\n */\r\n ThinEngine.prototype.disableInstanceAttributeByName = function (name) {\r\n if (!this._currentEffect) {\r\n return;\r\n }\r\n var attributeLocation = this._currentEffect.getAttributeLocationByName(name);\r\n this.disableInstanceAttribute(attributeLocation);\r\n };\r\n /**\r\n * Disable the instance attribute corresponding to the location in parameter\r\n * @param attributeLocation defines the attribute location of the attribute to disable\r\n */\r\n ThinEngine.prototype.disableInstanceAttribute = function (attributeLocation) {\r\n var shouldClean = false;\r\n var index;\r\n while ((index = this._currentInstanceLocations.indexOf(attributeLocation)) !== -1) {\r\n this._currentInstanceLocations.splice(index, 1);\r\n this._currentInstanceBuffers.splice(index, 1);\r\n shouldClean = true;\r\n index = this._currentInstanceLocations.indexOf(attributeLocation);\r\n }\r\n if (shouldClean) {\r\n this._gl.vertexAttribDivisor(attributeLocation, 0);\r\n this.disableAttributeByIndex(attributeLocation);\r\n }\r\n };\r\n /**\r\n * Disable the attribute corresponding to the location in parameter\r\n * @param attributeLocation defines the attribute location of the attribute to disable\r\n */\r\n ThinEngine.prototype.disableAttributeByIndex = function (attributeLocation) {\r\n this._gl.disableVertexAttribArray(attributeLocation);\r\n this._vertexAttribArraysEnabled[attributeLocation] = false;\r\n this._currentBufferPointers[attributeLocation].active = false;\r\n };\r\n /**\r\n * Send a draw order\r\n * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)\r\n * @param indexStart defines the starting index\r\n * @param indexCount defines the number of index to draw\r\n * @param instancesCount defines the number of instances to draw (if instanciation is enabled)\r\n */\r\n ThinEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {\r\n this.drawElementsType(useTriangles ? 0 : 1, indexStart, indexCount, instancesCount);\r\n };\r\n /**\r\n * Draw a list of points\r\n * @param verticesStart defines the index of first vertex to draw\r\n * @param verticesCount defines the count of vertices to draw\r\n * @param instancesCount defines the number of instances to draw (if instanciation is enabled)\r\n */\r\n ThinEngine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {\r\n this.drawArraysType(2, verticesStart, verticesCount, instancesCount);\r\n };\r\n /**\r\n * Draw a list of unindexed primitives\r\n * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)\r\n * @param verticesStart defines the index of first vertex to draw\r\n * @param verticesCount defines the count of vertices to draw\r\n * @param instancesCount defines the number of instances to draw (if instanciation is enabled)\r\n */\r\n ThinEngine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {\r\n this.drawArraysType(useTriangles ? 0 : 1, verticesStart, verticesCount, instancesCount);\r\n };\r\n /**\r\n * Draw a list of indexed primitives\r\n * @param fillMode defines the primitive to use\r\n * @param indexStart defines the starting index\r\n * @param indexCount defines the number of index to draw\r\n * @param instancesCount defines the number of instances to draw (if instanciation is enabled)\r\n */\r\n ThinEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {\r\n // Apply states\r\n this.applyStates();\r\n this._reportDrawCall();\r\n // Render\r\n var drawMode = this._drawMode(fillMode);\r\n var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;\r\n var mult = this._uintIndicesCurrentlySet ? 4 : 2;\r\n if (instancesCount) {\r\n this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);\r\n }\r\n else {\r\n this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);\r\n }\r\n };\r\n /**\r\n * Draw a list of unindexed primitives\r\n * @param fillMode defines the primitive to use\r\n * @param verticesStart defines the index of first vertex to draw\r\n * @param verticesCount defines the count of vertices to draw\r\n * @param instancesCount defines the number of instances to draw (if instanciation is enabled)\r\n */\r\n ThinEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {\r\n // Apply states\r\n this.applyStates();\r\n this._reportDrawCall();\r\n var drawMode = this._drawMode(fillMode);\r\n if (instancesCount) {\r\n this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);\r\n }\r\n else {\r\n this._gl.drawArrays(drawMode, verticesStart, verticesCount);\r\n }\r\n };\r\n ThinEngine.prototype._drawMode = function (fillMode) {\r\n switch (fillMode) {\r\n // Triangle views\r\n case 0:\r\n return this._gl.TRIANGLES;\r\n case 2:\r\n return this._gl.POINTS;\r\n case 1:\r\n return this._gl.LINES;\r\n // Draw modes\r\n case 3:\r\n return this._gl.POINTS;\r\n case 4:\r\n return this._gl.LINES;\r\n case 5:\r\n return this._gl.LINE_LOOP;\r\n case 6:\r\n return this._gl.LINE_STRIP;\r\n case 7:\r\n return this._gl.TRIANGLE_STRIP;\r\n case 8:\r\n return this._gl.TRIANGLE_FAN;\r\n default:\r\n return this._gl.TRIANGLES;\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._reportDrawCall = function () {\r\n // Will be implemented by children\r\n };\r\n // Shaders\r\n /** @hidden */\r\n ThinEngine.prototype._releaseEffect = function (effect) {\r\n if (this._compiledEffects[effect._key]) {\r\n delete this._compiledEffects[effect._key];\r\n this._deletePipelineContext(effect.getPipelineContext());\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._deletePipelineContext = function (pipelineContext) {\r\n var webGLPipelineContext = pipelineContext;\r\n if (webGLPipelineContext && webGLPipelineContext.program) {\r\n webGLPipelineContext.program.__SPECTOR_rebuildProgram = null;\r\n this._gl.deleteProgram(webGLPipelineContext.program);\r\n }\r\n };\r\n /**\r\n * Create a new effect (used to store vertex/fragment shaders)\r\n * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)\r\n * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object\r\n * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use\r\n * @param samplers defines an array of string used to represent textures\r\n * @param defines defines the string containing the defines to use to compile the shaders\r\n * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails\r\n * @param onCompiled defines a function to call when the effect creation is successful\r\n * @param onError defines a function to call when the effect creation has failed\r\n * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)\r\n * @returns the new Effect\r\n */\r\n ThinEngine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {\r\n var vertex = baseName.vertexElement || baseName.vertex || baseName;\r\n var fragment = baseName.fragmentElement || baseName.fragment || baseName;\r\n var name = vertex + \"+\" + fragment + \"@\" + (defines ? defines : attributesNamesOrOptions.defines);\r\n if (this._compiledEffects[name]) {\r\n var compiledEffect = this._compiledEffects[name];\r\n if (onCompiled && compiledEffect.isReady()) {\r\n onCompiled(compiledEffect);\r\n }\r\n return compiledEffect;\r\n }\r\n var effect = new Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);\r\n effect._key = name;\r\n this._compiledEffects[name] = effect;\r\n return effect;\r\n };\r\n ThinEngine._ConcatenateShader = function (source, defines, shaderVersion) {\r\n if (shaderVersion === void 0) { shaderVersion = \"\"; }\r\n return shaderVersion + (defines ? defines + \"\\n\" : \"\") + source;\r\n };\r\n ThinEngine.prototype._compileShader = function (source, type, defines, shaderVersion) {\r\n return this._compileRawShader(ThinEngine._ConcatenateShader(source, defines, shaderVersion), type);\r\n };\r\n ThinEngine.prototype._compileRawShader = function (source, type) {\r\n var gl = this._gl;\r\n var shader = gl.createShader(type === \"vertex\" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);\r\n if (!shader) {\r\n throw new Error(\"Something went wrong while compile the shader.\");\r\n }\r\n gl.shaderSource(shader, source);\r\n gl.compileShader(shader);\r\n return shader;\r\n };\r\n /**\r\n * Directly creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @returns the new webGL program\r\n */\r\n ThinEngine.prototype.createRawShaderProgram = function (pipelineContext, vertexCode, fragmentCode, context, transformFeedbackVaryings) {\r\n if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }\r\n context = context || this._gl;\r\n var vertexShader = this._compileRawShader(vertexCode, \"vertex\");\r\n var fragmentShader = this._compileRawShader(fragmentCode, \"fragment\");\r\n return this._createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);\r\n };\r\n /**\r\n * Creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param defines defines the string containing the defines to use to compile the shaders\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @returns the new webGL program\r\n */\r\n ThinEngine.prototype.createShaderProgram = function (pipelineContext, vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {\r\n if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }\r\n context = context || this._gl;\r\n var shaderVersion = (this._webGLVersion > 1) ? \"#version 300 es\\n#define WEBGL2 \\n\" : \"\";\r\n var vertexShader = this._compileShader(vertexCode, \"vertex\", defines, shaderVersion);\r\n var fragmentShader = this._compileShader(fragmentCode, \"fragment\", defines, shaderVersion);\r\n return this._createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);\r\n };\r\n /**\r\n * Creates a new pipeline context\r\n * @returns the new pipeline\r\n */\r\n ThinEngine.prototype.createPipelineContext = function () {\r\n var pipelineContext = new WebGLPipelineContext();\r\n pipelineContext.engine = this;\r\n if (this._caps.parallelShaderCompile) {\r\n pipelineContext.isParallelCompiled = true;\r\n }\r\n return pipelineContext;\r\n };\r\n ThinEngine.prototype._createShaderProgram = function (pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings) {\r\n if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }\r\n var shaderProgram = context.createProgram();\r\n pipelineContext.program = shaderProgram;\r\n if (!shaderProgram) {\r\n throw new Error(\"Unable to create program\");\r\n }\r\n context.attachShader(shaderProgram, vertexShader);\r\n context.attachShader(shaderProgram, fragmentShader);\r\n context.linkProgram(shaderProgram);\r\n pipelineContext.context = context;\r\n pipelineContext.vertexShader = vertexShader;\r\n pipelineContext.fragmentShader = fragmentShader;\r\n if (!pipelineContext.isParallelCompiled) {\r\n this._finalizePipelineContext(pipelineContext);\r\n }\r\n return shaderProgram;\r\n };\r\n ThinEngine.prototype._finalizePipelineContext = function (pipelineContext) {\r\n var context = pipelineContext.context;\r\n var vertexShader = pipelineContext.vertexShader;\r\n var fragmentShader = pipelineContext.fragmentShader;\r\n var program = pipelineContext.program;\r\n var linked = context.getProgramParameter(program, context.LINK_STATUS);\r\n if (!linked) { // Get more info\r\n // Vertex\r\n if (!this._gl.getShaderParameter(vertexShader, this._gl.COMPILE_STATUS)) {\r\n var log = this._gl.getShaderInfoLog(vertexShader);\r\n if (log) {\r\n pipelineContext.vertexCompilationError = log;\r\n throw new Error(\"VERTEX SHADER \" + log);\r\n }\r\n }\r\n // Fragment\r\n if (!this._gl.getShaderParameter(fragmentShader, this._gl.COMPILE_STATUS)) {\r\n var log = this._gl.getShaderInfoLog(fragmentShader);\r\n if (log) {\r\n pipelineContext.fragmentCompilationError = log;\r\n throw new Error(\"FRAGMENT SHADER \" + log);\r\n }\r\n }\r\n var error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programLinkError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n if (this.validateShaderPrograms) {\r\n context.validateProgram(program);\r\n var validated = context.getProgramParameter(program, context.VALIDATE_STATUS);\r\n if (!validated) {\r\n var error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programValidationError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n }\r\n context.deleteShader(vertexShader);\r\n context.deleteShader(fragmentShader);\r\n pipelineContext.vertexShader = undefined;\r\n pipelineContext.fragmentShader = undefined;\r\n if (pipelineContext.onCompiled) {\r\n pipelineContext.onCompiled();\r\n pipelineContext.onCompiled = undefined;\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._preparePipelineContext = function (pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rebuildRebind, defines, transformFeedbackVaryings) {\r\n var webGLRenderingState = pipelineContext;\r\n if (createAsRaw) {\r\n webGLRenderingState.program = this.createRawShaderProgram(webGLRenderingState, vertexSourceCode, fragmentSourceCode, undefined, transformFeedbackVaryings);\r\n }\r\n else {\r\n webGLRenderingState.program = this.createShaderProgram(webGLRenderingState, vertexSourceCode, fragmentSourceCode, defines, undefined, transformFeedbackVaryings);\r\n }\r\n webGLRenderingState.program.__SPECTOR_rebuildProgram = rebuildRebind;\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._isRenderingStateCompiled = function (pipelineContext) {\r\n var webGLPipelineContext = pipelineContext;\r\n if (this._gl.getProgramParameter(webGLPipelineContext.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {\r\n this._finalizePipelineContext(webGLPipelineContext);\r\n return true;\r\n }\r\n return false;\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._executeWhenRenderingStateIsCompiled = function (pipelineContext, action) {\r\n var webGLPipelineContext = pipelineContext;\r\n if (!webGLPipelineContext.isParallelCompiled) {\r\n action();\r\n return;\r\n }\r\n var oldHandler = webGLPipelineContext.onCompiled;\r\n if (oldHandler) {\r\n webGLPipelineContext.onCompiled = function () {\r\n oldHandler();\r\n action();\r\n };\r\n }\r\n else {\r\n webGLPipelineContext.onCompiled = action;\r\n }\r\n };\r\n /**\r\n * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names\r\n * @param pipelineContext defines the pipeline context to use\r\n * @param uniformsNames defines the list of uniform names\r\n * @returns an array of webGL uniform locations\r\n */\r\n ThinEngine.prototype.getUniforms = function (pipelineContext, uniformsNames) {\r\n var results = new Array();\r\n var webGLPipelineContext = pipelineContext;\r\n for (var index = 0; index < uniformsNames.length; index++) {\r\n results.push(this._gl.getUniformLocation(webGLPipelineContext.program, uniformsNames[index]));\r\n }\r\n return results;\r\n };\r\n /**\r\n * Gets the lsit of active attributes for a given webGL program\r\n * @param pipelineContext defines the pipeline context to use\r\n * @param attributesNames defines the list of attribute names to get\r\n * @returns an array of indices indicating the offset of each attribute\r\n */\r\n ThinEngine.prototype.getAttributes = function (pipelineContext, attributesNames) {\r\n var results = [];\r\n var webGLPipelineContext = pipelineContext;\r\n for (var index = 0; index < attributesNames.length; index++) {\r\n try {\r\n results.push(this._gl.getAttribLocation(webGLPipelineContext.program, attributesNames[index]));\r\n }\r\n catch (e) {\r\n results.push(-1);\r\n }\r\n }\r\n return results;\r\n };\r\n /**\r\n * Activates an effect, mkaing it the current one (ie. the one used for rendering)\r\n * @param effect defines the effect to activate\r\n */\r\n ThinEngine.prototype.enableEffect = function (effect) {\r\n if (!effect || effect === this._currentEffect) {\r\n return;\r\n }\r\n // Use program\r\n this.bindSamplers(effect);\r\n this._currentEffect = effect;\r\n if (effect.onBind) {\r\n effect.onBind(effect);\r\n }\r\n if (effect._onBindObservable) {\r\n effect._onBindObservable.notifyObservers(effect);\r\n }\r\n };\r\n /**\r\n * Set the value of an uniform to a number (int)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param value defines the int number to store\r\n */\r\n ThinEngine.prototype.setInt = function (uniform, value) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniform1i(uniform, value);\r\n };\r\n /**\r\n * Set the value of an uniform to an array of int32\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of int32 to store\r\n */\r\n ThinEngine.prototype.setIntArray = function (uniform, array) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniform1iv(uniform, array);\r\n };\r\n /**\r\n * Set the value of an uniform to an array of int32 (stored as vec2)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of int32 to store\r\n */\r\n ThinEngine.prototype.setIntArray2 = function (uniform, array) {\r\n if (!uniform || array.length % 2 !== 0) {\r\n return;\r\n }\r\n this._gl.uniform2iv(uniform, array);\r\n };\r\n /**\r\n * Set the value of an uniform to an array of int32 (stored as vec3)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of int32 to store\r\n */\r\n ThinEngine.prototype.setIntArray3 = function (uniform, array) {\r\n if (!uniform || array.length % 3 !== 0) {\r\n return;\r\n }\r\n this._gl.uniform3iv(uniform, array);\r\n };\r\n /**\r\n * Set the value of an uniform to an array of int32 (stored as vec4)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of int32 to store\r\n */\r\n ThinEngine.prototype.setIntArray4 = function (uniform, array) {\r\n if (!uniform || array.length % 4 !== 0) {\r\n return;\r\n }\r\n this._gl.uniform4iv(uniform, array);\r\n };\r\n /**\r\n * Set the value of an uniform to an array of number\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of number to store\r\n */\r\n ThinEngine.prototype.setArray = function (uniform, array) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniform1fv(uniform, array);\r\n };\r\n /**\r\n * Set the value of an uniform to an array of number (stored as vec2)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of number to store\r\n */\r\n ThinEngine.prototype.setArray2 = function (uniform, array) {\r\n if (!uniform || array.length % 2 !== 0) {\r\n return;\r\n }\r\n this._gl.uniform2fv(uniform, array);\r\n };\r\n /**\r\n * Set the value of an uniform to an array of number (stored as vec3)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of number to store\r\n */\r\n ThinEngine.prototype.setArray3 = function (uniform, array) {\r\n if (!uniform || array.length % 3 !== 0) {\r\n return;\r\n }\r\n this._gl.uniform3fv(uniform, array);\r\n };\r\n /**\r\n * Set the value of an uniform to an array of number (stored as vec4)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of number to store\r\n */\r\n ThinEngine.prototype.setArray4 = function (uniform, array) {\r\n if (!uniform || array.length % 4 !== 0) {\r\n return;\r\n }\r\n this._gl.uniform4fv(uniform, array);\r\n };\r\n /**\r\n * Set the value of an uniform to an array of float32 (stored as matrices)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param matrices defines the array of float32 to store\r\n */\r\n ThinEngine.prototype.setMatrices = function (uniform, matrices) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniformMatrix4fv(uniform, false, matrices);\r\n };\r\n /**\r\n * Set the value of an uniform to a matrix (3x3)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param matrix defines the Float32Array representing the 3x3 matrix to store\r\n */\r\n ThinEngine.prototype.setMatrix3x3 = function (uniform, matrix) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniformMatrix3fv(uniform, false, matrix);\r\n };\r\n /**\r\n * Set the value of an uniform to a matrix (2x2)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param matrix defines the Float32Array representing the 2x2 matrix to store\r\n */\r\n ThinEngine.prototype.setMatrix2x2 = function (uniform, matrix) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniformMatrix2fv(uniform, false, matrix);\r\n };\r\n /**\r\n * Set the value of an uniform to a number (float)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param value defines the float number to store\r\n */\r\n ThinEngine.prototype.setFloat = function (uniform, value) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniform1f(uniform, value);\r\n };\r\n /**\r\n * Set the value of an uniform to a vec2\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param x defines the 1st component of the value\r\n * @param y defines the 2nd component of the value\r\n */\r\n ThinEngine.prototype.setFloat2 = function (uniform, x, y) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniform2f(uniform, x, y);\r\n };\r\n /**\r\n * Set the value of an uniform to a vec3\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param x defines the 1st component of the value\r\n * @param y defines the 2nd component of the value\r\n * @param z defines the 3rd component of the value\r\n */\r\n ThinEngine.prototype.setFloat3 = function (uniform, x, y, z) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniform3f(uniform, x, y, z);\r\n };\r\n /**\r\n * Set the value of an uniform to a vec4\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param x defines the 1st component of the value\r\n * @param y defines the 2nd component of the value\r\n * @param z defines the 3rd component of the value\r\n * @param w defines the 4th component of the value\r\n */\r\n ThinEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {\r\n if (!uniform) {\r\n return;\r\n }\r\n this._gl.uniform4f(uniform, x, y, z, w);\r\n };\r\n // States\r\n /**\r\n * Apply all cached states (depth, culling, stencil and alpha)\r\n */\r\n ThinEngine.prototype.applyStates = function () {\r\n this._depthCullingState.apply(this._gl);\r\n this._stencilState.apply(this._gl);\r\n this._alphaState.apply(this._gl);\r\n if (this._colorWriteChanged) {\r\n this._colorWriteChanged = false;\r\n var enable = this._colorWrite;\r\n this._gl.colorMask(enable, enable, enable, enable);\r\n }\r\n };\r\n /**\r\n * Enable or disable color writing\r\n * @param enable defines the state to set\r\n */\r\n ThinEngine.prototype.setColorWrite = function (enable) {\r\n if (enable !== this._colorWrite) {\r\n this._colorWriteChanged = true;\r\n this._colorWrite = enable;\r\n }\r\n };\r\n /**\r\n * Gets a boolean indicating if color writing is enabled\r\n * @returns the current color writing state\r\n */\r\n ThinEngine.prototype.getColorWrite = function () {\r\n return this._colorWrite;\r\n };\r\n Object.defineProperty(ThinEngine.prototype, \"depthCullingState\", {\r\n /**\r\n * Gets the depth culling state manager\r\n */\r\n get: function () {\r\n return this._depthCullingState;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"alphaState\", {\r\n /**\r\n * Gets the alpha state manager\r\n */\r\n get: function () {\r\n return this._alphaState;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ThinEngine.prototype, \"stencilState\", {\r\n /**\r\n * Gets the stencil state manager\r\n */\r\n get: function () {\r\n return this._stencilState;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n // Textures\r\n /**\r\n * Clears the list of texture accessible through engine.\r\n * This can help preventing texture load conflict due to name collision.\r\n */\r\n ThinEngine.prototype.clearInternalTexturesCache = function () {\r\n this._internalTexturesCache = [];\r\n };\r\n /**\r\n * Force the entire cache to be cleared\r\n * You should not have to use this function unless your engine needs to share the webGL context with another engine\r\n * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)\r\n */\r\n ThinEngine.prototype.wipeCaches = function (bruteForce) {\r\n if (this.preventCacheWipeBetweenFrames && !bruteForce) {\r\n return;\r\n }\r\n this._currentEffect = null;\r\n this._viewportCached.x = 0;\r\n this._viewportCached.y = 0;\r\n this._viewportCached.z = 0;\r\n this._viewportCached.w = 0;\r\n // Done before in case we clean the attributes\r\n this._unbindVertexArrayObject();\r\n if (bruteForce) {\r\n this._currentProgram = null;\r\n this.resetTextureCache();\r\n this._stencilState.reset();\r\n this._depthCullingState.reset();\r\n this._depthCullingState.depthFunc = this._gl.LEQUAL;\r\n this._alphaState.reset();\r\n this._alphaMode = 1;\r\n this._alphaEquation = 0;\r\n this._colorWrite = true;\r\n this._colorWriteChanged = true;\r\n this._unpackFlipYCached = null;\r\n this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);\r\n this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);\r\n this._mustWipeVertexAttributes = true;\r\n this.unbindAllAttributes();\r\n }\r\n this._resetVertexBufferBinding();\r\n this._cachedIndexBuffer = null;\r\n this._cachedEffectForVertexBuffers = null;\r\n this.bindIndexBuffer(null);\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {\r\n var gl = this._gl;\r\n var magFilter = gl.NEAREST;\r\n var minFilter = gl.NEAREST;\r\n switch (samplingMode) {\r\n case 11:\r\n magFilter = gl.LINEAR;\r\n if (generateMipMaps) {\r\n minFilter = gl.LINEAR_MIPMAP_NEAREST;\r\n }\r\n else {\r\n minFilter = gl.LINEAR;\r\n }\r\n break;\r\n case 3:\r\n magFilter = gl.LINEAR;\r\n if (generateMipMaps) {\r\n minFilter = gl.LINEAR_MIPMAP_LINEAR;\r\n }\r\n else {\r\n minFilter = gl.LINEAR;\r\n }\r\n break;\r\n case 8:\r\n magFilter = gl.NEAREST;\r\n if (generateMipMaps) {\r\n minFilter = gl.NEAREST_MIPMAP_LINEAR;\r\n }\r\n else {\r\n minFilter = gl.NEAREST;\r\n }\r\n break;\r\n case 4:\r\n magFilter = gl.NEAREST;\r\n if (generateMipMaps) {\r\n minFilter = gl.NEAREST_MIPMAP_NEAREST;\r\n }\r\n else {\r\n minFilter = gl.NEAREST;\r\n }\r\n break;\r\n case 5:\r\n magFilter = gl.NEAREST;\r\n if (generateMipMaps) {\r\n minFilter = gl.LINEAR_MIPMAP_NEAREST;\r\n }\r\n else {\r\n minFilter = gl.LINEAR;\r\n }\r\n break;\r\n case 6:\r\n magFilter = gl.NEAREST;\r\n if (generateMipMaps) {\r\n minFilter = gl.LINEAR_MIPMAP_LINEAR;\r\n }\r\n else {\r\n minFilter = gl.LINEAR;\r\n }\r\n break;\r\n case 7:\r\n magFilter = gl.NEAREST;\r\n minFilter = gl.LINEAR;\r\n break;\r\n case 1:\r\n magFilter = gl.NEAREST;\r\n minFilter = gl.NEAREST;\r\n break;\r\n case 9:\r\n magFilter = gl.LINEAR;\r\n if (generateMipMaps) {\r\n minFilter = gl.NEAREST_MIPMAP_NEAREST;\r\n }\r\n else {\r\n minFilter = gl.NEAREST;\r\n }\r\n break;\r\n case 10:\r\n magFilter = gl.LINEAR;\r\n if (generateMipMaps) {\r\n minFilter = gl.NEAREST_MIPMAP_LINEAR;\r\n }\r\n else {\r\n minFilter = gl.NEAREST;\r\n }\r\n break;\r\n case 2:\r\n magFilter = gl.LINEAR;\r\n minFilter = gl.LINEAR;\r\n break;\r\n case 12:\r\n magFilter = gl.LINEAR;\r\n minFilter = gl.NEAREST;\r\n break;\r\n }\r\n return {\r\n min: minFilter,\r\n mag: magFilter\r\n };\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._createTexture = function () {\r\n var texture = this._gl.createTexture();\r\n if (!texture) {\r\n throw new Error(\"Unable to create texture\");\r\n }\r\n return texture;\r\n };\r\n /**\r\n * Usually called from Texture.ts.\r\n * Passed information to create a WebGLTexture\r\n * @param urlArg defines a value which contains one of the following:\r\n * * A conventional http URL, e.g. 'http://...' or 'file://...'\r\n * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'\r\n * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'\r\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file\r\n * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)\r\n * @param scene needed for loading to the correct scene\r\n * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)\r\n * @param onLoad optional callback to be called upon successful completion\r\n * @param onError optional callback to be called upon failure\r\n * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob\r\n * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities\r\n * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures\r\n * @param forcedExtension defines the extension to use to pick the right loader\r\n * @param mimeType defines an optional mime type\r\n * @returns a InternalTexture for assignment back into BABYLON.Texture\r\n */\r\n ThinEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, mimeType) {\r\n var _this = this;\r\n if (samplingMode === void 0) { samplingMode = 3; }\r\n if (onLoad === void 0) { onLoad = null; }\r\n if (onError === void 0) { onError = null; }\r\n if (buffer === void 0) { buffer = null; }\r\n if (fallback === void 0) { fallback = null; }\r\n if (format === void 0) { format = null; }\r\n if (forcedExtension === void 0) { forcedExtension = null; }\r\n var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback\r\n var fromData = url.substr(0, 5) === \"data:\";\r\n var fromBlob = url.substr(0, 5) === \"blob:\";\r\n var isBase64 = fromData && url.indexOf(\";base64,\") !== -1;\r\n var texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Url);\r\n // establish the file extension, if possible\r\n var lastDot = url.lastIndexOf('.');\r\n var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : \"\");\r\n var loader = null;\r\n for (var _i = 0, _a = ThinEngine._TextureLoaders; _i < _a.length; _i++) {\r\n var availableLoader = _a[_i];\r\n if (availableLoader.canLoad(extension)) {\r\n loader = availableLoader;\r\n break;\r\n }\r\n }\r\n if (scene) {\r\n scene._addPendingData(texture);\r\n }\r\n texture.url = url;\r\n texture.generateMipMaps = !noMipmap;\r\n texture.samplingMode = samplingMode;\r\n texture.invertY = invertY;\r\n if (!this._doNotHandleContextLost) {\r\n // Keep a link to the buffer only if we plan to handle context lost\r\n texture._buffer = buffer;\r\n }\r\n var onLoadObserver = null;\r\n if (onLoad && !fallback) {\r\n onLoadObserver = texture.onLoadedObservable.add(onLoad);\r\n }\r\n if (!fallback) {\r\n this._internalTexturesCache.push(texture);\r\n }\r\n var onInternalError = function (message, exception) {\r\n if (scene) {\r\n scene._removePendingData(texture);\r\n }\r\n if (onLoadObserver) {\r\n texture.onLoadedObservable.remove(onLoadObserver);\r\n }\r\n if (EngineStore.UseFallbackTexture) {\r\n _this.createTexture(EngineStore.FallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, onError, buffer, texture);\r\n return;\r\n }\r\n if (onError) {\r\n onError(message || \"Unknown error\", exception);\r\n }\r\n };\r\n // processing for non-image formats\r\n if (loader) {\r\n var callback = function (data) {\r\n loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {\r\n if (loadFailed) {\r\n onInternalError(\"TextureLoader failed to load data\");\r\n }\r\n else {\r\n _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {\r\n done();\r\n return false;\r\n }, samplingMode);\r\n }\r\n });\r\n };\r\n if (!buffer) {\r\n this._loadFile(url, function (data) { return callback(new Uint8Array(data)); }, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {\r\n onInternalError(\"Unable to load \" + (request ? request.responseURL : url, exception));\r\n });\r\n }\r\n else {\r\n if (buffer instanceof ArrayBuffer) {\r\n callback(new Uint8Array(buffer));\r\n }\r\n else if (ArrayBuffer.isView(buffer)) {\r\n callback(buffer);\r\n }\r\n else {\r\n if (onError) {\r\n onError(\"Unable to load: only ArrayBuffer or ArrayBufferView is supported\", null);\r\n }\r\n }\r\n }\r\n }\r\n else {\r\n var onload = function (img) {\r\n if (fromBlob && !_this._doNotHandleContextLost) {\r\n // We need to store the image if we need to rebuild the texture\r\n // in case of a webgl context lost\r\n texture._buffer = img;\r\n }\r\n _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {\r\n var gl = _this._gl;\r\n var isPot = (img.width === potWidth && img.height === potHeight);\r\n var internalFormat = format ? _this._getInternalFormat(format) : ((extension === \".jpg\") ? gl.RGB : gl.RGBA);\r\n if (isPot) {\r\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);\r\n return false;\r\n }\r\n var maxTextureSize = _this._caps.maxTextureSize;\r\n if (img.width > maxTextureSize || img.height > maxTextureSize || !_this._supportsHardwareTextureRescaling) {\r\n _this._prepareWorkingCanvas();\r\n if (!_this._workingCanvas || !_this._workingContext) {\r\n return false;\r\n }\r\n _this._workingCanvas.width = potWidth;\r\n _this._workingCanvas.height = potHeight;\r\n _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);\r\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);\r\n texture.width = potWidth;\r\n texture.height = potHeight;\r\n return false;\r\n }\r\n else {\r\n // Using shaders when possible to rescale because canvas.drawImage is lossy\r\n var source_1 = new InternalTexture(_this, InternalTextureSource.Temp);\r\n _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);\r\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);\r\n _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {\r\n _this._releaseTexture(source_1);\r\n _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);\r\n continuationCallback();\r\n });\r\n }\r\n return true;\r\n }, samplingMode);\r\n };\r\n if (!fromData || isBase64) {\r\n if (buffer && (buffer.decoding || buffer.close)) {\r\n onload(buffer);\r\n }\r\n else {\r\n ThinEngine._FileToolsLoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null, mimeType);\r\n }\r\n }\r\n else if (typeof buffer === \"string\" || buffer instanceof ArrayBuffer || ArrayBuffer.isView(buffer) || buffer instanceof Blob) {\r\n ThinEngine._FileToolsLoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null, mimeType);\r\n }\r\n else if (buffer) {\r\n onload(buffer);\r\n }\r\n }\r\n return texture;\r\n };\r\n /**\r\n * Loads an image as an HTMLImageElement.\r\n * @param input url string, ArrayBuffer, or Blob to load\r\n * @param onLoad callback called when the image successfully loads\r\n * @param onError callback called when the image fails to load\r\n * @param offlineProvider offline provider for caching\r\n * @param mimeType optional mime type\r\n * @returns the HTMLImageElement of the loaded image\r\n * @hidden\r\n */\r\n ThinEngine._FileToolsLoadImage = function (input, onLoad, onError, offlineProvider, mimeType) {\r\n throw _DevTools.WarnImport(\"FileTools\");\r\n };\r\n /**\r\n * @hidden\r\n */\r\n ThinEngine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {\r\n };\r\n /**\r\n * Creates a raw texture\r\n * @param data defines the data to store in the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param format defines the format of the data\r\n * @param generateMipMaps defines if the engine should generate the mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)\r\n * @param compression defines the compression used (null by default)\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @returns the raw texture inside an InternalTexture\r\n */\r\n ThinEngine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {\r\n if (compression === void 0) { compression = null; }\r\n if (type === void 0) { type = 0; }\r\n throw _DevTools.WarnImport(\"Engine.RawTexture\");\r\n };\r\n /**\r\n * Creates a new raw cube texture\r\n * @param data defines the array of data to use to create each face\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)\r\n * @param generateMipMaps defines if the engine should generate the mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compression used (null by default)\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n ThinEngine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {\r\n if (compression === void 0) { compression = null; }\r\n throw _DevTools.WarnImport(\"Engine.RawTexture\");\r\n };\r\n /**\r\n * Creates a new raw 3D texture\r\n * @param data defines the data used to create the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param depth defines the depth of the texture\r\n * @param format defines the format of the texture\r\n * @param generateMipMaps defines if the engine must generate mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compressed used (can be null)\r\n * @param textureType defines the compressed used (can be null)\r\n * @returns a new raw 3D texture (stored in an InternalTexture)\r\n */\r\n ThinEngine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {\r\n if (compression === void 0) { compression = null; }\r\n if (textureType === void 0) { textureType = 0; }\r\n throw _DevTools.WarnImport(\"Engine.RawTexture\");\r\n };\r\n /**\r\n * Creates a new raw 2D array texture\r\n * @param data defines the data used to create the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param depth defines the number of layers of the texture\r\n * @param format defines the format of the texture\r\n * @param generateMipMaps defines if the engine must generate mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compressed used (can be null)\r\n * @param textureType defines the compressed used (can be null)\r\n * @returns a new raw 2D array texture (stored in an InternalTexture)\r\n */\r\n ThinEngine.prototype.createRawTexture2DArray = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {\r\n if (compression === void 0) { compression = null; }\r\n if (textureType === void 0) { textureType = 0; }\r\n throw _DevTools.WarnImport(\"Engine.RawTexture\");\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._unpackFlipY = function (value) {\r\n if (this._unpackFlipYCached !== value) {\r\n this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);\r\n if (this.enableUnpackFlipYCached) {\r\n this._unpackFlipYCached = value;\r\n }\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._getUnpackAlignement = function () {\r\n return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);\r\n };\r\n ThinEngine.prototype._getTextureTarget = function (texture) {\r\n if (texture.isCube) {\r\n return this._gl.TEXTURE_CUBE_MAP;\r\n }\r\n else if (texture.is3D) {\r\n return this._gl.TEXTURE_3D;\r\n }\r\n else if (texture.is2DArray || texture.isMultiview) {\r\n return this._gl.TEXTURE_2D_ARRAY;\r\n }\r\n return this._gl.TEXTURE_2D;\r\n };\r\n /**\r\n * Update the sampling mode of a given texture\r\n * @param samplingMode defines the required sampling mode\r\n * @param texture defines the texture to update\r\n * @param generateMipMaps defines whether to generate mipmaps for the texture\r\n */\r\n ThinEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture, generateMipMaps) {\r\n if (generateMipMaps === void 0) { generateMipMaps = false; }\r\n var target = this._getTextureTarget(texture);\r\n var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps || generateMipMaps);\r\n this._setTextureParameterInteger(target, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);\r\n this._setTextureParameterInteger(target, this._gl.TEXTURE_MIN_FILTER, filters.min);\r\n if (generateMipMaps) {\r\n texture.generateMipMaps = true;\r\n this._gl.generateMipmap(target);\r\n }\r\n this._bindTextureDirectly(target, null);\r\n texture.samplingMode = samplingMode;\r\n };\r\n /**\r\n * Update the sampling mode of a given texture\r\n * @param texture defines the texture to update\r\n * @param wrapU defines the texture wrap mode of the u coordinates\r\n * @param wrapV defines the texture wrap mode of the v coordinates\r\n * @param wrapR defines the texture wrap mode of the r coordinates\r\n */\r\n ThinEngine.prototype.updateTextureWrappingMode = function (texture, wrapU, wrapV, wrapR) {\r\n if (wrapV === void 0) { wrapV = null; }\r\n if (wrapR === void 0) { wrapR = null; }\r\n var target = this._getTextureTarget(texture);\r\n if (wrapU !== null) {\r\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(wrapU), texture);\r\n texture._cachedWrapU = wrapU;\r\n }\r\n if (wrapV !== null) {\r\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(wrapV), texture);\r\n texture._cachedWrapV = wrapV;\r\n }\r\n if ((texture.is2DArray || texture.is3D) && (wrapR !== null)) {\r\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(wrapR), texture);\r\n texture._cachedWrapR = wrapR;\r\n }\r\n this._bindTextureDirectly(target, null);\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {\r\n var width = size.width || size;\r\n var height = size.height || size;\r\n var layers = size.layers || 0;\r\n internalTexture.baseWidth = width;\r\n internalTexture.baseHeight = height;\r\n internalTexture.width = width;\r\n internalTexture.height = height;\r\n internalTexture.is2DArray = layers > 0;\r\n internalTexture.depth = layers;\r\n internalTexture.isReady = true;\r\n internalTexture.samples = 1;\r\n internalTexture.generateMipMaps = false;\r\n internalTexture._generateDepthBuffer = true;\r\n internalTexture._generateStencilBuffer = generateStencil;\r\n internalTexture.samplingMode = bilinearFiltering ? 2 : 1;\r\n internalTexture.type = 0;\r\n internalTexture._comparisonFunction = comparisonFunction;\r\n var gl = this._gl;\r\n var target = this._getTextureTarget(internalTexture);\r\n var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);\r\n gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);\r\n gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\r\n if (comparisonFunction === 0) {\r\n gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, 515);\r\n gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);\r\n }\r\n else {\r\n gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);\r\n gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lod === void 0) { lod = 0; }\r\n var gl = this._gl;\r\n var target = gl.TEXTURE_2D;\r\n if (texture.isCube) {\r\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\r\n }\r\n this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod, babylonInternalFormat, useTextureWidthAndHeight) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lod === void 0) { lod = 0; }\r\n if (useTextureWidthAndHeight === void 0) { useTextureWidthAndHeight = false; }\r\n var gl = this._gl;\r\n var textureType = this._getWebGLTextureType(texture.type);\r\n var format = this._getInternalFormat(texture.format);\r\n var internalFormat = babylonInternalFormat === undefined ? this._getRGBABufferInternalSizedFormat(texture.type, texture.format) : this._getInternalFormat(babylonInternalFormat);\r\n this._unpackFlipY(texture.invertY);\r\n var target = gl.TEXTURE_2D;\r\n if (texture.isCube) {\r\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\r\n }\r\n var lodMaxWidth = Math.round(Math.log(texture.width) * Math.LOG2E);\r\n var lodMaxHeight = Math.round(Math.log(texture.height) * Math.LOG2E);\r\n var width = useTextureWidthAndHeight ? texture.width : Math.pow(2, Math.max(lodMaxWidth - lod, 0));\r\n var height = useTextureWidthAndHeight ? texture.height : Math.pow(2, Math.max(lodMaxHeight - lod, 0));\r\n gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);\r\n };\r\n /**\r\n * Update a portion of an internal texture\r\n * @param texture defines the texture to update\r\n * @param imageData defines the data to store into the texture\r\n * @param xOffset defines the x coordinates of the update rectangle\r\n * @param yOffset defines the y coordinates of the update rectangle\r\n * @param width defines the width of the update rectangle\r\n * @param height defines the height of the update rectangle\r\n * @param faceIndex defines the face index if texture is a cube (0 by default)\r\n * @param lod defines the lod level to update (0 by default)\r\n */\r\n ThinEngine.prototype.updateTextureData = function (texture, imageData, xOffset, yOffset, width, height, faceIndex, lod) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lod === void 0) { lod = 0; }\r\n var gl = this._gl;\r\n var textureType = this._getWebGLTextureType(texture.type);\r\n var format = this._getInternalFormat(texture.format);\r\n this._unpackFlipY(texture.invertY);\r\n var target = gl.TEXTURE_2D;\r\n if (texture.isCube) {\r\n target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\r\n }\r\n gl.texSubImage2D(target, lod, xOffset, yOffset, width, height, format, textureType, imageData);\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lod === void 0) { lod = 0; }\r\n var gl = this._gl;\r\n var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;\r\n this._bindTextureDirectly(bindTarget, texture, true);\r\n this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);\r\n this._bindTextureDirectly(bindTarget, null, true);\r\n };\r\n ThinEngine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {\r\n var gl = this._gl;\r\n if (!gl) {\r\n return;\r\n }\r\n var filters = this._getSamplingParameters(samplingMode, !noMipmap);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);\r\n if (!noMipmap && !isCompressed) {\r\n gl.generateMipmap(gl.TEXTURE_2D);\r\n }\r\n this._bindTextureDirectly(gl.TEXTURE_2D, null);\r\n // this.resetTextureCache();\r\n if (scene) {\r\n scene._removePendingData(texture);\r\n }\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n };\r\n ThinEngine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {\r\n var _this = this;\r\n if (samplingMode === void 0) { samplingMode = 3; }\r\n var maxTextureSize = this.getCaps().maxTextureSize;\r\n var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? ThinEngine.GetExponentOfTwo(width, maxTextureSize) : width);\r\n var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? ThinEngine.GetExponentOfTwo(height, maxTextureSize) : height);\r\n var gl = this._gl;\r\n if (!gl) {\r\n return;\r\n }\r\n if (!texture._webGLTexture) {\r\n // this.resetTextureCache();\r\n if (scene) {\r\n scene._removePendingData(texture);\r\n }\r\n return;\r\n }\r\n this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);\r\n this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = potWidth;\r\n texture.height = potHeight;\r\n texture.isReady = true;\r\n if (processFunction(potWidth, potHeight, function () {\r\n _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);\r\n })) {\r\n // Returning as texture needs extra async steps\r\n return;\r\n }\r\n this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {\r\n if (samples === void 0) { samples = 1; }\r\n var gl = this._gl;\r\n // Create the depth/stencil buffer\r\n if (generateStencilBuffer && generateDepthBuffer) {\r\n return this._getDepthStencilBuffer(width, height, samples, gl.DEPTH_STENCIL, gl.DEPTH24_STENCIL8, gl.DEPTH_STENCIL_ATTACHMENT);\r\n }\r\n if (generateDepthBuffer) {\r\n var depthFormat = gl.DEPTH_COMPONENT16;\r\n if (this._webGLVersion > 1) {\r\n depthFormat = gl.DEPTH_COMPONENT32F;\r\n }\r\n return this._getDepthStencilBuffer(width, height, samples, depthFormat, depthFormat, gl.DEPTH_ATTACHMENT);\r\n }\r\n if (generateStencilBuffer) {\r\n return this._getDepthStencilBuffer(width, height, samples, gl.STENCIL_INDEX8, gl.STENCIL_INDEX8, gl.STENCIL_ATTACHMENT);\r\n }\r\n return null;\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._releaseFramebufferObjects = function (texture) {\r\n var gl = this._gl;\r\n if (texture._framebuffer) {\r\n gl.deleteFramebuffer(texture._framebuffer);\r\n texture._framebuffer = null;\r\n }\r\n if (texture._depthStencilBuffer) {\r\n gl.deleteRenderbuffer(texture._depthStencilBuffer);\r\n texture._depthStencilBuffer = null;\r\n }\r\n if (texture._MSAAFramebuffer) {\r\n gl.deleteFramebuffer(texture._MSAAFramebuffer);\r\n texture._MSAAFramebuffer = null;\r\n }\r\n if (texture._MSAARenderBuffer) {\r\n gl.deleteRenderbuffer(texture._MSAARenderBuffer);\r\n texture._MSAARenderBuffer = null;\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._releaseTexture = function (texture) {\r\n this._releaseFramebufferObjects(texture);\r\n this._deleteTexture(texture._webGLTexture);\r\n // Unbind channels\r\n this.unbindAllTextures();\r\n var index = this._internalTexturesCache.indexOf(texture);\r\n if (index !== -1) {\r\n this._internalTexturesCache.splice(index, 1);\r\n }\r\n // Integrated fixed lod samplers.\r\n if (texture._lodTextureHigh) {\r\n texture._lodTextureHigh.dispose();\r\n }\r\n if (texture._lodTextureMid) {\r\n texture._lodTextureMid.dispose();\r\n }\r\n if (texture._lodTextureLow) {\r\n texture._lodTextureLow.dispose();\r\n }\r\n // Integrated irradiance map.\r\n if (texture._irradianceTexture) {\r\n texture._irradianceTexture.dispose();\r\n }\r\n };\r\n ThinEngine.prototype._deleteTexture = function (texture) {\r\n this._gl.deleteTexture(texture);\r\n };\r\n ThinEngine.prototype._setProgram = function (program) {\r\n if (this._currentProgram !== program) {\r\n this._gl.useProgram(program);\r\n this._currentProgram = program;\r\n }\r\n };\r\n /**\r\n * Binds an effect to the webGL context\r\n * @param effect defines the effect to bind\r\n */\r\n ThinEngine.prototype.bindSamplers = function (effect) {\r\n var webGLPipelineContext = effect.getPipelineContext();\r\n this._setProgram(webGLPipelineContext.program);\r\n var samplers = effect.getSamplers();\r\n for (var index = 0; index < samplers.length; index++) {\r\n var uniform = effect.getUniform(samplers[index]);\r\n if (uniform) {\r\n this._boundUniforms[index] = uniform;\r\n }\r\n }\r\n this._currentEffect = null;\r\n };\r\n ThinEngine.prototype._activateCurrentTexture = function () {\r\n if (this._currentTextureChannel !== this._activeChannel) {\r\n this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);\r\n this._currentTextureChannel = this._activeChannel;\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {\r\n if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }\r\n if (force === void 0) { force = false; }\r\n var wasPreviouslyBound = false;\r\n var isTextureForRendering = texture && texture._associatedChannel > -1;\r\n if (forTextureDataUpdate && isTextureForRendering) {\r\n this._activeChannel = texture._associatedChannel;\r\n }\r\n var currentTextureBound = this._boundTexturesCache[this._activeChannel];\r\n if (currentTextureBound !== texture || force) {\r\n this._activateCurrentTexture();\r\n if (texture && texture.isMultiview) {\r\n this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);\r\n }\r\n else {\r\n this._gl.bindTexture(target, texture ? texture._webGLTexture : null);\r\n }\r\n this._boundTexturesCache[this._activeChannel] = texture;\r\n if (texture) {\r\n texture._associatedChannel = this._activeChannel;\r\n }\r\n }\r\n else if (forTextureDataUpdate) {\r\n wasPreviouslyBound = true;\r\n this._activateCurrentTexture();\r\n }\r\n if (isTextureForRendering && !forTextureDataUpdate) {\r\n this._bindSamplerUniformToChannel(texture._associatedChannel, this._activeChannel);\r\n }\r\n return wasPreviouslyBound;\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._bindTexture = function (channel, texture) {\r\n if (channel === undefined) {\r\n return;\r\n }\r\n if (texture) {\r\n texture._associatedChannel = channel;\r\n }\r\n this._activeChannel = channel;\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);\r\n };\r\n /**\r\n * Unbind all textures from the webGL context\r\n */\r\n ThinEngine.prototype.unbindAllTextures = function () {\r\n for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {\r\n this._activeChannel = channel;\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\r\n if (this.webGLVersion > 1) {\r\n this._bindTextureDirectly(this._gl.TEXTURE_3D, null);\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null);\r\n }\r\n }\r\n };\r\n /**\r\n * Sets a texture to the according uniform.\r\n * @param channel The texture channel\r\n * @param uniform The uniform to set\r\n * @param texture The texture to apply\r\n */\r\n ThinEngine.prototype.setTexture = function (channel, uniform, texture) {\r\n if (channel === undefined) {\r\n return;\r\n }\r\n if (uniform) {\r\n this._boundUniforms[channel] = uniform;\r\n }\r\n this._setTexture(channel, texture);\r\n };\r\n ThinEngine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {\r\n var uniform = this._boundUniforms[sourceSlot];\r\n if (!uniform || uniform._currentState === destination) {\r\n return;\r\n }\r\n this._gl.uniform1i(uniform, destination);\r\n uniform._currentState = destination;\r\n };\r\n ThinEngine.prototype._getTextureWrapMode = function (mode) {\r\n switch (mode) {\r\n case 1:\r\n return this._gl.REPEAT;\r\n case 0:\r\n return this._gl.CLAMP_TO_EDGE;\r\n case 2:\r\n return this._gl.MIRRORED_REPEAT;\r\n }\r\n return this._gl.REPEAT;\r\n };\r\n ThinEngine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {\r\n if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }\r\n if (depthStencilTexture === void 0) { depthStencilTexture = false; }\r\n // Not ready?\r\n if (!texture) {\r\n if (this._boundTexturesCache[channel] != null) {\r\n this._activeChannel = channel;\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\r\n if (this.webGLVersion > 1) {\r\n this._bindTextureDirectly(this._gl.TEXTURE_3D, null);\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null);\r\n }\r\n }\r\n return false;\r\n }\r\n // Video\r\n if (texture.video) {\r\n this._activeChannel = channel;\r\n texture.update();\r\n }\r\n else if (texture.delayLoadState === 4) { // Delay loading\r\n texture.delayLoad();\r\n return false;\r\n }\r\n var internalTexture;\r\n if (depthStencilTexture) {\r\n internalTexture = texture.depthStencilTexture;\r\n }\r\n else if (texture.isReady()) {\r\n internalTexture = texture.getInternalTexture();\r\n }\r\n else if (texture.isCube) {\r\n internalTexture = this.emptyCubeTexture;\r\n }\r\n else if (texture.is3D) {\r\n internalTexture = this.emptyTexture3D;\r\n }\r\n else if (texture.is2DArray) {\r\n internalTexture = this.emptyTexture2DArray;\r\n }\r\n else {\r\n internalTexture = this.emptyTexture;\r\n }\r\n if (!isPartOfTextureArray && internalTexture) {\r\n internalTexture._associatedChannel = channel;\r\n }\r\n var needToBind = true;\r\n if (this._boundTexturesCache[channel] === internalTexture) {\r\n if (!isPartOfTextureArray) {\r\n this._bindSamplerUniformToChannel(internalTexture._associatedChannel, channel);\r\n }\r\n needToBind = false;\r\n }\r\n this._activeChannel = channel;\r\n var target = this._getTextureTarget(internalTexture);\r\n if (needToBind) {\r\n this._bindTextureDirectly(target, internalTexture, isPartOfTextureArray);\r\n }\r\n if (internalTexture && !internalTexture.isMultiview) {\r\n // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.\r\n if (internalTexture.isCube && internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {\r\n internalTexture._cachedCoordinatesMode = texture.coordinatesMode;\r\n var textureWrapMode = (texture.coordinatesMode !== 3 && texture.coordinatesMode !== 5) ? 1 : 0;\r\n texture.wrapU = textureWrapMode;\r\n texture.wrapV = textureWrapMode;\r\n }\r\n if (internalTexture._cachedWrapU !== texture.wrapU) {\r\n internalTexture._cachedWrapU = texture.wrapU;\r\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);\r\n }\r\n if (internalTexture._cachedWrapV !== texture.wrapV) {\r\n internalTexture._cachedWrapV = texture.wrapV;\r\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);\r\n }\r\n if (internalTexture.is3D && internalTexture._cachedWrapR !== texture.wrapR) {\r\n internalTexture._cachedWrapR = texture.wrapR;\r\n this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);\r\n }\r\n this._setAnisotropicLevel(target, internalTexture, texture.anisotropicFilteringLevel);\r\n }\r\n return true;\r\n };\r\n /**\r\n * Sets an array of texture to the webGL context\r\n * @param channel defines the channel where the texture array must be set\r\n * @param uniform defines the associated uniform location\r\n * @param textures defines the array of textures to bind\r\n */\r\n ThinEngine.prototype.setTextureArray = function (channel, uniform, textures) {\r\n if (channel === undefined || !uniform) {\r\n return;\r\n }\r\n if (!this._textureUnits || this._textureUnits.length !== textures.length) {\r\n this._textureUnits = new Int32Array(textures.length);\r\n }\r\n for (var i = 0; i < textures.length; i++) {\r\n var texture = textures[i].getInternalTexture();\r\n if (texture) {\r\n this._textureUnits[i] = channel + i;\r\n texture._associatedChannel = channel + i;\r\n }\r\n else {\r\n this._textureUnits[i] = -1;\r\n }\r\n }\r\n this._gl.uniform1iv(uniform, this._textureUnits);\r\n for (var index = 0; index < textures.length; index++) {\r\n this._setTexture(this._textureUnits[index], textures[index], true);\r\n }\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._setAnisotropicLevel = function (target, internalTexture, anisotropicFilteringLevel) {\r\n var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;\r\n if (internalTexture.samplingMode !== 11\r\n && internalTexture.samplingMode !== 3\r\n && internalTexture.samplingMode !== 2) {\r\n anisotropicFilteringLevel = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear\r\n }\r\n if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== anisotropicFilteringLevel) {\r\n this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(anisotropicFilteringLevel, this._caps.maxAnisotropy), internalTexture);\r\n internalTexture._cachedAnisotropicFilteringLevel = anisotropicFilteringLevel;\r\n }\r\n };\r\n ThinEngine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {\r\n this._bindTextureDirectly(target, texture, true, true);\r\n this._gl.texParameterf(target, parameter, value);\r\n };\r\n ThinEngine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {\r\n if (texture) {\r\n this._bindTextureDirectly(target, texture, true, true);\r\n }\r\n this._gl.texParameteri(target, parameter, value);\r\n };\r\n /**\r\n * Unbind all vertex attributes from the webGL context\r\n */\r\n ThinEngine.prototype.unbindAllAttributes = function () {\r\n if (this._mustWipeVertexAttributes) {\r\n this._mustWipeVertexAttributes = false;\r\n for (var i = 0; i < this._caps.maxVertexAttribs; i++) {\r\n this.disableAttributeByIndex(i);\r\n }\r\n return;\r\n }\r\n for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {\r\n if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {\r\n continue;\r\n }\r\n this.disableAttributeByIndex(i);\r\n }\r\n };\r\n /**\r\n * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled\r\n */\r\n ThinEngine.prototype.releaseEffects = function () {\r\n for (var name in this._compiledEffects) {\r\n var webGLPipelineContext = this._compiledEffects[name].getPipelineContext();\r\n this._deletePipelineContext(webGLPipelineContext);\r\n }\r\n this._compiledEffects = {};\r\n };\r\n /**\r\n * Dispose and release all associated resources\r\n */\r\n ThinEngine.prototype.dispose = function () {\r\n this.stopRenderLoop();\r\n // Clear observables\r\n if (this.onBeforeTextureInitObservable) {\r\n this.onBeforeTextureInitObservable.clear();\r\n }\r\n // Empty texture\r\n if (this._emptyTexture) {\r\n this._releaseTexture(this._emptyTexture);\r\n this._emptyTexture = null;\r\n }\r\n if (this._emptyCubeTexture) {\r\n this._releaseTexture(this._emptyCubeTexture);\r\n this._emptyCubeTexture = null;\r\n }\r\n // Release effects\r\n this.releaseEffects();\r\n // Unbind\r\n this.unbindAllAttributes();\r\n this._boundUniforms = [];\r\n // Events\r\n if (DomManagement.IsWindowObjectExist()) {\r\n if (this._renderingCanvas) {\r\n if (!this._doNotHandleContextLost) {\r\n this._renderingCanvas.removeEventListener(\"webglcontextlost\", this._onContextLost);\r\n this._renderingCanvas.removeEventListener(\"webglcontextrestored\", this._onContextRestored);\r\n }\r\n }\r\n }\r\n this._workingCanvas = null;\r\n this._workingContext = null;\r\n this._currentBufferPointers = [];\r\n this._renderingCanvas = null;\r\n this._currentProgram = null;\r\n this._boundRenderFunction = null;\r\n Effect.ResetCache();\r\n // Abort active requests\r\n for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {\r\n var request = _a[_i];\r\n request.abort();\r\n }\r\n };\r\n /**\r\n * Attach a new callback raised when context lost event is fired\r\n * @param callback defines the callback to call\r\n */\r\n ThinEngine.prototype.attachContextLostEvent = function (callback) {\r\n if (this._renderingCanvas) {\r\n this._renderingCanvas.addEventListener(\"webglcontextlost\", callback, false);\r\n }\r\n };\r\n /**\r\n * Attach a new callback raised when context restored event is fired\r\n * @param callback defines the callback to call\r\n */\r\n ThinEngine.prototype.attachContextRestoredEvent = function (callback) {\r\n if (this._renderingCanvas) {\r\n this._renderingCanvas.addEventListener(\"webglcontextrestored\", callback, false);\r\n }\r\n };\r\n /**\r\n * Get the current error code of the webGL context\r\n * @returns the error code\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError\r\n */\r\n ThinEngine.prototype.getError = function () {\r\n return this._gl.getError();\r\n };\r\n ThinEngine.prototype._canRenderToFloatFramebuffer = function () {\r\n if (this._webGLVersion > 1) {\r\n return this._caps.colorBufferFloat;\r\n }\r\n return this._canRenderToFramebuffer(1);\r\n };\r\n ThinEngine.prototype._canRenderToHalfFloatFramebuffer = function () {\r\n if (this._webGLVersion > 1) {\r\n return this._caps.colorBufferFloat;\r\n }\r\n return this._canRenderToFramebuffer(2);\r\n };\r\n // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\r\n ThinEngine.prototype._canRenderToFramebuffer = function (type) {\r\n var gl = this._gl;\r\n //clear existing errors\r\n while (gl.getError() !== gl.NO_ERROR) { }\r\n var successful = true;\r\n var texture = gl.createTexture();\r\n gl.bindTexture(gl.TEXTURE_2D, texture);\r\n gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\r\n var fb = gl.createFramebuffer();\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb);\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\r\n var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);\r\n successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);\r\n successful = successful && (gl.getError() === gl.NO_ERROR);\r\n //try render by clearing frame buffer's color buffer\r\n if (successful) {\r\n gl.clear(gl.COLOR_BUFFER_BIT);\r\n successful = successful && (gl.getError() === gl.NO_ERROR);\r\n }\r\n //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)\r\n if (successful) {\r\n //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\r\n var readFormat = gl.RGBA;\r\n var readType = gl.UNSIGNED_BYTE;\r\n var buffer = new Uint8Array(4);\r\n gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);\r\n successful = successful && (gl.getError() === gl.NO_ERROR);\r\n }\r\n //clean up\r\n gl.deleteTexture(texture);\r\n gl.deleteFramebuffer(fb);\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\r\n //clear accumulated errors\r\n while (!successful && (gl.getError() !== gl.NO_ERROR)) { }\r\n return successful;\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._getWebGLTextureType = function (type) {\r\n if (this._webGLVersion === 1) {\r\n switch (type) {\r\n case 1:\r\n return this._gl.FLOAT;\r\n case 2:\r\n return this._gl.HALF_FLOAT_OES;\r\n case 0:\r\n return this._gl.UNSIGNED_BYTE;\r\n case 8:\r\n return this._gl.UNSIGNED_SHORT_4_4_4_4;\r\n case 9:\r\n return this._gl.UNSIGNED_SHORT_5_5_5_1;\r\n case 10:\r\n return this._gl.UNSIGNED_SHORT_5_6_5;\r\n }\r\n return this._gl.UNSIGNED_BYTE;\r\n }\r\n switch (type) {\r\n case 3:\r\n return this._gl.BYTE;\r\n case 0:\r\n return this._gl.UNSIGNED_BYTE;\r\n case 4:\r\n return this._gl.SHORT;\r\n case 5:\r\n return this._gl.UNSIGNED_SHORT;\r\n case 6:\r\n return this._gl.INT;\r\n case 7: // Refers to UNSIGNED_INT\r\n return this._gl.UNSIGNED_INT;\r\n case 1:\r\n return this._gl.FLOAT;\r\n case 2:\r\n return this._gl.HALF_FLOAT;\r\n case 8:\r\n return this._gl.UNSIGNED_SHORT_4_4_4_4;\r\n case 9:\r\n return this._gl.UNSIGNED_SHORT_5_5_5_1;\r\n case 10:\r\n return this._gl.UNSIGNED_SHORT_5_6_5;\r\n case 11:\r\n return this._gl.UNSIGNED_INT_2_10_10_10_REV;\r\n case 12:\r\n return this._gl.UNSIGNED_INT_24_8;\r\n case 13:\r\n return this._gl.UNSIGNED_INT_10F_11F_11F_REV;\r\n case 14:\r\n return this._gl.UNSIGNED_INT_5_9_9_9_REV;\r\n case 15:\r\n return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;\r\n }\r\n return this._gl.UNSIGNED_BYTE;\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._getInternalFormat = function (format) {\r\n var internalFormat = this._gl.RGBA;\r\n switch (format) {\r\n case 0:\r\n internalFormat = this._gl.ALPHA;\r\n break;\r\n case 1:\r\n internalFormat = this._gl.LUMINANCE;\r\n break;\r\n case 2:\r\n internalFormat = this._gl.LUMINANCE_ALPHA;\r\n break;\r\n case 6:\r\n internalFormat = this._gl.RED;\r\n break;\r\n case 7:\r\n internalFormat = this._gl.RG;\r\n break;\r\n case 4:\r\n internalFormat = this._gl.RGB;\r\n break;\r\n case 5:\r\n internalFormat = this._gl.RGBA;\r\n break;\r\n }\r\n if (this._webGLVersion > 1) {\r\n switch (format) {\r\n case 8:\r\n internalFormat = this._gl.RED_INTEGER;\r\n break;\r\n case 9:\r\n internalFormat = this._gl.RG_INTEGER;\r\n break;\r\n case 10:\r\n internalFormat = this._gl.RGB_INTEGER;\r\n break;\r\n case 11:\r\n internalFormat = this._gl.RGBA_INTEGER;\r\n break;\r\n }\r\n }\r\n return internalFormat;\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {\r\n if (this._webGLVersion === 1) {\r\n if (format !== undefined) {\r\n switch (format) {\r\n case 0:\r\n return this._gl.ALPHA;\r\n case 1:\r\n return this._gl.LUMINANCE;\r\n case 2:\r\n return this._gl.LUMINANCE_ALPHA;\r\n case 4:\r\n return this._gl.RGB;\r\n }\r\n }\r\n return this._gl.RGBA;\r\n }\r\n switch (type) {\r\n case 3:\r\n switch (format) {\r\n case 6:\r\n return this._gl.R8_SNORM;\r\n case 7:\r\n return this._gl.RG8_SNORM;\r\n case 4:\r\n return this._gl.RGB8_SNORM;\r\n case 8:\r\n return this._gl.R8I;\r\n case 9:\r\n return this._gl.RG8I;\r\n case 10:\r\n return this._gl.RGB8I;\r\n case 11:\r\n return this._gl.RGBA8I;\r\n default:\r\n return this._gl.RGBA8_SNORM;\r\n }\r\n case 0:\r\n switch (format) {\r\n case 6:\r\n return this._gl.R8;\r\n case 7:\r\n return this._gl.RG8;\r\n case 4:\r\n return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.\r\n case 5:\r\n return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.\r\n case 8:\r\n return this._gl.R8UI;\r\n case 9:\r\n return this._gl.RG8UI;\r\n case 10:\r\n return this._gl.RGB8UI;\r\n case 11:\r\n return this._gl.RGBA8UI;\r\n case 0:\r\n return this._gl.ALPHA;\r\n case 1:\r\n return this._gl.LUMINANCE;\r\n case 2:\r\n return this._gl.LUMINANCE_ALPHA;\r\n default:\r\n return this._gl.RGBA8;\r\n }\r\n case 4:\r\n switch (format) {\r\n case 8:\r\n return this._gl.R16I;\r\n case 9:\r\n return this._gl.RG16I;\r\n case 10:\r\n return this._gl.RGB16I;\r\n case 11:\r\n return this._gl.RGBA16I;\r\n default:\r\n return this._gl.RGBA16I;\r\n }\r\n case 5:\r\n switch (format) {\r\n case 8:\r\n return this._gl.R16UI;\r\n case 9:\r\n return this._gl.RG16UI;\r\n case 10:\r\n return this._gl.RGB16UI;\r\n case 11:\r\n return this._gl.RGBA16UI;\r\n default:\r\n return this._gl.RGBA16UI;\r\n }\r\n case 6:\r\n switch (format) {\r\n case 8:\r\n return this._gl.R32I;\r\n case 9:\r\n return this._gl.RG32I;\r\n case 10:\r\n return this._gl.RGB32I;\r\n case 11:\r\n return this._gl.RGBA32I;\r\n default:\r\n return this._gl.RGBA32I;\r\n }\r\n case 7: // Refers to UNSIGNED_INT\r\n switch (format) {\r\n case 8:\r\n return this._gl.R32UI;\r\n case 9:\r\n return this._gl.RG32UI;\r\n case 10:\r\n return this._gl.RGB32UI;\r\n case 11:\r\n return this._gl.RGBA32UI;\r\n default:\r\n return this._gl.RGBA32UI;\r\n }\r\n case 1:\r\n switch (format) {\r\n case 6:\r\n return this._gl.R32F; // By default. Other possibility is R16F.\r\n case 7:\r\n return this._gl.RG32F; // By default. Other possibility is RG16F.\r\n case 4:\r\n return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.\r\n case 5:\r\n return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.\r\n default:\r\n return this._gl.RGBA32F;\r\n }\r\n case 2:\r\n switch (format) {\r\n case 6:\r\n return this._gl.R16F;\r\n case 7:\r\n return this._gl.RG16F;\r\n case 4:\r\n return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.\r\n case 5:\r\n return this._gl.RGBA16F;\r\n default:\r\n return this._gl.RGBA16F;\r\n }\r\n case 10:\r\n return this._gl.RGB565;\r\n case 13:\r\n return this._gl.R11F_G11F_B10F;\r\n case 14:\r\n return this._gl.RGB9_E5;\r\n case 8:\r\n return this._gl.RGBA4;\r\n case 9:\r\n return this._gl.RGB5_A1;\r\n case 11:\r\n switch (format) {\r\n case 5:\r\n return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.\r\n case 11:\r\n return this._gl.RGB10_A2UI;\r\n default:\r\n return this._gl.RGB10_A2;\r\n }\r\n }\r\n return this._gl.RGBA8;\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._getRGBAMultiSampleBufferFormat = function (type) {\r\n if (type === 1) {\r\n return this._gl.RGBA32F;\r\n }\r\n else if (type === 2) {\r\n return this._gl.RGBA16F;\r\n }\r\n return this._gl.RGBA8;\r\n };\r\n /** @hidden */\r\n ThinEngine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {\r\n var _this = this;\r\n var request = ThinEngine._FileToolsLoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);\r\n this._activeRequests.push(request);\r\n request.onCompleteObservable.add(function (request) {\r\n _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);\r\n });\r\n return request;\r\n };\r\n /**\r\n * Loads a file from a url\r\n * @param url url to load\r\n * @param onSuccess callback called when the file successfully loads\r\n * @param onProgress callback called while file is loading (if the server supports this mode)\r\n * @param offlineProvider defines the offline provider for caching\r\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\r\n * @param onError callback called when the file fails to load\r\n * @returns a file request object\r\n * @hidden\r\n */\r\n ThinEngine._FileToolsLoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {\r\n throw _DevTools.WarnImport(\"FileTools\");\r\n };\r\n /**\r\n * Reads pixels from the current frame buffer. Please note that this function can be slow\r\n * @param x defines the x coordinate of the rectangle where pixels must be read\r\n * @param y defines the y coordinate of the rectangle where pixels must be read\r\n * @param width defines the width of the rectangle where pixels must be read\r\n * @param height defines the height of the rectangle where pixels must be read\r\n * @param hasAlpha defines whether the output should have alpha or not (defaults to true)\r\n * @returns a Uint8Array containing RGBA colors\r\n */\r\n ThinEngine.prototype.readPixels = function (x, y, width, height, hasAlpha) {\r\n if (hasAlpha === void 0) { hasAlpha = true; }\r\n var numChannels = hasAlpha ? 4 : 3;\r\n var format = hasAlpha ? this._gl.RGBA : this._gl.RGB;\r\n var data = new Uint8Array(height * width * numChannels);\r\n this._gl.readPixels(x, y, width, height, format, this._gl.UNSIGNED_BYTE, data);\r\n return data;\r\n };\r\n /**\r\n * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)\r\n * @returns true if the engine can be created\r\n * @ignorenaming\r\n */\r\n ThinEngine.isSupported = function () {\r\n if (this._isSupported === null) {\r\n try {\r\n var tempcanvas = CanvasGenerator.CreateCanvas(1, 1);\r\n var gl = tempcanvas.getContext(\"webgl\") || tempcanvas.getContext(\"experimental-webgl\");\r\n this._isSupported = gl != null && !!window.WebGLRenderingContext;\r\n }\r\n catch (e) {\r\n this._isSupported = false;\r\n }\r\n }\r\n return this._isSupported;\r\n };\r\n /**\r\n * Find the next highest power of two.\r\n * @param x Number to start search from.\r\n * @return Next highest power of two.\r\n */\r\n ThinEngine.CeilingPOT = function (x) {\r\n x--;\r\n x |= x >> 1;\r\n x |= x >> 2;\r\n x |= x >> 4;\r\n x |= x >> 8;\r\n x |= x >> 16;\r\n x++;\r\n return x;\r\n };\r\n /**\r\n * Find the next lowest power of two.\r\n * @param x Number to start search from.\r\n * @return Next lowest power of two.\r\n */\r\n ThinEngine.FloorPOT = function (x) {\r\n x = x | (x >> 1);\r\n x = x | (x >> 2);\r\n x = x | (x >> 4);\r\n x = x | (x >> 8);\r\n x = x | (x >> 16);\r\n return x - (x >> 1);\r\n };\r\n /**\r\n * Find the nearest power of two.\r\n * @param x Number to start search from.\r\n * @return Next nearest power of two.\r\n */\r\n ThinEngine.NearestPOT = function (x) {\r\n var c = ThinEngine.CeilingPOT(x);\r\n var f = ThinEngine.FloorPOT(x);\r\n return (c - x) > (x - f) ? f : c;\r\n };\r\n /**\r\n * Get the closest exponent of two\r\n * @param value defines the value to approximate\r\n * @param max defines the maximum value to return\r\n * @param mode defines how to define the closest value\r\n * @returns closest exponent of two of the given value\r\n */\r\n ThinEngine.GetExponentOfTwo = function (value, max, mode) {\r\n if (mode === void 0) { mode = 2; }\r\n var pot;\r\n switch (mode) {\r\n case 1:\r\n pot = ThinEngine.FloorPOT(value);\r\n break;\r\n case 2:\r\n pot = ThinEngine.NearestPOT(value);\r\n break;\r\n case 3:\r\n default:\r\n pot = ThinEngine.CeilingPOT(value);\r\n break;\r\n }\r\n return Math.min(pot, max);\r\n };\r\n /**\r\n * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)\r\n * @param func - the function to be called\r\n * @param requester - the object that will request the next frame. Falls back to window.\r\n * @returns frame number\r\n */\r\n ThinEngine.QueueNewFrame = function (func, requester) {\r\n if (!DomManagement.IsWindowObjectExist()) {\r\n if (typeof requestAnimationFrame !== \"undefined\") {\r\n return requestAnimationFrame(func);\r\n }\r\n return setTimeout(func, 16);\r\n }\r\n if (!requester) {\r\n requester = window;\r\n }\r\n if (requester.requestAnimationFrame) {\r\n return requester.requestAnimationFrame(func);\r\n }\r\n else if (requester.msRequestAnimationFrame) {\r\n return requester.msRequestAnimationFrame(func);\r\n }\r\n else if (requester.webkitRequestAnimationFrame) {\r\n return requester.webkitRequestAnimationFrame(func);\r\n }\r\n else if (requester.mozRequestAnimationFrame) {\r\n return requester.mozRequestAnimationFrame(func);\r\n }\r\n else if (requester.oRequestAnimationFrame) {\r\n return requester.oRequestAnimationFrame(func);\r\n }\r\n else {\r\n return window.setTimeout(func, 16);\r\n }\r\n };\r\n /**\r\n * Gets host document\r\n * @returns the host document object\r\n */\r\n ThinEngine.prototype.getHostDocument = function () {\r\n if (this._renderingCanvas && this._renderingCanvas.ownerDocument) {\r\n return this._renderingCanvas.ownerDocument;\r\n }\r\n return document;\r\n };\r\n /** Use this array to turn off some WebGL2 features on known buggy browsers version */\r\n ThinEngine.ExceptionList = [\r\n { key: \"Chrome\\/63\\.0\", capture: \"63\\\\.0\\\\.3239\\\\.(\\\\d+)\", captureConstraint: 108, targets: [\"uniformBuffer\"] },\r\n { key: \"Firefox\\/58\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\r\n { key: \"Firefox\\/59\", capture: null, captureConstraint: null, targets: [\"uniformBuffer\"] },\r\n { key: \"Chrome\\/72.+?Mobile\", capture: null, captureConstraint: null, targets: [\"vao\"] },\r\n { key: \"Chrome\\/73.+?Mobile\", capture: null, captureConstraint: null, targets: [\"vao\"] },\r\n { key: \"Chrome\\/74.+?Mobile\", capture: null, captureConstraint: null, targets: [\"vao\"] },\r\n { key: \"Mac OS.+Chrome\\/71\", capture: null, captureConstraint: null, targets: [\"vao\"] },\r\n { key: \"Mac OS.+Chrome\\/72\", capture: null, captureConstraint: null, targets: [\"vao\"] }\r\n ];\r\n /** @hidden */\r\n ThinEngine._TextureLoaders = [];\r\n // Updatable statics so stick with vars here\r\n /**\r\n * Gets or sets the epsilon value used by collision engine\r\n */\r\n ThinEngine.CollisionsEpsilon = 0.001;\r\n // Statics\r\n ThinEngine._isSupported = null;\r\n return ThinEngine;\r\n}());\r\nexport { ThinEngine };\r\n//# sourceMappingURL=thinEngine.js.map","\"use strict\";\n\nexports.__esModule = true;\n\nvar _assign = require(\"../core-js/object/assign\");\n\nvar _assign2 = _interopRequireDefault(_assign);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = _assign2.default || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n};","\"use strict\";\n\nexports.__esModule = true;\n\nvar _defineProperty = require(\"../core-js/object/define-property\");\n\nvar _defineProperty2 = _interopRequireDefault(_defineProperty);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = function (obj, key, value) {\n if (key in obj) {\n (0, _defineProperty2.default)(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n};","/**\r\n * Helper to manipulate strings\r\n */\r\nvar StringTools = /** @class */ (function () {\r\n function StringTools() {\r\n }\r\n /**\r\n * Checks for a matching suffix at the end of a string (for ES5 and lower)\r\n * @param str Source string\r\n * @param suffix Suffix to search for in the source string\r\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\r\n */\r\n StringTools.EndsWith = function (str, suffix) {\r\n return str.indexOf(suffix, str.length - suffix.length) !== -1;\r\n };\r\n /**\r\n * Checks for a matching suffix at the beginning of a string (for ES5 and lower)\r\n * @param str Source string\r\n * @param suffix Suffix to search for in the source string\r\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\r\n */\r\n StringTools.StartsWith = function (str, suffix) {\r\n return str.indexOf(suffix) === 0;\r\n };\r\n /**\r\n * Decodes a buffer into a string\r\n * @param buffer The buffer to decode\r\n * @returns The decoded string\r\n */\r\n StringTools.Decode = function (buffer) {\r\n if (typeof TextDecoder !== \"undefined\") {\r\n return new TextDecoder().decode(buffer);\r\n }\r\n var result = \"\";\r\n for (var i = 0; i < buffer.byteLength; i++) {\r\n result += String.fromCharCode(buffer[i]);\r\n }\r\n return result;\r\n };\r\n /**\r\n * Encode a buffer to a base64 string\r\n * @param buffer defines the buffer to encode\r\n * @returns the encoded string\r\n */\r\n StringTools.EncodeArrayBufferToBase64 = function (buffer) {\r\n var keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\r\n var output = \"\";\r\n var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\r\n var i = 0;\r\n var bytes = ArrayBuffer.isView(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) : new Uint8Array(buffer);\r\n while (i < bytes.length) {\r\n chr1 = bytes[i++];\r\n chr2 = i < bytes.length ? bytes[i++] : Number.NaN;\r\n chr3 = i < bytes.length ? bytes[i++] : Number.NaN;\r\n enc1 = chr1 >> 2;\r\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\r\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\r\n enc4 = chr3 & 63;\r\n if (isNaN(chr2)) {\r\n enc3 = enc4 = 64;\r\n }\r\n else if (isNaN(chr3)) {\r\n enc4 = 64;\r\n }\r\n output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +\r\n keyStr.charAt(enc3) + keyStr.charAt(enc4);\r\n }\r\n return output;\r\n };\r\n return StringTools;\r\n}());\r\nexport { StringTools };\r\n//# sourceMappingURL=stringTools.js.map","function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport toArray from \"rc-util/es/Children/toArray\";\nimport warning from \"rc-util/es/warning\";\nimport { getPosition, isTreeNode } from '../util';\nexport function getKey(key, pos) {\n if (key !== null && key !== undefined) {\n return key;\n }\n\n return pos;\n}\n/**\n * Warning if TreeNode do not provides key\n */\n\nexport function warningWithoutKey() {\n var treeData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var keys = new Map();\n\n function dig(list) {\n var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n (list || []).forEach(function (treeNode) {\n var key = treeNode.key,\n children = treeNode.children;\n warning(key !== null && key !== undefined, \"Tree node must have a certain key: [\".concat(path).concat(key, \"]\"));\n var recordKey = String(key);\n warning(!keys.has(recordKey) || key === null || key === undefined, \"Same 'key' exist in the Tree: \".concat(recordKey));\n keys.set(recordKey, true);\n dig(children, \"\".concat(path).concat(recordKey, \" > \"));\n });\n }\n\n dig(treeData);\n}\n/**\n * Convert `children` of Tree into `treeData` structure.\n */\n\nexport function convertTreeToData(rootNodes) {\n function dig(node) {\n var treeNodes = toArray(node);\n return treeNodes.map(function (treeNode) {\n // Filter invalidate node\n if (!isTreeNode(treeNode)) {\n warning(!treeNode, 'Tree/TreeNode can only accept TreeNode as children.');\n return null;\n }\n\n var key = treeNode.key;\n\n var _treeNode$props = treeNode.props,\n children = _treeNode$props.children,\n rest = _objectWithoutProperties(_treeNode$props, [\"children\"]);\n\n var dataNode = _objectSpread({\n key: key\n }, rest);\n\n var parsedChildren = dig(children);\n\n if (parsedChildren.length) {\n dataNode.children = parsedChildren;\n }\n\n return dataNode;\n }).filter(function (dataNode) {\n return dataNode;\n });\n }\n\n return dig(rootNodes);\n}\n/**\n * Flat nest tree data into flatten list. This is used for virtual list render.\n * @param treeNodeList Origin data node list\n * @param expandedKeys\n * need expanded keys, provides `true` means all expanded (used in `rc-tree-select`).\n */\n\nexport function flattenTreeData() {\n var treeNodeList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var expandedKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var expandedKeySet = new Set(expandedKeys === true ? [] : expandedKeys);\n var flattenList = [];\n\n function dig(list) {\n var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n return list.map(function (treeNode, index) {\n var pos = getPosition(parent ? parent.pos : '0', index);\n var mergedKey = getKey(treeNode.key, pos); // Add FlattenDataNode into list\n\n var flattenNode = _objectSpread({}, treeNode, {\n parent: parent,\n pos: pos,\n children: null,\n data: treeNode,\n isStart: [].concat(_toConsumableArray(parent ? parent.isStart : []), [index === 0]),\n isEnd: [].concat(_toConsumableArray(parent ? parent.isEnd : []), [index === list.length - 1])\n });\n\n flattenList.push(flattenNode); // Loop treeNode children\n\n if (expandedKeys === true || expandedKeySet.has(mergedKey)) {\n flattenNode.children = dig(treeNode.children || [], flattenNode);\n } else {\n flattenNode.children = [];\n }\n\n return flattenNode;\n });\n }\n\n dig(treeNodeList);\n return flattenList;\n}\n/**\n * Traverse all the data by `treeData`.\n * Please not use it out of the `rc-tree` since we may refactor this code.\n */\n\nexport function traverseDataNodes(dataNodes, callback) {\n function processNode(node, index, parent) {\n var children = node ? node.children : dataNodes;\n var pos = node ? getPosition(parent.pos, index) : '0'; // Process node if is not root\n\n if (node) {\n var data = {\n node: node,\n index: index,\n pos: pos,\n key: node.key !== null ? node.key : pos,\n parentPos: parent.node ? parent.pos : null,\n level: parent.level + 1\n };\n callback(data);\n } // Process children node\n\n\n if (children) {\n children.forEach(function (subNode, subIndex) {\n processNode(subNode, subIndex, {\n node: node,\n pos: pos,\n level: parent ? parent.level + 1 : -1\n });\n });\n }\n }\n\n processNode(null);\n}\n/**\n * Convert `treeData` into entity records.\n */\n\nexport function convertDataToEntities(dataNodes) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n initWrapper = _ref.initWrapper,\n processEntity = _ref.processEntity,\n onProcessFinished = _ref.onProcessFinished;\n\n var posEntities = {};\n var keyEntities = {};\n var wrapper = {\n posEntities: posEntities,\n keyEntities: keyEntities\n };\n\n if (initWrapper) {\n wrapper = initWrapper(wrapper) || wrapper;\n }\n\n traverseDataNodes(dataNodes, function (item) {\n var node = item.node,\n index = item.index,\n pos = item.pos,\n key = item.key,\n parentPos = item.parentPos,\n level = item.level;\n var entity = {\n node: node,\n index: index,\n key: key,\n pos: pos,\n level: level\n };\n var mergedKey = getKey(key, pos);\n posEntities[pos] = entity;\n keyEntities[mergedKey] = entity; // Fill children\n\n entity.parent = posEntities[parentPos];\n\n if (entity.parent) {\n entity.parent.children = entity.parent.children || [];\n entity.parent.children.push(entity);\n }\n\n if (processEntity) {\n processEntity(entity, wrapper);\n }\n });\n\n if (onProcessFinished) {\n onProcessFinished(wrapper);\n }\n\n return wrapper;\n}\n/**\n * Get TreeNode props with Tree props.\n */\n\nexport function getTreeNodeProps(key, _ref2) {\n var expandedKeys = _ref2.expandedKeys,\n selectedKeys = _ref2.selectedKeys,\n loadedKeys = _ref2.loadedKeys,\n loadingKeys = _ref2.loadingKeys,\n checkedKeys = _ref2.checkedKeys,\n halfCheckedKeys = _ref2.halfCheckedKeys,\n dragOverNodeKey = _ref2.dragOverNodeKey,\n dropPosition = _ref2.dropPosition,\n keyEntities = _ref2.keyEntities;\n var entity = keyEntities[key];\n var treeNodeProps = {\n eventKey: key,\n expanded: expandedKeys.indexOf(key) !== -1,\n selected: selectedKeys.indexOf(key) !== -1,\n loaded: loadedKeys.indexOf(key) !== -1,\n loading: loadingKeys.indexOf(key) !== -1,\n checked: checkedKeys.indexOf(key) !== -1,\n halfChecked: halfCheckedKeys.indexOf(key) !== -1,\n pos: String(entity ? entity.pos : ''),\n // [Legacy] Drag props\n dragOver: dragOverNodeKey === key && dropPosition === 0,\n dragOverGapTop: dragOverNodeKey === key && dropPosition === -1,\n dragOverGapBottom: dragOverNodeKey === key && dropPosition === 1\n };\n return treeNodeProps;\n}\nexport function convertNodePropsToEventData(props) {\n var data = props.data,\n expanded = props.expanded,\n selected = props.selected,\n checked = props.checked,\n loaded = props.loaded,\n loading = props.loading,\n halfChecked = props.halfChecked,\n dragOver = props.dragOver,\n dragOverGapTop = props.dragOverGapTop,\n dragOverGapBottom = props.dragOverGapBottom,\n pos = props.pos,\n active = props.active;\n\n var eventData = _objectSpread({}, data, {\n expanded: expanded,\n selected: selected,\n checked: checked,\n loaded: loaded,\n loading: loading,\n halfChecked: halfChecked,\n dragOver: dragOver,\n dragOverGapTop: dragOverGapTop,\n dragOverGapBottom: dragOverGapBottom,\n pos: pos,\n active: active\n });\n\n if (!('props' in eventData)) {\n Object.defineProperty(eventData, 'props', {\n get: function get() {\n warning(false, 'Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`.');\n return props;\n }\n });\n }\n\n return eventData;\n}","/**\r\n * Sets of helpers dealing with the DOM and some of the recurrent functions needed in\r\n * Babylon.js\r\n */\r\nvar DomManagement = /** @class */ (function () {\r\n function DomManagement() {\r\n }\r\n /**\r\n * Checks if the window object exists\r\n * @returns true if the window object exists\r\n */\r\n DomManagement.IsWindowObjectExist = function () {\r\n return (typeof window) !== \"undefined\";\r\n };\r\n /**\r\n * Checks if the navigator object exists\r\n * @returns true if the navigator object exists\r\n */\r\n DomManagement.IsNavigatorAvailable = function () {\r\n return (typeof navigator) !== \"undefined\";\r\n };\r\n /**\r\n * Extracts text content from a DOM element hierarchy\r\n * @param element defines the root element\r\n * @returns a string\r\n */\r\n DomManagement.GetDOMTextContent = function (element) {\r\n var result = \"\";\r\n var child = element.firstChild;\r\n while (child) {\r\n if (child.nodeType === 3) {\r\n result += child.textContent;\r\n }\r\n child = (child.nextSibling);\r\n }\r\n return result;\r\n };\r\n return DomManagement;\r\n}());\r\nexport { DomManagement };\r\n//# sourceMappingURL=domManagement.js.map","/* eslint-disable no-console */\nvar warned = {};\nexport function warning(valid, message) {\n // Support uglify\n if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {\n console.error(\"Warning: \".concat(message));\n }\n}\nexport function note(valid, message) {\n // Support uglify\n if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {\n console.warn(\"Note: \".concat(message));\n }\n}\nexport function resetWarned() {\n warned = {};\n}\nexport function call(method, valid, message) {\n if (!valid && !warned[message]) {\n method(false, message);\n warned[message] = true;\n }\n}\nexport function warningOnce(valid, message) {\n call(warning, valid, message);\n}\nexport function noteOnce(valid, message) {\n call(note, valid, message);\n}\nexport default warningOnce;\n/* eslint-enable */","/**\n * @ignore\n * some key-codes definition and utils from closure-library\n * @author yiminghe@gmail.com\n */\nvar KeyCode = {\n /**\n * MAC_ENTER\n */\n MAC_ENTER: 3,\n\n /**\n * BACKSPACE\n */\n BACKSPACE: 8,\n\n /**\n * TAB\n */\n TAB: 9,\n\n /**\n * NUMLOCK on FF/Safari Mac\n */\n NUM_CENTER: 12,\n\n /**\n * ENTER\n */\n ENTER: 13,\n\n /**\n * SHIFT\n */\n SHIFT: 16,\n\n /**\n * CTRL\n */\n CTRL: 17,\n\n /**\n * ALT\n */\n ALT: 18,\n\n /**\n * PAUSE\n */\n PAUSE: 19,\n\n /**\n * CAPS_LOCK\n */\n CAPS_LOCK: 20,\n\n /**\n * ESC\n */\n ESC: 27,\n\n /**\n * SPACE\n */\n SPACE: 32,\n\n /**\n * PAGE_UP\n */\n PAGE_UP: 33,\n\n /**\n * PAGE_DOWN\n */\n PAGE_DOWN: 34,\n\n /**\n * END\n */\n END: 35,\n\n /**\n * HOME\n */\n HOME: 36,\n\n /**\n * LEFT\n */\n LEFT: 37,\n\n /**\n * UP\n */\n UP: 38,\n\n /**\n * RIGHT\n */\n RIGHT: 39,\n\n /**\n * DOWN\n */\n DOWN: 40,\n\n /**\n * PRINT_SCREEN\n */\n PRINT_SCREEN: 44,\n\n /**\n * INSERT\n */\n INSERT: 45,\n\n /**\n * DELETE\n */\n DELETE: 46,\n\n /**\n * ZERO\n */\n ZERO: 48,\n\n /**\n * ONE\n */\n ONE: 49,\n\n /**\n * TWO\n */\n TWO: 50,\n\n /**\n * THREE\n */\n THREE: 51,\n\n /**\n * FOUR\n */\n FOUR: 52,\n\n /**\n * FIVE\n */\n FIVE: 53,\n\n /**\n * SIX\n */\n SIX: 54,\n\n /**\n * SEVEN\n */\n SEVEN: 55,\n\n /**\n * EIGHT\n */\n EIGHT: 56,\n\n /**\n * NINE\n */\n NINE: 57,\n\n /**\n * QUESTION_MARK\n */\n QUESTION_MARK: 63,\n\n /**\n * A\n */\n A: 65,\n\n /**\n * B\n */\n B: 66,\n\n /**\n * C\n */\n C: 67,\n\n /**\n * D\n */\n D: 68,\n\n /**\n * E\n */\n E: 69,\n\n /**\n * F\n */\n F: 70,\n\n /**\n * G\n */\n G: 71,\n\n /**\n * H\n */\n H: 72,\n\n /**\n * I\n */\n I: 73,\n\n /**\n * J\n */\n J: 74,\n\n /**\n * K\n */\n K: 75,\n\n /**\n * L\n */\n L: 76,\n\n /**\n * M\n */\n M: 77,\n\n /**\n * N\n */\n N: 78,\n\n /**\n * O\n */\n O: 79,\n\n /**\n * P\n */\n P: 80,\n\n /**\n * Q\n */\n Q: 81,\n\n /**\n * R\n */\n R: 82,\n\n /**\n * S\n */\n S: 83,\n\n /**\n * T\n */\n T: 84,\n\n /**\n * U\n */\n U: 85,\n\n /**\n * V\n */\n V: 86,\n\n /**\n * W\n */\n W: 87,\n\n /**\n * X\n */\n X: 88,\n\n /**\n * Y\n */\n Y: 89,\n\n /**\n * Z\n */\n Z: 90,\n\n /**\n * META\n */\n META: 91,\n\n /**\n * WIN_KEY_RIGHT\n */\n WIN_KEY_RIGHT: 92,\n\n /**\n * CONTEXT_MENU\n */\n CONTEXT_MENU: 93,\n\n /**\n * NUM_ZERO\n */\n NUM_ZERO: 96,\n\n /**\n * NUM_ONE\n */\n NUM_ONE: 97,\n\n /**\n * NUM_TWO\n */\n NUM_TWO: 98,\n\n /**\n * NUM_THREE\n */\n NUM_THREE: 99,\n\n /**\n * NUM_FOUR\n */\n NUM_FOUR: 100,\n\n /**\n * NUM_FIVE\n */\n NUM_FIVE: 101,\n\n /**\n * NUM_SIX\n */\n NUM_SIX: 102,\n\n /**\n * NUM_SEVEN\n */\n NUM_SEVEN: 103,\n\n /**\n * NUM_EIGHT\n */\n NUM_EIGHT: 104,\n\n /**\n * NUM_NINE\n */\n NUM_NINE: 105,\n\n /**\n * NUM_MULTIPLY\n */\n NUM_MULTIPLY: 106,\n\n /**\n * NUM_PLUS\n */\n NUM_PLUS: 107,\n\n /**\n * NUM_MINUS\n */\n NUM_MINUS: 109,\n\n /**\n * NUM_PERIOD\n */\n NUM_PERIOD: 110,\n\n /**\n * NUM_DIVISION\n */\n NUM_DIVISION: 111,\n\n /**\n * F1\n */\n F1: 112,\n\n /**\n * F2\n */\n F2: 113,\n\n /**\n * F3\n */\n F3: 114,\n\n /**\n * F4\n */\n F4: 115,\n\n /**\n * F5\n */\n F5: 116,\n\n /**\n * F6\n */\n F6: 117,\n\n /**\n * F7\n */\n F7: 118,\n\n /**\n * F8\n */\n F8: 119,\n\n /**\n * F9\n */\n F9: 120,\n\n /**\n * F10\n */\n F10: 121,\n\n /**\n * F11\n */\n F11: 122,\n\n /**\n * F12\n */\n F12: 123,\n\n /**\n * NUMLOCK\n */\n NUMLOCK: 144,\n\n /**\n * SEMICOLON\n */\n SEMICOLON: 186,\n\n /**\n * DASH\n */\n DASH: 189,\n\n /**\n * EQUALS\n */\n EQUALS: 187,\n\n /**\n * COMMA\n */\n COMMA: 188,\n\n /**\n * PERIOD\n */\n PERIOD: 190,\n\n /**\n * SLASH\n */\n SLASH: 191,\n\n /**\n * APOSTROPHE\n */\n APOSTROPHE: 192,\n\n /**\n * SINGLE_QUOTE\n */\n SINGLE_QUOTE: 222,\n\n /**\n * OPEN_SQUARE_BRACKET\n */\n OPEN_SQUARE_BRACKET: 219,\n\n /**\n * BACKSLASH\n */\n BACKSLASH: 220,\n\n /**\n * CLOSE_SQUARE_BRACKET\n */\n CLOSE_SQUARE_BRACKET: 221,\n\n /**\n * WIN_KEY\n */\n WIN_KEY: 224,\n\n /**\n * MAC_FF_META\n */\n MAC_FF_META: 224,\n\n /**\n * WIN_IME\n */\n WIN_IME: 229,\n // ======================== Function ========================\n\n /**\n * whether text and modified key is entered at the same time.\n */\n isTextModifyingKeyEvent: function isTextModifyingKeyEvent(e) {\n var keyCode = e.keyCode;\n\n if (e.altKey && !e.ctrlKey || e.metaKey || // Function keys don't generate text\n keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) {\n return false;\n } // The following keys are quite harmless, even in combination with\n // CTRL, ALT or SHIFT.\n\n\n switch (keyCode) {\n case KeyCode.ALT:\n case KeyCode.CAPS_LOCK:\n case KeyCode.CONTEXT_MENU:\n case KeyCode.CTRL:\n case KeyCode.DOWN:\n case KeyCode.END:\n case KeyCode.ESC:\n case KeyCode.HOME:\n case KeyCode.INSERT:\n case KeyCode.LEFT:\n case KeyCode.MAC_FF_META:\n case KeyCode.META:\n case KeyCode.NUMLOCK:\n case KeyCode.NUM_CENTER:\n case KeyCode.PAGE_DOWN:\n case KeyCode.PAGE_UP:\n case KeyCode.PAUSE:\n case KeyCode.PRINT_SCREEN:\n case KeyCode.RIGHT:\n case KeyCode.SHIFT:\n case KeyCode.UP:\n case KeyCode.WIN_KEY:\n case KeyCode.WIN_KEY_RIGHT:\n return false;\n\n default:\n return true;\n }\n },\n\n /**\n * whether character is entered.\n */\n isCharacterKey: function isCharacterKey(keyCode) {\n if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) {\n return true;\n }\n\n if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) {\n return true;\n }\n\n if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) {\n return true;\n } // Safari sends zero key code for non-latin characters.\n\n\n if (window.navigator.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) {\n return true;\n }\n\n switch (keyCode) {\n case KeyCode.SPACE:\n case KeyCode.QUESTION_MARK:\n case KeyCode.NUM_PLUS:\n case KeyCode.NUM_MINUS:\n case KeyCode.NUM_PERIOD:\n case KeyCode.NUM_DIVISION:\n case KeyCode.SEMICOLON:\n case KeyCode.DASH:\n case KeyCode.EQUALS:\n case KeyCode.COMMA:\n case KeyCode.PERIOD:\n case KeyCode.SLASH:\n case KeyCode.APOSTROPHE:\n case KeyCode.SINGLE_QUOTE:\n case KeyCode.OPEN_SQUARE_BRACKET:\n case KeyCode.BACKSLASH:\n case KeyCode.CLOSE_SQUARE_BRACKET:\n return true;\n\n default:\n return false;\n }\n }\n};\nexport default KeyCode;","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/**\n * Legacy code. Should avoid to use if you are new to import these code.\n */\nimport React from 'react';\nimport warning from \"rc-util/es/warning\";\nimport TreeNode from './TreeNode';\nvar DRAG_SIDE_RANGE = 0.25;\nvar DRAG_MIN_GAP = 2;\nexport function arrDel(list, value) {\n var clone = list.slice();\n var index = clone.indexOf(value);\n\n if (index >= 0) {\n clone.splice(index, 1);\n }\n\n return clone;\n}\nexport function arrAdd(list, value) {\n var clone = list.slice();\n\n if (clone.indexOf(value) === -1) {\n clone.push(value);\n }\n\n return clone;\n}\nexport function posToArr(pos) {\n return pos.split('-');\n}\nexport function getPosition(level, index) {\n return \"\".concat(level, \"-\").concat(index);\n}\nexport function isTreeNode(node) {\n return node && node.type && node.type.isTreeNode;\n}\nexport function getDragNodesKeys(dragNodeKey, keyEntities) {\n var dragNodesKeys = [dragNodeKey];\n var entity = keyEntities[dragNodeKey];\n\n function dig() {\n var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n list.forEach(function (_ref) {\n var key = _ref.key,\n children = _ref.children;\n dragNodesKeys.push(key);\n dig(children);\n });\n }\n\n dig(entity.children);\n return dragNodesKeys;\n} // Only used when drag, not affect SSR.\n\nexport function calcDropPosition(event, treeNode) {\n var clientY = event.clientY;\n\n var _treeNode$selectHandl = treeNode.selectHandle.getBoundingClientRect(),\n top = _treeNode$selectHandl.top,\n bottom = _treeNode$selectHandl.bottom,\n height = _treeNode$selectHandl.height;\n\n var des = Math.max(height * DRAG_SIDE_RANGE, DRAG_MIN_GAP);\n\n if (clientY <= top + des) {\n return -1;\n }\n\n if (clientY >= bottom - des) {\n return 1;\n }\n\n return 0;\n}\n/**\n * Return selectedKeys according with multiple prop\n * @param selectedKeys\n * @param props\n * @returns [string]\n */\n\nexport function calcSelectedKeys(selectedKeys, props) {\n if (!selectedKeys) return undefined;\n var multiple = props.multiple;\n\n if (multiple) {\n return selectedKeys.slice();\n }\n\n if (selectedKeys.length) {\n return [selectedKeys[0]];\n }\n\n return selectedKeys;\n}\n\nvar internalProcessProps = function internalProcessProps(props) {\n return props;\n};\n\nexport function convertDataToTree(treeData, processor) {\n if (!treeData) return [];\n\n var _ref2 = processor || {},\n _ref2$processProps = _ref2.processProps,\n processProps = _ref2$processProps === void 0 ? internalProcessProps : _ref2$processProps;\n\n var list = Array.isArray(treeData) ? treeData : [treeData];\n return list.map(function (_ref3) {\n var children = _ref3.children,\n props = _objectWithoutProperties(_ref3, [\"children\"]);\n\n var childrenNodes = convertDataToTree(children, processor);\n return React.createElement(TreeNode, Object.assign({}, processProps(props)), childrenNodes);\n });\n}\n/**\n * Parse `checkedKeys` to { checkedKeys, halfCheckedKeys } style\n */\n\nexport function parseCheckedKeys(keys) {\n if (!keys) {\n return null;\n } // Convert keys to object format\n\n\n var keyProps;\n\n if (Array.isArray(keys)) {\n // [Legacy] Follow the api doc\n keyProps = {\n checkedKeys: keys,\n halfCheckedKeys: undefined\n };\n } else if (_typeof(keys) === 'object') {\n keyProps = {\n checkedKeys: keys.checked || undefined,\n halfCheckedKeys: keys.halfChecked || undefined\n };\n } else {\n warning(false, '`checkedKeys` is not an array or an object');\n return null;\n }\n\n return keyProps;\n}\n/**\n * If user use `autoExpandParent` we should get the list of parent node\n * @param keyList\n * @param keyEntities\n */\n\nexport function conductExpandParent(keyList, keyEntities) {\n var expandedKeys = {};\n\n function conductUp(key) {\n if (expandedKeys[key]) return;\n var entity = keyEntities[key];\n if (!entity) return;\n expandedKeys[key] = true;\n var parent = entity.parent,\n node = entity.node;\n if (node.disabled) return;\n\n if (parent) {\n conductUp(parent.key);\n }\n }\n\n (keyList || []).forEach(function (key) {\n conductUp(key);\n });\n return Object.keys(expandedKeys);\n}\n/**\n * Returns only the data- and aria- key/value pairs\n */\n\nexport function getDataAndAria(props) {\n var omitProps = {};\n Object.keys(props).forEach(function (key) {\n if (key.startsWith('data-') || key.startsWith('aria-')) {\n omitProps[key] = props[key];\n }\n });\n return omitProps;\n}","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","'use strict';\n\nfunction checkDCE() {\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\n if (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' ||\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function'\n ) {\n return;\n }\n if (process.env.NODE_ENV !== 'production') {\n // This branch is unreachable because this function is only called\n // in production, but the condition is true only in development.\n // Therefore if the branch is still here, dead code elimination wasn't\n // properly applied.\n // Don't change the message. React DevTools relies on it. Also make sure\n // this message doesn't occur elsewhere in this function, or it will cause\n // a false positive.\n throw new Error('^_^');\n }\n try {\n // Verify that the code above has been dead code eliminated (DCE'd).\n __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);\n } catch (err) {\n // DevTools shouldn't crash React, no matter what.\n // We should still report in case we break this code.\n console.error(err);\n }\n}\n\nif (process.env.NODE_ENV === 'production') {\n // DCE check should happen before ReactDOM bundle executes so that\n // DevTools can report bad minification during injection.\n checkDCE();\n module.exports = require('./cjs/react-dom.production.min.js');\n} else {\n module.exports = require('./cjs/react-dom.development.js');\n}\n","import { PrecisionDate } from './precisionDate';\r\n/**\r\n * This class is used to track a performance counter which is number based.\r\n * The user has access to many properties which give statistics of different nature.\r\n *\r\n * The implementer can track two kinds of Performance Counter: time and count.\r\n * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.\r\n * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.\r\n */\r\nvar PerfCounter = /** @class */ (function () {\r\n /**\r\n * Creates a new counter\r\n */\r\n function PerfCounter() {\r\n this._startMonitoringTime = 0;\r\n this._min = 0;\r\n this._max = 0;\r\n this._average = 0;\r\n this._lastSecAverage = 0;\r\n this._current = 0;\r\n this._totalValueCount = 0;\r\n this._totalAccumulated = 0;\r\n this._lastSecAccumulated = 0;\r\n this._lastSecTime = 0;\r\n this._lastSecValueCount = 0;\r\n }\r\n Object.defineProperty(PerfCounter.prototype, \"min\", {\r\n /**\r\n * Returns the smallest value ever\r\n */\r\n get: function () {\r\n return this._min;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerfCounter.prototype, \"max\", {\r\n /**\r\n * Returns the biggest value ever\r\n */\r\n get: function () {\r\n return this._max;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerfCounter.prototype, \"average\", {\r\n /**\r\n * Returns the average value since the performance counter is running\r\n */\r\n get: function () {\r\n return this._average;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerfCounter.prototype, \"lastSecAverage\", {\r\n /**\r\n * Returns the average value of the last second the counter was monitored\r\n */\r\n get: function () {\r\n return this._lastSecAverage;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerfCounter.prototype, \"current\", {\r\n /**\r\n * Returns the current value\r\n */\r\n get: function () {\r\n return this._current;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerfCounter.prototype, \"total\", {\r\n /**\r\n * Gets the accumulated total\r\n */\r\n get: function () {\r\n return this._totalAccumulated;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerfCounter.prototype, \"count\", {\r\n /**\r\n * Gets the total value count\r\n */\r\n get: function () {\r\n return this._totalValueCount;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Call this method to start monitoring a new frame.\r\n * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.\r\n */\r\n PerfCounter.prototype.fetchNewFrame = function () {\r\n this._totalValueCount++;\r\n this._current = 0;\r\n this._lastSecValueCount++;\r\n };\r\n /**\r\n * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)\r\n * @param newCount the count value to add to the monitored count\r\n * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.\r\n */\r\n PerfCounter.prototype.addCount = function (newCount, fetchResult) {\r\n if (!PerfCounter.Enabled) {\r\n return;\r\n }\r\n this._current += newCount;\r\n if (fetchResult) {\r\n this._fetchResult();\r\n }\r\n };\r\n /**\r\n * Start monitoring this performance counter\r\n */\r\n PerfCounter.prototype.beginMonitoring = function () {\r\n if (!PerfCounter.Enabled) {\r\n return;\r\n }\r\n this._startMonitoringTime = PrecisionDate.Now;\r\n };\r\n /**\r\n * Compute the time lapsed since the previous beginMonitoring() call.\r\n * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter\r\n */\r\n PerfCounter.prototype.endMonitoring = function (newFrame) {\r\n if (newFrame === void 0) { newFrame = true; }\r\n if (!PerfCounter.Enabled) {\r\n return;\r\n }\r\n if (newFrame) {\r\n this.fetchNewFrame();\r\n }\r\n var currentTime = PrecisionDate.Now;\r\n this._current = currentTime - this._startMonitoringTime;\r\n if (newFrame) {\r\n this._fetchResult();\r\n }\r\n };\r\n PerfCounter.prototype._fetchResult = function () {\r\n this._totalAccumulated += this._current;\r\n this._lastSecAccumulated += this._current;\r\n // Min/Max update\r\n this._min = Math.min(this._min, this._current);\r\n this._max = Math.max(this._max, this._current);\r\n this._average = this._totalAccumulated / this._totalValueCount;\r\n // Reset last sec?\r\n var now = PrecisionDate.Now;\r\n if ((now - this._lastSecTime) > 1000) {\r\n this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;\r\n this._lastSecTime = now;\r\n this._lastSecAccumulated = 0;\r\n this._lastSecValueCount = 0;\r\n }\r\n };\r\n /**\r\n * Gets or sets a global boolean to turn on and off all the counters\r\n */\r\n PerfCounter.Enabled = true;\r\n return PerfCounter;\r\n}());\r\nexport { PerfCounter };\r\n//# sourceMappingURL=perfCounter.js.map","export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","import { DomManagement } from './domManagement';\r\n/**\r\n * Class containing a set of static utilities functions for precision date\r\n */\r\nvar PrecisionDate = /** @class */ (function () {\r\n function PrecisionDate() {\r\n }\r\n Object.defineProperty(PrecisionDate, \"Now\", {\r\n /**\r\n * Gets either window.performance.now() if supported or Date.now() else\r\n */\r\n get: function () {\r\n if (DomManagement.IsWindowObjectExist() && window.performance && window.performance.now) {\r\n return window.performance.now();\r\n }\r\n return Date.now();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return PrecisionDate;\r\n}());\r\nexport { PrecisionDate };\r\n//# sourceMappingURL=precisionDate.js.map","\"use strict\";\n\nexports.__esModule = true;\n\nvar _typeof2 = require(\"../helpers/typeof\");\n\nvar _typeof3 = _interopRequireDefault(_typeof2);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = function (self, call) {\n if (!self) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return call && ((typeof call === \"undefined\" ? \"undefined\" : (0, _typeof3.default)(call)) === \"object\" || typeof call === \"function\") ? call : self;\n};","\"use strict\";\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar React = _interopRequireWildcard(require(\"react\"));\n\nvar _classnames = _interopRequireDefault(require(\"classnames\"));\n\nvar _IconBase = _interopRequireDefault(require(\"./IconBase\"));\n\nvar _twoTonePrimaryColor = require(\"./twoTonePrimaryColor\");\n\nvar _utils = require(\"../utils\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _getRequireWildcardCache() { if (typeof WeakMap !== \"function\") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== \"object\" && typeof obj !== \"function\") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(n); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { if (typeof Symbol === \"undefined\" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n// Initial setting\n// should move it to antd main repo?\n(0, _twoTonePrimaryColor.setTwoToneColor)('#1890ff');\nvar Icon = React.forwardRef(function (props, ref) {\n var className = props.className,\n icon = props.icon,\n spin = props.spin,\n rotate = props.rotate,\n tabIndex = props.tabIndex,\n onClick = props.onClick,\n twoToneColor = props.twoToneColor,\n restProps = _objectWithoutProperties(props, [\"className\", \"icon\", \"spin\", \"rotate\", \"tabIndex\", \"onClick\", \"twoToneColor\"]);\n\n var classString = (0, _classnames.default)('anticon', _defineProperty({}, \"anticon-\".concat(icon.name), Boolean(icon.name)), className);\n var svgClassString = (0, _classnames.default)({\n 'anticon-spin': !!spin || icon.name === 'loading'\n });\n var iconTabIndex = tabIndex;\n\n if (iconTabIndex === undefined && onClick) {\n iconTabIndex = -1;\n }\n\n var svgStyle = rotate ? {\n msTransform: \"rotate(\".concat(rotate, \"deg)\"),\n transform: \"rotate(\".concat(rotate, \"deg)\")\n } : undefined;\n\n var _normalizeTwoToneColo = (0, _utils.normalizeTwoToneColors)(twoToneColor),\n _normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2),\n primaryColor = _normalizeTwoToneColo2[0],\n secondaryColor = _normalizeTwoToneColo2[1];\n\n return React.createElement(\"span\", Object.assign({\n role: \"img\",\n \"aria-label\": icon.name\n }, restProps, {\n ref: ref,\n tabIndex: iconTabIndex,\n onClick: onClick,\n className: classString\n }), React.createElement(_IconBase.default, {\n className: svgClassString,\n icon: icon,\n primaryColor: primaryColor,\n secondaryColor: secondaryColor,\n style: svgStyle\n }));\n});\nIcon.displayName = 'AntdIcon';\nIcon.getTwoToneColor = _twoTonePrimaryColor.getTwoToneColor;\nIcon.setTwoToneColor = _twoTonePrimaryColor.setTwoToneColor;\nvar _default = Icon;\nexports.default = _default;","export default function _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n\n return target;\n}","\"use strict\";\n\nexports.__esModule = true;\n\nexports.default = function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n};","\"use strict\";\n\nexports.__esModule = true;\n\nvar _setPrototypeOf = require(\"../core-js/object/set-prototype-of\");\n\nvar _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf);\n\nvar _create = require(\"../core-js/object/create\");\n\nvar _create2 = _interopRequireDefault(_create);\n\nvar _typeof2 = require(\"../helpers/typeof\");\n\nvar _typeof3 = _interopRequireDefault(_typeof2);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = function (subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function, not \" + (typeof superClass === \"undefined\" ? \"undefined\" : (0, _typeof3.default)(superClass)));\n }\n\n subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass;\n};","import addDOMEventListener from 'add-dom-event-listener';\nimport ReactDOM from 'react-dom';\nexport default function addEventListenerWrap(target, eventType, cb, option) {\n /* eslint camelcase: 2 */\n var callback = ReactDOM.unstable_batchedUpdates ? function run(e) {\n ReactDOM.unstable_batchedUpdates(cb, e);\n } : cb;\n return addDOMEventListener(target, eventType, callback, option);\n}","var core = module.exports = { version: '2.6.11' };\nif (typeof __e == 'number') __e = core; // eslint-disable-line no-undef\n","/**\r\n * Helper class used to generate a canvas to manipulate images\r\n */\r\nvar CanvasGenerator = /** @class */ (function () {\r\n function CanvasGenerator() {\r\n }\r\n /**\r\n * Create a new canvas (or offscreen canvas depending on the context)\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @return a new canvas or offscreen canvas\r\n */\r\n CanvasGenerator.CreateCanvas = function (width, height) {\r\n if (typeof document === \"undefined\") {\r\n return new OffscreenCanvas(width, height);\r\n }\r\n var canvas = document.createElement(\"canvas\");\r\n canvas.width = width;\r\n canvas.height = height;\r\n return canvas;\r\n };\r\n return CanvasGenerator;\r\n}());\r\nexport { CanvasGenerator };\r\n//# sourceMappingURL=canvasGenerator.js.map","function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(n); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && Symbol.iterator in Object(iter)) return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nexport function toArray(value) {\n if (Array.isArray(value)) {\n return value;\n }\n\n return value !== undefined ? [value] : [];\n}\n/**\n * Convert outer props value into internal value\n */\n\nexport function toInnerValue(value, _ref) {\n var labelInValue = _ref.labelInValue,\n combobox = _ref.combobox;\n\n if (value === undefined || value === '' && combobox) {\n return [];\n }\n\n var values = Array.isArray(value) ? value : [value];\n\n if (labelInValue) {\n return values.map(function (_ref2) {\n var key = _ref2.key,\n val = _ref2.value;\n return val !== undefined ? val : key;\n });\n }\n\n return values;\n}\n/**\n * Convert internal value into out event value\n */\n\nexport function toOuterValues(valueList, _ref3) {\n var optionLabelProp = _ref3.optionLabelProp,\n labelInValue = _ref3.labelInValue,\n prevValue = _ref3.prevValue,\n options = _ref3.options,\n getLabeledValue = _ref3.getLabeledValue;\n var values = valueList;\n\n if (labelInValue) {\n values = values.map(function (val) {\n return getLabeledValue(val, {\n options: options,\n prevValue: prevValue,\n labelInValue: labelInValue,\n optionLabelProp: optionLabelProp\n });\n });\n }\n\n return values;\n}\nexport function removeLastEnabledValue(measureValues, values) {\n var newValues = _toConsumableArray(values);\n\n var removeIndex;\n\n for (removeIndex = measureValues.length - 1; removeIndex >= 0; removeIndex -= 1) {\n if (!measureValues[removeIndex].disabled) {\n break;\n }\n }\n\n var removedValue = null;\n\n if (removeIndex !== -1) {\n removedValue = newValues[removeIndex];\n newValues.splice(removeIndex, 1);\n }\n\n return {\n values: newValues,\n removedValue: removedValue\n };\n}\nexport var isClient = typeof window !== 'undefined' && window.document && window.document.documentElement;\n/** Is client side and not jsdom */\n\nexport var isBrowserClient = process.env.NODE_ENV !== 'test' && isClient;\nvar uuid = 0;\n/** Get unique id for accessibility usage */\n\nexport function getUUID() {\n var retId; // Test never reach\n\n /* istanbul ignore if */\n\n if (isBrowserClient) {\n retId = uuid;\n uuid += 1;\n } else {\n retId = 'TEST_OR_SSR';\n }\n\n return retId;\n}","\"use strict\";\n\nexports.__esModule = true;\n\nvar _defineProperty = require(\"../core-js/object/define-property\");\n\nvar _defineProperty2 = _interopRequireDefault(_defineProperty);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n (0, _defineProperty2.default)(target, descriptor.key, descriptor);\n }\n }\n\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();","var now = require('performance-now')\n , root = typeof window === 'undefined' ? global : window\n , vendors = ['moz', 'webkit']\n , suffix = 'AnimationFrame'\n , raf = root['request' + suffix]\n , caf = root['cancel' + suffix] || root['cancelRequest' + suffix]\n\nfor(var i = 0; !raf && i < vendors.length; i++) {\n raf = root[vendors[i] + 'Request' + suffix]\n caf = root[vendors[i] + 'Cancel' + suffix]\n || root[vendors[i] + 'CancelRequest' + suffix]\n}\n\n// Some versions of FF have rAF but not cAF\nif(!raf || !caf) {\n var last = 0\n , id = 0\n , queue = []\n , frameDuration = 1000 / 60\n\n raf = function(callback) {\n if(queue.length === 0) {\n var _now = now()\n , next = Math.max(0, frameDuration - (_now - last))\n last = next + _now\n setTimeout(function() {\n var cp = queue.slice(0)\n // Clear queue here to prevent\n // callbacks from appending listeners\n // to the current frame's queue\n queue.length = 0\n for(var i = 0; i < cp.length; i++) {\n if(!cp[i].cancelled) {\n try{\n cp[i].callback(last)\n } catch(e) {\n setTimeout(function() { throw e }, 0)\n }\n }\n }\n }, Math.round(next))\n }\n queue.push({\n handle: ++id,\n callback: callback,\n cancelled: false\n })\n return id\n }\n\n caf = function(handle) {\n for(var i = 0; i < queue.length; i++) {\n if(queue[i].handle === handle) {\n queue[i].cancelled = true\n }\n }\n }\n}\n\nmodule.exports = function(fn) {\n // Wrap in a new function to prevent\n // `cancel` potentially being assigned\n // to the native rAF function\n return raf.call(root, fn)\n}\nmodule.exports.cancel = function() {\n caf.apply(root, arguments)\n}\nmodule.exports.polyfill = function(object) {\n if (!object) {\n object = root;\n }\n object.requestAnimationFrame = raf\n object.cancelAnimationFrame = caf\n}\n","var store = require('./_shared')('wks');\nvar uid = require('./_uid');\nvar Symbol = require('./_global').Symbol;\nvar USE_SYMBOL = typeof Symbol == 'function';\n\nvar $exports = module.exports = function (name) {\n return store[name] || (store[name] =\n USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));\n};\n\n$exports.store = store;\n","import { __extends } from \"tslib\";\r\nimport { DataBuffer } from '../dataBuffer';\r\n/** @hidden */\r\nvar WebGLDataBuffer = /** @class */ (function (_super) {\r\n __extends(WebGLDataBuffer, _super);\r\n function WebGLDataBuffer(resource) {\r\n var _this = _super.call(this) || this;\r\n _this._buffer = resource;\r\n return _this;\r\n }\r\n Object.defineProperty(WebGLDataBuffer.prototype, \"underlyingResource\", {\r\n get: function () {\r\n return this._buffer;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return WebGLDataBuffer;\r\n}(DataBuffer));\r\nexport { WebGLDataBuffer };\r\n//# sourceMappingURL=webGLDataBuffer.js.map","/**\r\n * Class used to store gfx data (like WebGLBuffer)\r\n */\r\nvar DataBuffer = /** @class */ (function () {\r\n function DataBuffer() {\r\n /**\r\n * Gets or sets the number of objects referencing this buffer\r\n */\r\n this.references = 0;\r\n /** Gets or sets the size of the underlying buffer */\r\n this.capacity = 0;\r\n /**\r\n * Gets or sets a boolean indicating if the buffer contains 32bits indices\r\n */\r\n this.is32Bits = false;\r\n }\r\n Object.defineProperty(DataBuffer.prototype, \"underlyingResource\", {\r\n /**\r\n * Gets the underlying buffer\r\n */\r\n get: function () {\r\n return null;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return DataBuffer;\r\n}());\r\nexport { DataBuffer };\r\n//# sourceMappingURL=dataBuffer.js.map","var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);\n\n// ================= Transition =================\n// Event wrapper. Copy from react source code\nfunction makePrefixMap(styleProp, eventName) {\n var prefixes = {};\n\n prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();\n prefixes['Webkit' + styleProp] = 'webkit' + eventName;\n prefixes['Moz' + styleProp] = 'moz' + eventName;\n prefixes['ms' + styleProp] = 'MS' + eventName;\n prefixes['O' + styleProp] = 'o' + eventName.toLowerCase();\n\n return prefixes;\n}\n\nexport function getVendorPrefixes(domSupport, win) {\n var prefixes = {\n animationend: makePrefixMap('Animation', 'AnimationEnd'),\n transitionend: makePrefixMap('Transition', 'TransitionEnd')\n };\n\n if (domSupport) {\n if (!('AnimationEvent' in win)) {\n delete prefixes.animationend.animation;\n }\n\n if (!('TransitionEvent' in win)) {\n delete prefixes.transitionend.transition;\n }\n }\n\n return prefixes;\n}\n\nvar vendorPrefixes = getVendorPrefixes(canUseDOM, typeof window !== 'undefined' ? window : {});\n\nvar style = {};\n\nif (canUseDOM) {\n style = document.createElement('div').style;\n}\n\nvar prefixedEventNames = {};\n\nexport function getVendorPrefixedEventName(eventName) {\n if (prefixedEventNames[eventName]) {\n return prefixedEventNames[eventName];\n }\n\n var prefixMap = vendorPrefixes[eventName];\n\n if (prefixMap) {\n var stylePropList = Object.keys(prefixMap);\n var len = stylePropList.length;\n for (var i = 0; i < len; i += 1) {\n var styleProp = stylePropList[i];\n if (Object.prototype.hasOwnProperty.call(prefixMap, styleProp) && styleProp in style) {\n prefixedEventNames[eventName] = prefixMap[styleProp];\n return prefixedEventNames[eventName];\n }\n }\n }\n\n return '';\n}\n\nexport var animationEndName = getVendorPrefixedEventName('animationend');\nexport var transitionEndName = getVendorPrefixedEventName('transitionend');\nexport var supportTransition = !!(animationEndName && transitionEndName);\n\nexport function getTransitionName(transitionName, transitionType) {\n if (!transitionName) return null;\n\n if (typeof transitionName === 'object') {\n var type = transitionType.replace(/-\\w/g, function (match) {\n return match[1].toUpperCase();\n });\n return transitionName[type];\n }\n\n return transitionName + '-' + transitionType;\n}","function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nimport * as React from 'react';\nimport classNames from 'classnames';\n\nvar Indent = function Indent(_ref) {\n var prefixCls = _ref.prefixCls,\n level = _ref.level,\n isStart = _ref.isStart,\n isEnd = _ref.isEnd;\n\n if (!level) {\n return null;\n }\n\n var baseClassName = \"\".concat(prefixCls, \"-indent-unit\");\n var list = [];\n\n for (var i = 0; i < level; i += 1) {\n var _classNames;\n\n list.push(React.createElement(\"span\", {\n key: i,\n className: classNames(baseClassName, (_classNames = {}, _defineProperty(_classNames, \"\".concat(baseClassName, \"-start\"), isStart[i + 1]), _defineProperty(_classNames, \"\".concat(baseClassName, \"-end\"), isEnd[i + 1]), _classNames))\n }));\n }\n\n return React.createElement(\"span\", {\n \"aria-hidden\": \"true\",\n className: \"\".concat(prefixCls, \"-indent\")\n }, list);\n};\n\nexport default Indent;","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames'; // @ts-ignore\n\nimport { polyfill } from 'react-lifecycles-compat';\nimport { TreeContext } from './contextTypes';\nimport { getDataAndAria } from './util';\nimport Indent from './Indent';\nimport { convertNodePropsToEventData } from './utils/treeUtil';\nvar ICON_OPEN = 'open';\nvar ICON_CLOSE = 'close';\nvar defaultTitle = '---';\n\nvar InternalTreeNode = /*#__PURE__*/function (_React$Component) {\n _inherits(InternalTreeNode, _React$Component);\n\n function InternalTreeNode() {\n var _this;\n\n _classCallCheck(this, InternalTreeNode);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(InternalTreeNode).apply(this, arguments));\n _this.state = {\n dragNodeHighlight: false\n };\n\n _this.onSelectorClick = function (e) {\n // Click trigger before select/check operation\n var onNodeClick = _this.props.context.onNodeClick;\n onNodeClick(e, convertNodePropsToEventData(_this.props));\n\n if (_this.isSelectable()) {\n _this.onSelect(e);\n } else {\n _this.onCheck(e);\n }\n };\n\n _this.onSelectorDoubleClick = function (e) {\n var onNodeDoubleClick = _this.props.context.onNodeDoubleClick;\n onNodeDoubleClick(e, convertNodePropsToEventData(_this.props));\n };\n\n _this.onSelect = function (e) {\n if (_this.isDisabled()) return;\n var onNodeSelect = _this.props.context.onNodeSelect;\n e.preventDefault();\n onNodeSelect(e, convertNodePropsToEventData(_this.props));\n };\n\n _this.onCheck = function (e) {\n if (_this.isDisabled()) return;\n var _this$props = _this.props,\n disableCheckbox = _this$props.disableCheckbox,\n checked = _this$props.checked;\n var onNodeCheck = _this.props.context.onNodeCheck;\n if (!_this.isCheckable() || disableCheckbox) return;\n e.preventDefault();\n var targetChecked = !checked;\n onNodeCheck(e, convertNodePropsToEventData(_this.props), targetChecked);\n };\n\n _this.onMouseEnter = function (e) {\n var onNodeMouseEnter = _this.props.context.onNodeMouseEnter;\n onNodeMouseEnter(e, convertNodePropsToEventData(_this.props));\n };\n\n _this.onMouseLeave = function (e) {\n var onNodeMouseLeave = _this.props.context.onNodeMouseLeave;\n onNodeMouseLeave(e, convertNodePropsToEventData(_this.props));\n };\n\n _this.onContextMenu = function (e) {\n var onNodeContextMenu = _this.props.context.onNodeContextMenu;\n onNodeContextMenu(e, convertNodePropsToEventData(_this.props));\n };\n\n _this.onDragStart = function (e) {\n var onNodeDragStart = _this.props.context.onNodeDragStart;\n e.stopPropagation();\n\n _this.setState({\n dragNodeHighlight: true\n });\n\n onNodeDragStart(e, _assertThisInitialized(_this));\n\n try {\n // ie throw error\n // firefox-need-it\n e.dataTransfer.setData('text/plain', '');\n } catch (error) {// empty\n }\n };\n\n _this.onDragEnter = function (e) {\n var onNodeDragEnter = _this.props.context.onNodeDragEnter;\n e.preventDefault();\n e.stopPropagation();\n onNodeDragEnter(e, _assertThisInitialized(_this));\n };\n\n _this.onDragOver = function (e) {\n var onNodeDragOver = _this.props.context.onNodeDragOver;\n e.preventDefault();\n e.stopPropagation();\n onNodeDragOver(e, _assertThisInitialized(_this));\n };\n\n _this.onDragLeave = function (e) {\n var onNodeDragLeave = _this.props.context.onNodeDragLeave;\n e.stopPropagation();\n onNodeDragLeave(e, _assertThisInitialized(_this));\n };\n\n _this.onDragEnd = function (e) {\n var onNodeDragEnd = _this.props.context.onNodeDragEnd;\n e.stopPropagation();\n\n _this.setState({\n dragNodeHighlight: false\n });\n\n onNodeDragEnd(e, _assertThisInitialized(_this));\n };\n\n _this.onDrop = function (e) {\n var onNodeDrop = _this.props.context.onNodeDrop;\n e.preventDefault();\n e.stopPropagation();\n\n _this.setState({\n dragNodeHighlight: false\n });\n\n onNodeDrop(e, _assertThisInitialized(_this));\n }; // Disabled item still can be switch\n\n\n _this.onExpand = function (e) {\n var onNodeExpand = _this.props.context.onNodeExpand;\n onNodeExpand(e, convertNodePropsToEventData(_this.props));\n }; // Drag usage\n\n\n _this.setSelectHandle = function (node) {\n _this.selectHandle = node;\n };\n\n _this.getNodeState = function () {\n var expanded = _this.props.expanded;\n\n if (_this.isLeaf()) {\n return null;\n }\n\n return expanded ? ICON_OPEN : ICON_CLOSE;\n };\n\n _this.hasChildren = function () {\n var eventKey = _this.props.eventKey;\n var keyEntities = _this.props.context.keyEntities;\n\n var _ref = keyEntities[eventKey] || {},\n children = _ref.children;\n\n return !!(children || []).length;\n };\n\n _this.isLeaf = function () {\n var _this$props2 = _this.props,\n isLeaf = _this$props2.isLeaf,\n loaded = _this$props2.loaded;\n var loadData = _this.props.context.loadData;\n\n var hasChildren = _this.hasChildren();\n\n if (isLeaf === false) {\n return false;\n }\n\n return isLeaf || !loadData && !hasChildren || loadData && loaded && !hasChildren;\n };\n\n _this.isDisabled = function () {\n var disabled = _this.props.disabled;\n var treeDisabled = _this.props.context.disabled;\n return !!(treeDisabled || disabled);\n };\n\n _this.isCheckable = function () {\n var checkable = _this.props.checkable;\n var treeCheckable = _this.props.context.checkable; // Return false if tree or treeNode is not checkable\n\n if (!treeCheckable || checkable === false) return false;\n return treeCheckable;\n }; // Load data to avoid default expanded tree without data\n\n\n _this.syncLoadData = function (props) {\n var expanded = props.expanded,\n loading = props.loading,\n loaded = props.loaded;\n var _this$props$context = _this.props.context,\n loadData = _this$props$context.loadData,\n onNodeLoad = _this$props$context.onNodeLoad;\n if (loading) return; // read from state to avoid loadData at same time\n\n if (loadData && expanded && !_this.isLeaf()) {\n // We needn't reload data when has children in sync logic\n // It's only needed in node expanded\n if (!_this.hasChildren() && !loaded) {\n onNodeLoad(convertNodePropsToEventData(_this.props));\n }\n }\n }; // Switcher\n\n\n _this.renderSwitcher = function () {\n var _this$props3 = _this.props,\n expanded = _this$props3.expanded,\n switcherIconFromProps = _this$props3.switcherIcon;\n var _this$props$context2 = _this.props.context,\n prefixCls = _this$props$context2.prefixCls,\n switcherIconFromCtx = _this$props$context2.switcherIcon;\n var switcherIcon = switcherIconFromProps || switcherIconFromCtx;\n\n if (_this.isLeaf()) {\n return React.createElement(\"span\", {\n className: classNames(\"\".concat(prefixCls, \"-switcher\"), \"\".concat(prefixCls, \"-switcher-noop\"))\n }, typeof switcherIcon === 'function' ? switcherIcon(_objectSpread({}, _this.props, {\n isLeaf: true\n })) : switcherIcon);\n }\n\n var switcherCls = classNames(\"\".concat(prefixCls, \"-switcher\"), \"\".concat(prefixCls, \"-switcher_\").concat(expanded ? ICON_OPEN : ICON_CLOSE));\n return React.createElement(\"span\", {\n onClick: _this.onExpand,\n className: switcherCls\n }, typeof switcherIcon === 'function' ? switcherIcon(_objectSpread({}, _this.props, {\n isLeaf: false\n })) : switcherIcon);\n }; // Checkbox\n\n\n _this.renderCheckbox = function () {\n var _this$props4 = _this.props,\n checked = _this$props4.checked,\n halfChecked = _this$props4.halfChecked,\n disableCheckbox = _this$props4.disableCheckbox;\n var prefixCls = _this.props.context.prefixCls;\n\n var disabled = _this.isDisabled();\n\n var checkable = _this.isCheckable();\n\n if (!checkable) return null; // [Legacy] Custom element should be separate with `checkable` in future\n\n var $custom = typeof checkable !== 'boolean' ? checkable : null;\n return React.createElement(\"span\", {\n className: classNames(\"\".concat(prefixCls, \"-checkbox\"), checked && \"\".concat(prefixCls, \"-checkbox-checked\"), !checked && halfChecked && \"\".concat(prefixCls, \"-checkbox-indeterminate\"), (disabled || disableCheckbox) && \"\".concat(prefixCls, \"-checkbox-disabled\")),\n onClick: _this.onCheck\n }, $custom);\n };\n\n _this.renderIcon = function () {\n var loading = _this.props.loading;\n var prefixCls = _this.props.context.prefixCls;\n return React.createElement(\"span\", {\n className: classNames(\"\".concat(prefixCls, \"-iconEle\"), \"\".concat(prefixCls, \"-icon__\").concat(_this.getNodeState() || 'docu'), loading && \"\".concat(prefixCls, \"-icon_loading\"))\n });\n }; // Icon + Title\n\n\n _this.renderSelector = function () {\n var dragNodeHighlight = _this.state.dragNodeHighlight;\n var _this$props5 = _this.props,\n title = _this$props5.title,\n selected = _this$props5.selected,\n icon = _this$props5.icon,\n loading = _this$props5.loading,\n data = _this$props5.data;\n var _this$props$context3 = _this.props.context,\n prefixCls = _this$props$context3.prefixCls,\n showIcon = _this$props$context3.showIcon,\n treeIcon = _this$props$context3.icon,\n draggable = _this$props$context3.draggable,\n loadData = _this$props$context3.loadData;\n\n var disabled = _this.isDisabled();\n\n var wrapClass = \"\".concat(prefixCls, \"-node-content-wrapper\"); // Icon - Still show loading icon when loading without showIcon\n\n var $icon;\n\n if (showIcon) {\n var currentIcon = icon || treeIcon;\n $icon = currentIcon ? React.createElement(\"span\", {\n className: classNames(\"\".concat(prefixCls, \"-iconEle\"), \"\".concat(prefixCls, \"-icon__customize\"))\n }, typeof currentIcon === 'function' ? currentIcon(_this.props) : currentIcon) : _this.renderIcon();\n } else if (loadData && loading) {\n $icon = _this.renderIcon();\n } // Title\n\n\n var $title = React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-title\")\n }, typeof title === 'function' ? title(data) : title);\n return React.createElement(\"span\", {\n ref: _this.setSelectHandle,\n title: typeof title === 'string' ? title : '',\n className: classNames(\"\".concat(wrapClass), \"\".concat(wrapClass, \"-\").concat(_this.getNodeState() || 'normal'), !disabled && (selected || dragNodeHighlight) && \"\".concat(prefixCls, \"-node-selected\"), !disabled && draggable && 'draggable'),\n draggable: !disabled && draggable || undefined,\n \"aria-grabbed\": !disabled && draggable || undefined,\n onMouseEnter: _this.onMouseEnter,\n onMouseLeave: _this.onMouseLeave,\n onContextMenu: _this.onContextMenu,\n onClick: _this.onSelectorClick,\n onDoubleClick: _this.onSelectorDoubleClick,\n onDragStart: draggable ? _this.onDragStart : undefined\n }, $icon, $title);\n };\n\n return _this;\n } // Isomorphic needn't load data in server side\n\n\n _createClass(InternalTreeNode, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.syncLoadData(this.props);\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.syncLoadData(this.props);\n }\n }, {\n key: \"isSelectable\",\n value: function isSelectable() {\n var selectable = this.props.selectable;\n var treeSelectable = this.props.context.selectable; // Ignore when selectable is undefined or null\n\n if (typeof selectable === 'boolean') {\n return selectable;\n }\n\n return treeSelectable;\n }\n }, {\n key: \"render\",\n value: function render() {\n var _classNames;\n\n var _this$props6 = this.props,\n eventKey = _this$props6.eventKey,\n className = _this$props6.className,\n style = _this$props6.style,\n dragOver = _this$props6.dragOver,\n dragOverGapTop = _this$props6.dragOverGapTop,\n dragOverGapBottom = _this$props6.dragOverGapBottom,\n isLeaf = _this$props6.isLeaf,\n isStart = _this$props6.isStart,\n isEnd = _this$props6.isEnd,\n expanded = _this$props6.expanded,\n selected = _this$props6.selected,\n checked = _this$props6.checked,\n halfChecked = _this$props6.halfChecked,\n loading = _this$props6.loading,\n domRef = _this$props6.domRef,\n active = _this$props6.active,\n onMouseMove = _this$props6.onMouseMove,\n otherProps = _objectWithoutProperties(_this$props6, [\"eventKey\", \"className\", \"style\", \"dragOver\", \"dragOverGapTop\", \"dragOverGapBottom\", \"isLeaf\", \"isStart\", \"isEnd\", \"expanded\", \"selected\", \"checked\", \"halfChecked\", \"loading\", \"domRef\", \"active\", \"onMouseMove\"]);\n\n var _this$props$context4 = this.props.context,\n prefixCls = _this$props$context4.prefixCls,\n filterTreeNode = _this$props$context4.filterTreeNode,\n draggable = _this$props$context4.draggable,\n keyEntities = _this$props$context4.keyEntities;\n var disabled = this.isDisabled();\n var dataOrAriaAttributeProps = getDataAndAria(otherProps);\n\n var _ref2 = keyEntities[eventKey] || {},\n level = _ref2.level;\n\n return React.createElement(\"div\", Object.assign({\n ref: domRef,\n className: classNames(className, \"\".concat(prefixCls, \"-treenode\"), (_classNames = {}, _defineProperty(_classNames, \"\".concat(prefixCls, \"-treenode-disabled\"), disabled), _defineProperty(_classNames, \"\".concat(prefixCls, \"-treenode-switcher-\").concat(expanded ? 'open' : 'close'), !isLeaf), _defineProperty(_classNames, \"\".concat(prefixCls, \"-treenode-checkbox-checked\"), checked), _defineProperty(_classNames, \"\".concat(prefixCls, \"-treenode-checkbox-indeterminate\"), halfChecked), _defineProperty(_classNames, \"\".concat(prefixCls, \"-treenode-selected\"), selected), _defineProperty(_classNames, \"\".concat(prefixCls, \"-treenode-loading\"), loading), _defineProperty(_classNames, \"\".concat(prefixCls, \"-treenode-active\"), active), _defineProperty(_classNames, 'drag-over', !disabled && dragOver), _defineProperty(_classNames, 'drag-over-gap-top', !disabled && dragOverGapTop), _defineProperty(_classNames, 'drag-over-gap-bottom', !disabled && dragOverGapBottom), _defineProperty(_classNames, 'filter-node', filterTreeNode && filterTreeNode(convertNodePropsToEventData(this.props))), _classNames)),\n style: style,\n onDragEnter: draggable ? this.onDragEnter : undefined,\n onDragOver: draggable ? this.onDragOver : undefined,\n onDragLeave: draggable ? this.onDragLeave : undefined,\n onDrop: draggable ? this.onDrop : undefined,\n onDragEnd: draggable ? this.onDragEnd : undefined,\n onMouseMove: onMouseMove\n }, dataOrAriaAttributeProps), React.createElement(Indent, {\n prefixCls: prefixCls,\n level: level,\n isStart: isStart,\n isEnd: isEnd\n }), this.renderSwitcher(), this.renderCheckbox(), this.renderSelector());\n }\n }]);\n\n return InternalTreeNode;\n}(React.Component);\n\nInternalTreeNode.propTypes = {\n prefixCls: PropTypes.string,\n className: PropTypes.string,\n style: PropTypes.object,\n onSelect: PropTypes.func,\n // By parent\n eventKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n expanded: PropTypes.bool,\n selected: PropTypes.bool,\n checked: PropTypes.bool,\n loaded: PropTypes.bool,\n loading: PropTypes.bool,\n halfChecked: PropTypes.bool,\n title: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n dragOver: PropTypes.bool,\n dragOverGapTop: PropTypes.bool,\n dragOverGapBottom: PropTypes.bool,\n pos: PropTypes.string,\n // By user\n isLeaf: PropTypes.bool,\n checkable: PropTypes.bool,\n selectable: PropTypes.bool,\n disabled: PropTypes.bool,\n disableCheckbox: PropTypes.bool,\n icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n switcherIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])\n};\npolyfill(InternalTreeNode);\n\nvar ContextTreeNode = function ContextTreeNode(props) {\n return React.createElement(TreeContext.Consumer, null, function (context) {\n return React.createElement(InternalTreeNode, Object.assign({}, props, {\n context: context\n }));\n });\n};\n\nContextTreeNode.displayName = 'TreeNode';\nContextTreeNode.defaultProps = {\n title: defaultTitle\n};\nContextTreeNode.isTreeNode = 1;\nexport { InternalTreeNode };\nexport default ContextTreeNode;","import React from 'react';\nimport { isFragment } from 'react-is';\nexport default function toArray(children) {\n var ret = [];\n React.Children.forEach(children, function (child) {\n if (child === undefined || child === null) {\n return;\n }\n\n if (Array.isArray(child)) {\n ret = ret.concat(toArray(child));\n } else if (isFragment(child) && child.props) {\n ret = ret.concat(toArray(child.props.children));\n } else {\n ret.push(child);\n }\n });\n return ret;\n}","\"use strict\";\n\nexports.__esModule = true;\n\nexports.default = function (obj, keys) {\n var target = {};\n\n for (var i in obj) {\n if (keys.indexOf(i) >= 0) continue;\n if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;\n target[i] = obj[i];\n }\n\n return target;\n};","import _defineProperty from 'babel-runtime/helpers/defineProperty';\nimport _extends from 'babel-runtime/helpers/extends';\nimport _classCallCheck from 'babel-runtime/helpers/classCallCheck';\nimport _createClass from 'babel-runtime/helpers/createClass';\nimport _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';\nimport _inherits from 'babel-runtime/helpers/inherits';\n/* eslint-disable react/default-props-match-prop-types, react/no-multi-comp */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { polyfill } from 'react-lifecycles-compat';\nimport findDOMNode from 'rc-util/es/Dom/findDOMNode';\nimport classNames from 'classnames';\nimport raf from 'raf';\nimport { getTransitionName, animationEndName, transitionEndName, supportTransition } from './util/motion';\n\nvar STATUS_NONE = 'none';\nvar STATUS_APPEAR = 'appear';\nvar STATUS_ENTER = 'enter';\nvar STATUS_LEAVE = 'leave';\n\nexport var MotionPropTypes = {\n eventProps: PropTypes.object, // Internal usage. Only pass by CSSMotionList\n visible: PropTypes.bool,\n children: PropTypes.func,\n motionName: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),\n motionAppear: PropTypes.bool,\n motionEnter: PropTypes.bool,\n motionLeave: PropTypes.bool,\n motionLeaveImmediately: PropTypes.bool, // Trigger leave motion immediately\n removeOnLeave: PropTypes.bool,\n leavedClassName: PropTypes.string,\n onAppearStart: PropTypes.func,\n onAppearActive: PropTypes.func,\n onAppearEnd: PropTypes.func,\n onEnterStart: PropTypes.func,\n onEnterActive: PropTypes.func,\n onEnterEnd: PropTypes.func,\n onLeaveStart: PropTypes.func,\n onLeaveActive: PropTypes.func,\n onLeaveEnd: PropTypes.func\n};\n\n/**\n * `transitionSupport` is used for none transition test case.\n * Default we use browser transition event support check.\n */\nexport function genCSSMotion(config) {\n var transitionSupport = config;\n var forwardRef = !!React.forwardRef;\n\n if (typeof config === 'object') {\n transitionSupport = config.transitionSupport;\n forwardRef = 'forwardRef' in config ? config.forwardRef : forwardRef;\n }\n\n function isSupportTransition(props) {\n return !!(props.motionName && transitionSupport);\n }\n\n var CSSMotion = function (_React$Component) {\n _inherits(CSSMotion, _React$Component);\n\n function CSSMotion() {\n _classCallCheck(this, CSSMotion);\n\n var _this = _possibleConstructorReturn(this, (CSSMotion.__proto__ || Object.getPrototypeOf(CSSMotion)).call(this));\n\n _this.onDomUpdate = function () {\n var _this$state = _this.state,\n status = _this$state.status,\n newStatus = _this$state.newStatus;\n var _this$props = _this.props,\n onAppearStart = _this$props.onAppearStart,\n onEnterStart = _this$props.onEnterStart,\n onLeaveStart = _this$props.onLeaveStart,\n onAppearActive = _this$props.onAppearActive,\n onEnterActive = _this$props.onEnterActive,\n onLeaveActive = _this$props.onLeaveActive,\n motionAppear = _this$props.motionAppear,\n motionEnter = _this$props.motionEnter,\n motionLeave = _this$props.motionLeave;\n\n\n if (!isSupportTransition(_this.props)) {\n return;\n }\n\n // Event injection\n var $ele = _this.getElement();\n if (_this.$cacheEle !== $ele) {\n _this.removeEventListener(_this.$cacheEle);\n _this.addEventListener($ele);\n _this.$cacheEle = $ele;\n }\n\n // Init status\n if (newStatus && status === STATUS_APPEAR && motionAppear) {\n _this.updateStatus(onAppearStart, null, null, function () {\n _this.updateActiveStatus(onAppearActive, STATUS_APPEAR);\n });\n } else if (newStatus && status === STATUS_ENTER && motionEnter) {\n _this.updateStatus(onEnterStart, null, null, function () {\n _this.updateActiveStatus(onEnterActive, STATUS_ENTER);\n });\n } else if (newStatus && status === STATUS_LEAVE && motionLeave) {\n _this.updateStatus(onLeaveStart, null, null, function () {\n _this.updateActiveStatus(onLeaveActive, STATUS_LEAVE);\n });\n }\n };\n\n _this.onMotionEnd = function (event) {\n var _this$state2 = _this.state,\n status = _this$state2.status,\n statusActive = _this$state2.statusActive;\n var _this$props2 = _this.props,\n onAppearEnd = _this$props2.onAppearEnd,\n onEnterEnd = _this$props2.onEnterEnd,\n onLeaveEnd = _this$props2.onLeaveEnd;\n\n if (status === STATUS_APPEAR && statusActive) {\n _this.updateStatus(onAppearEnd, { status: STATUS_NONE }, event);\n } else if (status === STATUS_ENTER && statusActive) {\n _this.updateStatus(onEnterEnd, { status: STATUS_NONE }, event);\n } else if (status === STATUS_LEAVE && statusActive) {\n _this.updateStatus(onLeaveEnd, { status: STATUS_NONE }, event);\n }\n };\n\n _this.setNodeRef = function (node) {\n var internalRef = _this.props.internalRef;\n\n _this.node = node;\n\n if (typeof internalRef === 'function') {\n internalRef(node);\n } else if (internalRef && 'current' in internalRef) {\n internalRef.current = node;\n }\n };\n\n _this.getElement = function () {\n return findDOMNode(_this.node || _this);\n };\n\n _this.addEventListener = function ($ele) {\n if (!$ele) return;\n\n $ele.addEventListener(transitionEndName, _this.onMotionEnd);\n $ele.addEventListener(animationEndName, _this.onMotionEnd);\n };\n\n _this.removeEventListener = function ($ele) {\n if (!$ele) return;\n\n $ele.removeEventListener(transitionEndName, _this.onMotionEnd);\n $ele.removeEventListener(animationEndName, _this.onMotionEnd);\n };\n\n _this.updateStatus = function (styleFunc, additionalState, event, callback) {\n var statusStyle = styleFunc ? styleFunc(_this.getElement(), event) : null;\n\n if (statusStyle === false || _this._destroyed) return;\n\n var nextStep = void 0;\n if (callback) {\n nextStep = function nextStep() {\n _this.nextFrame(callback);\n };\n }\n\n _this.setState(_extends({\n statusStyle: typeof statusStyle === 'object' ? statusStyle : null,\n newStatus: false\n }, additionalState), nextStep); // Trigger before next frame & after `componentDidMount`\n };\n\n _this.updateActiveStatus = function (styleFunc, currentStatus) {\n // `setState` use `postMessage` to trigger at the end of frame.\n // Let's use requestAnimationFrame to update new state in next frame.\n _this.nextFrame(function () {\n var status = _this.state.status;\n\n if (status !== currentStatus) return;\n\n _this.updateStatus(styleFunc, { statusActive: true });\n });\n };\n\n _this.nextFrame = function (func) {\n _this.cancelNextFrame();\n _this.raf = raf(func);\n };\n\n _this.cancelNextFrame = function () {\n if (_this.raf) {\n raf.cancel(_this.raf);\n _this.raf = null;\n }\n };\n\n _this.state = {\n status: STATUS_NONE,\n statusActive: false,\n newStatus: false,\n statusStyle: null\n };\n _this.$cacheEle = null;\n _this.node = null;\n _this.raf = null;\n return _this;\n }\n\n _createClass(CSSMotion, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n this.onDomUpdate();\n }\n }, {\n key: 'componentDidUpdate',\n value: function componentDidUpdate() {\n this.onDomUpdate();\n }\n }, {\n key: 'componentWillUnmount',\n value: function componentWillUnmount() {\n this._destroyed = true;\n this.removeEventListener(this.$cacheEle);\n this.cancelNextFrame();\n }\n }, {\n key: 'render',\n value: function render() {\n var _classNames;\n\n var _state = this.state,\n status = _state.status,\n statusActive = _state.statusActive,\n statusStyle = _state.statusStyle;\n var _props = this.props,\n children = _props.children,\n motionName = _props.motionName,\n visible = _props.visible,\n removeOnLeave = _props.removeOnLeave,\n leavedClassName = _props.leavedClassName,\n eventProps = _props.eventProps;\n\n\n if (!children) return null;\n\n if (status === STATUS_NONE || !isSupportTransition(this.props)) {\n if (visible) {\n return children(_extends({}, eventProps), this.setNodeRef);\n } else if (!removeOnLeave) {\n return children(_extends({}, eventProps, { className: leavedClassName }), this.setNodeRef);\n }\n\n return null;\n }\n\n return children(_extends({}, eventProps, {\n className: classNames((_classNames = {}, _defineProperty(_classNames, getTransitionName(motionName, status), status !== STATUS_NONE), _defineProperty(_classNames, getTransitionName(motionName, status + '-active'), status !== STATUS_NONE && statusActive), _defineProperty(_classNames, motionName, typeof motionName === 'string'), _classNames)),\n style: statusStyle\n }), this.setNodeRef);\n }\n }], [{\n key: 'getDerivedStateFromProps',\n value: function getDerivedStateFromProps(props, _ref) {\n var prevProps = _ref.prevProps,\n prevStatus = _ref.status;\n\n if (!isSupportTransition(props)) return {};\n\n var visible = props.visible,\n motionAppear = props.motionAppear,\n motionEnter = props.motionEnter,\n motionLeave = props.motionLeave,\n motionLeaveImmediately = props.motionLeaveImmediately;\n\n var newState = {\n prevProps: props\n };\n\n // Clean up status if prop set to false\n if (prevStatus === STATUS_APPEAR && !motionAppear || prevStatus === STATUS_ENTER && !motionEnter || prevStatus === STATUS_LEAVE && !motionLeave) {\n newState.status = STATUS_NONE;\n newState.statusActive = false;\n newState.newStatus = false;\n }\n\n // Appear\n if (!prevProps && visible && motionAppear) {\n newState.status = STATUS_APPEAR;\n newState.statusActive = false;\n newState.newStatus = true;\n }\n\n // Enter\n if (prevProps && !prevProps.visible && visible && motionEnter) {\n newState.status = STATUS_ENTER;\n newState.statusActive = false;\n newState.newStatus = true;\n }\n\n // Leave\n if (prevProps && prevProps.visible && !visible && motionLeave || !prevProps && motionLeaveImmediately && !visible && motionLeave) {\n newState.status = STATUS_LEAVE;\n newState.statusActive = false;\n newState.newStatus = true;\n }\n\n return newState;\n }\n }]);\n\n return CSSMotion;\n }(React.Component);\n\n CSSMotion.propTypes = _extends({}, MotionPropTypes, {\n\n internalRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func])\n });\n CSSMotion.defaultProps = {\n visible: true,\n motionEnter: true,\n motionAppear: true,\n motionLeave: true,\n removeOnLeave: true\n };\n\n\n polyfill(CSSMotion);\n\n if (!forwardRef) {\n return CSSMotion;\n }\n\n return React.forwardRef(function (props, ref) {\n return React.createElement(CSSMotion, _extends({ internalRef: ref }, props));\n });\n}\n\nexport default genCSSMotion(supportTransition);","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nexport function fillRef(ref, node) {\n if (typeof ref === 'function') {\n ref(node);\n } else if (_typeof(ref) === 'object' && ref && 'current' in ref) {\n ref.current = node;\n }\n}\n/**\n * Merge refs into one ref function to support ref passing.\n */\n\nexport function composeRef() {\n for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {\n refs[_key] = arguments[_key];\n }\n\n return function (node) {\n refs.forEach(function (ref) {\n fillRef(ref, node);\n });\n };\n}\nexport function supportRef(nodeOrComponent) {\n // Function component node\n if (nodeOrComponent.type && nodeOrComponent.type.prototype && !nodeOrComponent.type.prototype.render) {\n return false;\n } // Class component\n\n\n if (typeof nodeOrComponent === 'function' && nodeOrComponent.prototype && !nodeOrComponent.prototype.render) {\n return false;\n }\n\n return true;\n}\n/* eslint-enable */","function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(n); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && Symbol.iterator in Object(iter)) return Array.from(iter); }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nimport warning from \"rc-util/es/warning\";\nimport { toArray } from './commonUtil';\n\nfunction getKey(data, index) {\n var key = data.key;\n var value;\n\n if ('value' in data) {\n value = data.value;\n }\n\n if (key !== null && key !== undefined) {\n return key;\n }\n\n if (value !== undefined) {\n return value;\n }\n\n return \"rc-index-key-\".concat(index);\n}\n/**\n * Flat options into flatten list.\n * We use `optionOnly` here is aim to avoid user use nested option group.\n * Here is simply set `key` to the index if not provided.\n */\n\n\nexport function flattenOptions(options) {\n var flattenList = [];\n\n function dig(list, isGroupOption) {\n list.forEach(function (data) {\n if (isGroupOption || !('options' in data)) {\n // Option\n flattenList.push({\n key: getKey(data, flattenList.length),\n groupOption: isGroupOption,\n data: data\n });\n } else {\n // Option Group\n flattenList.push({\n key: getKey(data, flattenList.length),\n group: true,\n data: data\n });\n dig(data.options, true);\n }\n });\n }\n\n dig(options, false);\n return flattenList;\n}\n/**\n * Inject `props` into `option` for legacy usage\n */\n\nfunction injectPropsWithOption(option) {\n var newOption = _objectSpread({}, option);\n\n if (!('props' in newOption)) {\n Object.defineProperty(newOption, 'props', {\n get: function get() {\n warning(false, 'Return type is option instead of Option instance. Please read value directly instead of reading from `props`.');\n return newOption;\n }\n });\n }\n\n return newOption;\n}\n\nexport function findValueOption(values, options) {\n var optionMap = new Map();\n options.forEach(function (flattenItem) {\n if (!flattenItem.group) {\n var data = flattenItem.data; // Check if match\n\n optionMap.set(data.value, data);\n }\n });\n return values.map(function (val) {\n return injectPropsWithOption(optionMap.get(val));\n });\n}\nexport var getLabeledValue = function getLabeledValue(value, _ref) {\n var options = _ref.options,\n prevValue = _ref.prevValue,\n labelInValue = _ref.labelInValue,\n optionLabelProp = _ref.optionLabelProp;\n var item = findValueOption([value], options)[0];\n var result = {\n value: value\n };\n var prevValItem;\n var prevValues = toArray(prevValue);\n\n if (labelInValue) {\n prevValItem = prevValues.find(function (prevItem) {\n if (_typeof(prevItem) === 'object' && 'value' in prevItem) {\n return prevItem.value === value;\n } // [Legacy] Support `key` as `value`\n\n\n return prevItem.key === value;\n });\n }\n\n if (prevValItem && _typeof(prevValItem) === 'object' && 'label' in prevValItem) {\n result.label = prevValItem.label;\n\n if (item && typeof prevValItem.label === 'string' && typeof item[optionLabelProp] === 'string' && prevValItem.label.trim() !== item[optionLabelProp].trim()) {\n warning(false, '`label` of `value` is not same as `label` in Select options.');\n }\n } else if (item && optionLabelProp in item) {\n result.label = item[optionLabelProp];\n } else {\n result.label = value;\n } // [Legacy] We need fill `key` as `value` to compatible old code usage\n\n\n result.key = result.value;\n return result;\n};\n\nfunction toRawString(content) {\n return toArray(content).join('');\n}\n/** Filter single option if match the search text */\n\n\nfunction getFilterFunction(optionFilterProp) {\n return function (searchValue, option) {\n var lowerSearchText = searchValue.toLowerCase(); // Group label search\n\n if ('options' in option) {\n return toRawString(option.label).toLowerCase().includes(lowerSearchText);\n } // Option value search\n\n\n var rawValue = option[optionFilterProp];\n var value = toRawString(rawValue).toLowerCase();\n return value.includes(lowerSearchText) && !option.disabled;\n };\n}\n/** Filter options and return a new options by the search text */\n\n\nexport function filterOptions(searchValue, options, _ref2) {\n var optionFilterProp = _ref2.optionFilterProp,\n filterOption = _ref2.filterOption;\n var filteredOptions = [];\n var filterFunc;\n\n if (filterOption === false) {\n return options;\n }\n\n if (typeof filterOption === 'function') {\n filterFunc = filterOption;\n } else {\n filterFunc = getFilterFunction(optionFilterProp);\n }\n\n options.forEach(function (item) {\n // Group should check child options\n if ('options' in item) {\n // Check group first\n var matchGroup = filterFunc(searchValue, item);\n\n if (matchGroup) {\n filteredOptions.push(item);\n } else {\n // Check option\n var subOptions = item.options.filter(function (subItem) {\n return filterFunc(searchValue, subItem);\n });\n\n if (subOptions.length) {\n filteredOptions.push(_objectSpread({}, item, {\n options: subOptions\n }));\n }\n }\n\n return;\n }\n\n if (filterFunc(searchValue, injectPropsWithOption(item))) {\n filteredOptions.push(item);\n }\n });\n return filteredOptions;\n}\nexport function getSeparatedContent(text, tokens) {\n if (!tokens || !tokens.length) {\n return null;\n }\n\n var match = false;\n\n function separate(str, _ref3) {\n var _ref4 = _toArray(_ref3),\n token = _ref4[0],\n restTokens = _ref4.slice(1);\n\n if (!token) {\n return [str];\n }\n\n var list = str.split(token);\n match = match || list.length > 1;\n return list.reduce(function (prevList, unitStr) {\n return [].concat(_toConsumableArray(prevList), _toConsumableArray(separate(unitStr, restTokens)));\n }, []).filter(function (unit) {\n return unit;\n });\n }\n\n var list = separate(text, tokens);\n return match ? list : null;\n}\nexport function isValueDisabled(value, options) {\n var option = findValueOption([value], options)[0];\n return option.disabled;\n}\n/**\n * `tags` mode should fill un-list item into the option list\n */\n\nexport function fillOptionsWithMissingValue(options, value, optionLabelProp, labelInValue) {\n var values = toArray(value).slice().sort();\n\n var cloneOptions = _toConsumableArray(options); // Convert options value to set\n\n\n var optionValues = new Set();\n options.forEach(function (opt) {\n if (opt.options) {\n opt.options.forEach(function (subOpt) {\n optionValues.add(subOpt.value);\n });\n } else {\n optionValues.add(opt.value);\n }\n }); // Fill missing value\n\n values.forEach(function (item) {\n var val = labelInValue ? item.value : item;\n\n if (!optionValues.has(val)) {\n var _ref5;\n\n cloneOptions.push(labelInValue ? (_ref5 = {}, _defineProperty(_ref5, optionLabelProp, item.label), _defineProperty(_ref5, \"value\", val), _ref5) : {\n value: val\n });\n }\n });\n return cloneOptions;\n}","var global = require('./_global');\nvar core = require('./_core');\nvar ctx = require('./_ctx');\nvar hide = require('./_hide');\nvar has = require('./_has');\nvar PROTOTYPE = 'prototype';\n\nvar $export = function (type, name, source) {\n var IS_FORCED = type & $export.F;\n var IS_GLOBAL = type & $export.G;\n var IS_STATIC = type & $export.S;\n var IS_PROTO = type & $export.P;\n var IS_BIND = type & $export.B;\n var IS_WRAP = type & $export.W;\n var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});\n var expProto = exports[PROTOTYPE];\n var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];\n var key, own, out;\n if (IS_GLOBAL) source = name;\n for (key in source) {\n // contains in native\n own = !IS_FORCED && target && target[key] !== undefined;\n if (own && has(exports, key)) continue;\n // export native or passed\n out = own ? target[key] : source[key];\n // prevent global pollution for namespaces\n exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]\n // bind timers to global for call from export context\n : IS_BIND && own ? ctx(out, global)\n // wrap global constructors for prevent change them in library\n : IS_WRAP && target[key] == out ? (function (C) {\n var F = function (a, b, c) {\n if (this instanceof C) {\n switch (arguments.length) {\n case 0: return new C();\n case 1: return new C(a);\n case 2: return new C(a, b);\n } return new C(a, b, c);\n } return C.apply(this, arguments);\n };\n F[PROTOTYPE] = C[PROTOTYPE];\n return F;\n // make static versions for prototype methods\n })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;\n // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%\n if (IS_PROTO) {\n (exports.virtual || (exports.virtual = {}))[key] = out;\n // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%\n if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);\n }\n }\n};\n// type bitmap\n$export.F = 1; // forced\n$export.G = 2; // global\n$export.S = 4; // static\n$export.P = 8; // proto\n$export.B = 16; // bind\n$export.W = 32; // wrap\n$export.U = 64; // safe\n$export.R = 128; // real proto method for `library`\nmodule.exports = $export;\n","// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nvar global = module.exports = typeof window != 'undefined' && window.Math == Math\n ? window : typeof self != 'undefined' && self.Math == Math ? self\n // eslint-disable-next-line no-new-func\n : Function('return this')();\nif (typeof __g == 'number') __g = global; // eslint-disable-line no-undef\n","var anObject = require('./_an-object');\nvar IE8_DOM_DEFINE = require('./_ie8-dom-define');\nvar toPrimitive = require('./_to-primitive');\nvar dP = Object.defineProperty;\n\nexports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {\n anObject(O);\n P = toPrimitive(P, true);\n anObject(Attributes);\n if (IE8_DOM_DEFINE) try {\n return dP(O, P, Attributes);\n } catch (e) { /* empty */ }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\n","// Thank's IE8 for his funny defineProperty\nmodule.exports = !require('./_fails')(function () {\n return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;\n});\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nfunction componentWillMount() {\n // Call this.constructor.gDSFP to support sub-classes.\n var state = this.constructor.getDerivedStateFromProps(this.props, this.state);\n if (state !== null && state !== undefined) {\n this.setState(state);\n }\n}\n\nfunction componentWillReceiveProps(nextProps) {\n // Call this.constructor.gDSFP to support sub-classes.\n // Use the setState() updater to ensure state isn't stale in certain edge cases.\n function updater(prevState) {\n var state = this.constructor.getDerivedStateFromProps(nextProps, prevState);\n return state !== null && state !== undefined ? state : null;\n }\n // Binding \"this\" is important for shallow renderer support.\n this.setState(updater.bind(this));\n}\n\nfunction componentWillUpdate(nextProps, nextState) {\n try {\n var prevProps = this.props;\n var prevState = this.state;\n this.props = nextProps;\n this.state = nextState;\n this.__reactInternalSnapshotFlag = true;\n this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate(\n prevProps,\n prevState\n );\n } finally {\n this.props = prevProps;\n this.state = prevState;\n }\n}\n\n// React may warn about cWM/cWRP/cWU methods being deprecated.\n// Add a flag to suppress these warnings for this special case.\ncomponentWillMount.__suppressDeprecationWarning = true;\ncomponentWillReceiveProps.__suppressDeprecationWarning = true;\ncomponentWillUpdate.__suppressDeprecationWarning = true;\n\nfunction polyfill(Component) {\n var prototype = Component.prototype;\n\n if (!prototype || !prototype.isReactComponent) {\n throw new Error('Can only polyfill class components');\n }\n\n if (\n typeof Component.getDerivedStateFromProps !== 'function' &&\n typeof prototype.getSnapshotBeforeUpdate !== 'function'\n ) {\n return Component;\n }\n\n // If new component APIs are defined, \"unsafe\" lifecycles won't be called.\n // Error if any of these lifecycles are present,\n // Because they would work differently between older and newer (16.3+) versions of React.\n var foundWillMountName = null;\n var foundWillReceivePropsName = null;\n var foundWillUpdateName = null;\n if (typeof prototype.componentWillMount === 'function') {\n foundWillMountName = 'componentWillMount';\n } else if (typeof prototype.UNSAFE_componentWillMount === 'function') {\n foundWillMountName = 'UNSAFE_componentWillMount';\n }\n if (typeof prototype.componentWillReceiveProps === 'function') {\n foundWillReceivePropsName = 'componentWillReceiveProps';\n } else if (typeof prototype.UNSAFE_componentWillReceiveProps === 'function') {\n foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';\n }\n if (typeof prototype.componentWillUpdate === 'function') {\n foundWillUpdateName = 'componentWillUpdate';\n } else if (typeof prototype.UNSAFE_componentWillUpdate === 'function') {\n foundWillUpdateName = 'UNSAFE_componentWillUpdate';\n }\n if (\n foundWillMountName !== null ||\n foundWillReceivePropsName !== null ||\n foundWillUpdateName !== null\n ) {\n var componentName = Component.displayName || Component.name;\n var newApiName =\n typeof Component.getDerivedStateFromProps === 'function'\n ? 'getDerivedStateFromProps()'\n : 'getSnapshotBeforeUpdate()';\n\n throw Error(\n 'Unsafe legacy lifecycles will not be called for components using new component APIs.\\n\\n' +\n componentName +\n ' uses ' +\n newApiName +\n ' but also contains the following legacy lifecycles:' +\n (foundWillMountName !== null ? '\\n ' + foundWillMountName : '') +\n (foundWillReceivePropsName !== null\n ? '\\n ' + foundWillReceivePropsName\n : '') +\n (foundWillUpdateName !== null ? '\\n ' + foundWillUpdateName : '') +\n '\\n\\nThe above lifecycles should be removed. Learn more about this warning here:\\n' +\n 'https://fb.me/react-async-component-lifecycle-hooks'\n );\n }\n\n // React <= 16.2 does not support static getDerivedStateFromProps.\n // As a workaround, use cWM and cWRP to invoke the new static lifecycle.\n // Newer versions of React will ignore these lifecycles if gDSFP exists.\n if (typeof Component.getDerivedStateFromProps === 'function') {\n prototype.componentWillMount = componentWillMount;\n prototype.componentWillReceiveProps = componentWillReceiveProps;\n }\n\n // React <= 16.2 does not support getSnapshotBeforeUpdate.\n // As a workaround, use cWU to invoke the new lifecycle.\n // Newer versions of React will ignore that lifecycle if gSBU exists.\n if (typeof prototype.getSnapshotBeforeUpdate === 'function') {\n if (typeof prototype.componentDidUpdate !== 'function') {\n throw new Error(\n 'Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype'\n );\n }\n\n prototype.componentWillUpdate = componentWillUpdate;\n\n var componentDidUpdate = prototype.componentDidUpdate;\n\n prototype.componentDidUpdate = function componentDidUpdatePolyfill(\n prevProps,\n prevState,\n maybeSnapshot\n ) {\n // 16.3+ will not execute our will-update method;\n // It will pass a snapshot value to did-update though.\n // Older versions will require our polyfilled will-update value.\n // We need to handle both cases, but can't just check for the presence of \"maybeSnapshot\",\n // Because for <= 15.x versions this might be a \"prevContext\" object.\n // We also can't just check \"__reactInternalSnapshot\",\n // Because get-snapshot might return a falsy value.\n // So check for the explicit __reactInternalSnapshotFlag flag to determine behavior.\n var snapshot = this.__reactInternalSnapshotFlag\n ? this.__reactInternalSnapshot\n : maybeSnapshot;\n\n componentDidUpdate.call(this, prevProps, prevState, snapshot);\n };\n }\n\n return Component;\n}\n\nexport { polyfill };\n","/**\r\n * Define options used to create a render target texture\r\n */\r\nvar RenderTargetCreationOptions = /** @class */ (function () {\r\n function RenderTargetCreationOptions() {\r\n }\r\n return RenderTargetCreationOptions;\r\n}());\r\nexport { RenderTargetCreationOptions };\r\n//# sourceMappingURL=renderTargetCreationOptions.js.map","var hasOwnProperty = {}.hasOwnProperty;\nmodule.exports = function (it, key) {\n return hasOwnProperty.call(it, key);\n};\n","// to indexed object, toObject with fallback for non-array-like ES3 strings\nvar IObject = require('./_iobject');\nvar defined = require('./_defined');\nmodule.exports = function (it) {\n return IObject(defined(it));\n};\n","import * as React from 'react';\nimport classNames from 'classnames';\n\nvar TransBtn = function TransBtn(_ref) {\n var className = _ref.className,\n customizeIcon = _ref.customizeIcon,\n customizeIconProps = _ref.customizeIconProps,\n _onMouseDown = _ref.onMouseDown,\n onClick = _ref.onClick,\n children = _ref.children;\n var icon;\n\n if (typeof customizeIcon === 'function') {\n icon = customizeIcon(customizeIconProps);\n } else {\n icon = customizeIcon;\n }\n\n return React.createElement(\"span\", {\n className: className,\n onMouseDown: function onMouseDown(event) {\n event.preventDefault();\n\n if (_onMouseDown) {\n _onMouseDown(event);\n }\n },\n style: {\n userSelect: 'none',\n WebkitUserSelect: 'none'\n },\n unselectable: \"on\",\n onClick: onClick,\n \"aria-hidden\": true\n }, icon !== undefined ? icon : React.createElement(\"span\", {\n className: classNames(className.split(/\\s+/).map(function (cls) {\n return \"\".concat(cls, \"-icon\");\n }))\n }, children));\n};\n\nexport default TransBtn;","'use strict';\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n exports.default = void 0;\n \n var _LoadingOutlined = _interopRequireDefault(require('./lib/icons/LoadingOutlined'));\n \n function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n \n var _default = _LoadingOutlined;\n exports.default = _default;\n module.exports = _default;","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\n/**\n * Similar to invariant but only logs a warning if the condition is not met.\n * This can be used to log issues in development environments in critical\n * paths. Removing the logging code for production environments will keep the\n * same logic and follow the same code paths.\n */\n\nvar __DEV__ = process.env.NODE_ENV !== 'production';\n\nvar warning = function() {};\n\nif (__DEV__) {\n var printWarning = function printWarning(format, args) {\n var len = arguments.length;\n args = new Array(len > 1 ? len - 1 : 0);\n for (var key = 1; key < len; key++) {\n args[key - 1] = arguments[key];\n }\n var argIndex = 0;\n var message = 'Warning: ' +\n format.replace(/%s/g, function() {\n return args[argIndex++];\n });\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch (x) {}\n }\n\n warning = function(condition, format, args) {\n var len = arguments.length;\n args = new Array(len > 2 ? len - 2 : 0);\n for (var key = 2; key < len; key++) {\n args[key - 2] = arguments[key];\n }\n if (format === undefined) {\n throw new Error(\n '`warning(condition, format, ...args)` requires a warning ' +\n 'message argument'\n );\n }\n if (!condition) {\n printWarning.apply(null, [format].concat(args));\n }\n };\n}\n\nmodule.exports = warning;\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","var dP = require('./_object-dp');\nvar createDesc = require('./_property-desc');\nmodule.exports = require('./_descriptors') ? function (object, key, value) {\n return dP.f(object, key, createDesc(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n","var isObject = require('./_is-object');\nmodule.exports = function (it) {\n if (!isObject(it)) throw TypeError(it + ' is not an object!');\n return it;\n};\n","module.exports = function (it) {\n return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n","module.exports = function (exec) {\n try {\n return !!exec();\n } catch (e) {\n return true;\n }\n};\n","/** @hidden */\r\nvar WebGL2ShaderProcessor = /** @class */ (function () {\r\n function WebGL2ShaderProcessor() {\r\n }\r\n WebGL2ShaderProcessor.prototype.attributeProcessor = function (attribute) {\r\n return attribute.replace(\"attribute\", \"in\");\r\n };\r\n WebGL2ShaderProcessor.prototype.varyingProcessor = function (varying, isFragment) {\r\n return varying.replace(\"varying\", isFragment ? \"in\" : \"out\");\r\n };\r\n WebGL2ShaderProcessor.prototype.postProcessor = function (code, defines, isFragment) {\r\n var hasDrawBuffersExtension = code.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;\r\n // Remove extensions\r\n var regex = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;\r\n code = code.replace(regex, \"\");\r\n // Replace instructions\r\n code = code.replace(/texture2D\\s*\\(/g, \"texture(\");\r\n if (isFragment) {\r\n code = code.replace(/texture2DLodEXT\\s*\\(/g, \"textureLod(\");\r\n code = code.replace(/textureCubeLodEXT\\s*\\(/g, \"textureLod(\");\r\n code = code.replace(/textureCube\\s*\\(/g, \"texture(\");\r\n code = code.replace(/gl_FragDepthEXT/g, \"gl_FragDepth\");\r\n code = code.replace(/gl_FragColor/g, \"glFragColor\");\r\n code = code.replace(/gl_FragData/g, \"glFragData\");\r\n code = code.replace(/void\\s+?main\\s*\\(/g, (hasDrawBuffersExtension ? \"\" : \"out vec4 glFragColor;\\n\") + \"void main(\");\r\n }\r\n else {\r\n var hasMultiviewExtension = defines.indexOf(\"#define MULTIVIEW\") !== -1;\r\n if (hasMultiviewExtension) {\r\n return \"#extension GL_OVR_multiview2 : require\\nlayout (num_views = 2) in;\\n\" + code;\r\n }\r\n }\r\n return code;\r\n };\r\n return WebGL2ShaderProcessor;\r\n}());\r\nexport { WebGL2ShaderProcessor };\r\n//# sourceMappingURL=webGL2ShaderProcessors.js.map","import ReactDOM from 'react-dom';\n/**\n * Return if a node is a DOM node. Else will return by `findDOMNode`\n */\n\nexport default function findDOMNode(node) {\n if (node instanceof HTMLElement) {\n return node;\n }\n\n return ReactDOM.findDOMNode(node);\n}","/**\n * Webpack has bug for import loop, which is not the same behavior as ES module.\n * When util.js imports the TreeNode for tree generate will cause treeContextTypes be empty.\n */\nimport * as React from 'react';\nexport var TreeContext = React.createContext(null);","export default function contains(root, n) {\n var node = n;\n\n while (node) {\n if (node === root) {\n return true;\n }\n\n node = node.parentNode;\n }\n\n return false;\n}","\"use strict\";\n\nexports.__esModule = true;\n\nvar _from = require(\"../core-js/array/from\");\n\nvar _from2 = _interopRequireDefault(_from);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = function (arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n } else {\n return (0, _from2.default)(arr);\n }\n};","module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n","// 7.1.13 ToObject(argument)\nvar defined = require('./_defined');\nmodule.exports = function (it) {\n return Object(defined(it));\n};\n","module.exports = {};\n","import { StringTools } from '../../Misc/stringTools';\r\n/** @hidden */\r\nvar ShaderCodeNode = /** @class */ (function () {\r\n function ShaderCodeNode() {\r\n this.children = [];\r\n }\r\n ShaderCodeNode.prototype.isValid = function (preprocessors) {\r\n return true;\r\n };\r\n ShaderCodeNode.prototype.process = function (preprocessors, options) {\r\n var result = \"\";\r\n if (this.line) {\r\n var value = this.line;\r\n var processor = options.processor;\r\n if (processor) {\r\n // This must be done before other replacements to avoid mistakenly changing something that was already changed.\r\n if (processor.lineProcessor) {\r\n value = processor.lineProcessor(value, options.isFragment);\r\n }\r\n if (processor.attributeProcessor && StringTools.StartsWith(this.line, \"attribute\")) {\r\n value = processor.attributeProcessor(this.line);\r\n }\r\n else if (processor.varyingProcessor && StringTools.StartsWith(this.line, \"varying\")) {\r\n value = processor.varyingProcessor(this.line, options.isFragment);\r\n }\r\n else if ((processor.uniformProcessor || processor.uniformBufferProcessor) && StringTools.StartsWith(this.line, \"uniform\")) {\r\n var regex = /uniform (.+) (.+)/;\r\n if (regex.test(this.line)) { // uniform\r\n if (processor.uniformProcessor) {\r\n value = processor.uniformProcessor(this.line, options.isFragment);\r\n }\r\n }\r\n else { // Uniform buffer\r\n if (processor.uniformBufferProcessor) {\r\n value = processor.uniformBufferProcessor(this.line, options.isFragment);\r\n options.lookForClosingBracketForUniformBuffer = true;\r\n }\r\n }\r\n }\r\n if (processor.endOfUniformBufferProcessor) {\r\n if (options.lookForClosingBracketForUniformBuffer && this.line.indexOf(\"}\") !== -1) {\r\n options.lookForClosingBracketForUniformBuffer = false;\r\n value = processor.endOfUniformBufferProcessor(this.line, options.isFragment);\r\n }\r\n }\r\n }\r\n result += value + \"\\r\\n\";\r\n }\r\n this.children.forEach(function (child) {\r\n result += child.process(preprocessors, options);\r\n });\r\n if (this.additionalDefineKey) {\r\n preprocessors[this.additionalDefineKey] = this.additionalDefineValue || \"true\";\r\n }\r\n return result;\r\n };\r\n return ShaderCodeNode;\r\n}());\r\nexport { ShaderCodeNode };\r\n//# sourceMappingURL=shaderCodeNode.js.map","/** @hidden */\r\nvar ShaderCodeCursor = /** @class */ (function () {\r\n function ShaderCodeCursor() {\r\n }\r\n Object.defineProperty(ShaderCodeCursor.prototype, \"currentLine\", {\r\n get: function () {\r\n return this._lines[this.lineIndex];\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ShaderCodeCursor.prototype, \"canRead\", {\r\n get: function () {\r\n return this.lineIndex < this._lines.length - 1;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ShaderCodeCursor.prototype, \"lines\", {\r\n set: function (value) {\r\n this._lines = [];\r\n for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {\r\n var line = value_1[_i];\r\n // Prevent removing line break in macros.\r\n if (line[0] === \"#\") {\r\n this._lines.push(line);\r\n continue;\r\n }\r\n var split = line.split(\";\");\r\n for (var index = 0; index < split.length; index++) {\r\n var subLine = split[index];\r\n subLine = subLine.trim();\r\n if (!subLine) {\r\n continue;\r\n }\r\n this._lines.push(subLine + (index !== split.length - 1 ? \";\" : \"\"));\r\n }\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return ShaderCodeCursor;\r\n}());\r\nexport { ShaderCodeCursor };\r\n//# sourceMappingURL=shaderCodeCursor.js.map","import { __extends } from \"tslib\";\r\nimport { ShaderCodeNode } from './shaderCodeNode';\r\n/** @hidden */\r\nvar ShaderCodeConditionNode = /** @class */ (function (_super) {\r\n __extends(ShaderCodeConditionNode, _super);\r\n function ShaderCodeConditionNode() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ShaderCodeConditionNode.prototype.process = function (preprocessors, options) {\r\n for (var index = 0; index < this.children.length; index++) {\r\n var node = this.children[index];\r\n if (node.isValid(preprocessors)) {\r\n return node.process(preprocessors, options);\r\n }\r\n }\r\n return \"\";\r\n };\r\n return ShaderCodeConditionNode;\r\n}(ShaderCodeNode));\r\nexport { ShaderCodeConditionNode };\r\n//# sourceMappingURL=shaderCodeConditionNode.js.map","import { __extends } from \"tslib\";\r\nimport { ShaderCodeNode } from './shaderCodeNode';\r\n/** @hidden */\r\nvar ShaderCodeTestNode = /** @class */ (function (_super) {\r\n __extends(ShaderCodeTestNode, _super);\r\n function ShaderCodeTestNode() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ShaderCodeTestNode.prototype.isValid = function (preprocessors) {\r\n return this.testExpression.isTrue(preprocessors);\r\n };\r\n return ShaderCodeTestNode;\r\n}(ShaderCodeNode));\r\nexport { ShaderCodeTestNode };\r\n//# sourceMappingURL=shaderCodeTestNode.js.map","/** @hidden */\r\nvar ShaderDefineExpression = /** @class */ (function () {\r\n function ShaderDefineExpression() {\r\n }\r\n ShaderDefineExpression.prototype.isTrue = function (preprocessors) {\r\n return true;\r\n };\r\n return ShaderDefineExpression;\r\n}());\r\nexport { ShaderDefineExpression };\r\n//# sourceMappingURL=shaderDefineExpression.js.map","import { __extends } from \"tslib\";\r\nimport { ShaderDefineExpression } from \"../shaderDefineExpression\";\r\n/** @hidden */\r\nvar ShaderDefineIsDefinedOperator = /** @class */ (function (_super) {\r\n __extends(ShaderDefineIsDefinedOperator, _super);\r\n function ShaderDefineIsDefinedOperator(define, not) {\r\n if (not === void 0) { not = false; }\r\n var _this = _super.call(this) || this;\r\n _this.define = define;\r\n _this.not = not;\r\n return _this;\r\n }\r\n ShaderDefineIsDefinedOperator.prototype.isTrue = function (preprocessors) {\r\n var condition = preprocessors[this.define] !== undefined;\r\n if (this.not) {\r\n condition = !condition;\r\n }\r\n return condition;\r\n };\r\n return ShaderDefineIsDefinedOperator;\r\n}(ShaderDefineExpression));\r\nexport { ShaderDefineIsDefinedOperator };\r\n//# sourceMappingURL=shaderDefineIsDefinedOperator.js.map","import { __extends } from \"tslib\";\r\nimport { ShaderDefineExpression } from '../shaderDefineExpression';\r\n/** @hidden */\r\nvar ShaderDefineOrOperator = /** @class */ (function (_super) {\r\n __extends(ShaderDefineOrOperator, _super);\r\n function ShaderDefineOrOperator() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ShaderDefineOrOperator.prototype.isTrue = function (preprocessors) {\r\n return this.leftOperand.isTrue(preprocessors) || this.rightOperand.isTrue(preprocessors);\r\n };\r\n return ShaderDefineOrOperator;\r\n}(ShaderDefineExpression));\r\nexport { ShaderDefineOrOperator };\r\n//# sourceMappingURL=shaderDefineOrOperator.js.map","import { __extends } from \"tslib\";\r\nimport { ShaderDefineExpression } from '../shaderDefineExpression';\r\n/** @hidden */\r\nvar ShaderDefineAndOperator = /** @class */ (function (_super) {\r\n __extends(ShaderDefineAndOperator, _super);\r\n function ShaderDefineAndOperator() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ShaderDefineAndOperator.prototype.isTrue = function (preprocessors) {\r\n return this.leftOperand.isTrue(preprocessors) && this.rightOperand.isTrue(preprocessors);\r\n };\r\n return ShaderDefineAndOperator;\r\n}(ShaderDefineExpression));\r\nexport { ShaderDefineAndOperator };\r\n//# sourceMappingURL=shaderDefineAndOperator.js.map","import { __extends } from \"tslib\";\r\nimport { ShaderDefineExpression } from '../shaderDefineExpression';\r\n/** @hidden */\r\nvar ShaderDefineArithmeticOperator = /** @class */ (function (_super) {\r\n __extends(ShaderDefineArithmeticOperator, _super);\r\n function ShaderDefineArithmeticOperator(define, operand, testValue) {\r\n var _this = _super.call(this) || this;\r\n _this.define = define;\r\n _this.operand = operand;\r\n _this.testValue = testValue;\r\n return _this;\r\n }\r\n ShaderDefineArithmeticOperator.prototype.isTrue = function (preprocessors) {\r\n var value = preprocessors[this.define];\r\n if (value === undefined) {\r\n value = this.define;\r\n }\r\n var condition = false;\r\n var left = parseInt(value);\r\n var right = parseInt(this.testValue);\r\n switch (this.operand) {\r\n case \">\":\r\n condition = left > right;\r\n break;\r\n case \"<\":\r\n condition = left < right;\r\n break;\r\n case \"<=\":\r\n condition = left <= right;\r\n break;\r\n case \">=\":\r\n condition = left >= right;\r\n break;\r\n case \"==\":\r\n condition = left === right;\r\n break;\r\n }\r\n return condition;\r\n };\r\n return ShaderDefineArithmeticOperator;\r\n}(ShaderDefineExpression));\r\nexport { ShaderDefineArithmeticOperator };\r\n//# sourceMappingURL=shaderDefineArithmeticOperator.js.map","import { ShaderCodeNode } from './shaderCodeNode';\r\nimport { ShaderCodeCursor } from './shaderCodeCursor';\r\nimport { ShaderCodeConditionNode } from './shaderCodeConditionNode';\r\nimport { ShaderCodeTestNode } from './shaderCodeTestNode';\r\nimport { ShaderDefineIsDefinedOperator } from './Expressions/Operators/shaderDefineIsDefinedOperator';\r\nimport { ShaderDefineOrOperator } from './Expressions/Operators/shaderDefineOrOperator';\r\nimport { ShaderDefineAndOperator } from './Expressions/Operators/shaderDefineAndOperator';\r\nimport { ShaderDefineArithmeticOperator } from './Expressions/Operators/shaderDefineArithmeticOperator';\r\nimport { _DevTools } from '../../Misc/devTools';\r\n/** @hidden */\r\nvar ShaderProcessor = /** @class */ (function () {\r\n function ShaderProcessor() {\r\n }\r\n ShaderProcessor.Process = function (sourceCode, options, callback) {\r\n var _this = this;\r\n this._ProcessIncludes(sourceCode, options, function (codeWithIncludes) {\r\n var migratedCode = _this._ProcessShaderConversion(codeWithIncludes, options);\r\n callback(migratedCode);\r\n });\r\n };\r\n ShaderProcessor._ProcessPrecision = function (source, options) {\r\n var shouldUseHighPrecisionShader = options.shouldUseHighPrecisionShader;\r\n if (source.indexOf(\"precision highp float\") === -1) {\r\n if (!shouldUseHighPrecisionShader) {\r\n source = \"precision mediump float;\\n\" + source;\r\n }\r\n else {\r\n source = \"precision highp float;\\n\" + source;\r\n }\r\n }\r\n else {\r\n if (!shouldUseHighPrecisionShader) { // Moving highp to mediump\r\n source = source.replace(\"precision highp float\", \"precision mediump float\");\r\n }\r\n }\r\n return source;\r\n };\r\n ShaderProcessor._ExtractOperation = function (expression) {\r\n var regex = /defined\\((.+)\\)/;\r\n var match = regex.exec(expression);\r\n if (match && match.length) {\r\n return new ShaderDefineIsDefinedOperator(match[1].trim(), expression[0] === \"!\");\r\n }\r\n var operators = [\"==\", \">=\", \"<=\", \"<\", \">\"];\r\n var operator = \"\";\r\n var indexOperator = 0;\r\n for (var _i = 0, operators_1 = operators; _i < operators_1.length; _i++) {\r\n operator = operators_1[_i];\r\n indexOperator = expression.indexOf(operator);\r\n if (indexOperator > -1) {\r\n break;\r\n }\r\n }\r\n if (indexOperator === -1) {\r\n return new ShaderDefineIsDefinedOperator(expression);\r\n }\r\n var define = expression.substring(0, indexOperator).trim();\r\n var value = expression.substring(indexOperator + operator.length).trim();\r\n return new ShaderDefineArithmeticOperator(define, operator, value);\r\n };\r\n ShaderProcessor._BuildSubExpression = function (expression) {\r\n var indexOr = expression.indexOf(\"||\");\r\n if (indexOr === -1) {\r\n var indexAnd = expression.indexOf(\"&&\");\r\n if (indexAnd > -1) {\r\n var andOperator = new ShaderDefineAndOperator();\r\n var leftPart = expression.substring(0, indexAnd).trim();\r\n var rightPart = expression.substring(indexAnd + 2).trim();\r\n andOperator.leftOperand = this._BuildSubExpression(leftPart);\r\n andOperator.rightOperand = this._BuildSubExpression(rightPart);\r\n return andOperator;\r\n }\r\n else {\r\n return this._ExtractOperation(expression);\r\n }\r\n }\r\n else {\r\n var orOperator = new ShaderDefineOrOperator();\r\n var leftPart = expression.substring(0, indexOr).trim();\r\n var rightPart = expression.substring(indexOr + 2).trim();\r\n orOperator.leftOperand = this._BuildSubExpression(leftPart);\r\n orOperator.rightOperand = this._BuildSubExpression(rightPart);\r\n return orOperator;\r\n }\r\n };\r\n ShaderProcessor._BuildExpression = function (line, start) {\r\n var node = new ShaderCodeTestNode();\r\n var command = line.substring(0, start);\r\n var expression = line.substring(start).trim();\r\n if (command === \"#ifdef\") {\r\n node.testExpression = new ShaderDefineIsDefinedOperator(expression);\r\n }\r\n else if (command === \"#ifndef\") {\r\n node.testExpression = new ShaderDefineIsDefinedOperator(expression, true);\r\n }\r\n else {\r\n node.testExpression = this._BuildSubExpression(expression);\r\n }\r\n return node;\r\n };\r\n ShaderProcessor._MoveCursorWithinIf = function (cursor, rootNode, ifNode) {\r\n var line = cursor.currentLine;\r\n while (this._MoveCursor(cursor, ifNode)) {\r\n line = cursor.currentLine;\r\n var first5 = line.substring(0, 5).toLowerCase();\r\n if (first5 === \"#else\") {\r\n var elseNode = new ShaderCodeNode();\r\n rootNode.children.push(elseNode);\r\n this._MoveCursor(cursor, elseNode);\r\n return;\r\n }\r\n else if (first5 === \"#elif\") {\r\n var elifNode = this._BuildExpression(line, 5);\r\n rootNode.children.push(elifNode);\r\n ifNode = elifNode;\r\n }\r\n }\r\n };\r\n ShaderProcessor._MoveCursor = function (cursor, rootNode) {\r\n while (cursor.canRead) {\r\n cursor.lineIndex++;\r\n var line = cursor.currentLine;\r\n var keywords = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;\r\n var matches = keywords.exec(line);\r\n if (matches && matches.length) {\r\n var keyword = matches[0];\r\n switch (keyword) {\r\n case \"#ifdef\": {\r\n var newRootNode = new ShaderCodeConditionNode();\r\n rootNode.children.push(newRootNode);\r\n var ifNode = this._BuildExpression(line, 6);\r\n newRootNode.children.push(ifNode);\r\n this._MoveCursorWithinIf(cursor, newRootNode, ifNode);\r\n break;\r\n }\r\n case \"#else\":\r\n case \"#elif\":\r\n return true;\r\n case \"#endif\":\r\n return false;\r\n case \"#ifndef\": {\r\n var newRootNode = new ShaderCodeConditionNode();\r\n rootNode.children.push(newRootNode);\r\n var ifNode = this._BuildExpression(line, 7);\r\n newRootNode.children.push(ifNode);\r\n this._MoveCursorWithinIf(cursor, newRootNode, ifNode);\r\n break;\r\n }\r\n case \"#if\": {\r\n var newRootNode = new ShaderCodeConditionNode();\r\n var ifNode = this._BuildExpression(line, 3);\r\n rootNode.children.push(newRootNode);\r\n newRootNode.children.push(ifNode);\r\n this._MoveCursorWithinIf(cursor, newRootNode, ifNode);\r\n break;\r\n }\r\n }\r\n }\r\n else {\r\n var newNode = new ShaderCodeNode();\r\n newNode.line = line;\r\n rootNode.children.push(newNode);\r\n // Detect additional defines\r\n if (line[0] === \"#\" && line[1] === \"d\") {\r\n var split = line.replace(\";\", \"\").split(\" \");\r\n newNode.additionalDefineKey = split[1];\r\n if (split.length === 3) {\r\n newNode.additionalDefineValue = split[2];\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n };\r\n ShaderProcessor._EvaluatePreProcessors = function (sourceCode, preprocessors, options) {\r\n var rootNode = new ShaderCodeNode();\r\n var cursor = new ShaderCodeCursor();\r\n cursor.lineIndex = -1;\r\n cursor.lines = sourceCode.split(\"\\n\");\r\n // Decompose (We keep it in 2 steps so it is easier to maintain and perf hit is insignificant)\r\n this._MoveCursor(cursor, rootNode);\r\n // Recompose\r\n return rootNode.process(preprocessors, options);\r\n };\r\n ShaderProcessor._PreparePreProcessors = function (options) {\r\n var defines = options.defines;\r\n var preprocessors = {};\r\n for (var _i = 0, defines_1 = defines; _i < defines_1.length; _i++) {\r\n var define = defines_1[_i];\r\n var keyValue = define.replace(\"#define\", \"\").replace(\";\", \"\").trim();\r\n var split = keyValue.split(\" \");\r\n preprocessors[split[0]] = split.length > 1 ? split[1] : \"\";\r\n }\r\n preprocessors[\"GL_ES\"] = \"true\";\r\n preprocessors[\"__VERSION__\"] = options.version;\r\n preprocessors[options.platformName] = \"true\";\r\n return preprocessors;\r\n };\r\n ShaderProcessor._ProcessShaderConversion = function (sourceCode, options) {\r\n var preparedSourceCode = this._ProcessPrecision(sourceCode, options);\r\n if (!options.processor) {\r\n return preparedSourceCode;\r\n }\r\n // Already converted\r\n if (preparedSourceCode.indexOf(\"#version 3\") !== -1) {\r\n return preparedSourceCode.replace(\"#version 300 es\", \"\");\r\n }\r\n var defines = options.defines;\r\n var preprocessors = this._PreparePreProcessors(options);\r\n // General pre processing\r\n if (options.processor.preProcessor) {\r\n preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, options.isFragment);\r\n }\r\n preparedSourceCode = this._EvaluatePreProcessors(preparedSourceCode, preprocessors, options);\r\n // Post processing\r\n if (options.processor.postProcessor) {\r\n preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment);\r\n }\r\n return preparedSourceCode;\r\n };\r\n ShaderProcessor._ProcessIncludes = function (sourceCode, options, callback) {\r\n var _this = this;\r\n var regex = /#include<(.+)>(\\((.*)\\))*(\\[(.*)\\])*/g;\r\n var match = regex.exec(sourceCode);\r\n var returnValue = new String(sourceCode);\r\n while (match != null) {\r\n var includeFile = match[1];\r\n // Uniform declaration\r\n if (includeFile.indexOf(\"__decl__\") !== -1) {\r\n includeFile = includeFile.replace(/__decl__/, \"\");\r\n if (options.supportsUniformBuffers) {\r\n includeFile = includeFile.replace(/Vertex/, \"Ubo\");\r\n includeFile = includeFile.replace(/Fragment/, \"Ubo\");\r\n }\r\n includeFile = includeFile + \"Declaration\";\r\n }\r\n if (options.includesShadersStore[includeFile]) {\r\n // Substitution\r\n var includeContent = options.includesShadersStore[includeFile];\r\n if (match[2]) {\r\n var splits = match[3].split(\",\");\r\n for (var index = 0; index < splits.length; index += 2) {\r\n var source = new RegExp(splits[index], \"g\");\r\n var dest = splits[index + 1];\r\n includeContent = includeContent.replace(source, dest);\r\n }\r\n }\r\n if (match[4]) {\r\n var indexString = match[5];\r\n if (indexString.indexOf(\"..\") !== -1) {\r\n var indexSplits = indexString.split(\"..\");\r\n var minIndex = parseInt(indexSplits[0]);\r\n var maxIndex = parseInt(indexSplits[1]);\r\n var sourceIncludeContent = includeContent.slice(0);\r\n includeContent = \"\";\r\n if (isNaN(maxIndex)) {\r\n maxIndex = options.indexParameters[indexSplits[1]];\r\n }\r\n for (var i = minIndex; i < maxIndex; i++) {\r\n if (!options.supportsUniformBuffers) {\r\n // Ubo replacement\r\n sourceIncludeContent = sourceIncludeContent.replace(/light\\{X\\}.(\\w*)/g, function (str, p1) {\r\n return p1 + \"{X}\";\r\n });\r\n }\r\n includeContent += sourceIncludeContent.replace(/\\{X\\}/g, i.toString()) + \"\\n\";\r\n }\r\n }\r\n else {\r\n if (!options.supportsUniformBuffers) {\r\n // Ubo replacement\r\n includeContent = includeContent.replace(/light\\{X\\}.(\\w*)/g, function (str, p1) {\r\n return p1 + \"{X}\";\r\n });\r\n }\r\n includeContent = includeContent.replace(/\\{X\\}/g, indexString);\r\n }\r\n }\r\n // Replace\r\n returnValue = returnValue.replace(match[0], includeContent);\r\n }\r\n else {\r\n var includeShaderUrl = options.shadersRepository + \"ShadersInclude/\" + includeFile + \".fx\";\r\n ShaderProcessor._FileToolsLoadFile(includeShaderUrl, function (fileContent) {\r\n options.includesShadersStore[includeFile] = fileContent;\r\n _this._ProcessIncludes(returnValue, options, callback);\r\n });\r\n return;\r\n }\r\n match = regex.exec(sourceCode);\r\n }\r\n callback(returnValue);\r\n };\r\n /**\r\n * Loads a file from a url\r\n * @param url url to load\r\n * @param onSuccess callback called when the file successfully loads\r\n * @param onProgress callback called while file is loading (if the server supports this mode)\r\n * @param offlineProvider defines the offline provider for caching\r\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\r\n * @param onError callback called when the file fails to load\r\n * @returns a file request object\r\n * @hidden\r\n */\r\n ShaderProcessor._FileToolsLoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {\r\n throw _DevTools.WarnImport(\"FileTools\");\r\n };\r\n return ShaderProcessor;\r\n}());\r\nexport { ShaderProcessor };\r\n//# sourceMappingURL=shaderProcessor.js.map","var START_EVENT_NAME_MAP = {\n transitionstart: {\n transition: 'transitionstart',\n WebkitTransition: 'webkitTransitionStart',\n MozTransition: 'mozTransitionStart',\n OTransition: 'oTransitionStart',\n msTransition: 'MSTransitionStart'\n },\n\n animationstart: {\n animation: 'animationstart',\n WebkitAnimation: 'webkitAnimationStart',\n MozAnimation: 'mozAnimationStart',\n OAnimation: 'oAnimationStart',\n msAnimation: 'MSAnimationStart'\n }\n};\n\nvar END_EVENT_NAME_MAP = {\n transitionend: {\n transition: 'transitionend',\n WebkitTransition: 'webkitTransitionEnd',\n MozTransition: 'mozTransitionEnd',\n OTransition: 'oTransitionEnd',\n msTransition: 'MSTransitionEnd'\n },\n\n animationend: {\n animation: 'animationend',\n WebkitAnimation: 'webkitAnimationEnd',\n MozAnimation: 'mozAnimationEnd',\n OAnimation: 'oAnimationEnd',\n msAnimation: 'MSAnimationEnd'\n }\n};\n\nvar startEvents = [];\nvar endEvents = [];\n\nfunction detectEvents() {\n var testEl = document.createElement('div');\n var style = testEl.style;\n\n if (!('AnimationEvent' in window)) {\n delete START_EVENT_NAME_MAP.animationstart.animation;\n delete END_EVENT_NAME_MAP.animationend.animation;\n }\n\n if (!('TransitionEvent' in window)) {\n delete START_EVENT_NAME_MAP.transitionstart.transition;\n delete END_EVENT_NAME_MAP.transitionend.transition;\n }\n\n function process(EVENT_NAME_MAP, events) {\n for (var baseEventName in EVENT_NAME_MAP) {\n if (EVENT_NAME_MAP.hasOwnProperty(baseEventName)) {\n var baseEvents = EVENT_NAME_MAP[baseEventName];\n for (var styleName in baseEvents) {\n if (styleName in style) {\n events.push(baseEvents[styleName]);\n break;\n }\n }\n }\n }\n }\n\n process(START_EVENT_NAME_MAP, startEvents);\n process(END_EVENT_NAME_MAP, endEvents);\n}\n\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n detectEvents();\n}\n\nfunction addEventListener(node, eventName, eventListener) {\n node.addEventListener(eventName, eventListener, false);\n}\n\nfunction removeEventListener(node, eventName, eventListener) {\n node.removeEventListener(eventName, eventListener, false);\n}\n\nvar TransitionEvents = {\n // Start events\n startEvents: startEvents,\n\n addStartEventListener: function addStartEventListener(node, eventListener) {\n if (startEvents.length === 0) {\n window.setTimeout(eventListener, 0);\n return;\n }\n startEvents.forEach(function (startEvent) {\n addEventListener(node, startEvent, eventListener);\n });\n },\n removeStartEventListener: function removeStartEventListener(node, eventListener) {\n if (startEvents.length === 0) {\n return;\n }\n startEvents.forEach(function (startEvent) {\n removeEventListener(node, startEvent, eventListener);\n });\n },\n\n\n // End events\n endEvents: endEvents,\n\n addEndEventListener: function addEndEventListener(node, eventListener) {\n if (endEvents.length === 0) {\n window.setTimeout(eventListener, 0);\n return;\n }\n endEvents.forEach(function (endEvent) {\n addEventListener(node, endEvent, eventListener);\n });\n },\n removeEndEventListener: function removeEndEventListener(node, eventListener) {\n if (endEvents.length === 0) {\n return;\n }\n endEvents.forEach(function (endEvent) {\n removeEventListener(node, endEvent, eventListener);\n });\n }\n};\n\nexport default TransitionEvents;","// 19.1.2.14 / 15.2.3.14 Object.keys(O)\nvar $keys = require('./_object-keys-internal');\nvar enumBugKeys = require('./_enum-bug-keys');\n\nmodule.exports = Object.keys || function keys(O) {\n return $keys(O, enumBugKeys);\n};\n","module.exports = true;\n","var id = 0;\nvar px = Math.random();\nmodule.exports = function (key) {\n return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));\n};\n","exports.f = {}.propertyIsEnumerable;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-is.production.min.js');\n} else {\n module.exports = require('./cjs/react-is.development.js');\n}\n","/**\r\n * @hidden\r\n **/\r\nvar DepthCullingState = /** @class */ (function () {\r\n /**\r\n * Initializes the state.\r\n */\r\n function DepthCullingState() {\r\n this._isDepthTestDirty = false;\r\n this._isDepthMaskDirty = false;\r\n this._isDepthFuncDirty = false;\r\n this._isCullFaceDirty = false;\r\n this._isCullDirty = false;\r\n this._isZOffsetDirty = false;\r\n this._isFrontFaceDirty = false;\r\n this.reset();\r\n }\r\n Object.defineProperty(DepthCullingState.prototype, \"isDirty\", {\r\n get: function () {\r\n return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DepthCullingState.prototype, \"zOffset\", {\r\n get: function () {\r\n return this._zOffset;\r\n },\r\n set: function (value) {\r\n if (this._zOffset === value) {\r\n return;\r\n }\r\n this._zOffset = value;\r\n this._isZOffsetDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DepthCullingState.prototype, \"cullFace\", {\r\n get: function () {\r\n return this._cullFace;\r\n },\r\n set: function (value) {\r\n if (this._cullFace === value) {\r\n return;\r\n }\r\n this._cullFace = value;\r\n this._isCullFaceDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DepthCullingState.prototype, \"cull\", {\r\n get: function () {\r\n return this._cull;\r\n },\r\n set: function (value) {\r\n if (this._cull === value) {\r\n return;\r\n }\r\n this._cull = value;\r\n this._isCullDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DepthCullingState.prototype, \"depthFunc\", {\r\n get: function () {\r\n return this._depthFunc;\r\n },\r\n set: function (value) {\r\n if (this._depthFunc === value) {\r\n return;\r\n }\r\n this._depthFunc = value;\r\n this._isDepthFuncDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DepthCullingState.prototype, \"depthMask\", {\r\n get: function () {\r\n return this._depthMask;\r\n },\r\n set: function (value) {\r\n if (this._depthMask === value) {\r\n return;\r\n }\r\n this._depthMask = value;\r\n this._isDepthMaskDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DepthCullingState.prototype, \"depthTest\", {\r\n get: function () {\r\n return this._depthTest;\r\n },\r\n set: function (value) {\r\n if (this._depthTest === value) {\r\n return;\r\n }\r\n this._depthTest = value;\r\n this._isDepthTestDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(DepthCullingState.prototype, \"frontFace\", {\r\n get: function () {\r\n return this._frontFace;\r\n },\r\n set: function (value) {\r\n if (this._frontFace === value) {\r\n return;\r\n }\r\n this._frontFace = value;\r\n this._isFrontFaceDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n DepthCullingState.prototype.reset = function () {\r\n this._depthMask = true;\r\n this._depthTest = true;\r\n this._depthFunc = null;\r\n this._cullFace = null;\r\n this._cull = null;\r\n this._zOffset = 0;\r\n this._frontFace = null;\r\n this._isDepthTestDirty = true;\r\n this._isDepthMaskDirty = true;\r\n this._isDepthFuncDirty = false;\r\n this._isCullFaceDirty = false;\r\n this._isCullDirty = false;\r\n this._isZOffsetDirty = false;\r\n this._isFrontFaceDirty = false;\r\n };\r\n DepthCullingState.prototype.apply = function (gl) {\r\n if (!this.isDirty) {\r\n return;\r\n }\r\n // Cull\r\n if (this._isCullDirty) {\r\n if (this.cull) {\r\n gl.enable(gl.CULL_FACE);\r\n }\r\n else {\r\n gl.disable(gl.CULL_FACE);\r\n }\r\n this._isCullDirty = false;\r\n }\r\n // Cull face\r\n if (this._isCullFaceDirty) {\r\n gl.cullFace(this.cullFace);\r\n this._isCullFaceDirty = false;\r\n }\r\n // Depth mask\r\n if (this._isDepthMaskDirty) {\r\n gl.depthMask(this.depthMask);\r\n this._isDepthMaskDirty = false;\r\n }\r\n // Depth test\r\n if (this._isDepthTestDirty) {\r\n if (this.depthTest) {\r\n gl.enable(gl.DEPTH_TEST);\r\n }\r\n else {\r\n gl.disable(gl.DEPTH_TEST);\r\n }\r\n this._isDepthTestDirty = false;\r\n }\r\n // Depth func\r\n if (this._isDepthFuncDirty) {\r\n gl.depthFunc(this.depthFunc);\r\n this._isDepthFuncDirty = false;\r\n }\r\n // zOffset\r\n if (this._isZOffsetDirty) {\r\n if (this.zOffset) {\r\n gl.enable(gl.POLYGON_OFFSET_FILL);\r\n gl.polygonOffset(this.zOffset, 0);\r\n }\r\n else {\r\n gl.disable(gl.POLYGON_OFFSET_FILL);\r\n }\r\n this._isZOffsetDirty = false;\r\n }\r\n // Front face\r\n if (this._isFrontFaceDirty) {\r\n gl.frontFace(this.frontFace);\r\n this._isFrontFaceDirty = false;\r\n }\r\n };\r\n return DepthCullingState;\r\n}());\r\nexport { DepthCullingState };\r\n//# sourceMappingURL=depthCullingState.js.map","/**\r\n * @hidden\r\n **/\r\nvar StencilState = /** @class */ (function () {\r\n function StencilState() {\r\n this._isStencilTestDirty = false;\r\n this._isStencilMaskDirty = false;\r\n this._isStencilFuncDirty = false;\r\n this._isStencilOpDirty = false;\r\n this.reset();\r\n }\r\n Object.defineProperty(StencilState.prototype, \"isDirty\", {\r\n get: function () {\r\n return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(StencilState.prototype, \"stencilFunc\", {\r\n get: function () {\r\n return this._stencilFunc;\r\n },\r\n set: function (value) {\r\n if (this._stencilFunc === value) {\r\n return;\r\n }\r\n this._stencilFunc = value;\r\n this._isStencilFuncDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(StencilState.prototype, \"stencilFuncRef\", {\r\n get: function () {\r\n return this._stencilFuncRef;\r\n },\r\n set: function (value) {\r\n if (this._stencilFuncRef === value) {\r\n return;\r\n }\r\n this._stencilFuncRef = value;\r\n this._isStencilFuncDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(StencilState.prototype, \"stencilFuncMask\", {\r\n get: function () {\r\n return this._stencilFuncMask;\r\n },\r\n set: function (value) {\r\n if (this._stencilFuncMask === value) {\r\n return;\r\n }\r\n this._stencilFuncMask = value;\r\n this._isStencilFuncDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(StencilState.prototype, \"stencilOpStencilFail\", {\r\n get: function () {\r\n return this._stencilOpStencilFail;\r\n },\r\n set: function (value) {\r\n if (this._stencilOpStencilFail === value) {\r\n return;\r\n }\r\n this._stencilOpStencilFail = value;\r\n this._isStencilOpDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(StencilState.prototype, \"stencilOpDepthFail\", {\r\n get: function () {\r\n return this._stencilOpDepthFail;\r\n },\r\n set: function (value) {\r\n if (this._stencilOpDepthFail === value) {\r\n return;\r\n }\r\n this._stencilOpDepthFail = value;\r\n this._isStencilOpDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(StencilState.prototype, \"stencilOpStencilDepthPass\", {\r\n get: function () {\r\n return this._stencilOpStencilDepthPass;\r\n },\r\n set: function (value) {\r\n if (this._stencilOpStencilDepthPass === value) {\r\n return;\r\n }\r\n this._stencilOpStencilDepthPass = value;\r\n this._isStencilOpDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(StencilState.prototype, \"stencilMask\", {\r\n get: function () {\r\n return this._stencilMask;\r\n },\r\n set: function (value) {\r\n if (this._stencilMask === value) {\r\n return;\r\n }\r\n this._stencilMask = value;\r\n this._isStencilMaskDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(StencilState.prototype, \"stencilTest\", {\r\n get: function () {\r\n return this._stencilTest;\r\n },\r\n set: function (value) {\r\n if (this._stencilTest === value) {\r\n return;\r\n }\r\n this._stencilTest = value;\r\n this._isStencilTestDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n StencilState.prototype.reset = function () {\r\n this._stencilTest = false;\r\n this._stencilMask = 0xFF;\r\n this._stencilFunc = StencilState.ALWAYS;\r\n this._stencilFuncRef = 1;\r\n this._stencilFuncMask = 0xFF;\r\n this._stencilOpStencilFail = StencilState.KEEP;\r\n this._stencilOpDepthFail = StencilState.KEEP;\r\n this._stencilOpStencilDepthPass = StencilState.REPLACE;\r\n this._isStencilTestDirty = true;\r\n this._isStencilMaskDirty = true;\r\n this._isStencilFuncDirty = true;\r\n this._isStencilOpDirty = true;\r\n };\r\n StencilState.prototype.apply = function (gl) {\r\n if (!this.isDirty) {\r\n return;\r\n }\r\n // Stencil test\r\n if (this._isStencilTestDirty) {\r\n if (this.stencilTest) {\r\n gl.enable(gl.STENCIL_TEST);\r\n }\r\n else {\r\n gl.disable(gl.STENCIL_TEST);\r\n }\r\n this._isStencilTestDirty = false;\r\n }\r\n // Stencil mask\r\n if (this._isStencilMaskDirty) {\r\n gl.stencilMask(this.stencilMask);\r\n this._isStencilMaskDirty = false;\r\n }\r\n // Stencil func\r\n if (this._isStencilFuncDirty) {\r\n gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);\r\n this._isStencilFuncDirty = false;\r\n }\r\n // Stencil op\r\n if (this._isStencilOpDirty) {\r\n gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);\r\n this._isStencilOpDirty = false;\r\n }\r\n };\r\n /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */\r\n StencilState.ALWAYS = 519;\r\n /** Passed to stencilOperation to specify that stencil value must be kept */\r\n StencilState.KEEP = 7680;\r\n /** Passed to stencilOperation to specify that stencil value must be replaced */\r\n StencilState.REPLACE = 7681;\r\n return StencilState;\r\n}());\r\nexport { StencilState };\r\n//# sourceMappingURL=stencilState.js.map","/**\r\n * @hidden\r\n **/\r\nvar AlphaState = /** @class */ (function () {\r\n /**\r\n * Initializes the state.\r\n */\r\n function AlphaState() {\r\n this._isAlphaBlendDirty = false;\r\n this._isBlendFunctionParametersDirty = false;\r\n this._isBlendEquationParametersDirty = false;\r\n this._isBlendConstantsDirty = false;\r\n this._alphaBlend = false;\r\n this._blendFunctionParameters = new Array(4);\r\n this._blendEquationParameters = new Array(2);\r\n this._blendConstants = new Array(4);\r\n this.reset();\r\n }\r\n Object.defineProperty(AlphaState.prototype, \"isDirty\", {\r\n get: function () {\r\n return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(AlphaState.prototype, \"alphaBlend\", {\r\n get: function () {\r\n return this._alphaBlend;\r\n },\r\n set: function (value) {\r\n if (this._alphaBlend === value) {\r\n return;\r\n }\r\n this._alphaBlend = value;\r\n this._isAlphaBlendDirty = true;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {\r\n if (this._blendConstants[0] === r &&\r\n this._blendConstants[1] === g &&\r\n this._blendConstants[2] === b &&\r\n this._blendConstants[3] === a) {\r\n return;\r\n }\r\n this._blendConstants[0] = r;\r\n this._blendConstants[1] = g;\r\n this._blendConstants[2] = b;\r\n this._blendConstants[3] = a;\r\n this._isBlendConstantsDirty = true;\r\n };\r\n AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {\r\n if (this._blendFunctionParameters[0] === value0 &&\r\n this._blendFunctionParameters[1] === value1 &&\r\n this._blendFunctionParameters[2] === value2 &&\r\n this._blendFunctionParameters[3] === value3) {\r\n return;\r\n }\r\n this._blendFunctionParameters[0] = value0;\r\n this._blendFunctionParameters[1] = value1;\r\n this._blendFunctionParameters[2] = value2;\r\n this._blendFunctionParameters[3] = value3;\r\n this._isBlendFunctionParametersDirty = true;\r\n };\r\n AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {\r\n if (this._blendEquationParameters[0] === rgb &&\r\n this._blendEquationParameters[1] === alpha) {\r\n return;\r\n }\r\n this._blendEquationParameters[0] = rgb;\r\n this._blendEquationParameters[1] = alpha;\r\n this._isBlendEquationParametersDirty = true;\r\n };\r\n AlphaState.prototype.reset = function () {\r\n this._alphaBlend = false;\r\n this._blendFunctionParameters[0] = null;\r\n this._blendFunctionParameters[1] = null;\r\n this._blendFunctionParameters[2] = null;\r\n this._blendFunctionParameters[3] = null;\r\n this._blendEquationParameters[0] = null;\r\n this._blendEquationParameters[1] = null;\r\n this._blendConstants[0] = null;\r\n this._blendConstants[1] = null;\r\n this._blendConstants[2] = null;\r\n this._blendConstants[3] = null;\r\n this._isAlphaBlendDirty = true;\r\n this._isBlendFunctionParametersDirty = false;\r\n this._isBlendEquationParametersDirty = false;\r\n this._isBlendConstantsDirty = false;\r\n };\r\n AlphaState.prototype.apply = function (gl) {\r\n if (!this.isDirty) {\r\n return;\r\n }\r\n // Alpha blend\r\n if (this._isAlphaBlendDirty) {\r\n if (this._alphaBlend) {\r\n gl.enable(gl.BLEND);\r\n }\r\n else {\r\n gl.disable(gl.BLEND);\r\n }\r\n this._isAlphaBlendDirty = false;\r\n }\r\n // Alpha function\r\n if (this._isBlendFunctionParametersDirty) {\r\n gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);\r\n this._isBlendFunctionParametersDirty = false;\r\n }\r\n // Alpha equation\r\n if (this._isBlendEquationParametersDirty) {\r\n gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);\r\n this._isBlendEquationParametersDirty = false;\r\n }\r\n // Constants\r\n if (this._isBlendConstantsDirty) {\r\n gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);\r\n this._isBlendConstantsDirty = false;\r\n }\r\n };\r\n return AlphaState;\r\n}());\r\nexport { AlphaState };\r\n//# sourceMappingURL=alphaCullingState.js.map","/** @hidden */\r\nvar WebGLPipelineContext = /** @class */ (function () {\r\n function WebGLPipelineContext() {\r\n this.vertexCompilationError = null;\r\n this.fragmentCompilationError = null;\r\n this.programLinkError = null;\r\n this.programValidationError = null;\r\n }\r\n Object.defineProperty(WebGLPipelineContext.prototype, \"isAsync\", {\r\n get: function () {\r\n return this.isParallelCompiled;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(WebGLPipelineContext.prototype, \"isReady\", {\r\n get: function () {\r\n if (this.program) {\r\n if (this.isParallelCompiled) {\r\n return this.engine._isRenderingStateCompiled(this);\r\n }\r\n return true;\r\n }\r\n return false;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n WebGLPipelineContext.prototype._handlesSpectorRebuildCallback = function (onCompiled) {\r\n if (onCompiled && this.program) {\r\n onCompiled(this.program);\r\n }\r\n };\r\n return WebGLPipelineContext;\r\n}());\r\nexport { WebGLPipelineContext };\r\n//# sourceMappingURL=webGLPipelineContext.js.map","import { PrecisionDate } from \"./precisionDate\";\r\n/**\r\n * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window\r\n */\r\nvar PerformanceMonitor = /** @class */ (function () {\r\n /**\r\n * constructor\r\n * @param frameSampleSize The number of samples required to saturate the sliding window\r\n */\r\n function PerformanceMonitor(frameSampleSize) {\r\n if (frameSampleSize === void 0) { frameSampleSize = 30; }\r\n this._enabled = true;\r\n this._rollingFrameTime = new RollingAverage(frameSampleSize);\r\n }\r\n /**\r\n * Samples current frame\r\n * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames\r\n */\r\n PerformanceMonitor.prototype.sampleFrame = function (timeMs) {\r\n if (timeMs === void 0) { timeMs = PrecisionDate.Now; }\r\n if (!this._enabled) {\r\n return;\r\n }\r\n if (this._lastFrameTimeMs != null) {\r\n var dt = timeMs - this._lastFrameTimeMs;\r\n this._rollingFrameTime.add(dt);\r\n }\r\n this._lastFrameTimeMs = timeMs;\r\n };\r\n Object.defineProperty(PerformanceMonitor.prototype, \"averageFrameTime\", {\r\n /**\r\n * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)\r\n */\r\n get: function () {\r\n return this._rollingFrameTime.average;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerformanceMonitor.prototype, \"averageFrameTimeVariance\", {\r\n /**\r\n * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)\r\n */\r\n get: function () {\r\n return this._rollingFrameTime.variance;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerformanceMonitor.prototype, \"instantaneousFrameTime\", {\r\n /**\r\n * Returns the frame time of the most recent frame\r\n */\r\n get: function () {\r\n return this._rollingFrameTime.history(0);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerformanceMonitor.prototype, \"averageFPS\", {\r\n /**\r\n * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)\r\n */\r\n get: function () {\r\n return 1000.0 / this._rollingFrameTime.average;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerformanceMonitor.prototype, \"instantaneousFPS\", {\r\n /**\r\n * Returns the average framerate in frames per second using the most recent frame time\r\n */\r\n get: function () {\r\n var history = this._rollingFrameTime.history(0);\r\n if (history === 0) {\r\n return 0;\r\n }\r\n return 1000.0 / history;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(PerformanceMonitor.prototype, \"isSaturated\", {\r\n /**\r\n * Returns true if enough samples have been taken to completely fill the sliding window\r\n */\r\n get: function () {\r\n return this._rollingFrameTime.isSaturated();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Enables contributions to the sliding window sample set\r\n */\r\n PerformanceMonitor.prototype.enable = function () {\r\n this._enabled = true;\r\n };\r\n /**\r\n * Disables contributions to the sliding window sample set\r\n * Samples will not be interpolated over the disabled period\r\n */\r\n PerformanceMonitor.prototype.disable = function () {\r\n this._enabled = false;\r\n //clear last sample to avoid interpolating over the disabled period when next enabled\r\n this._lastFrameTimeMs = null;\r\n };\r\n Object.defineProperty(PerformanceMonitor.prototype, \"isEnabled\", {\r\n /**\r\n * Returns true if sampling is enabled\r\n */\r\n get: function () {\r\n return this._enabled;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Resets performance monitor\r\n */\r\n PerformanceMonitor.prototype.reset = function () {\r\n //clear last sample to avoid interpolating over the disabled period when next enabled\r\n this._lastFrameTimeMs = null;\r\n //wipe record\r\n this._rollingFrameTime.reset();\r\n };\r\n return PerformanceMonitor;\r\n}());\r\nexport { PerformanceMonitor };\r\n/**\r\n * RollingAverage\r\n *\r\n * Utility to efficiently compute the rolling average and variance over a sliding window of samples\r\n */\r\nvar RollingAverage = /** @class */ (function () {\r\n /**\r\n * constructor\r\n * @param length The number of samples required to saturate the sliding window\r\n */\r\n function RollingAverage(length) {\r\n this._samples = new Array(length);\r\n this.reset();\r\n }\r\n /**\r\n * Adds a sample to the sample set\r\n * @param v The sample value\r\n */\r\n RollingAverage.prototype.add = function (v) {\r\n //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance\r\n var delta;\r\n //we need to check if we've already wrapped round\r\n if (this.isSaturated()) {\r\n //remove bottom of stack from mean\r\n var bottomValue = this._samples[this._pos];\r\n delta = bottomValue - this.average;\r\n this.average -= delta / (this._sampleCount - 1);\r\n this._m2 -= delta * (bottomValue - this.average);\r\n }\r\n else {\r\n this._sampleCount++;\r\n }\r\n //add new value to mean\r\n delta = v - this.average;\r\n this.average += delta / (this._sampleCount);\r\n this._m2 += delta * (v - this.average);\r\n //set the new variance\r\n this.variance = this._m2 / (this._sampleCount - 1);\r\n this._samples[this._pos] = v;\r\n this._pos++;\r\n this._pos %= this._samples.length; //positive wrap around\r\n };\r\n /**\r\n * Returns previously added values or null if outside of history or outside the sliding window domain\r\n * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that\r\n * @return Value previously recorded with add() or null if outside of range\r\n */\r\n RollingAverage.prototype.history = function (i) {\r\n if ((i >= this._sampleCount) || (i >= this._samples.length)) {\r\n return 0;\r\n }\r\n var i0 = this._wrapPosition(this._pos - 1.0);\r\n return this._samples[this._wrapPosition(i0 - i)];\r\n };\r\n /**\r\n * Returns true if enough samples have been taken to completely fill the sliding window\r\n * @return true if sample-set saturated\r\n */\r\n RollingAverage.prototype.isSaturated = function () {\r\n return this._sampleCount >= this._samples.length;\r\n };\r\n /**\r\n * Resets the rolling average (equivalent to 0 samples taken so far)\r\n */\r\n RollingAverage.prototype.reset = function () {\r\n this.average = 0;\r\n this.variance = 0;\r\n this._sampleCount = 0;\r\n this._pos = 0;\r\n this._m2 = 0;\r\n };\r\n /**\r\n * Wraps a value around the sample range boundaries\r\n * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.\r\n * @return Wrapped position in sample range\r\n */\r\n RollingAverage.prototype._wrapPosition = function (i) {\r\n var max = this._samples.length;\r\n return ((i % max) + max) % max;\r\n };\r\n return RollingAverage;\r\n}());\r\nexport { RollingAverage };\r\n//# sourceMappingURL=performanceMonitor.js.map","'use strict';\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n exports.default = void 0;\n \n var _FileOutlined = _interopRequireDefault(require('./lib/icons/FileOutlined'));\n \n function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n \n var _default = _FileOutlined;\n exports.default = _default;\n module.exports = _default;","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _ToastContainer = require('./ToastContainer');\n\nObject.defineProperty(exports, 'DefaultToastContainer', {\n enumerable: true,\n get: function get() {\n return _ToastContainer.ToastContainer;\n }\n});\n\nvar _ToastElement = require('./ToastElement');\n\nObject.defineProperty(exports, 'DefaultToast', {\n enumerable: true,\n get: function get() {\n return _ToastElement.DefaultToast;\n }\n});\n\nvar _ToastProvider = require('./ToastProvider');\n\nObject.defineProperty(exports, 'ToastConsumer', {\n enumerable: true,\n get: function get() {\n return _ToastProvider.ToastConsumer;\n }\n});\nObject.defineProperty(exports, 'ToastProvider', {\n enumerable: true,\n get: function get() {\n return _ToastProvider.ToastProvider;\n }\n});\nObject.defineProperty(exports, 'withToastManager', {\n enumerable: true,\n get: function get() {\n return _ToastProvider.withToastManager;\n }\n});\nObject.defineProperty(exports, 'useToasts', {\n enumerable: true,\n get: function get() {\n return _ToastProvider.useToasts;\n }\n});","function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction isPointsEq(a1, a2, isAlignPoint) {\n if (isAlignPoint) {\n return a1[0] === a2[0];\n }\n\n return a1[0] === a2[0] && a1[1] === a2[1];\n}\n\nexport function getAlignFromPlacement(builtinPlacements, placementStr, align) {\n var baseAlign = builtinPlacements[placementStr] || {};\n return _objectSpread({}, baseAlign, {}, align);\n}\nexport function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {\n var points = align.points;\n var placements = Object.keys(builtinPlacements);\n\n for (var i = 0; i < placements.length; i += 1) {\n var placement = placements[i];\n\n if (isPointsEq(builtinPlacements[placement].points, points, isAlignPoint)) {\n return \"\".concat(prefixCls, \"-placement-\").concat(placement);\n }\n }\n\n return '';\n}","function _typeof(obj) {\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n _typeof = function (obj) {\n return typeof obj;\n };\n } else {\n _typeof = function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n}\n\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nfunction ownKeys(object, enumerableOnly) {\n var keys = Object.keys(object);\n\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(object);\n if (enumerableOnly) symbols = symbols.filter(function (sym) {\n return Object.getOwnPropertyDescriptor(object, sym).enumerable;\n });\n keys.push.apply(keys, symbols);\n }\n\n return keys;\n}\n\nfunction _objectSpread2(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n\n if (i % 2) {\n ownKeys(source, true).forEach(function (key) {\n _defineProperty(target, key, source[key]);\n });\n } else if (Object.getOwnPropertyDescriptors) {\n Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));\n } else {\n ownKeys(source).forEach(function (key) {\n Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));\n });\n }\n }\n\n return target;\n}\n\nvar vendorPrefix;\nvar jsCssMap = {\n Webkit: '-webkit-',\n Moz: '-moz-',\n // IE did it wrong again ...\n ms: '-ms-',\n O: '-o-'\n};\n\nfunction getVendorPrefix() {\n if (vendorPrefix !== undefined) {\n return vendorPrefix;\n }\n\n vendorPrefix = '';\n var style = document.createElement('p').style;\n var testProp = 'Transform';\n\n for (var key in jsCssMap) {\n if (key + testProp in style) {\n vendorPrefix = key;\n }\n }\n\n return vendorPrefix;\n}\n\nfunction getTransitionName() {\n return getVendorPrefix() ? \"\".concat(getVendorPrefix(), \"TransitionProperty\") : 'transitionProperty';\n}\n\nfunction getTransformName() {\n return getVendorPrefix() ? \"\".concat(getVendorPrefix(), \"Transform\") : 'transform';\n}\nfunction setTransitionProperty(node, value) {\n var name = getTransitionName();\n\n if (name) {\n node.style[name] = value;\n\n if (name !== 'transitionProperty') {\n node.style.transitionProperty = value;\n }\n }\n}\n\nfunction setTransform(node, value) {\n var name = getTransformName();\n\n if (name) {\n node.style[name] = value;\n\n if (name !== 'transform') {\n node.style.transform = value;\n }\n }\n}\n\nfunction getTransitionProperty(node) {\n return node.style.transitionProperty || node.style[getTransitionName()];\n}\nfunction getTransformXY(node) {\n var style = window.getComputedStyle(node, null);\n var transform = style.getPropertyValue('transform') || style.getPropertyValue(getTransformName());\n\n if (transform && transform !== 'none') {\n var matrix = transform.replace(/[^0-9\\-.,]/g, '').split(',');\n return {\n x: parseFloat(matrix[12] || matrix[4], 0),\n y: parseFloat(matrix[13] || matrix[5], 0)\n };\n }\n\n return {\n x: 0,\n y: 0\n };\n}\nvar matrix2d = /matrix\\((.*)\\)/;\nvar matrix3d = /matrix3d\\((.*)\\)/;\nfunction setTransformXY(node, xy) {\n var style = window.getComputedStyle(node, null);\n var transform = style.getPropertyValue('transform') || style.getPropertyValue(getTransformName());\n\n if (transform && transform !== 'none') {\n var arr;\n var match2d = transform.match(matrix2d);\n\n if (match2d) {\n match2d = match2d[1];\n arr = match2d.split(',').map(function (item) {\n return parseFloat(item, 10);\n });\n arr[4] = xy.x;\n arr[5] = xy.y;\n setTransform(node, \"matrix(\".concat(arr.join(','), \")\"));\n } else {\n var match3d = transform.match(matrix3d)[1];\n arr = match3d.split(',').map(function (item) {\n return parseFloat(item, 10);\n });\n arr[12] = xy.x;\n arr[13] = xy.y;\n setTransform(node, \"matrix3d(\".concat(arr.join(','), \")\"));\n }\n } else {\n setTransform(node, \"translateX(\".concat(xy.x, \"px) translateY(\").concat(xy.y, \"px) translateZ(0)\"));\n }\n}\n\nvar RE_NUM = /[\\-+]?(?:\\d*\\.|)\\d+(?:[eE][\\-+]?\\d+|)/.source;\nvar getComputedStyleX; // https://stackoverflow.com/a/3485654/3040605\n\nfunction forceRelayout(elem) {\n var originalStyle = elem.style.display;\n elem.style.display = 'none';\n elem.offsetHeight; // eslint-disable-line\n\n elem.style.display = originalStyle;\n}\n\nfunction css(el, name, v) {\n var value = v;\n\n if (_typeof(name) === 'object') {\n for (var i in name) {\n if (name.hasOwnProperty(i)) {\n css(el, i, name[i]);\n }\n }\n\n return undefined;\n }\n\n if (typeof value !== 'undefined') {\n if (typeof value === 'number') {\n value = \"\".concat(value, \"px\");\n }\n\n el.style[name] = value;\n return undefined;\n }\n\n return getComputedStyleX(el, name);\n}\n\nfunction getClientPosition(elem) {\n var box;\n var x;\n var y;\n var doc = elem.ownerDocument;\n var body = doc.body;\n var docElem = doc && doc.documentElement; // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式\n\n box = elem.getBoundingClientRect(); // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop\n // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确\n // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin\n\n x = box.left;\n y = box.top; // In IE, most of the time, 2 extra pixels are added to the top and left\n // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and\n // IE6 standards mode, this border can be overridden by setting the\n // document element's border to zero -- thus, we cannot rely on the\n // offset always being 2 pixels.\n // In quirks mode, the offset can be determined by querying the body's\n // clientLeft/clientTop, but in standards mode, it is found by querying\n // the document element's clientLeft/clientTop. Since we already called\n // getClientBoundingRect we have already forced a reflow, so it is not\n // too expensive just to query them all.\n // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的\n // 窗口边框标准是设 documentElement ,quirks 时设置 body\n // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去\n // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置\n // 标准 ie 下 docElem.clientTop 就是 border-top\n // ie7 html 即窗口边框改变不了。永远为 2\n // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0\n\n x -= docElem.clientLeft || body.clientLeft || 0;\n y -= docElem.clientTop || body.clientTop || 0;\n return {\n left: x,\n top: y\n };\n}\n\nfunction getScroll(w, top) {\n var ret = w[\"page\".concat(top ? 'Y' : 'X', \"Offset\")];\n var method = \"scroll\".concat(top ? 'Top' : 'Left');\n\n if (typeof ret !== 'number') {\n var d = w.document; // ie6,7,8 standard mode\n\n ret = d.documentElement[method];\n\n if (typeof ret !== 'number') {\n // quirks mode\n ret = d.body[method];\n }\n }\n\n return ret;\n}\n\nfunction getScrollLeft(w) {\n return getScroll(w);\n}\n\nfunction getScrollTop(w) {\n return getScroll(w, true);\n}\n\nfunction getOffset(el) {\n var pos = getClientPosition(el);\n var doc = el.ownerDocument;\n var w = doc.defaultView || doc.parentWindow;\n pos.left += getScrollLeft(w);\n pos.top += getScrollTop(w);\n return pos;\n}\n/**\n * A crude way of determining if an object is a window\n * @member util\n */\n\n\nfunction isWindow(obj) {\n // must use == for ie8\n\n /* eslint eqeqeq:0 */\n return obj !== null && obj !== undefined && obj == obj.window;\n}\n\nfunction getDocument(node) {\n if (isWindow(node)) {\n return node.document;\n }\n\n if (node.nodeType === 9) {\n return node;\n }\n\n return node.ownerDocument;\n}\n\nfunction _getComputedStyle(elem, name, cs) {\n var computedStyle = cs;\n var val = '';\n var d = getDocument(elem);\n computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null); // https://github.com/kissyteam/kissy/issues/61\n\n if (computedStyle) {\n val = computedStyle.getPropertyValue(name) || computedStyle[name];\n }\n\n return val;\n}\n\nvar _RE_NUM_NO_PX = new RegExp(\"^(\".concat(RE_NUM, \")(?!px)[a-z%]+$\"), 'i');\n\nvar RE_POS = /^(top|right|bottom|left)$/;\nvar CURRENT_STYLE = 'currentStyle';\nvar RUNTIME_STYLE = 'runtimeStyle';\nvar LEFT = 'left';\nvar PX = 'px';\n\nfunction _getComputedStyleIE(elem, name) {\n // currentStyle maybe null\n // http://msdn.microsoft.com/en-us/library/ms535231.aspx\n var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值\n // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19\n // 在 ie 下不对,需要直接用 offset 方式\n // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了\n // From the awesome hack by Dean Edwards\n // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291\n // If we're not dealing with a regular pixel number\n // but a number that has a weird ending, we need to convert it to pixels\n // exclude left right for relativity\n\n if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {\n // Remember the original values\n var style = elem.style;\n var left = style[LEFT];\n var rsLeft = elem[RUNTIME_STYLE][LEFT]; // prevent flashing of content\n\n elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; // Put in the new values to get a computed value out\n\n style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;\n ret = style.pixelLeft + PX; // Revert the changed values\n\n style[LEFT] = left;\n elem[RUNTIME_STYLE][LEFT] = rsLeft;\n }\n\n return ret === '' ? 'auto' : ret;\n}\n\nif (typeof window !== 'undefined') {\n getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;\n}\n\nfunction getOffsetDirection(dir, option) {\n if (dir === 'left') {\n return option.useCssRight ? 'right' : dir;\n }\n\n return option.useCssBottom ? 'bottom' : dir;\n}\n\nfunction oppositeOffsetDirection(dir) {\n if (dir === 'left') {\n return 'right';\n } else if (dir === 'right') {\n return 'left';\n } else if (dir === 'top') {\n return 'bottom';\n } else if (dir === 'bottom') {\n return 'top';\n }\n} // 设置 elem 相对 elem.ownerDocument 的坐标\n\n\nfunction setLeftTop(elem, offset, option) {\n // set position first, in-case top/left are set even on static elem\n if (css(elem, 'position') === 'static') {\n elem.style.position = 'relative';\n }\n\n var presetH = -999;\n var presetV = -999;\n var horizontalProperty = getOffsetDirection('left', option);\n var verticalProperty = getOffsetDirection('top', option);\n var oppositeHorizontalProperty = oppositeOffsetDirection(horizontalProperty);\n var oppositeVerticalProperty = oppositeOffsetDirection(verticalProperty);\n\n if (horizontalProperty !== 'left') {\n presetH = 999;\n }\n\n if (verticalProperty !== 'top') {\n presetV = 999;\n }\n\n var originalTransition = '';\n var originalOffset = getOffset(elem);\n\n if ('left' in offset || 'top' in offset) {\n originalTransition = getTransitionProperty(elem) || '';\n setTransitionProperty(elem, 'none');\n }\n\n if ('left' in offset) {\n elem.style[oppositeHorizontalProperty] = '';\n elem.style[horizontalProperty] = \"\".concat(presetH, \"px\");\n }\n\n if ('top' in offset) {\n elem.style[oppositeVerticalProperty] = '';\n elem.style[verticalProperty] = \"\".concat(presetV, \"px\");\n } // force relayout\n\n\n forceRelayout(elem);\n var old = getOffset(elem);\n var originalStyle = {};\n\n for (var key in offset) {\n if (offset.hasOwnProperty(key)) {\n var dir = getOffsetDirection(key, option);\n var preset = key === 'left' ? presetH : presetV;\n var off = originalOffset[key] - old[key];\n\n if (dir === key) {\n originalStyle[dir] = preset + off;\n } else {\n originalStyle[dir] = preset - off;\n }\n }\n }\n\n css(elem, originalStyle); // force relayout\n\n forceRelayout(elem);\n\n if ('left' in offset || 'top' in offset) {\n setTransitionProperty(elem, originalTransition);\n }\n\n var ret = {};\n\n for (var _key in offset) {\n if (offset.hasOwnProperty(_key)) {\n var _dir = getOffsetDirection(_key, option);\n\n var _off = offset[_key] - originalOffset[_key];\n\n if (_key === _dir) {\n ret[_dir] = originalStyle[_dir] + _off;\n } else {\n ret[_dir] = originalStyle[_dir] - _off;\n }\n }\n }\n\n css(elem, ret);\n}\n\nfunction setTransform$1(elem, offset) {\n var originalOffset = getOffset(elem);\n var originalXY = getTransformXY(elem);\n var resultXY = {\n x: originalXY.x,\n y: originalXY.y\n };\n\n if ('left' in offset) {\n resultXY.x = originalXY.x + offset.left - originalOffset.left;\n }\n\n if ('top' in offset) {\n resultXY.y = originalXY.y + offset.top - originalOffset.top;\n }\n\n setTransformXY(elem, resultXY);\n}\n\nfunction setOffset(elem, offset, option) {\n if (option.ignoreShake) {\n var oriOffset = getOffset(elem);\n var oLeft = oriOffset.left.toFixed(0);\n var oTop = oriOffset.top.toFixed(0);\n var tLeft = offset.left.toFixed(0);\n var tTop = offset.top.toFixed(0);\n\n if (oLeft === tLeft && oTop === tTop) {\n return;\n }\n }\n\n if (option.useCssRight || option.useCssBottom) {\n setLeftTop(elem, offset, option);\n } else if (option.useCssTransform && getTransformName() in document.body.style) {\n setTransform$1(elem, offset);\n } else {\n setLeftTop(elem, offset, option);\n }\n}\n\nfunction each(arr, fn) {\n for (var i = 0; i < arr.length; i++) {\n fn(arr[i]);\n }\n}\n\nfunction isBorderBoxFn(elem) {\n return getComputedStyleX(elem, 'boxSizing') === 'border-box';\n}\n\nvar BOX_MODELS = ['margin', 'border', 'padding'];\nvar CONTENT_INDEX = -1;\nvar PADDING_INDEX = 2;\nvar BORDER_INDEX = 1;\nvar MARGIN_INDEX = 0;\n\nfunction swap(elem, options, callback) {\n var old = {};\n var style = elem.style;\n var name; // Remember the old values, and insert the new ones\n\n for (name in options) {\n if (options.hasOwnProperty(name)) {\n old[name] = style[name];\n style[name] = options[name];\n }\n }\n\n callback.call(elem); // Revert the old values\n\n for (name in options) {\n if (options.hasOwnProperty(name)) {\n style[name] = old[name];\n }\n }\n}\n\nfunction getPBMWidth(elem, props, which) {\n var value = 0;\n var prop;\n var j;\n var i;\n\n for (j = 0; j < props.length; j++) {\n prop = props[j];\n\n if (prop) {\n for (i = 0; i < which.length; i++) {\n var cssProp = void 0;\n\n if (prop === 'border') {\n cssProp = \"\".concat(prop).concat(which[i], \"Width\");\n } else {\n cssProp = prop + which[i];\n }\n\n value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;\n }\n }\n }\n\n return value;\n}\n\nvar domUtils = {\n getParent: function getParent(element) {\n var parent = element;\n\n do {\n if (parent.nodeType === 11 && parent.host) {\n parent = parent.host;\n } else {\n parent = parent.parentNode;\n }\n } while (parent && parent.nodeType !== 1 && parent.nodeType !== 9);\n\n return parent;\n }\n};\neach(['Width', 'Height'], function (name) {\n domUtils[\"doc\".concat(name)] = function (refWin) {\n var d = refWin.document;\n return Math.max( // firefox chrome documentElement.scrollHeight< body.scrollHeight\n // ie standard mode : documentElement.scrollHeight> body.scrollHeight\n d.documentElement[\"scroll\".concat(name)], // quirks : documentElement.scrollHeight 最大等于可视窗口多一点?\n d.body[\"scroll\".concat(name)], domUtils[\"viewport\".concat(name)](d));\n };\n\n domUtils[\"viewport\".concat(name)] = function (win) {\n // pc browser includes scrollbar in window.innerWidth\n var prop = \"client\".concat(name);\n var doc = win.document;\n var body = doc.body;\n var documentElement = doc.documentElement;\n var documentElementProp = documentElement[prop]; // 标准模式取 documentElement\n // backcompat 取 body\n\n return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;\n };\n});\n/*\n 得到元素的大小信息\n @param elem\n @param name\n @param {String} [extra] 'padding' : (css width) + padding\n 'border' : (css width) + padding + border\n 'margin' : (css width) + padding + border + margin\n */\n\nfunction getWH(elem, name, ex) {\n var extra = ex;\n\n if (isWindow(elem)) {\n return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);\n } else if (elem.nodeType === 9) {\n return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);\n }\n\n var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];\n var borderBoxValue = name === 'width' ? elem.getBoundingClientRect().width : elem.getBoundingClientRect().height;\n var computedStyle = getComputedStyleX(elem);\n var isBorderBox = isBorderBoxFn(elem);\n var cssBoxValue = 0;\n\n if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) {\n borderBoxValue = undefined; // Fall back to computed then un computed css if necessary\n\n cssBoxValue = getComputedStyleX(elem, name);\n\n if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) {\n cssBoxValue = elem.style[name] || 0;\n } // Normalize '', auto, and prepare for extra\n\n\n cssBoxValue = parseFloat(cssBoxValue) || 0;\n }\n\n if (extra === undefined) {\n extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;\n }\n\n var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;\n var val = borderBoxValue || cssBoxValue;\n\n if (extra === CONTENT_INDEX) {\n if (borderBoxValueOrIsBorderBox) {\n return val - getPBMWidth(elem, ['border', 'padding'], which);\n }\n\n return cssBoxValue;\n } else if (borderBoxValueOrIsBorderBox) {\n if (extra === BORDER_INDEX) {\n return val;\n }\n\n return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which) : getPBMWidth(elem, ['margin'], which));\n }\n\n return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which);\n}\n\nvar cssShow = {\n position: 'absolute',\n visibility: 'hidden',\n display: 'block'\n}; // fix #119 : https://github.com/kissyteam/kissy/issues/119\n\nfunction getWHIgnoreDisplay() {\n for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n var val;\n var elem = args[0]; // in case elem is window\n // elem.offsetWidth === undefined\n\n if (elem.offsetWidth !== 0) {\n val = getWH.apply(undefined, args);\n } else {\n swap(elem, cssShow, function () {\n val = getWH.apply(undefined, args);\n });\n }\n\n return val;\n}\n\neach(['width', 'height'], function (name) {\n var first = name.charAt(0).toUpperCase() + name.slice(1);\n\n domUtils[\"outer\".concat(first)] = function (el, includeMargin) {\n return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);\n };\n\n var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];\n\n domUtils[name] = function (elem, v) {\n var val = v;\n\n if (val !== undefined) {\n if (elem) {\n var computedStyle = getComputedStyleX(elem);\n var isBorderBox = isBorderBoxFn(elem);\n\n if (isBorderBox) {\n val += getPBMWidth(elem, ['padding', 'border'], which);\n }\n\n return css(elem, name, val);\n }\n\n return undefined;\n }\n\n return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);\n };\n});\n\nfunction mix(to, from) {\n for (var i in from) {\n if (from.hasOwnProperty(i)) {\n to[i] = from[i];\n }\n }\n\n return to;\n}\n\nvar utils = {\n getWindow: function getWindow(node) {\n if (node && node.document && node.setTimeout) {\n return node;\n }\n\n var doc = node.ownerDocument || node;\n return doc.defaultView || doc.parentWindow;\n },\n getDocument: getDocument,\n offset: function offset(el, value, option) {\n if (typeof value !== 'undefined') {\n setOffset(el, value, option || {});\n } else {\n return getOffset(el);\n }\n },\n isWindow: isWindow,\n each: each,\n css: css,\n clone: function clone(obj) {\n var i;\n var ret = {};\n\n for (i in obj) {\n if (obj.hasOwnProperty(i)) {\n ret[i] = obj[i];\n }\n }\n\n var overflow = obj.overflow;\n\n if (overflow) {\n for (i in obj) {\n if (obj.hasOwnProperty(i)) {\n ret.overflow[i] = obj.overflow[i];\n }\n }\n }\n\n return ret;\n },\n mix: mix,\n getWindowScrollLeft: function getWindowScrollLeft(w) {\n return getScrollLeft(w);\n },\n getWindowScrollTop: function getWindowScrollTop(w) {\n return getScrollTop(w);\n },\n merge: function merge() {\n var ret = {};\n\n for (var i = 0; i < arguments.length; i++) {\n utils.mix(ret, i < 0 || arguments.length <= i ? undefined : arguments[i]);\n }\n\n return ret;\n },\n viewportWidth: 0,\n viewportHeight: 0\n};\nmix(utils, domUtils);\n\n/**\n * 得到会导致元素显示不全的祖先元素\n */\n\nvar getParent = utils.getParent;\n\nfunction getOffsetParent(element) {\n if (utils.isWindow(element) || element.nodeType === 9) {\n return null;\n } // ie 这个也不是完全可行\n\n /*\n
\n
\n 元素 6 高 100px 宽 50px
\n
\n
\n */\n // element.offsetParent does the right thing in ie7 and below. Return parent with layout!\n // In other browsers it only includes elements with position absolute, relative or\n // fixed, not elements with overflow set to auto or scroll.\n // if (UA.ie && ieMode < 8) {\n // return element.offsetParent;\n // }\n // 统一的 offsetParent 方法\n\n\n var doc = utils.getDocument(element);\n var body = doc.body;\n var parent;\n var positionStyle = utils.css(element, 'position');\n var skipStatic = positionStyle === 'fixed' || positionStyle === 'absolute';\n\n if (!skipStatic) {\n return element.nodeName.toLowerCase() === 'html' ? null : getParent(element);\n }\n\n for (parent = getParent(element); parent && parent !== body && parent.nodeType !== 9; parent = getParent(parent)) {\n positionStyle = utils.css(parent, 'position');\n\n if (positionStyle !== 'static') {\n return parent;\n }\n }\n\n return null;\n}\n\nvar getParent$1 = utils.getParent;\nfunction isAncestorFixed(element) {\n if (utils.isWindow(element) || element.nodeType === 9) {\n return false;\n }\n\n var doc = utils.getDocument(element);\n var body = doc.body;\n var parent = null;\n\n for (parent = getParent$1(element); parent && parent !== body; parent = getParent$1(parent)) {\n var positionStyle = utils.css(parent, 'position');\n\n if (positionStyle === 'fixed') {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * 获得元素的显示部分的区域\n */\n\nfunction getVisibleRectForElement(element, alwaysByViewport) {\n var visibleRect = {\n left: 0,\n right: Infinity,\n top: 0,\n bottom: Infinity\n };\n var el = getOffsetParent(element);\n var doc = utils.getDocument(element);\n var win = doc.defaultView || doc.parentWindow;\n var body = doc.body;\n var documentElement = doc.documentElement; // Determine the size of the visible rect by climbing the dom accounting for\n // all scrollable containers.\n\n while (el) {\n // clientWidth is zero for inline block elements in ie.\n if ((navigator.userAgent.indexOf('MSIE') === -1 || el.clientWidth !== 0) && // body may have overflow set on it, yet we still get the entire\n // viewport. In some browsers, el.offsetParent may be\n // document.documentElement, so check for that too.\n el !== body && el !== documentElement && utils.css(el, 'overflow') !== 'visible') {\n var pos = utils.offset(el); // add border\n\n pos.left += el.clientLeft;\n pos.top += el.clientTop;\n visibleRect.top = Math.max(visibleRect.top, pos.top);\n visibleRect.right = Math.min(visibleRect.right, // consider area without scrollBar\n pos.left + el.clientWidth);\n visibleRect.bottom = Math.min(visibleRect.bottom, pos.top + el.clientHeight);\n visibleRect.left = Math.max(visibleRect.left, pos.left);\n } else if (el === body || el === documentElement) {\n break;\n }\n\n el = getOffsetParent(el);\n } // Set element position to fixed\n // make sure absolute element itself don't affect it's visible area\n // https://github.com/ant-design/ant-design/issues/7601\n\n\n var originalPosition = null;\n\n if (!utils.isWindow(element) && element.nodeType !== 9) {\n originalPosition = element.style.position;\n var position = utils.css(element, 'position');\n\n if (position === 'absolute') {\n element.style.position = 'fixed';\n }\n }\n\n var scrollX = utils.getWindowScrollLeft(win);\n var scrollY = utils.getWindowScrollTop(win);\n var viewportWidth = utils.viewportWidth(win);\n var viewportHeight = utils.viewportHeight(win);\n var documentWidth = documentElement.scrollWidth;\n var documentHeight = documentElement.scrollHeight; // scrollXXX on html is sync with body which means overflow: hidden on body gets wrong scrollXXX.\n // We should cut this ourself.\n\n var bodyStyle = window.getComputedStyle(body);\n\n if (bodyStyle.overflowX === 'hidden') {\n documentWidth = win.innerWidth;\n }\n\n if (bodyStyle.overflowY === 'hidden') {\n documentHeight = win.innerHeight;\n } // Reset element position after calculate the visible area\n\n\n if (element.style) {\n element.style.position = originalPosition;\n }\n\n if (alwaysByViewport || isAncestorFixed(element)) {\n // Clip by viewport's size.\n visibleRect.left = Math.max(visibleRect.left, scrollX);\n visibleRect.top = Math.max(visibleRect.top, scrollY);\n visibleRect.right = Math.min(visibleRect.right, scrollX + viewportWidth);\n visibleRect.bottom = Math.min(visibleRect.bottom, scrollY + viewportHeight);\n } else {\n // Clip by document's size.\n var maxVisibleWidth = Math.max(documentWidth, scrollX + viewportWidth);\n visibleRect.right = Math.min(visibleRect.right, maxVisibleWidth);\n var maxVisibleHeight = Math.max(documentHeight, scrollY + viewportHeight);\n visibleRect.bottom = Math.min(visibleRect.bottom, maxVisibleHeight);\n }\n\n return visibleRect.top >= 0 && visibleRect.left >= 0 && visibleRect.bottom > visibleRect.top && visibleRect.right > visibleRect.left ? visibleRect : null;\n}\n\nfunction adjustForViewport(elFuturePos, elRegion, visibleRect, overflow) {\n var pos = utils.clone(elFuturePos);\n var size = {\n width: elRegion.width,\n height: elRegion.height\n };\n\n if (overflow.adjustX && pos.left < visibleRect.left) {\n pos.left = visibleRect.left;\n } // Left edge inside and right edge outside viewport, try to resize it.\n\n\n if (overflow.resizeWidth && pos.left >= visibleRect.left && pos.left + size.width > visibleRect.right) {\n size.width -= pos.left + size.width - visibleRect.right;\n } // Right edge outside viewport, try to move it.\n\n\n if (overflow.adjustX && pos.left + size.width > visibleRect.right) {\n // 保证左边界和可视区域左边界对齐\n pos.left = Math.max(visibleRect.right - size.width, visibleRect.left);\n } // Top edge outside viewport, try to move it.\n\n\n if (overflow.adjustY && pos.top < visibleRect.top) {\n pos.top = visibleRect.top;\n } // Top edge inside and bottom edge outside viewport, try to resize it.\n\n\n if (overflow.resizeHeight && pos.top >= visibleRect.top && pos.top + size.height > visibleRect.bottom) {\n size.height -= pos.top + size.height - visibleRect.bottom;\n } // Bottom edge outside viewport, try to move it.\n\n\n if (overflow.adjustY && pos.top + size.height > visibleRect.bottom) {\n // 保证上边界和可视区域上边界对齐\n pos.top = Math.max(visibleRect.bottom - size.height, visibleRect.top);\n }\n\n return utils.mix(pos, size);\n}\n\nfunction getRegion(node) {\n var offset;\n var w;\n var h;\n\n if (!utils.isWindow(node) && node.nodeType !== 9) {\n offset = utils.offset(node);\n w = utils.outerWidth(node);\n h = utils.outerHeight(node);\n } else {\n var win = utils.getWindow(node);\n offset = {\n left: utils.getWindowScrollLeft(win),\n top: utils.getWindowScrollTop(win)\n };\n w = utils.viewportWidth(win);\n h = utils.viewportHeight(win);\n }\n\n offset.width = w;\n offset.height = h;\n return offset;\n}\n\n/**\n * 获取 node 上的 align 对齐点 相对于页面的坐标\n */\nfunction getAlignOffset(region, align) {\n var V = align.charAt(0);\n var H = align.charAt(1);\n var w = region.width;\n var h = region.height;\n var x = region.left;\n var y = region.top;\n\n if (V === 'c') {\n y += h / 2;\n } else if (V === 'b') {\n y += h;\n }\n\n if (H === 'c') {\n x += w / 2;\n } else if (H === 'r') {\n x += w;\n }\n\n return {\n left: x,\n top: y\n };\n}\n\nfunction getElFuturePos(elRegion, refNodeRegion, points, offset, targetOffset) {\n var p1 = getAlignOffset(refNodeRegion, points[1]);\n var p2 = getAlignOffset(elRegion, points[0]);\n var diff = [p2.left - p1.left, p2.top - p1.top];\n return {\n left: Math.round(elRegion.left - diff[0] + offset[0] - targetOffset[0]),\n top: Math.round(elRegion.top - diff[1] + offset[1] - targetOffset[1])\n };\n}\n\n/**\n * align dom node flexibly\n * @author yiminghe@gmail.com\n */\n\nfunction isFailX(elFuturePos, elRegion, visibleRect) {\n return elFuturePos.left < visibleRect.left || elFuturePos.left + elRegion.width > visibleRect.right;\n}\n\nfunction isFailY(elFuturePos, elRegion, visibleRect) {\n return elFuturePos.top < visibleRect.top || elFuturePos.top + elRegion.height > visibleRect.bottom;\n}\n\nfunction isCompleteFailX(elFuturePos, elRegion, visibleRect) {\n return elFuturePos.left > visibleRect.right || elFuturePos.left + elRegion.width < visibleRect.left;\n}\n\nfunction isCompleteFailY(elFuturePos, elRegion, visibleRect) {\n return elFuturePos.top > visibleRect.bottom || elFuturePos.top + elRegion.height < visibleRect.top;\n}\n\nfunction flip(points, reg, map) {\n var ret = [];\n utils.each(points, function (p) {\n ret.push(p.replace(reg, function (m) {\n return map[m];\n }));\n });\n return ret;\n}\n\nfunction flipOffset(offset, index) {\n offset[index] = -offset[index];\n return offset;\n}\n\nfunction convertOffset(str, offsetLen) {\n var n;\n\n if (/%$/.test(str)) {\n n = parseInt(str.substring(0, str.length - 1), 10) / 100 * offsetLen;\n } else {\n n = parseInt(str, 10);\n }\n\n return n || 0;\n}\n\nfunction normalizeOffset(offset, el) {\n offset[0] = convertOffset(offset[0], el.width);\n offset[1] = convertOffset(offset[1], el.height);\n}\n/**\n * @param el\n * @param tgtRegion 参照节点所占的区域: { left, top, width, height }\n * @param align\n */\n\n\nfunction doAlign(el, tgtRegion, align, isTgtRegionVisible) {\n var points = align.points;\n var offset = align.offset || [0, 0];\n var targetOffset = align.targetOffset || [0, 0];\n var overflow = align.overflow;\n var source = align.source || el;\n offset = [].concat(offset);\n targetOffset = [].concat(targetOffset);\n overflow = overflow || {};\n var newOverflowCfg = {};\n var fail = 0;\n var alwaysByViewport = !!(overflow && overflow.alwaysByViewport); // 当前节点可以被放置的显示区域\n\n var visibleRect = getVisibleRectForElement(source, alwaysByViewport); // 当前节点所占的区域, left/top/width/height\n\n var elRegion = getRegion(source); // 将 offset 转换成数值,支持百分比\n\n normalizeOffset(offset, elRegion);\n normalizeOffset(targetOffset, tgtRegion); // 当前节点将要被放置的位置\n\n var elFuturePos = getElFuturePos(elRegion, tgtRegion, points, offset, targetOffset); // 当前节点将要所处的区域\n\n var newElRegion = utils.merge(elRegion, elFuturePos); // 如果可视区域不能完全放置当前节点时允许调整\n\n if (visibleRect && (overflow.adjustX || overflow.adjustY) && isTgtRegionVisible) {\n if (overflow.adjustX) {\n // 如果横向不能放下\n if (isFailX(elFuturePos, elRegion, visibleRect)) {\n // 对齐位置反下\n var newPoints = flip(points, /[lr]/gi, {\n l: 'r',\n r: 'l'\n }); // 偏移量也反下\n\n var newOffset = flipOffset(offset, 0);\n var newTargetOffset = flipOffset(targetOffset, 0);\n var newElFuturePos = getElFuturePos(elRegion, tgtRegion, newPoints, newOffset, newTargetOffset);\n\n if (!isCompleteFailX(newElFuturePos, elRegion, visibleRect)) {\n fail = 1;\n points = newPoints;\n offset = newOffset;\n targetOffset = newTargetOffset;\n }\n }\n }\n\n if (overflow.adjustY) {\n // 如果纵向不能放下\n if (isFailY(elFuturePos, elRegion, visibleRect)) {\n // 对齐位置反下\n var _newPoints = flip(points, /[tb]/gi, {\n t: 'b',\n b: 't'\n }); // 偏移量也反下\n\n\n var _newOffset = flipOffset(offset, 1);\n\n var _newTargetOffset = flipOffset(targetOffset, 1);\n\n var _newElFuturePos = getElFuturePos(elRegion, tgtRegion, _newPoints, _newOffset, _newTargetOffset);\n\n if (!isCompleteFailY(_newElFuturePos, elRegion, visibleRect)) {\n fail = 1;\n points = _newPoints;\n offset = _newOffset;\n targetOffset = _newTargetOffset;\n }\n }\n } // 如果失败,重新计算当前节点将要被放置的位置\n\n\n if (fail) {\n elFuturePos = getElFuturePos(elRegion, tgtRegion, points, offset, targetOffset);\n utils.mix(newElRegion, elFuturePos);\n }\n\n var isStillFailX = isFailX(elFuturePos, elRegion, visibleRect);\n var isStillFailY = isFailY(elFuturePos, elRegion, visibleRect); // 检查反下后的位置是否可以放下了,如果仍然放不下:\n // 1. 复原修改过的定位参数\n\n if (isStillFailX || isStillFailY) {\n points = align.points;\n offset = align.offset || [0, 0];\n targetOffset = align.targetOffset || [0, 0];\n } // 2. 只有指定了可以调整当前方向才调整\n\n\n newOverflowCfg.adjustX = overflow.adjustX && isStillFailX;\n newOverflowCfg.adjustY = overflow.adjustY && isStillFailY; // 确实要调整,甚至可能会调整高度宽度\n\n if (newOverflowCfg.adjustX || newOverflowCfg.adjustY) {\n newElRegion = adjustForViewport(elFuturePos, elRegion, visibleRect, newOverflowCfg);\n }\n } // need judge to in case set fixed with in css on height auto element\n\n\n if (newElRegion.width !== elRegion.width) {\n utils.css(source, 'width', utils.width(source) + newElRegion.width - elRegion.width);\n }\n\n if (newElRegion.height !== elRegion.height) {\n utils.css(source, 'height', utils.height(source) + newElRegion.height - elRegion.height);\n } // https://github.com/kissyteam/kissy/issues/190\n // 相对于屏幕位置没变,而 left/top 变了\n // 例如
\n\n\n utils.offset(source, {\n left: newElRegion.left,\n top: newElRegion.top\n }, {\n useCssRight: align.useCssRight,\n useCssBottom: align.useCssBottom,\n useCssTransform: align.useCssTransform,\n ignoreShake: align.ignoreShake\n });\n return {\n points: points,\n offset: offset,\n targetOffset: targetOffset,\n overflow: newOverflowCfg\n };\n}\n/**\n * 2012-04-26 yiminghe@gmail.com\n * - 优化智能对齐算法\n * - 慎用 resizeXX\n *\n * 2011-07-13 yiminghe@gmail.com note:\n * - 增加智能对齐,以及大小调整选项\n **/\n\nfunction isOutOfVisibleRect(target, alwaysByViewport) {\n var visibleRect = getVisibleRectForElement(target, alwaysByViewport);\n var targetRegion = getRegion(target);\n return !visibleRect || targetRegion.left + targetRegion.width <= visibleRect.left || targetRegion.top + targetRegion.height <= visibleRect.top || targetRegion.left >= visibleRect.right || targetRegion.top >= visibleRect.bottom;\n}\n\nfunction alignElement(el, refNode, align) {\n var target = align.target || refNode;\n var refNodeRegion = getRegion(target);\n var isTargetNotOutOfVisible = !isOutOfVisibleRect(target, align.overflow && align.overflow.alwaysByViewport);\n return doAlign(el, refNodeRegion, align, isTargetNotOutOfVisible);\n}\n\nalignElement.__getOffsetParent = getOffsetParent;\nalignElement.__getVisibleRectForElement = getVisibleRectForElement;\n\n/**\n * `tgtPoint`: { pageX, pageY } or { clientX, clientY }.\n * If client position provided, will internal convert to page position.\n */\n\nfunction alignPoint(el, tgtPoint, align) {\n var pageX;\n var pageY;\n var doc = utils.getDocument(el);\n var win = doc.defaultView || doc.parentWindow;\n var scrollX = utils.getWindowScrollLeft(win);\n var scrollY = utils.getWindowScrollTop(win);\n var viewportWidth = utils.viewportWidth(win);\n var viewportHeight = utils.viewportHeight(win);\n\n if ('pageX' in tgtPoint) {\n pageX = tgtPoint.pageX;\n } else {\n pageX = scrollX + tgtPoint.clientX;\n }\n\n if ('pageY' in tgtPoint) {\n pageY = tgtPoint.pageY;\n } else {\n pageY = scrollY + tgtPoint.clientY;\n }\n\n var tgtRegion = {\n left: pageX,\n top: pageY,\n width: 0,\n height: 0\n };\n var pointInView = pageX >= 0 && pageX <= scrollX + viewportWidth && pageY >= 0 && pageY <= scrollY + viewportHeight; // Provide default target point\n\n var points = [align.points[0], 'cc'];\n return doAlign(el, tgtRegion, _objectSpread2({}, align, {\n points: points\n }), pointInView);\n}\n\nexport default alignElement;\nexport { alignElement, alignPoint };\n//# sourceMappingURL=index.js.map\n","function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nimport ResizeObserver from 'resize-observer-polyfill';\nimport contains from \"rc-util/es/Dom/contains\";\nexport function isSamePoint(prev, next) {\n if (prev === next) return true;\n if (!prev || !next) return false;\n\n if ('pageX' in next && 'pageY' in next) {\n return prev.pageX === next.pageX && prev.pageY === next.pageY;\n }\n\n if ('clientX' in next && 'clientY' in next) {\n return prev.clientX === next.clientX && prev.clientY === next.clientY;\n }\n\n return false;\n}\nexport function restoreFocus(activeElement, container) {\n // Focus back if is in the container\n if (activeElement !== document.activeElement && contains(container, activeElement)) {\n activeElement.focus();\n }\n}\nexport function monitorResize(element, callback) {\n var prevWidth = null;\n var prevHeight = null;\n\n function onResize(_ref) {\n var _ref2 = _slicedToArray(_ref, 1),\n target = _ref2[0].target;\n\n var _target$getBoundingCl = target.getBoundingClientRect(),\n width = _target$getBoundingCl.width,\n height = _target$getBoundingCl.height;\n\n var fixedWidth = Math.floor(width);\n var fixedHeight = Math.floor(height);\n\n if (prevWidth !== fixedWidth || prevHeight !== fixedHeight) {\n callback({\n width: fixedWidth,\n height: fixedHeight\n });\n }\n\n prevWidth = fixedWidth;\n prevHeight = fixedHeight;\n }\n\n var resizeObserver = new ResizeObserver(onResize);\n\n if (element) {\n resizeObserver.observe(element);\n }\n\n return function () {\n resizeObserver.disconnect();\n };\n}","function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/**\n * Removed props:\n * - childrenProps\n */\nimport React from 'react';\nimport { composeRef } from \"rc-util/es/ref\";\nimport { alignElement, alignPoint } from 'dom-align';\nimport addEventListener from \"rc-util/es/Dom/addEventListener\";\nimport { isSamePoint, restoreFocus, monitorResize } from './util';\nimport useBuffer from './hooks/useBuffer';\n\nfunction getElement(func) {\n if (typeof func !== 'function') return null;\n return func();\n}\n\nfunction getPoint(point) {\n if (_typeof(point) !== 'object' || !point) return null;\n return point;\n}\n\nvar Align = function Align(_ref, ref) {\n var children = _ref.children,\n disabled = _ref.disabled,\n target = _ref.target,\n align = _ref.align,\n onAlign = _ref.onAlign,\n monitorWindowResize = _ref.monitorWindowResize,\n _ref$monitorBufferTim = _ref.monitorBufferTime,\n monitorBufferTime = _ref$monitorBufferTim === void 0 ? 0 : _ref$monitorBufferTim;\n var cacheRef = React.useRef({});\n var nodeRef = React.useRef();\n var childNode = React.Children.only(children); // ===================== Align ======================\n // We save the props here to avoid closure makes props ood\n\n var forceAlignPropsRef = React.useRef({});\n forceAlignPropsRef.current.disabled = disabled;\n forceAlignPropsRef.current.target = target;\n forceAlignPropsRef.current.onAlign = onAlign;\n\n var _useBuffer = useBuffer(function () {\n var _forceAlignPropsRef$c = forceAlignPropsRef.current,\n latestDisabled = _forceAlignPropsRef$c.disabled,\n latestTarget = _forceAlignPropsRef$c.target;\n\n if (!latestDisabled && latestTarget) {\n var source = nodeRef.current;\n var result;\n var element = getElement(latestTarget);\n var point = getPoint(latestTarget);\n cacheRef.current.element = element;\n cacheRef.current.point = point; // IE lose focus after element realign\n // We should record activeElement and restore later\n\n var _document = document,\n activeElement = _document.activeElement;\n\n if (element) {\n result = alignElement(source, element, align);\n } else if (point) {\n result = alignPoint(source, point, align);\n }\n\n restoreFocus(activeElement, source);\n\n if (onAlign) {\n onAlign(source, result);\n }\n\n return true;\n }\n\n return false;\n }, monitorBufferTime),\n _useBuffer2 = _slicedToArray(_useBuffer, 2),\n _forceAlign = _useBuffer2[0],\n cancelForceAlign = _useBuffer2[1]; // ===================== Effect =====================\n // Listen for target updated\n\n\n var resizeMonitor = React.useRef({\n cancel: function cancel() {}\n }); // Listen for source updated\n\n var sourceResizeMonitor = React.useRef({\n cancel: function cancel() {}\n });\n React.useEffect(function () {\n var element = getElement(target);\n var point = getPoint(target);\n\n if (nodeRef.current !== sourceResizeMonitor.current.element) {\n sourceResizeMonitor.current.cancel();\n sourceResizeMonitor.current.element = nodeRef.current;\n sourceResizeMonitor.current.cancel = monitorResize(nodeRef.current, _forceAlign);\n }\n\n if (cacheRef.current.element !== element || !isSamePoint(cacheRef.current.point, point)) {\n _forceAlign(); // Add resize observer\n\n\n if (resizeMonitor.current.element !== element) {\n resizeMonitor.current.cancel();\n resizeMonitor.current.element = element;\n resizeMonitor.current.cancel = monitorResize(element, _forceAlign);\n }\n }\n }); // Listen for disabled change\n\n React.useEffect(function () {\n if (!disabled) {\n _forceAlign();\n } else {\n cancelForceAlign();\n }\n }, [disabled]); // Listen for window resize\n\n var winResizeRef = React.useRef(null);\n React.useEffect(function () {\n if (monitorWindowResize) {\n if (!winResizeRef.current) {\n winResizeRef.current = addEventListener(window, 'resize', _forceAlign);\n }\n } else if (winResizeRef.current) {\n winResizeRef.current.remove();\n winResizeRef.current = null;\n }\n }, [monitorWindowResize]); // Clear all if unmount\n\n React.useEffect(function () {\n return function () {\n resizeMonitor.current.cancel();\n sourceResizeMonitor.current.cancel();\n if (winResizeRef.current) winResizeRef.current.remove();\n cancelForceAlign();\n };\n }, []); // ====================== Ref =======================\n\n React.useImperativeHandle(ref, function () {\n return {\n forceAlign: function forceAlign() {\n return _forceAlign(true);\n }\n };\n }); // ===================== Render =====================\n\n if (React.isValidElement(childNode)) {\n childNode = React.cloneElement(childNode, {\n ref: composeRef(childNode.ref, nodeRef)\n });\n }\n\n return childNode;\n};\n\nvar RefAlign = React.forwardRef(Align);\nRefAlign.displayName = 'Align';\nexport default RefAlign;","import React from 'react';\nexport default (function (callback, buffer) {\n var calledRef = React.useRef(false);\n var timeoutRef = React.useRef(null);\n\n function cancelTrigger() {\n window.clearTimeout(timeoutRef.current);\n }\n\n function trigger(force) {\n if (!calledRef.current || force === true) {\n if (callback() === false) {\n // Not delay since callback cancelled self\n return;\n }\n\n calledRef.current = true;\n cancelTrigger();\n timeoutRef.current = window.setTimeout(function () {\n calledRef.current = false;\n }, buffer);\n } else {\n cancelTrigger();\n timeoutRef.current = window.setTimeout(function () {\n calledRef.current = false;\n trigger();\n }, buffer);\n }\n }\n\n return [trigger, function () {\n calledRef.current = false;\n cancelTrigger();\n }];\n});","// export this package's api\nimport Align from './Align';\nexport default Align;","import React from 'react';\nimport classNames from 'classnames';\n\nvar PopupInner = function PopupInner(props, ref) {\n var prefixCls = props.prefixCls,\n className = props.className,\n visible = props.visible,\n style = props.style,\n children = props.children,\n onMouseEnter = props.onMouseEnter,\n onMouseLeave = props.onMouseLeave,\n onMouseDown = props.onMouseDown,\n onTouchStart = props.onTouchStart;\n var childNode = children;\n\n if (React.Children.count(children) > 1) {\n childNode = React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-content\")\n }, children);\n }\n\n return React.createElement(\"div\", {\n ref: ref,\n className: classNames(className, !visible && \"\".concat(props.hiddenClassName)),\n onMouseEnter: onMouseEnter,\n onMouseLeave: onMouseLeave,\n onMouseDown: onMouseDown,\n onTouchStart: onTouchStart,\n style: style\n }, childNode);\n};\n\nvar RefPopupInner = React.forwardRef(PopupInner);\nRefPopupInner.displayName = 'PopupInner';\nexport default RefPopupInner;","export function getMotion(_ref) {\n var prefixCls = _ref.prefixCls,\n motion = _ref.motion,\n animation = _ref.animation,\n transitionName = _ref.transitionName;\n\n if (motion) {\n return motion;\n }\n\n if (animation) {\n return {\n motionName: \"\".concat(prefixCls, \"-\").concat(animation)\n };\n }\n\n if (transitionName) {\n return {\n motionName: transitionName\n };\n }\n\n return null;\n}","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n/* eslint-disable no-param-reassign */\nimport React, { Component } from 'react';\nimport raf from 'raf';\nimport Align from 'rc-align';\nimport { composeRef } from \"rc-util/es/ref\";\nimport classNames from 'classnames';\nimport RawCSSMotion from \"rc-animate/es/CSSMotion\";\nimport PopupInner from './PopupInner';\nimport { getMotion } from './utils/legacyUtil';\nvar CSSMotion = RawCSSMotion;\n\nfunction supportMotion(motion) {\n return motion && motion.motionName;\n}\n\nvar Popup =\n/*#__PURE__*/\nfunction (_Component) {\n _inherits(Popup, _Component);\n\n function Popup() {\n var _this;\n\n _classCallCheck(this, Popup);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Popup).apply(this, arguments));\n _this.state = {\n targetWidth: undefined,\n targetHeight: undefined,\n status: null,\n prevVisible: null,\n alignClassName: null\n };\n _this.popupRef = React.createRef();\n _this.alignRef = React.createRef();\n _this.nextFrameState = null;\n _this.nextFrameId = null;\n\n _this.onAlign = function (popupDomNode, align) {\n var status = _this.state.status;\n var _this$props = _this.props,\n getClassNameFromAlign = _this$props.getClassNameFromAlign,\n onAlign = _this$props.onAlign;\n var alignClassName = getClassNameFromAlign(align);\n\n if (status === 'align') {\n _this.setState({\n alignClassName: alignClassName,\n status: 'aligned'\n }, function () {\n _this.alignRef.current.forceAlign();\n });\n } else if (status === 'aligned') {\n _this.setState({\n alignClassName: alignClassName,\n status: 'afterAlign'\n });\n\n onAlign(popupDomNode, align);\n } else {\n _this.setState({\n alignClassName: alignClassName\n });\n }\n };\n\n _this.onMotionEnd = function () {\n var visible = _this.props.visible;\n\n _this.setState({\n status: visible ? 'AfterMotion' : 'stable'\n });\n };\n\n _this.setStateOnNextFrame = function (state) {\n _this.cancelFrameState();\n\n _this.nextFrameState = _objectSpread({}, _this.nextFrameState, {}, state);\n _this.nextFrameId = raf(function () {\n var submitState = _objectSpread({}, _this.nextFrameState);\n\n _this.nextFrameState = null;\n\n _this.setState(submitState);\n });\n };\n\n _this.getMotion = function () {\n return _objectSpread({}, getMotion(_this.props));\n }; // `target` on `rc-align` can accept as a function to get the bind element or a point.\n // ref: https://www.npmjs.com/package/rc-align\n\n\n _this.getAlignTarget = function () {\n var _this$props2 = _this.props,\n point = _this$props2.point,\n getRootDomNode = _this$props2.getRootDomNode;\n\n if (point) {\n return point;\n }\n\n return getRootDomNode;\n };\n\n _this.cancelFrameState = function () {\n raf.cancel(_this.nextFrameId);\n };\n\n _this.renderPopupElement = function () {\n var _this$state = _this.state,\n status = _this$state.status,\n targetHeight = _this$state.targetHeight,\n targetWidth = _this$state.targetWidth,\n alignClassName = _this$state.alignClassName;\n var _this$props3 = _this.props,\n prefixCls = _this$props3.prefixCls,\n className = _this$props3.className,\n style = _this$props3.style,\n stretch = _this$props3.stretch,\n visible = _this$props3.visible,\n align = _this$props3.align,\n destroyPopupOnHide = _this$props3.destroyPopupOnHide,\n onMouseEnter = _this$props3.onMouseEnter,\n onMouseLeave = _this$props3.onMouseLeave,\n onMouseDown = _this$props3.onMouseDown,\n onTouchStart = _this$props3.onTouchStart,\n children = _this$props3.children;\n var mergedClassName = classNames(prefixCls, className, alignClassName);\n var hiddenClassName = \"\".concat(prefixCls, \"-hidden\"); // ================== Style ==================\n\n var sizeStyle = {};\n\n if (stretch) {\n // Stretch with target\n if (stretch.indexOf('height') !== -1) {\n sizeStyle.height = targetHeight;\n } else if (stretch.indexOf('minHeight') !== -1) {\n sizeStyle.minHeight = targetHeight;\n }\n\n if (stretch.indexOf('width') !== -1) {\n sizeStyle.width = targetWidth;\n } else if (stretch.indexOf('minWidth') !== -1) {\n sizeStyle.minWidth = targetWidth;\n }\n }\n\n var mergedStyle = _objectSpread({}, sizeStyle, {}, _this.getZIndexStyle(), {}, style, {\n opacity: status === 'stable' || !visible ? undefined : 0\n }); // ================= Motions =================\n\n\n var mergedMotion = _this.getMotion();\n\n var mergedMotionVisible = visible;\n\n if (visible && status !== 'beforeMotion' && status !== 'motion' && status !== 'stable') {\n mergedMotion.motionAppear = false;\n mergedMotion.motionEnter = false;\n mergedMotion.motionLeave = false;\n }\n\n if (status === 'afterAlign' || status === 'beforeMotion') {\n mergedMotionVisible = false;\n } // ================== Align ==================\n\n\n var mergedAlignDisabled = !visible || status !== 'align' && status !== 'aligned' && status !== 'stable'; // ================== Popup ==================\n\n var mergedPopupVisible = true;\n\n if (status === 'stable') {\n mergedPopupVisible = visible;\n } // Only remove popup since mask may still need animation\n\n\n if (destroyPopupOnHide && !mergedPopupVisible) {\n return null;\n }\n\n return React.createElement(CSSMotion, Object.assign({\n visible: mergedMotionVisible\n }, mergedMotion, {\n removeOnLeave: false,\n onEnterEnd: _this.onMotionEnd,\n onLeaveEnd: _this.onMotionEnd\n }), function (_ref, motionRef) {\n var motionStyle = _ref.style,\n motionClassName = _ref.className;\n return React.createElement(Align, {\n target: _this.getAlignTarget(),\n key: \"popup\",\n ref: _this.alignRef,\n monitorWindowResize: true,\n disabled: mergedAlignDisabled,\n align: align,\n onAlign: _this.onAlign\n }, React.createElement(PopupInner, {\n prefixCls: prefixCls,\n visible: mergedPopupVisible,\n hiddenClassName: hiddenClassName,\n className: classNames(mergedClassName, motionClassName),\n ref: composeRef(motionRef, _this.popupRef),\n onMouseEnter: onMouseEnter,\n onMouseLeave: onMouseLeave,\n onMouseDown: onMouseDown,\n onTouchStart: onTouchStart,\n style: _objectSpread({}, mergedStyle, {}, motionStyle)\n }, children));\n });\n };\n\n _this.renderMaskElement = function () {\n var _this$props4 = _this.props,\n mask = _this$props4.mask,\n maskMotion = _this$props4.maskMotion,\n maskTransitionName = _this$props4.maskTransitionName,\n maskAnimation = _this$props4.maskAnimation,\n prefixCls = _this$props4.prefixCls,\n visible = _this$props4.visible;\n\n if (!mask) {\n return null;\n }\n\n var motion = {};\n\n if (maskMotion && maskMotion.motionName) {\n motion = _objectSpread({\n motionAppear: true\n }, getMotion({\n motion: maskMotion,\n prefixCls: prefixCls,\n transitionName: maskTransitionName,\n animation: maskAnimation\n }));\n }\n\n return React.createElement(CSSMotion, Object.assign({}, motion, {\n visible: visible,\n removeOnLeave: true\n }), function (_ref2) {\n var className = _ref2.className;\n return React.createElement(\"div\", {\n style: _this.getZIndexStyle(),\n key: \"mask\",\n className: classNames(\"\".concat(prefixCls, \"-mask\"), className)\n });\n });\n };\n\n return _this;\n }\n\n _createClass(Popup, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.componentDidUpdate();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n var status = this.state.status;\n var _this$props5 = this.props,\n getRootDomNode = _this$props5.getRootDomNode,\n visible = _this$props5.visible,\n stretch = _this$props5.stretch; // If there is a pending state update, cancel it, a new one will be set if necessary\n\n this.cancelFrameState();\n\n if (visible && status !== 'stable') {\n switch (status) {\n case null:\n {\n this.setStateOnNextFrame({\n status: stretch ? 'measure' : 'align'\n });\n break;\n }\n\n case 'afterAlign':\n {\n this.setStateOnNextFrame({\n status: supportMotion(this.getMotion()) ? 'beforeMotion' : 'stable'\n });\n break;\n }\n\n case 'AfterMotion':\n {\n this.setStateOnNextFrame({\n status: 'stable'\n });\n break;\n }\n\n default:\n {\n // Go to next status\n var queue = ['measure', 'align', null, 'beforeMotion', 'motion'];\n var index = queue.indexOf(status);\n var nextStatus = queue[index + 1];\n\n if (index !== -1 && nextStatus) {\n this.setStateOnNextFrame({\n status: nextStatus\n });\n }\n }\n }\n } // Measure stretch size\n\n\n if (status === 'measure') {\n var $ele = getRootDomNode();\n\n if ($ele) {\n this.setStateOnNextFrame({\n targetHeight: $ele.offsetHeight,\n targetWidth: $ele.offsetWidth\n });\n }\n }\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n this.cancelFrameState();\n }\n }, {\n key: \"getZIndexStyle\",\n value: function getZIndexStyle() {\n var zIndex = this.props.zIndex;\n return {\n zIndex: zIndex\n };\n }\n }, {\n key: \"render\",\n value: function render() {\n return React.createElement(\"div\", null, this.renderMaskElement(), this.renderPopupElement());\n }\n }], [{\n key: \"getDerivedStateFromProps\",\n value: function getDerivedStateFromProps(_ref3, _ref4) {\n var visible = _ref3.visible,\n props = _objectWithoutProperties(_ref3, [\"visible\"]);\n\n var prevVisible = _ref4.prevVisible,\n status = _ref4.status;\n var newState = {\n prevVisible: visible,\n status: status\n };\n var mergedMotion = getMotion(props);\n\n if (prevVisible === null && visible === false) {\n // Init render should always be stable\n newState.status = 'stable';\n } else if (visible !== prevVisible) {\n if (visible || supportMotion(mergedMotion) && ['motion', 'AfterMotion', 'stable'].includes(status)) {\n newState.status = null;\n } else {\n newState.status = 'stable';\n }\n\n if (visible) {\n newState.alignClassName = null;\n }\n }\n\n return newState;\n }\n }]);\n\n return Popup;\n}(Component);\n\nexport default Popup;\n/* eslint-enable */","import React from 'react';\nvar TriggerContext = React.createContext(null);\nexport default TriggerContext;","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport contains from \"rc-util/es/Dom/contains\";\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\nimport { composeRef, supportRef } from \"rc-util/es/ref\";\nimport addEventListener from \"rc-util/es/Dom/addEventListener\";\nimport Portal from \"rc-util/es/Portal\";\nimport classNames from 'classnames';\nimport { getAlignFromPlacement, getAlignPopupClassName } from './utils/alignUtil';\nimport Popup from './Popup';\nimport TriggerContext from './context';\n\nfunction noop() {}\n\nfunction returnEmptyString() {\n return '';\n}\n\nfunction returnDocument() {\n return window.document;\n}\n\nvar ALL_HANDLERS = ['onClick', 'onMouseDown', 'onTouchStart', 'onMouseEnter', 'onMouseLeave', 'onFocus', 'onBlur', 'onContextMenu'];\n/**\n * Internal usage. Do not use in your code since this will be removed.\n */\n\nexport function generateTrigger(PortalComponent) {\n var Trigger =\n /*#__PURE__*/\n function (_React$Component) {\n _inherits(Trigger, _React$Component);\n\n function Trigger(props) {\n var _this;\n\n _classCallCheck(this, Trigger);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Trigger).call(this, props));\n _this.popupRef = React.createRef();\n _this.triggerRef = React.createRef();\n\n _this.onMouseEnter = function (e) {\n var mouseEnterDelay = _this.props.mouseEnterDelay;\n\n _this.fireEvents('onMouseEnter', e);\n\n _this.delaySetPopupVisible(true, mouseEnterDelay, mouseEnterDelay ? null : e);\n };\n\n _this.onMouseMove = function (e) {\n _this.fireEvents('onMouseMove', e);\n\n _this.setPoint(e);\n };\n\n _this.onMouseLeave = function (e) {\n _this.fireEvents('onMouseLeave', e);\n\n _this.delaySetPopupVisible(false, _this.props.mouseLeaveDelay);\n };\n\n _this.onPopupMouseEnter = function () {\n _this.clearDelayTimer();\n };\n\n _this.onPopupMouseLeave = function (e) {\n // https://github.com/react-component/trigger/pull/13\n // react bug?\n if (e.relatedTarget && !e.relatedTarget.setTimeout && _this.popupRef.current && _this.popupRef.current.popupRef.current && contains(_this.popupRef.current.popupRef.current, e.relatedTarget)) {\n return;\n }\n\n _this.delaySetPopupVisible(false, _this.props.mouseLeaveDelay);\n };\n\n _this.onFocus = function (e) {\n _this.fireEvents('onFocus', e); // incase focusin and focusout\n\n\n _this.clearDelayTimer();\n\n if (_this.isFocusToShow()) {\n _this.focusTime = Date.now();\n\n _this.delaySetPopupVisible(true, _this.props.focusDelay);\n }\n };\n\n _this.onMouseDown = function (e) {\n _this.fireEvents('onMouseDown', e);\n\n _this.preClickTime = Date.now();\n };\n\n _this.onTouchStart = function (e) {\n _this.fireEvents('onTouchStart', e);\n\n _this.preTouchTime = Date.now();\n };\n\n _this.onBlur = function (e) {\n _this.fireEvents('onBlur', e);\n\n _this.clearDelayTimer();\n\n if (_this.isBlurToHide()) {\n _this.delaySetPopupVisible(false, _this.props.blurDelay);\n }\n };\n\n _this.onContextMenu = function (e) {\n e.preventDefault();\n\n _this.fireEvents('onContextMenu', e);\n\n _this.setPopupVisible(true, e);\n };\n\n _this.onContextMenuClose = function () {\n if (_this.isContextMenuToShow()) {\n _this.close();\n }\n };\n\n _this.onClick = function (event) {\n _this.fireEvents('onClick', event); // focus will trigger click\n\n\n if (_this.focusTime) {\n var preTime;\n\n if (_this.preClickTime && _this.preTouchTime) {\n preTime = Math.min(_this.preClickTime, _this.preTouchTime);\n } else if (_this.preClickTime) {\n preTime = _this.preClickTime;\n } else if (_this.preTouchTime) {\n preTime = _this.preTouchTime;\n }\n\n if (Math.abs(preTime - _this.focusTime) < 20) {\n return;\n }\n\n _this.focusTime = 0;\n }\n\n _this.preClickTime = 0;\n _this.preTouchTime = 0; // Only prevent default when all the action is click.\n // https://github.com/ant-design/ant-design/issues/17043\n // https://github.com/ant-design/ant-design/issues/17291\n\n if (_this.isClickToShow() && (_this.isClickToHide() || _this.isBlurToHide()) && event && event.preventDefault) {\n event.preventDefault();\n }\n\n var nextVisible = !_this.state.popupVisible;\n\n if (_this.isClickToHide() && !nextVisible || nextVisible && _this.isClickToShow()) {\n _this.setPopupVisible(!_this.state.popupVisible, event);\n }\n };\n\n _this.onPopupMouseDown = function () {\n _this.hasPopupMouseDown = true;\n clearTimeout(_this.mouseDownTimeout);\n _this.mouseDownTimeout = window.setTimeout(function () {\n _this.hasPopupMouseDown = false;\n }, 0);\n\n if (_this.context) {\n var _this$context;\n\n (_this$context = _this.context).onPopupMouseDown.apply(_this$context, arguments);\n }\n };\n\n _this.onDocumentClick = function (event) {\n if (_this.props.mask && !_this.props.maskClosable) {\n return;\n }\n\n var target = event.target;\n\n var root = _this.getRootDomNode();\n\n var popupNode = _this.getPopupDomNode();\n\n if (!contains(root, target) && !contains(popupNode, target) && !_this.hasPopupMouseDown) {\n _this.close();\n }\n };\n\n _this.getRootDomNode = function () {\n var getTriggerDOMNode = _this.props.getTriggerDOMNode;\n\n if (getTriggerDOMNode) {\n return getTriggerDOMNode(_this.triggerRef.current);\n }\n\n try {\n var domNode = findDOMNode(_this.triggerRef.current);\n\n if (domNode) {\n return domNode;\n }\n } catch (err) {// Do nothing\n }\n\n return ReactDOM.findDOMNode(_assertThisInitialized(_this));\n };\n\n _this.getPopupClassNameFromAlign = function (align) {\n var className = [];\n var _this$props = _this.props,\n popupPlacement = _this$props.popupPlacement,\n builtinPlacements = _this$props.builtinPlacements,\n prefixCls = _this$props.prefixCls,\n alignPoint = _this$props.alignPoint,\n getPopupClassNameFromAlign = _this$props.getPopupClassNameFromAlign;\n\n if (popupPlacement && builtinPlacements) {\n className.push(getAlignPopupClassName(builtinPlacements, prefixCls, align, alignPoint));\n }\n\n if (getPopupClassNameFromAlign) {\n className.push(getPopupClassNameFromAlign(align));\n }\n\n return className.join(' ');\n };\n\n _this.getComponent = function () {\n var _this$props2 = _this.props,\n prefixCls = _this$props2.prefixCls,\n destroyPopupOnHide = _this$props2.destroyPopupOnHide,\n popupClassName = _this$props2.popupClassName,\n onPopupAlign = _this$props2.onPopupAlign,\n popupMotion = _this$props2.popupMotion,\n popupAnimation = _this$props2.popupAnimation,\n popupTransitionName = _this$props2.popupTransitionName,\n popupStyle = _this$props2.popupStyle,\n mask = _this$props2.mask,\n maskAnimation = _this$props2.maskAnimation,\n maskTransitionName = _this$props2.maskTransitionName,\n maskMotion = _this$props2.maskMotion,\n zIndex = _this$props2.zIndex,\n popup = _this$props2.popup,\n stretch = _this$props2.stretch,\n alignPoint = _this$props2.alignPoint;\n var _this$state = _this.state,\n popupVisible = _this$state.popupVisible,\n point = _this$state.point;\n\n var align = _this.getPopupAlign();\n\n var mouseProps = {};\n\n if (_this.isMouseEnterToShow()) {\n mouseProps.onMouseEnter = _this.onPopupMouseEnter;\n }\n\n if (_this.isMouseLeaveToHide()) {\n mouseProps.onMouseLeave = _this.onPopupMouseLeave;\n }\n\n mouseProps.onMouseDown = _this.onPopupMouseDown;\n mouseProps.onTouchStart = _this.onPopupMouseDown;\n return React.createElement(Popup, Object.assign({\n prefixCls: prefixCls,\n destroyPopupOnHide: destroyPopupOnHide,\n visible: popupVisible,\n point: alignPoint && point,\n className: popupClassName,\n align: align,\n onAlign: onPopupAlign,\n animation: popupAnimation,\n getClassNameFromAlign: _this.getPopupClassNameFromAlign\n }, mouseProps, {\n stretch: stretch,\n getRootDomNode: _this.getRootDomNode,\n style: popupStyle,\n mask: mask,\n zIndex: zIndex,\n transitionName: popupTransitionName,\n maskAnimation: maskAnimation,\n maskTransitionName: maskTransitionName,\n maskMotion: maskMotion,\n ref: _this.popupRef,\n motion: popupMotion\n }), typeof popup === 'function' ? popup() : popup);\n };\n\n _this.getContainer = function () {\n var _assertThisInitialize = _assertThisInitialized(_this),\n props = _assertThisInitialize.props;\n\n var popupContainer = document.createElement('div'); // Make sure default popup container will never cause scrollbar appearing\n // https://github.com/react-component/trigger/issues/41\n\n popupContainer.style.position = 'absolute';\n popupContainer.style.top = '0';\n popupContainer.style.left = '0';\n popupContainer.style.width = '100%';\n var mountNode = props.getPopupContainer ? props.getPopupContainer(_this.getRootDomNode()) : props.getDocument().body;\n mountNode.appendChild(popupContainer);\n return popupContainer;\n };\n\n _this.setPoint = function (point) {\n var alignPoint = _this.props.alignPoint;\n if (!alignPoint || !point) return;\n\n _this.setState({\n point: {\n pageX: point.pageX,\n pageY: point.pageY\n }\n });\n };\n\n _this.handlePortalUpdate = function () {\n if (_this.state.prevPopupVisible !== _this.state.popupVisible) {\n _this.props.afterPopupVisibleChange(_this.state.popupVisible);\n }\n };\n\n var popupVisible;\n\n if ('popupVisible' in props) {\n popupVisible = !!props.popupVisible;\n } else {\n popupVisible = !!props.defaultPopupVisible;\n }\n\n _this.state = {\n prevPopupVisible: popupVisible,\n popupVisible: popupVisible\n };\n ALL_HANDLERS.forEach(function (h) {\n _this[\"fire\".concat(h)] = function (e) {\n _this.fireEvents(h, e);\n };\n });\n return _this;\n }\n\n _createClass(Trigger, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.componentDidUpdate();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n var props = this.props;\n var state = this.state; // We must listen to `mousedown` or `touchstart`, edge case:\n // https://github.com/ant-design/ant-design/issues/5804\n // https://github.com/react-component/calendar/issues/250\n // https://github.com/react-component/trigger/issues/50\n\n if (state.popupVisible) {\n var currentDocument;\n\n if (!this.clickOutsideHandler && (this.isClickToHide() || this.isContextMenuToShow())) {\n currentDocument = props.getDocument();\n this.clickOutsideHandler = addEventListener(currentDocument, 'mousedown', this.onDocumentClick);\n } // always hide on mobile\n\n\n if (!this.touchOutsideHandler) {\n currentDocument = currentDocument || props.getDocument();\n this.touchOutsideHandler = addEventListener(currentDocument, 'touchstart', this.onDocumentClick);\n } // close popup when trigger type contains 'onContextMenu' and document is scrolling.\n\n\n if (!this.contextMenuOutsideHandler1 && this.isContextMenuToShow()) {\n currentDocument = currentDocument || props.getDocument();\n this.contextMenuOutsideHandler1 = addEventListener(currentDocument, 'scroll', this.onContextMenuClose);\n } // close popup when trigger type contains 'onContextMenu' and window is blur.\n\n\n if (!this.contextMenuOutsideHandler2 && this.isContextMenuToShow()) {\n this.contextMenuOutsideHandler2 = addEventListener(window, 'blur', this.onContextMenuClose);\n }\n\n return;\n }\n\n this.clearOutsideHandler();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n this.clearDelayTimer();\n this.clearOutsideHandler();\n clearTimeout(this.mouseDownTimeout);\n }\n }, {\n key: \"getPopupDomNode\",\n value: function getPopupDomNode() {\n // for test\n if (this.popupRef.current && this.popupRef.current.popupRef.current) {\n return this.popupRef.current.popupRef.current;\n }\n\n return null;\n }\n }, {\n key: \"getPopupAlign\",\n value: function getPopupAlign() {\n var props = this.props;\n var popupPlacement = props.popupPlacement,\n popupAlign = props.popupAlign,\n builtinPlacements = props.builtinPlacements;\n\n if (popupPlacement && builtinPlacements) {\n return getAlignFromPlacement(builtinPlacements, popupPlacement, popupAlign);\n }\n\n return popupAlign;\n }\n /**\n * @param popupVisible Show or not the popup element\n * @param event SyntheticEvent, used for `pointAlign`\n */\n\n }, {\n key: \"setPopupVisible\",\n value: function setPopupVisible(popupVisible, event) {\n var alignPoint = this.props.alignPoint;\n var prevPopupVisible = this.state.popupVisible;\n this.clearDelayTimer();\n\n if (prevPopupVisible !== popupVisible) {\n if (!('popupVisible' in this.props)) {\n this.setState({\n popupVisible: popupVisible,\n prevPopupVisible: prevPopupVisible\n });\n }\n\n this.props.onPopupVisibleChange(popupVisible);\n } // Always record the point position since mouseEnterDelay will delay the show\n\n\n if (alignPoint && event) {\n this.setPoint(event);\n }\n }\n }, {\n key: \"delaySetPopupVisible\",\n value: function delaySetPopupVisible(visible, delayS, event) {\n var _this2 = this;\n\n var delay = delayS * 1000;\n this.clearDelayTimer();\n\n if (delay) {\n var point = event ? {\n pageX: event.pageX,\n pageY: event.pageY\n } : null;\n this.delayTimer = window.setTimeout(function () {\n _this2.setPopupVisible(visible, point);\n\n _this2.clearDelayTimer();\n }, delay);\n } else {\n this.setPopupVisible(visible, event);\n }\n }\n }, {\n key: \"clearDelayTimer\",\n value: function clearDelayTimer() {\n if (this.delayTimer) {\n clearTimeout(this.delayTimer);\n this.delayTimer = null;\n }\n }\n }, {\n key: \"clearOutsideHandler\",\n value: function clearOutsideHandler() {\n if (this.clickOutsideHandler) {\n this.clickOutsideHandler.remove();\n this.clickOutsideHandler = null;\n }\n\n if (this.contextMenuOutsideHandler1) {\n this.contextMenuOutsideHandler1.remove();\n this.contextMenuOutsideHandler1 = null;\n }\n\n if (this.contextMenuOutsideHandler2) {\n this.contextMenuOutsideHandler2.remove();\n this.contextMenuOutsideHandler2 = null;\n }\n\n if (this.touchOutsideHandler) {\n this.touchOutsideHandler.remove();\n this.touchOutsideHandler = null;\n }\n }\n }, {\n key: \"createTwoChains\",\n value: function createTwoChains(event) {\n var childPros = this.props.children.props;\n var props = this.props;\n\n if (childPros[event] && props[event]) {\n return this[\"fire\".concat(event)];\n }\n\n return childPros[event] || props[event];\n }\n }, {\n key: \"isClickToShow\",\n value: function isClickToShow() {\n var _this$props3 = this.props,\n action = _this$props3.action,\n showAction = _this$props3.showAction;\n return action.indexOf('click') !== -1 || showAction.indexOf('click') !== -1;\n }\n }, {\n key: \"isContextMenuToShow\",\n value: function isContextMenuToShow() {\n var _this$props4 = this.props,\n action = _this$props4.action,\n showAction = _this$props4.showAction;\n return action.indexOf('contextMenu') !== -1 || showAction.indexOf('contextMenu') !== -1;\n }\n }, {\n key: \"isClickToHide\",\n value: function isClickToHide() {\n var _this$props5 = this.props,\n action = _this$props5.action,\n hideAction = _this$props5.hideAction;\n return action.indexOf('click') !== -1 || hideAction.indexOf('click') !== -1;\n }\n }, {\n key: \"isMouseEnterToShow\",\n value: function isMouseEnterToShow() {\n var _this$props6 = this.props,\n action = _this$props6.action,\n showAction = _this$props6.showAction;\n return action.indexOf('hover') !== -1 || showAction.indexOf('mouseEnter') !== -1;\n }\n }, {\n key: \"isMouseLeaveToHide\",\n value: function isMouseLeaveToHide() {\n var _this$props7 = this.props,\n action = _this$props7.action,\n hideAction = _this$props7.hideAction;\n return action.indexOf('hover') !== -1 || hideAction.indexOf('mouseLeave') !== -1;\n }\n }, {\n key: \"isFocusToShow\",\n value: function isFocusToShow() {\n var _this$props8 = this.props,\n action = _this$props8.action,\n showAction = _this$props8.showAction;\n return action.indexOf('focus') !== -1 || showAction.indexOf('focus') !== -1;\n }\n }, {\n key: \"isBlurToHide\",\n value: function isBlurToHide() {\n var _this$props9 = this.props,\n action = _this$props9.action,\n hideAction = _this$props9.hideAction;\n return action.indexOf('focus') !== -1 || hideAction.indexOf('blur') !== -1;\n }\n }, {\n key: \"forcePopupAlign\",\n value: function forcePopupAlign() {\n if (this.state.popupVisible && this.popupRef.current && this.popupRef.current.alignRef.current) {\n this.popupRef.current.alignRef.current.forceAlign();\n }\n }\n }, {\n key: \"fireEvents\",\n value: function fireEvents(type, e) {\n var childCallback = this.props.children.props[type];\n\n if (childCallback) {\n childCallback(e);\n }\n\n var callback = this.props[type];\n\n if (callback) {\n callback(e);\n }\n }\n }, {\n key: \"close\",\n value: function close() {\n this.setPopupVisible(false);\n }\n }, {\n key: \"render\",\n value: function render() {\n var popupVisible = this.state.popupVisible;\n var _this$props10 = this.props,\n children = _this$props10.children,\n forceRender = _this$props10.forceRender,\n alignPoint = _this$props10.alignPoint,\n className = _this$props10.className;\n var child = React.Children.only(children);\n var newChildProps = {\n key: 'trigger'\n };\n\n if (this.isContextMenuToShow()) {\n newChildProps.onContextMenu = this.onContextMenu;\n } else {\n newChildProps.onContextMenu = this.createTwoChains('onContextMenu');\n }\n\n if (this.isClickToHide() || this.isClickToShow()) {\n newChildProps.onClick = this.onClick;\n newChildProps.onMouseDown = this.onMouseDown;\n newChildProps.onTouchStart = this.onTouchStart;\n } else {\n newChildProps.onClick = this.createTwoChains('onClick');\n newChildProps.onMouseDown = this.createTwoChains('onMouseDown');\n newChildProps.onTouchStart = this.createTwoChains('onTouchStart');\n }\n\n if (this.isMouseEnterToShow()) {\n newChildProps.onMouseEnter = this.onMouseEnter;\n\n if (alignPoint) {\n newChildProps.onMouseMove = this.onMouseMove;\n }\n } else {\n newChildProps.onMouseEnter = this.createTwoChains('onMouseEnter');\n }\n\n if (this.isMouseLeaveToHide()) {\n newChildProps.onMouseLeave = this.onMouseLeave;\n } else {\n newChildProps.onMouseLeave = this.createTwoChains('onMouseLeave');\n }\n\n if (this.isFocusToShow() || this.isBlurToHide()) {\n newChildProps.onFocus = this.onFocus;\n newChildProps.onBlur = this.onBlur;\n } else {\n newChildProps.onFocus = this.createTwoChains('onFocus');\n newChildProps.onBlur = this.createTwoChains('onBlur');\n }\n\n var childrenClassName = classNames(child && child.props && child.props.className, className);\n\n if (childrenClassName) {\n newChildProps.className = childrenClassName;\n }\n\n var cloneProps = _objectSpread({}, newChildProps);\n\n if (supportRef(child)) {\n cloneProps.ref = composeRef(this.triggerRef, child.ref);\n }\n\n var trigger = React.cloneElement(child, cloneProps);\n var portal; // prevent unmounting after it's rendered\n\n if (popupVisible || this.popupRef.current || forceRender) {\n portal = React.createElement(PortalComponent, {\n key: \"portal\",\n getContainer: this.getContainer,\n didUpdate: this.handlePortalUpdate\n }, this.getComponent());\n }\n\n return React.createElement(TriggerContext.Provider, {\n value: {\n onPopupMouseDown: this.onPopupMouseDown\n }\n }, trigger, portal);\n }\n }], [{\n key: \"getDerivedStateFromProps\",\n value: function getDerivedStateFromProps(_ref, prevState) {\n var popupVisible = _ref.popupVisible;\n var newState = {};\n\n if (popupVisible !== undefined && prevState.popupVisible !== popupVisible) {\n newState.popupVisible = popupVisible;\n newState.prevPopupVisible = prevState.popupVisible;\n }\n\n return newState;\n }\n }]);\n\n return Trigger;\n }(React.Component);\n\n Trigger.contextType = TriggerContext;\n Trigger.defaultProps = {\n prefixCls: 'rc-trigger-popup',\n getPopupClassNameFromAlign: returnEmptyString,\n getDocument: returnDocument,\n onPopupVisibleChange: noop,\n afterPopupVisibleChange: noop,\n onPopupAlign: noop,\n popupClassName: '',\n mouseEnterDelay: 0,\n mouseLeaveDelay: 0.1,\n focusDelay: 0,\n blurDelay: 0.15,\n popupStyle: {},\n destroyPopupOnHide: false,\n popupAlign: {},\n defaultPopupVisible: false,\n mask: false,\n maskClosable: true,\n action: [],\n showAction: [],\n hideAction: []\n };\n return Trigger;\n}\nexport default generateTrigger(Portal);","function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nimport * as React from 'react';\nimport classNames from 'classnames';\n/**\n * Fill component to provided the scroll content real height.\n */\n\nvar Filler = function Filler(_ref) {\n var height = _ref.height,\n offset = _ref.offset,\n children = _ref.children,\n prefixCls = _ref.prefixCls;\n var outerStyle = {};\n var innerStyle = {\n display: 'flex',\n flexDirection: 'column'\n };\n\n if (offset !== undefined) {\n outerStyle = {\n height: height,\n position: 'relative',\n overflow: 'hidden'\n };\n innerStyle = _objectSpread({}, innerStyle, {\n transform: \"translateY(\".concat(offset, \"px)\"),\n position: 'absolute',\n left: 0,\n right: 0,\n top: 0\n });\n }\n\n return React.createElement(\"div\", {\n style: outerStyle\n }, React.createElement(\"div\", {\n style: innerStyle,\n className: classNames(_defineProperty({}, \"\".concat(prefixCls, \"-holder-inner\"), prefixCls))\n }, children));\n};\n\nexport default Filler;","function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\n/**\n * Our algorithm have additional one ghost item\n * whose index as `data.length` to simplify the calculation\n */\n\nexport var GHOST_ITEM_KEY = '__rc_ghost_item__';\n/**\n * Get location item and its align percentage with the scroll percentage.\n * We should measure current scroll position to decide which item is the location item.\n * And then fill the top count and bottom count with the base of location item.\n *\n * `total` should be the real count instead of `total - 1` in calculation.\n */\n\nfunction getLocationItem(scrollPtg, total) {\n var itemIndex = Math.floor(scrollPtg * total);\n var itemTopPtg = itemIndex / total;\n var itemBottomPtg = (itemIndex + 1) / total;\n var itemOffsetPtg = (scrollPtg - itemTopPtg) / (itemBottomPtg - itemTopPtg);\n return {\n index: itemIndex,\n offsetPtg: itemOffsetPtg\n };\n}\n/**\n * Safari has the elasticity effect which provides negative `scrollTop` value.\n * We should ignore it since will make scroll animation shake.\n */\n\n\nexport function alignScrollTop(scrollTop, scrollRange) {\n if (scrollTop < 0) {\n return 0;\n }\n\n if (scrollTop >= scrollRange) {\n return scrollRange;\n }\n\n return scrollTop;\n}\nexport function getScrollPercentage(_ref) {\n var scrollTop = _ref.scrollTop,\n scrollHeight = _ref.scrollHeight,\n clientHeight = _ref.clientHeight;\n\n if (scrollHeight <= clientHeight) {\n return 0;\n }\n\n var scrollRange = scrollHeight - clientHeight;\n var alignedScrollTop = alignScrollTop(scrollTop, scrollRange);\n var scrollTopPtg = alignedScrollTop / scrollRange;\n return scrollTopPtg;\n}\nexport function getElementScrollPercentage(element) {\n if (!element) {\n return 0;\n }\n\n return getScrollPercentage(element);\n}\n/**\n * Get node `offsetHeight`. We prefer node is a dom element directly.\n * But if not provided, downgrade to `findDOMNode` to get the real dom element.\n */\n\nexport function getNodeHeight(node) {\n var element = findDOMNode(node);\n return element ? element.offsetHeight : 0;\n}\n/**\n * Get display items start, end, located item index. This is pure math calculation\n */\n\nexport function getRangeIndex(scrollPtg, itemCount, visibleCount) {\n var _getLocationItem = getLocationItem(scrollPtg, itemCount),\n index = _getLocationItem.index,\n offsetPtg = _getLocationItem.offsetPtg;\n\n var beforeCount = Math.ceil(scrollPtg * visibleCount);\n var afterCount = Math.ceil((1 - scrollPtg) * visibleCount);\n return {\n itemIndex: index,\n itemOffsetPtg: offsetPtg,\n startIndex: Math.max(0, index - beforeCount),\n endIndex: Math.min(itemCount - 1, index + afterCount)\n };\n}\n/**\n * Calculate the located item related top with current window height\n */\n\nexport function getItemRelativeTop(_ref2) {\n var itemIndex = _ref2.itemIndex,\n itemOffsetPtg = _ref2.itemOffsetPtg,\n itemElementHeights = _ref2.itemElementHeights,\n scrollPtg = _ref2.scrollPtg,\n clientHeight = _ref2.clientHeight,\n getItemKey = _ref2.getItemKey;\n var locatedItemHeight = itemElementHeights[getItemKey(itemIndex)] || 0;\n var locatedItemTop = scrollPtg * clientHeight;\n var locatedItemOffset = itemOffsetPtg * locatedItemHeight;\n return Math.floor(locatedItemTop - locatedItemOffset);\n}\n/**\n * Calculate the located item absolute top with whole scroll height\n */\n\nexport function getItemAbsoluteTop(_ref3) {\n var scrollTop = _ref3.scrollTop,\n rest = _objectWithoutProperties(_ref3, [\"scrollTop\"]);\n\n return scrollTop + getItemRelativeTop(rest);\n}\nexport function getCompareItemRelativeTop(_ref4) {\n var locatedItemRelativeTop = _ref4.locatedItemRelativeTop,\n locatedItemIndex = _ref4.locatedItemIndex,\n compareItemIndex = _ref4.compareItemIndex,\n startIndex = _ref4.startIndex,\n endIndex = _ref4.endIndex,\n getItemKey = _ref4.getItemKey,\n itemElementHeights = _ref4.itemElementHeights;\n var originCompareItemTop = locatedItemRelativeTop;\n var compareItemKey = getItemKey(compareItemIndex);\n\n if (compareItemIndex <= locatedItemIndex) {\n for (var index = locatedItemIndex; index >= startIndex; index -= 1) {\n var key = getItemKey(index);\n\n if (key === compareItemKey) {\n break;\n }\n\n var prevItemKey = getItemKey(index - 1);\n originCompareItemTop -= itemElementHeights[prevItemKey] || 0;\n }\n } else {\n for (var _index = locatedItemIndex; _index <= endIndex; _index += 1) {\n var _key = getItemKey(_index);\n\n if (_key === compareItemKey) {\n break;\n }\n\n originCompareItemTop += itemElementHeights[_key] || 0;\n }\n }\n\n return originCompareItemTop;\n}\nexport function requireVirtual(height, itemHeight, count, virtual) {\n return virtual !== false && typeof height === 'number' && count * itemHeight > height;\n}","/**\n * Get index with specific start index one by one. e.g.\n * min: 3, max: 9, start: 6\n *\n * Return index is:\n * [0]: 6\n * [1]: 7\n * [2]: 5\n * [3]: 8\n * [4]: 4\n * [5]: 9\n * [6]: 3\n */\nexport function getIndexByStartLoc(min, max, start, index) {\n var beforeCount = start - min;\n var afterCount = max - start;\n var balanceCount = Math.min(beforeCount, afterCount) * 2; // Balance\n\n if (index <= balanceCount) {\n var stepIndex = Math.floor(index / 2);\n\n if (index % 2) {\n return start + stepIndex + 1;\n }\n\n return start - stepIndex;\n } // One is out of range\n\n\n if (beforeCount > afterCount) {\n return start - (index - afterCount);\n }\n\n return start + (index - beforeCount);\n}\n/**\n * We assume that 2 list has only 1 item diff and others keeping the order.\n * So we can use dichotomy algorithm to find changed one.\n */\n\nexport function findListDiffIndex(originList, targetList, getKey) {\n var originLen = originList.length;\n var targetLen = targetList.length;\n var shortList;\n var longList;\n\n if (originLen === 0 && targetLen === 0) {\n return null;\n }\n\n if (originLen < targetLen) {\n shortList = originList;\n longList = targetList;\n } else {\n shortList = targetList;\n longList = originList;\n }\n\n var notExistKey = {\n __EMPTY_ITEM__: true\n };\n\n function getItemKey(item) {\n if (item !== undefined) {\n return getKey(item);\n }\n\n return notExistKey;\n } // Loop to find diff one\n\n\n var diffIndex = null;\n var multiple = Math.abs(originLen - targetLen) !== 1;\n\n for (var i = 0; i < longList.length; i += 1) {\n var shortKey = getItemKey(shortList[i]);\n var longKey = getItemKey(longList[i]);\n\n if (shortKey !== longKey) {\n diffIndex = i;\n multiple = multiple || shortKey !== getItemKey(longList[i + 1]);\n break;\n }\n }\n\n return diffIndex === null ? null : {\n index: diffIndex,\n multiple: multiple\n };\n}","function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport raf from 'raf';\nimport Filler from './Filler';\nimport { getElementScrollPercentage, getScrollPercentage, getNodeHeight, getRangeIndex, getItemAbsoluteTop, GHOST_ITEM_KEY, getItemRelativeTop, getCompareItemRelativeTop, alignScrollTop, requireVirtual } from './utils/itemUtil';\nimport { getIndexByStartLoc, findListDiffIndex } from './utils/algorithmUtil';\nvar ScrollStyle = {\n overflowY: 'auto',\n overflowAnchor: 'none'\n};\nvar ITEM_SCALE_RATE = 1;\n/**\n * We use class component here since typescript can not support generic in function component\n *\n * Virtual list display logic:\n * 1. scroll / initialize trigger measure\n * 2. Get location item of current `scrollTop`\n * 3. [Render] Render visible items\n * 4. Get all the visible items height\n * 5. [Render] Update top item `margin-top` to fit the position\n *\n * Algorithm:\n * We split scroll bar into equal slice. An item with whatever height occupy the same range slice.\n * When `scrollTop` change,\n * it will calculate the item percentage position and move item to the position.\n * Then calculate other item position base on the located item.\n *\n * Concept:\n *\n * # located item\n * The base position item which other items position calculate base on.\n */\n\nvar List = /*#__PURE__*/function (_React$Component) {\n _inherits(List, _React$Component);\n\n function List(props) {\n var _this;\n\n _classCallCheck(this, List);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(List).call(this, props));\n _this.listRef = React.createRef();\n _this.itemElements = {};\n _this.itemElementHeights = {};\n /**\n * Lock scroll process with `onScroll` event.\n * This is used for `data` length change and `scrollTop` restore\n */\n\n _this.lockScroll = false;\n /**\n * Phase 2: Trigger render since we should re-calculate current position.\n */\n\n _this.onScroll = function (event) {\n var _this$props = _this.props,\n data = _this$props.data,\n height = _this$props.height,\n itemHeight = _this$props.itemHeight,\n disabled = _this$props.disabled;\n var _this$listRef$current = _this.listRef.current,\n originScrollTop = _this$listRef$current.scrollTop,\n clientHeight = _this$listRef$current.clientHeight,\n scrollHeight = _this$listRef$current.scrollHeight;\n var scrollTop = alignScrollTop(originScrollTop, scrollHeight - clientHeight); // Skip if `scrollTop` not change to avoid shake\n\n if (scrollTop === _this.state.scrollTop || _this.lockScroll || disabled) {\n return;\n }\n\n var scrollPtg = getElementScrollPercentage(_this.listRef.current);\n var visibleCount = Math.ceil(height / itemHeight);\n\n var _getRangeIndex = getRangeIndex(scrollPtg, data.length, visibleCount),\n itemIndex = _getRangeIndex.itemIndex,\n itemOffsetPtg = _getRangeIndex.itemOffsetPtg,\n startIndex = _getRangeIndex.startIndex,\n endIndex = _getRangeIndex.endIndex;\n\n _this.setState({\n status: 'MEASURE_START',\n scrollTop: scrollTop,\n itemIndex: itemIndex,\n itemOffsetPtg: itemOffsetPtg,\n startIndex: startIndex,\n endIndex: endIndex\n });\n\n _this.triggerOnScroll(event);\n };\n\n _this.onRawScroll = function (event) {\n var scrollTop = _this.listRef.current.scrollTop;\n\n _this.setState({\n scrollTop: scrollTop\n });\n\n _this.triggerOnScroll(event);\n };\n\n _this.triggerOnScroll = function (event) {\n var onScroll = _this.props.onScroll;\n\n if (onScroll && event) {\n onScroll(event);\n }\n };\n\n _this.getIndexKey = function (index, props) {\n var mergedProps = props || _this.props;\n var _mergedProps$data = mergedProps.data,\n data = _mergedProps$data === void 0 ? [] : _mergedProps$data; // Return ghost key as latest index item\n\n if (index === data.length) {\n return GHOST_ITEM_KEY;\n }\n\n var item = data[index];\n\n if (!item) {\n /* istanbul ignore next */\n console.error('Not find index item. Please report this since it is a bug.');\n }\n\n return _this.getItemKey(item, mergedProps);\n };\n\n _this.getItemKey = function (item, props) {\n var _ref = props || _this.props,\n itemKey = _ref.itemKey;\n\n return typeof itemKey === 'function' ? itemKey(item) : item[itemKey];\n };\n /**\n * Collect current rendered dom element item heights\n */\n\n\n _this.collectItemHeights = function (range) {\n var _ref2 = range || _this.state,\n startIndex = _ref2.startIndex,\n endIndex = _ref2.endIndex;\n\n var data = _this.props.data; // Record here since measure item height will get warning in `render`\n\n for (var index = startIndex; index <= endIndex; index += 1) {\n var item = data[index]; // Only collect exist item height\n\n if (item) {\n var eleKey = _this.getItemKey(item);\n\n _this.itemElementHeights[eleKey] = getNodeHeight(_this.itemElements[eleKey]);\n }\n }\n };\n\n _this.scrollTo = function (arg0) {\n raf(function () {\n // Number top\n if (_typeof(arg0) === 'object') {\n var isVirtual = _this.state.isVirtual;\n var _this$props2 = _this.props,\n height = _this$props2.height,\n itemHeight = _this$props2.itemHeight,\n data = _this$props2.data;\n var _arg0$align = arg0.align,\n align = _arg0$align === void 0 ? 'auto' : _arg0$align;\n var index = 0;\n\n if ('index' in arg0) {\n index = arg0.index;\n } else if ('key' in arg0) {\n var key = arg0.key;\n index = data.findIndex(function (item) {\n return _this.getItemKey(item) === key;\n });\n }\n\n var visibleCount = Math.ceil(height / itemHeight);\n var item = data[index];\n\n if (item) {\n var clientHeight = _this.listRef.current.clientHeight;\n\n if (isVirtual) {\n // Calculate related data\n var _this$state = _this.state,\n itemIndex = _this$state.itemIndex,\n itemOffsetPtg = _this$state.itemOffsetPtg;\n var scrollTop = _this.listRef.current.scrollTop;\n var scrollPtg = getElementScrollPercentage(_this.listRef.current);\n var relativeLocatedItemTop = getItemRelativeTop({\n itemIndex: itemIndex,\n itemOffsetPtg: itemOffsetPtg,\n itemElementHeights: _this.itemElementHeights,\n scrollPtg: scrollPtg,\n clientHeight: clientHeight,\n getItemKey: _this.getIndexKey\n }); // We will force render related items to collect height for re-location\n\n _this.setState({\n startIndex: Math.max(0, index - visibleCount),\n endIndex: Math.min(data.length - 1, index + visibleCount)\n }, function () {\n _this.collectItemHeights(); // Calculate related top\n\n\n var relativeTop;\n var mergedAlgin = align;\n\n if (align === 'auto') {\n var shouldChange = true; // Check if exist in the visible range\n\n if (Math.abs(itemIndex - index) < visibleCount) {\n var itemTop = relativeLocatedItemTop;\n\n if (index < itemIndex) {\n for (var i = index; i < itemIndex; i += 1) {\n var eleKey = _this.getIndexKey(i);\n\n itemTop -= _this.itemElementHeights[eleKey] || 0;\n }\n } else {\n for (var _i = itemIndex; _i <= index; _i += 1) {\n var _eleKey = _this.getIndexKey(_i);\n\n itemTop += _this.itemElementHeights[_eleKey] || 0;\n }\n }\n\n shouldChange = itemTop <= 0 || itemTop >= clientHeight;\n }\n\n if (shouldChange) {\n // Out of range will fall back to position align\n mergedAlgin = index < itemIndex ? 'top' : 'bottom';\n } else {\n var _getRangeIndex2 = getRangeIndex(scrollPtg, data.length, visibleCount),\n nextIndex = _getRangeIndex2.itemIndex,\n newOffsetPtg = _getRangeIndex2.itemOffsetPtg,\n startIndex = _getRangeIndex2.startIndex,\n endIndex = _getRangeIndex2.endIndex;\n\n _this.setState({\n scrollTop: scrollTop,\n itemIndex: nextIndex,\n itemOffsetPtg: newOffsetPtg,\n startIndex: startIndex,\n endIndex: endIndex\n });\n\n return;\n }\n } // Align with position should make scroll happen\n\n\n if (mergedAlgin === 'top') {\n relativeTop = 0;\n } else if (mergedAlgin === 'bottom') {\n var _eleKey2 = _this.getItemKey(item);\n\n relativeTop = clientHeight - _this.itemElementHeights[_eleKey2] || 0;\n }\n\n _this.internalScrollTo({\n itemIndex: index,\n relativeTop: relativeTop\n });\n });\n } else {\n // Raw list without virtual scroll set position directly\n _this.collectItemHeights({\n startIndex: 0,\n endIndex: data.length - 1\n });\n\n var mergedAlgin = align; // Collection index item position\n\n var indexItemHeight = _this.itemElementHeights[_this.getIndexKey(index)];\n\n var itemTop = 0;\n\n for (var i = 0; i < index; i += 1) {\n var eleKey = _this.getIndexKey(i);\n\n itemTop += _this.itemElementHeights[eleKey] || 0;\n }\n\n var itemBottom = itemTop + indexItemHeight;\n\n if (mergedAlgin === 'auto') {\n if (itemTop < _this.listRef.current.scrollTop) {\n mergedAlgin = 'top';\n } else if (itemBottom > _this.listRef.current.scrollTop + clientHeight) {\n mergedAlgin = 'bottom';\n }\n }\n\n if (mergedAlgin === 'top') {\n _this.listRef.current.scrollTop = itemTop;\n } else if (mergedAlgin === 'bottom') {\n _this.listRef.current.scrollTop = itemTop - (clientHeight - indexItemHeight);\n }\n }\n }\n } else {\n _this.listRef.current.scrollTop = arg0;\n }\n });\n };\n /**\n * Phase 4: Render item and get all the visible items height\n */\n\n\n _this.renderChildren = function (list, startIndex, renderFunc) {\n var status = _this.state.status; // We should measure rendered item height\n\n return list.map(function (item, index) {\n var eleIndex = startIndex + index;\n var node = renderFunc(item, eleIndex, {\n style: status === 'MEASURE_START' ? {\n visibility: 'hidden'\n } : {}\n });\n\n var eleKey = _this.getIndexKey(eleIndex); // Pass `key` and `ref` for internal measure\n\n\n return React.cloneElement(node, {\n key: eleKey,\n ref: function ref(ele) {\n _this.itemElements[eleKey] = ele;\n }\n });\n });\n };\n\n _this.cachedProps = props;\n _this.state = {\n status: 'NONE',\n scrollTop: null,\n itemIndex: 0,\n itemOffsetPtg: 0,\n startIndex: 0,\n endIndex: 0,\n startItemTop: 0,\n isVirtual: requireVirtual(props.height, props.itemHeight, props.data.length, props.virtual),\n itemCount: props.data.length\n };\n return _this;\n }\n\n _createClass(List, [{\n key: \"componentDidMount\",\n\n /**\n * Phase 1: Initial should sync with default scroll top\n */\n value: function componentDidMount() {\n if (this.listRef.current) {\n this.listRef.current.scrollTop = 0;\n this.onScroll(null);\n }\n }\n /**\n * Phase 4: Record used item height\n * Phase 5: Trigger re-render to use correct position\n */\n\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n var _this2 = this;\n\n var status = this.state.status;\n var _this$props3 = this.props,\n data = _this$props3.data,\n height = _this$props3.height,\n itemHeight = _this$props3.itemHeight,\n disabled = _this$props3.disabled,\n onSkipRender = _this$props3.onSkipRender,\n virtual = _this$props3.virtual;\n var prevData = this.cachedProps.data || [];\n var changedItemIndex = null;\n\n if (prevData.length !== data.length) {\n var diff = findListDiffIndex(prevData, data, this.getItemKey);\n changedItemIndex = diff ? diff.index : null;\n }\n\n if (disabled) {\n // Should trigger `onSkipRender` to tell that diff component is not render in the list\n if (data.length > prevData.length) {\n var _this$state2 = this.state,\n startIndex = _this$state2.startIndex,\n endIndex = _this$state2.endIndex;\n\n if (onSkipRender && (changedItemIndex === null || changedItemIndex < startIndex || endIndex < changedItemIndex)) {\n onSkipRender();\n }\n }\n\n return;\n }\n\n var isVirtual = requireVirtual(height, itemHeight, data.length, virtual);\n var nextStatus = status;\n\n if (this.state.isVirtual !== isVirtual) {\n nextStatus = isVirtual ? 'SWITCH_TO_VIRTUAL' : 'SWITCH_TO_RAW';\n this.setState({\n isVirtual: isVirtual,\n status: nextStatus\n });\n /**\n * We will wait a tick to let list turn to virtual list.\n * And then use virtual list sync logic to adjust the scroll.\n */\n\n if (nextStatus === 'SWITCH_TO_VIRTUAL') {\n return;\n }\n }\n\n if (status === 'MEASURE_START') {\n var _this$state3 = this.state,\n _startIndex = _this$state3.startIndex,\n itemIndex = _this$state3.itemIndex,\n itemOffsetPtg = _this$state3.itemOffsetPtg;\n var scrollTop = this.listRef.current.scrollTop; // Record here since measure item height will get warning in `render`\n\n this.collectItemHeights(); // Calculate top visible item top offset\n\n var locatedItemTop = getItemAbsoluteTop({\n itemIndex: itemIndex,\n itemOffsetPtg: itemOffsetPtg,\n itemElementHeights: this.itemElementHeights,\n scrollTop: scrollTop,\n scrollPtg: getElementScrollPercentage(this.listRef.current),\n clientHeight: this.listRef.current.clientHeight,\n getItemKey: this.getIndexKey\n });\n var startItemTop = locatedItemTop;\n\n for (var index = itemIndex - 1; index >= _startIndex; index -= 1) {\n startItemTop -= this.itemElementHeights[this.getIndexKey(index)] || 0;\n }\n\n this.setState({\n status: 'MEASURE_DONE',\n startItemTop: startItemTop\n });\n }\n\n if (status === 'SWITCH_TO_RAW') {\n /**\n * After virtual list back to raw list,\n * we update the `scrollTop` to real top instead of percentage top.\n */\n var _this$state$cacheScro = this.state.cacheScroll,\n _itemIndex = _this$state$cacheScro.itemIndex,\n relativeTop = _this$state$cacheScro.relativeTop;\n var rawTop = relativeTop;\n\n for (var _index = 0; _index < _itemIndex; _index += 1) {\n rawTop -= this.itemElementHeights[this.getIndexKey(_index)] || 0;\n }\n\n this.lockScroll = true;\n this.listRef.current.scrollTop = -rawTop;\n this.setState({\n status: 'MEASURE_DONE',\n itemIndex: 0\n });\n requestAnimationFrame(function () {\n requestAnimationFrame(function () {\n _this2.lockScroll = false;\n });\n });\n } else if (prevData.length !== data.length && changedItemIndex !== null && height) {\n /**\n * Re-calculate the item position since `data` length changed.\n * [IMPORTANT] We use relative position calculate here.\n */\n var originItemIndex = this.state.itemIndex;\n var _this$state4 = this.state,\n originItemOffsetPtg = _this$state4.itemOffsetPtg,\n originStartIndex = _this$state4.startIndex,\n originEndIndex = _this$state4.endIndex,\n originScrollTop = _this$state4.scrollTop; // 1. Refresh item heights\n\n this.collectItemHeights(); // 1. Get origin located item top\n\n var originLocatedItemRelativeTop;\n\n if (this.state.status === 'SWITCH_TO_VIRTUAL') {\n originItemIndex = 0;\n originLocatedItemRelativeTop = -this.state.scrollTop;\n } else {\n originLocatedItemRelativeTop = getItemRelativeTop({\n itemIndex: originItemIndex,\n itemOffsetPtg: originItemOffsetPtg,\n itemElementHeights: this.itemElementHeights,\n scrollPtg: getScrollPercentage({\n scrollTop: originScrollTop,\n scrollHeight: prevData.length * itemHeight,\n clientHeight: this.listRef.current.clientHeight\n }),\n clientHeight: this.listRef.current.clientHeight,\n getItemKey: function getItemKey(index) {\n return _this2.getIndexKey(index, _this2.cachedProps);\n }\n });\n } // 2. Find the compare item\n\n\n var originCompareItemIndex = changedItemIndex - 1; // Use next one since there are not more item before removed\n\n if (originCompareItemIndex < 0) {\n originCompareItemIndex = 0;\n } // 3. Find the compare item top\n\n\n var originCompareItemTop = getCompareItemRelativeTop({\n locatedItemRelativeTop: originLocatedItemRelativeTop,\n locatedItemIndex: originItemIndex,\n compareItemIndex: originCompareItemIndex,\n startIndex: originStartIndex,\n endIndex: originEndIndex,\n getItemKey: function getItemKey(index) {\n return _this2.getIndexKey(index, _this2.cachedProps);\n },\n itemElementHeights: this.itemElementHeights\n });\n\n if (nextStatus === 'SWITCH_TO_RAW') {\n /**\n * We will record current measure relative item top and apply in raw list after list turned\n */\n this.setState({\n cacheScroll: {\n itemIndex: originCompareItemIndex,\n relativeTop: originCompareItemTop\n }\n });\n } else {\n this.internalScrollTo({\n itemIndex: originCompareItemIndex,\n relativeTop: originCompareItemTop\n });\n }\n } else if (nextStatus === 'SWITCH_TO_RAW') {\n // This is only trigger when height changes that all items can show in raw\n // Let's reset back to top\n this.setState({\n cacheScroll: {\n itemIndex: 0,\n relativeTop: 0\n }\n });\n }\n\n this.cachedProps = this.props;\n }\n }, {\n key: \"internalScrollTo\",\n value: function internalScrollTo(relativeScroll) {\n var _this3 = this;\n\n var compareItemIndex = relativeScroll.itemIndex,\n compareItemRelativeTop = relativeScroll.relativeTop;\n var originScrollTop = this.state.scrollTop;\n var _this$props4 = this.props,\n data = _this$props4.data,\n itemHeight = _this$props4.itemHeight,\n height = _this$props4.height; // 1. Find the best match compare item top\n\n var bestSimilarity = Number.MAX_VALUE;\n var bestScrollTop = null;\n var bestItemIndex = null;\n var bestItemOffsetPtg = null;\n var bestStartIndex = null;\n var bestEndIndex = null;\n var missSimilarity = 0;\n var scrollHeight = data.length * itemHeight;\n var clientHeight = this.listRef.current.clientHeight;\n var maxScrollTop = scrollHeight - clientHeight;\n\n for (var i = 0; i < maxScrollTop; i += 1) {\n var scrollTop = getIndexByStartLoc(0, maxScrollTop, originScrollTop, i);\n var scrollPtg = getScrollPercentage({\n scrollTop: scrollTop,\n scrollHeight: scrollHeight,\n clientHeight: clientHeight\n });\n var visibleCount = Math.ceil(height / itemHeight);\n\n var _getRangeIndex3 = getRangeIndex(scrollPtg, data.length, visibleCount),\n itemIndex = _getRangeIndex3.itemIndex,\n itemOffsetPtg = _getRangeIndex3.itemOffsetPtg,\n startIndex = _getRangeIndex3.startIndex,\n endIndex = _getRangeIndex3.endIndex; // No need to check if compare item out of the index to save performance\n\n\n if (startIndex <= compareItemIndex && compareItemIndex <= endIndex) {\n // 1.1 Get measure located item relative top\n var locatedItemRelativeTop = getItemRelativeTop({\n itemIndex: itemIndex,\n itemOffsetPtg: itemOffsetPtg,\n itemElementHeights: this.itemElementHeights,\n scrollPtg: scrollPtg,\n clientHeight: clientHeight,\n getItemKey: this.getIndexKey\n });\n var compareItemTop = getCompareItemRelativeTop({\n locatedItemRelativeTop: locatedItemRelativeTop,\n locatedItemIndex: itemIndex,\n compareItemIndex: compareItemIndex,\n startIndex: startIndex,\n endIndex: endIndex,\n getItemKey: this.getIndexKey,\n itemElementHeights: this.itemElementHeights\n }); // 1.2 Find best match compare item top\n\n var similarity = Math.abs(compareItemTop - compareItemRelativeTop);\n\n if (similarity < bestSimilarity) {\n bestSimilarity = similarity;\n bestScrollTop = scrollTop;\n bestItemIndex = itemIndex;\n bestItemOffsetPtg = itemOffsetPtg;\n bestStartIndex = startIndex;\n bestEndIndex = endIndex;\n missSimilarity = 0;\n } else {\n missSimilarity += 1;\n }\n } // If keeping 10 times not match similarity,\n // check more scrollTop is meaningless.\n // Here boundary is set to 10.\n\n\n if (missSimilarity > 10) {\n break;\n }\n } // 2. Re-scroll if has best scroll match\n\n\n if (bestScrollTop !== null) {\n this.lockScroll = true;\n this.listRef.current.scrollTop = bestScrollTop;\n this.setState({\n status: 'MEASURE_START',\n scrollTop: bestScrollTop,\n itemIndex: bestItemIndex,\n itemOffsetPtg: bestItemOffsetPtg,\n startIndex: bestStartIndex,\n endIndex: bestEndIndex\n });\n requestAnimationFrame(function () {\n requestAnimationFrame(function () {\n _this3.lockScroll = false;\n });\n });\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this$state5 = this.state,\n isVirtual = _this$state5.isVirtual,\n itemCount = _this$state5.itemCount;\n\n var _this$props5 = this.props,\n prefixCls = _this$props5.prefixCls,\n style = _this$props5.style,\n className = _this$props5.className,\n _this$props5$componen = _this$props5.component,\n Component = _this$props5$componen === void 0 ? 'div' : _this$props5$componen,\n height = _this$props5.height,\n itemHeight = _this$props5.itemHeight,\n _this$props5$fullHeig = _this$props5.fullHeight,\n fullHeight = _this$props5$fullHeig === void 0 ? true : _this$props5$fullHeig,\n data = _this$props5.data,\n children = _this$props5.children,\n itemKey = _this$props5.itemKey,\n onSkipRender = _this$props5.onSkipRender,\n disabled = _this$props5.disabled,\n virtual = _this$props5.virtual,\n restProps = _objectWithoutProperties(_this$props5, [\"prefixCls\", \"style\", \"className\", \"component\", \"height\", \"itemHeight\", \"fullHeight\", \"data\", \"children\", \"itemKey\", \"onSkipRender\", \"disabled\", \"virtual\"]);\n\n var mergedClassName = classNames(prefixCls, className); // Render pure list if not set height or height is enough for all items\n\n if (!isVirtual) {\n /**\n * Virtual list switch is works on component updated.\n * We should double check here if need cut the content.\n */\n var shouldVirtual = requireVirtual(height, itemHeight, data.length, virtual);\n return React.createElement(Component, Object.assign({\n style: height ? _objectSpread({}, style, _defineProperty({}, fullHeight ? 'height' : 'maxHeight', height), ScrollStyle) : style,\n className: mergedClassName\n }, restProps, {\n onScroll: this.onRawScroll,\n ref: this.listRef\n }), React.createElement(Filler, {\n prefixCls: prefixCls,\n height: height\n }, this.renderChildren(shouldVirtual ? data.slice(0, Math.ceil(height / itemHeight)) : data, 0, children)));\n } // Use virtual list\n\n\n var mergedStyle = _objectSpread({}, style, {\n height: height\n }, ScrollStyle);\n\n var _this$state6 = this.state,\n status = _this$state6.status,\n startIndex = _this$state6.startIndex,\n endIndex = _this$state6.endIndex,\n startItemTop = _this$state6.startItemTop;\n var contentHeight = itemCount * itemHeight * ITEM_SCALE_RATE;\n return React.createElement(Component, Object.assign({\n style: mergedStyle,\n className: mergedClassName\n }, restProps, {\n onScroll: this.onScroll,\n ref: this.listRef\n }), React.createElement(Filler, {\n prefixCls: prefixCls,\n height: contentHeight,\n offset: status === 'MEASURE_DONE' ? startItemTop : 0\n }, this.renderChildren(data.slice(startIndex, endIndex + 1), startIndex, children)));\n }\n }], [{\n key: \"getDerivedStateFromProps\",\n value: function getDerivedStateFromProps(nextProps) {\n if (!nextProps.disabled) {\n return {\n itemCount: nextProps.data.length\n };\n }\n\n return null;\n }\n }]);\n\n return List;\n}(React.Component);\n\nList.defaultProps = {\n itemHeight: 15,\n data: []\n};\nexport default List;","import List from './List';\nexport default List;","import warning from \"rc-util/es/warning\";\n\nfunction removeFromCheckedKeys(halfCheckedKeys, checkedKeys) {\n var filteredKeys = new Set();\n halfCheckedKeys.forEach(function (key) {\n if (!checkedKeys.has(key)) {\n filteredKeys.add(key);\n }\n });\n return filteredKeys;\n}\n\nexport function isCheckDisabled(node) {\n var _ref = node || {},\n disabled = _ref.disabled,\n disableCheckbox = _ref.disableCheckbox,\n checkable = _ref.checkable;\n\n return !!(disabled || disableCheckbox) || checkable === false;\n} // Fill miss keys\n\nfunction fillConductCheck(keys, levelEntities, maxLevel) {\n var checkedKeys = new Set(keys);\n var halfCheckedKeys = new Set(); // Add checked keys top to bottom\n\n for (var level = 0; level <= maxLevel; level += 1) {\n var entities = levelEntities.get(level) || new Set();\n entities.forEach(function (entity) {\n var key = entity.key,\n node = entity.node,\n _entity$children = entity.children,\n children = _entity$children === void 0 ? [] : _entity$children;\n\n if (checkedKeys.has(key) && !isCheckDisabled(node)) {\n children.filter(function (childEntity) {\n return !isCheckDisabled(childEntity.node);\n }).forEach(function (childEntity) {\n checkedKeys.add(childEntity.key);\n });\n }\n });\n } // Add checked keys from bottom to top\n\n\n var visitedKeys = new Set();\n\n for (var _level = maxLevel; _level >= 0; _level -= 1) {\n var _entities = levelEntities.get(_level) || new Set();\n\n _entities.forEach(function (entity) {\n var parent = entity.parent,\n node = entity.node; // Skip if no need to check\n\n if (isCheckDisabled(node) || !entity.parent || visitedKeys.has(entity.parent.key)) {\n return;\n } // Skip if parent is disabled\n\n\n if (isCheckDisabled(entity.parent.node)) {\n visitedKeys.add(parent.key);\n return;\n }\n\n var allChecked = true;\n var partialChecked = false;\n (parent.children || []).filter(function (childEntity) {\n return !isCheckDisabled(childEntity.node);\n }).forEach(function (_ref2) {\n var key = _ref2.key;\n var checked = checkedKeys.has(key);\n\n if (allChecked && !checked) {\n allChecked = false;\n }\n\n if (!partialChecked && (checked || halfCheckedKeys.has(key))) {\n partialChecked = true;\n }\n });\n\n if (allChecked) {\n checkedKeys.add(parent.key);\n }\n\n if (partialChecked) {\n halfCheckedKeys.add(parent.key);\n }\n\n visitedKeys.add(parent.key);\n });\n }\n\n return {\n checkedKeys: Array.from(checkedKeys),\n halfCheckedKeys: Array.from(removeFromCheckedKeys(halfCheckedKeys, checkedKeys))\n };\n} // Remove useless key\n\n\nfunction cleanConductCheck(keys, halfKeys, levelEntities, maxLevel) {\n var checkedKeys = new Set(keys);\n var halfCheckedKeys = new Set(halfKeys); // Remove checked keys from top to bottom\n\n for (var level = 0; level <= maxLevel; level += 1) {\n var entities = levelEntities.get(level) || new Set();\n entities.forEach(function (entity) {\n var key = entity.key,\n node = entity.node,\n _entity$children2 = entity.children,\n children = _entity$children2 === void 0 ? [] : _entity$children2;\n\n if (!checkedKeys.has(key) && !halfCheckedKeys.has(key) && !isCheckDisabled(node)) {\n children.filter(function (childEntity) {\n return !isCheckDisabled(childEntity.node);\n }).forEach(function (childEntity) {\n checkedKeys.delete(childEntity.key);\n });\n }\n });\n } // Remove checked keys form bottom to top\n\n\n halfCheckedKeys = new Set();\n var visitedKeys = new Set();\n\n for (var _level2 = maxLevel; _level2 >= 0; _level2 -= 1) {\n var _entities2 = levelEntities.get(_level2) || new Set();\n\n _entities2.forEach(function (entity) {\n var parent = entity.parent,\n node = entity.node; // Skip if no need to check\n\n if (isCheckDisabled(node) || !entity.parent || visitedKeys.has(entity.parent.key)) {\n return;\n } // Skip if parent is disabled\n\n\n if (isCheckDisabled(entity.parent.node)) {\n visitedKeys.add(parent.key);\n return;\n }\n\n var allChecked = true;\n var partialChecked = false;\n (parent.children || []).filter(function (childEntity) {\n return !isCheckDisabled(childEntity.node);\n }).forEach(function (_ref3) {\n var key = _ref3.key;\n var checked = checkedKeys.has(key);\n\n if (allChecked && !checked) {\n allChecked = false;\n }\n\n if (!partialChecked && (checked || halfCheckedKeys.has(key))) {\n partialChecked = true;\n }\n });\n\n if (!allChecked) {\n checkedKeys.delete(parent.key);\n }\n\n if (partialChecked) {\n halfCheckedKeys.add(parent.key);\n }\n\n visitedKeys.add(parent.key);\n });\n }\n\n return {\n checkedKeys: Array.from(checkedKeys),\n halfCheckedKeys: Array.from(removeFromCheckedKeys(halfCheckedKeys, checkedKeys))\n };\n}\n/**\n * Conduct with keys.\n * @param keyList current key list\n * @param keyEntities key - dataEntity map\n * @param mode `fill` to fill missing key, `clean` to remove useless key\n */\n\n\nexport function conductCheck(keyList, checked, keyEntities) {\n var warningMissKeys = []; // We only handle exist keys\n\n var keys = new Set(keyList.filter(function (key) {\n var hasEntity = !!keyEntities[key];\n\n if (!hasEntity) {\n warningMissKeys.push(key);\n }\n\n return hasEntity;\n }));\n var levelEntities = new Map();\n var maxLevel = 0; // Convert entities by level for calculation\n\n Object.keys(keyEntities).forEach(function (key) {\n var entity = keyEntities[key];\n var level = entity.level;\n var levelSet = levelEntities.get(level);\n\n if (!levelSet) {\n levelSet = new Set();\n levelEntities.set(level, levelSet);\n }\n\n levelSet.add(entity);\n maxLevel = Math.max(maxLevel, level);\n });\n warning(!warningMissKeys.length, \"Tree missing follow keys: \".concat(warningMissKeys.slice(0, 100).map(function (key) {\n return \"'\".concat(key, \"'\");\n }).join(', ')));\n var result;\n\n if (checked === true) {\n result = fillConductCheck(keys, levelEntities, maxLevel);\n } else {\n result = cleanConductCheck(keys, checked.halfCheckedKeys, levelEntities, maxLevel);\n }\n\n return result;\n}","\"use strict\";\n\nexports.__esModule = true;\n\nvar _getPrototypeOf = require(\"../core-js/object/get-prototype-of\");\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _getOwnPropertyDescriptor = require(\"../core-js/object/get-own-property-descriptor\");\n\nvar _getOwnPropertyDescriptor2 = _interopRequireDefault(_getOwnPropertyDescriptor);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = function get(object, property, receiver) {\n if (object === null) object = Function.prototype;\n var desc = (0, _getOwnPropertyDescriptor2.default)(object, property);\n\n if (desc === undefined) {\n var parent = (0, _getPrototypeOf2.default)(object);\n\n if (parent === null) {\n return undefined;\n } else {\n return get(parent, property, receiver);\n }\n } else if (\"value\" in desc) {\n return desc.value;\n } else {\n var getter = desc.get;\n\n if (getter === undefined) {\n return undefined;\n }\n\n return getter.call(receiver);\n }\n};","/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","// optional / simple context binding\nvar aFunction = require('./_a-function');\nmodule.exports = function (fn, that, length) {\n aFunction(fn);\n if (that === undefined) return fn;\n switch (length) {\n case 1: return function (a) {\n return fn.call(that, a);\n };\n case 2: return function (a, b) {\n return fn.call(that, a, b);\n };\n case 3: return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n return function (/* ...args */) {\n return fn.apply(that, arguments);\n };\n};\n","// 7.1.1 ToPrimitive(input [, PreferredType])\nvar isObject = require('./_is-object');\n// instead of the ES6 spec version, we didn't implement @@toPrimitive case\n// and the second argument - flag - preferred type is a string\nmodule.exports = function (it, S) {\n if (!isObject(it)) return it;\n var fn, val;\n if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;\n if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n","var toString = {}.toString;\n\nmodule.exports = function (it) {\n return toString.call(it).slice(8, -1);\n};\n","// 7.2.1 RequireObjectCoercible(argument)\nmodule.exports = function (it) {\n if (it == undefined) throw TypeError(\"Can't call method on \" + it);\n return it;\n};\n","// 7.1.4 ToInteger\nvar ceil = Math.ceil;\nvar floor = Math.floor;\nmodule.exports = function (it) {\n return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);\n};\n","var shared = require('./_shared')('keys');\nvar uid = require('./_uid');\nmodule.exports = function (key) {\n return shared[key] || (shared[key] = uid(key));\n};\n","var core = require('./_core');\nvar global = require('./_global');\nvar SHARED = '__core-js_shared__';\nvar store = global[SHARED] || (global[SHARED] = {});\n\n(module.exports = function (key, value) {\n return store[key] || (store[key] = value !== undefined ? value : {});\n})('versions', []).push({\n version: core.version,\n mode: require('./_library') ? 'pure' : 'global',\n copyright: '© 2019 Denis Pushkarev (zloirock.ru)'\n});\n","// IE 8- don't enum bug keys\nmodule.exports = (\n 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'\n).split(',');\n","exports.f = Object.getOwnPropertySymbols;\n","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.warning = warning;\nexports.isIconDefinition = isIconDefinition;\nexports.normalizeAttrs = normalizeAttrs;\nexports.generate = generate;\nexports.getSecondaryColor = getSecondaryColor;\nexports.normalizeTwoToneColors = normalizeTwoToneColors;\nexports.useInsertStyles = exports.iconStyles = exports.svgBaseProps = void 0;\n\nvar _colors = require(\"@ant-design/colors\");\n\nvar _react = _interopRequireWildcard(require(\"react\"));\n\nvar _warning = _interopRequireDefault(require(\"rc-util/lib/warning\"));\n\nvar _insertCss = require(\"insert-css\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _getRequireWildcardCache() { if (typeof WeakMap !== \"function\") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== \"object\" && typeof obj !== \"function\") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction warning(valid, message) {\n (0, _warning.default)(valid, \"[@ant-design/icons] \".concat(message));\n}\n\nfunction isIconDefinition(target) {\n return _typeof(target) === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (_typeof(target.icon) === 'object' || typeof target.icon === 'function');\n}\n\nfunction normalizeAttrs() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return Object.keys(attrs).reduce(function (acc, key) {\n var val = attrs[key];\n\n switch (key) {\n case 'class':\n acc.className = val;\n delete acc.class;\n break;\n\n default:\n acc[key] = val;\n }\n\n return acc;\n }, {});\n}\n\nfunction generate(node, key, rootProps) {\n if (!rootProps) {\n return _react.default.createElement(node.tag, _objectSpread({\n key: key\n }, normalizeAttrs(node.attrs)), (node.children || []).map(function (child, index) {\n return generate(child, \"\".concat(key, \"-\").concat(node.tag, \"-\").concat(index));\n }));\n }\n\n return _react.default.createElement(node.tag, _objectSpread({\n key: key\n }, normalizeAttrs(node.attrs), {}, rootProps), (node.children || []).map(function (child, index) {\n return generate(child, \"\".concat(key, \"-\").concat(node.tag, \"-\").concat(index));\n }));\n}\n\nfunction getSecondaryColor(primaryColor) {\n // choose the second color\n return (0, _colors.generate)(primaryColor)[0];\n}\n\nfunction normalizeTwoToneColors(twoToneColor) {\n if (!twoToneColor) {\n return [];\n }\n\n return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor];\n} // These props make sure that the SVG behaviours like general text.\n// Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4\n\n\nvar svgBaseProps = {\n width: '1em',\n height: '1em',\n fill: 'currentColor',\n 'aria-hidden': 'true',\n focusable: 'false'\n};\nexports.svgBaseProps = svgBaseProps;\nvar iconStyles = \"\\n.anticon {\\n display: inline-block;\\n color: inherit;\\n font-style: normal;\\n line-height: 0;\\n text-align: center;\\n text-transform: none;\\n vertical-align: -0.125em;\\n text-rendering: optimizeLegibility;\\n -webkit-font-smoothing: antialiased;\\n -moz-osx-font-smoothing: grayscale;\\n}\\n\\n.anticon > * {\\n line-height: 1;\\n}\\n\\n.anticon svg {\\n display: inline-block;\\n}\\n\\n.anticon::before {\\n display: none;\\n}\\n\\n.anticon .anticon-icon {\\n display: block;\\n}\\n\\n.anticon[tabindex] {\\n cursor: pointer;\\n}\\n\\n.anticon-spin::before,\\n.anticon-spin {\\n display: inline-block;\\n -webkit-animation: loadingCircle 1s infinite linear;\\n animation: loadingCircle 1s infinite linear;\\n}\\n\\n@-webkit-keyframes loadingCircle {\\n 100% {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n\\n@keyframes loadingCircle {\\n 100% {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n\";\nexports.iconStyles = iconStyles;\nvar cssInjectedFlag = false;\n\nvar useInsertStyles = function useInsertStyles() {\n var styleStr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : iconStyles;\n (0, _react.useEffect)(function () {\n if (!cssInjectedFlag) {\n (0, _insertCss.insertCss)(styleStr, {\n prepend: true\n });\n cssInjectedFlag = true;\n }\n }, []);\n};\n\nexports.useInsertStyles = useInsertStyles;","// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])\nvar anObject = require('./_an-object');\nvar dPs = require('./_object-dps');\nvar enumBugKeys = require('./_enum-bug-keys');\nvar IE_PROTO = require('./_shared-key')('IE_PROTO');\nvar Empty = function () { /* empty */ };\nvar PROTOTYPE = 'prototype';\n\n// Create object with fake `null` prototype: use iframe Object with cleared prototype\nvar createDict = function () {\n // Thrash, waste and sodomy: IE GC bug\n var iframe = require('./_dom-create')('iframe');\n var i = enumBugKeys.length;\n var lt = '<';\n var gt = '>';\n var iframeDocument;\n iframe.style.display = 'none';\n require('./_html').appendChild(iframe);\n iframe.src = 'javascript:'; // eslint-disable-line no-script-url\n // createDict = iframe.contentWindow.Object;\n // html.removeChild(iframe);\n iframeDocument = iframe.contentWindow.document;\n iframeDocument.open();\n iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);\n iframeDocument.close();\n createDict = iframeDocument.F;\n while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];\n return createDict();\n};\n\nmodule.exports = Object.create || function create(O, Properties) {\n var result;\n if (O !== null) {\n Empty[PROTOTYPE] = anObject(O);\n result = new Empty();\n Empty[PROTOTYPE] = null;\n // add \"__proto__\" for Object.getPrototypeOf polyfill\n result[IE_PROTO] = O;\n } else result = createDict();\n return Properties === undefined ? result : dPs(result, Properties);\n};\n","var def = require('./_object-dp').f;\nvar has = require('./_has');\nvar TAG = require('./_wks')('toStringTag');\n\nmodule.exports = function (it, tag, stat) {\n if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });\n};\n","exports.f = require('./_wks');\n","var global = require('./_global');\nvar core = require('./_core');\nvar LIBRARY = require('./_library');\nvar wksExt = require('./_wks-ext');\nvar defineProperty = require('./_object-dp').f;\nmodule.exports = function (name) {\n var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});\n if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });\n};\n","var pIE = require('./_object-pie');\nvar createDesc = require('./_property-desc');\nvar toIObject = require('./_to-iobject');\nvar toPrimitive = require('./_to-primitive');\nvar has = require('./_has');\nvar IE8_DOM_DEFINE = require('./_ie8-dom-define');\nvar gOPD = Object.getOwnPropertyDescriptor;\n\nexports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {\n O = toIObject(O);\n P = toPrimitive(P, true);\n if (IE8_DOM_DEFINE) try {\n return gOPD(O, P);\n } catch (e) { /* empty */ }\n if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);\n};\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.DefaultToast = exports.shrinkKeyframes = exports.toastWidth = exports.gutter = exports.borderRadius = undefined;\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar _templateObject = _taggedTemplateLiteral(['from { height: 100%; } to { height: 0% }'], ['from { height: 100%; } to { height: 0% }']);\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _core = require('@emotion/core');\n\nvar _icons = require('./icons');\n\nvar _colors = require('./colors');\n\nvar colors = _interopRequireWildcard(_colors);\n\nvar _utils = require('./utils');\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\nfunction _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }\n/** @jsx jsx */\n\n// common\nvar borderRadius = exports.borderRadius = 4;\nvar gutter = exports.gutter = 8;\nvar toastWidth = exports.toastWidth = 360;\nvar shrinkKeyframes = exports.shrinkKeyframes = (0, _core.keyframes)(_templateObject);\n\n// a11y helper\nvar A11yText = function A11yText(_ref) {\n var Tag = _ref.tag,\n props = _objectWithoutProperties(_ref, ['tag']);\n\n return (0, _core.jsx)(Tag, _extends({\n css: {\n border: 0,\n clip: 'rect(1px, 1px, 1px, 1px)',\n height: 1,\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n whiteSpace: 'nowrap',\n width: 1\n }\n }, props));\n};\nA11yText.defaultProps = {\n tag: 'span'\n};\n\n// default appearances\n\nvar appearances = {\n success: {\n icon: _icons.CheckIcon,\n text: colors.G500,\n fg: colors.G300,\n bg: colors.G50\n },\n error: {\n icon: _icons.FlameIcon,\n text: colors.R500,\n fg: colors.R300,\n bg: colors.R50\n },\n warning: {\n icon: _icons.AlertIcon,\n text: colors.Y500,\n fg: colors.Y300,\n bg: colors.Y50\n },\n info: {\n icon: _icons.InfoIcon,\n text: colors.N400,\n fg: colors.B200,\n bg: 'white'\n }\n};\n\n\nvar Button = function Button(props) {\n return (0, _core.jsx)('div', _extends({\n role: 'button',\n className: 'react-toast-notifications__toast__dismiss-button',\n css: {\n cursor: 'pointer',\n flexShrink: 0,\n opacity: 0.5,\n padding: gutter + 'px ' + gutter * 1.5 + 'px',\n transition: 'opacity 150ms',\n\n ':hover': { opacity: 1 }\n }\n }, props));\n};\n\nvar Content = function Content(props) {\n return (0, _core.jsx)('div', _extends({\n className: 'react-toast-notifications__toast__content',\n css: {\n flexGrow: 1,\n fontSize: 14,\n lineHeight: 1.4,\n minHeight: 40,\n padding: gutter + 'px ' + gutter * 1.5 + 'px'\n }\n }, props));\n};\n\n// NOTE: invoke animation when NOT `autoDismiss` with opacity of 0 to avoid a\n// paint bug in FireFox.\n// https://bugzilla.mozilla.org/show_bug.cgi?id=625289\nvar Countdown = function Countdown(_ref2) {\n var autoDismissTimeout = _ref2.autoDismissTimeout,\n opacity = _ref2.opacity,\n isRunning = _ref2.isRunning,\n props = _objectWithoutProperties(_ref2, ['autoDismissTimeout', 'opacity', 'isRunning']);\n\n return (0, _core.jsx)('div', _extends({\n className: 'react-toast-notifications__toast__countdown',\n css: {\n animation: shrinkKeyframes + ' ' + autoDismissTimeout + 'ms linear',\n animationPlayState: isRunning ? 'running' : 'paused',\n backgroundColor: 'rgba(0,0,0,0.1)',\n bottom: 0,\n height: 0,\n left: 0,\n opacity: opacity,\n position: 'absolute',\n width: '100%'\n }\n }, props));\n};\n\nvar Icon = function Icon(_ref3) {\n var appearance = _ref3.appearance,\n autoDismiss = _ref3.autoDismiss,\n autoDismissTimeout = _ref3.autoDismissTimeout,\n isRunning = _ref3.isRunning;\n\n var meta = appearances[appearance];\n var Glyph = meta.icon;\n\n return (0, _core.jsx)(\n 'div',\n {\n className: 'react-toast-notifications__toast__icon-wrapper',\n css: {\n backgroundColor: meta.fg,\n borderTopLeftRadius: borderRadius,\n borderBottomLeftRadius: borderRadius,\n color: meta.bg,\n flexShrink: 0,\n paddingBottom: gutter,\n paddingTop: gutter,\n position: 'relative',\n overflow: 'hidden',\n textAlign: 'center',\n width: 30\n }\n },\n (0, _core.jsx)(Countdown, {\n opacity: autoDismiss ? 1 : 0,\n autoDismissTimeout: autoDismissTimeout,\n isRunning: isRunning\n }),\n (0, _core.jsx)(Glyph, {\n className: 'react-toast-notifications__toast__icon',\n css: { position: 'relative', zIndex: 1 }\n })\n );\n};\n\n// Transitions\n// ------------------------------\n\nfunction getTranslate(placement) {\n var pos = placement.split('-');\n var relevantPlacement = pos[1] === 'center' ? pos[0] : pos[1];\n var translateMap = {\n right: 'translate3d(120%, 0, 0)',\n left: 'translate3d(-120%, 0, 0)',\n bottom: 'translate3d(0, 120%, 0)',\n top: 'translate3d(0, -120%, 0)'\n };\n\n return translateMap[relevantPlacement];\n}\n\nvar toastStates = function toastStates(placement) {\n return {\n entering: { transform: getTranslate(placement) },\n entered: { transform: 'translate3d(0,0,0)' },\n exiting: { transform: 'scale(0.66)', opacity: 0 },\n exited: { transform: 'scale(0.66)', opacity: 0 }\n };\n};\n\nvar ToastElement = function ToastElement(_ref4) {\n var appearance = _ref4.appearance,\n placement = _ref4.placement,\n transitionDuration = _ref4.transitionDuration,\n transitionState = _ref4.transitionState,\n props = _objectWithoutProperties(_ref4, ['appearance', 'placement', 'transitionDuration', 'transitionState']);\n\n var _useState = (0, _react.useState)('auto'),\n _useState2 = _slicedToArray(_useState, 2),\n height = _useState2[0],\n setHeight = _useState2[1];\n\n var elementRef = (0, _react.useRef)(null);\n\n (0, _react.useEffect)(function () {\n if (transitionState === 'entered') {\n var el = elementRef.current;\n setHeight(el.offsetHeight + gutter);\n }\n if (transitionState === 'exiting') {\n setHeight(0);\n }\n }, [transitionState]);\n\n return (0, _core.jsx)(\n 'div',\n {\n ref: elementRef,\n style: { height: height },\n css: {\n transition: 'height ' + (transitionDuration - 100) + 'ms 100ms'\n }\n },\n (0, _core.jsx)('div', _extends({\n className: 'react-toast-notifications__toast react-toast-notifications__toast--' + appearance,\n css: _extends({\n backgroundColor: appearances[appearance].bg,\n borderRadius: borderRadius,\n boxShadow: '0 3px 8px rgba(0, 0, 0, 0.175)',\n color: appearances[appearance].text,\n display: 'flex',\n marginBottom: gutter,\n transition: 'transform ' + transitionDuration + 'ms cubic-bezier(0.2, 0, 0, 1), opacity ' + transitionDuration + 'ms',\n width: toastWidth\n }, toastStates(placement)[transitionState])\n }, props))\n );\n};\n\n// ==============================\n// DefaultToast\n// ==============================\n\nvar DefaultToast = function DefaultToast(_ref5) {\n var appearance = _ref5.appearance,\n autoDismiss = _ref5.autoDismiss,\n autoDismissTimeout = _ref5.autoDismissTimeout,\n children = _ref5.children,\n isRunning = _ref5.isRunning,\n onDismiss = _ref5.onDismiss,\n placement = _ref5.placement,\n transitionDuration = _ref5.transitionDuration,\n transitionState = _ref5.transitionState,\n onMouseEnter = _ref5.onMouseEnter,\n onMouseLeave = _ref5.onMouseLeave,\n otherProps = _objectWithoutProperties(_ref5, ['appearance', 'autoDismiss', 'autoDismissTimeout', 'children', 'isRunning', 'onDismiss', 'placement', 'transitionDuration', 'transitionState', 'onMouseEnter', 'onMouseLeave']);\n\n return (0, _core.jsx)(\n ToastElement,\n _extends({\n appearance: appearance,\n placement: placement,\n transitionState: transitionState,\n transitionDuration: transitionDuration,\n onMouseEnter: onMouseEnter,\n onMouseLeave: onMouseLeave\n }, otherProps),\n (0, _core.jsx)(Icon, {\n appearance: appearance,\n autoDismiss: autoDismiss,\n autoDismissTimeout: autoDismissTimeout,\n isRunning: isRunning\n }),\n (0, _core.jsx)(\n Content,\n null,\n children\n ),\n onDismiss ? (0, _core.jsx)(\n Button,\n { onClick: onDismiss },\n (0, _core.jsx)(_icons.CloseIcon, { className: 'react-toast-notifications__toast__dismiss-icon' }),\n (0, _core.jsx)(\n A11yText,\n { className: 'react-toast-notifications__toast__dismiss-text' },\n 'Close'\n )\n ) : null\n );\n};\n\nexports.DefaultToast = DefaultToast;\nDefaultToast.defaultProps = {\n onDismiss: _utils.NOOP\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.generateUEID = generateUEID;\nvar NOOP = exports.NOOP = function NOOP() {};\nfunction generateUEID() {\n var first = Math.random() * 46656 | 0;\n var second = Math.random() * 46656 | 0;\n first = ('000' + first.toString(36)).slice(-3);\n second = ('000' + second.toString(36)).slice(-3);\n return first + second;\n}","// Copyright 2014 Simon Lydell\r\n// X11 (“MIT”) Licensed. (See LICENSE.)\r\n\r\nvoid (function(root, factory) {\r\n if (typeof define === \"function\" && define.amd) {\r\n define(factory)\r\n } else if (typeof exports === \"object\") {\r\n module.exports = factory()\r\n } else {\r\n root.resolveUrl = factory()\r\n }\r\n}(this, function() {\r\n\r\n function resolveUrl(/* ...urls */) {\r\n var numUrls = arguments.length\r\n\r\n if (numUrls === 0) {\r\n throw new Error(\"resolveUrl requires at least one argument; got none.\")\r\n }\r\n\r\n var base = document.createElement(\"base\")\r\n base.href = arguments[0]\r\n\r\n if (numUrls === 1) {\r\n return base.href\r\n }\r\n\r\n var head = document.getElementsByTagName(\"head\")[0]\r\n head.insertBefore(base, head.firstChild)\r\n\r\n var a = document.createElement(\"a\")\r\n var resolved\r\n\r\n for (var index = 1; index < numUrls; index++) {\r\n a.href = arguments[index]\r\n resolved = a.href\r\n base.href = resolved\r\n }\r\n\r\n head.removeChild(base)\r\n\r\n return resolved\r\n }\r\n\r\n return resolveUrl\r\n\r\n}));\r\n","function replaceClassName(origClass, classToRemove) {\n return origClass.replace(new RegExp(\"(^|\\\\s)\" + classToRemove + \"(?:\\\\s|$)\", 'g'), '$1').replace(/\\s+/g, ' ').replace(/^\\s*|\\s*$/g, '');\n}\n\nexport default function removeClass(element, className) {\n if (element.classList) {\n element.classList.remove(className);\n } else if (typeof element.className === 'string') {\n ;\n element.className = replaceClassName(element.className, className);\n } else {\n element.setAttribute('class', replaceClassName(element.className && element.className.baseVal || '', className));\n }\n}","export default {\n disabled: false\n};","import React from 'react';\nexport default React.createContext(null);","import _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport config from './config';\nimport { timeoutsShape } from './utils/PropTypes';\nimport TransitionGroupContext from './TransitionGroupContext';\nexport var UNMOUNTED = 'unmounted';\nexport var EXITED = 'exited';\nexport var ENTERING = 'entering';\nexport var ENTERED = 'entered';\nexport var EXITING = 'exiting';\n/**\n * The Transition component lets you describe a transition from one component\n * state to another _over time_ with a simple declarative API. Most commonly\n * it's used to animate the mounting and unmounting of a component, but can also\n * be used to describe in-place transition states as well.\n *\n * ---\n *\n * **Note**: `Transition` is a platform-agnostic base component. If you're using\n * transitions in CSS, you'll probably want to use\n * [`CSSTransition`](https://reactcommunity.org/react-transition-group/css-transition)\n * instead. It inherits all the features of `Transition`, but contains\n * additional features necessary to play nice with CSS transitions (hence the\n * name of the component).\n *\n * ---\n *\n * By default the `Transition` component does not alter the behavior of the\n * component it renders, it only tracks \"enter\" and \"exit\" states for the\n * components. It's up to you to give meaning and effect to those states. For\n * example we can add styles to a component when it enters or exits:\n *\n * ```jsx\n * import { Transition } from 'react-transition-group';\n *\n * const duration = 300;\n *\n * const defaultStyle = {\n * transition: `opacity ${duration}ms ease-in-out`,\n * opacity: 0,\n * }\n *\n * const transitionStyles = {\n * entering: { opacity: 1 },\n * entered: { opacity: 1 },\n * exiting: { opacity: 0 },\n * exited: { opacity: 0 },\n * };\n *\n * const Fade = ({ in: inProp }) => (\n * \n * {state => (\n *
\n * I'm a fade Transition!\n *
\n * )}\n *
\n * );\n * ```\n *\n * There are 4 main states a Transition can be in:\n * - `'entering'`\n * - `'entered'`\n * - `'exiting'`\n * - `'exited'`\n *\n * Transition state is toggled via the `in` prop. When `true` the component\n * begins the \"Enter\" stage. During this stage, the component will shift from\n * its current transition state, to `'entering'` for the duration of the\n * transition and then to the `'entered'` stage once it's complete. Let's take\n * the following example (we'll use the\n * [useState](https://reactjs.org/docs/hooks-reference.html#usestate) hook):\n *\n * ```jsx\n * function App() {\n * const [inProp, setInProp] = useState(false);\n * return (\n *
\n * \n * {state => (\n * // ...\n * )}\n * \n * \n *
\n * );\n * }\n * ```\n *\n * When the button is clicked the component will shift to the `'entering'` state\n * and stay there for 500ms (the value of `timeout`) before it finally switches\n * to `'entered'`.\n *\n * When `in` is `false` the same thing happens except the state moves from\n * `'exiting'` to `'exited'`.\n */\n\nvar Transition = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(Transition, _React$Component);\n\n function Transition(props, context) {\n var _this;\n\n _this = _React$Component.call(this, props, context) || this;\n var parentGroup = context; // In the context of a TransitionGroup all enters are really appears\n\n var appear = parentGroup && !parentGroup.isMounting ? props.enter : props.appear;\n var initialStatus;\n _this.appearStatus = null;\n\n if (props.in) {\n if (appear) {\n initialStatus = EXITED;\n _this.appearStatus = ENTERING;\n } else {\n initialStatus = ENTERED;\n }\n } else {\n if (props.unmountOnExit || props.mountOnEnter) {\n initialStatus = UNMOUNTED;\n } else {\n initialStatus = EXITED;\n }\n }\n\n _this.state = {\n status: initialStatus\n };\n _this.nextCallback = null;\n return _this;\n }\n\n Transition.getDerivedStateFromProps = function getDerivedStateFromProps(_ref, prevState) {\n var nextIn = _ref.in;\n\n if (nextIn && prevState.status === UNMOUNTED) {\n return {\n status: EXITED\n };\n }\n\n return null;\n } // getSnapshotBeforeUpdate(prevProps) {\n // let nextStatus = null\n // if (prevProps !== this.props) {\n // const { status } = this.state\n // if (this.props.in) {\n // if (status !== ENTERING && status !== ENTERED) {\n // nextStatus = ENTERING\n // }\n // } else {\n // if (status === ENTERING || status === ENTERED) {\n // nextStatus = EXITING\n // }\n // }\n // }\n // return { nextStatus }\n // }\n ;\n\n var _proto = Transition.prototype;\n\n _proto.componentDidMount = function componentDidMount() {\n this.updateStatus(true, this.appearStatus);\n };\n\n _proto.componentDidUpdate = function componentDidUpdate(prevProps) {\n var nextStatus = null;\n\n if (prevProps !== this.props) {\n var status = this.state.status;\n\n if (this.props.in) {\n if (status !== ENTERING && status !== ENTERED) {\n nextStatus = ENTERING;\n }\n } else {\n if (status === ENTERING || status === ENTERED) {\n nextStatus = EXITING;\n }\n }\n }\n\n this.updateStatus(false, nextStatus);\n };\n\n _proto.componentWillUnmount = function componentWillUnmount() {\n this.cancelNextCallback();\n };\n\n _proto.getTimeouts = function getTimeouts() {\n var timeout = this.props.timeout;\n var exit, enter, appear;\n exit = enter = appear = timeout;\n\n if (timeout != null && typeof timeout !== 'number') {\n exit = timeout.exit;\n enter = timeout.enter; // TODO: remove fallback for next major\n\n appear = timeout.appear !== undefined ? timeout.appear : enter;\n }\n\n return {\n exit: exit,\n enter: enter,\n appear: appear\n };\n };\n\n _proto.updateStatus = function updateStatus(mounting, nextStatus) {\n if (mounting === void 0) {\n mounting = false;\n }\n\n if (nextStatus !== null) {\n // nextStatus will always be ENTERING or EXITING.\n this.cancelNextCallback();\n\n if (nextStatus === ENTERING) {\n this.performEnter(mounting);\n } else {\n this.performExit();\n }\n } else if (this.props.unmountOnExit && this.state.status === EXITED) {\n this.setState({\n status: UNMOUNTED\n });\n }\n };\n\n _proto.performEnter = function performEnter(mounting) {\n var _this2 = this;\n\n var enter = this.props.enter;\n var appearing = this.context ? this.context.isMounting : mounting;\n\n var _ref2 = this.props.nodeRef ? [appearing] : [ReactDOM.findDOMNode(this), appearing],\n maybeNode = _ref2[0],\n maybeAppearing = _ref2[1];\n\n var timeouts = this.getTimeouts();\n var enterTimeout = appearing ? timeouts.appear : timeouts.enter; // no enter animation skip right to ENTERED\n // if we are mounting and running this it means appear _must_ be set\n\n if (!mounting && !enter || config.disabled) {\n this.safeSetState({\n status: ENTERED\n }, function () {\n _this2.props.onEntered(maybeNode);\n });\n return;\n }\n\n this.props.onEnter(maybeNode, maybeAppearing);\n this.safeSetState({\n status: ENTERING\n }, function () {\n _this2.props.onEntering(maybeNode, maybeAppearing);\n\n _this2.onTransitionEnd(enterTimeout, function () {\n _this2.safeSetState({\n status: ENTERED\n }, function () {\n _this2.props.onEntered(maybeNode, maybeAppearing);\n });\n });\n });\n };\n\n _proto.performExit = function performExit() {\n var _this3 = this;\n\n var exit = this.props.exit;\n var timeouts = this.getTimeouts();\n var maybeNode = this.props.nodeRef ? undefined : ReactDOM.findDOMNode(this); // no exit animation skip right to EXITED\n\n if (!exit || config.disabled) {\n this.safeSetState({\n status: EXITED\n }, function () {\n _this3.props.onExited(maybeNode);\n });\n return;\n }\n\n this.props.onExit(maybeNode);\n this.safeSetState({\n status: EXITING\n }, function () {\n _this3.props.onExiting(maybeNode);\n\n _this3.onTransitionEnd(timeouts.exit, function () {\n _this3.safeSetState({\n status: EXITED\n }, function () {\n _this3.props.onExited(maybeNode);\n });\n });\n });\n };\n\n _proto.cancelNextCallback = function cancelNextCallback() {\n if (this.nextCallback !== null) {\n this.nextCallback.cancel();\n this.nextCallback = null;\n }\n };\n\n _proto.safeSetState = function safeSetState(nextState, callback) {\n // This shouldn't be necessary, but there are weird race conditions with\n // setState callbacks and unmounting in testing, so always make sure that\n // we can cancel any pending setState callbacks after we unmount.\n callback = this.setNextCallback(callback);\n this.setState(nextState, callback);\n };\n\n _proto.setNextCallback = function setNextCallback(callback) {\n var _this4 = this;\n\n var active = true;\n\n this.nextCallback = function (event) {\n if (active) {\n active = false;\n _this4.nextCallback = null;\n callback(event);\n }\n };\n\n this.nextCallback.cancel = function () {\n active = false;\n };\n\n return this.nextCallback;\n };\n\n _proto.onTransitionEnd = function onTransitionEnd(timeout, handler) {\n this.setNextCallback(handler);\n var node = this.props.nodeRef ? this.props.nodeRef.current : ReactDOM.findDOMNode(this);\n var doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener;\n\n if (!node || doesNotHaveTimeoutOrListener) {\n setTimeout(this.nextCallback, 0);\n return;\n }\n\n if (this.props.addEndListener) {\n var _ref3 = this.props.nodeRef ? [this.nextCallback] : [node, this.nextCallback],\n maybeNode = _ref3[0],\n maybeNextCallback = _ref3[1];\n\n this.props.addEndListener(maybeNode, maybeNextCallback);\n }\n\n if (timeout != null) {\n setTimeout(this.nextCallback, timeout);\n }\n };\n\n _proto.render = function render() {\n var status = this.state.status;\n\n if (status === UNMOUNTED) {\n return null;\n }\n\n var _this$props = this.props,\n children = _this$props.children,\n _in = _this$props.in,\n _mountOnEnter = _this$props.mountOnEnter,\n _unmountOnExit = _this$props.unmountOnExit,\n _appear = _this$props.appear,\n _enter = _this$props.enter,\n _exit = _this$props.exit,\n _timeout = _this$props.timeout,\n _addEndListener = _this$props.addEndListener,\n _onEnter = _this$props.onEnter,\n _onEntering = _this$props.onEntering,\n _onEntered = _this$props.onEntered,\n _onExit = _this$props.onExit,\n _onExiting = _this$props.onExiting,\n _onExited = _this$props.onExited,\n _nodeRef = _this$props.nodeRef,\n childProps = _objectWithoutPropertiesLoose(_this$props, [\"children\", \"in\", \"mountOnEnter\", \"unmountOnExit\", \"appear\", \"enter\", \"exit\", \"timeout\", \"addEndListener\", \"onEnter\", \"onEntering\", \"onEntered\", \"onExit\", \"onExiting\", \"onExited\", \"nodeRef\"]);\n\n return (\n /*#__PURE__*/\n // allows for nested Transitions\n React.createElement(TransitionGroupContext.Provider, {\n value: null\n }, typeof children === 'function' ? children(status, childProps) : React.cloneElement(React.Children.only(children), childProps))\n );\n };\n\n return Transition;\n}(React.Component);\n\nTransition.contextType = TransitionGroupContext;\nTransition.propTypes = process.env.NODE_ENV !== \"production\" ? {\n /**\n * A React reference to DOM element that need to transition:\n * https://stackoverflow.com/a/51127130/4671932\n *\n * - When `nodeRef` prop is used, `node` is not passed to callback functions\n * (e.g. `onEnter`) because user already has direct access to the node.\n * - When changing `key` prop of `Transition` in a `TransitionGroup` a new\n * `nodeRef` need to be provided to `Transition` with changed `key` prop\n * (see\n * [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)).\n */\n nodeRef: PropTypes.shape({\n current: typeof Element === 'undefined' ? PropTypes.any : PropTypes.instanceOf(Element)\n }),\n\n /**\n * A `function` child can be used instead of a React element. This function is\n * called with the current transition status (`'entering'`, `'entered'`,\n * `'exiting'`, `'exited'`), which can be used to apply context\n * specific props to a component.\n *\n * ```jsx\n * \n * {state => (\n * \n * )}\n * \n * ```\n */\n children: PropTypes.oneOfType([PropTypes.func.isRequired, PropTypes.element.isRequired]).isRequired,\n\n /**\n * Show the component; triggers the enter or exit states\n */\n in: PropTypes.bool,\n\n /**\n * By default the child component is mounted immediately along with\n * the parent `Transition` component. If you want to \"lazy mount\" the component on the\n * first `in={true}` you can set `mountOnEnter`. After the first enter transition the component will stay\n * mounted, even on \"exited\", unless you also specify `unmountOnExit`.\n */\n mountOnEnter: PropTypes.bool,\n\n /**\n * By default the child component stays mounted after it reaches the `'exited'` state.\n * Set `unmountOnExit` if you'd prefer to unmount the component after it finishes exiting.\n */\n unmountOnExit: PropTypes.bool,\n\n /**\n * By default the child component does not perform the enter transition when\n * it first mounts, regardless of the value of `in`. If you want this\n * behavior, set both `appear` and `in` to `true`.\n *\n * > **Note**: there are no special appear states like `appearing`/`appeared`, this prop\n * > only adds an additional enter transition. However, in the\n * > `` component that first enter transition does result in\n * > additional `.appear-*` classes, that way you can choose to style it\n * > differently.\n */\n appear: PropTypes.bool,\n\n /**\n * Enable or disable enter transitions.\n */\n enter: PropTypes.bool,\n\n /**\n * Enable or disable exit transitions.\n */\n exit: PropTypes.bool,\n\n /**\n * The duration of the transition, in milliseconds.\n * Required unless `addEndListener` is provided.\n *\n * You may specify a single timeout for all transitions:\n *\n * ```jsx\n * timeout={500}\n * ```\n *\n * or individually:\n *\n * ```jsx\n * timeout={{\n * appear: 500,\n * enter: 300,\n * exit: 500,\n * }}\n * ```\n *\n * - `appear` defaults to the value of `enter`\n * - `enter` defaults to `0`\n * - `exit` defaults to `0`\n *\n * @type {number | { enter?: number, exit?: number, appear?: number }}\n */\n timeout: function timeout(props) {\n var pt = timeoutsShape;\n if (!props.addEndListener) pt = pt.isRequired;\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n return pt.apply(void 0, [props].concat(args));\n },\n\n /**\n * Add a custom transition end trigger. Called with the transitioning\n * DOM node and a `done` callback. Allows for more fine grained transition end\n * logic. Timeouts are still used as a fallback if provided.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed.\n *\n * ```jsx\n * addEndListener={(node, done) => {\n * // use the css transitionend event to mark the finish of a transition\n * node.addEventListener('transitionend', done, false);\n * }}\n * ```\n */\n addEndListener: PropTypes.func,\n\n /**\n * Callback fired before the \"entering\" status is applied. An extra parameter\n * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed.\n *\n * @type Function(node: HtmlElement, isAppearing: bool) -> void\n */\n onEnter: PropTypes.func,\n\n /**\n * Callback fired after the \"entering\" status is applied. An extra parameter\n * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed.\n *\n * @type Function(node: HtmlElement, isAppearing: bool)\n */\n onEntering: PropTypes.func,\n\n /**\n * Callback fired after the \"entered\" status is applied. An extra parameter\n * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed.\n *\n * @type Function(node: HtmlElement, isAppearing: bool) -> void\n */\n onEntered: PropTypes.func,\n\n /**\n * Callback fired before the \"exiting\" status is applied.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed.\n *\n * @type Function(node: HtmlElement) -> void\n */\n onExit: PropTypes.func,\n\n /**\n * Callback fired after the \"exiting\" status is applied.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed.\n *\n * @type Function(node: HtmlElement) -> void\n */\n onExiting: PropTypes.func,\n\n /**\n * Callback fired after the \"exited\" status is applied.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed\n *\n * @type Function(node: HtmlElement) -> void\n */\n onExited: PropTypes.func\n} : {}; // Name the function so it is clearer in the documentation\n\nfunction noop() {}\n\nTransition.defaultProps = {\n in: false,\n mountOnEnter: false,\n unmountOnExit: false,\n appear: false,\n enter: true,\n exit: true,\n onEnter: noop,\n onEntering: noop,\n onEntered: noop,\n onExit: noop,\n onExiting: noop,\n onExited: noop\n};\nTransition.UNMOUNTED = UNMOUNTED;\nTransition.EXITED = EXITED;\nTransition.ENTERING = ENTERING;\nTransition.ENTERED = ENTERED;\nTransition.EXITING = EXITING;\nexport default Transition;","import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\nimport PropTypes from 'prop-types';\nimport addOneClass from 'dom-helpers/addClass';\nimport removeOneClass from 'dom-helpers/removeClass';\nimport React from 'react';\nimport Transition from './Transition';\nimport { classNamesShape } from './utils/PropTypes';\n\nvar _addClass = function addClass(node, classes) {\n return node && classes && classes.split(' ').forEach(function (c) {\n return addOneClass(node, c);\n });\n};\n\nvar removeClass = function removeClass(node, classes) {\n return node && classes && classes.split(' ').forEach(function (c) {\n return removeOneClass(node, c);\n });\n};\n/**\n * A transition component inspired by the excellent\n * [ng-animate](https://docs.angularjs.org/api/ngAnimate) library, you should\n * use it if you're using CSS transitions or animations. It's built upon the\n * [`Transition`](https://reactcommunity.org/react-transition-group/transition)\n * component, so it inherits all of its props.\n *\n * `CSSTransition` applies a pair of class names during the `appear`, `enter`,\n * and `exit` states of the transition. The first class is applied and then a\n * second `*-active` class in order to activate the CSS transition. After the\n * transition, matching `*-done` class names are applied to persist the\n * transition state.\n *\n * ```jsx\n * function App() {\n * const [inProp, setInProp] = useState(false);\n * return (\n *
\n * \n *
\n * {\"I'll receive my-node-* classes\"}\n *
\n *
\n * \n *
\n * );\n * }\n * ```\n *\n * When the `in` prop is set to `true`, the child component will first receive\n * the class `example-enter`, then the `example-enter-active` will be added in\n * the next tick. `CSSTransition` [forces a\n * reflow](https://github.com/reactjs/react-transition-group/blob/5007303e729a74be66a21c3e2205e4916821524b/src/CSSTransition.js#L208-L215)\n * between before adding the `example-enter-active`. This is an important trick\n * because it allows us to transition between `example-enter` and\n * `example-enter-active` even though they were added immediately one after\n * another. Most notably, this is what makes it possible for us to animate\n * _appearance_.\n *\n * ```css\n * .my-node-enter {\n * opacity: 0;\n * }\n * .my-node-enter-active {\n * opacity: 1;\n * transition: opacity 200ms;\n * }\n * .my-node-exit {\n * opacity: 1;\n * }\n * .my-node-exit-active {\n * opacity: 0;\n * transition: opacity 200ms;\n * }\n * ```\n *\n * `*-active` classes represent which styles you want to animate **to**, so it's\n * important to add `transition` declaration only to them, otherwise transitions\n * might not behave as intended! This might not be obvious when the transitions\n * are symmetrical, i.e. when `*-enter-active` is the same as `*-exit`, like in\n * the example above (minus `transition`), but it becomes apparent in more\n * complex transitions.\n *\n * **Note**: If you're using the\n * [`appear`](http://reactcommunity.org/react-transition-group/transition#Transition-prop-appear)\n * prop, make sure to define styles for `.appear-*` classes as well.\n */\n\n\nvar CSSTransition = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(CSSTransition, _React$Component);\n\n function CSSTransition() {\n var _this;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;\n _this.appliedClasses = {\n appear: {},\n enter: {},\n exit: {}\n };\n\n _this.onEnter = function (maybeNode, maybeAppearing) {\n var _this$resolveArgument = _this.resolveArguments(maybeNode, maybeAppearing),\n node = _this$resolveArgument[0],\n appearing = _this$resolveArgument[1];\n\n _this.removeClasses(node, 'exit');\n\n _this.addClass(node, appearing ? 'appear' : 'enter', 'base');\n\n if (_this.props.onEnter) {\n _this.props.onEnter(maybeNode, maybeAppearing);\n }\n };\n\n _this.onEntering = function (maybeNode, maybeAppearing) {\n var _this$resolveArgument2 = _this.resolveArguments(maybeNode, maybeAppearing),\n node = _this$resolveArgument2[0],\n appearing = _this$resolveArgument2[1];\n\n var type = appearing ? 'appear' : 'enter';\n\n _this.addClass(node, type, 'active');\n\n if (_this.props.onEntering) {\n _this.props.onEntering(maybeNode, maybeAppearing);\n }\n };\n\n _this.onEntered = function (maybeNode, maybeAppearing) {\n var _this$resolveArgument3 = _this.resolveArguments(maybeNode, maybeAppearing),\n node = _this$resolveArgument3[0],\n appearing = _this$resolveArgument3[1];\n\n var type = appearing ? 'appear' : 'enter';\n\n _this.removeClasses(node, type);\n\n _this.addClass(node, type, 'done');\n\n if (_this.props.onEntered) {\n _this.props.onEntered(maybeNode, maybeAppearing);\n }\n };\n\n _this.onExit = function (maybeNode) {\n var _this$resolveArgument4 = _this.resolveArguments(maybeNode),\n node = _this$resolveArgument4[0];\n\n _this.removeClasses(node, 'appear');\n\n _this.removeClasses(node, 'enter');\n\n _this.addClass(node, 'exit', 'base');\n\n if (_this.props.onExit) {\n _this.props.onExit(maybeNode);\n }\n };\n\n _this.onExiting = function (maybeNode) {\n var _this$resolveArgument5 = _this.resolveArguments(maybeNode),\n node = _this$resolveArgument5[0];\n\n _this.addClass(node, 'exit', 'active');\n\n if (_this.props.onExiting) {\n _this.props.onExiting(maybeNode);\n }\n };\n\n _this.onExited = function (maybeNode) {\n var _this$resolveArgument6 = _this.resolveArguments(maybeNode),\n node = _this$resolveArgument6[0];\n\n _this.removeClasses(node, 'exit');\n\n _this.addClass(node, 'exit', 'done');\n\n if (_this.props.onExited) {\n _this.props.onExited(maybeNode);\n }\n };\n\n _this.resolveArguments = function (maybeNode, maybeAppearing) {\n return _this.props.nodeRef ? [_this.props.nodeRef.current, maybeNode] // here `maybeNode` is actually `appearing`\n : [maybeNode, maybeAppearing];\n };\n\n _this.getClassNames = function (type) {\n var classNames = _this.props.classNames;\n var isStringClassNames = typeof classNames === 'string';\n var prefix = isStringClassNames && classNames ? classNames + \"-\" : '';\n var baseClassName = isStringClassNames ? \"\" + prefix + type : classNames[type];\n var activeClassName = isStringClassNames ? baseClassName + \"-active\" : classNames[type + \"Active\"];\n var doneClassName = isStringClassNames ? baseClassName + \"-done\" : classNames[type + \"Done\"];\n return {\n baseClassName: baseClassName,\n activeClassName: activeClassName,\n doneClassName: doneClassName\n };\n };\n\n return _this;\n }\n\n var _proto = CSSTransition.prototype;\n\n _proto.addClass = function addClass(node, type, phase) {\n var className = this.getClassNames(type)[phase + \"ClassName\"];\n\n var _this$getClassNames = this.getClassNames('enter'),\n doneClassName = _this$getClassNames.doneClassName;\n\n if (type === 'appear' && phase === 'done' && doneClassName) {\n className += \" \" + doneClassName;\n } // This is for to force a repaint,\n // which is necessary in order to transition styles when adding a class name.\n\n\n if (phase === 'active') {\n /* eslint-disable no-unused-expressions */\n node && node.scrollTop;\n }\n\n if (className) {\n this.appliedClasses[type][phase] = className;\n\n _addClass(node, className);\n }\n };\n\n _proto.removeClasses = function removeClasses(node, type) {\n var _this$appliedClasses$ = this.appliedClasses[type],\n baseClassName = _this$appliedClasses$.base,\n activeClassName = _this$appliedClasses$.active,\n doneClassName = _this$appliedClasses$.done;\n this.appliedClasses[type] = {};\n\n if (baseClassName) {\n removeClass(node, baseClassName);\n }\n\n if (activeClassName) {\n removeClass(node, activeClassName);\n }\n\n if (doneClassName) {\n removeClass(node, doneClassName);\n }\n };\n\n _proto.render = function render() {\n var _this$props = this.props,\n _ = _this$props.classNames,\n props = _objectWithoutPropertiesLoose(_this$props, [\"classNames\"]);\n\n return /*#__PURE__*/React.createElement(Transition, _extends({}, props, {\n onEnter: this.onEnter,\n onEntered: this.onEntered,\n onEntering: this.onEntering,\n onExit: this.onExit,\n onExiting: this.onExiting,\n onExited: this.onExited\n }));\n };\n\n return CSSTransition;\n}(React.Component);\n\nCSSTransition.defaultProps = {\n classNames: ''\n};\nCSSTransition.propTypes = process.env.NODE_ENV !== \"production\" ? _extends({}, Transition.propTypes, {\n /**\n * The animation classNames applied to the component as it appears, enters,\n * exits or has finished the transition. A single name can be provided, which\n * will be suffixed for each stage, e.g. `classNames=\"fade\"` applies:\n *\n * - `fade-appear`, `fade-appear-active`, `fade-appear-done`\n * - `fade-enter`, `fade-enter-active`, `fade-enter-done`\n * - `fade-exit`, `fade-exit-active`, `fade-exit-done`\n *\n * A few details to note about how these classes are applied:\n *\n * 1. They are _joined_ with the ones that are already defined on the child\n * component, so if you want to add some base styles, you can use\n * `className` without worrying that it will be overridden.\n *\n * 2. If the transition component mounts with `in={false}`, no classes are\n * applied yet. You might be expecting `*-exit-done`, but if you think\n * about it, a component cannot finish exiting if it hasn't entered yet.\n *\n * 2. `fade-appear-done` and `fade-enter-done` will _both_ be applied. This\n * allows you to define different behavior for when appearing is done and\n * when regular entering is done, using selectors like\n * `.fade-enter-done:not(.fade-appear-done)`. For example, you could apply\n * an epic entrance animation when element first appears in the DOM using\n * [Animate.css](https://daneden.github.io/animate.css/). Otherwise you can\n * simply use `fade-enter-done` for defining both cases.\n *\n * Each individual classNames can also be specified independently like:\n *\n * ```js\n * classNames={{\n * appear: 'my-appear',\n * appearActive: 'my-active-appear',\n * appearDone: 'my-done-appear',\n * enter: 'my-enter',\n * enterActive: 'my-active-enter',\n * enterDone: 'my-done-enter',\n * exit: 'my-exit',\n * exitActive: 'my-active-exit',\n * exitDone: 'my-done-exit',\n * }}\n * ```\n *\n * If you want to set these classes using CSS Modules:\n *\n * ```js\n * import styles from './styles.css';\n * ```\n *\n * you might want to use camelCase in your CSS file, that way could simply\n * spread them instead of listing them one by one:\n *\n * ```js\n * classNames={{ ...styles }}\n * ```\n *\n * @type {string | {\n * appear?: string,\n * appearActive?: string,\n * appearDone?: string,\n * enter?: string,\n * enterActive?: string,\n * enterDone?: string,\n * exit?: string,\n * exitActive?: string,\n * exitDone?: string,\n * }}\n */\n classNames: classNamesShape,\n\n /**\n * A `` callback fired immediately after the 'enter' or 'appear' class is\n * applied.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed.\n *\n * @type Function(node: HtmlElement, isAppearing: bool)\n */\n onEnter: PropTypes.func,\n\n /**\n * A `` callback fired immediately after the 'enter-active' or\n * 'appear-active' class is applied.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed.\n *\n * @type Function(node: HtmlElement, isAppearing: bool)\n */\n onEntering: PropTypes.func,\n\n /**\n * A `` callback fired immediately after the 'enter' or\n * 'appear' classes are **removed** and the `done` class is added to the DOM node.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed.\n *\n * @type Function(node: HtmlElement, isAppearing: bool)\n */\n onEntered: PropTypes.func,\n\n /**\n * A `` callback fired immediately after the 'exit' class is\n * applied.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed\n *\n * @type Function(node: HtmlElement)\n */\n onExit: PropTypes.func,\n\n /**\n * A `` callback fired immediately after the 'exit-active' is applied.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed\n *\n * @type Function(node: HtmlElement)\n */\n onExiting: PropTypes.func,\n\n /**\n * A `` callback fired immediately after the 'exit' classes\n * are **removed** and the `exit-done` class is added to the DOM node.\n *\n * **Note**: when `nodeRef` prop is passed, `node` is not passed\n *\n * @type Function(node: HtmlElement)\n */\n onExited: PropTypes.func\n}) : {};\nexport default CSSTransition;","import hasClass from './hasClass';\nexport default function addClass(element, className) {\n if (element.classList) element.classList.add(className);else if (!hasClass(element, className)) if (typeof element.className === 'string') element.className = element.className + \" \" + className;else element.setAttribute('class', (element.className && element.className.baseVal || '') + \" \" + className);\n}","export default function hasClass(element, className) {\n if (element.classList) return !!className && element.classList.contains(className);\n return (\" \" + (element.className.baseVal || element.className) + \" \").indexOf(\" \" + className + \" \") !== -1;\n}","import { Children, cloneElement, isValidElement } from 'react';\n/**\n * Given `this.props.children`, return an object mapping key to child.\n *\n * @param {*} children `this.props.children`\n * @return {object} Mapping of key to child\n */\n\nexport function getChildMapping(children, mapFn) {\n var mapper = function mapper(child) {\n return mapFn && isValidElement(child) ? mapFn(child) : child;\n };\n\n var result = Object.create(null);\n if (children) Children.map(children, function (c) {\n return c;\n }).forEach(function (child) {\n // run the map function here instead so that the key is the computed one\n result[child.key] = mapper(child);\n });\n return result;\n}\n/**\n * When you're adding or removing children some may be added or removed in the\n * same render pass. We want to show *both* since we want to simultaneously\n * animate elements in and out. This function takes a previous set of keys\n * and a new set of keys and merges them with its best guess of the correct\n * ordering. In the future we may expose some of the utilities in\n * ReactMultiChild to make this easy, but for now React itself does not\n * directly have this concept of the union of prevChildren and nextChildren\n * so we implement it here.\n *\n * @param {object} prev prev children as returned from\n * `ReactTransitionChildMapping.getChildMapping()`.\n * @param {object} next next children as returned from\n * `ReactTransitionChildMapping.getChildMapping()`.\n * @return {object} a key set that contains all keys in `prev` and all keys\n * in `next` in a reasonable order.\n */\n\nexport function mergeChildMappings(prev, next) {\n prev = prev || {};\n next = next || {};\n\n function getValueForKey(key) {\n return key in next ? next[key] : prev[key];\n } // For each key of `next`, the list of keys to insert before that key in\n // the combined list\n\n\n var nextKeysPending = Object.create(null);\n var pendingKeys = [];\n\n for (var prevKey in prev) {\n if (prevKey in next) {\n if (pendingKeys.length) {\n nextKeysPending[prevKey] = pendingKeys;\n pendingKeys = [];\n }\n } else {\n pendingKeys.push(prevKey);\n }\n }\n\n var i;\n var childMapping = {};\n\n for (var nextKey in next) {\n if (nextKeysPending[nextKey]) {\n for (i = 0; i < nextKeysPending[nextKey].length; i++) {\n var pendingNextKey = nextKeysPending[nextKey][i];\n childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);\n }\n }\n\n childMapping[nextKey] = getValueForKey(nextKey);\n } // Finally, add the keys which didn't appear before any key in `next`\n\n\n for (i = 0; i < pendingKeys.length; i++) {\n childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);\n }\n\n return childMapping;\n}\n\nfunction getProp(child, prop, props) {\n return props[prop] != null ? props[prop] : child.props[prop];\n}\n\nexport function getInitialChildMapping(props, onExited) {\n return getChildMapping(props.children, function (child) {\n return cloneElement(child, {\n onExited: onExited.bind(null, child),\n in: true,\n appear: getProp(child, 'appear', props),\n enter: getProp(child, 'enter', props),\n exit: getProp(child, 'exit', props)\n });\n });\n}\nexport function getNextChildMapping(nextProps, prevChildMapping, onExited) {\n var nextChildMapping = getChildMapping(nextProps.children);\n var children = mergeChildMappings(prevChildMapping, nextChildMapping);\n Object.keys(children).forEach(function (key) {\n var child = children[key];\n if (!isValidElement(child)) return;\n var hasPrev = (key in prevChildMapping);\n var hasNext = (key in nextChildMapping);\n var prevChild = prevChildMapping[key];\n var isLeaving = isValidElement(prevChild) && !prevChild.props.in; // item is new (entering)\n\n if (hasNext && (!hasPrev || isLeaving)) {\n // console.log('entering', key)\n children[key] = cloneElement(child, {\n onExited: onExited.bind(null, child),\n in: true,\n exit: getProp(child, 'exit', nextProps),\n enter: getProp(child, 'enter', nextProps)\n });\n } else if (!hasNext && hasPrev && !isLeaving) {\n // item is old (exiting)\n // console.log('leaving', key)\n children[key] = cloneElement(child, {\n in: false\n });\n } else if (hasNext && hasPrev && isValidElement(prevChild)) {\n // item hasn't changed transition states\n // copy over the last transition props;\n // console.log('unchanged', key)\n children[key] = cloneElement(child, {\n onExited: onExited.bind(null, child),\n in: prevChild.props.in,\n exit: getProp(child, 'exit', nextProps),\n enter: getProp(child, 'enter', nextProps)\n });\n }\n });\n return children;\n}","import _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport TransitionGroupContext from './TransitionGroupContext';\nimport { getChildMapping, getInitialChildMapping, getNextChildMapping } from './utils/ChildMapping';\n\nvar values = Object.values || function (obj) {\n return Object.keys(obj).map(function (k) {\n return obj[k];\n });\n};\n\nvar defaultProps = {\n component: 'div',\n childFactory: function childFactory(child) {\n return child;\n }\n};\n/**\n * The `` component manages a set of transition components\n * (`` and ``) in a list. Like with the transition\n * components, `` is a state machine for managing the mounting\n * and unmounting of components over time.\n *\n * Consider the example below. As items are removed or added to the TodoList the\n * `in` prop is toggled automatically by the ``.\n *\n * Note that `` does not define any animation behavior!\n * Exactly _how_ a list item animates is up to the individual transition\n * component. This means you can mix and match animations across different list\n * items.\n */\n\nvar TransitionGroup = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(TransitionGroup, _React$Component);\n\n function TransitionGroup(props, context) {\n var _this;\n\n _this = _React$Component.call(this, props, context) || this;\n\n var handleExited = _this.handleExited.bind(_assertThisInitialized(_this)); // Initial children should all be entering, dependent on appear\n\n\n _this.state = {\n contextValue: {\n isMounting: true\n },\n handleExited: handleExited,\n firstRender: true\n };\n return _this;\n }\n\n var _proto = TransitionGroup.prototype;\n\n _proto.componentDidMount = function componentDidMount() {\n this.mounted = true;\n this.setState({\n contextValue: {\n isMounting: false\n }\n });\n };\n\n _proto.componentWillUnmount = function componentWillUnmount() {\n this.mounted = false;\n };\n\n TransitionGroup.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, _ref) {\n var prevChildMapping = _ref.children,\n handleExited = _ref.handleExited,\n firstRender = _ref.firstRender;\n return {\n children: firstRender ? getInitialChildMapping(nextProps, handleExited) : getNextChildMapping(nextProps, prevChildMapping, handleExited),\n firstRender: false\n };\n } // node is `undefined` when user provided `nodeRef` prop\n ;\n\n _proto.handleExited = function handleExited(child, node) {\n var currentChildMapping = getChildMapping(this.props.children);\n if (child.key in currentChildMapping) return;\n\n if (child.props.onExited) {\n child.props.onExited(node);\n }\n\n if (this.mounted) {\n this.setState(function (state) {\n var children = _extends({}, state.children);\n\n delete children[child.key];\n return {\n children: children\n };\n });\n }\n };\n\n _proto.render = function render() {\n var _this$props = this.props,\n Component = _this$props.component,\n childFactory = _this$props.childFactory,\n props = _objectWithoutPropertiesLoose(_this$props, [\"component\", \"childFactory\"]);\n\n var contextValue = this.state.contextValue;\n var children = values(this.state.children).map(childFactory);\n delete props.appear;\n delete props.enter;\n delete props.exit;\n\n if (Component === null) {\n return /*#__PURE__*/React.createElement(TransitionGroupContext.Provider, {\n value: contextValue\n }, children);\n }\n\n return /*#__PURE__*/React.createElement(TransitionGroupContext.Provider, {\n value: contextValue\n }, /*#__PURE__*/React.createElement(Component, props, children));\n };\n\n return TransitionGroup;\n}(React.Component);\n\nTransitionGroup.propTypes = process.env.NODE_ENV !== \"production\" ? {\n /**\n * `` renders a `
` by default. You can change this\n * behavior by providing a `component` prop.\n * If you use React v16+ and would like to avoid a wrapping `
` element\n * you can pass in `component={null}`. This is useful if the wrapping div\n * borks your css styles.\n */\n component: PropTypes.any,\n\n /**\n * A set of `` components, that are toggled `in` and out as they\n * leave. the `` will inject specific transition props, so\n * remember to spread them through if you are wrapping the `` as\n * with our `` example.\n *\n * While this component is meant for multiple `Transition` or `CSSTransition`\n * children, sometimes you may want to have a single transition child with\n * content that you want to be transitioned out and in when you change it\n * (e.g. routes, images etc.) In that case you can change the `key` prop of\n * the transition child as you change its content, this will cause\n * `TransitionGroup` to transition the child out and back in.\n */\n children: PropTypes.node,\n\n /**\n * A convenience prop that enables or disables appear animations\n * for all children. Note that specifying this will override any defaults set\n * on individual children Transitions.\n */\n appear: PropTypes.bool,\n\n /**\n * A convenience prop that enables or disables enter animations\n * for all children. Note that specifying this will override any defaults set\n * on individual children Transitions.\n */\n enter: PropTypes.bool,\n\n /**\n * A convenience prop that enables or disables exit animations\n * for all children. Note that specifying this will override any defaults set\n * on individual children Transitions.\n */\n exit: PropTypes.bool,\n\n /**\n * You may need to apply reactive updates to a child as it is exiting.\n * This is generally done by using `cloneElement` however in the case of an exiting\n * child the element has already been removed and not accessible to the consumer.\n *\n * If you do need to update a child as it leaves you can provide a `childFactory`\n * to wrap every child, even the ones that are leaving.\n *\n * @type Function(child: ReactElement) -> ReactElement\n */\n childFactory: PropTypes.func\n} : {};\nTransitionGroup.defaultProps = defaultProps;\nexport default TransitionGroup;","import _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport TransitionGroup from './TransitionGroup';\n/**\n * The `` component is a specialized `Transition` component\n * that animates between two children.\n *\n * ```jsx\n * \n *
I appear first
\n *
I replace the above
\n *
\n * ```\n */\n\nvar ReplaceTransition = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(ReplaceTransition, _React$Component);\n\n function ReplaceTransition() {\n var _this;\n\n for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {\n _args[_key] = arguments[_key];\n }\n\n _this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;\n\n _this.handleEnter = function () {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n return _this.handleLifecycle('onEnter', 0, args);\n };\n\n _this.handleEntering = function () {\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n\n return _this.handleLifecycle('onEntering', 0, args);\n };\n\n _this.handleEntered = function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n\n return _this.handleLifecycle('onEntered', 0, args);\n };\n\n _this.handleExit = function () {\n for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n args[_key5] = arguments[_key5];\n }\n\n return _this.handleLifecycle('onExit', 1, args);\n };\n\n _this.handleExiting = function () {\n for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n args[_key6] = arguments[_key6];\n }\n\n return _this.handleLifecycle('onExiting', 1, args);\n };\n\n _this.handleExited = function () {\n for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {\n args[_key7] = arguments[_key7];\n }\n\n return _this.handleLifecycle('onExited', 1, args);\n };\n\n return _this;\n }\n\n var _proto = ReplaceTransition.prototype;\n\n _proto.handleLifecycle = function handleLifecycle(handler, idx, originalArgs) {\n var _child$props;\n\n var children = this.props.children;\n var child = React.Children.toArray(children)[idx];\n if (child.props[handler]) (_child$props = child.props)[handler].apply(_child$props, originalArgs);\n\n if (this.props[handler]) {\n var maybeNode = child.props.nodeRef ? undefined : ReactDOM.findDOMNode(this);\n this.props[handler](maybeNode);\n }\n };\n\n _proto.render = function render() {\n var _this$props = this.props,\n children = _this$props.children,\n inProp = _this$props.in,\n props = _objectWithoutPropertiesLoose(_this$props, [\"children\", \"in\"]);\n\n var _React$Children$toArr = React.Children.toArray(children),\n first = _React$Children$toArr[0],\n second = _React$Children$toArr[1];\n\n delete props.onEnter;\n delete props.onEntering;\n delete props.onEntered;\n delete props.onExit;\n delete props.onExiting;\n delete props.onExited;\n return /*#__PURE__*/React.createElement(TransitionGroup, props, inProp ? React.cloneElement(first, {\n key: 'first',\n onEnter: this.handleEnter,\n onEntering: this.handleEntering,\n onEntered: this.handleEntered\n }) : React.cloneElement(second, {\n key: 'second',\n onEnter: this.handleExit,\n onEntering: this.handleExiting,\n onEntered: this.handleExited\n }));\n };\n\n return ReplaceTransition;\n}(React.Component);\n\nReplaceTransition.propTypes = process.env.NODE_ENV !== \"production\" ? {\n in: PropTypes.bool.isRequired,\n children: function children(props, propName) {\n if (React.Children.count(props[propName]) !== 2) return new Error(\"\\\"\" + propName + \"\\\" must be exactly two transition components.\");\n return null;\n }\n} : {};\nexport default ReplaceTransition;","import _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\n\nvar _leaveRenders, _enterRenders;\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { ENTERED, ENTERING, EXITING } from './Transition';\nimport TransitionGroupContext from './TransitionGroupContext';\n\nfunction areChildrenDifferent(oldChildren, newChildren) {\n if (oldChildren === newChildren) return false;\n\n if (React.isValidElement(oldChildren) && React.isValidElement(newChildren) && oldChildren.key != null && oldChildren.key === newChildren.key) {\n return false;\n }\n\n return true;\n}\n/**\n * Enum of modes for SwitchTransition component\n * @enum { string }\n */\n\n\nexport var modes = {\n out: 'out-in',\n in: 'in-out'\n};\n\nvar callHook = function callHook(element, name, cb) {\n return function () {\n var _element$props;\n\n element.props[name] && (_element$props = element.props)[name].apply(_element$props, arguments);\n cb();\n };\n};\n\nvar leaveRenders = (_leaveRenders = {}, _leaveRenders[modes.out] = function (_ref) {\n var current = _ref.current,\n changeState = _ref.changeState;\n return React.cloneElement(current, {\n in: false,\n onExited: callHook(current, 'onExited', function () {\n changeState(ENTERING, null);\n })\n });\n}, _leaveRenders[modes.in] = function (_ref2) {\n var current = _ref2.current,\n changeState = _ref2.changeState,\n children = _ref2.children;\n return [current, React.cloneElement(children, {\n in: true,\n onEntered: callHook(children, 'onEntered', function () {\n changeState(ENTERING);\n })\n })];\n}, _leaveRenders);\nvar enterRenders = (_enterRenders = {}, _enterRenders[modes.out] = function (_ref3) {\n var children = _ref3.children,\n changeState = _ref3.changeState;\n return React.cloneElement(children, {\n in: true,\n onEntered: callHook(children, 'onEntered', function () {\n changeState(ENTERED, React.cloneElement(children, {\n in: true\n }));\n })\n });\n}, _enterRenders[modes.in] = function (_ref4) {\n var current = _ref4.current,\n children = _ref4.children,\n changeState = _ref4.changeState;\n return [React.cloneElement(current, {\n in: false,\n onExited: callHook(current, 'onExited', function () {\n changeState(ENTERED, React.cloneElement(children, {\n in: true\n }));\n })\n }), React.cloneElement(children, {\n in: true\n })];\n}, _enterRenders);\n/**\n * A transition component inspired by the [vue transition modes](https://vuejs.org/v2/guide/transitions.html#Transition-Modes).\n * You can use it when you want to control the render between state transitions.\n * Based on the selected mode and the child's key which is the `Transition` or `CSSTransition` component, the `SwitchTransition` makes a consistent transition between them.\n *\n * If the `out-in` mode is selected, the `SwitchTransition` waits until the old child leaves and then inserts a new child.\n * If the `in-out` mode is selected, the `SwitchTransition` inserts a new child first, waits for the new child to enter and then removes the old child.\n *\n * **Note**: If you want the animation to happen simultaneously\n * (that is, to have the old child removed and a new child inserted **at the same time**),\n * you should use\n * [`TransitionGroup`](https://reactcommunity.org/react-transition-group/transition-group)\n * instead.\n *\n * ```jsx\n * function App() {\n * const [state, setState] = useState(false);\n * return (\n * \n * node.addEventListener(\"transitionend\", done, false)}\n * classNames='fade'\n * >\n * \n * \n * \n * );\n * }\n * ```\n *\n * ```css\n * .fade-enter{\n * opacity: 0;\n * }\n * .fade-exit{\n * opacity: 1;\n * }\n * .fade-enter-active{\n * opacity: 1;\n * }\n * .fade-exit-active{\n * opacity: 0;\n * }\n * .fade-enter-active,\n * .fade-exit-active{\n * transition: opacity 500ms;\n * }\n * ```\n */\n\nvar SwitchTransition = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(SwitchTransition, _React$Component);\n\n function SwitchTransition() {\n var _this;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;\n _this.state = {\n status: ENTERED,\n current: null\n };\n _this.appeared = false;\n\n _this.changeState = function (status, current) {\n if (current === void 0) {\n current = _this.state.current;\n }\n\n _this.setState({\n status: status,\n current: current\n });\n };\n\n return _this;\n }\n\n var _proto = SwitchTransition.prototype;\n\n _proto.componentDidMount = function componentDidMount() {\n this.appeared = true;\n };\n\n SwitchTransition.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {\n if (props.children == null) {\n return {\n current: null\n };\n }\n\n if (state.status === ENTERING && props.mode === modes.in) {\n return {\n status: ENTERING\n };\n }\n\n if (state.current && areChildrenDifferent(state.current, props.children)) {\n return {\n status: EXITING\n };\n }\n\n return {\n current: React.cloneElement(props.children, {\n in: true\n })\n };\n };\n\n _proto.render = function render() {\n var _this$props = this.props,\n children = _this$props.children,\n mode = _this$props.mode,\n _this$state = this.state,\n status = _this$state.status,\n current = _this$state.current;\n var data = {\n children: children,\n current: current,\n changeState: this.changeState,\n status: status\n };\n var component;\n\n switch (status) {\n case ENTERING:\n component = enterRenders[mode](data);\n break;\n\n case EXITING:\n component = leaveRenders[mode](data);\n break;\n\n case ENTERED:\n component = current;\n }\n\n return /*#__PURE__*/React.createElement(TransitionGroupContext.Provider, {\n value: {\n isMounting: !this.appeared\n }\n }, component);\n };\n\n return SwitchTransition;\n}(React.Component);\n\nSwitchTransition.propTypes = process.env.NODE_ENV !== \"production\" ? {\n /**\n * Transition modes.\n * `out-in`: Current element transitions out first, then when complete, the new element transitions in.\n * `in-out`: New element transitions in first, then when complete, the current element transitions out.\n *\n * @type {'out-in'|'in-out'}\n */\n mode: PropTypes.oneOf([modes.in, modes.out]),\n\n /**\n * Any `Transition` or `CSSTransition` component.\n */\n children: PropTypes.oneOfType([PropTypes.element.isRequired])\n} : {};\nSwitchTransition.defaultProps = {\n mode: modes.out\n};\nexport default SwitchTransition;","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar generate_1 = __importDefault(require(\"./generate\"));\nexports.generate = generate_1.default;\nvar presetPrimaryColors = {\n red: '#F5222D',\n volcano: '#FA541C',\n orange: '#FA8C16',\n gold: '#FAAD14',\n yellow: '#FADB14',\n lime: '#A0D911',\n green: '#52C41A',\n cyan: '#13C2C2',\n blue: '#1890FF',\n geekblue: '#2F54EB',\n purple: '#722ED1',\n magenta: '#EB2F96',\n grey: '#666666',\n};\nexports.presetPrimaryColors = presetPrimaryColors;\nvar presetPalettes = {};\nexports.presetPalettes = presetPalettes;\nObject.keys(presetPrimaryColors).forEach(function (key) {\n presetPalettes[key] = generate_1.default(presetPrimaryColors[key]);\n presetPalettes[key].primary = presetPalettes[key][5];\n});\nvar red = presetPalettes.red;\nexports.red = red;\nvar volcano = presetPalettes.volcano;\nexports.volcano = volcano;\nvar gold = presetPalettes.gold;\nexports.gold = gold;\nvar orange = presetPalettes.orange;\nexports.orange = orange;\nvar yellow = presetPalettes.yellow;\nexports.yellow = yellow;\nvar lime = presetPalettes.lime;\nexports.lime = lime;\nvar green = presetPalettes.green;\nexports.green = green;\nvar cyan = presetPalettes.cyan;\nexports.cyan = cyan;\nvar blue = presetPalettes.blue;\nexports.blue = blue;\nvar geekblue = presetPalettes.geekblue;\nexports.geekblue = geekblue;\nvar purple = presetPalettes.purple;\nexports.purple = purple;\nvar magenta = presetPalettes.magenta;\nexports.magenta = magenta;\nvar grey = presetPalettes.grey;\nexports.grey = grey;\n","var containers = []; // will store container HTMLElement references\nvar styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement}\n\nvar usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).';\n\nfunction insertCss(css, options) {\n options = options || {};\n\n if (css === undefined) {\n throw new Error(usage);\n }\n\n var position = options.prepend === true ? 'prepend' : 'append';\n var container = options.container !== undefined ? options.container : document.querySelector('head');\n var containerId = containers.indexOf(container);\n\n // first time we see this container, create the necessary entries\n if (containerId === -1) {\n containerId = containers.push(container) - 1;\n styleElements[containerId] = {};\n }\n\n // try to get the correponding container + position styleElement, create it otherwise\n var styleElement;\n\n if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) {\n styleElement = styleElements[containerId][position];\n } else {\n styleElement = styleElements[containerId][position] = createStyleElement();\n\n if (position === 'prepend') {\n container.insertBefore(styleElement, container.childNodes[0]);\n } else {\n container.appendChild(styleElement);\n }\n }\n\n // strip potential UTF-8 BOM if css was read from a file\n if (css.charCodeAt(0) === 0xFEFF) { css = css.substr(1, css.length); }\n\n // actually add the stylesheet\n if (styleElement.styleSheet) {\n styleElement.styleSheet.cssText += css\n } else {\n styleElement.textContent += css;\n }\n\n return styleElement;\n};\n\nfunction createStyleElement() {\n var styleElement = document.createElement('style');\n styleElement.setAttribute('type', 'text/css');\n return styleElement;\n}\n\nmodule.exports = insertCss;\nmodule.exports.insertCss = insertCss;\n","'use strict';\r\n\r\n// Last time updated: 2020-02-26 1:11:47 PM UTC\r\n\r\n// ________________\r\n// RecordRTC v5.5.9\r\n\r\n// Open-Sourced: https://github.com/muaz-khan/RecordRTC\r\n\r\n// --------------------------------------------------\r\n// Muaz Khan - www.MuazKhan.com\r\n// MIT License - www.WebRTC-Experiment.com/licence\r\n// --------------------------------------------------\r\n\r\n// ____________\r\n// RecordRTC.js\r\n\r\n/**\r\n * {@link https://github.com/muaz-khan/RecordRTC|RecordRTC} is a WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows. \r\n * @summary Record audio, video or screen inside the browser.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef RecordRTC\r\n * @class\r\n * @example\r\n * var recorder = RecordRTC(mediaStream or [arrayOfMediaStream], {\r\n * type: 'video', // audio or video or gif or canvas\r\n * recorderType: MediaStreamRecorder || CanvasRecorder || StereoAudioRecorder || Etc\r\n * });\r\n * recorder.startRecording();\r\n * @see For further information:\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - Single media-stream object, array of media-streams, html-canvas-element, etc.\r\n * @param {object} config - {type:\"video\", recorderType: MediaStreamRecorder, disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, desiredSampRate: 16000, video: HTMLVideoElement, etc.}\r\n */\r\n\r\nfunction RecordRTC(mediaStream, config) {\r\n if (!mediaStream) {\r\n throw 'First parameter is required.';\r\n }\r\n\r\n config = config || {\r\n type: 'video'\r\n };\r\n\r\n config = new RecordRTCConfiguration(mediaStream, config);\r\n\r\n // a reference to user's recordRTC object\r\n var self = this;\r\n\r\n function startRecording(config2) {\r\n if (!config.disableLogs) {\r\n console.log('RecordRTC version: ', self.version);\r\n }\r\n\r\n if (!!config2) {\r\n // allow users to set options using startRecording method\r\n // config2 is similar to main \"config\" object (second parameter over RecordRTC constructor)\r\n config = new RecordRTCConfiguration(mediaStream, config2);\r\n }\r\n\r\n if (!config.disableLogs) {\r\n console.log('started recording ' + config.type + ' stream.');\r\n }\r\n\r\n if (mediaRecorder) {\r\n mediaRecorder.clearRecordedData();\r\n mediaRecorder.record();\r\n\r\n setState('recording');\r\n\r\n if (self.recordingDuration) {\r\n handleRecordingDuration();\r\n }\r\n return self;\r\n }\r\n\r\n initRecorder(function() {\r\n if (self.recordingDuration) {\r\n handleRecordingDuration();\r\n }\r\n });\r\n\r\n return self;\r\n }\r\n\r\n function initRecorder(initCallback) {\r\n if (initCallback) {\r\n config.initCallback = function() {\r\n initCallback();\r\n initCallback = config.initCallback = null; // recorder.initRecorder should be call-backed once.\r\n };\r\n }\r\n\r\n var Recorder = new GetRecorderType(mediaStream, config);\r\n\r\n mediaRecorder = new Recorder(mediaStream, config);\r\n mediaRecorder.record();\r\n\r\n setState('recording');\r\n\r\n if (!config.disableLogs) {\r\n console.log('Initialized recorderType:', mediaRecorder.constructor.name, 'for output-type:', config.type);\r\n }\r\n }\r\n\r\n function stopRecording(callback) {\r\n callback = callback || function() {};\r\n\r\n if (!mediaRecorder) {\r\n warningLog();\r\n return;\r\n }\r\n\r\n if (self.state === 'paused') {\r\n self.resumeRecording();\r\n\r\n setTimeout(function() {\r\n stopRecording(callback);\r\n }, 1);\r\n return;\r\n }\r\n\r\n if (self.state !== 'recording' && !config.disableLogs) {\r\n console.warn('Recording state should be: \"recording\", however current state is: ', self.state);\r\n }\r\n\r\n if (!config.disableLogs) {\r\n console.log('Stopped recording ' + config.type + ' stream.');\r\n }\r\n\r\n if (config.type !== 'gif') {\r\n mediaRecorder.stop(_callback);\r\n } else {\r\n mediaRecorder.stop();\r\n _callback();\r\n }\r\n\r\n setState('stopped');\r\n\r\n function _callback(__blob) {\r\n if (!mediaRecorder) {\r\n if (typeof callback.call === 'function') {\r\n callback.call(self, '');\r\n } else {\r\n callback('');\r\n }\r\n return;\r\n }\r\n\r\n Object.keys(mediaRecorder).forEach(function(key) {\r\n if (typeof mediaRecorder[key] === 'function') {\r\n return;\r\n }\r\n\r\n self[key] = mediaRecorder[key];\r\n });\r\n\r\n var blob = mediaRecorder.blob;\r\n\r\n if (!blob) {\r\n if (__blob) {\r\n mediaRecorder.blob = blob = __blob;\r\n } else {\r\n throw 'Recording failed.';\r\n }\r\n }\r\n\r\n if (blob && !config.disableLogs) {\r\n console.log(blob.type, '->', bytesToSize(blob.size));\r\n }\r\n\r\n if (callback) {\r\n var url;\r\n\r\n try {\r\n url = URL.createObjectURL(blob);\r\n } catch (e) {}\r\n\r\n if (typeof callback.call === 'function') {\r\n callback.call(self, url);\r\n } else {\r\n callback(url);\r\n }\r\n }\r\n\r\n if (!config.autoWriteToDisk) {\r\n return;\r\n }\r\n\r\n getDataURL(function(dataURL) {\r\n var parameter = {};\r\n parameter[config.type + 'Blob'] = dataURL;\r\n DiskStorage.Store(parameter);\r\n });\r\n }\r\n }\r\n\r\n function pauseRecording() {\r\n if (!mediaRecorder) {\r\n warningLog();\r\n return;\r\n }\r\n\r\n if (self.state !== 'recording') {\r\n if (!config.disableLogs) {\r\n console.warn('Unable to pause the recording. Recording state: ', self.state);\r\n }\r\n return;\r\n }\r\n\r\n setState('paused');\r\n\r\n mediaRecorder.pause();\r\n\r\n if (!config.disableLogs) {\r\n console.log('Paused recording.');\r\n }\r\n }\r\n\r\n function resumeRecording() {\r\n if (!mediaRecorder) {\r\n warningLog();\r\n return;\r\n }\r\n\r\n if (self.state !== 'paused') {\r\n if (!config.disableLogs) {\r\n console.warn('Unable to resume the recording. Recording state: ', self.state);\r\n }\r\n return;\r\n }\r\n\r\n setState('recording');\r\n\r\n // not all libs have this method yet\r\n mediaRecorder.resume();\r\n\r\n if (!config.disableLogs) {\r\n console.log('Resumed recording.');\r\n }\r\n }\r\n\r\n function readFile(_blob) {\r\n postMessage(new FileReaderSync().readAsDataURL(_blob));\r\n }\r\n\r\n function getDataURL(callback, _mediaRecorder) {\r\n if (!callback) {\r\n throw 'Pass a callback function over getDataURL.';\r\n }\r\n\r\n var blob = _mediaRecorder ? _mediaRecorder.blob : (mediaRecorder || {}).blob;\r\n\r\n if (!blob) {\r\n if (!config.disableLogs) {\r\n console.warn('Blob encoder did not finish its job yet.');\r\n }\r\n\r\n setTimeout(function() {\r\n getDataURL(callback, _mediaRecorder);\r\n }, 1000);\r\n return;\r\n }\r\n\r\n if (typeof Worker !== 'undefined' && !navigator.mozGetUserMedia) {\r\n var webWorker = processInWebWorker(readFile);\r\n\r\n webWorker.onmessage = function(event) {\r\n callback(event.data);\r\n };\r\n\r\n webWorker.postMessage(blob);\r\n } else {\r\n var reader = new FileReader();\r\n reader.readAsDataURL(blob);\r\n reader.onload = function(event) {\r\n callback(event.target.result);\r\n };\r\n }\r\n\r\n function processInWebWorker(_function) {\r\n try {\r\n var blob = URL.createObjectURL(new Blob([_function.toString(),\r\n 'this.onmessage = function (eee) {' + _function.name + '(eee.data);}'\r\n ], {\r\n type: 'application/javascript'\r\n }));\r\n\r\n var worker = new Worker(blob);\r\n URL.revokeObjectURL(blob);\r\n return worker;\r\n } catch (e) {}\r\n }\r\n }\r\n\r\n function handleRecordingDuration(counter) {\r\n counter = counter || 0;\r\n\r\n if (self.state === 'paused') {\r\n setTimeout(function() {\r\n handleRecordingDuration(counter);\r\n }, 1000);\r\n return;\r\n }\r\n\r\n if (self.state === 'stopped') {\r\n return;\r\n }\r\n\r\n if (counter >= self.recordingDuration) {\r\n stopRecording(self.onRecordingStopped);\r\n return;\r\n }\r\n\r\n counter += 1000; // 1-second\r\n\r\n setTimeout(function() {\r\n handleRecordingDuration(counter);\r\n }, 1000);\r\n }\r\n\r\n function setState(state) {\r\n if (!self) {\r\n return;\r\n }\r\n\r\n self.state = state;\r\n\r\n if (typeof self.onStateChanged.call === 'function') {\r\n self.onStateChanged.call(self, state);\r\n } else {\r\n self.onStateChanged(state);\r\n }\r\n }\r\n\r\n var WARNING = 'It seems that recorder is destroyed or \"startRecording\" is not invoked for ' + config.type + ' recorder.';\r\n\r\n function warningLog() {\r\n if (config.disableLogs === true) {\r\n return;\r\n }\r\n\r\n console.warn(WARNING);\r\n }\r\n\r\n var mediaRecorder;\r\n\r\n var returnObject = {\r\n /**\r\n * This method starts the recording.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * var recorder = RecordRTC(mediaStream, {\r\n * type: 'video'\r\n * });\r\n * recorder.startRecording();\r\n */\r\n startRecording: startRecording,\r\n\r\n /**\r\n * This method stops the recording. It is strongly recommended to get \"blob\" or \"URI\" inside the callback to make sure all recorders finished their job.\r\n * @param {function} callback - Callback to get the recorded blob.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * recorder.stopRecording(function() {\r\n * // use either \"this\" or \"recorder\" object; both are identical\r\n * video.src = this.toURL();\r\n * var blob = this.getBlob();\r\n * });\r\n */\r\n stopRecording: stopRecording,\r\n\r\n /**\r\n * This method pauses the recording. You can resume recording using \"resumeRecording\" method.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @todo Firefox is unable to pause the recording. Fix it.\r\n * @example\r\n * recorder.pauseRecording(); // pause the recording\r\n * recorder.resumeRecording(); // resume again\r\n */\r\n pauseRecording: pauseRecording,\r\n\r\n /**\r\n * This method resumes the recording.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * recorder.pauseRecording(); // first of all, pause the recording\r\n * recorder.resumeRecording(); // now resume it\r\n */\r\n resumeRecording: resumeRecording,\r\n\r\n /**\r\n * This method initializes the recording.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @todo This method should be deprecated.\r\n * @example\r\n * recorder.initRecorder();\r\n */\r\n initRecorder: initRecorder,\r\n\r\n /**\r\n * Ask RecordRTC to auto-stop the recording after 5 minutes.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * var fiveMinutes = 5 * 1000 * 60;\r\n * recorder.setRecordingDuration(fiveMinutes, function() {\r\n * var blob = this.getBlob();\r\n * video.src = this.toURL();\r\n * });\r\n * \r\n * // or otherwise\r\n * recorder.setRecordingDuration(fiveMinutes).onRecordingStopped(function() {\r\n * var blob = this.getBlob();\r\n * video.src = this.toURL();\r\n * });\r\n */\r\n setRecordingDuration: function(recordingDuration, callback) {\r\n if (typeof recordingDuration === 'undefined') {\r\n throw 'recordingDuration is required.';\r\n }\r\n\r\n if (typeof recordingDuration !== 'number') {\r\n throw 'recordingDuration must be a number.';\r\n }\r\n\r\n self.recordingDuration = recordingDuration;\r\n self.onRecordingStopped = callback || function() {};\r\n\r\n return {\r\n onRecordingStopped: function(callback) {\r\n self.onRecordingStopped = callback;\r\n }\r\n };\r\n },\r\n\r\n /**\r\n * This method can be used to clear/reset all the recorded data.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @todo Figure out the difference between \"reset\" and \"clearRecordedData\" methods.\r\n * @example\r\n * recorder.clearRecordedData();\r\n */\r\n clearRecordedData: function() {\r\n if (!mediaRecorder) {\r\n warningLog();\r\n return;\r\n }\r\n\r\n mediaRecorder.clearRecordedData();\r\n\r\n if (!config.disableLogs) {\r\n console.log('Cleared old recorded data.');\r\n }\r\n },\r\n\r\n /**\r\n * Get the recorded blob. Use this method inside the \"stopRecording\" callback.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * recorder.stopRecording(function() {\r\n * var blob = this.getBlob();\r\n *\r\n * var file = new File([blob], 'filename.webm', {\r\n * type: 'video/webm'\r\n * });\r\n *\r\n * var formData = new FormData();\r\n * formData.append('file', file); // upload \"File\" object rather than a \"Blob\"\r\n * uploadToServer(formData);\r\n * });\r\n * @returns {Blob} Returns recorded data as \"Blob\" object.\r\n */\r\n getBlob: function() {\r\n if (!mediaRecorder) {\r\n warningLog();\r\n return;\r\n }\r\n\r\n return mediaRecorder.blob;\r\n },\r\n\r\n /**\r\n * Get data-URI instead of Blob.\r\n * @param {function} callback - Callback to get the Data-URI.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * recorder.stopRecording(function() {\r\n * recorder.getDataURL(function(dataURI) {\r\n * video.src = dataURI;\r\n * });\r\n * });\r\n */\r\n getDataURL: getDataURL,\r\n\r\n /**\r\n * Get virtual/temporary URL. Usage of this URL is limited to current tab.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * recorder.stopRecording(function() {\r\n * video.src = this.toURL();\r\n * });\r\n * @returns {String} Returns a virtual/temporary URL for the recorded \"Blob\".\r\n */\r\n toURL: function() {\r\n if (!mediaRecorder) {\r\n warningLog();\r\n return;\r\n }\r\n\r\n return URL.createObjectURL(mediaRecorder.blob);\r\n },\r\n\r\n /**\r\n * Get internal recording object (i.e. internal module) e.g. MutliStreamRecorder, MediaStreamRecorder, StereoAudioRecorder or WhammyRecorder etc.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * var internalRecorder = recorder.getInternalRecorder();\r\n * if(internalRecorder instanceof MultiStreamRecorder) {\r\n * internalRecorder.addStreams([newAudioStream]);\r\n * internalRecorder.resetVideoStreams([screenStream]);\r\n * }\r\n * @returns {Object} Returns internal recording object.\r\n */\r\n getInternalRecorder: function() {\r\n return mediaRecorder;\r\n },\r\n\r\n /**\r\n * Invoke save-as dialog to save the recorded blob into your disk.\r\n * @param {string} fileName - Set your own file name.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * recorder.stopRecording(function() {\r\n * this.save('file-name');\r\n *\r\n * // or manually:\r\n * invokeSaveAsDialog(this.getBlob(), 'filename.webm');\r\n * });\r\n */\r\n save: function(fileName) {\r\n if (!mediaRecorder) {\r\n warningLog();\r\n return;\r\n }\r\n\r\n invokeSaveAsDialog(mediaRecorder.blob, fileName);\r\n },\r\n\r\n /**\r\n * This method gets a blob from indexed-DB storage.\r\n * @param {function} callback - Callback to get the recorded blob.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * recorder.getFromDisk(function(dataURL) {\r\n * video.src = dataURL;\r\n * });\r\n */\r\n getFromDisk: function(callback) {\r\n if (!mediaRecorder) {\r\n warningLog();\r\n return;\r\n }\r\n\r\n RecordRTC.getFromDisk(config.type, callback);\r\n },\r\n\r\n /**\r\n * This method appends an array of webp images to the recorded video-blob. It takes an \"array\" object.\r\n * @type {Array.}\r\n * @param {Array} arrayOfWebPImages - Array of webp images.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @todo This method should be deprecated.\r\n * @example\r\n * var arrayOfWebPImages = [];\r\n * arrayOfWebPImages.push({\r\n * duration: index,\r\n * image: 'data:image/webp;base64,...'\r\n * });\r\n * recorder.setAdvertisementArray(arrayOfWebPImages);\r\n */\r\n setAdvertisementArray: function(arrayOfWebPImages) {\r\n config.advertisement = [];\r\n\r\n var length = arrayOfWebPImages.length;\r\n for (var i = 0; i < length; i++) {\r\n config.advertisement.push({\r\n duration: i,\r\n image: arrayOfWebPImages[i]\r\n });\r\n }\r\n },\r\n\r\n /**\r\n * It is equivalent to \"recorder.getBlob()\" method. Usage of \"getBlob\" is recommended, though.\r\n * @property {Blob} blob - Recorded Blob can be accessed using this property.\r\n * @memberof RecordRTC\r\n * @instance\r\n * @readonly\r\n * @example\r\n * recorder.stopRecording(function() {\r\n * var blob = this.blob;\r\n *\r\n * // below one is recommended\r\n * var blob = this.getBlob();\r\n * });\r\n */\r\n blob: null,\r\n\r\n /**\r\n * This works only with {recorderType:StereoAudioRecorder}. Use this property on \"stopRecording\" to verify the encoder's sample-rates.\r\n * @property {number} bufferSize - Buffer-size used to encode the WAV container\r\n * @memberof RecordRTC\r\n * @instance\r\n * @readonly\r\n * @example\r\n * recorder.stopRecording(function() {\r\n * alert('Recorder used this buffer-size: ' + this.bufferSize);\r\n * });\r\n */\r\n bufferSize: 0,\r\n\r\n /**\r\n * This works only with {recorderType:StereoAudioRecorder}. Use this property on \"stopRecording\" to verify the encoder's sample-rates.\r\n * @property {number} sampleRate - Sample-rates used to encode the WAV container\r\n * @memberof RecordRTC\r\n * @instance\r\n * @readonly\r\n * @example\r\n * recorder.stopRecording(function() {\r\n * alert('Recorder used these sample-rates: ' + this.sampleRate);\r\n * });\r\n */\r\n sampleRate: 0,\r\n\r\n /**\r\n * {recorderType:StereoAudioRecorder} returns ArrayBuffer object.\r\n * @property {ArrayBuffer} buffer - Audio ArrayBuffer, supported only in Chrome.\r\n * @memberof RecordRTC\r\n * @instance\r\n * @readonly\r\n * @example\r\n * recorder.stopRecording(function() {\r\n * var arrayBuffer = this.buffer;\r\n * alert(arrayBuffer.byteLength);\r\n * });\r\n */\r\n buffer: null,\r\n\r\n /**\r\n * This method resets the recorder. So that you can reuse single recorder instance many times.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * recorder.reset();\r\n * recorder.startRecording();\r\n */\r\n reset: function() {\r\n if (self.state === 'recording' && !config.disableLogs) {\r\n console.warn('Stop an active recorder.');\r\n }\r\n\r\n if (mediaRecorder && typeof mediaRecorder.clearRecordedData === 'function') {\r\n mediaRecorder.clearRecordedData();\r\n }\r\n mediaRecorder = null;\r\n setState('inactive');\r\n self.blob = null;\r\n },\r\n\r\n /**\r\n * This method is called whenever recorder's state changes. Use this as an \"event\".\r\n * @property {String} state - A recorder's state can be: recording, paused, stopped or inactive.\r\n * @method\r\n * @memberof RecordRTC\r\n * @instance\r\n * @example\r\n * recorder.onStateChanged = function(state) {\r\n * console.log('Recorder state: ', state);\r\n * };\r\n */\r\n onStateChanged: function(state) {\r\n if (!config.disableLogs) {\r\n console.log('Recorder state changed:', state);\r\n }\r\n },\r\n\r\n /**\r\n * A recorder can have inactive, recording, paused or stopped states.\r\n * @property {String} state - A recorder's state can be: recording, paused, stopped or inactive.\r\n * @memberof RecordRTC\r\n * @static\r\n * @readonly\r\n * @example\r\n * // this looper function will keep you updated about the recorder's states.\r\n * (function looper() {\r\n * document.querySelector('h1').innerHTML = 'Recorder\\'s state is: ' + recorder.state;\r\n * if(recorder.state === 'stopped') return; // ignore+stop\r\n * setTimeout(looper, 1000); // update after every 3-seconds\r\n * })();\r\n * recorder.startRecording();\r\n */\r\n state: 'inactive',\r\n\r\n /**\r\n * Get recorder's readonly state.\r\n * @method\r\n * @memberof RecordRTC\r\n * @example\r\n * var state = recorder.getState();\r\n * @returns {String} Returns recording state.\r\n */\r\n getState: function() {\r\n return self.state;\r\n },\r\n\r\n /**\r\n * Destroy RecordRTC instance. Clear all recorders and objects.\r\n * @method\r\n * @memberof RecordRTC\r\n * @example\r\n * recorder.destroy();\r\n */\r\n destroy: function() {\r\n var disableLogsCache = config.disableLogs;\r\n\r\n config = {\r\n disableLogs: true\r\n };\r\n self.reset();\r\n setState('destroyed');\r\n returnObject = self = null;\r\n\r\n if (Storage.AudioContextConstructor) {\r\n Storage.AudioContextConstructor.close();\r\n Storage.AudioContextConstructor = null;\r\n }\r\n\r\n config.disableLogs = disableLogsCache;\r\n\r\n if (!config.disableLogs) {\r\n console.log('RecordRTC is destroyed.');\r\n }\r\n },\r\n\r\n /**\r\n * RecordRTC version number\r\n * @property {String} version - Release version number.\r\n * @memberof RecordRTC\r\n * @static\r\n * @readonly\r\n * @example\r\n * alert(recorder.version);\r\n */\r\n version: '5.5.9'\r\n };\r\n\r\n if (!this) {\r\n self = returnObject;\r\n return returnObject;\r\n }\r\n\r\n // if someone wants to use RecordRTC with the \"new\" keyword.\r\n for (var prop in returnObject) {\r\n this[prop] = returnObject[prop];\r\n }\r\n\r\n self = this;\r\n\r\n return returnObject;\r\n}\r\n\r\nRecordRTC.version = '5.5.9';\r\n\r\nif (typeof module !== 'undefined' /* && !!module.exports*/ ) {\r\n module.exports = RecordRTC;\r\n}\r\n\r\nif (typeof define === 'function' && define.amd) {\r\n define('RecordRTC', [], function() {\r\n return RecordRTC;\r\n });\r\n}\n\r\nRecordRTC.getFromDisk = function(type, callback) {\r\n if (!callback) {\r\n throw 'callback is mandatory.';\r\n }\r\n\r\n console.log('Getting recorded ' + (type === 'all' ? 'blobs' : type + ' blob ') + ' from disk!');\r\n DiskStorage.Fetch(function(dataURL, _type) {\r\n if (type !== 'all' && _type === type + 'Blob' && callback) {\r\n callback(dataURL);\r\n }\r\n\r\n if (type === 'all' && callback) {\r\n callback(dataURL, _type.replace('Blob', ''));\r\n }\r\n });\r\n};\r\n\r\n/**\r\n * This method can be used to store recorded blobs into IndexedDB storage.\r\n * @param {object} options - {audio: Blob, video: Blob, gif: Blob}\r\n * @method\r\n * @memberof RecordRTC\r\n * @example\r\n * RecordRTC.writeToDisk({\r\n * audio: audioBlob,\r\n * video: videoBlob,\r\n * gif : gifBlob\r\n * });\r\n */\r\nRecordRTC.writeToDisk = function(options) {\r\n console.log('Writing recorded blob(s) to disk!');\r\n options = options || {};\r\n if (options.audio && options.video && options.gif) {\r\n options.audio.getDataURL(function(audioDataURL) {\r\n options.video.getDataURL(function(videoDataURL) {\r\n options.gif.getDataURL(function(gifDataURL) {\r\n DiskStorage.Store({\r\n audioBlob: audioDataURL,\r\n videoBlob: videoDataURL,\r\n gifBlob: gifDataURL\r\n });\r\n });\r\n });\r\n });\r\n } else if (options.audio && options.video) {\r\n options.audio.getDataURL(function(audioDataURL) {\r\n options.video.getDataURL(function(videoDataURL) {\r\n DiskStorage.Store({\r\n audioBlob: audioDataURL,\r\n videoBlob: videoDataURL\r\n });\r\n });\r\n });\r\n } else if (options.audio && options.gif) {\r\n options.audio.getDataURL(function(audioDataURL) {\r\n options.gif.getDataURL(function(gifDataURL) {\r\n DiskStorage.Store({\r\n audioBlob: audioDataURL,\r\n gifBlob: gifDataURL\r\n });\r\n });\r\n });\r\n } else if (options.video && options.gif) {\r\n options.video.getDataURL(function(videoDataURL) {\r\n options.gif.getDataURL(function(gifDataURL) {\r\n DiskStorage.Store({\r\n videoBlob: videoDataURL,\r\n gifBlob: gifDataURL\r\n });\r\n });\r\n });\r\n } else if (options.audio) {\r\n options.audio.getDataURL(function(audioDataURL) {\r\n DiskStorage.Store({\r\n audioBlob: audioDataURL\r\n });\r\n });\r\n } else if (options.video) {\r\n options.video.getDataURL(function(videoDataURL) {\r\n DiskStorage.Store({\r\n videoBlob: videoDataURL\r\n });\r\n });\r\n } else if (options.gif) {\r\n options.gif.getDataURL(function(gifDataURL) {\r\n DiskStorage.Store({\r\n gifBlob: gifDataURL\r\n });\r\n });\r\n }\r\n};\n\r\n// __________________________\r\n// RecordRTC-Configuration.js\r\n\r\n/**\r\n * {@link RecordRTCConfiguration} is an inner/private helper for {@link RecordRTC}.\r\n * @summary It configures the 2nd parameter passed over {@link RecordRTC} and returns a valid \"config\" object.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef RecordRTCConfiguration\r\n * @class\r\n * @example\r\n * var options = RecordRTCConfiguration(mediaStream, options);\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.\r\n * @param {object} config - {type:\"video\", disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, getNativeBlob:true, etc.}\r\n */\r\n\r\nfunction RecordRTCConfiguration(mediaStream, config) {\r\n if (!config.recorderType && !config.type) {\r\n if (!!config.audio && !!config.video) {\r\n config.type = 'video';\r\n } else if (!!config.audio && !config.video) {\r\n config.type = 'audio';\r\n }\r\n }\r\n\r\n if (config.recorderType && !config.type) {\r\n if (config.recorderType === WhammyRecorder || config.recorderType === CanvasRecorder || (typeof WebAssemblyRecorder !== 'undefined' && config.recorderType === WebAssemblyRecorder)) {\r\n config.type = 'video';\r\n } else if (config.recorderType === GifRecorder) {\r\n config.type = 'gif';\r\n } else if (config.recorderType === StereoAudioRecorder) {\r\n config.type = 'audio';\r\n } else if (config.recorderType === MediaStreamRecorder) {\r\n if (getTracks(mediaStream, 'audio').length && getTracks(mediaStream, 'video').length) {\r\n config.type = 'video';\r\n } else if (!getTracks(mediaStream, 'audio').length && getTracks(mediaStream, 'video').length) {\r\n config.type = 'video';\r\n } else if (getTracks(mediaStream, 'audio').length && !getTracks(mediaStream, 'video').length) {\r\n config.type = 'audio';\r\n } else {\r\n // config.type = 'UnKnown';\r\n }\r\n }\r\n }\r\n\r\n if (typeof MediaStreamRecorder !== 'undefined' && typeof MediaRecorder !== 'undefined' && 'requestData' in MediaRecorder.prototype) {\r\n if (!config.mimeType) {\r\n config.mimeType = 'video/webm';\r\n }\r\n\r\n if (!config.type) {\r\n config.type = config.mimeType.split('/')[0];\r\n }\r\n\r\n if (!config.bitsPerSecond) {\r\n // config.bitsPerSecond = 128000;\r\n }\r\n }\r\n\r\n // consider default type=audio\r\n if (!config.type) {\r\n if (config.mimeType) {\r\n config.type = config.mimeType.split('/')[0];\r\n }\r\n if (!config.type) {\r\n config.type = 'audio';\r\n }\r\n }\r\n\r\n return config;\r\n}\n\r\n// __________________\r\n// GetRecorderType.js\r\n\r\n/**\r\n * {@link GetRecorderType} is an inner/private helper for {@link RecordRTC}.\r\n * @summary It returns best recorder-type available for your browser.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef GetRecorderType\r\n * @class\r\n * @example\r\n * var RecorderType = GetRecorderType(options);\r\n * var recorder = new RecorderType(options);\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.\r\n * @param {object} config - {type:\"video\", disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, etc.}\r\n */\r\n\r\nfunction GetRecorderType(mediaStream, config) {\r\n var recorder;\r\n\r\n // StereoAudioRecorder can work with all three: Edge, Firefox and Chrome\r\n // todo: detect if it is Edge, then auto use: StereoAudioRecorder\r\n if (isChrome || isEdge || isOpera) {\r\n // Media Stream Recording API has not been implemented in chrome yet;\r\n // That's why using WebAudio API to record stereo audio in WAV format\r\n recorder = StereoAudioRecorder;\r\n }\r\n\r\n if (typeof MediaRecorder !== 'undefined' && 'requestData' in MediaRecorder.prototype && !isChrome) {\r\n recorder = MediaStreamRecorder;\r\n }\r\n\r\n // video recorder (in WebM format)\r\n if (config.type === 'video' && (isChrome || isOpera)) {\r\n recorder = WhammyRecorder;\r\n\r\n if (typeof WebAssemblyRecorder !== 'undefined' && typeof ReadableStream !== 'undefined') {\r\n recorder = WebAssemblyRecorder;\r\n }\r\n }\r\n\r\n // video recorder (in Gif format)\r\n if (config.type === 'gif') {\r\n recorder = GifRecorder;\r\n }\r\n\r\n // html2canvas recording!\r\n if (config.type === 'canvas') {\r\n recorder = CanvasRecorder;\r\n }\r\n\r\n if (isMediaRecorderCompatible() && recorder !== CanvasRecorder && recorder !== GifRecorder && typeof MediaRecorder !== 'undefined' && 'requestData' in MediaRecorder.prototype) {\r\n if (getTracks(mediaStream, 'video').length || getTracks(mediaStream, 'audio').length) {\r\n // audio-only recording\r\n if (config.type === 'audio') {\r\n if (typeof MediaRecorder.isTypeSupported === 'function' && MediaRecorder.isTypeSupported('audio/webm')) {\r\n recorder = MediaStreamRecorder;\r\n }\r\n // else recorder = StereoAudioRecorder;\r\n } else {\r\n // video or screen tracks\r\n if (typeof MediaRecorder.isTypeSupported === 'function' && MediaRecorder.isTypeSupported('video/webm')) {\r\n recorder = MediaStreamRecorder;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (mediaStream instanceof Array && mediaStream.length) {\r\n recorder = MultiStreamRecorder;\r\n }\r\n\r\n if (config.recorderType) {\r\n recorder = config.recorderType;\r\n }\r\n\r\n if (!config.disableLogs && !!recorder && !!recorder.name) {\r\n console.log('Using recorderType:', recorder.name || recorder.constructor.name);\r\n }\r\n\r\n if (!recorder && isSafari) {\r\n recorder = MediaStreamRecorder;\r\n }\r\n\r\n return recorder;\r\n}\n\r\n// _____________\r\n// MRecordRTC.js\r\n\r\n/**\r\n * MRecordRTC runs on top of {@link RecordRTC} to bring multiple recordings in a single place, by providing simple API.\r\n * @summary MRecordRTC stands for \"Multiple-RecordRTC\".\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef MRecordRTC\r\n * @class\r\n * @example\r\n * var recorder = new MRecordRTC();\r\n * recorder.addStream(MediaStream);\r\n * recorder.mediaType = {\r\n * audio: true, // or StereoAudioRecorder or MediaStreamRecorder\r\n * video: true, // or WhammyRecorder or MediaStreamRecorder or WebAssemblyRecorder or CanvasRecorder\r\n * gif: true // or GifRecorder\r\n * };\r\n * // mimeType is optional and should be set only in advance cases.\r\n * recorder.mimeType = {\r\n * audio: 'audio/wav',\r\n * video: 'video/webm',\r\n * gif: 'image/gif'\r\n * };\r\n * recorder.startRecording();\r\n * @see For further information:\r\n * @see {@link https://github.com/muaz-khan/RecordRTC/tree/master/MRecordRTC|MRecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.\r\n * @requires {@link RecordRTC}\r\n */\r\n\r\nfunction MRecordRTC(mediaStream) {\r\n\r\n /**\r\n * This method attaches MediaStream object to {@link MRecordRTC}.\r\n * @param {MediaStream} mediaStream - A MediaStream object, either fetched using getUserMedia API, or generated using captureStreamUntilEnded or WebAudio API.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.addStream(MediaStream);\r\n */\r\n this.addStream = function(_mediaStream) {\r\n if (_mediaStream) {\r\n mediaStream = _mediaStream;\r\n }\r\n };\r\n\r\n /**\r\n * This property can be used to set the recording type e.g. audio, or video, or gif, or canvas.\r\n * @property {object} mediaType - {audio: true, video: true, gif: true}\r\n * @memberof MRecordRTC\r\n * @example\r\n * var recorder = new MRecordRTC();\r\n * recorder.mediaType = {\r\n * audio: true, // TRUE or StereoAudioRecorder or MediaStreamRecorder\r\n * video: true, // TRUE or WhammyRecorder or MediaStreamRecorder or WebAssemblyRecorder or CanvasRecorder\r\n * gif : true // TRUE or GifRecorder\r\n * };\r\n */\r\n this.mediaType = {\r\n audio: true,\r\n video: true\r\n };\r\n\r\n /**\r\n * This method starts recording.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.startRecording();\r\n */\r\n this.startRecording = function() {\r\n var mediaType = this.mediaType;\r\n var recorderType;\r\n var mimeType = this.mimeType || {\r\n audio: null,\r\n video: null,\r\n gif: null\r\n };\r\n\r\n if (typeof mediaType.audio !== 'function' && isMediaRecorderCompatible() && !getTracks(mediaStream, 'audio').length) {\r\n mediaType.audio = false;\r\n }\r\n\r\n if (typeof mediaType.video !== 'function' && isMediaRecorderCompatible() && !getTracks(mediaStream, 'video').length) {\r\n mediaType.video = false;\r\n }\r\n\r\n if (typeof mediaType.gif !== 'function' && isMediaRecorderCompatible() && !getTracks(mediaStream, 'video').length) {\r\n mediaType.gif = false;\r\n }\r\n\r\n if (!mediaType.audio && !mediaType.video && !mediaType.gif) {\r\n throw 'MediaStream must have either audio or video tracks.';\r\n }\r\n\r\n if (!!mediaType.audio) {\r\n recorderType = null;\r\n if (typeof mediaType.audio === 'function') {\r\n recorderType = mediaType.audio;\r\n }\r\n\r\n this.audioRecorder = new RecordRTC(mediaStream, {\r\n type: 'audio',\r\n bufferSize: this.bufferSize,\r\n sampleRate: this.sampleRate,\r\n numberOfAudioChannels: this.numberOfAudioChannels || 2,\r\n disableLogs: this.disableLogs,\r\n recorderType: recorderType,\r\n mimeType: mimeType.audio,\r\n timeSlice: this.timeSlice,\r\n onTimeStamp: this.onTimeStamp\r\n });\r\n\r\n if (!mediaType.video) {\r\n this.audioRecorder.startRecording();\r\n }\r\n }\r\n\r\n if (!!mediaType.video) {\r\n recorderType = null;\r\n if (typeof mediaType.video === 'function') {\r\n recorderType = mediaType.video;\r\n }\r\n\r\n var newStream = mediaStream;\r\n\r\n if (isMediaRecorderCompatible() && !!mediaType.audio && typeof mediaType.audio === 'function') {\r\n var videoTrack = getTracks(mediaStream, 'video')[0];\r\n\r\n if (isFirefox) {\r\n newStream = new MediaStream();\r\n newStream.addTrack(videoTrack);\r\n\r\n if (recorderType && recorderType === WhammyRecorder) {\r\n // Firefox does NOT supports webp-encoding yet\r\n // But Firefox do supports WebAssemblyRecorder\r\n recorderType = MediaStreamRecorder;\r\n }\r\n } else {\r\n newStream = new MediaStream();\r\n newStream.addTrack(videoTrack);\r\n }\r\n }\r\n\r\n this.videoRecorder = new RecordRTC(newStream, {\r\n type: 'video',\r\n video: this.video,\r\n canvas: this.canvas,\r\n frameInterval: this.frameInterval || 10,\r\n disableLogs: this.disableLogs,\r\n recorderType: recorderType,\r\n mimeType: mimeType.video,\r\n timeSlice: this.timeSlice,\r\n onTimeStamp: this.onTimeStamp,\r\n workerPath: this.workerPath,\r\n webAssemblyPath: this.webAssemblyPath,\r\n frameRate: this.frameRate, // used by WebAssemblyRecorder; values: usually 30; accepts any.\r\n bitrate: this.bitrate // used by WebAssemblyRecorder; values: 0 to 1000+\r\n });\r\n\r\n if (!mediaType.audio) {\r\n this.videoRecorder.startRecording();\r\n }\r\n }\r\n\r\n if (!!mediaType.audio && !!mediaType.video) {\r\n var self = this;\r\n\r\n var isSingleRecorder = isMediaRecorderCompatible() === true;\r\n\r\n if (mediaType.audio instanceof StereoAudioRecorder && !!mediaType.video) {\r\n isSingleRecorder = false;\r\n } else if (mediaType.audio !== true && mediaType.video !== true && mediaType.audio !== mediaType.video) {\r\n isSingleRecorder = false;\r\n }\r\n\r\n if (isSingleRecorder === true) {\r\n self.audioRecorder = null;\r\n self.videoRecorder.startRecording();\r\n } else {\r\n self.videoRecorder.initRecorder(function() {\r\n self.audioRecorder.initRecorder(function() {\r\n // Both recorders are ready to record things accurately\r\n self.videoRecorder.startRecording();\r\n self.audioRecorder.startRecording();\r\n });\r\n });\r\n }\r\n }\r\n\r\n if (!!mediaType.gif) {\r\n recorderType = null;\r\n if (typeof mediaType.gif === 'function') {\r\n recorderType = mediaType.gif;\r\n }\r\n this.gifRecorder = new RecordRTC(mediaStream, {\r\n type: 'gif',\r\n frameRate: this.frameRate || 200,\r\n quality: this.quality || 10,\r\n disableLogs: this.disableLogs,\r\n recorderType: recorderType,\r\n mimeType: mimeType.gif\r\n });\r\n this.gifRecorder.startRecording();\r\n }\r\n };\r\n\r\n /**\r\n * This method stops recording.\r\n * @param {function} callback - Callback function is invoked when all encoders finished their jobs.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.stopRecording(function(recording){\r\n * var audioBlob = recording.audio;\r\n * var videoBlob = recording.video;\r\n * var gifBlob = recording.gif;\r\n * });\r\n */\r\n this.stopRecording = function(callback) {\r\n callback = callback || function() {};\r\n\r\n if (this.audioRecorder) {\r\n this.audioRecorder.stopRecording(function(blobURL) {\r\n callback(blobURL, 'audio');\r\n });\r\n }\r\n\r\n if (this.videoRecorder) {\r\n this.videoRecorder.stopRecording(function(blobURL) {\r\n callback(blobURL, 'video');\r\n });\r\n }\r\n\r\n if (this.gifRecorder) {\r\n this.gifRecorder.stopRecording(function(blobURL) {\r\n callback(blobURL, 'gif');\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * This method pauses recording.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.pauseRecording();\r\n */\r\n this.pauseRecording = function() {\r\n if (this.audioRecorder) {\r\n this.audioRecorder.pauseRecording();\r\n }\r\n\r\n if (this.videoRecorder) {\r\n this.videoRecorder.pauseRecording();\r\n }\r\n\r\n if (this.gifRecorder) {\r\n this.gifRecorder.pauseRecording();\r\n }\r\n };\r\n\r\n /**\r\n * This method resumes recording.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.resumeRecording();\r\n */\r\n this.resumeRecording = function() {\r\n if (this.audioRecorder) {\r\n this.audioRecorder.resumeRecording();\r\n }\r\n\r\n if (this.videoRecorder) {\r\n this.videoRecorder.resumeRecording();\r\n }\r\n\r\n if (this.gifRecorder) {\r\n this.gifRecorder.resumeRecording();\r\n }\r\n };\r\n\r\n /**\r\n * This method can be used to manually get all recorded blobs.\r\n * @param {function} callback - All recorded blobs are passed back to the \"callback\" function.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.getBlob(function(recording){\r\n * var audioBlob = recording.audio;\r\n * var videoBlob = recording.video;\r\n * var gifBlob = recording.gif;\r\n * });\r\n * // or\r\n * var audioBlob = recorder.getBlob().audio;\r\n * var videoBlob = recorder.getBlob().video;\r\n */\r\n this.getBlob = function(callback) {\r\n var output = {};\r\n\r\n if (this.audioRecorder) {\r\n output.audio = this.audioRecorder.getBlob();\r\n }\r\n\r\n if (this.videoRecorder) {\r\n output.video = this.videoRecorder.getBlob();\r\n }\r\n\r\n if (this.gifRecorder) {\r\n output.gif = this.gifRecorder.getBlob();\r\n }\r\n\r\n if (callback) {\r\n callback(output);\r\n }\r\n\r\n return output;\r\n };\r\n\r\n /**\r\n * Destroy all recorder instances.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.destroy();\r\n */\r\n this.destroy = function() {\r\n if (this.audioRecorder) {\r\n this.audioRecorder.destroy();\r\n this.audioRecorder = null;\r\n }\r\n\r\n if (this.videoRecorder) {\r\n this.videoRecorder.destroy();\r\n this.videoRecorder = null;\r\n }\r\n\r\n if (this.gifRecorder) {\r\n this.gifRecorder.destroy();\r\n this.gifRecorder = null;\r\n }\r\n };\r\n\r\n /**\r\n * This method can be used to manually get all recorded blobs' DataURLs.\r\n * @param {function} callback - All recorded blobs' DataURLs are passed back to the \"callback\" function.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.getDataURL(function(recording){\r\n * var audioDataURL = recording.audio;\r\n * var videoDataURL = recording.video;\r\n * var gifDataURL = recording.gif;\r\n * });\r\n */\r\n this.getDataURL = function(callback) {\r\n this.getBlob(function(blob) {\r\n if (blob.audio && blob.video) {\r\n getDataURL(blob.audio, function(_audioDataURL) {\r\n getDataURL(blob.video, function(_videoDataURL) {\r\n callback({\r\n audio: _audioDataURL,\r\n video: _videoDataURL\r\n });\r\n });\r\n });\r\n } else if (blob.audio) {\r\n getDataURL(blob.audio, function(_audioDataURL) {\r\n callback({\r\n audio: _audioDataURL\r\n });\r\n });\r\n } else if (blob.video) {\r\n getDataURL(blob.video, function(_videoDataURL) {\r\n callback({\r\n video: _videoDataURL\r\n });\r\n });\r\n }\r\n });\r\n\r\n function getDataURL(blob, callback00) {\r\n if (typeof Worker !== 'undefined') {\r\n var webWorker = processInWebWorker(function readFile(_blob) {\r\n postMessage(new FileReaderSync().readAsDataURL(_blob));\r\n });\r\n\r\n webWorker.onmessage = function(event) {\r\n callback00(event.data);\r\n };\r\n\r\n webWorker.postMessage(blob);\r\n } else {\r\n var reader = new FileReader();\r\n reader.readAsDataURL(blob);\r\n reader.onload = function(event) {\r\n callback00(event.target.result);\r\n };\r\n }\r\n }\r\n\r\n function processInWebWorker(_function) {\r\n var blob = URL.createObjectURL(new Blob([_function.toString(),\r\n 'this.onmessage = function (eee) {' + _function.name + '(eee.data);}'\r\n ], {\r\n type: 'application/javascript'\r\n }));\r\n\r\n var worker = new Worker(blob);\r\n var url;\r\n if (typeof URL !== 'undefined') {\r\n url = URL;\r\n } else if (typeof webkitURL !== 'undefined') {\r\n url = webkitURL;\r\n } else {\r\n throw 'Neither URL nor webkitURL detected.';\r\n }\r\n url.revokeObjectURL(blob);\r\n return worker;\r\n }\r\n };\r\n\r\n /**\r\n * This method can be used to ask {@link MRecordRTC} to write all recorded blobs into IndexedDB storage.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.writeToDisk();\r\n */\r\n this.writeToDisk = function() {\r\n RecordRTC.writeToDisk({\r\n audio: this.audioRecorder,\r\n video: this.videoRecorder,\r\n gif: this.gifRecorder\r\n });\r\n };\r\n\r\n /**\r\n * This method can be used to invoke a save-as dialog for all recorded blobs.\r\n * @param {object} args - {audio: 'audio-name', video: 'video-name', gif: 'gif-name'}\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * recorder.save({\r\n * audio: 'audio-file-name',\r\n * video: 'video-file-name',\r\n * gif : 'gif-file-name'\r\n * });\r\n */\r\n this.save = function(args) {\r\n args = args || {\r\n audio: true,\r\n video: true,\r\n gif: true\r\n };\r\n\r\n if (!!args.audio && this.audioRecorder) {\r\n this.audioRecorder.save(typeof args.audio === 'string' ? args.audio : '');\r\n }\r\n\r\n if (!!args.video && this.videoRecorder) {\r\n this.videoRecorder.save(typeof args.video === 'string' ? args.video : '');\r\n }\r\n if (!!args.gif && this.gifRecorder) {\r\n this.gifRecorder.save(typeof args.gif === 'string' ? args.gif : '');\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * This method can be used to get all recorded blobs from IndexedDB storage.\r\n * @param {string} type - 'all' or 'audio' or 'video' or 'gif'\r\n * @param {function} callback - Callback function to get all stored blobs.\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * MRecordRTC.getFromDisk('all', function(dataURL, type){\r\n * if(type === 'audio') { }\r\n * if(type === 'video') { }\r\n * if(type === 'gif') { }\r\n * });\r\n */\r\nMRecordRTC.getFromDisk = RecordRTC.getFromDisk;\r\n\r\n/**\r\n * This method can be used to store recorded blobs into IndexedDB storage.\r\n * @param {object} options - {audio: Blob, video: Blob, gif: Blob}\r\n * @method\r\n * @memberof MRecordRTC\r\n * @example\r\n * MRecordRTC.writeToDisk({\r\n * audio: audioBlob,\r\n * video: videoBlob,\r\n * gif : gifBlob\r\n * });\r\n */\r\nMRecordRTC.writeToDisk = RecordRTC.writeToDisk;\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.MRecordRTC = MRecordRTC;\r\n}\n\r\nvar browserFakeUserAgent = 'Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45';\r\n\r\n(function(that) {\r\n if (!that) {\r\n return;\r\n }\r\n\r\n if (typeof window !== 'undefined') {\r\n return;\r\n }\r\n\r\n if (typeof global === 'undefined') {\r\n return;\r\n }\r\n\r\n global.navigator = {\r\n userAgent: browserFakeUserAgent,\r\n getUserMedia: function() {}\r\n };\r\n\r\n if (!global.console) {\r\n global.console = {};\r\n }\r\n\r\n if (typeof global.console.log === 'undefined' || typeof global.console.error === 'undefined') {\r\n global.console.error = global.console.log = global.console.log || function() {\r\n console.log(arguments);\r\n };\r\n }\r\n\r\n if (typeof document === 'undefined') {\r\n /*global document:true */\r\n that.document = {\r\n documentElement: {\r\n appendChild: function() {\r\n return '';\r\n }\r\n }\r\n };\r\n\r\n document.createElement = document.captureStream = document.mozCaptureStream = function() {\r\n var obj = {\r\n getContext: function() {\r\n return obj;\r\n },\r\n play: function() {},\r\n pause: function() {},\r\n drawImage: function() {},\r\n toDataURL: function() {\r\n return '';\r\n },\r\n style: {}\r\n };\r\n return obj;\r\n };\r\n\r\n that.HTMLVideoElement = function() {};\r\n }\r\n\r\n if (typeof location === 'undefined') {\r\n /*global location:true */\r\n that.location = {\r\n protocol: 'file:',\r\n href: '',\r\n hash: ''\r\n };\r\n }\r\n\r\n if (typeof screen === 'undefined') {\r\n /*global screen:true */\r\n that.screen = {\r\n width: 0,\r\n height: 0\r\n };\r\n }\r\n\r\n if (typeof URL === 'undefined') {\r\n /*global screen:true */\r\n that.URL = {\r\n createObjectURL: function() {\r\n return '';\r\n },\r\n revokeObjectURL: function() {\r\n return '';\r\n }\r\n };\r\n }\r\n\r\n /*global window:true */\r\n that.window = global;\r\n})(typeof global !== 'undefined' ? global : null);\n\r\n// _____________________________\r\n// Cross-Browser-Declarations.js\r\n\r\n// animation-frame used in WebM recording\r\n\r\n/*jshint -W079 */\r\nvar requestAnimationFrame = window.requestAnimationFrame;\r\nif (typeof requestAnimationFrame === 'undefined') {\r\n if (typeof webkitRequestAnimationFrame !== 'undefined') {\r\n /*global requestAnimationFrame:true */\r\n requestAnimationFrame = webkitRequestAnimationFrame;\r\n } else if (typeof mozRequestAnimationFrame !== 'undefined') {\r\n /*global requestAnimationFrame:true */\r\n requestAnimationFrame = mozRequestAnimationFrame;\r\n } else if (typeof msRequestAnimationFrame !== 'undefined') {\r\n /*global requestAnimationFrame:true */\r\n requestAnimationFrame = msRequestAnimationFrame;\r\n } else if (typeof requestAnimationFrame === 'undefined') {\r\n // via: https://gist.github.com/paulirish/1579671\r\n var lastTime = 0;\r\n\r\n /*global requestAnimationFrame:true */\r\n requestAnimationFrame = function(callback, element) {\r\n var currTime = new Date().getTime();\r\n var timeToCall = Math.max(0, 16 - (currTime - lastTime));\r\n var id = setTimeout(function() {\r\n callback(currTime + timeToCall);\r\n }, timeToCall);\r\n lastTime = currTime + timeToCall;\r\n return id;\r\n };\r\n }\r\n}\r\n\r\n/*jshint -W079 */\r\nvar cancelAnimationFrame = window.cancelAnimationFrame;\r\nif (typeof cancelAnimationFrame === 'undefined') {\r\n if (typeof webkitCancelAnimationFrame !== 'undefined') {\r\n /*global cancelAnimationFrame:true */\r\n cancelAnimationFrame = webkitCancelAnimationFrame;\r\n } else if (typeof mozCancelAnimationFrame !== 'undefined') {\r\n /*global cancelAnimationFrame:true */\r\n cancelAnimationFrame = mozCancelAnimationFrame;\r\n } else if (typeof msCancelAnimationFrame !== 'undefined') {\r\n /*global cancelAnimationFrame:true */\r\n cancelAnimationFrame = msCancelAnimationFrame;\r\n } else if (typeof cancelAnimationFrame === 'undefined') {\r\n /*global cancelAnimationFrame:true */\r\n cancelAnimationFrame = function(id) {\r\n clearTimeout(id);\r\n };\r\n }\r\n}\r\n\r\n// WebAudio API representer\r\nvar AudioContext = window.AudioContext;\r\n\r\nif (typeof AudioContext === 'undefined') {\r\n if (typeof webkitAudioContext !== 'undefined') {\r\n /*global AudioContext:true */\r\n AudioContext = webkitAudioContext;\r\n }\r\n\r\n if (typeof mozAudioContext !== 'undefined') {\r\n /*global AudioContext:true */\r\n AudioContext = mozAudioContext;\r\n }\r\n}\r\n\r\n/*jshint -W079 */\r\nvar URL = window.URL;\r\n\r\nif (typeof URL === 'undefined' && typeof webkitURL !== 'undefined') {\r\n /*global URL:true */\r\n URL = webkitURL;\r\n}\r\n\r\nif (typeof navigator !== 'undefined' && typeof navigator.getUserMedia === 'undefined') { // maybe window.navigator?\r\n if (typeof navigator.webkitGetUserMedia !== 'undefined') {\r\n navigator.getUserMedia = navigator.webkitGetUserMedia;\r\n }\r\n\r\n if (typeof navigator.mozGetUserMedia !== 'undefined') {\r\n navigator.getUserMedia = navigator.mozGetUserMedia;\r\n }\r\n}\r\n\r\nvar isEdge = navigator.userAgent.indexOf('Edge') !== -1 && (!!navigator.msSaveBlob || !!navigator.msSaveOrOpenBlob);\r\nvar isOpera = !!window.opera || navigator.userAgent.indexOf('OPR/') !== -1;\r\nvar isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && ('netscape' in window) && / rv:/.test(navigator.userAgent);\r\nvar isChrome = (!isOpera && !isEdge && !!navigator.webkitGetUserMedia) || isElectron() || navigator.userAgent.toLowerCase().indexOf('chrome/') !== -1;\r\n\r\nvar isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\r\n\r\nif (isSafari && !isChrome && navigator.userAgent.indexOf('CriOS') !== -1) {\r\n isSafari = false;\r\n isChrome = true;\r\n}\r\n\r\nvar MediaStream = window.MediaStream;\r\n\r\nif (typeof MediaStream === 'undefined' && typeof webkitMediaStream !== 'undefined') {\r\n MediaStream = webkitMediaStream;\r\n}\r\n\r\n/*global MediaStream:true */\r\nif (typeof MediaStream !== 'undefined') {\r\n // override \"stop\" method for all browsers\r\n if (typeof MediaStream.prototype.stop === 'undefined') {\r\n MediaStream.prototype.stop = function() {\r\n this.getTracks().forEach(function(track) {\r\n track.stop();\r\n });\r\n };\r\n }\r\n}\r\n\r\n// below function via: http://goo.gl/B3ae8c\r\n/**\r\n * Return human-readable file size.\r\n * @param {number} bytes - Pass bytes and get formatted string.\r\n * @returns {string} - formatted string\r\n * @example\r\n * bytesToSize(1024*1024*5) === '5 GB'\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n */\r\nfunction bytesToSize(bytes) {\r\n var k = 1000;\r\n var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\r\n if (bytes === 0) {\r\n return '0 Bytes';\r\n }\r\n var i = parseInt(Math.floor(Math.log(bytes) / Math.log(k)), 10);\r\n return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];\r\n}\r\n\r\n/**\r\n * @param {Blob} file - File or Blob object. This parameter is required.\r\n * @param {string} fileName - Optional file name e.g. \"Recorded-Video.webm\"\r\n * @example\r\n * invokeSaveAsDialog(blob or file, [optional] fileName);\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n */\r\nfunction invokeSaveAsDialog(file, fileName) {\r\n if (!file) {\r\n throw 'Blob object is required.';\r\n }\r\n\r\n if (!file.type) {\r\n try {\r\n file.type = 'video/webm';\r\n } catch (e) {}\r\n }\r\n\r\n var fileExtension = (file.type || 'video/webm').split('/')[1];\r\n\r\n if (fileName && fileName.indexOf('.') !== -1) {\r\n var splitted = fileName.split('.');\r\n fileName = splitted[0];\r\n fileExtension = splitted[1];\r\n }\r\n\r\n var fileFullName = (fileName || (Math.round(Math.random() * 9999999999) + 888888888)) + '.' + fileExtension;\r\n\r\n if (typeof navigator.msSaveOrOpenBlob !== 'undefined') {\r\n return navigator.msSaveOrOpenBlob(file, fileFullName);\r\n } else if (typeof navigator.msSaveBlob !== 'undefined') {\r\n return navigator.msSaveBlob(file, fileFullName);\r\n }\r\n\r\n var hyperlink = document.createElement('a');\r\n hyperlink.href = URL.createObjectURL(file);\r\n hyperlink.download = fileFullName;\r\n\r\n hyperlink.style = 'display:none;opacity:0;color:transparent;';\r\n (document.body || document.documentElement).appendChild(hyperlink);\r\n\r\n if (typeof hyperlink.click === 'function') {\r\n hyperlink.click();\r\n } else {\r\n hyperlink.target = '_blank';\r\n hyperlink.dispatchEvent(new MouseEvent('click', {\r\n view: window,\r\n bubbles: true,\r\n cancelable: true\r\n }));\r\n }\r\n\r\n URL.revokeObjectURL(hyperlink.href);\r\n}\r\n\r\n/**\r\n * from: https://github.com/cheton/is-electron/blob/master/index.js\r\n **/\r\nfunction isElectron() {\r\n // Renderer process\r\n if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {\r\n return true;\r\n }\r\n\r\n // Main process\r\n if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {\r\n return true;\r\n }\r\n\r\n // Detect the user agent when the `nodeIntegration` option is set to true\r\n if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\nfunction getTracks(stream, kind) {\r\n if (!stream || !stream.getTracks) {\r\n return [];\r\n }\r\n\r\n return stream.getTracks().filter(function(t) {\r\n return t.kind === (kind || 'audio');\r\n });\r\n}\r\n\r\nfunction setSrcObject(stream, element) {\r\n if ('srcObject' in element) {\r\n element.srcObject = stream;\r\n } else if ('mozSrcObject' in element) {\r\n element.mozSrcObject = stream;\r\n } else {\r\n element.srcObject = stream;\r\n }\r\n}\r\n\r\n/**\r\n * @param {Blob} file - File or Blob object.\r\n * @param {function} callback - Callback function.\r\n * @example\r\n * getSeekableBlob(blob or file, callback);\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n */\r\nfunction getSeekableBlob(inputBlob, callback) {\r\n // EBML.js copyrights goes to: https://github.com/legokichi/ts-ebml\r\n if (typeof EBML === 'undefined') {\r\n throw new Error('Please link: https://www.webrtc-experiment.com/EBML.js');\r\n }\r\n\r\n var reader = new EBML.Reader();\r\n var decoder = new EBML.Decoder();\r\n var tools = EBML.tools;\r\n\r\n var fileReader = new FileReader();\r\n fileReader.onload = function(e) {\r\n var ebmlElms = decoder.decode(this.result);\r\n ebmlElms.forEach(function(element) {\r\n reader.read(element);\r\n });\r\n reader.stop();\r\n var refinedMetadataBuf = tools.makeMetadataSeekable(reader.metadatas, reader.duration, reader.cues);\r\n var body = this.result.slice(reader.metadataSize);\r\n var newBlob = new Blob([refinedMetadataBuf, body], {\r\n type: 'video/webm'\r\n });\r\n\r\n callback(newBlob);\r\n };\r\n fileReader.readAsArrayBuffer(inputBlob);\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.invokeSaveAsDialog = invokeSaveAsDialog;\r\n RecordRTC.getTracks = getTracks;\r\n RecordRTC.getSeekableBlob = getSeekableBlob;\r\n RecordRTC.bytesToSize = bytesToSize;\r\n RecordRTC.isElectron = isElectron;\r\n}\n\r\n// __________ (used to handle stuff like http://goo.gl/xmE5eg) issue #129\r\n// Storage.js\r\n\r\n/**\r\n * Storage is a standalone object used by {@link RecordRTC} to store reusable objects e.g. \"new AudioContext\".\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @example\r\n * Storage.AudioContext === webkitAudioContext\r\n * @property {webkitAudioContext} AudioContext - Keeps a reference to AudioContext object.\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n */\r\n\r\nvar Storage = {};\r\n\r\nif (typeof AudioContext !== 'undefined') {\r\n Storage.AudioContext = AudioContext;\r\n} else if (typeof webkitAudioContext !== 'undefined') {\r\n Storage.AudioContext = webkitAudioContext;\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.Storage = Storage;\r\n}\n\r\nfunction isMediaRecorderCompatible() {\r\n if (isFirefox || isSafari || isEdge) {\r\n return true;\r\n }\r\n\r\n var nVer = navigator.appVersion;\r\n var nAgt = navigator.userAgent;\r\n var fullVersion = '' + parseFloat(navigator.appVersion);\r\n var majorVersion = parseInt(navigator.appVersion, 10);\r\n var nameOffset, verOffset, ix;\r\n\r\n if (isChrome || isOpera) {\r\n verOffset = nAgt.indexOf('Chrome');\r\n fullVersion = nAgt.substring(verOffset + 7);\r\n }\r\n\r\n // trim the fullVersion string at semicolon/space if present\r\n if ((ix = fullVersion.indexOf(';')) !== -1) {\r\n fullVersion = fullVersion.substring(0, ix);\r\n }\r\n\r\n if ((ix = fullVersion.indexOf(' ')) !== -1) {\r\n fullVersion = fullVersion.substring(0, ix);\r\n }\r\n\r\n majorVersion = parseInt('' + fullVersion, 10);\r\n\r\n if (isNaN(majorVersion)) {\r\n fullVersion = '' + parseFloat(navigator.appVersion);\r\n majorVersion = parseInt(navigator.appVersion, 10);\r\n }\r\n\r\n return majorVersion >= 49;\r\n}\n\r\n// ______________________\r\n// MediaStreamRecorder.js\r\n\r\n/**\r\n * MediaStreamRecorder is an abstraction layer for {@link https://w3c.github.io/mediacapture-record/MediaRecorder.html|MediaRecorder API}. It is used by {@link RecordRTC} to record MediaStream(s) in both Chrome and Firefox.\r\n * @summary Runs top over {@link https://w3c.github.io/mediacapture-record/MediaRecorder.html|MediaRecorder API}.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://github.com/muaz-khan|Muaz Khan}\r\n * @typedef MediaStreamRecorder\r\n * @class\r\n * @example\r\n * var config = {\r\n * mimeType: 'video/webm', // vp8, vp9, h264, mkv, opus/vorbis\r\n * audioBitsPerSecond : 256 * 8 * 1024,\r\n * videoBitsPerSecond : 256 * 8 * 1024,\r\n * bitsPerSecond: 256 * 8 * 1024, // if this is provided, skip above two\r\n * checkForInactiveTracks: true,\r\n * timeSlice: 1000, // concatenate intervals based blobs\r\n * ondataavailable: function() {} // get intervals based blobs\r\n * }\r\n * var recorder = new MediaStreamRecorder(mediaStream, config);\r\n * recorder.record();\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n *\r\n * // or\r\n * var blob = recorder.blob;\r\n * });\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.\r\n * @param {object} config - {disableLogs:true, initCallback: function, mimeType: \"video/webm\", timeSlice: 1000}\r\n * @throws Will throw an error if first argument \"MediaStream\" is missing. Also throws error if \"MediaRecorder API\" are not supported by the browser.\r\n */\r\n\r\nfunction MediaStreamRecorder(mediaStream, config) {\r\n var self = this;\r\n\r\n if (typeof mediaStream === 'undefined') {\r\n throw 'First argument \"MediaStream\" is required.';\r\n }\r\n\r\n if (typeof MediaRecorder === 'undefined') {\r\n throw 'Your browser does not support the Media Recorder API. Please try other modules e.g. WhammyRecorder or StereoAudioRecorder.';\r\n }\r\n\r\n config = config || {\r\n // bitsPerSecond: 256 * 8 * 1024,\r\n mimeType: 'video/webm'\r\n };\r\n\r\n if (config.type === 'audio') {\r\n if (getTracks(mediaStream, 'video').length && getTracks(mediaStream, 'audio').length) {\r\n var stream;\r\n if (!!navigator.mozGetUserMedia) {\r\n stream = new MediaStream();\r\n stream.addTrack(getTracks(mediaStream, 'audio')[0]);\r\n } else {\r\n // webkitMediaStream\r\n stream = new MediaStream(getTracks(mediaStream, 'audio'));\r\n }\r\n mediaStream = stream;\r\n }\r\n\r\n if (!config.mimeType || config.mimeType.toString().toLowerCase().indexOf('audio') === -1) {\r\n config.mimeType = isChrome ? 'audio/webm' : 'audio/ogg';\r\n }\r\n\r\n if (config.mimeType && config.mimeType.toString().toLowerCase() !== 'audio/ogg' && !!navigator.mozGetUserMedia) {\r\n // forcing better codecs on Firefox (via #166)\r\n config.mimeType = 'audio/ogg';\r\n }\r\n }\r\n\r\n var arrayOfBlobs = [];\r\n\r\n /**\r\n * This method returns array of blobs. Use only with \"timeSlice\". Its useful to preview recording anytime, without using the \"stop\" method.\r\n * @method\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * var arrayOfBlobs = recorder.getArrayOfBlobs();\r\n * @returns {Array} Returns array of recorded blobs.\r\n */\r\n this.getArrayOfBlobs = function() {\r\n return arrayOfBlobs;\r\n };\r\n\r\n /**\r\n * This method records MediaStream.\r\n * @method\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * recorder.record();\r\n */\r\n this.record = function() {\r\n // set defaults\r\n self.blob = null;\r\n self.clearRecordedData();\r\n self.timestamps = [];\r\n allStates = [];\r\n arrayOfBlobs = [];\r\n\r\n var recorderHints = config;\r\n\r\n if (!config.disableLogs) {\r\n console.log('Passing following config over MediaRecorder API.', recorderHints);\r\n }\r\n\r\n if (mediaRecorder) {\r\n // mandatory to make sure Firefox doesn't fails to record streams 3-4 times without reloading the page.\r\n mediaRecorder = null;\r\n }\r\n\r\n if (isChrome && !isMediaRecorderCompatible()) {\r\n // to support video-only recording on stable\r\n recorderHints = 'video/vp8';\r\n }\r\n\r\n if (typeof MediaRecorder.isTypeSupported === 'function' && recorderHints.mimeType) {\r\n if (!MediaRecorder.isTypeSupported(recorderHints.mimeType)) {\r\n if (!config.disableLogs) {\r\n console.warn('MediaRecorder API seems unable to record mimeType:', recorderHints.mimeType);\r\n }\r\n\r\n recorderHints.mimeType = config.type === 'audio' ? 'audio/webm' : 'video/webm';\r\n }\r\n }\r\n\r\n // using MediaRecorder API here\r\n try {\r\n mediaRecorder = new MediaRecorder(mediaStream, recorderHints);\r\n\r\n // reset\r\n config.mimeType = recorderHints.mimeType;\r\n } catch (e) {\r\n // chrome-based fallback\r\n mediaRecorder = new MediaRecorder(mediaStream);\r\n }\r\n\r\n // old hack?\r\n if (recorderHints.mimeType && !MediaRecorder.isTypeSupported && 'canRecordMimeType' in mediaRecorder && mediaRecorder.canRecordMimeType(recorderHints.mimeType) === false) {\r\n if (!config.disableLogs) {\r\n console.warn('MediaRecorder API seems unable to record mimeType:', recorderHints.mimeType);\r\n }\r\n }\r\n\r\n // Dispatching OnDataAvailable Handler\r\n mediaRecorder.ondataavailable = function(e) {\r\n if (e.data) {\r\n allStates.push('ondataavailable: ' + bytesToSize(e.data.size));\r\n }\r\n\r\n if (typeof config.timeSlice === 'number') {\r\n if (e.data && e.data.size && e.data.size > 100) {\r\n arrayOfBlobs.push(e.data);\r\n updateTimeStamp();\r\n\r\n if (typeof config.ondataavailable === 'function') {\r\n // intervals based blobs\r\n var blob = config.getNativeBlob ? e.data : new Blob([e.data], {\r\n type: getMimeType(recorderHints)\r\n });\r\n config.ondataavailable(blob);\r\n }\r\n }\r\n return;\r\n }\r\n\r\n if (!e.data || !e.data.size || e.data.size < 100 || self.blob) {\r\n // make sure that stopRecording always getting fired\r\n // even if there is invalid data\r\n if (self.recordingCallback) {\r\n self.recordingCallback(new Blob([], {\r\n type: getMimeType(recorderHints)\r\n }));\r\n self.recordingCallback = null;\r\n }\r\n return;\r\n }\r\n\r\n self.blob = config.getNativeBlob ? e.data : new Blob([e.data], {\r\n type: getMimeType(recorderHints)\r\n });\r\n\r\n if (self.recordingCallback) {\r\n self.recordingCallback(self.blob);\r\n self.recordingCallback = null;\r\n }\r\n };\r\n\r\n mediaRecorder.onstart = function() {\r\n allStates.push('started');\r\n };\r\n\r\n mediaRecorder.onpause = function() {\r\n allStates.push('paused');\r\n };\r\n\r\n mediaRecorder.onresume = function() {\r\n allStates.push('resumed');\r\n };\r\n\r\n mediaRecorder.onstop = function() {\r\n allStates.push('stopped');\r\n };\r\n\r\n mediaRecorder.onerror = function(error) {\r\n if (!error) {\r\n return;\r\n }\r\n\r\n if (!error.name) {\r\n error.name = 'UnknownError';\r\n }\r\n\r\n allStates.push('error: ' + error);\r\n\r\n if (!config.disableLogs) {\r\n // via: https://w3c.github.io/mediacapture-record/MediaRecorder.html#exception-summary\r\n if (error.name.toString().toLowerCase().indexOf('invalidstate') !== -1) {\r\n console.error('The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.', error);\r\n } else if (error.name.toString().toLowerCase().indexOf('notsupported') !== -1) {\r\n console.error('MIME type (', recorderHints.mimeType, ') is not supported.', error);\r\n } else if (error.name.toString().toLowerCase().indexOf('security') !== -1) {\r\n console.error('MediaRecorder security error', error);\r\n }\r\n\r\n // older code below\r\n else if (error.name === 'OutOfMemory') {\r\n console.error('The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.', error);\r\n } else if (error.name === 'IllegalStreamModification') {\r\n console.error('A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute.', error);\r\n } else if (error.name === 'OtherRecordingError') {\r\n console.error('Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute.', error);\r\n } else if (error.name === 'GenericError') {\r\n console.error('The UA cannot provide the codec or recording option that has been requested.', error);\r\n } else {\r\n console.error('MediaRecorder Error', error);\r\n }\r\n }\r\n\r\n (function(looper) {\r\n if (!self.manuallyStopped && mediaRecorder && mediaRecorder.state === 'inactive') {\r\n delete config.timeslice;\r\n\r\n // 10 minutes, enough?\r\n mediaRecorder.start(10 * 60 * 1000);\r\n return;\r\n }\r\n\r\n setTimeout(looper, 1000);\r\n })();\r\n\r\n if (mediaRecorder.state !== 'inactive' && mediaRecorder.state !== 'stopped') {\r\n mediaRecorder.stop();\r\n }\r\n };\r\n\r\n if (typeof config.timeSlice === 'number') {\r\n updateTimeStamp();\r\n mediaRecorder.start(config.timeSlice);\r\n } else {\r\n // default is 60 minutes; enough?\r\n // use config => {timeSlice: 1000} otherwise\r\n\r\n mediaRecorder.start(3.6e+6);\r\n }\r\n\r\n if (config.initCallback) {\r\n config.initCallback(); // old code\r\n }\r\n };\r\n\r\n /**\r\n * @property {Array} timestamps - Array of time stamps\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * console.log(recorder.timestamps);\r\n */\r\n this.timestamps = [];\r\n\r\n function updateTimeStamp() {\r\n self.timestamps.push(new Date().getTime());\r\n\r\n if (typeof config.onTimeStamp === 'function') {\r\n config.onTimeStamp(self.timestamps[self.timestamps.length - 1], self.timestamps);\r\n }\r\n }\r\n\r\n function getMimeType(secondObject) {\r\n if (mediaRecorder && mediaRecorder.mimeType) {\r\n return mediaRecorder.mimeType;\r\n }\r\n\r\n return secondObject.mimeType || 'video/webm';\r\n }\r\n\r\n /**\r\n * This method stops recording MediaStream.\r\n * @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.\r\n * @method\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n */\r\n this.stop = function(callback) {\r\n callback = callback || function() {};\r\n\r\n self.manuallyStopped = true; // used inside the mediaRecorder.onerror\r\n\r\n if (!mediaRecorder) {\r\n return;\r\n }\r\n\r\n this.recordingCallback = callback;\r\n\r\n if (mediaRecorder.state === 'recording') {\r\n mediaRecorder.stop();\r\n }\r\n\r\n if (typeof config.timeSlice === 'number') {\r\n setTimeout(function() {\r\n self.blob = new Blob(arrayOfBlobs, {\r\n type: getMimeType(config)\r\n });\r\n\r\n self.recordingCallback(self.blob);\r\n }, 100);\r\n }\r\n };\r\n\r\n /**\r\n * This method pauses the recording process.\r\n * @method\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * recorder.pause();\r\n */\r\n this.pause = function() {\r\n if (!mediaRecorder) {\r\n return;\r\n }\r\n\r\n if (mediaRecorder.state === 'recording') {\r\n mediaRecorder.pause();\r\n }\r\n };\r\n\r\n /**\r\n * This method resumes the recording process.\r\n * @method\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * recorder.resume();\r\n */\r\n this.resume = function() {\r\n if (!mediaRecorder) {\r\n return;\r\n }\r\n\r\n if (mediaRecorder.state === 'paused') {\r\n mediaRecorder.resume();\r\n }\r\n };\r\n\r\n /**\r\n * This method resets currently recorded data.\r\n * @method\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * recorder.clearRecordedData();\r\n */\r\n this.clearRecordedData = function() {\r\n if (mediaRecorder && mediaRecorder.state === 'recording') {\r\n self.stop(clearRecordedDataCB);\r\n }\r\n\r\n clearRecordedDataCB();\r\n };\r\n\r\n function clearRecordedDataCB() {\r\n arrayOfBlobs = [];\r\n mediaRecorder = null;\r\n self.timestamps = [];\r\n }\r\n\r\n // Reference to \"MediaRecorder\" object\r\n var mediaRecorder;\r\n\r\n /**\r\n * Access to native MediaRecorder API\r\n * @method\r\n * @memberof MediaStreamRecorder\r\n * @instance\r\n * @example\r\n * var internal = recorder.getInternalRecorder();\r\n * internal.ondataavailable = function() {}; // override\r\n * internal.stream, internal.onpause, internal.onstop, etc.\r\n * @returns {Object} Returns internal recording object.\r\n */\r\n this.getInternalRecorder = function() {\r\n return mediaRecorder;\r\n };\r\n\r\n function isMediaStreamActive() {\r\n if ('active' in mediaStream) {\r\n if (!mediaStream.active) {\r\n return false;\r\n }\r\n } else if ('ended' in mediaStream) { // old hack\r\n if (mediaStream.ended) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * @property {Blob} blob - Recorded data as \"Blob\" object.\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * recorder.stop(function() {\r\n * var blob = recorder.blob;\r\n * });\r\n */\r\n this.blob = null;\r\n\r\n\r\n /**\r\n * Get MediaRecorder readonly state.\r\n * @method\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * var state = recorder.getState();\r\n * @returns {String} Returns recording state.\r\n */\r\n this.getState = function() {\r\n if (!mediaRecorder) {\r\n return 'inactive';\r\n }\r\n\r\n return mediaRecorder.state || 'inactive';\r\n };\r\n\r\n // list of all recording states\r\n var allStates = [];\r\n\r\n /**\r\n * Get MediaRecorder all recording states.\r\n * @method\r\n * @memberof MediaStreamRecorder\r\n * @example\r\n * var state = recorder.getAllStates();\r\n * @returns {Array} Returns all recording states\r\n */\r\n this.getAllStates = function() {\r\n return allStates;\r\n };\r\n\r\n // if any Track within the MediaStream is muted or not enabled at any time, \r\n // the browser will only record black frames \r\n // or silence since that is the content produced by the Track\r\n // so we need to stopRecording as soon as any single track ends.\r\n if (typeof config.checkForInactiveTracks === 'undefined') {\r\n config.checkForInactiveTracks = false; // disable to minimize CPU usage\r\n }\r\n\r\n var self = this;\r\n\r\n // this method checks if media stream is stopped\r\n // or if any track is ended.\r\n (function looper() {\r\n if (!mediaRecorder || config.checkForInactiveTracks === false) {\r\n return;\r\n }\r\n\r\n if (isMediaStreamActive() === false) {\r\n if (!config.disableLogs) {\r\n console.log('MediaStream seems stopped.');\r\n }\r\n self.stop();\r\n return;\r\n }\r\n\r\n setTimeout(looper, 1000); // check every second\r\n })();\r\n\r\n // for debugging\r\n this.name = 'MediaStreamRecorder';\r\n this.toString = function() {\r\n return this.name;\r\n };\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.MediaStreamRecorder = MediaStreamRecorder;\r\n}\n\r\n// source code from: http://typedarray.org/wp-content/projects/WebAudioRecorder/script.js\r\n// https://github.com/mattdiamond/Recorderjs#license-mit\r\n// ______________________\r\n// StereoAudioRecorder.js\r\n\r\n/**\r\n * StereoAudioRecorder is a standalone class used by {@link RecordRTC} to bring \"stereo\" audio-recording in chrome.\r\n * @summary JavaScript standalone object for stereo audio recording.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef StereoAudioRecorder\r\n * @class\r\n * @example\r\n * var recorder = new StereoAudioRecorder(MediaStream, {\r\n * sampleRate: 44100,\r\n * bufferSize: 4096\r\n * });\r\n * recorder.record();\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.\r\n * @param {object} config - {sampleRate: 44100, bufferSize: 4096, numberOfAudioChannels: 1, etc.}\r\n */\r\n\r\nfunction StereoAudioRecorder(mediaStream, config) {\r\n if (!getTracks(mediaStream, 'audio').length) {\r\n throw 'Your stream has no audio tracks.';\r\n }\r\n\r\n config = config || {};\r\n\r\n var self = this;\r\n\r\n // variables\r\n var leftchannel = [];\r\n var rightchannel = [];\r\n var recording = false;\r\n var recordingLength = 0;\r\n var jsAudioNode;\r\n\r\n var numberOfAudioChannels = 2;\r\n\r\n /**\r\n * Set sample rates such as 8K or 16K. Reference: http://stackoverflow.com/a/28977136/552182\r\n * @property {number} desiredSampRate - Desired Bits per sample * 1000\r\n * @memberof StereoAudioRecorder\r\n * @instance\r\n * @example\r\n * var recorder = StereoAudioRecorder(mediaStream, {\r\n * desiredSampRate: 16 * 1000 // bits-per-sample * 1000\r\n * });\r\n */\r\n var desiredSampRate = config.desiredSampRate;\r\n\r\n // backward compatibility\r\n if (config.leftChannel === true) {\r\n numberOfAudioChannels = 1;\r\n }\r\n\r\n if (config.numberOfAudioChannels === 1) {\r\n numberOfAudioChannels = 1;\r\n }\r\n\r\n if (!numberOfAudioChannels || numberOfAudioChannels < 1) {\r\n numberOfAudioChannels = 2;\r\n }\r\n\r\n if (!config.disableLogs) {\r\n console.log('StereoAudioRecorder is set to record number of channels: ' + numberOfAudioChannels);\r\n }\r\n\r\n // if any Track within the MediaStream is muted or not enabled at any time, \r\n // the browser will only record black frames \r\n // or silence since that is the content produced by the Track\r\n // so we need to stopRecording as soon as any single track ends.\r\n if (typeof config.checkForInactiveTracks === 'undefined') {\r\n config.checkForInactiveTracks = true;\r\n }\r\n\r\n function isMediaStreamActive() {\r\n if (config.checkForInactiveTracks === false) {\r\n // always return \"true\"\r\n return true;\r\n }\r\n\r\n if ('active' in mediaStream) {\r\n if (!mediaStream.active) {\r\n return false;\r\n }\r\n } else if ('ended' in mediaStream) { // old hack\r\n if (mediaStream.ended) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * This method records MediaStream.\r\n * @method\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder.record();\r\n */\r\n this.record = function() {\r\n if (isMediaStreamActive() === false) {\r\n throw 'Please make sure MediaStream is active.';\r\n }\r\n\r\n resetVariables();\r\n\r\n isAudioProcessStarted = isPaused = false;\r\n recording = true;\r\n\r\n if (typeof config.timeSlice !== 'undefined') {\r\n looper();\r\n }\r\n };\r\n\r\n function mergeLeftRightBuffers(config, callback) {\r\n function mergeAudioBuffers(config, cb) {\r\n var numberOfAudioChannels = config.numberOfAudioChannels;\r\n\r\n // todo: \"slice(0)\" --- is it causes loop? Should be removed?\r\n var leftBuffers = config.leftBuffers.slice(0);\r\n var rightBuffers = config.rightBuffers.slice(0);\r\n var sampleRate = config.sampleRate;\r\n var internalInterleavedLength = config.internalInterleavedLength;\r\n var desiredSampRate = config.desiredSampRate;\r\n\r\n if (numberOfAudioChannels === 2) {\r\n leftBuffers = mergeBuffers(leftBuffers, internalInterleavedLength);\r\n rightBuffers = mergeBuffers(rightBuffers, internalInterleavedLength);\r\n\r\n if (desiredSampRate) {\r\n leftBuffers = interpolateArray(leftBuffers, desiredSampRate, sampleRate);\r\n rightBuffers = interpolateArray(rightBuffers, desiredSampRate, sampleRate);\r\n }\r\n }\r\n\r\n if (numberOfAudioChannels === 1) {\r\n leftBuffers = mergeBuffers(leftBuffers, internalInterleavedLength);\r\n\r\n if (desiredSampRate) {\r\n leftBuffers = interpolateArray(leftBuffers, desiredSampRate, sampleRate);\r\n }\r\n }\r\n\r\n // set sample rate as desired sample rate\r\n if (desiredSampRate) {\r\n sampleRate = desiredSampRate;\r\n }\r\n\r\n // for changing the sampling rate, reference:\r\n // http://stackoverflow.com/a/28977136/552182\r\n function interpolateArray(data, newSampleRate, oldSampleRate) {\r\n var fitCount = Math.round(data.length * (newSampleRate / oldSampleRate));\r\n var newData = [];\r\n var springFactor = Number((data.length - 1) / (fitCount - 1));\r\n newData[0] = data[0];\r\n for (var i = 1; i < fitCount - 1; i++) {\r\n var tmp = i * springFactor;\r\n var before = Number(Math.floor(tmp)).toFixed();\r\n var after = Number(Math.ceil(tmp)).toFixed();\r\n var atPoint = tmp - before;\r\n newData[i] = linearInterpolate(data[before], data[after], atPoint);\r\n }\r\n newData[fitCount - 1] = data[data.length - 1];\r\n return newData;\r\n }\r\n\r\n function linearInterpolate(before, after, atPoint) {\r\n return before + (after - before) * atPoint;\r\n }\r\n\r\n function mergeBuffers(channelBuffer, rLength) {\r\n var result = new Float64Array(rLength);\r\n var offset = 0;\r\n var lng = channelBuffer.length;\r\n\r\n for (var i = 0; i < lng; i++) {\r\n var buffer = channelBuffer[i];\r\n result.set(buffer, offset);\r\n offset += buffer.length;\r\n }\r\n\r\n return result;\r\n }\r\n\r\n function interleave(leftChannel, rightChannel) {\r\n var length = leftChannel.length + rightChannel.length;\r\n\r\n var result = new Float64Array(length);\r\n\r\n var inputIndex = 0;\r\n\r\n for (var index = 0; index < length;) {\r\n result[index++] = leftChannel[inputIndex];\r\n result[index++] = rightChannel[inputIndex];\r\n inputIndex++;\r\n }\r\n return result;\r\n }\r\n\r\n function writeUTFBytes(view, offset, string) {\r\n var lng = string.length;\r\n for (var i = 0; i < lng; i++) {\r\n view.setUint8(offset + i, string.charCodeAt(i));\r\n }\r\n }\r\n\r\n // interleave both channels together\r\n var interleaved;\r\n\r\n if (numberOfAudioChannels === 2) {\r\n interleaved = interleave(leftBuffers, rightBuffers);\r\n }\r\n\r\n if (numberOfAudioChannels === 1) {\r\n interleaved = leftBuffers;\r\n }\r\n\r\n var interleavedLength = interleaved.length;\r\n\r\n // create wav file\r\n var resultingBufferLength = 44 + interleavedLength * 2;\r\n\r\n var buffer = new ArrayBuffer(resultingBufferLength);\r\n\r\n var view = new DataView(buffer);\r\n\r\n // RIFF chunk descriptor/identifier \r\n writeUTFBytes(view, 0, 'RIFF');\r\n\r\n // RIFF chunk length\r\n // changed \"44\" to \"36\" via #401\r\n view.setUint32(4, 36 + interleavedLength * 2, true);\r\n\r\n // RIFF type \r\n writeUTFBytes(view, 8, 'WAVE');\r\n\r\n // format chunk identifier \r\n // FMT sub-chunk\r\n writeUTFBytes(view, 12, 'fmt ');\r\n\r\n // format chunk length \r\n view.setUint32(16, 16, true);\r\n\r\n // sample format (raw)\r\n view.setUint16(20, 1, true);\r\n\r\n // stereo (2 channels)\r\n view.setUint16(22, numberOfAudioChannels, true);\r\n\r\n // sample rate \r\n view.setUint32(24, sampleRate, true);\r\n\r\n // byte rate (sample rate * block align)\r\n view.setUint32(28, sampleRate * 2, true);\r\n\r\n // block align (channel count * bytes per sample) \r\n view.setUint16(32, numberOfAudioChannels * 2, true);\r\n\r\n // bits per sample \r\n view.setUint16(34, 16, true);\r\n\r\n // data sub-chunk\r\n // data chunk identifier \r\n writeUTFBytes(view, 36, 'data');\r\n\r\n // data chunk length \r\n view.setUint32(40, interleavedLength * 2, true);\r\n\r\n // write the PCM samples\r\n var lng = interleavedLength;\r\n var index = 44;\r\n var volume = 1;\r\n for (var i = 0; i < lng; i++) {\r\n view.setInt16(index, interleaved[i] * (0x7FFF * volume), true);\r\n index += 2;\r\n }\r\n\r\n if (cb) {\r\n return cb({\r\n buffer: buffer,\r\n view: view\r\n });\r\n }\r\n\r\n postMessage({\r\n buffer: buffer,\r\n view: view\r\n });\r\n }\r\n\r\n if (config.noWorker) {\r\n mergeAudioBuffers(config, function(data) {\r\n callback(data.buffer, data.view);\r\n });\r\n return;\r\n }\r\n\r\n\r\n var webWorker = processInWebWorker(mergeAudioBuffers);\r\n\r\n webWorker.onmessage = function(event) {\r\n callback(event.data.buffer, event.data.view);\r\n\r\n // release memory\r\n URL.revokeObjectURL(webWorker.workerURL);\r\n\r\n // kill webworker (or Chrome will kill your page after ~25 calls)\r\n webWorker.terminate();\r\n };\r\n\r\n webWorker.postMessage(config);\r\n }\r\n\r\n function processInWebWorker(_function) {\r\n var workerURL = URL.createObjectURL(new Blob([_function.toString(),\r\n ';this.onmessage = function (eee) {' + _function.name + '(eee.data);}'\r\n ], {\r\n type: 'application/javascript'\r\n }));\r\n\r\n var worker = new Worker(workerURL);\r\n worker.workerURL = workerURL;\r\n return worker;\r\n }\r\n\r\n /**\r\n * This method stops recording MediaStream.\r\n * @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.\r\n * @method\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n */\r\n this.stop = function(callback) {\r\n callback = callback || function() {};\r\n\r\n // stop recording\r\n recording = false;\r\n\r\n mergeLeftRightBuffers({\r\n desiredSampRate: desiredSampRate,\r\n sampleRate: sampleRate,\r\n numberOfAudioChannels: numberOfAudioChannels,\r\n internalInterleavedLength: recordingLength,\r\n leftBuffers: leftchannel,\r\n rightBuffers: numberOfAudioChannels === 1 ? [] : rightchannel,\r\n noWorker: config.noWorker\r\n }, function(buffer, view) {\r\n /**\r\n * @property {Blob} blob - The recorded blob object.\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder.stop(function(){\r\n * var blob = recorder.blob;\r\n * });\r\n */\r\n self.blob = new Blob([view], {\r\n type: 'audio/wav'\r\n });\r\n\r\n /**\r\n * @property {ArrayBuffer} buffer - The recorded buffer object.\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder.stop(function(){\r\n * var buffer = recorder.buffer;\r\n * });\r\n */\r\n self.buffer = new ArrayBuffer(view.buffer.byteLength);\r\n\r\n /**\r\n * @property {DataView} view - The recorded data-view object.\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder.stop(function(){\r\n * var view = recorder.view;\r\n * });\r\n */\r\n self.view = view;\r\n\r\n self.sampleRate = desiredSampRate || sampleRate;\r\n self.bufferSize = bufferSize;\r\n\r\n // recorded audio length\r\n self.length = recordingLength;\r\n\r\n isAudioProcessStarted = false;\r\n\r\n if (callback) {\r\n callback(self.blob);\r\n }\r\n });\r\n };\r\n\r\n if (typeof RecordRTC.Storage === 'undefined') {\r\n RecordRTC.Storage = {\r\n AudioContextConstructor: null,\r\n AudioContext: window.AudioContext || window.webkitAudioContext\r\n };\r\n }\r\n\r\n if (!RecordRTC.Storage.AudioContextConstructor || RecordRTC.Storage.AudioContextConstructor.state === 'closed') {\r\n RecordRTC.Storage.AudioContextConstructor = new RecordRTC.Storage.AudioContext();\r\n }\r\n\r\n var context = RecordRTC.Storage.AudioContextConstructor;\r\n\r\n // creates an audio node from the microphone incoming stream\r\n var audioInput = context.createMediaStreamSource(mediaStream);\r\n\r\n var legalBufferValues = [0, 256, 512, 1024, 2048, 4096, 8192, 16384];\r\n\r\n /**\r\n * From the spec: This value controls how frequently the audioprocess event is\r\n * dispatched and how many sample-frames need to be processed each call.\r\n * Lower values for buffer size will result in a lower (better) latency.\r\n * Higher values will be necessary to avoid audio breakup and glitches\r\n * The size of the buffer (in sample-frames) which needs to\r\n * be processed each time onprocessaudio is called.\r\n * Legal values are (256, 512, 1024, 2048, 4096, 8192, 16384).\r\n * @property {number} bufferSize - Buffer-size for how frequently the audioprocess event is dispatched.\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder = new StereoAudioRecorder(mediaStream, {\r\n * bufferSize: 4096\r\n * });\r\n */\r\n\r\n // \"0\" means, let chrome decide the most accurate buffer-size for current platform.\r\n var bufferSize = typeof config.bufferSize === 'undefined' ? 4096 : config.bufferSize;\r\n\r\n if (legalBufferValues.indexOf(bufferSize) === -1) {\r\n if (!config.disableLogs) {\r\n console.log('Legal values for buffer-size are ' + JSON.stringify(legalBufferValues, null, '\\t'));\r\n }\r\n }\r\n\r\n if (context.createJavaScriptNode) {\r\n jsAudioNode = context.createJavaScriptNode(bufferSize, numberOfAudioChannels, numberOfAudioChannels);\r\n } else if (context.createScriptProcessor) {\r\n jsAudioNode = context.createScriptProcessor(bufferSize, numberOfAudioChannels, numberOfAudioChannels);\r\n } else {\r\n throw 'WebAudio API has no support on this browser.';\r\n }\r\n\r\n // connect the stream to the script processor\r\n audioInput.connect(jsAudioNode);\r\n\r\n if (!config.bufferSize) {\r\n bufferSize = jsAudioNode.bufferSize; // device buffer-size\r\n }\r\n\r\n /**\r\n * The sample rate (in sample-frames per second) at which the\r\n * AudioContext handles audio. It is assumed that all AudioNodes\r\n * in the context run at this rate. In making this assumption,\r\n * sample-rate converters or \"varispeed\" processors are not supported\r\n * in real-time processing.\r\n * The sampleRate parameter describes the sample-rate of the\r\n * linear PCM audio data in the buffer in sample-frames per second.\r\n * An implementation must support sample-rates in at least\r\n * the range 22050 to 96000.\r\n * @property {number} sampleRate - Buffer-size for how frequently the audioprocess event is dispatched.\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder = new StereoAudioRecorder(mediaStream, {\r\n * sampleRate: 44100\r\n * });\r\n */\r\n var sampleRate = typeof config.sampleRate !== 'undefined' ? config.sampleRate : context.sampleRate || 44100;\r\n\r\n if (sampleRate < 22050 || sampleRate > 96000) {\r\n // Ref: http://stackoverflow.com/a/26303918/552182\r\n if (!config.disableLogs) {\r\n console.log('sample-rate must be under range 22050 and 96000.');\r\n }\r\n }\r\n\r\n if (!config.disableLogs) {\r\n if (config.desiredSampRate) {\r\n console.log('Desired sample-rate: ' + config.desiredSampRate);\r\n }\r\n }\r\n\r\n var isPaused = false;\r\n /**\r\n * This method pauses the recording process.\r\n * @method\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder.pause();\r\n */\r\n this.pause = function() {\r\n isPaused = true;\r\n };\r\n\r\n /**\r\n * This method resumes the recording process.\r\n * @method\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder.resume();\r\n */\r\n this.resume = function() {\r\n if (isMediaStreamActive() === false) {\r\n throw 'Please make sure MediaStream is active.';\r\n }\r\n\r\n if (!recording) {\r\n if (!config.disableLogs) {\r\n console.log('Seems recording has been restarted.');\r\n }\r\n this.record();\r\n return;\r\n }\r\n\r\n isPaused = false;\r\n };\r\n\r\n /**\r\n * This method resets currently recorded data.\r\n * @method\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder.clearRecordedData();\r\n */\r\n this.clearRecordedData = function() {\r\n config.checkForInactiveTracks = false;\r\n\r\n if (recording) {\r\n this.stop(clearRecordedDataCB);\r\n }\r\n\r\n clearRecordedDataCB();\r\n };\r\n\r\n function resetVariables() {\r\n leftchannel = [];\r\n rightchannel = [];\r\n recordingLength = 0;\r\n isAudioProcessStarted = false;\r\n recording = false;\r\n isPaused = false;\r\n context = null;\r\n\r\n self.leftchannel = leftchannel;\r\n self.rightchannel = rightchannel;\r\n self.numberOfAudioChannels = numberOfAudioChannels;\r\n self.desiredSampRate = desiredSampRate;\r\n self.sampleRate = sampleRate;\r\n self.recordingLength = recordingLength;\r\n\r\n intervalsBasedBuffers = {\r\n left: [],\r\n right: [],\r\n recordingLength: 0\r\n };\r\n }\r\n\r\n function clearRecordedDataCB() {\r\n if (jsAudioNode) {\r\n jsAudioNode.onaudioprocess = null;\r\n jsAudioNode.disconnect();\r\n jsAudioNode = null;\r\n }\r\n\r\n if (audioInput) {\r\n audioInput.disconnect();\r\n audioInput = null;\r\n }\r\n\r\n resetVariables();\r\n }\r\n\r\n // for debugging\r\n this.name = 'StereoAudioRecorder';\r\n this.toString = function() {\r\n return this.name;\r\n };\r\n\r\n var isAudioProcessStarted = false;\r\n\r\n function onAudioProcessDataAvailable(e) {\r\n if (isPaused) {\r\n return;\r\n }\r\n\r\n if (isMediaStreamActive() === false) {\r\n if (!config.disableLogs) {\r\n console.log('MediaStream seems stopped.');\r\n }\r\n jsAudioNode.disconnect();\r\n recording = false;\r\n }\r\n\r\n if (!recording) {\r\n if (audioInput) {\r\n audioInput.disconnect();\r\n audioInput = null;\r\n }\r\n return;\r\n }\r\n\r\n /**\r\n * This method is called on \"onaudioprocess\" event's first invocation.\r\n * @method {function} onAudioProcessStarted\r\n * @memberof StereoAudioRecorder\r\n * @example\r\n * recorder.onAudioProcessStarted: function() { };\r\n */\r\n if (!isAudioProcessStarted) {\r\n isAudioProcessStarted = true;\r\n if (config.onAudioProcessStarted) {\r\n config.onAudioProcessStarted();\r\n }\r\n\r\n if (config.initCallback) {\r\n config.initCallback();\r\n }\r\n }\r\n\r\n var left = e.inputBuffer.getChannelData(0);\r\n\r\n // we clone the samples\r\n var chLeft = new Float32Array(left);\r\n leftchannel.push(chLeft);\r\n\r\n if (numberOfAudioChannels === 2) {\r\n var right = e.inputBuffer.getChannelData(1);\r\n var chRight = new Float32Array(right);\r\n rightchannel.push(chRight);\r\n }\r\n\r\n recordingLength += bufferSize;\r\n\r\n // export raw PCM\r\n self.recordingLength = recordingLength;\r\n\r\n if (typeof config.timeSlice !== 'undefined') {\r\n intervalsBasedBuffers.recordingLength += bufferSize;\r\n intervalsBasedBuffers.left.push(chLeft);\r\n\r\n if (numberOfAudioChannels === 2) {\r\n intervalsBasedBuffers.right.push(chRight);\r\n }\r\n }\r\n }\r\n\r\n jsAudioNode.onaudioprocess = onAudioProcessDataAvailable;\r\n\r\n // to prevent self audio to be connected with speakers\r\n if (context.createMediaStreamDestination) {\r\n jsAudioNode.connect(context.createMediaStreamDestination());\r\n } else {\r\n jsAudioNode.connect(context.destination);\r\n }\r\n\r\n // export raw PCM\r\n this.leftchannel = leftchannel;\r\n this.rightchannel = rightchannel;\r\n this.numberOfAudioChannels = numberOfAudioChannels;\r\n this.desiredSampRate = desiredSampRate;\r\n this.sampleRate = sampleRate;\r\n self.recordingLength = recordingLength;\r\n\r\n // helper for intervals based blobs\r\n var intervalsBasedBuffers = {\r\n left: [],\r\n right: [],\r\n recordingLength: 0\r\n };\r\n\r\n // this looper is used to support intervals based blobs (via timeSlice+ondataavailable)\r\n function looper() {\r\n if (!recording || typeof config.ondataavailable !== 'function' || typeof config.timeSlice === 'undefined') {\r\n return;\r\n }\r\n\r\n if (intervalsBasedBuffers.left.length) {\r\n mergeLeftRightBuffers({\r\n desiredSampRate: desiredSampRate,\r\n sampleRate: sampleRate,\r\n numberOfAudioChannels: numberOfAudioChannels,\r\n internalInterleavedLength: intervalsBasedBuffers.recordingLength,\r\n leftBuffers: intervalsBasedBuffers.left,\r\n rightBuffers: numberOfAudioChannels === 1 ? [] : intervalsBasedBuffers.right\r\n }, function(buffer, view) {\r\n var blob = new Blob([view], {\r\n type: 'audio/wav'\r\n });\r\n config.ondataavailable(blob);\r\n\r\n setTimeout(looper, config.timeSlice);\r\n });\r\n\r\n intervalsBasedBuffers = {\r\n left: [],\r\n right: [],\r\n recordingLength: 0\r\n };\r\n } else {\r\n setTimeout(looper, config.timeSlice);\r\n }\r\n }\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.StereoAudioRecorder = StereoAudioRecorder;\r\n}\r\n\r\n// _________________\r\n// CanvasRecorder.js\r\n\r\n/**\r\n * CanvasRecorder is a standalone class used by {@link RecordRTC} to bring HTML5-Canvas recording into video WebM. It uses HTML2Canvas library and runs top over {@link Whammy}.\r\n * @summary HTML2Canvas recording into video WebM.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef CanvasRecorder\r\n * @class\r\n * @example\r\n * var recorder = new CanvasRecorder(htmlElement, { disableLogs: true, useWhammyRecorder: true });\r\n * recorder.record();\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {HTMLElement} htmlElement - querySelector/getElementById/getElementsByTagName[0]/etc.\r\n * @param {object} config - {disableLogs:true, initCallback: function}\r\n */\r\n\r\nfunction CanvasRecorder(htmlElement, config) {\r\n if (typeof html2canvas === 'undefined') {\r\n throw 'Please link: https://www.webrtc-experiment.com/screenshot.js';\r\n }\r\n\r\n config = config || {};\r\n if (!config.frameInterval) {\r\n config.frameInterval = 10;\r\n }\r\n\r\n // via DetectRTC.js\r\n var isCanvasSupportsStreamCapturing = false;\r\n ['captureStream', 'mozCaptureStream', 'webkitCaptureStream'].forEach(function(item) {\r\n if (item in document.createElement('canvas')) {\r\n isCanvasSupportsStreamCapturing = true;\r\n }\r\n });\r\n\r\n var _isChrome = (!!window.webkitRTCPeerConnection || !!window.webkitGetUserMedia) && !!window.chrome;\r\n\r\n var chromeVersion = 50;\r\n var matchArray = navigator.userAgent.match(/Chrom(e|ium)\\/([0-9]+)\\./);\r\n if (_isChrome && matchArray && matchArray[2]) {\r\n chromeVersion = parseInt(matchArray[2], 10);\r\n }\r\n\r\n if (_isChrome && chromeVersion < 52) {\r\n isCanvasSupportsStreamCapturing = false;\r\n }\r\n\r\n if (config.useWhammyRecorder) {\r\n isCanvasSupportsStreamCapturing = false;\r\n }\r\n\r\n var globalCanvas, mediaStreamRecorder;\r\n\r\n if (isCanvasSupportsStreamCapturing) {\r\n if (!config.disableLogs) {\r\n console.log('Your browser supports both MediRecorder API and canvas.captureStream!');\r\n }\r\n\r\n if (htmlElement instanceof HTMLCanvasElement) {\r\n globalCanvas = htmlElement;\r\n } else if (htmlElement instanceof CanvasRenderingContext2D) {\r\n globalCanvas = htmlElement.canvas;\r\n } else {\r\n throw 'Please pass either HTMLCanvasElement or CanvasRenderingContext2D.';\r\n }\r\n } else if (!!navigator.mozGetUserMedia) {\r\n if (!config.disableLogs) {\r\n console.error('Canvas recording is NOT supported in Firefox.');\r\n }\r\n }\r\n\r\n var isRecording;\r\n\r\n /**\r\n * This method records Canvas.\r\n * @method\r\n * @memberof CanvasRecorder\r\n * @example\r\n * recorder.record();\r\n */\r\n this.record = function() {\r\n isRecording = true;\r\n\r\n if (isCanvasSupportsStreamCapturing && !config.useWhammyRecorder) {\r\n // CanvasCaptureMediaStream\r\n var canvasMediaStream;\r\n if ('captureStream' in globalCanvas) {\r\n canvasMediaStream = globalCanvas.captureStream(25); // 25 FPS\r\n } else if ('mozCaptureStream' in globalCanvas) {\r\n canvasMediaStream = globalCanvas.mozCaptureStream(25);\r\n } else if ('webkitCaptureStream' in globalCanvas) {\r\n canvasMediaStream = globalCanvas.webkitCaptureStream(25);\r\n }\r\n\r\n try {\r\n var mdStream = new MediaStream();\r\n mdStream.addTrack(getTracks(canvasMediaStream, 'video')[0]);\r\n canvasMediaStream = mdStream;\r\n } catch (e) {}\r\n\r\n if (!canvasMediaStream) {\r\n throw 'captureStream API are NOT available.';\r\n }\r\n\r\n // Note: Jan 18, 2016 status is that, \r\n // Firefox MediaRecorder API can't record CanvasCaptureMediaStream object.\r\n mediaStreamRecorder = new MediaStreamRecorder(canvasMediaStream, {\r\n mimeType: config.mimeType || 'video/webm'\r\n });\r\n mediaStreamRecorder.record();\r\n } else {\r\n whammy.frames = [];\r\n lastTime = new Date().getTime();\r\n drawCanvasFrame();\r\n }\r\n\r\n if (config.initCallback) {\r\n config.initCallback();\r\n }\r\n };\r\n\r\n this.getWebPImages = function(callback) {\r\n if (htmlElement.nodeName.toLowerCase() !== 'canvas') {\r\n callback();\r\n return;\r\n }\r\n\r\n var framesLength = whammy.frames.length;\r\n whammy.frames.forEach(function(frame, idx) {\r\n var framesRemaining = framesLength - idx;\r\n if (!config.disableLogs) {\r\n console.log(framesRemaining + '/' + framesLength + ' frames remaining');\r\n }\r\n\r\n if (config.onEncodingCallback) {\r\n config.onEncodingCallback(framesRemaining, framesLength);\r\n }\r\n\r\n var webp = frame.image.toDataURL('image/webp', 1);\r\n whammy.frames[idx].image = webp;\r\n });\r\n\r\n if (!config.disableLogs) {\r\n console.log('Generating WebM');\r\n }\r\n\r\n callback();\r\n };\r\n\r\n /**\r\n * This method stops recording Canvas.\r\n * @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.\r\n * @method\r\n * @memberof CanvasRecorder\r\n * @example\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n */\r\n this.stop = function(callback) {\r\n isRecording = false;\r\n\r\n var that = this;\r\n\r\n if (isCanvasSupportsStreamCapturing && mediaStreamRecorder) {\r\n mediaStreamRecorder.stop(callback);\r\n return;\r\n }\r\n\r\n this.getWebPImages(function() {\r\n /**\r\n * @property {Blob} blob - Recorded frames in video/webm blob.\r\n * @memberof CanvasRecorder\r\n * @example\r\n * recorder.stop(function() {\r\n * var blob = recorder.blob;\r\n * });\r\n */\r\n whammy.compile(function(blob) {\r\n if (!config.disableLogs) {\r\n console.log('Recording finished!');\r\n }\r\n\r\n that.blob = blob;\r\n\r\n if (that.blob.forEach) {\r\n that.blob = new Blob([], {\r\n type: 'video/webm'\r\n });\r\n }\r\n\r\n if (callback) {\r\n callback(that.blob);\r\n }\r\n\r\n whammy.frames = [];\r\n });\r\n });\r\n };\r\n\r\n var isPausedRecording = false;\r\n\r\n /**\r\n * This method pauses the recording process.\r\n * @method\r\n * @memberof CanvasRecorder\r\n * @example\r\n * recorder.pause();\r\n */\r\n this.pause = function() {\r\n isPausedRecording = true;\r\n\r\n if (mediaStreamRecorder instanceof MediaStreamRecorder) {\r\n mediaStreamRecorder.pause();\r\n return;\r\n }\r\n };\r\n\r\n /**\r\n * This method resumes the recording process.\r\n * @method\r\n * @memberof CanvasRecorder\r\n * @example\r\n * recorder.resume();\r\n */\r\n this.resume = function() {\r\n isPausedRecording = false;\r\n\r\n if (mediaStreamRecorder instanceof MediaStreamRecorder) {\r\n mediaStreamRecorder.resume();\r\n return;\r\n }\r\n\r\n if (!isRecording) {\r\n this.record();\r\n }\r\n };\r\n\r\n /**\r\n * This method resets currently recorded data.\r\n * @method\r\n * @memberof CanvasRecorder\r\n * @example\r\n * recorder.clearRecordedData();\r\n */\r\n this.clearRecordedData = function() {\r\n if (isRecording) {\r\n this.stop(clearRecordedDataCB);\r\n }\r\n clearRecordedDataCB();\r\n };\r\n\r\n function clearRecordedDataCB() {\r\n whammy.frames = [];\r\n isRecording = false;\r\n isPausedRecording = false;\r\n }\r\n\r\n // for debugging\r\n this.name = 'CanvasRecorder';\r\n this.toString = function() {\r\n return this.name;\r\n };\r\n\r\n function cloneCanvas() {\r\n //create a new canvas\r\n var newCanvas = document.createElement('canvas');\r\n var context = newCanvas.getContext('2d');\r\n\r\n //set dimensions\r\n newCanvas.width = htmlElement.width;\r\n newCanvas.height = htmlElement.height;\r\n\r\n //apply the old canvas to the new one\r\n context.drawImage(htmlElement, 0, 0);\r\n\r\n //return the new canvas\r\n return newCanvas;\r\n }\r\n\r\n function drawCanvasFrame() {\r\n if (isPausedRecording) {\r\n lastTime = new Date().getTime();\r\n return setTimeout(drawCanvasFrame, 500);\r\n }\r\n\r\n if (htmlElement.nodeName.toLowerCase() === 'canvas') {\r\n var duration = new Date().getTime() - lastTime;\r\n // via #206, by Jack i.e. @Seymourr\r\n lastTime = new Date().getTime();\r\n\r\n whammy.frames.push({\r\n image: cloneCanvas(),\r\n duration: duration\r\n });\r\n\r\n if (isRecording) {\r\n setTimeout(drawCanvasFrame, config.frameInterval);\r\n }\r\n return;\r\n }\r\n\r\n html2canvas(htmlElement, {\r\n grabMouse: typeof config.showMousePointer === 'undefined' || config.showMousePointer,\r\n onrendered: function(canvas) {\r\n var duration = new Date().getTime() - lastTime;\r\n if (!duration) {\r\n return setTimeout(drawCanvasFrame, config.frameInterval);\r\n }\r\n\r\n // via #206, by Jack i.e. @Seymourr\r\n lastTime = new Date().getTime();\r\n\r\n whammy.frames.push({\r\n image: canvas.toDataURL('image/webp', 1),\r\n duration: duration\r\n });\r\n\r\n if (isRecording) {\r\n setTimeout(drawCanvasFrame, config.frameInterval);\r\n }\r\n }\r\n });\r\n }\r\n\r\n var lastTime = new Date().getTime();\r\n\r\n var whammy = new Whammy.Video(100);\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.CanvasRecorder = CanvasRecorder;\r\n}\n\r\n// _________________\r\n// WhammyRecorder.js\r\n\r\n/**\r\n * WhammyRecorder is a standalone class used by {@link RecordRTC} to bring video recording in Chrome. It runs top over {@link Whammy}.\r\n * @summary Video recording feature in Chrome.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef WhammyRecorder\r\n * @class\r\n * @example\r\n * var recorder = new WhammyRecorder(mediaStream);\r\n * recorder.record();\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.\r\n * @param {object} config - {disableLogs: true, initCallback: function, video: HTMLVideoElement, etc.}\r\n */\r\n\r\nfunction WhammyRecorder(mediaStream, config) {\r\n\r\n config = config || {};\r\n\r\n if (!config.frameInterval) {\r\n config.frameInterval = 10;\r\n }\r\n\r\n if (!config.disableLogs) {\r\n console.log('Using frames-interval:', config.frameInterval);\r\n }\r\n\r\n /**\r\n * This method records video.\r\n * @method\r\n * @memberof WhammyRecorder\r\n * @example\r\n * recorder.record();\r\n */\r\n this.record = function() {\r\n if (!config.width) {\r\n config.width = 320;\r\n }\r\n\r\n if (!config.height) {\r\n config.height = 240;\r\n }\r\n\r\n if (!config.video) {\r\n config.video = {\r\n width: config.width,\r\n height: config.height\r\n };\r\n }\r\n\r\n if (!config.canvas) {\r\n config.canvas = {\r\n width: config.width,\r\n height: config.height\r\n };\r\n }\r\n\r\n canvas.width = config.canvas.width || 320;\r\n canvas.height = config.canvas.height || 240;\r\n\r\n context = canvas.getContext('2d');\r\n\r\n // setting defaults\r\n if (config.video && config.video instanceof HTMLVideoElement) {\r\n video = config.video.cloneNode();\r\n\r\n if (config.initCallback) {\r\n config.initCallback();\r\n }\r\n } else {\r\n video = document.createElement('video');\r\n\r\n setSrcObject(mediaStream, video);\r\n\r\n video.onloadedmetadata = function() { // \"onloadedmetadata\" may NOT work in FF?\r\n if (config.initCallback) {\r\n config.initCallback();\r\n }\r\n };\r\n\r\n video.width = config.video.width;\r\n video.height = config.video.height;\r\n }\r\n\r\n video.muted = true;\r\n video.play();\r\n\r\n lastTime = new Date().getTime();\r\n whammy = new Whammy.Video();\r\n\r\n if (!config.disableLogs) {\r\n console.log('canvas resolutions', canvas.width, '*', canvas.height);\r\n console.log('video width/height', video.width || canvas.width, '*', video.height || canvas.height);\r\n }\r\n\r\n drawFrames(config.frameInterval);\r\n };\r\n\r\n /**\r\n * Draw and push frames to Whammy\r\n * @param {integer} frameInterval - set minimum interval (in milliseconds) between each time we push a frame to Whammy\r\n */\r\n function drawFrames(frameInterval) {\r\n frameInterval = typeof frameInterval !== 'undefined' ? frameInterval : 10;\r\n\r\n var duration = new Date().getTime() - lastTime;\r\n if (!duration) {\r\n return setTimeout(drawFrames, frameInterval, frameInterval);\r\n }\r\n\r\n if (isPausedRecording) {\r\n lastTime = new Date().getTime();\r\n return setTimeout(drawFrames, 100);\r\n }\r\n\r\n // via #206, by Jack i.e. @Seymourr\r\n lastTime = new Date().getTime();\r\n\r\n if (video.paused) {\r\n // via: https://github.com/muaz-khan/WebRTC-Experiment/pull/316\r\n // Tweak for Android Chrome\r\n video.play();\r\n }\r\n\r\n context.drawImage(video, 0, 0, canvas.width, canvas.height);\r\n whammy.frames.push({\r\n duration: duration,\r\n image: canvas.toDataURL('image/webp')\r\n });\r\n\r\n if (!isStopDrawing) {\r\n setTimeout(drawFrames, frameInterval, frameInterval);\r\n }\r\n }\r\n\r\n function asyncLoop(o) {\r\n var i = -1,\r\n length = o.length;\r\n\r\n (function loop() {\r\n i++;\r\n if (i === length) {\r\n o.callback();\r\n return;\r\n }\r\n\r\n // \"setTimeout\" added by Jim McLeod\r\n setTimeout(function() {\r\n o.functionToLoop(loop, i);\r\n }, 1);\r\n })();\r\n }\r\n\r\n\r\n /**\r\n * remove black frames from the beginning to the specified frame\r\n * @param {Array} _frames - array of frames to be checked\r\n * @param {number} _framesToCheck - number of frame until check will be executed (-1 - will drop all frames until frame not matched will be found)\r\n * @param {number} _pixTolerance - 0 - very strict (only black pixel color) ; 1 - all\r\n * @param {number} _frameTolerance - 0 - very strict (only black frame color) ; 1 - all\r\n * @returns {Array} - array of frames\r\n */\r\n // pull#293 by @volodalexey\r\n function dropBlackFrames(_frames, _framesToCheck, _pixTolerance, _frameTolerance, callback) {\r\n var localCanvas = document.createElement('canvas');\r\n localCanvas.width = canvas.width;\r\n localCanvas.height = canvas.height;\r\n var context2d = localCanvas.getContext('2d');\r\n var resultFrames = [];\r\n\r\n var checkUntilNotBlack = _framesToCheck === -1;\r\n var endCheckFrame = (_framesToCheck && _framesToCheck > 0 && _framesToCheck <= _frames.length) ?\r\n _framesToCheck : _frames.length;\r\n var sampleColor = {\r\n r: 0,\r\n g: 0,\r\n b: 0\r\n };\r\n var maxColorDifference = Math.sqrt(\r\n Math.pow(255, 2) +\r\n Math.pow(255, 2) +\r\n Math.pow(255, 2)\r\n );\r\n var pixTolerance = _pixTolerance && _pixTolerance >= 0 && _pixTolerance <= 1 ? _pixTolerance : 0;\r\n var frameTolerance = _frameTolerance && _frameTolerance >= 0 && _frameTolerance <= 1 ? _frameTolerance : 0;\r\n var doNotCheckNext = false;\r\n\r\n asyncLoop({\r\n length: endCheckFrame,\r\n functionToLoop: function(loop, f) {\r\n var matchPixCount, endPixCheck, maxPixCount;\r\n\r\n var finishImage = function() {\r\n if (!doNotCheckNext && maxPixCount - matchPixCount <= maxPixCount * frameTolerance) {\r\n // console.log('removed black frame : ' + f + ' ; frame duration ' + _frames[f].duration);\r\n } else {\r\n // console.log('frame is passed : ' + f);\r\n if (checkUntilNotBlack) {\r\n doNotCheckNext = true;\r\n }\r\n resultFrames.push(_frames[f]);\r\n }\r\n loop();\r\n };\r\n\r\n if (!doNotCheckNext) {\r\n var image = new Image();\r\n image.onload = function() {\r\n context2d.drawImage(image, 0, 0, canvas.width, canvas.height);\r\n var imageData = context2d.getImageData(0, 0, canvas.width, canvas.height);\r\n matchPixCount = 0;\r\n endPixCheck = imageData.data.length;\r\n maxPixCount = imageData.data.length / 4;\r\n\r\n for (var pix = 0; pix < endPixCheck; pix += 4) {\r\n var currentColor = {\r\n r: imageData.data[pix],\r\n g: imageData.data[pix + 1],\r\n b: imageData.data[pix + 2]\r\n };\r\n var colorDifference = Math.sqrt(\r\n Math.pow(currentColor.r - sampleColor.r, 2) +\r\n Math.pow(currentColor.g - sampleColor.g, 2) +\r\n Math.pow(currentColor.b - sampleColor.b, 2)\r\n );\r\n // difference in color it is difference in color vectors (r1,g1,b1) <=> (r2,g2,b2)\r\n if (colorDifference <= maxColorDifference * pixTolerance) {\r\n matchPixCount++;\r\n }\r\n }\r\n finishImage();\r\n };\r\n image.src = _frames[f].image;\r\n } else {\r\n finishImage();\r\n }\r\n },\r\n callback: function() {\r\n resultFrames = resultFrames.concat(_frames.slice(endCheckFrame));\r\n\r\n if (resultFrames.length <= 0) {\r\n // at least one last frame should be available for next manipulation\r\n // if total duration of all frames will be < 1000 than ffmpeg doesn't work well...\r\n resultFrames.push(_frames[_frames.length - 1]);\r\n }\r\n callback(resultFrames);\r\n }\r\n });\r\n }\r\n\r\n var isStopDrawing = false;\r\n\r\n /**\r\n * This method stops recording video.\r\n * @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.\r\n * @method\r\n * @memberof WhammyRecorder\r\n * @example\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n */\r\n this.stop = function(callback) {\r\n callback = callback || function() {};\r\n\r\n isStopDrawing = true;\r\n\r\n var _this = this;\r\n // analyse of all frames takes some time!\r\n setTimeout(function() {\r\n // e.g. dropBlackFrames(frames, 10, 1, 1) - will cut all 10 frames\r\n // e.g. dropBlackFrames(frames, 10, 0.5, 0.5) - will analyse 10 frames\r\n // e.g. dropBlackFrames(frames, 10) === dropBlackFrames(frames, 10, 0, 0) - will analyse 10 frames with strict black color\r\n dropBlackFrames(whammy.frames, -1, null, null, function(frames) {\r\n whammy.frames = frames;\r\n\r\n // to display advertisement images!\r\n if (config.advertisement && config.advertisement.length) {\r\n whammy.frames = config.advertisement.concat(whammy.frames);\r\n }\r\n\r\n /**\r\n * @property {Blob} blob - Recorded frames in video/webm blob.\r\n * @memberof WhammyRecorder\r\n * @example\r\n * recorder.stop(function() {\r\n * var blob = recorder.blob;\r\n * });\r\n */\r\n whammy.compile(function(blob) {\r\n _this.blob = blob;\r\n\r\n if (_this.blob.forEach) {\r\n _this.blob = new Blob([], {\r\n type: 'video/webm'\r\n });\r\n }\r\n\r\n if (callback) {\r\n callback(_this.blob);\r\n }\r\n });\r\n });\r\n }, 10);\r\n };\r\n\r\n var isPausedRecording = false;\r\n\r\n /**\r\n * This method pauses the recording process.\r\n * @method\r\n * @memberof WhammyRecorder\r\n * @example\r\n * recorder.pause();\r\n */\r\n this.pause = function() {\r\n isPausedRecording = true;\r\n };\r\n\r\n /**\r\n * This method resumes the recording process.\r\n * @method\r\n * @memberof WhammyRecorder\r\n * @example\r\n * recorder.resume();\r\n */\r\n this.resume = function() {\r\n isPausedRecording = false;\r\n\r\n if (isStopDrawing) {\r\n this.record();\r\n }\r\n };\r\n\r\n /**\r\n * This method resets currently recorded data.\r\n * @method\r\n * @memberof WhammyRecorder\r\n * @example\r\n * recorder.clearRecordedData();\r\n */\r\n this.clearRecordedData = function() {\r\n if (!isStopDrawing) {\r\n this.stop(clearRecordedDataCB);\r\n }\r\n clearRecordedDataCB();\r\n };\r\n\r\n function clearRecordedDataCB() {\r\n whammy.frames = [];\r\n isStopDrawing = true;\r\n isPausedRecording = false;\r\n }\r\n\r\n // for debugging\r\n this.name = 'WhammyRecorder';\r\n this.toString = function() {\r\n return this.name;\r\n };\r\n\r\n var canvas = document.createElement('canvas');\r\n var context = canvas.getContext('2d');\r\n\r\n var video;\r\n var lastTime;\r\n var whammy;\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.WhammyRecorder = WhammyRecorder;\r\n}\n\r\n// https://github.com/antimatter15/whammy/blob/master/LICENSE\r\n// _________\r\n// Whammy.js\r\n\r\n// todo: Firefox now supports webp for webm containers!\r\n// their MediaRecorder implementation works well!\r\n// should we provide an option to record via Whammy.js or MediaRecorder API is a better solution?\r\n\r\n/**\r\n * Whammy is a standalone class used by {@link RecordRTC} to bring video recording in Chrome. It is written by {@link https://github.com/antimatter15|antimatter15}\r\n * @summary A real time javascript webm encoder based on a canvas hack.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef Whammy\r\n * @class\r\n * @example\r\n * var recorder = new Whammy().Video(15);\r\n * recorder.add(context || canvas || dataURL);\r\n * var output = recorder.compile();\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n */\r\n\r\nvar Whammy = (function() {\r\n // a more abstract-ish API\r\n\r\n function WhammyVideo(duration) {\r\n this.frames = [];\r\n this.duration = duration || 1;\r\n this.quality = 0.8;\r\n }\r\n\r\n /**\r\n * Pass Canvas or Context or image/webp(string) to {@link Whammy} encoder.\r\n * @method\r\n * @memberof Whammy\r\n * @example\r\n * recorder = new Whammy().Video(0.8, 100);\r\n * recorder.add(canvas || context || 'image/webp');\r\n * @param {string} frame - Canvas || Context || image/webp\r\n * @param {number} duration - Stick a duration (in milliseconds)\r\n */\r\n WhammyVideo.prototype.add = function(frame, duration) {\r\n if ('canvas' in frame) { //CanvasRenderingContext2D\r\n frame = frame.canvas;\r\n }\r\n\r\n if ('toDataURL' in frame) {\r\n frame = frame.toDataURL('image/webp', this.quality);\r\n }\r\n\r\n if (!(/^data:image\\/webp;base64,/ig).test(frame)) {\r\n throw 'Input must be formatted properly as a base64 encoded DataURI of type image/webp';\r\n }\r\n this.frames.push({\r\n image: frame,\r\n duration: duration || this.duration\r\n });\r\n };\r\n\r\n function processInWebWorker(_function) {\r\n var blob = URL.createObjectURL(new Blob([_function.toString(),\r\n 'this.onmessage = function (eee) {' + _function.name + '(eee.data);}'\r\n ], {\r\n type: 'application/javascript'\r\n }));\r\n\r\n var worker = new Worker(blob);\r\n URL.revokeObjectURL(blob);\r\n return worker;\r\n }\r\n\r\n function whammyInWebWorker(frames) {\r\n function ArrayToWebM(frames) {\r\n var info = checkFrames(frames);\r\n if (!info) {\r\n return [];\r\n }\r\n\r\n var clusterMaxDuration = 30000;\r\n\r\n var EBML = [{\r\n 'id': 0x1a45dfa3, // EBML\r\n 'data': [{\r\n 'data': 1,\r\n 'id': 0x4286 // EBMLVersion\r\n }, {\r\n 'data': 1,\r\n 'id': 0x42f7 // EBMLReadVersion\r\n }, {\r\n 'data': 4,\r\n 'id': 0x42f2 // EBMLMaxIDLength\r\n }, {\r\n 'data': 8,\r\n 'id': 0x42f3 // EBMLMaxSizeLength\r\n }, {\r\n 'data': 'webm',\r\n 'id': 0x4282 // DocType\r\n }, {\r\n 'data': 2,\r\n 'id': 0x4287 // DocTypeVersion\r\n }, {\r\n 'data': 2,\r\n 'id': 0x4285 // DocTypeReadVersion\r\n }]\r\n }, {\r\n 'id': 0x18538067, // Segment\r\n 'data': [{\r\n 'id': 0x1549a966, // Info\r\n 'data': [{\r\n 'data': 1e6, //do things in millisecs (num of nanosecs for duration scale)\r\n 'id': 0x2ad7b1 // TimecodeScale\r\n }, {\r\n 'data': 'whammy',\r\n 'id': 0x4d80 // MuxingApp\r\n }, {\r\n 'data': 'whammy',\r\n 'id': 0x5741 // WritingApp\r\n }, {\r\n 'data': doubleToString(info.duration),\r\n 'id': 0x4489 // Duration\r\n }]\r\n }, {\r\n 'id': 0x1654ae6b, // Tracks\r\n 'data': [{\r\n 'id': 0xae, // TrackEntry\r\n 'data': [{\r\n 'data': 1,\r\n 'id': 0xd7 // TrackNumber\r\n }, {\r\n 'data': 1,\r\n 'id': 0x73c5 // TrackUID\r\n }, {\r\n 'data': 0,\r\n 'id': 0x9c // FlagLacing\r\n }, {\r\n 'data': 'und',\r\n 'id': 0x22b59c // Language\r\n }, {\r\n 'data': 'V_VP8',\r\n 'id': 0x86 // CodecID\r\n }, {\r\n 'data': 'VP8',\r\n 'id': 0x258688 // CodecName\r\n }, {\r\n 'data': 1,\r\n 'id': 0x83 // TrackType\r\n }, {\r\n 'id': 0xe0, // Video\r\n 'data': [{\r\n 'data': info.width,\r\n 'id': 0xb0 // PixelWidth\r\n }, {\r\n 'data': info.height,\r\n 'id': 0xba // PixelHeight\r\n }]\r\n }]\r\n }]\r\n }]\r\n }];\r\n\r\n //Generate clusters (max duration)\r\n var frameNumber = 0;\r\n var clusterTimecode = 0;\r\n while (frameNumber < frames.length) {\r\n\r\n var clusterFrames = [];\r\n var clusterDuration = 0;\r\n do {\r\n clusterFrames.push(frames[frameNumber]);\r\n clusterDuration += frames[frameNumber].duration;\r\n frameNumber++;\r\n } while (frameNumber < frames.length && clusterDuration < clusterMaxDuration);\r\n\r\n var clusterCounter = 0;\r\n var cluster = {\r\n 'id': 0x1f43b675, // Cluster\r\n 'data': getClusterData(clusterTimecode, clusterCounter, clusterFrames)\r\n }; //Add cluster to segment\r\n EBML[1].data.push(cluster);\r\n clusterTimecode += clusterDuration;\r\n }\r\n\r\n return generateEBML(EBML);\r\n }\r\n\r\n function getClusterData(clusterTimecode, clusterCounter, clusterFrames) {\r\n return [{\r\n 'data': clusterTimecode,\r\n 'id': 0xe7 // Timecode\r\n }].concat(clusterFrames.map(function(webp) {\r\n var block = makeSimpleBlock({\r\n discardable: 0,\r\n frame: webp.data.slice(4),\r\n invisible: 0,\r\n keyframe: 1,\r\n lacing: 0,\r\n trackNum: 1,\r\n timecode: Math.round(clusterCounter)\r\n });\r\n clusterCounter += webp.duration;\r\n return {\r\n data: block,\r\n id: 0xa3\r\n };\r\n }));\r\n }\r\n\r\n // sums the lengths of all the frames and gets the duration\r\n\r\n function checkFrames(frames) {\r\n if (!frames[0]) {\r\n postMessage({\r\n error: 'Something went wrong. Maybe WebP format is not supported in the current browser.'\r\n });\r\n return;\r\n }\r\n\r\n var width = frames[0].width,\r\n height = frames[0].height,\r\n duration = frames[0].duration;\r\n\r\n for (var i = 1; i < frames.length; i++) {\r\n duration += frames[i].duration;\r\n }\r\n return {\r\n duration: duration,\r\n width: width,\r\n height: height\r\n };\r\n }\r\n\r\n function numToBuffer(num) {\r\n var parts = [];\r\n while (num > 0) {\r\n parts.push(num & 0xff);\r\n num = num >> 8;\r\n }\r\n return new Uint8Array(parts.reverse());\r\n }\r\n\r\n function strToBuffer(str) {\r\n return new Uint8Array(str.split('').map(function(e) {\r\n return e.charCodeAt(0);\r\n }));\r\n }\r\n\r\n function bitsToBuffer(bits) {\r\n var data = [];\r\n var pad = (bits.length % 8) ? (new Array(1 + 8 - (bits.length % 8))).join('0') : '';\r\n bits = pad + bits;\r\n for (var i = 0; i < bits.length; i += 8) {\r\n data.push(parseInt(bits.substr(i, 8), 2));\r\n }\r\n return new Uint8Array(data);\r\n }\r\n\r\n function generateEBML(json) {\r\n var ebml = [];\r\n for (var i = 0; i < json.length; i++) {\r\n var data = json[i].data;\r\n\r\n if (typeof data === 'object') {\r\n data = generateEBML(data);\r\n }\r\n\r\n if (typeof data === 'number') {\r\n data = bitsToBuffer(data.toString(2));\r\n }\r\n\r\n if (typeof data === 'string') {\r\n data = strToBuffer(data);\r\n }\r\n\r\n var len = data.size || data.byteLength || data.length;\r\n var zeroes = Math.ceil(Math.ceil(Math.log(len) / Math.log(2)) / 8);\r\n var sizeToString = len.toString(2);\r\n var padded = (new Array((zeroes * 7 + 7 + 1) - sizeToString.length)).join('0') + sizeToString;\r\n var size = (new Array(zeroes)).join('0') + '1' + padded;\r\n\r\n ebml.push(numToBuffer(json[i].id));\r\n ebml.push(bitsToBuffer(size));\r\n ebml.push(data);\r\n }\r\n\r\n return new Blob(ebml, {\r\n type: 'video/webm'\r\n });\r\n }\r\n\r\n function toBinStrOld(bits) {\r\n var data = '';\r\n var pad = (bits.length % 8) ? (new Array(1 + 8 - (bits.length % 8))).join('0') : '';\r\n bits = pad + bits;\r\n for (var i = 0; i < bits.length; i += 8) {\r\n data += String.fromCharCode(parseInt(bits.substr(i, 8), 2));\r\n }\r\n return data;\r\n }\r\n\r\n function makeSimpleBlock(data) {\r\n var flags = 0;\r\n\r\n if (data.keyframe) {\r\n flags |= 128;\r\n }\r\n\r\n if (data.invisible) {\r\n flags |= 8;\r\n }\r\n\r\n if (data.lacing) {\r\n flags |= (data.lacing << 1);\r\n }\r\n\r\n if (data.discardable) {\r\n flags |= 1;\r\n }\r\n\r\n if (data.trackNum > 127) {\r\n throw 'TrackNumber > 127 not supported';\r\n }\r\n\r\n var out = [data.trackNum | 0x80, data.timecode >> 8, data.timecode & 0xff, flags].map(function(e) {\r\n return String.fromCharCode(e);\r\n }).join('') + data.frame;\r\n\r\n return out;\r\n }\r\n\r\n function parseWebP(riff) {\r\n var VP8 = riff.RIFF[0].WEBP[0];\r\n\r\n var frameStart = VP8.indexOf('\\x9d\\x01\\x2a'); // A VP8 keyframe starts with the 0x9d012a header\r\n for (var i = 0, c = []; i < 4; i++) {\r\n c[i] = VP8.charCodeAt(frameStart + 3 + i);\r\n }\r\n\r\n var width, height, tmp;\r\n\r\n //the code below is literally copied verbatim from the bitstream spec\r\n tmp = (c[1] << 8) | c[0];\r\n width = tmp & 0x3FFF;\r\n tmp = (c[3] << 8) | c[2];\r\n height = tmp & 0x3FFF;\r\n return {\r\n width: width,\r\n height: height,\r\n data: VP8,\r\n riff: riff\r\n };\r\n }\r\n\r\n function getStrLength(string, offset) {\r\n return parseInt(string.substr(offset + 4, 4).split('').map(function(i) {\r\n var unpadded = i.charCodeAt(0).toString(2);\r\n return (new Array(8 - unpadded.length + 1)).join('0') + unpadded;\r\n }).join(''), 2);\r\n }\r\n\r\n function parseRIFF(string) {\r\n var offset = 0;\r\n var chunks = {};\r\n\r\n while (offset < string.length) {\r\n var id = string.substr(offset, 4);\r\n var len = getStrLength(string, offset);\r\n var data = string.substr(offset + 4 + 4, len);\r\n offset += 4 + 4 + len;\r\n chunks[id] = chunks[id] || [];\r\n\r\n if (id === 'RIFF' || id === 'LIST') {\r\n chunks[id].push(parseRIFF(data));\r\n } else {\r\n chunks[id].push(data);\r\n }\r\n }\r\n return chunks;\r\n }\r\n\r\n function doubleToString(num) {\r\n return [].slice.call(\r\n new Uint8Array((new Float64Array([num])).buffer), 0).map(function(e) {\r\n return String.fromCharCode(e);\r\n }).reverse().join('');\r\n }\r\n\r\n var webm = new ArrayToWebM(frames.map(function(frame) {\r\n var webp = parseWebP(parseRIFF(atob(frame.image.slice(23))));\r\n webp.duration = frame.duration;\r\n return webp;\r\n }));\r\n\r\n postMessage(webm);\r\n }\r\n\r\n /**\r\n * Encodes frames in WebM container. It uses WebWorkinvoke to invoke 'ArrayToWebM' method.\r\n * @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.\r\n * @method\r\n * @memberof Whammy\r\n * @example\r\n * recorder = new Whammy().Video(0.8, 100);\r\n * recorder.compile(function(blob) {\r\n * // blob.size - blob.type\r\n * });\r\n */\r\n WhammyVideo.prototype.compile = function(callback) {\r\n var webWorker = processInWebWorker(whammyInWebWorker);\r\n\r\n webWorker.onmessage = function(event) {\r\n if (event.data.error) {\r\n console.error(event.data.error);\r\n return;\r\n }\r\n callback(event.data);\r\n };\r\n\r\n webWorker.postMessage(this.frames);\r\n };\r\n\r\n return {\r\n /**\r\n * A more abstract-ish API.\r\n * @method\r\n * @memberof Whammy\r\n * @example\r\n * recorder = new Whammy().Video(0.8, 100);\r\n * @param {?number} speed - 0.8\r\n * @param {?number} quality - 100\r\n */\r\n Video: WhammyVideo\r\n };\r\n})();\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.Whammy = Whammy;\r\n}\n\r\n// ______________ (indexed-db)\r\n// DiskStorage.js\r\n\r\n/**\r\n * DiskStorage is a standalone object used by {@link RecordRTC} to store recorded blobs in IndexedDB storage.\r\n * @summary Writing blobs into IndexedDB.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @example\r\n * DiskStorage.Store({\r\n * audioBlob: yourAudioBlob,\r\n * videoBlob: yourVideoBlob,\r\n * gifBlob : yourGifBlob\r\n * });\r\n * DiskStorage.Fetch(function(dataURL, type) {\r\n * if(type === 'audioBlob') { }\r\n * if(type === 'videoBlob') { }\r\n * if(type === 'gifBlob') { }\r\n * });\r\n * // DiskStorage.dataStoreName = 'recordRTC';\r\n * // DiskStorage.onError = function(error) { };\r\n * @property {function} init - This method must be called once to initialize IndexedDB ObjectStore. Though, it is auto-used internally.\r\n * @property {function} Fetch - This method fetches stored blobs from IndexedDB.\r\n * @property {function} Store - This method stores blobs in IndexedDB.\r\n * @property {function} onError - This function is invoked for any known/unknown error.\r\n * @property {string} dataStoreName - Name of the ObjectStore created in IndexedDB storage.\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n */\r\n\r\n\r\nvar DiskStorage = {\r\n /**\r\n * This method must be called once to initialize IndexedDB ObjectStore. Though, it is auto-used internally.\r\n * @method\r\n * @memberof DiskStorage\r\n * @internal\r\n * @example\r\n * DiskStorage.init();\r\n */\r\n init: function() {\r\n var self = this;\r\n\r\n if (typeof indexedDB === 'undefined' || typeof indexedDB.open === 'undefined') {\r\n console.error('IndexedDB API are not available in this browser.');\r\n return;\r\n }\r\n\r\n var dbVersion = 1;\r\n var dbName = this.dbName || location.href.replace(/\\/|:|#|%|\\.|\\[|\\]/g, ''),\r\n db;\r\n var request = indexedDB.open(dbName, dbVersion);\r\n\r\n function createObjectStore(dataBase) {\r\n dataBase.createObjectStore(self.dataStoreName);\r\n }\r\n\r\n function putInDB() {\r\n var transaction = db.transaction([self.dataStoreName], 'readwrite');\r\n\r\n if (self.videoBlob) {\r\n transaction.objectStore(self.dataStoreName).put(self.videoBlob, 'videoBlob');\r\n }\r\n\r\n if (self.gifBlob) {\r\n transaction.objectStore(self.dataStoreName).put(self.gifBlob, 'gifBlob');\r\n }\r\n\r\n if (self.audioBlob) {\r\n transaction.objectStore(self.dataStoreName).put(self.audioBlob, 'audioBlob');\r\n }\r\n\r\n function getFromStore(portionName) {\r\n transaction.objectStore(self.dataStoreName).get(portionName).onsuccess = function(event) {\r\n if (self.callback) {\r\n self.callback(event.target.result, portionName);\r\n }\r\n };\r\n }\r\n\r\n getFromStore('audioBlob');\r\n getFromStore('videoBlob');\r\n getFromStore('gifBlob');\r\n }\r\n\r\n request.onerror = self.onError;\r\n\r\n request.onsuccess = function() {\r\n db = request.result;\r\n db.onerror = self.onError;\r\n\r\n if (db.setVersion) {\r\n if (db.version !== dbVersion) {\r\n var setVersion = db.setVersion(dbVersion);\r\n setVersion.onsuccess = function() {\r\n createObjectStore(db);\r\n putInDB();\r\n };\r\n } else {\r\n putInDB();\r\n }\r\n } else {\r\n putInDB();\r\n }\r\n };\r\n request.onupgradeneeded = function(event) {\r\n createObjectStore(event.target.result);\r\n };\r\n },\r\n /**\r\n * This method fetches stored blobs from IndexedDB.\r\n * @method\r\n * @memberof DiskStorage\r\n * @internal\r\n * @example\r\n * DiskStorage.Fetch(function(dataURL, type) {\r\n * if(type === 'audioBlob') { }\r\n * if(type === 'videoBlob') { }\r\n * if(type === 'gifBlob') { }\r\n * });\r\n */\r\n Fetch: function(callback) {\r\n this.callback = callback;\r\n this.init();\r\n\r\n return this;\r\n },\r\n /**\r\n * This method stores blobs in IndexedDB.\r\n * @method\r\n * @memberof DiskStorage\r\n * @internal\r\n * @example\r\n * DiskStorage.Store({\r\n * audioBlob: yourAudioBlob,\r\n * videoBlob: yourVideoBlob,\r\n * gifBlob : yourGifBlob\r\n * });\r\n */\r\n Store: function(config) {\r\n this.audioBlob = config.audioBlob;\r\n this.videoBlob = config.videoBlob;\r\n this.gifBlob = config.gifBlob;\r\n\r\n this.init();\r\n\r\n return this;\r\n },\r\n /**\r\n * This function is invoked for any known/unknown error.\r\n * @method\r\n * @memberof DiskStorage\r\n * @internal\r\n * @example\r\n * DiskStorage.onError = function(error){\r\n * alerot( JSON.stringify(error) );\r\n * };\r\n */\r\n onError: function(error) {\r\n console.error(JSON.stringify(error, null, '\\t'));\r\n },\r\n\r\n /**\r\n * @property {string} dataStoreName - Name of the ObjectStore created in IndexedDB storage.\r\n * @memberof DiskStorage\r\n * @internal\r\n * @example\r\n * DiskStorage.dataStoreName = 'recordRTC';\r\n */\r\n dataStoreName: 'recordRTC',\r\n dbName: null\r\n};\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.DiskStorage = DiskStorage;\r\n}\n\r\n// ______________\r\n// GifRecorder.js\r\n\r\n/**\r\n * GifRecorder is standalone calss used by {@link RecordRTC} to record video or canvas into animated gif.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef GifRecorder\r\n * @class\r\n * @example\r\n * var recorder = new GifRecorder(mediaStream || canvas || context, { onGifPreview: function, onGifRecordingStarted: function, width: 1280, height: 720, frameRate: 200, quality: 10 });\r\n * recorder.record();\r\n * recorder.stop(function(blob) {\r\n * img.src = URL.createObjectURL(blob);\r\n * });\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - MediaStream object or HTMLCanvasElement or CanvasRenderingContext2D.\r\n * @param {object} config - {disableLogs:true, initCallback: function, width: 320, height: 240, frameRate: 200, quality: 10}\r\n */\r\n\r\nfunction GifRecorder(mediaStream, config) {\r\n if (typeof GIFEncoder === 'undefined') {\r\n var script = document.createElement('script');\r\n script.src = 'https://www.webrtc-experiment.com/gif-recorder.js';\r\n (document.body || document.documentElement).appendChild(script);\r\n }\r\n\r\n config = config || {};\r\n\r\n var isHTMLObject = mediaStream instanceof CanvasRenderingContext2D || mediaStream instanceof HTMLCanvasElement;\r\n\r\n /**\r\n * This method records MediaStream.\r\n * @method\r\n * @memberof GifRecorder\r\n * @example\r\n * recorder.record();\r\n */\r\n this.record = function() {\r\n if (typeof GIFEncoder === 'undefined') {\r\n setTimeout(self.record, 1000);\r\n return;\r\n }\r\n\r\n if (!isLoadedMetaData) {\r\n setTimeout(self.record, 1000);\r\n return;\r\n }\r\n\r\n if (!isHTMLObject) {\r\n if (!config.width) {\r\n config.width = video.offsetWidth || 320;\r\n }\r\n\r\n if (!config.height) {\r\n config.height = video.offsetHeight || 240;\r\n }\r\n\r\n if (!config.video) {\r\n config.video = {\r\n width: config.width,\r\n height: config.height\r\n };\r\n }\r\n\r\n if (!config.canvas) {\r\n config.canvas = {\r\n width: config.width,\r\n height: config.height\r\n };\r\n }\r\n\r\n canvas.width = config.canvas.width || 320;\r\n canvas.height = config.canvas.height || 240;\r\n\r\n video.width = config.video.width || 320;\r\n video.height = config.video.height || 240;\r\n }\r\n\r\n // external library to record as GIF images\r\n gifEncoder = new GIFEncoder();\r\n\r\n // void setRepeat(int iter) \r\n // Sets the number of times the set of GIF frames should be played. \r\n // Default is 1; 0 means play indefinitely.\r\n gifEncoder.setRepeat(0);\r\n\r\n // void setFrameRate(Number fps) \r\n // Sets frame rate in frames per second. \r\n // Equivalent to setDelay(1000/fps).\r\n // Using \"setDelay\" instead of \"setFrameRate\"\r\n gifEncoder.setDelay(config.frameRate || 200);\r\n\r\n // void setQuality(int quality) \r\n // Sets quality of color quantization (conversion of images to the \r\n // maximum 256 colors allowed by the GIF specification). \r\n // Lower values (minimum = 1) produce better colors, \r\n // but slow processing significantly. 10 is the default, \r\n // and produces good color mapping at reasonable speeds. \r\n // Values greater than 20 do not yield significant improvements in speed.\r\n gifEncoder.setQuality(config.quality || 10);\r\n\r\n // Boolean start() \r\n // This writes the GIF Header and returns false if it fails.\r\n gifEncoder.start();\r\n\r\n if (typeof config.onGifRecordingStarted === 'function') {\r\n config.onGifRecordingStarted();\r\n }\r\n\r\n startTime = Date.now();\r\n\r\n function drawVideoFrame(time) {\r\n if (self.clearedRecordedData === true) {\r\n return;\r\n }\r\n\r\n if (isPausedRecording) {\r\n return setTimeout(function() {\r\n drawVideoFrame(time);\r\n }, 100);\r\n }\r\n\r\n lastAnimationFrame = requestAnimationFrame(drawVideoFrame);\r\n\r\n if (typeof lastFrameTime === undefined) {\r\n lastFrameTime = time;\r\n }\r\n\r\n // ~10 fps\r\n if (time - lastFrameTime < 90) {\r\n return;\r\n }\r\n\r\n if (!isHTMLObject && video.paused) {\r\n // via: https://github.com/muaz-khan/WebRTC-Experiment/pull/316\r\n // Tweak for Android Chrome\r\n video.play();\r\n }\r\n\r\n if (!isHTMLObject) {\r\n context.drawImage(video, 0, 0, canvas.width, canvas.height);\r\n }\r\n\r\n if (config.onGifPreview) {\r\n config.onGifPreview(canvas.toDataURL('image/png'));\r\n }\r\n\r\n gifEncoder.addFrame(context);\r\n lastFrameTime = time;\r\n }\r\n\r\n lastAnimationFrame = requestAnimationFrame(drawVideoFrame);\r\n\r\n if (config.initCallback) {\r\n config.initCallback();\r\n }\r\n };\r\n\r\n /**\r\n * This method stops recording MediaStream.\r\n * @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.\r\n * @method\r\n * @memberof GifRecorder\r\n * @example\r\n * recorder.stop(function(blob) {\r\n * img.src = URL.createObjectURL(blob);\r\n * });\r\n */\r\n this.stop = function(callback) {\r\n callback = callback || function() {};\r\n\r\n if (lastAnimationFrame) {\r\n cancelAnimationFrame(lastAnimationFrame);\r\n }\r\n\r\n endTime = Date.now();\r\n\r\n /**\r\n * @property {Blob} blob - The recorded blob object.\r\n * @memberof GifRecorder\r\n * @example\r\n * recorder.stop(function(){\r\n * var blob = recorder.blob;\r\n * });\r\n */\r\n this.blob = new Blob([new Uint8Array(gifEncoder.stream().bin)], {\r\n type: 'image/gif'\r\n });\r\n\r\n callback(this.blob);\r\n\r\n // bug: find a way to clear old recorded blobs\r\n gifEncoder.stream().bin = [];\r\n };\r\n\r\n var isPausedRecording = false;\r\n\r\n /**\r\n * This method pauses the recording process.\r\n * @method\r\n * @memberof GifRecorder\r\n * @example\r\n * recorder.pause();\r\n */\r\n this.pause = function() {\r\n isPausedRecording = true;\r\n };\r\n\r\n /**\r\n * This method resumes the recording process.\r\n * @method\r\n * @memberof GifRecorder\r\n * @example\r\n * recorder.resume();\r\n */\r\n this.resume = function() {\r\n isPausedRecording = false;\r\n };\r\n\r\n /**\r\n * This method resets currently recorded data.\r\n * @method\r\n * @memberof GifRecorder\r\n * @example\r\n * recorder.clearRecordedData();\r\n */\r\n this.clearRecordedData = function() {\r\n self.clearedRecordedData = true;\r\n clearRecordedDataCB();\r\n };\r\n\r\n function clearRecordedDataCB() {\r\n if (gifEncoder) {\r\n gifEncoder.stream().bin = [];\r\n }\r\n }\r\n\r\n // for debugging\r\n this.name = 'GifRecorder';\r\n this.toString = function() {\r\n return this.name;\r\n };\r\n\r\n var canvas = document.createElement('canvas');\r\n var context = canvas.getContext('2d');\r\n\r\n if (isHTMLObject) {\r\n if (mediaStream instanceof CanvasRenderingContext2D) {\r\n context = mediaStream;\r\n canvas = context.canvas;\r\n } else if (mediaStream instanceof HTMLCanvasElement) {\r\n context = mediaStream.getContext('2d');\r\n canvas = mediaStream;\r\n }\r\n }\r\n\r\n var isLoadedMetaData = true;\r\n\r\n if (!isHTMLObject) {\r\n var video = document.createElement('video');\r\n video.muted = true;\r\n video.autoplay = true;\r\n video.playsInline = true;\r\n\r\n isLoadedMetaData = false;\r\n video.onloadedmetadata = function() {\r\n isLoadedMetaData = true;\r\n };\r\n\r\n setSrcObject(mediaStream, video);\r\n\r\n video.play();\r\n }\r\n\r\n var lastAnimationFrame = null;\r\n var startTime, endTime, lastFrameTime;\r\n\r\n var gifEncoder;\r\n\r\n var self = this;\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.GifRecorder = GifRecorder;\r\n}\n\r\n// Last time updated: 2019-06-21 4:09:42 AM UTC\r\n\r\n// ________________________\r\n// MultiStreamsMixer v1.2.2\r\n\r\n// Open-Sourced: https://github.com/muaz-khan/MultiStreamsMixer\r\n\r\n// --------------------------------------------------\r\n// Muaz Khan - www.MuazKhan.com\r\n// MIT License - www.WebRTC-Experiment.com/licence\r\n// --------------------------------------------------\r\n\r\nfunction MultiStreamsMixer(arrayOfMediaStreams, elementClass) {\r\n\r\n var browserFakeUserAgent = 'Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45';\r\n\r\n (function(that) {\r\n if (typeof RecordRTC !== 'undefined') {\r\n return;\r\n }\r\n\r\n if (!that) {\r\n return;\r\n }\r\n\r\n if (typeof window !== 'undefined') {\r\n return;\r\n }\r\n\r\n if (typeof global === 'undefined') {\r\n return;\r\n }\r\n\r\n global.navigator = {\r\n userAgent: browserFakeUserAgent,\r\n getUserMedia: function() {}\r\n };\r\n\r\n if (!global.console) {\r\n global.console = {};\r\n }\r\n\r\n if (typeof global.console.log === 'undefined' || typeof global.console.error === 'undefined') {\r\n global.console.error = global.console.log = global.console.log || function() {\r\n console.log(arguments);\r\n };\r\n }\r\n\r\n if (typeof document === 'undefined') {\r\n /*global document:true */\r\n that.document = {\r\n documentElement: {\r\n appendChild: function() {\r\n return '';\r\n }\r\n }\r\n };\r\n\r\n document.createElement = document.captureStream = document.mozCaptureStream = function() {\r\n var obj = {\r\n getContext: function() {\r\n return obj;\r\n },\r\n play: function() {},\r\n pause: function() {},\r\n drawImage: function() {},\r\n toDataURL: function() {\r\n return '';\r\n },\r\n style: {}\r\n };\r\n return obj;\r\n };\r\n\r\n that.HTMLVideoElement = function() {};\r\n }\r\n\r\n if (typeof location === 'undefined') {\r\n /*global location:true */\r\n that.location = {\r\n protocol: 'file:',\r\n href: '',\r\n hash: ''\r\n };\r\n }\r\n\r\n if (typeof screen === 'undefined') {\r\n /*global screen:true */\r\n that.screen = {\r\n width: 0,\r\n height: 0\r\n };\r\n }\r\n\r\n if (typeof URL === 'undefined') {\r\n /*global screen:true */\r\n that.URL = {\r\n createObjectURL: function() {\r\n return '';\r\n },\r\n revokeObjectURL: function() {\r\n return '';\r\n }\r\n };\r\n }\r\n\r\n /*global window:true */\r\n that.window = global;\r\n })(typeof global !== 'undefined' ? global : null);\r\n\r\n // requires: chrome://flags/#enable-experimental-web-platform-features\r\n\r\n elementClass = elementClass || 'multi-streams-mixer';\r\n\r\n var videos = [];\r\n var isStopDrawingFrames = false;\r\n\r\n var canvas = document.createElement('canvas');\r\n var context = canvas.getContext('2d');\r\n canvas.style.opacity = 0;\r\n canvas.style.position = 'absolute';\r\n canvas.style.zIndex = -1;\r\n canvas.style.top = '-1000em';\r\n canvas.style.left = '-1000em';\r\n canvas.className = elementClass;\r\n (document.body || document.documentElement).appendChild(canvas);\r\n\r\n this.disableLogs = false;\r\n this.frameInterval = 10;\r\n\r\n this.width = 360;\r\n this.height = 240;\r\n\r\n // use gain node to prevent echo\r\n this.useGainNode = true;\r\n\r\n var self = this;\r\n\r\n // _____________________________\r\n // Cross-Browser-Declarations.js\r\n\r\n // WebAudio API representer\r\n var AudioContext = window.AudioContext;\r\n\r\n if (typeof AudioContext === 'undefined') {\r\n if (typeof webkitAudioContext !== 'undefined') {\r\n /*global AudioContext:true */\r\n AudioContext = webkitAudioContext;\r\n }\r\n\r\n if (typeof mozAudioContext !== 'undefined') {\r\n /*global AudioContext:true */\r\n AudioContext = mozAudioContext;\r\n }\r\n }\r\n\r\n /*jshint -W079 */\r\n var URL = window.URL;\r\n\r\n if (typeof URL === 'undefined' && typeof webkitURL !== 'undefined') {\r\n /*global URL:true */\r\n URL = webkitURL;\r\n }\r\n\r\n if (typeof navigator !== 'undefined' && typeof navigator.getUserMedia === 'undefined') { // maybe window.navigator?\r\n if (typeof navigator.webkitGetUserMedia !== 'undefined') {\r\n navigator.getUserMedia = navigator.webkitGetUserMedia;\r\n }\r\n\r\n if (typeof navigator.mozGetUserMedia !== 'undefined') {\r\n navigator.getUserMedia = navigator.mozGetUserMedia;\r\n }\r\n }\r\n\r\n var MediaStream = window.MediaStream;\r\n\r\n if (typeof MediaStream === 'undefined' && typeof webkitMediaStream !== 'undefined') {\r\n MediaStream = webkitMediaStream;\r\n }\r\n\r\n /*global MediaStream:true */\r\n if (typeof MediaStream !== 'undefined') {\r\n // override \"stop\" method for all browsers\r\n if (typeof MediaStream.prototype.stop === 'undefined') {\r\n MediaStream.prototype.stop = function() {\r\n this.getTracks().forEach(function(track) {\r\n track.stop();\r\n });\r\n };\r\n }\r\n }\r\n\r\n var Storage = {};\r\n\r\n if (typeof AudioContext !== 'undefined') {\r\n Storage.AudioContext = AudioContext;\r\n } else if (typeof webkitAudioContext !== 'undefined') {\r\n Storage.AudioContext = webkitAudioContext;\r\n }\r\n\r\n function setSrcObject(stream, element) {\r\n if ('srcObject' in element) {\r\n element.srcObject = stream;\r\n } else if ('mozSrcObject' in element) {\r\n element.mozSrcObject = stream;\r\n } else {\r\n element.srcObject = stream;\r\n }\r\n }\r\n\r\n this.startDrawingFrames = function() {\r\n drawVideosToCanvas();\r\n };\r\n\r\n function drawVideosToCanvas() {\r\n if (isStopDrawingFrames) {\r\n return;\r\n }\r\n\r\n var videosLength = videos.length;\r\n\r\n var fullcanvas = false;\r\n var remaining = [];\r\n videos.forEach(function(video) {\r\n if (!video.stream) {\r\n video.stream = {};\r\n }\r\n\r\n if (video.stream.fullcanvas) {\r\n fullcanvas = video;\r\n } else {\r\n // todo: video.stream.active or video.stream.live to fix blank frames issues?\r\n remaining.push(video);\r\n }\r\n });\r\n\r\n if (fullcanvas) {\r\n canvas.width = fullcanvas.stream.width;\r\n canvas.height = fullcanvas.stream.height;\r\n } else if (remaining.length) {\r\n canvas.width = videosLength > 1 ? remaining[0].width * 2 : remaining[0].width;\r\n\r\n var height = 1;\r\n if (videosLength === 3 || videosLength === 4) {\r\n height = 2;\r\n }\r\n if (videosLength === 5 || videosLength === 6) {\r\n height = 3;\r\n }\r\n if (videosLength === 7 || videosLength === 8) {\r\n height = 4;\r\n }\r\n if (videosLength === 9 || videosLength === 10) {\r\n height = 5;\r\n }\r\n canvas.height = remaining[0].height * height;\r\n } else {\r\n canvas.width = self.width || 360;\r\n canvas.height = self.height || 240;\r\n }\r\n\r\n if (fullcanvas && fullcanvas instanceof HTMLVideoElement) {\r\n drawImage(fullcanvas);\r\n }\r\n\r\n remaining.forEach(function(video, idx) {\r\n drawImage(video, idx);\r\n });\r\n\r\n setTimeout(drawVideosToCanvas, self.frameInterval);\r\n }\r\n\r\n function drawImage(video, idx) {\r\n if (isStopDrawingFrames) {\r\n return;\r\n }\r\n\r\n var x = 0;\r\n var y = 0;\r\n var width = video.width;\r\n var height = video.height;\r\n\r\n if (idx === 1) {\r\n x = video.width;\r\n }\r\n\r\n if (idx === 2) {\r\n y = video.height;\r\n }\r\n\r\n if (idx === 3) {\r\n x = video.width;\r\n y = video.height;\r\n }\r\n\r\n if (idx === 4) {\r\n y = video.height * 2;\r\n }\r\n\r\n if (idx === 5) {\r\n x = video.width;\r\n y = video.height * 2;\r\n }\r\n\r\n if (idx === 6) {\r\n y = video.height * 3;\r\n }\r\n\r\n if (idx === 7) {\r\n x = video.width;\r\n y = video.height * 3;\r\n }\r\n\r\n if (typeof video.stream.left !== 'undefined') {\r\n x = video.stream.left;\r\n }\r\n\r\n if (typeof video.stream.top !== 'undefined') {\r\n y = video.stream.top;\r\n }\r\n\r\n if (typeof video.stream.width !== 'undefined') {\r\n width = video.stream.width;\r\n }\r\n\r\n if (typeof video.stream.height !== 'undefined') {\r\n height = video.stream.height;\r\n }\r\n\r\n context.drawImage(video, x, y, width, height);\r\n\r\n if (typeof video.stream.onRender === 'function') {\r\n video.stream.onRender(context, x, y, width, height, idx);\r\n }\r\n }\r\n\r\n function getMixedStream() {\r\n isStopDrawingFrames = false;\r\n var mixedVideoStream = getMixedVideoStream();\r\n\r\n var mixedAudioStream = getMixedAudioStream();\r\n if (mixedAudioStream) {\r\n mixedAudioStream.getTracks().filter(function(t) {\r\n return t.kind === 'audio';\r\n }).forEach(function(track) {\r\n mixedVideoStream.addTrack(track);\r\n });\r\n }\r\n\r\n var fullcanvas;\r\n arrayOfMediaStreams.forEach(function(stream) {\r\n if (stream.fullcanvas) {\r\n fullcanvas = true;\r\n }\r\n });\r\n\r\n // mixedVideoStream.prototype.appendStreams = appendStreams;\r\n // mixedVideoStream.prototype.resetVideoStreams = resetVideoStreams;\r\n // mixedVideoStream.prototype.clearRecordedData = clearRecordedData;\r\n\r\n return mixedVideoStream;\r\n }\r\n\r\n function getMixedVideoStream() {\r\n resetVideoStreams();\r\n\r\n var capturedStream;\r\n\r\n if ('captureStream' in canvas) {\r\n capturedStream = canvas.captureStream();\r\n } else if ('mozCaptureStream' in canvas) {\r\n capturedStream = canvas.mozCaptureStream();\r\n } else if (!self.disableLogs) {\r\n console.error('Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features');\r\n }\r\n\r\n var videoStream = new MediaStream();\r\n\r\n capturedStream.getTracks().filter(function(t) {\r\n return t.kind === 'video';\r\n }).forEach(function(track) {\r\n videoStream.addTrack(track);\r\n });\r\n\r\n canvas.stream = videoStream;\r\n\r\n return videoStream;\r\n }\r\n\r\n function getMixedAudioStream() {\r\n // via: @pehrsons\r\n if (!Storage.AudioContextConstructor) {\r\n Storage.AudioContextConstructor = new Storage.AudioContext();\r\n }\r\n\r\n self.audioContext = Storage.AudioContextConstructor;\r\n\r\n self.audioSources = [];\r\n\r\n if (self.useGainNode === true) {\r\n self.gainNode = self.audioContext.createGain();\r\n self.gainNode.connect(self.audioContext.destination);\r\n self.gainNode.gain.value = 0; // don't hear self\r\n }\r\n\r\n var audioTracksLength = 0;\r\n arrayOfMediaStreams.forEach(function(stream) {\r\n if (!stream.getTracks().filter(function(t) {\r\n return t.kind === 'audio';\r\n }).length) {\r\n return;\r\n }\r\n\r\n audioTracksLength++;\r\n\r\n var audioSource = self.audioContext.createMediaStreamSource(stream);\r\n\r\n if (self.useGainNode === true) {\r\n audioSource.connect(self.gainNode);\r\n }\r\n\r\n self.audioSources.push(audioSource);\r\n });\r\n\r\n if (!audioTracksLength) {\r\n // because \"self.audioContext\" is not initialized\r\n // that's why we've to ignore rest of the code\r\n return;\r\n }\r\n\r\n self.audioDestination = self.audioContext.createMediaStreamDestination();\r\n self.audioSources.forEach(function(audioSource) {\r\n audioSource.connect(self.audioDestination);\r\n });\r\n return self.audioDestination.stream;\r\n }\r\n\r\n function getVideo(stream) {\r\n var video = document.createElement('video');\r\n\r\n setSrcObject(stream, video);\r\n\r\n video.className = elementClass;\r\n\r\n video.muted = true;\r\n video.volume = 0;\r\n\r\n video.width = stream.width || self.width || 360;\r\n video.height = stream.height || self.height || 240;\r\n\r\n video.play();\r\n\r\n return video;\r\n }\r\n\r\n this.appendStreams = function(streams) {\r\n if (!streams) {\r\n throw 'First parameter is required.';\r\n }\r\n\r\n if (!(streams instanceof Array)) {\r\n streams = [streams];\r\n }\r\n\r\n streams.forEach(function(stream) {\r\n var newStream = new MediaStream();\r\n\r\n if (stream.getTracks().filter(function(t) {\r\n return t.kind === 'video';\r\n }).length) {\r\n var video = getVideo(stream);\r\n video.stream = stream;\r\n videos.push(video);\r\n\r\n newStream.addTrack(stream.getTracks().filter(function(t) {\r\n return t.kind === 'video';\r\n })[0]);\r\n }\r\n\r\n if (stream.getTracks().filter(function(t) {\r\n return t.kind === 'audio';\r\n }).length) {\r\n var audioSource = self.audioContext.createMediaStreamSource(stream);\r\n self.audioDestination = self.audioContext.createMediaStreamDestination();\r\n audioSource.connect(self.audioDestination);\r\n\r\n newStream.addTrack(self.audioDestination.stream.getTracks().filter(function(t) {\r\n return t.kind === 'audio';\r\n })[0]);\r\n }\r\n\r\n arrayOfMediaStreams.push(newStream);\r\n });\r\n };\r\n\r\n this.releaseStreams = function() {\r\n videos = [];\r\n isStopDrawingFrames = true;\r\n\r\n if (self.gainNode) {\r\n self.gainNode.disconnect();\r\n self.gainNode = null;\r\n }\r\n\r\n if (self.audioSources.length) {\r\n self.audioSources.forEach(function(source) {\r\n source.disconnect();\r\n });\r\n self.audioSources = [];\r\n }\r\n\r\n if (self.audioDestination) {\r\n self.audioDestination.disconnect();\r\n self.audioDestination = null;\r\n }\r\n\r\n if (self.audioContext) {\r\n self.audioContext.close();\r\n }\r\n\r\n self.audioContext = null;\r\n\r\n context.clearRect(0, 0, canvas.width, canvas.height);\r\n\r\n if (canvas.stream) {\r\n canvas.stream.stop();\r\n canvas.stream = null;\r\n }\r\n };\r\n\r\n this.resetVideoStreams = function(streams) {\r\n if (streams && !(streams instanceof Array)) {\r\n streams = [streams];\r\n }\r\n\r\n resetVideoStreams(streams);\r\n };\r\n\r\n function resetVideoStreams(streams) {\r\n videos = [];\r\n streams = streams || arrayOfMediaStreams;\r\n\r\n // via: @adrian-ber\r\n streams.forEach(function(stream) {\r\n if (!stream.getTracks().filter(function(t) {\r\n return t.kind === 'video';\r\n }).length) {\r\n return;\r\n }\r\n\r\n var video = getVideo(stream);\r\n video.stream = stream;\r\n videos.push(video);\r\n });\r\n }\r\n\r\n // for debugging\r\n this.name = 'MultiStreamsMixer';\r\n this.toString = function() {\r\n return this.name;\r\n };\r\n\r\n this.getMixedStream = getMixedStream;\r\n\r\n}\r\n\r\nif (typeof RecordRTC === 'undefined') {\r\n if (typeof module !== 'undefined' /* && !!module.exports*/ ) {\r\n module.exports = MultiStreamsMixer;\r\n }\r\n\r\n if (typeof define === 'function' && define.amd) {\r\n define('MultiStreamsMixer', [], function() {\r\n return MultiStreamsMixer;\r\n });\r\n }\r\n}\n\r\n// ______________________\r\n// MultiStreamRecorder.js\r\n\r\n/*\r\n * Video conference recording, using captureStream API along with WebAudio and Canvas2D API.\r\n */\r\n\r\n/**\r\n * MultiStreamRecorder can record multiple videos in single container.\r\n * @summary Multi-videos recorder.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef MultiStreamRecorder\r\n * @class\r\n * @example\r\n * var options = {\r\n * mimeType: 'video/webm'\r\n * }\r\n * var recorder = new MultiStreamRecorder(ArrayOfMediaStreams, options);\r\n * recorder.record();\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n *\r\n * // or\r\n * var blob = recorder.blob;\r\n * });\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStreams} mediaStreams - Array of MediaStreams.\r\n * @param {object} config - {disableLogs:true, frameInterval: 1, mimeType: \"video/webm\"}\r\n */\r\n\r\nfunction MultiStreamRecorder(arrayOfMediaStreams, options) {\r\n arrayOfMediaStreams = arrayOfMediaStreams || [];\r\n var self = this;\r\n\r\n var mixer;\r\n var mediaRecorder;\r\n\r\n options = options || {\r\n elementClass: 'multi-streams-mixer',\r\n mimeType: 'video/webm',\r\n video: {\r\n width: 360,\r\n height: 240\r\n }\r\n };\r\n\r\n if (!options.frameInterval) {\r\n options.frameInterval = 10;\r\n }\r\n\r\n if (!options.video) {\r\n options.video = {};\r\n }\r\n\r\n if (!options.video.width) {\r\n options.video.width = 360;\r\n }\r\n\r\n if (!options.video.height) {\r\n options.video.height = 240;\r\n }\r\n\r\n /**\r\n * This method records all MediaStreams.\r\n * @method\r\n * @memberof MultiStreamRecorder\r\n * @example\r\n * recorder.record();\r\n */\r\n this.record = function() {\r\n // github/muaz-khan/MultiStreamsMixer\r\n mixer = new MultiStreamsMixer(arrayOfMediaStreams, options.elementClass || 'multi-streams-mixer');\r\n\r\n if (getAllVideoTracks().length) {\r\n mixer.frameInterval = options.frameInterval || 10;\r\n mixer.width = options.video.width || 360;\r\n mixer.height = options.video.height || 240;\r\n mixer.startDrawingFrames();\r\n }\r\n\r\n if (options.previewStream && typeof options.previewStream === 'function') {\r\n options.previewStream(mixer.getMixedStream());\r\n }\r\n\r\n // record using MediaRecorder API\r\n mediaRecorder = new MediaStreamRecorder(mixer.getMixedStream(), options);\r\n mediaRecorder.record();\r\n };\r\n\r\n function getAllVideoTracks() {\r\n var tracks = [];\r\n arrayOfMediaStreams.forEach(function(stream) {\r\n getTracks(stream, 'video').forEach(function(track) {\r\n tracks.push(track);\r\n });\r\n });\r\n return tracks;\r\n }\r\n\r\n /**\r\n * This method stops recording MediaStream.\r\n * @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.\r\n * @method\r\n * @memberof MultiStreamRecorder\r\n * @example\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n */\r\n this.stop = function(callback) {\r\n if (!mediaRecorder) {\r\n return;\r\n }\r\n\r\n mediaRecorder.stop(function(blob) {\r\n self.blob = blob;\r\n\r\n callback(blob);\r\n\r\n self.clearRecordedData();\r\n });\r\n };\r\n\r\n /**\r\n * This method pauses the recording process.\r\n * @method\r\n * @memberof MultiStreamRecorder\r\n * @example\r\n * recorder.pause();\r\n */\r\n this.pause = function() {\r\n if (mediaRecorder) {\r\n mediaRecorder.pause();\r\n }\r\n };\r\n\r\n /**\r\n * This method resumes the recording process.\r\n * @method\r\n * @memberof MultiStreamRecorder\r\n * @example\r\n * recorder.resume();\r\n */\r\n this.resume = function() {\r\n if (mediaRecorder) {\r\n mediaRecorder.resume();\r\n }\r\n };\r\n\r\n /**\r\n * This method resets currently recorded data.\r\n * @method\r\n * @memberof MultiStreamRecorder\r\n * @example\r\n * recorder.clearRecordedData();\r\n */\r\n this.clearRecordedData = function() {\r\n if (mediaRecorder) {\r\n mediaRecorder.clearRecordedData();\r\n mediaRecorder = null;\r\n }\r\n\r\n if (mixer) {\r\n mixer.releaseStreams();\r\n mixer = null;\r\n }\r\n };\r\n\r\n /**\r\n * Add extra media-streams to existing recordings.\r\n * @method\r\n * @memberof MultiStreamRecorder\r\n * @param {MediaStreams} mediaStreams - Array of MediaStreams\r\n * @example\r\n * recorder.addStreams([newAudioStream, newVideoStream]);\r\n */\r\n this.addStreams = function(streams) {\r\n if (!streams) {\r\n throw 'First parameter is required.';\r\n }\r\n\r\n if (!(streams instanceof Array)) {\r\n streams = [streams];\r\n }\r\n\r\n arrayOfMediaStreams.concat(streams);\r\n\r\n if (!mediaRecorder || !mixer) {\r\n return;\r\n }\r\n\r\n mixer.appendStreams(streams);\r\n\r\n if (options.previewStream && typeof options.previewStream === 'function') {\r\n options.previewStream(mixer.getMixedStream());\r\n }\r\n };\r\n\r\n /**\r\n * Reset videos during live recording. Replace old videos e.g. replace cameras with full-screen.\r\n * @method\r\n * @memberof MultiStreamRecorder\r\n * @param {MediaStreams} mediaStreams - Array of MediaStreams\r\n * @example\r\n * recorder.resetVideoStreams([newVideo1, newVideo2]);\r\n */\r\n this.resetVideoStreams = function(streams) {\r\n if (!mixer) {\r\n return;\r\n }\r\n\r\n if (streams && !(streams instanceof Array)) {\r\n streams = [streams];\r\n }\r\n\r\n mixer.resetVideoStreams(streams);\r\n };\r\n\r\n /**\r\n * Returns MultiStreamsMixer\r\n * @method\r\n * @memberof MultiStreamRecorder\r\n * @example\r\n * let mixer = recorder.getMixer();\r\n * mixer.appendStreams([newStream]);\r\n */\r\n this.getMixer = function() {\r\n return mixer;\r\n };\r\n\r\n // for debugging\r\n this.name = 'MultiStreamRecorder';\r\n this.toString = function() {\r\n return this.name;\r\n };\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.MultiStreamRecorder = MultiStreamRecorder;\r\n}\n\r\n// _____________________\r\n// RecordRTC.promises.js\r\n\r\n/**\r\n * RecordRTCPromisesHandler adds promises support in {@link RecordRTC}. Try a {@link https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/RecordRTCPromisesHandler.html|demo here}\r\n * @summary Promises for {@link RecordRTC}\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef RecordRTCPromisesHandler\r\n * @class\r\n * @example\r\n * var recorder = new RecordRTCPromisesHandler(mediaStream, options);\r\n * recorder.startRecording()\r\n * .then(successCB)\r\n * .catch(errorCB);\r\n * // Note: You can access all RecordRTC API using \"recorder.recordRTC\" e.g. \r\n * recorder.recordRTC.onStateChanged = function(state) {};\r\n * recorder.recordRTC.setRecordingDuration(5000);\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - Single media-stream object, array of media-streams, html-canvas-element, etc.\r\n * @param {object} config - {type:\"video\", recorderType: MediaStreamRecorder, disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, etc.}\r\n * @throws Will throw an error if \"new\" keyword is not used to initiate \"RecordRTCPromisesHandler\". Also throws error if first argument \"MediaStream\" is missing.\r\n * @requires {@link RecordRTC}\r\n */\r\n\r\nfunction RecordRTCPromisesHandler(mediaStream, options) {\r\n if (!this) {\r\n throw 'Use \"new RecordRTCPromisesHandler()\"';\r\n }\r\n\r\n if (typeof mediaStream === 'undefined') {\r\n throw 'First argument \"MediaStream\" is required.';\r\n }\r\n\r\n var self = this;\r\n\r\n /**\r\n * @property {Blob} blob - Access/reach the native {@link RecordRTC} object.\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * let internal = recorder.recordRTC.getInternalRecorder();\r\n * alert(internal instanceof MediaStreamRecorder);\r\n * recorder.recordRTC.onStateChanged = function(state) {};\r\n */\r\n self.recordRTC = new RecordRTC(mediaStream, options);\r\n\r\n /**\r\n * This method records MediaStream.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * recorder.startRecording()\r\n * .then(successCB)\r\n * .catch(errorCB);\r\n */\r\n this.startRecording = function() {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n self.recordRTC.startRecording();\r\n resolve();\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * This method stops the recording.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * recorder.stopRecording().then(function() {\r\n * var blob = recorder.getBlob();\r\n * }).catch(errorCB);\r\n */\r\n this.stopRecording = function() {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n self.recordRTC.stopRecording(function(url) {\r\n self.blob = self.recordRTC.getBlob();\r\n\r\n if (!self.blob || !self.blob.size) {\r\n reject('Empty blob.', self.blob);\r\n return;\r\n }\r\n\r\n resolve(url);\r\n });\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * This method pauses the recording. You can resume recording using \"resumeRecording\" method.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * recorder.pauseRecording()\r\n * .then(successCB)\r\n * .catch(errorCB);\r\n */\r\n this.pauseRecording = function() {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n self.recordRTC.pauseRecording();\r\n resolve();\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * This method resumes the recording.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * recorder.resumeRecording()\r\n * .then(successCB)\r\n * .catch(errorCB);\r\n */\r\n this.resumeRecording = function() {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n self.recordRTC.resumeRecording();\r\n resolve();\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * This method returns data-url for the recorded blob.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * recorder.stopRecording().then(function() {\r\n * recorder.getDataURL().then(function(dataURL) {\r\n * window.open(dataURL);\r\n * }).catch(errorCB);;\r\n * }).catch(errorCB);\r\n */\r\n this.getDataURL = function(callback) {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n self.recordRTC.getDataURL(function(dataURL) {\r\n resolve(dataURL);\r\n });\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * This method returns the recorded blob.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * recorder.stopRecording().then(function() {\r\n * recorder.getBlob().then(function(blob) {})\r\n * }).catch(errorCB);\r\n */\r\n this.getBlob = function() {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n resolve(self.recordRTC.getBlob());\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * This method returns the internal recording object.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * let internalRecorder = await recorder.getInternalRecorder();\r\n * if(internalRecorder instanceof MultiStreamRecorder) {\r\n * internalRecorder.addStreams([newAudioStream]);\r\n * internalRecorder.resetVideoStreams([screenStream]);\r\n * }\r\n * @returns {Object} \r\n */\r\n this.getInternalRecorder = function() {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n resolve(self.recordRTC.getInternalRecorder());\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * This method resets the recorder. So that you can reuse single recorder instance many times.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * await recorder.reset();\r\n * recorder.startRecording(); // record again\r\n */\r\n this.reset = function() {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n resolve(self.recordRTC.reset());\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * Destroy RecordRTC instance. Clear all recorders and objects.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * recorder.destroy().then(successCB).catch(errorCB);\r\n */\r\n this.destroy = function() {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n resolve(self.recordRTC.destroy());\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * Get recorder's readonly state.\r\n * @method\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * let state = await recorder.getState();\r\n * // or\r\n * recorder.getState().then(state => { console.log(state); })\r\n * @returns {String} Returns recording state.\r\n */\r\n this.getState = function() {\r\n return new Promise(function(resolve, reject) {\r\n try {\r\n resolve(self.recordRTC.getState());\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * @property {Blob} blob - Recorded data as \"Blob\" object.\r\n * @memberof RecordRTCPromisesHandler\r\n * @example\r\n * await recorder.stopRecording();\r\n * let blob = recorder.getBlob(); // or \"recorder.recordRTC.blob\"\r\n * invokeSaveAsDialog(blob);\r\n */\r\n this.blob = null;\r\n\r\n /**\r\n * RecordRTC version number\r\n * @property {String} version - Release version number.\r\n * @memberof RecordRTCPromisesHandler\r\n * @static\r\n * @readonly\r\n * @example\r\n * alert(recorder.version);\r\n */\r\n this.version = '5.5.9';\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.RecordRTCPromisesHandler = RecordRTCPromisesHandler;\r\n}\n\r\n// ______________________\r\n// WebAssemblyRecorder.js\r\n\r\n/**\r\n * WebAssemblyRecorder lets you create webm videos in JavaScript via WebAssembly. The library consumes raw RGBA32 buffers (4 bytes per pixel) and turns them into a webm video with the given framerate and quality. This makes it compatible out-of-the-box with ImageData from a CANVAS. With realtime mode you can also use webm-wasm for streaming webm videos.\r\n * @summary Video recording feature in Chrome, Firefox and maybe Edge.\r\n * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}\r\n * @author {@link https://MuazKhan.com|Muaz Khan}\r\n * @typedef WebAssemblyRecorder\r\n * @class\r\n * @example\r\n * var recorder = new WebAssemblyRecorder(mediaStream);\r\n * recorder.record();\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}\r\n * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.\r\n * @param {object} config - {webAssemblyPath:'webm-wasm.wasm',workerPath: 'webm-worker.js', frameRate: 30, width: 1920, height: 1080, bitrate: 1024}\r\n */\r\nfunction WebAssemblyRecorder(stream, config) {\r\n // based on: github.com/GoogleChromeLabs/webm-wasm\r\n\r\n if (typeof ReadableStream === 'undefined' || typeof WritableStream === 'undefined') {\r\n // because it fixes readable/writable streams issues\r\n console.error('Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js');\r\n }\r\n\r\n config = config || {};\r\n\r\n config.width = config.width || 640;\r\n config.height = config.height || 480;\r\n config.frameRate = config.frameRate || 30;\r\n config.bitrate = config.bitrate || 1200;\r\n\r\n function createBufferURL(buffer, type) {\r\n return URL.createObjectURL(new Blob([buffer], {\r\n type: type || ''\r\n }));\r\n }\r\n\r\n function cameraStream() {\r\n return new ReadableStream({\r\n start: function(controller) {\r\n var cvs = document.createElement('canvas');\r\n var video = document.createElement('video');\r\n video.srcObject = stream;\r\n video.onplaying = function() {\r\n cvs.width = config.width;\r\n cvs.height = config.height;\r\n var ctx = cvs.getContext('2d');\r\n var frameTimeout = 1000 / config.frameRate;\r\n setTimeout(function f() {\r\n ctx.drawImage(video, 0, 0);\r\n controller.enqueue(\r\n ctx.getImageData(0, 0, config.width, config.height)\r\n );\r\n setTimeout(f, frameTimeout);\r\n }, frameTimeout);\r\n };\r\n video.play();\r\n }\r\n });\r\n }\r\n\r\n var worker;\r\n\r\n function startRecording(stream, buffer) {\r\n if (!config.workerPath && !buffer) {\r\n // is it safe to use @latest ?\r\n fetch(\r\n 'https://unpkg.com/webm-wasm@latest/dist/webm-worker.js'\r\n ).then(function(r) {\r\n r.arrayBuffer().then(function(buffer) {\r\n startRecording(stream, buffer);\r\n });\r\n });\r\n return;\r\n }\r\n\r\n if (!config.workerPath && buffer instanceof ArrayBuffer) {\r\n var blob = new Blob([buffer], {\r\n type: 'text/javascript'\r\n });\r\n config.workerPath = URL.createObjectURL(blob);\r\n }\r\n\r\n if (!config.workerPath) {\r\n console.error('workerPath parameter is missing.');\r\n }\r\n\r\n worker = new Worker(config.workerPath);\r\n\r\n worker.postMessage(config.webAssemblyPath || 'https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm');\r\n worker.addEventListener('message', function(event) {\r\n if (event.data === 'READY') {\r\n worker.postMessage({\r\n width: config.width,\r\n height: config.height,\r\n bitrate: config.bitrate || 1200,\r\n timebaseDen: config.frameRate || 30,\r\n realtime: true\r\n });\r\n\r\n cameraStream().pipeTo(new WritableStream({\r\n write: function(image) {\r\n if (!worker) {\r\n return;\r\n }\r\n\r\n worker.postMessage(image.data.buffer, [image.data.buffer]);\r\n }\r\n }));\r\n } else if (!!event.data) {\r\n if (!isPaused) {\r\n arrayOfBuffers.push(event.data);\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * This method records video.\r\n * @method\r\n * @memberof WebAssemblyRecorder\r\n * @example\r\n * recorder.record();\r\n */\r\n this.record = function() {\r\n arrayOfBuffers = [];\r\n isPaused = false;\r\n this.blob = null;\r\n startRecording(stream);\r\n\r\n if (typeof config.initCallback === 'function') {\r\n config.initCallback();\r\n }\r\n };\r\n\r\n var isPaused;\r\n\r\n /**\r\n * This method pauses the recording process.\r\n * @method\r\n * @memberof WebAssemblyRecorder\r\n * @example\r\n * recorder.pause();\r\n */\r\n this.pause = function() {\r\n isPaused = true;\r\n };\r\n\r\n /**\r\n * This method resumes the recording process.\r\n * @method\r\n * @memberof WebAssemblyRecorder\r\n * @example\r\n * recorder.resume();\r\n */\r\n this.resume = function() {\r\n isPaused = false;\r\n };\r\n\r\n function terminate() {\r\n if (!worker) {\r\n return;\r\n }\r\n\r\n worker.postMessage(null);\r\n worker.terminate();\r\n worker = null;\r\n }\r\n\r\n var arrayOfBuffers = [];\r\n\r\n /**\r\n * This method stops recording video.\r\n * @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.\r\n * @method\r\n * @memberof WebAssemblyRecorder\r\n * @example\r\n * recorder.stop(function(blob) {\r\n * video.src = URL.createObjectURL(blob);\r\n * });\r\n */\r\n this.stop = function(callback) {\r\n terminate();\r\n\r\n this.blob = new Blob(arrayOfBuffers, {\r\n type: 'video/webm'\r\n });\r\n\r\n callback(this.blob);\r\n };\r\n\r\n // for debugging\r\n this.name = 'WebAssemblyRecorder';\r\n this.toString = function() {\r\n return this.name;\r\n };\r\n\r\n /**\r\n * This method resets currently recorded data.\r\n * @method\r\n * @memberof WebAssemblyRecorder\r\n * @example\r\n * recorder.clearRecordedData();\r\n */\r\n this.clearRecordedData = function() {\r\n arrayOfBuffers = [];\r\n isPaused = false;\r\n this.blob = null;\r\n\r\n // todo: if recording-ON then STOP it first\r\n };\r\n\r\n /**\r\n * @property {Blob} blob - The recorded blob object.\r\n * @memberof WebAssemblyRecorder\r\n * @example\r\n * recorder.stop(function(){\r\n * var blob = recorder.blob;\r\n * });\r\n */\r\n this.blob = null;\r\n}\r\n\r\nif (typeof RecordRTC !== 'undefined') {\r\n RecordRTC.WebAssemblyRecorder = WebAssemblyRecorder;\r\n}\n","'use strict';\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n exports.default = void 0;\n \n var _RightOutlined = _interopRequireDefault(require('./lib/icons/RightOutlined'));\n \n function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n \n var _default = _RightOutlined;\n exports.default = _default;\n module.exports = _default;","'use strict';\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n exports.default = void 0;\n \n var _LeftOutlined = _interopRequireDefault(require('./lib/icons/LeftOutlined'));\n \n function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n \n var _default = _LeftOutlined;\n exports.default = _default;\n module.exports = _default;","import React, { Component } from 'react';\nimport _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';\nimport PropTypes from 'prop-types';\nimport warning from 'tiny-warning';\n\nvar MAX_SIGNED_31_BIT_INT = 1073741823;\nvar commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};\n\nfunction getUniqueId() {\n var key = '__global_unique_id__';\n return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;\n}\n\nfunction objectIs(x, y) {\n if (x === y) {\n return x !== 0 || 1 / x === 1 / y;\n } else {\n return x !== x && y !== y;\n }\n}\n\nfunction createEventEmitter(value) {\n var handlers = [];\n return {\n on: function on(handler) {\n handlers.push(handler);\n },\n off: function off(handler) {\n handlers = handlers.filter(function (h) {\n return h !== handler;\n });\n },\n get: function get() {\n return value;\n },\n set: function set(newValue, changedBits) {\n value = newValue;\n handlers.forEach(function (handler) {\n return handler(value, changedBits);\n });\n }\n };\n}\n\nfunction onlyChild(children) {\n return Array.isArray(children) ? children[0] : children;\n}\n\nfunction createReactContext(defaultValue, calculateChangedBits) {\n var _Provider$childContex, _Consumer$contextType;\n\n var contextProp = '__create-react-context-' + getUniqueId() + '__';\n\n var Provider = /*#__PURE__*/function (_Component) {\n _inheritsLoose(Provider, _Component);\n\n function Provider() {\n var _this;\n\n _this = _Component.apply(this, arguments) || this;\n _this.emitter = createEventEmitter(_this.props.value);\n return _this;\n }\n\n var _proto = Provider.prototype;\n\n _proto.getChildContext = function getChildContext() {\n var _ref;\n\n return _ref = {}, _ref[contextProp] = this.emitter, _ref;\n };\n\n _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {\n if (this.props.value !== nextProps.value) {\n var oldValue = this.props.value;\n var newValue = nextProps.value;\n var changedBits;\n\n if (objectIs(oldValue, newValue)) {\n changedBits = 0;\n } else {\n changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;\n\n if (process.env.NODE_ENV !== 'production') {\n warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: ' + changedBits);\n }\n\n changedBits |= 0;\n\n if (changedBits !== 0) {\n this.emitter.set(nextProps.value, changedBits);\n }\n }\n }\n };\n\n _proto.render = function render() {\n return this.props.children;\n };\n\n return Provider;\n }(Component);\n\n Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = PropTypes.object.isRequired, _Provider$childContex);\n\n var Consumer = /*#__PURE__*/function (_Component2) {\n _inheritsLoose(Consumer, _Component2);\n\n function Consumer() {\n var _this2;\n\n _this2 = _Component2.apply(this, arguments) || this;\n _this2.state = {\n value: _this2.getValue()\n };\n\n _this2.onUpdate = function (newValue, changedBits) {\n var observedBits = _this2.observedBits | 0;\n\n if ((observedBits & changedBits) !== 0) {\n _this2.setState({\n value: _this2.getValue()\n });\n }\n };\n\n return _this2;\n }\n\n var _proto2 = Consumer.prototype;\n\n _proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {\n var observedBits = nextProps.observedBits;\n this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;\n };\n\n _proto2.componentDidMount = function componentDidMount() {\n if (this.context[contextProp]) {\n this.context[contextProp].on(this.onUpdate);\n }\n\n var observedBits = this.props.observedBits;\n this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;\n };\n\n _proto2.componentWillUnmount = function componentWillUnmount() {\n if (this.context[contextProp]) {\n this.context[contextProp].off(this.onUpdate);\n }\n };\n\n _proto2.getValue = function getValue() {\n if (this.context[contextProp]) {\n return this.context[contextProp].get();\n } else {\n return defaultValue;\n }\n };\n\n _proto2.render = function render() {\n return onlyChild(this.props.children)(this.state.value);\n };\n\n return Consumer;\n }(Component);\n\n Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = PropTypes.object, _Consumer$contextType);\n return {\n Provider: Provider,\n Consumer: Consumer\n };\n}\n\nvar index = React.createContext || createReactContext;\n\nexport default index;\n","var isarray = require('isarray')\n\n/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \"/:test(\\\\d+)?\" => [\"/\", \"test\", \"\\d+\", undefined, \"?\", undefined]\n // \"/route(\\\\d+)\" => [undefined, undefined, undefined, \"\\d+\", undefined, undefined]\n // \"/*\" => [\"/\", undefined, undefined, undefined, undefined, \"*\"]\n '([\\\\/.])?(?:(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?|(\\\\*))'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = options && options.delimiter || '/'\n var res\n\n while ((res = PATH_REGEXP.exec(str)) != null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n continue\n }\n\n var next = str[index]\n var prefix = res[2]\n var name = res[3]\n var capture = res[4]\n var group = res[5]\n var modifier = res[6]\n var asterisk = res[7]\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n }\n\n var partial = prefix != null && next != null && next !== prefix\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var delimiter = res[2] || defaultDelimiter\n var pattern = capture || group\n\n tokens.push({\n name: name || key++,\n prefix: prefix || '',\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n partial: partial,\n asterisk: !!asterisk,\n pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')\n })\n }\n\n // Match any characters still remaining.\n if (index < str.length) {\n path += str.substr(index)\n }\n\n // If the path exists, push it onto the end.\n if (path) {\n tokens.push(path)\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options), options)\n}\n\n/**\n * Prettier encoding of URI path segments.\n *\n * @param {string}\n * @return {string}\n */\nfunction encodeURIComponentPretty (str) {\n return encodeURI(str).replace(/[\\/?#]/g, function (c) {\n return '%' + c.charCodeAt(0).toString(16).toUpperCase()\n })\n}\n\n/**\n * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.\n *\n * @param {string}\n * @return {string}\n */\nfunction encodeAsterisk (str) {\n return encodeURI(str).replace(/[?#]/g, function (c) {\n return '%' + c.charCodeAt(0).toString(16).toUpperCase()\n })\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens, options) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options))\n }\n }\n\n return function (obj, opts) {\n var path = ''\n var data = obj || {}\n var options = opts || {}\n var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n\n continue\n }\n\n var value = data[token.name]\n var segment\n\n if (value == null) {\n if (token.optional) {\n // Prepend partial segment prefixes.\n if (token.partial) {\n path += token.prefix\n }\n\n continue\n } else {\n throw new TypeError('Expected \"' + token.name + '\" to be defined')\n }\n }\n\n if (isarray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but received `' + JSON.stringify(value) + '`')\n }\n\n if (value.length === 0) {\n if (token.optional) {\n continue\n } else {\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j])\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\", but received `' + JSON.stringify(segment) + '`')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n segment = token.asterisk ? encodeAsterisk(value) : encode(value)\n\n if (!matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but received \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|\\/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$\\/()])/g, '\\\\$1')\n}\n\n/**\n * Attach the keys as a property of the regexp.\n *\n * @param {!RegExp} re\n * @param {Array} keys\n * @return {!RegExp}\n */\nfunction attachKeys (re, keys) {\n re.keys = keys\n return re\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {!Array} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n partial: false,\n asterisk: false,\n pattern: null\n })\n }\n }\n\n return attachKeys(path, keys)\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array} keys\n * @param {!Object} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options))\n\n return attachKeys(regexp, keys)\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {!Array} keys\n * @param {!Object} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {(Array|Object)=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n if (!isarray(keys)) {\n options = /** @type {!Object} */ (keys || options)\n keys = []\n }\n\n options = options || {}\n\n var strict = options.strict\n var end = options.end !== false\n var route = ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var prefix = escapeString(token.prefix)\n var capture = '(?:' + token.pattern + ')'\n\n keys.push(token)\n\n if (token.repeat) {\n capture += '(?:' + prefix + capture + ')*'\n }\n\n if (token.optional) {\n if (!token.partial) {\n capture = '(?:' + prefix + '(' + capture + '))?'\n } else {\n capture = prefix + '(' + capture + ')?'\n }\n } else {\n capture = prefix + '(' + capture + ')'\n }\n\n route += capture\n }\n }\n\n var delimiter = escapeString(options.delimiter || '/')\n var endsWithDelimiter = route.slice(-delimiter.length) === delimiter\n\n // In non-strict mode we allow a slash at the end of match. If the path to\n // match already ends with a slash, we remove it for consistency. The slash\n // is valid at the end of a path match, not in the middle. This is important\n // in non-ending mode, where \"/test/\" shouldn't match \"/test//route\".\n if (!strict) {\n route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?'\n }\n\n if (end) {\n route += '$'\n } else {\n // In non-ending mode, we need the capturing groups to match as much as\n // possible by using a positive lookahead to the end or next path segment.\n route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)'\n }\n\n return attachKeys(new RegExp('^' + route, flags(options)), keys)\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {(Array|Object)=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (!isarray(keys)) {\n options = /** @type {!Object} */ (keys || options)\n keys = []\n }\n\n options = options || {}\n\n if (path instanceof RegExp) {\n return regexpToRegexp(path, /** @type {!Array} */ (keys))\n }\n\n if (isarray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)\n}\n","function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport * as React from 'react';\nimport classNames from 'classnames'; // @ts-ignore\n\nimport CSSMotion from \"rc-animate/es/CSSMotion\";\nimport TreeNode from './TreeNode';\nimport { getTreeNodeProps } from './utils/treeUtil';\nimport { TreeContext } from './contextTypes';\n\nvar MotionTreeNode = function MotionTreeNode(_ref, ref) {\n var className = _ref.className,\n style = _ref.style,\n motion = _ref.motion,\n motionNodes = _ref.motionNodes,\n motionType = _ref.motionType,\n onMotionEnd = _ref.onMotionEnd,\n active = _ref.active,\n treeNodeRequiredProps = _ref.treeNodeRequiredProps,\n props = _objectWithoutProperties(_ref, [\"className\", \"style\", \"motion\", \"motionNodes\", \"motionType\", \"onMotionEnd\", \"active\", \"treeNodeRequiredProps\"]);\n\n var _React$useState = React.useState(true),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n visible = _React$useState2[0],\n setVisible = _React$useState2[1];\n\n var _React$useContext = React.useContext(TreeContext),\n prefixCls = _React$useContext.prefixCls;\n\n React.useEffect(function () {\n if (motionNodes && motionType === 'hide' && visible) {\n setVisible(false);\n }\n }, [motionNodes]);\n\n if (motionNodes) {\n return React.createElement(CSSMotion, Object.assign({\n ref: ref,\n visible: visible\n }, motion, {\n motionAppear: motionType === 'show',\n onAppearEnd: onMotionEnd,\n onLeaveEnd: onMotionEnd\n }), function (_ref2, motionRef) {\n var motionClassName = _ref2.className,\n motionStyle = _ref2.style;\n return React.createElement(\"div\", {\n ref: motionRef,\n className: classNames(\"\".concat(prefixCls, \"-treenode-motion\"), motionClassName),\n style: motionStyle\n }, motionNodes.map(function (treeNode) {\n var _treeNode$data = treeNode.data,\n key = _treeNode$data.key,\n restProps = _objectWithoutProperties(_treeNode$data, [\"key\"]),\n isStart = treeNode.isStart,\n isEnd = treeNode.isEnd;\n\n delete restProps.children;\n var treeNodeProps = getTreeNodeProps(key, treeNodeRequiredProps);\n return React.createElement(TreeNode, Object.assign({}, restProps, treeNodeProps, {\n active: active,\n data: treeNode.data,\n key: key,\n isStart: isStart,\n isEnd: isEnd\n }));\n }));\n });\n }\n\n return React.createElement(TreeNode, Object.assign({\n domRef: ref,\n className: className,\n style: style\n }, props, {\n active: active\n }));\n};\n\nMotionTreeNode.displayName = 'MotionTreeNode';\nvar RefMotionTreeNode = React.forwardRef(MotionTreeNode);\nexport default RefMotionTreeNode;","export function findExpandedKeys() {\n var prev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var next = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var prevLen = prev.length;\n var nextLen = next.length;\n\n if (Math.abs(prevLen - nextLen) !== 1) {\n return {\n add: false,\n key: null\n };\n }\n\n function find(shorter, longer) {\n var cache = new Map();\n shorter.forEach(function (key) {\n cache.set(key, true);\n });\n var keys = longer.filter(function (key) {\n return !cache.has(key);\n });\n return keys.length === 1 ? keys[0] : null;\n }\n\n if (prevLen < nextLen) {\n return {\n add: true,\n key: find(prev, next)\n };\n }\n\n return {\n add: false,\n key: find(next, prev)\n };\n}\nexport function getExpandRange(shorter, longer, key) {\n var shorterStartIndex = shorter.findIndex(function (_ref) {\n var data = _ref.data;\n return data.key === key;\n });\n var shorterEndNode = shorter[shorterStartIndex + 1];\n var longerStartIndex = longer.findIndex(function (_ref2) {\n var data = _ref2.data;\n return data.key === key;\n });\n\n if (shorterEndNode) {\n var longerEndIndex = longer.findIndex(function (_ref3) {\n var data = _ref3.data;\n return data.key === shorterEndNode.data.key;\n });\n return longer.slice(longerStartIndex + 1, longerEndIndex);\n }\n\n return longer.slice(longerStartIndex + 1);\n}","function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/**\n * Handle virtual list of the TreeNodes.\n */\nimport * as React from 'react';\nimport VirtualList from 'rc-virtual-list';\nimport MotionTreeNode from './MotionTreeNode';\nimport { findExpandedKeys, getExpandRange } from './utils/diffUtil';\nimport { getTreeNodeProps, getKey } from './utils/treeUtil';\nvar HIDDEN_STYLE = {\n width: 0,\n height: 0,\n display: 'flex',\n overflow: 'hidden',\n opacity: 0,\n border: 0,\n padding: 0,\n margin: 0\n};\n\nvar noop = function noop() {};\n\nexport var MOTION_KEY = \"RC_TREE_MOTION_\".concat(Math.random());\nvar MotionNode = {\n key: MOTION_KEY\n};\nexport var MotionEntity = {\n key: MOTION_KEY,\n level: 0,\n index: 0,\n pos: '0',\n node: MotionNode\n};\nvar MotionFlattenData = {\n parent: null,\n children: [],\n pos: MotionEntity.pos,\n data: MotionNode,\n\n /** Hold empty list here since we do not use it */\n isStart: [],\n isEnd: []\n};\n/**\n * We only need get visible content items to play the animation.\n */\n\nexport function getMinimumRangeTransitionRange(list, height, itemHeight) {\n if (!height) {\n return list;\n }\n\n return list.slice(0, Math.ceil(height / itemHeight) + 1);\n}\n\nfunction itemKey(item) {\n var key = item.data.key,\n pos = item.pos;\n return getKey(key, pos);\n}\n\nfunction getAccessibilityPath(item) {\n var path = String(item.data.key);\n var current = item;\n\n while (current.parent) {\n current = current.parent;\n path = \"\".concat(current.data.key, \" > \").concat(path);\n }\n\n return path;\n}\n\nvar RefNodeList = function RefNodeList(props, ref) {\n var prefixCls = props.prefixCls,\n data = props.data,\n selectable = props.selectable,\n checkable = props.checkable,\n expandedKeys = props.expandedKeys,\n selectedKeys = props.selectedKeys,\n checkedKeys = props.checkedKeys,\n loadedKeys = props.loadedKeys,\n loadingKeys = props.loadingKeys,\n halfCheckedKeys = props.halfCheckedKeys,\n keyEntities = props.keyEntities,\n disabled = props.disabled,\n dragging = props.dragging,\n dragOverNodeKey = props.dragOverNodeKey,\n dropPosition = props.dropPosition,\n motion = props.motion,\n height = props.height,\n itemHeight = props.itemHeight,\n virtual = props.virtual,\n focusable = props.focusable,\n activeItem = props.activeItem,\n focused = props.focused,\n tabIndex = props.tabIndex,\n onKeyDown = props.onKeyDown,\n onFocus = props.onFocus,\n onBlur = props.onBlur,\n onActiveChange = props.onActiveChange,\n domProps = _objectWithoutProperties(props, [\"prefixCls\", \"data\", \"selectable\", \"checkable\", \"expandedKeys\", \"selectedKeys\", \"checkedKeys\", \"loadedKeys\", \"loadingKeys\", \"halfCheckedKeys\", \"keyEntities\", \"disabled\", \"dragging\", \"dragOverNodeKey\", \"dropPosition\", \"motion\", \"height\", \"itemHeight\", \"virtual\", \"focusable\", \"activeItem\", \"focused\", \"tabIndex\", \"onKeyDown\", \"onFocus\", \"onBlur\", \"onActiveChange\"]); // =============================== Ref ================================\n\n\n var listRef = React.useRef(null);\n React.useImperativeHandle(ref, function () {\n return {\n scrollTo: function scrollTo(scroll) {\n listRef.current.scrollTo(scroll);\n }\n };\n }); // ============================== Motion ==============================\n\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n disableVirtual = _React$useState2[0],\n setDisableVirtual = _React$useState2[1];\n\n var _React$useState3 = React.useState(expandedKeys),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n prevExpandedKeys = _React$useState4[0],\n setPrevExpandedKeys = _React$useState4[1];\n\n var _React$useState5 = React.useState(data),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n prevData = _React$useState6[0],\n setPrevData = _React$useState6[1];\n\n var _React$useState7 = React.useState(data),\n _React$useState8 = _slicedToArray(_React$useState7, 2),\n transitionData = _React$useState8[0],\n setTransitionData = _React$useState8[1];\n\n var _React$useState9 = React.useState([]),\n _React$useState10 = _slicedToArray(_React$useState9, 2),\n transitionRange = _React$useState10[0],\n setTransitionRange = _React$useState10[1];\n\n var _React$useState11 = React.useState(null),\n _React$useState12 = _slicedToArray(_React$useState11, 2),\n motionType = _React$useState12[0],\n setMotionType = _React$useState12[1];\n\n function onMotionEnd() {\n setPrevData(data);\n setTransitionData(data);\n setTransitionRange([]);\n setMotionType(null);\n setDisableVirtual(false);\n } // Do animation if expanded keys changed\n\n\n React.useEffect(function () {\n setPrevExpandedKeys(expandedKeys);\n var diffExpanded = findExpandedKeys(prevExpandedKeys, expandedKeys);\n\n if (diffExpanded.key !== null) {\n if (diffExpanded.add) {\n var keyIndex = prevData.findIndex(function (_ref) {\n var key = _ref.data.key;\n return key === diffExpanded.key;\n });\n if (motion) setDisableVirtual(true);\n var rangeNodes = getMinimumRangeTransitionRange(getExpandRange(prevData, data, diffExpanded.key), height, itemHeight);\n var newTransitionData = prevData.slice();\n newTransitionData.splice(keyIndex + 1, 0, MotionFlattenData);\n setTransitionData(newTransitionData);\n setTransitionRange(rangeNodes);\n setMotionType('show');\n } else {\n var _keyIndex = data.findIndex(function (_ref2) {\n var key = _ref2.data.key;\n return key === diffExpanded.key;\n });\n\n if (motion) setDisableVirtual(true);\n\n var _rangeNodes = getMinimumRangeTransitionRange(getExpandRange(data, prevData, diffExpanded.key), height, itemHeight);\n\n var _newTransitionData = data.slice();\n\n _newTransitionData.splice(_keyIndex + 1, 0, MotionFlattenData);\n\n setTransitionData(_newTransitionData);\n setTransitionRange(_rangeNodes);\n setMotionType('hide');\n }\n } else if (prevData !== data) {\n // If whole data changed, we just refresh the list\n setPrevData(data);\n setTransitionData(data);\n }\n }, [expandedKeys, data]); // We should clean up motion if is changed by dragging\n\n React.useEffect(function () {\n if (!dragging) {\n onMotionEnd();\n }\n }, [dragging]);\n var mergedData = motion ? transitionData : data;\n var treeNodeRequiredProps = {\n expandedKeys: expandedKeys,\n selectedKeys: selectedKeys,\n loadedKeys: loadedKeys,\n loadingKeys: loadingKeys,\n checkedKeys: checkedKeys,\n halfCheckedKeys: halfCheckedKeys,\n dragOverNodeKey: dragOverNodeKey,\n dropPosition: dropPosition,\n keyEntities: keyEntities\n };\n return React.createElement(React.Fragment, null, focused && activeItem && React.createElement(\"span\", {\n style: HIDDEN_STYLE,\n \"aria-live\": \"assertive\"\n }, getAccessibilityPath(activeItem)), React.createElement(\"div\", {\n role: \"tree\"\n }, React.createElement(\"input\", {\n style: HIDDEN_STYLE,\n disabled: focusable === false || disabled,\n tabIndex: focusable !== false ? tabIndex : null,\n onKeyDown: onKeyDown,\n onFocus: onFocus,\n onBlur: onBlur,\n value: \"\",\n onChange: noop\n })), React.createElement(VirtualList, Object.assign({}, domProps, {\n disabled: disableVirtual,\n data: mergedData,\n itemKey: itemKey,\n height: height,\n fullHeight: false,\n virtual: virtual,\n itemHeight: itemHeight,\n onSkipRender: onMotionEnd,\n prefixCls: \"\".concat(prefixCls, \"-list\"),\n ref: listRef\n }), function (treeNode) {\n var pos = treeNode.pos,\n _treeNode$data = treeNode.data,\n key = _treeNode$data.key,\n restProps = _objectWithoutProperties(_treeNode$data, [\"key\"]),\n isStart = treeNode.isStart,\n isEnd = treeNode.isEnd;\n\n var mergedKey = getKey(key, pos);\n delete restProps.children;\n var treeNodeProps = getTreeNodeProps(mergedKey, treeNodeRequiredProps);\n return React.createElement(MotionTreeNode, Object.assign({}, restProps, treeNodeProps, {\n active: activeItem && key === activeItem.data.key,\n pos: pos,\n data: treeNode.data,\n isStart: isStart,\n isEnd: isEnd,\n motion: motion,\n motionNodes: key === MOTION_KEY ? transitionRange : null,\n motionType: motionType,\n onMotionEnd: onMotionEnd,\n treeNodeRequiredProps: treeNodeRequiredProps,\n onMouseMove: function onMouseMove() {\n onActiveChange(null);\n }\n }));\n }));\n};\n\nvar NodeList = React.forwardRef(RefNodeList);\nNodeList.displayName = 'NodeList';\nexport default NodeList;","function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n// TODO: https://www.w3.org/TR/2017/NOTE-wai-aria-practices-1.1-20171214/examples/treeview/treeview-2/treeview-2a.html\n// Fully accessibility support\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport warning from \"rc-util/es/warning\";\nimport classNames from 'classnames';\nimport { polyfill } from 'react-lifecycles-compat';\nimport { TreeContext } from './contextTypes';\nimport { getDataAndAria, getDragNodesKeys, parseCheckedKeys, conductExpandParent, calcSelectedKeys, calcDropPosition, arrAdd, arrDel, posToArr } from './util';\nimport { flattenTreeData, convertTreeToData, convertDataToEntities, warningWithoutKey, convertNodePropsToEventData, getTreeNodeProps } from './utils/treeUtil';\nimport NodeList, { MOTION_KEY, MotionEntity } from './NodeList';\nimport TreeNode from './TreeNode';\nimport { conductCheck } from './utils/conductUtil';\nvar keyPropType = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);\n\nvar Tree = /*#__PURE__*/function (_React$Component) {\n _inherits(Tree, _React$Component);\n\n function Tree() {\n var _this;\n\n _classCallCheck(this, Tree);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Tree).apply(this, arguments));\n _this.state = {\n keyEntities: {},\n selectedKeys: [],\n checkedKeys: [],\n halfCheckedKeys: [],\n loadedKeys: [],\n loadingKeys: [],\n expandedKeys: [],\n dragging: false,\n dragNodesKeys: [],\n dragOverNodeKey: null,\n dropPosition: null,\n treeData: [],\n flattenNodes: [],\n focused: false,\n activeKey: null,\n prevProps: null\n };\n _this.listRef = React.createRef();\n\n _this.onNodeDragStart = function (event, node) {\n var _this$state = _this.state,\n expandedKeys = _this$state.expandedKeys,\n keyEntities = _this$state.keyEntities;\n var onDragStart = _this.props.onDragStart;\n var eventKey = node.props.eventKey;\n _this.dragNode = node;\n\n _this.setState({\n dragging: true,\n dragNodesKeys: getDragNodesKeys(eventKey, keyEntities),\n expandedKeys: arrDel(expandedKeys, eventKey)\n });\n\n if (onDragStart) {\n onDragStart({\n event: event,\n node: convertNodePropsToEventData(node.props)\n });\n }\n };\n /**\n * [Legacy] Select handler is less small than node,\n * so that this will trigger when drag enter node or select handler.\n * This is a little tricky if customize css without padding.\n * Better for use mouse move event to refresh drag state.\n * But let's just keep it to avoid event trigger logic change.\n */\n\n\n _this.onNodeDragEnter = function (event, node) {\n var _this$state2 = _this.state,\n expandedKeys = _this$state2.expandedKeys,\n keyEntities = _this$state2.keyEntities;\n var onDragEnter = _this.props.onDragEnter;\n var _node$props = node.props,\n pos = _node$props.pos,\n eventKey = _node$props.eventKey;\n if (!_this.dragNode) return;\n var dropPosition = calcDropPosition(event, node); // Skip if drag node is self\n\n if (_this.dragNode.props.eventKey === eventKey && dropPosition === 0) {\n _this.setState({\n dragOverNodeKey: '',\n dropPosition: null\n });\n\n return;\n } // Ref: https://github.com/react-component/tree/issues/132\n // Add timeout to let onDragLevel fire before onDragEnter,\n // so that we can clean drag props for onDragLeave node.\n // Macro task for this:\n // https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-script\n\n\n setTimeout(function () {\n // Update drag over node\n _this.setState({\n dragOverNodeKey: eventKey,\n dropPosition: dropPosition\n }); // Side effect for delay drag\n\n\n if (!_this.delayedDragEnterLogic) {\n _this.delayedDragEnterLogic = {};\n }\n\n Object.keys(_this.delayedDragEnterLogic).forEach(function (key) {\n clearTimeout(_this.delayedDragEnterLogic[key]);\n });\n _this.delayedDragEnterLogic[pos] = window.setTimeout(function () {\n if (!_this.state.dragging) return;\n\n var newExpandedKeys = _toConsumableArray(expandedKeys);\n\n var entity = keyEntities[eventKey];\n\n if (entity && (entity.children || []).length) {\n newExpandedKeys = arrAdd(expandedKeys, eventKey);\n }\n\n if (!('expandedKeys' in _this.props)) {\n _this.setState({\n expandedKeys: newExpandedKeys\n });\n }\n\n if (onDragEnter) {\n onDragEnter({\n event: event,\n node: convertNodePropsToEventData(node.props),\n expandedKeys: newExpandedKeys\n });\n }\n }, 400);\n }, 0);\n };\n\n _this.onNodeDragOver = function (event, node) {\n var onDragOver = _this.props.onDragOver;\n var eventKey = node.props.eventKey; // Update drag position\n\n if (_this.dragNode && eventKey === _this.state.dragOverNodeKey) {\n var dropPosition = calcDropPosition(event, node);\n if (dropPosition === _this.state.dropPosition) return;\n\n _this.setState({\n dropPosition: dropPosition\n });\n }\n\n if (onDragOver) {\n onDragOver({\n event: event,\n node: convertNodePropsToEventData(node.props)\n });\n }\n };\n\n _this.onNodeDragLeave = function (event, node) {\n var onDragLeave = _this.props.onDragLeave;\n\n _this.setState({\n dragOverNodeKey: ''\n });\n\n if (onDragLeave) {\n onDragLeave({\n event: event,\n node: convertNodePropsToEventData(node.props)\n });\n }\n };\n\n _this.onNodeDragEnd = function (event, node) {\n var onDragEnd = _this.props.onDragEnd;\n\n _this.setState({\n dragOverNodeKey: ''\n });\n\n _this.cleanDragState();\n\n if (onDragEnd) {\n onDragEnd({\n event: event,\n node: convertNodePropsToEventData(node.props)\n });\n }\n\n _this.dragNode = null;\n };\n\n _this.onNodeDrop = function (event, node) {\n var _this$state3 = _this.state,\n _this$state3$dragNode = _this$state3.dragNodesKeys,\n dragNodesKeys = _this$state3$dragNode === void 0 ? [] : _this$state3$dragNode,\n dropPosition = _this$state3.dropPosition;\n var onDrop = _this.props.onDrop;\n var _node$props2 = node.props,\n eventKey = _node$props2.eventKey,\n pos = _node$props2.pos;\n\n _this.setState({\n dragOverNodeKey: ''\n });\n\n _this.cleanDragState();\n\n if (dragNodesKeys.indexOf(eventKey) !== -1) {\n warning(false, \"Can not drop to dragNode(include it's children node)\");\n return;\n }\n\n var posArr = posToArr(pos);\n var dropResult = {\n event: event,\n node: convertNodePropsToEventData(node.props),\n dragNode: convertNodePropsToEventData(_this.dragNode.props),\n dragNodesKeys: dragNodesKeys.slice(),\n dropPosition: dropPosition + Number(posArr[posArr.length - 1]),\n dropToGap: false\n };\n\n if (dropPosition !== 0) {\n dropResult.dropToGap = true;\n }\n\n if (onDrop) {\n onDrop(dropResult);\n }\n\n _this.dragNode = null;\n };\n\n _this.cleanDragState = function () {\n var dragging = _this.state.dragging;\n\n if (dragging) {\n _this.setState({\n dragging: false\n });\n }\n };\n\n _this.onNodeClick = function (e, treeNode) {\n var onClick = _this.props.onClick;\n\n if (onClick) {\n onClick(e, treeNode);\n }\n };\n\n _this.onNodeDoubleClick = function (e, treeNode) {\n var onDoubleClick = _this.props.onDoubleClick;\n\n if (onDoubleClick) {\n onDoubleClick(e, treeNode);\n }\n };\n\n _this.onNodeSelect = function (e, treeNode) {\n var selectedKeys = _this.state.selectedKeys;\n var keyEntities = _this.state.keyEntities;\n var _this$props = _this.props,\n onSelect = _this$props.onSelect,\n multiple = _this$props.multiple;\n var selected = treeNode.selected,\n key = treeNode.key;\n var targetSelected = !selected; // Update selected keys\n\n if (!targetSelected) {\n selectedKeys = arrDel(selectedKeys, key);\n } else if (!multiple) {\n selectedKeys = [key];\n } else {\n selectedKeys = arrAdd(selectedKeys, key);\n } // [Legacy] Not found related usage in doc or upper libs\n\n\n var selectedNodes = selectedKeys.map(function (selectedKey) {\n var entity = keyEntities[selectedKey];\n if (!entity) return null;\n return entity.node;\n }).filter(function (node) {\n return node;\n });\n\n _this.setUncontrolledState({\n selectedKeys: selectedKeys\n });\n\n if (onSelect) {\n onSelect(selectedKeys, {\n event: 'select',\n selected: targetSelected,\n node: treeNode,\n selectedNodes: selectedNodes,\n nativeEvent: e.nativeEvent\n });\n }\n };\n\n _this.onNodeCheck = function (e, treeNode, checked) {\n var _this$state4 = _this.state,\n keyEntities = _this$state4.keyEntities,\n oriCheckedKeys = _this$state4.checkedKeys,\n oriHalfCheckedKeys = _this$state4.halfCheckedKeys;\n var _this$props2 = _this.props,\n checkStrictly = _this$props2.checkStrictly,\n onCheck = _this$props2.onCheck;\n var key = treeNode.key; // Prepare trigger arguments\n\n var checkedObj;\n var eventObj = {\n event: 'check',\n node: treeNode,\n checked: checked,\n nativeEvent: e.nativeEvent\n };\n\n if (checkStrictly) {\n var checkedKeys = checked ? arrAdd(oriCheckedKeys, key) : arrDel(oriCheckedKeys, key);\n var halfCheckedKeys = arrDel(oriHalfCheckedKeys, key);\n checkedObj = {\n checked: checkedKeys,\n halfChecked: halfCheckedKeys\n };\n eventObj.checkedNodes = checkedKeys.map(function (checkedKey) {\n return keyEntities[checkedKey];\n }).filter(function (entity) {\n return entity;\n }).map(function (entity) {\n return entity.node;\n });\n\n _this.setUncontrolledState({\n checkedKeys: checkedKeys\n });\n } else {\n // Always fill first\n var _conductCheck = conductCheck([].concat(_toConsumableArray(oriCheckedKeys), [key]), true, keyEntities),\n _checkedKeys = _conductCheck.checkedKeys,\n _halfCheckedKeys = _conductCheck.halfCheckedKeys; // If remove, we do it again to correction\n\n\n if (!checked) {\n var keySet = new Set(_checkedKeys);\n keySet.delete(key);\n\n var _conductCheck2 = conductCheck(Array.from(keySet), {\n checked: false,\n halfCheckedKeys: _halfCheckedKeys\n }, keyEntities);\n\n _checkedKeys = _conductCheck2.checkedKeys;\n _halfCheckedKeys = _conductCheck2.halfCheckedKeys;\n }\n\n checkedObj = _checkedKeys; // [Legacy] This is used for `rc-tree-select`\n\n eventObj.checkedNodes = [];\n eventObj.checkedNodesPositions = [];\n eventObj.halfCheckedKeys = _halfCheckedKeys;\n\n _checkedKeys.forEach(function (checkedKey) {\n var entity = keyEntities[checkedKey];\n if (!entity) return;\n var node = entity.node,\n pos = entity.pos;\n eventObj.checkedNodes.push(node);\n eventObj.checkedNodesPositions.push({\n node: node,\n pos: pos\n });\n });\n\n _this.setUncontrolledState({\n checkedKeys: _checkedKeys\n }, false, {\n halfCheckedKeys: _halfCheckedKeys\n });\n }\n\n if (onCheck) {\n onCheck(checkedObj, eventObj);\n }\n };\n\n _this.onNodeLoad = function (treeNode) {\n return new Promise(function (resolve) {\n // We need to get the latest state of loading/loaded keys\n _this.setState(function (_ref) {\n var _ref$loadedKeys = _ref.loadedKeys,\n loadedKeys = _ref$loadedKeys === void 0 ? [] : _ref$loadedKeys,\n _ref$loadingKeys = _ref.loadingKeys,\n loadingKeys = _ref$loadingKeys === void 0 ? [] : _ref$loadingKeys;\n var _this$props3 = _this.props,\n loadData = _this$props3.loadData,\n onLoad = _this$props3.onLoad;\n var key = treeNode.key;\n\n if (!loadData || loadedKeys.indexOf(key) !== -1 || loadingKeys.indexOf(key) !== -1) {\n // react 15 will warn if return null\n return {};\n } // Process load data\n\n\n var promise = loadData(treeNode);\n promise.then(function () {\n var _this$state5 = _this.state,\n currentLoadedKeys = _this$state5.loadedKeys,\n currentLoadingKeys = _this$state5.loadingKeys;\n var newLoadedKeys = arrAdd(currentLoadedKeys, key);\n var newLoadingKeys = arrDel(currentLoadingKeys, key); // onLoad should trigger before internal setState to avoid `loadData` trigger twice.\n // https://github.com/ant-design/ant-design/issues/12464\n\n if (onLoad) {\n onLoad(newLoadedKeys, {\n event: 'load',\n node: treeNode\n });\n }\n\n _this.setUncontrolledState({\n loadedKeys: newLoadedKeys\n });\n\n _this.setState({\n loadingKeys: newLoadingKeys\n });\n\n resolve();\n });\n return {\n loadingKeys: arrAdd(loadingKeys, key)\n };\n });\n });\n };\n\n _this.onNodeExpand = function (e, treeNode) {\n var expandedKeys = _this.state.expandedKeys;\n var treeData = _this.state.treeData;\n var _this$props4 = _this.props,\n onExpand = _this$props4.onExpand,\n loadData = _this$props4.loadData;\n var key = treeNode.key,\n expanded = treeNode.expanded; // Update selected keys\n\n var index = expandedKeys.indexOf(key);\n var targetExpanded = !expanded;\n warning(expanded && index !== -1 || !expanded && index === -1, 'Expand state not sync with index check');\n\n if (targetExpanded) {\n expandedKeys = arrAdd(expandedKeys, key);\n } else {\n expandedKeys = arrDel(expandedKeys, key);\n }\n\n var flattenNodes = flattenTreeData(treeData, expandedKeys);\n\n _this.setUncontrolledState({\n expandedKeys: expandedKeys,\n flattenNodes: flattenNodes\n }, true);\n\n if (onExpand) {\n onExpand(expandedKeys, {\n node: treeNode,\n expanded: targetExpanded,\n nativeEvent: e.nativeEvent\n });\n } // Async Load data\n\n\n if (targetExpanded && loadData) {\n var loadPromise = _this.onNodeLoad(treeNode);\n\n return loadPromise ? loadPromise.then(function () {\n // [Legacy] Refresh logic\n var newFlattenTreeData = flattenTreeData(_this.state.treeData, expandedKeys);\n\n _this.setUncontrolledState({\n flattenNodes: newFlattenTreeData\n });\n }) : null;\n }\n\n return null;\n };\n\n _this.onNodeMouseEnter = function (event, node) {\n var onMouseEnter = _this.props.onMouseEnter;\n\n if (onMouseEnter) {\n onMouseEnter({\n event: event,\n node: node\n });\n }\n };\n\n _this.onNodeMouseLeave = function (event, node) {\n var onMouseLeave = _this.props.onMouseLeave;\n\n if (onMouseLeave) {\n onMouseLeave({\n event: event,\n node: node\n });\n }\n };\n\n _this.onNodeContextMenu = function (event, node) {\n var onRightClick = _this.props.onRightClick;\n\n if (onRightClick) {\n event.preventDefault();\n onRightClick({\n event: event,\n node: node\n });\n }\n };\n\n _this.onFocus = function () {\n var onFocus = _this.props.onFocus;\n\n _this.setState({\n focused: true\n });\n\n if (onFocus) {\n onFocus.apply(void 0, arguments);\n }\n };\n\n _this.onBlur = function () {\n var onBlur = _this.props.onBlur;\n\n _this.setState({\n focused: false\n });\n\n _this.onActiveChange(null);\n\n if (onBlur) {\n onBlur.apply(void 0, arguments);\n }\n };\n\n _this.getTreeNodeRequiredProps = function () {\n var _this$state6 = _this.state,\n expandedKeys = _this$state6.expandedKeys,\n selectedKeys = _this$state6.selectedKeys,\n loadedKeys = _this$state6.loadedKeys,\n loadingKeys = _this$state6.loadingKeys,\n checkedKeys = _this$state6.checkedKeys,\n halfCheckedKeys = _this$state6.halfCheckedKeys,\n dragOverNodeKey = _this$state6.dragOverNodeKey,\n dropPosition = _this$state6.dropPosition,\n keyEntities = _this$state6.keyEntities;\n return {\n expandedKeys: expandedKeys || [],\n selectedKeys: selectedKeys || [],\n loadedKeys: loadedKeys || [],\n loadingKeys: loadingKeys || [],\n checkedKeys: checkedKeys || [],\n halfCheckedKeys: halfCheckedKeys || [],\n dragOverNodeKey: dragOverNodeKey,\n dropPosition: dropPosition,\n keyEntities: keyEntities\n };\n }; // =========================== Keyboard ===========================\n\n\n _this.onActiveChange = function (newActiveKey) {\n var activeKey = _this.state.activeKey;\n var onActiveChange = _this.props.onActiveChange;\n\n if (activeKey === newActiveKey) {\n return;\n }\n\n _this.setState({\n activeKey: newActiveKey\n });\n\n if (newActiveKey !== null) {\n _this.scrollTo({\n key: newActiveKey\n });\n }\n\n if (onActiveChange) {\n onActiveChange(newActiveKey);\n }\n };\n\n _this.getActiveItem = function () {\n var _this$state7 = _this.state,\n activeKey = _this$state7.activeKey,\n flattenNodes = _this$state7.flattenNodes;\n\n if (activeKey === null) {\n return null;\n }\n\n return flattenNodes.find(function (_ref2) {\n var key = _ref2.data.key;\n return key === activeKey;\n }) || null;\n };\n\n _this.offsetActiveKey = function (offset) {\n var _this$state8 = _this.state,\n flattenNodes = _this$state8.flattenNodes,\n activeKey = _this$state8.activeKey;\n var index = flattenNodes.findIndex(function (_ref3) {\n var key = _ref3.data.key;\n return key === activeKey;\n }); // Align with index\n\n if (index === -1 && offset < 0) {\n index = flattenNodes.length;\n }\n\n index = (index + offset + flattenNodes.length) % flattenNodes.length;\n var item = flattenNodes[index];\n\n if (item) {\n var key = item.data.key;\n\n _this.onActiveChange(key);\n } else {\n _this.onActiveChange(null);\n }\n };\n\n _this.onKeyDown = function (event) {\n var _this$state9 = _this.state,\n activeKey = _this$state9.activeKey,\n expandedKeys = _this$state9.expandedKeys,\n checkedKeys = _this$state9.checkedKeys;\n var _this$props5 = _this.props,\n onKeyDown = _this$props5.onKeyDown,\n checkable = _this$props5.checkable,\n selectable = _this$props5.selectable; // >>>>>>>>>> Direction\n\n switch (event.which) {\n case KeyCode.UP:\n {\n _this.offsetActiveKey(-1);\n\n event.preventDefault();\n break;\n }\n\n case KeyCode.DOWN:\n {\n _this.offsetActiveKey(1);\n\n event.preventDefault();\n break;\n }\n } // >>>>>>>>>> Expand & Selection\n\n\n var activeItem = _this.getActiveItem();\n\n if (activeItem && activeItem.data) {\n var treeNodeRequiredProps = _this.getTreeNodeRequiredProps();\n\n var expandable = activeItem.data.isLeaf === false || !!(activeItem.data.children || []).length;\n var eventNode = convertNodePropsToEventData(_objectSpread({}, getTreeNodeProps(activeKey, treeNodeRequiredProps), {\n data: activeItem.data,\n active: true\n }));\n\n switch (event.which) {\n // >>> Expand\n case KeyCode.LEFT:\n {\n // Collapse if possible\n if (expandable && expandedKeys.includes(activeKey)) {\n _this.onNodeExpand({}, eventNode);\n } else if (activeItem.parent) {\n _this.onActiveChange(activeItem.parent.data.key);\n }\n\n event.preventDefault();\n break;\n }\n\n case KeyCode.RIGHT:\n {\n // Expand if possible\n if (expandable && !expandedKeys.includes(activeKey)) {\n _this.onNodeExpand({}, eventNode);\n } else if (activeItem.children && activeItem.children.length) {\n _this.onActiveChange(activeItem.children[0].data.key);\n }\n\n event.preventDefault();\n break;\n }\n // Selection\n\n case KeyCode.ENTER:\n case KeyCode.SPACE:\n {\n if (checkable && !eventNode.disabled && eventNode.checkable !== false && !eventNode.disableCheckbox) {\n _this.onNodeCheck({}, eventNode, !checkedKeys.includes(activeKey));\n } else if (!checkable && selectable && !eventNode.disabled && eventNode.selectable !== false) {\n _this.onNodeSelect({}, eventNode);\n }\n\n break;\n }\n }\n }\n\n if (onKeyDown) {\n onKeyDown(event);\n }\n };\n /**\n * Only update the value which is not in props\n */\n\n\n _this.setUncontrolledState = function (state) {\n var atomic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var forceState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n var needSync = false;\n var allPassed = true;\n var newState = {};\n Object.keys(state).forEach(function (name) {\n if (name in _this.props) {\n allPassed = false;\n return;\n }\n\n needSync = true;\n newState[name] = state[name];\n });\n\n if (needSync && (!atomic || allPassed)) {\n _this.setState(_objectSpread({}, newState, {}, forceState));\n }\n };\n\n _this.scrollTo = function (scroll) {\n _this.listRef.current.scrollTo(scroll);\n };\n\n return _this;\n }\n\n _createClass(Tree, [{\n key: \"render\",\n value: function render() {\n var _classNames;\n\n var _this$state10 = this.state,\n focused = _this$state10.focused,\n flattenNodes = _this$state10.flattenNodes,\n keyEntities = _this$state10.keyEntities,\n dragging = _this$state10.dragging,\n activeKey = _this$state10.activeKey;\n var _this$props6 = this.props,\n prefixCls = _this$props6.prefixCls,\n className = _this$props6.className,\n style = _this$props6.style,\n showLine = _this$props6.showLine,\n focusable = _this$props6.focusable,\n _this$props6$tabIndex = _this$props6.tabIndex,\n tabIndex = _this$props6$tabIndex === void 0 ? 0 : _this$props6$tabIndex,\n selectable = _this$props6.selectable,\n showIcon = _this$props6.showIcon,\n icon = _this$props6.icon,\n switcherIcon = _this$props6.switcherIcon,\n draggable = _this$props6.draggable,\n checkable = _this$props6.checkable,\n checkStrictly = _this$props6.checkStrictly,\n disabled = _this$props6.disabled,\n motion = _this$props6.motion,\n loadData = _this$props6.loadData,\n filterTreeNode = _this$props6.filterTreeNode,\n height = _this$props6.height,\n itemHeight = _this$props6.itemHeight,\n virtual = _this$props6.virtual;\n var domProps = getDataAndAria(this.props);\n return React.createElement(TreeContext.Provider, {\n value: {\n prefixCls: prefixCls,\n selectable: selectable,\n showIcon: showIcon,\n icon: icon,\n switcherIcon: switcherIcon,\n draggable: draggable,\n checkable: checkable,\n checkStrictly: checkStrictly,\n disabled: disabled,\n keyEntities: keyEntities,\n loadData: loadData,\n filterTreeNode: filterTreeNode,\n onNodeClick: this.onNodeClick,\n onNodeDoubleClick: this.onNodeDoubleClick,\n onNodeExpand: this.onNodeExpand,\n onNodeSelect: this.onNodeSelect,\n onNodeCheck: this.onNodeCheck,\n onNodeLoad: this.onNodeLoad,\n onNodeMouseEnter: this.onNodeMouseEnter,\n onNodeMouseLeave: this.onNodeMouseLeave,\n onNodeContextMenu: this.onNodeContextMenu,\n onNodeDragStart: this.onNodeDragStart,\n onNodeDragEnter: this.onNodeDragEnter,\n onNodeDragOver: this.onNodeDragOver,\n onNodeDragLeave: this.onNodeDragLeave,\n onNodeDragEnd: this.onNodeDragEnd,\n onNodeDrop: this.onNodeDrop\n }\n }, React.createElement(\"div\", {\n className: classNames(prefixCls, className, (_classNames = {}, _defineProperty(_classNames, \"\".concat(prefixCls, \"-show-line\"), showLine), _defineProperty(_classNames, \"\".concat(prefixCls, \"-focused\"), focused), _defineProperty(_classNames, \"\".concat(prefixCls, \"-active-focused\"), activeKey !== null), _classNames))\n }, React.createElement(NodeList, Object.assign({\n ref: this.listRef,\n prefixCls: prefixCls,\n style: style,\n data: flattenNodes,\n disabled: disabled,\n selectable: selectable,\n checkable: !!checkable,\n motion: motion,\n dragging: dragging,\n height: height,\n itemHeight: itemHeight,\n virtual: virtual,\n focusable: focusable,\n focused: focused,\n tabIndex: tabIndex,\n activeItem: this.getActiveItem(),\n onFocus: this.onFocus,\n onBlur: this.onBlur,\n onKeyDown: this.onKeyDown,\n onActiveChange: this.onActiveChange\n }, this.getTreeNodeRequiredProps(), domProps))));\n }\n }], [{\n key: \"getDerivedStateFromProps\",\n value: function getDerivedStateFromProps(props, prevState) {\n var prevProps = prevState.prevProps;\n var newState = {\n prevProps: props\n };\n\n function needSync(name) {\n return !prevProps && name in props || prevProps && prevProps[name] !== props[name];\n } // ================== Tree Node ==================\n\n\n var treeData; // Check if `treeData` or `children` changed and save into the state.\n\n if (needSync('treeData')) {\n treeData = props.treeData;\n } else if (needSync('children')) {\n warning(false, '`children` of Tree is deprecated. Please use `treeData` instead.');\n treeData = convertTreeToData(props.children);\n } // Save flatten nodes info and convert `treeData` into keyEntities\n\n\n if (treeData) {\n newState.treeData = treeData;\n var entitiesMap = convertDataToEntities(treeData);\n newState.keyEntities = _objectSpread(_defineProperty({}, MOTION_KEY, MotionEntity), entitiesMap.keyEntities); // Warning if treeNode not provide key\n\n if (process.env.NODE_ENV !== 'production') {\n warningWithoutKey(treeData);\n }\n }\n\n var keyEntities = newState.keyEntities || prevState.keyEntities; // ================ expandedKeys =================\n\n if (needSync('expandedKeys') || prevProps && needSync('autoExpandParent')) {\n newState.expandedKeys = props.autoExpandParent || !prevProps && props.defaultExpandParent ? conductExpandParent(props.expandedKeys, keyEntities) : props.expandedKeys;\n } else if (!prevProps && props.defaultExpandAll) {\n var cloneKeyEntities = _objectSpread({}, keyEntities);\n\n delete cloneKeyEntities[MOTION_KEY];\n newState.expandedKeys = Object.keys(cloneKeyEntities).map(function (key) {\n return cloneKeyEntities[key].key;\n });\n } else if (!prevProps && props.defaultExpandedKeys) {\n newState.expandedKeys = props.autoExpandParent || props.defaultExpandParent ? conductExpandParent(props.defaultExpandedKeys, keyEntities) : props.defaultExpandedKeys;\n }\n\n if (!newState.expandedKeys) {\n delete newState.expandedKeys;\n } // ================ flattenNodes =================\n\n\n if (treeData || newState.expandedKeys) {\n var flattenNodes = flattenTreeData(treeData || prevState.treeData, newState.expandedKeys || prevState.expandedKeys);\n newState.flattenNodes = flattenNodes;\n } // ================ selectedKeys =================\n\n\n if (props.selectable) {\n if (needSync('selectedKeys')) {\n newState.selectedKeys = calcSelectedKeys(props.selectedKeys, props);\n } else if (!prevProps && props.defaultSelectedKeys) {\n newState.selectedKeys = calcSelectedKeys(props.defaultSelectedKeys, props);\n }\n } // ================= checkedKeys =================\n\n\n if (props.checkable) {\n var checkedKeyEntity;\n\n if (needSync('checkedKeys')) {\n checkedKeyEntity = parseCheckedKeys(props.checkedKeys) || {};\n } else if (!prevProps && props.defaultCheckedKeys) {\n checkedKeyEntity = parseCheckedKeys(props.defaultCheckedKeys) || {};\n } else if (treeData) {\n // If `treeData` changed, we also need check it\n checkedKeyEntity = parseCheckedKeys(props.checkedKeys) || {\n checkedKeys: prevState.checkedKeys,\n halfCheckedKeys: prevState.halfCheckedKeys\n };\n }\n\n if (checkedKeyEntity) {\n var _checkedKeyEntity = checkedKeyEntity,\n _checkedKeyEntity$che = _checkedKeyEntity.checkedKeys,\n checkedKeys = _checkedKeyEntity$che === void 0 ? [] : _checkedKeyEntity$che,\n _checkedKeyEntity$hal = _checkedKeyEntity.halfCheckedKeys,\n halfCheckedKeys = _checkedKeyEntity$hal === void 0 ? [] : _checkedKeyEntity$hal;\n\n if (!props.checkStrictly) {\n var conductKeys = conductCheck(checkedKeys, true, keyEntities);\n checkedKeys = conductKeys.checkedKeys;\n halfCheckedKeys = conductKeys.halfCheckedKeys;\n }\n\n newState.checkedKeys = checkedKeys;\n newState.halfCheckedKeys = halfCheckedKeys;\n }\n } // ================= loadedKeys ==================\n\n\n if (needSync('loadedKeys')) {\n newState.loadedKeys = props.loadedKeys;\n }\n\n return newState;\n }\n }]);\n\n return Tree;\n}(React.Component);\n\nTree.propTypes = {\n prefixCls: PropTypes.string,\n className: PropTypes.string,\n style: PropTypes.object,\n tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n children: PropTypes.any,\n treeData: PropTypes.array,\n showLine: PropTypes.bool,\n showIcon: PropTypes.bool,\n icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n selectable: PropTypes.bool,\n disabled: PropTypes.bool,\n multiple: PropTypes.bool,\n checkable: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),\n checkStrictly: PropTypes.bool,\n draggable: PropTypes.bool,\n defaultExpandParent: PropTypes.bool,\n autoExpandParent: PropTypes.bool,\n defaultExpandAll: PropTypes.bool,\n defaultExpandedKeys: PropTypes.arrayOf(keyPropType),\n expandedKeys: PropTypes.arrayOf(keyPropType),\n defaultCheckedKeys: PropTypes.arrayOf(keyPropType),\n checkedKeys: PropTypes.oneOfType([PropTypes.arrayOf(keyPropType), PropTypes.object]),\n defaultSelectedKeys: PropTypes.arrayOf(keyPropType),\n selectedKeys: PropTypes.arrayOf(keyPropType),\n onClick: PropTypes.func,\n onDoubleClick: PropTypes.func,\n onExpand: PropTypes.func,\n onCheck: PropTypes.func,\n onSelect: PropTypes.func,\n onLoad: PropTypes.func,\n loadData: PropTypes.func,\n loadedKeys: PropTypes.arrayOf(keyPropType),\n onMouseEnter: PropTypes.func,\n onMouseLeave: PropTypes.func,\n onRightClick: PropTypes.func,\n onDragStart: PropTypes.func,\n onDragEnter: PropTypes.func,\n onDragOver: PropTypes.func,\n onDragLeave: PropTypes.func,\n onDragEnd: PropTypes.func,\n onDrop: PropTypes.func,\n filterTreeNode: PropTypes.func,\n motion: PropTypes.object,\n switcherIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])\n};\nTree.defaultProps = {\n prefixCls: 'rc-tree',\n showLine: false,\n showIcon: true,\n selectable: true,\n multiple: false,\n checkable: false,\n disabled: false,\n checkStrictly: false,\n draggable: false,\n defaultExpandParent: true,\n autoExpandParent: false,\n defaultExpandAll: false,\n defaultExpandedKeys: [],\n defaultCheckedKeys: [],\n defaultSelectedKeys: []\n};\nTree.TreeNode = TreeNode;\npolyfill(Tree);\nexport default Tree;","import Tree from './Tree';\nimport TreeNode from './TreeNode';\nexport { TreeNode };\nexport default Tree;","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","module.exports = !require('./_descriptors') && !require('./_fails')(function () {\n return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;\n});\n","var isObject = require('./_is-object');\nvar document = require('./_global').document;\n// typeof document.createElement is 'object' in old IE\nvar is = isObject(document) && isObject(document.createElement);\nmodule.exports = function (it) {\n return is ? document.createElement(it) : {};\n};\n","var has = require('./_has');\nvar toIObject = require('./_to-iobject');\nvar arrayIndexOf = require('./_array-includes')(false);\nvar IE_PROTO = require('./_shared-key')('IE_PROTO');\n\nmodule.exports = function (object, names) {\n var O = toIObject(object);\n var i = 0;\n var result = [];\n var key;\n for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);\n // Don't enum bug & hidden keys\n while (names.length > i) if (has(O, key = names[i++])) {\n ~arrayIndexOf(result, key) || result.push(key);\n }\n return result;\n};\n","// fallback for non-array-like ES3 and non-enumerable old V8 strings\nvar cof = require('./_cof');\n// eslint-disable-next-line no-prototype-builtins\nmodule.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {\n return cof(it) == 'String' ? it.split('') : Object(it);\n};\n","// 7.1.15 ToLength\nvar toInteger = require('./_to-integer');\nvar min = Math.min;\nmodule.exports = function (it) {\n return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991\n};\n","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _utils = require(\"../utils\");\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar twoToneColorPalette = {\n primaryColor: '#333',\n secondaryColor: '#E6E6E6',\n calculated: false\n};\n\nfunction setTwoToneColors(_ref) {\n var primaryColor = _ref.primaryColor,\n secondaryColor = _ref.secondaryColor;\n twoToneColorPalette.primaryColor = primaryColor;\n twoToneColorPalette.secondaryColor = secondaryColor || (0, _utils.getSecondaryColor)(primaryColor);\n twoToneColorPalette.calculated = !!secondaryColor;\n}\n\nfunction getTwoToneColors() {\n return _objectSpread({}, twoToneColorPalette);\n}\n\nvar IconBase = function IconBase(props) {\n var icon = props.icon,\n className = props.className,\n onClick = props.onClick,\n style = props.style,\n primaryColor = props.primaryColor,\n secondaryColor = props.secondaryColor,\n restProps = _objectWithoutProperties(props, [\"icon\", \"className\", \"onClick\", \"style\", \"primaryColor\", \"secondaryColor\"]);\n\n var colors = twoToneColorPalette;\n\n if (primaryColor) {\n colors = {\n primaryColor: primaryColor,\n secondaryColor: secondaryColor || (0, _utils.getSecondaryColor)(primaryColor)\n };\n }\n\n (0, _utils.useInsertStyles)();\n (0, _utils.warning)((0, _utils.isIconDefinition)(icon), \"icon should be icon definiton, but got \".concat(icon));\n\n if (!(0, _utils.isIconDefinition)(icon)) {\n return null;\n }\n\n var target = icon;\n\n if (target && typeof target.icon === 'function') {\n target = _objectSpread({}, target, {\n icon: target.icon(colors.primaryColor, colors.secondaryColor)\n });\n }\n\n return (0, _utils.generate)(target.icon, \"svg-\".concat(target.name), _objectSpread({\n className: className,\n onClick: onClick,\n style: style,\n 'data-icon': target.name,\n width: '1em',\n height: '1em',\n fill: 'currentColor',\n 'aria-hidden': 'true'\n }, restProps));\n};\n\nIconBase.displayName = 'IconReact';\nIconBase.getTwoToneColors = getTwoToneColors;\nIconBase.setTwoToneColors = setTwoToneColors;\nvar _default = IconBase;\nexports.default = _default;","module.exports = { \"default\": require(\"core-js/library/fn/object/define-property\"), __esModule: true };","\"use strict\";\n\nexports.__esModule = true;\n\nvar _iterator = require(\"../core-js/symbol/iterator\");\n\nvar _iterator2 = _interopRequireDefault(_iterator);\n\nvar _symbol = require(\"../core-js/symbol\");\n\nvar _symbol2 = _interopRequireDefault(_symbol);\n\nvar _typeof = typeof _symbol2.default === \"function\" && typeof _iterator2.default === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === \"function\" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? \"symbol\" : typeof obj; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = typeof _symbol2.default === \"function\" && _typeof(_iterator2.default) === \"symbol\" ? function (obj) {\n return typeof obj === \"undefined\" ? \"undefined\" : _typeof(obj);\n} : function (obj) {\n return obj && typeof _symbol2.default === \"function\" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? \"symbol\" : typeof obj === \"undefined\" ? \"undefined\" : _typeof(obj);\n};","'use strict';\nvar $at = require('./_string-at')(true);\n\n// 21.1.3.27 String.prototype[@@iterator]()\nrequire('./_iter-define')(String, 'String', function (iterated) {\n this._t = String(iterated); // target\n this._i = 0; // next index\n// 21.1.5.2.1 %StringIteratorPrototype%.next()\n}, function () {\n var O = this._t;\n var index = this._i;\n var point;\n if (index >= O.length) return { value: undefined, done: true };\n point = $at(O, index);\n this._i += point.length;\n return { value: point, done: false };\n});\n","'use strict';\nvar LIBRARY = require('./_library');\nvar $export = require('./_export');\nvar redefine = require('./_redefine');\nvar hide = require('./_hide');\nvar Iterators = require('./_iterators');\nvar $iterCreate = require('./_iter-create');\nvar setToStringTag = require('./_set-to-string-tag');\nvar getPrototypeOf = require('./_object-gpo');\nvar ITERATOR = require('./_wks')('iterator');\nvar BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`\nvar FF_ITERATOR = '@@iterator';\nvar KEYS = 'keys';\nvar VALUES = 'values';\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {\n $iterCreate(Constructor, NAME, next);\n var getMethod = function (kind) {\n if (!BUGGY && kind in proto) return proto[kind];\n switch (kind) {\n case KEYS: return function keys() { return new Constructor(this, kind); };\n case VALUES: return function values() { return new Constructor(this, kind); };\n } return function entries() { return new Constructor(this, kind); };\n };\n var TAG = NAME + ' Iterator';\n var DEF_VALUES = DEFAULT == VALUES;\n var VALUES_BUG = false;\n var proto = Base.prototype;\n var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];\n var $default = $native || getMethod(DEFAULT);\n var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;\n var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;\n var methods, key, IteratorPrototype;\n // Fix native\n if ($anyNative) {\n IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));\n if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {\n // Set @@toStringTag to native iterators\n setToStringTag(IteratorPrototype, TAG, true);\n // fix for some old engines\n if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);\n }\n }\n // fix Array#{values, @@iterator}.name in V8 / FF\n if (DEF_VALUES && $native && $native.name !== VALUES) {\n VALUES_BUG = true;\n $default = function values() { return $native.call(this); };\n }\n // Define iterator\n if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {\n hide(proto, ITERATOR, $default);\n }\n // Plug for library\n Iterators[NAME] = $default;\n Iterators[TAG] = returnThis;\n if (DEFAULT) {\n methods = {\n values: DEF_VALUES ? $default : getMethod(VALUES),\n keys: IS_SET ? $default : getMethod(KEYS),\n entries: $entries\n };\n if (FORCED) for (key in methods) {\n if (!(key in proto)) redefine(proto, key, methods[key]);\n } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);\n }\n return methods;\n};\n","module.exports = require('./_hide');\n","// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)\nvar has = require('./_has');\nvar toObject = require('./_to-object');\nvar IE_PROTO = require('./_shared-key')('IE_PROTO');\nvar ObjectProto = Object.prototype;\n\nmodule.exports = Object.getPrototypeOf || function (O) {\n O = toObject(O);\n if (has(O, IE_PROTO)) return O[IE_PROTO];\n if (typeof O.constructor == 'function' && O instanceof O.constructor) {\n return O.constructor.prototype;\n } return O instanceof Object ? ObjectProto : null;\n};\n","// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)\nvar $keys = require('./_object-keys-internal');\nvar hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');\n\nexports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {\n return $keys(O, hiddenKeys);\n};\n","import { __extends } from \"tslib\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { RenderTargetCreationOptions } from \"../Materials/Textures/renderTargetCreationOptions\";\r\nimport { InternalTexture, InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport { DataBuffer } from '../Meshes/dataBuffer';\r\n/**\r\n * Options to create the null engine\r\n */\r\nvar NullEngineOptions = /** @class */ (function () {\r\n function NullEngineOptions() {\r\n /**\r\n * Render width (Default: 512)\r\n */\r\n this.renderWidth = 512;\r\n /**\r\n * Render height (Default: 256)\r\n */\r\n this.renderHeight = 256;\r\n /**\r\n * Texture size (Default: 512)\r\n */\r\n this.textureSize = 512;\r\n /**\r\n * If delta time between frames should be constant\r\n * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep\r\n */\r\n this.deterministicLockstep = false;\r\n /**\r\n * Maximum about of steps between frames (Default: 4)\r\n * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep\r\n */\r\n this.lockstepMaxSteps = 4;\r\n }\r\n return NullEngineOptions;\r\n}());\r\nexport { NullEngineOptions };\r\n/**\r\n * The null engine class provides support for headless version of babylon.js.\r\n * This can be used in server side scenario or for testing purposes\r\n */\r\nvar NullEngine = /** @class */ (function (_super) {\r\n __extends(NullEngine, _super);\r\n function NullEngine(options) {\r\n if (options === void 0) { options = new NullEngineOptions(); }\r\n var _this = _super.call(this, null) || this;\r\n Engine.Instances.push(_this);\r\n if (options.deterministicLockstep === undefined) {\r\n options.deterministicLockstep = false;\r\n }\r\n if (options.lockstepMaxSteps === undefined) {\r\n options.lockstepMaxSteps = 4;\r\n }\r\n _this._options = options;\r\n // Init caps\r\n // We consider we are on a webgl1 capable device\r\n _this._caps = {\r\n maxTexturesImageUnits: 16,\r\n maxVertexTextureImageUnits: 16,\r\n maxCombinedTexturesImageUnits: 32,\r\n maxTextureSize: 512,\r\n maxCubemapTextureSize: 512,\r\n maxRenderTextureSize: 512,\r\n maxVertexAttribs: 16,\r\n maxVaryingVectors: 16,\r\n maxFragmentUniformVectors: 16,\r\n maxVertexUniformVectors: 16,\r\n standardDerivatives: false,\r\n astc: null,\r\n pvrtc: null,\r\n etc1: null,\r\n etc2: null,\r\n maxAnisotropy: 0,\r\n uintIndices: false,\r\n fragmentDepthSupported: false,\r\n highPrecisionShaderSupported: true,\r\n colorBufferFloat: false,\r\n textureFloat: false,\r\n textureFloatLinearFiltering: false,\r\n textureFloatRender: false,\r\n textureHalfFloat: false,\r\n textureHalfFloatLinearFiltering: false,\r\n textureHalfFloatRender: false,\r\n textureLOD: false,\r\n drawBuffersExtension: false,\r\n depthTextureExtension: false,\r\n vertexArrayObject: false,\r\n instancedArrays: false,\r\n canUseTimestampForTimerQuery: false,\r\n maxMSAASamples: 1,\r\n blendMinMax: false\r\n };\r\n Logger.Log(\"Babylon.js v\" + Engine.Version + \" - Null engine\");\r\n // Wrappers\r\n var theCurrentGlobal = (typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : window);\r\n if (typeof URL === \"undefined\") {\r\n theCurrentGlobal.URL = {\r\n createObjectURL: function () { },\r\n revokeObjectURL: function () { }\r\n };\r\n }\r\n if (typeof Blob === \"undefined\") {\r\n theCurrentGlobal.Blob = function () { };\r\n }\r\n return _this;\r\n }\r\n /**\r\n * Gets a boolean indicating that the engine is running in deterministic lock step mode\r\n * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep\r\n * @returns true if engine is in deterministic lock step mode\r\n */\r\n NullEngine.prototype.isDeterministicLockStep = function () {\r\n return this._options.deterministicLockstep;\r\n };\r\n /**\r\n * Gets the max steps when engine is running in deterministic lock step\r\n * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep\r\n * @returns the max steps\r\n */\r\n NullEngine.prototype.getLockstepMaxSteps = function () {\r\n return this._options.lockstepMaxSteps;\r\n };\r\n /**\r\n * Gets the current hardware scaling level.\r\n * By default the hardware scaling level is computed from the window device ratio.\r\n * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.\r\n * @returns a number indicating the current hardware scaling level\r\n */\r\n NullEngine.prototype.getHardwareScalingLevel = function () {\r\n return 1.0;\r\n };\r\n /**\r\n * Creates a vertex buffer\r\n * @param vertices the data for the vertex buffer\r\n * @returns the new WebGL static buffer\r\n */\r\n NullEngine.prototype.createVertexBuffer = function (vertices) {\r\n var buffer = new DataBuffer();\r\n buffer.references = 1;\r\n return buffer;\r\n };\r\n /**\r\n * Creates a new index buffer\r\n * @param indices defines the content of the index buffer\r\n * @param updatable defines if the index buffer must be updatable\r\n * @returns a new webGL buffer\r\n */\r\n NullEngine.prototype.createIndexBuffer = function (indices) {\r\n var buffer = new DataBuffer();\r\n buffer.references = 1;\r\n return buffer;\r\n };\r\n /**\r\n * Clear the current render buffer or the current render target (if any is set up)\r\n * @param color defines the color to use\r\n * @param backBuffer defines if the back buffer must be cleared\r\n * @param depth defines if the depth buffer must be cleared\r\n * @param stencil defines if the stencil buffer must be cleared\r\n */\r\n NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {\r\n if (stencil === void 0) { stencil = false; }\r\n };\r\n /**\r\n * Gets the current render width\r\n * @param useScreen defines if screen size must be used (or the current render target if any)\r\n * @returns a number defining the current render width\r\n */\r\n NullEngine.prototype.getRenderWidth = function (useScreen) {\r\n if (useScreen === void 0) { useScreen = false; }\r\n if (!useScreen && this._currentRenderTarget) {\r\n return this._currentRenderTarget.width;\r\n }\r\n return this._options.renderWidth;\r\n };\r\n /**\r\n * Gets the current render height\r\n * @param useScreen defines if screen size must be used (or the current render target if any)\r\n * @returns a number defining the current render height\r\n */\r\n NullEngine.prototype.getRenderHeight = function (useScreen) {\r\n if (useScreen === void 0) { useScreen = false; }\r\n if (!useScreen && this._currentRenderTarget) {\r\n return this._currentRenderTarget.height;\r\n }\r\n return this._options.renderHeight;\r\n };\r\n /**\r\n * Set the WebGL's viewport\r\n * @param viewport defines the viewport element to be used\r\n * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used\r\n * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used\r\n */\r\n NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {\r\n this._cachedViewport = viewport;\r\n };\r\n NullEngine.prototype.createShaderProgram = function (pipelineContext, vertexCode, fragmentCode, defines, context) {\r\n return {\r\n __SPECTOR_rebuildProgram: null,\r\n };\r\n };\r\n /**\r\n * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names\r\n * @param pipelineContext defines the pipeline context to use\r\n * @param uniformsNames defines the list of uniform names\r\n * @returns an array of webGL uniform locations\r\n */\r\n NullEngine.prototype.getUniforms = function (pipelineContext, uniformsNames) {\r\n return [];\r\n };\r\n /**\r\n * Gets the lsit of active attributes for a given webGL program\r\n * @param pipelineContext defines the pipeline context to use\r\n * @param attributesNames defines the list of attribute names to get\r\n * @returns an array of indices indicating the offset of each attribute\r\n */\r\n NullEngine.prototype.getAttributes = function (pipelineContext, attributesNames) {\r\n return [];\r\n };\r\n /**\r\n * Binds an effect to the webGL context\r\n * @param effect defines the effect to bind\r\n */\r\n NullEngine.prototype.bindSamplers = function (effect) {\r\n this._currentEffect = null;\r\n };\r\n /**\r\n * Activates an effect, mkaing it the current one (ie. the one used for rendering)\r\n * @param effect defines the effect to activate\r\n */\r\n NullEngine.prototype.enableEffect = function (effect) {\r\n this._currentEffect = effect;\r\n if (effect.onBind) {\r\n effect.onBind(effect);\r\n }\r\n if (effect._onBindObservable) {\r\n effect._onBindObservable.notifyObservers(effect);\r\n }\r\n };\r\n /**\r\n * Set various states to the webGL context\r\n * @param culling defines backface culling state\r\n * @param zOffset defines the value to apply to zOffset (0 by default)\r\n * @param force defines if states must be applied even if cache is up to date\r\n * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)\r\n */\r\n NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {\r\n if (zOffset === void 0) { zOffset = 0; }\r\n if (reverseSide === void 0) { reverseSide = false; }\r\n };\r\n /**\r\n * Set the value of an uniform to an array of int32\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of int32 to store\r\n */\r\n NullEngine.prototype.setIntArray = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of int32 (stored as vec2)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of int32 to store\r\n */\r\n NullEngine.prototype.setIntArray2 = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of int32 (stored as vec3)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of int32 to store\r\n */\r\n NullEngine.prototype.setIntArray3 = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of int32 (stored as vec4)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of int32 to store\r\n */\r\n NullEngine.prototype.setIntArray4 = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of float32\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of float32 to store\r\n */\r\n NullEngine.prototype.setFloatArray = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of float32 (stored as vec2)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of float32 to store\r\n */\r\n NullEngine.prototype.setFloatArray2 = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of float32 (stored as vec3)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of float32 to store\r\n */\r\n NullEngine.prototype.setFloatArray3 = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of float32 (stored as vec4)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of float32 to store\r\n */\r\n NullEngine.prototype.setFloatArray4 = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of number\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of number to store\r\n */\r\n NullEngine.prototype.setArray = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of number (stored as vec2)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of number to store\r\n */\r\n NullEngine.prototype.setArray2 = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of number (stored as vec3)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of number to store\r\n */\r\n NullEngine.prototype.setArray3 = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of number (stored as vec4)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param array defines the array of number to store\r\n */\r\n NullEngine.prototype.setArray4 = function (uniform, array) {\r\n };\r\n /**\r\n * Set the value of an uniform to an array of float32 (stored as matrices)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param matrices defines the array of float32 to store\r\n */\r\n NullEngine.prototype.setMatrices = function (uniform, matrices) {\r\n };\r\n /**\r\n * Set the value of an uniform to a matrix (3x3)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param matrix defines the Float32Array representing the 3x3 matrix to store\r\n */\r\n NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {\r\n };\r\n /**\r\n * Set the value of an uniform to a matrix (2x2)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param matrix defines the Float32Array representing the 2x2 matrix to store\r\n */\r\n NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {\r\n };\r\n /**\r\n * Set the value of an uniform to a number (float)\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param value defines the float number to store\r\n */\r\n NullEngine.prototype.setFloat = function (uniform, value) {\r\n };\r\n /**\r\n * Set the value of an uniform to a vec2\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param x defines the 1st component of the value\r\n * @param y defines the 2nd component of the value\r\n */\r\n NullEngine.prototype.setFloat2 = function (uniform, x, y) {\r\n };\r\n /**\r\n * Set the value of an uniform to a vec3\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param x defines the 1st component of the value\r\n * @param y defines the 2nd component of the value\r\n * @param z defines the 3rd component of the value\r\n */\r\n NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {\r\n };\r\n /**\r\n * Set the value of an uniform to a boolean\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param bool defines the boolean to store\r\n */\r\n NullEngine.prototype.setBool = function (uniform, bool) {\r\n };\r\n /**\r\n * Set the value of an uniform to a vec4\r\n * @param uniform defines the webGL uniform location where to store the value\r\n * @param x defines the 1st component of the value\r\n * @param y defines the 2nd component of the value\r\n * @param z defines the 3rd component of the value\r\n * @param w defines the 4th component of the value\r\n */\r\n NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {\r\n };\r\n /**\r\n * Sets the current alpha mode\r\n * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)\r\n * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)\r\n * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered\r\n */\r\n NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {\r\n if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }\r\n if (this._alphaMode === mode) {\r\n return;\r\n }\r\n this.alphaState.alphaBlend = (mode !== 0);\r\n if (!noDepthWriteChange) {\r\n this.setDepthWrite(mode === 0);\r\n }\r\n this._alphaMode = mode;\r\n };\r\n /**\r\n * Bind webGl buffers directly to the webGL context\r\n * @param vertexBuffers defines the vertex buffer to bind\r\n * @param indexBuffer defines the index buffer to bind\r\n * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer\r\n * @param vertexStrideSize defines the vertex stride of the vertex buffer\r\n * @param effect defines the effect associated with the vertex buffer\r\n */\r\n NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {\r\n };\r\n /**\r\n * Force the entire cache to be cleared\r\n * You should not have to use this function unless your engine needs to share the webGL context with another engine\r\n * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)\r\n */\r\n NullEngine.prototype.wipeCaches = function (bruteForce) {\r\n if (this.preventCacheWipeBetweenFrames) {\r\n return;\r\n }\r\n this.resetTextureCache();\r\n this._currentEffect = null;\r\n if (bruteForce) {\r\n this._currentProgram = null;\r\n this.stencilState.reset();\r\n this.depthCullingState.reset();\r\n this.alphaState.reset();\r\n }\r\n this._cachedVertexBuffers = null;\r\n this._cachedIndexBuffer = null;\r\n this._cachedEffectForVertexBuffers = null;\r\n };\r\n /**\r\n * Send a draw order\r\n * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)\r\n * @param indexStart defines the starting index\r\n * @param indexCount defines the number of index to draw\r\n * @param instancesCount defines the number of instances to draw (if instanciation is enabled)\r\n */\r\n NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {\r\n };\r\n /**\r\n * Draw a list of indexed primitives\r\n * @param fillMode defines the primitive to use\r\n * @param indexStart defines the starting index\r\n * @param indexCount defines the number of index to draw\r\n * @param instancesCount defines the number of instances to draw (if instanciation is enabled)\r\n */\r\n NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {\r\n };\r\n /**\r\n * Draw a list of unindexed primitives\r\n * @param fillMode defines the primitive to use\r\n * @param verticesStart defines the index of first vertex to draw\r\n * @param verticesCount defines the count of vertices to draw\r\n * @param instancesCount defines the number of instances to draw (if instanciation is enabled)\r\n */\r\n NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._createTexture = function () {\r\n return {};\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._releaseTexture = function (texture) {\r\n };\r\n /**\r\n * Usually called from Texture.ts.\r\n * Passed information to create a WebGLTexture\r\n * @param urlArg defines a value which contains one of the following:\r\n * * A conventional http URL, e.g. 'http://...' or 'file://...'\r\n * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'\r\n * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'\r\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file\r\n * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)\r\n * @param scene needed for loading to the correct scene\r\n * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)\r\n * @param onLoad optional callback to be called upon successful completion\r\n * @param onError optional callback to be called upon failure\r\n * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob\r\n * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities\r\n * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures\r\n * @param forcedExtension defines the extension to use to pick the right loader\r\n * @param mimeType defines an optional mime type\r\n * @returns a InternalTexture for assignment back into BABYLON.Texture\r\n */\r\n NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, mimeType) {\r\n if (samplingMode === void 0) { samplingMode = 3; }\r\n if (onLoad === void 0) { onLoad = null; }\r\n if (onError === void 0) { onError = null; }\r\n if (buffer === void 0) { buffer = null; }\r\n if (fallback === void 0) { fallback = null; }\r\n if (format === void 0) { format = null; }\r\n if (forcedExtension === void 0) { forcedExtension = null; }\r\n var texture = new InternalTexture(this, InternalTextureSource.Url);\r\n var url = String(urlArg);\r\n texture.url = url;\r\n texture.generateMipMaps = !noMipmap;\r\n texture.samplingMode = samplingMode;\r\n texture.invertY = invertY;\r\n texture.baseWidth = this._options.textureSize;\r\n texture.baseHeight = this._options.textureSize;\r\n texture.width = this._options.textureSize;\r\n texture.height = this._options.textureSize;\r\n if (format) {\r\n texture.format = format;\r\n }\r\n texture.isReady = true;\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n this._internalTexturesCache.push(texture);\r\n return texture;\r\n };\r\n /**\r\n * Creates a new render target texture\r\n * @param size defines the size of the texture\r\n * @param options defines the options used to create the texture\r\n * @returns a new render target texture stored in an InternalTexture\r\n */\r\n NullEngine.prototype.createRenderTargetTexture = function (size, options) {\r\n var fullOptions = new RenderTargetCreationOptions();\r\n if (options !== undefined && typeof options === \"object\") {\r\n fullOptions.generateMipMaps = options.generateMipMaps;\r\n fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;\r\n fullOptions.type = options.type === undefined ? 0 : options.type;\r\n fullOptions.samplingMode = options.samplingMode === undefined ? 3 : options.samplingMode;\r\n }\r\n else {\r\n fullOptions.generateMipMaps = options;\r\n fullOptions.generateDepthBuffer = true;\r\n fullOptions.generateStencilBuffer = false;\r\n fullOptions.type = 0;\r\n fullOptions.samplingMode = 3;\r\n }\r\n var texture = new InternalTexture(this, InternalTextureSource.RenderTarget);\r\n var width = size.width || size;\r\n var height = size.height || size;\r\n texture._depthStencilBuffer = {};\r\n texture._framebuffer = {};\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.isReady = true;\r\n texture.samples = 1;\r\n texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;\r\n texture.samplingMode = fullOptions.samplingMode;\r\n texture.type = fullOptions.type;\r\n texture._generateDepthBuffer = fullOptions.generateDepthBuffer;\r\n texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;\r\n this._internalTexturesCache.push(texture);\r\n return texture;\r\n };\r\n /**\r\n * Update the sampling mode of a given texture\r\n * @param samplingMode defines the required sampling mode\r\n * @param texture defines the texture to update\r\n */\r\n NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {\r\n texture.samplingMode = samplingMode;\r\n };\r\n /**\r\n * Binds the frame buffer to the specified texture.\r\n * @param texture The texture to render to or null for the default canvas\r\n * @param faceIndex The face of the texture to render to in case of cube texture\r\n * @param requiredWidth The width of the target to render to\r\n * @param requiredHeight The height of the target to render to\r\n * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true\r\n * @param lodLevel defines le lod level to bind to the frame buffer\r\n */\r\n NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {\r\n if (this._currentRenderTarget) {\r\n this.unBindFramebuffer(this._currentRenderTarget);\r\n }\r\n this._currentRenderTarget = texture;\r\n this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;\r\n if (this._cachedViewport && !forceFullscreenViewport) {\r\n this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);\r\n }\r\n };\r\n /**\r\n * Unbind the current render target texture from the webGL context\r\n * @param texture defines the render target texture to unbind\r\n * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated\r\n * @param onBeforeUnbind defines a function which will be called before the effective unbind\r\n */\r\n NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {\r\n if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }\r\n this._currentRenderTarget = null;\r\n if (onBeforeUnbind) {\r\n if (texture._MSAAFramebuffer) {\r\n this._currentFramebuffer = texture._framebuffer;\r\n }\r\n onBeforeUnbind();\r\n }\r\n this._currentFramebuffer = null;\r\n };\r\n /**\r\n * Creates a dynamic vertex buffer\r\n * @param vertices the data for the dynamic vertex buffer\r\n * @returns the new WebGL dynamic buffer\r\n */\r\n NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {\r\n var buffer = new DataBuffer();\r\n buffer.references = 1;\r\n buffer.capacity = 1;\r\n return buffer;\r\n };\r\n /**\r\n * Update the content of a dynamic texture\r\n * @param texture defines the texture to update\r\n * @param canvas defines the canvas containing the source\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param premulAlpha defines if alpha is stored as premultiplied\r\n * @param format defines the format of the data\r\n * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)\r\n */\r\n NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {\r\n if (premulAlpha === void 0) { premulAlpha = false; }\r\n };\r\n /**\r\n * Gets a boolean indicating if all created effects are ready\r\n * @returns true if all effects are ready\r\n */\r\n NullEngine.prototype.areAllEffectsReady = function () {\r\n return true;\r\n };\r\n /**\r\n * @hidden\r\n * Get the current error code of the webGL context\r\n * @returns the error code\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError\r\n */\r\n NullEngine.prototype.getError = function () {\r\n return 0;\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._getUnpackAlignement = function () {\r\n return 1;\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._unpackFlipY = function (value) {\r\n };\r\n /**\r\n * Update a dynamic index buffer\r\n * @param indexBuffer defines the target index buffer\r\n * @param indices defines the data to update\r\n * @param offset defines the offset in the target index buffer where update should start\r\n */\r\n NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {\r\n if (offset === void 0) { offset = 0; }\r\n };\r\n /**\r\n * Updates a dynamic vertex buffer.\r\n * @param vertexBuffer the vertex buffer to update\r\n * @param vertices the data used to update the vertex buffer\r\n * @param byteOffset the byte offset of the data (optional)\r\n * @param byteLength the byte length of the data (optional)\r\n */\r\n NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._bindTextureDirectly = function (target, texture) {\r\n if (this._boundTexturesCache[this._activeChannel] !== texture) {\r\n this._boundTexturesCache[this._activeChannel] = texture;\r\n return true;\r\n }\r\n return false;\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._bindTexture = function (channel, texture) {\r\n if (channel < 0) {\r\n return;\r\n }\r\n this._bindTextureDirectly(0, texture);\r\n };\r\n NullEngine.prototype._deleteBuffer = function (buffer) {\r\n };\r\n /**\r\n * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled\r\n */\r\n NullEngine.prototype.releaseEffects = function () {\r\n };\r\n NullEngine.prototype.displayLoadingUI = function () {\r\n };\r\n NullEngine.prototype.hideLoadingUI = function () {\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lod === void 0) { lod = 0; }\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lod === void 0) { lod = 0; }\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lod === void 0) { lod = 0; }\r\n };\r\n /** @hidden */\r\n NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {\r\n if (faceIndex === void 0) { faceIndex = 0; }\r\n if (lod === void 0) { lod = 0; }\r\n };\r\n return NullEngine;\r\n}(Engine));\r\nexport { NullEngine };\r\n//# sourceMappingURL=nullEngine.js.map","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isObject;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nmodule.exports = root;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nmodule.exports = Symbol;\n","// most Object methods by ES6 should accept primitives\nvar $export = require('./_export');\nvar core = require('./_core');\nvar fails = require('./_fails');\nmodule.exports = function (KEY, exec) {\n var fn = (core.Object || {})[KEY] || Object[KEY];\n var exp = {};\n exp[KEY] = exec(fn);\n $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);\n};\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.ToastContainer = undefined;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar _core = require('@emotion/core');\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _reactTransitionGroup = require('react-transition-group');\n\nvar _ToastElement = require('./ToastElement');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n/** @jsx jsx */\n\nvar placements = {\n 'top-left': { top: 0, left: 0 },\n 'top-center': { top: 0, left: '50%', transform: 'translateX(-50%)' },\n 'top-right': { top: 0, right: 0 },\n 'bottom-left': { bottom: 0, left: 0 },\n 'bottom-center': { bottom: 0, left: '50%', transform: 'translateX(-50%)' },\n 'bottom-right': { bottom: 0, right: 0 }\n};\n\nvar ToastContainer = function ToastContainer(_ref) {\n var hasToasts = _ref.hasToasts,\n placement = _ref.placement,\n props = _objectWithoutProperties(_ref, ['hasToasts', 'placement']);\n\n return (0, _core.jsx)('div', _extends({\n className: 'react-toast-notifications__container',\n css: _extends({\n boxSizing: 'border-box',\n maxHeight: '100%',\n overflowX: 'hidden',\n overflowY: 'auto',\n padding: _ToastElement.gutter,\n pointerEvents: hasToasts ? null : 'none',\n position: 'fixed',\n zIndex: 1000\n }, placements[placement])\n }, props));\n};\nexports.ToastContainer = ToastContainer;","let logging = false;\nlet customLogger = () => {};\n\nconst setLogging = (_logging) => {\n logging = _logging;\n};\n\nconst setCustomLogger = (logger) => {\n customLogger = logger;\n};\n\nconst log = (type, message) => {\n customLogger({ type, message });\n if (logging) {\n console.log(`[${type}] ${message}`);\n }\n};\n\nmodule.exports = {\n logging,\n setLogging,\n setCustomLogger,\n log,\n};\n","const defaultOptions = require('./defaultOptions');\nconst getCreateFFmpegCore = require('./getCreateFFmpegCore');\nconst fetchFile = require('./fetchFile');\n\nmodule.exports = {\n defaultOptions,\n getCreateFFmpegCore,\n fetchFile,\n};\n","/*\n\nBased off glamor's StyleSheet, thanks Sunil ❤️\n\nhigh performance StyleSheet for css-in-js systems\n\n- uses multiple style tags behind the scenes for millions of rules\n- uses `insertRule` for appending in production for *much* faster performance\n\n// usage\n\nimport { StyleSheet } from '@emotion/sheet'\n\nlet styleSheet = new StyleSheet({ key: '', container: document.head })\n\nstyleSheet.insert('#box { border: 1px solid red; }')\n- appends a css rule into the stylesheet\n\nstyleSheet.flush()\n- empties the stylesheet of all its contents\n\n*/\n// $FlowFixMe\nfunction sheetForTag(tag) {\n if (tag.sheet) {\n // $FlowFixMe\n return tag.sheet;\n } // this weirdness brought to you by firefox\n\n /* istanbul ignore next */\n\n\n for (var i = 0; i < document.styleSheets.length; i++) {\n if (document.styleSheets[i].ownerNode === tag) {\n // $FlowFixMe\n return document.styleSheets[i];\n }\n }\n}\n\nfunction createStyleElement(options) {\n var tag = document.createElement('style');\n tag.setAttribute('data-emotion', options.key);\n\n if (options.nonce !== undefined) {\n tag.setAttribute('nonce', options.nonce);\n }\n\n tag.appendChild(document.createTextNode(''));\n return tag;\n}\n\nvar StyleSheet =\n/*#__PURE__*/\nfunction () {\n function StyleSheet(options) {\n this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === 'production' : options.speedy;\n this.tags = [];\n this.ctr = 0;\n this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets\n\n this.key = options.key;\n this.container = options.container;\n this.before = null;\n }\n\n var _proto = StyleSheet.prototype;\n\n _proto.insert = function insert(rule) {\n // the max length is how many rules we have per style tag, it's 65000 in speedy mode\n // it's 1 in dev because we insert source maps that map a single rule to a location\n // and you can only have one source map per style tag\n if (this.ctr % (this.isSpeedy ? 65000 : 1) === 0) {\n var _tag = createStyleElement(this);\n\n var before;\n\n if (this.tags.length === 0) {\n before = this.before;\n } else {\n before = this.tags[this.tags.length - 1].nextSibling;\n }\n\n this.container.insertBefore(_tag, before);\n this.tags.push(_tag);\n }\n\n var tag = this.tags[this.tags.length - 1];\n\n if (this.isSpeedy) {\n var sheet = sheetForTag(tag);\n\n try {\n // this is a really hot path\n // we check the second character first because having \"i\"\n // as the second character will happen less often than\n // having \"@\" as the first character\n var isImportRule = rule.charCodeAt(1) === 105 && rule.charCodeAt(0) === 64; // this is the ultrafast version, works across browsers\n // the big drawback is that the css won't be editable in devtools\n\n sheet.insertRule(rule, // we need to insert @import rules before anything else\n // otherwise there will be an error\n // technically this means that the @import rules will\n // _usually_(not always since there could be multiple style tags)\n // be the first ones in prod and generally later in dev\n // this shouldn't really matter in the real world though\n // @import is generally only used for font faces from google fonts and etc.\n // so while this could be technically correct then it would be slower and larger\n // for a tiny bit of correctness that won't matter in the real world\n isImportRule ? 0 : sheet.cssRules.length);\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\"There was a problem inserting the following rule: \\\"\" + rule + \"\\\"\", e);\n }\n }\n } else {\n tag.appendChild(document.createTextNode(rule));\n }\n\n this.ctr++;\n };\n\n _proto.flush = function flush() {\n // $FlowFixMe\n this.tags.forEach(function (tag) {\n return tag.parentNode.removeChild(tag);\n });\n this.tags = [];\n this.ctr = 0;\n };\n\n return StyleSheet;\n}();\n\nexport { StyleSheet };\n","function stylis_min (W) {\n function M(d, c, e, h, a) {\n for (var m = 0, b = 0, v = 0, n = 0, q, g, x = 0, K = 0, k, u = k = q = 0, l = 0, r = 0, I = 0, t = 0, B = e.length, J = B - 1, y, f = '', p = '', F = '', G = '', C; l < B;) {\n g = e.charCodeAt(l);\n l === J && 0 !== b + n + v + m && (0 !== b && (g = 47 === b ? 10 : 47), n = v = m = 0, B++, J++);\n\n if (0 === b + n + v + m) {\n if (l === J && (0 < r && (f = f.replace(N, '')), 0 < f.trim().length)) {\n switch (g) {\n case 32:\n case 9:\n case 59:\n case 13:\n case 10:\n break;\n\n default:\n f += e.charAt(l);\n }\n\n g = 59;\n }\n\n switch (g) {\n case 123:\n f = f.trim();\n q = f.charCodeAt(0);\n k = 1;\n\n for (t = ++l; l < B;) {\n switch (g = e.charCodeAt(l)) {\n case 123:\n k++;\n break;\n\n case 125:\n k--;\n break;\n\n case 47:\n switch (g = e.charCodeAt(l + 1)) {\n case 42:\n case 47:\n a: {\n for (u = l + 1; u < J; ++u) {\n switch (e.charCodeAt(u)) {\n case 47:\n if (42 === g && 42 === e.charCodeAt(u - 1) && l + 2 !== u) {\n l = u + 1;\n break a;\n }\n\n break;\n\n case 10:\n if (47 === g) {\n l = u + 1;\n break a;\n }\n\n }\n }\n\n l = u;\n }\n\n }\n\n break;\n\n case 91:\n g++;\n\n case 40:\n g++;\n\n case 34:\n case 39:\n for (; l++ < J && e.charCodeAt(l) !== g;) {\n }\n\n }\n\n if (0 === k) break;\n l++;\n }\n\n k = e.substring(t, l);\n 0 === q && (q = (f = f.replace(ca, '').trim()).charCodeAt(0));\n\n switch (q) {\n case 64:\n 0 < r && (f = f.replace(N, ''));\n g = f.charCodeAt(1);\n\n switch (g) {\n case 100:\n case 109:\n case 115:\n case 45:\n r = c;\n break;\n\n default:\n r = O;\n }\n\n k = M(c, r, k, g, a + 1);\n t = k.length;\n 0 < A && (r = X(O, f, I), C = H(3, k, r, c, D, z, t, g, a, h), f = r.join(''), void 0 !== C && 0 === (t = (k = C.trim()).length) && (g = 0, k = ''));\n if (0 < t) switch (g) {\n case 115:\n f = f.replace(da, ea);\n\n case 100:\n case 109:\n case 45:\n k = f + '{' + k + '}';\n break;\n\n case 107:\n f = f.replace(fa, '$1 $2');\n k = f + '{' + k + '}';\n k = 1 === w || 2 === w && L('@' + k, 3) ? '@-webkit-' + k + '@' + k : '@' + k;\n break;\n\n default:\n k = f + k, 112 === h && (k = (p += k, ''));\n } else k = '';\n break;\n\n default:\n k = M(c, X(c, f, I), k, h, a + 1);\n }\n\n F += k;\n k = I = r = u = q = 0;\n f = '';\n g = e.charCodeAt(++l);\n break;\n\n case 125:\n case 59:\n f = (0 < r ? f.replace(N, '') : f).trim();\n if (1 < (t = f.length)) switch (0 === u && (q = f.charCodeAt(0), 45 === q || 96 < q && 123 > q) && (t = (f = f.replace(' ', ':')).length), 0 < A && void 0 !== (C = H(1, f, c, d, D, z, p.length, h, a, h)) && 0 === (t = (f = C.trim()).length) && (f = '\\x00\\x00'), q = f.charCodeAt(0), g = f.charCodeAt(1), q) {\n case 0:\n break;\n\n case 64:\n if (105 === g || 99 === g) {\n G += f + e.charAt(l);\n break;\n }\n\n default:\n 58 !== f.charCodeAt(t - 1) && (p += P(f, q, g, f.charCodeAt(2)));\n }\n I = r = u = q = 0;\n f = '';\n g = e.charCodeAt(++l);\n }\n }\n\n switch (g) {\n case 13:\n case 10:\n 47 === b ? b = 0 : 0 === 1 + q && 107 !== h && 0 < f.length && (r = 1, f += '\\x00');\n 0 < A * Y && H(0, f, c, d, D, z, p.length, h, a, h);\n z = 1;\n D++;\n break;\n\n case 59:\n case 125:\n if (0 === b + n + v + m) {\n z++;\n break;\n }\n\n default:\n z++;\n y = e.charAt(l);\n\n switch (g) {\n case 9:\n case 32:\n if (0 === n + m + b) switch (x) {\n case 44:\n case 58:\n case 9:\n case 32:\n y = '';\n break;\n\n default:\n 32 !== g && (y = ' ');\n }\n break;\n\n case 0:\n y = '\\\\0';\n break;\n\n case 12:\n y = '\\\\f';\n break;\n\n case 11:\n y = '\\\\v';\n break;\n\n case 38:\n 0 === n + b + m && (r = I = 1, y = '\\f' + y);\n break;\n\n case 108:\n if (0 === n + b + m + E && 0 < u) switch (l - u) {\n case 2:\n 112 === x && 58 === e.charCodeAt(l - 3) && (E = x);\n\n case 8:\n 111 === K && (E = K);\n }\n break;\n\n case 58:\n 0 === n + b + m && (u = l);\n break;\n\n case 44:\n 0 === b + v + n + m && (r = 1, y += '\\r');\n break;\n\n case 34:\n case 39:\n 0 === b && (n = n === g ? 0 : 0 === n ? g : n);\n break;\n\n case 91:\n 0 === n + b + v && m++;\n break;\n\n case 93:\n 0 === n + b + v && m--;\n break;\n\n case 41:\n 0 === n + b + m && v--;\n break;\n\n case 40:\n if (0 === n + b + m) {\n if (0 === q) switch (2 * x + 3 * K) {\n case 533:\n break;\n\n default:\n q = 1;\n }\n v++;\n }\n\n break;\n\n case 64:\n 0 === b + v + n + m + u + k && (k = 1);\n break;\n\n case 42:\n case 47:\n if (!(0 < n + m + v)) switch (b) {\n case 0:\n switch (2 * g + 3 * e.charCodeAt(l + 1)) {\n case 235:\n b = 47;\n break;\n\n case 220:\n t = l, b = 42;\n }\n\n break;\n\n case 42:\n 47 === g && 42 === x && t + 2 !== l && (33 === e.charCodeAt(t + 2) && (p += e.substring(t, l + 1)), y = '', b = 0);\n }\n }\n\n 0 === b && (f += y);\n }\n\n K = x;\n x = g;\n l++;\n }\n\n t = p.length;\n\n if (0 < t) {\n r = c;\n if (0 < A && (C = H(2, p, r, d, D, z, t, h, a, h), void 0 !== C && 0 === (p = C).length)) return G + p + F;\n p = r.join(',') + '{' + p + '}';\n\n if (0 !== w * E) {\n 2 !== w || L(p, 2) || (E = 0);\n\n switch (E) {\n case 111:\n p = p.replace(ha, ':-moz-$1') + p;\n break;\n\n case 112:\n p = p.replace(Q, '::-webkit-input-$1') + p.replace(Q, '::-moz-$1') + p.replace(Q, ':-ms-input-$1') + p;\n }\n\n E = 0;\n }\n }\n\n return G + p + F;\n }\n\n function X(d, c, e) {\n var h = c.trim().split(ia);\n c = h;\n var a = h.length,\n m = d.length;\n\n switch (m) {\n case 0:\n case 1:\n var b = 0;\n\n for (d = 0 === m ? '' : d[0] + ' '; b < a; ++b) {\n c[b] = Z(d, c[b], e).trim();\n }\n\n break;\n\n default:\n var v = b = 0;\n\n for (c = []; b < a; ++b) {\n for (var n = 0; n < m; ++n) {\n c[v++] = Z(d[n] + ' ', h[b], e).trim();\n }\n }\n\n }\n\n return c;\n }\n\n function Z(d, c, e) {\n var h = c.charCodeAt(0);\n 33 > h && (h = (c = c.trim()).charCodeAt(0));\n\n switch (h) {\n case 38:\n return c.replace(F, '$1' + d.trim());\n\n case 58:\n return d.trim() + c.replace(F, '$1' + d.trim());\n\n default:\n if (0 < 1 * e && 0 < c.indexOf('\\f')) return c.replace(F, (58 === d.charCodeAt(0) ? '' : '$1') + d.trim());\n }\n\n return d + c;\n }\n\n function P(d, c, e, h) {\n var a = d + ';',\n m = 2 * c + 3 * e + 4 * h;\n\n if (944 === m) {\n d = a.indexOf(':', 9) + 1;\n var b = a.substring(d, a.length - 1).trim();\n b = a.substring(0, d).trim() + b + ';';\n return 1 === w || 2 === w && L(b, 1) ? '-webkit-' + b + b : b;\n }\n\n if (0 === w || 2 === w && !L(a, 1)) return a;\n\n switch (m) {\n case 1015:\n return 97 === a.charCodeAt(10) ? '-webkit-' + a + a : a;\n\n case 951:\n return 116 === a.charCodeAt(3) ? '-webkit-' + a + a : a;\n\n case 963:\n return 110 === a.charCodeAt(5) ? '-webkit-' + a + a : a;\n\n case 1009:\n if (100 !== a.charCodeAt(4)) break;\n\n case 969:\n case 942:\n return '-webkit-' + a + a;\n\n case 978:\n return '-webkit-' + a + '-moz-' + a + a;\n\n case 1019:\n case 983:\n return '-webkit-' + a + '-moz-' + a + '-ms-' + a + a;\n\n case 883:\n if (45 === a.charCodeAt(8)) return '-webkit-' + a + a;\n if (0 < a.indexOf('image-set(', 11)) return a.replace(ja, '$1-webkit-$2') + a;\n break;\n\n case 932:\n if (45 === a.charCodeAt(4)) switch (a.charCodeAt(5)) {\n case 103:\n return '-webkit-box-' + a.replace('-grow', '') + '-webkit-' + a + '-ms-' + a.replace('grow', 'positive') + a;\n\n case 115:\n return '-webkit-' + a + '-ms-' + a.replace('shrink', 'negative') + a;\n\n case 98:\n return '-webkit-' + a + '-ms-' + a.replace('basis', 'preferred-size') + a;\n }\n return '-webkit-' + a + '-ms-' + a + a;\n\n case 964:\n return '-webkit-' + a + '-ms-flex-' + a + a;\n\n case 1023:\n if (99 !== a.charCodeAt(8)) break;\n b = a.substring(a.indexOf(':', 15)).replace('flex-', '').replace('space-between', 'justify');\n return '-webkit-box-pack' + b + '-webkit-' + a + '-ms-flex-pack' + b + a;\n\n case 1005:\n return ka.test(a) ? a.replace(aa, ':-webkit-') + a.replace(aa, ':-moz-') + a : a;\n\n case 1e3:\n b = a.substring(13).trim();\n c = b.indexOf('-') + 1;\n\n switch (b.charCodeAt(0) + b.charCodeAt(c)) {\n case 226:\n b = a.replace(G, 'tb');\n break;\n\n case 232:\n b = a.replace(G, 'tb-rl');\n break;\n\n case 220:\n b = a.replace(G, 'lr');\n break;\n\n default:\n return a;\n }\n\n return '-webkit-' + a + '-ms-' + b + a;\n\n case 1017:\n if (-1 === a.indexOf('sticky', 9)) break;\n\n case 975:\n c = (a = d).length - 10;\n b = (33 === a.charCodeAt(c) ? a.substring(0, c) : a).substring(d.indexOf(':', 7) + 1).trim();\n\n switch (m = b.charCodeAt(0) + (b.charCodeAt(7) | 0)) {\n case 203:\n if (111 > b.charCodeAt(8)) break;\n\n case 115:\n a = a.replace(b, '-webkit-' + b) + ';' + a;\n break;\n\n case 207:\n case 102:\n a = a.replace(b, '-webkit-' + (102 < m ? 'inline-' : '') + 'box') + ';' + a.replace(b, '-webkit-' + b) + ';' + a.replace(b, '-ms-' + b + 'box') + ';' + a;\n }\n\n return a + ';';\n\n case 938:\n if (45 === a.charCodeAt(5)) switch (a.charCodeAt(6)) {\n case 105:\n return b = a.replace('-items', ''), '-webkit-' + a + '-webkit-box-' + b + '-ms-flex-' + b + a;\n\n case 115:\n return '-webkit-' + a + '-ms-flex-item-' + a.replace(ba, '') + a;\n\n default:\n return '-webkit-' + a + '-ms-flex-line-pack' + a.replace('align-content', '').replace(ba, '') + a;\n }\n break;\n\n case 973:\n case 989:\n if (45 !== a.charCodeAt(3) || 122 === a.charCodeAt(4)) break;\n\n case 931:\n case 953:\n if (!0 === la.test(d)) return 115 === (b = d.substring(d.indexOf(':') + 1)).charCodeAt(0) ? P(d.replace('stretch', 'fill-available'), c, e, h).replace(':fill-available', ':stretch') : a.replace(b, '-webkit-' + b) + a.replace(b, '-moz-' + b.replace('fill-', '')) + a;\n break;\n\n case 962:\n if (a = '-webkit-' + a + (102 === a.charCodeAt(5) ? '-ms-' + a : '') + a, 211 === e + h && 105 === a.charCodeAt(13) && 0 < a.indexOf('transform', 10)) return a.substring(0, a.indexOf(';', 27) + 1).replace(ma, '$1-webkit-$2') + a;\n }\n\n return a;\n }\n\n function L(d, c) {\n var e = d.indexOf(1 === c ? ':' : '{'),\n h = d.substring(0, 3 !== c ? e : 10);\n e = d.substring(e + 1, d.length - 1);\n return R(2 !== c ? h : h.replace(na, '$1'), e, c);\n }\n\n function ea(d, c) {\n var e = P(c, c.charCodeAt(0), c.charCodeAt(1), c.charCodeAt(2));\n return e !== c + ';' ? e.replace(oa, ' or ($1)').substring(4) : '(' + c + ')';\n }\n\n function H(d, c, e, h, a, m, b, v, n, q) {\n for (var g = 0, x = c, w; g < A; ++g) {\n switch (w = S[g].call(B, d, x, e, h, a, m, b, v, n, q)) {\n case void 0:\n case !1:\n case !0:\n case null:\n break;\n\n default:\n x = w;\n }\n }\n\n if (x !== c) return x;\n }\n\n function T(d) {\n switch (d) {\n case void 0:\n case null:\n A = S.length = 0;\n break;\n\n default:\n if ('function' === typeof d) S[A++] = d;else if ('object' === typeof d) for (var c = 0, e = d.length; c < e; ++c) {\n T(d[c]);\n } else Y = !!d | 0;\n }\n\n return T;\n }\n\n function U(d) {\n d = d.prefix;\n void 0 !== d && (R = null, d ? 'function' !== typeof d ? w = 1 : (w = 2, R = d) : w = 0);\n return U;\n }\n\n function B(d, c) {\n var e = d;\n 33 > e.charCodeAt(0) && (e = e.trim());\n V = e;\n e = [V];\n\n if (0 < A) {\n var h = H(-1, c, e, e, D, z, 0, 0, 0, 0);\n void 0 !== h && 'string' === typeof h && (c = h);\n }\n\n var a = M(O, e, c, 0, 0);\n 0 < A && (h = H(-2, a, e, e, D, z, a.length, 0, 0, 0), void 0 !== h && (a = h));\n V = '';\n E = 0;\n z = D = 1;\n return a;\n }\n\n var ca = /^\\0+/g,\n N = /[\\0\\r\\f]/g,\n aa = /: */g,\n ka = /zoo|gra/,\n ma = /([,: ])(transform)/g,\n ia = /,\\r+?/g,\n F = /([\\t\\r\\n ])*\\f?&/g,\n fa = /@(k\\w+)\\s*(\\S*)\\s*/,\n Q = /::(place)/g,\n ha = /:(read-only)/g,\n G = /[svh]\\w+-[tblr]{2}/,\n da = /\\(\\s*(.*)\\s*\\)/g,\n oa = /([\\s\\S]*?);/g,\n ba = /-self|flex-/g,\n na = /[^]*?(:[rp][el]a[\\w-]+)[^]*/,\n la = /stretch|:\\s*\\w+\\-(?:conte|avail)/,\n ja = /([^-])(image-set\\()/,\n z = 1,\n D = 1,\n E = 0,\n w = 1,\n O = [],\n S = [],\n A = 0,\n R = null,\n Y = 0,\n V = '';\n B.use = T;\n B.set = U;\n void 0 !== W && U(W);\n return B;\n}\n\nexport default stylis_min;\n","import { StyleSheet } from '@emotion/sheet';\nimport Stylis from '@emotion/stylis';\nimport '@emotion/weak-memoize';\n\n// https://github.com/thysultan/stylis.js/tree/master/plugins/rule-sheet\n// inlined to avoid umd wrapper and peerDep warnings/installing stylis\n// since we use stylis after closure compiler\nvar delimiter = '/*|*/';\nvar needle = delimiter + '}';\n\nfunction toSheet(block) {\n if (block) {\n Sheet.current.insert(block + '}');\n }\n}\n\nvar Sheet = {\n current: null\n};\nvar ruleSheet = function ruleSheet(context, content, selectors, parents, line, column, length, ns, depth, at) {\n switch (context) {\n // property\n case 1:\n {\n switch (content.charCodeAt(0)) {\n case 64:\n {\n // @import\n Sheet.current.insert(content + ';');\n return '';\n }\n // charcode for l\n\n case 108:\n {\n // charcode for b\n // this ignores label\n if (content.charCodeAt(2) === 98) {\n return '';\n }\n }\n }\n\n break;\n }\n // selector\n\n case 2:\n {\n if (ns === 0) return content + delimiter;\n break;\n }\n // at-rule\n\n case 3:\n {\n switch (ns) {\n // @font-face, @page\n case 102:\n case 112:\n {\n Sheet.current.insert(selectors[0] + content);\n return '';\n }\n\n default:\n {\n return content + (at === 0 ? delimiter : '');\n }\n }\n }\n\n case -2:\n {\n content.split(needle).forEach(toSheet);\n }\n }\n};\n\nvar createCache = function createCache(options) {\n if (options === undefined) options = {};\n var key = options.key || 'css';\n var stylisOptions;\n\n if (options.prefix !== undefined) {\n stylisOptions = {\n prefix: options.prefix\n };\n }\n\n var stylis = new Stylis(stylisOptions);\n\n if (process.env.NODE_ENV !== 'production') {\n // $FlowFixMe\n if (/[^a-z-]/.test(key)) {\n throw new Error(\"Emotion key must only contain lower case alphabetical characters and - but \\\"\" + key + \"\\\" was passed\");\n }\n }\n\n var inserted = {}; // $FlowFixMe\n\n var container;\n\n {\n container = options.container || document.head;\n var nodes = document.querySelectorAll(\"style[data-emotion-\" + key + \"]\");\n Array.prototype.forEach.call(nodes, function (node) {\n var attrib = node.getAttribute(\"data-emotion-\" + key); // $FlowFixMe\n\n attrib.split(' ').forEach(function (id) {\n inserted[id] = true;\n });\n\n if (node.parentNode !== container) {\n container.appendChild(node);\n }\n });\n }\n\n var _insert;\n\n {\n stylis.use(options.stylisPlugins)(ruleSheet);\n\n _insert = function insert(selector, serialized, sheet, shouldCache) {\n var name = serialized.name;\n Sheet.current = sheet;\n\n if (process.env.NODE_ENV !== 'production' && serialized.map !== undefined) {\n var map = serialized.map;\n Sheet.current = {\n insert: function insert(rule) {\n sheet.insert(rule + map);\n }\n };\n }\n\n stylis(selector, serialized.styles);\n\n if (shouldCache) {\n cache.inserted[name] = true;\n }\n };\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // https://esbench.com/bench/5bf7371a4cd7e6009ef61d0a\n var commentStart = /\\/\\*/g;\n var commentEnd = /\\*\\//g;\n stylis.use(function (context, content) {\n switch (context) {\n case -1:\n {\n while (commentStart.test(content)) {\n commentEnd.lastIndex = commentStart.lastIndex;\n\n if (commentEnd.test(content)) {\n commentStart.lastIndex = commentEnd.lastIndex;\n continue;\n }\n\n throw new Error('Your styles have an unterminated comment (\"/*\" without corresponding \"*/\").');\n }\n\n commentStart.lastIndex = 0;\n break;\n }\n }\n });\n stylis.use(function (context, content, selectors) {\n switch (context) {\n case -1:\n {\n var flag = 'emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason';\n var unsafePseudoClasses = content.match(/(:first|:nth|:nth-last)-child/g);\n\n if (unsafePseudoClasses && cache.compat !== true) {\n unsafePseudoClasses.forEach(function (unsafePseudoClass) {\n var ignoreRegExp = new RegExp(unsafePseudoClass + \".*\\\\/\\\\* \" + flag + \" \\\\*\\\\/\");\n var ignore = ignoreRegExp.test(content);\n\n if (unsafePseudoClass && !ignore) {\n console.error(\"The pseudo class \\\"\" + unsafePseudoClass + \"\\\" is potentially unsafe when doing server-side rendering. Try changing it to \\\"\" + unsafePseudoClass.split('-child')[0] + \"-of-type\\\".\");\n }\n });\n }\n\n break;\n }\n }\n });\n }\n\n var cache = {\n key: key,\n sheet: new StyleSheet({\n key: key,\n container: container,\n nonce: options.nonce,\n speedy: options.speedy\n }),\n nonce: options.nonce,\n inserted: inserted,\n registered: {},\n insert: _insert\n };\n return cache;\n};\n\nexport default createCache;\n","var isBrowser = \"object\" !== 'undefined';\nfunction getRegisteredStyles(registered, registeredStyles, classNames) {\n var rawClassName = '';\n classNames.split(' ').forEach(function (className) {\n if (registered[className] !== undefined) {\n registeredStyles.push(registered[className]);\n } else {\n rawClassName += className + \" \";\n }\n });\n return rawClassName;\n}\nvar insertStyles = function insertStyles(cache, serialized, isStringTag) {\n var className = cache.key + \"-\" + serialized.name;\n\n if ( // we only need to add the styles to the registered cache if the\n // class name could be used further down\n // the tree but if it's a string tag, we know it won't\n // so we don't have to add it to registered cache.\n // this improves memory usage since we can avoid storing the whole style string\n (isStringTag === false || // we need to always store it if we're in compat mode and\n // in node since emotion-server relies on whether a style is in\n // the registered cache to know whether a style is global or not\n // also, note that this check will be dead code eliminated in the browser\n isBrowser === false && cache.compat !== undefined) && cache.registered[className] === undefined) {\n cache.registered[className] = serialized.styles;\n }\n\n if (cache.inserted[serialized.name] === undefined) {\n var current = serialized;\n\n do {\n var maybeStyles = cache.insert(\".\" + className, current, cache.sheet, true);\n\n current = current.next;\n } while (current !== undefined);\n }\n};\n\nexport { getRegisteredStyles, insertStyles };\n","/* eslint-disable */\n// Inspired by https://github.com/garycourt/murmurhash-js\n// Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86\nfunction murmur2(str) {\n // 'm' and 'r' are mixing constants generated offline.\n // They're not really 'magic', they just happen to work well.\n // const m = 0x5bd1e995;\n // const r = 24;\n // Initialize the hash\n var h = 0; // Mix 4 bytes at a time into the hash\n\n var k,\n i = 0,\n len = str.length;\n\n for (; len >= 4; ++i, len -= 4) {\n k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;\n k =\n /* Math.imul(k, m): */\n (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);\n k ^=\n /* k >>> r: */\n k >>> 24;\n h =\n /* Math.imul(k, m): */\n (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);\n } // Handle the last few bytes of the input array\n\n\n switch (len) {\n case 3:\n h ^= (str.charCodeAt(i + 2) & 0xff) << 16;\n\n case 2:\n h ^= (str.charCodeAt(i + 1) & 0xff) << 8;\n\n case 1:\n h ^= str.charCodeAt(i) & 0xff;\n h =\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);\n } // Do a few final mixes of the hash to ensure the last few\n // bytes are well-incorporated.\n\n\n h ^= h >>> 13;\n h =\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);\n return ((h ^ h >>> 15) >>> 0).toString(36);\n}\n\nexport default murmur2;\n","var unitlessKeys = {\n animationIterationCount: 1,\n borderImageOutset: 1,\n borderImageSlice: 1,\n borderImageWidth: 1,\n boxFlex: 1,\n boxFlexGroup: 1,\n boxOrdinalGroup: 1,\n columnCount: 1,\n columns: 1,\n flex: 1,\n flexGrow: 1,\n flexPositive: 1,\n flexShrink: 1,\n flexNegative: 1,\n flexOrder: 1,\n gridRow: 1,\n gridRowEnd: 1,\n gridRowSpan: 1,\n gridRowStart: 1,\n gridColumn: 1,\n gridColumnEnd: 1,\n gridColumnSpan: 1,\n gridColumnStart: 1,\n msGridRow: 1,\n msGridRowSpan: 1,\n msGridColumn: 1,\n msGridColumnSpan: 1,\n fontWeight: 1,\n lineHeight: 1,\n opacity: 1,\n order: 1,\n orphans: 1,\n tabSize: 1,\n widows: 1,\n zIndex: 1,\n zoom: 1,\n WebkitLineClamp: 1,\n // SVG-related properties\n fillOpacity: 1,\n floodOpacity: 1,\n stopOpacity: 1,\n strokeDasharray: 1,\n strokeDashoffset: 1,\n strokeMiterlimit: 1,\n strokeOpacity: 1,\n strokeWidth: 1\n};\n\nexport default unitlessKeys;\n","function memoize(fn) {\n var cache = {};\n return function (arg) {\n if (cache[arg] === undefined) cache[arg] = fn(arg);\n return cache[arg];\n };\n}\n\nexport default memoize;\n","import hashString from '@emotion/hash';\nimport unitless from '@emotion/unitless';\nimport memoize from '@emotion/memoize';\n\nvar ILLEGAL_ESCAPE_SEQUENCE_ERROR = \"You have illegal escape sequence in your template literal, most likely inside content's property value.\\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \\\"content: '\\\\00d7';\\\" should become \\\"content: '\\\\\\\\00d7';\\\".\\nYou can read more about this here:\\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences\";\nvar UNDEFINED_AS_OBJECT_KEY_ERROR = \"You have passed in falsy value as style object's key (can happen when in example you pass unexported component as computed key).\";\nvar hyphenateRegex = /[A-Z]|^ms/g;\nvar animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;\n\nvar isCustomProperty = function isCustomProperty(property) {\n return property.charCodeAt(1) === 45;\n};\n\nvar isProcessableValue = function isProcessableValue(value) {\n return value != null && typeof value !== 'boolean';\n};\n\nvar processStyleName = memoize(function (styleName) {\n return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, '-$&').toLowerCase();\n});\n\nvar processStyleValue = function processStyleValue(key, value) {\n switch (key) {\n case 'animation':\n case 'animationName':\n {\n if (typeof value === 'string') {\n return value.replace(animationRegex, function (match, p1, p2) {\n cursor = {\n name: p1,\n styles: p2,\n next: cursor\n };\n return p1;\n });\n }\n }\n }\n\n if (unitless[key] !== 1 && !isCustomProperty(key) && typeof value === 'number' && value !== 0) {\n return value + 'px';\n }\n\n return value;\n};\n\nif (process.env.NODE_ENV !== 'production') {\n var contentValuePattern = /(attr|calc|counters?|url)\\(/;\n var contentValues = ['normal', 'none', 'counter', 'open-quote', 'close-quote', 'no-open-quote', 'no-close-quote', 'initial', 'inherit', 'unset'];\n var oldProcessStyleValue = processStyleValue;\n var msPattern = /^-ms-/;\n var hyphenPattern = /-(.)/g;\n var hyphenatedCache = {};\n\n processStyleValue = function processStyleValue(key, value) {\n if (key === 'content') {\n if (typeof value !== 'string' || contentValues.indexOf(value) === -1 && !contentValuePattern.test(value) && (value.charAt(0) !== value.charAt(value.length - 1) || value.charAt(0) !== '\"' && value.charAt(0) !== \"'\")) {\n console.error(\"You seem to be using a value for 'content' without quotes, try replacing it with `content: '\\\"\" + value + \"\\\"'`\");\n }\n }\n\n var processed = oldProcessStyleValue(key, value);\n\n if (processed !== '' && !isCustomProperty(key) && key.indexOf('-') !== -1 && hyphenatedCache[key] === undefined) {\n hyphenatedCache[key] = true;\n console.error(\"Using kebab-case for css properties in objects is not supported. Did you mean \" + key.replace(msPattern, 'ms-').replace(hyphenPattern, function (str, _char) {\n return _char.toUpperCase();\n }) + \"?\");\n }\n\n return processed;\n };\n}\n\nvar shouldWarnAboutInterpolatingClassNameFromCss = true;\n\nfunction handleInterpolation(mergedProps, registered, interpolation, couldBeSelectorInterpolation) {\n if (interpolation == null) {\n return '';\n }\n\n if (interpolation.__emotion_styles !== undefined) {\n if (process.env.NODE_ENV !== 'production' && interpolation.toString() === 'NO_COMPONENT_SELECTOR') {\n throw new Error('Component selectors can only be used in conjunction with babel-plugin-emotion.');\n }\n\n return interpolation;\n }\n\n switch (typeof interpolation) {\n case 'boolean':\n {\n return '';\n }\n\n case 'object':\n {\n if (interpolation.anim === 1) {\n cursor = {\n name: interpolation.name,\n styles: interpolation.styles,\n next: cursor\n };\n return interpolation.name;\n }\n\n if (interpolation.styles !== undefined) {\n var next = interpolation.next;\n\n if (next !== undefined) {\n // not the most efficient thing ever but this is a pretty rare case\n // and there will be very few iterations of this generally\n while (next !== undefined) {\n cursor = {\n name: next.name,\n styles: next.styles,\n next: cursor\n };\n next = next.next;\n }\n }\n\n var styles = interpolation.styles + \";\";\n\n if (process.env.NODE_ENV !== 'production' && interpolation.map !== undefined) {\n styles += interpolation.map;\n }\n\n return styles;\n }\n\n return createStringFromObject(mergedProps, registered, interpolation);\n }\n\n case 'function':\n {\n if (mergedProps !== undefined) {\n var previousCursor = cursor;\n var result = interpolation(mergedProps);\n cursor = previousCursor;\n return handleInterpolation(mergedProps, registered, result, couldBeSelectorInterpolation);\n } else if (process.env.NODE_ENV !== 'production') {\n console.error('Functions that are interpolated in css calls will be stringified.\\n' + 'If you want to have a css call based on props, create a function that returns a css call like this\\n' + 'let dynamicStyle = (props) => css`color: ${props.color}`\\n' + 'It can be called directly with props or interpolated in a styled call like this\\n' + \"let SomeComponent = styled('div')`${dynamicStyle}`\");\n }\n\n break;\n }\n\n case 'string':\n if (process.env.NODE_ENV !== 'production') {\n var matched = [];\n var replaced = interpolation.replace(animationRegex, function (match, p1, p2) {\n var fakeVarName = \"animation\" + matched.length;\n matched.push(\"const \" + fakeVarName + \" = keyframes`\" + p2.replace(/^@keyframes animation-\\w+/, '') + \"`\");\n return \"${\" + fakeVarName + \"}\";\n });\n\n if (matched.length) {\n console.error('`keyframes` output got interpolated into plain string, please wrap it with `css`.\\n\\n' + 'Instead of doing this:\\n\\n' + [].concat(matched, [\"`\" + replaced + \"`\"]).join('\\n') + '\\n\\nYou should wrap it with `css` like this:\\n\\n' + (\"css`\" + replaced + \"`\"));\n }\n }\n\n break;\n } // finalize string values (regular strings and functions interpolated into css calls)\n\n\n if (registered == null) {\n return interpolation;\n }\n\n var cached = registered[interpolation];\n\n if (process.env.NODE_ENV !== 'production' && couldBeSelectorInterpolation && shouldWarnAboutInterpolatingClassNameFromCss && cached !== undefined) {\n console.error('Interpolating a className from css`` is not recommended and will cause problems with composition.\\n' + 'Interpolating a className from css`` will be completely unsupported in a future major version of Emotion');\n shouldWarnAboutInterpolatingClassNameFromCss = false;\n }\n\n return cached !== undefined && !couldBeSelectorInterpolation ? cached : interpolation;\n}\n\nfunction createStringFromObject(mergedProps, registered, obj) {\n var string = '';\n\n if (Array.isArray(obj)) {\n for (var i = 0; i < obj.length; i++) {\n string += handleInterpolation(mergedProps, registered, obj[i], false);\n }\n } else {\n for (var _key in obj) {\n var value = obj[_key];\n\n if (typeof value !== 'object') {\n if (registered != null && registered[value] !== undefined) {\n string += _key + \"{\" + registered[value] + \"}\";\n } else if (isProcessableValue(value)) {\n string += processStyleName(_key) + \":\" + processStyleValue(_key, value) + \";\";\n }\n } else {\n if (_key === 'NO_COMPONENT_SELECTOR' && process.env.NODE_ENV !== 'production') {\n throw new Error('Component selectors can only be used in conjunction with babel-plugin-emotion.');\n }\n\n if (Array.isArray(value) && typeof value[0] === 'string' && (registered == null || registered[value[0]] === undefined)) {\n for (var _i = 0; _i < value.length; _i++) {\n if (isProcessableValue(value[_i])) {\n string += processStyleName(_key) + \":\" + processStyleValue(_key, value[_i]) + \";\";\n }\n }\n } else {\n var interpolated = handleInterpolation(mergedProps, registered, value, false);\n\n switch (_key) {\n case 'animation':\n case 'animationName':\n {\n string += processStyleName(_key) + \":\" + interpolated + \";\";\n break;\n }\n\n default:\n {\n if (process.env.NODE_ENV !== 'production' && _key === 'undefined') {\n console.error(UNDEFINED_AS_OBJECT_KEY_ERROR);\n }\n\n string += _key + \"{\" + interpolated + \"}\";\n }\n }\n }\n }\n }\n }\n\n return string;\n}\n\nvar labelPattern = /label:\\s*([^\\s;\\n{]+)\\s*;/g;\nvar sourceMapPattern;\n\nif (process.env.NODE_ENV !== 'production') {\n sourceMapPattern = /\\/\\*#\\ssourceMappingURL=data:application\\/json;\\S+\\s+\\*\\//;\n} // this is the cursor for keyframes\n// keyframes are stored on the SerializedStyles object as a linked list\n\n\nvar cursor;\nvar serializeStyles = function serializeStyles(args, registered, mergedProps) {\n if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && args[0].styles !== undefined) {\n return args[0];\n }\n\n var stringMode = true;\n var styles = '';\n cursor = undefined;\n var strings = args[0];\n\n if (strings == null || strings.raw === undefined) {\n stringMode = false;\n styles += handleInterpolation(mergedProps, registered, strings, false);\n } else {\n if (process.env.NODE_ENV !== 'production' && strings[0] === undefined) {\n console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR);\n }\n\n styles += strings[0];\n } // we start at 1 since we've already handled the first arg\n\n\n for (var i = 1; i < args.length; i++) {\n styles += handleInterpolation(mergedProps, registered, args[i], styles.charCodeAt(styles.length - 1) === 46);\n\n if (stringMode) {\n if (process.env.NODE_ENV !== 'production' && strings[i] === undefined) {\n console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR);\n }\n\n styles += strings[i];\n }\n }\n\n var sourceMap;\n\n if (process.env.NODE_ENV !== 'production') {\n styles = styles.replace(sourceMapPattern, function (match) {\n sourceMap = match;\n return '';\n });\n } // using a global regex with .exec is stateful so lastIndex has to be reset each time\n\n\n labelPattern.lastIndex = 0;\n var identifierName = '';\n var match; // https://esbench.com/bench/5b809c2cf2949800a0f61fb5\n\n while ((match = labelPattern.exec(styles)) !== null) {\n identifierName += '-' + // $FlowFixMe we know it's not null\n match[1];\n }\n\n var name = hashString(styles) + identifierName;\n\n if (process.env.NODE_ENV !== 'production') {\n // $FlowFixMe SerializedStyles type doesn't have toString property (and we don't want to add it)\n return {\n name: name,\n styles: styles,\n map: sourceMap,\n next: cursor,\n toString: function toString() {\n return \"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).\";\n }\n };\n }\n\n return {\n name: name,\n styles: styles,\n next: cursor\n };\n};\n\nexport { serializeStyles };\n","import '@babel/runtime/helpers/inheritsLoose';\nimport { createContext, forwardRef, createElement } from 'react';\nimport createCache from '@emotion/cache';\nimport { getRegisteredStyles, insertStyles } from '@emotion/utils';\nimport { serializeStyles } from '@emotion/serialize';\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar EmotionCacheContext = /*#__PURE__*/createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case\n// because this module is primarily intended for the browser and node\n// but it's also required in react native and similar environments sometimes\n// and we could have a special build just for that\n// but this is much easier and the native packages\n// might use a different theme context in the future anyway\ntypeof HTMLElement !== 'undefined' ? createCache() : null);\nvar ThemeContext = /*#__PURE__*/createContext({});\nvar CacheProvider = EmotionCacheContext.Provider;\n\nvar withEmotionCache = function withEmotionCache(func) {\n var render = function render(props, ref) {\n return /*#__PURE__*/createElement(EmotionCacheContext.Consumer, null, function (cache) {\n return func(props, cache, ref);\n });\n }; // $FlowFixMe\n\n\n return /*#__PURE__*/forwardRef(render);\n};\n\n// thus we only need to replace what is a valid character for JS, but not for CSS\n\nvar sanitizeIdentifier = function sanitizeIdentifier(identifier) {\n return identifier.replace(/\\$/g, '-');\n};\n\nvar typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';\nvar labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';\nvar createEmotionProps = function createEmotionProps(type, props) {\n if (process.env.NODE_ENV !== 'production' && typeof props.css === 'string' && // check if there is a css declaration\n props.css.indexOf(':') !== -1) {\n throw new Error(\"Strings are not allowed as css prop values, please wrap it in a css template literal from '@emotion/css' like this: css`\" + props.css + \"`\");\n }\n\n var newProps = {};\n\n for (var key in props) {\n if (hasOwnProperty.call(props, key)) {\n newProps[key] = props[key];\n }\n }\n\n newProps[typePropName] = type; // TODO: check if this still works with all of those different JSX functions\n\n if (process.env.NODE_ENV !== 'production') {\n var error = new Error();\n\n if (error.stack) {\n // chrome\n var match = error.stack.match(/at (?:Object\\.|Module\\.|)(?:jsx|createEmotionProps).*\\n\\s+at (?:Object\\.|)([A-Z][A-Za-z$]+) /);\n\n if (!match) {\n // safari and firefox\n match = error.stack.match(/.*\\n([A-Z][A-Za-z$]+)@/);\n }\n\n if (match) {\n newProps[labelPropName] = sanitizeIdentifier(match[1]);\n }\n }\n }\n\n return newProps;\n};\n\nvar render = function render(cache, props, theme, ref) {\n var cssProp = theme === null ? props.css : props.css(theme); // so that using `css` from `emotion` and passing the result to the css prop works\n // not passing the registered cache to serializeStyles because it would\n // make certain babel optimisations not possible\n\n if (typeof cssProp === 'string' && cache.registered[cssProp] !== undefined) {\n cssProp = cache.registered[cssProp];\n }\n\n var type = props[typePropName];\n var registeredStyles = [cssProp];\n var className = '';\n\n if (typeof props.className === 'string') {\n className = getRegisteredStyles(cache.registered, registeredStyles, props.className);\n } else if (props.className != null) {\n className = props.className + \" \";\n }\n\n var serialized = serializeStyles(registeredStyles);\n\n if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {\n var labelFromStack = props[labelPropName];\n\n if (labelFromStack) {\n serialized = serializeStyles([serialized, 'label:' + labelFromStack + ';']);\n }\n }\n\n var rules = insertStyles(cache, serialized, typeof type === 'string');\n className += cache.key + \"-\" + serialized.name;\n var newProps = {};\n\n for (var key in props) {\n if (hasOwnProperty.call(props, key) && key !== 'css' && key !== typePropName && (process.env.NODE_ENV === 'production' || key !== labelPropName)) {\n newProps[key] = props[key];\n }\n }\n\n newProps.ref = ref;\n newProps.className = className;\n var ele = /*#__PURE__*/createElement(type, newProps);\n\n return ele;\n}; // eslint-disable-next-line no-undef\n\n\nvar Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {\n if (typeof props.css === 'function') {\n return /*#__PURE__*/createElement(ThemeContext.Consumer, null, function (theme) {\n return render(cache, props, theme, ref);\n });\n }\n\n return render(cache, props, null, ref);\n});\n\nif (process.env.NODE_ENV !== 'production') {\n Emotion.displayName = 'EmotionCssPropInternal';\n}\n\nexport { CacheProvider as C, Emotion as E, ThemeContext as T, createEmotionProps as c, hasOwnProperty as h, withEmotionCache as w };\n","import { serializeStyles } from '@emotion/serialize';\n\nfunction css() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return serializeStyles(args);\n}\n\nexport default css;\n","import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';\nimport { createElement, Component } from 'react';\nimport '@emotion/cache';\nimport { h as hasOwnProperty, E as Emotion, c as createEmotionProps, w as withEmotionCache, T as ThemeContext } from './emotion-element-57a3a7a3.browser.esm.js';\nexport { C as CacheProvider, T as ThemeContext, w as withEmotionCache } from './emotion-element-57a3a7a3.browser.esm.js';\nimport { insertStyles, getRegisteredStyles } from '@emotion/utils';\nimport { serializeStyles } from '@emotion/serialize';\nimport { StyleSheet } from '@emotion/sheet';\nimport css from '@emotion/css';\nexport { default as css } from '@emotion/css';\n\nvar jsx = function jsx(type, props) {\n var args = arguments;\n\n if (props == null || !hasOwnProperty.call(props, 'css')) {\n // $FlowFixMe\n return createElement.apply(undefined, args);\n }\n\n var argsLength = args.length;\n var createElementArgArray = new Array(argsLength);\n createElementArgArray[0] = Emotion;\n createElementArgArray[1] = createEmotionProps(type, props);\n\n for (var i = 2; i < argsLength; i++) {\n createElementArgArray[i] = args[i];\n } // $FlowFixMe\n\n\n return createElement.apply(null, createElementArgArray);\n};\n\nvar warnedAboutCssPropForGlobal = false;\nvar Global = /* #__PURE__ */withEmotionCache(function (props, cache) {\n if (process.env.NODE_ENV !== 'production' && !warnedAboutCssPropForGlobal && ( // check for className as well since the user is\n // probably using the custom createElement which\n // means it will be turned into a className prop\n // $FlowFixMe I don't really want to add it to the type since it shouldn't be used\n props.className || props.css)) {\n console.error(\"It looks like you're using the css prop on Global, did you mean to use the styles prop instead?\");\n warnedAboutCssPropForGlobal = true;\n }\n\n var styles = props.styles;\n\n if (typeof styles === 'function') {\n return /*#__PURE__*/createElement(ThemeContext.Consumer, null, function (theme) {\n var serialized = serializeStyles([styles(theme)]);\n return /*#__PURE__*/createElement(InnerGlobal, {\n serialized: serialized,\n cache: cache\n });\n });\n }\n\n var serialized = serializeStyles([styles]);\n return /*#__PURE__*/createElement(InnerGlobal, {\n serialized: serialized,\n cache: cache\n });\n});\n\n// maintain place over rerenders.\n// initial render from browser, insertBefore context.sheet.tags[0] or if a style hasn't been inserted there yet, appendChild\n// initial client-side render from SSR, use place of hydrating tag\nvar InnerGlobal = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(InnerGlobal, _React$Component);\n\n function InnerGlobal(props, context, updater) {\n return _React$Component.call(this, props, context, updater) || this;\n }\n\n var _proto = InnerGlobal.prototype;\n\n _proto.componentDidMount = function componentDidMount() {\n this.sheet = new StyleSheet({\n key: this.props.cache.key + \"-global\",\n nonce: this.props.cache.sheet.nonce,\n container: this.props.cache.sheet.container\n }); // $FlowFixMe\n\n var node = document.querySelector(\"style[data-emotion-\" + this.props.cache.key + \"=\\\"\" + this.props.serialized.name + \"\\\"]\");\n\n if (node !== null) {\n this.sheet.tags.push(node);\n }\n\n if (this.props.cache.sheet.tags.length) {\n this.sheet.before = this.props.cache.sheet.tags[0];\n }\n\n this.insertStyles();\n };\n\n _proto.componentDidUpdate = function componentDidUpdate(prevProps) {\n if (prevProps.serialized.name !== this.props.serialized.name) {\n this.insertStyles();\n }\n };\n\n _proto.insertStyles = function insertStyles$1() {\n if (this.props.serialized.next !== undefined) {\n // insert keyframes\n insertStyles(this.props.cache, this.props.serialized.next, true);\n }\n\n if (this.sheet.tags.length) {\n // if this doesn't exist then it will be null so the style element will be appended\n var element = this.sheet.tags[this.sheet.tags.length - 1].nextElementSibling;\n this.sheet.before = element;\n this.sheet.flush();\n }\n\n this.props.cache.insert(\"\", this.props.serialized, this.sheet, false);\n };\n\n _proto.componentWillUnmount = function componentWillUnmount() {\n this.sheet.flush();\n };\n\n _proto.render = function render() {\n\n return null;\n };\n\n return InnerGlobal;\n}(Component);\n\nvar keyframes = function keyframes() {\n var insertable = css.apply(void 0, arguments);\n var name = \"animation-\" + insertable.name; // $FlowFixMe\n\n return {\n name: name,\n styles: \"@keyframes \" + name + \"{\" + insertable.styles + \"}\",\n anim: 1,\n toString: function toString() {\n return \"_EMO_\" + this.name + \"_\" + this.styles + \"_EMO_\";\n }\n };\n};\n\nvar classnames = function classnames(args) {\n var len = args.length;\n var i = 0;\n var cls = '';\n\n for (; i < len; i++) {\n var arg = args[i];\n if (arg == null) continue;\n var toAdd = void 0;\n\n switch (typeof arg) {\n case 'boolean':\n break;\n\n case 'object':\n {\n if (Array.isArray(arg)) {\n toAdd = classnames(arg);\n } else {\n toAdd = '';\n\n for (var k in arg) {\n if (arg[k] && k) {\n toAdd && (toAdd += ' ');\n toAdd += k;\n }\n }\n }\n\n break;\n }\n\n default:\n {\n toAdd = arg;\n }\n }\n\n if (toAdd) {\n cls && (cls += ' ');\n cls += toAdd;\n }\n }\n\n return cls;\n};\n\nfunction merge(registered, css, className) {\n var registeredStyles = [];\n var rawClassName = getRegisteredStyles(registered, registeredStyles, className);\n\n if (registeredStyles.length < 2) {\n return className;\n }\n\n return rawClassName + css(registeredStyles);\n}\n\nvar ClassNames = withEmotionCache(function (props, context) {\n return /*#__PURE__*/createElement(ThemeContext.Consumer, null, function (theme) {\n var hasRendered = false;\n\n var css = function css() {\n if (hasRendered && process.env.NODE_ENV !== 'production') {\n throw new Error('css can only be used during render');\n }\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var serialized = serializeStyles(args, context.registered);\n\n {\n insertStyles(context, serialized, false);\n }\n\n return context.key + \"-\" + serialized.name;\n };\n\n var cx = function cx() {\n if (hasRendered && process.env.NODE_ENV !== 'production') {\n throw new Error('cx can only be used during render');\n }\n\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n return merge(context.registered, css, classnames(args));\n };\n\n var content = {\n css: css,\n cx: cx,\n theme: theme\n };\n var ele = props.children(content);\n hasRendered = true;\n\n return ele;\n });\n});\n\nexport { ClassNames, Global, jsx as createElement, jsx, keyframes };\n","/*!\n * html2canvas 1.0.0-rc.5 \n * Copyright (c) 2019 Niklas von Hertzen \n * Released under MIT License\n */\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global = global || self, global.html2canvas = factory());\n}(this, function () { 'use strict';\n\n /*! *****************************************************************************\r\n Copyright (c) Microsoft Corporation. All rights reserved.\r\n Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\n this file except in compliance with the License. You may obtain a copy of the\r\n License at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\n KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\n WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\n MERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\n See the Apache Version 2.0 License for specific language governing permissions\r\n and limitations under the License.\r\n ***************************************************************************** */\r\n /* global Reflect, Promise */\r\n\r\n var extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n\r\n function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n }\r\n\r\n var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n };\r\n\r\n function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n }\r\n\r\n function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n }\n\n var Bounds = /** @class */ (function () {\r\n function Bounds(x, y, w, h) {\r\n this.left = x;\r\n this.top = y;\r\n this.width = w;\r\n this.height = h;\r\n }\r\n Bounds.prototype.add = function (x, y, w, h) {\r\n return new Bounds(this.left + x, this.top + y, this.width + w, this.height + h);\r\n };\r\n Bounds.fromClientRect = function (clientRect) {\r\n return new Bounds(clientRect.left, clientRect.top, clientRect.width, clientRect.height);\r\n };\r\n return Bounds;\r\n }());\r\n var parseBounds = function (node) {\r\n return Bounds.fromClientRect(node.getBoundingClientRect());\r\n };\r\n var parseDocumentSize = function (document) {\r\n var body = document.body;\r\n var documentElement = document.documentElement;\r\n if (!body || !documentElement) {\r\n throw new Error(\"Unable to get document size\");\r\n }\r\n var width = Math.max(Math.max(body.scrollWidth, documentElement.scrollWidth), Math.max(body.offsetWidth, documentElement.offsetWidth), Math.max(body.clientWidth, documentElement.clientWidth));\r\n var height = Math.max(Math.max(body.scrollHeight, documentElement.scrollHeight), Math.max(body.offsetHeight, documentElement.offsetHeight), Math.max(body.clientHeight, documentElement.clientHeight));\r\n return new Bounds(0, 0, width, height);\r\n };\n\n /*\n * css-line-break 1.1.1 \n * Copyright (c) 2019 Niklas von Hertzen \n * Released under MIT License\n */\n var toCodePoints = function (str) {\r\n var codePoints = [];\r\n var i = 0;\r\n var length = str.length;\r\n while (i < length) {\r\n var value = str.charCodeAt(i++);\r\n if (value >= 0xd800 && value <= 0xdbff && i < length) {\r\n var extra = str.charCodeAt(i++);\r\n if ((extra & 0xfc00) === 0xdc00) {\r\n codePoints.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);\r\n }\r\n else {\r\n codePoints.push(value);\r\n i--;\r\n }\r\n }\r\n else {\r\n codePoints.push(value);\r\n }\r\n }\r\n return codePoints;\r\n };\r\n var fromCodePoint = function () {\r\n var codePoints = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n codePoints[_i] = arguments[_i];\r\n }\r\n if (String.fromCodePoint) {\r\n return String.fromCodePoint.apply(String, codePoints);\r\n }\r\n var length = codePoints.length;\r\n if (!length) {\r\n return '';\r\n }\r\n var codeUnits = [];\r\n var index = -1;\r\n var result = '';\r\n while (++index < length) {\r\n var codePoint = codePoints[index];\r\n if (codePoint <= 0xffff) {\r\n codeUnits.push(codePoint);\r\n }\r\n else {\r\n codePoint -= 0x10000;\r\n codeUnits.push((codePoint >> 10) + 0xd800, codePoint % 0x400 + 0xdc00);\r\n }\r\n if (index + 1 === length || codeUnits.length > 0x4000) {\r\n result += String.fromCharCode.apply(String, codeUnits);\r\n codeUnits.length = 0;\r\n }\r\n }\r\n return result;\r\n };\r\n var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\r\n // Use a lookup table to find the index.\r\n var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\r\n for (var i = 0; i < chars.length; i++) {\r\n lookup[chars.charCodeAt(i)] = i;\r\n }\r\n var decode = function (base64) {\r\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\r\n if (base64[base64.length - 1] === '=') {\r\n bufferLength--;\r\n if (base64[base64.length - 2] === '=') {\r\n bufferLength--;\r\n }\r\n }\r\n var buffer = typeof ArrayBuffer !== 'undefined' &&\r\n typeof Uint8Array !== 'undefined' &&\r\n typeof Uint8Array.prototype.slice !== 'undefined'\r\n ? new ArrayBuffer(bufferLength)\r\n : new Array(bufferLength);\r\n var bytes = Array.isArray(buffer) ? buffer : new Uint8Array(buffer);\r\n for (i = 0; i < len; i += 4) {\r\n encoded1 = lookup[base64.charCodeAt(i)];\r\n encoded2 = lookup[base64.charCodeAt(i + 1)];\r\n encoded3 = lookup[base64.charCodeAt(i + 2)];\r\n encoded4 = lookup[base64.charCodeAt(i + 3)];\r\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\r\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\r\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\r\n }\r\n return buffer;\r\n };\r\n var polyUint16Array = function (buffer) {\r\n var length = buffer.length;\r\n var bytes = [];\r\n for (var i = 0; i < length; i += 2) {\r\n bytes.push((buffer[i + 1] << 8) | buffer[i]);\r\n }\r\n return bytes;\r\n };\r\n var polyUint32Array = function (buffer) {\r\n var length = buffer.length;\r\n var bytes = [];\r\n for (var i = 0; i < length; i += 4) {\r\n bytes.push((buffer[i + 3] << 24) | (buffer[i + 2] << 16) | (buffer[i + 1] << 8) | buffer[i]);\r\n }\r\n return bytes;\r\n };\n\n /** Shift size for getting the index-2 table offset. */\r\n var UTRIE2_SHIFT_2 = 5;\r\n /** Shift size for getting the index-1 table offset. */\r\n var UTRIE2_SHIFT_1 = 6 + 5;\r\n /**\r\n * Shift size for shifting left the index array values.\r\n * Increases possible data size with 16-bit index values at the cost\r\n * of compactability.\r\n * This requires data blocks to be aligned by UTRIE2_DATA_GRANULARITY.\r\n */\r\n var UTRIE2_INDEX_SHIFT = 2;\r\n /**\r\n * Difference between the two shift sizes,\r\n * for getting an index-1 offset from an index-2 offset. 6=11-5\r\n */\r\n var UTRIE2_SHIFT_1_2 = UTRIE2_SHIFT_1 - UTRIE2_SHIFT_2;\r\n /**\r\n * The part of the index-2 table for U+D800..U+DBFF stores values for\r\n * lead surrogate code _units_ not code _points_.\r\n * Values for lead surrogate code _points_ are indexed with this portion of the table.\r\n * Length=32=0x20=0x400>>UTRIE2_SHIFT_2. (There are 1024=0x400 lead surrogates.)\r\n */\r\n var UTRIE2_LSCP_INDEX_2_OFFSET = 0x10000 >> UTRIE2_SHIFT_2;\r\n /** Number of entries in a data block. 32=0x20 */\r\n var UTRIE2_DATA_BLOCK_LENGTH = 1 << UTRIE2_SHIFT_2;\r\n /** Mask for getting the lower bits for the in-data-block offset. */\r\n var UTRIE2_DATA_MASK = UTRIE2_DATA_BLOCK_LENGTH - 1;\r\n var UTRIE2_LSCP_INDEX_2_LENGTH = 0x400 >> UTRIE2_SHIFT_2;\r\n /** Count the lengths of both BMP pieces. 2080=0x820 */\r\n var UTRIE2_INDEX_2_BMP_LENGTH = UTRIE2_LSCP_INDEX_2_OFFSET + UTRIE2_LSCP_INDEX_2_LENGTH;\r\n /**\r\n * The 2-byte UTF-8 version of the index-2 table follows at offset 2080=0x820.\r\n * Length 32=0x20 for lead bytes C0..DF, regardless of UTRIE2_SHIFT_2.\r\n */\r\n var UTRIE2_UTF8_2B_INDEX_2_OFFSET = UTRIE2_INDEX_2_BMP_LENGTH;\r\n var UTRIE2_UTF8_2B_INDEX_2_LENGTH = 0x800 >> 6; /* U+0800 is the first code point after 2-byte UTF-8 */\r\n /**\r\n * The index-1 table, only used for supplementary code points, at offset 2112=0x840.\r\n * Variable length, for code points up to highStart, where the last single-value range starts.\r\n * Maximum length 512=0x200=0x100000>>UTRIE2_SHIFT_1.\r\n * (For 0x100000 supplementary code points U+10000..U+10ffff.)\r\n *\r\n * The part of the index-2 table for supplementary code points starts\r\n * after this index-1 table.\r\n *\r\n * Both the index-1 table and the following part of the index-2 table\r\n * are omitted completely if there is only BMP data.\r\n */\r\n var UTRIE2_INDEX_1_OFFSET = UTRIE2_UTF8_2B_INDEX_2_OFFSET + UTRIE2_UTF8_2B_INDEX_2_LENGTH;\r\n /**\r\n * Number of index-1 entries for the BMP. 32=0x20\r\n * This part of the index-1 table is omitted from the serialized form.\r\n */\r\n var UTRIE2_OMITTED_BMP_INDEX_1_LENGTH = 0x10000 >> UTRIE2_SHIFT_1;\r\n /** Number of entries in an index-2 block. 64=0x40 */\r\n var UTRIE2_INDEX_2_BLOCK_LENGTH = 1 << UTRIE2_SHIFT_1_2;\r\n /** Mask for getting the lower bits for the in-index-2-block offset. */\r\n var UTRIE2_INDEX_2_MASK = UTRIE2_INDEX_2_BLOCK_LENGTH - 1;\r\n var slice16 = function (view, start, end) {\r\n if (view.slice) {\r\n return view.slice(start, end);\r\n }\r\n return new Uint16Array(Array.prototype.slice.call(view, start, end));\r\n };\r\n var slice32 = function (view, start, end) {\r\n if (view.slice) {\r\n return view.slice(start, end);\r\n }\r\n return new Uint32Array(Array.prototype.slice.call(view, start, end));\r\n };\r\n var createTrieFromBase64 = function (base64) {\r\n var buffer = decode(base64);\r\n var view32 = Array.isArray(buffer) ? polyUint32Array(buffer) : new Uint32Array(buffer);\r\n var view16 = Array.isArray(buffer) ? polyUint16Array(buffer) : new Uint16Array(buffer);\r\n var headerLength = 24;\r\n var index = slice16(view16, headerLength / 2, view32[4] / 2);\r\n var data = view32[5] === 2\r\n ? slice16(view16, (headerLength + view32[4]) / 2)\r\n : slice32(view32, Math.ceil((headerLength + view32[4]) / 4));\r\n return new Trie(view32[0], view32[1], view32[2], view32[3], index, data);\r\n };\r\n var Trie = /** @class */ (function () {\r\n function Trie(initialValue, errorValue, highStart, highValueIndex, index, data) {\r\n this.initialValue = initialValue;\r\n this.errorValue = errorValue;\r\n this.highStart = highStart;\r\n this.highValueIndex = highValueIndex;\r\n this.index = index;\r\n this.data = data;\r\n }\r\n /**\r\n * Get the value for a code point as stored in the Trie.\r\n *\r\n * @param codePoint the code point\r\n * @return the value\r\n */\r\n Trie.prototype.get = function (codePoint) {\r\n var ix;\r\n if (codePoint >= 0) {\r\n if (codePoint < 0x0d800 || (codePoint > 0x0dbff && codePoint <= 0x0ffff)) {\r\n // Ordinary BMP code point, excluding leading surrogates.\r\n // BMP uses a single level lookup. BMP index starts at offset 0 in the Trie2 index.\r\n // 16 bit data is stored in the index array itself.\r\n ix = this.index[codePoint >> UTRIE2_SHIFT_2];\r\n ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);\r\n return this.data[ix];\r\n }\r\n if (codePoint <= 0xffff) {\r\n // Lead Surrogate Code Point. A Separate index section is stored for\r\n // lead surrogate code units and code points.\r\n // The main index has the code unit data.\r\n // For this function, we need the code point data.\r\n // Note: this expression could be refactored for slightly improved efficiency, but\r\n // surrogate code points will be so rare in practice that it's not worth it.\r\n ix = this.index[UTRIE2_LSCP_INDEX_2_OFFSET + ((codePoint - 0xd800) >> UTRIE2_SHIFT_2)];\r\n ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);\r\n return this.data[ix];\r\n }\r\n if (codePoint < this.highStart) {\r\n // Supplemental code point, use two-level lookup.\r\n ix = UTRIE2_INDEX_1_OFFSET - UTRIE2_OMITTED_BMP_INDEX_1_LENGTH + (codePoint >> UTRIE2_SHIFT_1);\r\n ix = this.index[ix];\r\n ix += (codePoint >> UTRIE2_SHIFT_2) & UTRIE2_INDEX_2_MASK;\r\n ix = this.index[ix];\r\n ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);\r\n return this.data[ix];\r\n }\r\n if (codePoint <= 0x10ffff) {\r\n return this.data[this.highValueIndex];\r\n }\r\n }\r\n // Fall through. The code point is outside of the legal range of 0..0x10ffff.\r\n return this.errorValue;\r\n };\r\n return Trie;\r\n }());\n\n var base64 = 'KwAAAAAAAAAACA4AIDoAAPAfAAACAAAAAAAIABAAGABAAEgAUABYAF4AZgBeAGYAYABoAHAAeABeAGYAfACEAIAAiACQAJgAoACoAK0AtQC9AMUAXgBmAF4AZgBeAGYAzQDVAF4AZgDRANkA3gDmAOwA9AD8AAQBDAEUARoBIgGAAIgAJwEvATcBPwFFAU0BTAFUAVwBZAFsAXMBewGDATAAiwGTAZsBogGkAawBtAG8AcIBygHSAdoB4AHoAfAB+AH+AQYCDgIWAv4BHgImAi4CNgI+AkUCTQJTAlsCYwJrAnECeQKBAk0CiQKRApkCoQKoArACuALAAsQCzAIwANQC3ALkAjAA7AL0AvwCAQMJAxADGAMwACADJgMuAzYDPgOAAEYDSgNSA1IDUgNaA1oDYANiA2IDgACAAGoDgAByA3YDfgOAAIQDgACKA5IDmgOAAIAAogOqA4AAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAK8DtwOAAIAAvwPHA88D1wPfAyAD5wPsA/QD/AOAAIAABAQMBBIEgAAWBB4EJgQuBDMEIAM7BEEEXgBJBCADUQRZBGEEaQQwADAAcQQ+AXkEgQSJBJEEgACYBIAAoASoBK8EtwQwAL8ExQSAAIAAgACAAIAAgACgAM0EXgBeAF4AXgBeAF4AXgBeANUEXgDZBOEEXgDpBPEE+QQBBQkFEQUZBSEFKQUxBTUFPQVFBUwFVAVcBV4AYwVeAGsFcwV7BYMFiwWSBV4AmgWgBacFXgBeAF4AXgBeAKsFXgCyBbEFugW7BcIFwgXIBcIFwgXQBdQF3AXkBesF8wX7BQMGCwYTBhsGIwYrBjMGOwZeAD8GRwZNBl4AVAZbBl4AXgBeAF4AXgBeAF4AXgBeAF4AXgBeAGMGXgBqBnEGXgBeAF4AXgBeAF4AXgBeAF4AXgB5BoAG4wSGBo4GkwaAAIADHgR5AF4AXgBeAJsGgABGA4AAowarBrMGswagALsGwwbLBjAA0wbaBtoG3QbaBtoG2gbaBtoG2gblBusG8wb7BgMHCwcTBxsHCwcjBysHMAc1BzUHOgdCB9oGSgdSB1oHYAfaBloHaAfaBlIH2gbaBtoG2gbaBtoG2gbaBjUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHbQdeAF4ANQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQd1B30HNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B4MH2gaKB68EgACAAIAAgACAAIAAgACAAI8HlwdeAJ8HpweAAIAArwe3B14AXgC/B8UHygcwANAH2AfgB4AA6AfwBz4B+AcACFwBCAgPCBcIogEYAR8IJwiAAC8INwg/CCADRwhPCFcIXwhnCEoDGgSAAIAAgABvCHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIfQh3CHgIeQh6CHsIfAh9CHcIeAh5CHoIewh8CH0Idwh4CHkIegh7CHwIhAiLCI4IMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAANQc1BzUHNQc1BzUHNQc1BzUHNQc1B54INQc1B6II2gaqCLIIugiAAIAAvgjGCIAAgACAAIAAgACAAIAAgACAAIAAywiHAYAA0wiAANkI3QjlCO0I9Aj8CIAAgACAAAIJCgkSCRoJIgknCTYHLwk3CZYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiWCJYIlgiAAIAAAAFAAXgBeAGAAcABeAHwAQACQAKAArQC9AJ4AXgBeAE0A3gBRAN4A7AD8AMwBGgEAAKcBNwEFAUwBXAF4QkhCmEKnArcCgAHHAsABz4LAAcABwAHAAd+C6ABoAG+C/4LAAcABwAHAAc+DF4MAAcAB54M3gweDV4Nng3eDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEeDqABVg6WDqABoQ6gAaABoAHXDvcONw/3DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DvcO9w73DncPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcAB7cPPwlGCU4JMACAAIAAgABWCV4JYQmAAGkJcAl4CXwJgAkwADAAMAAwAIgJgACLCZMJgACZCZ8JowmrCYAAswkwAF4AXgB8AIAAuwkABMMJyQmAAM4JgADVCTAAMAAwADAAgACAAIAAgACAAIAAgACAAIAAqwYWBNkIMAAwADAAMADdCeAJ6AnuCR4E9gkwAP4JBQoNCjAAMACAABUK0wiAAB0KJAosCjQKgAAwADwKQwqAAEsKvQmdCVMKWwowADAAgACAALcEMACAAGMKgABrCjAAMAAwADAAMAAwADAAMAAwADAAMAAeBDAAMAAwADAAMAAwADAAMAAwADAAMAAwAIkEPQFzCnoKiQSCCooKkAqJBJgKoAqkCokEGAGsCrQKvArBCjAAMADJCtEKFQHZCuEK/gHpCvEKMAAwADAAMACAAIwE+QowAIAAPwEBCzAAMAAwADAAMACAAAkLEQswAIAAPwEZCyELgAAOCCkLMAAxCzkLMAAwADAAMAAwADAAXgBeAEELMAAwADAAMAAwADAAMAAwAEkLTQtVC4AAXAtkC4AAiQkwADAAMAAwADAAMAAwADAAbAtxC3kLgAuFC4sLMAAwAJMLlwufCzAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAApwswADAAMACAAIAAgACvC4AAgACAAIAAgACAALcLMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAvwuAAMcLgACAAIAAgACAAIAAyguAAIAAgACAAIAA0QswADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAANkLgACAAIAA4AswADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACJCR4E6AswADAAhwHwC4AA+AsADAgMEAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMACAAIAAGAwdDCUMMAAwAC0MNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQw1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHPQwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADUHNQc1BzUHNQc1BzUHNQc2BzAAMAA5DDUHNQc1BzUHNQc1BzUHNQc1BzUHNQdFDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAgACAAIAATQxSDFoMMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAF4AXgBeAF4AXgBeAF4AYgxeAGoMXgBxDHkMfwxeAIUMXgBeAI0MMAAwADAAMAAwAF4AXgCVDJ0MMAAwADAAMABeAF4ApQxeAKsMswy7DF4Awgy9DMoMXgBeAF4AXgBeAF4AXgBeAF4AXgDRDNkMeQBqCeAM3Ax8AOYM7Az0DPgMXgBeAF4AXgBeAF4AXgBeAF4AXgBeAF4AXgBeAF4AXgCgAAANoAAHDQ4NFg0wADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAeDSYNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIAAgACAAIAAgACAAC4NMABeAF4ANg0wADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAD4NRg1ODVYNXg1mDTAAbQ0wADAAMAAwADAAMAAwADAA2gbaBtoG2gbaBtoG2gbaBnUNeg3CBYANwgWFDdoGjA3aBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gaUDZwNpA2oDdoG2gawDbcNvw3HDdoG2gbPDdYN3A3fDeYN2gbsDfMN2gbaBvoN/g3aBgYODg7aBl4AXgBeABYOXgBeACUG2gYeDl4AJA5eACwO2w3aBtoGMQ45DtoG2gbaBtoGQQ7aBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gZJDjUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B1EO2gY1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQdZDjUHNQc1BzUHNQc1B2EONQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHaA41BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B3AO2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gY1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1BzUHNQc1B2EO2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gZJDtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBtoG2gbaBkkOeA6gAKAAoAAwADAAMAAwAKAAoACgAKAAoACgAKAAgA4wADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAD//wQABAAEAAQABAAEAAQABAAEAA0AAwABAAEAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAKABMAFwAeABsAGgAeABcAFgASAB4AGwAYAA8AGAAcAEsASwBLAEsASwBLAEsASwBLAEsAGAAYAB4AHgAeABMAHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAFgAbABIAHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYADQARAB4ABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkAFgAaABsAGwAbAB4AHQAdAB4ATwAXAB4ADQAeAB4AGgAbAE8ATwAOAFAAHQAdAB0ATwBPABcATwBPAE8AFgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAFAATwBAAE8ATwBPAEAATwBQAFAATwBQAB4AHgAeAB4AHgAeAB0AHQAdAB0AHgAdAB4ADgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgBQAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkACQAJAAkACQAJAAkABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAFAAHgAeAB4AKwArAFAAUABQAFAAGABQACsAKwArACsAHgAeAFAAHgBQAFAAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUAAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAYAA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwArAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAAQABAANAA0ASwBLAEsASwBLAEsASwBLAEsASwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAKwArACsAUABQAFAAUAArACsABABQAAQABAAEAAQABAAEAAQAKwArAAQABAArACsABAAEAAQAUAArACsAKwArACsAKwArACsABAArACsAKwArAFAAUAArAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAGgAaAFAAUABQAFAAUABMAB4AGwBQAB4AKwArACsABAAEAAQAKwBQAFAAUABQAFAAUAArACsAKwArAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUAArAFAAUAArACsABAArAAQABAAEAAQABAArACsAKwArAAQABAArACsABAAEAAQAKwArACsABAArACsAKwArACsAKwArAFAAUABQAFAAKwBQACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwAEAAQAUABQAFAABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUAArACsABABQAAQABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQAKwArAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwAeABsAKwArACsAKwArACsAKwBQAAQABAAEAAQABAAEACsABAAEAAQAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwArAAQABAArACsABAAEAAQAKwArACsAKwArACsAKwArAAQABAArACsAKwArAFAAUAArAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwAeAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwAEAFAAKwBQAFAAUABQAFAAUAArACsAKwBQAFAAUAArAFAAUABQAFAAKwArACsAUABQACsAUAArAFAAUAArACsAKwBQAFAAKwArACsAUABQAFAAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQAKwArACsABAAEAAQAKwAEAAQABAAEACsAKwBQACsAKwArACsAKwArAAQAKwArACsAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAB4AHgAeAB4AHgAeABsAHgArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABAArACsAKwArACsAKwArAAQABAArAFAAUABQACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAB4AUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABAArACsAKwArACsAKwArAAQABAArACsAKwArACsAKwArAFAAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwArAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAKwBcAFwAKwBcACsAKwBcACsAKwArACsAKwArAFwAXABcAFwAKwBcAFwAXABcAFwAXABcACsAXABcAFwAKwBcACsAXAArACsAXABcACsAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgArACoAKgBcACsAKwBcAFwAXABcAFwAKwBcACsAKgAqACoAKgAqACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAFwAXABcAFwAUAAOAA4ADgAOAB4ADgAOAAkADgAOAA0ACQATABMAEwATABMACQAeABMAHgAeAB4ABAAEAB4AHgAeAB4AHgAeAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUAANAAQAHgAEAB4ABAAWABEAFgARAAQABABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAAQABAAEAAQABAANAAQABABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsADQANAB4AHgAeAB4AHgAeAAQAHgAeAB4AHgAeAB4AKwAeAB4ADgAOAA0ADgAeAB4AHgAeAB4ACQAJACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgAeAB4AHgBcAFwAXABcAFwAXAAqACoAKgAqAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAKgAqACoAKgAqACoAKgBcAFwAXAAqACoAKgAqAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAXAAqAEsASwBLAEsASwBLAEsASwBLAEsAKgAqACoAKgAqACoAUABQAFAAUABQAFAAKwBQACsAKwArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQACsAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwAEAAQABAAeAA0AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYAEQArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAADQANAA0AUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAA0ADQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQACsABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoADQANABUAXAANAB4ADQAbAFwAKgArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAB4AHgATABMADQANAA4AHgATABMAHgAEAAQABAAJACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAUABQAFAAUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwAeACsAKwArABMAEwBLAEsASwBLAEsASwBLAEsASwBLAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwBcAFwAXABcAFwAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcACsAKwArACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwAeAB4AXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgArACsABABLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKgAqACoAKgAqACoAKgBcACoAKgAqACoAKgAqACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAUABQAFAAUABQAFAAUAArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4ADQANAA0ADQAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAHgAeAB4AHgBQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwANAA0ADQANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwBQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsABAAEAAQAHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAABABQAFAAUABQAAQABAAEAFAAUAAEAAQABAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAKwBQACsAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAHgAeAB4AHgAeAB4AHgAeAFAAHgAeAB4AUABQAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAKwArAB4AHgAeAB4AHgAeACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAUABQAFAAKwAeAB4AHgAeAB4AHgAeAA4AHgArAA0ADQANAA0ADQANAA0ACQANAA0ADQAIAAQACwAEAAQADQAJAA0ADQAMAB0AHQAeABcAFwAWABcAFwAXABYAFwAdAB0AHgAeABQAFAAUAA0AAQABAAQABAAEAAQABAAJABoAGgAaABoAGgAaABoAGgAeABcAFwAdABUAFQAeAB4AHgAeAB4AHgAYABYAEQAVABUAFQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgANAB4ADQANAA0ADQAeAA0ADQANAAcAHgAeAB4AHgArAAQABAAEAAQABAAEAAQABAAEAAQAUABQACsAKwBPAFAAUABQAFAAUAAeAB4AHgAWABEATwBQAE8ATwBPAE8AUABQAFAAUABQAB4AHgAeABYAEQArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAGwAbABsAGwAbABsAGwAaABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAaABsAGwAbABsAGgAbABsAGgAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgBQABoAHgAdAB4AUAAeABoAHgAeAB4AHgAeAB4AHgAeAB4ATwAeAFAAGwAeAB4AUABQAFAAUABQAB4AHgAeAB0AHQAeAFAAHgBQAB4AUAAeAFAATwBQAFAAHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AUABQAFAAUABPAE8AUABQAFAAUABQAE8AUABQAE8AUABPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBQAFAAUABQAE8ATwBPAE8ATwBPAE8ATwBPAE8AUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAATwAeAB4AKwArACsAKwAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB0AHQAeAB4AHgAdAB0AHgAeAB0AHgAeAB4AHQAeAB0AGwAbAB4AHQAeAB4AHgAeAB0AHgAeAB0AHQAdAB0AHgAeAB0AHgAdAB4AHQAdAB0AHQAdAB0AHgAdAB4AHgAeAB4AHgAdAB0AHQAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAdAB4AHgAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHgAdAB0AHQAdAB4AHgAdAB0AHgAeAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHQAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABQAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAlACUAHgAeAB4AHgAeAB4AHgAeAB4AFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBQAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeAB4AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAdAB0AHQAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAeAB4AHgAeAB0AHQAeAB4AHgAeAB0AHQAdAB4AHgAdAB4AHgAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB0AHQAeAB4AHQAeAB4AHgAeAB0AHQAeAB4AHgAeACUAJQAdAB0AJQAeACUAJQAlACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAHgAeAB4AHgAdAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHQAdAB0AHgAdACUAHQAdAB4AHQAdAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAHQAdAB0AHQAlAB4AJQAlACUAHQAlACUAHQAdAB0AJQAlAB0AHQAlAB0AHQAlACUAJQAeAB0AHgAeAB4AHgAdAB0AJQAdAB0AHQAdAB0AHQAlACUAJQAlACUAHQAlACUAIAAlAB0AHQAlACUAJQAlACUAJQAlACUAHgAeAB4AJQAlACAAIAAgACAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeABcAFwAXABcAFwAXAB4AEwATACUAHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAWABEAFgARAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAeAB4AKwArACsAKwArABMADQANAA0AUAATAA0AUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUAANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAA0ADQANAA0ADQANAA0ADQAeAA0AFgANAB4AHgAXABcAHgAeABcAFwAWABEAFgARABYAEQAWABEADQANAA0ADQATAFAADQANAB4ADQANAB4AHgAeAB4AHgAMAAwADQANAA0AHgANAA0AFgANAA0ADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArAA0AEQARACUAJQBHAFcAVwAWABEAFgARABYAEQAWABEAFgARACUAJQAWABEAFgARABYAEQAWABEAFQAWABEAEQAlAFcAVwBXAFcAVwBXAFcAVwBXAAQABAAEAAQABAAEACUAVwBXAFcAVwA2ACUAJQBXAFcAVwBHAEcAJQAlACUAKwBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBRAFcAUQBXAFEAVwBXAFcAVwBXAFcAUQBXAFcAVwBXAFcAVwBRAFEAKwArAAQABAAVABUARwBHAFcAFQBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBRAFcAVwBXAFcAVwBXAFEAUQBXAFcAVwBXABUAUQBHAEcAVwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwArACUAJQBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAKwArACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAE8ATwBPAE8ATwBPAE8ATwAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADQATAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQAHgBQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeACsAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUAArACsAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQBQAFAAUABQACsAKwArACsAUABQAFAAUABQAFAAUABQAA0AUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQACsAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgBQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAABAAEAAQAKwAEAAQAKwArACsAKwArAAQABAAEAAQAUABQAFAAUAArAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsABAAEAAQAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsADQANAA0ADQANAA0ADQANAB4AKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AUABQAFAAUABQAFAAUABQAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAUABQAFAAUABQAA0ADQANAA0ADQANABQAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwANAA0ADQANAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAeAAQABAAEAB4AKwArAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLACsADQArAB4AKwArAAQABAAEAAQAUABQAB4AUAArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwAEAAQABAAEAAQABAAEAAQABAAOAA0ADQATABMAHgAeAB4ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0AUABQAFAAUAAEAAQAKwArAAQADQANAB4AUAArACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXABcAA0ADQANACoASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUAArACsAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANACsADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEcARwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQACsAKwAeAAQABAANAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAHgAeAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAEAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUAArACsAUAArACsAUABQACsAKwBQAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQACsAUABQAFAAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwAeAB4AUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AKwArAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAeAB4ADQANAA0ADQAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAArAAQABAArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAEAAQABAAEAAQABAAEACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAFgAWAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAKwBQACsAKwArACsAKwArAFAAKwArACsAKwBQACsAUAArAFAAKwBQAFAAUAArAFAAUAArAFAAKwArAFAAKwBQACsAUAArAFAAKwBQACsAUABQACsAUAArACsAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAUABQAFAAUAArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUAArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAlACUAJQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeACUAJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeACUAJQAlACUAJQAeACUAJQAlACUAJQAgACAAIAAlACUAIAAlACUAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIQAhACEAIQAhACUAJQAgACAAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAgACAAIAAlACUAJQAlACAAJQAgACAAIAAgACAAIAAgACAAIAAlACUAJQAgACUAJQAlACUAIAAgACAAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeACUAHgAlAB4AJQAlACUAJQAlACAAJQAlACUAJQAeACUAHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAgACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAlACUAJQAlACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAIAAgACAAJQAlACUAIAAgACAAIAAgAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFwAXABcAFQAVABUAHgAeAB4AHgAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAIAAgACAAJQAlACUAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAlACAAIAAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsA';\n\n /* @flow */\r\n var LETTER_NUMBER_MODIFIER = 50;\r\n // Non-tailorable Line Breaking Classes\r\n var BK = 1; // Cause a line break (after)\r\n var CR = 2; // Cause a line break (after), except between CR and LF\r\n var LF = 3; // Cause a line break (after)\r\n var CM = 4; // Prohibit a line break between the character and the preceding character\r\n var NL = 5; // Cause a line break (after)\r\n var WJ = 7; // Prohibit line breaks before and after\r\n var ZW = 8; // Provide a break opportunity\r\n var GL = 9; // Prohibit line breaks before and after\r\n var SP = 10; // Enable indirect line breaks\r\n var ZWJ = 11; // Prohibit line breaks within joiner sequences\r\n // Break Opportunities\r\n var B2 = 12; // Provide a line break opportunity before and after the character\r\n var BA = 13; // Generally provide a line break opportunity after the character\r\n var BB = 14; // Generally provide a line break opportunity before the character\r\n var HY = 15; // Provide a line break opportunity after the character, except in numeric context\r\n var CB = 16; // Provide a line break opportunity contingent on additional information\r\n // Characters Prohibiting Certain Breaks\r\n var CL = 17; // Prohibit line breaks before\r\n var CP = 18; // Prohibit line breaks before\r\n var EX = 19; // Prohibit line breaks before\r\n var IN = 20; // Allow only indirect line breaks between pairs\r\n var NS = 21; // Allow only indirect line breaks before\r\n var OP = 22; // Prohibit line breaks after\r\n var QU = 23; // Act like they are both opening and closing\r\n // Numeric Context\r\n var IS = 24; // Prevent breaks after any and before numeric\r\n var NU = 25; // Form numeric expressions for line breaking purposes\r\n var PO = 26; // Do not break following a numeric expression\r\n var PR = 27; // Do not break in front of a numeric expression\r\n var SY = 28; // Prevent a break before; and allow a break after\r\n // Other Characters\r\n var AI = 29; // Act like AL when the resolvedEAW is N; otherwise; act as ID\r\n var AL = 30; // Are alphabetic characters or symbols that are used with alphabetic characters\r\n var CJ = 31; // Treat as NS or ID for strict or normal breaking.\r\n var EB = 32; // Do not break from following Emoji Modifier\r\n var EM = 33; // Do not break from preceding Emoji Base\r\n var H2 = 34; // Form Korean syllable blocks\r\n var H3 = 35; // Form Korean syllable blocks\r\n var HL = 36; // Do not break around a following hyphen; otherwise act as Alphabetic\r\n var ID = 37; // Break before or after; except in some numeric context\r\n var JL = 38; // Form Korean syllable blocks\r\n var JV = 39; // Form Korean syllable blocks\r\n var JT = 40; // Form Korean syllable blocks\r\n var RI = 41; // Keep pairs together. For pairs; break before and after other classes\r\n var SA = 42; // Provide a line break opportunity contingent on additional, language-specific context analysis\r\n var XX = 43; // Have as yet unknown line breaking behavior or unassigned code positions\r\n var BREAK_MANDATORY = '!';\r\n var BREAK_NOT_ALLOWED = '×';\r\n var BREAK_ALLOWED = '÷';\r\n var UnicodeTrie = createTrieFromBase64(base64);\r\n var ALPHABETICS = [AL, HL];\r\n var HARD_LINE_BREAKS = [BK, CR, LF, NL];\r\n var SPACE = [SP, ZW];\r\n var PREFIX_POSTFIX = [PR, PO];\r\n var LINE_BREAKS = HARD_LINE_BREAKS.concat(SPACE);\r\n var KOREAN_SYLLABLE_BLOCK = [JL, JV, JT, H2, H3];\r\n var HYPHEN = [HY, BA];\r\n var codePointsToCharacterClasses = function (codePoints, lineBreak) {\r\n if (lineBreak === void 0) { lineBreak = 'strict'; }\r\n var types = [];\r\n var indicies = [];\r\n var categories = [];\r\n codePoints.forEach(function (codePoint, index) {\r\n var classType = UnicodeTrie.get(codePoint);\r\n if (classType > LETTER_NUMBER_MODIFIER) {\r\n categories.push(true);\r\n classType -= LETTER_NUMBER_MODIFIER;\r\n }\r\n else {\r\n categories.push(false);\r\n }\r\n if (['normal', 'auto', 'loose'].indexOf(lineBreak) !== -1) {\r\n // U+2010, – U+2013, 〜 U+301C, ゠ U+30A0\r\n if ([0x2010, 0x2013, 0x301c, 0x30a0].indexOf(codePoint) !== -1) {\r\n indicies.push(index);\r\n return types.push(CB);\r\n }\r\n }\r\n if (classType === CM || classType === ZWJ) {\r\n // LB10 Treat any remaining combining mark or ZWJ as AL.\r\n if (index === 0) {\r\n indicies.push(index);\r\n return types.push(AL);\r\n }\r\n // LB9 Do not break a combining character sequence; treat it as if it has the line breaking class of\r\n // the base character in all of the following rules. Treat ZWJ as if it were CM.\r\n var prev = types[index - 1];\r\n if (LINE_BREAKS.indexOf(prev) === -1) {\r\n indicies.push(indicies[index - 1]);\r\n return types.push(prev);\r\n }\r\n indicies.push(index);\r\n return types.push(AL);\r\n }\r\n indicies.push(index);\r\n if (classType === CJ) {\r\n return types.push(lineBreak === 'strict' ? NS : ID);\r\n }\r\n if (classType === SA) {\r\n return types.push(AL);\r\n }\r\n if (classType === AI) {\r\n return types.push(AL);\r\n }\r\n // For supplementary characters, a useful default is to treat characters in the range 10000..1FFFD as AL\r\n // and characters in the ranges 20000..2FFFD and 30000..3FFFD as ID, until the implementation can be revised\r\n // to take into account the actual line breaking properties for these characters.\r\n if (classType === XX) {\r\n if ((codePoint >= 0x20000 && codePoint <= 0x2fffd) || (codePoint >= 0x30000 && codePoint <= 0x3fffd)) {\r\n return types.push(ID);\r\n }\r\n else {\r\n return types.push(AL);\r\n }\r\n }\r\n types.push(classType);\r\n });\r\n return [indicies, types, categories];\r\n };\r\n var isAdjacentWithSpaceIgnored = function (a, b, currentIndex, classTypes) {\r\n var current = classTypes[currentIndex];\r\n if (Array.isArray(a) ? a.indexOf(current) !== -1 : a === current) {\r\n var i = currentIndex;\r\n while (i <= classTypes.length) {\r\n i++;\r\n var next = classTypes[i];\r\n if (next === b) {\r\n return true;\r\n }\r\n if (next !== SP) {\r\n break;\r\n }\r\n }\r\n }\r\n if (current === SP) {\r\n var i = currentIndex;\r\n while (i > 0) {\r\n i--;\r\n var prev = classTypes[i];\r\n if (Array.isArray(a) ? a.indexOf(prev) !== -1 : a === prev) {\r\n var n = currentIndex;\r\n while (n <= classTypes.length) {\r\n n++;\r\n var next = classTypes[n];\r\n if (next === b) {\r\n return true;\r\n }\r\n if (next !== SP) {\r\n break;\r\n }\r\n }\r\n }\r\n if (prev !== SP) {\r\n break;\r\n }\r\n }\r\n }\r\n return false;\r\n };\r\n var previousNonSpaceClassType = function (currentIndex, classTypes) {\r\n var i = currentIndex;\r\n while (i >= 0) {\r\n var type = classTypes[i];\r\n if (type === SP) {\r\n i--;\r\n }\r\n else {\r\n return type;\r\n }\r\n }\r\n return 0;\r\n };\r\n var _lineBreakAtIndex = function (codePoints, classTypes, indicies, index, forbiddenBreaks) {\r\n if (indicies[index] === 0) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n var currentIndex = index - 1;\r\n if (Array.isArray(forbiddenBreaks) && forbiddenBreaks[currentIndex] === true) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n var beforeIndex = currentIndex - 1;\r\n var afterIndex = currentIndex + 1;\r\n var current = classTypes[currentIndex];\r\n // LB4 Always break after hard line breaks.\r\n // LB5 Treat CR followed by LF, as well as CR, LF, and NL as hard line breaks.\r\n var before = beforeIndex >= 0 ? classTypes[beforeIndex] : 0;\r\n var next = classTypes[afterIndex];\r\n if (current === CR && next === LF) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n if (HARD_LINE_BREAKS.indexOf(current) !== -1) {\r\n return BREAK_MANDATORY;\r\n }\r\n // LB6 Do not break before hard line breaks.\r\n if (HARD_LINE_BREAKS.indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB7 Do not break before spaces or zero width space.\r\n if (SPACE.indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB8 Break before any character following a zero-width space, even if one or more spaces intervene.\r\n if (previousNonSpaceClassType(currentIndex, classTypes) === ZW) {\r\n return BREAK_ALLOWED;\r\n }\r\n // LB8a Do not break between a zero width joiner and an ideograph, emoji base or emoji modifier.\r\n if (UnicodeTrie.get(codePoints[currentIndex]) === ZWJ && (next === ID || next === EB || next === EM)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB11 Do not break before or after Word joiner and related characters.\r\n if (current === WJ || next === WJ) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB12 Do not break after NBSP and related characters.\r\n if (current === GL) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB12a Do not break before NBSP and related characters, except after spaces and hyphens.\r\n if ([SP, BA, HY].indexOf(current) === -1 && next === GL) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB13 Do not break before ‘]’ or ‘!’ or ‘;’ or ‘/’, even after spaces.\r\n if ([CL, CP, EX, IS, SY].indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB14 Do not break after ‘[’, even after spaces.\r\n if (previousNonSpaceClassType(currentIndex, classTypes) === OP) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB15 Do not break within ‘”[’, even with intervening spaces.\r\n if (isAdjacentWithSpaceIgnored(QU, OP, currentIndex, classTypes)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB16 Do not break between closing punctuation and a nonstarter (lb=NS), even with intervening spaces.\r\n if (isAdjacentWithSpaceIgnored([CL, CP], NS, currentIndex, classTypes)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB17 Do not break within ‘——’, even with intervening spaces.\r\n if (isAdjacentWithSpaceIgnored(B2, B2, currentIndex, classTypes)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB18 Break after spaces.\r\n if (current === SP) {\r\n return BREAK_ALLOWED;\r\n }\r\n // LB19 Do not break before or after quotation marks, such as ‘ ” ’.\r\n if (current === QU || next === QU) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB20 Break before and after unresolved CB.\r\n if (next === CB || current === CB) {\r\n return BREAK_ALLOWED;\r\n }\r\n // LB21 Do not break before hyphen-minus, other hyphens, fixed-width spaces, small kana, and other non-starters, or after acute accents.\r\n if ([BA, HY, NS].indexOf(next) !== -1 || current === BB) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB21a Don't break after Hebrew + Hyphen.\r\n if (before === HL && HYPHEN.indexOf(current) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB21b Don’t break between Solidus and Hebrew letters.\r\n if (current === SY && next === HL) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB22 Do not break between two ellipses, or between letters, numbers or exclamations and ellipsis.\r\n if (next === IN && ALPHABETICS.concat(IN, EX, NU, ID, EB, EM).indexOf(current) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB23 Do not break between digits and letters.\r\n if ((ALPHABETICS.indexOf(next) !== -1 && current === NU) || (ALPHABETICS.indexOf(current) !== -1 && next === NU)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB23a Do not break between numeric prefixes and ideographs, or between ideographs and numeric postfixes.\r\n if ((current === PR && [ID, EB, EM].indexOf(next) !== -1) ||\r\n ([ID, EB, EM].indexOf(current) !== -1 && next === PO)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB24 Do not break between numeric prefix/postfix and letters, or between letters and prefix/postfix.\r\n if ((ALPHABETICS.indexOf(current) !== -1 && PREFIX_POSTFIX.indexOf(next) !== -1) ||\r\n (PREFIX_POSTFIX.indexOf(current) !== -1 && ALPHABETICS.indexOf(next) !== -1)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB25 Do not break between the following pairs of classes relevant to numbers:\r\n if (\r\n // (PR | PO) × ( OP | HY )? NU\r\n ([PR, PO].indexOf(current) !== -1 &&\r\n (next === NU || ([OP, HY].indexOf(next) !== -1 && classTypes[afterIndex + 1] === NU))) ||\r\n // ( OP | HY ) × NU\r\n ([OP, HY].indexOf(current) !== -1 && next === NU) ||\r\n // NU ×\t(NU | SY | IS)\r\n (current === NU && [NU, SY, IS].indexOf(next) !== -1)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // NU (NU | SY | IS)* × (NU | SY | IS | CL | CP)\r\n if ([NU, SY, IS, CL, CP].indexOf(next) !== -1) {\r\n var prevIndex = currentIndex;\r\n while (prevIndex >= 0) {\r\n var type = classTypes[prevIndex];\r\n if (type === NU) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n else if ([SY, IS].indexOf(type) !== -1) {\r\n prevIndex--;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n // NU (NU | SY | IS)* (CL | CP)? × (PO | PR))\r\n if ([PR, PO].indexOf(next) !== -1) {\r\n var prevIndex = [CL, CP].indexOf(current) !== -1 ? beforeIndex : currentIndex;\r\n while (prevIndex >= 0) {\r\n var type = classTypes[prevIndex];\r\n if (type === NU) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n else if ([SY, IS].indexOf(type) !== -1) {\r\n prevIndex--;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n // LB26 Do not break a Korean syllable.\r\n if ((JL === current && [JL, JV, H2, H3].indexOf(next) !== -1) ||\r\n ([JV, H2].indexOf(current) !== -1 && [JV, JT].indexOf(next) !== -1) ||\r\n ([JT, H3].indexOf(current) !== -1 && next === JT)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB27 Treat a Korean Syllable Block the same as ID.\r\n if ((KOREAN_SYLLABLE_BLOCK.indexOf(current) !== -1 && [IN, PO].indexOf(next) !== -1) ||\r\n (KOREAN_SYLLABLE_BLOCK.indexOf(next) !== -1 && current === PR)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB28 Do not break between alphabetics (“at”).\r\n if (ALPHABETICS.indexOf(current) !== -1 && ALPHABETICS.indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB29 Do not break between numeric punctuation and alphabetics (“e.g.”).\r\n if (current === IS && ALPHABETICS.indexOf(next) !== -1) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB30 Do not break between letters, numbers, or ordinary symbols and opening or closing parentheses.\r\n if ((ALPHABETICS.concat(NU).indexOf(current) !== -1 && next === OP) ||\r\n (ALPHABETICS.concat(NU).indexOf(next) !== -1 && current === CP)) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n // LB30a Break between two regional indicator symbols if and only if there are an even number of regional\r\n // indicators preceding the position of the break.\r\n if (current === RI && next === RI) {\r\n var i = indicies[currentIndex];\r\n var count = 1;\r\n while (i > 0) {\r\n i--;\r\n if (classTypes[i] === RI) {\r\n count++;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n if (count % 2 !== 0) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n }\r\n // LB30b Do not break between an emoji base and an emoji modifier.\r\n if (current === EB && next === EM) {\r\n return BREAK_NOT_ALLOWED;\r\n }\r\n return BREAK_ALLOWED;\r\n };\r\n var cssFormattedClasses = function (codePoints, options) {\r\n if (!options) {\r\n options = { lineBreak: 'normal', wordBreak: 'normal' };\r\n }\r\n var _a = codePointsToCharacterClasses(codePoints, options.lineBreak), indicies = _a[0], classTypes = _a[1], isLetterNumber = _a[2];\r\n if (options.wordBreak === 'break-all' || options.wordBreak === 'break-word') {\r\n classTypes = classTypes.map(function (type) { return ([NU, AL, SA].indexOf(type) !== -1 ? ID : type); });\r\n }\r\n var forbiddenBreakpoints = options.wordBreak === 'keep-all'\r\n ? isLetterNumber.map(function (letterNumber, i) {\r\n return letterNumber && codePoints[i] >= 0x4e00 && codePoints[i] <= 0x9fff;\r\n })\r\n : undefined;\r\n return [indicies, classTypes, forbiddenBreakpoints];\r\n };\r\n var Break = /** @class */ (function () {\r\n function Break(codePoints, lineBreak, start, end) {\r\n this.codePoints = codePoints;\r\n this.required = lineBreak === BREAK_MANDATORY;\r\n this.start = start;\r\n this.end = end;\r\n }\r\n Break.prototype.slice = function () {\r\n return fromCodePoint.apply(void 0, this.codePoints.slice(this.start, this.end));\r\n };\r\n return Break;\r\n }());\r\n var LineBreaker = function (str, options) {\r\n var codePoints = toCodePoints(str);\r\n var _a = cssFormattedClasses(codePoints, options), indicies = _a[0], classTypes = _a[1], forbiddenBreakpoints = _a[2];\r\n var length = codePoints.length;\r\n var lastEnd = 0;\r\n var nextIndex = 0;\r\n return {\r\n next: function () {\r\n if (nextIndex >= length) {\r\n return { done: true, value: null };\r\n }\r\n var lineBreak = BREAK_NOT_ALLOWED;\r\n while (nextIndex < length &&\r\n (lineBreak = _lineBreakAtIndex(codePoints, classTypes, indicies, ++nextIndex, forbiddenBreakpoints)) ===\r\n BREAK_NOT_ALLOWED) { }\r\n if (lineBreak !== BREAK_NOT_ALLOWED || nextIndex === length) {\r\n var value = new Break(codePoints, lineBreak, lastEnd, nextIndex);\r\n lastEnd = nextIndex;\r\n return { value: value, done: false };\r\n }\r\n return { done: true, value: null };\r\n },\r\n };\r\n };\n\n // https://www.w3.org/TR/css-syntax-3\r\n var TokenType;\r\n (function (TokenType) {\r\n TokenType[TokenType[\"STRING_TOKEN\"] = 0] = \"STRING_TOKEN\";\r\n TokenType[TokenType[\"BAD_STRING_TOKEN\"] = 1] = \"BAD_STRING_TOKEN\";\r\n TokenType[TokenType[\"LEFT_PARENTHESIS_TOKEN\"] = 2] = \"LEFT_PARENTHESIS_TOKEN\";\r\n TokenType[TokenType[\"RIGHT_PARENTHESIS_TOKEN\"] = 3] = \"RIGHT_PARENTHESIS_TOKEN\";\r\n TokenType[TokenType[\"COMMA_TOKEN\"] = 4] = \"COMMA_TOKEN\";\r\n TokenType[TokenType[\"HASH_TOKEN\"] = 5] = \"HASH_TOKEN\";\r\n TokenType[TokenType[\"DELIM_TOKEN\"] = 6] = \"DELIM_TOKEN\";\r\n TokenType[TokenType[\"AT_KEYWORD_TOKEN\"] = 7] = \"AT_KEYWORD_TOKEN\";\r\n TokenType[TokenType[\"PREFIX_MATCH_TOKEN\"] = 8] = \"PREFIX_MATCH_TOKEN\";\r\n TokenType[TokenType[\"DASH_MATCH_TOKEN\"] = 9] = \"DASH_MATCH_TOKEN\";\r\n TokenType[TokenType[\"INCLUDE_MATCH_TOKEN\"] = 10] = \"INCLUDE_MATCH_TOKEN\";\r\n TokenType[TokenType[\"LEFT_CURLY_BRACKET_TOKEN\"] = 11] = \"LEFT_CURLY_BRACKET_TOKEN\";\r\n TokenType[TokenType[\"RIGHT_CURLY_BRACKET_TOKEN\"] = 12] = \"RIGHT_CURLY_BRACKET_TOKEN\";\r\n TokenType[TokenType[\"SUFFIX_MATCH_TOKEN\"] = 13] = \"SUFFIX_MATCH_TOKEN\";\r\n TokenType[TokenType[\"SUBSTRING_MATCH_TOKEN\"] = 14] = \"SUBSTRING_MATCH_TOKEN\";\r\n TokenType[TokenType[\"DIMENSION_TOKEN\"] = 15] = \"DIMENSION_TOKEN\";\r\n TokenType[TokenType[\"PERCENTAGE_TOKEN\"] = 16] = \"PERCENTAGE_TOKEN\";\r\n TokenType[TokenType[\"NUMBER_TOKEN\"] = 17] = \"NUMBER_TOKEN\";\r\n TokenType[TokenType[\"FUNCTION\"] = 18] = \"FUNCTION\";\r\n TokenType[TokenType[\"FUNCTION_TOKEN\"] = 19] = \"FUNCTION_TOKEN\";\r\n TokenType[TokenType[\"IDENT_TOKEN\"] = 20] = \"IDENT_TOKEN\";\r\n TokenType[TokenType[\"COLUMN_TOKEN\"] = 21] = \"COLUMN_TOKEN\";\r\n TokenType[TokenType[\"URL_TOKEN\"] = 22] = \"URL_TOKEN\";\r\n TokenType[TokenType[\"BAD_URL_TOKEN\"] = 23] = \"BAD_URL_TOKEN\";\r\n TokenType[TokenType[\"CDC_TOKEN\"] = 24] = \"CDC_TOKEN\";\r\n TokenType[TokenType[\"CDO_TOKEN\"] = 25] = \"CDO_TOKEN\";\r\n TokenType[TokenType[\"COLON_TOKEN\"] = 26] = \"COLON_TOKEN\";\r\n TokenType[TokenType[\"SEMICOLON_TOKEN\"] = 27] = \"SEMICOLON_TOKEN\";\r\n TokenType[TokenType[\"LEFT_SQUARE_BRACKET_TOKEN\"] = 28] = \"LEFT_SQUARE_BRACKET_TOKEN\";\r\n TokenType[TokenType[\"RIGHT_SQUARE_BRACKET_TOKEN\"] = 29] = \"RIGHT_SQUARE_BRACKET_TOKEN\";\r\n TokenType[TokenType[\"UNICODE_RANGE_TOKEN\"] = 30] = \"UNICODE_RANGE_TOKEN\";\r\n TokenType[TokenType[\"WHITESPACE_TOKEN\"] = 31] = \"WHITESPACE_TOKEN\";\r\n TokenType[TokenType[\"EOF_TOKEN\"] = 32] = \"EOF_TOKEN\";\r\n })(TokenType || (TokenType = {}));\r\n var FLAG_UNRESTRICTED = 1 << 0;\r\n var FLAG_ID = 1 << 1;\r\n var FLAG_INTEGER = 1 << 2;\r\n var FLAG_NUMBER = 1 << 3;\r\n var LINE_FEED = 0x000a;\r\n var SOLIDUS = 0x002f;\r\n var REVERSE_SOLIDUS = 0x005c;\r\n var CHARACTER_TABULATION = 0x0009;\r\n var SPACE$1 = 0x0020;\r\n var QUOTATION_MARK = 0x0022;\r\n var EQUALS_SIGN = 0x003d;\r\n var NUMBER_SIGN = 0x0023;\r\n var DOLLAR_SIGN = 0x0024;\r\n var PERCENTAGE_SIGN = 0x0025;\r\n var APOSTROPHE = 0x0027;\r\n var LEFT_PARENTHESIS = 0x0028;\r\n var RIGHT_PARENTHESIS = 0x0029;\r\n var LOW_LINE = 0x005f;\r\n var HYPHEN_MINUS = 0x002d;\r\n var EXCLAMATION_MARK = 0x0021;\r\n var LESS_THAN_SIGN = 0x003c;\r\n var GREATER_THAN_SIGN = 0x003e;\r\n var COMMERCIAL_AT = 0x0040;\r\n var LEFT_SQUARE_BRACKET = 0x005b;\r\n var RIGHT_SQUARE_BRACKET = 0x005d;\r\n var CIRCUMFLEX_ACCENT = 0x003d;\r\n var LEFT_CURLY_BRACKET = 0x007b;\r\n var QUESTION_MARK = 0x003f;\r\n var RIGHT_CURLY_BRACKET = 0x007d;\r\n var VERTICAL_LINE = 0x007c;\r\n var TILDE = 0x007e;\r\n var CONTROL = 0x0080;\r\n var REPLACEMENT_CHARACTER = 0xfffd;\r\n var ASTERISK = 0x002a;\r\n var PLUS_SIGN = 0x002b;\r\n var COMMA = 0x002c;\r\n var COLON = 0x003a;\r\n var SEMICOLON = 0x003b;\r\n var FULL_STOP = 0x002e;\r\n var NULL = 0x0000;\r\n var BACKSPACE = 0x0008;\r\n var LINE_TABULATION = 0x000b;\r\n var SHIFT_OUT = 0x000e;\r\n var INFORMATION_SEPARATOR_ONE = 0x001f;\r\n var DELETE = 0x007f;\r\n var EOF = -1;\r\n var ZERO = 0x0030;\r\n var a = 0x0061;\r\n var e = 0x0065;\r\n var f = 0x0066;\r\n var u = 0x0075;\r\n var z = 0x007a;\r\n var A = 0x0041;\r\n var E = 0x0045;\r\n var F = 0x0046;\r\n var U = 0x0055;\r\n var Z = 0x005a;\r\n var isDigit = function (codePoint) { return codePoint >= ZERO && codePoint <= 0x0039; };\r\n var isSurrogateCodePoint = function (codePoint) { return codePoint >= 0xd800 && codePoint <= 0xdfff; };\r\n var isHex = function (codePoint) {\r\n return isDigit(codePoint) || (codePoint >= A && codePoint <= F) || (codePoint >= a && codePoint <= f);\r\n };\r\n var isLowerCaseLetter = function (codePoint) { return codePoint >= a && codePoint <= z; };\r\n var isUpperCaseLetter = function (codePoint) { return codePoint >= A && codePoint <= Z; };\r\n var isLetter = function (codePoint) { return isLowerCaseLetter(codePoint) || isUpperCaseLetter(codePoint); };\r\n var isNonASCIICodePoint = function (codePoint) { return codePoint >= CONTROL; };\r\n var isWhiteSpace = function (codePoint) {\r\n return codePoint === LINE_FEED || codePoint === CHARACTER_TABULATION || codePoint === SPACE$1;\r\n };\r\n var isNameStartCodePoint = function (codePoint) {\r\n return isLetter(codePoint) || isNonASCIICodePoint(codePoint) || codePoint === LOW_LINE;\r\n };\r\n var isNameCodePoint = function (codePoint) {\r\n return isNameStartCodePoint(codePoint) || isDigit(codePoint) || codePoint === HYPHEN_MINUS;\r\n };\r\n var isNonPrintableCodePoint = function (codePoint) {\r\n return ((codePoint >= NULL && codePoint <= BACKSPACE) ||\r\n codePoint === LINE_TABULATION ||\r\n (codePoint >= SHIFT_OUT && codePoint <= INFORMATION_SEPARATOR_ONE) ||\r\n codePoint === DELETE);\r\n };\r\n var isValidEscape = function (c1, c2) {\r\n if (c1 !== REVERSE_SOLIDUS) {\r\n return false;\r\n }\r\n return c2 !== LINE_FEED;\r\n };\r\n var isIdentifierStart = function (c1, c2, c3) {\r\n if (c1 === HYPHEN_MINUS) {\r\n return isNameStartCodePoint(c2) || isValidEscape(c2, c3);\r\n }\r\n else if (isNameStartCodePoint(c1)) {\r\n return true;\r\n }\r\n else if (c1 === REVERSE_SOLIDUS && isValidEscape(c1, c2)) {\r\n return true;\r\n }\r\n return false;\r\n };\r\n var isNumberStart = function (c1, c2, c3) {\r\n if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {\r\n if (isDigit(c2)) {\r\n return true;\r\n }\r\n return c2 === FULL_STOP && isDigit(c3);\r\n }\r\n if (c1 === FULL_STOP) {\r\n return isDigit(c2);\r\n }\r\n return isDigit(c1);\r\n };\r\n var stringToNumber = function (codePoints) {\r\n var c = 0;\r\n var sign = 1;\r\n if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {\r\n if (codePoints[c] === HYPHEN_MINUS) {\r\n sign = -1;\r\n }\r\n c++;\r\n }\r\n var integers = [];\r\n while (isDigit(codePoints[c])) {\r\n integers.push(codePoints[c++]);\r\n }\r\n var int = integers.length ? parseInt(fromCodePoint.apply(void 0, integers), 10) : 0;\r\n if (codePoints[c] === FULL_STOP) {\r\n c++;\r\n }\r\n var fraction = [];\r\n while (isDigit(codePoints[c])) {\r\n fraction.push(codePoints[c++]);\r\n }\r\n var fracd = fraction.length;\r\n var frac = fracd ? parseInt(fromCodePoint.apply(void 0, fraction), 10) : 0;\r\n if (codePoints[c] === E || codePoints[c] === e) {\r\n c++;\r\n }\r\n var expsign = 1;\r\n if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {\r\n if (codePoints[c] === HYPHEN_MINUS) {\r\n expsign = -1;\r\n }\r\n c++;\r\n }\r\n var exponent = [];\r\n while (isDigit(codePoints[c])) {\r\n exponent.push(codePoints[c++]);\r\n }\r\n var exp = exponent.length ? parseInt(fromCodePoint.apply(void 0, exponent), 10) : 0;\r\n return sign * (int + frac * Math.pow(10, -fracd)) * Math.pow(10, expsign * exp);\r\n };\r\n var LEFT_PARENTHESIS_TOKEN = {\r\n type: TokenType.LEFT_PARENTHESIS_TOKEN\r\n };\r\n var RIGHT_PARENTHESIS_TOKEN = {\r\n type: TokenType.RIGHT_PARENTHESIS_TOKEN\r\n };\r\n var COMMA_TOKEN = { type: TokenType.COMMA_TOKEN };\r\n var SUFFIX_MATCH_TOKEN = { type: TokenType.SUFFIX_MATCH_TOKEN };\r\n var PREFIX_MATCH_TOKEN = { type: TokenType.PREFIX_MATCH_TOKEN };\r\n var COLUMN_TOKEN = { type: TokenType.COLUMN_TOKEN };\r\n var DASH_MATCH_TOKEN = { type: TokenType.DASH_MATCH_TOKEN };\r\n var INCLUDE_MATCH_TOKEN = { type: TokenType.INCLUDE_MATCH_TOKEN };\r\n var LEFT_CURLY_BRACKET_TOKEN = {\r\n type: TokenType.LEFT_CURLY_BRACKET_TOKEN\r\n };\r\n var RIGHT_CURLY_BRACKET_TOKEN = {\r\n type: TokenType.RIGHT_CURLY_BRACKET_TOKEN\r\n };\r\n var SUBSTRING_MATCH_TOKEN = { type: TokenType.SUBSTRING_MATCH_TOKEN };\r\n var BAD_URL_TOKEN = { type: TokenType.BAD_URL_TOKEN };\r\n var BAD_STRING_TOKEN = { type: TokenType.BAD_STRING_TOKEN };\r\n var CDO_TOKEN = { type: TokenType.CDO_TOKEN };\r\n var CDC_TOKEN = { type: TokenType.CDC_TOKEN };\r\n var COLON_TOKEN = { type: TokenType.COLON_TOKEN };\r\n var SEMICOLON_TOKEN = { type: TokenType.SEMICOLON_TOKEN };\r\n var LEFT_SQUARE_BRACKET_TOKEN = {\r\n type: TokenType.LEFT_SQUARE_BRACKET_TOKEN\r\n };\r\n var RIGHT_SQUARE_BRACKET_TOKEN = {\r\n type: TokenType.RIGHT_SQUARE_BRACKET_TOKEN\r\n };\r\n var WHITESPACE_TOKEN = { type: TokenType.WHITESPACE_TOKEN };\r\n var EOF_TOKEN = { type: TokenType.EOF_TOKEN };\r\n var Tokenizer = /** @class */ (function () {\r\n function Tokenizer() {\r\n this._value = [];\r\n }\r\n Tokenizer.prototype.write = function (chunk) {\r\n this._value = this._value.concat(toCodePoints(chunk));\r\n };\r\n Tokenizer.prototype.read = function () {\r\n var tokens = [];\r\n var token = this.consumeToken();\r\n while (token !== EOF_TOKEN) {\r\n tokens.push(token);\r\n token = this.consumeToken();\r\n }\r\n return tokens;\r\n };\r\n Tokenizer.prototype.consumeToken = function () {\r\n var codePoint = this.consumeCodePoint();\r\n switch (codePoint) {\r\n case QUOTATION_MARK:\r\n return this.consumeStringToken(QUOTATION_MARK);\r\n case NUMBER_SIGN:\r\n var c1 = this.peekCodePoint(0);\r\n var c2 = this.peekCodePoint(1);\r\n var c3 = this.peekCodePoint(2);\r\n if (isNameCodePoint(c1) || isValidEscape(c2, c3)) {\r\n var flags = isIdentifierStart(c1, c2, c3) ? FLAG_ID : FLAG_UNRESTRICTED;\r\n var value = this.consumeName();\r\n return { type: TokenType.HASH_TOKEN, value: value, flags: flags };\r\n }\r\n break;\r\n case DOLLAR_SIGN:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return SUFFIX_MATCH_TOKEN;\r\n }\r\n break;\r\n case APOSTROPHE:\r\n return this.consumeStringToken(APOSTROPHE);\r\n case LEFT_PARENTHESIS:\r\n return LEFT_PARENTHESIS_TOKEN;\r\n case RIGHT_PARENTHESIS:\r\n return RIGHT_PARENTHESIS_TOKEN;\r\n case ASTERISK:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return SUBSTRING_MATCH_TOKEN;\r\n }\r\n break;\r\n case PLUS_SIGN:\r\n if (isNumberStart(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeNumericToken();\r\n }\r\n break;\r\n case COMMA:\r\n return COMMA_TOKEN;\r\n case HYPHEN_MINUS:\r\n var e1 = codePoint;\r\n var e2 = this.peekCodePoint(0);\r\n var e3 = this.peekCodePoint(1);\r\n if (isNumberStart(e1, e2, e3)) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeNumericToken();\r\n }\r\n if (isIdentifierStart(e1, e2, e3)) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeIdentLikeToken();\r\n }\r\n if (e2 === HYPHEN_MINUS && e3 === GREATER_THAN_SIGN) {\r\n this.consumeCodePoint();\r\n this.consumeCodePoint();\r\n return CDC_TOKEN;\r\n }\r\n break;\r\n case FULL_STOP:\r\n if (isNumberStart(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeNumericToken();\r\n }\r\n break;\r\n case SOLIDUS:\r\n if (this.peekCodePoint(0) === ASTERISK) {\r\n this.consumeCodePoint();\r\n while (true) {\r\n var c = this.consumeCodePoint();\r\n if (c === ASTERISK) {\r\n c = this.consumeCodePoint();\r\n if (c === SOLIDUS) {\r\n return this.consumeToken();\r\n }\r\n }\r\n if (c === EOF) {\r\n return this.consumeToken();\r\n }\r\n }\r\n }\r\n break;\r\n case COLON:\r\n return COLON_TOKEN;\r\n case SEMICOLON:\r\n return SEMICOLON_TOKEN;\r\n case LESS_THAN_SIGN:\r\n if (this.peekCodePoint(0) === EXCLAMATION_MARK &&\r\n this.peekCodePoint(1) === HYPHEN_MINUS &&\r\n this.peekCodePoint(2) === HYPHEN_MINUS) {\r\n this.consumeCodePoint();\r\n this.consumeCodePoint();\r\n return CDO_TOKEN;\r\n }\r\n break;\r\n case COMMERCIAL_AT:\r\n var a1 = this.peekCodePoint(0);\r\n var a2 = this.peekCodePoint(1);\r\n var a3 = this.peekCodePoint(2);\r\n if (isIdentifierStart(a1, a2, a3)) {\r\n var value = this.consumeName();\r\n return { type: TokenType.AT_KEYWORD_TOKEN, value: value };\r\n }\r\n break;\r\n case LEFT_SQUARE_BRACKET:\r\n return LEFT_SQUARE_BRACKET_TOKEN;\r\n case REVERSE_SOLIDUS:\r\n if (isValidEscape(codePoint, this.peekCodePoint(0))) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeIdentLikeToken();\r\n }\r\n break;\r\n case RIGHT_SQUARE_BRACKET:\r\n return RIGHT_SQUARE_BRACKET_TOKEN;\r\n case CIRCUMFLEX_ACCENT:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return PREFIX_MATCH_TOKEN;\r\n }\r\n break;\r\n case LEFT_CURLY_BRACKET:\r\n return LEFT_CURLY_BRACKET_TOKEN;\r\n case RIGHT_CURLY_BRACKET:\r\n return RIGHT_CURLY_BRACKET_TOKEN;\r\n case u:\r\n case U:\r\n var u1 = this.peekCodePoint(0);\r\n var u2 = this.peekCodePoint(1);\r\n if (u1 === PLUS_SIGN && (isHex(u2) || u2 === QUESTION_MARK)) {\r\n this.consumeCodePoint();\r\n this.consumeUnicodeRangeToken();\r\n }\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeIdentLikeToken();\r\n case VERTICAL_LINE:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return DASH_MATCH_TOKEN;\r\n }\r\n if (this.peekCodePoint(0) === VERTICAL_LINE) {\r\n this.consumeCodePoint();\r\n return COLUMN_TOKEN;\r\n }\r\n break;\r\n case TILDE:\r\n if (this.peekCodePoint(0) === EQUALS_SIGN) {\r\n this.consumeCodePoint();\r\n return INCLUDE_MATCH_TOKEN;\r\n }\r\n break;\r\n case EOF:\r\n return EOF_TOKEN;\r\n }\r\n if (isWhiteSpace(codePoint)) {\r\n this.consumeWhiteSpace();\r\n return WHITESPACE_TOKEN;\r\n }\r\n if (isDigit(codePoint)) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeNumericToken();\r\n }\r\n if (isNameStartCodePoint(codePoint)) {\r\n this.reconsumeCodePoint(codePoint);\r\n return this.consumeIdentLikeToken();\r\n }\r\n return { type: TokenType.DELIM_TOKEN, value: fromCodePoint(codePoint) };\r\n };\r\n Tokenizer.prototype.consumeCodePoint = function () {\r\n var value = this._value.shift();\r\n return typeof value === 'undefined' ? -1 : value;\r\n };\r\n Tokenizer.prototype.reconsumeCodePoint = function (codePoint) {\r\n this._value.unshift(codePoint);\r\n };\r\n Tokenizer.prototype.peekCodePoint = function (delta) {\r\n if (delta >= this._value.length) {\r\n return -1;\r\n }\r\n return this._value[delta];\r\n };\r\n Tokenizer.prototype.consumeUnicodeRangeToken = function () {\r\n var digits = [];\r\n var codePoint = this.consumeCodePoint();\r\n while (isHex(codePoint) && digits.length < 6) {\r\n digits.push(codePoint);\r\n codePoint = this.consumeCodePoint();\r\n }\r\n var questionMarks = false;\r\n while (codePoint === QUESTION_MARK && digits.length < 6) {\r\n digits.push(codePoint);\r\n codePoint = this.consumeCodePoint();\r\n questionMarks = true;\r\n }\r\n if (questionMarks) {\r\n var start_1 = parseInt(fromCodePoint.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? ZERO : digit); })), 16);\r\n var end = parseInt(fromCodePoint.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? F : digit); })), 16);\r\n return { type: TokenType.UNICODE_RANGE_TOKEN, start: start_1, end: end };\r\n }\r\n var start = parseInt(fromCodePoint.apply(void 0, digits), 16);\r\n if (this.peekCodePoint(0) === HYPHEN_MINUS && isHex(this.peekCodePoint(1))) {\r\n this.consumeCodePoint();\r\n codePoint = this.consumeCodePoint();\r\n var endDigits = [];\r\n while (isHex(codePoint) && endDigits.length < 6) {\r\n endDigits.push(codePoint);\r\n codePoint = this.consumeCodePoint();\r\n }\r\n var end = parseInt(fromCodePoint.apply(void 0, endDigits), 16);\r\n return { type: TokenType.UNICODE_RANGE_TOKEN, start: start, end: end };\r\n }\r\n else {\r\n return { type: TokenType.UNICODE_RANGE_TOKEN, start: start, end: start };\r\n }\r\n };\r\n Tokenizer.prototype.consumeIdentLikeToken = function () {\r\n var value = this.consumeName();\r\n if (value.toLowerCase() === 'url' && this.peekCodePoint(0) === LEFT_PARENTHESIS) {\r\n this.consumeCodePoint();\r\n return this.consumeUrlToken();\r\n }\r\n else if (this.peekCodePoint(0) === LEFT_PARENTHESIS) {\r\n this.consumeCodePoint();\r\n return { type: TokenType.FUNCTION_TOKEN, value: value };\r\n }\r\n return { type: TokenType.IDENT_TOKEN, value: value };\r\n };\r\n Tokenizer.prototype.consumeUrlToken = function () {\r\n var value = [];\r\n this.consumeWhiteSpace();\r\n if (this.peekCodePoint(0) === EOF) {\r\n return { type: TokenType.URL_TOKEN, value: '' };\r\n }\r\n var next = this.peekCodePoint(0);\r\n if (next === APOSTROPHE || next === QUOTATION_MARK) {\r\n var stringToken = this.consumeStringToken(this.consumeCodePoint());\r\n if (stringToken.type === TokenType.STRING_TOKEN) {\r\n this.consumeWhiteSpace();\r\n if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {\r\n this.consumeCodePoint();\r\n return { type: TokenType.URL_TOKEN, value: stringToken.value };\r\n }\r\n }\r\n this.consumeBadUrlRemnants();\r\n return BAD_URL_TOKEN;\r\n }\r\n while (true) {\r\n var codePoint = this.consumeCodePoint();\r\n if (codePoint === EOF || codePoint === RIGHT_PARENTHESIS) {\r\n return { type: TokenType.URL_TOKEN, value: fromCodePoint.apply(void 0, value) };\r\n }\r\n else if (isWhiteSpace(codePoint)) {\r\n this.consumeWhiteSpace();\r\n if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {\r\n this.consumeCodePoint();\r\n return { type: TokenType.URL_TOKEN, value: fromCodePoint.apply(void 0, value) };\r\n }\r\n this.consumeBadUrlRemnants();\r\n return BAD_URL_TOKEN;\r\n }\r\n else if (codePoint === QUOTATION_MARK ||\r\n codePoint === APOSTROPHE ||\r\n codePoint === LEFT_PARENTHESIS ||\r\n isNonPrintableCodePoint(codePoint)) {\r\n this.consumeBadUrlRemnants();\r\n return BAD_URL_TOKEN;\r\n }\r\n else if (codePoint === REVERSE_SOLIDUS) {\r\n if (isValidEscape(codePoint, this.peekCodePoint(0))) {\r\n value.push(this.consumeEscapedCodePoint());\r\n }\r\n else {\r\n this.consumeBadUrlRemnants();\r\n return BAD_URL_TOKEN;\r\n }\r\n }\r\n else {\r\n value.push(codePoint);\r\n }\r\n }\r\n };\r\n Tokenizer.prototype.consumeWhiteSpace = function () {\r\n while (isWhiteSpace(this.peekCodePoint(0))) {\r\n this.consumeCodePoint();\r\n }\r\n };\r\n Tokenizer.prototype.consumeBadUrlRemnants = function () {\r\n while (true) {\r\n var codePoint = this.consumeCodePoint();\r\n if (codePoint === RIGHT_PARENTHESIS || codePoint === EOF) {\r\n return;\r\n }\r\n if (isValidEscape(codePoint, this.peekCodePoint(0))) {\r\n this.consumeEscapedCodePoint();\r\n }\r\n }\r\n };\r\n Tokenizer.prototype.consumeStringSlice = function (count) {\r\n var SLICE_STACK_SIZE = 60000;\r\n var value = '';\r\n while (count > 0) {\r\n var amount = Math.min(SLICE_STACK_SIZE, count);\r\n value += fromCodePoint.apply(void 0, this._value.splice(0, amount));\r\n count -= amount;\r\n }\r\n this._value.shift();\r\n return value;\r\n };\r\n Tokenizer.prototype.consumeStringToken = function (endingCodePoint) {\r\n var value = '';\r\n var i = 0;\r\n do {\r\n var codePoint = this._value[i];\r\n if (codePoint === EOF || codePoint === undefined || codePoint === endingCodePoint) {\r\n value += this.consumeStringSlice(i);\r\n return { type: TokenType.STRING_TOKEN, value: value };\r\n }\r\n if (codePoint === LINE_FEED) {\r\n this._value.splice(0, i);\r\n return BAD_STRING_TOKEN;\r\n }\r\n if (codePoint === REVERSE_SOLIDUS) {\r\n var next = this._value[i + 1];\r\n if (next !== EOF && next !== undefined) {\r\n if (next === LINE_FEED) {\r\n value += this.consumeStringSlice(i);\r\n i = -1;\r\n this._value.shift();\r\n }\r\n else if (isValidEscape(codePoint, next)) {\r\n value += this.consumeStringSlice(i);\r\n value += fromCodePoint(this.consumeEscapedCodePoint());\r\n i = -1;\r\n }\r\n }\r\n }\r\n i++;\r\n } while (true);\r\n };\r\n Tokenizer.prototype.consumeNumber = function () {\r\n var repr = [];\r\n var type = FLAG_INTEGER;\r\n var c1 = this.peekCodePoint(0);\r\n if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {\r\n repr.push(this.consumeCodePoint());\r\n }\r\n while (isDigit(this.peekCodePoint(0))) {\r\n repr.push(this.consumeCodePoint());\r\n }\r\n c1 = this.peekCodePoint(0);\r\n var c2 = this.peekCodePoint(1);\r\n if (c1 === FULL_STOP && isDigit(c2)) {\r\n repr.push(this.consumeCodePoint(), this.consumeCodePoint());\r\n type = FLAG_NUMBER;\r\n while (isDigit(this.peekCodePoint(0))) {\r\n repr.push(this.consumeCodePoint());\r\n }\r\n }\r\n c1 = this.peekCodePoint(0);\r\n c2 = this.peekCodePoint(1);\r\n var c3 = this.peekCodePoint(2);\r\n if ((c1 === E || c1 === e) && (((c2 === PLUS_SIGN || c2 === HYPHEN_MINUS) && isDigit(c3)) || isDigit(c2))) {\r\n repr.push(this.consumeCodePoint(), this.consumeCodePoint());\r\n type = FLAG_NUMBER;\r\n while (isDigit(this.peekCodePoint(0))) {\r\n repr.push(this.consumeCodePoint());\r\n }\r\n }\r\n return [stringToNumber(repr), type];\r\n };\r\n Tokenizer.prototype.consumeNumericToken = function () {\r\n var _a = this.consumeNumber(), number = _a[0], flags = _a[1];\r\n var c1 = this.peekCodePoint(0);\r\n var c2 = this.peekCodePoint(1);\r\n var c3 = this.peekCodePoint(2);\r\n if (isIdentifierStart(c1, c2, c3)) {\r\n var unit = this.consumeName();\r\n return { type: TokenType.DIMENSION_TOKEN, number: number, flags: flags, unit: unit };\r\n }\r\n if (c1 === PERCENTAGE_SIGN) {\r\n this.consumeCodePoint();\r\n return { type: TokenType.PERCENTAGE_TOKEN, number: number, flags: flags };\r\n }\r\n return { type: TokenType.NUMBER_TOKEN, number: number, flags: flags };\r\n };\r\n Tokenizer.prototype.consumeEscapedCodePoint = function () {\r\n var codePoint = this.consumeCodePoint();\r\n if (isHex(codePoint)) {\r\n var hex = fromCodePoint(codePoint);\r\n while (isHex(this.peekCodePoint(0)) && hex.length < 6) {\r\n hex += fromCodePoint(this.consumeCodePoint());\r\n }\r\n if (isWhiteSpace(this.peekCodePoint(0))) {\r\n this.consumeCodePoint();\r\n }\r\n var hexCodePoint = parseInt(hex, 16);\r\n if (hexCodePoint === 0 || isSurrogateCodePoint(hexCodePoint) || hexCodePoint > 0x10ffff) {\r\n return REPLACEMENT_CHARACTER;\r\n }\r\n return hexCodePoint;\r\n }\r\n if (codePoint === EOF) {\r\n return REPLACEMENT_CHARACTER;\r\n }\r\n return codePoint;\r\n };\r\n Tokenizer.prototype.consumeName = function () {\r\n var result = '';\r\n while (true) {\r\n var codePoint = this.consumeCodePoint();\r\n if (isNameCodePoint(codePoint)) {\r\n result += fromCodePoint(codePoint);\r\n }\r\n else if (isValidEscape(codePoint, this.peekCodePoint(0))) {\r\n result += fromCodePoint(this.consumeEscapedCodePoint());\r\n }\r\n else {\r\n this.reconsumeCodePoint(codePoint);\r\n return result;\r\n }\r\n }\r\n };\r\n return Tokenizer;\r\n }());\n\n var Parser = /** @class */ (function () {\r\n function Parser(tokens) {\r\n this._tokens = tokens;\r\n }\r\n Parser.create = function (value) {\r\n var tokenizer = new Tokenizer();\r\n tokenizer.write(value);\r\n return new Parser(tokenizer.read());\r\n };\r\n Parser.parseValue = function (value) {\r\n return Parser.create(value).parseComponentValue();\r\n };\r\n Parser.parseValues = function (value) {\r\n return Parser.create(value).parseComponentValues();\r\n };\r\n Parser.prototype.parseComponentValue = function () {\r\n var token = this.consumeToken();\r\n while (token.type === TokenType.WHITESPACE_TOKEN) {\r\n token = this.consumeToken();\r\n }\r\n if (token.type === TokenType.EOF_TOKEN) {\r\n throw new SyntaxError(\"Error parsing CSS component value, unexpected EOF\");\r\n }\r\n this.reconsumeToken(token);\r\n var value = this.consumeComponentValue();\r\n do {\r\n token = this.consumeToken();\r\n } while (token.type === TokenType.WHITESPACE_TOKEN);\r\n if (token.type === TokenType.EOF_TOKEN) {\r\n return value;\r\n }\r\n throw new SyntaxError(\"Error parsing CSS component value, multiple values found when expecting only one\");\r\n };\r\n Parser.prototype.parseComponentValues = function () {\r\n var values = [];\r\n while (true) {\r\n var value = this.consumeComponentValue();\r\n if (value.type === TokenType.EOF_TOKEN) {\r\n return values;\r\n }\r\n values.push(value);\r\n values.push();\r\n }\r\n };\r\n Parser.prototype.consumeComponentValue = function () {\r\n var token = this.consumeToken();\r\n switch (token.type) {\r\n case TokenType.LEFT_CURLY_BRACKET_TOKEN:\r\n case TokenType.LEFT_SQUARE_BRACKET_TOKEN:\r\n case TokenType.LEFT_PARENTHESIS_TOKEN:\r\n return this.consumeSimpleBlock(token.type);\r\n case TokenType.FUNCTION_TOKEN:\r\n return this.consumeFunction(token);\r\n }\r\n return token;\r\n };\r\n Parser.prototype.consumeSimpleBlock = function (type) {\r\n var block = { type: type, values: [] };\r\n var token = this.consumeToken();\r\n while (true) {\r\n if (token.type === TokenType.EOF_TOKEN || isEndingTokenFor(token, type)) {\r\n return block;\r\n }\r\n this.reconsumeToken(token);\r\n block.values.push(this.consumeComponentValue());\r\n token = this.consumeToken();\r\n }\r\n };\r\n Parser.prototype.consumeFunction = function (functionToken) {\r\n var cssFunction = {\r\n name: functionToken.value,\r\n values: [],\r\n type: TokenType.FUNCTION\r\n };\r\n while (true) {\r\n var token = this.consumeToken();\r\n if (token.type === TokenType.EOF_TOKEN || token.type === TokenType.RIGHT_PARENTHESIS_TOKEN) {\r\n return cssFunction;\r\n }\r\n this.reconsumeToken(token);\r\n cssFunction.values.push(this.consumeComponentValue());\r\n }\r\n };\r\n Parser.prototype.consumeToken = function () {\r\n var token = this._tokens.shift();\r\n return typeof token === 'undefined' ? EOF_TOKEN : token;\r\n };\r\n Parser.prototype.reconsumeToken = function (token) {\r\n this._tokens.unshift(token);\r\n };\r\n return Parser;\r\n }());\r\n var isDimensionToken = function (token) { return token.type === TokenType.DIMENSION_TOKEN; };\r\n var isNumberToken = function (token) { return token.type === TokenType.NUMBER_TOKEN; };\r\n var isIdentToken = function (token) { return token.type === TokenType.IDENT_TOKEN; };\r\n var isStringToken = function (token) { return token.type === TokenType.STRING_TOKEN; };\r\n var isIdentWithValue = function (token, value) {\r\n return isIdentToken(token) && token.value === value;\r\n };\r\n var nonWhiteSpace = function (token) { return token.type !== TokenType.WHITESPACE_TOKEN; };\r\n var nonFunctionArgSeparator = function (token) {\r\n return token.type !== TokenType.WHITESPACE_TOKEN && token.type !== TokenType.COMMA_TOKEN;\r\n };\r\n var parseFunctionArgs = function (tokens) {\r\n var args = [];\r\n var arg = [];\r\n tokens.forEach(function (token) {\r\n if (token.type === TokenType.COMMA_TOKEN) {\r\n if (arg.length === 0) {\r\n throw new Error(\"Error parsing function args, zero tokens for arg\");\r\n }\r\n args.push(arg);\r\n arg = [];\r\n return;\r\n }\r\n if (token.type !== TokenType.WHITESPACE_TOKEN) {\r\n arg.push(token);\r\n }\r\n });\r\n if (arg.length) {\r\n args.push(arg);\r\n }\r\n return args;\r\n };\r\n var isEndingTokenFor = function (token, type) {\r\n if (type === TokenType.LEFT_CURLY_BRACKET_TOKEN && token.type === TokenType.RIGHT_CURLY_BRACKET_TOKEN) {\r\n return true;\r\n }\r\n if (type === TokenType.LEFT_SQUARE_BRACKET_TOKEN && token.type === TokenType.RIGHT_SQUARE_BRACKET_TOKEN) {\r\n return true;\r\n }\r\n return type === TokenType.LEFT_PARENTHESIS_TOKEN && token.type === TokenType.RIGHT_PARENTHESIS_TOKEN;\r\n };\n\n var isLength = function (token) {\r\n return token.type === TokenType.NUMBER_TOKEN || token.type === TokenType.DIMENSION_TOKEN;\r\n };\n\n var isLengthPercentage = function (token) {\r\n return token.type === TokenType.PERCENTAGE_TOKEN || isLength(token);\r\n };\r\n var parseLengthPercentageTuple = function (tokens) {\r\n return tokens.length > 1 ? [tokens[0], tokens[1]] : [tokens[0]];\r\n };\r\n var ZERO_LENGTH = {\r\n type: TokenType.NUMBER_TOKEN,\r\n number: 0,\r\n flags: FLAG_INTEGER\r\n };\r\n var FIFTY_PERCENT = {\r\n type: TokenType.PERCENTAGE_TOKEN,\r\n number: 50,\r\n flags: FLAG_INTEGER\r\n };\r\n var HUNDRED_PERCENT = {\r\n type: TokenType.PERCENTAGE_TOKEN,\r\n number: 100,\r\n flags: FLAG_INTEGER\r\n };\r\n var getAbsoluteValueForTuple = function (tuple, width, height) {\r\n var x = tuple[0], y = tuple[1];\r\n return [getAbsoluteValue(x, width), getAbsoluteValue(typeof y !== 'undefined' ? y : x, height)];\r\n };\r\n var getAbsoluteValue = function (token, parent) {\r\n if (token.type === TokenType.PERCENTAGE_TOKEN) {\r\n return (token.number / 100) * parent;\r\n }\r\n if (isDimensionToken(token)) {\r\n switch (token.unit) {\r\n case 'rem':\r\n case 'em':\r\n return 16 * token.number; // TODO use correct font-size\r\n case 'px':\r\n default:\r\n return token.number;\r\n }\r\n }\r\n return token.number;\r\n };\n\n var DEG = 'deg';\r\n var GRAD = 'grad';\r\n var RAD = 'rad';\r\n var TURN = 'turn';\r\n var angle = {\r\n name: 'angle',\r\n parse: function (value) {\r\n if (value.type === TokenType.DIMENSION_TOKEN) {\r\n switch (value.unit) {\r\n case DEG:\r\n return (Math.PI * value.number) / 180;\r\n case GRAD:\r\n return (Math.PI / 200) * value.number;\r\n case RAD:\r\n return value.number;\r\n case TURN:\r\n return Math.PI * 2 * value.number;\r\n }\r\n }\r\n throw new Error(\"Unsupported angle type\");\r\n }\r\n };\r\n var isAngle = function (value) {\r\n if (value.type === TokenType.DIMENSION_TOKEN) {\r\n if (value.unit === DEG || value.unit === GRAD || value.unit === RAD || value.unit === TURN) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n var parseNamedSide = function (tokens) {\r\n var sideOrCorner = tokens\r\n .filter(isIdentToken)\r\n .map(function (ident) { return ident.value; })\r\n .join(' ');\r\n switch (sideOrCorner) {\r\n case 'to bottom right':\r\n case 'to right bottom':\r\n case 'left top':\r\n case 'top left':\r\n return [ZERO_LENGTH, ZERO_LENGTH];\r\n case 'to top':\r\n case 'bottom':\r\n return deg(0);\r\n case 'to bottom left':\r\n case 'to left bottom':\r\n case 'right top':\r\n case 'top right':\r\n return [ZERO_LENGTH, HUNDRED_PERCENT];\r\n case 'to right':\r\n case 'left':\r\n return deg(90);\r\n case 'to top left':\r\n case 'to left top':\r\n case 'right bottom':\r\n case 'bottom right':\r\n return [HUNDRED_PERCENT, HUNDRED_PERCENT];\r\n case 'to bottom':\r\n case 'top':\r\n return deg(180);\r\n case 'to top right':\r\n case 'to right top':\r\n case 'left bottom':\r\n case 'bottom left':\r\n return [HUNDRED_PERCENT, ZERO_LENGTH];\r\n case 'to left':\r\n case 'right':\r\n return deg(270);\r\n }\r\n return 0;\r\n };\r\n var deg = function (deg) { return (Math.PI * deg) / 180; };\n\n var color = {\r\n name: 'color',\r\n parse: function (value) {\r\n if (value.type === TokenType.FUNCTION) {\r\n var colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];\r\n if (typeof colorFunction === 'undefined') {\r\n throw new Error(\"Attempting to parse an unsupported color function \\\"\" + value.name + \"\\\"\");\r\n }\r\n return colorFunction(value.values);\r\n }\r\n if (value.type === TokenType.HASH_TOKEN) {\r\n if (value.value.length === 3) {\r\n var r = value.value.substring(0, 1);\r\n var g = value.value.substring(1, 2);\r\n var b = value.value.substring(2, 3);\r\n return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1);\r\n }\r\n if (value.value.length === 4) {\r\n var r = value.value.substring(0, 1);\r\n var g = value.value.substring(1, 2);\r\n var b = value.value.substring(2, 3);\r\n var a = value.value.substring(3, 4);\r\n return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255);\r\n }\r\n if (value.value.length === 6) {\r\n var r = value.value.substring(0, 2);\r\n var g = value.value.substring(2, 4);\r\n var b = value.value.substring(4, 6);\r\n return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1);\r\n }\r\n if (value.value.length === 8) {\r\n var r = value.value.substring(0, 2);\r\n var g = value.value.substring(2, 4);\r\n var b = value.value.substring(4, 6);\r\n var a = value.value.substring(6, 8);\r\n return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255);\r\n }\r\n }\r\n if (value.type === TokenType.IDENT_TOKEN) {\r\n var namedColor = COLORS[value.value.toUpperCase()];\r\n if (typeof namedColor !== 'undefined') {\r\n return namedColor;\r\n }\r\n }\r\n return COLORS.TRANSPARENT;\r\n }\r\n };\r\n var isTransparent = function (color) { return (0xff & color) === 0; };\r\n var asString = function (color) {\r\n var alpha = 0xff & color;\r\n var blue = 0xff & (color >> 8);\r\n var green = 0xff & (color >> 16);\r\n var red = 0xff & (color >> 24);\r\n return alpha < 255 ? \"rgba(\" + red + \",\" + green + \",\" + blue + \",\" + alpha / 255 + \")\" : \"rgb(\" + red + \",\" + green + \",\" + blue + \")\";\r\n };\r\n var pack = function (r, g, b, a) {\r\n return ((r << 24) | (g << 16) | (b << 8) | (Math.round(a * 255) << 0)) >>> 0;\r\n };\r\n var getTokenColorValue = function (token, i) {\r\n if (token.type === TokenType.NUMBER_TOKEN) {\r\n return token.number;\r\n }\r\n if (token.type === TokenType.PERCENTAGE_TOKEN) {\r\n var max = i === 3 ? 1 : 255;\r\n return i === 3 ? (token.number / 100) * max : Math.round((token.number / 100) * max);\r\n }\r\n return 0;\r\n };\r\n var rgb = function (args) {\r\n var tokens = args.filter(nonFunctionArgSeparator);\r\n if (tokens.length === 3) {\r\n var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2];\r\n return pack(r, g, b, 1);\r\n }\r\n if (tokens.length === 4) {\r\n var _b = tokens.map(getTokenColorValue), r = _b[0], g = _b[1], b = _b[2], a = _b[3];\r\n return pack(r, g, b, a);\r\n }\r\n return 0;\r\n };\r\n function hue2rgb(t1, t2, hue) {\r\n if (hue < 0) {\r\n hue += 1;\r\n }\r\n if (hue >= 1) {\r\n hue -= 1;\r\n }\r\n if (hue < 1 / 6) {\r\n return (t2 - t1) * hue * 6 + t1;\r\n }\r\n else if (hue < 1 / 2) {\r\n return t2;\r\n }\r\n else if (hue < 2 / 3) {\r\n return (t2 - t1) * 6 * (2 / 3 - hue) + t1;\r\n }\r\n else {\r\n return t1;\r\n }\r\n }\r\n var hsl = function (args) {\r\n var tokens = args.filter(nonFunctionArgSeparator);\r\n var hue = tokens[0], saturation = tokens[1], lightness = tokens[2], alpha = tokens[3];\r\n var h = (hue.type === TokenType.NUMBER_TOKEN ? deg(hue.number) : angle.parse(hue)) / (Math.PI * 2);\r\n var s = isLengthPercentage(saturation) ? saturation.number / 100 : 0;\r\n var l = isLengthPercentage(lightness) ? lightness.number / 100 : 0;\r\n var a = typeof alpha !== 'undefined' && isLengthPercentage(alpha) ? getAbsoluteValue(alpha, 1) : 1;\r\n if (s === 0) {\r\n return pack(l * 255, l * 255, l * 255, 1);\r\n }\r\n var t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;\r\n var t1 = l * 2 - t2;\r\n var r = hue2rgb(t1, t2, h + 1 / 3);\r\n var g = hue2rgb(t1, t2, h);\r\n var b = hue2rgb(t1, t2, h - 1 / 3);\r\n return pack(r * 255, g * 255, b * 255, a);\r\n };\r\n var SUPPORTED_COLOR_FUNCTIONS = {\r\n hsl: hsl,\r\n hsla: hsl,\r\n rgb: rgb,\r\n rgba: rgb\r\n };\r\n var COLORS = {\r\n ALICEBLUE: 0xf0f8ffff,\r\n ANTIQUEWHITE: 0xfaebd7ff,\r\n AQUA: 0x00ffffff,\r\n AQUAMARINE: 0x7fffd4ff,\r\n AZURE: 0xf0ffffff,\r\n BEIGE: 0xf5f5dcff,\r\n BISQUE: 0xffe4c4ff,\r\n BLACK: 0x000000ff,\r\n BLANCHEDALMOND: 0xffebcdff,\r\n BLUE: 0x0000ffff,\r\n BLUEVIOLET: 0x8a2be2ff,\r\n BROWN: 0xa52a2aff,\r\n BURLYWOOD: 0xdeb887ff,\r\n CADETBLUE: 0x5f9ea0ff,\r\n CHARTREUSE: 0x7fff00ff,\r\n CHOCOLATE: 0xd2691eff,\r\n CORAL: 0xff7f50ff,\r\n CORNFLOWERBLUE: 0x6495edff,\r\n CORNSILK: 0xfff8dcff,\r\n CRIMSON: 0xdc143cff,\r\n CYAN: 0x00ffffff,\r\n DARKBLUE: 0x00008bff,\r\n DARKCYAN: 0x008b8bff,\r\n DARKGOLDENROD: 0xb886bbff,\r\n DARKGRAY: 0xa9a9a9ff,\r\n DARKGREEN: 0x006400ff,\r\n DARKGREY: 0xa9a9a9ff,\r\n DARKKHAKI: 0xbdb76bff,\r\n DARKMAGENTA: 0x8b008bff,\r\n DARKOLIVEGREEN: 0x556b2fff,\r\n DARKORANGE: 0xff8c00ff,\r\n DARKORCHID: 0x9932ccff,\r\n DARKRED: 0x8b0000ff,\r\n DARKSALMON: 0xe9967aff,\r\n DARKSEAGREEN: 0x8fbc8fff,\r\n DARKSLATEBLUE: 0x483d8bff,\r\n DARKSLATEGRAY: 0x2f4f4fff,\r\n DARKSLATEGREY: 0x2f4f4fff,\r\n DARKTURQUOISE: 0x00ced1ff,\r\n DARKVIOLET: 0x9400d3ff,\r\n DEEPPINK: 0xff1493ff,\r\n DEEPSKYBLUE: 0x00bfffff,\r\n DIMGRAY: 0x696969ff,\r\n DIMGREY: 0x696969ff,\r\n DODGERBLUE: 0x1e90ffff,\r\n FIREBRICK: 0xb22222ff,\r\n FLORALWHITE: 0xfffaf0ff,\r\n FORESTGREEN: 0x228b22ff,\r\n FUCHSIA: 0xff00ffff,\r\n GAINSBORO: 0xdcdcdcff,\r\n GHOSTWHITE: 0xf8f8ffff,\r\n GOLD: 0xffd700ff,\r\n GOLDENROD: 0xdaa520ff,\r\n GRAY: 0x808080ff,\r\n GREEN: 0x008000ff,\r\n GREENYELLOW: 0xadff2fff,\r\n GREY: 0x808080ff,\r\n HONEYDEW: 0xf0fff0ff,\r\n HOTPINK: 0xff69b4ff,\r\n INDIANRED: 0xcd5c5cff,\r\n INDIGO: 0x4b0082ff,\r\n IVORY: 0xfffff0ff,\r\n KHAKI: 0xf0e68cff,\r\n LAVENDER: 0xe6e6faff,\r\n LAVENDERBLUSH: 0xfff0f5ff,\r\n LAWNGREEN: 0x7cfc00ff,\r\n LEMONCHIFFON: 0xfffacdff,\r\n LIGHTBLUE: 0xadd8e6ff,\r\n LIGHTCORAL: 0xf08080ff,\r\n LIGHTCYAN: 0xe0ffffff,\r\n LIGHTGOLDENRODYELLOW: 0xfafad2ff,\r\n LIGHTGRAY: 0xd3d3d3ff,\r\n LIGHTGREEN: 0x90ee90ff,\r\n LIGHTGREY: 0xd3d3d3ff,\r\n LIGHTPINK: 0xffb6c1ff,\r\n LIGHTSALMON: 0xffa07aff,\r\n LIGHTSEAGREEN: 0x20b2aaff,\r\n LIGHTSKYBLUE: 0x87cefaff,\r\n LIGHTSLATEGRAY: 0x778899ff,\r\n LIGHTSLATEGREY: 0x778899ff,\r\n LIGHTSTEELBLUE: 0xb0c4deff,\r\n LIGHTYELLOW: 0xffffe0ff,\r\n LIME: 0x00ff00ff,\r\n LIMEGREEN: 0x32cd32ff,\r\n LINEN: 0xfaf0e6ff,\r\n MAGENTA: 0xff00ffff,\r\n MAROON: 0x800000ff,\r\n MEDIUMAQUAMARINE: 0x66cdaaff,\r\n MEDIUMBLUE: 0x0000cdff,\r\n MEDIUMORCHID: 0xba55d3ff,\r\n MEDIUMPURPLE: 0x9370dbff,\r\n MEDIUMSEAGREEN: 0x3cb371ff,\r\n MEDIUMSLATEBLUE: 0x7b68eeff,\r\n MEDIUMSPRINGGREEN: 0x00fa9aff,\r\n MEDIUMTURQUOISE: 0x48d1ccff,\r\n MEDIUMVIOLETRED: 0xc71585ff,\r\n MIDNIGHTBLUE: 0x191970ff,\r\n MINTCREAM: 0xf5fffaff,\r\n MISTYROSE: 0xffe4e1ff,\r\n MOCCASIN: 0xffe4b5ff,\r\n NAVAJOWHITE: 0xffdeadff,\r\n NAVY: 0x000080ff,\r\n OLDLACE: 0xfdf5e6ff,\r\n OLIVE: 0x808000ff,\r\n OLIVEDRAB: 0x6b8e23ff,\r\n ORANGE: 0xffa500ff,\r\n ORANGERED: 0xff4500ff,\r\n ORCHID: 0xda70d6ff,\r\n PALEGOLDENROD: 0xeee8aaff,\r\n PALEGREEN: 0x98fb98ff,\r\n PALETURQUOISE: 0xafeeeeff,\r\n PALEVIOLETRED: 0xdb7093ff,\r\n PAPAYAWHIP: 0xffefd5ff,\r\n PEACHPUFF: 0xffdab9ff,\r\n PERU: 0xcd853fff,\r\n PINK: 0xffc0cbff,\r\n PLUM: 0xdda0ddff,\r\n POWDERBLUE: 0xb0e0e6ff,\r\n PURPLE: 0x800080ff,\r\n REBECCAPURPLE: 0x663399ff,\r\n RED: 0xff0000ff,\r\n ROSYBROWN: 0xbc8f8fff,\r\n ROYALBLUE: 0x4169e1ff,\r\n SADDLEBROWN: 0x8b4513ff,\r\n SALMON: 0xfa8072ff,\r\n SANDYBROWN: 0xf4a460ff,\r\n SEAGREEN: 0x2e8b57ff,\r\n SEASHELL: 0xfff5eeff,\r\n SIENNA: 0xa0522dff,\r\n SILVER: 0xc0c0c0ff,\r\n SKYBLUE: 0x87ceebff,\r\n SLATEBLUE: 0x6a5acdff,\r\n SLATEGRAY: 0x708090ff,\r\n SLATEGREY: 0x708090ff,\r\n SNOW: 0xfffafaff,\r\n SPRINGGREEN: 0x00ff7fff,\r\n STEELBLUE: 0x4682b4ff,\r\n TAN: 0xd2b48cff,\r\n TEAL: 0x008080ff,\r\n THISTLE: 0xd8bfd8ff,\r\n TOMATO: 0xff6347ff,\r\n TRANSPARENT: 0x00000000,\r\n TURQUOISE: 0x40e0d0ff,\r\n VIOLET: 0xee82eeff,\r\n WHEAT: 0xf5deb3ff,\r\n WHITE: 0xffffffff,\r\n WHITESMOKE: 0xf5f5f5ff,\r\n YELLOW: 0xffff00ff,\r\n YELLOWGREEN: 0x9acd32ff\r\n };\n\n var PropertyDescriptorParsingType;\r\n (function (PropertyDescriptorParsingType) {\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"VALUE\"] = 0] = \"VALUE\";\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"LIST\"] = 1] = \"LIST\";\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"IDENT_VALUE\"] = 2] = \"IDENT_VALUE\";\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"TYPE_VALUE\"] = 3] = \"TYPE_VALUE\";\r\n PropertyDescriptorParsingType[PropertyDescriptorParsingType[\"TOKEN_VALUE\"] = 4] = \"TOKEN_VALUE\";\r\n })(PropertyDescriptorParsingType || (PropertyDescriptorParsingType = {}));\n\n var BACKGROUND_CLIP;\r\n (function (BACKGROUND_CLIP) {\r\n BACKGROUND_CLIP[BACKGROUND_CLIP[\"BORDER_BOX\"] = 0] = \"BORDER_BOX\";\r\n BACKGROUND_CLIP[BACKGROUND_CLIP[\"PADDING_BOX\"] = 1] = \"PADDING_BOX\";\r\n BACKGROUND_CLIP[BACKGROUND_CLIP[\"CONTENT_BOX\"] = 2] = \"CONTENT_BOX\";\r\n })(BACKGROUND_CLIP || (BACKGROUND_CLIP = {}));\r\n var backgroundClip = {\r\n name: 'background-clip',\r\n initialValue: 'border-box',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens.map(function (token) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'padding-box':\r\n return BACKGROUND_CLIP.PADDING_BOX;\r\n case 'content-box':\r\n return BACKGROUND_CLIP.CONTENT_BOX;\r\n }\r\n }\r\n return BACKGROUND_CLIP.BORDER_BOX;\r\n });\r\n }\r\n };\n\n var backgroundColor = {\r\n name: \"background-color\",\r\n initialValue: 'transparent',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'color'\r\n };\n\n var parseColorStop = function (args) {\r\n var color$1 = color.parse(args[0]);\r\n var stop = args[1];\r\n return stop && isLengthPercentage(stop) ? { color: color$1, stop: stop } : { color: color$1, stop: null };\r\n };\r\n var processColorStops = function (stops, lineLength) {\r\n var first = stops[0];\r\n var last = stops[stops.length - 1];\r\n if (first.stop === null) {\r\n first.stop = ZERO_LENGTH;\r\n }\r\n if (last.stop === null) {\r\n last.stop = HUNDRED_PERCENT;\r\n }\r\n var processStops = [];\r\n var previous = 0;\r\n for (var i = 0; i < stops.length; i++) {\r\n var stop_1 = stops[i].stop;\r\n if (stop_1 !== null) {\r\n var absoluteValue = getAbsoluteValue(stop_1, lineLength);\r\n if (absoluteValue > previous) {\r\n processStops.push(absoluteValue);\r\n }\r\n else {\r\n processStops.push(previous);\r\n }\r\n previous = absoluteValue;\r\n }\r\n else {\r\n processStops.push(null);\r\n }\r\n }\r\n var gapBegin = null;\r\n for (var i = 0; i < processStops.length; i++) {\r\n var stop_2 = processStops[i];\r\n if (stop_2 === null) {\r\n if (gapBegin === null) {\r\n gapBegin = i;\r\n }\r\n }\r\n else if (gapBegin !== null) {\r\n var gapLength = i - gapBegin;\r\n var beforeGap = processStops[gapBegin - 1];\r\n var gapValue = (stop_2 - beforeGap) / (gapLength + 1);\r\n for (var g = 1; g <= gapLength; g++) {\r\n processStops[gapBegin + g - 1] = gapValue * g;\r\n }\r\n gapBegin = null;\r\n }\r\n }\r\n return stops.map(function (_a, i) {\r\n var color = _a.color;\r\n return { color: color, stop: Math.max(Math.min(1, processStops[i] / lineLength), 0) };\r\n });\r\n };\r\n var getAngleFromCorner = function (corner, width, height) {\r\n var centerX = width / 2;\r\n var centerY = height / 2;\r\n var x = getAbsoluteValue(corner[0], width) - centerX;\r\n var y = centerY - getAbsoluteValue(corner[1], height);\r\n return (Math.atan2(y, x) + Math.PI * 2) % (Math.PI * 2);\r\n };\r\n var calculateGradientDirection = function (angle, width, height) {\r\n var radian = typeof angle === 'number' ? angle : getAngleFromCorner(angle, width, height);\r\n var lineLength = Math.abs(width * Math.sin(radian)) + Math.abs(height * Math.cos(radian));\r\n var halfWidth = width / 2;\r\n var halfHeight = height / 2;\r\n var halfLineLength = lineLength / 2;\r\n var yDiff = Math.sin(radian - Math.PI / 2) * halfLineLength;\r\n var xDiff = Math.cos(radian - Math.PI / 2) * halfLineLength;\r\n return [lineLength, halfWidth - xDiff, halfWidth + xDiff, halfHeight - yDiff, halfHeight + yDiff];\r\n };\r\n var distance = function (a, b) { return Math.sqrt(a * a + b * b); };\r\n var findCorner = function (width, height, x, y, closest) {\r\n var corners = [[0, 0], [0, height], [width, 0], [width, height]];\r\n return corners.reduce(function (stat, corner) {\r\n var cx = corner[0], cy = corner[1];\r\n var d = distance(x - cx, y - cy);\r\n if (closest ? d < stat.optimumDistance : d > stat.optimumDistance) {\r\n return {\r\n optimumCorner: corner,\r\n optimumDistance: d\r\n };\r\n }\r\n return stat;\r\n }, {\r\n optimumDistance: closest ? Infinity : -Infinity,\r\n optimumCorner: null\r\n }).optimumCorner;\r\n };\r\n var calculateRadius = function (gradient, x, y, width, height) {\r\n var rx = 0;\r\n var ry = 0;\r\n switch (gradient.size) {\r\n case CSSRadialExtent.CLOSEST_SIDE:\r\n // The ending shape is sized so that that it exactly meets the side of the gradient box closest to the gradient’s center.\r\n // If the shape is an ellipse, it exactly meets the closest side in each dimension.\r\n if (gradient.shape === CSSRadialShape.CIRCLE) {\r\n rx = ry = Math.min(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));\r\n }\r\n else if (gradient.shape === CSSRadialShape.ELLIPSE) {\r\n rx = Math.min(Math.abs(x), Math.abs(x - width));\r\n ry = Math.min(Math.abs(y), Math.abs(y - height));\r\n }\r\n break;\r\n case CSSRadialExtent.CLOSEST_CORNER:\r\n // The ending shape is sized so that that it passes through the corner of the gradient box closest to the gradient’s center.\r\n // If the shape is an ellipse, the ending shape is given the same aspect-ratio it would have if closest-side were specified.\r\n if (gradient.shape === CSSRadialShape.CIRCLE) {\r\n rx = ry = Math.min(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));\r\n }\r\n else if (gradient.shape === CSSRadialShape.ELLIPSE) {\r\n // Compute the ratio ry/rx (which is to be the same as for \"closest-side\")\r\n var c = Math.min(Math.abs(y), Math.abs(y - height)) / Math.min(Math.abs(x), Math.abs(x - width));\r\n var _a = findCorner(width, height, x, y, true), cx = _a[0], cy = _a[1];\r\n rx = distance(cx - x, (cy - y) / c);\r\n ry = c * rx;\r\n }\r\n break;\r\n case CSSRadialExtent.FARTHEST_SIDE:\r\n // Same as closest-side, except the ending shape is sized based on the farthest side(s)\r\n if (gradient.shape === CSSRadialShape.CIRCLE) {\r\n rx = ry = Math.max(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));\r\n }\r\n else if (gradient.shape === CSSRadialShape.ELLIPSE) {\r\n rx = Math.max(Math.abs(x), Math.abs(x - width));\r\n ry = Math.max(Math.abs(y), Math.abs(y - height));\r\n }\r\n break;\r\n case CSSRadialExtent.FARTHEST_CORNER:\r\n // Same as closest-corner, except the ending shape is sized based on the farthest corner.\r\n // If the shape is an ellipse, the ending shape is given the same aspect ratio it would have if farthest-side were specified.\r\n if (gradient.shape === CSSRadialShape.CIRCLE) {\r\n rx = ry = Math.max(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));\r\n }\r\n else if (gradient.shape === CSSRadialShape.ELLIPSE) {\r\n // Compute the ratio ry/rx (which is to be the same as for \"farthest-side\")\r\n var c = Math.max(Math.abs(y), Math.abs(y - height)) / Math.max(Math.abs(x), Math.abs(x - width));\r\n var _b = findCorner(width, height, x, y, false), cx = _b[0], cy = _b[1];\r\n rx = distance(cx - x, (cy - y) / c);\r\n ry = c * rx;\r\n }\r\n break;\r\n }\r\n if (Array.isArray(gradient.size)) {\r\n rx = getAbsoluteValue(gradient.size[0], width);\r\n ry = gradient.size.length === 2 ? getAbsoluteValue(gradient.size[1], height) : rx;\r\n }\r\n return [rx, ry];\r\n };\n\n var linearGradient = function (tokens) {\r\n var angle$1 = deg(180);\r\n var stops = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n if (i === 0) {\r\n var firstToken = arg[0];\r\n if (firstToken.type === TokenType.IDENT_TOKEN && firstToken.value === 'to') {\r\n angle$1 = parseNamedSide(arg);\r\n return;\r\n }\r\n else if (isAngle(firstToken)) {\r\n angle$1 = angle.parse(firstToken);\r\n return;\r\n }\r\n }\r\n var colorStop = parseColorStop(arg);\r\n stops.push(colorStop);\r\n });\r\n return { angle: angle$1, stops: stops, type: CSSImageType.LINEAR_GRADIENT };\r\n };\n\n var prefixLinearGradient = function (tokens) {\r\n var angle$1 = deg(180);\r\n var stops = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n if (i === 0) {\r\n var firstToken = arg[0];\r\n if (firstToken.type === TokenType.IDENT_TOKEN &&\r\n ['top', 'left', 'right', 'bottom'].indexOf(firstToken.value) !== -1) {\r\n angle$1 = parseNamedSide(arg);\r\n return;\r\n }\r\n else if (isAngle(firstToken)) {\r\n angle$1 = (angle.parse(firstToken) + deg(270)) % deg(360);\r\n return;\r\n }\r\n }\r\n var colorStop = parseColorStop(arg);\r\n stops.push(colorStop);\r\n });\r\n return {\r\n angle: angle$1,\r\n stops: stops,\r\n type: CSSImageType.LINEAR_GRADIENT\r\n };\r\n };\n\n var testRangeBounds = function (document) {\r\n var TEST_HEIGHT = 123;\r\n if (document.createRange) {\r\n var range = document.createRange();\r\n if (range.getBoundingClientRect) {\r\n var testElement = document.createElement('boundtest');\r\n testElement.style.height = TEST_HEIGHT + \"px\";\r\n testElement.style.display = 'block';\r\n document.body.appendChild(testElement);\r\n range.selectNode(testElement);\r\n var rangeBounds = range.getBoundingClientRect();\r\n var rangeHeight = Math.round(rangeBounds.height);\r\n document.body.removeChild(testElement);\r\n if (rangeHeight === TEST_HEIGHT) {\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n };\r\n var testCORS = function () { return typeof new Image().crossOrigin !== 'undefined'; };\r\n var testResponseType = function () { return typeof new XMLHttpRequest().responseType === 'string'; };\r\n var testSVG = function (document) {\r\n var img = new Image();\r\n var canvas = document.createElement('canvas');\r\n var ctx = canvas.getContext('2d');\r\n if (!ctx) {\r\n return false;\r\n }\r\n img.src = \"data:image/svg+xml,\";\r\n try {\r\n ctx.drawImage(img, 0, 0);\r\n canvas.toDataURL();\r\n }\r\n catch (e) {\r\n return false;\r\n }\r\n return true;\r\n };\r\n var isGreenPixel = function (data) {\r\n return data[0] === 0 && data[1] === 255 && data[2] === 0 && data[3] === 255;\r\n };\r\n var testForeignObject = function (document) {\r\n var canvas = document.createElement('canvas');\r\n var size = 100;\r\n canvas.width = size;\r\n canvas.height = size;\r\n var ctx = canvas.getContext('2d');\r\n if (!ctx) {\r\n return Promise.reject(false);\r\n }\r\n ctx.fillStyle = 'rgb(0, 255, 0)';\r\n ctx.fillRect(0, 0, size, size);\r\n var img = new Image();\r\n var greenImageSrc = canvas.toDataURL();\r\n img.src = greenImageSrc;\r\n var svg = createForeignObjectSVG(size, size, 0, 0, img);\r\n ctx.fillStyle = 'red';\r\n ctx.fillRect(0, 0, size, size);\r\n return loadSerializedSVG(svg)\r\n .then(function (img) {\r\n ctx.drawImage(img, 0, 0);\r\n var data = ctx.getImageData(0, 0, size, size).data;\r\n ctx.fillStyle = 'red';\r\n ctx.fillRect(0, 0, size, size);\r\n var node = document.createElement('div');\r\n node.style.backgroundImage = \"url(\" + greenImageSrc + \")\";\r\n node.style.height = size + \"px\";\r\n // Firefox 55 does not render inline tags\r\n return isGreenPixel(data)\r\n ? loadSerializedSVG(createForeignObjectSVG(size, size, 0, 0, node))\r\n : Promise.reject(false);\r\n })\r\n .then(function (img) {\r\n ctx.drawImage(img, 0, 0);\r\n // Edge does not render background-images\r\n return isGreenPixel(ctx.getImageData(0, 0, size, size).data);\r\n })\r\n .catch(function () { return false; });\r\n };\r\n var createForeignObjectSVG = function (width, height, x, y, node) {\r\n var xmlns = 'http://www.w3.org/2000/svg';\r\n var svg = document.createElementNS(xmlns, 'svg');\r\n var foreignObject = document.createElementNS(xmlns, 'foreignObject');\r\n svg.setAttributeNS(null, 'width', width.toString());\r\n svg.setAttributeNS(null, 'height', height.toString());\r\n foreignObject.setAttributeNS(null, 'width', '100%');\r\n foreignObject.setAttributeNS(null, 'height', '100%');\r\n foreignObject.setAttributeNS(null, 'x', x.toString());\r\n foreignObject.setAttributeNS(null, 'y', y.toString());\r\n foreignObject.setAttributeNS(null, 'externalResourcesRequired', 'true');\r\n svg.appendChild(foreignObject);\r\n foreignObject.appendChild(node);\r\n return svg;\r\n };\r\n var loadSerializedSVG = function (svg) {\r\n return new Promise(function (resolve, reject) {\r\n var img = new Image();\r\n img.onload = function () { return resolve(img); };\r\n img.onerror = reject;\r\n img.src = \"data:image/svg+xml;charset=utf-8,\" + encodeURIComponent(new XMLSerializer().serializeToString(svg));\r\n });\r\n };\r\n var FEATURES = {\r\n get SUPPORT_RANGE_BOUNDS() {\r\n var value = testRangeBounds(document);\r\n Object.defineProperty(FEATURES, 'SUPPORT_RANGE_BOUNDS', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_SVG_DRAWING() {\r\n var value = testSVG(document);\r\n Object.defineProperty(FEATURES, 'SUPPORT_SVG_DRAWING', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_FOREIGNOBJECT_DRAWING() {\r\n var value = typeof Array.from === 'function' && typeof window.fetch === 'function'\r\n ? testForeignObject(document)\r\n : Promise.resolve(false);\r\n Object.defineProperty(FEATURES, 'SUPPORT_FOREIGNOBJECT_DRAWING', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_CORS_IMAGES() {\r\n var value = testCORS();\r\n Object.defineProperty(FEATURES, 'SUPPORT_CORS_IMAGES', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_RESPONSE_TYPE() {\r\n var value = testResponseType();\r\n Object.defineProperty(FEATURES, 'SUPPORT_RESPONSE_TYPE', { value: value });\r\n return value;\r\n },\r\n get SUPPORT_CORS_XHR() {\r\n var value = 'withCredentials' in new XMLHttpRequest();\r\n Object.defineProperty(FEATURES, 'SUPPORT_CORS_XHR', { value: value });\r\n return value;\r\n }\r\n };\n\n var Logger = /** @class */ (function () {\r\n function Logger(_a) {\r\n var id = _a.id, enabled = _a.enabled;\r\n this.id = id;\r\n this.enabled = enabled;\r\n this.start = Date.now();\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n Logger.prototype.debug = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n if (this.enabled) {\r\n // eslint-disable-next-line no-console\r\n if (typeof window !== 'undefined' && window.console && typeof console.debug === 'function') {\r\n // eslint-disable-next-line no-console\r\n console.debug.apply(console, [this.id, this.getTime() + \"ms\"].concat(args));\r\n }\r\n else {\r\n this.info.apply(this, args);\r\n }\r\n }\r\n };\r\n Logger.prototype.getTime = function () {\r\n return Date.now() - this.start;\r\n };\r\n Logger.create = function (options) {\r\n Logger.instances[options.id] = new Logger(options);\r\n };\r\n Logger.destroy = function (id) {\r\n delete Logger.instances[id];\r\n };\r\n Logger.getInstance = function (id) {\r\n var instance = Logger.instances[id];\r\n if (typeof instance === 'undefined') {\r\n throw new Error(\"No logger instance found with id \" + id);\r\n }\r\n return instance;\r\n };\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n Logger.prototype.info = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n if (this.enabled) {\r\n // eslint-disable-next-line no-console\r\n if (typeof window !== 'undefined' && window.console && typeof console.info === 'function') {\r\n // eslint-disable-next-line no-console\r\n console.info.apply(console, [this.id, this.getTime() + \"ms\"].concat(args));\r\n }\r\n }\r\n };\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n Logger.prototype.error = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n if (this.enabled) {\r\n // eslint-disable-next-line no-console\r\n if (typeof window !== 'undefined' && window.console && typeof console.error === 'function') {\r\n // eslint-disable-next-line no-console\r\n console.error.apply(console, [this.id, this.getTime() + \"ms\"].concat(args));\r\n }\r\n else {\r\n this.info.apply(this, args);\r\n }\r\n }\r\n };\r\n Logger.instances = {};\r\n return Logger;\r\n }());\n\n var CacheStorage = /** @class */ (function () {\r\n function CacheStorage() {\r\n }\r\n CacheStorage.create = function (name, options) {\r\n return (CacheStorage._caches[name] = new Cache(name, options));\r\n };\r\n CacheStorage.destroy = function (name) {\r\n delete CacheStorage._caches[name];\r\n };\r\n CacheStorage.open = function (name) {\r\n var cache = CacheStorage._caches[name];\r\n if (typeof cache !== 'undefined') {\r\n return cache;\r\n }\r\n throw new Error(\"Cache with key \\\"\" + name + \"\\\" not found\");\r\n };\r\n CacheStorage.getOrigin = function (url) {\r\n var link = CacheStorage._link;\r\n if (!link) {\r\n return 'about:blank';\r\n }\r\n link.href = url;\r\n link.href = link.href; // IE9, LOL! - http://jsfiddle.net/niklasvh/2e48b/\r\n return link.protocol + link.hostname + link.port;\r\n };\r\n CacheStorage.isSameOrigin = function (src) {\r\n return CacheStorage.getOrigin(src) === CacheStorage._origin;\r\n };\r\n CacheStorage.setContext = function (window) {\r\n CacheStorage._link = window.document.createElement('a');\r\n CacheStorage._origin = CacheStorage.getOrigin(window.location.href);\r\n };\r\n CacheStorage.getInstance = function () {\r\n var current = CacheStorage._current;\r\n if (current === null) {\r\n throw new Error(\"No cache instance attached\");\r\n }\r\n return current;\r\n };\r\n CacheStorage.attachInstance = function (cache) {\r\n CacheStorage._current = cache;\r\n };\r\n CacheStorage.detachInstance = function () {\r\n CacheStorage._current = null;\r\n };\r\n CacheStorage._caches = {};\r\n CacheStorage._origin = 'about:blank';\r\n CacheStorage._current = null;\r\n return CacheStorage;\r\n }());\r\n var Cache = /** @class */ (function () {\r\n function Cache(id, options) {\r\n this.id = id;\r\n this._options = options;\r\n this._cache = {};\r\n }\r\n Cache.prototype.addImage = function (src) {\r\n var result = Promise.resolve();\r\n if (this.has(src)) {\r\n return result;\r\n }\r\n if (isBlobImage(src) || isRenderable(src)) {\r\n this._cache[src] = this.loadImage(src);\r\n return result;\r\n }\r\n return result;\r\n };\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n Cache.prototype.match = function (src) {\r\n return this._cache[src];\r\n };\r\n Cache.prototype.loadImage = function (key) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var isSameOrigin, useCORS, useProxy, src;\r\n var _this = this;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n isSameOrigin = CacheStorage.isSameOrigin(key);\r\n useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;\r\n useProxy = !isInlineImage(key) &&\r\n !isSameOrigin &&\r\n typeof this._options.proxy === 'string' &&\r\n FEATURES.SUPPORT_CORS_XHR &&\r\n !useCORS;\r\n if (!isSameOrigin && this._options.allowTaint === false && !isInlineImage(key) && !useProxy && !useCORS) {\r\n return [2 /*return*/];\r\n }\r\n src = key;\r\n if (!useProxy) return [3 /*break*/, 2];\r\n return [4 /*yield*/, this.proxy(src)];\r\n case 1:\r\n src = _a.sent();\r\n _a.label = 2;\r\n case 2:\r\n Logger.getInstance(this.id).debug(\"Added image \" + key.substring(0, 256));\r\n return [4 /*yield*/, new Promise(function (resolve, reject) {\r\n var img = new Image();\r\n img.onload = function () { return resolve(img); };\r\n img.onerror = reject;\r\n //ios safari 10.3 taints canvas with data urls unless crossOrigin is set to anonymous\r\n if (isInlineBase64Image(src) || useCORS) {\r\n img.crossOrigin = 'anonymous';\r\n }\r\n img.src = src;\r\n if (img.complete === true) {\r\n // Inline XML images may fail to parse, throwing an Error later on\r\n setTimeout(function () { return resolve(img); }, 500);\r\n }\r\n if (_this._options.imageTimeout > 0) {\r\n setTimeout(function () { return reject(\"Timed out (\" + _this._options.imageTimeout + \"ms) loading image\"); }, _this._options.imageTimeout);\r\n }\r\n })];\r\n case 3: return [2 /*return*/, _a.sent()];\r\n }\r\n });\r\n });\r\n };\r\n Cache.prototype.has = function (key) {\r\n return typeof this._cache[key] !== 'undefined';\r\n };\r\n Cache.prototype.keys = function () {\r\n return Promise.resolve(Object.keys(this._cache));\r\n };\r\n Cache.prototype.proxy = function (src) {\r\n var _this = this;\r\n var proxy = this._options.proxy;\r\n if (!proxy) {\r\n throw new Error('No proxy defined');\r\n }\r\n var key = src.substring(0, 256);\r\n return new Promise(function (resolve, reject) {\r\n var responseType = FEATURES.SUPPORT_RESPONSE_TYPE ? 'blob' : 'text';\r\n var xhr = new XMLHttpRequest();\r\n xhr.onload = function () {\r\n if (xhr.status === 200) {\r\n if (responseType === 'text') {\r\n resolve(xhr.response);\r\n }\r\n else {\r\n var reader_1 = new FileReader();\r\n reader_1.addEventListener('load', function () { return resolve(reader_1.result); }, false);\r\n reader_1.addEventListener('error', function (e) { return reject(e); }, false);\r\n reader_1.readAsDataURL(xhr.response);\r\n }\r\n }\r\n else {\r\n reject(\"Failed to proxy resource \" + key + \" with status code \" + xhr.status);\r\n }\r\n };\r\n xhr.onerror = reject;\r\n xhr.open('GET', proxy + \"?url=\" + encodeURIComponent(src) + \"&responseType=\" + responseType);\r\n if (responseType !== 'text' && xhr instanceof XMLHttpRequest) {\r\n xhr.responseType = responseType;\r\n }\r\n if (_this._options.imageTimeout) {\r\n var timeout_1 = _this._options.imageTimeout;\r\n xhr.timeout = timeout_1;\r\n xhr.ontimeout = function () { return reject(\"Timed out (\" + timeout_1 + \"ms) proxying \" + key); };\r\n }\r\n xhr.send();\r\n });\r\n };\r\n return Cache;\r\n }());\r\n var INLINE_SVG = /^data:image\\/svg\\+xml/i;\r\n var INLINE_BASE64 = /^data:image\\/.*;base64,/i;\r\n var INLINE_IMG = /^data:image\\/.*/i;\r\n var isRenderable = function (src) { return FEATURES.SUPPORT_SVG_DRAWING || !isSVG(src); };\r\n var isInlineImage = function (src) { return INLINE_IMG.test(src); };\r\n var isInlineBase64Image = function (src) { return INLINE_BASE64.test(src); };\r\n var isBlobImage = function (src) { return src.substr(0, 4) === 'blob'; };\r\n var isSVG = function (src) { return src.substr(-3).toLowerCase() === 'svg' || INLINE_SVG.test(src); };\n\n var webkitGradient = function (tokens) {\r\n var angle = deg(180);\r\n var stops = [];\r\n var type = CSSImageType.LINEAR_GRADIENT;\r\n var shape = CSSRadialShape.CIRCLE;\r\n var size = CSSRadialExtent.FARTHEST_CORNER;\r\n var position = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n var firstToken = arg[0];\r\n if (i === 0) {\r\n if (isIdentToken(firstToken) && firstToken.value === 'linear') {\r\n type = CSSImageType.LINEAR_GRADIENT;\r\n return;\r\n }\r\n else if (isIdentToken(firstToken) && firstToken.value === 'radial') {\r\n type = CSSImageType.RADIAL_GRADIENT;\r\n return;\r\n }\r\n }\r\n if (firstToken.type === TokenType.FUNCTION) {\r\n if (firstToken.name === 'from') {\r\n var color$1 = color.parse(firstToken.values[0]);\r\n stops.push({ stop: ZERO_LENGTH, color: color$1 });\r\n }\r\n else if (firstToken.name === 'to') {\r\n var color$1 = color.parse(firstToken.values[0]);\r\n stops.push({ stop: HUNDRED_PERCENT, color: color$1 });\r\n }\r\n else if (firstToken.name === 'color-stop') {\r\n var values = firstToken.values.filter(nonFunctionArgSeparator);\r\n if (values.length === 2) {\r\n var color$1 = color.parse(values[1]);\r\n var stop_1 = values[0];\r\n if (isNumberToken(stop_1)) {\r\n stops.push({\r\n stop: { type: TokenType.PERCENTAGE_TOKEN, number: stop_1.number * 100, flags: stop_1.flags },\r\n color: color$1\r\n });\r\n }\r\n }\r\n }\r\n }\r\n });\r\n return type === CSSImageType.LINEAR_GRADIENT\r\n ? {\r\n angle: (angle + deg(180)) % deg(360),\r\n stops: stops,\r\n type: type\r\n }\r\n : { size: size, shape: shape, stops: stops, position: position, type: type };\r\n };\n\n var CLOSEST_SIDE = 'closest-side';\r\n var FARTHEST_SIDE = 'farthest-side';\r\n var CLOSEST_CORNER = 'closest-corner';\r\n var FARTHEST_CORNER = 'farthest-corner';\r\n var CIRCLE = 'circle';\r\n var ELLIPSE = 'ellipse';\r\n var COVER = 'cover';\r\n var CONTAIN = 'contain';\r\n var radialGradient = function (tokens) {\r\n var shape = CSSRadialShape.CIRCLE;\r\n var size = CSSRadialExtent.FARTHEST_CORNER;\r\n var stops = [];\r\n var position = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n var isColorStop = true;\r\n if (i === 0) {\r\n var isAtPosition_1 = false;\r\n isColorStop = arg.reduce(function (acc, token) {\r\n if (isAtPosition_1) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'center':\r\n position.push(FIFTY_PERCENT);\r\n return acc;\r\n case 'top':\r\n case 'left':\r\n position.push(ZERO_LENGTH);\r\n return acc;\r\n case 'right':\r\n case 'bottom':\r\n position.push(HUNDRED_PERCENT);\r\n return acc;\r\n }\r\n }\r\n else if (isLengthPercentage(token) || isLength(token)) {\r\n position.push(token);\r\n }\r\n }\r\n else if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case CIRCLE:\r\n shape = CSSRadialShape.CIRCLE;\r\n return false;\r\n case ELLIPSE:\r\n shape = CSSRadialShape.ELLIPSE;\r\n return false;\r\n case 'at':\r\n isAtPosition_1 = true;\r\n return false;\r\n case CLOSEST_SIDE:\r\n size = CSSRadialExtent.CLOSEST_SIDE;\r\n return false;\r\n case COVER:\r\n case FARTHEST_SIDE:\r\n size = CSSRadialExtent.FARTHEST_SIDE;\r\n return false;\r\n case CONTAIN:\r\n case CLOSEST_CORNER:\r\n size = CSSRadialExtent.CLOSEST_CORNER;\r\n return false;\r\n case FARTHEST_CORNER:\r\n size = CSSRadialExtent.FARTHEST_CORNER;\r\n return false;\r\n }\r\n }\r\n else if (isLength(token) || isLengthPercentage(token)) {\r\n if (!Array.isArray(size)) {\r\n size = [];\r\n }\r\n size.push(token);\r\n return false;\r\n }\r\n return acc;\r\n }, isColorStop);\r\n }\r\n if (isColorStop) {\r\n var colorStop = parseColorStop(arg);\r\n stops.push(colorStop);\r\n }\r\n });\r\n return { size: size, shape: shape, stops: stops, position: position, type: CSSImageType.RADIAL_GRADIENT };\r\n };\n\n var prefixRadialGradient = function (tokens) {\r\n var shape = CSSRadialShape.CIRCLE;\r\n var size = CSSRadialExtent.FARTHEST_CORNER;\r\n var stops = [];\r\n var position = [];\r\n parseFunctionArgs(tokens).forEach(function (arg, i) {\r\n var isColorStop = true;\r\n if (i === 0) {\r\n isColorStop = arg.reduce(function (acc, token) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'center':\r\n position.push(FIFTY_PERCENT);\r\n return false;\r\n case 'top':\r\n case 'left':\r\n position.push(ZERO_LENGTH);\r\n return false;\r\n case 'right':\r\n case 'bottom':\r\n position.push(HUNDRED_PERCENT);\r\n return false;\r\n }\r\n }\r\n else if (isLengthPercentage(token) || isLength(token)) {\r\n position.push(token);\r\n return false;\r\n }\r\n return acc;\r\n }, isColorStop);\r\n }\r\n else if (i === 1) {\r\n isColorStop = arg.reduce(function (acc, token) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case CIRCLE:\r\n shape = CSSRadialShape.CIRCLE;\r\n return false;\r\n case ELLIPSE:\r\n shape = CSSRadialShape.ELLIPSE;\r\n return false;\r\n case CONTAIN:\r\n case CLOSEST_SIDE:\r\n size = CSSRadialExtent.CLOSEST_SIDE;\r\n return false;\r\n case FARTHEST_SIDE:\r\n size = CSSRadialExtent.FARTHEST_SIDE;\r\n return false;\r\n case CLOSEST_CORNER:\r\n size = CSSRadialExtent.CLOSEST_CORNER;\r\n return false;\r\n case COVER:\r\n case FARTHEST_CORNER:\r\n size = CSSRadialExtent.FARTHEST_CORNER;\r\n return false;\r\n }\r\n }\r\n else if (isLength(token) || isLengthPercentage(token)) {\r\n if (!Array.isArray(size)) {\r\n size = [];\r\n }\r\n size.push(token);\r\n return false;\r\n }\r\n return acc;\r\n }, isColorStop);\r\n }\r\n if (isColorStop) {\r\n var colorStop = parseColorStop(arg);\r\n stops.push(colorStop);\r\n }\r\n });\r\n return { size: size, shape: shape, stops: stops, position: position, type: CSSImageType.RADIAL_GRADIENT };\r\n };\n\n var CSSImageType;\r\n (function (CSSImageType) {\r\n CSSImageType[CSSImageType[\"URL\"] = 0] = \"URL\";\r\n CSSImageType[CSSImageType[\"LINEAR_GRADIENT\"] = 1] = \"LINEAR_GRADIENT\";\r\n CSSImageType[CSSImageType[\"RADIAL_GRADIENT\"] = 2] = \"RADIAL_GRADIENT\";\r\n })(CSSImageType || (CSSImageType = {}));\r\n var isLinearGradient = function (background) {\r\n return background.type === CSSImageType.LINEAR_GRADIENT;\r\n };\r\n var isRadialGradient = function (background) {\r\n return background.type === CSSImageType.RADIAL_GRADIENT;\r\n };\r\n var CSSRadialShape;\r\n (function (CSSRadialShape) {\r\n CSSRadialShape[CSSRadialShape[\"CIRCLE\"] = 0] = \"CIRCLE\";\r\n CSSRadialShape[CSSRadialShape[\"ELLIPSE\"] = 1] = \"ELLIPSE\";\r\n })(CSSRadialShape || (CSSRadialShape = {}));\r\n var CSSRadialExtent;\r\n (function (CSSRadialExtent) {\r\n CSSRadialExtent[CSSRadialExtent[\"CLOSEST_SIDE\"] = 0] = \"CLOSEST_SIDE\";\r\n CSSRadialExtent[CSSRadialExtent[\"FARTHEST_SIDE\"] = 1] = \"FARTHEST_SIDE\";\r\n CSSRadialExtent[CSSRadialExtent[\"CLOSEST_CORNER\"] = 2] = \"CLOSEST_CORNER\";\r\n CSSRadialExtent[CSSRadialExtent[\"FARTHEST_CORNER\"] = 3] = \"FARTHEST_CORNER\";\r\n })(CSSRadialExtent || (CSSRadialExtent = {}));\r\n var image = {\r\n name: 'image',\r\n parse: function (value) {\r\n if (value.type === TokenType.URL_TOKEN) {\r\n var image_1 = { url: value.value, type: CSSImageType.URL };\r\n CacheStorage.getInstance().addImage(value.value);\r\n return image_1;\r\n }\r\n if (value.type === TokenType.FUNCTION) {\r\n var imageFunction = SUPPORTED_IMAGE_FUNCTIONS[value.name];\r\n if (typeof imageFunction === 'undefined') {\r\n throw new Error(\"Attempting to parse an unsupported image function \\\"\" + value.name + \"\\\"\");\r\n }\r\n return imageFunction(value.values);\r\n }\r\n throw new Error(\"Unsupported image type\");\r\n }\r\n };\r\n function isSupportedImage(value) {\r\n return value.type !== TokenType.FUNCTION || SUPPORTED_IMAGE_FUNCTIONS[value.name];\r\n }\r\n var SUPPORTED_IMAGE_FUNCTIONS = {\r\n 'linear-gradient': linearGradient,\r\n '-moz-linear-gradient': prefixLinearGradient,\r\n '-ms-linear-gradient': prefixLinearGradient,\r\n '-o-linear-gradient': prefixLinearGradient,\r\n '-webkit-linear-gradient': prefixLinearGradient,\r\n 'radial-gradient': radialGradient,\r\n '-moz-radial-gradient': prefixRadialGradient,\r\n '-ms-radial-gradient': prefixRadialGradient,\r\n '-o-radial-gradient': prefixRadialGradient,\r\n '-webkit-radial-gradient': prefixRadialGradient,\r\n '-webkit-gradient': webkitGradient\r\n };\n\n var backgroundImage = {\r\n name: 'background-image',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return [];\r\n }\r\n var first = tokens[0];\r\n if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {\r\n return [];\r\n }\r\n return tokens.filter(function (value) { return nonFunctionArgSeparator(value) && isSupportedImage(value); }).map(image.parse);\r\n }\r\n };\n\n var backgroundOrigin = {\r\n name: 'background-origin',\r\n initialValue: 'border-box',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens.map(function (token) {\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'padding-box':\r\n return 1 /* PADDING_BOX */;\r\n case 'content-box':\r\n return 2 /* CONTENT_BOX */;\r\n }\r\n }\r\n return 0 /* BORDER_BOX */;\r\n });\r\n }\r\n };\n\n var backgroundPosition = {\r\n name: 'background-position',\r\n initialValue: '0% 0%',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n return parseFunctionArgs(tokens)\r\n .map(function (values) { return values.filter(isLengthPercentage); })\r\n .map(parseLengthPercentageTuple);\r\n }\r\n };\n\n var BACKGROUND_REPEAT;\r\n (function (BACKGROUND_REPEAT) {\r\n BACKGROUND_REPEAT[BACKGROUND_REPEAT[\"REPEAT\"] = 0] = \"REPEAT\";\r\n BACKGROUND_REPEAT[BACKGROUND_REPEAT[\"NO_REPEAT\"] = 1] = \"NO_REPEAT\";\r\n BACKGROUND_REPEAT[BACKGROUND_REPEAT[\"REPEAT_X\"] = 2] = \"REPEAT_X\";\r\n BACKGROUND_REPEAT[BACKGROUND_REPEAT[\"REPEAT_Y\"] = 3] = \"REPEAT_Y\";\r\n })(BACKGROUND_REPEAT || (BACKGROUND_REPEAT = {}));\r\n var backgroundRepeat = {\r\n name: 'background-repeat',\r\n initialValue: 'repeat',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return parseFunctionArgs(tokens)\r\n .map(function (values) {\r\n return values\r\n .filter(isIdentToken)\r\n .map(function (token) { return token.value; })\r\n .join(' ');\r\n })\r\n .map(parseBackgroundRepeat);\r\n }\r\n };\r\n var parseBackgroundRepeat = function (value) {\r\n switch (value) {\r\n case 'no-repeat':\r\n return BACKGROUND_REPEAT.NO_REPEAT;\r\n case 'repeat-x':\r\n case 'repeat no-repeat':\r\n return BACKGROUND_REPEAT.REPEAT_X;\r\n case 'repeat-y':\r\n case 'no-repeat repeat':\r\n return BACKGROUND_REPEAT.REPEAT_Y;\r\n case 'repeat':\r\n default:\r\n return BACKGROUND_REPEAT.REPEAT;\r\n }\r\n };\n\n var BACKGROUND_SIZE;\r\n (function (BACKGROUND_SIZE) {\r\n BACKGROUND_SIZE[\"AUTO\"] = \"auto\";\r\n BACKGROUND_SIZE[\"CONTAIN\"] = \"contain\";\r\n BACKGROUND_SIZE[\"COVER\"] = \"cover\";\r\n })(BACKGROUND_SIZE || (BACKGROUND_SIZE = {}));\r\n var backgroundSize = {\r\n name: 'background-size',\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return parseFunctionArgs(tokens).map(function (values) { return values.filter(isBackgroundSizeInfoToken); });\r\n }\r\n };\r\n var isBackgroundSizeInfoToken = function (value) {\r\n return isIdentToken(value) || isLengthPercentage(value);\r\n };\n\n var borderColorForSide = function (side) { return ({\r\n name: \"border-\" + side + \"-color\",\r\n initialValue: 'transparent',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'color'\r\n }); };\r\n var borderTopColor = borderColorForSide('top');\r\n var borderRightColor = borderColorForSide('right');\r\n var borderBottomColor = borderColorForSide('bottom');\r\n var borderLeftColor = borderColorForSide('left');\n\n var borderRadiusForSide = function (side) { return ({\r\n name: \"border-radius-\" + side,\r\n initialValue: '0 0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) { return parseLengthPercentageTuple(tokens.filter(isLengthPercentage)); }\r\n }); };\r\n var borderTopLeftRadius = borderRadiusForSide('top-left');\r\n var borderTopRightRadius = borderRadiusForSide('top-right');\r\n var borderBottomRightRadius = borderRadiusForSide('bottom-right');\r\n var borderBottomLeftRadius = borderRadiusForSide('bottom-left');\n\n var BORDER_STYLE;\r\n (function (BORDER_STYLE) {\r\n BORDER_STYLE[BORDER_STYLE[\"NONE\"] = 0] = \"NONE\";\r\n BORDER_STYLE[BORDER_STYLE[\"SOLID\"] = 1] = \"SOLID\";\r\n })(BORDER_STYLE || (BORDER_STYLE = {}));\r\n var borderStyleForSide = function (side) { return ({\r\n name: \"border-\" + side + \"-style\",\r\n initialValue: 'solid',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (style) {\r\n switch (style) {\r\n case 'none':\r\n return BORDER_STYLE.NONE;\r\n }\r\n return BORDER_STYLE.SOLID;\r\n }\r\n }); };\r\n var borderTopStyle = borderStyleForSide('top');\r\n var borderRightStyle = borderStyleForSide('right');\r\n var borderBottomStyle = borderStyleForSide('bottom');\r\n var borderLeftStyle = borderStyleForSide('left');\n\n var borderWidthForSide = function (side) { return ({\r\n name: \"border-\" + side + \"-width\",\r\n initialValue: '0',\r\n type: PropertyDescriptorParsingType.VALUE,\r\n prefix: false,\r\n parse: function (token) {\r\n if (isDimensionToken(token)) {\r\n return token.number;\r\n }\r\n return 0;\r\n }\r\n }); };\r\n var borderTopWidth = borderWidthForSide('top');\r\n var borderRightWidth = borderWidthForSide('right');\r\n var borderBottomWidth = borderWidthForSide('bottom');\r\n var borderLeftWidth = borderWidthForSide('left');\n\n var color$1 = {\r\n name: \"color\",\r\n initialValue: 'transparent',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'color'\r\n };\n\n var display = {\r\n name: 'display',\r\n initialValue: 'inline-block',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens.filter(isIdentToken).reduce(function (bit, token) {\r\n return bit | parseDisplayValue(token.value);\r\n }, 0 /* NONE */);\r\n }\r\n };\r\n var parseDisplayValue = function (display) {\r\n switch (display) {\r\n case 'block':\r\n return 2 /* BLOCK */;\r\n case 'inline':\r\n return 4 /* INLINE */;\r\n case 'run-in':\r\n return 8 /* RUN_IN */;\r\n case 'flow':\r\n return 16 /* FLOW */;\r\n case 'flow-root':\r\n return 32 /* FLOW_ROOT */;\r\n case 'table':\r\n return 64 /* TABLE */;\r\n case 'flex':\r\n case '-webkit-flex':\r\n return 128 /* FLEX */;\r\n case 'grid':\r\n case '-ms-grid':\r\n return 256 /* GRID */;\r\n case 'ruby':\r\n return 512 /* RUBY */;\r\n case 'subgrid':\r\n return 1024 /* SUBGRID */;\r\n case 'list-item':\r\n return 2048 /* LIST_ITEM */;\r\n case 'table-row-group':\r\n return 4096 /* TABLE_ROW_GROUP */;\r\n case 'table-header-group':\r\n return 8192 /* TABLE_HEADER_GROUP */;\r\n case 'table-footer-group':\r\n return 16384 /* TABLE_FOOTER_GROUP */;\r\n case 'table-row':\r\n return 32768 /* TABLE_ROW */;\r\n case 'table-cell':\r\n return 65536 /* TABLE_CELL */;\r\n case 'table-column-group':\r\n return 131072 /* TABLE_COLUMN_GROUP */;\r\n case 'table-column':\r\n return 262144 /* TABLE_COLUMN */;\r\n case 'table-caption':\r\n return 524288 /* TABLE_CAPTION */;\r\n case 'ruby-base':\r\n return 1048576 /* RUBY_BASE */;\r\n case 'ruby-text':\r\n return 2097152 /* RUBY_TEXT */;\r\n case 'ruby-base-container':\r\n return 4194304 /* RUBY_BASE_CONTAINER */;\r\n case 'ruby-text-container':\r\n return 8388608 /* RUBY_TEXT_CONTAINER */;\r\n case 'contents':\r\n return 16777216 /* CONTENTS */;\r\n case 'inline-block':\r\n return 33554432 /* INLINE_BLOCK */;\r\n case 'inline-list-item':\r\n return 67108864 /* INLINE_LIST_ITEM */;\r\n case 'inline-table':\r\n return 134217728 /* INLINE_TABLE */;\r\n case 'inline-flex':\r\n return 268435456 /* INLINE_FLEX */;\r\n case 'inline-grid':\r\n return 536870912 /* INLINE_GRID */;\r\n }\r\n return 0 /* NONE */;\r\n };\n\n var FLOAT;\r\n (function (FLOAT) {\r\n FLOAT[FLOAT[\"NONE\"] = 0] = \"NONE\";\r\n FLOAT[FLOAT[\"LEFT\"] = 1] = \"LEFT\";\r\n FLOAT[FLOAT[\"RIGHT\"] = 2] = \"RIGHT\";\r\n FLOAT[FLOAT[\"INLINE_START\"] = 3] = \"INLINE_START\";\r\n FLOAT[FLOAT[\"INLINE_END\"] = 4] = \"INLINE_END\";\r\n })(FLOAT || (FLOAT = {}));\r\n var float = {\r\n name: 'float',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (float) {\r\n switch (float) {\r\n case 'left':\r\n return FLOAT.LEFT;\r\n case 'right':\r\n return FLOAT.RIGHT;\r\n case 'inline-start':\r\n return FLOAT.INLINE_START;\r\n case 'inline-end':\r\n return FLOAT.INLINE_END;\r\n }\r\n return FLOAT.NONE;\r\n }\r\n };\n\n var letterSpacing = {\r\n name: 'letter-spacing',\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.VALUE,\r\n parse: function (token) {\r\n if (token.type === TokenType.IDENT_TOKEN && token.value === 'normal') {\r\n return 0;\r\n }\r\n if (token.type === TokenType.NUMBER_TOKEN) {\r\n return token.number;\r\n }\r\n if (token.type === TokenType.DIMENSION_TOKEN) {\r\n return token.number;\r\n }\r\n return 0;\r\n }\r\n };\n\n var LINE_BREAK;\r\n (function (LINE_BREAK) {\r\n LINE_BREAK[\"NORMAL\"] = \"normal\";\r\n LINE_BREAK[\"STRICT\"] = \"strict\";\r\n })(LINE_BREAK || (LINE_BREAK = {}));\r\n var lineBreak = {\r\n name: 'line-break',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (lineBreak) {\r\n switch (lineBreak) {\r\n case 'strict':\r\n return LINE_BREAK.STRICT;\r\n case 'normal':\r\n default:\r\n return LINE_BREAK.NORMAL;\r\n }\r\n }\r\n };\n\n var lineHeight = {\r\n name: 'line-height',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TOKEN_VALUE\r\n };\r\n var computeLineHeight = function (token, fontSize) {\r\n if (isIdentToken(token) && token.value === 'normal') {\r\n return 1.2 * fontSize;\r\n }\r\n else if (token.type === TokenType.NUMBER_TOKEN) {\r\n return fontSize * token.number;\r\n }\r\n else if (isLengthPercentage(token)) {\r\n return getAbsoluteValue(token, fontSize);\r\n }\r\n return fontSize;\r\n };\n\n var listStyleImage = {\r\n name: 'list-style-image',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.VALUE,\r\n prefix: false,\r\n parse: function (token) {\r\n if (token.type === TokenType.IDENT_TOKEN && token.value === 'none') {\r\n return null;\r\n }\r\n return image.parse(token);\r\n }\r\n };\n\n var LIST_STYLE_POSITION;\r\n (function (LIST_STYLE_POSITION) {\r\n LIST_STYLE_POSITION[LIST_STYLE_POSITION[\"INSIDE\"] = 0] = \"INSIDE\";\r\n LIST_STYLE_POSITION[LIST_STYLE_POSITION[\"OUTSIDE\"] = 1] = \"OUTSIDE\";\r\n })(LIST_STYLE_POSITION || (LIST_STYLE_POSITION = {}));\r\n var listStylePosition = {\r\n name: 'list-style-position',\r\n initialValue: 'outside',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (position) {\r\n switch (position) {\r\n case 'inside':\r\n return LIST_STYLE_POSITION.INSIDE;\r\n case 'outside':\r\n default:\r\n return LIST_STYLE_POSITION.OUTSIDE;\r\n }\r\n }\r\n };\n\n var LIST_STYLE_TYPE;\r\n (function (LIST_STYLE_TYPE) {\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"NONE\"] = -1] = \"NONE\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DISC\"] = 0] = \"DISC\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CIRCLE\"] = 1] = \"CIRCLE\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"SQUARE\"] = 2] = \"SQUARE\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DECIMAL\"] = 3] = \"DECIMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CJK_DECIMAL\"] = 4] = \"CJK_DECIMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DECIMAL_LEADING_ZERO\"] = 5] = \"DECIMAL_LEADING_ZERO\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LOWER_ROMAN\"] = 6] = \"LOWER_ROMAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"UPPER_ROMAN\"] = 7] = \"UPPER_ROMAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LOWER_GREEK\"] = 8] = \"LOWER_GREEK\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LOWER_ALPHA\"] = 9] = \"LOWER_ALPHA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"UPPER_ALPHA\"] = 10] = \"UPPER_ALPHA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"ARABIC_INDIC\"] = 11] = \"ARABIC_INDIC\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"ARMENIAN\"] = 12] = \"ARMENIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"BENGALI\"] = 13] = \"BENGALI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CAMBODIAN\"] = 14] = \"CAMBODIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CJK_EARTHLY_BRANCH\"] = 15] = \"CJK_EARTHLY_BRANCH\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CJK_HEAVENLY_STEM\"] = 16] = \"CJK_HEAVENLY_STEM\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"CJK_IDEOGRAPHIC\"] = 17] = \"CJK_IDEOGRAPHIC\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DEVANAGARI\"] = 18] = \"DEVANAGARI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"ETHIOPIC_NUMERIC\"] = 19] = \"ETHIOPIC_NUMERIC\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"GEORGIAN\"] = 20] = \"GEORGIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"GUJARATI\"] = 21] = \"GUJARATI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"GURMUKHI\"] = 22] = \"GURMUKHI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"HEBREW\"] = 22] = \"HEBREW\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"HIRAGANA\"] = 23] = \"HIRAGANA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"HIRAGANA_IROHA\"] = 24] = \"HIRAGANA_IROHA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"JAPANESE_FORMAL\"] = 25] = \"JAPANESE_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"JAPANESE_INFORMAL\"] = 26] = \"JAPANESE_INFORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KANNADA\"] = 27] = \"KANNADA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KATAKANA\"] = 28] = \"KATAKANA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KATAKANA_IROHA\"] = 29] = \"KATAKANA_IROHA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KHMER\"] = 30] = \"KHMER\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KOREAN_HANGUL_FORMAL\"] = 31] = \"KOREAN_HANGUL_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KOREAN_HANJA_FORMAL\"] = 32] = \"KOREAN_HANJA_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"KOREAN_HANJA_INFORMAL\"] = 33] = \"KOREAN_HANJA_INFORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LAO\"] = 34] = \"LAO\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"LOWER_ARMENIAN\"] = 35] = \"LOWER_ARMENIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"MALAYALAM\"] = 36] = \"MALAYALAM\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"MONGOLIAN\"] = 37] = \"MONGOLIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"MYANMAR\"] = 38] = \"MYANMAR\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"ORIYA\"] = 39] = \"ORIYA\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"PERSIAN\"] = 40] = \"PERSIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"SIMP_CHINESE_FORMAL\"] = 41] = \"SIMP_CHINESE_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"SIMP_CHINESE_INFORMAL\"] = 42] = \"SIMP_CHINESE_INFORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TAMIL\"] = 43] = \"TAMIL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TELUGU\"] = 44] = \"TELUGU\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"THAI\"] = 45] = \"THAI\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TIBETAN\"] = 46] = \"TIBETAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TRAD_CHINESE_FORMAL\"] = 47] = \"TRAD_CHINESE_FORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"TRAD_CHINESE_INFORMAL\"] = 48] = \"TRAD_CHINESE_INFORMAL\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"UPPER_ARMENIAN\"] = 49] = \"UPPER_ARMENIAN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DISCLOSURE_OPEN\"] = 50] = \"DISCLOSURE_OPEN\";\r\n LIST_STYLE_TYPE[LIST_STYLE_TYPE[\"DISCLOSURE_CLOSED\"] = 51] = \"DISCLOSURE_CLOSED\";\r\n })(LIST_STYLE_TYPE || (LIST_STYLE_TYPE = {}));\r\n var listStyleType = {\r\n name: 'list-style-type',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (type) {\r\n switch (type) {\r\n case 'disc':\r\n return LIST_STYLE_TYPE.DISC;\r\n case 'circle':\r\n return LIST_STYLE_TYPE.CIRCLE;\r\n case 'square':\r\n return LIST_STYLE_TYPE.SQUARE;\r\n case 'decimal':\r\n return LIST_STYLE_TYPE.DECIMAL;\r\n case 'cjk-decimal':\r\n return LIST_STYLE_TYPE.CJK_DECIMAL;\r\n case 'decimal-leading-zero':\r\n return LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO;\r\n case 'lower-roman':\r\n return LIST_STYLE_TYPE.LOWER_ROMAN;\r\n case 'upper-roman':\r\n return LIST_STYLE_TYPE.UPPER_ROMAN;\r\n case 'lower-greek':\r\n return LIST_STYLE_TYPE.LOWER_GREEK;\r\n case 'lower-alpha':\r\n return LIST_STYLE_TYPE.LOWER_ALPHA;\r\n case 'upper-alpha':\r\n return LIST_STYLE_TYPE.UPPER_ALPHA;\r\n case 'arabic-indic':\r\n return LIST_STYLE_TYPE.ARABIC_INDIC;\r\n case 'armenian':\r\n return LIST_STYLE_TYPE.ARMENIAN;\r\n case 'bengali':\r\n return LIST_STYLE_TYPE.BENGALI;\r\n case 'cambodian':\r\n return LIST_STYLE_TYPE.CAMBODIAN;\r\n case 'cjk-earthly-branch':\r\n return LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH;\r\n case 'cjk-heavenly-stem':\r\n return LIST_STYLE_TYPE.CJK_HEAVENLY_STEM;\r\n case 'cjk-ideographic':\r\n return LIST_STYLE_TYPE.CJK_IDEOGRAPHIC;\r\n case 'devanagari':\r\n return LIST_STYLE_TYPE.DEVANAGARI;\r\n case 'ethiopic-numeric':\r\n return LIST_STYLE_TYPE.ETHIOPIC_NUMERIC;\r\n case 'georgian':\r\n return LIST_STYLE_TYPE.GEORGIAN;\r\n case 'gujarati':\r\n return LIST_STYLE_TYPE.GUJARATI;\r\n case 'gurmukhi':\r\n return LIST_STYLE_TYPE.GURMUKHI;\r\n case 'hebrew':\r\n return LIST_STYLE_TYPE.HEBREW;\r\n case 'hiragana':\r\n return LIST_STYLE_TYPE.HIRAGANA;\r\n case 'hiragana-iroha':\r\n return LIST_STYLE_TYPE.HIRAGANA_IROHA;\r\n case 'japanese-formal':\r\n return LIST_STYLE_TYPE.JAPANESE_FORMAL;\r\n case 'japanese-informal':\r\n return LIST_STYLE_TYPE.JAPANESE_INFORMAL;\r\n case 'kannada':\r\n return LIST_STYLE_TYPE.KANNADA;\r\n case 'katakana':\r\n return LIST_STYLE_TYPE.KATAKANA;\r\n case 'katakana-iroha':\r\n return LIST_STYLE_TYPE.KATAKANA_IROHA;\r\n case 'khmer':\r\n return LIST_STYLE_TYPE.KHMER;\r\n case 'korean-hangul-formal':\r\n return LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL;\r\n case 'korean-hanja-formal':\r\n return LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL;\r\n case 'korean-hanja-informal':\r\n return LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL;\r\n case 'lao':\r\n return LIST_STYLE_TYPE.LAO;\r\n case 'lower-armenian':\r\n return LIST_STYLE_TYPE.LOWER_ARMENIAN;\r\n case 'malayalam':\r\n return LIST_STYLE_TYPE.MALAYALAM;\r\n case 'mongolian':\r\n return LIST_STYLE_TYPE.MONGOLIAN;\r\n case 'myanmar':\r\n return LIST_STYLE_TYPE.MYANMAR;\r\n case 'oriya':\r\n return LIST_STYLE_TYPE.ORIYA;\r\n case 'persian':\r\n return LIST_STYLE_TYPE.PERSIAN;\r\n case 'simp-chinese-formal':\r\n return LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL;\r\n case 'simp-chinese-informal':\r\n return LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL;\r\n case 'tamil':\r\n return LIST_STYLE_TYPE.TAMIL;\r\n case 'telugu':\r\n return LIST_STYLE_TYPE.TELUGU;\r\n case 'thai':\r\n return LIST_STYLE_TYPE.THAI;\r\n case 'tibetan':\r\n return LIST_STYLE_TYPE.TIBETAN;\r\n case 'trad-chinese-formal':\r\n return LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL;\r\n case 'trad-chinese-informal':\r\n return LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL;\r\n case 'upper-armenian':\r\n return LIST_STYLE_TYPE.UPPER_ARMENIAN;\r\n case 'disclosure-open':\r\n return LIST_STYLE_TYPE.DISCLOSURE_OPEN;\r\n case 'disclosure-closed':\r\n return LIST_STYLE_TYPE.DISCLOSURE_CLOSED;\r\n case 'none':\r\n default:\r\n return LIST_STYLE_TYPE.NONE;\r\n }\r\n }\r\n };\n\n var marginForSide = function (side) { return ({\r\n name: \"margin-\" + side,\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TOKEN_VALUE\r\n }); };\r\n var marginTop = marginForSide('top');\r\n var marginRight = marginForSide('right');\r\n var marginBottom = marginForSide('bottom');\r\n var marginLeft = marginForSide('left');\n\n var OVERFLOW;\r\n (function (OVERFLOW) {\r\n OVERFLOW[OVERFLOW[\"VISIBLE\"] = 0] = \"VISIBLE\";\r\n OVERFLOW[OVERFLOW[\"HIDDEN\"] = 1] = \"HIDDEN\";\r\n OVERFLOW[OVERFLOW[\"SCROLL\"] = 2] = \"SCROLL\";\r\n OVERFLOW[OVERFLOW[\"AUTO\"] = 3] = \"AUTO\";\r\n })(OVERFLOW || (OVERFLOW = {}));\r\n var overflow = {\r\n name: 'overflow',\r\n initialValue: 'visible',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens.filter(isIdentToken).map(function (overflow) {\r\n switch (overflow.value) {\r\n case 'hidden':\r\n return OVERFLOW.HIDDEN;\r\n case 'scroll':\r\n return OVERFLOW.SCROLL;\r\n case 'auto':\r\n return OVERFLOW.AUTO;\r\n case 'visible':\r\n default:\r\n return OVERFLOW.VISIBLE;\r\n }\r\n });\r\n }\r\n };\n\n var OVERFLOW_WRAP;\r\n (function (OVERFLOW_WRAP) {\r\n OVERFLOW_WRAP[\"NORMAL\"] = \"normal\";\r\n OVERFLOW_WRAP[\"BREAK_WORD\"] = \"break-word\";\r\n })(OVERFLOW_WRAP || (OVERFLOW_WRAP = {}));\r\n var overflowWrap = {\r\n name: 'overflow-wrap',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (overflow) {\r\n switch (overflow) {\r\n case 'break-word':\r\n return OVERFLOW_WRAP.BREAK_WORD;\r\n case 'normal':\r\n default:\r\n return OVERFLOW_WRAP.NORMAL;\r\n }\r\n }\r\n };\n\n var paddingForSide = function (side) { return ({\r\n name: \"padding-\" + side,\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'length-percentage'\r\n }); };\r\n var paddingTop = paddingForSide('top');\r\n var paddingRight = paddingForSide('right');\r\n var paddingBottom = paddingForSide('bottom');\r\n var paddingLeft = paddingForSide('left');\n\n var TEXT_ALIGN;\r\n (function (TEXT_ALIGN) {\r\n TEXT_ALIGN[TEXT_ALIGN[\"LEFT\"] = 0] = \"LEFT\";\r\n TEXT_ALIGN[TEXT_ALIGN[\"CENTER\"] = 1] = \"CENTER\";\r\n TEXT_ALIGN[TEXT_ALIGN[\"RIGHT\"] = 2] = \"RIGHT\";\r\n })(TEXT_ALIGN || (TEXT_ALIGN = {}));\r\n var textAlign = {\r\n name: 'text-align',\r\n initialValue: 'left',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (textAlign) {\r\n switch (textAlign) {\r\n case 'right':\r\n return TEXT_ALIGN.RIGHT;\r\n case 'center':\r\n case 'justify':\r\n return TEXT_ALIGN.CENTER;\r\n case 'left':\r\n default:\r\n return TEXT_ALIGN.LEFT;\r\n }\r\n }\r\n };\n\n var POSITION;\r\n (function (POSITION) {\r\n POSITION[POSITION[\"STATIC\"] = 0] = \"STATIC\";\r\n POSITION[POSITION[\"RELATIVE\"] = 1] = \"RELATIVE\";\r\n POSITION[POSITION[\"ABSOLUTE\"] = 2] = \"ABSOLUTE\";\r\n POSITION[POSITION[\"FIXED\"] = 3] = \"FIXED\";\r\n POSITION[POSITION[\"STICKY\"] = 4] = \"STICKY\";\r\n })(POSITION || (POSITION = {}));\r\n var position = {\r\n name: 'position',\r\n initialValue: 'static',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (position) {\r\n switch (position) {\r\n case 'relative':\r\n return POSITION.RELATIVE;\r\n case 'absolute':\r\n return POSITION.ABSOLUTE;\r\n case 'fixed':\r\n return POSITION.FIXED;\r\n case 'sticky':\r\n return POSITION.STICKY;\r\n }\r\n return POSITION.STATIC;\r\n }\r\n };\n\n var textShadow = {\r\n name: 'text-shadow',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {\r\n return [];\r\n }\r\n return parseFunctionArgs(tokens).map(function (values) {\r\n var shadow = {\r\n color: COLORS.TRANSPARENT,\r\n offsetX: ZERO_LENGTH,\r\n offsetY: ZERO_LENGTH,\r\n blur: ZERO_LENGTH\r\n };\r\n var c = 0;\r\n for (var i = 0; i < values.length; i++) {\r\n var token = values[i];\r\n if (isLength(token)) {\r\n if (c === 0) {\r\n shadow.offsetX = token;\r\n }\r\n else if (c === 1) {\r\n shadow.offsetY = token;\r\n }\r\n else {\r\n shadow.blur = token;\r\n }\r\n c++;\r\n }\r\n else {\r\n shadow.color = color.parse(token);\r\n }\r\n }\r\n return shadow;\r\n });\r\n }\r\n };\n\n var TEXT_TRANSFORM;\r\n (function (TEXT_TRANSFORM) {\r\n TEXT_TRANSFORM[TEXT_TRANSFORM[\"NONE\"] = 0] = \"NONE\";\r\n TEXT_TRANSFORM[TEXT_TRANSFORM[\"LOWERCASE\"] = 1] = \"LOWERCASE\";\r\n TEXT_TRANSFORM[TEXT_TRANSFORM[\"UPPERCASE\"] = 2] = \"UPPERCASE\";\r\n TEXT_TRANSFORM[TEXT_TRANSFORM[\"CAPITALIZE\"] = 3] = \"CAPITALIZE\";\r\n })(TEXT_TRANSFORM || (TEXT_TRANSFORM = {}));\r\n var textTransform = {\r\n name: 'text-transform',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (textTransform) {\r\n switch (textTransform) {\r\n case 'uppercase':\r\n return TEXT_TRANSFORM.UPPERCASE;\r\n case 'lowercase':\r\n return TEXT_TRANSFORM.LOWERCASE;\r\n case 'capitalize':\r\n return TEXT_TRANSFORM.CAPITALIZE;\r\n }\r\n return TEXT_TRANSFORM.NONE;\r\n }\r\n };\n\n var transform = {\r\n name: 'transform',\r\n initialValue: 'none',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.VALUE,\r\n parse: function (token) {\r\n if (token.type === TokenType.IDENT_TOKEN && token.value === 'none') {\r\n return null;\r\n }\r\n if (token.type === TokenType.FUNCTION) {\r\n var transformFunction = SUPPORTED_TRANSFORM_FUNCTIONS[token.name];\r\n if (typeof transformFunction === 'undefined') {\r\n throw new Error(\"Attempting to parse an unsupported transform function \\\"\" + token.name + \"\\\"\");\r\n }\r\n return transformFunction(token.values);\r\n }\r\n return null;\r\n }\r\n };\r\n var matrix = function (args) {\r\n var values = args.filter(function (arg) { return arg.type === TokenType.NUMBER_TOKEN; }).map(function (arg) { return arg.number; });\r\n return values.length === 6 ? values : null;\r\n };\r\n // doesn't support 3D transforms at the moment\r\n var matrix3d = function (args) {\r\n var values = args.filter(function (arg) { return arg.type === TokenType.NUMBER_TOKEN; }).map(function (arg) { return arg.number; });\r\n var a1 = values[0], b1 = values[1], _a = values[2], _b = values[3], a2 = values[4], b2 = values[5], _c = values[6], _d = values[7], _e = values[8], _f = values[9], _g = values[10], _h = values[11], a4 = values[12], b4 = values[13], _j = values[14], _k = values[15];\r\n return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;\r\n };\r\n var SUPPORTED_TRANSFORM_FUNCTIONS = {\r\n matrix: matrix,\r\n matrix3d: matrix3d\r\n };\n\n var DEFAULT_VALUE = {\r\n type: TokenType.PERCENTAGE_TOKEN,\r\n number: 50,\r\n flags: FLAG_INTEGER\r\n };\r\n var DEFAULT = [DEFAULT_VALUE, DEFAULT_VALUE];\r\n var transformOrigin = {\r\n name: 'transform-origin',\r\n initialValue: '50% 50%',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n var origins = tokens.filter(isLengthPercentage);\r\n if (origins.length !== 2) {\r\n return DEFAULT;\r\n }\r\n return [origins[0], origins[1]];\r\n }\r\n };\n\n var VISIBILITY;\r\n (function (VISIBILITY) {\r\n VISIBILITY[VISIBILITY[\"VISIBLE\"] = 0] = \"VISIBLE\";\r\n VISIBILITY[VISIBILITY[\"HIDDEN\"] = 1] = \"HIDDEN\";\r\n VISIBILITY[VISIBILITY[\"COLLAPSE\"] = 2] = \"COLLAPSE\";\r\n })(VISIBILITY || (VISIBILITY = {}));\r\n var visibility = {\r\n name: 'visible',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (visibility) {\r\n switch (visibility) {\r\n case 'hidden':\r\n return VISIBILITY.HIDDEN;\r\n case 'collapse':\r\n return VISIBILITY.COLLAPSE;\r\n case 'visible':\r\n default:\r\n return VISIBILITY.VISIBLE;\r\n }\r\n }\r\n };\n\n var WORD_BREAK;\r\n (function (WORD_BREAK) {\r\n WORD_BREAK[\"NORMAL\"] = \"normal\";\r\n WORD_BREAK[\"BREAK_ALL\"] = \"break-all\";\r\n WORD_BREAK[\"KEEP_ALL\"] = \"keep-all\";\r\n })(WORD_BREAK || (WORD_BREAK = {}));\r\n var wordBreak = {\r\n name: 'word-break',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (wordBreak) {\r\n switch (wordBreak) {\r\n case 'break-all':\r\n return WORD_BREAK.BREAK_ALL;\r\n case 'keep-all':\r\n return WORD_BREAK.KEEP_ALL;\r\n case 'normal':\r\n default:\r\n return WORD_BREAK.NORMAL;\r\n }\r\n }\r\n };\n\n var zIndex = {\r\n name: 'z-index',\r\n initialValue: 'auto',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.VALUE,\r\n parse: function (token) {\r\n if (token.type === TokenType.IDENT_TOKEN) {\r\n return { auto: true, order: 0 };\r\n }\r\n if (isNumberToken(token)) {\r\n return { auto: false, order: token.number };\r\n }\r\n throw new Error(\"Invalid z-index number parsed\");\r\n }\r\n };\n\n var opacity = {\r\n name: 'opacity',\r\n initialValue: '1',\r\n type: PropertyDescriptorParsingType.VALUE,\r\n prefix: false,\r\n parse: function (token) {\r\n if (isNumberToken(token)) {\r\n return token.number;\r\n }\r\n return 1;\r\n }\r\n };\n\n var textDecorationColor = {\r\n name: \"text-decoration-color\",\r\n initialValue: 'transparent',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'color'\r\n };\n\n var textDecorationLine = {\r\n name: 'text-decoration-line',\r\n initialValue: 'none',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens\r\n .filter(isIdentToken)\r\n .map(function (token) {\r\n switch (token.value) {\r\n case 'underline':\r\n return 1 /* UNDERLINE */;\r\n case 'overline':\r\n return 2 /* OVERLINE */;\r\n case 'line-through':\r\n return 3 /* LINE_THROUGH */;\r\n case 'none':\r\n return 4 /* BLINK */;\r\n }\r\n return 0 /* NONE */;\r\n })\r\n .filter(function (line) { return line !== 0 /* NONE */; });\r\n }\r\n };\n\n var fontFamily = {\r\n name: \"font-family\",\r\n initialValue: '',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n return tokens.filter(isStringToken$1).map(function (token) { return token.value; });\r\n }\r\n };\r\n var isStringToken$1 = function (token) {\r\n return token.type === TokenType.STRING_TOKEN || token.type === TokenType.IDENT_TOKEN;\r\n };\n\n var fontSize = {\r\n name: \"font-size\",\r\n initialValue: '0',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.TYPE_VALUE,\r\n format: 'length'\r\n };\n\n var fontWeight = {\r\n name: 'font-weight',\r\n initialValue: 'normal',\r\n type: PropertyDescriptorParsingType.VALUE,\r\n prefix: false,\r\n parse: function (token) {\r\n if (isNumberToken(token)) {\r\n return token.number;\r\n }\r\n if (isIdentToken(token)) {\r\n switch (token.value) {\r\n case 'bold':\r\n return 700;\r\n case 'normal':\r\n default:\r\n return 400;\r\n }\r\n }\r\n return 400;\r\n }\r\n };\n\n var fontVariant = {\r\n name: 'font-variant',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n return tokens.filter(isIdentToken).map(function (token) { return token.value; });\r\n }\r\n };\n\n var FONT_STYLE;\r\n (function (FONT_STYLE) {\r\n FONT_STYLE[\"NORMAL\"] = \"normal\";\r\n FONT_STYLE[\"ITALIC\"] = \"italic\";\r\n FONT_STYLE[\"OBLIQUE\"] = \"oblique\";\r\n })(FONT_STYLE || (FONT_STYLE = {}));\r\n var fontStyle = {\r\n name: 'font-style',\r\n initialValue: 'normal',\r\n prefix: false,\r\n type: PropertyDescriptorParsingType.IDENT_VALUE,\r\n parse: function (overflow) {\r\n switch (overflow) {\r\n case 'oblique':\r\n return FONT_STYLE.OBLIQUE;\r\n case 'italic':\r\n return FONT_STYLE.ITALIC;\r\n case 'normal':\r\n default:\r\n return FONT_STYLE.NORMAL;\r\n }\r\n }\r\n };\n\n var contains = function (bit, value) { return (bit & value) !== 0; };\n\n var content = {\r\n name: 'content',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return [];\r\n }\r\n var first = tokens[0];\r\n if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {\r\n return [];\r\n }\r\n return tokens;\r\n }\r\n };\n\n var counterIncrement = {\r\n name: 'counter-increment',\r\n initialValue: 'none',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return null;\r\n }\r\n var first = tokens[0];\r\n if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {\r\n return null;\r\n }\r\n var increments = [];\r\n var filtered = tokens.filter(nonWhiteSpace);\r\n for (var i = 0; i < filtered.length; i++) {\r\n var counter = filtered[i];\r\n var next = filtered[i + 1];\r\n if (counter.type === TokenType.IDENT_TOKEN) {\r\n var increment = next && isNumberToken(next) ? next.number : 1;\r\n increments.push({ counter: counter.value, increment: increment });\r\n }\r\n }\r\n return increments;\r\n }\r\n };\n\n var counterReset = {\r\n name: 'counter-reset',\r\n initialValue: 'none',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return [];\r\n }\r\n var resets = [];\r\n var filtered = tokens.filter(nonWhiteSpace);\r\n for (var i = 0; i < filtered.length; i++) {\r\n var counter = filtered[i];\r\n var next = filtered[i + 1];\r\n if (isIdentToken(counter) && counter.value !== 'none') {\r\n var reset = next && isNumberToken(next) ? next.number : 0;\r\n resets.push({ counter: counter.value, reset: reset });\r\n }\r\n }\r\n return resets;\r\n }\r\n };\n\n var quotes = {\r\n name: 'quotes',\r\n initialValue: 'none',\r\n prefix: true,\r\n type: PropertyDescriptorParsingType.LIST,\r\n parse: function (tokens) {\r\n if (tokens.length === 0) {\r\n return null;\r\n }\r\n var first = tokens[0];\r\n if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {\r\n return null;\r\n }\r\n var quotes = [];\r\n var filtered = tokens.filter(isStringToken);\r\n if (filtered.length % 2 !== 0) {\r\n return null;\r\n }\r\n for (var i = 0; i < filtered.length; i += 2) {\r\n var open_1 = filtered[i].value;\r\n var close_1 = filtered[i + 1].value;\r\n quotes.push({ open: open_1, close: close_1 });\r\n }\r\n return quotes;\r\n }\r\n };\r\n var getQuote = function (quotes, depth, open) {\r\n if (!quotes) {\r\n return '';\r\n }\r\n var quote = quotes[Math.min(depth, quotes.length - 1)];\r\n if (!quote) {\r\n return '';\r\n }\r\n return open ? quote.open : quote.close;\r\n };\n\n var boxShadow = {\r\n name: 'box-shadow',\r\n initialValue: 'none',\r\n type: PropertyDescriptorParsingType.LIST,\r\n prefix: false,\r\n parse: function (tokens) {\r\n if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {\r\n return [];\r\n }\r\n return parseFunctionArgs(tokens).map(function (values) {\r\n var shadow = {\r\n color: 0x000000ff,\r\n offsetX: ZERO_LENGTH,\r\n offsetY: ZERO_LENGTH,\r\n blur: ZERO_LENGTH,\r\n spread: ZERO_LENGTH,\r\n inset: false\r\n };\r\n var c = 0;\r\n for (var i = 0; i < values.length; i++) {\r\n var token = values[i];\r\n if (isIdentWithValue(token, 'inset')) {\r\n shadow.inset = true;\r\n }\r\n else if (isLength(token)) {\r\n if (c === 0) {\r\n shadow.offsetX = token;\r\n }\r\n else if (c === 1) {\r\n shadow.offsetY = token;\r\n }\r\n else if (c === 2) {\r\n shadow.blur = token;\r\n }\r\n else {\r\n shadow.spread = token;\r\n }\r\n c++;\r\n }\r\n else {\r\n shadow.color = color.parse(token);\r\n }\r\n }\r\n return shadow;\r\n });\r\n }\r\n };\n\n var CSSParsedDeclaration = /** @class */ (function () {\r\n function CSSParsedDeclaration(declaration) {\r\n this.backgroundClip = parse(backgroundClip, declaration.backgroundClip);\r\n this.backgroundColor = parse(backgroundColor, declaration.backgroundColor);\r\n this.backgroundImage = parse(backgroundImage, declaration.backgroundImage);\r\n this.backgroundOrigin = parse(backgroundOrigin, declaration.backgroundOrigin);\r\n this.backgroundPosition = parse(backgroundPosition, declaration.backgroundPosition);\r\n this.backgroundRepeat = parse(backgroundRepeat, declaration.backgroundRepeat);\r\n this.backgroundSize = parse(backgroundSize, declaration.backgroundSize);\r\n this.borderTopColor = parse(borderTopColor, declaration.borderTopColor);\r\n this.borderRightColor = parse(borderRightColor, declaration.borderRightColor);\r\n this.borderBottomColor = parse(borderBottomColor, declaration.borderBottomColor);\r\n this.borderLeftColor = parse(borderLeftColor, declaration.borderLeftColor);\r\n this.borderTopLeftRadius = parse(borderTopLeftRadius, declaration.borderTopLeftRadius);\r\n this.borderTopRightRadius = parse(borderTopRightRadius, declaration.borderTopRightRadius);\r\n this.borderBottomRightRadius = parse(borderBottomRightRadius, declaration.borderBottomRightRadius);\r\n this.borderBottomLeftRadius = parse(borderBottomLeftRadius, declaration.borderBottomLeftRadius);\r\n this.borderTopStyle = parse(borderTopStyle, declaration.borderTopStyle);\r\n this.borderRightStyle = parse(borderRightStyle, declaration.borderRightStyle);\r\n this.borderBottomStyle = parse(borderBottomStyle, declaration.borderBottomStyle);\r\n this.borderLeftStyle = parse(borderLeftStyle, declaration.borderLeftStyle);\r\n this.borderTopWidth = parse(borderTopWidth, declaration.borderTopWidth);\r\n this.borderRightWidth = parse(borderRightWidth, declaration.borderRightWidth);\r\n this.borderBottomWidth = parse(borderBottomWidth, declaration.borderBottomWidth);\r\n this.borderLeftWidth = parse(borderLeftWidth, declaration.borderLeftWidth);\r\n this.boxShadow = parse(boxShadow, declaration.boxShadow);\r\n this.color = parse(color$1, declaration.color);\r\n this.display = parse(display, declaration.display);\r\n this.float = parse(float, declaration.cssFloat);\r\n this.fontFamily = parse(fontFamily, declaration.fontFamily);\r\n this.fontSize = parse(fontSize, declaration.fontSize);\r\n this.fontStyle = parse(fontStyle, declaration.fontStyle);\r\n this.fontVariant = parse(fontVariant, declaration.fontVariant);\r\n this.fontWeight = parse(fontWeight, declaration.fontWeight);\r\n this.letterSpacing = parse(letterSpacing, declaration.letterSpacing);\r\n this.lineBreak = parse(lineBreak, declaration.lineBreak);\r\n this.lineHeight = parse(lineHeight, declaration.lineHeight);\r\n this.listStyleImage = parse(listStyleImage, declaration.listStyleImage);\r\n this.listStylePosition = parse(listStylePosition, declaration.listStylePosition);\r\n this.listStyleType = parse(listStyleType, declaration.listStyleType);\r\n this.marginTop = parse(marginTop, declaration.marginTop);\r\n this.marginRight = parse(marginRight, declaration.marginRight);\r\n this.marginBottom = parse(marginBottom, declaration.marginBottom);\r\n this.marginLeft = parse(marginLeft, declaration.marginLeft);\r\n this.opacity = parse(opacity, declaration.opacity);\r\n var overflowTuple = parse(overflow, declaration.overflow);\r\n this.overflowX = overflowTuple[0];\r\n this.overflowY = overflowTuple[overflowTuple.length > 1 ? 1 : 0];\r\n this.overflowWrap = parse(overflowWrap, declaration.overflowWrap);\r\n this.paddingTop = parse(paddingTop, declaration.paddingTop);\r\n this.paddingRight = parse(paddingRight, declaration.paddingRight);\r\n this.paddingBottom = parse(paddingBottom, declaration.paddingBottom);\r\n this.paddingLeft = parse(paddingLeft, declaration.paddingLeft);\r\n this.position = parse(position, declaration.position);\r\n this.textAlign = parse(textAlign, declaration.textAlign);\r\n this.textDecorationColor = parse(textDecorationColor, declaration.textDecorationColor || declaration.color);\r\n this.textDecorationLine = parse(textDecorationLine, declaration.textDecorationLine);\r\n this.textShadow = parse(textShadow, declaration.textShadow);\r\n this.textTransform = parse(textTransform, declaration.textTransform);\r\n this.transform = parse(transform, declaration.transform);\r\n this.transformOrigin = parse(transformOrigin, declaration.transformOrigin);\r\n this.visibility = parse(visibility, declaration.visibility);\r\n this.wordBreak = parse(wordBreak, declaration.wordBreak);\r\n this.zIndex = parse(zIndex, declaration.zIndex);\r\n }\r\n CSSParsedDeclaration.prototype.isVisible = function () {\r\n return this.display > 0 && this.opacity > 0 && this.visibility === VISIBILITY.VISIBLE;\r\n };\r\n CSSParsedDeclaration.prototype.isTransparent = function () {\r\n return isTransparent(this.backgroundColor);\r\n };\r\n CSSParsedDeclaration.prototype.isTransformed = function () {\r\n return this.transform !== null;\r\n };\r\n CSSParsedDeclaration.prototype.isPositioned = function () {\r\n return this.position !== POSITION.STATIC;\r\n };\r\n CSSParsedDeclaration.prototype.isPositionedWithZIndex = function () {\r\n return this.isPositioned() && !this.zIndex.auto;\r\n };\r\n CSSParsedDeclaration.prototype.isFloating = function () {\r\n return this.float !== FLOAT.NONE;\r\n };\r\n CSSParsedDeclaration.prototype.isInlineLevel = function () {\r\n return (contains(this.display, 4 /* INLINE */) ||\r\n contains(this.display, 33554432 /* INLINE_BLOCK */) ||\r\n contains(this.display, 268435456 /* INLINE_FLEX */) ||\r\n contains(this.display, 536870912 /* INLINE_GRID */) ||\r\n contains(this.display, 67108864 /* INLINE_LIST_ITEM */) ||\r\n contains(this.display, 134217728 /* INLINE_TABLE */));\r\n };\r\n return CSSParsedDeclaration;\r\n }());\r\n var CSSParsedPseudoDeclaration = /** @class */ (function () {\r\n function CSSParsedPseudoDeclaration(declaration) {\r\n this.content = parse(content, declaration.content);\r\n this.quotes = parse(quotes, declaration.quotes);\r\n }\r\n return CSSParsedPseudoDeclaration;\r\n }());\r\n var CSSParsedCounterDeclaration = /** @class */ (function () {\r\n function CSSParsedCounterDeclaration(declaration) {\r\n this.counterIncrement = parse(counterIncrement, declaration.counterIncrement);\r\n this.counterReset = parse(counterReset, declaration.counterReset);\r\n }\r\n return CSSParsedCounterDeclaration;\r\n }());\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n var parse = function (descriptor, style) {\r\n var tokenizer = new Tokenizer();\r\n var value = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue;\r\n tokenizer.write(value);\r\n var parser = new Parser(tokenizer.read());\r\n switch (descriptor.type) {\r\n case PropertyDescriptorParsingType.IDENT_VALUE:\r\n var token = parser.parseComponentValue();\r\n return descriptor.parse(isIdentToken(token) ? token.value : descriptor.initialValue);\r\n case PropertyDescriptorParsingType.VALUE:\r\n return descriptor.parse(parser.parseComponentValue());\r\n case PropertyDescriptorParsingType.LIST:\r\n return descriptor.parse(parser.parseComponentValues());\r\n case PropertyDescriptorParsingType.TOKEN_VALUE:\r\n return parser.parseComponentValue();\r\n case PropertyDescriptorParsingType.TYPE_VALUE:\r\n switch (descriptor.format) {\r\n case 'angle':\r\n return angle.parse(parser.parseComponentValue());\r\n case 'color':\r\n return color.parse(parser.parseComponentValue());\r\n case 'image':\r\n return image.parse(parser.parseComponentValue());\r\n case 'length':\r\n var length_1 = parser.parseComponentValue();\r\n return isLength(length_1) ? length_1 : ZERO_LENGTH;\r\n case 'length-percentage':\r\n var value_1 = parser.parseComponentValue();\r\n return isLengthPercentage(value_1) ? value_1 : ZERO_LENGTH;\r\n }\r\n }\r\n throw new Error(\"Attempting to parse unsupported css format type \" + descriptor.format);\r\n };\n\n var ElementContainer = /** @class */ (function () {\r\n function ElementContainer(element) {\r\n this.styles = new CSSParsedDeclaration(window.getComputedStyle(element, null));\r\n this.textNodes = [];\r\n this.elements = [];\r\n if (this.styles.transform !== null && isHTMLElementNode(element)) {\r\n // getBoundingClientRect takes transforms into account\r\n element.style.transform = 'none';\r\n }\r\n this.bounds = parseBounds(element);\r\n this.flags = 0;\r\n }\r\n return ElementContainer;\r\n }());\n\n var TextBounds = /** @class */ (function () {\r\n function TextBounds(text, bounds) {\r\n this.text = text;\r\n this.bounds = bounds;\r\n }\r\n return TextBounds;\r\n }());\r\n var parseTextBounds = function (value, styles, node) {\r\n var textList = breakText(value, styles);\r\n var textBounds = [];\r\n var offset = 0;\r\n textList.forEach(function (text) {\r\n if (styles.textDecorationLine.length || text.trim().length > 0) {\r\n if (FEATURES.SUPPORT_RANGE_BOUNDS) {\r\n textBounds.push(new TextBounds(text, getRangeBounds(node, offset, text.length)));\r\n }\r\n else {\r\n var replacementNode = node.splitText(text.length);\r\n textBounds.push(new TextBounds(text, getWrapperBounds(node)));\r\n node = replacementNode;\r\n }\r\n }\r\n else if (!FEATURES.SUPPORT_RANGE_BOUNDS) {\r\n node = node.splitText(text.length);\r\n }\r\n offset += text.length;\r\n });\r\n return textBounds;\r\n };\r\n var getWrapperBounds = function (node) {\r\n var ownerDocument = node.ownerDocument;\r\n if (ownerDocument) {\r\n var wrapper = ownerDocument.createElement('html2canvaswrapper');\r\n wrapper.appendChild(node.cloneNode(true));\r\n var parentNode = node.parentNode;\r\n if (parentNode) {\r\n parentNode.replaceChild(wrapper, node);\r\n var bounds = parseBounds(wrapper);\r\n if (wrapper.firstChild) {\r\n parentNode.replaceChild(wrapper.firstChild, wrapper);\r\n }\r\n return bounds;\r\n }\r\n }\r\n return new Bounds(0, 0, 0, 0);\r\n };\r\n var getRangeBounds = function (node, offset, length) {\r\n var ownerDocument = node.ownerDocument;\r\n if (!ownerDocument) {\r\n throw new Error('Node has no owner document');\r\n }\r\n var range = ownerDocument.createRange();\r\n range.setStart(node, offset);\r\n range.setEnd(node, offset + length);\r\n return Bounds.fromClientRect(range.getBoundingClientRect());\r\n };\r\n var breakText = function (value, styles) {\r\n return styles.letterSpacing !== 0 ? toCodePoints(value).map(function (i) { return fromCodePoint(i); }) : breakWords(value, styles);\r\n };\r\n var breakWords = function (str, styles) {\r\n var breaker = LineBreaker(str, {\r\n lineBreak: styles.lineBreak,\r\n wordBreak: styles.overflowWrap === OVERFLOW_WRAP.BREAK_WORD ? 'break-word' : styles.wordBreak\r\n });\r\n var words = [];\r\n var bk;\r\n while (!(bk = breaker.next()).done) {\r\n if (bk.value) {\r\n words.push(bk.value.slice());\r\n }\r\n }\r\n return words;\r\n };\n\n var TextContainer = /** @class */ (function () {\r\n function TextContainer(node, styles) {\r\n this.text = transform$1(node.data, styles.textTransform);\r\n this.textBounds = parseTextBounds(this.text, styles, node);\r\n }\r\n return TextContainer;\r\n }());\r\n var transform$1 = function (text, transform) {\r\n switch (transform) {\r\n case TEXT_TRANSFORM.LOWERCASE:\r\n return text.toLowerCase();\r\n case TEXT_TRANSFORM.CAPITALIZE:\r\n return text.replace(CAPITALIZE, capitalize);\r\n case TEXT_TRANSFORM.UPPERCASE:\r\n return text.toUpperCase();\r\n default:\r\n return text;\r\n }\r\n };\r\n var CAPITALIZE = /(^|\\s|:|-|\\(|\\))([a-z])/g;\r\n var capitalize = function (m, p1, p2) {\r\n if (m.length > 0) {\r\n return p1 + p2.toUpperCase();\r\n }\r\n return m;\r\n };\n\n var ImageElementContainer = /** @class */ (function (_super) {\r\n __extends(ImageElementContainer, _super);\r\n function ImageElementContainer(img) {\r\n var _this = _super.call(this, img) || this;\r\n _this.src = img.currentSrc || img.src;\r\n _this.intrinsicWidth = img.naturalWidth;\r\n _this.intrinsicHeight = img.naturalHeight;\r\n CacheStorage.getInstance().addImage(_this.src);\r\n return _this;\r\n }\r\n return ImageElementContainer;\r\n }(ElementContainer));\n\n var CanvasElementContainer = /** @class */ (function (_super) {\r\n __extends(CanvasElementContainer, _super);\r\n function CanvasElementContainer(canvas) {\r\n var _this = _super.call(this, canvas) || this;\r\n _this.canvas = canvas;\r\n _this.intrinsicWidth = canvas.width;\r\n _this.intrinsicHeight = canvas.height;\r\n return _this;\r\n }\r\n return CanvasElementContainer;\r\n }(ElementContainer));\n\n var SVGElementContainer = /** @class */ (function (_super) {\r\n __extends(SVGElementContainer, _super);\r\n function SVGElementContainer(img) {\r\n var _this = _super.call(this, img) || this;\r\n var s = new XMLSerializer();\r\n _this.svg = \"data:image/svg+xml,\" + encodeURIComponent(s.serializeToString(img));\r\n _this.intrinsicWidth = img.width.baseVal.value;\r\n _this.intrinsicHeight = img.height.baseVal.value;\r\n CacheStorage.getInstance().addImage(_this.svg);\r\n return _this;\r\n }\r\n return SVGElementContainer;\r\n }(ElementContainer));\n\n var LIElementContainer = /** @class */ (function (_super) {\r\n __extends(LIElementContainer, _super);\r\n function LIElementContainer(element) {\r\n var _this = _super.call(this, element) || this;\r\n _this.value = element.value;\r\n return _this;\r\n }\r\n return LIElementContainer;\r\n }(ElementContainer));\n\n var OLElementContainer = /** @class */ (function (_super) {\r\n __extends(OLElementContainer, _super);\r\n function OLElementContainer(element) {\r\n var _this = _super.call(this, element) || this;\r\n _this.start = element.start;\r\n _this.reversed = typeof element.reversed === 'boolean' && element.reversed === true;\r\n return _this;\r\n }\r\n return OLElementContainer;\r\n }(ElementContainer));\n\n var CHECKBOX_BORDER_RADIUS = [\r\n {\r\n type: TokenType.DIMENSION_TOKEN,\r\n flags: 0,\r\n unit: 'px',\r\n number: 3\r\n }\r\n ];\r\n var RADIO_BORDER_RADIUS = [\r\n {\r\n type: TokenType.PERCENTAGE_TOKEN,\r\n flags: 0,\r\n number: 50\r\n }\r\n ];\r\n var reformatInputBounds = function (bounds) {\r\n if (bounds.width > bounds.height) {\r\n return new Bounds(bounds.left + (bounds.width - bounds.height) / 2, bounds.top, bounds.height, bounds.height);\r\n }\r\n else if (bounds.width < bounds.height) {\r\n return new Bounds(bounds.left, bounds.top + (bounds.height - bounds.width) / 2, bounds.width, bounds.width);\r\n }\r\n return bounds;\r\n };\r\n var getInputValue = function (node) {\r\n var value = node.type === PASSWORD ? new Array(node.value.length + 1).join('\\u2022') : node.value;\r\n return value.length === 0 ? node.placeholder || '' : value;\r\n };\r\n var CHECKBOX = 'checkbox';\r\n var RADIO = 'radio';\r\n var PASSWORD = 'password';\r\n var INPUT_COLOR = 0x2a2a2aff;\r\n var InputElementContainer = /** @class */ (function (_super) {\r\n __extends(InputElementContainer, _super);\r\n function InputElementContainer(input) {\r\n var _this = _super.call(this, input) || this;\r\n _this.type = input.type.toLowerCase();\r\n _this.checked = input.checked;\r\n _this.value = getInputValue(input);\r\n if (_this.type === CHECKBOX || _this.type === RADIO) {\r\n _this.styles.backgroundColor = 0xdededeff;\r\n _this.styles.borderTopColor = _this.styles.borderRightColor = _this.styles.borderBottomColor = _this.styles.borderLeftColor = 0xa5a5a5ff;\r\n _this.styles.borderTopWidth = _this.styles.borderRightWidth = _this.styles.borderBottomWidth = _this.styles.borderLeftWidth = 1;\r\n _this.styles.borderTopStyle = _this.styles.borderRightStyle = _this.styles.borderBottomStyle = _this.styles.borderLeftStyle =\r\n BORDER_STYLE.SOLID;\r\n _this.styles.backgroundClip = [BACKGROUND_CLIP.BORDER_BOX];\r\n _this.styles.backgroundOrigin = [0 /* BORDER_BOX */];\r\n _this.bounds = reformatInputBounds(_this.bounds);\r\n }\r\n switch (_this.type) {\r\n case CHECKBOX:\r\n _this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = CHECKBOX_BORDER_RADIUS;\r\n break;\r\n case RADIO:\r\n _this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = RADIO_BORDER_RADIUS;\r\n break;\r\n }\r\n return _this;\r\n }\r\n return InputElementContainer;\r\n }(ElementContainer));\n\n var SelectElementContainer = /** @class */ (function (_super) {\r\n __extends(SelectElementContainer, _super);\r\n function SelectElementContainer(element) {\r\n var _this = _super.call(this, element) || this;\r\n var option = element.options[element.selectedIndex || 0];\r\n _this.value = option ? option.text || '' : '';\r\n return _this;\r\n }\r\n return SelectElementContainer;\r\n }(ElementContainer));\n\n var TextareaElementContainer = /** @class */ (function (_super) {\r\n __extends(TextareaElementContainer, _super);\r\n function TextareaElementContainer(element) {\r\n var _this = _super.call(this, element) || this;\r\n _this.value = element.value;\r\n return _this;\r\n }\r\n return TextareaElementContainer;\r\n }(ElementContainer));\n\n var parseColor = function (value) { return color.parse(Parser.create(value).parseComponentValue()); };\r\n var IFrameElementContainer = /** @class */ (function (_super) {\r\n __extends(IFrameElementContainer, _super);\r\n function IFrameElementContainer(iframe) {\r\n var _this = _super.call(this, iframe) || this;\r\n _this.src = iframe.src;\r\n _this.width = parseInt(iframe.width, 10) || 0;\r\n _this.height = parseInt(iframe.height, 10) || 0;\r\n _this.backgroundColor = _this.styles.backgroundColor;\r\n try {\r\n if (iframe.contentWindow &&\r\n iframe.contentWindow.document &&\r\n iframe.contentWindow.document.documentElement) {\r\n _this.tree = parseTree(iframe.contentWindow.document.documentElement);\r\n // http://www.w3.org/TR/css3-background/#special-backgrounds\r\n var documentBackgroundColor = iframe.contentWindow.document.documentElement\r\n ? parseColor(getComputedStyle(iframe.contentWindow.document.documentElement)\r\n .backgroundColor)\r\n : COLORS.TRANSPARENT;\r\n var bodyBackgroundColor = iframe.contentWindow.document.body\r\n ? parseColor(getComputedStyle(iframe.contentWindow.document.body).backgroundColor)\r\n : COLORS.TRANSPARENT;\r\n _this.backgroundColor = isTransparent(documentBackgroundColor)\r\n ? isTransparent(bodyBackgroundColor)\r\n ? _this.styles.backgroundColor\r\n : bodyBackgroundColor\r\n : documentBackgroundColor;\r\n }\r\n }\r\n catch (e) { }\r\n return _this;\r\n }\r\n return IFrameElementContainer;\r\n }(ElementContainer));\n\n var LIST_OWNERS = ['OL', 'UL', 'MENU'];\r\n var parseNodeTree = function (node, parent, root) {\r\n for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {\r\n nextNode = childNode.nextSibling;\r\n if (isTextNode(childNode) && childNode.data.trim().length > 0) {\r\n parent.textNodes.push(new TextContainer(childNode, parent.styles));\r\n }\r\n else if (isElementNode(childNode)) {\r\n var container = createContainer(childNode);\r\n if (container.styles.isVisible()) {\r\n if (createsRealStackingContext(childNode, container, root)) {\r\n container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;\r\n }\r\n else if (createsStackingContext(container.styles)) {\r\n container.flags |= 2 /* CREATES_STACKING_CONTEXT */;\r\n }\r\n if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {\r\n container.flags |= 8 /* IS_LIST_OWNER */;\r\n }\r\n parent.elements.push(container);\r\n if (!isTextareaElement(childNode) && !isSVGElement(childNode) && !isSelectElement(childNode)) {\r\n parseNodeTree(childNode, container, root);\r\n }\r\n }\r\n }\r\n }\r\n };\r\n var createContainer = function (element) {\r\n if (isImageElement(element)) {\r\n return new ImageElementContainer(element);\r\n }\r\n if (isCanvasElement(element)) {\r\n return new CanvasElementContainer(element);\r\n }\r\n if (isSVGElement(element)) {\r\n return new SVGElementContainer(element);\r\n }\r\n if (isLIElement(element)) {\r\n return new LIElementContainer(element);\r\n }\r\n if (isOLElement(element)) {\r\n return new OLElementContainer(element);\r\n }\r\n if (isInputElement(element)) {\r\n return new InputElementContainer(element);\r\n }\r\n if (isSelectElement(element)) {\r\n return new SelectElementContainer(element);\r\n }\r\n if (isTextareaElement(element)) {\r\n return new TextareaElementContainer(element);\r\n }\r\n if (isIFrameElement(element)) {\r\n return new IFrameElementContainer(element);\r\n }\r\n return new ElementContainer(element);\r\n };\r\n var parseTree = function (element) {\r\n var container = createContainer(element);\r\n container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;\r\n parseNodeTree(element, container, container);\r\n return container;\r\n };\r\n var createsRealStackingContext = function (node, container, root) {\r\n return (container.styles.isPositionedWithZIndex() ||\r\n container.styles.opacity < 1 ||\r\n container.styles.isTransformed() ||\r\n (isBodyElement(node) && root.styles.isTransparent()));\r\n };\r\n var createsStackingContext = function (styles) { return styles.isPositioned() || styles.isFloating(); };\r\n var isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };\r\n var isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };\r\n var isHTMLElementNode = function (node) {\r\n return typeof node.style !== 'undefined';\r\n };\r\n var isLIElement = function (node) { return node.tagName === 'LI'; };\r\n var isOLElement = function (node) { return node.tagName === 'OL'; };\r\n var isInputElement = function (node) { return node.tagName === 'INPUT'; };\r\n var isHTMLElement = function (node) { return node.tagName === 'HTML'; };\r\n var isSVGElement = function (node) { return node.tagName === 'svg'; };\r\n var isBodyElement = function (node) { return node.tagName === 'BODY'; };\r\n var isCanvasElement = function (node) { return node.tagName === 'CANVAS'; };\r\n var isImageElement = function (node) { return node.tagName === 'IMG'; };\r\n var isIFrameElement = function (node) { return node.tagName === 'IFRAME'; };\r\n var isStyleElement = function (node) { return node.tagName === 'STYLE'; };\r\n var isScriptElement = function (node) { return node.tagName === 'SCRIPT'; };\r\n var isTextareaElement = function (node) { return node.tagName === 'TEXTAREA'; };\r\n var isSelectElement = function (node) { return node.tagName === 'SELECT'; };\n\n var CounterState = /** @class */ (function () {\r\n function CounterState() {\r\n this.counters = {};\r\n }\r\n CounterState.prototype.getCounterValue = function (name) {\r\n var counter = this.counters[name];\r\n if (counter && counter.length) {\r\n return counter[counter.length - 1];\r\n }\r\n return 1;\r\n };\r\n CounterState.prototype.getCounterValues = function (name) {\r\n var counter = this.counters[name];\r\n return counter ? counter : [];\r\n };\r\n CounterState.prototype.pop = function (counters) {\r\n var _this = this;\r\n counters.forEach(function (counter) { return _this.counters[counter].pop(); });\r\n };\r\n CounterState.prototype.parse = function (style) {\r\n var _this = this;\r\n var counterIncrement = style.counterIncrement;\r\n var counterReset = style.counterReset;\r\n var canReset = true;\r\n if (counterIncrement !== null) {\r\n counterIncrement.forEach(function (entry) {\r\n var counter = _this.counters[entry.counter];\r\n if (counter && entry.increment !== 0) {\r\n canReset = false;\r\n counter[Math.max(0, counter.length - 1)] += entry.increment;\r\n }\r\n });\r\n }\r\n var counterNames = [];\r\n if (canReset) {\r\n counterReset.forEach(function (entry) {\r\n var counter = _this.counters[entry.counter];\r\n counterNames.push(entry.counter);\r\n if (!counter) {\r\n counter = _this.counters[entry.counter] = [];\r\n }\r\n counter.push(entry.reset);\r\n });\r\n }\r\n return counterNames;\r\n };\r\n return CounterState;\r\n }());\r\n var ROMAN_UPPER = {\r\n integers: [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],\r\n values: ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']\r\n };\r\n var ARMENIAN = {\r\n integers: [\r\n 9000,\r\n 8000,\r\n 7000,\r\n 6000,\r\n 5000,\r\n 4000,\r\n 3000,\r\n 2000,\r\n 1000,\r\n 900,\r\n 800,\r\n 700,\r\n 600,\r\n 500,\r\n 400,\r\n 300,\r\n 200,\r\n 100,\r\n 90,\r\n 80,\r\n 70,\r\n 60,\r\n 50,\r\n 40,\r\n 30,\r\n 20,\r\n 10,\r\n 9,\r\n 8,\r\n 7,\r\n 6,\r\n 5,\r\n 4,\r\n 3,\r\n 2,\r\n 1\r\n ],\r\n values: [\r\n 'Ք',\r\n 'Փ',\r\n 'Ւ',\r\n 'Ց',\r\n 'Ր',\r\n 'Տ',\r\n 'Վ',\r\n 'Ս',\r\n 'Ռ',\r\n 'Ջ',\r\n 'Պ',\r\n 'Չ',\r\n 'Ո',\r\n 'Շ',\r\n 'Ն',\r\n 'Յ',\r\n 'Մ',\r\n 'Ճ',\r\n 'Ղ',\r\n 'Ձ',\r\n 'Հ',\r\n 'Կ',\r\n 'Ծ',\r\n 'Խ',\r\n 'Լ',\r\n 'Ի',\r\n 'Ժ',\r\n 'Թ',\r\n 'Ը',\r\n 'Է',\r\n 'Զ',\r\n 'Ե',\r\n 'Դ',\r\n 'Գ',\r\n 'Բ',\r\n 'Ա'\r\n ]\r\n };\r\n var HEBREW = {\r\n integers: [\r\n 10000,\r\n 9000,\r\n 8000,\r\n 7000,\r\n 6000,\r\n 5000,\r\n 4000,\r\n 3000,\r\n 2000,\r\n 1000,\r\n 400,\r\n 300,\r\n 200,\r\n 100,\r\n 90,\r\n 80,\r\n 70,\r\n 60,\r\n 50,\r\n 40,\r\n 30,\r\n 20,\r\n 19,\r\n 18,\r\n 17,\r\n 16,\r\n 15,\r\n 10,\r\n 9,\r\n 8,\r\n 7,\r\n 6,\r\n 5,\r\n 4,\r\n 3,\r\n 2,\r\n 1\r\n ],\r\n values: [\r\n 'י׳',\r\n 'ט׳',\r\n 'ח׳',\r\n 'ז׳',\r\n 'ו׳',\r\n 'ה׳',\r\n 'ד׳',\r\n 'ג׳',\r\n 'ב׳',\r\n 'א׳',\r\n 'ת',\r\n 'ש',\r\n 'ר',\r\n 'ק',\r\n 'צ',\r\n 'פ',\r\n 'ע',\r\n 'ס',\r\n 'נ',\r\n 'מ',\r\n 'ל',\r\n 'כ',\r\n 'יט',\r\n 'יח',\r\n 'יז',\r\n 'טז',\r\n 'טו',\r\n 'י',\r\n 'ט',\r\n 'ח',\r\n 'ז',\r\n 'ו',\r\n 'ה',\r\n 'ד',\r\n 'ג',\r\n 'ב',\r\n 'א'\r\n ]\r\n };\r\n var GEORGIAN = {\r\n integers: [\r\n 10000,\r\n 9000,\r\n 8000,\r\n 7000,\r\n 6000,\r\n 5000,\r\n 4000,\r\n 3000,\r\n 2000,\r\n 1000,\r\n 900,\r\n 800,\r\n 700,\r\n 600,\r\n 500,\r\n 400,\r\n 300,\r\n 200,\r\n 100,\r\n 90,\r\n 80,\r\n 70,\r\n 60,\r\n 50,\r\n 40,\r\n 30,\r\n 20,\r\n 10,\r\n 9,\r\n 8,\r\n 7,\r\n 6,\r\n 5,\r\n 4,\r\n 3,\r\n 2,\r\n 1\r\n ],\r\n values: [\r\n 'ჵ',\r\n 'ჰ',\r\n 'ჯ',\r\n 'ჴ',\r\n 'ხ',\r\n 'ჭ',\r\n 'წ',\r\n 'ძ',\r\n 'ც',\r\n 'ჩ',\r\n 'შ',\r\n 'ყ',\r\n 'ღ',\r\n 'ქ',\r\n 'ფ',\r\n 'ჳ',\r\n 'ტ',\r\n 'ს',\r\n 'რ',\r\n 'ჟ',\r\n 'პ',\r\n 'ო',\r\n 'ჲ',\r\n 'ნ',\r\n 'მ',\r\n 'ლ',\r\n 'კ',\r\n 'ი',\r\n 'თ',\r\n 'ჱ',\r\n 'ზ',\r\n 'ვ',\r\n 'ე',\r\n 'დ',\r\n 'გ',\r\n 'ბ',\r\n 'ა'\r\n ]\r\n };\r\n var createAdditiveCounter = function (value, min, max, symbols, fallback, suffix) {\r\n if (value < min || value > max) {\r\n return createCounterText(value, fallback, suffix.length > 0);\r\n }\r\n return (symbols.integers.reduce(function (string, integer, index) {\r\n while (value >= integer) {\r\n value -= integer;\r\n string += symbols.values[index];\r\n }\r\n return string;\r\n }, '') + suffix);\r\n };\r\n var createCounterStyleWithSymbolResolver = function (value, codePointRangeLength, isNumeric, resolver) {\r\n var string = '';\r\n do {\r\n if (!isNumeric) {\r\n value--;\r\n }\r\n string = resolver(value) + string;\r\n value /= codePointRangeLength;\r\n } while (value * codePointRangeLength >= codePointRangeLength);\r\n return string;\r\n };\r\n var createCounterStyleFromRange = function (value, codePointRangeStart, codePointRangeEnd, isNumeric, suffix) {\r\n var codePointRangeLength = codePointRangeEnd - codePointRangeStart + 1;\r\n return ((value < 0 ? '-' : '') +\r\n (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, isNumeric, function (codePoint) {\r\n return fromCodePoint(Math.floor(codePoint % codePointRangeLength) + codePointRangeStart);\r\n }) +\r\n suffix));\r\n };\r\n var createCounterStyleFromSymbols = function (value, symbols, suffix) {\r\n if (suffix === void 0) { suffix = '. '; }\r\n var codePointRangeLength = symbols.length;\r\n return (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, false, function (codePoint) { return symbols[Math.floor(codePoint % codePointRangeLength)]; }) + suffix);\r\n };\r\n var CJK_ZEROS = 1 << 0;\r\n var CJK_TEN_COEFFICIENTS = 1 << 1;\r\n var CJK_TEN_HIGH_COEFFICIENTS = 1 << 2;\r\n var CJK_HUNDRED_COEFFICIENTS = 1 << 3;\r\n var createCJKCounter = function (value, numbers, multipliers, negativeSign, suffix, flags) {\r\n if (value < -9999 || value > 9999) {\r\n return createCounterText(value, LIST_STYLE_TYPE.CJK_DECIMAL, suffix.length > 0);\r\n }\r\n var tmp = Math.abs(value);\r\n var string = suffix;\r\n if (tmp === 0) {\r\n return numbers[0] + string;\r\n }\r\n for (var digit = 0; tmp > 0 && digit <= 4; digit++) {\r\n var coefficient = tmp % 10;\r\n if (coefficient === 0 && contains(flags, CJK_ZEROS) && string !== '') {\r\n string = numbers[coefficient] + string;\r\n }\r\n else if (coefficient > 1 ||\r\n (coefficient === 1 && digit === 0) ||\r\n (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_COEFFICIENTS)) ||\r\n (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_HIGH_COEFFICIENTS) && value > 100) ||\r\n (coefficient === 1 && digit > 1 && contains(flags, CJK_HUNDRED_COEFFICIENTS))) {\r\n string = numbers[coefficient] + (digit > 0 ? multipliers[digit - 1] : '') + string;\r\n }\r\n else if (coefficient === 1 && digit > 0) {\r\n string = multipliers[digit - 1] + string;\r\n }\r\n tmp = Math.floor(tmp / 10);\r\n }\r\n return (value < 0 ? negativeSign : '') + string;\r\n };\r\n var CHINESE_INFORMAL_MULTIPLIERS = '十百千萬';\r\n var CHINESE_FORMAL_MULTIPLIERS = '拾佰仟萬';\r\n var JAPANESE_NEGATIVE = 'マイナス';\r\n var KOREAN_NEGATIVE = '마이너스';\r\n var createCounterText = function (value, type, appendSuffix) {\r\n var defaultSuffix = appendSuffix ? '. ' : '';\r\n var cjkSuffix = appendSuffix ? '、' : '';\r\n var koreanSuffix = appendSuffix ? ', ' : '';\r\n var spaceSuffix = appendSuffix ? ' ' : '';\r\n switch (type) {\r\n case LIST_STYLE_TYPE.DISC:\r\n return '•' + spaceSuffix;\r\n case LIST_STYLE_TYPE.CIRCLE:\r\n return '◦' + spaceSuffix;\r\n case LIST_STYLE_TYPE.SQUARE:\r\n return '◾' + spaceSuffix;\r\n case LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO:\r\n var string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);\r\n return string.length < 4 ? \"0\" + string : string;\r\n case LIST_STYLE_TYPE.CJK_DECIMAL:\r\n return createCounterStyleFromSymbols(value, '〇一二三四五六七八九', cjkSuffix);\r\n case LIST_STYLE_TYPE.LOWER_ROMAN:\r\n return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase();\r\n case LIST_STYLE_TYPE.UPPER_ROMAN:\r\n return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);\r\n case LIST_STYLE_TYPE.LOWER_GREEK:\r\n return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix);\r\n case LIST_STYLE_TYPE.LOWER_ALPHA:\r\n return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix);\r\n case LIST_STYLE_TYPE.UPPER_ALPHA:\r\n return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix);\r\n case LIST_STYLE_TYPE.ARABIC_INDIC:\r\n return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.ARMENIAN:\r\n case LIST_STYLE_TYPE.UPPER_ARMENIAN:\r\n return createAdditiveCounter(value, 1, 9999, ARMENIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);\r\n case LIST_STYLE_TYPE.LOWER_ARMENIAN:\r\n return createAdditiveCounter(value, 1, 9999, ARMENIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase();\r\n case LIST_STYLE_TYPE.BENGALI:\r\n return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.CAMBODIAN:\r\n case LIST_STYLE_TYPE.KHMER:\r\n return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH:\r\n return createCounterStyleFromSymbols(value, '子丑寅卯辰巳午未申酉戌亥', cjkSuffix);\r\n case LIST_STYLE_TYPE.CJK_HEAVENLY_STEM:\r\n return createCounterStyleFromSymbols(value, '甲乙丙丁戊己庚辛壬癸', cjkSuffix);\r\n case LIST_STYLE_TYPE.CJK_IDEOGRAPHIC:\r\n case LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL:\r\n return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL:\r\n return createCJKCounter(value, '零壹貳參肆伍陸柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL:\r\n return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL:\r\n return createCJKCounter(value, '零壹贰叁肆伍陆柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.JAPANESE_INFORMAL:\r\n return createCJKCounter(value, '〇一二三四五六七八九', '十百千万', JAPANESE_NEGATIVE, cjkSuffix, 0);\r\n case LIST_STYLE_TYPE.JAPANESE_FORMAL:\r\n return createCJKCounter(value, '零壱弐参四伍六七八九', '拾百千万', JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL:\r\n return createCJKCounter(value, '영일이삼사오육칠팔구', '십백천만', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL:\r\n return createCJKCounter(value, '零一二三四五六七八九', '十百千萬', KOREAN_NEGATIVE, koreanSuffix, 0);\r\n case LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL:\r\n return createCJKCounter(value, '零壹貳參四五六七八九', '拾百千', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);\r\n case LIST_STYLE_TYPE.DEVANAGARI:\r\n return createCounterStyleFromRange(value, 0x966, 0x96f, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.GEORGIAN:\r\n return createAdditiveCounter(value, 1, 19999, GEORGIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);\r\n case LIST_STYLE_TYPE.GUJARATI:\r\n return createCounterStyleFromRange(value, 0xae6, 0xaef, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.GURMUKHI:\r\n return createCounterStyleFromRange(value, 0xa66, 0xa6f, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.HEBREW:\r\n return createAdditiveCounter(value, 1, 10999, HEBREW, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);\r\n case LIST_STYLE_TYPE.HIRAGANA:\r\n return createCounterStyleFromSymbols(value, 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん');\r\n case LIST_STYLE_TYPE.HIRAGANA_IROHA:\r\n return createCounterStyleFromSymbols(value, 'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす');\r\n case LIST_STYLE_TYPE.KANNADA:\r\n return createCounterStyleFromRange(value, 0xce6, 0xcef, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.KATAKANA:\r\n return createCounterStyleFromSymbols(value, 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン', cjkSuffix);\r\n case LIST_STYLE_TYPE.KATAKANA_IROHA:\r\n return createCounterStyleFromSymbols(value, 'イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス', cjkSuffix);\r\n case LIST_STYLE_TYPE.LAO:\r\n return createCounterStyleFromRange(value, 0xed0, 0xed9, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.MONGOLIAN:\r\n return createCounterStyleFromRange(value, 0x1810, 0x1819, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.MYANMAR:\r\n return createCounterStyleFromRange(value, 0x1040, 0x1049, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.ORIYA:\r\n return createCounterStyleFromRange(value, 0xb66, 0xb6f, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.PERSIAN:\r\n return createCounterStyleFromRange(value, 0x6f0, 0x6f9, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.TAMIL:\r\n return createCounterStyleFromRange(value, 0xbe6, 0xbef, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.TELUGU:\r\n return createCounterStyleFromRange(value, 0xc66, 0xc6f, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.THAI:\r\n return createCounterStyleFromRange(value, 0xe50, 0xe59, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.TIBETAN:\r\n return createCounterStyleFromRange(value, 0xf20, 0xf29, true, defaultSuffix);\r\n case LIST_STYLE_TYPE.DECIMAL:\r\n default:\r\n return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);\r\n }\r\n };\n\n var IGNORE_ATTRIBUTE = 'data-html2canvas-ignore';\r\n var DocumentCloner = /** @class */ (function () {\r\n function DocumentCloner(element, options) {\r\n this.options = options;\r\n this.scrolledElements = [];\r\n this.referenceElement = element;\r\n this.counters = new CounterState();\r\n this.quoteDepth = 0;\r\n if (!element.ownerDocument) {\r\n throw new Error('Cloned element does not have an owner document');\r\n }\r\n this.documentElement = this.cloneNode(element.ownerDocument.documentElement);\r\n }\r\n DocumentCloner.prototype.toIFrame = function (ownerDocument, windowSize) {\r\n var _this = this;\r\n var iframe = createIFrameContainer(ownerDocument, windowSize);\r\n if (!iframe.contentWindow) {\r\n return Promise.reject(\"Unable to find iframe window\");\r\n }\r\n var scrollX = ownerDocument.defaultView.pageXOffset;\r\n var scrollY = ownerDocument.defaultView.pageYOffset;\r\n var cloneWindow = iframe.contentWindow;\r\n var documentClone = cloneWindow.document;\r\n /* Chrome doesn't detect relative background-images assigned in inline