diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..bfb572a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/survex"] + path = src/survex + url = git@github.com:ojwb/survex.git diff --git a/Skydusky.3d b/Skydusky.3d new file mode 100644 index 0000000..8617464 Binary files /dev/null and b/Skydusky.3d differ diff --git a/launch.sh b/launch.sh index 3deec96..fc02a26 100755 --- a/launch.sh +++ b/launch.sh @@ -10,7 +10,7 @@ build () { gofmt -w . staticcheck . - CGO_ENABLED=1 GOARCH=amd64 go build -o ./cavepedia_linux_amd64 -v . + CGO_ENABLED=1 GOARCH=amd64 go build -o ./kavea_linux_amd64 -v . popd &>/dev/null } diff --git a/src/Skydusky.3d b/src/Skydusky.3d new file mode 100644 index 0000000..8617464 Binary files /dev/null and b/src/Skydusky.3d differ diff --git a/src/common.go b/src/common.go new file mode 100644 index 0000000..d4bb085 --- /dev/null +++ b/src/common.go @@ -0,0 +1,22 @@ +package main + +import ( + "log" + "net/http" +) + +func checkError(err error) bool { + if err != nil { + log.Print("ERROR! " + err.Error()) + return false + } + return true +} + +func checkWebError(w http.ResponseWriter, err error) bool { + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return false + } + return true +} diff --git a/src/go.mod b/src/go.mod index f6df017..f08aa87 100644 --- a/src/go.mod +++ b/src/go.mod @@ -2,4 +2,10 @@ module git.seaturtle.pw/pew/kavea go 1.16 -require github.com/zserge/lorca v0.1.10 +require ( + github.com/google/renameio v0.1.0 // indirect + github.com/kisielk/gotool v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.3.0 // indirect + github.com/zserge/lorca v0.1.10 + honnef.co/go/tools v0.2.1 // indirect +) diff --git a/src/go.sum b/src/go.sum new file mode 100644 index 0000000..3cc0a66 --- /dev/null +++ b/src/go.sum @@ -0,0 +1,45 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/zserge/lorca v0.1.10 h1:f/xBJ3D3ipcVRCcvN8XqZnpoKcOXV8I4vwqlFyw7ruc= +github.com/zserge/lorca v0.1.10/go.mod h1:bVmnIbIRlOcoV285KIRSe4bUABKi7R7384Ycuum6e4A= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +honnef.co/go/tools v0.2.1 h1:/EPr//+UMMXwMTkXvCCoaJDq8cpjMO80Ou+L4PDo2mY= +honnef.co/go/tools v0.2.1/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY= diff --git a/src/img.c b/src/img.c new file mode 100644 index 0000000..93e5ac3 --- /dev/null +++ b/src/img.c @@ -0,0 +1,2778 @@ +/* img.c + * Routines for reading and writing Survex ".3d" image files + * Copyright (C) 1993-2021 Olly Betts + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "img.h" + +#define TIMENA "?" +#ifdef IMG_HOSTED +# define INT32_T int32_t +# define UINT32_T uint32_t +# include "debug.h" +# include "filelist.h" +# include "filename.h" +# include "message.h" +# include "useful.h" +# define TIMEFMT msg(/*%a,%Y.%m.%d %H:%M:%S %Z*/107) +#else +# ifdef HAVE_STDINT_H +# include +# define INT32_T int32_t +# define UINT32_T uint32_t +# else +# include +# if INT_MAX >= 2147483647 +# define INT32_T int +# define UINT32_T unsigned +# else +# define INT32_T long +# define UINT32_T unsigned long +# endif +# endif +# define TIMEFMT "%a,%Y.%m.%d %H:%M:%S %Z" +# define EXT_SVX_3D "3d" +# define EXT_SVX_POS "pos" +# define FNM_SEP_EXT '.' +# define METRES_PER_FOOT 0.3048 /* exact value */ +# define xosmalloc(L) malloc((L)) +# define xosrealloc(L,S) realloc((L),(S)) +# define osfree(P) free((P)) +# define osnew(T) (T*)malloc(sizeof(T)) + +/* in IMG_HOSTED mode, this tests if a filename refers to a directory */ +# define fDirectory(X) 0 +/* open file FNM with mode MODE, maybe using path PTH and/or extension EXT */ +/* path isn't used in img.c, but EXT is */ +# define fopenWithPthAndExt(PTH,FNM,EXT,MODE,X) \ + ((*(X) = NULL), fopen(FNM,MODE)) +# ifndef PUTC +# define PUTC(C, FH) putc(C, FH) +# endif +# ifndef GETC +# define GETC(FH) getc(FH) +# endif +# define fputsnl(S, FH) (fputs((S), (FH)) == EOF ? EOF : putc('\n', (FH))) +# define SVX_ASSERT(X) + +#ifdef __cplusplus +# include +using std::max; +using std::min; +#else +/* Return max/min of two numbers. */ +/* May be defined already (e.g. by Borland C in stdlib.h) */ +/* NB Bad news if X or Y has side-effects... */ +# ifndef max +# define max(X, Y) ((X) > (Y) ? (X) : (Y)) +# endif +# ifndef min +# define min(X, Y) ((X) < (Y) ? (X) : (Y)) +# endif +#endif + +static INT32_T +get32(FILE *fh) +{ + UINT32_T w = GETC(fh); + w |= (UINT32_T)GETC(fh) << 8l; + w |= (UINT32_T)GETC(fh) << 16l; + w |= (UINT32_T)GETC(fh) << 24l; + return (INT32_T)w; +} + +static void +put32(UINT32_T w, FILE *fh) +{ + PUTC((char)(w), fh); + PUTC((char)(w >> 8l), fh); + PUTC((char)(w >> 16l), fh); + PUTC((char)(w >> 24l), fh); +} + +static short +get16(FILE *fh) +{ + UINT32_T w = GETC(fh); + w |= (UINT32_T)GETC(fh) << 8l; + return (short)w; +} + +static void +put16(short word, FILE *fh) +{ + unsigned short w = (unsigned short)word; + PUTC((char)(w), fh); + PUTC((char)(w >> 8l), fh); +} + +static char * +baseleaf_from_fnm(const char *fnm) +{ + const char *p; + const char *q; + char * res; + size_t len; + + p = fnm; + q = strrchr(p, '/'); + if (q) p = q + 1; + q = strrchr(p, '\\'); + if (q) p = q + 1; + + q = strrchr(p, FNM_SEP_EXT); + if (q) len = (const char *)q - p; else len = strlen(p); + + res = (char *)xosmalloc(len + 1); + if (!res) return NULL; + memcpy(res, p, len); + res[len] = '\0'; + return res; +} +#endif + +static char * my_strdup(const char *str); + +static time_t +mktime_with_tz(struct tm * tm, const char * tz) +{ + time_t r; + char * old_tz = getenv("TZ"); +#ifdef _MSC_VER + if (old_tz) { + old_tz = my_strdup(old_tz); + if (!old_tz) + return (time_t)-1; + } + if (_putenv_s("TZ", tz) != 0) { + osfree(old_tz); + return (time_t)-1; + } +#elif defined HAVE_SETENV + if (old_tz) { + old_tz = my_strdup(old_tz); + if (!old_tz) + return (time_t)-1; + } + if (setenv("TZ", tz, 1) < 0) { + osfree(old_tz); + return (time_t)-1; + } +#else + char * p; + if (old_tz) { + size_t len = strlen(old_tz) + 1; + p = (char *)xosmalloc(len + 3); + if (!p) + return (time_t)-1; + memcpy(p, "TZ=", 3); + memcpy(p + 3, tz, len); + old_tz = p; + } + p = (char *)xosmalloc(strlen(tz) + 4); + if (!p) { + osfree(old_tz); + return (time_t)-1; + } + memcpy(p, "TZ=", 3); + strcpy(p + 3, tz); + if (putenv(p) != 0) { + osfree(p); + osfree(old_tz); + return (time_t)-1; + } +#define CLEANUP() osfree(p) +#endif + tzset(); + r = mktime(tm); + if (old_tz) { +#ifdef _MSC_VER + _putenv_s("TZ", old_tz); +#elif !defined HAVE_SETENV + putenv(old_tz); +#else + setenv("TZ", old_tz, 1); +#endif + osfree(old_tz); + } else { +#ifdef _MSC_VER + _putenv_s("TZ", ""); +#elif !defined HAVE_UNSETENV + putenv((char*)"TZ"); +#else + unsetenv("TZ"); +#endif + } +#ifdef CLEANUP + CLEANUP(); +#undef CLEANUP +#endif + return r; +} + +static unsigned short +getu16(FILE *fh) +{ + return (unsigned short)get16(fh); +} + +#include + +#if !defined HAVE_LROUND && !defined HAVE_DECL_LROUND +/* The autoconf tests are not in use, but C99 and C++11 both added lround(), + * so set HAVE_LROUND and HAVE_DECL_LROUND conservatively based on the language + * standard version the compiler claims to support. */ +# if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || \ + (defined __cplusplus && __cplusplus >= 201103L) +# define HAVE_LROUND 1 +# define HAVE_DECL_LROUND 1 +# endif +#endif + +#ifdef HAVE_LROUND +# if defined HAVE_DECL_LROUND && !HAVE_DECL_LROUND +/* On older systems, the prototype may be missing. */ +extern long lround(double); +# endif +# define my_lround lround +#else +static long +my_lround(double x) { + return (x >= 0.0) ? (long)(x + 0.5) : -(long)(0.5 - x); +} +#endif + +/* portable case insensitive string compare */ +#if defined(strcasecmp) || defined(HAVE_STRCASECMP) +# define my_strcasecmp strcasecmp +#else +static int my_strcasecmp(const char *s1, const char *s2) { + unsigned char c1, c2; + do { + c1 = *s1++; + c2 = *s2++; + } while (c1 && toupper(c1) == toupper(c2)); + /* now calculate real difference */ + return c1 - c2; +} +#endif + +unsigned int img_output_version = IMG_VERSION_MAX; + +static img_errcode img_errno = IMG_NONE; + +#define FILEID "Survex 3D Image File" + +#define EXT_PLT "plt" +#define EXT_PLF "plf" + +/* Attempt to string paste to ensure we are passed a literal string */ +#define LITLEN(S) (sizeof(S"") - 1) + +/* Fake "version numbers" for non-3d formats we can read. */ +#define VERSION_CMAP_SHOT -4 +#define VERSION_CMAP_STATION -3 +#define VERSION_COMPASS_PLT -2 +#define VERSION_SURVEX_POS -1 + +static char * +my_strdup(const char *str) +{ + char *p; + size_t len = strlen(str) + 1; + p = (char *)xosmalloc(len); + if (p) memcpy(p, str, len); + return p; +} + +#define getline_alloc(FH) getline_alloc_len(FH, NULL) + +static char * +getline_alloc_len(FILE *fh, size_t * p_len) +{ + int ch; + size_t i = 0; + size_t len = 16; + char *buf = (char *)xosmalloc(len); + if (!buf) return NULL; + + ch = GETC(fh); + while (ch != '\n' && ch != '\r' && ch != EOF) { + buf[i++] = ch; + if (i == len - 1) { + char *p; + len += len; + p = (char *)xosrealloc(buf, len); + if (!p) { + osfree(buf); + return NULL; + } + buf = p; + } + ch = GETC(fh); + } + if (ch == '\n' || ch == '\r') { + int otherone = ch ^ ('\n' ^ '\r'); + ch = GETC(fh); + /* if it's not the other eol character, put it back */ + if (ch != otherone) ungetc(ch, fh); + } + buf[i] = '\0'; + if (p_len) *p_len = i; + return buf; +} + +img_errcode +img_error(void) +{ + return img_errno; +} + +static int +check_label_space(img *pimg, size_t len) +{ + if (len > pimg->buf_len) { + char *b = (char *)xosrealloc(pimg->label_buf, len); + if (!b) return 0; + pimg->label = (pimg->label - pimg->label_buf) + b; + pimg->label_buf = b; + pimg->buf_len = len; + } + return 1; +} + +/* Check if a station name should be included. */ +static int +stn_included(img *pimg) +{ + if (!pimg->survey_len) return 1; + size_t l = pimg->survey_len; + const char *s = pimg->label_buf; + if (strncmp(pimg->survey, s, l + 1) != 0) { + return 0; + } + pimg->label += l + 1; + return 1; +} + +/* Check if a survey name should be included. */ +static int +survey_included(img *pimg) +{ + if (!pimg->survey_len) return 1; + size_t l = pimg->survey_len; + const char *s = pimg->label_buf; + if (strncmp(pimg->survey, s, l) != 0 || + !(s[l] == '.' || s[l] == '\0')) { + return 0; + } + pimg->label += l; + /* skip the dot if there */ + if (*pimg->label) pimg->label++; + return 1; +} + +/* Check if a survey name in a buffer should be included. + * + * For "foreign" formats which just have one level of surveys. + */ +static int +buf_included(img *pimg, const char *buf, size_t len) +{ + return pimg->survey_len == len && strncmp(buf, pimg->survey, len) == 0; +} + +#define has_ext(F,L,E) ((L) > LITLEN(E) + 1 &&\ + (F)[(L) - LITLEN(E) - 1] == FNM_SEP_EXT &&\ + my_strcasecmp((F) + (L) - LITLEN(E), E) == 0) + +img * +img_open_survey(const char *fnm, const char *survey) +{ + img *pimg; + FILE *fh; + char* filename_opened = NULL; + + if (fDirectory(fnm)) { + img_errno = IMG_DIRECTORY; + return NULL; + } + + fh = fopenWithPthAndExt("", fnm, EXT_SVX_3D, "rb", &filename_opened); + pimg = img_read_stream_survey(fh, fclose, + filename_opened ? filename_opened : fnm, + survey); + if (pimg) { + pimg->filename_opened = filename_opened; + } else { + osfree(filename_opened); + } + return pimg; +} + +img * +img_read_stream_survey(FILE *stream, int (*close_func)(FILE*), + const char *fnm, + const char *survey) +{ + img *pimg; + size_t len; + char buf[LITLEN(FILEID) + 9]; + int ch; + + if (stream == NULL) { + img_errno = IMG_FILENOTFOUND; + return NULL; + } + + pimg = osnew(img); + if (pimg == NULL) { + img_errno = IMG_OUTOFMEMORY; + if (close_func) close_func(stream); + return NULL; + } + + pimg->fh = stream; + pimg->close_func = close_func; + + pimg->buf_len = 257; + pimg->label_buf = (char *)xosmalloc(pimg->buf_len); + if (!pimg->label_buf) { + if (pimg->close_func) pimg->close_func(pimg->fh); + osfree(pimg); + img_errno = IMG_OUTOFMEMORY; + return NULL; + } + + pimg->fRead = 1; /* reading from this file */ + img_errno = IMG_NONE; + + pimg->flags = 0; + pimg->filename_opened = NULL; + + /* for version >= 3 we use label_buf to store the prefix for reuse */ + /* for VERSION_COMPASS_PLT, 0 value indicates we haven't + * entered a survey yet */ + /* for VERSION_CMAP_SHOT, we store the last station here + * to detect whether we MOVE or LINE */ + pimg->label_len = 0; + pimg->label_buf[0] = '\0'; + + pimg->survey = NULL; + pimg->survey_len = 0; + pimg->separator = '.'; +#if IMG_API_VERSION == 0 + pimg->date1 = pimg->date2 = 0; +#else /* IMG_API_VERSION == 1 */ + pimg->days1 = pimg->days2 = -1; +#endif + pimg->is_extended_elevation = 0; + + pimg->style = pimg->oldstyle = img_STYLE_UNKNOWN; + + pimg->l = pimg->r = pimg->u = pimg->d = -1.0; + + pimg->title = pimg->datestamp = pimg->cs = NULL; + pimg->datestamp_numeric = (time_t)-1; + + if (survey) { + len = strlen(survey); + if (len) { + if (survey[len - 1] == '.') len--; + if (len) { + char *p; + pimg->survey = (char *)xosmalloc(len + 2); + if (!pimg->survey) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + memcpy(pimg->survey, survey, len); + /* Set title to leaf survey name */ + pimg->survey[len] = '\0'; + p = strrchr(pimg->survey, '.'); + if (p) p++; else p = pimg->survey; + pimg->title = my_strdup(p); + if (!pimg->title) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + pimg->survey[len] = '.'; + pimg->survey[len + 1] = '\0'; + } + } + pimg->survey_len = len; + } + + /* [VERSION_COMPASS_PLT, VERSION_CMAP_STATION, VERSION_CMAP_SHOT] pending + * IMG_LINE or IMG_MOVE - both have 4 added. + * [VERSION_SURVEX_POS] already skipped heading line, or there wasn't one + * [version 0] not in the middle of a 'LINE' command + * [version >= 3] not in the middle of turning a LINE into a MOVE + */ + pimg->pending = 0; + + len = strlen(fnm); + if (has_ext(fnm, len, EXT_SVX_POS)) { +pos_file: + pimg->version = VERSION_SURVEX_POS; + if (!pimg->survey) pimg->title = baseleaf_from_fnm(fnm); + pimg->datestamp = my_strdup(TIMENA); + if (!pimg->datestamp) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + pimg->start = 0; + return pimg; + } + + if (has_ext(fnm, len, EXT_PLT) || has_ext(fnm, len, EXT_PLF)) { + long fpos; +plt_file: + pimg->version = VERSION_COMPASS_PLT; + /* Spaces aren't legal in Compass station names, but dots are, so + * use space as the level separator */ + pimg->separator = ' '; + pimg->start = 0; + if (!pimg->survey) pimg->title = baseleaf_from_fnm(fnm); + pimg->datestamp = my_strdup(TIMENA); + if (!pimg->datestamp) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + while (1) { + ch = GETC(pimg->fh); + switch (ch) { + case '\x1a': + fseek(pimg->fh, -1, SEEK_CUR); + /* FALL THRU */ + case EOF: + pimg->start = ftell(pimg->fh); + return pimg; + case 'N': { + char *line, *q; + fpos = ftell(pimg->fh) - 1; + if (!pimg->survey) { + /* FIXME : if there's only one survey in the file, it'd be nice + * to use its description as the title here... + */ + ungetc('N', pimg->fh); + pimg->start = fpos; + return pimg; + } + line = getline_alloc(pimg->fh); + if (!line) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + len = 0; + while (line[len] > 32) ++len; + if (!buf_included(pimg, line, len)) { + osfree(line); + continue; + } + q = strchr(line + len, 'C'); + if (q && q[1]) { + osfree(pimg->title); + pimg->title = my_strdup(q + 1); + } else if (!pimg->title) { + pimg->title = my_strdup(pimg->label); + } + osfree(line); + if (!pimg->title) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + if (!pimg->start) pimg->start = fpos; + fseek(pimg->fh, pimg->start, SEEK_SET); + return pimg; + } + case 'M': case 'D': + pimg->start = ftell(pimg->fh) - 1; + break; + } + while (ch != '\n' && ch != '\r') { + ch = GETC(pimg->fh); + } + } + } + + /* Although these are often referred to as "CMAP .XYZ files", it seems + * that actually, the extension .XYZ isn't used, rather .SHT (shot + * variant, produced by CMAP v16 and later), .UNA (unadjusted) and + * .ADJ (adjusted) extensions are. Since img has long checked for + * .XYZ, we continue to do so in case anyone is relying on it. + */ + if (has_ext(fnm, len, "sht") || + has_ext(fnm, len, "adj") || + has_ext(fnm, len, "una") || + has_ext(fnm, len, "xyz")) { + char *line; +xyz_file: + /* Spaces aren't legal in CMAP station names, but dots are, so + * use space as the level separator. */ + pimg->separator = ' '; + line = getline_alloc(pimg->fh); + if (!line) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + /* There doesn't seem to be a spec for what happens after 1999 with cmap + * files, so this code allows for: + * * 21xx -> xx (up to 2150) + * * 21xx -> 1xx (up to 2199) + * * full year being specified instead of 2 digits + */ + len = strlen(line); + if (len > 59) { + /* Don't just truncate at column 59, allow for a > 2 digit year. */ + char * p = strstr(line + len, "Page"); + if (p) { + while (p > line && p[-1] == ' ') + --p; + *p = '\0'; + len = p - line; + } else { + line[59] = '\0'; + } + } + if (len > 45) { + /* YY/MM/DD HH:MM */ + struct tm tm; + unsigned long v; + char * p; + pimg->datestamp = my_strdup(line + 45); + p = pimg->datestamp; + v = strtoul(p, &p, 10); + if (v <= 50) { + /* In the absence of a spec for cmap files, assume <= 50 means 21st + * century. */ + v += 2000; + } else if (v < 200) { + /* Map 100-199 to 21st century. */ + v += 1900; + } + if (v == ULONG_MAX || *p++ != '/') + goto bad_cmap_date; + tm.tm_year = v - 1900; + v = strtoul(p, &p, 10); + if (v < 1 || v > 12 || *p++ != '/') + goto bad_cmap_date; + tm.tm_mon = v - 1; + v = strtoul(p, &p, 10); + if (v < 1 || v > 31 || *p++ != ' ') + goto bad_cmap_date; + tm.tm_mday = v; + v = strtoul(p, &p, 10); + if (v >= 24 || *p++ != ':') + goto bad_cmap_date; + tm.tm_hour = v; + v = strtoul(p, &p, 10); + if (v >= 60) + goto bad_cmap_date; + tm.tm_min = v; + if (*p == ':') { + v = strtoul(p + 1, &p, 10); + if (v > 60) + goto bad_cmap_date; + tm.tm_sec = v; + } else { + tm.tm_sec = 0; + } + tm.tm_isdst = 0; + /* We have no indication of what timezone this timestamp is in. It's + * probably local time for whoever processed the data, so just assume + * UTC, which is at least fairly central in the possibilities. + */ + pimg->datestamp_numeric = mktime_with_tz(&tm, ""); + } else { + pimg->datestamp = my_strdup(TIMENA); + } +bad_cmap_date: + if (strncmp(line, " Cave Survey Data Processed by CMAP ", + LITLEN(" Cave Survey Data Processed by CMAP ")) == 0) { + len = 0; + } else { + if (len > 45) { + line[45] = '\0'; + len = 45; + } + while (len > 2 && line[len - 1] == ' ') --len; + if (len > 2) { + line[len] = '\0'; + pimg->title = my_strdup(line + 2); + } + } + if (len <= 2) pimg->title = baseleaf_from_fnm(fnm); + osfree(line); + if (!pimg->datestamp || !pimg->title) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + line = getline_alloc(pimg->fh); + if (!line) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + if (line[0] != ' ' || (line[1] != 'S' && line[1] != 'O')) { + img_errno = IMG_BADFORMAT; + goto error; + } + if (line[1] == 'S') { + pimg->version = VERSION_CMAP_STATION; + } else { + pimg->version = VERSION_CMAP_SHOT; + } + osfree(line); + line = getline_alloc(pimg->fh); + if (!line) { + img_errno = IMG_OUTOFMEMORY; + goto error; + } + if (line[0] != ' ' || line[1] != '-') { + img_errno = IMG_BADFORMAT; + goto error; + } + osfree(line); + pimg->start = ftell(pimg->fh); + return pimg; + } + + if (fread(buf, LITLEN(FILEID) + 1, 1, pimg->fh) != 1 || + memcmp(buf, FILEID"\n", LITLEN(FILEID) + 1) != 0) { + if (fread(buf + LITLEN(FILEID) + 1, 8, 1, pimg->fh) == 1 && + memcmp(buf, FILEID"\r\nv0.01\r\n", LITLEN(FILEID) + 9) == 0) { + /* v0 3d file with DOS EOLs */ + pimg->version = 0; + goto v03d; + } + rewind(pimg->fh); + if (buf[1] == ' ') { + if (buf[0] == ' ') { + /* Looks like a CMAP .xyz file ... */ + goto xyz_file; + } else if (strchr("ZSNF", buf[0])) { + /* Looks like a Compass .plt file ... */ + /* Almost certainly it'll start "Z " */ + goto plt_file; + } + } + if (buf[0] == '(') { + /* Looks like a Survex .pos file ... */ + goto pos_file; + } + img_errno = IMG_BADFORMAT; + goto error; + } + + /* check file format version */ + ch = GETC(pimg->fh); + pimg->version = 0; + if (tolower(ch) == 'b') { + /* binary file iff B/b prefix */ + pimg->version = 1; + ch = GETC(pimg->fh); + } + if (ch != 'v') { + img_errno = IMG_BADFORMAT; + goto error; + } + ch = GETC(pimg->fh); + if (ch == '0') { + if (fread(buf, 4, 1, pimg->fh) != 1 || memcmp(buf, ".01\n", 4) != 0) { + img_errno = IMG_BADFORMAT; + goto error; + } + /* nothing special to do */ + } else if (pimg->version == 0) { + if (ch < '2' || ch > '0' + IMG_VERSION_MAX || GETC(pimg->fh) != '\n') { + img_errno = IMG_TOONEW; + goto error; + } + pimg->version = ch - '0'; + } else { + img_errno = IMG_BADFORMAT; + goto error; + } + +v03d: + { + size_t title_len; + char * title = getline_alloc_len(pimg->fh, &title_len); + if (pimg->version == 8 && title) { + /* We sneak in an extra field after a zero byte here, containing the + * specified coordinate system (if any). Older readers will just + * not see it (which is fine), and this trick avoids us having to + * bump the 3d format version. + */ + size_t real_len = strlen(title); + if (real_len != title_len) { + pimg->cs = my_strdup(title + real_len + 1); + } + } + if (!pimg->title) { + pimg->title = title; + } else { + osfree(title); + } + } + pimg->datestamp = getline_alloc(pimg->fh); + if (!pimg->title || !pimg->datestamp) { + img_errno = IMG_OUTOFMEMORY; + error: + osfree(pimg->title); + osfree(pimg->cs); + osfree(pimg->datestamp); + osfree(pimg->filename_opened); + if (pimg->close_func) pimg->close_func(pimg->fh); + osfree(pimg); + return NULL; + } + + if (pimg->version >= 8) { + int flags = GETC(pimg->fh); + if (flags & img_FFLAG_EXTENDED) pimg->is_extended_elevation = 1; + } else { + len = strlen(pimg->title); + if (len > 11 && strcmp(pimg->title + len - 11, " (extended)") == 0) { + pimg->title[len - 11] = '\0'; + pimg->is_extended_elevation = 1; + } + } + + if (pimg->datestamp[0] == '@') { + unsigned long v; + char * p; + errno = 0; + v = strtoul(pimg->datestamp + 1, &p, 10); + if (errno == 0 && *p == '\0') + pimg->datestamp_numeric = v; + /* FIXME: We're assuming here that the C time_t epoch is 1970, which is + * true for Unix-like systems, macOS and Windows, but isn't guaranteed + * by ISO C. + */ + } else { + /* %a,%Y.%m.%d %H:%M:%S %Z */ + struct tm tm; + unsigned long v; + char * p = pimg->datestamp; + while (isalpha((unsigned char)*p)) ++p; + if (*p == ',') ++p; + while (isspace((unsigned char)*p)) ++p; + v = strtoul(p, &p, 10); + if (v == ULONG_MAX || *p++ != '.') + goto bad_3d_date; + tm.tm_year = v - 1900; + v = strtoul(p, &p, 10); + if (v < 1 || v > 12 || *p++ != '.') + goto bad_3d_date; + tm.tm_mon = v - 1; + v = strtoul(p, &p, 10); + if (v < 1 || v > 31 || *p++ != ' ') + goto bad_3d_date; + tm.tm_mday = v; + v = strtoul(p, &p, 10); + if (v >= 24 || *p++ != ':') + goto bad_3d_date; + tm.tm_hour = v; + v = strtoul(p, &p, 10); + if (v >= 60 || *p++ != ':') + goto bad_3d_date; + tm.tm_min = v; + v = strtoul(p, &p, 10); + if (v > 60) + goto bad_3d_date; + tm.tm_sec = v; + tm.tm_isdst = 0; + while (isspace((unsigned char)*p)) ++p; + /* p now points to the timezone string. + * + * However, it's likely to be a string like "BST", and such strings can + * be ambiguous (BST could be UTC+1 or UTC+6), so it is impossible to + * reliably convert in all cases. Just pass what we have to tzset() - if + * it doesn't handle it, UTC will be used. + */ + pimg->datestamp_numeric = mktime_with_tz(&tm, p); + } +bad_3d_date: + + pimg->start = ftell(pimg->fh); + + return pimg; +} + +int +img_rewind(img *pimg) +{ + if (!pimg->fRead) { + img_errno = IMG_WRITEERROR; + return 0; + } + if (fseek(pimg->fh, pimg->start, SEEK_SET) != 0) { + img_errno = IMG_READERROR; + return 0; + } + clearerr(pimg->fh); + /* [VERSION_SURVEX_POS] already skipped heading line, or there wasn't one + * [version 0] not in the middle of a 'LINE' command + * [version >= 3] not in the middle of turning a LINE into a MOVE */ + pimg->pending = 0; + + img_errno = IMG_NONE; + + /* for version >= 3 we use label_buf to store the prefix for reuse */ + /* for VERSION_COMPASS_PLT, 0 value indicates we haven't entered a survey + * yet */ + /* for VERSION_CMAP_SHOT, we store the last station here to detect whether + * we MOVE or LINE */ + pimg->label_len = 0; + pimg->style = img_STYLE_UNKNOWN; + return 1; +} + +img * +img_open_write_cs(const char *fnm, const char *title, const char *cs, int flags) +{ + if (fDirectory(fnm)) { + img_errno = IMG_DIRECTORY; + return NULL; + } + + return img_write_stream(fopen(fnm, "wb"), fclose, title, cs, flags); +} + +img * +img_write_stream(FILE *stream, int (*close_func)(FILE*), + const char *title, const char *cs, int flags) +{ + time_t tm; + img *pimg; + + if (stream == NULL) { + img_errno = IMG_FILENOTFOUND; + return NULL; + } + + pimg = osnew(img); + if (pimg == NULL) { + img_errno = IMG_OUTOFMEMORY; + if (close_func) close_func(stream); + return NULL; + } + + pimg->fh = stream; + pimg->close_func = close_func; + pimg->buf_len = 257; + pimg->label_buf = (char *)xosmalloc(pimg->buf_len); + if (!pimg->label_buf) { + if (pimg->close_func) pimg->close_func(pimg->fh); + osfree(pimg); + img_errno = IMG_OUTOFMEMORY; + return NULL; + } + + pimg->filename_opened = NULL; + + /* Output image file header */ + fputs("Survex 3D Image File\n", pimg->fh); /* file identifier string */ + if (img_output_version < 2) { + pimg->version = 1; + fputs("Bv0.01\n", pimg->fh); /* binary file format version number */ + } else { + pimg->version = (img_output_version > IMG_VERSION_MAX) ? IMG_VERSION_MAX : img_output_version; + fprintf(pimg->fh, "v%d\n", pimg->version); /* file format version no. */ + } + + fputs(title, pimg->fh); + if (pimg->version < 8 && (flags & img_FFLAG_EXTENDED)) { + /* Older format versions append " (extended)" to the title to mark + * extended elevations. */ + size_t len = strlen(title); + if (len < 11 || strcmp(title + len - 11, " (extended)") != 0) + fputs(" (extended)", pimg->fh); + } + if (pimg->version == 8 && cs && *cs) { + /* We sneak in an extra field after a zero byte here, containing the + * specified coordinate system (if any). Older readers will just not + * see it (which is fine), and this trick avoids us having to bump the + * 3d format version. + */ + PUTC('\0', pimg->fh); + fputs(cs, pimg->fh); + } + PUTC('\n', pimg->fh); + + tm = time(NULL); + if (tm == (time_t)-1) { + fputsnl(TIMENA, pimg->fh); + } else if (pimg->version <= 7) { + char date[256]; + /* output current date and time in format specified */ + strftime(date, 256, TIMEFMT, localtime(&tm)); + fputsnl(date, pimg->fh); + } else { + fprintf(pimg->fh, "@%ld\n", (long)tm); + } + + if (pimg->version >= 8) { + /* Clear bit one in case anyone has been passing true for fBinary. */ + flags &=~ 1; + PUTC(flags, pimg->fh); + } + +#if 0 + if (img_output_version >= 5) { + static const unsigned char codelengths[32] = { + 4, 8, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + fwrite(codelengths, 32, 1, pimg->fh); + } +#endif + pimg->fRead = 0; /* writing to this file */ + img_errno = IMG_NONE; + + /* for version >= 3 we use label_buf to store the prefix for reuse */ + pimg->label_buf[0] = '\0'; + pimg->label_len = 0; + +#if IMG_API_VERSION == 0 + pimg->date1 = pimg->date2 = 0; + pimg->olddate1 = pimg->olddate2 = 0; +#else /* IMG_API_VERSION == 1 */ + pimg->days1 = pimg->days2 = -1; + pimg->olddays1 = pimg->olddays2 = -1; +#endif + pimg->style = pimg->oldstyle = img_STYLE_UNKNOWN; + + pimg->l = pimg->r = pimg->u = pimg->d = -1.0; + + pimg->n_legs = 0; + pimg->length = 0.0; + pimg->E = pimg->H = pimg->V = 0.0; + + /* Don't check for write errors now - let img_close() report them... */ + return pimg; +} + +static void +read_xyz_station_coords(img_point *pt, const char *line) +{ + char num[12]; + memcpy(num, line + 6, 9); + num[9] = '\0'; + pt->x = atof(num) / METRES_PER_FOOT; + memcpy(num, line + 15, 9); + pt->y = atof(num) / METRES_PER_FOOT; + memcpy(num, line + 24, 8); + num[8] = '\0'; + pt->z = atof(num) / METRES_PER_FOOT; +} + +static void +read_xyz_shot_coords(img_point *pt, const char *line) +{ + char num[12]; + memcpy(num, line + 40, 10); + num[10] = '\0'; + pt->x = atof(num) / METRES_PER_FOOT; + memcpy(num, line + 50, 10); + pt->y = atof(num) / METRES_PER_FOOT; + memcpy(num, line + 60, 9); + num[9] = '\0'; + pt->z = atof(num) / METRES_PER_FOOT; +} + +static void +subtract_xyz_shot_deltas(img_point *pt, const char *line) +{ + char num[12]; + memcpy(num, line + 15, 9); + num[9] = '\0'; + pt->x -= atof(num) / METRES_PER_FOOT; + memcpy(num, line + 24, 8); + num[8] = '\0'; + pt->y -= atof(num) / METRES_PER_FOOT; + memcpy(num, line + 32, 8); + pt->z -= atof(num) / METRES_PER_FOOT; +} + +static int +read_coord(FILE *fh, img_point *pt) +{ + SVX_ASSERT(fh); + SVX_ASSERT(pt); + pt->x = get32(fh) / 100.0; + pt->y = get32(fh) / 100.0; + pt->z = get32(fh) / 100.0; + if (ferror(fh) || feof(fh)) { + img_errno = feof(fh) ? IMG_BADFORMAT : IMG_READERROR; + return 0; + } + return 1; +} + +static int +skip_coord(FILE *fh) +{ + return (fseek(fh, 12, SEEK_CUR) == 0); +} + +static int +read_v3label(img *pimg) +{ + char *q; + long len = GETC(pimg->fh); + if (len == EOF) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + if (len == 0xfe) { + len += get16(pimg->fh); + if (feof(pimg->fh)) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + } else if (len == 0xff) { + len = get32(pimg->fh); + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + if (feof(pimg->fh) || len < 0xfe + 0xffff) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + } + + if (!check_label_space(pimg, pimg->label_len + len + 1)) { + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + q = pimg->label_buf + pimg->label_len; + pimg->label_len += len; + if (len && fread(q, len, 1, pimg->fh) != 1) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + q[len] = '\0'; + return 0; +} + +static int +read_v8label(img *pimg, int common_flag, size_t common_val) +{ + char *q; + size_t del, add; + if (common_flag) { + if (common_val == 0) return 0; + add = del = common_val; + } else { + int ch = GETC(pimg->fh); + if (ch == EOF) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + if (ch != 0x00) { + del = ch >> 4; + add = ch & 0x0f; + } else { + ch = GETC(pimg->fh); + if (ch == EOF) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + if (ch != 0xff) { + del = ch; + } else { + del = get32(pimg->fh); + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + } + ch = GETC(pimg->fh); + if (ch == EOF) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + if (ch != 0xff) { + add = ch; + } else { + add = get32(pimg->fh); + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + } + } + + if (add > del && !check_label_space(pimg, pimg->label_len + add - del + 1)) { + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + } + if (del > pimg->label_len) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + pimg->label_len -= del; + q = pimg->label_buf + pimg->label_len; + pimg->label_len += add; + if (add && fread(q, add, 1, pimg->fh) != 1) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + q[add] = '\0'; + return 0; +} + +static int img_read_item_new(img *pimg, img_point *p); +static int img_read_item_v3to7(img *pimg, img_point *p); +static int img_read_item_ancient(img *pimg, img_point *p); +static int img_read_item_ascii_wrapper(img *pimg, img_point *p); +static int img_read_item_ascii(img *pimg, img_point *p); + +int +img_read_item(img *pimg, img_point *p) +{ + pimg->flags = 0; + + if (pimg->version >= 8) { + return img_read_item_new(pimg, p); + } else if (pimg->version >= 3) { + return img_read_item_v3to7(pimg, p); + } else if (pimg->version >= 1) { + return img_read_item_ancient(pimg, p); + } else { + return img_read_item_ascii_wrapper(pimg, p); + } +} + +static int +img_read_item_new(img *pimg, img_point *p) +{ + int result; + int opt; + pimg->l = pimg->r = pimg->u = pimg->d = -1.0; + if (pimg->pending >= 0x40) { + if (pimg->pending == 256) { + pimg->pending = 0; + return img_XSECT_END; + } + *p = pimg->mv; + pimg->flags = (int)(pimg->pending) & 0x3f; + pimg->pending = 0; + return img_LINE; + } + again3: /* label to goto if we get a prefix, date, or lrud */ + pimg->label = pimg->label_buf; + opt = GETC(pimg->fh); + if (opt == EOF) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + if (opt >> 6 == 0) { + if (opt <= 4) { + if (opt == 0 && pimg->style == 0) + return img_STOP; /* end of data marker */ + /* STYLE */ + pimg->style = opt; + goto again3; + } + if (opt >= 0x10) { + switch (opt) { + case 0x10: { /* No date info */ +#if IMG_API_VERSION == 0 + pimg->date1 = pimg->date2 = 0; +#else /* IMG_API_VERSION == 1 */ + pimg->days1 = pimg->days2 = -1; +#endif + break; + } + case 0x11: { /* Single date */ + int days1 = (int)getu16(pimg->fh); +#if IMG_API_VERSION == 0 + pimg->date2 = pimg->date1 = (days1 - 25567) * 86400; +#else /* IMG_API_VERSION == 1 */ + pimg->days2 = pimg->days1 = days1; +#endif + break; + } + case 0x12: { /* Date range (short) */ + int days1 = (int)getu16(pimg->fh); + int days2 = days1 + GETC(pimg->fh) + 1; +#if IMG_API_VERSION == 0 + pimg->date1 = (days1 - 25567) * 86400; + pimg->date2 = (days2 - 25567) * 86400; +#else /* IMG_API_VERSION == 1 */ + pimg->days1 = days1; + pimg->days2 = days2; +#endif + break; + } + case 0x13: { /* Date range (long) */ + int days1 = (int)getu16(pimg->fh); + int days2 = (int)getu16(pimg->fh); +#if IMG_API_VERSION == 0 + pimg->date1 = (days1 - 25567) * 86400; + pimg->date2 = (days2 - 25567) * 86400; +#else /* IMG_API_VERSION == 1 */ + pimg->days1 = days1; + pimg->days2 = days2; +#endif + break; + } + case 0x1f: /* Error info */ + pimg->n_legs = get32(pimg->fh); + pimg->length = get32(pimg->fh) / 100.0; + pimg->E = get32(pimg->fh) / 100.0; + pimg->H = get32(pimg->fh) / 100.0; + pimg->V = get32(pimg->fh) / 100.0; + return img_ERROR_INFO; + case 0x30: case 0x31: /* LRUD */ + case 0x32: case 0x33: /* Big LRUD! */ + if (read_v8label(pimg, 0, 0) == img_BAD) return img_BAD; + pimg->flags = (int)opt & 0x01; + if (opt < 0x32) { + pimg->l = get16(pimg->fh) / 100.0; + pimg->r = get16(pimg->fh) / 100.0; + pimg->u = get16(pimg->fh) / 100.0; + pimg->d = get16(pimg->fh) / 100.0; + } else { + pimg->l = get32(pimg->fh) / 100.0; + pimg->r = get32(pimg->fh) / 100.0; + pimg->u = get32(pimg->fh) / 100.0; + pimg->d = get32(pimg->fh) / 100.0; + } + if (!stn_included(pimg)) { + return img_XSECT_END; + } + /* If this is the last cross-section in this passage, set + * pending so we return img_XSECT_END next time. */ + if (pimg->flags & 0x01) { + pimg->pending = 256; + pimg->flags &= ~0x01; + } + return img_XSECT; + default: /* 0x25 - 0x2f and 0x34 - 0x3f are currently unallocated. */ + img_errno = IMG_BADFORMAT; + return img_BAD; + } + goto again3; + } + if (opt != 15) { + /* 1-14 and 16-31 reserved */ + img_errno = IMG_BADFORMAT; + return img_BAD; + } + result = img_MOVE; + } else if (opt >= 0x80) { + if (read_v8label(pimg, 0, 0) == img_BAD) return img_BAD; + + result = img_LABEL; + + if (!stn_included(pimg)) { + if (!skip_coord(pimg->fh)) return img_BAD; + pimg->pending = 0; + goto again3; + } + + pimg->flags = (int)opt & 0x7f; + } else if ((opt >> 6) == 1) { + if (read_v8label(pimg, opt & 0x20, 0) == img_BAD) return img_BAD; + + result = img_LINE; + + if (!survey_included(pimg)) { + if (!read_coord(pimg->fh, &(pimg->mv))) return img_BAD; + pimg->pending = 15; + goto again3; + } + + if (pimg->pending) { + *p = pimg->mv; + if (!read_coord(pimg->fh, &(pimg->mv))) return img_BAD; + pimg->pending = opt; + return img_MOVE; + } + pimg->flags = (int)opt & 0x1f; + } else { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (!read_coord(pimg->fh, p)) return img_BAD; + pimg->pending = 0; + return result; +} + +static int +img_read_item_v3to7(img *pimg, img_point *p) +{ + int result; + int opt; + pimg->l = pimg->r = pimg->u = pimg->d = -1.0; + if (pimg->pending == 256) { + pimg->pending = 0; + return img_XSECT_END; + } + if (pimg->pending >= 0x80) { + *p = pimg->mv; + pimg->flags = (int)(pimg->pending) & 0x3f; + pimg->pending = 0; + return img_LINE; + } + again3: /* label to goto if we get a prefix, date, or lrud */ + pimg->label = pimg->label_buf; + opt = GETC(pimg->fh); + if (opt == EOF) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + switch (opt >> 6) { + case 0: + if (opt == 0) { + if (!pimg->label_len) return img_STOP; /* end of data marker */ + pimg->label_len = 0; + goto again3; + } + if (opt < 15) { + /* 1-14 mean trim that many levels from current prefix */ + int c; + if (pimg->label_len <= 17) { + /* zero prefix using "0" */ + img_errno = IMG_BADFORMAT; + return img_BAD; + } + /* extra - 1 because label_len points to one past the end */ + c = pimg->label_len - 17 - 1; + while (pimg->label_buf[c] != '.' || --opt > 0) { + if (--c < 0) { + /* zero prefix using "0" */ + img_errno = IMG_BADFORMAT; + return img_BAD; + } + } + c++; + pimg->label_len = c; + goto again3; + } + if (opt == 15) { + result = img_MOVE; + break; + } + if (opt >= 0x20) { + switch (opt) { + case 0x20: /* Single date */ + if (pimg->version < 7) { + int date1 = get32(pimg->fh); +#if IMG_API_VERSION == 0 + pimg->date2 = pimg->date1 = date1; +#else /* IMG_API_VERSION == 1 */ + if (date1 != 0) { + pimg->days2 = pimg->days1 = (date1 / 86400) + 25567; + } else { + pimg->days2 = pimg->days1 = -1; + } +#endif + } else { + int days1 = (int)getu16(pimg->fh); +#if IMG_API_VERSION == 0 + pimg->date2 = pimg->date1 = (days1 - 25567) * 86400; +#else /* IMG_API_VERSION == 1 */ + pimg->days2 = pimg->days1 = days1; +#endif + } + break; + case 0x21: /* Date range (short for v7+) */ + if (pimg->version < 7) { + INT32_T date1 = get32(pimg->fh); + INT32_T date2 = get32(pimg->fh); +#if IMG_API_VERSION == 0 + pimg->date1 = date1; + pimg->date2 = date2; +#else /* IMG_API_VERSION == 1 */ + pimg->days1 = (date1 / 86400) + 25567; + pimg->days2 = (date2 / 86400) + 25567; +#endif + } else { + int days1 = (int)getu16(pimg->fh); + int days2 = days1 + GETC(pimg->fh) + 1; +#if IMG_API_VERSION == 0 + pimg->date1 = (days1 - 25567) * 86400; + pimg->date2 = (days2 - 25567) * 86400; +#else /* IMG_API_VERSION == 1 */ + pimg->days1 = days1; + pimg->days2 = days2; +#endif + } + break; + case 0x22: /* Error info */ + pimg->n_legs = get32(pimg->fh); + pimg->length = get32(pimg->fh) / 100.0; + pimg->E = get32(pimg->fh) / 100.0; + pimg->H = get32(pimg->fh) / 100.0; + pimg->V = get32(pimg->fh) / 100.0; + if (feof(pimg->fh)) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + return img_ERROR_INFO; + case 0x23: { /* v7+: Date range (long) */ + if (pimg->version < 7) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + int days1 = (int)getu16(pimg->fh); + int days2 = (int)getu16(pimg->fh); + if (feof(pimg->fh)) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } +#if IMG_API_VERSION == 0 + pimg->date1 = (days1 - 25567) * 86400; + pimg->date2 = (days2 - 25567) * 86400; +#else /* IMG_API_VERSION == 1 */ + pimg->days1 = days1; + pimg->days2 = days2; +#endif + break; + } + case 0x24: { /* v7+: No date info */ +#if IMG_API_VERSION == 0 + pimg->date1 = pimg->date2 = 0; +#else /* IMG_API_VERSION == 1 */ + pimg->days1 = pimg->days2 = -1; +#endif + break; + } + case 0x30: case 0x31: /* LRUD */ + case 0x32: case 0x33: /* Big LRUD! */ + if (read_v3label(pimg) == img_BAD) return img_BAD; + pimg->flags = (int)opt & 0x01; + if (opt < 0x32) { + pimg->l = get16(pimg->fh) / 100.0; + pimg->r = get16(pimg->fh) / 100.0; + pimg->u = get16(pimg->fh) / 100.0; + pimg->d = get16(pimg->fh) / 100.0; + } else { + pimg->l = get32(pimg->fh) / 100.0; + pimg->r = get32(pimg->fh) / 100.0; + pimg->u = get32(pimg->fh) / 100.0; + pimg->d = get32(pimg->fh) / 100.0; + } + if (feof(pimg->fh)) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + if (!stn_included(pimg)) { + return img_XSECT_END; + } + /* If this is the last cross-section in this passage, set + * pending so we return img_XSECT_END next time. */ + if (pimg->flags & 0x01) { + pimg->pending = 256; + pimg->flags &= ~0x01; + } + return img_XSECT; + default: /* 0x25 - 0x2f and 0x34 - 0x3f are currently unallocated. */ + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (feof(pimg->fh)) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + goto again3; + } + /* 16-31 mean remove (n - 15) characters from the prefix */ + /* zero prefix using 0 */ + if (pimg->label_len <= (size_t)(opt - 15)) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + pimg->label_len -= (opt - 15); + goto again3; + case 1: + if (read_v3label(pimg) == img_BAD) return img_BAD; + + result = img_LABEL; + + if (!stn_included(pimg)) { + if (!skip_coord(pimg->fh)) return img_BAD; + pimg->pending = 0; + goto again3; + } + + pimg->flags = (int)opt & 0x3f; + break; + case 2: + if (read_v3label(pimg) == img_BAD) return img_BAD; + + result = img_LINE; + + if (!survey_included(pimg)) { + if (!read_coord(pimg->fh, &(pimg->mv))) return img_BAD; + pimg->pending = 15; + goto again3; + } + + if (pimg->pending) { + *p = pimg->mv; + if (!read_coord(pimg->fh, &(pimg->mv))) return img_BAD; + pimg->pending = opt; + return img_MOVE; + } + pimg->flags = (int)opt & 0x3f; + break; + default: + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (!read_coord(pimg->fh, p)) return img_BAD; + pimg->pending = 0; + return result; +} + +static int +img_read_item_ancient(img *pimg, img_point *p) +{ + int result; + static long opt_lookahead = 0; + static img_point pt = { 0.0, 0.0, 0.0 }; + long opt; + + again: /* label to goto if we get a cross */ + pimg->label = pimg->label_buf; + pimg->label[0] = '\0'; + + if (pimg->version == 1) { + if (opt_lookahead) { + opt = opt_lookahead; + opt_lookahead = 0; + } else { + opt = get32(pimg->fh); + } + } else { + opt = GETC(pimg->fh); + } + + if (feof(pimg->fh)) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + + switch (opt) { + case -1: case 0: + return img_STOP; /* end of data marker */ + case 1: + /* skip coordinates */ + if (!skip_coord(pimg->fh)) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + goto again; + case 2: case 3: { + size_t len; + result = img_LABEL; + if (!fgets(pimg->label_buf, pimg->buf_len, pimg->fh)) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + if (pimg->label[0] == '\\') pimg->label++; + len = strlen(pimg->label); + if (len == 0 || pimg->label[len - 1] != '\n') { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + /* Ignore empty labels in some .3d files (caused by a bug) */ + if (len == 1) goto again; + pimg->label[len - 1] = '\0'; + pimg->flags = img_SFLAG_UNDERGROUND; /* no flags given... */ + if (opt == 2) goto done; + break; + } + case 6: case 7: { + long len; + result = img_LABEL; + + if (opt == 7) + pimg->flags = GETC(pimg->fh); + else + pimg->flags = img_SFLAG_UNDERGROUND; /* no flags given... */ + + len = get32(pimg->fh); + + if (feof(pimg->fh)) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + + /* Ignore empty labels in some .3d files (caused by a bug) */ + if (len == 0) goto again; + if (!check_label_space(pimg, len + 1)) { + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + if (fread(pimg->label_buf, len, 1, pimg->fh) != 1) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + pimg->label_buf[len] = '\0'; + break; + } + case 4: + result = img_MOVE; + break; + case 5: + result = img_LINE; + break; + default: + switch ((int)opt & 0xc0) { + case 0x80: + pimg->flags = (int)opt & 0x3f; + result = img_LINE; + break; + case 0x40: { + char *q; + pimg->flags = (int)opt & 0x3f; + result = img_LABEL; + if (!fgets(pimg->label_buf, pimg->buf_len, pimg->fh)) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + q = pimg->label_buf + strlen(pimg->label_buf) - 1; + /* Ignore empty-labels in some .3d files (caused by a bug) */ + if (q == pimg->label_buf) goto again; + if (*q != '\n') { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + *q = '\0'; + break; + } + default: + img_errno = IMG_BADFORMAT; + return img_BAD; + } + break; + } + + if (!read_coord(pimg->fh, &pt)) return img_BAD; + + if (result == img_LABEL && !stn_included(pimg)) { + goto again; + } + + done: + *p = pt; + + if (result == img_MOVE && pimg->version == 1) { + /* peek at next code and see if it's an old-style label */ + opt_lookahead = get32(pimg->fh); + + if (feof(pimg->fh)) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + + if (opt_lookahead == 2) return img_read_item_ancient(pimg, p); + } + + return result; +} + +static int +img_read_item_ascii_wrapper(img *pimg, img_point *p) +{ + /* We need to set the default locale for fscanf() to work on + * numbers with "." as decimal point. */ + int result; + char * current_locale = my_strdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); + result = img_read_item_ascii(pimg, p); + setlocale(LC_NUMERIC, current_locale); + free(current_locale); + return result; +} + +/* Handle all ASCII formats. */ +static int +img_read_item_ascii(img *pimg, img_point *p) +{ + int result; + pimg->label = pimg->label_buf; + if (pimg->version == 0) { + ascii_again: + pimg->label[0] = '\0'; + if (feof(pimg->fh)) return img_STOP; + if (pimg->pending) { + pimg->pending = 0; + result = img_LINE; + } else { + char cmd[7]; + /* Stop if nothing found */ + if (fscanf(pimg->fh, "%6s", cmd) < 1) return img_STOP; + if (strcmp(cmd, "move") == 0) + result = img_MOVE; + else if (strcmp(cmd, "draw") == 0) + result = img_LINE; + else if (strcmp(cmd, "line") == 0) { + /* set flag to indicate to process second triplet as LINE */ + pimg->pending = 1; + result = img_MOVE; + } else if (strcmp(cmd, "cross") == 0) { + if (fscanf(pimg->fh, "%lf%lf%lf", &p->x, &p->y, &p->z) < 3) { + img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR; + return img_BAD; + } + goto ascii_again; + } else if (strcmp(cmd, "name") == 0) { + size_t off = 0; + int ch = GETC(pimg->fh); + if (ch == ' ') ch = GETC(pimg->fh); + while (ch != ' ') { + if (ch == '\n' || ch == EOF) { + img_errno = ferror(pimg->fh) ? IMG_READERROR : IMG_BADFORMAT; + return img_BAD; + } + if (off == pimg->buf_len) { + if (!check_label_space(pimg, pimg->buf_len * 2)) { + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + } + pimg->label_buf[off++] = ch; + ch = GETC(pimg->fh); + } + pimg->label_buf[off] = '\0'; + + pimg->label = pimg->label_buf; + if (pimg->label[0] == '\\') pimg->label++; + + pimg->flags = img_SFLAG_UNDERGROUND; /* default flags */ + + result = img_LABEL; + } else { + img_errno = IMG_BADFORMAT; + return img_BAD; /* unknown keyword */ + } + } + + if (fscanf(pimg->fh, "%lf%lf%lf", &p->x, &p->y, &p->z) < 3) { + img_errno = ferror(pimg->fh) ? IMG_READERROR : IMG_BADFORMAT; + return img_BAD; + } + + if (result == img_LABEL && !stn_included(pimg)) { + goto ascii_again; + } + + return result; + } else if (pimg->version == VERSION_SURVEX_POS) { + /* Survex .pos file */ + int ch; + size_t off; + pimg->flags = img_SFLAG_UNDERGROUND; /* default flags */ + againpos: + while (fscanf(pimg->fh, "(%lf,%lf,%lf )", &p->x, &p->y, &p->z) != 3) { + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + if (feof(pimg->fh)) return img_STOP; + if (pimg->pending) { + img_errno = IMG_BADFORMAT; + return img_BAD; + } + pimg->pending = 1; + /* ignore rest of line */ + do { + ch = GETC(pimg->fh); + } while (ch != '\n' && ch != '\r' && ch != EOF); + } + + pimg->label_buf[0] = '\0'; + do { + ch = GETC(pimg->fh); + } while (ch == ' ' || ch == '\t'); + if (ch == '\n' || ch == EOF) { + /* If there's no label, set img_SFLAG_ANON. */ + pimg->flags |= img_SFLAG_ANON; + return img_LABEL; + } + pimg->label_buf[0] = ch; + off = 1; + while (!feof(pimg->fh)) { + if (!fgets(pimg->label_buf + off, pimg->buf_len - off, pimg->fh)) { + img_errno = IMG_READERROR; + return img_BAD; + } + + off += strlen(pimg->label_buf + off); + if (off && pimg->label_buf[off - 1] == '\n') { + pimg->label_buf[off - 1] = '\0'; + break; + } + if (!check_label_space(pimg, pimg->buf_len * 2)) { + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + } + + pimg->label = pimg->label_buf; + + if (pimg->label[0] == '\\') pimg->label++; + + if (!stn_included(pimg)) goto againpos; + + return img_LABEL; + } else if (pimg->version == VERSION_COMPASS_PLT) { + /* Compass .plt file */ + if (pimg->pending > 0) { + /* -1 signals we've entered the first survey we want to + * read, and need to fudge lots if the first action is 'D'... + */ + /* pending MOVE or LINE */ + int r = pimg->pending - 4; + pimg->pending = 0; + pimg->flags = 0; + pimg->label[pimg->label_len] = '\0'; + return r; + } + + while (1) { + char *line; + char *q; + size_t len = 0; + int ch = GETC(pimg->fh); + + switch (ch) { + case '\x1a': case EOF: /* Don't insist on ^Z at end of file */ + return img_STOP; + case 'X': case 'F': case 'S': + /* bounding boX (marks end of survey), Feature survey, or + * new Section - skip to next survey */ + if (pimg->survey) return img_STOP; +skip_to_N: + while (1) { + do { + ch = GETC(pimg->fh); + } while (ch != '\n' && ch != '\r' && ch != EOF); + while (ch == '\n' || ch == '\r') ch = GETC(pimg->fh); + if (ch == 'N') break; + if (ch == '\x1a' || ch == EOF) return img_STOP; + } + /* FALLTHRU */ + case 'N': + line = getline_alloc(pimg->fh); + if (!line) { + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + while (line[len] > 32) ++len; + if (pimg->label_len == 0) pimg->pending = -1; + if (!check_label_space(pimg, len + 1)) { + osfree(line); + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + pimg->label_len = len; + pimg->label = pimg->label_buf; + memcpy(pimg->label, line, len); + pimg->label[len] = '\0'; + osfree(line); + break; + case 'M': case 'D': { + /* Move or Draw */ + long fpos = -1; + if (pimg->survey && pimg->label_len == 0) { + /* We're only holding onto this line in case the first line + * of the 'N' is a 'D', so skip it for now... + */ + goto skip_to_N; + } + if (ch == 'D' && pimg->pending == -1) { + if (pimg->survey) { + fpos = ftell(pimg->fh) - 1; + fseek(pimg->fh, pimg->start, SEEK_SET); + ch = GETC(pimg->fh); + pimg->pending = 0; + } else { + /* If a file actually has a 'D' before any 'M', then + * pretend the 'D' is an 'M' - one of the examples + * in the docs was like this! */ + ch = 'M'; + } + } + line = getline_alloc(pimg->fh); + if (!line) { + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + /* Compass stores coordinates as North, East, Up = (y,x,z)! */ + if (sscanf(line, "%lf%lf%lf", &p->y, &p->x, &p->z) != 3) { + osfree(line); + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + } else { + img_errno = IMG_BADFORMAT; + } + return img_BAD; + } + p->x *= METRES_PER_FOOT; + p->y *= METRES_PER_FOOT; + p->z *= METRES_PER_FOOT; + q = strchr(line, 'S'); + if (!q) { + osfree(line); + img_errno = IMG_BADFORMAT; + return img_BAD; + } + ++q; + len = 0; + while (q[len] > ' ') ++len; + q[len] = '\0'; + len += 2; /* ' ' and '\0' */ + if (!check_label_space(pimg, pimg->label_len + len)) { + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + pimg->label = pimg->label_buf; + if (pimg->label_len) { + pimg->label[pimg->label_len] = ' '; + memcpy(pimg->label + pimg->label_len + 1, q, len - 1); + } else { + memcpy(pimg->label, q, len - 1); + } + q += len - 1; + /* Now read LRUD. Technically, this is optional but virtually + * all PLT files have it (with dummy negative values if no LRUD + * was measured) and some versions of Compass can't read PLT + * files without it! + */ + while (*q && *q <= ' ') q++; + if (*q == 'P') { + if (sscanf(q + 1, "%lf%lf%lf%lf", + &pimg->l, &pimg->r, &pimg->u, &pimg->d) != 4) { + osfree(line); + if (ferror(pimg->fh)) { + img_errno = IMG_READERROR; + } else { + img_errno = IMG_BADFORMAT; + } + return img_BAD; + } + pimg->l *= METRES_PER_FOOT; + pimg->r *= METRES_PER_FOOT; + pimg->u *= METRES_PER_FOOT; + pimg->d *= METRES_PER_FOOT; + } else { + pimg->l = pimg->r = pimg->u = pimg->d = -1; + } + osfree(line); + pimg->flags = img_SFLAG_UNDERGROUND; /* default flags */ + if (fpos != -1) { + fseek(pimg->fh, fpos, SEEK_SET); + } else { + pimg->pending = (ch == 'M' ? img_MOVE : img_LINE) + 4; + } + return img_LABEL; + } + default: + img_errno = IMG_BADFORMAT; + return img_BAD; + } + } + } else { + /* CMAP .xyz file */ + char *line = NULL; + char *q; + size_t len; + + if (pimg->pending) { + /* pending MOVE or LINE or LABEL or STOP */ + int r = pimg->pending - 4; + /* Set label to empty - don't use "" as we adjust label relative + * to label_buf when label_buf is reallocated. */ + pimg->label = pimg->label_buf + strlen(pimg->label_buf); + pimg->flags = 0; + if (r == img_LABEL) { + /* nasty magic */ + read_xyz_shot_coords(p, pimg->label_buf + 16); + subtract_xyz_shot_deltas(p, pimg->label_buf + 16); + pimg->pending = img_STOP + 4; + return img_MOVE; + } + + pimg->pending = 0; + + if (r == img_STOP) { + /* nasty magic */ + read_xyz_shot_coords(p, pimg->label_buf + 16); + return img_LINE; + } + + return r; + } + + pimg->label = pimg->label_buf; + do { + osfree(line); + if (feof(pimg->fh)) return img_STOP; + line = getline_alloc(pimg->fh); + if (!line) { + img_errno = IMG_OUTOFMEMORY; + return img_BAD; + } + } while (line[0] == ' ' || line[0] == '\0'); + if (line[0] == '\x1a') return img_STOP; + + len = strlen(line); + if (pimg->version == VERSION_CMAP_STATION) { + /* station variant */ + if (len < 37) { + osfree(line); + img_errno = IMG_BADFORMAT; + return img_BAD; + } + memcpy(pimg->label, line, 6); + q = (char *)memchr(pimg->label, ' ', 6); + if (!q) q = pimg->label + 6; + *q = '\0'; + + read_xyz_station_coords(p, line); + + /* FIXME: look at prev for lines (line + 32, 5) */ + /* FIXME: duplicate stations... */ + return img_LABEL; + } else { + /* Shot variant (VERSION_CMAP_SHOT) */ + char old[8], new_[8]; + if (len < 61) { + osfree(line); + img_errno = IMG_BADFORMAT; + return img_BAD; + } + + memcpy(old, line, 7); + q = (char *)memchr(old, ' ', 7); + if (!q) q = old + 7; + *q = '\0'; + + memcpy(new_, line + 7, 7); + q = (char *)memchr(new_, ' ', 7); + if (!q) q = new_ + 7; + *q = '\0'; + + pimg->flags = img_SFLAG_UNDERGROUND; + + if (strcmp(old, new_) == 0) { + pimg->pending = img_MOVE + 4; + read_xyz_shot_coords(p, line); + strcpy(pimg->label, new_); + osfree(line); + return img_LABEL; + } + + if (strcmp(old, pimg->label) == 0) { + pimg->pending = img_LINE + 4; + read_xyz_shot_coords(p, line); + strcpy(pimg->label, new_); + osfree(line); + return img_LABEL; + } + + pimg->pending = img_LABEL + 4; + read_xyz_shot_coords(p, line); + strcpy(pimg->label, new_); + memcpy(pimg->label + 16, line, 70); + + osfree(line); + return img_LABEL; + } + } +} + +static void +write_coord(FILE *fh, double x, double y, double z) +{ + SVX_ASSERT(fh); + /* Output in cm */ + static INT32_T X_, Y_, Z_; + INT32_T X = my_lround(x * 100.0); + INT32_T Y = my_lround(y * 100.0); + INT32_T Z = my_lround(z * 100.0); + + X_ -= X; + Y_ -= Y; + Z_ -= Z; + put32(X, fh); + put32(Y, fh); + put32(Z, fh); + X_ = X; Y_ = Y; Z_ = Z; +} + +static int +write_v3label(img *pimg, int opt, const char *s) +{ + size_t len, n, dot; + + /* find length of common prefix */ + dot = 0; + for (len = 0; s[len] == pimg->label_buf[len] && s[len] != '\0'; len++) { + if (s[len] == '.') dot = len + 1; + } + + SVX_ASSERT(len <= pimg->label_len); + n = pimg->label_len - len; + if (len == 0) { + if (pimg->label_len) PUTC(0, pimg->fh); + } else if (n <= 16) { + if (n) PUTC(n + 15, pimg->fh); + } else if (dot == 0) { + if (pimg->label_len) PUTC(0, pimg->fh); + len = 0; + } else { + const char *p = pimg->label_buf + dot; + n = 1; + for (len = pimg->label_len - dot - 17; len; len--) { + if (*p++ == '.') n++; + } + if (n <= 14) { + PUTC(n, pimg->fh); + len = dot; + } else { + if (pimg->label_len) PUTC(0, pimg->fh); + len = 0; + } + } + + n = strlen(s + len); + PUTC(opt, pimg->fh); + if (n < 0xfe) { + PUTC(n, pimg->fh); + } else if (n < 0xffff + 0xfe) { + PUTC(0xfe, pimg->fh); + put16((short)(n - 0xfe), pimg->fh); + } else { + PUTC(0xff, pimg->fh); + put32(n, pimg->fh); + } + fwrite(s + len, n, 1, pimg->fh); + + n += len; + pimg->label_len = n; + if (!check_label_space(pimg, n + 1)) + return 0; /* FIXME: distinguish out of memory... */ + memcpy(pimg->label_buf + len, s + len, n - len + 1); + + return !ferror(pimg->fh); +} + +static int +write_v8label(img *pimg, int opt, int common_flag, size_t common_val, + const char *s) +{ + size_t len, del, add; + + /* find length of common prefix */ + for (len = 0; s[len] == pimg->label_buf[len] && s[len] != '\0'; len++) { + } + + SVX_ASSERT(len <= pimg->label_len); + del = pimg->label_len - len; + add = strlen(s + len); + + if (add == common_val && del == common_val) { + PUTC(opt | common_flag, pimg->fh); + } else { + PUTC(opt, pimg->fh); + if (del <= 15 && add <= 15 && (del || add)) { + PUTC((del << 4) | add, pimg->fh); + } else { + PUTC(0x00, pimg->fh); + if (del < 0xff) { + PUTC(del, pimg->fh); + } else { + PUTC(0xff, pimg->fh); + put32(del, pimg->fh); + } + if (add < 0xff) { + PUTC(add, pimg->fh); + } else { + PUTC(0xff, pimg->fh); + put32(add, pimg->fh); + } + } + } + + if (add) + fwrite(s + len, add, 1, pimg->fh); + + pimg->label_len = len + add; + if (add > del && !check_label_space(pimg, pimg->label_len + 1)) + return 0; /* FIXME: distinguish out of memory... */ + + memcpy(pimg->label_buf + len, s + len, add + 1); + + return !ferror(pimg->fh); +} + +static void +img_write_item_date_new(img *pimg) +{ + int same, unset; + /* Only write dates when they've changed. */ +#if IMG_API_VERSION == 0 + if (pimg->date1 == pimg->olddate1 && pimg->date2 == pimg->olddate2) + return; + + same = (pimg->date1 == pimg->date2); + unset = (pimg->date1 == 0); +#else /* IMG_API_VERSION == 1 */ + if (pimg->days1 == pimg->olddays1 && pimg->days2 == pimg->olddays2) + return; + + same = (pimg->days1 == pimg->days2); + unset = (pimg->days1 == -1); +#endif + + if (same) { + if (unset) { + PUTC(0x10, pimg->fh); + } else { + PUTC(0x11, pimg->fh); +#if IMG_API_VERSION == 0 + put16(pimg->date1 / 86400 + 25567, pimg->fh); +#else /* IMG_API_VERSION == 1 */ + put16(pimg->days1, pimg->fh); +#endif + } + } else { +#if IMG_API_VERSION == 0 + int diff = (pimg->date2 - pimg->date1) / 86400; + if (diff > 0 && diff <= 256) { + PUTC(0x12, pimg->fh); + put16(pimg->date1 / 86400 + 25567, pimg->fh); + PUTC(diff - 1, pimg->fh); + } else { + PUTC(0x13, pimg->fh); + put16(pimg->date1 / 86400 + 25567, pimg->fh); + put16(pimg->date2 / 86400 + 25567, pimg->fh); + } +#else /* IMG_API_VERSION == 1 */ + int diff = pimg->days2 - pimg->days1; + if (diff > 0 && diff <= 256) { + PUTC(0x12, pimg->fh); + put16(pimg->days1, pimg->fh); + PUTC(diff - 1, pimg->fh); + } else { + PUTC(0x13, pimg->fh); + put16(pimg->days1, pimg->fh); + put16(pimg->days2, pimg->fh); + } +#endif + } +#if IMG_API_VERSION == 0 + pimg->olddate1 = pimg->date1; + pimg->olddate2 = pimg->date2; +#else /* IMG_API_VERSION == 1 */ + pimg->olddays1 = pimg->days1; + pimg->olddays2 = pimg->days2; +#endif +} + +static void +img_write_item_date(img *pimg) +{ + int same, unset; + /* Only write dates when they've changed. */ +#if IMG_API_VERSION == 0 + if (pimg->date1 == pimg->olddate1 && pimg->date2 == pimg->olddate2) + return; + + same = (pimg->date1 == pimg->date2); + unset = (pimg->date1 == 0); +#else /* IMG_API_VERSION == 1 */ + if (pimg->days1 == pimg->olddays1 && pimg->days2 == pimg->olddays2) + return; + + same = (pimg->days1 == pimg->days2); + unset = (pimg->days1 == -1); +#endif + + if (same) { + if (img_output_version < 7) { + PUTC(0x20, pimg->fh); +#if IMG_API_VERSION == 0 + put32(pimg->date1, pimg->fh); +#else /* IMG_API_VERSION == 1 */ + put32((pimg->days1 - 25567) * 86400, pimg->fh); +#endif + } else { + if (unset) { + PUTC(0x24, pimg->fh); + } else { + PUTC(0x20, pimg->fh); +#if IMG_API_VERSION == 0 + put16(pimg->date1 / 86400 + 25567, pimg->fh); +#else /* IMG_API_VERSION == 1 */ + put16(pimg->days1, pimg->fh); +#endif + } + } + } else { + if (img_output_version < 7) { + PUTC(0x21, pimg->fh); +#if IMG_API_VERSION == 0 + put32(pimg->date1, pimg->fh); + put32(pimg->date2, pimg->fh); +#else /* IMG_API_VERSION == 1 */ + put32((pimg->days1 - 25567) * 86400, pimg->fh); + put32((pimg->days2 - 25567) * 86400, pimg->fh); +#endif + } else { +#if IMG_API_VERSION == 0 + int diff = (pimg->date2 - pimg->date1) / 86400; + if (diff > 0 && diff <= 256) { + PUTC(0x21, pimg->fh); + put16(pimg->date1 / 86400 + 25567, pimg->fh); + PUTC(diff - 1, pimg->fh); + } else { + PUTC(0x23, pimg->fh); + put16(pimg->date1 / 86400 + 25567, pimg->fh); + put16(pimg->date2 / 86400 + 25567, pimg->fh); + } +#else /* IMG_API_VERSION == 1 */ + int diff = pimg->days2 - pimg->days1; + if (diff > 0 && diff <= 256) { + PUTC(0x21, pimg->fh); + put16(pimg->days1, pimg->fh); + PUTC(diff - 1, pimg->fh); + } else { + PUTC(0x23, pimg->fh); + put16(pimg->days1, pimg->fh); + put16(pimg->days2, pimg->fh); + } +#endif + } + } +#if IMG_API_VERSION == 0 + pimg->olddate1 = pimg->date1; + pimg->olddate2 = pimg->date2; +#else /* IMG_API_VERSION == 1 */ + pimg->olddays1 = pimg->days1; + pimg->olddays2 = pimg->days2; +#endif +} + +static void +img_write_item_new(img *pimg, int code, int flags, const char *s, + double x, double y, double z); +static void +img_write_item_v3to7(img *pimg, int code, int flags, const char *s, + double x, double y, double z); +static void +img_write_item_ancient(img *pimg, int code, int flags, const char *s, + double x, double y, double z); + +void +img_write_item(img *pimg, int code, int flags, const char *s, + double x, double y, double z) +{ + if (!pimg) return; + if (pimg->version >= 8) { + img_write_item_new(pimg, code, flags, s, x, y, z); + } else if (pimg->version >= 3) { + img_write_item_v3to7(pimg, code, flags, s, x, y, z); + } else { + img_write_item_ancient(pimg, code, flags, s, x, y, z); + } +} + +static void +img_write_item_new(img *pimg, int code, int flags, const char *s, + double x, double y, double z) +{ + switch (code) { + case img_LABEL: + write_v8label(pimg, 0x80 | flags, 0, -1, s); + break; + case img_XSECT: { + INT32_T l, r, u, d, max_dim; + img_write_item_date_new(pimg); + l = (INT32_T)my_lround(pimg->l * 100.0); + r = (INT32_T)my_lround(pimg->r * 100.0); + u = (INT32_T)my_lround(pimg->u * 100.0); + d = (INT32_T)my_lround(pimg->d * 100.0); + if (l < 0) l = -1; + if (r < 0) r = -1; + if (u < 0) u = -1; + if (d < 0) d = -1; + max_dim = max(max(l, r), max(u, d)); + flags = (flags & img_XFLAG_END) ? 1 : 0; + if (max_dim >= 32768) flags |= 2; + write_v8label(pimg, 0x30 | flags, 0, -1, s); + if (flags & 2) { + /* Big passage! Need to use 4 bytes. */ + put32(l, pimg->fh); + put32(r, pimg->fh); + put32(u, pimg->fh); + put32(d, pimg->fh); + } else { + put16(l, pimg->fh); + put16(r, pimg->fh); + put16(u, pimg->fh); + put16(d, pimg->fh); + } + return; + } + case img_MOVE: + PUTC(15, pimg->fh); + break; + case img_LINE: + img_write_item_date_new(pimg); + if (pimg->style != pimg->oldstyle) { + switch (pimg->style) { + case img_STYLE_NORMAL: + case img_STYLE_DIVING: + case img_STYLE_CARTESIAN: + case img_STYLE_CYLPOLAR: + case img_STYLE_NOSURVEY: + PUTC(pimg->style, pimg->fh); + break; + } + pimg->oldstyle = pimg->style; + } + write_v8label(pimg, 0x40 | flags, 0x20, 0x00, s ? s : ""); + break; + default: /* ignore for now */ + return; + } + write_coord(pimg->fh, x, y, z); +} + +static void +img_write_item_v3to7(img *pimg, int code, int flags, const char *s, + double x, double y, double z) +{ + switch (code) { + case img_LABEL: + write_v3label(pimg, 0x40 | flags, s); + break; + case img_XSECT: { + INT32_T l, r, u, d, max_dim; + /* Need at least version 5 for img_XSECT. */ + if (pimg->version < 5) return; + img_write_item_date(pimg); + l = (INT32_T)my_lround(pimg->l * 100.0); + r = (INT32_T)my_lround(pimg->r * 100.0); + u = (INT32_T)my_lround(pimg->u * 100.0); + d = (INT32_T)my_lround(pimg->d * 100.0); + if (l < 0) l = -1; + if (r < 0) r = -1; + if (u < 0) u = -1; + if (d < 0) d = -1; + max_dim = max(max(l, r), max(u, d)); + flags = (flags & img_XFLAG_END) ? 1 : 0; + if (max_dim >= 32768) flags |= 2; + write_v3label(pimg, 0x30 | flags, s); + if (flags & 2) { + /* Big passage! Need to use 4 bytes. */ + put32(l, pimg->fh); + put32(r, pimg->fh); + put32(u, pimg->fh); + put32(d, pimg->fh); + } else { + put16(l, pimg->fh); + put16(r, pimg->fh); + put16(u, pimg->fh); + put16(d, pimg->fh); + } + return; + } + case img_MOVE: + PUTC(15, pimg->fh); + break; + case img_LINE: + if (pimg->version >= 4) { + img_write_item_date(pimg); + } + write_v3label(pimg, 0x80 | flags, s ? s : ""); + break; + default: /* ignore for now */ + return; + } + write_coord(pimg->fh, x, y, z); +} + +static void +img_write_item_ancient(img *pimg, int code, int flags, const char *s, + double x, double y, double z) +{ + size_t len; + INT32_T opt = 0; + SVX_ASSERT(pimg->version > 0); + switch (code) { + case img_LABEL: + if (pimg->version == 1) { + /* put a move before each label */ + img_write_item_ancient(pimg, img_MOVE, 0, NULL, x, y, z); + put32(2, pimg->fh); + fputsnl(s, pimg->fh); + return; + } + len = strlen(s); + if (len > 255 || strchr(s, '\n')) { + /* long label - not in early incarnations of v2 format, but few + * 3d files will need these, so better not to force incompatibility + * with a new version I think... */ + PUTC(7, pimg->fh); + PUTC(flags, pimg->fh); + put32(len, pimg->fh); + fputs(s, pimg->fh); + } else { + PUTC(0x40 | (flags & 0x3f), pimg->fh); + fputsnl(s, pimg->fh); + } + opt = 0; + break; + case img_MOVE: + opt = 4; + break; + case img_LINE: + if (pimg->version > 1) { + opt = 0x80 | (flags & 0x3f); + break; + } + opt = 5; + break; + default: /* ignore for now */ + return; + } + if (pimg->version == 1) { + put32(opt, pimg->fh); + } else { + if (opt) PUTC(opt, pimg->fh); + } + write_coord(pimg->fh, x, y, z); +} + +/* Write error information for the current traverse + * n_legs is the number of legs in the traverse + * length is the traverse length (in m) + * E is the ratio of the observed misclosure to the theoretical one + * H is the ratio of the observed horizontal misclosure to the theoretical one + * V is the ratio of the observed vertical misclosure to the theoretical one + */ +void +img_write_errors(img *pimg, int n_legs, double length, + double E, double H, double V) +{ + PUTC((pimg->version >= 8 ? 0x1f : 0x22), pimg->fh); + put32(n_legs, pimg->fh); + put32((INT32_T)my_lround(length * 100.0), pimg->fh); + put32((INT32_T)my_lround(E * 100.0), pimg->fh); + put32((INT32_T)my_lround(H * 100.0), pimg->fh); + put32((INT32_T)my_lround(V * 100.0), pimg->fh); +} + +int +img_close(img *pimg) +{ + int result = 1; + if (pimg) { + if (pimg->fh) { + if (pimg->fRead) { + osfree(pimg->survey); + osfree(pimg->title); + osfree(pimg->cs); + osfree(pimg->datestamp); + } else { + /* write end of data marker */ + switch (pimg->version) { + case 1: + put32((INT32_T)-1, pimg->fh); + break; + default: + if (pimg->version <= 7 ? + (pimg->label_len != 0) : + (pimg->style != img_STYLE_NORMAL)) { + PUTC(0, pimg->fh); + } + /* FALL THROUGH */ + case 2: + PUTC(0, pimg->fh); + break; + } + } + if (ferror(pimg->fh)) result = 0; + if (pimg->close_func && pimg->close_func(pimg->fh)) + result = 0; + if (!result) img_errno = pimg->fRead ? IMG_READERROR : IMG_WRITEERROR; + } + osfree(pimg->label_buf); + osfree(pimg->filename_opened); + osfree(pimg); + } + return result; +} diff --git a/src/img.go b/src/img.go new file mode 100644 index 0000000..ef5c9c5 --- /dev/null +++ b/src/img.go @@ -0,0 +1,22 @@ +package main + +/* + #cgo LDFLAGS: -lm + #include "img.h" +*/ +import "C" +import ( + "fmt" + // "unsafe" +) + +func Test() { + filename := C.CString("Skydusky.3d") + pimg := C.img_open_survey(filename, nil) + // for C.img_read_item(((*C.CStruct)(unsafe.Pointer(pimg))), ((*C.CStruct)(unsafe.Pointer((&pimg.mv))))) != C.img_BAD { + for C.img_read_item(pimg, &pimg.mv) != C.img_BAD { + if pimg.label != nil { + fmt.Println(C.GoString(pimg.label)) + } + } +} diff --git a/src/img.h b/src/img.h new file mode 100644 index 0000000..a616615 --- /dev/null +++ b/src/img.h @@ -0,0 +1,413 @@ +/* img.h + * Header file for routines to read and write processed survey data files + * + * These routines support reading processed survey data in a variety of formats + * - currently: + * + * - Survex ".3d" image files + * - Survex ".pos" files + * - Compass Plot files (".plt" and ".plf") + * - CMAP XYZ files (".sht", ".adj", ".una", ".xyz") + * + * Writing Survex ".3d" image files is supported. + * + * Copyright (C) Olly Betts 1993,1994,1997,2001,2002,2003,2004,2005,2006,2010,2011,2012,2013,2014,2016,2018 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef IMG_H +# define IMG_H + +/* Define IMG_API_VERSION if you want more recent versions of the img API. + * + * 0 (default) The old API. date1 and date2 give the survey date as time_t. + * Set to 0 for "unknown". + * 1 days1 and days2 give survey dates as days since 1st Jan 1900. + * Set to -1 for "unknown". + */ +#ifndef IMG_API_VERSION +# define IMG_API_VERSION 0 +#elif IMG_API_VERSION > 1 +# error IMG_API_VERSION > 1 too new +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include /* for time_t */ + +# define img_BAD -2 +# define img_STOP -1 +# define img_MOVE 0 +# define img_LINE 1 +/* NB: img_CROSS is never output and ignored on input. + * Put crosses where labels are. */ +/* # define img_CROSS 2 */ +# define img_LABEL 3 +# define img_XSECT 4 +# define img_XSECT_END 5 +/* Loop closure information for the *preceding* traverse (img_MOVE + one or + * more img_LINEs). */ +# define img_ERROR_INFO 6 + +/* Leg flags */ +# define img_FLAG_SURFACE 0x01 +# define img_FLAG_DUPLICATE 0x02 +# define img_FLAG_SPLAY 0x04 + +/* Station flags */ +# define img_SFLAG_SURFACE 0x01 +# define img_SFLAG_UNDERGROUND 0x02 +# define img_SFLAG_ENTRANCE 0x04 +# define img_SFLAG_EXPORTED 0x08 +# define img_SFLAG_FIXED 0x10 +# define img_SFLAG_ANON 0x20 +# define img_SFLAG_WALL 0x40 + +/* File-wide flags */ +# define img_FFLAG_EXTENDED 0x80 + +/* When writing img_XSECT, img_XFLAG_END in pimg->flags means this is the last + * img_XSECT in this tube: + */ +# define img_XFLAG_END 0x01 + +# define img_STYLE_UNKNOWN -1 +# define img_STYLE_NORMAL 0 +# define img_STYLE_DIVING 1 +# define img_STYLE_CARTESIAN 2 +# define img_STYLE_CYLPOLAR 3 +# define img_STYLE_NOSURVEY 4 + +/* 3D coordinates (in metres) */ +typedef struct { + double x, y, z; +} img_point; + +typedef struct { + /* Members you can access when reading (don't touch when writing): */ + char *label; + int flags; + char *title; + /* If the coordinate system was specified, this contains a PROJ4 string + * describing it. If not, this member will be NULL. + */ + char *cs; + /* Older .3d format versions stored a human readable datestamp string. + * Format versions >= 8 versions store a string consisting of "@" followed + * by the number of seconds since midnight UTC on 1/1/1970. Some foreign + * formats contain a human readable string, others no date information + * (which results in "?" being returned). + */ + char *datestamp; + /* The datestamp as a time_t (or (time_t)-1 if not available). + * + * For 3d format versions >= 8, this is a reliable value and in UTC. Older + * 3d format versions store a human readable time, which img will attempt + * to decode, but it may fail, particularly with handling timezones. Even + * if it does work, beware that times in local time where DST applies are + * inherently ambiguous around when the clocks go back. + * + * CMAP XYZ files contain a timestamp. It's probably in localtime (but + * without any timezone information) and the example files are all pre-2000 + * and have two digit years. We do our best to turn these into a useful + * time_t value. + */ + time_t datestamp_numeric; + char separator; /* character used to separate survey levels ('.' usually) */ + + /* Members that can be set when writing: */ +#if IMG_API_VERSION == 0 + time_t date1, date2; +#else /* IMG_API_VERSION == 1 */ + int days1, days2; +#endif + double l, r, u, d; + + /* Error information - valid when img_ERROR_INFO is returned: */ + int n_legs; + double length; + double E, H, V; + + /* The filename actually opened (e.g. may have ".3d" added). + * + * This is only set if img opened the filename - if an existing stream + * is used (via img_read_stream() or similar) then this member will be + * NULL. + */ + char * filename_opened; + + /* Non-zero if reading an extended elevation: */ + int is_extended_elevation; + + /* Members that can be set when writing: */ + /* The style of the data - one of the img_STYLE_* constants above */ + int style; + + /* All other members are for internal use only: */ + FILE *fh; /* file handle of image file */ + int (*close_func)(FILE*); + char *label_buf; + size_t buf_len; + size_t label_len; + int fRead; /* 1 for reading, 0 for writing */ + long start; + /* version of file format: + * -4 => CMAP .xyz file, shot format + * -3 => CMAP .xyz file, station format + * -2 => Compass .plt file + * -1 => .pos file + * 0 => 0.01 ascii + * 1 => 0.01 binary, + * 2 => byte actions and flags + * 3 => prefixes for legs; compressed prefixes + * 4 => survey date + * 5 => LRUD info + * 6 => error info + * 7 => more compact dates with wider range + * 8 => lots of changes + */ + int version; + char *survey; + size_t survey_len; + int pending; /* for old style text format files and survey filtering */ + img_point mv; +#if IMG_API_VERSION == 0 + time_t olddate1, olddate2; +#else /* IMG_API_VERSION == 1 */ + int olddays1, olddays2; +#endif + int oldstyle; +} img; + +/* Which version of the file format to output (defaults to newest) */ +extern unsigned int img_output_version; + +/* Minimum supported value for img_output_version: */ +#define IMG_VERSION_MIN 1 + +/* Maximum supported value for img_output_version: */ +#define IMG_VERSION_MAX 8 + +/* Open a processed survey data file for reading + * + * fnm is the filename + * + * Returns pointer to an img struct or NULL + */ +#define img_open(F) img_open_survey((F), NULL) + +/* Open a processed survey data file for reading + * + * fnm is the filename + * + * survey points to a survey name to restrict reading to (or NULL for all + * survey data in the file) + * + * Returns pointer to an img struct or NULL + */ +img *img_open_survey(const char *fnm, const char *survey); + +/* Read processed survey data from an existing stream. + * + * stream is a FILE* open on the stream (can be NULL which will give error + * IMG_FILENOTFOUND so you don't need to handle that case specially). The + * stream should be opened for reading in binary mode and positioned at the + * start of the survey data file. + * + * close_func is a function to call to close the stream (most commonly + * fclose, or pclose if the stream was opened using popen()) or NULL if + * the caller wants to take care of closing the stream. + * + * filename is used to determine the format based on the file extension, + * and also the leafname with the extension removed is used for the survey + * title for formats which don't support a title or when no title is + * specified. If you're not interested in default titles, you can just + * pass the extension including a leading "." - e.g. ".3d". May not be + * NULL. + * + * Returns pointer to an img struct or NULL on error. Any close function + * specified is called on error (unless stream is NULL). + */ +#define img_read_stream(S, C, F) img_read_stream_survey((S), (C), (F), NULL) + +/* Read processed survey data from an existing stream. + * + * stream is a FILE* open on the stream (can be NULL which will give error + * IMG_FILENOTFOUND so you don't need to handle that case specially). The + * stream should be opened for reading in binary mode and positioned at the + * start of the survey data file. + * + * close_func is a function to call to close the stream (most commonly + * fclose, or pclose if the stream was opened using popen()) or NULL if + * the caller wants to take care of closing the stream. + * + * filename is used to determine the format based on the file extension, + * and also the leafname with the extension removed is used for the survey + * title for formats which don't support a title or when no title is + * specified. If you're not interested in default titles, you can just + * pass the extension including a leading "." - e.g. ".3d". filename must + * not be NULL. + * + * survey points to a survey name to restrict reading to (or NULL for all + * survey data in the file) + * + * Returns pointer to an img struct or NULL on error. Any close function + * specified is called on error. + */ +img *img_read_stream_survey(FILE *stream, int (*close_func)(FILE*), + const char *filename, + const char *survey); + +/* Open a .3d file for output with no specified coordinate system + * + * This is a very thin wrapper around img_open_write_cs() which passes NULL for + * cs, provided for compatibility with the API provided before support for + * coordinate systems was added. + * + * See img_open_write_cs() for documentation. + */ +#define img_open_write(F, T, S) img_open_write_cs(F, T, NULL, S) + +/* Open a .3d file for output in a specified coordinate system + * + * fnm is the filename + * + * title is the title + * + * cs is a PROJ4 string describing the coordinate system (or NULL to not + * specify a coordinate system). + * + * flags contains a bitwise-or of any file-wide flags - currently only one + * is available: img_FFLAG_EXTENDED. + * + * Returns pointer to an img struct or NULL for error (check img_error() + * for details) + */ +img *img_open_write_cs(const char *fnm, const char *title, const char * cs, + int flags); + +/* Write a .3d file to a stream + * + * stream is a FILE* open on the stream (can be NULL which will give error + * IMG_FILENOTFOUND so you don't need to handle that case specially). The + * stream should be opened for writing in binary mode. + * + * close_func is a function to call to close the stream (most commonly + * fclose, or pclose if the stream was opened using popen()) or NULL if + * the caller wants to take care of closing the stream. + * + * title is the title + * + * cs is a PROJ4 string describing the coordinate system (or NULL to not + * specify a coordinate system). + * + * flags contains a bitwise-or of any file-wide flags - currently only one + * is available: img_FFLAG_EXTENDED. + * + * Returns pointer to an img struct or NULL for error (check img_error() + * for details). Any close function specified is called on error (unless + * stream is NULL). + */ +img *img_write_stream(FILE *stream, int (*close_func)(FILE*), + const char *title, const char * cs, int flags); + +/* Read an item from a processed survey data file + * + * pimg is a pointer to an img struct returned by img_open() + * + * coordinates are returned in p + * + * flags and label name are returned in fields in pimg + * + * Returns img_XXXX as #define-d above + */ +int img_read_item(img *pimg, img_point *p); + +/* Write a item to a .3d file + * + * pimg is a pointer to an img struct returned by img_open_write() + * + * code is one of the img_XXXX #define-d above + * + * flags is the leg, station, or xsect flags + * (meaningful for img_LINE, img_LABEL, and img_XSECT respectively) + * + * s is the label (only meaningful for img_LABEL) + * + * x, y, z are the coordinates + */ +void img_write_item(img *pimg, int code, int flags, const char *s, + double x, double y, double z); + +/* Write error information for the current traverse + * + * n_legs is the number of legs in the traverse + * + * length is the traverse length (in m) + * + * E is the ratio of the observed misclosure to the theoretical one + * + * H is the ratio of the observed horizontal misclosure to the theoretical one + * + * V is the ratio of the observed vertical misclosure to the theoretical one + */ +void img_write_errors(img *pimg, int n_legs, double length, + double E, double H, double V); + +/* rewind a processed survey data file opened for reading + * + * This is useful if you want to read the data in several passes. + * + * pimg is a pointer to an img struct returned by img_open() + * + * Returns: non-zero for success, zero for error (check img_error() for + * details) + */ +int img_rewind(img *pimg); + +/* Close a processed survey data file + * + * pimg is a pointer to an img struct returned by img_open() or + * img_open_write() + * + * Returns: non-zero for success, zero for error (check img_error() for + * details) + */ +int img_close(img *pimg); + +/* Codes returned by img_error */ +typedef enum { + IMG_NONE = 0, IMG_FILENOTFOUND, IMG_OUTOFMEMORY, + IMG_CANTOPENOUT, IMG_BADFORMAT, IMG_DIRECTORY, + IMG_READERROR, IMG_WRITEERROR, IMG_TOONEW +} img_errcode; + +/* Read the error code + * + * If img_open(), img_open_survey() or img_open_write() returns NULL, or + * img_rewind() or img_close() returns 0, or img_read_item() returns img_BAD + * then you can call this function to discover why. + */ +img_errcode img_error(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/kavea_linux_amd64 b/src/kavea_linux_amd64 new file mode 100755 index 0000000..84423ea Binary files /dev/null and b/src/kavea_linux_amd64 differ diff --git a/src/main.go b/src/main.go index ad18241..d659ff8 100644 --- a/src/main.go +++ b/src/main.go @@ -1,19 +1,23 @@ package main import ( + "embed" "log" "net/http" "runtime" - "github.com/blevesearch/bleve/v2" "github.com/zserge/lorca" ) +//go:embed templates +var templatesHTML embed.FS + //go:embed static var staticFiles embed.FS func main() { log.SetFlags(log.Lshortfile) + Test() /* Web Server */ http.Handle("/static/", http.FileServer(http.FS(staticFiles))) diff --git a/src/static/babylon-4.2.0.gui.min.js b/src/static/babylon-4.2.0.gui.min.js new file mode 100644 index 0000000..23660f0 --- /dev/null +++ b/src/static/babylon-4.2.0.gui.min.js @@ -0,0 +1,16 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-gui",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-gui"]=e(require("babylonjs")):(t.BABYLON=t.BABYLON||{},t.BABYLON.GUI=e(t.BABYLON))}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(t){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=2)}([function(e,i){e.exports=t},function(t,e,i){"use strict";i.r(e),i.d(e,"Button",(function(){return O})),i.d(e,"Checkbox",(function(){return T})),i.d(e,"ColorPicker",(function(){return M})),i.d(e,"Container",(function(){return g})),i.d(e,"Control",(function(){return f})),i.d(e,"Ellipse",(function(){return I})),i.d(e,"Grid",(function(){return P})),i.d(e,"Image",(function(){return v})),i.d(e,"InputText",(function(){return x})),i.d(e,"InputPassword",(function(){return k})),i.d(e,"Line",(function(){return A})),i.d(e,"MultiLine",(function(){return E})),i.d(e,"RadioButton",(function(){return D})),i.d(e,"StackPanel",(function(){return C})),i.d(e,"SelectorGroup",(function(){return B})),i.d(e,"CheckboxGroup",(function(){return N})),i.d(e,"RadioGroup",(function(){return H})),i.d(e,"SliderGroup",(function(){return V})),i.d(e,"SelectionPanel",(function(){return W})),i.d(e,"ScrollViewer",(function(){return G})),i.d(e,"TextWrapping",(function(){return m})),i.d(e,"TextBlock",(function(){return y})),i.d(e,"TextWrapper",(function(){return w})),i.d(e,"KeyPropertySet",(function(){return X})),i.d(e,"VirtualKeyboard",(function(){return U})),i.d(e,"Rectangle",(function(){return b})),i.d(e,"DisplayGrid",(function(){return Y})),i.d(e,"BaseSlider",(function(){return L})),i.d(e,"Slider",(function(){return R})),i.d(e,"ImageBasedSlider",(function(){return q})),i.d(e,"ScrollBar",(function(){return j})),i.d(e,"ImageScrollBar",(function(){return z})),i.d(e,"name",(function(){return K})),i.d(e,"AdvancedDynamicTexture",(function(){return J})),i.d(e,"AdvancedDynamicTextureInstrumentation",(function(){return Q})),i.d(e,"Vector2WithInfo",(function(){return d})),i.d(e,"Matrix2D",(function(){return p})),i.d(e,"Measure",(function(){return _})),i.d(e,"MultiLinePoint",(function(){return S})),i.d(e,"Style",(function(){return Z})),i.d(e,"ValueAndUnit",(function(){return a})),i.d(e,"XmlLoader",(function(){return $})),i.d(e,"AbstractButton3D",(function(){return it})),i.d(e,"Button3D",(function(){return rt})),i.d(e,"Container3D",(function(){return nt})),i.d(e,"Control3D",(function(){return et})),i.d(e,"CylinderPanel",(function(){return st})),i.d(e,"HolographicButton",(function(){return ct})),i.d(e,"MeshButton3D",(function(){return _t})),i.d(e,"PlanePanel",(function(){return dt})),i.d(e,"ScatterPanel",(function(){return pt})),i.d(e,"SpherePanel",(function(){return ft})),i.d(e,"StackPanel3D",(function(){return gt})),i.d(e,"VolumeBasedPanel",(function(){return ot})),i.d(e,"FluentMaterialDefines",(function(){return lt})),i.d(e,"FluentMaterial",(function(){return ut})),i.d(e,"GUI3DManager",(function(){return mt})),i.d(e,"Vector3WithInfo",(function(){return tt})); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};function n(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function o(t,e,i,r){var n,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(o<3?n(s):o>3?n(e,i,s):n(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s}Object.create;Object.create;var s=i(0),a=function(){function t(e,i,r){void 0===i&&(i=t.UNITMODE_PIXEL),void 0===r&&(r=!0),this.unit=i,this.negativeValueAllowed=r,this._value=1,this.ignoreAdaptiveScaling=!1,this._value=e,this._originalUnit=i}return Object.defineProperty(t.prototype,"isPercentage",{get:function(){return this.unit===t.UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPixel",{get:function(){return this.unit===t.UNITMODE_PIXEL},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"internalValue",{get:function(){return this._value},enumerable:!1,configurable:!0}),t.prototype.getValueInPixel=function(t,e){return this.isPixel?this.getValue(t):this.getValue(t)*e},t.prototype.updateInPlace=function(e,i){return void 0===i&&(i=t.UNITMODE_PIXEL),this._value=e,this.unit=i,this},t.prototype.getValue=function(e){if(e&&!this.ignoreAdaptiveScaling&&this.unit!==t.UNITMODE_PERCENTAGE){var i=0,r=0;if(e.idealWidth&&(i=this._value*e.getSize().width/e.idealWidth),e.idealHeight&&(r=this._value*e.getSize().height/e.idealHeight),e.useSmallestIdeal&&e.idealWidth&&e.idealHeight)return window.innerWidth1?this.notRenderable=!0:this.notRenderable=!1}else s.Tools.Error("Cannot move a control to a vector3 if the control is not at root level")},t.prototype.getDescendantsToRef=function(t,e,i){void 0===e&&(e=!1)},t.prototype.getDescendants=function(t,e){var i=new Array;return this.getDescendantsToRef(i,t,e),i},t.prototype.linkWithMesh=function(e){if(!this._host||this.parent&&this.parent!==this._host._rootContainer)e&&s.Tools.Error("Cannot link a control to a mesh if the control is not at root level");else{var i=this._host._linkedControls.indexOf(this);if(-1!==i)return this._linkedMesh=e,void(e||this._host._linkedControls.splice(i,1));e&&(this.horizontalAlignment=t.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=e,this._host._linkedControls.push(this))}},t.prototype._moveToProjectedPosition=function(t){var e=this._left.getValue(this._host),i=this._top.getValue(this._host),r=t.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2,n=t.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2;this._left.ignoreAdaptiveScaling&&this._top.ignoreAdaptiveScaling&&(Math.abs(r-e)<.5&&(r=e),Math.abs(n-i)<.5&&(n=i)),this.left=r+"px",this.top=n+"px",this._left.ignoreAdaptiveScaling=!0,this._top.ignoreAdaptiveScaling=!0,this._markAsDirty()},t.prototype._offsetLeft=function(t){this._isDirty=!0,this._currentMeasure.left+=t},t.prototype._offsetTop=function(t){this._isDirty=!0,this._currentMeasure.top+=t},t.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._flagDescendantsAsMatrixDirty()},t.prototype._flagDescendantsAsMatrixDirty=function(){},t.prototype._intersectsRect=function(t){return this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),!(this._tmpMeasureA.left>=t.left+t.width)&&(!(this._tmpMeasureA.top>=t.top+t.height)&&(!(this._tmpMeasureA.left+this._tmpMeasureA.width<=t.left)&&!(this._tmpMeasureA.top+this._tmpMeasureA.height<=t.top)))},t.prototype.invalidateRect=function(){if(this._transform(),this.host&&this.host.useInvalidateRectOptimization)if(this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),_.CombineToRef(this._tmpMeasureA,this._prevCurrentMeasureTransformedIntoGlobalSpace,this._tmpMeasureA),this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var t=this.shadowOffsetX,e=this.shadowOffsetY,i=this.shadowBlur,r=Math.min(Math.min(t,0)-2*i,0),n=Math.max(Math.max(t,0)+2*i,0),o=Math.min(Math.min(e,0)-2*i,0),s=Math.max(Math.max(e,0)+2*i,0);this.host.invalidateRect(Math.floor(this._tmpMeasureA.left+r),Math.floor(this._tmpMeasureA.top+o),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width+n),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height+s))}else this.host.invalidateRect(Math.floor(this._tmpMeasureA.left),Math.floor(this._tmpMeasureA.top),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height))},t.prototype._markAsDirty=function(t){void 0===t&&(t=!1),(this._isVisible||t)&&(this._isDirty=!0,this._host&&this._host.markAsDirty())},t.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},t.prototype._link=function(t){this._host=t,this._host&&(this.uniqueId=this._host.getScene().getUniqueId())},t.prototype._transform=function(t){if(this._isMatrixDirty||1!==this._scaleX||1!==this._scaleY||0!==this._rotation){var e=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,i=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;t&&(t.translate(e,i),t.rotate(this._rotation),t.scale(this._scaleX,this._scaleY),t.translate(-e,-i)),(this._isMatrixDirty||this._cachedOffsetX!==e||this._cachedOffsetY!==i)&&(this._cachedOffsetX=e,this._cachedOffsetY=i,this._isMatrixDirty=!1,this._flagDescendantsAsMatrixDirty(),p.ComposeToRef(-e,-i,this._rotation,this._scaleX,this._scaleY,this.parent?this.parent._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix))}},t.prototype._renderHighlight=function(t){this.isHighlighted&&(t.save(),t.strokeStyle="#4affff",t.lineWidth=2,this._renderHighlightSpecific(t),t.restore())},t.prototype._renderHighlightSpecific=function(t){t.strokeRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)},t.prototype._applyStates=function(e){this._isFontSizeInPercentage&&(this._fontSet=!0),this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(e.font=this._font),this._color&&(e.fillStyle=this._color),t.AllowAlphaInheritance?e.globalAlpha*=this._alpha:this._alphaSet&&(e.globalAlpha=this.parent?this.parent.alpha*this._alpha:this._alpha)},t.prototype._layout=function(t,e){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;if(this._isDirty||!this._cachedParentMeasure.isEqualsTo(t)){this.host._numLayoutCalls++,this._currentMeasure.addAndTransformToRef(this._transformMatrix,0|-this.paddingLeftInPixels,0|-this.paddingTopInPixels,0|this.paddingRightInPixels,0|this.paddingBottomInPixels,this._prevCurrentMeasureTransformedIntoGlobalSpace),e.save(),this._applyStates(e);var i=0;do{this._rebuildLayout=!1,this._processMeasures(t,e),i++}while(this._rebuildLayout&&i<3);i>=3&&s.Logger.Error("Layout cycle detected in GUI (Control name="+this.name+", uniqueId="+this.uniqueId+")"),e.restore(),this.invalidateRect(),this._evaluateClippingState(t)}return this._wasDirty=this._isDirty,this._isDirty=!1,!0},t.prototype._processMeasures=function(t,e){this._currentMeasure.copyFrom(t),this._preMeasure(t,e),this._measure(),this._computeAlignment(t,e),this._currentMeasure.left=0|this._currentMeasure.left,this._currentMeasure.top=0|this._currentMeasure.top,this._currentMeasure.width=0|this._currentMeasure.width,this._currentMeasure.height=0|this._currentMeasure.height,this._additionalProcessing(t,e),this._cachedParentMeasure.copyFrom(t),this.onDirtyObservable.hasObservers()&&this.onDirtyObservable.notifyObservers(this)},t.prototype._evaluateClippingState=function(t){if(this.parent&&this.parent.clipChildren){if(this._currentMeasure.left>t.left+t.width)return void(this._isClipped=!0);if(this._currentMeasure.left+this._currentMeasure.widtht.top+t.height)return void(this._isClipped=!0);if(this._currentMeasure.top+this._currentMeasure.heightthis._currentMeasure.left+this._currentMeasure.width)&&(!(ethis._currentMeasure.top+this._currentMeasure.height)&&(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0))))},t.prototype._processPicking=function(t,e,i,r,n,o,s,a){return!!this._isEnabled&&(!(!this.isHitTestVisible||!this.isVisible||this._doNotRender)&&(!!this.contains(t,e)&&(this._processObservables(r,t,e,i,n,o,s,a),!0)))},t.prototype._onPointerMove=function(t,e,i,r){this.onPointerMoveObservable.notifyObservers(e,-1,t,this,r)&&null!=this.parent&&this.parent._onPointerMove(t,e,i,r)},t.prototype._onPointerEnter=function(t,e){return!!this._isEnabled&&(!(this._enterCount>0)&&(-1===this._enterCount&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,t,this,e)&&null!=this.parent&&this.parent._onPointerEnter(t,e),!0))},t.prototype._onPointerOut=function(t,e,i){if(void 0===i&&(i=!1),i||this._isEnabled&&t!==this){this._enterCount=0;var r=!0;t.isAscendant(this)||(r=this.onPointerOutObservable.notifyObservers(this,-1,t,this,e)),r&&null!=this.parent&&this.parent._onPointerOut(t,e,i)}},t.prototype._onPointerDown=function(t,e,i,r,n){return this._onPointerEnter(this,n),0===this._downCount&&(this._downCount++,this._downPointerIds[i]=!0,this.onPointerDownObservable.notifyObservers(new d(e,r),-1,t,this,n)&&null!=this.parent&&this.parent._onPointerDown(t,e,i,r,n),!0)},t.prototype._onPointerUp=function(t,e,i,r,n,o){if(this._isEnabled){this._downCount=0,delete this._downPointerIds[i];var s=n;n&&(this._enterCount>0||-1===this._enterCount)&&(s=this.onPointerClickObservable.notifyObservers(new d(e,r),-1,t,this,o)),this.onPointerUpObservable.notifyObservers(new d(e,r),-1,t,this,o)&&null!=this.parent&&this.parent._onPointerUp(t,e,i,r,s,o)}},t.prototype._forcePointerUp=function(t){if(void 0===t&&(t=null),null!==t)this._onPointerUp(this,s.Vector2.Zero(),t,0,!0);else for(var e in this._downPointerIds)this._onPointerUp(this,s.Vector2.Zero(),+e,0,!0)},t.prototype._onWheelScroll=function(t,e){this._isEnabled&&(this.onWheelObservable.notifyObservers(new s.Vector2(t,e))&&null!=this.parent&&this.parent._onWheelScroll(t,e))},t.prototype._onCanvasBlur=function(){},t.prototype._processObservables=function(t,e,i,r,n,o,a,h){if(!this._isEnabled)return!1;if(this._dummyVector2.copyFromFloats(e,i),t===s.PointerEventTypes.POINTERMOVE){this._onPointerMove(this,this._dummyVector2,n,r);var l=this._host._lastControlOver[n];return l&&l!==this&&l._onPointerOut(this,r),l!==this&&this._onPointerEnter(this,r),this._host._lastControlOver[n]=this,!0}return t===s.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this,this._dummyVector2,n,o,r),this._host._registerLastControlDown(this,n),this._host._lastPickedControl=this,!0):t===s.PointerEventTypes.POINTERUP?(this._host._lastControlDown[n]&&this._host._lastControlDown[n]._onPointerUp(this,this._dummyVector2,n,o,!0,r),delete this._host._lastControlDown[n],!0):!(t!==s.PointerEventTypes.POINTERWHEEL||!this._host._lastControlOver[n])&&(this._host._lastControlOver[n]._onWheelScroll(a,h),!0)},t.prototype._prepareFont=function(){(this._font||this._fontSet)&&(this._style?this._font=this._style.fontStyle+" "+this._style.fontWeight+" "+this.fontSizeInPixels+"px "+this._style.fontFamily:this._font=this._fontStyle+" "+this._fontWeight+" "+this.fontSizeInPixels+"px "+this._fontFamily,this._fontOffset=t._GetFontOffset(this._font))},t.prototype.dispose=function(){(this.onDirtyObservable.clear(),this.onBeforeDrawObservable.clear(),this.onAfterDrawObservable.clear(),this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this.onWheelObservable.clear(),this._styleObserver&&this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this.parent&&(this.parent.removeControl(this),this.parent=null),this._host)&&(this._host._linkedControls.indexOf(this)>-1&&this.linkWithMesh(null));this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},Object.defineProperty(t,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return t._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return t._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return t._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),Object.defineProperty(t,"VERTICAL_ALIGNMENT_TOP",{get:function(){return t._VERTICAL_ALIGNMENT_TOP},enumerable:!1,configurable:!0}),Object.defineProperty(t,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return t._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!1,configurable:!0}),Object.defineProperty(t,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return t._VERTICAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),t._GetFontOffset=function(e){if(t._FontHeightSizes[e])return t._FontHeightSizes[e];var i=document.createElement("span");i.innerHTML="Hg",i.style.font=e;var r=document.createElement("div");r.style.display="inline-block",r.style.width="1px",r.style.height="0px",r.style.verticalAlign="bottom";var n=document.createElement("div");n.style.whiteSpace="nowrap",n.appendChild(i),n.appendChild(r),document.body.appendChild(n);var o=0,s=0;try{s=r.getBoundingClientRect().top-i.getBoundingClientRect().top,r.style.verticalAlign="baseline",o=r.getBoundingClientRect().top-i.getBoundingClientRect().top}finally{document.body.removeChild(n)}var a={ascent:o,height:s,descent:s-o};return t._FontHeightSizes[e]=a,a},t.drawEllipse=function(t,e,i,r,n){n.translate(t,e),n.scale(i,r),n.beginPath(),n.arc(0,0,1,0,2*Math.PI),n.closePath(),n.scale(1/i,1/r),n.translate(-t,-e)},t.AllowAlphaInheritance=!1,t._ClipMeasure=new _(0,0,0,0),t._HORIZONTAL_ALIGNMENT_LEFT=0,t._HORIZONTAL_ALIGNMENT_RIGHT=1,t._HORIZONTAL_ALIGNMENT_CENTER=2,t._VERTICAL_ALIGNMENT_TOP=0,t._VERTICAL_ALIGNMENT_BOTTOM=1,t._VERTICAL_ALIGNMENT_CENTER=2,t._FontHeightSizes={},t.AddHeader=function(){},t}();s._TypeStore.RegisteredTypes["BABYLON.GUI.Control"]=f;var g=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._children=new Array,i._measureForChildren=_.Empty(),i._background="",i._adaptWidthToChildren=!1,i._adaptHeightToChildren=!1,i.logLayoutCycleErrors=!1,i.maxLayoutCycle=3,i}return n(e,t),Object.defineProperty(e.prototype,"adaptHeightToChildren",{get:function(){return this._adaptHeightToChildren},set:function(t){this._adaptHeightToChildren!==t&&(this._adaptHeightToChildren=t,t&&(this.height="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"adaptWidthToChildren",{get:function(){return this._adaptWidthToChildren},set:function(t){this._adaptWidthToChildren!==t&&(this._adaptWidthToChildren=t,t&&(this.width="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this._children},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Container"},e.prototype._flagDescendantsAsMatrixDirty=function(){for(var t=0,e=this.children;tt.zIndex){this._children.splice(i,0,t),e=!0;break}e||this._children.push(t),t.parent=this,this._markAsDirty()},e.prototype._offsetLeft=function(e){t.prototype._offsetLeft.call(this,e);for(var i=0,r=this._children;i=0&&(r+=this.paddingLeftInPixels+this.paddingRightInPixels,this.width!==r+"px"&&(this.width=r+"px",this._rebuildLayout=!0)),this.adaptHeightToChildren&&n>=0&&(n+=this.paddingTopInPixels+this.paddingBottomInPixels,this.height!==n+"px"&&(this.height=n+"px",this._rebuildLayout=!0)),this._postMeasure()}i++}while(this._rebuildLayout&&i=3&&this.logLayoutCycleErrors&&s.Logger.Error("Layout cycle detected in GUI (Container name="+this.name+", uniqueId="+this.uniqueId+")"),e.restore(),this._isDirty&&(this.invalidateRect(),this._isDirty=!1),!0},e.prototype._postMeasure=function(){},e.prototype._draw=function(t,e){this._localDraw(t),this.clipChildren&&this._clipForChildren(t);for(var i=0,r=this._children;i=0;l--){var u=this._children[l];if(u._processPicking(e,i,r,n,o,s,a,h))return u.hoverCursor&&this._host._changeCursor(u.hoverCursor),!0}return!!this.isHitTestVisible&&this._processObservables(n,e,i,r,o,s,a,h)},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.copyFrom(this._currentMeasure)},e.prototype.dispose=function(){t.prototype.dispose.call(this);for(var e=this.children.length-1;e>=0;e--)this.children[e].dispose()},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.Container"]=g;var m,b=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thickness=1,i._cornerRadius=0,i}return n(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cornerRadius",{get:function(){return this._cornerRadius},set:function(t){t<0&&(t=0),this._cornerRadius!==t&&(this._cornerRadius=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Rectangle"},e.prototype._localDraw=function(t){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._background&&(t.fillStyle=this._background,this._cornerRadius?(this._drawRoundedRect(t,this._thickness/2),t.fill()):t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._thickness&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this.color&&(t.strokeStyle=this.color),t.lineWidth=this._thickness,this._cornerRadius?(this._drawRoundedRect(t,this._thickness/2),t.stroke()):t.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),t.restore()},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},e.prototype._drawRoundedRect=function(t,e){void 0===e&&(e=0);var i=this._currentMeasure.left+e,r=this._currentMeasure.top+e,n=this._currentMeasure.width-2*e,o=this._currentMeasure.height-2*e,s=Math.min(o/2-2,Math.min(n/2-2,this._cornerRadius));t.beginPath(),t.moveTo(i+s,r),t.lineTo(i+n-s,r),t.quadraticCurveTo(i+n,r,i+n,r+s),t.lineTo(i+n,r+o-s),t.quadraticCurveTo(i+n,r+o,i+n-s,r+o),t.lineTo(i+s,r+o),t.quadraticCurveTo(i,r+o,i,r+o-s),t.lineTo(i,r+s),t.quadraticCurveTo(i,r,i+s,r),t.closePath()},e.prototype._clipForChildren=function(t){this._cornerRadius&&(this._drawRoundedRect(t,this._thickness),t.clip())},e}(g);s._TypeStore.RegisteredTypes["BABYLON.GUI.Rectangle"]=b,function(t){t[t.Clip=0]="Clip",t[t.WordWrap=1]="WordWrap",t[t.Ellipsis=2]="Ellipsis"}(m||(m={}));var y=function(t){function e(e,i){void 0===i&&(i="");var r=t.call(this,e)||this;return r.name=e,r._text="",r._textWrapping=m.Clip,r._textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,r._textVerticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,r._resizeToFit=!1,r._lineSpacing=new a(0),r._outlineWidth=0,r._outlineColor="white",r._underline=!1,r._lineThrough=!1,r.onTextChangedObservable=new s.Observable,r.onLinesReadyObservable=new s.Observable,r.text=i,r}return n(e,t),Object.defineProperty(e.prototype,"lines",{get:function(){return this._lines},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"resizeToFit",{get:function(){return this._resizeToFit},set:function(t){this._resizeToFit!==t&&(this._resizeToFit=t,this._resizeToFit&&(this._width.ignoreAdaptiveScaling=!0,this._height.ignoreAdaptiveScaling=!0),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textWrapping",{get:function(){return this._textWrapping},set:function(t){this._textWrapping!==t&&(this._textWrapping=+t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textHorizontalAlignment",{get:function(){return this._textHorizontalAlignment},set:function(t){this._textHorizontalAlignment!==t&&(this._textHorizontalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textVerticalAlignment",{get:function(){return this._textVerticalAlignment},set:function(t){this._textVerticalAlignment!==t&&(this._textVerticalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineSpacing",{get:function(){return this._lineSpacing.toString(this._host)},set:function(t){this._lineSpacing.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outlineWidth",{get:function(){return this._outlineWidth},set:function(t){this._outlineWidth!==t&&(this._outlineWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"underline",{get:function(){return this._underline},set:function(t){this._underline!==t&&(this._underline=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineThrough",{get:function(){return this._lineThrough},set:function(t){this._lineThrough!==t&&(this._lineThrough=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outlineColor",{get:function(){return this._outlineColor},set:function(t){this._outlineColor!==t&&(this._outlineColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"TextBlock"},e.prototype._processMeasures=function(e,i){this._fontOffset||(this._fontOffset=f._GetFontOffset(i.font)),t.prototype._processMeasures.call(this,e,i),this._lines=this._breakLines(this._currentMeasure.width,i),this.onLinesReadyObservable.notifyObservers(this);for(var r=0,n=0;nr&&(r=o.width)}if(this._resizeToFit){if(this._textWrapping===m.Clip){var s=this.paddingLeftInPixels+this.paddingRightInPixels+r|0;s!==this._width.internalValue&&(this._width.updateInPlace(s,a.UNITMODE_PIXEL),this._rebuildLayout=!0)}var h=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*this._lines.length|0;if(this._lines.length>0&&0!==this._lineSpacing.internalValue){var l=0;l=this._lineSpacing.isPixel?this._lineSpacing.getValue(this._host):this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),h+=(this._lines.length-1)*l}h!==this._height.internalValue&&(this._height.updateInPlace(h,a.UNITMODE_PIXEL),this._rebuildLayout=!0)}},e.prototype._drawText=function(t,e,i,r){var n=this._currentMeasure.width,o=0;switch(this._textHorizontalAlignment){case f.HORIZONTAL_ALIGNMENT_LEFT:o=0;break;case f.HORIZONTAL_ALIGNMENT_RIGHT:o=n-e;break;case f.HORIZONTAL_ALIGNMENT_CENTER:o=(n-e)/2}(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(r.shadowColor=this.shadowColor,r.shadowBlur=this.shadowBlur,r.shadowOffsetX=this.shadowOffsetX,r.shadowOffsetY=this.shadowOffsetY),this.outlineWidth&&r.strokeText(t,this._currentMeasure.left+o,i),r.fillText(t,this._currentMeasure.left+o,i),this._underline&&(r.beginPath(),r.lineWidth=Math.round(.05*this.fontSizeInPixels),r.moveTo(this._currentMeasure.left+o,i+3),r.lineTo(this._currentMeasure.left+o+e,i+3),r.stroke(),r.closePath()),this._lineThrough&&(r.beginPath(),r.lineWidth=Math.round(.05*this.fontSizeInPixels),r.moveTo(this._currentMeasure.left+o,i-this.fontSizeInPixels/3),r.lineTo(this._currentMeasure.left+o+e,i-this.fontSizeInPixels/3),r.stroke(),r.closePath())},e.prototype._draw=function(t,e){t.save(),this._applyStates(t),this._renderLines(t),t.restore()},e.prototype._applyStates=function(e){t.prototype._applyStates.call(this,e),this.outlineWidth&&(e.lineWidth=this.outlineWidth,e.strokeStyle=this.outlineColor,e.lineJoin="miter",e.miterLimit=2)},e.prototype._breakLines=function(t,e){var i=[],r=this.text.split("\n");if(this._textWrapping===m.Ellipsis)for(var n=0,o=r;ne&&(t+="…");var n=Array.from&&Array.from(t);if(n)for(;n.length&&r>e;)n.pop(),t=n.join("")+"...",r=i.measureText(t).width;else for(;t.length>2&&r>e;)t=t.slice(0,-2)+"…",r=i.measureText(t).width;return{text:t,width:r}},e.prototype._parseLineWordWrap=function(t,e,i){void 0===t&&(t="");for(var r=[],n=this.wordSplittingFunction?this.wordSplittingFunction(t):t.split(" "),o=0,s=0;s0?t+" "+n[s]:n[0],h=i.measureText(a).width;h>e&&s>0?(r.push({text:t,width:o}),t=n[s],o=i.measureText(t).width):(o=h,t=a)}return r.push({text:t,width:o}),r},e.prototype._renderLines=function(t){var e=this._currentMeasure.height,i=0;switch(this._textVerticalAlignment){case f.VERTICAL_ALIGNMENT_TOP:i=this._fontOffset.ascent;break;case f.VERTICAL_ALIGNMENT_BOTTOM:i=e-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case f.VERTICAL_ALIGNMENT_CENTER:i=this._fontOffset.ascent+(e-this._fontOffset.height*this._lines.length)/2}i+=this._currentMeasure.top;for(var r=0;r0&&0!==this._lineSpacing.internalValue){var r=0;r=this._lineSpacing.isPixel?this._lineSpacing.getValue(this._host):this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),i+=(e.length-1)*r}return i}}return 0},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.onTextChangedObservable.clear()},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.TextBlock"]=y;var v=function(t){function e(i,r){void 0===r&&(r=null);var n=t.call(this,i)||this;return n.name=i,n._workingCanvas=null,n._loaded=!1,n._stretch=e.STRETCH_FILL,n._autoScale=!1,n._sourceLeft=0,n._sourceTop=0,n._sourceWidth=0,n._sourceHeight=0,n._svgAttributesComputationCompleted=!1,n._isSVG=!1,n._cellWidth=0,n._cellHeight=0,n._cellId=-1,n._populateNinePatchSlicesFromImage=!1,n._imageDataCache={data:null,key:""},n.onImageLoadedObservable=new s.Observable,n.onSVGAttributesComputedObservable=new s.Observable,n.source=r,n}return n(e,t),Object.defineProperty(e.prototype,"isLoaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"populateNinePatchSlicesFromImage",{get:function(){return this._populateNinePatchSlicesFromImage},set:function(t){this._populateNinePatchSlicesFromImage!==t&&(this._populateNinePatchSlicesFromImage=t,this._populateNinePatchSlicesFromImage&&this._loaded&&this._extractNinePatchSliceDataFromImage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"detectPointerOnOpaqueOnly",{get:function(){return this._detectPointerOnOpaqueOnly},set:function(t){this._detectPointerOnOpaqueOnly!==t&&(this._detectPointerOnOpaqueOnly=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceLeft",{get:function(){return this._sliceLeft},set:function(t){this._sliceLeft!==t&&(this._sliceLeft=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceRight",{get:function(){return this._sliceRight},set:function(t){this._sliceRight!==t&&(this._sliceRight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceTop",{get:function(){return this._sliceTop},set:function(t){this._sliceTop!==t&&(this._sliceTop=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceBottom",{get:function(){return this._sliceBottom},set:function(t){this._sliceBottom!==t&&(this._sliceBottom=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceLeft",{get:function(){return this._sourceLeft},set:function(t){this._sourceLeft!==t&&(this._sourceLeft=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceTop",{get:function(){return this._sourceTop},set:function(t){this._sourceTop!==t&&(this._sourceTop=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceWidth",{get:function(){return this._sourceWidth},set:function(t){this._sourceWidth!==t&&(this._sourceWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceHeight",{get:function(){return this._sourceHeight},set:function(t){this._sourceHeight!==t&&(this._sourceHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSVG",{get:function(){return this._isSVG},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"svgAttributesComputationCompleted",{get:function(){return this._svgAttributesComputationCompleted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoScale",{get:function(){return this._autoScale},set:function(t){this._autoScale!==t&&(this._autoScale=t,t&&this._loaded&&this.synchronizeSizeWithContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stretch",{get:function(){return this._stretch},set:function(t){this._stretch!==t&&(this._stretch=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._rotate90=function(t,i){void 0===i&&(i=!1);var r=document.createElement("canvas"),n=r.getContext("2d"),o=this._domImage.width,s=this._domImage.height;r.width=s,r.height=o,n.translate(r.width/2,r.height/2),n.rotate(t*Math.PI/2),n.drawImage(this._domImage,0,0,o,s,-o/2,-s/2,o,s);var a=r.toDataURL("image/jpg"),h=new e(this.name+"rotated",a);return i&&(h._stretch=this._stretch,h._autoScale=this._autoScale,h._cellId=this._cellId,h._cellWidth=t%1?this._cellHeight:this._cellWidth,h._cellHeight=t%1?this._cellWidth:this._cellHeight),this._handleRotationForSVGImage(this,h,t),this._imageDataCache.data=null,h},e.prototype._handleRotationForSVGImage=function(t,e,i){var r=this;t._isSVG&&(t._svgAttributesComputationCompleted?(this._rotate90SourceProperties(t,e,i),this._markAsDirty()):t.onSVGAttributesComputedObservable.addOnce((function(){r._rotate90SourceProperties(t,e,i),r._markAsDirty()})))},e.prototype._rotate90SourceProperties=function(t,e,i){var r,n,o=t.sourceLeft,s=t.sourceTop,a=t.domImage.width,h=t.domImage.height,l=o,u=s,c=t.sourceWidth,_=t.sourceHeight;if(0!=i){var d=i<0?-1:1;i%=4;for(var p=0;p127&&-1===this._sliceLeft)this._sliceLeft=o;else if(a<127&&this._sliceLeft>-1){this._sliceRight=o;break}}this._sliceTop=-1,this._sliceBottom=-1;for(var s=0;s127&&-1===this._sliceTop)this._sliceTop=s;else if(a<127&&this._sliceTop>-1){this._sliceBottom=s;break}}},Object.defineProperty(e.prototype,"source",{set:function(t){var e=this;this._source!==t&&(this._loaded=!1,this._source=t,this._imageDataCache.data=null,t&&(t=this._svgCheck(t)),this._domImage=document.createElement("img"),this._domImage.onload=function(){e._onImageLoaded()},t&&(s.Tools.SetCorsBehavior(t,this._domImage),this._domImage.src=t))},enumerable:!1,configurable:!0}),e.prototype._svgCheck=function(t){var e=this;if(window.SVGSVGElement&&-1!==t.search(/.svg#/gi)&&t.indexOf("#")===t.lastIndexOf("#")){this._isSVG=!0;var i=t.split("#")[0],r=t.split("#")[1],n=document.body.querySelector('object[data="'+i+'"]');if(n){var o=n.contentDocument;if(o&&o.documentElement){var s=o.documentElement.getAttribute("viewBox"),a=Number(o.documentElement.getAttribute("width")),h=Number(o.documentElement.getAttribute("height"));if(o.getElementById(r)&&s&&a&&h)return this._getSVGAttribs(n,r),t}n.addEventListener("load",(function(){e._getSVGAttribs(n,r)}))}else{var l=document.createElement("object");l.data=i,l.type="image/svg+xml",l.width="0%",l.height="0%",document.body.appendChild(l),l.onload=function(){var t=document.body.querySelector('object[data="'+i+'"]');t&&e._getSVGAttribs(t,r)}}return i}return t},e.prototype._getSVGAttribs=function(t,e){var i=t.contentDocument;if(i&&i.documentElement){var r=i.documentElement.getAttribute("viewBox"),n=Number(i.documentElement.getAttribute("width")),o=Number(i.documentElement.getAttribute("height")),s=i.getElementById(e);if(r&&n&&o&&s){var a=Number(r.split(" ")[2]),h=Number(r.split(" ")[3]),l=s.getBBox(),u=1,c=1,_=0,d=0;s.transform&&s.transform.baseVal.consolidate()&&(u=s.transform.baseVal.consolidate().matrix.a,c=s.transform.baseVal.consolidate().matrix.d,_=s.transform.baseVal.consolidate().matrix.e,d=s.transform.baseVal.consolidate().matrix.f),this.sourceLeft=(u*l.x+_)*n/a,this.sourceTop=(c*l.y+d)*o/h,this.sourceWidth=l.width*u*(n/a),this.sourceHeight=l.height*c*(o/h),this._svgAttributesComputationCompleted=!0,this.onSVGAttributesComputedObservable.notifyObservers(this)}}},Object.defineProperty(e.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(t){this._cellWidth!==t&&(this._cellWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(t){this._cellHeight!==t&&(this._cellHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellId",{get:function(){return this._cellId},set:function(t){this._cellId!==t&&(this._cellId=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype.contains=function(e,i){if(!t.prototype.contains.call(this,e,i))return!1;if(!this._detectPointerOnOpaqueOnly||!this._workingCanvas)return!0;var r=0|this._currentMeasure.width,n=0|this._currentMeasure.height,o=r+"_"+n,s=this._imageDataCache.data;if(!s||this._imageDataCache.key!==o){var a=this._workingCanvas.getContext("2d");this._imageDataCache.data=s=a.getImageData(0,0,r,n).data,this._imageDataCache.key=o}return s[4*((e=e-this._currentMeasure.left|0)+(i=i-this._currentMeasure.top|0)*r)+3]>0},e.prototype._getTypeName=function(){return"Image"},e.prototype.synchronizeSizeWithContent=function(){this._loaded&&(this.width=this._domImage.width+"px",this.height=this._domImage.height+"px")},e.prototype._processMeasures=function(i,r){if(this._loaded)switch(this._stretch){case e.STRETCH_NONE:case e.STRETCH_FILL:case e.STRETCH_UNIFORM:case e.STRETCH_NINE_PATCH:break;case e.STRETCH_EXTEND:this._autoScale&&this.synchronizeSizeWithContent(),this.parent&&this.parent.parent&&(this.parent.adaptWidthToChildren=!0,this.parent.adaptHeightToChildren=!0)}t.prototype._processMeasures.call(this,i,r)},e.prototype._prepareWorkingCanvasForOpaqueDetection=function(){if(this._detectPointerOnOpaqueOnly){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"));var t=this._workingCanvas,e=this._currentMeasure.width,i=this._currentMeasure.height,r=t.getContext("2d");t.width=e,t.height=i,r.clearRect(0,0,e,i)}},e.prototype._drawImage=function(t,e,i,r,n,o,s,a,h){(t.drawImage(this._domImage,e,i,r,n,o,s,a,h),this._detectPointerOnOpaqueOnly)&&(t=this._workingCanvas.getContext("2d")).drawImage(this._domImage,e,i,r,n,o-this._currentMeasure.left,s-this._currentMeasure.top,a,h)},e.prototype._draw=function(t){var i,r,n,o;if(t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),-1==this.cellId)i=this._sourceLeft,r=this._sourceTop,n=this._sourceWidth?this._sourceWidth:this._imageWidth,o=this._sourceHeight?this._sourceHeight:this._imageHeight;else{var s=this._domImage.naturalWidth/this.cellWidth,a=this.cellId/s>>0,h=this.cellId%s;i=this.cellWidth*h,r=this.cellHeight*a,n=this.cellWidth,o=this.cellHeight}if(this._prepareWorkingCanvasForOpaqueDetection(),this._applyStates(t),this._loaded)switch(this._stretch){case e.STRETCH_NONE:case e.STRETCH_FILL:this._drawImage(t,i,r,n,o,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case e.STRETCH_UNIFORM:var l=this._currentMeasure.width/n,u=this._currentMeasure.height/o,c=Math.min(l,u),_=(this._currentMeasure.width-n*c)/2,d=(this._currentMeasure.height-o*c)/2;this._drawImage(t,i,r,n,o,this._currentMeasure.left+_,this._currentMeasure.top+d,n*c,o*c);break;case e.STRETCH_EXTEND:this._drawImage(t,i,r,n,o,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case e.STRETCH_NINE_PATCH:this._renderNinePatch(t)}t.restore()},e.prototype._renderCornerPatch=function(t,e,i,r,n,o,s){this._drawImage(t,e,i,r,n,this._currentMeasure.left+o,this._currentMeasure.top+s,r,n)},e.prototype._renderNinePatch=function(t){var e=this._imageHeight,i=this._sliceLeft,r=this._sliceTop,n=this._imageHeight-this._sliceBottom,o=this._imageWidth-this._sliceRight,s=0,a=0;this._populateNinePatchSlicesFromImage&&(s=1,a=1,e-=2,i-=1,r-=1,n-=1,o-=1);var h=this._sliceRight-this._sliceLeft,l=this._currentMeasure.width-o-this.sliceLeft,u=this._currentMeasure.height-e+this._sliceBottom;this._renderCornerPatch(t,s,a,i,r,0,0),this._renderCornerPatch(t,s,this._sliceBottom,i,e-this._sliceBottom,0,u),this._renderCornerPatch(t,this._sliceRight,a,o,r,this._currentMeasure.width-o,0),this._renderCornerPatch(t,this._sliceRight,this._sliceBottom,o,e-this._sliceBottom,this._currentMeasure.width-o,u),this._drawImage(t,this._sliceLeft,this._sliceTop,h,this._sliceBottom-this._sliceTop,this._currentMeasure.left+i,this._currentMeasure.top+r,l,u-r),this._drawImage(t,s,this._sliceTop,i,this._sliceBottom-this._sliceTop,this._currentMeasure.left,this._currentMeasure.top+r,i,u-r),this._drawImage(t,this._sliceRight,this._sliceTop,i,this._sliceBottom-this._sliceTop,this._currentMeasure.left+this._currentMeasure.width-o,this._currentMeasure.top+r,i,u-r),this._drawImage(t,this._sliceLeft,a,h,r,this._currentMeasure.left+i,this._currentMeasure.top,l,r),this._drawImage(t,this._sliceLeft,this._sliceBottom,h,n,this._currentMeasure.left+i,this._currentMeasure.top+u,l,n)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.onImageLoadedObservable.clear(),this.onSVGAttributesComputedObservable.clear()},e.STRETCH_NONE=0,e.STRETCH_FILL=1,e.STRETCH_UNIFORM=2,e.STRETCH_EXTEND=3,e.STRETCH_NINE_PATCH=4,e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.Image"]=v;var O=function(t){function e(e){var i=t.call(this,e)||this;i.name=e,i.delegatePickingToChildren=!1,i.thickness=1,i.isPointerBlocker=!0;var r=null;return i.pointerEnterAnimation=function(){r=i.alpha,i.alpha-=.1},i.pointerOutAnimation=function(){null!==r&&(i.alpha=r)},i.pointerDownAnimation=function(){i.scaleX-=.05,i.scaleY-=.05},i.pointerUpAnimation=function(){i.scaleX+=.05,i.scaleY+=.05},i}return n(e,t),Object.defineProperty(e.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textBlock",{get:function(){return this._textBlock},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Button"},e.prototype._processPicking=function(e,i,r,n,o,s,a,h){if(!this._isEnabled||!this.isHitTestVisible||!this.isVisible||this.notRenderable)return!1;if(!t.prototype.contains.call(this,e,i))return!1;if(this.delegatePickingToChildren){for(var l=!1,u=this._children.length-1;u>=0;u--){var c=this._children[u];if(c.isEnabled&&c.isHitTestVisible&&c.isVisible&&!c.notRenderable&&c.contains(e,i)){l=!0;break}}if(!l)return!1}return this._processObservables(n,e,i,r,o,s,a,h),!0},e.prototype._onPointerEnter=function(e,i){return!!t.prototype._onPointerEnter.call(this,e,i)&&(this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},e.prototype._onPointerOut=function(e,i,r){void 0===r&&(r=!1),this.pointerOutAnimation&&this.pointerOutAnimation(),t.prototype._onPointerOut.call(this,e,i,r)},e.prototype._onPointerDown=function(e,i,r,n,o){return!!t.prototype._onPointerDown.call(this,e,i,r,n,o)&&(this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},e.prototype._onPointerUp=function(e,i,r,n,o,s){this.pointerUpAnimation&&this.pointerUpAnimation(),t.prototype._onPointerUp.call(this,e,i,r,n,o,s)},e.CreateImageButton=function(t,i,r){var n=new e(t),o=new y(t+"_button",i);o.textWrapping=!0,o.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,o.paddingLeft="20%",n.addControl(o);var s=new v(t+"_icon",r);return s.width="20%",s.stretch=v.STRETCH_UNIFORM,s.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,n.addControl(s),n._image=s,n._textBlock=o,n},e.CreateImageOnlyButton=function(t,i){var r=new e(t),n=new v(t+"_icon",i);return n.stretch=v.STRETCH_FILL,n.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r.addControl(n),r._image=n,r},e.CreateSimpleButton=function(t,i){var r=new e(t),n=new y(t+"_button",i);return n.textWrapping=!0,n.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,r.addControl(n),r._textBlock=n,r},e.CreateImageWithCenterTextButton=function(t,i,r){var n=new e(t),o=new v(t+"_icon",r);o.stretch=v.STRETCH_FILL,n.addControl(o);var s=new y(t+"_button",i);return s.textWrapping=!0,s.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,n.addControl(s),n._image=o,n._textBlock=s,n},e}(b);s._TypeStore.RegisteredTypes["BABYLON.GUI.Button"]=O;var C=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._isVertical=!0,i._manualWidth=!1,i._manualHeight=!1,i._doNotTrackManualChanges=!1,i.ignoreLayoutWarnings=!1,i}return n(e,t),Object.defineProperty(e.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._doNotTrackManualChanges||(this._manualWidth=!0),this._width.toString(this._host)!==t&&this._width.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._doNotTrackManualChanges||(this._manualHeight=!0),this._height.toString(this._host)!==t&&this._height.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"StackPanel"},e.prototype._preMeasure=function(e,i){for(var r=0,n=this._children;r=0?Math.min(t,this._characters.length):this._characters.length+Math.max(t,-this._characters.length),void 0===e?e=this._characters.length-t:(isNaN(e)||e<0)&&(e=0);for(var i=[];--e>=0;)i[e]=this._characters[t+e];return i.join("")}return this._text.substr(t,e)},t.prototype.substring=function(t,e){if(this._characters){isNaN(t)?t=0:t>this._characters.length?t=this._characters.length:t<0&&(t=0),void 0===e?e=this._characters.length:isNaN(e)?e=0:e>this._characters.length?e=this._characters.length:e<0&&(e=0);for(var i=[],r=0;t0){if(this._isTextHighlightOn)return this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._blinkIsEven=!1,void(i&&i.preventDefault());if(0===this._cursorOffset)this.text=this._textWrapper.substr(0,this._textWrapper.length-1);else(r=this._textWrapper.length-this._cursorOffset)>0&&(this._textWrapper.removePart(r-1,r),this._textHasChanged())}return void(i&&i.preventDefault());case 46:if(this._isTextHighlightOn)return this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,void(i&&i.preventDefault());if(this._textWrapper.text&&this._textWrapper.length>0&&this._cursorOffset>0){var r=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(r,r+1),this._textHasChanged(),this._cursorOffset--}return void(i&&i.preventDefault());case 13:return this._host.focusedControl=null,void(this._isTextHighlightOn=!1);case 35:return this._cursorOffset=0,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 36:return this._cursorOffset=this._textWrapper.length,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 37:if(this._cursorOffset++,this._cursorOffset>this._textWrapper.length&&(this._cursorOffset=this._textWrapper.length),i&&i.shiftKey){if(this._blinkIsEven=!1,i.ctrlKey||i.metaKey){if(!this._isTextHighlightOn){if(this._textWrapper.length===this._cursorOffset)return;this._endHighlightIndex=this._textWrapper.length-this._cursorOffset+1}return this._startHighlightIndex=0,this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=this._textWrapper.length,this._isTextHighlightOn=!0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=0===this._startHighlightIndex?this._textWrapper.length:this._textWrapper.length-this._startHighlightIndex+1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset>=this._textWrapper.length?this._textWrapper.length:this._cursorOffset-1),this._cursorIndexthis._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._isTextHighlightOn=!1),i&&(i.ctrlKey||i.metaKey)&&(this._cursorOffset=this._textWrapper.length,i.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 39:if(this._cursorOffset--,this._cursorOffset<0&&(this._cursorOffset=0),i&&i.shiftKey){if(this._blinkIsEven=!1,i.ctrlKey||i.metaKey){if(!this._isTextHighlightOn){if(0===this._cursorOffset)return;this._startHighlightIndex=this._textWrapper.length-this._cursorOffset-1}return this._endHighlightIndex=this._textWrapper.length,this._isTextHighlightOn=!0,this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=this._textWrapper.length===this._endHighlightIndex?0:this._textWrapper.length-this._endHighlightIndex-1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset<=0?0:this._cursorOffset+1),this._cursorIndexthis._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._endHighlightIndex,this._isTextHighlightOn=!1),i&&(i.ctrlKey||i.metaKey)&&(this._cursorOffset=0,i.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 222:i&&i.preventDefault(),this._cursorIndex=-1,this.deadKey=!0}if(e&&(-1===t||32===t||t>47&&t<64||t>64&&t<91||t>159&&t<193||t>218&&t<223||t>95&&t<112)&&(this._currentKey=e,this.onBeforeKeyAddObservable.notifyObservers(this),e=this._currentKey,this._addKey))if(this._isTextHighlightOn)this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex,e),this._textHasChanged(),this._cursorOffset=this._textWrapper.length-(this._startHighlightIndex+1),this._isTextHighlightOn=!1,this._blinkIsEven=!1,this._markAsDirty();else if(0===this._cursorOffset)this.text+=e;else{var n=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(n,n,e),this._textHasChanged()}}},e.prototype._updateValueFromCursorIndex=function(t){if(this._blinkIsEven=!1,-1===this._cursorIndex)this._cursorIndex=t;else if(this._cursorIndexthis._cursorOffset))return this._isTextHighlightOn=!1,void this._markAsDirty();this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex}this._isTextHighlightOn=!0,this._markAsDirty()},e.prototype._processDblClick=function(t){var e,i;this._startHighlightIndex=this._textWrapper.length-this._cursorOffset,this._endHighlightIndex=this._startHighlightIndex;do{i=this._endHighlightIndex0&&this._textWrapper.isWord(this._startHighlightIndex-1)?--this._startHighlightIndex:0}while(e||i);this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this.onTextHighlightObservable.notifyObservers(this),this._isTextHighlightOn=!0,this._clickedCoordinate=null,this._blinkIsEven=!0,this._cursorIndex=-1,this._markAsDirty()},e.prototype._selectAllText=function(){this._blinkIsEven=!0,this._isTextHighlightOn=!0,this._startHighlightIndex=0,this._endHighlightIndex=this._textWrapper.length,this._cursorOffset=this._textWrapper.length,this._cursorIndex=-1,this._markAsDirty()},e.prototype.processKeyboard=function(t){this.processKey(t.keyCode,t.key,t),this.onKeyboardEventProcessedObservable.notifyObservers(t)},e.prototype._onCopyText=function(t){this._isTextHighlightOn=!1;try{t.clipboardData&&t.clipboardData.setData("text/plain",this._highlightedText)}catch(t){}this._host.clipboardData=this._highlightedText},e.prototype._onCutText=function(t){if(this._highlightedText){this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex;try{t.clipboardData&&t.clipboardData.setData("text/plain",this._highlightedText)}catch(t){}this._host.clipboardData=this._highlightedText,this._highlightedText=""}},e.prototype._onPasteText=function(t){var e="";e=t.clipboardData&&-1!==t.clipboardData.types.indexOf("text/plain")?t.clipboardData.getData("text/plain"):this._host.clipboardData;var i=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(i,i,e),this._textHasChanged()},e.prototype._draw=function(t,e){var i=this;t.save(),this._applyStates(t),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._isFocused?this._focusedBackground&&(t.fillStyle=this._isEnabled?this._focusedBackground:this._disabledColor,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)):this._background&&(t.fillStyle=this._isEnabled?this._background:this._disabledColor,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._fontOffset||(this._fontOffset=f._GetFontOffset(t.font));var r=this._currentMeasure.left+this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this.color&&(t.fillStyle=this.color);var n=this._beforeRenderText(this._textWrapper);this._isFocused||this._textWrapper.text||!this._placeholderText||((n=new w).text=this._placeholderText,this._placeholderColor&&(t.fillStyle=this._placeholderColor)),this._textWidth=t.measureText(n.text).width;var o=2*this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this._autoStretchWidth&&(this.width=Math.min(this._maxWidth.getValueInPixel(this._host,this._tempParentMeasure.width),this._textWidth+o)+"px");var s=this._fontOffset.ascent+(this._currentMeasure.height-this._fontOffset.height)/2,a=this._width.getValueInPixel(this._host,this._tempParentMeasure.width)-o;if(t.save(),t.beginPath(),t.rect(r,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,a+2,this._currentMeasure.height),t.clip(),this._isFocused&&this._textWidth>a){var h=r-this._textWidth+a;this._scrollLeft||(this._scrollLeft=h)}else this._scrollLeft=r;if(t.fillText(n.text,this._scrollLeft,this._currentMeasure.top+s),this._isFocused){if(this._clickedCoordinate){var l=this._scrollLeft+this._textWidth-this._clickedCoordinate,u=0;this._cursorOffset=0;var c=0;do{this._cursorOffset&&(c=Math.abs(l-u)),this._cursorOffset++,u=t.measureText(n.substr(n.length-this._cursorOffset,this._cursorOffset)).width}while(u=this._cursorOffset);Math.abs(l-u)>c&&this._cursorOffset--,this._blinkIsEven=!1,this._clickedCoordinate=null}if(!this._blinkIsEven){var _=n.substr(n.length-this._cursorOffset),d=t.measureText(_).width,p=this._scrollLeft+this._textWidth-d;pr+a&&(this._scrollLeft+=r+a-p,p=r+a,this._markAsDirty()),this._isTextHighlightOn||t.fillRect(p,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,2,this._fontOffset.height)}if(clearTimeout(this._blinkTimeout),this._blinkTimeout=setTimeout((function(){i._blinkIsEven=!i._blinkIsEven,i._markAsDirty()}),500),this._isTextHighlightOn){clearTimeout(this._blinkTimeout);var g=t.measureText(n.substring(this._startHighlightIndex)).width,m=this._scrollLeft+this._textWidth-g;this._highlightedText=n.substring(this._startHighlightIndex,this._endHighlightIndex);var b=t.measureText(n.substring(this._startHighlightIndex,this._endHighlightIndex)).width;m=this._rowDefinitions.length?null:this._rowDefinitions[t]},e.prototype.getColumnDefinition=function(t){return t<0||t>=this._columnDefinitions.length?null:this._columnDefinitions[t]},e.prototype.addRowDefinition=function(t,e){return void 0===e&&(e=!1),this._rowDefinitions.push(new a(t,e?a.UNITMODE_PIXEL:a.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},e.prototype.addColumnDefinition=function(t,e){return void 0===e&&(e=!1),this._columnDefinitions.push(new a(t,e?a.UNITMODE_PIXEL:a.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},e.prototype.setRowDefinition=function(t,e,i){if(void 0===i&&(i=!1),t<0||t>=this._rowDefinitions.length)return this;var r=this._rowDefinitions[t];return r&&r.isPixel===i&&r.internalValue===e||(this._rowDefinitions[t]=new a(e,i?a.UNITMODE_PIXEL:a.UNITMODE_PERCENTAGE),this._markAsDirty()),this},e.prototype.setColumnDefinition=function(t,e,i){if(void 0===i&&(i=!1),t<0||t>=this._columnDefinitions.length)return this;var r=this._columnDefinitions[t];return r&&r.isPixel===i&&r.internalValue===e||(this._columnDefinitions[t]=new a(e,i?a.UNITMODE_PIXEL:a.UNITMODE_PERCENTAGE),this._markAsDirty()),this},e.prototype.getChildrenAt=function(t,e){var i=this._cells[t+":"+e];return i?i.children:null},e.prototype.getChildCellInfo=function(t){return t._tag},e.prototype._removeCell=function(e,i){if(e){t.prototype.removeControl.call(this,e);for(var r=0,n=e.children;r=this._columnDefinitions.length)return this;for(var e=0;e=this._rowDefinitions.length)return this;for(var e=0;e=1-e._Epsilon&&(this._value.r=1),this._value.g>=1-e._Epsilon&&(this._value.g=1),this._value.b>=1-e._Epsilon&&(this._value.b=1),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._width.toString(this._host)!==t&&this._width.fromString(t)&&(this._height.fromString(t),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._height.toString(this._host)!==t&&this._height.fromString(t)&&(this._width.fromString(t),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.width},set:function(t){this.width=t},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"ColorPicker"},e.prototype._preMeasure=function(t,e){t.widthh||d150?.04:-.16*(t-50)/100+.2;var b=(p-l)/(t-l);o[g+3]=b1-m?255*(1-(b-(1-m))/m):255}}return r.putImageData(n,0,0),i},e.prototype._draw=function(t){t.save(),this._applyStates(t);var e=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),i=.2*e,r=this._currentMeasure.left,n=this._currentMeasure.top;this._colorWheelCanvas&&this._colorWheelCanvas.width==2*e||(this._colorWheelCanvas=this._createColorWheelCanvas(e,i)),this._updateSquareProps(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.fillRect(this._squareLeft,this._squareTop,this._squareSize,this._squareSize)),t.drawImage(this._colorWheelCanvas,r,n),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._drawGradientSquare(this._h,this._squareLeft,this._squareTop,this._squareSize,this._squareSize,t);var o=this._squareLeft+this._squareSize*this._s,s=this._squareTop+this._squareSize*(1-this._v);this._drawCircle(o,s,.04*e,t);var a=e-.5*i;o=r+e+Math.cos((this._h-180)*Math.PI/180)*a,s=n+e+Math.sin((this._h-180)*Math.PI/180)*a,this._drawCircle(o,s,.35*i,t),t.restore()},e.prototype._updateValueFromPointer=function(t,i){if(this._pointerStartedOnWheel){var r=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),n=r+this._currentMeasure.left,o=r+this._currentMeasure.top;this._h=180*Math.atan2(i-o,t-n)/Math.PI+180}else this._pointerStartedOnSquare&&(this._updateSquareProps(),this._s=(t-this._squareLeft)/this._squareSize,this._v=1-(i-this._squareTop)/this._squareSize,this._s=Math.min(this._s,1),this._s=Math.max(this._s,e._Epsilon),this._v=Math.min(this._v,1),this._v=Math.max(this._v,e._Epsilon));s.Color3.HSVtoRGBToRef(this._h,this._s,this._v,this._tmpColor),this.value=this._tmpColor},e.prototype._isPointOnSquare=function(t,e){this._updateSquareProps();var i=this._squareLeft,r=this._squareTop,n=this._squareSize;return t>=i&&t<=i+n&&e>=r&&e<=r+n},e.prototype._isPointOnWheel=function(t,e){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=i-.2*i,n=t-(i+this._currentMeasure.left),o=e-(i+this._currentMeasure.top),s=n*n+o*o;return s<=i*i&&s>=r*r},e.prototype._onPointerDown=function(e,i,r,n,o){if(!t.prototype._onPointerDown.call(this,e,i,r,n,o))return!1;this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var s=this._transformedPosition.x,a=this._transformedPosition.y;return this._isPointOnSquare(s,a)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(s,a)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(s,a),this._host._capturingControl[r]=this,this._lastPointerDownID=r,!0},e.prototype._onPointerMove=function(e,i,r,n){if(r==this._lastPointerDownID){this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var o=this._transformedPosition.x,s=this._transformedPosition.y;this._pointerIsDown&&this._updateValueFromPointer(o,s),t.prototype._onPointerMove.call(this,e,i,r,n)}},e.prototype._onPointerUp=function(e,i,r,n,o,s){this._pointerIsDown=!1,delete this._host._capturingControl[r],t.prototype._onPointerUp.call(this,e,i,r,n,o,s)},e.prototype._onCanvasBlur=function(){this._forcePointerUp(),t.prototype._onCanvasBlur.call(this)},e.ShowPickerDialogAsync=function(t,i){return new Promise((function(r,n){i.pickerWidth=i.pickerWidth||"640px",i.pickerHeight=i.pickerHeight||"400px",i.headerHeight=i.headerHeight||"35px",i.lastColor=i.lastColor||"#000000",i.swatchLimit=i.swatchLimit||20,i.numSwatchesPerLine=i.numSwatchesPerLine||10;var o,a,h,l,u,c,_,d,p,g,m,v,C,T,w,M,I,k,A,S=i.swatchLimit/i.numSwatchesPerLine,E=parseFloat(i.pickerWidth)/i.numSwatchesPerLine,D=Math.floor(.25*E),L=D*(i.numSwatchesPerLine+1),R=Math.floor((parseFloat(i.pickerWidth)-L)/i.numSwatchesPerLine),B=R*S+D*(S+1),N=(parseInt(i.pickerHeight)+B+Math.floor(.25*R)).toString()+"px",H=s.Color3.FromHexString("#dddddd"),V=H.r+H.g+H.b,W=["R","G","B"],F=!1;function j(t,e){A=e;var i=t.toHexString();if(I.background=i,g.name!=A&&(g.text=Math.floor(255*t.r).toString()),m.name!=A&&(m.text=Math.floor(255*t.g).toString()),v.name!=A&&(v.text=Math.floor(255*t.b).toString()),C.name!=A&&(C.text=t.r.toString()),T.name!=A&&(T.text=t.g.toString()),w.name!=A&&(w.text=t.b.toString()),M.name!=A){var r=i.split("#");M.text=r[1]}p.name!=A&&(p.value=t)}function z(t,e){var i=t.text;if(/[^0-9]/g.test(i))t.text=k;else if(""!=i&&(Math.floor(parseInt(i))<0?i="0":Math.floor(parseInt(i))>255?i="255":isNaN(parseInt(i))&&(i="0")),A==t.name&&(k=i),""!=i){i=parseInt(i).toString(),t.text=i;var r=s.Color3.FromHexString(I.background);A==t.name&&j("r"==e?new s.Color3(parseInt(i)/255,r.g,r.b):"g"==e?new s.Color3(r.r,parseInt(i)/255,r.b):new s.Color3(r.r,r.g,parseInt(i)/255),t.name)}}function G(t,e){var i=t.text;if(/[^0-9\.]/g.test(i))t.text=k;else{""!=i&&"."!=i&&0!=parseFloat(i)&&(parseFloat(i)<0?i="0.0":parseFloat(i)>1?i="1.0":isNaN(parseFloat(i))&&(i="0.0")),A==t.name&&(k=i),""!=i&&"."!=i&&0!=parseFloat(i)?(i=parseFloat(i).toString(),t.text=i):i="0.0";var r=s.Color3.FromHexString(I.background);A==t.name&&j("r"==e?new s.Color3(parseFloat(i),r.g,r.b):"g"==e?new s.Color3(r.r,parseFloat(i),r.b):new s.Color3(r.r,r.g,parseFloat(i)),t.name)}}function X(){if(i.savedColors&&i.savedColors[_]){if(F)var t="b";else t="";var e=O.CreateSimpleButton("Swatch_"+_,t);e.fontFamily="BabylonJSglyphs";var r=s.Color3.FromHexString(i.savedColors[_]),n=r.r+r.g+r.b;e.color=n>V?"#aaaaaa":"#ffffff",e.fontSize=Math.floor(.7*R),e.textBlock.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,e.height=e.width=R.toString()+"px",e.background=i.savedColors[_],e.thickness=2;var o=_;return e.pointerDownAnimation=function(){e.thickness=4},e.pointerUpAnimation=function(){e.thickness=3},e.pointerEnterAnimation=function(){e.thickness=3},e.pointerOutAnimation=function(){e.thickness=2},e.onPointerClickObservable.add((function(){var t;F?(t=o,i.savedColors&&i.savedColors.splice(t,1),i.savedColors&&0==i.savedColors.length&&(q(!1),F=!1),Y("",It)):i.savedColors&&j(s.Color3.FromHexString(i.savedColors[o]),e.name)})),e}return null}function U(t){if(void 0!==t&&(F=t),F){for(var e=0;eh*i.numSwatchesPerLine)var l=i.numSwatchesPerLine;else l=i.savedColors.length-(h-1)*i.numSwatchesPerLine;for(var u=Math.min(Math.max(l,0),i.numSwatchesPerLine),c=0,p=1;ci.numSwatchesPerLine)){var f=X();null!=f&&(d.addControl(f,a,p),p+=2,_++)}}i.savedColors.length>=i.swatchLimit?K(e,!0):K(e,!1)}}function q(t){t?((h=O.CreateSimpleButton("butEdit","Edit")).width=l,h.height=u,h.left=Math.floor(.1*parseInt(l)).toString()+"px",h.top=(-1*parseFloat(h.left)).toString()+"px",h.verticalAlignment=f.VERTICAL_ALIGNMENT_BOTTOM,h.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,h.thickness=2,h.color="#c0c0c0",h.fontSize=a,h.background="#535353",h.onPointerEnterObservable.add((function(){h.background="#414141"})),h.onPointerOutObservable.add((function(){h.background="#535353"})),h.pointerDownAnimation=function(){h.background="515151"},h.pointerUpAnimation=function(){h.background="#414141"},h.onPointerClickObservable.add((function(){F=!F,U()})),ut.addControl(h,1,0)):ut.removeControl(h)}function K(t,e){e?(t.color="#555555",t.background="#454545"):(t.color="#c0c0c0",t.background="#535353")}function Z(e){i.savedColors&&i.savedColors.length>0?r({savedColors:i.savedColors,pickedColor:e}):r({pickedColor:e}),t.removeControl(J)}var J=new P;if(J.name="Dialog Container",J.width=i.pickerWidth,i.savedColors){J.height=N;var Q=parseInt(i.pickerHeight)/parseInt(N);J.addRowDefinition(Q,!1),J.addRowDefinition(1-Q,!1)}else J.height=i.pickerHeight,J.addRowDefinition(1,!1);if(t.addControl(J),i.savedColors){(d=new P).name="Swatch Drawer",d.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,d.background="#535353",d.width=i.pickerWidth;var $=i.savedColors.length/i.numSwatchesPerLine;if(0==$)var tt=0;else tt=$+1;d.height=(R*$+tt*D).toString()+"px",d.top=Math.floor(.25*R).toString()+"px";for(var et=0;et<2*Math.ceil(i.savedColors.length/i.numSwatchesPerLine)+1;et++)et%2!=0?d.addRowDefinition(R,!0):d.addRowDefinition(D,!0);for(et=0;et<2*i.numSwatchesPerLine+1;et++)et%2!=0?d.addColumnDefinition(R,!0):d.addColumnDefinition(D,!0);J.addControl(d,1,0)}var it=new P;it.name="Picker Panel",it.height=i.pickerHeight;var rt=parseInt(i.headerHeight)/parseInt(i.pickerHeight),nt=[rt,1-rt];it.addRowDefinition(nt[0],!1),it.addRowDefinition(nt[1],!1),J.addControl(it,0,0);var ot=new b;ot.name="Dialogue Header Bar",ot.background="#cccccc",ot.thickness=0,it.addControl(ot,0,0);var st=O.CreateSimpleButton("closeButton","a");st.fontFamily="BabylonJSglyphs";var at=s.Color3.FromHexString(ot.background);o=new s.Color3(1-at.r,1-at.g,1-at.b),st.color=o.toHexString(),st.fontSize=Math.floor(.6*parseInt(i.headerHeight)),st.textBlock.textVerticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,st.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_RIGHT,st.height=st.width=i.headerHeight,st.background=ot.background,st.thickness=0,st.pointerDownAnimation=function(){},st.pointerUpAnimation=function(){st.background=ot.background},st.pointerEnterAnimation=function(){st.color=ot.background,st.background="red"},st.pointerOutAnimation=function(){st.color=o.toHexString(),st.background=ot.background},st.onPointerClickObservable.add((function(){Z(Ct.background)})),it.addControl(st,0,0);var ht=new P;ht.name="Dialogue Body",ht.background="#535353";var lt=[.4375,.5625];ht.addRowDefinition(1,!1),ht.addColumnDefinition(lt[0],!1),ht.addColumnDefinition(lt[1],!1),it.addControl(ht,1,0);var ut=new P;ut.name="Picker Grid",ut.addRowDefinition(.85,!1),ut.addRowDefinition(.15,!1),ht.addControl(ut,0,0),(p=new e).name="GUI Color Picker",i.pickerHeighti.pickerHeight)var vt=yt;else vt=bt;var Ot=new y;Ot.text="new",Ot.name="New Color Label",Ot.color="#c0c0c0",Ot.fontSize=vt,ft.addControl(Ot,1,0),(I=new b).name="New Color Swatch",I.background=i.lastColor,I.thickness=0,mt.addControl(I,0,0);var Ct=O.CreateSimpleButton("currentSwatch","");Ct.background=i.lastColor,Ct.thickness=0,Ct.onPointerClickObservable.add((function(){j(s.Color3.FromHexString(Ct.background),Ct.name),U(!1)})),Ct.pointerDownAnimation=function(){},Ct.pointerUpAnimation=function(){},Ct.pointerEnterAnimation=function(){},Ct.pointerOutAnimation=function(){},mt.addControl(Ct,1,0);var Tt=new b;Tt.name="Swatch Outline",Tt.width=.67,Tt.thickness=2,Tt.color="#404040",Tt.isHitTestVisible=!1,ft.addControl(Tt,2,0);var wt=new y;wt.name="Current Color Label",wt.text="current",wt.color="#c0c0c0",wt.fontSize=vt,ft.addControl(wt,3,0);var xt=new P;xt.name="Button Grid",xt.height=.8;xt.addRowDefinition(1/3,!1),xt.addRowDefinition(1/3,!1),xt.addRowDefinition(1/3,!1),dt.addControl(xt,0,1),l=Math.floor(parseInt(i.pickerWidth)*lt[1]*pt[1]*.67).toString()+"px",u=Math.floor(parseInt(i.pickerHeight)*nt[1]*_t[0]*(parseFloat(xt.height.toString())/100)*(1/3)*.7).toString()+"px",a=parseFloat(l)>parseFloat(u)?Math.floor(.45*parseFloat(u)):Math.floor(.11*parseFloat(l));var Pt=O.CreateSimpleButton("butOK","OK");Pt.width=l,Pt.height=u,Pt.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,Pt.thickness=2,Pt.color="#c0c0c0",Pt.fontSize=a,Pt.background="#535353",Pt.onPointerEnterObservable.add((function(){Pt.background="#414141"})),Pt.onPointerOutObservable.add((function(){Pt.background="#535353"})),Pt.pointerDownAnimation=function(){Pt.background="515151"},Pt.pointerUpAnimation=function(){Pt.background="#414141"},Pt.onPointerClickObservable.add((function(){U(!1),Z(I.background)})),xt.addControl(Pt,0,0);var Mt=O.CreateSimpleButton("butCancel","Cancel");if(Mt.width=l,Mt.height=u,Mt.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,Mt.thickness=2,Mt.color="#c0c0c0",Mt.fontSize=a,Mt.background="#535353",Mt.onPointerEnterObservable.add((function(){Mt.background="#414141"})),Mt.onPointerOutObservable.add((function(){Mt.background="#535353"})),Mt.pointerDownAnimation=function(){Mt.background="515151"},Mt.pointerUpAnimation=function(){Mt.background="#414141"},Mt.onPointerClickObservable.add((function(){U(!1),Z(Ct.background)})),xt.addControl(Mt,1,0),i.savedColors){var It=O.CreateSimpleButton("butSave","Save");It.width=l,It.height=u,It.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,It.thickness=2,It.fontSize=a,i.savedColors.length0&&q(!0),xt.addControl(It,2,0)}var kt=new P;kt.name="Dialog Lower Right",kt.addRowDefinition(.02,!1),kt.addRowDefinition(.63,!1),kt.addRowDefinition(.21,!1),kt.addRowDefinition(.14,!1),ct.addControl(kt,1,0),c=s.Color3.FromHexString(i.lastColor);var At=new P;At.name="RGB Values",At.width=.82,At.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,At.addRowDefinition(1/3,!1),At.addRowDefinition(1/3,!1),At.addRowDefinition(1/3,!1),At.addColumnDefinition(.1,!1),At.addColumnDefinition(.2,!1),At.addColumnDefinition(.7,!1),kt.addControl(At,1,0);for(et=0;et6||e)&&A==M.name)M.text=k;else{if(M.text.length<6)for(var i=6-M.text.length,r=0;r0&&Y("",It)}))},e._Epsilon=1e-6,e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.ColorPicker"]=M;var I=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thickness=1,i}return n(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Ellipse"},e.prototype._localDraw=function(t){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),f.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,t),this._background&&(t.fillStyle=this._background,t.fill()),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._thickness&&(this.color&&(t.strokeStyle=this.color),t.lineWidth=this._thickness,t.stroke()),t.restore()},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},e.prototype._clipForChildren=function(t){f.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2,this._currentMeasure.height/2,t),t.clip()},e}(g);s._TypeStore.RegisteredTypes["BABYLON.GUI.Ellipse"]=I;var k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._beforeRenderText=function(t){for(var e=new w,i="",r=0;r1?this.notRenderable=!0:this.notRenderable=!1}else s.Tools.Error("Cannot move a control to a vector3 if the control is not at root level")},e.prototype._moveToProjectedPosition=function(t,e){void 0===e&&(e=!1);var i=t.x+this._linkOffsetX.getValue(this._host)+"px",r=t.y+this._linkOffsetY.getValue(this._host)+"px";e?(this.x2=i,this.y2=r,this._x2.ignoreAdaptiveScaling=!0,this._y2.ignoreAdaptiveScaling=!0):(this.x1=i,this.y1=r,this._x1.ignoreAdaptiveScaling=!0,this._y1.ignoreAdaptiveScaling=!0)},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.Line"]=A;var S=function(){function t(t){this._multiLine=t,this._x=new a(0),this._y=new a(0),this._point=new s.Vector3(0,0,0)}return Object.defineProperty(t.prototype,"x",{get:function(){return this._x.toString(this._multiLine._host)},set:function(t){this._x.toString(this._multiLine._host)!==t&&this._x.fromString(t)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y.toString(this._multiLine._host)},set:function(t){this._y.toString(this._multiLine._host)!==t&&this._y.fromString(t)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"control",{get:function(){return this._control},set:function(t){this._control!==t&&(this._control&&this._controlObserver&&(this._control.onDirtyObservable.remove(this._controlObserver),this._controlObserver=null),this._control=t,this._control&&(this._controlObserver=this._control.onDirtyObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh&&this._meshObserver&&this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver),this._mesh=t,this._mesh&&(this._meshObserver=this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype.resetLinks=function(){this.control=null,this.mesh=null},t.prototype.translate=function(){return this._point=this._translatePoint(),this._point},t.prototype._translatePoint=function(){if(null!=this._mesh)return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center,this._mesh.getWorldMatrix());if(null!=this._control)return new s.Vector3(this._control.centerX,this._control.centerY,1-s.Epsilon);var t=this._multiLine._host,e=this._x.getValueInPixel(t,Number(t._canvas.width)),i=this._y.getValueInPixel(t,Number(t._canvas.height));return new s.Vector3(e,i,1-s.Epsilon)},t.prototype.dispose=function(){this.resetLinks()},t}(),E=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._lineWidth=1,i.onPointUpdate=function(){i._markAsDirty()},i._automaticSize=!0,i.isHitTestVisible=!1,i._horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,i._dash=[],i._points=[],i}return n(e,t),Object.defineProperty(e.prototype,"dash",{get:function(){return this._dash},set:function(t){this._dash!==t&&(this._dash=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype.getAt=function(t){return this._points[t]||(this._points[t]=new S(this)),this._points[t]},e.prototype.add=function(){for(var t=this,e=[],i=0;i0;)this.remove(this._points.length-1)},e.prototype.resetLinks=function(){this._points.forEach((function(t){null!=t&&t.resetLinks()}))},Object.defineProperty(e.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(t){this._lineWidth!==t&&(this._lineWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"MultiLine"},e.prototype._draw=function(t,e){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._applyStates(t),t.strokeStyle=this.color,t.lineWidth=this._lineWidth,t.setLineDash(this._dash),t.beginPath();var i,r=!0;this._points.forEach((function(e){e&&(r?(t.moveTo(e._point.x,e._point.y),r=!1):e._point.z<1&&i.z<1?t.lineTo(e._point.x,e._point.y):t.moveTo(e._point.x,e._point.y),i=e._point)})),t.stroke(),t.restore()},e.prototype._additionalProcessing=function(t,e){var i=this;this._minX=null,this._minY=null,this._maxX=null,this._maxY=null,this._points.forEach((function(t,e){t&&(t.translate(),(null==i._minX||t._point.xi._maxX)&&(i._maxX=t._point.x),(null==i._maxY||t._point.y>i._maxY)&&(i._maxY=t._point.y))})),null==this._minX&&(this._minX=0),null==this._minY&&(this._minY=0),null==this._maxX&&(this._maxX=0),null==this._maxY&&(this._maxY=0)},e.prototype._measure=function(){null!=this._minX&&null!=this._maxX&&null!=this._minY&&null!=this._maxY&&(this._currentMeasure.width=Math.abs(this._maxX-this._minX)+this._lineWidth,this._currentMeasure.height=Math.abs(this._maxY-this._minY)+this._lineWidth)},e.prototype._computeAlignment=function(t,e){null!=this._minX&&null!=this._minY&&(this._currentMeasure.left=this._minX-this._lineWidth/2,this._currentMeasure.top=this._minY-this._lineWidth/2)},e.prototype.dispose=function(){this.reset(),t.prototype.dispose.call(this)},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.MultiLine"]=E;var D=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._isChecked=!1,i._background="black",i._checkSizeRatio=.8,i._thickness=1,i.group="",i.onIsCheckedChangedObservable=new s.Observable,i.isPointerBlocker=!0,i}return n(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(t){t=Math.max(Math.min(1,t),0),this._checkSizeRatio!==t&&(this._checkSizeRatio=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isChecked",{get:function(){return this._isChecked},set:function(t){var e=this;this._isChecked!==t&&(this._isChecked=t,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(t),this._isChecked&&this._host&&this._host.executeOnAllControls((function(t){if(t!==e&&void 0!==t.group){var i=t;i.group===e.group&&(i.isChecked=!1)}})))},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"RadioButton"},e.prototype._draw=function(t){t.save(),this._applyStates(t);var e=this._currentMeasure.width-this._thickness,i=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),f.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,t),t.fillStyle=this._isEnabled?this._background:this._disabledColor,t.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=this.color,t.lineWidth=this._thickness,t.stroke(),this._isChecked){t.fillStyle=this._isEnabled?this.color:this._disabledColor;var r=e*this._checkSizeRatio,n=i*this._checkSizeRatio;f.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,r/2-this._thickness/2,n/2-this._thickness/2,t),t.fill()}t.restore()},e.prototype._onPointerDown=function(e,i,r,n,o){return!!t.prototype._onPointerDown.call(this,e,i,r,n,o)&&(this.isChecked||(this.isChecked=!0),!0)},e.AddRadioButtonWithHeader=function(t,i,r,n){var o=new C;o.isVertical=!1,o.height="30px";var s=new e;s.width="20px",s.height="20px",s.isChecked=r,s.color="green",s.group=i,s.onIsCheckedChangedObservable.add((function(t){return n(s,t)})),o.addControl(s);var a=new y;return a.text=t,a.width="180px",a.paddingLeft="5px",a.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,a.color="white",o.addControl(a),o},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.RadioButton"]=D;var L=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thumbWidth=new a(20,a.UNITMODE_PIXEL,!1),i._minimum=0,i._maximum=100,i._value=50,i._isVertical=!1,i._barOffset=new a(5,a.UNITMODE_PIXEL,!1),i._isThumbClamped=!1,i._displayThumb=!0,i._step=0,i._lastPointerDownID=-1,i._effectiveBarOffset=0,i.onValueChangedObservable=new s.Observable,i._pointerIsDown=!1,i.isPointerBlocker=!0,i}return n(e,t),Object.defineProperty(e.prototype,"displayThumb",{get:function(){return this._displayThumb},set:function(t){this._displayThumb!==t&&(this._displayThumb=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"step",{get:function(){return this._step},set:function(t){this._step!==t&&(this._step=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barOffset",{get:function(){return this._barOffset.toString(this._host)},set:function(t){this._barOffset.toString(this._host)!==t&&this._barOffset.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barOffsetInPixels",{get:function(){return this._barOffset.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbWidth",{get:function(){return this._thumbWidth.toString(this._host)},set:function(t){this._thumbWidth.toString(this._host)!==t&&this._thumbWidth.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbWidthInPixels",{get:function(){return this._thumbWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minimum",{get:function(){return this._minimum},set:function(t){this._minimum!==t&&(this._minimum=t,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this._maximum},set:function(t){this._maximum!==t&&(this._maximum=t,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(t){t=Math.max(Math.min(t,this._maximum),this._minimum),this._value!==t&&(this._value=t,this._markAsDirty(),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isThumbClamped",{get:function(){return this._isThumbClamped},set:function(t){this._isThumbClamped!==t&&(this._isThumbClamped=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"BaseSlider"},e.prototype._getThumbPosition=function(){return this.isVertical?(this.maximum-this.value)/(this.maximum-this.minimum)*this._backgroundBoxLength:(this.value-this.minimum)/(this.maximum-this.minimum)*this._backgroundBoxLength},e.prototype._getThumbThickness=function(t){var e=0;switch(t){case"circle":e=this._thumbWidth.isPixel?Math.max(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host);break;case"rectangle":e=this._thumbWidth.isPixel?Math.min(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)}return e},e.prototype._prepareRenderingData=function(t){this._effectiveBarOffset=0,this._renderLeft=this._currentMeasure.left,this._renderTop=this._currentMeasure.top,this._renderWidth=this._currentMeasure.width,this._renderHeight=this._currentMeasure.height,this._backgroundBoxLength=Math.max(this._currentMeasure.width,this._currentMeasure.height),this._backgroundBoxThickness=Math.min(this._currentMeasure.width,this._currentMeasure.height),this._effectiveThumbThickness=this._getThumbThickness(t),this.displayThumb&&(this._backgroundBoxLength-=this._effectiveThumbThickness),this.isVertical&&this._currentMeasure.height=this._selectors.length))return this._selectors[t]},t.prototype.removeSelector=function(t){t<0||t>=this._selectors.length||(this._groupPanel.removeControl(this._selectors[t]),this._selectors.splice(t,1))},t}(),N=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.addCheckbox=function(t,e,i){void 0===e&&(e=function(t){}),void 0===i&&(i=!1);i=i||!1;var r=new T;r.width="20px",r.height="20px",r.color="#364249",r.background="#CCCCCC",r.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r.onIsCheckedChangedObservable.add((function(t){e(t)}));var n=f.AddHeader(r,t,"200px",{isHorizontal:!0,controlFirst:!0});n.height="30px",n.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,n.left="4px",this.groupPanel.addControl(n),this.selectors.push(n),r.isChecked=i,this.groupPanel.parent&&this.groupPanel.parent.parent&&(r.color=this.groupPanel.parent.parent.buttonColor,r.background=this.groupPanel.parent.parent.buttonBackground)},e.prototype._setSelectorLabel=function(t,e){this.selectors[t].children[1].text=e},e.prototype._setSelectorLabelColor=function(t,e){this.selectors[t].children[1].color=e},e.prototype._setSelectorButtonColor=function(t,e){this.selectors[t].children[0].color=e},e.prototype._setSelectorButtonBackground=function(t,e){this.selectors[t].children[0].background=e},e}(B),H=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._selectNb=0,e}return n(e,t),e.prototype.addRadio=function(t,e,i){void 0===e&&(e=function(t){}),void 0===i&&(i=!1);var r=this._selectNb++,n=new D;n.name=t,n.width="20px",n.height="20px",n.color="#364249",n.background="#CCCCCC",n.group=this.name,n.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,n.onIsCheckedChangedObservable.add((function(t){t&&e(r)}));var o=f.AddHeader(n,t,"200px",{isHorizontal:!0,controlFirst:!0});o.height="30px",o.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,o.left="4px",this.groupPanel.addControl(o),this.selectors.push(o),n.isChecked=i,this.groupPanel.parent&&this.groupPanel.parent.parent&&(n.color=this.groupPanel.parent.parent.buttonColor,n.background=this.groupPanel.parent.parent.buttonBackground)},e.prototype._setSelectorLabel=function(t,e){this.selectors[t].children[1].text=e},e.prototype._setSelectorLabelColor=function(t,e){this.selectors[t].children[1].color=e},e.prototype._setSelectorButtonColor=function(t,e){this.selectors[t].children[0].color=e},e.prototype._setSelectorButtonBackground=function(t,e){this.selectors[t].children[0].background=e},e}(B),V=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.addSlider=function(t,e,i,r,n,o,s){void 0===e&&(e=function(t){}),void 0===i&&(i="Units"),void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=function(t){return 0|t});var a=new R;a.name=i,a.value=o,a.minimum=r,a.maximum=n,a.width=.9,a.height="20px",a.color="#364249",a.background="#CCCCCC",a.borderColor="black",a.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,a.left="4px",a.paddingBottom="4px",a.onValueChangedObservable.add((function(t){a.parent.children[0].text=a.parent.children[0].name+": "+s(t)+" "+a.name,e(t)}));var h=f.AddHeader(a,t+": "+s(o)+" "+i,"30px",{isHorizontal:!1,controlFirst:!1});h.height="60px",h.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,h.left="4px",h.children[0].name=t,this.groupPanel.addControl(h),this.selectors.push(h),this.groupPanel.parent&&this.groupPanel.parent.parent&&(a.color=this.groupPanel.parent.parent.buttonColor,a.background=this.groupPanel.parent.parent.buttonBackground)},e.prototype._setSelectorLabel=function(t,e){this.selectors[t].children[0].name=e,this.selectors[t].children[0].text=e+": "+this.selectors[t].children[1].value+" "+this.selectors[t].children[1].name},e.prototype._setSelectorLabelColor=function(t,e){this.selectors[t].children[0].color=e},e.prototype._setSelectorButtonColor=function(t,e){this.selectors[t].children[1].color=e},e.prototype._setSelectorButtonBackground=function(t,e){this.selectors[t].children[1].background=e},e}(B),W=function(t){function e(e,i){void 0===i&&(i=[]);var r=t.call(this,e)||this;if(r.name=e,r.groups=i,r._buttonColor="#364249",r._buttonBackground="#CCCCCC",r._headerColor="black",r._barColor="white",r._barHeight="2px",r._spacerHeight="20px",r._bars=new Array,r._groups=i,r.thickness=2,r._panel=new C,r._panel.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,r._panel.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r._panel.top=5,r._panel.left=5,r._panel.width=.95,i.length>0){for(var n=0;n0&&this._addSpacer(),this._panel.addControl(t.groupPanel),this._groups.push(t),t.groupPanel.children[0].color=this._headerColor;for(var e=0;e=this._groups.length)){var e=this._groups[t];this._panel.removeControl(e.groupPanel),this._groups.splice(t,1),t=this._groups.length||(this._groups[e].groupPanel.children[0].text=t)},e.prototype.relabel=function(t,e,i){if(!(e<0||e>=this._groups.length)){var r=this._groups[e];i<0||i>=r.selectors.length||r._setSelectorLabel(i,t)}},e.prototype.removeFromGroupSelector=function(t,e){if(!(t<0||t>=this._groups.length)){var i=this._groups[t];e<0||e>=i.selectors.length||i.removeSelector(e)}},e.prototype.addToGroupCheckbox=function(t,e,i,r){(void 0===i&&(i=function(){}),void 0===r&&(r=!1),t<0||t>=this._groups.length)||this._groups[t].addCheckbox(e,i,r)},e.prototype.addToGroupRadio=function(t,e,i,r){(void 0===i&&(i=function(){}),void 0===r&&(r=!1),t<0||t>=this._groups.length)||this._groups[t].addRadio(e,i,r)},e.prototype.addToGroupSlider=function(t,e,i,r,n,o,s,a){(void 0===i&&(i=function(){}),void 0===r&&(r="Units"),void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===a&&(a=function(t){return 0|t}),t<0||t>=this._groups.length)||this._groups[t].addSlider(e,i,r,n,o,s,a)},e}(b),F=function(t){function e(e){var i=t.call(this,e)||this;return i._freezeControls=!1,i._bucketWidth=0,i._bucketHeight=0,i._buckets={},i}return n(e,t),Object.defineProperty(e.prototype,"freezeControls",{get:function(){return this._freezeControls},set:function(t){if(this._freezeControls!==t){t||this._restoreMeasures(),this._freezeControls=!1;var e=this.host.getSize(),i=e.width,r=e.height,n=this.host.getContext(),o=new _(0,0,i,r);this.host._numLayoutCalls=0,this.host._rootContainer._layout(o,n),t&&(this._updateMeasures(),this._useBuckets()&&this._makeBuckets()),this._freezeControls=t,this.host.markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketWidth",{get:function(){return this._bucketWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketHeight",{get:function(){return this._bucketHeight},enumerable:!1,configurable:!0}),e.prototype.setBucketSizes=function(t,e){this._bucketWidth=t,this._bucketHeight=e,this._useBuckets()?this._freezeControls&&this._makeBuckets():this._buckets={}},e.prototype._useBuckets=function(){return this._bucketWidth>0&&this._bucketHeight>0},e.prototype._makeBuckets=function(){this._buckets={},this._bucketLen=Math.ceil(this.widthInPixels/this._bucketWidth),this._dispatchInBuckets(this._children),this._oldLeft=null,this._oldTop=null},e.prototype._dispatchInBuckets=function(t){for(var e=0;e0&&this._dispatchInBuckets(i._children)}},e.prototype._updateMeasures=function(){var t=0|this.leftInPixels,e=0|this.topInPixels;this._measureForChildren.left-=t,this._measureForChildren.top-=e,this._currentMeasure.left-=t,this._currentMeasure.top-=e,this._customData.origLeftForChildren=this._measureForChildren.left,this._customData.origTopForChildren=this._measureForChildren.top,this._customData.origLeft=this._currentMeasure.left,this._customData.origTop=this._currentMeasure.top,this._updateChildrenMeasures(this._children,t,e)},e.prototype._updateChildrenMeasures=function(t,e,i){for(var r=0;r0&&this._updateChildrenMeasures(n._children,e,i)}},e.prototype._restoreMeasures=function(){var t=0|this.leftInPixels,e=0|this.topInPixels;this._measureForChildren.left=this._customData.origLeftForChildren+t,this._measureForChildren.top=this._customData.origTopForChildren+e,this._currentMeasure.left=this._customData.origLeft+t,this._currentMeasure.top=this._customData.origTop+e},e.prototype._getTypeName=function(){return"ScrollViewerWindow"},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._parentMeasure=e,this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,this._measureForChildren.width=e.width,this._measureForChildren.height=e.height},e.prototype._layout=function(e,i){return this._freezeControls?(this.invalidateRect(),!1):t.prototype._layout.call(this,e,i)},e.prototype._scrollChildren=function(t,e,i){for(var r=0;r0&&this._scrollChildren(n._children,e,i)}},e.prototype._scrollChildrenWithBuckets=function(t,e,i,r){for(var n=Math.max(0,Math.floor(-t/this._bucketWidth)),o=Math.floor((-t+this._parentMeasure.width-1)/this._bucketWidth),s=Math.max(0,Math.floor(-e/this._bucketHeight)),a=Math.floor((-e+this._parentMeasure.height-1)/this._bucketHeight);s<=a;){for(var h=n;h<=o;++h){var l=s*this._bucketLen+h,u=this._buckets[l];if(u)for(var c=0;cthis._tempMeasure.left+this._tempMeasure.width||ethis._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(e-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(t-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var i=0;i=this.isVertical?-(e-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness):(t-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=i*(this.maximum-this.minimum),this._originX=t,this._originY=e},e.prototype._onPointerDown=function(e,i,r,n,o){return this._first=!0,t.prototype._onPointerDown.call(this,e,i,r,n,o)},e}(L),z=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thumbLength=.5,i._thumbHeight=1,i._barImageHeight=1,i._tempMeasure=new _(0,0,0,0),i.num90RotationInVerticalMode=1,i}return n(e,t),Object.defineProperty(e.prototype,"backgroundImage",{get:function(){return this._backgroundBaseImage},set:function(t){var e=this;this._backgroundBaseImage!==t&&(this._backgroundBaseImage=t,this.isVertical&&0!==this.num90RotationInVerticalMode?t.isLoaded?(this._backgroundImage=t._rotate90(this.num90RotationInVerticalMode,!0),this._markAsDirty()):t.onImageLoadedObservable.addOnce((function(){var i=t._rotate90(e.num90RotationInVerticalMode,!0);e._backgroundImage=i,i.isLoaded||i.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),e._markAsDirty()})):(this._backgroundImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbImage",{get:function(){return this._thumbBaseImage},set:function(t){var e=this;this._thumbBaseImage!==t&&(this._thumbBaseImage=t,this.isVertical&&0!==this.num90RotationInVerticalMode?t.isLoaded?(this._thumbImage=t._rotate90(-this.num90RotationInVerticalMode,!0),this._markAsDirty()):t.onImageLoadedObservable.addOnce((function(){var i=t._rotate90(-e.num90RotationInVerticalMode,!0);e._thumbImage=i,i.isLoaded||i.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),e._markAsDirty()})):(this._thumbImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(t){this._thumbLength!==t&&(this._thumbLength=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(t){this._thumbLength!==t&&(this._thumbHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(t){this._barImageHeight!==t&&(this._barImageHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"ImageScrollBar"},e.prototype._getThumbThickness=function(){return this._thumbWidth.isPixel?this._thumbWidth.getValue(this._host):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)},e.prototype._draw=function(t){t.save(),this._applyStates(t),this._prepareRenderingData("rectangle");var e=this._getThumbPosition(),i=this._renderLeft,r=this._renderTop,n=this._renderWidth,o=this._renderHeight;this._backgroundImage&&(this._tempMeasure.copyFromFloats(i,r,n,o),this.isVertical?(this._tempMeasure.copyFromFloats(i+n*(1-this._barImageHeight)*.5,this._currentMeasure.top,n*this._barImageHeight,o),this._tempMeasure.height+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)):(this._tempMeasure.copyFromFloats(this._currentMeasure.left,r+o*(1-this._barImageHeight)*.5,n,o*this._barImageHeight),this._tempMeasure.width+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)),this._backgroundImage._draw(t)),this.isVertical?this._tempMeasure.copyFromFloats(i-this._effectiveBarOffset+this._currentMeasure.width*(1-this._thumbHeight)*.5,this._currentMeasure.top+e,this._currentMeasure.width*this._thumbHeight,this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(this._currentMeasure.left+e,this._currentMeasure.top+this._currentMeasure.height*(1-this._thumbHeight)*.5,this._effectiveThumbThickness,this._currentMeasure.height*this._thumbHeight),this._thumbImage&&(this._thumbImage._currentMeasure.copyFrom(this._tempMeasure),this._thumbImage._draw(t)),t.restore()},e.prototype._updateValueFromPointer=function(t,e){0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y),this._first&&(this._first=!1,this._originX=t,this._originY=e,(tthis._tempMeasure.left+this._tempMeasure.width||ethis._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(e-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(t-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var i=0;i=this.isVertical?-(e-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness):(t-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=i*(this.maximum-this.minimum),this._originX=t,this._originY=e},e.prototype._onPointerDown=function(e,i,r,n,o){return this._first=!0,t.prototype._onPointerDown.call(this,e,i,r,n,o)},e}(L),G=function(t){function e(e,i){var r=t.call(this,e)||this;return r._barSize=20,r._pointerIsOver=!1,r._wheelPrecision=.05,r._thumbLength=.5,r._thumbHeight=1,r._barImageHeight=1,r._horizontalBarImageHeight=1,r._verticalBarImageHeight=1,r._oldWindowContentsWidth=0,r._oldWindowContentsHeight=0,r._forceHorizontalBar=!1,r._forceVerticalBar=!1,r._useImageBar=i||!1,r.onDirtyObservable.add((function(){r._horizontalBarSpace.color=r.color,r._verticalBarSpace.color=r.color,r._dragSpace.color=r.color})),r.onPointerEnterObservable.add((function(){r._pointerIsOver=!0})),r.onPointerOutObservable.add((function(){r._pointerIsOver=!1})),r._grid=new P,r._useImageBar?(r._horizontalBar=new z,r._verticalBar=new z):(r._horizontalBar=new j,r._verticalBar=new j),r._window=new F("scrollViewer_window"),r._window.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r._window.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,r._grid.addColumnDefinition(1),r._grid.addColumnDefinition(0,!0),r._grid.addRowDefinition(1),r._grid.addRowDefinition(0,!0),t.prototype.addControl.call(r,r._grid),r._grid.addControl(r._window,0,0),r._verticalBarSpace=new b,r._verticalBarSpace.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r._verticalBarSpace.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,r._verticalBarSpace.thickness=1,r._grid.addControl(r._verticalBarSpace,0,1),r._addBar(r._verticalBar,r._verticalBarSpace,!0,Math.PI),r._horizontalBarSpace=new b,r._horizontalBarSpace.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r._horizontalBarSpace.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,r._horizontalBarSpace.thickness=1,r._grid.addControl(r._horizontalBarSpace,1,0),r._addBar(r._horizontalBar,r._horizontalBarSpace,!1,0),r._dragSpace=new b,r._dragSpace.thickness=1,r._grid.addControl(r._dragSpace,1,1),r._useImageBar||(r.barColor="grey",r.barBackground="transparent"),r}return n(e,t),Object.defineProperty(e.prototype,"horizontalBar",{get:function(){return this._horizontalBar},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalBar",{get:function(){return this._verticalBar},enumerable:!1,configurable:!0}),e.prototype.addControl=function(t){return t?(this._window.addControl(t),this):this},e.prototype.removeControl=function(t){return this._window.removeControl(t),this},Object.defineProperty(e.prototype,"children",{get:function(){return this._window.children},enumerable:!1,configurable:!0}),e.prototype._flagDescendantsAsMatrixDirty=function(){for(var t=0,e=this._children;t1&&(t=1),this._wheelPrecision=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scrollBackground",{get:function(){return this._horizontalBarSpace.background},set:function(t){this._horizontalBarSpace.background!==t&&(this._horizontalBarSpace.background=t,this._verticalBarSpace.background=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barColor",{get:function(){return this._barColor},set:function(t){this._barColor!==t&&(this._barColor=t,this._horizontalBar.color=t,this._verticalBar.color=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbImage",{get:function(){return this._barImage},set:function(t){if(this._barImage!==t){this._barImage=t;var e=this._horizontalBar,i=this._verticalBar;e.thumbImage=t,i.thumbImage=t}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalThumbImage",{get:function(){return this._horizontalBarImage},set:function(t){this._horizontalBarImage!==t&&(this._horizontalBarImage=t,this._horizontalBar.thumbImage=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalThumbImage",{get:function(){return this._verticalBarImage},set:function(t){this._verticalBarImage!==t&&(this._verticalBarImage=t,this._verticalBar.thumbImage=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barSize",{get:function(){return this._barSize},set:function(t){this._barSize!==t&&(this._barSize=t,this._markAsDirty(),this._horizontalBar.isVisible&&this._grid.setRowDefinition(1,this._barSize,!0),this._verticalBar.isVisible&&this._grid.setColumnDefinition(1,this._barSize,!0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(t){if(this._thumbLength!==t){t<=0&&(t=.1),t>1&&(t=1),this._thumbLength=t;var e=this._horizontalBar,i=this._verticalBar;e.thumbLength=t,i.thumbLength=t,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(t){if(this._thumbHeight!==t){t<=0&&(t=.1),t>1&&(t=1),this._thumbHeight=t;var e=this._horizontalBar,i=this._verticalBar;e.thumbHeight=t,i.thumbHeight=t,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(t){if(this._barImageHeight!==t){t<=0&&(t=.1),t>1&&(t=1),this._barImageHeight=t;var e=this._horizontalBar,i=this._verticalBar;e.barImageHeight=t,i.barImageHeight=t,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalBarImageHeight",{get:function(){return this._horizontalBarImageHeight},set:function(t){this._horizontalBarImageHeight!==t&&(t<=0&&(t=.1),t>1&&(t=1),this._horizontalBarImageHeight=t,this._horizontalBar.barImageHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalBarImageHeight",{get:function(){return this._verticalBarImageHeight},set:function(t){this._verticalBarImageHeight!==t&&(t<=0&&(t=.1),t>1&&(t=1),this._verticalBarImageHeight=t,this._verticalBar.barImageHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barBackground",{get:function(){return this._barBackground},set:function(t){if(this._barBackground!==t){this._barBackground=t;var e=this._horizontalBar,i=this._verticalBar;e.background=t,i.background=t,this._dragSpace.background=t}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barImage",{get:function(){return this._barBackgroundImage},set:function(t){this._barBackgroundImage,this._barBackgroundImage=t;var e=this._horizontalBar,i=this._verticalBar;e.backgroundImage=t,i.backgroundImage=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalBarImage",{get:function(){return this._horizontalBarBackgroundImage},set:function(t){this._horizontalBarBackgroundImage,this._horizontalBarBackgroundImage=t,this._horizontalBar.backgroundImage=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalBarImage",{get:function(){return this._verticalBarBackgroundImage},set:function(t){this._verticalBarBackgroundImage,this._verticalBarBackgroundImage=t,this._verticalBar.backgroundImage=t},enumerable:!1,configurable:!0}),e.prototype._setWindowPosition=function(t){void 0===t&&(t=!0);var e=this.host.idealRatio,i=this._window._currentMeasure.width,r=this._window._currentMeasure.height;if(t||this._oldWindowContentsWidth!==i||this._oldWindowContentsHeight!==r){this._oldWindowContentsWidth=i,this._oldWindowContentsHeight=r;var n=this._clientWidth-i,o=this._clientHeight-r,s=this._horizontalBar.value/e*n+"px",a=this._verticalBar.value/e*o+"px";s!==this._window.left&&(this._window.left=s,this.freezeControls||(this._rebuildLayout=!0)),a!==this._window.top&&(this._window.top=a,this.freezeControls||(this._rebuildLayout=!0))}},e.prototype._updateScroller=function(){var t=this._window._currentMeasure.width,e=this._window._currentMeasure.height;this._horizontalBar.isVisible&&t<=this._clientWidth&&!this.forceHorizontalBar?(this._grid.setRowDefinition(1,0,!0),this._horizontalBar.isVisible=!1,this._horizontalBar.value=0,this._rebuildLayout=!0):!this._horizontalBar.isVisible&&(t>this._clientWidth||this.forceHorizontalBar)&&(this._grid.setRowDefinition(1,this._barSize,!0),this._horizontalBar.isVisible=!0,this._rebuildLayout=!0),this._verticalBar.isVisible&&e<=this._clientHeight&&!this.forceVerticalBar?(this._grid.setColumnDefinition(1,0,!0),this._verticalBar.isVisible=!1,this._verticalBar.value=0,this._rebuildLayout=!0):!this._verticalBar.isVisible&&(e>this._clientHeight||this.forceVerticalBar)&&(this._grid.setColumnDefinition(1,this._barSize,!0),this._verticalBar.isVisible=!0,this._rebuildLayout=!0),this._buildClientSizes();var i=this.host.idealRatio;this._horizontalBar.thumbWidth=.9*this._thumbLength*(this._clientWidth/i)+"px",this._verticalBar.thumbWidth=.9*this._thumbLength*(this._clientHeight/i)+"px"},e.prototype._link=function(e){t.prototype._link.call(this,e),this._attachWheel()},e.prototype._addBar=function(t,e,i,r){var n=this;t.paddingLeft=0,t.width="100%",t.height="100%",t.barOffset=0,t.value=0,t.maximum=1,t.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,t.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,t.isVertical=i,t.rotation=r,t.isVisible=!1,e.addControl(t),t.onValueChangedObservable.add((function(t){n._setWindowPosition()}))},e.prototype._attachWheel=function(){var t=this;this._host&&!this._onWheelObserver&&(this._onWheelObserver=this.onWheelObservable.add((function(e){t._pointerIsOver&&(1==t._verticalBar.isVisible&&(e.y<0&&t._verticalBar.value>0?t._verticalBar.value-=t._wheelPrecision:e.y>0&&t._verticalBar.value0&&t._horizontalBar.value>0&&(t._horizontalBar.value-=t._wheelPrecision)))})))},e.prototype._renderHighlightSpecific=function(e){this.isHighlighted&&(t.prototype._renderHighlightSpecific.call(this,e),this._grid._renderHighlightSpecific(e),e.restore())},e.prototype.dispose=function(){this.onWheelObservable.remove(this._onWheelObserver),this._onWheelObserver=null,t.prototype.dispose.call(this)},e}(b);s._TypeStore.RegisteredTypes["BABYLON.GUI.ScrollViewer"]=G;var X=function(){},U=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.onKeyPressObservable=new s.Observable,e.defaultButtonWidth="40px",e.defaultButtonHeight="40px",e.defaultButtonPaddingLeft="2px",e.defaultButtonPaddingRight="2px",e.defaultButtonPaddingTop="2px",e.defaultButtonPaddingBottom="2px",e.defaultButtonColor="#DDD",e.defaultButtonBackground="#070707",e.shiftButtonColor="#7799FF",e.selectedShiftThickness=1,e.shiftState=0,e._currentlyConnectedInputText=null,e._connectedInputTexts=[],e._onKeyPressObserver=null,e}return n(e,t),e.prototype._getTypeName=function(){return"VirtualKeyboard"},e.prototype._createKey=function(t,e){var i=this,r=O.CreateSimpleButton(t,t);return r.width=e&&e.width?e.width:this.defaultButtonWidth,r.height=e&&e.height?e.height:this.defaultButtonHeight,r.color=e&&e.color?e.color:this.defaultButtonColor,r.background=e&&e.background?e.background:this.defaultButtonBackground,r.paddingLeft=e&&e.paddingLeft?e.paddingLeft:this.defaultButtonPaddingLeft,r.paddingRight=e&&e.paddingRight?e.paddingRight:this.defaultButtonPaddingRight,r.paddingTop=e&&e.paddingTop?e.paddingTop:this.defaultButtonPaddingTop,r.paddingBottom=e&&e.paddingBottom?e.paddingBottom:this.defaultButtonPaddingBottom,r.thickness=0,r.isFocusInvisible=!0,r.shadowColor=this.shadowColor,r.shadowBlur=this.shadowBlur,r.shadowOffsetX=this.shadowOffsetX,r.shadowOffsetY=this.shadowOffsetY,r.onPointerUpObservable.add((function(){i.onKeyPressObservable.notifyObservers(t)})),r},e.prototype.addKeysRow=function(t,e){var i=new C;i.isVertical=!1,i.isFocusInvisible=!0;for(var r=null,n=0;nr.heightInPixels)&&(r=s),i.addControl(s)}i.height=r?r.height:this.defaultButtonHeight,this.addControl(i)},e.prototype.applyShiftState=function(t){if(this.children)for(var e=0;e1?this.selectedShiftThickness:0),s.text=t>0?s.text.toUpperCase():s.text.toLowerCase()}}}},Object.defineProperty(e.prototype,"connectedInputText",{get:function(){return this._currentlyConnectedInputText},enumerable:!1,configurable:!0}),e.prototype.connect=function(t){var e=this;if(!this._connectedInputTexts.some((function(e){return e.input===t}))){null===this._onKeyPressObserver&&(this._onKeyPressObserver=this.onKeyPressObservable.add((function(t){if(e._currentlyConnectedInputText){switch(e._currentlyConnectedInputText._host.focusedControl=e._currentlyConnectedInputText,t){case"⇧":return e.shiftState++,e.shiftState>2&&(e.shiftState=0),void e.applyShiftState(e.shiftState);case"←":return void e._currentlyConnectedInputText.processKey(8);case"↵":return void e._currentlyConnectedInputText.processKey(13)}e._currentlyConnectedInputText.processKey(-1,e.shiftState?t.toUpperCase():t),1===e.shiftState&&(e.shiftState=0,e.applyShiftState(e.shiftState))}}))),this.isVisible=!1,this._currentlyConnectedInputText=t,t._connectedVirtualKeyboard=this;var i=t.onFocusObservable.add((function(){e._currentlyConnectedInputText=t,t._connectedVirtualKeyboard=e,e.isVisible=!0})),r=t.onBlurObservable.add((function(){t._connectedVirtualKeyboard=null,e._currentlyConnectedInputText=null,e.isVisible=!1}));this._connectedInputTexts.push({input:t,onBlurObserver:r,onFocusObserver:i})}},e.prototype.disconnect=function(t){var e=this;if(t){var i=this._connectedInputTexts.filter((function(e){return e.input===t}));1===i.length&&(this._removeConnectedInputObservables(i[0]),this._connectedInputTexts=this._connectedInputTexts.filter((function(e){return e.input!==t})),this._currentlyConnectedInputText===t&&(this._currentlyConnectedInputText=null))}else this._connectedInputTexts.forEach((function(t){e._removeConnectedInputObservables(t)})),this._connectedInputTexts=[];0===this._connectedInputTexts.length&&(this._currentlyConnectedInputText=null,this.onKeyPressObservable.remove(this._onKeyPressObserver),this._onKeyPressObserver=null)},e.prototype._removeConnectedInputObservables=function(t){t.input._connectedVirtualKeyboard=null,t.input.onFocusObservable.remove(t.onFocusObserver),t.input.onBlurObservable.remove(t.onBlurObserver)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.disconnect()},e.CreateDefaultLayout=function(t){var i=new e(t);return i.addKeysRow(["1","2","3","4","5","6","7","8","9","0","←"]),i.addKeysRow(["q","w","e","r","t","y","u","i","o","p"]),i.addKeysRow(["a","s","d","f","g","h","j","k","l",";","'","↵"]),i.addKeysRow(["⇧","z","x","c","v","b","n","m",",",".","/"]),i.addKeysRow([" "],[{width:"200px"}]),i},e}(C);s._TypeStore.RegisteredTypes["BABYLON.GUI.VirtualKeyboard"]=U;var Y=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._cellWidth=20,i._cellHeight=20,i._minorLineTickness=1,i._minorLineColor="DarkGray",i._majorLineTickness=2,i._majorLineColor="White",i._majorLineFrequency=5,i._background="Black",i._displayMajorLines=!0,i._displayMinorLines=!0,i}return n(e,t),Object.defineProperty(e.prototype,"displayMinorLines",{get:function(){return this._displayMinorLines},set:function(t){this._displayMinorLines!==t&&(this._displayMinorLines=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayMajorLines",{get:function(){return this._displayMajorLines},set:function(t){this._displayMajorLines!==t&&(this._displayMajorLines=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(t){this._cellWidth=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(t){this._cellHeight=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorLineTickness",{get:function(){return this._minorLineTickness},set:function(t){this._minorLineTickness=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorLineColor",{get:function(){return this._minorLineColor},set:function(t){this._minorLineColor=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorLineTickness",{get:function(){return this._majorLineTickness},set:function(t){this._majorLineTickness=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorLineColor",{get:function(){return this._majorLineColor},set:function(t){this._majorLineColor=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorLineFrequency",{get:function(){return this._majorLineFrequency},set:function(t){this._majorLineFrequency=t,this._markAsDirty()},enumerable:!1,configurable:!0}),e.prototype._draw=function(t,e){if(t.save(),this._applyStates(t),this._isEnabled){this._background&&(t.fillStyle=this._background,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height));var i=this._currentMeasure.width/this._cellWidth,r=this._currentMeasure.height/this._cellHeight,n=this._currentMeasure.left+this._currentMeasure.width/2,o=this._currentMeasure.top+this._currentMeasure.height/2;if(this._displayMinorLines){t.strokeStyle=this._minorLineColor,t.lineWidth=this._minorLineTickness;for(var s=-i/2;s1)return t.notRenderable=!0,"continue";t.notRenderable=!1,a.scaleInPlace(n.renderScale),t._moveToProjectedPosition(a)},n=this,o=0,a=this._linkedControls;o0&&c>_)throw"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.";if(0==u){if(!o[p].attributes.getNamedItem("width"))throw"XmlLoader Exception : Width must be defined for all the grid columns in the first row";r=Number(o[p].attributes.getNamedItem("width").nodeValue),l=!!o[p].attributes.getNamedItem("isPixel")&&JSON.parse(o[p].attributes.getNamedItem("isPixel").nodeValue),e.addColumnDefinition(r,l)}s=o[p].children;for(var f=0;f0)&&(-1===this._enterCount&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,t,this),this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},t.prototype._onPointerOut=function(t){this._enterCount=0,this.onPointerOutObservable.notifyObservers(this,-1,t,this),this.pointerOutAnimation&&this.pointerOutAnimation()},t.prototype._onPointerDown=function(t,e,i,r){return 0!==this._downCount?(this._downCount++,!1):(this._downCount++,this._downPointerIds[i]=!0,this.onPointerDownObservable.notifyObservers(new tt(e,r),-1,t,this),this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},t.prototype._onPointerUp=function(t,e,i,r,n){this._downCount--,delete this._downPointerIds[i],this._downCount<0?this._downCount=0:0==this._downCount&&(n&&(this._enterCount>0||-1===this._enterCount)&&this.onPointerClickObservable.notifyObservers(new tt(e,r),-1,t,this),this.onPointerUpObservable.notifyObservers(new tt(e,r),-1,t,this),this.pointerUpAnimation&&this.pointerUpAnimation())},t.prototype.forcePointerUp=function(t){if(void 0===t&&(t=null),null!==t)this._onPointerUp(this,s.Vector3.Zero(),t,0,!0);else{for(var e in this._downPointerIds)this._onPointerUp(this,s.Vector3.Zero(),+e,0,!0);this._downCount>0&&(this._downCount=1,this._onPointerUp(this,s.Vector3.Zero(),0,0,!0))}},t.prototype._processObservables=function(t,e,i,r){if(t===s.PointerEventTypes.POINTERMOVE){this._onPointerMove(this,e);var n=this._host._lastControlOver[i];return n&&n!==this&&n._onPointerOut(this),n!==this&&this._onPointerEnter(this),this._host._lastControlOver[i]=this,!0}return t===s.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this,e,i,r),this._host._lastControlDown[i]=this,this._host._lastPickedControl=this,!0):(t===s.PointerEventTypes.POINTERUP||t===s.PointerEventTypes.POINTERDOUBLETAP)&&(this._host._lastControlDown[i]&&this._host._lastControlDown[i]._onPointerUp(this,e,i,r,!0),delete this._host._lastControlDown[i],!0)},t.prototype._disposeNode=function(){this._node&&(this._node.dispose(),this._node=null)},t.prototype.dispose=function(){this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this._disposeNode();for(var t=0,e=this._behaviors;ti));f++);else for(f=0;fi));p++);d=0;for(var g=0,m=this._children;g0,n.BORDER=this.renderBorders,n.HOVERLIGHT=this.renderHoverLight,this._albedoTexture){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;n.TEXTURE=!0}else n.TEXTURE=!1;var o=r.getEngine();if(n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var a=[s.VertexBuffer.PositionKind];a.push(s.VertexBuffer.NormalKind),a.push(s.VertexBuffer.UVKind);var h=["world","viewProjection","innerGlowColor","albedoColor","borderWidth","edgeSmoothingValue","scaleFactor","borderMinValue","hoverColor","hoverPosition","hoverRadius"],l=["albedoSampler"],u=new Array;s.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:h,uniformBuffersNames:u,samplers:l,defines:n,maxSimultaneousLights:4});var c=n.toString();e.setEffect(r.getEngine().createEffect("fluent",{attributes:a,uniformsNames:h,uniformBuffersNames:u,samplers:l,defines:c,fallbacks:null,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},o))}return!(!e.effect||!e.effect.isReady())&&(n._renderId=r.getRenderId(),e.effect._wasPreviouslyReady=!0,!0)},e.prototype.bindForSubMesh=function(t,e,i){var r=this.getScene(),n=i._materialDefines;if(n){var o=i.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(t),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),this._mustRebind(r,o)&&(this._activeEffect.setColor4("albedoColor",this.albedoColor,this.alpha),n.INNERGLOW&&this._activeEffect.setColor4("innerGlowColor",this.innerGlowColor,this.innerGlowColorIntensity),n.BORDER&&(this._activeEffect.setFloat("borderWidth",this.borderWidth),this._activeEffect.setFloat("edgeSmoothingValue",this.edgeSmoothingValue),this._activeEffect.setFloat("borderMinValue",this.borderMinValue),e.getBoundingInfo().boundingBox.extendSize.multiplyToRef(e.scaling,s.TmpVectors.Vector3[0]),this._activeEffect.setVector3("scaleFactor",s.TmpVectors.Vector3[0])),n.HOVERLIGHT&&(this._activeEffect.setDirectColor4("hoverColor",this.hoverColor),this._activeEffect.setFloat("hoverRadius",this.hoverRadius),this._activeEffect.setVector3("hoverPosition",this.hoverPosition)),n.TEXTURE&&this._activeEffect.setTexture("albedoSampler",this._albedoTexture)),this._afterBind(e,this._activeEffect))}},e.prototype.getActiveTextures=function(){return t.prototype.getActiveTextures.call(this)},e.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)},e.prototype.dispose=function(e){t.prototype.dispose.call(this,e)},e.prototype.clone=function(t){var i=this;return s.SerializationHelper.Clone((function(){return new e(t,i.getScene())}),this)},e.prototype.serialize=function(){var t=s.SerializationHelper.Serialize(this);return t.customType="BABYLON.GUI.FluentMaterial",t},e.prototype.getClassName=function(){return"FluentMaterial"},e.Parse=function(t,i,r){return s.SerializationHelper.Parse((function(){return new e(t.name,i)}),t,i,r)},o([Object(s.serialize)(),Object(s.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"innerGlowColorIntensity",void 0),o([Object(s.serializeAsColor3)()],e.prototype,"innerGlowColor",void 0),o([Object(s.serializeAsColor3)()],e.prototype,"albedoColor",void 0),o([Object(s.serialize)(),Object(s.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"renderBorders",void 0),o([Object(s.serialize)()],e.prototype,"borderWidth",void 0),o([Object(s.serialize)()],e.prototype,"edgeSmoothingValue",void 0),o([Object(s.serialize)()],e.prototype,"borderMinValue",void 0),o([Object(s.serialize)(),Object(s.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"renderHoverLight",void 0),o([Object(s.serialize)()],e.prototype,"hoverRadius",void 0),o([Object(s.serializeAsColor4)()],e.prototype,"hoverColor",void 0),o([Object(s.serializeAsVector3)()],e.prototype,"hoverPosition",void 0),o([Object(s.serializeAsTexture)("albedoTexture")],e.prototype,"_albedoTexture",void 0),o([Object(s.expandToProperty)("_markAllSubMeshesAsTexturesAndMiscDirty")],e.prototype,"albedoTexture",void 0),e}(s.PushMaterial);s._TypeStore.RegisteredTypes["BABYLON.GUI.FluentMaterial"]=ut;var ct=function(t){function e(e,i){void 0===i&&(i=!0);var r=t.call(this,e)||this;return r._shareMaterials=!0,r._shareMaterials=i,r.pointerEnterAnimation=function(){r.mesh&&r._frontPlate.setEnabled(!0)},r.pointerOutAnimation=function(){r.mesh&&r._frontPlate.setEnabled(!1)},r}return n(e,t),e.prototype._disposeTooltip=function(){this._tooltipFade=null,this._tooltipTextBlock&&this._tooltipTextBlock.dispose(),this._tooltipTexture&&this._tooltipTexture.dispose(),this._tooltipMesh&&this._tooltipMesh.dispose(),this.onPointerEnterObservable.remove(this._tooltipHoverObserver),this.onPointerOutObservable.remove(this._tooltipOutObserver)},Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._backPlate.renderingGroupId},set:function(t){this._backPlate.renderingGroupId=t,this._textPlate.renderingGroupId=t,this._frontPlate.renderingGroupId=t,this._tooltipMesh&&(this._tooltipMesh.renderingGroupId=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tooltipText",{get:function(){return this._tooltipTextBlock?this._tooltipTextBlock.text:null},set:function(t){var e=this;if(t){if(!this._tooltipFade){this._tooltipMesh=s.PlaneBuilder.CreatePlane("",{size:1},this._backPlate._scene);var i=s.PlaneBuilder.CreatePlane("",{size:1,sideOrientation:s.Mesh.DOUBLESIDE},this._backPlate._scene),r=new s.StandardMaterial("",this._backPlate._scene);r.diffuseColor=s.Color3.FromHexString("#212121"),i.material=r,i.isPickable=!1,this._tooltipMesh.addChild(i),i.position.z=.05,this._tooltipMesh.scaling.y=1/3,this._tooltipMesh.position.y=.7,this._tooltipMesh.position.z=-.15,this._tooltipMesh.isPickable=!1,this._tooltipMesh.parent=this._backPlate,this._tooltipTexture=J.CreateForMesh(this._tooltipMesh),this._tooltipTextBlock=new y,this._tooltipTextBlock.scaleY=3,this._tooltipTextBlock.color="white",this._tooltipTextBlock.fontSize=130,this._tooltipTexture.addControl(this._tooltipTextBlock),this._tooltipFade=new s.FadeInOutBehavior,this._tooltipFade.delay=500,this._tooltipMesh.addBehavior(this._tooltipFade),this._tooltipHoverObserver=this.onPointerEnterObservable.add((function(){e._tooltipFade&&e._tooltipFade.fadeIn(!0)})),this._tooltipOutObserver=this.onPointerOutObservable.add((function(){e._tooltipFade&&e._tooltipFade.fadeIn(!1)}))}this._tooltipTextBlock&&(this._tooltipTextBlock.text=t)}else this._disposeTooltip()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._rebuildContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageUrl",{get:function(){return this._imageUrl},set:function(t){this._imageUrl!==t&&(this._imageUrl=t,this._rebuildContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backMaterial",{get:function(){return this._backMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frontMaterial",{get:function(){return this._frontMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"plateMaterial",{get:function(){return this._plateMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shareMaterials",{get:function(){return this._shareMaterials},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"HolographicButton"},e.prototype._rebuildContent=function(){this._disposeFacadeTexture();var t=new C;if(t.isVertical=!0,this._imageUrl){var e=new v;e.source=this._imageUrl,e.paddingTop="40px",e.height="180px",e.width="100px",e.paddingBottom="40px",t.addControl(e)}if(this._text){var i=new y;i.text=this._text,i.color="white",i.height="30px",i.fontSize=24,t.addControl(i)}this._frontPlate&&(this.content=t)},e.prototype._createNode=function(e){return this._backPlate=s.BoxBuilder.CreateBox(this.name+"BackMesh",{width:1,height:1,depth:.08},e),this._frontPlate=s.BoxBuilder.CreateBox(this.name+"FrontMesh",{width:1,height:1,depth:.08},e),this._frontPlate.parent=this._backPlate,this._frontPlate.position.z=-.08,this._frontPlate.isPickable=!1,this._frontPlate.setEnabled(!1),this._textPlate=t.prototype._createNode.call(this,e),this._textPlate.parent=this._backPlate,this._textPlate.position.z=-.08,this._textPlate.isPickable=!1,this._backPlate},e.prototype._applyFacade=function(t){this._plateMaterial.emissiveTexture=t,this._plateMaterial.opacityTexture=t},e.prototype._createBackMaterial=function(t){var e=this;this._backMaterial=new ut(this.name+"Back Material",t.getScene()),this._backMaterial.renderHoverLight=!0,this._pickedPointObserver=this._host.onPickedPointChangedObservable.add((function(t){t?(e._backMaterial.hoverPosition=t,e._backMaterial.hoverColor.a=1):e._backMaterial.hoverColor.a=0}))},e.prototype._createFrontMaterial=function(t){this._frontMaterial=new ut(this.name+"Front Material",t.getScene()),this._frontMaterial.innerGlowColorIntensity=0,this._frontMaterial.alpha=.5,this._frontMaterial.renderBorders=!0},e.prototype._createPlateMaterial=function(t){this._plateMaterial=new s.StandardMaterial(this.name+"Plate Material",t.getScene()),this._plateMaterial.specularColor=s.Color3.Black()},e.prototype._affectMaterial=function(t){this._shareMaterials?(this._host._sharedMaterials.backFluentMaterial?this._backMaterial=this._host._sharedMaterials.backFluentMaterial:(this._createBackMaterial(t),this._host._sharedMaterials.backFluentMaterial=this._backMaterial),this._host._sharedMaterials.frontFluentMaterial?this._frontMaterial=this._host._sharedMaterials.frontFluentMaterial:(this._createFrontMaterial(t),this._host._sharedMaterials.frontFluentMaterial=this._frontMaterial)):(this._createBackMaterial(t),this._createFrontMaterial(t)),this._createPlateMaterial(t),this._backPlate.material=this._backMaterial,this._frontPlate.material=this._frontMaterial,this._textPlate.material=this._plateMaterial,this._rebuildContent()},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._disposeTooltip(),this.shareMaterials||(this._backMaterial.dispose(),this._frontMaterial.dispose(),this._plateMaterial.dispose(),this._pickedPointObserver&&(this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver),this._pickedPointObserver=null))},e}(rt),_t=function(t){function e(e,i){var r=t.call(this,i)||this;return r._currentMesh=e,r.pointerEnterAnimation=function(){r.mesh&&r.mesh.scaling.scaleInPlace(1.1)},r.pointerOutAnimation=function(){r.mesh&&r.mesh.scaling.scaleInPlace(1/1.1)},r.pointerDownAnimation=function(){r.mesh&&r.mesh.scaling.scaleInPlace(.95)},r.pointerUpAnimation=function(){r.mesh&&r.mesh.scaling.scaleInPlace(1/.95)},r}return n(e,t),e.prototype._getTypeName=function(){return"MeshButton3D"},e.prototype._createNode=function(t){var e=this;return this._currentMesh.getChildMeshes().forEach((function(t){t.metadata=e})),this._currentMesh},e.prototype._affectMaterial=function(t){},e}(rt),dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._mapGridNode=function(t,e){var i=t.mesh;if(i){t.position=e.clone();var r=s.TmpVectors.Vector3[0];switch(r.copyFrom(e),this.orientation){case nt.FACEORIGIN_ORIENTATION:case nt.FACEFORWARD_ORIENTATION:r.addInPlace(new s.Vector3(0,0,1)),i.lookAt(r);break;case nt.FACEFORWARDREVERSED_ORIENTATION:case nt.FACEORIGINREVERSED_ORIENTATION:r.addInPlace(new s.Vector3(0,0,-1)),i.lookAt(r)}}},e}(ot),pt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._iteration=100,e}return n(e,t),Object.defineProperty(e.prototype,"iteration",{get:function(){return this._iteration},set:function(t){var e=this;this._iteration!==t&&(this._iteration=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._mapGridNode=function(t,e){var i=t.mesh,r=this._scatterMapping(e);if(i){switch(this.orientation){case nt.FACEORIGIN_ORIENTATION:case nt.FACEFORWARD_ORIENTATION:i.lookAt(new s.Vector3(0,0,1));break;case nt.FACEFORWARDREVERSED_ORIENTATION:case nt.FACEORIGINREVERSED_ORIENTATION:i.lookAt(new s.Vector3(0,0,-1))}t.position=r}},e.prototype._scatterMapping=function(t){return t.x=(1-2*Math.random())*this._cellWidth,t.y=(1-2*Math.random())*this._cellHeight,t},e.prototype._finalProcessing=function(){for(var t=[],e=0,i=this._children;er?-1:0}));for(var o=Math.pow(this.margin,2),a=Math.max(this._cellWidth,this._cellHeight),h=s.TmpVectors.Vector2[0],l=s.TmpVectors.Vector3[0],u=0;u0?this.margin:0}}},e}(nt),mt=function(){function t(t){var e=this;this._lastControlOver={},this._lastControlDown={},this.onPickedPointChangedObservable=new s.Observable,this._sharedMaterials={},this._scene=t||s.EngineStore.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add((function(){e._sceneDisposeObserver=null,e._utilityLayer=null,e.dispose()})),this._utilityLayer=new s.UtilityLayerRenderer(this._scene),this._utilityLayer.onlyCheckPointerDownEvents=!1,this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.mainSceneTrackerPredicate=function(t){return t&&t.metadata&&t.metadata._node},this._rootContainer=new nt("RootContainer"),this._rootContainer._host=this;var i=this._utilityLayer.utilityLayerScene;this._pointerOutObserver=this._utilityLayer.onPointerOutObservable.add((function(t){e._handlePointerOut(t,!0)})),this._pointerObserver=i.onPointerObservable.add((function(t,i){e._doPicking(t)})),this._utilityLayer.utilityLayerScene.autoClear=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,new s.HemisphericLight("hemi",s.Vector3.Up(),this._utilityLayer.utilityLayerScene)}return Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"utilityLayer",{get:function(){return this._utilityLayer},enumerable:!1,configurable:!0}),t.prototype._handlePointerOut=function(t,e){var i=this._lastControlOver[t];i&&(i._onPointerOut(i),delete this._lastControlOver[t]),e&&this._lastControlDown[t]&&(this._lastControlDown[t].forcePointerUp(),delete this._lastControlDown[t]),this.onPickedPointChangedObservable.notifyObservers(null)},t.prototype._doPicking=function(t){if(!this._utilityLayer||!this._utilityLayer.shouldRender||!this._utilityLayer.utilityLayerScene.activeCamera)return!1;var e=t.event,i=e.pointerId||0,r=e.button,n=t.pickInfo;if(!n||!n.hit)return this._handlePointerOut(i,t.type===s.PointerEventTypes.POINTERUP),!1;var o=n.pickedMesh.metadata;return n.pickedPoint&&this.onPickedPointChangedObservable.notifyObservers(n.pickedPoint),o._processObservables(t.type,n.pickedPoint,i,r)||t.type===s.PointerEventTypes.POINTERMOVE&&(this._lastControlOver[i]&&this._lastControlOver[i]._onPointerOut(this._lastControlOver[i]),delete this._lastControlOver[i]),t.type===s.PointerEventTypes.POINTERUP&&(this._lastControlDown[e.pointerId]&&(this._lastControlDown[e.pointerId].forcePointerUp(),delete this._lastControlDown[e.pointerId]),"touch"===e.pointerType&&this._handlePointerOut(i,!1)),!0},Object.defineProperty(t.prototype,"rootContainer",{get:function(){return this._rootContainer},enumerable:!1,configurable:!0}),t.prototype.containsControl=function(t){return this._rootContainer.containsControl(t)},t.prototype.addControl=function(t){return this._rootContainer.addControl(t),this},t.prototype.removeControl=function(t){return this._rootContainer.removeControl(t),this},t.prototype.dispose=function(){for(var t in this._rootContainer.dispose(),this._sharedMaterials)this._sharedMaterials.hasOwnProperty(t)&&this._sharedMaterials[t].dispose();this._sharedMaterials={},this._pointerOutObserver&&this._utilityLayer&&(this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver),this._pointerOutObserver=null),this.onPickedPointChangedObservable.clear();var e=this._utilityLayer?this._utilityLayer.utilityLayerScene:null;e&&this._pointerObserver&&(e.onPointerObservable.remove(this._pointerObserver),this._pointerObserver=null),this._scene&&this._sceneDisposeObserver&&(this._scene.onDisposeObservable.remove(this._sceneDisposeObserver),this._sceneDisposeObserver=null),this._utilityLayer&&this._utilityLayer.dispose()},t}()},function(t,e,i){"use strict";i.r(e),function(t){var r=i(1);i.d(e,"Button",(function(){return r.Button})),i.d(e,"Checkbox",(function(){return r.Checkbox})),i.d(e,"ColorPicker",(function(){return r.ColorPicker})),i.d(e,"Container",(function(){return r.Container})),i.d(e,"Control",(function(){return r.Control})),i.d(e,"Ellipse",(function(){return r.Ellipse})),i.d(e,"Grid",(function(){return r.Grid})),i.d(e,"Image",(function(){return r.Image})),i.d(e,"InputText",(function(){return r.InputText})),i.d(e,"InputPassword",(function(){return r.InputPassword})),i.d(e,"Line",(function(){return r.Line})),i.d(e,"MultiLine",(function(){return r.MultiLine})),i.d(e,"RadioButton",(function(){return r.RadioButton})),i.d(e,"StackPanel",(function(){return r.StackPanel})),i.d(e,"SelectorGroup",(function(){return r.SelectorGroup})),i.d(e,"CheckboxGroup",(function(){return r.CheckboxGroup})),i.d(e,"RadioGroup",(function(){return r.RadioGroup})),i.d(e,"SliderGroup",(function(){return r.SliderGroup})),i.d(e,"SelectionPanel",(function(){return r.SelectionPanel})),i.d(e,"ScrollViewer",(function(){return r.ScrollViewer})),i.d(e,"TextWrapping",(function(){return r.TextWrapping})),i.d(e,"TextBlock",(function(){return r.TextBlock})),i.d(e,"TextWrapper",(function(){return r.TextWrapper})),i.d(e,"KeyPropertySet",(function(){return r.KeyPropertySet})),i.d(e,"VirtualKeyboard",(function(){return r.VirtualKeyboard})),i.d(e,"Rectangle",(function(){return r.Rectangle})),i.d(e,"DisplayGrid",(function(){return r.DisplayGrid})),i.d(e,"BaseSlider",(function(){return r.BaseSlider})),i.d(e,"Slider",(function(){return r.Slider})),i.d(e,"ImageBasedSlider",(function(){return r.ImageBasedSlider})),i.d(e,"ScrollBar",(function(){return r.ScrollBar})),i.d(e,"ImageScrollBar",(function(){return r.ImageScrollBar})),i.d(e,"name",(function(){return r.name})),i.d(e,"AdvancedDynamicTexture",(function(){return r.AdvancedDynamicTexture})),i.d(e,"AdvancedDynamicTextureInstrumentation",(function(){return r.AdvancedDynamicTextureInstrumentation})),i.d(e,"Vector2WithInfo",(function(){return r.Vector2WithInfo})),i.d(e,"Matrix2D",(function(){return r.Matrix2D})),i.d(e,"Measure",(function(){return r.Measure})),i.d(e,"MultiLinePoint",(function(){return r.MultiLinePoint})),i.d(e,"Style",(function(){return r.Style})),i.d(e,"ValueAndUnit",(function(){return r.ValueAndUnit})),i.d(e,"XmlLoader",(function(){return r.XmlLoader})),i.d(e,"AbstractButton3D",(function(){return r.AbstractButton3D})),i.d(e,"Button3D",(function(){return r.Button3D})),i.d(e,"Container3D",(function(){return r.Container3D})),i.d(e,"Control3D",(function(){return r.Control3D})),i.d(e,"CylinderPanel",(function(){return r.CylinderPanel})),i.d(e,"HolographicButton",(function(){return r.HolographicButton})),i.d(e,"MeshButton3D",(function(){return r.MeshButton3D})),i.d(e,"PlanePanel",(function(){return r.PlanePanel})),i.d(e,"ScatterPanel",(function(){return r.ScatterPanel})),i.d(e,"SpherePanel",(function(){return r.SpherePanel})),i.d(e,"StackPanel3D",(function(){return r.StackPanel3D})),i.d(e,"VolumeBasedPanel",(function(){return r.VolumeBasedPanel})),i.d(e,"FluentMaterialDefines",(function(){return r.FluentMaterialDefines})),i.d(e,"FluentMaterial",(function(){return r.FluentMaterial})),i.d(e,"GUI3DManager",(function(){return r.GUI3DManager})),i.d(e,"Vector3WithInfo",(function(){return r.Vector3WithInfo}));var n=void 0!==t?t:"undefined"!=typeof window?window:void 0;void 0!==n&&(n.BABYLON=n.BABYLON||{},n.BABYLON.GUI=r)}.call(this,i(3))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i}])})); \ No newline at end of file diff --git a/src/static/babylon-4.2.0.js b/src/static/babylon-4.2.0.js new file mode 100644 index 0000000..9e0dda1 --- /dev/null +++ b/src/static/babylon-4.2.0.js @@ -0,0 +1,16 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("babylonjs",[],t):"object"==typeof exports?exports.babylonjs=t():e.BABYLON=t()}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=169)}([function(e,t,i){"use strict";i.d(t,"d",(function(){return c})),i.d(t,"e",(function(){return l})),i.d(t,"f",(function(){return u})),i.d(t,"b",(function(){return h})),i.d(t,"a",(function(){return d})),i.d(t,"c",(function(){return p}));var n=i(14),r=i(28),o=i(44),a=i(11),s=i(74),c=function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.x=e,this.y=t}return e.prototype.toString=function(){return"{X: "+this.x+" Y: "+this.y+"}"},e.prototype.getClassName=function(){return"Vector2"},e.prototype.getHashCode=function(){var e=0|this.x;return e=397*e^(0|this.y)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},e.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},e.prototype.set=function(e,t){return this.copyFromFloats(e,t)},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},e.prototype.addVector3=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y)},e.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},e.prototype.multiply=function(t){return new e(this.x*t.x,this.y*t.y)},e.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},e.prototype.multiplyByFloats=function(t,i){return new e(this.x*t,this.y*i)},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y)},e.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.negate=function(){return new e(-this.x,-this.y)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this.x,-1*this.y)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},e.prototype.scale=function(t){var i=new e(0,0);return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,this},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=r.a),e&&n.a.WithinEpsilon(this.x,e.x,t)&&n.a.WithinEpsilon(this.y,e.y,t)},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.normalize=function(){var e=this.length();return 0===e||(this.x/=e,this.y/=e),this},e.prototype.clone=function(){return new e(this.x,this.y)},e.Zero=function(){return new e(0,0)},e.One=function(){return new e(1,1)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},e.CatmullRom=function(t,i,n,r,o){var a=o*o,s=o*a;return new e(.5*(2*i.x+(-t.x+n.x)*o+(2*t.x-5*i.x+4*n.x-r.x)*a+(-t.x+3*i.x-3*n.x+r.x)*s),.5*(2*i.y+(-t.y+n.y)*o+(2*t.y-5*i.y+4*n.y-r.y)*a+(-t.y+3*i.y-3*n.y+r.y)*s))},e.Clamp=function(t,i,n){var r=t.x;r=(r=r>n.x?n.x:r)n.y?n.y:o)i.x?t.x:i.x,t.y>i.y?t.y:i.y)},e.Transform=function(t,i){var n=e.Zero();return e.TransformToRef(t,i,n),n},e.TransformToRef=function(e,t,i){var n=t.m,r=e.x*n[0]+e.y*n[4]+n[12],o=e.x*n[1]+e.y*n[5]+n[13];i.x=r,i.y=o},e.PointInTriangle=function(e,t,i,n){var r=.5*(-i.y*n.x+t.y*(-i.x+n.x)+t.x*(i.y-n.y)+i.x*n.y),o=r<0?-1:1,a=(t.y*n.x-t.x*n.y+(n.y-t.y)*e.x+(t.x-n.x)*e.y)*o,s=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return a>0&&s>0&&a+s<2*r*o},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.DistanceOfPointFromSegment=function(t,i,n){var r=e.DistanceSquared(i,n);if(0===r)return e.Distance(t,i);var o=n.subtract(i),a=Math.max(0,Math.min(1,e.Dot(t.subtract(i),o)/r)),s=i.add(o.multiplyByFloats(a,a));return e.Distance(t,s)},e}(),l=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this._isDirty=!0,this._x=e,this._y=t,this._z=i}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),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.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toQuaternion=function(){return h.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,i){return this.x+=e,this.y+=t,this.z+=i,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,i,n){return new e(this._x-t,this._y-i,this._z-n)},e.prototype.subtractFromFloatsToRef=function(e,t,i,n){return n.copyFromFloats(this._x-e,this._y-t,this._z-i)},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.projectOnPlane=function(t,i){var n=e.Zero();return this.projectOnPlaneToRef(t,i,n),n},e.prototype.projectOnPlaneToRef=function(t,i,n){var r=t.normal,o=t.d,a=f.Vector3[0];this.subtractToRef(i,a),a.normalize();var s=e.Dot(a,r),c=-(e.Dot(i,r)+o)/s,l=a.scaleInPlace(c);i.addToRef(l,n)},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=r.a),e&&n.a.WithinEpsilon(this._x,e._x,t)&&n.a.WithinEpsilon(this._y,e._y,t)&&n.a.WithinEpsilon(this._z,e._z,t)},e.prototype.equalsToFloats=function(e,t,i){return this._x===e&&this._y===t&&this._z===i},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,i,n){return new e(this._x*t,this._y*i,this._z*n)},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,i){return ethis._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this},e.prototype.isNonUniformWithinEpsilon=function(e){var t=Math.abs(this._x),i=Math.abs(this._y);if(!n.a.WithinEpsilon(t,i,e))return!0;var r=Math.abs(this._z);return!n.a.WithinEpsilon(t,r,e)||!n.a.WithinEpsilon(i,r,e)},Object.defineProperty(e.prototype,"isNonUniform",{get:function(){var e=Math.abs(this._x);return e!==Math.abs(this._y)||e!==Math.abs(this._z)},enumerable:!1,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())||(f.Vector3[0].copyFrom(this),["x","y","z"].forEach((function(i,n){t[i]=f.Vector3[0][e[n]]}))),this},e.prototype.rotateByQuaternionToRef=function(t,i){return t.toRotationMatrix(f.Matrix[0]),e.TransformCoordinatesToRef(this,f.Matrix[0],i),i},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,i){return this.subtractToRef(t,f.Vector3[0]),f.Vector3[0].rotateByQuaternionToRef(e,f.Vector3[0]),t.addToRef(f.Vector3[0],i),i},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,i){return this.x=e,this.y=t,this.z=i,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.setAll=function(e){return this.x=this.y=this.z=e,this},e.GetClipFactor=function(t,i,n,r){var o=e.Dot(t,n)-r;return o/(o-(e.Dot(i,n)-r))},e.GetAngleBetweenVectors=function(t,i,n){var r=t.normalizeToRef(f.Vector3[1]),o=i.normalizeToRef(f.Vector3[2]),a=e.Dot(r,o),s=f.Vector3[3];return e.CrossToRef(r,o,s),e.Dot(s,n)>0?Math.acos(a):-Math.acos(a)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromFloatArray=function(t,i){return e.FromArray(t,i)},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},e.FromFloatArrayToRef=function(t,i,n){return e.FromArrayToRef(t,i,n)},e.FromFloatsToRef=function(e,t,i,n){n.copyFromFloats(e,t,i)},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:!1,configurable:!0}),Object.defineProperty(e,"ZeroReadOnly",{get:function(){return e._ZeroReadOnly},enumerable:!1,configurable:!0}),e.Down=function(){return new e(0,-1,0)},e.Forward=function(t){return void 0===t&&(t=!1),new e(0,0,t?-1:1)},e.Backward=function(t){return void 0===t&&(t=!1),new e(0,0,t?1:-1)},e.Right=function(){return new e(1,0,0)},e.Left=function(){return new e(-1,0,0)},e.TransformCoordinates=function(t,i){var n=e.Zero();return e.TransformCoordinatesToRef(t,i,n),n},e.TransformCoordinatesToRef=function(t,i,n){e.TransformCoordinatesFromFloatsToRef(t._x,t._y,t._z,i,n)},e.TransformCoordinatesFromFloatsToRef=function(e,t,i,n,r){var o=n.m,a=e*o[0]+t*o[4]+i*o[8]+o[12],s=e*o[1]+t*o[5]+i*o[9]+o[13],c=e*o[2]+t*o[6]+i*o[10]+o[14],l=1/(e*o[3]+t*o[7]+i*o[11]+o[15]);r.x=a*l,r.y=s*l,r.z=c*l},e.TransformNormal=function(t,i){var n=e.Zero();return e.TransformNormalToRef(t,i,n),n},e.TransformNormalToRef=function(e,t,i){this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,i)},e.TransformNormalFromFloatsToRef=function(e,t,i,n,r){var o=n.m;r.x=e*o[0]+t*o[4]+i*o[8],r.y=e*o[1]+t*o[5]+i*o[9],r.z=e*o[2]+t*o[6]+i*o[10]},e.CatmullRom=function(t,i,n,r,o){var a=o*o,s=o*a;return new e(.5*(2*i._x+(-t._x+n._x)*o+(2*t._x-5*i._x+4*n._x-r._x)*a+(-t._x+3*i._x-3*n._x+r._x)*s),.5*(2*i._y+(-t._y+n._y)*o+(2*t._y-5*i._y+4*n._y-r._y)*a+(-t._y+3*i._y-3*n._y+r._y)*s),.5*(2*i._z+(-t._z+n._z)*o+(2*t._z-5*i._z+4*n._z-r._z)*a+(-t._z+3*i._z-3*n._z+r._z)*s))},e.Clamp=function(t,i,n){var r=new e;return e.ClampToRef(t,i,n,r),r},e.ClampToRef=function(e,t,i,n){var r=e._x;r=(r=r>i._x?i._x:r)i._y?i._y:o)i._z?i._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 l(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,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this},e.prototype.set=function(e,t,i,n){return this.copyFromFloats(e,t,i,n)},e.prototype.setAll=function(e){return this.x=this.y=this.z=this.w=e,this},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},e.FromFloatArrayToRef=function(t,i,n){e.FromArrayToRef(t,i,n)},e.FromFloatsToRef=function(e,t,i,n,r){r.x=e,r.y=t,r.z=i,r.w=n},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 i=e.Zero();return e.NormalizeToRef(t,i),i},e.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},e.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},e.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z,o=e.w-t.w;return i*i+n*n+r*r+o*o},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.TransformNormal=function(t,i){var n=e.Zero();return e.TransformNormalToRef(t,i,n),n},e.TransformNormalToRef=function(e,t,i){var n=t.m,r=e.x*n[0]+e.y*n[4]+e.z*n[8],o=e.x*n[1]+e.y*n[5]+e.z*n[9],a=e.x*n[2]+e.y*n[6]+e.z*n[10];i.x=r,i.y=o,i.z=a,i.w=e.w},e.TransformNormalFromFloatsToRef=function(e,t,i,n,r,o){var a=r.m;o.x=e*a[0]+t*a[4]+i*a[8],o.y=e*a[1]+t*a[5]+i*a[9],o.z=e*a[2]+t*a[6]+i*a[10],o.w=n},e.FromVector3=function(t,i){return void 0===i&&(i=0),new e(t._x,t._y,t._z,i)},e}(),h=function(){function e(e,t,i,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=1),this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=n}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"w",{get:function(){return this._w},set:function(e){this._w=e,this._isDirty=!0},enumerable:!1,configurable:!0}),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=r.a),e&&n.a.WithinEpsilon(this._x,e._x,t)&&n.a.WithinEpsilon(this._y,e._y,t)&&n.a.WithinEpsilon(this._z,e._z,t)&&n.a.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,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this},e.prototype.set=function(e,t,i,n){return this.copyFromFloats(e,t,i,n)},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 i=new e(0,0,0,1);return this.multiplyToRef(t,i),i},e.prototype.multiplyToRef=function(e,t){var i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,n=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,r=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(i,n,r,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=l.Zero();return this.toEulerAnglesToRef(t),t},e.prototype.toEulerAnglesToRef=function(e){var t=this._z,i=this._x,n=this._y,r=this._w,o=r*r,a=t*t,s=i*i,c=n*n,l=n*t-i*r;return l<-.4999999?(e.y=2*Math.atan2(n,r),e.x=Math.PI/2,e.z=0):l>.4999999?(e.y=2*Math.atan2(n,r),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(i*n+t*r),-a-s+c+o),e.x=Math.asin(-2*(t*n-i*r)),e.y=Math.atan2(2*(t*i+n*r),a-s-c+o)),this},e.prototype.toRotationMatrix=function(e){return d.FromQuaternionToRef(this,e),this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,n=e.m,r=n[0],o=n[4],a=n[8],s=n[1],c=n[5],l=n[9],u=n[2],h=n[6],d=n[10],f=r+c+d;f>0?(i=.5/Math.sqrt(f+1),t.w=.25/i,t.x=(h-l)*i,t.y=(a-u)*i,t.z=(s-o)*i):r>c&&r>d?(i=2*Math.sqrt(1+r-c-d),t.w=(h-l)/i,t.x=.25*i,t.y=(o+s)/i,t.z=(a+u)/i):c>d?(i=2*Math.sqrt(1+c-r-d),t.w=(a-u)/i,t.x=(o+s)/i,t.y=.25*i,t.z=(l+h)/i):(i=2*Math.sqrt(1+d-r-c),t.w=(s-o)/i,t.x=(a+u)/i,t.y=(l+h)/i,t.z=.25*i)},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,i){return e.Dot(t,i)>=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,i){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var n=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e._x*n,i.y=e._y*n,i.z=e._z*n,i},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},e.FromEulerAngles=function(t,i,n){var r=new e;return e.RotationYawPitchRollToRef(i,t,n,r),r},e.FromEulerAnglesToRef=function(t,i,n,r){return e.RotationYawPitchRollToRef(i,t,n,r),r},e.FromEulerVector=function(t){var i=new e;return e.RotationYawPitchRollToRef(t._y,t._x,t._z,i),i},e.FromEulerVectorToRef=function(t,i){return e.RotationYawPitchRollToRef(t._y,t._x,t._z,i),i},e.RotationYawPitchRoll=function(t,i,n){var r=new e;return e.RotationYawPitchRollToRef(t,i,n,r),r},e.RotationYawPitchRollToRef=function(e,t,i,n){var r=.5*i,o=.5*t,a=.5*e,s=Math.sin(r),c=Math.cos(r),l=Math.sin(o),u=Math.cos(o),h=Math.sin(a),d=Math.cos(a);n.x=d*l*c+h*u*s,n.y=h*u*c-d*l*s,n.z=d*u*s-h*l*c,n.w=d*u*c+h*l*s},e.RotationAlphaBetaGamma=function(t,i,n){var r=new e;return e.RotationAlphaBetaGammaToRef(t,i,n,r),r},e.RotationAlphaBetaGammaToRef=function(e,t,i,n){var r=.5*(i+e),o=.5*(i-e),a=.5*t;n.x=Math.cos(o)*Math.sin(a),n.y=Math.sin(o)*Math.sin(a),n.z=Math.sin(r)*Math.cos(a),n.w=Math.cos(r)*Math.cos(a)},e.RotationQuaternionFromAxis=function(t,i,n){var r=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,i,n,r),r},e.RotationQuaternionFromAxisToRef=function(t,i,n,r){var o=f.Matrix[0];d.FromXYZAxesToRef(t.normalize(),i.normalize(),n.normalize(),o),e.FromRotationMatrixToRef(o,r)},e.Slerp=function(t,i,n){var r=e.Identity();return e.SlerpToRef(t,i,n,r),r},e.SlerpToRef=function(e,t,i,n){var r,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-i,r=s?-i:i;else{var c=Math.acos(a),l=1/Math.sin(c);o=Math.sin((1-i)*c)*l,r=s?-Math.sin(i*c)*l:Math.sin(i*c)*l}n.x=o*e._x+r*t._x,n.y=o*e._y+r*t._y,n.z=o*e._z+r*t._z,n.w=o*e._w+r*t._w},e.Hermite=function(t,i,n,r,o){var a=o*o,s=o*a,c=2*s-3*a+1,l=-2*s+3*a,u=s-2*a+o,h=s-a;return new e(t._x*c+n._x*l+i._x*u+r._x*h,t._y*c+n._y*l+i._y*u+r._y*h,t._z*c+n._z*l+i._z*u+r._z*h,t._w*c+n._w*l+i._w*u+r._w*h)},e}(),d=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,s.a.MatrixTrackPrecisionChange&&s.a.MatrixTrackedMatrices.push(this),this._m=new s.a.MatrixCurrentType(16),this._updateIdentityStatus(!1)}return Object.defineProperty(e,"Use64Bits",{get:function(){return s.a.MatrixUse64Bits},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"m",{get:function(){return this._m},enumerable:!1,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,i,n,r){void 0===i&&(i=!1),void 0===n&&(n=!1),void 0===r&&(r=!0),this.updateFlag=e._updateFlagSeed++,this._isIdentity=t,this._isIdentity3x2=t||n,this._isIdentityDirty=!this._isIdentity&&i,this._isIdentity3x2Dirty=!this._isIdentity3x2&&r},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],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],s=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],p=e[13],_=e[14],m=e[15],g=h*m-_*d,v=u*m-p*d,b=u*_-p*h,y=l*m-f*d,T=l*_-h*f,E=l*p-f*u;return t*+(a*g-s*v+c*b)+i*-(o*g-s*y+c*T)+n*+(o*v-a*y+c*E)+r*-(o*b-a*T+s*E)},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 i=new e;return this.addToRef(t,i),i},e.prototype.addToRef=function(e,t){for(var i=this._m,n=t._m,r=e.m,o=0;o<16;o++)n[o]=i[o]+r[o];return t._markAsUpdated(),this},e.prototype.addToSelf=function(e){for(var t=this._m,i=e.m,n=0;n<16;n++)t[n]+=i[n];return this._markAsUpdated(),this},e.prototype.invertToRef=function(t){if(!0===this._isIdentity)return e.IdentityToRef(t),this;var i=this._m,n=i[0],r=i[1],o=i[2],a=i[3],s=i[4],c=i[5],l=i[6],u=i[7],h=i[8],d=i[9],f=i[10],p=i[11],_=i[12],m=i[13],g=i[14],v=i[15],b=f*v-g*p,y=d*v-m*p,T=d*g-m*f,E=h*v-_*p,S=h*g-f*_,A=h*m-_*d,P=+(c*b-l*y+u*T),C=-(s*b-l*E+u*S),R=+(s*y-c*E+u*A),x=-(s*T-c*S+l*A),O=n*P+r*C+o*R+a*x;if(0===O)return t.copyFrom(this),this;var M=1/O,I=l*v-g*u,D=c*v-m*u,N=c*g-m*l,L=s*v-_*u,w=s*g-_*l,F=s*m-_*c,B=l*p-f*u,U=c*p-d*u,V=c*f-d*l,k=s*p-h*u,z=s*f-h*l,G=s*d-h*c,j=-(r*b-o*y+a*T),W=+(n*b-o*E+a*S),H=-(n*y-r*E+a*A),X=+(n*T-r*S+o*A),Y=+(r*I-o*D+a*N),K=-(n*I-o*L+a*w),Q=+(n*D-r*L+a*F),q=-(n*N-r*w+o*F),Z=-(r*B-o*U+a*V),J=+(n*B-o*k+a*z),$=-(n*U-r*k+a*G),ee=+(n*V-r*z+o*G);return e.FromValuesToRef(P*M,j*M,Y*M,Z*M,C*M,W*M,K*M,J*M,R*M,H*M,Q*M,$*M,x*M,X*M,q*M,ee*M,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,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this._markAsUpdated(),this},e.prototype.addTranslationFromFloats=function(e,t,i){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=i,this._markAsUpdated(),this},e.prototype.setTranslation=function(e){return this.setTranslationFromFloats(e._x,e._y,e._z)},e.prototype.getTranslation=function(){return new l(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 i=new e;return this.multiplyToRef(t,i),i},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 i=this._m;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[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,i){var n=this._m,r=e.m,o=n[0],a=n[1],s=n[2],c=n[3],l=n[4],u=n[5],h=n[6],d=n[7],f=n[8],p=n[9],_=n[10],m=n[11],g=n[12],v=n[13],b=n[14],y=n[15],T=r[0],E=r[1],S=r[2],A=r[3],P=r[4],C=r[5],R=r[6],x=r[7],O=r[8],M=r[9],I=r[10],D=r[11],N=r[12],L=r[13],w=r[14],F=r[15];return t[i]=o*T+a*P+s*O+c*N,t[i+1]=o*E+a*C+s*M+c*L,t[i+2]=o*S+a*R+s*I+c*w,t[i+3]=o*A+a*x+s*D+c*F,t[i+4]=l*T+u*P+h*O+d*N,t[i+5]=l*E+u*C+h*M+d*L,t[i+6]=l*S+u*R+h*I+d*w,t[i+7]=l*A+u*x+h*D+d*F,t[i+8]=f*T+p*P+_*O+m*N,t[i+9]=f*E+p*C+_*M+m*L,t[i+10]=f*S+p*R+_*I+m*w,t[i+11]=f*A+p*x+_*D+m*F,t[i+12]=g*T+v*P+b*O+y*N,t[i+13]=g*E+v*C+b*M+y*L,t[i+14]=g*S+v*R+b*I+y*w,t[i+15]=g*A+v*x+b*D+y*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 i=this.m,n=t.m;return i[0]===n[0]&&i[1]===n[1]&&i[2]===n[2]&&i[3]===n[3]&&i[4]===n[4]&&i[5]===n[5]&&i[6]===n[6]&&i[7]===n[7]&&i[8]===n[8]&&i[9]===n[9]&&i[10]===n[10]&&i[11]===n[11]&&i[12]===n[12]&&i[13]===n[13]&&i[14]===n[14]&&i[15]===n[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,i,n){if(this._isIdentity)return n&&n.setAll(0),t&&t.setAll(1),i&&i.copyFromFloats(0,0,0,1),!0;var r=this._m;if(n&&n.copyFromFloats(r[12],r[13],r[14]),(t=t||f.Vector3[0]).x=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),t.y=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),t.z=Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[10]),this.determinant()<=0&&(t.y*=-1),0===t._x||0===t._y||0===t._z)return i&&i.copyFromFloats(0,0,0,1),!1;if(i){var o=1/t._x,a=1/t._y,s=1/t._z;e.FromValuesToRef(r[0]*o,r[1]*o,r[2]*o,0,r[4]*a,r[5]*a,r[6]*a,0,r[8]*s,r[9]*s,r[10]*s,0,0,0,0,1,f.Matrix[0]),h.FromRotationMatrixToRef(f.Matrix[0],i)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new u(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,i,n,r){if(e<0||e>3)return this;var o=4*e;return this._m[o+0]=t,this._m[o+1]=i,this._m[o+2]=n,this._m[o+3]=r,this._markAsUpdated(),this},e.prototype.scale=function(t){var i=new e;return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]=this._m[i]*e;return t._markAsUpdated(),this},e.prototype.scaleAndAddToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]+=this._m[i]*e;return t._markAsUpdated(),this},e.prototype.toNormalMatrix=function(t){var i=f.Matrix[0];this.invertToRef(i),i.transposeToRef(t);var n=t._m;e.FromValuesToRef(n[0],n[1],n[2],0,n[4],n[5],n[6],0,n[8],n[9],n[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 i=f.Vector3[0];if(!this.decompose(i))return e.IdentityToRef(t),this;var n=this._m,r=1/i._x,o=1/i._y,a=1/i._z;return e.FromValuesToRef(n[0]*r,n[1]*r,n[2]*r,0,n[4]*o,n[5]*o,n[6]*o,0,n[8]*a,n[9]*a,n[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,i){void 0===i&&(i=0);var n=new e;return e.FromArrayToRef(t,i,n),n},e.FromArrayToRef=function(e,t,i){for(var n=0;n<16;n++)i._m[n]=e[n+t];i._markAsUpdated()},e.FromFloat32ArrayToRefScaled=function(e,t,i,n){for(var r=0;r<16;r++)n._m[r]=e[r+t]*i;n._markAsUpdated()},Object.defineProperty(e,"IdentityReadOnly",{get:function(){return e._identityReadOnly},enumerable:!1,configurable:!0}),e.FromValuesToRef=function(e,t,i,n,r,o,a,s,c,l,u,h,d,f,p,_,m){var g=m._m;g[0]=e,g[1]=t,g[2]=i,g[3]=n,g[4]=r,g[5]=o,g[6]=a,g[7]=s,g[8]=c,g[9]=l,g[10]=u,g[11]=h,g[12]=d,g[13]=f,g[14]=p,g[15]=_,m._markAsUpdated()},e.FromValues=function(t,i,n,r,o,a,s,c,l,u,h,d,f,p,_,m){var g=new e,v=g._m;return v[0]=t,v[1]=i,v[2]=n,v[3]=r,v[4]=o,v[5]=a,v[6]=s,v[7]=c,v[8]=l,v[9]=u,v[10]=h,v[11]=d,v[12]=f,v[13]=p,v[14]=_,v[15]=m,g._markAsUpdated(),g},e.Compose=function(t,i,n){var r=new e;return e.ComposeToRef(t,i,n,r),r},e.ComposeToRef=function(e,t,i,n){var r=n._m,o=t._x,a=t._y,s=t._z,c=t._w,l=o+o,u=a+a,h=s+s,d=o*l,f=o*u,p=o*h,_=a*u,m=a*h,g=s*h,v=c*l,b=c*u,y=c*h,T=e._x,E=e._y,S=e._z;r[0]=(1-(_+g))*T,r[1]=(f+y)*T,r[2]=(p-b)*T,r[3]=0,r[4]=(f-y)*E,r[5]=(1-(d+g))*E,r[6]=(m+v)*E,r[7]=0,r[8]=(p+b)*S,r[9]=(m-v)*S,r[10]=(1-(d+_))*S,r[11]=0,r[12]=i._x,r[13]=i._y,r[14]=i._z,r[15]=1,n._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 i=new e;return e.RotationXToRef(t,i),i},e.Invert=function(t){var i=new e;return t.invertToRef(i),i},e.RotationXToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(1,0,0,0,0,r,n,0,0,-n,r,0,0,0,0,1,i),i._updateIdentityStatus(1===r&&0===n)},e.RotationY=function(t){var i=new e;return e.RotationYToRef(t,i),i},e.RotationYToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(r,0,-n,0,0,1,0,0,n,0,r,0,0,0,0,1,i),i._updateIdentityStatus(1===r&&0===n)},e.RotationZ=function(t){var i=new e;return e.RotationZToRef(t,i),i},e.RotationZToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(r,n,0,0,-n,r,0,0,0,0,1,0,0,0,0,1,i),i._updateIdentityStatus(1===r&&0===n)},e.RotationAxis=function(t,i){var n=new e;return e.RotationAxisToRef(t,i,n),n},e.RotationAxisToRef=function(e,t,i){var n=Math.sin(-t),r=Math.cos(-t),o=1-r;e.normalize();var a=i._m;a[0]=e._x*e._x*o+r,a[1]=e._x*e._y*o-e._z*n,a[2]=e._x*e._z*o+e._y*n,a[3]=0,a[4]=e._y*e._x*o+e._z*n,a[5]=e._y*e._y*o+r,a[6]=e._y*e._z*o-e._x*n,a[7]=0,a[8]=e._z*e._x*o-e._y*n,a[9]=e._z*e._y*o+e._x*n,a[10]=e._z*e._z*o+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,i._markAsUpdated()},e.RotationAlignToRef=function(e,t,i){var n=l.Cross(t,e),r=l.Dot(t,e),o=1/(1+r),a=i._m;a[0]=n._x*n._x*o+r,a[1]=n._y*n._x*o-n._z,a[2]=n._z*n._x*o+n._y,a[3]=0,a[4]=n._x*n._y*o+n._z,a[5]=n._y*n._y*o+r,a[6]=n._z*n._y*o-n._x,a[7]=0,a[8]=n._x*n._z*o-n._y,a[9]=n._y*n._z*o+n._x,a[10]=n._z*n._z*o+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,i._markAsUpdated()},e.RotationYawPitchRoll=function(t,i,n){var r=new e;return e.RotationYawPitchRollToRef(t,i,n,r),r},e.RotationYawPitchRollToRef=function(e,t,i,n){h.RotationYawPitchRollToRef(e,t,i,f.Quaternion[0]),f.Quaternion[0].toRotationMatrix(n)},e.Scaling=function(t,i,n){var r=new e;return e.ScalingToRef(t,i,n,r),r},e.ScalingToRef=function(t,i,n,r){e.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,n,0,0,0,0,1,r),r._updateIdentityStatus(1===t&&1===i&&1===n)},e.Translation=function(t,i,n){var r=new e;return e.TranslationToRef(t,i,n,r),r},e.TranslationToRef=function(t,i,n,r){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,n,1,r),r._updateIdentityStatus(0===t&&0===i&&0===n)},e.Lerp=function(t,i,n){var r=new e;return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){for(var r=n._m,o=e.m,a=t.m,s=0;s<16;s++)r[s]=o[s]*(1-i)+a[s]*i;n._markAsUpdated()},e.DecomposeLerp=function(t,i,n){var r=new e;return e.DecomposeLerpToRef(t,i,n,r),r},e.DecomposeLerpToRef=function(t,i,n,r){var o=f.Vector3[0],a=f.Quaternion[0],s=f.Vector3[1];t.decompose(o,a,s);var c=f.Vector3[2],u=f.Quaternion[1],d=f.Vector3[3];i.decompose(c,u,d);var p=f.Vector3[4];l.LerpToRef(o,c,n,p);var _=f.Quaternion[2];h.SlerpToRef(a,u,n,_);var m=f.Vector3[5];l.LerpToRef(s,d,n,m),e.ComposeToRef(p,_,m,r)},e.LookAtLH=function(t,i,n){var r=new e;return e.LookAtLHToRef(t,i,n,r),r},e.LookAtLHToRef=function(t,i,n,r){var o=f.Vector3[0],a=f.Vector3[1],s=f.Vector3[2];i.subtractToRef(t,s),s.normalize(),l.CrossToRef(n,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),l.CrossToRef(s,o,a),a.normalize();var u=-l.Dot(o,t),h=-l.Dot(a,t),d=-l.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,u,h,d,1,r)},e.LookAtRH=function(t,i,n){var r=new e;return e.LookAtRHToRef(t,i,n,r),r},e.LookAtRHToRef=function(t,i,n,r){var o=f.Vector3[0],a=f.Vector3[1],s=f.Vector3[2];t.subtractToRef(i,s),s.normalize(),l.CrossToRef(n,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),l.CrossToRef(s,o,a),a.normalize();var u=-l.Dot(o,t),h=-l.Dot(a,t),d=-l.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,u,h,d,1,r)},e.OrthoLH=function(t,i,n,r){var o=new e;return e.OrthoLHToRef(t,i,n,r,o),o},e.OrthoLHToRef=function(t,i,n,r,o){var a=2/t,s=2/i,c=2/(r-n),l=-(r+n)/(r-n);e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,c,0,0,0,l,1,o),o._updateIdentityStatus(1===a&&1===s&&1===c&&0===l)},e.OrthoOffCenterLH=function(t,i,n,r,o,a){var s=new e;return e.OrthoOffCenterLHToRef(t,i,n,r,o,a,s),s},e.OrthoOffCenterLHToRef=function(t,i,n,r,o,a,s){var c=2/(i-t),l=2/(r-n),u=2/(a-o),h=-(a+o)/(a-o),d=(t+i)/(t-i),f=(r+n)/(n-r);e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,u,0,d,f,h,1,s),s._markAsUpdated()},e.OrthoOffCenterRH=function(t,i,n,r,o,a){var s=new e;return e.OrthoOffCenterRHToRef(t,i,n,r,o,a,s),s},e.OrthoOffCenterRHToRef=function(t,i,n,r,o,a,s){e.OrthoOffCenterLHToRef(t,i,n,r,o,a,s),s._m[10]*=-1},e.PerspectiveLH=function(t,i,n,r){var o=new e,a=2*n/t,s=2*n/i,c=(r+n)/(r-n),l=-2*r*n/(r-n);return e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,c,1,0,0,l,0,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovLH=function(t,i,n,r){var o=new e;return e.PerspectiveFovLHToRef(t,i,n,r,o),o},e.PerspectiveFovLHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=n,c=r,l=1/Math.tan(.5*t),u=a?l/i:l,h=a?l:l*i,d=(c+s)/(c-s),f=-2*c*s/(c-s);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseLHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),c=a?s/i:s,l=a?s:s*i;e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,-n,1,0,0,1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovRH=function(t,i,n,r){var o=new e;return e.PerspectiveFovRHToRef(t,i,n,r,o),o},e.PerspectiveFovRHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=n,c=r,l=1/Math.tan(.5*t),u=a?l/i:l,h=a?l:l*i,d=-(c+s)/(c-s),f=-2*c*s/(c-s);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,-1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseRHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),c=a?s/i:s,l=a?s:s*i;e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,-n,-1,0,0,-1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovWebVRToRef=function(e,t,i,n,r){void 0===r&&(r=!1);var o=r?-1:1,a=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),c=Math.tan(e.leftDegrees*Math.PI/180),l=Math.tan(e.rightDegrees*Math.PI/180),u=2/(c+l),h=2/(a+s),d=n._m;d[0]=u,d[1]=d[2]=d[3]=d[4]=0,d[5]=h,d[6]=d[7]=0,d[8]=(c-l)*u*.5,d[9]=-(a-s)*h*.5,d[10]=-i/(t-i),d[11]=1*o,d[12]=d[13]=d[15]=0,d[14]=-2*i*t/(i-t),n._markAsUpdated()},e.GetFinalMatrix=function(t,i,n,r,o,a){var s=t.width,c=t.height,l=t.x,u=t.y,h=e.FromValues(s/2,0,0,0,0,-c/2,0,0,0,0,a-o,0,l+s/2,c/2+u,o,1),d=f.Matrix[0];return i.multiplyToRef(n,d),d.multiplyToRef(r,d),d.multiply(h)},e.GetAsMatrix2x2=function(e){var t=e.m,i=[t[0],t[1],t[4],t[5]];return s.a.MatrixUse64Bits?i:new Float32Array(i)},e.GetAsMatrix3x3=function(e){var t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return s.a.MatrixUse64Bits?i:new Float32Array(i)},e.Transpose=function(t){var i=new e;return e.TransposeToRef(t,i),i},e.TransposeToRef=function(e,t){var i=t._m,n=e.m;i[0]=n[0],i[1]=n[4],i[2]=n[8],i[3]=n[12],i[4]=n[1],i[5]=n[5],i[6]=n[9],i[7]=n[13],i[8]=n[2],i[9]=n[6],i[10]=n[10],i[11]=n[14],i[12]=n[3],i[13]=n[7],i[14]=n[11],i[15]=n[15],t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty)},e.Reflection=function(t){var i=new e;return e.ReflectionToRef(t,i),i},e.ReflectionToRef=function(t,i){t.normalize();var n=t.normal.x,r=t.normal.y,o=t.normal.z,a=-2*n,s=-2*r,c=-2*o;e.FromValuesToRef(a*n+1,s*n,c*n,0,a*r,s*r+1,c*r,0,a*o,s*o,c*o+1,0,a*t.d,s*t.d,c*t.d,1,i)},e.FromXYZAxesToRef=function(t,i,n,r){e.FromValuesToRef(t._x,t._y,t._z,0,i._x,i._y,i._z,0,n._x,n._y,n._z,0,0,0,0,1,r)},e.FromQuaternionToRef=function(e,t){var i=e._x*e._x,n=e._y*e._y,r=e._z*e._z,o=e._x*e._y,a=e._z*e._w,s=e._z*e._x,c=e._y*e._w,l=e._y*e._z,u=e._x*e._w;t._m[0]=1-2*(n+r),t._m[1]=2*(o+a),t._m[2]=2*(s-c),t._m[3]=0,t._m[4]=2*(o-a),t._m[5]=1-2*(r+i),t._m[6]=2*(l+u),t._m[7]=0,t._m[8]=2*(s+c),t._m[9]=2*(l-u),t._m[10]=1-2*(n+i),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}(),f=function(){function e(){}return e.Vector3=o.a.BuildArray(6,l.Zero),e.Matrix=o.a.BuildArray(2,d.Identity),e.Quaternion=o.a.BuildArray(3,h.Zero),e}(),p=function(){function e(){}return e.Vector2=o.a.BuildArray(3,c.Zero),e.Vector3=o.a.BuildArray(13,l.Zero),e.Vector4=o.a.BuildArray(3,u.Zero),e.Quaternion=o.a.BuildArray(2,h.Zero),e.Matrix=o.a.BuildArray(8,d.Identity),e}();a.a.RegisteredTypes["BABYLON.Vector2"]=c,a.a.RegisteredTypes["BABYLON.Vector3"]=l,a.a.RegisteredTypes["BABYLON.Vector4"]=u,a.a.RegisteredTypes["BABYLON.Matrix"]=d},function(e,t,i){"use strict";i.d(t,"d",(function(){return r})),i.d(t,"a",(function(){return o})),i.d(t,"c",(function(){return a})),i.d(t,"b",(function(){return s})),i.d(t,"e",(function(){return c})),i.d(t,"f",(function(){return l})); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)};function r(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var o=function(){return(o=Object.assign||function(e){for(var t,i=1,n=arguments.length;i=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}function s(e,t,i,n){return new(i||(i=Promise))((function(r,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=2?"WEBGL2":"WEBGL1"};this._loadShader(m,"Vertex","",(function(e){_._rawVertexSourceCode=e,_._loadShader(g,"Fragment","Pixel",(function(i){_._rawFragmentSourceCode=i,s.a.Process(e,E,(function(e){v&&(e=v("vertex",e)),E.isFragment=!0,s.a.Process(i,E,(function(i){v&&(i=v("fragment",i)),_._useFinalCode(e,i,t)}),_._engine)}),_._engine)}))}))}return Object.defineProperty(e.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new n.c),this._onBindObservable},enumerable:!1,configurable:!0}),e.prototype._useFinalCode=function(e,t,i){if(i){var n=i.vertexElement||i.vertex||i.spectorName||i,r=i.fragmentElement||i.fragment||i.spectorName||i;this._vertexSourceCode="#define SHADER_NAME vertex:"+n+"\n"+e,this._fragmentSourceCode="#define SHADER_NAME fragment:"+r+"\n"+t}else this._vertexSourceCode=e,this._fragmentSourceCode=t;this._prepareEffect()},Object.defineProperty(e.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),e.prototype.isReady=function(){try{return this._isReadyInternal()}catch(e){return!1}},e.prototype._isReadyInternal=function(){return!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady},e.prototype.getEngine=function(){return this._engine},e.prototype.getPipelineContext=function(){return this._pipelineContext},e.prototype.getAttributesNames=function(){return this._attributesNames},e.prototype.getAttributeLocation=function(e){return this._attributes[e]},e.prototype.getAttributeLocationByName=function(e){return this._attributeLocationByName[e]},e.prototype.getAttributesCount=function(){return this._attributes.length},e.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},e.prototype.getUniform=function(e){return this._uniforms[e]},e.prototype.getSamplers=function(){return this._samplerList},e.prototype.getUniformNames=function(){return this._uniformsNames},e.prototype.getUniformBuffersNames=function(){return this._uniformBuffersNamesList},e.prototype.getIndexParameters=function(){return this._indexParameters},e.prototype.getCompilationError=function(){return this._compilationError},e.prototype.allFallbacksProcessed=function(){return this._allFallbacksProcessed},e.prototype.executeWhenCompiled=function(e){var t=this;this.isReady()?e(this):(this.onCompileObservable.add((function(t){e(t)})),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout((function(){t._checkIsReady(null)}),16))},e.prototype._checkIsReady=function(e){var t=this;try{if(this._isReadyInternal())return}catch(t){return void this._processCompilationErrors(t,e)}setTimeout((function(){t._checkIsReady(e)}),16)},e.prototype._loadShader=function(t,i,n,r){var a;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return void r(o.a.GetDOMTextContent(t));"source:"!==t.substr(0,7)?"base64:"!==t.substr(0,7)?e.ShadersStore[t+i+"Shader"]?r(e.ShadersStore[t+i+"Shader"]):n&&e.ShadersStore[t+n+"Shader"]?r(e.ShadersStore[t+n+"Shader"]):(a="."===t[0]||"/"===t[0]||t.indexOf("http")>-1?t:e.ShadersRepository+t,this._engine._loadFile(a+"."+i.toLowerCase()+".fx",r)):r(window.atob(t.substr(7))):r(t.substr(7))},Object.defineProperty(e.prototype,"vertexSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._vertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fragmentSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._fragmentSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawVertexSourceCode",{get:function(){return this._rawVertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawFragmentSourceCode",{get:function(){return this._rawFragmentSourceCode},enumerable:!1,configurable:!0}),e.prototype._rebuildProgram=function(e,t,i,n){var o=this;this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=function(e,t){n&&n(t)},this.onCompiled=function(){var e=o.getEngine().scenes;if(e)for(var t=0;t=a&&(r="Offending line ["+a+"] in "+(i?"fragment":"vertex")+" code: "+s[a-1])}}return[e,r]},e.prototype._processCompilationErrors=function(t,i){var n,r,o,s,c;void 0===i&&(i=null),this._compilationError=t.message;var l=this._attributesNames,u=this._fallbacks;if(a.a.Error("Unable to compile effect:"),a.a.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),a.a.Error("Attributes: "+l.map((function(e){return" "+e}))),a.a.Error("Defines:\r\n"+this.defines),e.LogShaderCodeOnCompilationError){var h=null,d=null,f=null;(null===(o=this._pipelineContext)||void 0===o?void 0:o._getVertexShaderCode())&&(f=(n=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1))[0],h=n[1],f&&(a.a.Error("Vertex code:"),a.a.Error(f))),(null===(s=this._pipelineContext)||void 0===s?void 0:s._getFragmentShaderCode())&&(f=(r=this._getShaderCodeAndErrorLine(null===(c=this._pipelineContext)||void 0===c?void 0:c._getFragmentShaderCode(),this._compilationError,!0))[0],d=r[1],f&&(a.a.Error("Fragment code:"),a.a.Error(f))),h&&a.a.Error(h),d&&a.a.Error(d)}a.a.Error("Error: "+this._compilationError),i&&(this._pipelineContext=i,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)),u?(this._pipelineContext=null,u.hasMoreFallbacks?(this._allFallbacksProcessed=!1,a.a.Error("Trying next fallback."),this.defines=u.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):this._allFallbacksProcessed=!0},Object.defineProperty(e.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!1,configurable:!0}),e.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers[e],t)},e.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t)},e.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers[e],this._uniforms[e],t)},e.prototype.setTextureArray=function(e,t){var i=e+"Ex";if(-1===this._samplerList.indexOf(i+"0")){for(var n=this._samplerList.indexOf(e),r=1;r0},e.prototype.clear=function(){this._observers=new Array,this._onObserverAdded=null},e.prototype.clone=function(){var t=new e;return t._observers=this._observers.slice(0),t},e.prototype.hasSpecificMask=function(e){void 0===e&&(e=-1);for(var t=0,i=this._observers;t0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasThinInstances",{get:function(){var e;return(null!==(e=this._thinInstanceDataStorage.instancesCount)&&void 0!==e?e:0)>0},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._internalMeshDataInfo._source},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cloneMeshMap",{get:function(){return this._internalMeshDataInfo.meshMap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manualUpdateOfWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.manualUpdate},set:function(e){this._instanceDataStorage.manualUpdate=e},enumerable:!1,configurable:!0}),t.prototype.instantiateHierarchy=function(e,t,i){void 0===e&&(e=null);var n=!(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));n&&(n.parent=e||this.parent,n.position=this.position.clone(),n.scaling=this.scaling.clone(),this.rotationQuaternion?n.rotationQuaternion=this.rotationQuaternion.clone():n.rotation=this.rotation.clone(),i&&i(this,n));for(var r=0,o=this.getChildTransformNodes(!0);r0},enumerable:!1,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 E.a.Warn("You cannot use a mesh as LOD level twice"),this;var i=new C.a(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this},t.prototype.getLODLevelAtDistance=function(e){for(var t=this._internalMeshDataInfo,i=0;ir)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this),this;for(var o=0;o0||this.hasThinInstances);this.computeWorldMatrix();var d=this.material||u.defaultMaterial;if(d)if(d._storeEffectOnSubMeshes)for(var f=0,p=this.subMeshes;f0){var i=this.getIndices();if(!i)return null;var n=i.length,r=!1;if(e)r=!0;else for(var o=0,a=this.subMeshes;on){r=!0;break}if(s.verticesStart+s.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new _.a(0,0,t,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),i=t/e|0,n=0;i%3!=0;)i++;this.releaseSubMeshes();for(var r=0;r=t);r++)_.a.CreateFromIndices(0,n,r===e-1?t-n:i,this),n+=i;this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,t,i,n){if(void 0===i&&(i=!1),this._geometry)this._geometry.setVerticesData(e,t,i,n);else{var r=new d.a;r.set(t,e);var o=this.getScene();new f.a(f.a.RandomId(),o,r,i,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 i=this.getVertexBuffer(e);i&&i.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},t.prototype.setVerticesBuffer=function(e){return this._geometry||(this._geometry=f.a.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e),this},t.prototype.updateVerticesData=function(e,t,i,n){return this._geometry?(n?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this},t.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var i=this.getVerticesData(h.b.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(h.b.PositionKind,i,!1,!1),t){var n=this.getIndices(),r=this.getVerticesData(h.b.NormalKind);if(!r)return this;d.a.ComputeNormals(i,n,r),this.updateVerticesData(h.b.NormalKind,r,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;if(1===this._geometry.meshes.length)return this;var e=this._geometry,t=this._geometry.copy(f.a.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},t.prototype.setIndices=function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=!1),this._geometry)this._geometry.setIndices(e,t,i);else{var n=new d.a;n.indices=e;var r=this.getScene();new f.a(f.a.RandomId(),r,n,i,this)}return this},t.prototype.updateIndices=function(e,t,i){return void 0===i&&(i=!1),this._geometry?(this._geometry.updateIndices(e,t,i),this):this},t.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},t.prototype._bind=function(e,t,i){if(!this._geometry)return this;var n,r=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(i){case g.a.PointFillMode:n=null;break;case g.a.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case g.a.TriangleFillMode:n=this._geometry.getIndexBuffer()}return this._geometry._bind(t,n),this},t.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();return this._unIndexed||t==g.a.PointFillMode?n.drawArraysType(t,e.verticesStart,e.verticesCount,i):t==g.a.WireFrameFillMode?n.drawElementsType(t,0,e._linesIndexCount,i):n.drawElementsType(t,e.indexStart,e.indexCount,i),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 i=this.getScene(),n=i._isInIntermediateRendering(),r=n?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=this._instanceDataStorage.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!r&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){var a=this._instanceDataStorage.visibleInstances,s=i.getRenderId(),c=n?a.intermediateDefaultRenderId:a.defaultRenderId;o.visibleInstances[e]=a[s],!o.visibleInstances[e]&&c&&(o.visibleInstances[e]=a[c])}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,i,n,r){var o=i.visibleInstances[e._id];if(!o)return this;for(var a=this._instanceDataStorage,s=a.instancesBufferSize,c=a.instancesBuffer,l=16*(o.length+1)*4;a.instancesBufferSizeu&&n++,0!==_&&f++,d+=_,u=_}if(c[f]++,f>o&&(o=f),0===d)r++;else{var m=1/d,g=0;for(p=0;p.001&&a++}}var v=this.skeleton.bones.length,b=this.getVerticesData(h.b.MatricesIndicesKind),y=this.getVerticesData(h.b.MatricesIndicesExtraKind),T=0;for(l=0;l=v||E<0)&&T++}return{skinned:!0,valid:0===r&&0===a&&0===T,report:"Number of Weights = "+i/4+"\nMaximum influences = "+o+"\nMissing Weights = "+r+"\nNot Sorted = "+n+"\nNot Normalized = "+a+"\nWeightCounts = ["+c+"]\nNumber of bones = "+v+"\nBad Bone Indices = "+T}},t.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===y.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=y.a.DELAYLOADSTATE_LOADING,this._queueLoad(e)),this},t.prototype._queueLoad=function(e){var t=this;e._addPendingData(this);var i=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return o.b.LoadFile(this.delayLoadingFile,(function(i){i instanceof ArrayBuffer?t._delayLoadingFunction(i,t):t._delayLoadingFunction(JSON.parse(i),t),t.instances.forEach((function(e){e.refreshBoundingInfo(),e._syncSubMeshes()})),t.delayLoadState=y.a.DELAYLOADSTATE_LOADED,e._removePendingData(t)}),(function(){}),e.offlineProvider,i),this},t.prototype.isInFrustum=function(t){return this.delayLoadState!==y.a.DELAYLOADSTATE_LOADING&&(!!e.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},t.prototype.setMaterialByID=function(e){var t,i=this.getScene().materials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;var n=this.getScene().multiMaterials;for(t=n.length-1;t>-1;t--)if(n[t].id===e)return this.material=n[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(h.b.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,n=this.getVerticesData(h.b.PositionKind),r=new Array;for(i=0;i1)for(var n=0,r=i.meshes.slice(0);n-1&&(r.morphTargetManager=i.getMorphTargetManagerById(e.morphTargetManagerId)),void 0!==e.skeletonId&&null!==e.skeletonId&&(r.skeleton=i.getLastSkeletonByID(e.skeletonId),e.numBoneInfluencers&&(r.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o4,d=u?this.getVerticesData(h.b.MatricesIndicesExtraKind):null,f=u?this.getVerticesData(h.b.MatricesWeightsExtraKind):null,p=e.getTransformMatrices(this),_=c.e.Zero(),m=new c.a,g=new c.a,v=0,b=0;b0&&(c.a.FromFloat32ArrayToRefScaled(p,Math.floor(16*a[v+l]),y,g),m.addToSelf(g));if(u)for(l=0;l<4;l++)(y=f[v+l])>0&&(c.a.FromFloat32ArrayToRefScaled(p,Math.floor(16*d[v+l]),y,g),m.addToSelf(g));c.e.TransformCoordinatesFromFloatsToRef(i._sourcePositions[b],i._sourcePositions[b+1],i._sourcePositions[b+2],m,_),_.toArray(r,b),t&&(c.e.TransformNormalFromFloatsToRef(i._sourceNormals[b],i._sourceNormals[b+1],i._sourceNormals[b+2],m,_),_.toArray(o,b)),m.reset()}return this.updateVerticesData(h.b.PositionKind,r),t&&this.updateVerticesData(h.b.NormalKind,o),this},t.MinMax=function(e){var t=null,i=null;return e.forEach((function(e){var n=e.getBoundingInfo().boundingBox;t&&i?(t.minimizeInPlace(n.minimumWorld),i.maximizeInPlace(n.maximumWorld)):(t=n.minimumWorld,i=n.maximumWorld)})),t&&i?{min:t,max:i}:{min:c.e.Zero(),max:c.e.Zero()}},t.Center=function(e){var i=e instanceof Array?t.MinMax(e):e;return c.e.Center(i.min,i.max)},t.MergeMeshes=function(e,i,n,r,o,a){var s;if(void 0===i&&(i=!0),!n){var c=0;for(s=0;s=65536)return E.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 l,u,h=null;o=!1}var f,p=new Array,m=new Array,g=null,b=new Array,y=null;for(s=0;s
";e._AddLogEntry(n)},e._WarnDisabled=function(e){},e._WarnEnabled=function(t){var i=e._FormatMessage(t);console.warn("BJS - "+i);var n="
"+i+"

";e._AddLogEntry(n)},e._ErrorDisabled=function(e){},e._ErrorEnabled=function(t){e.errorsCount++;var i=e._FormatMessage(t);console.error("BJS - "+i);var n="
"+i+"

";e._AddLogEntry(n)},Object.defineProperty(e,"LogCache",{get:function(){return e._LogCache},enumerable:!1,configurable:!0}),e.ClearLogCache=function(){e._LogCache="",e.errorsCount=0},Object.defineProperty(e,"LogLevels",{set:function(t){(t&e.MessageLogLevel)===e.MessageLogLevel?e.Log=e._LogEnabled:e.Log=e._LogDisabled,(t&e.WarningLogLevel)===e.WarningLogLevel?e.Warn=e._WarnEnabled:e.Warn=e._WarnDisabled,(t&e.ErrorLogLevel)===e.ErrorLogLevel?e.Error=e._ErrorEnabled:e.Error=e._ErrorDisabled},enumerable:!1,configurable:!0}),e.NoneLogLevel=0,e.MessageLogLevel=1,e.WarningLogLevel=2,e.ErrorLogLevel=4,e.AllLogLevel=7,e._LogCache="",e.errorsCount=0,e.Log=e._LogEnabled,e.Warn=e._WarnEnabled,e.Error=e._ErrorEnabled,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return s})),i.d(t,"b",(function(){return c})),i.d(t,"c",(function(){return l}));var n=i(14),r=i(28),o=i(44),a=i(11),s=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}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.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toColor4=function(e){return void 0===e&&(e=1),new c(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,i){return this.r===e&&this.g===t&&this.b===i},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,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=n.a.Clamp(this.r,e,t),i.g=n.a.Clamp(this.g,e,t),i.b=n.a.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,i){return this.r=e,this.g=t,this.b=i,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,i=255*this.b|0;return"#"+n.a.ToHex(e)+n.a.ToHex(t)+n.a.ToHex(i)},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,i=this.g,n=this.b,r=Math.max(t,i,n),o=Math.min(t,i,n),a=0,s=0,c=r,l=r-o;0!==r&&(s=l/r),r!=o&&(r==t?(a=(i-n)/l,i=0&&o<=1?(s=r,c=a):o>=1&&o<=2?(s=a,c=r):o>=2&&o<=3?(c=r,l=a):o>=3&&o<=4?(c=a,l=r):o>=4&&o<=5?(s=a,l=r):o>=5&&o<=6&&(s=r,l=a);var u=i-r;n.set(s+u,c+u,l+u)},e.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new e(0,0,0);var i=parseInt(t.substring(1,3),16),n=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16);return e.FromInts(i,n,r)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2]},e.FromInts=function(t,i,n){return new e(t/255,i/255,n/255)},e.Lerp=function(t,i,n){var r=new e(0,0,0);return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){n.r=e.r+(t.r-e.r)*i,n.g=e.g+(t.g-e.g)*i,n.b=e.b+(t.b-e.b)*i},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:!1,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}(),c=function(){function e(e,t,i,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=1),this.r=e,this.g=t,this.b=i,this.a=n}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.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),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,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=n.a.Clamp(this.r,e,t),i.g=n.a.Clamp(this.g,e,t),i.b=n.a.Clamp(this.b,e,t),i.a=n.a.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,i,n){return this.r=e,this.g=t,this.b=i,this.a=n,this},e.prototype.set=function(e,t,i,n){return this.copyFromFloats(e,t,i,n)},e.prototype.toHexString=function(e){void 0===e&&(e=!1);var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0;if(e)return"#"+n.a.ToHex(t)+n.a.ToHex(i)+n.a.ToHex(r);var o=255*this.a|0;return"#"+n.a.ToHex(t)+n.a.ToHex(i)+n.a.ToHex(r)+n.a.ToHex(o)},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,r.c),e.g=Math.pow(this.g,r.c),e.b=Math.pow(this.b,r.c),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,r.b),e.g=Math.pow(this.g,r.b),e.b=Math.pow(this.b,r.b),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 i=parseInt(t.substring(1,3),16),n=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(i,n,r,o)},e.Lerp=function(t,i,n){var r=new e(0,0,0,0);return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){n.r=e.r+(t.r-e.r)*i,n.g=e.g+(t.g-e.g)*i,n.b=e.b+(t.b-e.b)*i,n.a=e.a+(t.a-e.a)*i},e.FromColor3=function(t,i){return void 0===i&&(i=1),new e(t.r,t.g,t.b,i)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2],i.a=e[t+3]},e.FromInts=function(t,i,n,r){return new e(t/255,i/255,n/255,r/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],n=0;n0?e.name:n+e.name,(p.a.StartsWith(e.url,"data:")||t.UseSerializedUrlIfAny&&e.url)&&(h=e.url),r=new t(h,i,!o,e.invertY,void 0,a)}return r}),e,i);return s},t.CreateFromBase64String=function(e,i,n,r,o,a,s,l,u){return void 0===a&&(a=t.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===l&&(l=null),void 0===u&&(u=c.a.TEXTUREFORMAT_RGBA),new t("data:"+i,n,r,o,a,s,l,e,!1,u)},t.LoadFromDataString=function(e,i,n,r,o,a,s,l,u,h){return void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=!0),void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===u&&(u=null),void 0===h&&(h=c.a.TEXTUREFORMAT_RGBA),"data:"!==e.substr(0,5)&&(e="data:"+e),new t(e,n,o,a,s,l,u,i,r,h)},t.SerializeBuffers=!0,t.ForceSerializeBuffers=!1,t._CubeTextureParser=function(e,t,i){throw u.a.WarnImport("CubeTexture")},t._CreateMirror=function(e,t,i,n){throw u.a.WarnImport("MirrorTexture")},t._CreateRenderTargetTexture=function(e,t,i,n){throw u.a.WarnImport("RenderTargetTexture")},t.NEAREST_SAMPLINGMODE=c.a.TEXTURE_NEAREST_SAMPLINGMODE,t.NEAREST_NEAREST_MIPLINEAR=c.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.BILINEAR_SAMPLINGMODE=c.a.TEXTURE_BILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPNEAREST=c.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TRILINEAR_SAMPLINGMODE=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPLINEAR=c.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.NEAREST_NEAREST_MIPNEAREST=c.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.NEAREST_LINEAR_MIPNEAREST=c.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.NEAREST_LINEAR_MIPLINEAR=c.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.NEAREST_LINEAR=c.a.TEXTURE_NEAREST_LINEAR,t.NEAREST_NEAREST=c.a.TEXTURE_NEAREST_NEAREST,t.LINEAR_NEAREST_MIPNEAREST=c.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.LINEAR_NEAREST_MIPLINEAR=c.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.LINEAR_LINEAR=c.a.TEXTURE_LINEAR_LINEAR,t.LINEAR_NEAREST=c.a.TEXTURE_LINEAR_NEAREST,t.EXPLICIT_MODE=c.a.TEXTURE_EXPLICIT_MODE,t.SPHERICAL_MODE=c.a.TEXTURE_SPHERICAL_MODE,t.PLANAR_MODE=c.a.TEXTURE_PLANAR_MODE,t.CUBIC_MODE=c.a.TEXTURE_CUBIC_MODE,t.PROJECTION_MODE=c.a.TEXTURE_PROJECTION_MODE,t.SKYBOX_MODE=c.a.TEXTURE_SKYBOX_MODE,t.INVCUBIC_MODE=c.a.TEXTURE_INVCUBIC_MODE,t.EQUIRECTANGULAR_MODE=c.a.TEXTURE_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MODE=c.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=c.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.CLAMP_ADDRESSMODE=c.a.TEXTURE_CLAMP_ADDRESSMODE,t.WRAP_ADDRESSMODE=c.a.TEXTURE_WRAP_ADDRESSMODE,t.MIRROR_ADDRESSMODE=c.a.TEXTURE_MIRROR_ADDRESSMODE,t.UseSerializedUrlIfAny=!1,Object(n.c)([Object(r.c)()],t.prototype,"url",void 0),Object(n.c)([Object(r.c)()],t.prototype,"uOffset",void 0),Object(n.c)([Object(r.c)()],t.prototype,"vOffset",void 0),Object(n.c)([Object(r.c)()],t.prototype,"uScale",void 0),Object(n.c)([Object(r.c)()],t.prototype,"vScale",void 0),Object(n.c)([Object(r.c)()],t.prototype,"uAng",void 0),Object(n.c)([Object(r.c)()],t.prototype,"vAng",void 0),Object(n.c)([Object(r.c)()],t.prototype,"wAng",void 0),Object(n.c)([Object(r.c)()],t.prototype,"uRotationCenter",void 0),Object(n.c)([Object(r.c)()],t.prototype,"vRotationCenter",void 0),Object(n.c)([Object(r.c)()],t.prototype,"wRotationCenter",void 0),Object(n.c)([Object(r.c)()],t.prototype,"homogeneousRotationInUVTransform",void 0),Object(n.c)([Object(r.c)()],t.prototype,"isBlocking",null),t}(s.a);l.a.RegisteredTypes["BABYLON.Texture"]=m,r.a._TextureParser=m.Parse},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.GetClass=function(e){return this.RegisteredTypes&&this.RegisteredTypes[e]?this.RegisteredTypes[e]:null},e.RegisteredTypes={},e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return m})),i.d(t,"c",(function(){return g})),i.d(t,"a",(function(){return v}));var n=i(6),r=i(38),o=i(8),a=i(41),s=i(57),c=i(21),l=i(49),u=i(22),h=i(56),d=i(145),f=i(104),p=i(122),_=i(120),m=function(){function e(){}return Object.defineProperty(e,"BaseUrl",{get:function(){return h.a.BaseUrl},set:function(e){h.a.BaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DefaultRetryStrategy",{get:function(){return h.a.DefaultRetryStrategy},set:function(e){h.a.DefaultRetryStrategy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CorsBehavior",{get:function(){return h.a.CorsBehavior},set:function(e){h.a.CorsBehavior=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"UseFallbackTexture",{get:function(){return u.a.UseFallbackTexture},set:function(e){u.a.UseFallbackTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RegisteredExternalClasses",{get:function(){return p.a.RegisteredExternalClasses},set:function(e){p.a.RegisteredExternalClasses=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"fallbackTexture",{get:function(){return u.a.FallbackTexture},set:function(e){u.a.FallbackTexture=e},enumerable:!1,configurable:!0}),e.FetchToRef=function(e,t,i,n,r,o){var a=4*((Math.abs(e)*i%i|0)+(Math.abs(t)*n%n|0)*i);o.r=r[a]/255,o.g=r[a+1]/255,o.b=r[a+2]/255,o.a=r[a+3]/255},e.Mix=function(e,t,i){return e*(1-i)+t*i},e.Instantiate=function(e){return p.a.Instantiate(e)},e.Slice=function(e,t,i){return e.slice?e.slice(t,i):Array.prototype.slice.call(e,t,i)},e.SliceToArray=function(e,t,i){return Array.isArray(e)?e.slice(t,i):Array.prototype.slice.call(e,t,i)},e.SetImmediate=function(e){f.a.SetImmediate(e)},e.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(t=t)break;if(n(a),o&&o()){e.breakLoop();break}}e.executeNext()}),a)}),r)},e}();u.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",d.a.Apply()},function(e,t,i){"use strict";i.d(t,"a",(function(){return p}));var n=i(1),r=i(6),o=i(38),a=i(22),s=i(21),c=i(26),l=i(2),u=i(146),h=i(55),d=i(88),f=i(8),p=(i(123),i(129),i(124),function(e){function t(i,n,a,s){void 0===s&&(s=!1);var c=e.call(this,i,n,a,s)||this;if(c.enableOfflineSupport=!1,c.disableManifestCheck=!1,c.scenes=new Array,c.onNewSceneAddedObservable=new r.c,c.postProcesses=new Array,c.isPointerLock=!1,c.onResizeObservable=new r.c,c.onCanvasBlurObservable=new r.c,c.onCanvasFocusObservable=new r.c,c.onCanvasPointerOutObservable=new r.c,c.onBeginFrameObservable=new r.c,c.customAnimationFrameRequester=null,c.onEndFrameObservable=new r.c,c.onBeforeShaderCompilationObservable=new r.c,c.onAfterShaderCompilationObservable=new r.c,c._deterministicLockstep=!1,c._lockstepMaxSteps=4,c._timeStep=1/60,c._fps=60,c._deltaTime=0,c._drawCalls=new h.a,c.canvasTabIndex=1,c.disablePerformanceMonitorInBackground=!1,c._performanceMonitor=new u.a,t.Instances.push(c),!i)return c;if(a=c._creationOptions,i.getContext){var l=i;if(c._onCanvasFocus=function(){c.onCanvasFocusObservable.notifyObservers(c)},c._onCanvasBlur=function(){c.onCanvasBlurObservable.notifyObservers(c)},l.addEventListener("focus",c._onCanvasFocus),l.addEventListener("blur",c._onCanvasBlur),c._onBlur=function(){c.disablePerformanceMonitorInBackground&&c._performanceMonitor.disable(),c._windowIsBackground=!0},c._onFocus=function(){c.disablePerformanceMonitorInBackground&&c._performanceMonitor.enable(),c._windowIsBackground=!1},c._onCanvasPointerOut=function(e){c.onCanvasPointerOutObservable.notifyObservers(e)},l.addEventListener("pointerout",c._onCanvasPointerOut),o.a.IsWindowObjectExist()){var d=c.getHostWindow();d.addEventListener("blur",c._onBlur),d.addEventListener("focus",c._onFocus);var f=document;c._onFullscreenChange=function(){void 0!==f.fullscreen?c.isFullscreen=f.fullscreen:void 0!==f.mozFullScreen?c.isFullscreen=f.mozFullScreen:void 0!==f.webkitIsFullScreen?c.isFullscreen=f.webkitIsFullScreen:void 0!==f.msIsFullScreen&&(c.isFullscreen=f.msIsFullScreen),c.isFullscreen&&c._pointerLockRequested&&l&&t._RequestPointerlock(l)},document.addEventListener("fullscreenchange",c._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",c._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",c._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",c._onFullscreenChange,!1),c._onPointerLockChange=function(){c.isPointerLock=f.mozPointerLockElement===l||f.webkitPointerLockElement===l||f.msPointerLockElement===l||f.pointerLockElement===l},document.addEventListener("pointerlockchange",c._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",c._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",c._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",c._onPointerLockChange,!1),!t.audioEngine&&a.audioEngine&&t.AudioEngineFactory&&(t.audioEngine=t.AudioEngineFactory(c.getRenderingCanvas()))}c._connectVREvents(),c.enableOfflineSupport=void 0!==t.OfflineProviderFactory,a.doNotHandleTouchAction||c._disableTouchAction(),c._deterministicLockstep=!!a.deterministicLockstep,c._lockstepMaxSteps=a.lockstepMaxSteps||0,c._timeStep=a.timeStep||1/60}return c._prepareVRComponent(),a.autoEnableWebVR&&c.initWebVR(),c}return Object(n.d)(t,e),Object.defineProperty(t,"NpmPackage",{get:function(){return c.a.NpmPackage},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Version",{get:function(){return c.a.Version},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Instances",{get:function(){return a.a.Instances},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LastCreatedEngine",{get:function(){return a.a.LastCreatedEngine},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LastCreatedScene",{get:function(){return a.a.LastCreatedScene},enumerable:!1,configurable:!0}),t.MarkAllMaterialsAsDirty=function(e,i){for(var n=0;n0?this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this.isVRPresenting()?this._requestVRFrame():this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},t.prototype._renderViews=function(){return!1},t.prototype.switchFullscreen=function(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)},t.prototype.enterFullscreen=function(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&t._RequestFullscreen(this._renderingCanvas))},t.prototype.exitFullscreen=function(){this.isFullscreen&&t._ExitFullscreen()},t.prototype.enterPointerlock=function(){this._renderingCanvas&&t._RequestPointerlock(this._renderingCanvas)},t.prototype.exitPointerlock=function(){t._ExitPointerlock()},t.prototype.beginFrame=function(){this._measureFps(),this.onBeginFrameObservable.notifyObservers(this),e.prototype.beginFrame.call(this)},t.prototype.endFrame=function(){e.prototype.endFrame.call(this),this._submitVRFrame(),this.onEndFrameObservable.notifyObservers(this)},t.prototype.resize=function(){this.isVRPresenting()||e.prototype.resize.call(this)},t.prototype.setSize=function(t,i){if(!this._renderingCanvas)return!1;if(!e.prototype.setSize.call(this,t,i))return!1;if(this.scenes){for(var n=0;n1&&r){var a=this.createTransformFeedback();this.bindTransformFeedback(a),this.setTranformFeedbackVaryings(o,r),e.transformFeedback=a}return n.linkProgram(o),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),e.context=n,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},t.prototype._releaseTexture=function(t){e.prototype._releaseTexture.call(this,t),this.scenes.forEach((function(e){e.postProcesses.forEach((function(e){e._outputTexture==t&&(e._outputTexture=null)})),e.cameras.forEach((function(e){e._postProcesses.forEach((function(e){e&&e._outputTexture==t&&(e._outputTexture=null)}))}))}))},t.prototype._rescaleTexture=function(e,i,n,r,o){var a=this;this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);var s=this.createRenderTargetTexture({width:i.width,height:i.height},{generateMipMaps:!1,type:l.a.TEXTURETYPE_UNSIGNED_INT,samplingMode:l.a.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});!this._rescalePostProcess&&t._RescalePostProcessFactory&&(this._rescalePostProcess=t._RescalePostProcessFactory(this)),this._rescalePostProcess.getEffect().executeWhenCompiled((function(){a._rescalePostProcess.onApply=function(t){t._bindTexture("textureSampler",e)};var t=n;t||(t=a.scenes[a.scenes.length-1]),t.postProcessManager.directRender([a._rescalePostProcess],s,!0),a._bindTextureDirectly(a._gl.TEXTURE_2D,i,!0),a._gl.copyTexImage2D(a._gl.TEXTURE_2D,0,r,0,0,i.width,i.height,0),a.unBindFramebuffer(s),a._releaseTexture(s),o&&o()}))},t.prototype.getFps=function(){return this._fps},t.prototype.getDeltaTime=function(){return this._deltaTime},t.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},t.prototype._uploadImageToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0);var r=this._gl,o=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),s=this._getRGBABufferInternalSizedFormat(e.type,a),c=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(c,e,!0),this._unpackFlipY(e.invertY);var l=r.TEXTURE_2D;e.isCube&&(l=r.TEXTURE_CUBE_MAP_POSITIVE_X+i),r.texImage2D(l,n,s,a,o,t),this._bindTextureDirectly(c,null,!0)},t.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;var i=this._gl;if(t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(i.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(i.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null),t>1&&i.renderbufferStorageMultisample){var n=i.createFramebuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=n,this._bindUnboundFramebuffer(e._MSAAFramebuffer);var r=i.createRenderbuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,r),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(e.type),e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r),e._MSAARenderBuffer=r}else this._bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t),this._bindUnboundFramebuffer(null),t},t.prototype.updateTextureComparisonFunction=function(e,t){if(1!==this.webGLVersion){var i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),0===t?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,l.a.LEQUAL),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),0===t?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,l.a.LEQUAL),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}else f.a.Error("WebGL 1 does not support texture comparison.")},t.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");var i=new d.a(t);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i},t.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},t.prototype._clientWaitAsync=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=10);var n=this._gl;return new Promise((function(r,o){var a=function(){var s=n.clientWaitSync(e,t,0);s!=n.WAIT_FAILED?s!=n.TIMEOUT_EXPIRED?r():setTimeout(a,i):o()};a()}))},t.prototype._readPixelsAsync=function(e,t,i,n,r,o,a){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");var s=this._gl,c=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,c),s.bufferData(s.PIXEL_PACK_BUFFER,a.byteLength,s.STREAM_READ),s.readPixels(e,t,i,n,r,o,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null);var l=s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE,0);return l?(s.flush(),this._clientWaitAsync(l,0,10).then((function(){return s.deleteSync(l),s.bindBuffer(s.PIXEL_PACK_BUFFER,c),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,a),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),s.deleteBuffer(c),a}))):null},t.prototype.dispose=function(){for(this.hideLoadingUI(),this.onNewSceneAddedObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(this._rescalePostProcess&&this._rescalePostProcess.dispose();this.scenes.length;)this.scenes[0].dispose();1===t.Instances.length&&t.audioEngine&&t.audioEngine.dispose(),this.disableVR(),o.a.IsWindowObjectExist()&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._renderingCanvas&&(this._renderingCanvas.removeEventListener("focus",this._onCanvasFocus),this._renderingCanvas.removeEventListener("blur",this._onCanvasBlur),this._renderingCanvas.removeEventListener("pointerout",this._onCanvasPointerOut)),o.a.IsDocumentAvailable()&&(document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.removeEventListener("pointerlockchange",this._onPointerLockChange),document.removeEventListener("mspointerlockchange",this._onPointerLockChange),document.removeEventListener("mozpointerlockchange",this._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",this._onPointerLockChange))),e.prototype.dispose.call(this);var i=t.Instances.indexOf(this);i>=0&&t.Instances.splice(i,1),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()},t.prototype._disableTouchAction=function(){this._renderingCanvas&&this._renderingCanvas.setAttribute&&(this._renderingCanvas.setAttribute("touch-action","none"),this._renderingCanvas.style.touchAction="none",this._renderingCanvas.style.msTouchAction="none")},t.prototype.displayLoadingUI=function(){if(o.a.IsWindowObjectExist()){var e=this.loadingScreen;e&&e.displayLoadingUI()}},t.prototype.hideLoadingUI=function(){if(o.a.IsWindowObjectExist()){var e=this._loadingScreen;e&&e.hideLoadingUI()}},Object.defineProperty(t.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=t.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!1,configurable:!0}),t._RequestPointerlock=function(e){e.requestPointerLock=e.requestPointerLock||e.msRequestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock,e.requestPointerLock&&e.requestPointerLock()},t._ExitPointerlock=function(){var e=document;document.exitPointerLock=document.exitPointerLock||e.msExitPointerLock||e.mozExitPointerLock||e.webkitExitPointerLock,document.exitPointerLock&&document.exitPointerLock()},t._RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t._ExitFullscreen=function(){var e=document;document.exitFullscreen?document.exitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.webkitCancelFullScreen?e.webkitCancelFullScreen():e.msCancelFullScreen&&e.msCancelFullScreen()},t.ALPHA_DISABLE=l.a.ALPHA_DISABLE,t.ALPHA_ADD=l.a.ALPHA_ADD,t.ALPHA_COMBINE=l.a.ALPHA_COMBINE,t.ALPHA_SUBTRACT=l.a.ALPHA_SUBTRACT,t.ALPHA_MULTIPLY=l.a.ALPHA_MULTIPLY,t.ALPHA_MAXIMIZED=l.a.ALPHA_MAXIMIZED,t.ALPHA_ONEONE=l.a.ALPHA_ONEONE,t.ALPHA_PREMULTIPLIED=l.a.ALPHA_PREMULTIPLIED,t.ALPHA_PREMULTIPLIED_PORTERDUFF=l.a.ALPHA_PREMULTIPLIED_PORTERDUFF,t.ALPHA_INTERPOLATE=l.a.ALPHA_INTERPOLATE,t.ALPHA_SCREENMODE=l.a.ALPHA_SCREENMODE,t.DELAYLOADSTATE_NONE=l.a.DELAYLOADSTATE_NONE,t.DELAYLOADSTATE_LOADED=l.a.DELAYLOADSTATE_LOADED,t.DELAYLOADSTATE_LOADING=l.a.DELAYLOADSTATE_LOADING,t.DELAYLOADSTATE_NOTLOADED=l.a.DELAYLOADSTATE_NOTLOADED,t.NEVER=l.a.NEVER,t.ALWAYS=l.a.ALWAYS,t.LESS=l.a.LESS,t.EQUAL=l.a.EQUAL,t.LEQUAL=l.a.LEQUAL,t.GREATER=l.a.GREATER,t.GEQUAL=l.a.GEQUAL,t.NOTEQUAL=l.a.NOTEQUAL,t.KEEP=l.a.KEEP,t.REPLACE=l.a.REPLACE,t.INCR=l.a.INCR,t.DECR=l.a.DECR,t.INVERT=l.a.INVERT,t.INCR_WRAP=l.a.INCR_WRAP,t.DECR_WRAP=l.a.DECR_WRAP,t.TEXTURE_CLAMP_ADDRESSMODE=l.a.TEXTURE_CLAMP_ADDRESSMODE,t.TEXTURE_WRAP_ADDRESSMODE=l.a.TEXTURE_WRAP_ADDRESSMODE,t.TEXTURE_MIRROR_ADDRESSMODE=l.a.TEXTURE_MIRROR_ADDRESSMODE,t.TEXTUREFORMAT_ALPHA=l.a.TEXTUREFORMAT_ALPHA,t.TEXTUREFORMAT_LUMINANCE=l.a.TEXTUREFORMAT_LUMINANCE,t.TEXTUREFORMAT_LUMINANCE_ALPHA=l.a.TEXTUREFORMAT_LUMINANCE_ALPHA,t.TEXTUREFORMAT_RGB=l.a.TEXTUREFORMAT_RGB,t.TEXTUREFORMAT_RGBA=l.a.TEXTUREFORMAT_RGBA,t.TEXTUREFORMAT_RED=l.a.TEXTUREFORMAT_RED,t.TEXTUREFORMAT_R=l.a.TEXTUREFORMAT_R,t.TEXTUREFORMAT_RG=l.a.TEXTUREFORMAT_RG,t.TEXTUREFORMAT_RED_INTEGER=l.a.TEXTUREFORMAT_RED_INTEGER,t.TEXTUREFORMAT_R_INTEGER=l.a.TEXTUREFORMAT_R_INTEGER,t.TEXTUREFORMAT_RG_INTEGER=l.a.TEXTUREFORMAT_RG_INTEGER,t.TEXTUREFORMAT_RGB_INTEGER=l.a.TEXTUREFORMAT_RGB_INTEGER,t.TEXTUREFORMAT_RGBA_INTEGER=l.a.TEXTUREFORMAT_RGBA_INTEGER,t.TEXTURETYPE_UNSIGNED_BYTE=l.a.TEXTURETYPE_UNSIGNED_BYTE,t.TEXTURETYPE_UNSIGNED_INT=l.a.TEXTURETYPE_UNSIGNED_INT,t.TEXTURETYPE_FLOAT=l.a.TEXTURETYPE_FLOAT,t.TEXTURETYPE_HALF_FLOAT=l.a.TEXTURETYPE_HALF_FLOAT,t.TEXTURETYPE_BYTE=l.a.TEXTURETYPE_BYTE,t.TEXTURETYPE_SHORT=l.a.TEXTURETYPE_SHORT,t.TEXTURETYPE_UNSIGNED_SHORT=l.a.TEXTURETYPE_UNSIGNED_SHORT,t.TEXTURETYPE_INT=l.a.TEXTURETYPE_INT,t.TEXTURETYPE_UNSIGNED_INTEGER=l.a.TEXTURETYPE_UNSIGNED_INTEGER,t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=l.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=l.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=l.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=l.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,t.TEXTURETYPE_UNSIGNED_INT_24_8=l.a.TEXTURETYPE_UNSIGNED_INT_24_8,t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=l.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=l.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=l.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,t.TEXTURE_NEAREST_SAMPLINGMODE=l.a.TEXTURE_NEAREST_SAMPLINGMODE,t.TEXTURE_BILINEAR_SAMPLINGMODE=l.a.TEXTURE_BILINEAR_SAMPLINGMODE,t.TEXTURE_TRILINEAR_SAMPLINGMODE=l.a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.TEXTURE_NEAREST_NEAREST_MIPLINEAR=l.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR_MIPNEAREST=l.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TEXTURE_LINEAR_LINEAR_MIPLINEAR=l.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_NEAREST_MIPNEAREST=l.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPNEAREST=l.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPLINEAR=l.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_LINEAR=l.a.TEXTURE_NEAREST_LINEAR,t.TEXTURE_NEAREST_NEAREST=l.a.TEXTURE_NEAREST_NEAREST,t.TEXTURE_LINEAR_NEAREST_MIPNEAREST=l.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.TEXTURE_LINEAR_NEAREST_MIPLINEAR=l.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR=l.a.TEXTURE_LINEAR_LINEAR,t.TEXTURE_LINEAR_NEAREST=l.a.TEXTURE_LINEAR_NEAREST,t.TEXTURE_EXPLICIT_MODE=l.a.TEXTURE_EXPLICIT_MODE,t.TEXTURE_SPHERICAL_MODE=l.a.TEXTURE_SPHERICAL_MODE,t.TEXTURE_PLANAR_MODE=l.a.TEXTURE_PLANAR_MODE,t.TEXTURE_CUBIC_MODE=l.a.TEXTURE_CUBIC_MODE,t.TEXTURE_PROJECTION_MODE=l.a.TEXTURE_PROJECTION_MODE,t.TEXTURE_SKYBOX_MODE=l.a.TEXTURE_SKYBOX_MODE,t.TEXTURE_INVCUBIC_MODE=l.a.TEXTURE_INVCUBIC_MODE,t.TEXTURE_EQUIRECTANGULAR_MODE=l.a.TEXTURE_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=l.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=l.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.SCALEMODE_FLOOR=l.a.SCALEMODE_FLOOR,t.SCALEMODE_NEAREST=l.a.SCALEMODE_NEAREST,t.SCALEMODE_CEILING=l.a.SCALEMODE_CEILING,t._RescalePostProcessFactory=null,t}(c.a))},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.WithinEpsilon=function(e,t,i){void 0===i&&(i=1401298e-51);var n=e-t;return-i<=n&&n<=i},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,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,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,i){return(e-t)/(i-t)},e.Denormalize=function(e,t,i){return e*(i-t)+t},e.DeltaAngle=function(t,i){var n=e.Repeat(i-t,360);return n>180&&(n-=360),n},e.PingPong=function(t,i){var n=e.Repeat(t,2*i);return i-Math.abs(n-i)},e.SmoothStep=function(t,i,n){var r=e.Clamp(n);return i*(r=-2*r*r*r+3*r*r)+t*(1-r)},e.MoveTowards=function(t,i,n){return Math.abs(i-t)<=n?i:t+e.Sign(i-t)*n},e.MoveTowardsAngle=function(t,i,n){var r=e.DeltaAngle(t,i),o=0;return-n180&&(r-=360),t+r*e.Clamp(n)},e.InverseLerp=function(t,i,n){return t!=i?e.Clamp((n-t)/(i-t)):0},e.Hermite=function(e,t,i,n,r){var o=r*r,a=r*o;return e*(2*a-3*o+1)+i*(-2*a+3*o)+t*(a-2*o+r)+n*(a-o)},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,i){return(e-t)/(i-t)},e.PercentToRange=function(e,t,i){return(i-t)*e+t},e.NormalizeRadians=function(t){return t-=e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.TwoPi=2*Math.PI,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return h}));var n=i(8),r=i(20),o=i(22),a=i(4),s=i(48),c=i(2),l=i(9),u=i(119),h=function(){function e(){}return e.BindEyePosition=function(e,t,i){if(void 0===i&&(i="vEyePosition"),t._forcedViewPosition)e.setVector3(i,t._forcedViewPosition);else{var n=t.activeCamera.globalPosition;n||(n=t.activeCamera.devicePosition),e.setVector3(i,t._mirroredCameraPosition?t._mirroredCameraPosition:n)}},e.PrepareDefinesForMergedUV=function(e,t,i){t._needUVs=!0,t[i]=!0,e.getTextureMatrix().isIdentityAs3x2()?(t[i+"DIRECTUV"]=e.coordinatesIndex+1,0===e.coordinatesIndex?t.MAINUV1=!0:t.MAINUV2=!0):t[i+"DIRECTUV"]=0},e.BindTextureMatrix=function(e,t,i){var n=e.getTextureMatrix();t.updateMatrix(i+"Matrix",n)},e.GetFogState=function(e,t){return t.fogEnabled&&e.applyFog&&t.fogMode!==r.a.FOGMODE_NONE},e.PrepareDefinesForMisc=function(e,t,i,n,r,o,a){a._areMiscDirty&&(a.LOGARITHMICDEPTH=i,a.POINTSIZE=n,a.FOG=r&&this.GetFogState(e,t),a.NONUNIFORMSCALING=e.nonUniformScaling,a.ALPHATEST=o)},e.PrepareDefinesForFrameBoundValues=function(e,t,i,n,r,o){void 0===r&&(r=null),void 0===o&&(o=!1);var a,s,c,l,u,h,d=!1;a=null==r?void 0!==e.clipPlane&&null!==e.clipPlane:r,s=null==r?void 0!==e.clipPlane2&&null!==e.clipPlane2:r,c=null==r?void 0!==e.clipPlane3&&null!==e.clipPlane3:r,l=null==r?void 0!==e.clipPlane4&&null!==e.clipPlane4:r,u=null==r?void 0!==e.clipPlane5&&null!==e.clipPlane5:r,h=null==r?void 0!==e.clipPlane6&&null!==e.clipPlane6:r,i.CLIPPLANE!==a&&(i.CLIPPLANE=a,d=!0),i.CLIPPLANE2!==s&&(i.CLIPPLANE2=s,d=!0),i.CLIPPLANE3!==c&&(i.CLIPPLANE3=c,d=!0),i.CLIPPLANE4!==l&&(i.CLIPPLANE4=l,d=!0),i.CLIPPLANE5!==u&&(i.CLIPPLANE5=u,d=!0),i.CLIPPLANE6!==h&&(i.CLIPPLANE6=h,d=!0),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,d=!0),i.INSTANCES!==n&&(i.INSTANCES=n,d=!0),i.THIN_INSTANCES!==o&&(i.THIN_INSTANCES=o,d=!0),d&&i.markAsUnprocessed()},e.PrepareDefinesForBones=function(e,t){if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;var i=void 0!==t.BONETEXTURE;if(e.skeleton.isUsingTextureForMatrices&&i)t.BONETEXTURE=!0;else{t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!i&&void 0;var n=e.getScene().prePassRenderer;if(n&&n.enabled){var r=-1===n.excludedSkinnedMesh.indexOf(e);t.BONES_VELOCITY_ENABLED=r}}}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0},e.PrepareDefinesForMorphTargets=function(e,t){var i=e.morphTargetManager;i?(t.MORPHTARGETS_UV=i.supportsUVs&&t.UV1,t.MORPHTARGETS_TANGENT=i.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=i.supportsNormals&&t.NORMAL,t.MORPHTARGETS=i.numInfluencers>0,t.NUM_MORPH_INFLUENCERS=i.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,i,n,r,o){if(void 0===r&&(r=!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(a.b.NormalKind),t._needNormals&&e.isVerticesDataPresent(a.b.TangentKind)&&(t.TANGENT=!0),t._needUVs?(t.UV1=e.isVerticesDataPresent(a.b.UVKind),t.UV2=e.isVerticesDataPresent(a.b.UV2Kind)):(t.UV1=!1,t.UV2=!1),i){var s=e.useVertexColors&&e.isVerticesDataPresent(a.b.ColorKind);t.VERTEXCOLOR=s,t.VERTEXALPHA=e.hasVertexAlpha&&s&&o}return n&&this.PrepareDefinesForBones(e,t),r&&this.PrepareDefinesForMorphTargets(e,t),!0},e.PrepareDefinesForMultiview=function(e,t){if(e.activeCamera){var i=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=i&&t.markAsUnprocessed()}},e.PrepareDefinesForPrePass=function(e,t,i){var n=t.PREPASS;if(t._arePrePassDirty){var r=[{type:c.a.PREPASS_POSITION_TEXTURE_TYPE,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:c.a.PREPASS_VELOCITY_TEXTURE_TYPE,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:c.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:c.a.PREPASS_IRRADIANCE_TEXTURE_TYPE,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:c.a.PREPASS_ALBEDO_TEXTURE_TYPE,define:"PREPASS_ALBEDO",index:"PREPASS_ALBEDO_INDEX"},{type:c.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,define:"PREPASS_DEPTHNORMAL",index:"PREPASS_DEPTHNORMAL_INDEX"}];if(e.prePassRenderer&&e.prePassRenderer.enabled&&i){t.PREPASS=!0,t.SCENE_MRT_COUNT=e.prePassRenderer.mrtCount;for(var o=0;o0&&(a.shadowEnabled=!0,c.prepareDefines(r,n))}}i.lightmapMode!=s.a.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,r["LIGHTMAPEXCLUDED"+n]=!0,r["LIGHTMAPNOSPECULAR"+n]=i.lightmapMode==s.a.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+n]=!1,r["LIGHTMAPNOSPECULAR"+n]=!1)},e.PrepareDefinesForLights=function(e,t,i,n,r,o){if(void 0===r&&(r=4),void 0===o&&(o=!1),!i._areLightsDirty)return i._needNormals;var a=0,s={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!o)for(var c=0,l=t.lightSources;c0&&(r=n+o,t.addFallback(r,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(n,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(n,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(n,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(n,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(n,"SHADOWESM"+o),e["SHADOWCLOSEESM"+o]&&t.addFallback(n,"SHADOWCLOSEESM"+o));return r++},e.PrepareAttributesForMorphTargetsInfluencers=function(e,t,i){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=i,this.PrepareAttributesForMorphTargets(e,t,this._TmpMorphInfluencers)},e.PrepareAttributesForMorphTargets=function(e,t,i){var r=i.NUM_MORPH_INFLUENCERS;if(r>0&&o.a.LastCreatedEngine)for(var s=o.a.LastCreatedEngine.getCaps().maxVertexAttribs,c=t.morphTargetManager,l=c&&c.supportsNormals&&i.NORMAL,u=c&&c.supportsTangents&&i.TANGENT,h=c&&c.supportsUVs&&i.UV1,d=0;ds&&n.a.Error("Cannot add more vertex attributes for mesh "+t.name)},e.PrepareAttributesForBones=function(e,t,i,n){i.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,t),e.push(a.b.MatricesIndicesKind),e.push(a.b.MatricesWeightsKind),i.NUM_BONE_INFLUENCERS>4&&(e.push(a.b.MatricesIndicesExtraKind),e.push(a.b.MatricesWeightsExtraKind)))},e.PrepareAttributesForInstances=function(e,t){(t.INSTANCES||t.THIN_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,i){e.transferToEffect(t,i+"")},e.BindLight=function(e,t,i,n,r,o){void 0===o&&(o=!1),e._bindLight(t,i,n,r,o)},e.BindLights=function(e,t,i,n,r,o){void 0===r&&(r=4),void 0===o&&(o=!1);for(var a=Math.min(t.lightSources.length,r),s=0;s-1){var o=r.getTransformMatrixTexture(t);i.setTexture("boneSampler",o),i.setFloat("boneTextureWidth",4*(r.bones.length+1))}else{var a=r.getTransformMatrices(t);a&&(i.setMatrices("mBones",a),n&&t.getScene().prePassRenderer&&t.getScene().prePassRenderer.getIndex(c.a.PREPASS_VELOCITY_TEXTURE_TYPE)&&(n.previousBones[t.uniqueId]&&i.setMatrices("mPreviousBones",n.previousBones[t.uniqueId]),e._CopyBonesTransformationMatrices(a,n.previousBones[t.uniqueId])))}}},e._CopyBonesTransformationMatrices=function(e,t){return t.set(e),t},e.BindMorphTargetParameters=function(e,t){var i=e.morphTargetManager;e&&i&&t.setFloatArray("morphTargetInfluences",i.influences)},e.BindLogDepth=function(e,t,i){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2))},e.BindClipPlane=function(e,t){u.a.BindClipPlane(e,t)},e._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},e._tempFogColor=l.a.Black(),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(0),r=i(4),o=i(21),a=i(9),s=i(8),c=function(){function e(){}return e.prototype.set=function(e,t){switch(e.length||s.a.Warn("Setting vertex data kind '"+t+"' with an empty array"),t){case r.b.PositionKind:this.positions=e;break;case r.b.NormalKind:this.normals=e;break;case r.b.TangentKind:this.tangents=e;break;case r.b.UVKind:this.uvs=e;break;case r.b.UV2Kind:this.uvs2=e;break;case r.b.UV3Kind:this.uvs3=e;break;case r.b.UV4Kind:this.uvs4=e;break;case r.b.UV5Kind:this.uvs5=e;break;case r.b.UV6Kind:this.uvs6=e;break;case r.b.ColorKind:this.colors=e;break;case r.b.MatricesIndicesKind:this.matricesIndices=e;break;case r.b.MatricesWeightsKind:this.matricesWeights=e;break;case r.b.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case r.b.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}},e.prototype.applyToMesh=function(e,t){return this._applyTo(e,t),this},e.prototype.applyToGeometry=function(e,t){return this._applyTo(e,t),this},e.prototype.updateMesh=function(e){return this._update(e),this},e.prototype.updateGeometry=function(e){return this._update(e),this},e.prototype._applyTo=function(e,t){return void 0===t&&(t=!1),this.positions&&e.setVerticesData(r.b.PositionKind,this.positions,t),this.normals&&e.setVerticesData(r.b.NormalKind,this.normals,t),this.tangents&&e.setVerticesData(r.b.TangentKind,this.tangents,t),this.uvs&&e.setVerticesData(r.b.UVKind,this.uvs,t),this.uvs2&&e.setVerticesData(r.b.UV2Kind,this.uvs2,t),this.uvs3&&e.setVerticesData(r.b.UV3Kind,this.uvs3,t),this.uvs4&&e.setVerticesData(r.b.UV4Kind,this.uvs4,t),this.uvs5&&e.setVerticesData(r.b.UV5Kind,this.uvs5,t),this.uvs6&&e.setVerticesData(r.b.UV6Kind,this.uvs6,t),this.colors&&e.setVerticesData(r.b.ColorKind,this.colors,t),this.matricesIndices&&e.setVerticesData(r.b.MatricesIndicesKind,this.matricesIndices,t),this.matricesWeights&&e.setVerticesData(r.b.MatricesWeightsKind,this.matricesWeights,t),this.matricesIndicesExtra&&e.setVerticesData(r.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),this.matricesWeightsExtra&&e.setVerticesData(r.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),this.indices?e.setIndices(this.indices,null,t):e.setIndices([],null),this},e.prototype._update=function(e,t,i){return this.positions&&e.updateVerticesData(r.b.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(r.b.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(r.b.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(r.b.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(r.b.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(r.b.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(r.b.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(r.b.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(r.b.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(r.b.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(r.b.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(r.b.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(r.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(r.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this},e.prototype.transform=function(e){var t,i=e.determinant()<0,r=n.e.Zero();if(this.positions){var o=n.e.Zero();for(t=0;tr.bbSize.y?r.bbSize.x:r.bbSize.y;$=$>r.bbSize.z?$:r.bbSize.z,N=r.subDiv.X*M/r.bbSize.x,L=r.subDiv.Y*M/r.bbSize.y,w=r.subDiv.Z*M/r.bbSize.z,F=r.subDiv.max*r.subDiv.max,r.facetPartitioning.length=0}for(o=0;oe.LongPressDelay&&!n._isPointerSwiping()&&(n._startingPointerTime=0,o.processTrigger(S.a.ACTION_OnLongPressTrigger,b.a.CreateNew(t.pickedMesh,i)))}),e.LongPressDelay)}}else for(var a=0,s=r._pointerDownStage;ae.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>e.DragMovementThreshold},e.prototype.simulatePointerUp=function(e,t,i){var n=new PointerEvent("pointerup",t),r=new I;i?r.doubleClick=!0:r.singleClick=!0,this._checkPrePointerObservable(e,n,x.a.POINTERUP)||this._processPointerUp(e,n,r)},e.prototype._processPointerUp=function(e,t,i){var n=this._scene;if(e&&e&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(n.onPointerPick&&n.onPointerPick(t,e),i.singleClick&&!i.ignore&&n.onPointerObservable.hasObservers())){var r=x.a.POINTERPICK,o=new x.b(r,t,e);this._setRayOnPointerInfo(o),n.onPointerObservable.notifyObservers(o,r)}var a=e.pickedMesh._getActionManagerForTrigger();if(a&&!i.ignore){a.processTrigger(S.a.ACTION_OnPickUpTrigger,b.a.CreateNew(e.pickedMesh,t)),!i.hasSwiped&&i.singleClick&&a.processTrigger(S.a.ACTION_OnPickTrigger,b.a.CreateNew(e.pickedMesh,t));var s=e.pickedMesh._getActionManagerForTrigger(S.a.ACTION_OnDoublePickTrigger);i.doubleClick&&s&&s.processTrigger(S.a.ACTION_OnDoublePickTrigger,b.a.CreateNew(e.pickedMesh,t))}}else if(!i.ignore)for(var c=0,l=n._pointerUpStage;ce.DoubleClickDelay&&!a._doubleClickOccured||t!==a._previousButtonPressed)&&(a._doubleClickOccured=!1,i.singleClick=!0,i.ignore=!1,n(i,a._currentPickResult))},this._initClickEvent=function(t,i,n,r){var o=new I;a._currentPickResult=null;var s=null,c=t.hasSpecificMask(x.a.POINTERPICK)||i.hasSpecificMask(x.a.POINTERPICK)||t.hasSpecificMask(x.a.POINTERTAP)||i.hasSpecificMask(x.a.POINTERTAP)||t.hasSpecificMask(x.a.POINTERDOUBLETAP)||i.hasSpecificMask(x.a.POINTERDOUBLETAP);!c&&O.a&&(s=a._initActionManager(s,o))&&(c=s.hasPickTriggers);var l=!1;if(c){var u=n.button;if(o.hasSwiped=a._isPointerSwiping(),!o.hasSwiped){var h=!e.ExclusiveDoubleClickMode;h||(h=!t.hasSpecificMask(x.a.POINTERDOUBLETAP)&&!i.hasSpecificMask(x.a.POINTERDOUBLETAP))&&!O.a.HasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)&&(s=a._initActionManager(s,o))&&(h=!s.hasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)),h?(Date.now()-a._previousStartingPointerTime>e.DoubleClickDelay||u!==a._previousButtonPressed)&&(o.singleClick=!0,r(o,a._currentPickResult),l=!0):(a._previousDelayedSimpleClickTimeout=a._delayedSimpleClickTimeout,a._delayedSimpleClickTimeout=window.setTimeout(a._delayedSimpleClick.bind(a,u,o,r),e.DoubleClickDelay));var d=t.hasSpecificMask(x.a.POINTERDOUBLETAP)||i.hasSpecificMask(x.a.POINTERDOUBLETAP);!d&&O.a.HasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)&&(s=a._initActionManager(s,o))&&(d=s.hasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)),d&&(u===a._previousButtonPressed&&Date.now()-a._previousStartingPointerTime0){for(var e=0,t=this._transientComponents;e0)return!1;for(e=0;e0,r=0,o=this._isReadyForMeshStage;r0)for(var a=0,s=this.activeCameras;a0},enumerable:!1,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:!1,configurable:!0}),t.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=o.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,i,n){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?w.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=w.a.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,n):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 F.a.UniqueId},t.prototype.addMesh=function(e,t){var i=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){i.addMesh(e)})))},t.prototype.removeMesh=function(e,t){var i=this;void 0===t&&(t=!1);var n=this.meshes.indexOf(e);return-1!==n&&(this.meshes[n]=this.meshes[this.meshes.length-1],this.meshes.pop(),e.parent||e._removeFromSceneRootNodes()),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.removeMesh(e)})),n},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 i=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=i,i._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 i=0,n=this.meshes;i0?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,i){},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),this.onMultiMaterialRemovedObservable.notifyObservers(e),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 i=this.getTransformNodeByID(e);if(i)return i;var n=this.getLightByID(e);if(n)return n;var r=this.getCameraByID(e);if(r)return r;var o=this.getBoneByID(e);return o||null},t.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getTransformNodeByName(e);if(i)return i;var n=this.getLightByName(e);if(n)return n;var r=this.getCameraByName(e);if(r)return r;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!=(s.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||s.alwaysSelectAsActiveMesh||s.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(s),this.activeCamera._activeMeshes.push(s),c!==s&&c._activate(this._renderId,!1);for(var l=0,u=this._preActiveMeshStage;l0)for(var i=this.getActiveSubMeshCandidates(t),n=i.length,r=0;r1)this.activeCamera.outputRenderTarget._bindFrameBuffer();else{var e=this.activeCamera.outputRenderTarget.getInternalTexture();e?this.getEngine().bindFramebuffer(e):P.a.Error("Camera contains invalid customDefaultRenderTarget")}}else this.getEngine().restoreDefaultFramebuffer()},t.prototype._renderForCamera=function(e,t){if(!e||!e._skipRendering){var i=this._engine;if(this._activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");i.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 n=0;n0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets);for(var a=0,s=this._gatherActiveCameraRenderTargetsStage;a0){r.b.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var l=0;l0),this._renderId++}for(var d=0,f=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&&(n.trigger===S.a.ACTION_OnIntersectionExitTrigger&&n._executeCurrent(b.a.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(S.a.ACTION_OnIntersectionExitTrigger,(function(e){var t=e instanceof d.a?e:e.mesh;return o===t}))&&n.trigger!==S.a.ACTION_OnIntersectionExitTrigger||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,i=this._engine.getTimeStep(),n=1e3/i/1e3,r=0,o=this._engine.getLockstepMaxSteps(),a=Math.floor(e/i);for(a=Math.min(a,o);e>0&&r0)for(var o=0;o0),this._intermediateRendering=!0;for(var u=0;u0),this._intermediateRendering=!1,this._renderId++}this.activeCamera=l,this._activeCamera&&this._activeCamera.cameraRigMode!==f.a.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var d=0,p=this._beforeClearStage;d0)for(o=0;o0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[o]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var g=0,v=this._afterRenderStage;g-1&&this._engine.scenes.splice(r,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),t.prototype.clearCachedVertexData=function(){for(var e=0;e-1?(u.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._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))},t.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()},t.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},t.prototype._getViewMatrix=function(){return c.a.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){var i,n,r,o,a,s,l,u;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 h=this.getEngine(),d=this.getScene();if(this.mode===t.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=h.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1);var f=h.useReverseDepthBuffer;(d.useRightHandedSystem?f?c.a.PerspectiveFovReverseRHToRef:c.a.PerspectiveFovRHToRef:f?c.a.PerspectiveFovReverseLHToRef:c.a.PerspectiveFovLHToRef)(this.fov,h.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED)}else{var p=h.getRenderWidth()/2,_=h.getRenderHeight()/2;d.useRightHandedSystem?c.a.OrthoOffCenterRHToRef(null!==(i=this.orthoLeft)&&void 0!==i?i:-p,null!==(n=this.orthoRight)&&void 0!==n?n:p,null!==(r=this.orthoBottom)&&void 0!==r?r:-_,null!==(o=this.orthoTop)&&void 0!==o?o:_,this.minZ,this.maxZ,this._projectionMatrix):c.a.OrthoOffCenterLHToRef(null!==(a=this.orthoLeft)&&void 0!==a?a:-p,null!==(s=this.orthoRight)&&void 0!==s?s:p,null!==(l=this.orthoBottom)&&void 0!==l?l:-_,null!==(u=this.orthoTop)&&void 0!==u?u:_,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=h.getRenderWidth(),this._cache.renderHeight=h.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?p.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=p.a.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 i=!1;return this.rigCameras.forEach((function(t){t._updateFrustumPlanes(),i=i||e.isInFrustum(t._frustumPlanes)})),i}return e.isInFrustum(this._frustumPlanes)},t.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},t.prototype.getForwardRay=function(e,t,i){throw void 0===e&&(e=100),d.a.WarnImport("Ray")},t.prototype.getForwardRayToRef=function(e,t,i,n){throw void 0===t&&(t=100),d.a.WarnImport("Ray")},t.prototype.dispose=function(i,n){for(void 0===n&&(n=!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 r=this._rigCameras.pop();r&&r.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,i,n)},Object.defineProperty(t.prototype,"isLeftCamera",{get:function(){return this._isLeftCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRightCamera",{get:function(){return this._isRightCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!1,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,i){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){var n=this._rigCameras.pop();n&&n.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=i.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=a.b.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==t.RIG_MODE_NONE){var r=this.createRigCamera(this.name+"_L",0);r&&(r._isLeftCamera=!0);var o=this.createRigCamera(this.name+"_R",1);o&&(o._isRightCamera=!0),r&&o&&(this._rigCameras.push(r),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,i);break;case t.RIG_MODE_WEBVR:t._setWebVRRigMode(this,i)}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 c.a.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},t.prototype._updateCameraRotationMatrix=function(){},t.prototype._updateWebVRCameraRotationMatrix=function(){},t.prototype._getWebVRProjectionMatrix=function(){return c.a.Identity()},t.prototype._getWebVRViewMatrix=function(){return c.a.Identity()},t.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=a.b.ToRadians(t/.0637))},t.prototype.createRigCamera=function(e,t){return null},t.prototype._updateRigCameras=function(){for(var e=0;e=1)&&(this.needAlphaBlending()||e.visibility<1||e.hasVertexAlpha)},e.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest},e.prototype._shouldTurnAlphaTestOn=function(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.markDirty=function(){for(var e=0,t=this.getScene().meshes;e1&&s.renderbufferStorageMultisample?s.renderbufferStorageMultisample(s.RENDERBUFFER,i,r,e,t):s.renderbufferStorage(s.RENDERBUFFER,n,e,t),s.framebufferRenderbuffer(s.FRAMEBUFFER,a,s.RENDERBUFFER,c),s.bindRenderbuffer(s.RENDERBUFFER,null),c},this._boundUniforms={};var h=null;if(t){if(n=n||{},b.a.SetMatrixPrecision(!!n.useHighPrecisionMatrix),t.getContext){if(h=t,this._renderingCanvas=h,null!=i&&(n.antialias=i),void 0===n.deterministicLockstep&&(n.deterministicLockstep=!1),void 0===n.lockstepMaxSteps&&(n.lockstepMaxSteps=4),void 0===n.timeStep&&(n.timeStep=1/60),void 0===n.preserveDrawingBuffer&&(n.preserveDrawingBuffer=!1),void 0===n.audioEngine&&(n.audioEngine=!0),void 0===n.stencil&&(n.stencil=!0),!1===n.premultipliedAlpha&&(this.premultipliedAlpha=!1),void 0===n.xrCompatible&&(n.xrCompatible=!0),this._doNotHandleContextLost=!!n.doNotHandleContextLost,navigator&&navigator.userAgent){var m=navigator.userAgent;this.hostInformation.isMobile=-1!==m.indexOf("Mobile");for(var g=0,v=e.ExceptionList;g0)if(parseInt(C[C.length-1])>=P)continue}for(var R=0,x=S;R1?this._shaderProcessor=new _.a:this._shaderProcessor=new p,this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this._creationOptions=n,console.log("Babylon.js v"+e.Version+" - "+this.description)}}return Object.defineProperty(e,"NpmPackage",{get:function(){return"babylonjs@4.2.0"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"Version",{get:function(){return"4.2.0"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"description",{get:function(){var e="WebGL"+this.webGLVersion;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShadersRepository",{get:function(){return r.a.ShadersRepository},set:function(e){r.a.ShadersRepository=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_shouldUseHighPrecisionShader",{get:function(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(e){this._doNotHandleContextLost=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"framebufferDimensionsObject",{set:function(e){this._framebufferDimensionsObject=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,u.a.TEXTUREFORMAT_RGBA,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,u.a.TEXTUREFORMAT_RGBA,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture2DArray",{get:function(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,u.a.TEXTUREFORMAT_RGBA,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture2DArray},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,u.a.TEXTUREFORMAT_RGBA,u.a.TEXTURETYPE_UNSIGNED_INT,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!1,configurable:!0}),e.prototype._rebuildInternalTextures=function(){for(var e=0,t=this._internalTexturesCache.slice();e1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile"),standardDerivatives:this._webGLVersion>1||null!==this._gl.getExtension("OES_standard_derivatives"),maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),fragmentDepthSupported:this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float"),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1},this._glVersion=this._gl.getParameter(this._gl.VERSION);var e=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=e&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),36193!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=36193),34842!==this._gl.RGBA16F&&(this._gl.RGBA16F=34842),34836!==this._gl.RGBA32F&&(this._gl.RGBA32F=34836),35056!==this._gl.DEPTH24_STENCIL8&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(1===this._webGLVersion&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)>0),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._webGLVersion>1&&5131!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._webGLVersion>1)this._caps.drawBuffersExtension=!0,this._caps.maxMSAASamples=this._gl.getParameter(this._gl.MAX_SAMPLES);else{var t=this._gl.getExtension("WEBGL_draw_buffers");if(null!==t){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=t.drawBuffersWEBGL.bind(t),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var i=0;i<16;i++)this._gl["COLOR_ATTACHMENT"+i+"_WEBGL"]=t["COLOR_ATTACHMENT"+i+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{var n=this._gl.getExtension("WEBGL_depth_texture");null!=n&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=n.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var r=this._gl.getExtension("OES_vertex_array_object");null!=r&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=r.createVertexArrayOES.bind(r),this._gl.bindVertexArray=r.bindVertexArrayOES.bind(r),this._gl.deleteVertexArray=r.deleteVertexArrayOES.bind(r))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var o=this._gl.getExtension("ANGLE_instanced_arrays");null!=o?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=o.drawArraysInstancedANGLE.bind(o),this._gl.drawElementsInstanced=o.drawElementsInstancedANGLE.bind(o),this._gl.vertexAttribDivisor=o.vertexAttribDivisorANGLE.bind(o)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){var a=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);a&&s&&(this._caps.highPrecisionShaderSupported=0!==a.precision&&0!==s.precision)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{var c=this._gl.getExtension("EXT_blend_minmax");null!=c&&(this._caps.blendMinMax=!0,this._gl.MAX=c.MAX_EXT,this._gl.MIN=c.MIN_EXT)}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var l=0;l=0&&this._activeRenderLoops.splice(t,1)}else this._activeRenderLoops=[]},e.prototype._renderLoop=function(){if(!this._contextWasLost){var e=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(e=!1),e){this.beginFrame();for(var t=0;t0?this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},e.prototype.getRenderingCanvas=function(){return this._renderingCanvas},e.prototype.getHostWindow=function(){return f.a.IsWindowObjectExist()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null},e.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferWidth:this._gl.drawingBufferWidth},e.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferHeight:this._gl.drawingBufferHeight},e.prototype._queueNewFrame=function(t,i){return e.QueueNewFrame(t,i)},e.prototype.runRenderLoop=function(e){-1===this._activeRenderLoops.indexOf(e)&&(this._activeRenderLoops.push(e),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._boundRenderFunction=this._renderLoop.bind(this),this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))},e.prototype.clear=function(e,t,i,n){void 0===n&&(n=!1),this.applyStates();var r=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),r|=this._gl.COLOR_BUFFER_BIT),i&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GREATER,this._gl.clearDepth(0)):this._gl.clearDepth(1),r|=this._gl.DEPTH_BUFFER_BIT),n&&(this._gl.clearStencil(0),r|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(r)},e.prototype._viewport=function(e,t,i,n){e===this._viewportCached.x&&t===this._viewportCached.y&&i===this._viewportCached.z&&n===this._viewportCached.w||(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=n,this._gl.viewport(e,t,i,n))},e.prototype.setViewport=function(e,t,i){var n=t||this.getRenderWidth(),r=i||this.getRenderHeight(),o=e.x||0,a=e.y||0;this._cachedViewport=e,this._viewport(o*n,a*r,n*e.width,r*e.height)},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer()},e.prototype.resize=function(){var e,t;f.a.IsWindowObjectExist()?(e=this._renderingCanvas?this._renderingCanvas.clientWidth||this._renderingCanvas.width:window.innerWidth,t=this._renderingCanvas?this._renderingCanvas.clientHeight||this._renderingCanvas.height:window.innerHeight):(e=this._renderingCanvas?this._renderingCanvas.width:100,t=this._renderingCanvas?this._renderingCanvas.height:100),this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel)},e.prototype.setSize=function(e,t){return!!this._renderingCanvas&&(e|=0,t|=0,(this._renderingCanvas.width!==e||this._renderingCanvas.height!==t)&&(this._renderingCanvas.width=e,this._renderingCanvas.height=t,!0))},e.prototype.bindFramebuffer=function(e,t,i,n,r,o,a){void 0===t&&(t=0),void 0===o&&(o=0),void 0===a&&(a=0),this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var s=this._gl;e.is2DArray?s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,e._webGLTexture,o,a):e.isCube&&s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+t,e._webGLTexture,o);var c=e._depthStencilTexture;if(c){var l=c._generateStencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;e.is2DArray?s.framebufferTextureLayer(s.FRAMEBUFFER,l,c._webGLTexture,o,a):e.isCube?s.framebufferTexture2D(s.FRAMEBUFFER,l,s.TEXTURE_CUBE_MAP_POSITIVE_X+t,c._webGLTexture,o):s.framebufferTexture2D(s.FRAMEBUFFER,l,s.TEXTURE_2D,c._webGLTexture,o)}this._cachedViewport&&!r?this.setViewport(this._cachedViewport,i,n):(i||(i=e.width,o&&(i/=Math.pow(2,o))),n||(n=e.height,o&&(n/=Math.pow(2,o))),this._viewport(0,0,i,n)),this.wipeCaches()},e.prototype._bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},e.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null;var n=this._gl;if(e._MSAAFramebuffer){if(e._textureArray)return void this.unBindMultiColorAttachmentFramebuffer(e._textureArray,t,i);n.bindFramebuffer(n.READ_FRAMEBUFFER,e._MSAAFramebuffer),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,e._framebuffer),n.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,n.COLOR_BUFFER_BIT,n.NEAREST)}!e.generateMipMaps||t||e.isCube||(this._bindTextureDirectly(n.TEXTURE_2D,e,!0),n.generateMipmap(n.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null)),i&&(e._MSAAFramebuffer&&this._bindUnboundFramebuffer(e._framebuffer),i()),this._bindUnboundFramebuffer(null)},e.prototype.flushFramebuffer=function(){this._gl.flush()},e.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},e.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},e.prototype.createVertexBuffer=function(e){return this._createVertexBuffer(e,this._gl.STATIC_DRAW)},e.prototype._createVertexBuffer=function(e,t){var i=this._gl.createBuffer();if(!i)throw new Error("Unable to create vertex buffer");var n=new m.a(i);return this.bindArrayBuffer(n),e instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),n.references=1,n},e.prototype.createDynamicVertexBuffer=function(e){return this._createVertexBuffer(e,this._gl.DYNAMIC_DRAW)},e.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},e.prototype.createIndexBuffer=function(e,t){var i=this._gl.createBuffer(),n=new m.a(i);if(!i)throw new Error("Unable to create index buffer");this.bindIndexBuffer(n);var r=this._normalizeIndexData(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),n.references=1,n.is32Bits=4===r.BYTES_PER_ELEMENT,n},e.prototype._normalizeIndexData=function(e){if(e instanceof Uint16Array)return e;if(this._caps.uintIndices){if(e instanceof Uint32Array)return e;for(var t=0;t=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)},e.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},e.prototype.bindUniformBlock=function(e,t,i){var n=e.program,r=this._gl.getUniformBlockIndex(n,t);this._gl.uniformBlockBinding(n,r,i)},e.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},e.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)},e.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},e.prototype._vertexAttribPointer=function(e,t,i,n,r,o,a){var s=this._currentBufferPointers[t];if(s){var c=!1;s.active?(s.buffer!==e&&(s.buffer=e,c=!0),s.size!==i&&(s.size=i,c=!0),s.type!==n&&(s.type=n,c=!0),s.normalized!==r&&(s.normalized=r,c=!0),s.stride!==o&&(s.stride=o,c=!0),s.offset!==a&&(s.offset=a,c=!0)):(c=!0,s.active=!0,s.index=t,s.size=i,s.type=n,s.normalized=r,s.stride=o,s.offset=a,s.buffer=e),(c||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,n,r,o,a))}},e.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},e.prototype._bindVertexBuffersAttributes=function(e,t){var i=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var n=0;n=0){var o=e[i[n]];if(!o)continue;this._gl.enableVertexAttribArray(r),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[r]=!0);var a=o.getBuffer();a&&(this._vertexAttribPointer(a,r,o.getSize(),o.type,o.normalized,o.byteStride,o.byteOffset),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(r,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(r),this._currentInstanceBuffers.push(a))))}}},e.prototype.recordVertexArrayObject=function(e,t,i){var n=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(n),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),n},e.prototype.bindVertexArrayObject=function(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=null!=t&&t.is32Bits,this._mustWipeVertexAttributes=!0)},e.prototype.bindBuffersDirectly=function(e,t,i,n,r){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==r){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=r;var o=r.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var a=0,s=0;s=0&&(this._gl.enableVertexAttribArray(c),this._vertexAttribArraysEnabled[c]=!0,this._vertexAttribPointer(e,c,i[s],this._gl.FLOAT,!1,n,a)),a+=4*i[s]}}this._bindIndexBufferWithCache(t)},e.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},e.prototype.bindBuffers=function(e,t,i){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===i||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i)),this._bindIndexBufferWithCache(t)},e.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1?"#version 300 es\n#define WEBGL2 \n":"",s=this._compileShader(t,"vertex",n,a),c=this._compileShader(i,"fragment",n,a);return this._createShaderProgram(e,s,c,r,o)},e.prototype.createPipelineContext=function(){var e=new g.a;return e.engine=this,this._caps.parallelShaderCompile&&(e.isParallelCompiled=!0),e},e.prototype._createShaderProgram=function(e,t,i,n,r){void 0===r&&(r=null);var o=n.createProgram();if(e.program=o,!o)throw new Error("Unable to create program");return n.attachShader(o,t),n.attachShader(o,i),n.linkProgram(o),e.context=n,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},e.prototype._finalizePipelineContext=function(e){var t=e.context,i=e.vertexShader,n=e.fragmentShader,r=e.program;if(!t.getProgramParameter(r,t.LINK_STATUS)){var o,a;if(!this._gl.getShaderParameter(i,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(i))throw e.vertexCompilationError=o,new Error("VERTEX SHADER "+o);if(!this._gl.getShaderParameter(n,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(n))throw e.fragmentCompilationError=o,new Error("FRAGMENT SHADER "+o);if(a=t.getProgramInfoLog(r))throw e.programLinkError=a,new Error(a)}if(this.validateShaderPrograms&&(t.validateProgram(r),!t.getProgramParameter(r,t.VALIDATE_STATUS)&&(a=t.getProgramInfoLog(r))))throw e.programValidationError=a,new Error(a);t.deleteShader(i),t.deleteShader(n),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)},e.prototype._preparePipelineContext=function(e,t,i,n,r,o,a){var s=e;s.program=n?this.createRawShaderProgram(s,t,i,void 0,a):this.createShaderProgram(s,t,i,o,void 0,a),s.program.__SPECTOR_rebuildProgram=r},e.prototype._isRenderingStateCompiled=function(e){var t=e;return!!this._gl.getProgramParameter(t.program,this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)&&(this._finalizePipelineContext(t),!0)},e.prototype._executeWhenRenderingStateIsCompiled=function(e,t){var i=e;if(i.isParallelCompiled){var n=i.onCompiled;i.onCompiled=n?function(){n(),t()}:t}else t()},e.prototype.getUniforms=function(e,t){for(var i=new Array,n=e,r=0;r-1?t.substring(A).toLowerCase():""),C=null;P.indexOf("?")>-1&&(P=P.split("?")[0]);for(var R=0,x=e._TextureLoaders;Rc||e.height>c||!v._supportsHardwareTextureRescaling)return v._prepareWorkingCanvas(),!(!v._workingCanvas||!v._workingContext)&&(v._workingCanvas.width=t,v._workingCanvas.height=i,v._workingContext.drawImage(e,0,0,e.width,e.height,0,0,t,i),r.texImage2D(r.TEXTURE_2D,0,s,s,r.UNSIGNED_BYTE,v._workingCanvas),E.width=t,E.height=i,!1);var l=new h.a(v,h.b.Temp);return v._bindTextureDirectly(r.TEXTURE_2D,l,!0),r.texImage2D(r.TEXTURE_2D,0,s,s,r.UNSIGNED_BYTE,e),v._rescaleTexture(l,E,o,s,(function(){v._releaseTexture(l),v._bindTextureDirectly(r.TEXTURE_2D,E,!0),n()})),!0}),a)};!b||T?l&&(l.decoding||l.close)?N(l):e._FileToolsLoadImage(t,N,I,o?o.offlineProvider:null,m):"string"==typeof l||l instanceof ArrayBuffer||ArrayBuffer.isView(l)||l instanceof Blob?e._FileToolsLoadImage(l,N,I,o?o.offlineProvider:null,m):l&&N(l)}return E},e._FileToolsLoadImage=function(e,t,i,n,r){throw o.a.WarnImport("FileTools")},e.prototype._rescaleTexture=function(e,t,i,n,r){},e.prototype.createRawTexture=function(e,t,i,n,r,a,s,c,l){throw void 0===c&&(c=null),void 0===l&&(l=u.a.TEXTURETYPE_UNSIGNED_INT),o.a.WarnImport("Engine.RawTexture")},e.prototype.createRawCubeTexture=function(e,t,i,n,r,a,s,c){throw void 0===c&&(c=null),o.a.WarnImport("Engine.RawTexture")},e.prototype.createRawTexture3D=function(e,t,i,n,r,a,s,c,l,h){throw void 0===l&&(l=null),void 0===h&&(h=u.a.TEXTURETYPE_UNSIGNED_INT),o.a.WarnImport("Engine.RawTexture")},e.prototype.createRawTexture2DArray=function(e,t,i,n,r,a,s,c,l,h){throw void 0===l&&(l=null),void 0===h&&(h=u.a.TEXTURETYPE_UNSIGNED_INT),o.a.WarnImport("Engine.RawTexture")},e.prototype._unpackFlipY=function(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))},e.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},e.prototype._getTextureTarget=function(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D},e.prototype.updateTextureSamplingMode=function(e,t,i){void 0===i&&(i=!1);var n=this._getTextureTarget(t),r=this._getSamplingParameters(e,t.generateMipMaps||i);this._setTextureParameterInteger(n,this._gl.TEXTURE_MAG_FILTER,r.mag,t),this._setTextureParameterInteger(n,this._gl.TEXTURE_MIN_FILTER,r.min),i&&(t.generateMipMaps=!0,this._gl.generateMipmap(n)),this._bindTextureDirectly(n,null),t.samplingMode=e},e.prototype.updateTextureWrappingMode=function(e,t,i,n){void 0===i&&(i=null),void 0===n&&(n=null);var r=this._getTextureTarget(e);null!==t&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),null!==i&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&null!==n&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(n),e),e._cachedWrapR=n),this._bindTextureDirectly(r,null)},e.prototype._setupDepthStencilTexture=function(e,t,i,n,r){var o=t.width||t,a=t.height||t,s=t.layers||0;e.baseWidth=o,e.baseHeight=a,e.width=o,e.height=a,e.is2DArray=s>0,e.depth=s,e.isReady=!0,e.samples=1,e.generateMipMaps=!1,e._generateDepthBuffer=!0,e._generateStencilBuffer=i,e.samplingMode=n?u.a.TEXTURE_BILINEAR_SAMPLINGMODE:u.a.TEXTURE_NEAREST_SAMPLINGMODE,e.type=u.a.TEXTURETYPE_UNSIGNED_INT,e._comparisonFunction=r;var c=this._gl,l=this._getTextureTarget(e),h=this._getSamplingParameters(e.samplingMode,!1);c.texParameteri(l,c.TEXTURE_MAG_FILTER,h.mag),c.texParameteri(l,c.TEXTURE_MIN_FILTER,h.min),c.texParameteri(l,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(l,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),0===r?(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,u.a.LEQUAL),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.NONE)):(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,r),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.COMPARE_REF_TO_TEXTURE))},e.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,n,r,o,a){void 0===o&&(o=0),void 0===a&&(a=0);var s=this._gl,c=s.TEXTURE_2D;e.isCube&&(c=s.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._gl.compressedTexImage2D(c,a,t,i,n,0,r)},e.prototype._uploadDataToTextureDirectly=function(e,t,i,n,r,o){void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=!1);var a=this._gl,s=this._getWebGLTextureType(e.type),c=this._getInternalFormat(e.format),l=void 0===r?this._getRGBABufferInternalSizedFormat(e.type,e.format):this._getInternalFormat(r);this._unpackFlipY(e.invertY);var u=a.TEXTURE_2D;e.isCube&&(u=a.TEXTURE_CUBE_MAP_POSITIVE_X+i);var h=Math.round(Math.log(e.width)*Math.LOG2E),d=Math.round(Math.log(e.height)*Math.LOG2E),f=o?e.width:Math.pow(2,Math.max(h-n,0)),p=o?e.height:Math.pow(2,Math.max(d-n,0));a.texImage2D(u,n,l,f,p,0,c,s,t)},e.prototype.updateTextureData=function(e,t,i,n,r,o,a,s){void 0===a&&(a=0),void 0===s&&(s=0);var c=this._gl,l=this._getWebGLTextureType(e.type),u=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);var h=c.TEXTURE_2D;e.isCube&&(h=c.TEXTURE_CUBE_MAP_POSITIVE_X+a),c.texSubImage2D(h,s,i,n,r,o,u,l,t)},e.prototype._uploadArrayBufferViewToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0);var r=this._gl,o=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(o,e,!0),this._uploadDataToTextureDirectly(e,t,i,n),this._bindTextureDirectly(o,null,!0)},e.prototype._prepareWebGLTextureContinuation=function(e,t,i,n,r){var o=this._gl;if(o){var a=this._getSamplingParameters(r,!i);o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,a.mag),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,a.min),i||n||o.generateMipmap(o.TEXTURE_2D),this._bindTextureDirectly(o.TEXTURE_2D,null),t&&t._removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}},e.prototype._prepareWebGLTexture=function(t,i,n,r,o,a,s,c,l){var h=this;void 0===l&&(l=u.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var d=this.getCaps().maxTextureSize,f=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(n,d):n),p=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(r,d):r),_=this._gl;_&&(t._webGLTexture?(this._bindTextureDirectly(_.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===o||!!o),t.baseWidth=n,t.baseHeight=r,t.width=f,t.height=p,t.isReady=!0,c(f,p,(function(){h._prepareWebGLTextureContinuation(t,i,a,s,l)}))||this._prepareWebGLTextureContinuation(t,i,a,s,l)):i&&i._removePendingData(t))},e.prototype._setupFramebufferDepthAttachments=function(e,t,i,n,r){void 0===r&&(r=1);var o=this._gl;if(e&&t)return this._getDepthStencilBuffer(i,n,r,o.DEPTH_STENCIL,o.DEPTH24_STENCIL8,o.DEPTH_STENCIL_ATTACHMENT);if(t){var a=o.DEPTH_COMPONENT16;return this._webGLVersion>1&&(a=o.DEPTH_COMPONENT32F),this._getDepthStencilBuffer(i,n,r,a,a,o.DEPTH_ATTACHMENT)}return e?this._getDepthStencilBuffer(i,n,r,o.STENCIL_INDEX8,o.STENCIL_INDEX8,o.STENCIL_ATTACHMENT):null},e.prototype._releaseFramebufferObjects=function(e){var t=this._gl;e._framebuffer&&(t.deleteFramebuffer(e._framebuffer),e._framebuffer=null),e._depthStencilBuffer&&(t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(t.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(t.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null)},e.prototype._releaseTexture=function(e){this._releaseFramebufferObjects(e),this._deleteTexture(e._webGLTexture),this.unbindAllTextures();var t=this._internalTexturesCache.indexOf(e);-1!==t&&this._internalTexturesCache.splice(t,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()},e.prototype._deleteTexture=function(e){this._gl.deleteTexture(e)},e.prototype._setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},e.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.program);for(var i=e.getSamplers(),n=0;n-1;return i&&o&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||n?(this._activateCurrentTexture(),t&&t.isMultiview?this._gl.bindTexture(e,t?t._colorTextureArray:null):this._gl.bindTexture(e,t?t._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)):i&&(r=!0,this._activateCurrentTexture()),o&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),r},e.prototype._bindTexture=function(e,t){if(void 0!==e){t&&(t._associatedChannel=e),this._activeChannel=e;var i=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(i,t)}},e.prototype.unbindAllTextures=function(){for(var e=0;e1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))},e.prototype.setTexture=function(e,t,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},e.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i&&i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},e.prototype._getTextureWrapMode=function(e){switch(e){case u.a.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case u.a.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case u.a.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},e.prototype._setTexture=function(e,t,i,n){if(void 0===i&&(i=!1),void 0===n&&(n=!1),!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(t.video)this._activeChannel=e,t.update();else if(t.delayLoadState===u.a.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;var r;r=n?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!i&&r&&(r._associatedChannel=e);var o=!0;this._boundTexturesCache[e]===r&&(i||this._bindSamplerUniformToChannel(r._associatedChannel,e),o=!1),this._activeChannel=e;var a=this._getTextureTarget(r);if(o&&this._bindTextureDirectly(a,r,i),r&&!r.isMultiview){if(r.isCube&&r._cachedCoordinatesMode!==t.coordinatesMode){r._cachedCoordinatesMode=t.coordinatesMode;var s=t.coordinatesMode!==u.a.TEXTURE_CUBIC_MODE&&t.coordinatesMode!==u.a.TEXTURE_SKYBOX_MODE?u.a.TEXTURE_WRAP_ADDRESSMODE:u.a.TEXTURE_CLAMP_ADDRESSMODE;t.wrapU=s,t.wrapV=s}r._cachedWrapU!==t.wrapU&&(r._cachedWrapU=t.wrapU,this._setTextureParameterInteger(a,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),r)),r._cachedWrapV!==t.wrapV&&(r._cachedWrapV=t.wrapV,this._setTextureParameterInteger(a,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),r)),r.is3D&&r._cachedWrapR!==t.wrapR&&(r._cachedWrapR=t.wrapR,this._setTextureParameterInteger(a,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),r)),this._setAnisotropicLevel(a,r,t.anisotropicFilteringLevel)}return!0},e.prototype.setTextureArray=function(e,t,i){if(void 0!==e&&t){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var n=0;n=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}},e.prototype.releaseEffects=function(){for(var e in this._compiledEffects){var t=this._compiledEffects[e].getPipelineContext();this._deletePipelineContext(t)}this._compiledEffects={}},e.prototype.dispose=function(){this.stopRenderLoop(),this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.releaseEffects(),this.unbindAllAttributes(),this._boundUniforms=[],f.a.IsWindowObjectExist()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=[],this._renderingCanvas=null,this._currentProgram=null,this._boundRenderFunction=null,r.a.ResetCache();for(var e=0,t=this._activeRequests;e1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(u.a.TEXTURETYPE_FLOAT)},e.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(u.a.TEXTURETYPE_HALF_FLOAT)},e.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var i=!0,n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);var r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER);if((i=(i=i&&o===t.FRAMEBUFFER_COMPLETE)&&t.getError()===t.NO_ERROR)&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);var a=t.RGBA,s=t.UNSIGNED_BYTE,c=new Uint8Array(4);t.readPixels(0,0,1,1,a,s,c),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(n),t.deleteFramebuffer(r),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i},e.prototype._getWebGLTextureType=function(e){if(1===this._webGLVersion){switch(e){case u.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case u.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case u.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case u.a.TEXTURETYPE_BYTE:return this._gl.BYTE;case u.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case u.a.TEXTURETYPE_SHORT:return this._gl.SHORT;case u.a.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case u.a.TEXTURETYPE_INT:return this._gl.INT;case u.a.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case u.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case u.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case u.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case u.a.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case u.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case u.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case u.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},e.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case u.a.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case u.a.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case u.a.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case u.a.TEXTUREFORMAT_RED:t=this._gl.RED;break;case u.a.TEXTUREFORMAT_RG:t=this._gl.RG;break;case u.a.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case u.a.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}if(this._webGLVersion>1)switch(e){case u.a.TEXTUREFORMAT_RED_INTEGER:t=this._gl.RED_INTEGER;break;case u.a.TEXTUREFORMAT_RG_INTEGER:t=this._gl.RG_INTEGER;break;case u.a.TEXTUREFORMAT_RGB_INTEGER:t=this._gl.RGB_INTEGER;break;case u.a.TEXTUREFORMAT_RGBA_INTEGER:t=this._gl.RGBA_INTEGER}return t},e.prototype._getRGBABufferInternalSizedFormat=function(e,t){if(1===this._webGLVersion){if(void 0!==t)switch(t){case u.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case u.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case u.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB}return this._gl.RGBA}switch(e){case u.a.TEXTURETYPE_BYTE:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case u.a.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case u.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case u.a.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R8;case u.a.TEXTUREFORMAT_RG:return this._gl.RG8;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB8;case u.a.TEXTUREFORMAT_RGBA:return this._gl.RGBA8;case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case u.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;case u.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case u.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case u.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case u.a.TEXTURETYPE_SHORT:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case u.a.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case u.a.TEXTURETYPE_INT:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case u.a.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case u.a.TEXTURETYPE_FLOAT:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R32F;case u.a.TEXTUREFORMAT_RG:return this._gl.RG32F;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case u.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case u.a.TEXTURETYPE_HALF_FLOAT:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R16F;case u.a.TEXTUREFORMAT_RG:return this._gl.RG16F;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case u.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case u.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case u.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case u.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case u.a.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case u.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return this._gl.RGBA8},e.prototype._getRGBAMultiSampleBufferFormat=function(e){return e===u.a.TEXTURETYPE_FLOAT?this._gl.RGBA32F:e===u.a.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},e.prototype._loadFile=function(t,i,n,r,o,a){var s=this,c=e._FileToolsLoadFile(t,i,n,r,o,a);return this._activeRequests.push(c),c.onCompleteObservable.add((function(e){s._activeRequests.splice(s._activeRequests.indexOf(e),1)})),c},e._FileToolsLoadFile=function(e,t,i,n,r,a){throw o.a.WarnImport("FileTools")},e.prototype.readPixels=function(e,t,i,n,r){void 0===r&&(r=!0);var o=r?4:3,a=r?this._gl.RGBA:this._gl.RGB,s=new Uint8Array(n*i*o);return this._gl.readPixels(e,t,i,n,a,this._gl.UNSIGNED_BYTE,s),s},Object.defineProperty(e,"IsSupported",{get:function(){return this.isSupported()},enumerable:!1,configurable:!0}),e.isSupported=function(){if(null!==this._HasMajorPerformanceCaveat)return!this._HasMajorPerformanceCaveat;if(null===this._IsSupported)try{var e=v.a.CreateCanvas(1,1),t=e.getContext("webgl")||e.getContext("experimental-webgl");this._IsSupported=null!=t&&!!window.WebGLRenderingContext}catch(e){this._IsSupported=!1}return this._IsSupported},Object.defineProperty(e,"HasMajorPerformanceCaveat",{get:function(){if(null===this._HasMajorPerformanceCaveat)try{var e=v.a.CreateCanvas(1,1),t=e.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||e.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!t}catch(e){this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat},enumerable:!1,configurable:!0}),e.CeilingPOT=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},e.FloorPOT=function(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)},e.NearestPOT=function(t){var i=e.CeilingPOT(t),n=e.FloorPOT(t);return i-t>t-n?n:i},e.GetExponentOfTwo=function(t,i,n){var r;switch(void 0===n&&(n=u.a.SCALEMODE_NEAREST),n){case u.a.SCALEMODE_FLOOR:r=e.FloorPOT(t);break;case u.a.SCALEMODE_NEAREST:r=e.NearestPOT(t);break;case u.a.SCALEMODE_CEILING:default:r=e.CeilingPOT(t)}return Math.min(r,i)},e.QueueNewFrame=function(e,t){return f.a.IsWindowObjectExist()?(t||(t=window),t.requestPostAnimationFrame?t.requestPostAnimationFrame(e):t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)):"undefined"!=typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,16)},e.prototype.getHostDocument=function(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:document},e.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/72.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/73.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/74.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/71",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/72",capture:null,captureConstraint:null,targets:["vao"]}],e._TextureLoaders=[],e.CollisionsEpsilon=.001,e._IsSupported=null,e._HasMajorPerformanceCaveat=null,e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"a",(function(){return c}));var n,r=i(6),o=i(102),a=i(2),s=i(21);!function(e){e[e.Unknown=0]="Unknown",e[e.Url=1]="Url",e[e.Temp=2]="Temp",e[e.Raw=3]="Raw",e[e.Dynamic=4]="Dynamic",e[e.RenderTarget=5]="RenderTarget",e[e.MultiRenderTarget=6]="MultiRenderTarget",e[e.Cube=7]="Cube",e[e.CubeRaw=8]="CubeRaw",e[e.CubePrefiltered=9]="CubePrefiltered",e[e.Raw3D=10]="Raw3D",e[e.Raw2DArray=11]="Raw2DArray",e[e.Depth=12]="Depth",e[e.CubeRawRGBD=13]="CubeRawRGBD"}(n||(n={}));var c=function(){function e(e,t,i){void 0===i&&(i=!1),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.samplingMode=-1,this.generateMipMaps=!1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new r.c,this.width=0,this.height=0,this.depth=0,this.baseWidth=0,this.baseHeight=0,this.baseDepth=0,this.invertY=!1,this._invertVScale=!1,this._associatedChannel=-1,this._source=n.Unknown,this._buffer=null,this._bufferView=null,this._bufferViewArray=null,this._bufferViewArrayArray=null,this._size=0,this._extension="",this._files=null,this._workingCanvas=null,this._workingContext=null,this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._MSAARenderBuffer=null,this._attachments=null,this._textureArray=null,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._isDisabled=!1,this._compression=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._comparisonFunction=0,this._sphericalPolynomial=null,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._lodTextureHigh=null,this._lodTextureMid=null,this._lodTextureLow=null,this._isRGBD=!1,this._linearSpecularLOD=!1,this._irradianceTexture=null,this._webGLTexture=null,this._references=1,this._gammaSpace=null,this._engine=e,this._source=t,i||(this._webGLTexture=e._createTexture())}return e.prototype.getEngine=function(){return this._engine},Object.defineProperty(e.prototype,"source",{get:function(){return this._source},enumerable:!1,configurable:!0}),e.prototype.incrementReferences=function(){this._references++},e.prototype.updateSize=function(e,t,i){void 0===i&&(i=1),this.width=e,this.height=t,this.depth=i,this.baseWidth=e,this.baseHeight=t,this.baseDepth=i,this._size=e*t*i},e.prototype._rebuild=function(){var t,i,r=this;switch(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedAnisotropicFilteringLevel=null,this.source){case n.Temp:return;case n.Url:return void(i=this._engine.createTexture(null!==(t=this._originalUrl)&&void 0!==t?t:this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,(function(){i._swapAndDie(r),r.isReady=!0}),null,this._buffer,void 0,this.format));case n.Raw:return(i=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case n.Raw3D:return(i=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case n.Raw2DArray:return(i=this._engine.createRawTexture2DArray(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case n.Dynamic:return(i=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode))._swapAndDie(this),void this._engine.updateDynamicTexture(this,this._engine.getRenderingCanvas(),this.invertY,void 0,void 0,!0);case n.RenderTarget:var s=new o.a;if(s.generateDepthBuffer=this._generateDepthBuffer,s.generateMipMaps=this.generateMipMaps,s.generateStencilBuffer=this._generateStencilBuffer,s.samplingMode=this.samplingMode,s.type=this.type,this.isCube)i=this._engine.createRenderTargetCubeTexture(this.width,s);else{var c={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};i=this._engine.createRenderTargetTexture(c,s)}return i._swapAndDie(this),void(this.isReady=!0);case n.Depth:var l={bilinearFiltering:this.samplingMode!==a.a.TEXTURE_BILINEAR_SAMPLINGMODE,comparisonFunction:this._comparisonFunction,generateStencil:this._generateStencilBuffer,isCube:this.isCube},u={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};return(i=this._engine.createDepthStencilTexture(u,l))._swapAndDie(this),void(this.isReady=!0);case n.Cube:return void(i=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,(function(){i._swapAndDie(r),r.isReady=!0}),null,this.format,this._extension));case n.CubeRaw:return(i=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case n.CubeRawRGBD:return i=this._engine.createRawCubeTexture(null,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),void e._UpdateRGBDAsync(i,this._bufferViewArrayArray,this._sphericalPolynomial,this._lodGenerationScale,this._lodGenerationOffset).then((function(){i._swapAndDie(r),r.isReady=!0}));case n.CubePrefiltered:return void((i=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,(function(e){e&&e._swapAndDie(r),r.isReady=!0}),null,this.format,this._extension))._sphericalPolynomial=this._sphericalPolynomial)}},e.prototype._swapAndDie=function(e){e._webGLTexture=this._webGLTexture,e._isRGBD=this._isRGBD,this._framebuffer&&(e._framebuffer=this._framebuffer),this._depthStencilBuffer&&(e._depthStencilBuffer=this._depthStencilBuffer),e._depthStencilTexture=this._depthStencilTexture,this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);var t,i=this._engine.getLoadedTexturesCache();-1!==(t=i.indexOf(this))&&i.splice(t,1),-1===(t=i.indexOf(e))&&i.push(e)},e.prototype.dispose=function(){this._webGLTexture&&(this._references--,0===this._references&&(this._engine._releaseTexture(this),this._webGLTexture=null))},e._UpdateRGBDAsync=function(e,t,i,n,r){throw s.a.WarnImport("environmentTextureTools")},e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"c",(function(){return r})),i.d(t,"a",(function(){return o}));var n=1/2.2,r=2.2,o=.001},function(e,t,i){"use strict";i.d(t,"a",(function(){return l}));var n=i(1),r=i(0),o=i(3),a=i(6),s=i(22),c=i(21),l=function(){function e(e,t){void 0===t&&(t=null),this.state="",this.metadata=null,this.reservedDataStore=null,this._doNotSerialize=!1,this._isDisposed=!1,this.animations=new Array,this._ranges={},this.onReady=null,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=r.a.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._sceneRootNodesIndex=-1,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new a.c,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||s.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}return e.AddNodeConstructor=function(e,t){this._NodeConstructors[e]=t},e.Construct=function(e,t,i,n){var r=this._NodeConstructors[e];return r?r(t,i,n):null},Object.defineProperty(e.prototype,"doNotSerialize",{get:function(){return!!this._doNotSerialize||!!this._parentNode&&this._parentNode.doNotSerialize},set:function(e){this._doNotSerialize=e},enumerable:!1,configurable:!0}),e.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(e.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){var t=this._parentNode;if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){var i=this._parentNode._children.indexOf(this);-1!==i&&this._parentNode._children.splice(i,1),e||this._isDisposed||this._addToSceneRootNodes()}this._parentNode=e,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}},enumerable:!1,configurable:!0}),e.prototype._addToSceneRootNodes=function(){-1===this._sceneRootNodesIndex&&(this._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))},e.prototype._removeFromSceneRootNodes=function(){if(-1!==this._sceneRootNodesIndex){var e=this._scene.rootNodes,t=e.length-1;e[this._sceneRootNodesIndex]=e[t],e[this._sceneRootNodesIndex]._sceneRootNodesIndex=this._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._sceneRootNodesIndex=-1}},Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"Node"},Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._scene.getEngine()},e.prototype.addBehavior=function(e,t){var i=this;return void 0===t&&(t=!1),-1!==this._behaviors.indexOf(e)||(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce((function(){e.attach(i)})):e.attach(this),this._behaviors.push(e)),this},e.prototype.removeBehavior=function(e){var t=this._behaviors.indexOf(e);return-1===t||(this._behaviors[t].detach(),this._behaviors.splice(t,1)),this},Object.defineProperty(e.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),e.prototype.getBehaviorByName=function(e){for(var t=0,i=this._behaviors;t0,o.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,o.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===m.a.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,o.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case m.a.EXPLICIT_MODE:o.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case m.a.PLANAR_MODE:o.setReflectionMode("REFLECTIONMAP_PLANAR");break;case m.a.PROJECTION_MODE:o.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case m.a.SKYBOX_MODE:o.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case m.a.SPHERICAL_MODE:o.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case m.a.EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case m.a.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case m.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case m.a.CUBIC_MODE:case m.a.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;_.a.PrepareDefinesForMergedUV(this._emissiveTexture,o,"EMISSIVE")}else o.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;_.a.PrepareDefinesForMergedUV(this._lightmapTexture,o,"LIGHTMAP"),o.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,o.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else o.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;_.a.PrepareDefinesForMergedUV(this._specularTexture,o,"SPECULAR"),o.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else o.SPECULAR=!1;if(r.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;_.a.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,o.RGBDREFRACTION=this._refractionTexture.isRGBD}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=this.alphaMode===P.a.ALPHA_PREMULTIPLIED||this.alphaMode===P.a.ALPHA_PREMULTIPLIED_PORTERDUFF,o.ALPHATEST_AFTERALLALPHACOMPUTATIONS=null!==this.transparencyMode,o.ALPHABLEND=null===this.transparencyMode||this.needAlphaBlendingForMesh(e)}if(!this.detailMap.isReadyForSubMesh(o,r))return!1;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),_.a.PrepareDefinesForMisc(e,r,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,o),_.a.PrepareDefinesForAttributes(e,o,!0,!0,!0),_.a.PrepareDefinesForFrameBoundValues(r,a,o,n,null,i.getRenderingMesh().hasThinInstances),this.detailMap.prepareDefines(o,r),o.isDirty){var s=o._areLightsDisposed;o.markAsProcessed();var c=new C.a;o.REFLECTION&&c.addFallback(0,"REFLECTION"),o.SPECULAR&&c.addFallback(0,"SPECULAR"),o.BUMP&&c.addFallback(0,"BUMP"),o.PARALLAX&&c.addFallback(1,"PARALLAX"),o.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),o.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),o.FOG&&c.addFallback(1,"FOG"),o.POINTSIZE&&c.addFallback(0,"POINTSIZE"),o.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),_.a.HandleFallbacksForShadows(o,c,this._maxSimultaneousLights),o.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),o.DIFFUSEFRESNEL&&c.addFallback(1,"DIFFUSEFRESNEL"),o.OPACITYFRESNEL&&c.addFallback(2,"OPACITYFRESNEL"),o.REFLECTIONFRESNEL&&c.addFallback(3,"REFLECTIONFRESNEL"),o.EMISSIVEFRESNEL&&c.addFallback(4,"EMISSIVEFRESNEL"),o.FRESNEL&&c.addFallback(4,"FRESNEL"),o.MULTIVIEW&&c.addFallback(0,"MULTIVIEW");var d=[l.b.PositionKind];o.NORMAL&&d.push(l.b.NormalKind),o.UV1&&d.push(l.b.UVKind),o.UV2&&d.push(l.b.UV2Kind),o.VERTEXCOLOR&&d.push(l.b.ColorKind),_.a.PrepareAttributesForBones(d,e,o,c),_.a.PrepareAttributesForInstances(d,o),_.a.PrepareAttributesForMorphTargets(d,e,o);var f="default",p=["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"],g=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler"],v=["Material","Scene"];R.a.AddUniforms(p),R.a.AddSamplers(g),u.a.AddUniforms(p),u.a.AddSamplers(p),h.a&&(h.a.PrepareUniforms(p,o),h.a.PrepareSamplers(g,o)),_.a.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:v,samplers:g,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var b={};this.customShaderNameResolve&&(f=this.customShaderNameResolve(f,p,v,g,o,d,b));var y=o.toString(),T=i.effect,E=r.getEngine().createEffect(f,{attributes:d,uniformsNames:p,uniformBuffersNames:v,samplers:g,defines:y,fallbacks:c,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS},processFinalCode:b.processFinalCode,multiTarget:o.PREPASS},a);if(E)if(this._onEffectCreatedObservable&&(x.effect=E,x.subMesh=i,this._onEffectCreatedObservable.notifyObservers(x)),this.allowShaderHotSwapping&&T&&!E.isReady()){if(E=T,this._rebuildInParallel=!0,o.markAsUnprocessed(),s)return o._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,r.resetCachedMaterial(),i.setEffect(E,o),this.buildUniformLayout()}return!(!i.effect||!i.effect.isReady())&&(o._renderId=r.getRenderId(),i.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),R.a.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._refractionTexture&&this._refractionTexture.isRenderTarget&&(this._activeEffect.setTexture("refraction2DSampler",null),t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,i,n){var r=this.getScene(),o=n._materialDefines;if(o){var s=n.effect;if(s){this._activeEffect=s,o.INSTANCES&&!o.THIN_INSTANCES||this.bindOnlyWorldMatrix(e),this.prePassConfiguration.bindForSubMesh(this._activeEffect,r,i,e,this.isFrozen),o.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var l=this._mustRebind(r,s,i.visibility);_.a.BindBonesParameters(i,s);var u=this._uniformBuffer;if(l){if(u.bindToEffect(s,"Material"),this.bindViewProjection(s),!u.useUbo||!this.isFrozen||!u.isSync){if(t.FresnelEnabled&&o.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(u.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),u.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&u.updateColor4("opacityParts",new c.a(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(u.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),u.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(u.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),u.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(u.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),u.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),r.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(u.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),_.a.BindTextureMatrix(this._diffuseTexture,u,"diffuse")),this._ambientTexture&&t.AmbientTextureEnabled&&(u.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),_.a.BindTextureMatrix(this._ambientTexture,u,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(u.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),_.a.BindTextureMatrix(this._opacityTexture,u,"opacity")),this._hasAlphaChannel()&&s.setFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&t.ReflectionTextureEnabled&&(u.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),u.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var h=this._reflectionTexture;u.updateVector3("vReflectionPosition",h.boundingBoxPosition),u.updateVector3("vReflectionSize",h.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(u.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),_.a.BindTextureMatrix(this._emissiveTexture,u,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(u.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),_.a.BindTextureMatrix(this._lightmapTexture,u,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(u.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),_.a.BindTextureMatrix(this._specularTexture,u,"specular")),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(u.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),_.a.BindTextureMatrix(this._bumpTexture,u,"bump"),r._mirroredCameraPosition?u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.RefractionTextureEnabled){var d=1;this._refractionTexture.isCube||(u.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(d=this._refractionTexture.depth)),u.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,d,this.invertRefractionY?-1:1)}}this.pointsCloud&&u.updateFloat("pointSize",this.pointSize),o.SPECULARTERM&&u.updateColor4("vSpecularColor",this.specularColor,this.specularPower),u.updateColor3("vEmissiveColor",t.EmissiveTextureEnabled?this.emissiveColor:c.a.BlackReadOnly),u.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha)}if(u.updateFloat("visibility",i.visibility),r.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&s.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&s.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&s.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?s.setTexture("reflectionCubeSampler",this._reflectionTexture):s.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&s.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&s.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&s.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&s.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled)){d=1;this._refractionTexture.isCube?s.setTexture("refractionCubeSampler",this._refractionTexture):s.setTexture("refraction2DSampler",this._refractionTexture)}this.detailMap.bindForSubMesh(u,r,this.isFrozen),_.a.BindClipPlane(s,r),r.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),_.a.BindEyePosition(s,r),s.setColor3("vAmbientColor",this._globalAmbientColor)}!l&&this.isFrozen||(r.lightsEnabled&&!this._disableLighting&&_.a.BindLights(r,i,s,o,this._maxSimultaneousLights,this._rebuildInParallel),(r.fogEnabled&&i.applyFog&&r.fogMode!==a.a.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(s),_.a.BindFogParameters(r,i,s),o.NUM_MORPH_INFLUENCERS&&_.a.BindMorphTargetParameters(i,s),this.useLogarithmicDepth&&_.a.BindLogDepth(o,s,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),u.update(),this._afterBind(i,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),this.detailMap.getAnimatables(e),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),this.detailMap.getActiveTextures(t),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||this.detailMap.hasTexture(t))))))))))},t.prototype.dispose=function(t,i){var n,r,o,a,s,c,l,u,h;i&&(null===(n=this._diffuseTexture)||void 0===n||n.dispose(),null===(r=this._ambientTexture)||void 0===r||r.dispose(),null===(o=this._opacityTexture)||void 0===o||o.dispose(),null===(a=this._reflectionTexture)||void 0===a||a.dispose(),null===(s=this._emissiveTexture)||void 0===s||s.dispose(),null===(c=this._specularTexture)||void 0===c||c.dispose(),null===(l=this._bumpTexture)||void 0===l||l.dispose(),null===(u=this._lightmapTexture)||void 0===u||u.dispose(),null===(h=this._refractionTexture)||void 0===h||h.dispose()),this.detailMap.dispose(i),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},t.prototype.clone=function(e){var i=this,n=r.a.Clone((function(){return new t(e,i.getScene())}),this);return n.name=e,n.id=e,n},t.prototype.serialize=function(){return r.a.Serialize(this)},t.Parse=function(e,i,n){return r.a.Parse((function(){return new t(e.name,i)}),e,i,n)},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return v.a.DiffuseTextureEnabled},set:function(e){v.a.DiffuseTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DetailTextureEnabled",{get:function(){return v.a.DetailTextureEnabled},set:function(e){v.a.DetailTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return v.a.AmbientTextureEnabled},set:function(e){v.a.AmbientTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return v.a.OpacityTextureEnabled},set:function(e){v.a.OpacityTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return v.a.ReflectionTextureEnabled},set:function(e){v.a.ReflectionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return v.a.EmissiveTextureEnabled},set:function(e){v.a.EmissiveTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return v.a.SpecularTextureEnabled},set:function(e){v.a.SpecularTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return v.a.BumpTextureEnabled},set:function(e){v.a.BumpTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return v.a.LightmapTextureEnabled},set:function(e){v.a.LightmapTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return v.a.RefractionTextureEnabled},set:function(e){v.a.RefractionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return v.a.ColorGradingTextureEnabled},set:function(e){v.a.ColorGradingTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return v.a.FresnelEnabled},set:function(e){v.a.FresnelEnabled=e},enumerable:!1,configurable:!0}),Object(n.c)([Object(r.m)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),Object(n.c)([Object(r.m)("ambientTexture")],t.prototype,"_ambientTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(n.c)([Object(r.m)("opacityTexture")],t.prototype,"_opacityTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(n.c)([Object(r.m)("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(n.c)([Object(r.m)("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(n.c)([Object(r.m)("specularTexture")],t.prototype,"_specularTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),Object(n.c)([Object(r.m)("bumpTexture")],t.prototype,"_bumpTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(n.c)([Object(r.m)("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),Object(n.c)([Object(r.m)("refractionTexture")],t.prototype,"_refractionTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),Object(n.c)([Object(r.e)("ambient")],t.prototype,"ambientColor",void 0),Object(n.c)([Object(r.e)("diffuse")],t.prototype,"diffuseColor",void 0),Object(n.c)([Object(r.e)("specular")],t.prototype,"specularColor",void 0),Object(n.c)([Object(r.e)("emissive")],t.prototype,"emissiveColor",void 0),Object(n.c)([Object(r.c)()],t.prototype,"specularPower",void 0),Object(n.c)([Object(r.c)("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),Object(n.c)([Object(r.c)("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),Object(n.c)([Object(r.c)("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),Object(n.c)([Object(r.c)("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(n.c)([Object(r.c)("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),Object(n.c)([Object(r.c)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.c)([Object(r.c)("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(n.c)([Object(r.c)("useParallax")],t.prototype,"_useParallax",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(n.c)([Object(r.c)("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(n.c)([Object(r.c)()],t.prototype,"parallaxScaleBias",void 0),Object(n.c)([Object(r.c)("roughness")],t.prototype,"_roughness",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(n.c)([Object(r.c)()],t.prototype,"indexOfRefraction",void 0),Object(n.c)([Object(r.c)()],t.prototype,"invertRefractionY",void 0),Object(n.c)([Object(r.c)()],t.prototype,"alphaCutOff",void 0),Object(n.c)([Object(r.c)("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(n.c)([Object(r.h)("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),Object(n.c)([Object(r.h)("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),Object(n.c)([Object(r.h)("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),Object(n.c)([Object(r.h)("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),Object(n.c)([Object(r.h)("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),Object(n.c)([Object(r.c)("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),Object(n.c)([Object(r.c)("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),Object(n.c)([Object(r.c)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(n.c)([Object(r.c)("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(n.c)([Object(r.c)("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(n.c)([Object(r.c)("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(n.c)([Object(r.c)()],t.prototype,"useLogarithmicDepth",null),t}(p.a);g.a.RegisteredTypes["BABYLON.StandardMaterial"]=M,a.a.DefaultMaterialFactory=function(e){return new M("default material",e)}},function(e,t,i){"use strict";i.d(t,"a",(function(){return S}));var n=i(1),r=i(12),o=i(6),a=i(0),s=i(13),c=i(4),l=i(16),u=i(46),h=i(54),d=i(43),f=i(2),p=i(147),_=i(21),m=i(101),g=i(9),v=i(28),b=i(23),y=i(11),T=function(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=a.e.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1},E=function(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new T,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=null,this._currentLODIsUpToDate=!1},S=function(e){function t(i,n){void 0===n&&(n=null);var r=e.call(this,i,n,!1)||this;return r._internalAbstractMeshDataInfo=new E,r.cullingStrategy=t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,r.onCollideObservable=new o.c,r.onCollisionPositionChangeObservable=new o.c,r.onMaterialChangedObservable=new o.c,r.definedFacingForward=!0,r._occlusionQuery=null,r._renderingGroup=null,r.alphaIndex=Number.MAX_VALUE,r.isVisible=!0,r.isPickable=!0,r.showSubMeshesBoundingBox=!1,r.isBlocker=!1,r.enablePointerMoveEvents=!1,r._renderingGroupId=0,r._material=null,r.outlineColor=g.a.Red(),r.outlineWidth=.02,r.overlayColor=g.a.Red(),r.overlayAlpha=.5,r.useOctreeForRenderingSelection=!0,r.useOctreeForPicking=!0,r.useOctreeForCollisions=!0,r.alwaysSelectAsActiveMesh=!1,r.doNotSyncBoundingInfo=!1,r.actionManager=null,r._meshCollisionData=new p.a,r.ellipsoid=new a.e(.5,1,.5),r.ellipsoidOffset=new a.e(0,0,0),r.edgesWidth=1,r.edgesColor=new g.b(1,0,0,1),r._edgesRenderer=null,r._masterMesh=null,r._boundingInfo=null,r._renderId=0,r._intersectionsInProgress=new Array,r._unIndexed=!1,r._lightSources=new Array,r._waitingData={lods:null,actions:null,freezeWorldMatrix:null},r._bonesTransformMatrices=null,r._transformMatrixTexture=null,r.onRebuildObservable=new o.c,r._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),t.subtractToRef(r._meshCollisionData._oldPositionForCollisions,r._meshCollisionData._diffPositionForCollisions),r._meshCollisionData._diffPositionForCollisions.length()>s.a.CollisionsEpsilon&&r.position.addInPlace(r._meshCollisionData._diffPositionForCollisions),i&&r.onCollideObservable.notifyObservers(i),r.onCollisionPositionChangeObservable.notifyObservers(r.position)},r.getScene().addMesh(r),r._resyncLightSources(),r}return Object(n.d)(t,e),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return u.a.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return u.a.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return u.a.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return u.a.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return u.a.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_USE_POSITION",{get:function(){return u.a.BILLBOARDMODE_USE_POSITION},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!1,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:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderingGroupId",{get:function(){return this._renderingGroupId},set:function(e){this._renderingGroupId=e},enumerable:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._meshCollisionData._collisionMask},set:function(e){this._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionResponse",{get:function(){return this._meshCollisionData._collisionResponse},set:function(e){this._meshCollisionData._collisionResponse=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionGroup",{get:function(){return this._meshCollisionData._collisionGroup},set:function(e){this._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"surroundingMeshes",{get:function(){return this._meshCollisionData._surroundingMeshes},set:function(e){this._meshCollisionData._surroundingMeshes=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_positions",{get:function(){return null},enumerable:!1,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:!1,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 i=this._internalAbstractMeshDataInfo._skeleton;return i&&(t+=", skeleton: "+i.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!==u.a.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,s=o?this.getVerticesData(c.b.MatricesIndicesExtraKind):null,l=o?this.getVerticesData(c.b.MatricesWeightsExtraKind):null;this.skeleton.prepare();for(var u=this.skeleton.getTransformMatrices(this),h=a.c.Vector3[0],d=a.c.Matrix[0],f=a.c.Matrix[1],p=0,_=0;_0&&(a.a.FromFloat32ArrayToRefScaled(u,Math.floor(16*i[p+m]),g,f),d.addToSelf(f));if(o)for(m=0;m<4;m++)(g=l[p+m])>0&&(a.a.FromFloat32ArrayToRefScaled(u,Math.floor(16*s[p+m]),g,f),d.addToSelf(f));a.e.TransformCoordinatesFromFloatsToRef(t[_],t[_+1],t[_+2],d,h),h.toArray(t,_),this._positions&&this._positions[_/3].copyFrom(h)}}}return t},t.prototype._updateBoundingInfo=function(){var e=this._effectiveMesh;return this._boundingInfo?this._boundingInfo.update(e.worldMatrixFromCache):this._boundingInfo=new d.a(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,i=0;i1||!n.IsGlobal)&&n.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:!1,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,i){if(void 0===t&&(t=!1),!this._boundingInfo||!e._boundingInfo)return!1;if(this._boundingInfo.intersects(e._boundingInfo,t))return!0;if(i)for(var n=0,r=this.getChildMeshes();n1&&!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=a.c.Matrix[0],i=a.c.Matrix[1];return a.a.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,i),this._processCollisionsForSubMeshes(e,i),this},t.prototype._generatePointsArray=function(){return!1},t.prototype.intersects=function(e,t,i,n,r,o){var s;void 0===n&&(n=!1),void 0===o&&(o=!1);var c=new h.a,l="InstancedLinesMesh"===this.getClassName()||"LinesMesh"===this.getClassName()?this.intersectionThreshold:0,u=this._boundingInfo;if(!this.subMeshes||!u)return c;if(!(o||e.intersectsSphere(u.boundingSphere,l)&&e.intersectsBox(u.boundingBox,l)))return c;if(n)return c.hit=!o,c.pickedMesh=o?null:this,c.distance=o?0:a.e.Distance(e.origin,u.boundingSphere.center),c.subMeshId=0,c;if(!this._generatePointsArray())return c;for(var d=null,p=this._scene.getIntersectingSubMeshCandidates(this,e),_=p.length,m=!1,g=0;g<_;g++){var v=(b=p.data[g]).getMaterial();if(v&&((null===(s=this.getIndices())||void 0===s?void 0:s.length)&&(v.fillMode==f.a.MATERIAL_TriangleStripDrawMode||v.fillMode==f.a.MATERIAL_TriangleFillMode||v.fillMode==f.a.MATERIAL_WireFrameFillMode||v.fillMode==f.a.MATERIAL_PointFillMode))){m=!0;break}}if(!m)return c.hit=!0,c.pickedMesh=this,c.distance=a.e.Distance(e.origin,u.boundingSphere.center),c.subMeshId=-1,c;for(g=0;g<_;g++){var b=p.data[g];if(!(_>1)||b.canIntersects(e)){var y=b.intersects(e,this._positions,this.getIndices(),t,i);if(y&&(t||!d||y.distance65535){o=!0;break}e.depthSortedIndices=o?new Uint32Array(i):new Uint16Array(i)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){var u=this.getScene().activeCamera;e.facetDepthSortFrom=u?u.position:a.e.Zero()}e.depthSortedFacets=[];for(var h=0;hv.a?r.maximum.x-r.minimum.x:v.a,e.bbSize.y=r.maximum.y-r.minimum.y>v.a?r.maximum.y-r.minimum.y:v.a,e.bbSize.z=r.maximum.z-r.minimum.z>v.a?r.maximum.z-r.minimum.z:v.a;var f=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(f=f>e.bbSize.z?f:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/f),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/f),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/f),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=r,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),a.e.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,l.a.ComputeNormals(t,i,n,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var p=e.depthSortedIndices.length/3|0;for(h=0;hr.subDiv.max||a<0||a>r.subDiv.max||s<0||s>r.subDiv.max?null:r.facetPartitioning[o+r.subDiv.max*a+r.subDiv.max*r.subDiv.max*s]},t.prototype.getClosestFacetAtCoordinates=function(e,t,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=!0);var s=this.getWorldMatrix(),c=a.c.Matrix[5];s.invertToRef(c);var l=a.c.Vector3[8];a.e.TransformCoordinatesFromFloatsToRef(e,t,i,c,l);var u=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,n,r,o);return n&&a.e.TransformCoordinatesFromFloatsToRef(n.x,n.y,n.z,s,n),u},t.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=!0);var a=null,s=0,c=0,l=0,u=0,h=0,d=0,f=0,p=0,_=this.getFacetLocalPositions(),m=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,i);if(!g)return null;for(var v,b,y,T=Number.MAX_VALUE,E=T,S=0;S=0||r&&!o&&u<=0)&&(u=b.x*y.x+b.y*y.y+b.z*y.z,h=-(b.x*e+b.y*t+b.z*i-u)/(b.x*b.x+b.y*b.y+b.z*b.z),(E=(s=(d=e+b.x*h)-e)*s+(c=(f=t+b.y*h)-t)*c+(l=(p=i+b.z*h)-i)*l)100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=o.b.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new o.b),this._options.mass=void 0===i.mass?0:i.mass,this._options.friction=void 0===i.friction?.2:i.friction,this._options.restitution=void 0===i.restitution?.2:i.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=void 0===i.pressure?200:i.pressure,this._options.stiffness=void 0===i.stiffness?1:i.stiffness,this._options.velocityIterations=void 0===i.velocityIterations?20:i.velocityIterations,this._options.positionIterations=void 0===i.positionIterations?20:i.positionIterations,this._options.fixedPoints=void 0===i.fixedPoints?0:i.fixedPoints,this._options.margin=void 0===i.margin?0:i.margin,this._options.damping=void 0===i.damping?0:i.damping,this._options.path=void 0===i.path?null:i.path,this._options.shape=void 0===i.shape?null:i.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&n.a.Warn("You must affect impostors to children before affecting impostor to parent.")):n.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):n.a.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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 a.a?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:!1,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:!1,configurable:!0}),e.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},e.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion,i=this.object.scaling.clone();this.object.rotationQuaternion=e.IDENTITY_QUATERNION;var n=this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);n&&n.decompose(i,void 0,void 0);var r=this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(i);return this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),r}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):o.e.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):o.e.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):n.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):n.a.Warn("Function to remove was not found")},e.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},e.prototype.unregisterOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e],r=-1;this._onPhysicsCollideCallbacks.some((function(e,n){if(e.callback===t&&e.otherImpostors.length===i.length){var o=e.otherImpostors.every((function(e){return i.indexOf(e)>-1}));return o&&(r=n),o}return!1}))?this._onPhysicsCollideCallbacks.splice(r,1):n.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):o.b.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,i){var n=new c.e(t,i);return this.addJoint(e,n),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,i,n,r){if(!this._physicsEngine)return this;var o=this._physicsEngine.getPhysicsPlugin();return o.appendAnchor?(this._physicsEngine&&o.appendAnchor(this,e,t,i,n,r),this):this},e.prototype.addHook=function(e,t,i,n){if(!this._physicsEngine)return this;var r=this._physicsEngine.getPhysicsPlugin();return r.appendAnchor?(this._physicsEngine&&r.appendHook(this,e,t,i,n),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 o.b),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,i,n,r,o){var a=e._tmpVecs[0],s=this.object;if(s.rotationQuaternion)if(o){var c=e._tmpQuat;s.rotationQuaternion.multiplyToRef(o,c),t.setRotationQuaternion(c,l.c.WORLD,i)}else t.setRotationQuaternion(s.rotationQuaternion,l.c.WORLD,i);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,t.getDirectionToRef(a,i,a),null==r&&(r=n.length()),a.x*=r,a.y*=r,a.z*=r),t.getParent()?(a.addInPlace(s.getAbsolutePosition()),t.setAbsolutePosition(a,i)):(i.setAbsolutePosition(s.getAbsolutePosition()),i.position.x-=a.x,i.position.y-=a.y,i.position.z-=a.z)},e.prototype.syncImpostorWithBone=function(t,i,n,r,o,a){var s=this.object;if(s.rotationQuaternion)if(o){var c=e._tmpQuat;t.getRotationQuaternionToRef(l.c.WORLD,i,c),c.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(l.c.WORLD,i,s.rotationQuaternion);var u=e._tmpVecs[0],h=e._tmpVecs[1];a||((a=e._tmpVecs[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,i,h),t.getAbsolutePositionToRef(i,u),null==r&&n&&(r=n.length()),null!=r&&(u.x+=h.x*r,u.y+=h.y*r,u.z+=h.z*r),s.setAbsolutePosition(u)},e.DEFAULT_OBJECT_SIZE=new o.e(1,1,1),e.IDENTITY_QUATERNION=o.b.Identity(),e._tmpVecs=r.a.BuildArray(3,o.e.Zero),e._tmpQuat=o.b.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(e,t,i){"use strict";i.d(t,"a",(function(){return r})),i.d(t,"b",(function(){return o}));var n=i(1),r=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}(),o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return Object(n.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;t>2,o=(3&t)<<4|(i=u>4,a=(15&i)<<2|(n=u>6,s=63&n,isNaN(i)?a=s=64:isNaN(n)&&(s=64),l+=c.charAt(r)+c.charAt(o)+c.charAt(a)+c.charAt(s);return l},e.PadNumber=function(e,t){for(var i=String(e);i.length0)):!i._pointerCaptures[c.pointerId]&&a.distance>s.distance&&(i.mainSceneTrackerPredicate&&i.mainSceneTrackerPredicate(s.pickedMesh)?(i._notifyObservers(t,s,c),t.skipOnPointerObservable=!0):i._lastPointerEvents[c.pointerId]&&(i.onPointerOutObservable.notifyObservers(c.pointerId),delete i._lastPointerEvents[c.pointerId])),t.type===o.a.POINTERUP&&i._pointerCaptures[c.pointerId]&&(i._pointerCaptures[c.pointerId]=!1))}}}})),this._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterCameraRenderObservable.add((function(e){i.shouldRender&&e==i.getRenderCamera()&&i.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add((function(){i.dispose()})),this._updateCamera()}return e.prototype.getRenderCamera=function(e){if(this._renderCamera)return this._renderCamera;var t=void 0;return t=this.originalScene.activeCameras&&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 s.a("shared gizmo light",new c.e(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=l.a.Gray()),this._sharedGizmoLight},Object.defineProperty(e,"DefaultUtilityLayer",{get:function(){return null==e._DefaultUtilityLayer&&(e._DefaultUtilityLayer=new e(a.a.LastCreatedScene),e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultUtilityLayer=null}))),e._DefaultUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DefaultKeepDepthUtilityLayer",{get:function(){return null==e._DefaultKeepDepthUtilityLayer&&(e._DefaultKeepDepthUtilityLayer=new e(a.a.LastCreatedScene),e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultKeepDepthUtilityLayer=null}))),e._DefaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),e.prototype._notifyObservers=function(e,t,i){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new o.b(e.type,e.event,t),e.type),this._lastPointerEvents[i.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}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(139),r=function(){function e(){}return e.EnableFor=function(t){t._tags=t._tags||{},t.hasTags=function(){return e.HasTags(t)},t.addTags=function(i){return e.AddTagsTo(t,i)},t.removeTags=function(i){return e.RemoveTagsFrom(t,i)},t.matchesTagsQuery=function(i){return e.MatchesQuery(t,i)}},e.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},e.HasTags=function(e){if(!e._tags)return!1;var t=e._tags;for(var i in t)if(t.hasOwnProperty(i))return!0;return!1},e.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var n in e._tags)e._tags.hasOwnProperty(n)&&!0===e._tags[n]&&i.push(n);return i.join(" ")}return e._tags},e.AddTagsTo=function(t,i){i&&("string"==typeof i&&i.split(" ").forEach((function(i,n,r){e._AddTagTo(t,i)})))},e._AddTagTo=function(t,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(e.EnableFor(t),t._tags[i]=!0))},e.RemoveTagsFrom=function(t,i){if(e.HasTags(t)){var n=i.split(" ");for(var r in n)e._RemoveTagFrom(t,n[r])}},e._RemoveTagFrom=function(e,t){delete e._tags[t]},e.MatchesQuery=function(t,i){return void 0===i||(""===i?e.HasTags(t):n.a.Eval(i,(function(i){return e.HasTags(t)&&t._tags[i]})))},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.IsWindowObjectExist=function(){return"undefined"!=typeof window},e.IsNavigatorAvailable=function(){return"undefined"!=typeof navigator},e.IsDocumentAvailable=function(){return"undefined"!=typeof document},e.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return l}));var n=i(44),r=i(0),o=i(54),a=i(114),s=i(20),c=i(24),l=function(){function e(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i}return e.prototype.intersectsBoxMinMax=function(t,i,n){void 0===n&&(n=0);var r,o,a,s,c=e._TmpVector3[0].copyFromFloats(t.x-n,t.y-n,t.z-n),l=e._TmpVector3[1].copyFromFloats(i.x+n,i.y+n,i.z+n),u=0,h=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xl.x)return!1}else if(r=1/this.direction.x,o=(c.x-this.origin.x)*r,(a=(l.x-this.origin.x)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yl.y)return!1}else if(r=1/this.direction.y,o=(c.y-this.origin.y)*r,(a=(l.y-this.origin.y)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zl.z)return!1}else if(r=1/this.direction.z,o=(c.z-this.origin.z)*r,(a=(l.z-this.origin.z)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))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 i=e.center.x-this.origin.x,n=e.center.y-this.origin.y,r=e.center.z-this.origin.z,o=i*i+n*n+r*r,a=e.radius+t,s=a*a;if(o<=s)return!0;var c=i*this.direction.x+n*this.direction.y+r*this.direction.z;return!(c<0)&&o-c*c<=s},e.prototype.intersectsTriangle=function(t,i,n){var o=e._TmpVector3[0],s=e._TmpVector3[1],c=e._TmpVector3[2],l=e._TmpVector3[3],u=e._TmpVector3[4];i.subtractToRef(t,o),n.subtractToRef(t,s),r.e.CrossToRef(this.direction,s,c);var h=r.e.Dot(o,c);if(0===h)return null;var d=1/h;this.origin.subtractToRef(t,l);var f=r.e.Dot(l,c)*d;if(f<0||f>1)return null;r.e.CrossToRef(l,o,u);var p=r.e.Dot(this.direction,u)*d;if(p<0||f+p>1)return null;var _=r.e.Dot(s,u)*d;return _>this.length?null:new a.a(1-f-p,f,_)},e.prototype.intersectsPlane=function(e){var t,i=r.e.Dot(e.normal,this.direction);if(Math.abs(i)<9.99999997475243e-7)return null;var n=r.e.Dot(e.normal,this.origin);return(t=(-e.d-n)/i)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsAxis=function(e,t){switch(void 0===t&&(t=0),e){case"y":return(i=(this.origin.y-t)/this.direction.y)>0?null:new r.e(this.origin.x+this.direction.x*-i,t,this.origin.z+this.direction.z*-i);case"x":return(i=(this.origin.x-t)/this.direction.x)>0?null:new r.e(t,this.origin.y+this.direction.y*-i,this.origin.z+this.direction.z*-i);case"z":var i;return(i=(this.origin.z-t)/this.direction.z)>0?null:new r.e(this.origin.x+this.direction.x*-i,this.origin.y+this.direction.y*-i,t);default:return null}},e.prototype.intersectsMesh=function(t,i){var n=r.c.Matrix[0];return t.getWorldMatrix().invertToRef(n),this._tmpRay?e.TransformToRef(this,n,this._tmpRay):this._tmpRay=e.Transform(this,n),t.intersects(this._tmpRay,i)},e.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var n=0;nt.distance?1:0},e.prototype.intersectionSegment=function(t,i,n){var o=this.origin,a=r.c.Vector3[0],s=r.c.Vector3[1],c=r.c.Vector3[2],l=r.c.Vector3[3];i.subtractToRef(t,a),this.direction.scaleToRef(e.rayl,c),o.addToRef(c,s),t.subtractToRef(o,l);var u,h,d,f,p=r.e.Dot(a,a),_=r.e.Dot(a,c),m=r.e.Dot(c,c),g=r.e.Dot(a,l),v=r.e.Dot(c,l),b=p*m-_*_,y=b,T=b;by&&(h=y,f=v+_,T=m)),f<0?(f=0,-g<0?h=0:-g>p?h=y:(h=-g,y=p)):f>T&&(f=T,-g+_<0?h=0:-g+_>p?h=y:(h=-g+_,y=p)),u=Math.abs(h)0&&d<=this.length&&A.lengthSquared()=e.distance?null:l:null},s.a.prototype._internalPick=function(e,t,i,n,a){if(!o.a)return null;for(var s=null,c=0;c0&&(t.push(s-1),t.push(s)),s++}var d=new o.a;return d.indices=t,d.positions=i,r&&(d.colors=a),d},o.a.CreateDashedLines=function(e){var t,i,r=e.dashSize||3,a=e.gapSize||1,s=e.dashNb||200,c=e.points,l=new Array,u=new Array,h=n.e.Zero(),d=0,f=0,p=0,_=0,m=0;for(m=0;m0)if("object"==typeof u[0])for(var d=0;dl.max||l.min>c.max)},d=function(){function e(e,t,i){this._isLocked=!1,this.boundingBox=new a.a(e,t,i),this.boundingSphere=new s.a(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.boundingBox.reConstruct(e,t,i),this.boundingSphere.reConstruct(e,t,i)},Object.defineProperty(e.prototype,"minimum",{get:function(){return this.boundingBox.minimum},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!1,configurable:!0}),e.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},e.prototype.centerOn=function(t,i){var n=e.TmpVector3[0].copyFrom(t).subtractInPlace(i),r=e.TmpVector3[1].copyFrom(t).addInPlace(i);return this.boundingBox.reConstruct(n,r,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(n,r,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=o.a.MESHES_CULLINGSTRATEGY_STANDARD),!(t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION&&t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(t!==o.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)||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:!1,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(!s.a.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!a.a.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var i=this.boundingBox,n=e.boundingBox;return!!h(i.directions[0],i,n)&&(!!h(i.directions[1],i,n)&&(!!h(i.directions[2],i,n)&&(!!h(n.directions[0],i,n)&&(!!h(n.directions[1],i,n)&&(!!h(n.directions[2],i,n)&&(!!h(r.e.Cross(i.directions[0],n.directions[0]),i,n)&&(!!h(r.e.Cross(i.directions[0],n.directions[1]),i,n)&&(!!h(r.e.Cross(i.directions[0],n.directions[2]),i,n)&&(!!h(r.e.Cross(i.directions[1],n.directions[0]),i,n)&&(!!h(r.e.Cross(i.directions[1],n.directions[1]),i,n)&&(!!h(r.e.Cross(i.directions[1],n.directions[2]),i,n)&&(!!h(r.e.Cross(i.directions[2],n.directions[0]),i,n)&&(!!h(r.e.Cross(i.directions[2],n.directions[1]),i,n)&&!!h(r.e.Cross(i.directions[2],n.directions[2]),i,n))))))))))))))},e.TmpVector3=n.a.BuildArray(2,r.e.Zero),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.BuildArray=function(e,t){for(var i=[],n=0;n1)?1:e.arc||1,c=e.slice&&e.slice<=0?1:e.slice||1,l=0===e.sideOrientation?0:e.sideOrientation||o.a.DEFAULTSIDE,u=!!e.dedupTopBottomIndices,h=new n.e(i/2,r/2,a/2),d=2+t,f=2*d,p=[],_=[],m=[],g=[],v=0;v<=d;v++){for(var b=v/d,y=b*Math.PI*c,T=0;T<=f;T++){var E=T/f,S=E*Math.PI*2*s,A=n.a.RotationZ(-y),P=n.a.RotationY(S),C=n.e.TransformCoordinates(n.e.Up(),A),R=n.e.TransformCoordinates(C,P),x=R.multiply(h),O=R.divide(h).normalize();_.push(x.x,x.y,x.z),m.push(O.x,O.y,O.z),g.push(E,b)}if(v>0)for(var M=_.length/3,I=M-2*(f+1);I+f+21&&(p.push(I),p.push(I+1),p.push(I+f+1)),(v0&&-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,i){void 0===i&&(i=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var n=0,r=this.getScene().meshes;n0&&(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)}))),r.a.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},t.GetConstructorFromName=function(e,t,i){var n=s.a.Construct("Light_Type_"+e,t,i);return n||null},t.Parse=function(e,i){var n=t.GetConstructorFromName(e.type,e.name,i);if(!n)return null;var o=r.a.Parse(n,e,i);if(e.excludedMeshesIds&&(o._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(o._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId&&(o._waitingParentId=e.parentId),void 0!==e.falloffType&&(o.falloffType=e.falloffType),void 0!==e.lightmapMode&&(o.lightmapMode=e.lightmapMode),e.animations){for(var a=0;a=0&&this._scene.textures.splice(t,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),e.prototype.dispose.call(this)},t.prototype.serialize=function(){if(!this.name)return null;var e=r.a.Serialize(this);return r.a.AppendSerializedAnimations(this,e),e},t.WhenAllReady=function(e,t){var i=e.length;if(0!==i)for(var n=0;n1)?1:e.arc||1,m=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,g=e.faceUV||new Array(3),v=e.faceColors,b=2+(1+(1!==_&&f?2:0))*(d?h:1);for(l=0;l1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return f})),i.d(t,"d",(function(){return p})),i.d(t,"c",(function(){return _})),i.d(t,"a",(function(){return m}));var n=i(1),r=i(49),o=i(38),a=i(6),s=i(83),c=i(140),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t}(Error),u=i(34),h=i(26),d=i(128),f=function(e){function t(i,n){var o=e.call(this,i)||this;return o.name="LoadFileError",l._setPrototypeOf(o,t.prototype),n instanceof r.a?o.request=n:o.file=n,o}return Object(n.d)(t,e),t}(l),p=function(e){function t(i,n){var r=e.call(this,i)||this;return r.request=n,r.name="RequestFileError",l._setPrototypeOf(r,t.prototype),r}return Object(n.d)(t,e),t}(l),_=function(e){function t(i,n){var r=e.call(this,i)||this;return r.file=n,r.name="ReadFileError",l._setPrototypeOf(r,t.prototype),r}return Object(n.d)(t,e),t}(l),m=function(){function e(){}return e._CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},e.SetCorsBehavior=function(t,i){if((!t||0!==t.indexOf("data:"))&&e.CorsBehavior)if("string"==typeof e.CorsBehavior||this.CorsBehavior instanceof String)i.crossOrigin=e.CorsBehavior;else{var n=e.CorsBehavior(t);n&&(i.crossOrigin=n)}},e.LoadImage=function(t,i,n,r,o){var a;void 0===o&&(o="");var c=!1;if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)?"undefined"!=typeof Blob?(a=URL.createObjectURL(new Blob([t],{type:o})),c=!0):a="data:"+o+";base64,"+u.a.EncodeArrayBufferToBase64(t):t instanceof Blob?(a=URL.createObjectURL(t),c=!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){i(e),c&&URL.revokeObjectURL(a)})).catch((function(e){n&&n("Error while trying to load image: "+t,e)}))}),void 0,r||void 0,!0,(function(e,i){n&&n("Error while trying to load image: "+t,i)})),null;var l=new Image;e.SetCorsBehavior(a,l);var h=function(){l.removeEventListener("load",h),l.removeEventListener("error",d),i(l),c&&l.src&&URL.revokeObjectURL(l.src)},d=function(e){if(l.removeEventListener("load",h),l.removeEventListener("error",d),n){var i=t.toString();n("Error while trying to load image: "+(i.length<32?i:i.slice(0,32)+"..."),e)}c&&l.src&&URL.revokeObjectURL(l.src)};l.addEventListener("load",h),l.addEventListener("error",d);var f=function(){l.src=a};if("data:"!==a.substr(0,5)&&r&&r.enableTexturesOffline)r.open((function(){r&&r.loadImage(a,l)}),f);else{if(-1!==a.indexOf("file:")){var p=decodeURIComponent(a.substring(5).toLowerCase());if(s.a.FilesToLoad[p]){try{var _;try{_=URL.createObjectURL(s.a.FilesToLoad[p])}catch(e){_=URL.createObjectURL(s.a.FilesToLoad[p])}l.src=_,c=!0}catch(e){l.src=""}return l}}f()}return l},e.ReadFile=function(e,t,i,n,r){var o=new FileReader,s={onCompleteObservable:new a.c,abort:function(){return o.abort()}};return o.onloadend=function(e){return s.onCompleteObservable.notifyObservers(s)},r&&(o.onerror=function(t){r(new _("Unable to read "+e.name,e))}),o.onload=function(e){t(e.target.result)},i&&(o.onprogress=i),n?o.readAsArrayBuffer(e):o.readAsText(e),s},e.LoadFile=function(t,i,n,r,o,a){if(-1!==t.indexOf("file:")){var c=decodeURIComponent(t.substring(5).toLowerCase());0===c.indexOf("./")&&(c=c.substring(2));var l=s.a.FilesToLoad[c];if(l)return e.ReadFile(l,i,n,o,a?function(e){return a(void 0,new f(e.message,e.file))}:void 0)}return e.RequestFile(t,(function(e,t){i(e,t?t.responseURL:void 0)}),n,r,o,a?function(e){a(e.request,new f(e.message,e.request))}:void 0)},e.RequestFile=function(t,i,n,s,c,l,u){t=e._CleanUrl(t),t=e.PreprocessUrl(t);var h=e.BaseUrl+t,d=!1,f={onCompleteObservable:new a.c,abort:function(){return d=!0}},_=function(){var t=new r.a,a=null;f.abort=function(){d=!0,t.readyState!==(XMLHttpRequest.DONE||4)&&t.abort(),null!==a&&(clearTimeout(a),a=null)};var s=function(_){t.open("GET",h),u&&u(t),c&&(t.responseType="arraybuffer"),n&&t.addEventListener("progress",n);var m=function(){t.removeEventListener("loadend",m),f.onCompleteObservable.notifyObservers(f),f.onCompleteObservable.clear()};t.addEventListener("loadend",m);var g=function(){if(!d&&t.readyState===(XMLHttpRequest.DONE||4)){if(t.removeEventListener("readystatechange",g),t.status>=200&&t.status<300||0===t.status&&(!o.a.IsWindowObjectExist()||e.IsFileURL()))return void i(c?t.response:t.responseText,t);var n=e.DefaultRetryStrategy;if(n){var u=n(h,t,_);if(-1!==u)return t.removeEventListener("loadend",m),t=new r.a,void(a=setTimeout((function(){return s(_+1)}),u))}var f=new p("Error status: "+t.status+" "+t.statusText+" - Unable to load "+h,t);l&&l(f)}};t.addEventListener("readystatechange",g),t.send()};s(0)};if(s&&s.enableSceneOffline){var m=function(e){e&&e.status>400?l&&l(e):_()};s.open((function(){s&&s.loadFile(e.BaseUrl+t,(function(e){d||i(e),f.onCompleteObservable.notifyObservers(f)}),n?function(e){d||n(e)}:void 0,m,c)}),m)}else _();return f},e.IsFileURL=function(){return"undefined"!=typeof location&&"file:"===location.protocol},e.DefaultRetryStrategy=c.a.ExponentialBackoff(),e.BaseUrl="",e.CorsBehavior="anonymous",e.PreprocessUrl=function(e){return e},e}();h.a._FileToolsLoadImage=m.LoadImage.bind(m),h.a._FileToolsLoadFile=m.LoadFile.bind(m),d.a._FileToolsLoadFile=m.LoadFile.bind(m)},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(38),r=function(){function e(){}return Object.defineProperty(e,"Now",{get:function(){return n.a.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!1,configurable:!0}),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(e,t,i,n){this.x=e,this.y=t,this.width=i,this.height=n}return e.prototype.toGlobal=function(t,i){return new e(this.x*t,this.y*i,this.width*t,this.height*i)},e.prototype.toGlobalToRef=function(e,t,i){return i.x=this.x*e,i.y=this.y*t,i.width=this.width*e,i.height=this.height*t,this},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e}()},function(e,t,i){"use strict";var n="helperFunctions",r="const float PI=3.1415926535897932384626433832795;\nconst float HALF_MIN=5.96046448e-08;\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}\nfloat toLinearSpace(float color)\n{\nreturn pow(color,LinearEncodePowerApprox);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec4 toLinearSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nvec4 toGammaSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\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";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(0),r=function(){function e(){}return e._RemoveAndStorePivotPoint=function(t){t&&0===e._PivotCached&&(t.getPivotPointToRef(e._OldPivotPoint),e._PivotPostMultiplyPivotMatrix=t._postMultiplyPivotMatrix,e._OldPivotPoint.equalsToFloats(0,0,0)||(t.setPivotMatrix(n.a.IdentityReadOnly),e._OldPivotPoint.subtractToRef(t.getPivotPoint(),e._PivotTranslation),e._PivotTmpVector.copyFromFloats(1,1,1),e._PivotTmpVector.subtractInPlace(t.scaling),e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),t.position.addInPlace(e._PivotTmpVector))),e._PivotCached++},e._RestorePivotPoint=function(t){t&&!e._OldPivotPoint.equalsToFloats(0,0,0)&&1===e._PivotCached&&(t.setPivotPoint(e._OldPivotPoint),t._postMultiplyPivotMatrix=e._PivotPostMultiplyPivotMatrix,e._PivotTmpVector.copyFromFloats(1,1,1),e._PivotTmpVector.subtractInPlace(t.scaling),e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),t.position.subtractInPlace(e._PivotTmpVector)),this._PivotCached--},e._PivotCached=0,e._OldPivotPoint=new n.e,e._PivotTranslation=new n.e,e._PivotTmpVector=new n.e,e._PivotPostMultiplyPivotMatrix=!1,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(4),r=i(114),o=i(43),a=i(2),s=i(101),c=function(){function e(e,t,i,n,r,o,a,s,c){void 0===s&&(s=!0),void 0===c&&(c=!0),this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=n,this.indexCount=r,this._materialDefines=null,this._materialEffect=null,this._effectOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=o,this._renderingMesh=a||o,c&&o.subMeshes.push(this),this._trianglePlanes=[],this._id=o.subMeshes.length-1,s&&(this.refreshBoundingInfo(),o.computeWorldMatrix(!0))}return Object.defineProperty(e.prototype,"materialDefines",{get:function(){return this._materialDefines},set:function(e){this._materialDefines=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"effect",{get:function(){var e;return null!==(e=this._effectOverride)&&void 0!==e?e:this._materialEffect},enumerable:!1,configurable:!0}),e.prototype.setEffect=function(e,t){void 0===t&&(t=null),this._materialEffect!==e?(this._materialDefines=t,this._materialEffect=e):e||(this._materialDefines=null)},e.AddToMesh=function(t,i,n,r,o,a,s,c){return void 0===c&&(c=!0),new e(t,i,n,r,o,a,s,c)},Object.defineProperty(e.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount===this._mesh.getTotalVertices()},enumerable:!1,configurable:!0}),e.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},e.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},e.prototype.getMesh=function(){return this._mesh},e.prototype.getRenderingMesh=function(){return this._renderingMesh},e.prototype.getReplacementMesh=function(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null},e.prototype.getEffectiveMesh=function(){var e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh},e.prototype.getMaterial=function(){var e=this._renderingMesh.material;if(null==e)return this._mesh.getScene().defaultMaterial;if(this._IsMultiMaterial(e)){var t=e.getSubMaterial(this.materialIndex);return this._currentMaterial!==t&&(this._currentMaterial=t,this._materialDefines=null),t}return e},e.prototype._IsMultiMaterial=function(e){return void 0!==e.getSubMaterial},e.prototype.refreshBoundingInfo=function(e){if(void 0===e&&(e=null),this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(n.b.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var t,i=this._renderingMesh.getIndices();if(0===this.indexStart&&this.indexCount===i.length){var r=this._renderingMesh.getBoundingInfo();t={minimum:r.minimum.clone(),maximum:r.maximum.clone()}}else t=Object(s.b)(e,i,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(t.minimum,t.maximum):this._boundingInfo=new o.a(t.minimum,t.maximum),this},e.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},e.prototype.updateBoundingInfo=function(e){var t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t&&t.update(e),this},e.prototype.isInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)},e.prototype.isCompletelyInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)},e.prototype.render=function(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this},e.prototype._getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var i=[],n=this.indexStart;ns&&(s=u)}return new e(t,a,s-a+1,i,n,r,o)},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(1),r=i(8),o=i(10),a=i(2),s=(i(126),i(70)),c=function(e){function t(t,i,n,r,c,l,u){void 0===n&&(n=null),void 0===c&&(c=a.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=a.a.TEXTUREFORMAT_RGBA);var h=e.call(this,null,n,!r,u,c,void 0,void 0,void 0,void 0,l)||this;h.name=t,h.wrapU=o.a.CLAMP_ADDRESSMODE,h.wrapV=o.a.CLAMP_ADDRESSMODE,h._generateMipMaps=r;var d=h._getEngine();if(!d)return h;i.getContext?(h._canvas=i,h._texture=d.createDynamicTexture(i.width,i.height,r,c)):(h._canvas=s.a.CreateCanvas(1,1),i.width||0===i.width?h._texture=d.createDynamicTexture(i.width,i.height,r,c):h._texture=d.createDynamicTexture(i,i,r,c));var f=h.getSize();return h._canvas.width=f.width,h._canvas.height=f.height,h._context=h._canvas.getContext("2d"),h}return Object(n.d)(t,e),t.prototype.getClassName=function(){return"DynamicTexture"},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().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 i=this.getSize();i.width=e,i.height=t,this._recreate(i)},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._getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0)},t.prototype.drawText=function(e,t,i,n,r,o,a,s){void 0===s&&(s=!0);var c=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,c.width,c.height)),this._context.font=n,null==t){var l=this._context.measureText(e);t=(c.width-l.width)/2}if(null==i){var u=parseInt(n.replace(/\D/g,""));i=c.height/2+u/3.65}this._context.fillStyle=r||"",this._context.fillText(e,t,i),s&&this.update(a)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),n=new t(this.name,i,e,this._generateMipMaps);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.wrapU=this.wrapU,n.wrapV=this.wrapV,n},t.prototype.serialize=function(){var t=this.getScene();t&&!t.isReady()&&r.a.Warn("The scene must be ready before serializing the dynamic texture");var i=e.prototype.serialize.call(this);return this._IsCanvasElement(this._canvas)&&(i.base64String=this._canvas.toDataURL()),i.invertY=this._invertY,i.samplingMode=this.samplingMode,i},t.prototype._IsCanvasElement=function(e){return void 0!==e.toDataURL},t.prototype._rebuild=function(){this.update()},t}(o.a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return s}));var n=i(0),r=i(9),o=i(7),a=i(16);a.a.CreateBox=function(e){var t,i=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23],o=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],s=[],c=e.width||e.size||1,l=e.height||e.size||1,u=e.depth||e.size||1,h=e.wrap||!1,d=void 0===e.topBaseAt?1:e.topBaseAt,f=void 0===e.bottomBaseAt?0:e.bottomBaseAt,p=[2,0,3,1][d=(d+4)%4],_=[2,0,1,3][f=(f+4)%4],m=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(h){i=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],m=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];for(var g=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],v=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],b=[17,18,19,16],y=[22,23,20,21];p>0;)g.unshift(g.pop()),b.unshift(b.pop()),p--;for(;_>0;)v.unshift(v.pop()),y.unshift(y.pop()),_--;g=g.flat(),v=v.flat(),m=m.concat(g).concat(v),i.push(b[0],b[2],b[3],b[0],b[1],b[2]),i.push(y[0],y[2],y[3],y[0],y[1],y[2])}var T=[c/2,l/2,u/2];t=m.reduce((function(e,t,i){return e.concat(t*T[i%3])}),[]);for(var E=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,S=e.faceUV||new Array(6),A=e.faceColors,P=[],C=0;C<6;C++)void 0===S[C]&&(S[C]=new n.f(0,0,1,1)),A&&void 0===A[C]&&(A[C]=new r.b(1,1,1,1));for(var R=0;R<6;R++)if(s.push(S[R].z,S[R].w),s.push(S[R].x,S[R].w),s.push(S[R].x,S[R].y),s.push(S[R].z,S[R].y),A)for(var x=0;x<4;x++)P.push(A[R].r,A[R].g,A[R].b,A[R].a);a.a._ComputeSides(E,t,i,o,s,e.frontUVs,e.backUVs);var O=new a.a;if(O.indices=i,O.positions=t,O.normals=o,O.uvs=s,A){var M=E===a.a.DOUBLESIDE?P.concat(P):P;O.colors=M}return O},o.a.CreateBox=function(e,t,i,n,r){void 0===i&&(i=null);var o={size:t,sideOrientation:r,updatable:n};return s.CreateBox(e,o,i)};var s=function(){function e(){}return e.CreateBox=function(e,t,i){void 0===i&&(i=null);var n=new o.a(e,i);return t.sideOrientation=o.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,a.a.CreateBox(t).applyToMesh(n,t.updatable),n},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(0),r=function(){function e(e,t,i,r){this.normal=new n.e(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return"Plane"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return e=397*e^(0|this.d)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=e._TmpMatrix;t.invertToRef(i);var n=i.m,r=this.normal.x,o=this.normal.y,a=this.normal.z,s=this.d;return new e(r*n[0]+o*n[1]+a*n[2]+s*n[3],r*n[4]+o*n[5]+a*n[6]+s*n[7],r*n[8]+o*n[9]+a*n[10]+s*n[11],r*n[12]+o*n[13]+a*n[14]+s*n[15])},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,i){var n,r=t.x-e.x,o=t.y-e.y,a=t.z-e.z,s=i.x-e.x,c=i.y-e.y,l=i.z-e.z,u=o*l-a*c,h=a*s-r*l,d=r*c-o*s,f=Math.sqrt(u*u+h*h+d*d);return n=0!==f?1/f:0,this.normal.x=u*n,this.normal.y=h*n,this.normal.z=d*n,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return n.e.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return n.e.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,n){var r=new e(0,0,0,0);return r.copyFromPoints(t,i,n),r},e.FromPositionAndNormal=function(t,i){var n=new e(0,0,0,0);return i.normalize(),n.normal=i,n.d=-(i.x*t.x+i.y*t.y+i.z*t.z),n},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return n.e.Dot(i,t)+r},e._TmpMatrix=n.a.Identity(),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return u}));var n=i(7),r=i(20),o=i(6),a=i(0),s=i(18),c=i(39),l=i(60),u=(i(84),function(){function e(e){this._useAlternatePickedPointAboveMaxDragAngleDragSpeed=-1.1,this.maxDragAngle=0,this._useAlternatePickedPointAboveMaxDragAngle=!1,this.currentDraggingPointerID=-1,this.dragging=!1,this.dragDeltaRatio=.2,this.updateDragPlane=!0,this._debugMode=!1,this._moving=!1,this.onDragObservable=new o.c,this.onDragStartObservable=new o.c,this.onDragEndObservable=new o.c,this.moveAttached=!0,this.enabled=!0,this.startAndReleaseDragOnPointerEvents=!0,this.detachCameraControls=!0,this.useObjectOrientationForDragging=!0,this.validateDrag=function(e){return!0},this._tmpVector=new a.e(0,0,0),this._alternatePickedPoint=new a.e(0,0,0),this._worldDragAxis=new a.e(0,0,0),this._targetPosition=new a.e(0,0,0),this._attachedToElement=!1,this._startDragRay=new c.a(new a.e,new a.e),this._lastPointerRay={},this._dragDelta=new a.e,this._pointA=new a.e(0,0,0),this._pointC=new a.e(0,0,0),this._localAxis=new a.e(0,0,0),this._lookAt=new a.e(0,0,0),this._options=e||{};var t=0;if(this._options.dragAxis&&t++,this._options.dragPlaneNormal&&t++,t>1)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:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t,i){var o=this;this._scene=t.getScene(),this.attachedNode=t,e._planeScene||(this._debugMode?e._planeScene=this._scene:(e._planeScene=new r.a(this._scene.getEngine(),{virtual:!0}),e._planeScene.detachControl(),this._scene.onDisposeObservable.addOnce((function(){e._planeScene.dispose(),e._planeScene=null})))),this._dragPlane=n.a.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,e._planeScene,!1,n.a.DOUBLESIDE),this.lastDragPosition=new a.e(0,0,0);var u=i||function(e){return o.attachedNode==e||e.isDescendantOf(o.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add((function(t,i){if(o.enabled)if(t.type==s.a.POINTERDOWN)o.startAndReleaseDragOnPointerEvents&&!o.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.pickedPoint&&t.pickInfo.ray&&u(t.pickInfo.pickedMesh)&&o._startDrag(t.event.pointerId,t.pickInfo.ray,t.pickInfo.pickedPoint);else if(t.type==s.a.POINTERUP)o.startAndReleaseDragOnPointerEvents&&o.currentDraggingPointerID==t.event.pointerId&&o.releaseDrag();else if(t.type==s.a.POINTERMOVE){var n=t.event.pointerId;if(o.currentDraggingPointerID===e._AnyMouseID&&n!==e._AnyMouseID){var r=t.event;("mouse"===r.pointerType||!o._scene.getEngine().hostInformation.isMobile&&r instanceof MouseEvent)&&(o._lastPointerRay[o.currentDraggingPointerID]&&(o._lastPointerRay[n]=o._lastPointerRay[o.currentDraggingPointerID],delete o._lastPointerRay[o.currentDraggingPointerID]),o.currentDraggingPointerID=n)}o._lastPointerRay[n]||(o._lastPointerRay[n]=new c.a(new a.e,new a.e)),t.pickInfo&&t.pickInfo.ray&&(o._lastPointerRay[n].origin.copyFrom(t.pickInfo.ray.origin),o._lastPointerRay[n].direction.copyFrom(t.pickInfo.ray.direction),o.currentDraggingPointerID==n&&o.dragging&&o._moveDrag(t.pickInfo.ray))}})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){o._moving&&o.moveAttached&&(l.a._RemoveAndStorePivotPoint(o.attachedNode),o._targetPosition.subtractToRef(o.attachedNode.absolutePosition,o._tmpVector),o._tmpVector.scaleInPlace(o.dragDeltaRatio),o.attachedNode.getAbsolutePosition().addToRef(o._tmpVector,o._tmpVector),o.validateDrag(o._tmpVector)&&o.attachedNode.setAbsolutePosition(o._tmpVector),l.a._RestorePivotPoint(o.attachedNode))}))},e.prototype.releaseDrag=function(){if(this.dragging&&(this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerID})),this.currentDraggingPointerID=-1,this._moving=!1,this.detachCameraControls&&this._attachedToElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera){if("ArcRotateCamera"===this._scene.activeCamera.getClassName()){var e=this._scene.activeCamera;e.attachControl(!e.inputs||e.inputs.noPreventDefault,e._useCtrlForPanning,e._panningMouseButton)}else this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault);this._attachedToElement=!1}},e.prototype.startDrag=function(t,i,n){void 0===t&&(t=e._AnyMouseID),this._startDrag(t,i,n);var r=this._lastPointerRay[t];t===e._AnyMouseID&&(r=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),r&&this._moveDrag(r)},e.prototype._startDrag=function(e,t,i){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){l.a._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,i||this._tmpVector);var n=this._pickWithRayOnDragPlane(this._startDragRay);n&&(this.dragging=!0,this.currentDraggingPointerID=e,this.lastDragPosition.copyFrom(n),this.onDragStartObservable.notifyObservers({dragPlanePoint:n,pointerId:this.currentDraggingPointerID}),this._targetPosition.copyFrom(this.attachedNode.absolutePosition),this.detachCameraControls&&this._scene.activeCamera&&this._scene.activeCamera.inputs&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedToElement?(this._scene.activeCamera.detachControl(),this._attachedToElement=!0):this._attachedToElement=!1)),l.a._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 i=0;this._options.dragAxis?(this.useObjectOrientationForDragging?a.e.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),i=a.e.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(i,this._dragDelta)):(i=this._dragDelta.length(),t.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:i,delta:this._dragDelta,dragPlanePoint:t,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerID}),this.lastDragPosition.copyFrom(t)}},e.prototype._pickWithRayOnDragPlane=function(t){var i=this;if(!t)return null;var n=Math.acos(a.e.Dot(this._dragPlane.forward,t.direction));if(n>Math.PI/2&&(n=Math.PI-n),this.maxDragAngle>0&&n>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*a.e.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var r=a.e.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-r,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==i._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?a.e.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),e.origin.subtractToRef(this._pointA,this._pointC),this._pointC.normalize(),Math.abs(a.e.Dot(this._localAxis,this._pointC))>.999?Math.abs(a.e.Dot(a.e.UpReadOnly,this._pointC))>.999?this._lookAt.copyFrom(a.e.Right()):this._lookAt.copyFrom(a.e.UpReadOnly):(a.e.CrossToRef(this._localAxis,this._pointC,this._lookAt),a.e.CrossToRef(this._localAxis,this._lookAt,this._lookAt),this._lookAt.normalize()),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._lookAt,this._lookAt),this._dragPlane.lookAt(this._lookAt)):this._options.dragPlaneNormal?(this.useObjectOrientationForDragging?a.e.TransformCoordinatesToRef(this._options.dragPlaneNormal,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragPlaneNormal),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._localAxis,this._lookAt),this._dragPlane.lookAt(this._lookAt)):(this._dragPlane.position.copyFrom(this._pointA),this._dragPlane.lookAt(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}())},function(e,t,i){"use strict";i.d(t,"a",(function(){return r})),i.d(t,"b",(function(){return o})),i.d(t,"c",(function(){return a}));var n=i(1),r=function(){function e(){}return e.KEYDOWN=1,e.KEYUP=2,e}(),o=function(e,t){this.type=e,this.event=t},a=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.type=t,n.event=i,n.skipOnPointerObservable=!1,n}return Object(n.d)(t,e),t}(o)},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}return e.prototype.unBindMesh=function(){this._mesh=null},e.prototype.addFallback=function(e,t){this._defines[e]||(ethis._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:!1,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 i=this._mesh.getScene(),n=0;n0&&(r.computeBonesUsingShaders=!1)}}else{var s=this._defines[this._currentRank];if(s)for(n=0;n=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.hasTexture=function(t){var i;if(e.prototype.hasTexture.call(this,t))return!0;for(var n=0;n=0&&r.multiMaterials.splice(o,1),e.prototype.dispose.call(this,t,i)}},t.ParseMultiMaterial=function(e,i){var n=new t(e.name,i);n.id=e.id,o.a&&o.a.AddTagsTo(n,e.tags);for(var r=0;r0&&(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,i=this._meshes;t0){for(var t=0;t0){for(t=0;t0){for(t=0;t0){var u=new Float32Array(t,l.positionsAttrDesc.offset,l.positionsAttrDesc.count);i.setVerticesData(a.b.PositionKind,u,!1)}if(l.normalsAttrDesc&&l.normalsAttrDesc.count>0){var h=new Float32Array(t,l.normalsAttrDesc.offset,l.normalsAttrDesc.count);i.setVerticesData(a.b.NormalKind,h,!1)}if(l.tangetsAttrDesc&&l.tangetsAttrDesc.count>0){var d=new Float32Array(t,l.tangetsAttrDesc.offset,l.tangetsAttrDesc.count);i.setVerticesData(a.b.TangentKind,d,!1)}if(l.uvsAttrDesc&&l.uvsAttrDesc.count>0){var f=new Float32Array(t,l.uvsAttrDesc.offset,l.uvsAttrDesc.count);i.setVerticesData(a.b.UVKind,f,!1)}if(l.uvs2AttrDesc&&l.uvs2AttrDesc.count>0){var p=new Float32Array(t,l.uvs2AttrDesc.offset,l.uvs2AttrDesc.count);i.setVerticesData(a.b.UV2Kind,p,!1)}if(l.uvs3AttrDesc&&l.uvs3AttrDesc.count>0){var _=new Float32Array(t,l.uvs3AttrDesc.offset,l.uvs3AttrDesc.count);i.setVerticesData(a.b.UV3Kind,_,!1)}if(l.uvs4AttrDesc&&l.uvs4AttrDesc.count>0){var m=new Float32Array(t,l.uvs4AttrDesc.offset,l.uvs4AttrDesc.count);i.setVerticesData(a.b.UV4Kind,m,!1)}if(l.uvs5AttrDesc&&l.uvs5AttrDesc.count>0){var g=new Float32Array(t,l.uvs5AttrDesc.offset,l.uvs5AttrDesc.count);i.setVerticesData(a.b.UV5Kind,g,!1)}if(l.uvs6AttrDesc&&l.uvs6AttrDesc.count>0){var v=new Float32Array(t,l.uvs6AttrDesc.offset,l.uvs6AttrDesc.count);i.setVerticesData(a.b.UV6Kind,v,!1)}if(l.colorsAttrDesc&&l.colorsAttrDesc.count>0){var b=new Float32Array(t,l.colorsAttrDesc.offset,l.colorsAttrDesc.count);i.setVerticesData(a.b.ColorKind,b,!1,l.colorsAttrDesc.stride)}if(l.matricesIndicesAttrDesc&&l.matricesIndicesAttrDesc.count>0){for(var y=new Int32Array(t,l.matricesIndicesAttrDesc.offset,l.matricesIndicesAttrDesc.count),T=[],E=0;E>8),T.push((16711680&S)>>16),T.push(S>>24&255)}i.setVerticesData(a.b.MatricesIndicesKind,T,!1)}if(l.matricesIndicesExtraAttrDesc&&l.matricesIndicesExtraAttrDesc.count>0){for(y=new Int32Array(t,l.matricesIndicesExtraAttrDesc.offset,l.matricesIndicesExtraAttrDesc.count),T=[],E=0;E>8),T.push((16711680&S)>>16),T.push(S>>24&255)}i.setVerticesData(a.b.MatricesIndicesExtraKind,T,!1)}if(l.matricesWeightsAttrDesc&&l.matricesWeightsAttrDesc.count>0){var A=new Float32Array(t,l.matricesWeightsAttrDesc.offset,l.matricesWeightsAttrDesc.count);i.setVerticesData(a.b.MatricesWeightsKind,A,!1)}if(l.indicesAttrDesc&&l.indicesAttrDesc.count>0){var P=new Int32Array(t,l.indicesAttrDesc.offset,l.indicesAttrDesc.count);i.setIndices(P,null)}if(l.subMeshesAttrDesc&&l.subMeshesAttrDesc.count>0){var C=new Int32Array(t,l.subMeshesAttrDesc.offset,5*l.subMeshesAttrDesc.count);i.subMeshes=[];for(E=0;E>8),T.push((16711680&D)>>16),T.push(D>>24&255)}i.setVerticesData(a.b.MatricesIndicesKind,T,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(a.b.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(T=[],E=0;E>8),T.push((16711680&D)>>16),T.push(D>>24&255)}i.setVerticesData(a.b.MatricesIndicesExtraKind,T,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,i),i.setVerticesData(a.b.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&i.setVerticesData(a.b.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),i.setIndices(t.indices,null)}if(t.subMeshes){i.subMeshes=[];for(var N=0;N-1){var n=t.getScene().getLastSkeletonByID(e.skeletonId);if(n){i=n.bones.length;for(var r=t.getVerticesData(a.b.MatricesIndicesKind),o=t.getVerticesData(a.b.MatricesIndicesExtraKind),s=e.matricesWeights,l=e.matricesWeightsExtra,u=e.numBoneInfluencer,h=s.length,d=0;du-1)&&(p=u-1),f>.001){var g=1/f;for(_=0;_<4;_++)s[d+_]*=g;if(l)for(_=0;_<4;_++)l[d+_]*=g}else p>=4?(l[d+p-4]=1-f,o[d+p-4]=i):(s[d+p]=1-f,r[d+p]=i)}t.setVerticesData(a.b.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(a.b.MatricesIndicesExtraKind,o)}}}},e.Parse=function(t,i,r){if(i.getGeometryByID(t.id))return null;var s=new e(t.id,i,void 0,t.updatable);return d.a&&d.a.AddTagsTo(s,t.tags),t.delayLoadingFile?(s.delayLoadState=u.a.DELAYLOADSTATE_NOTLOADED,s.delayLoadingFile=r+t.delayLoadingFile,s._boundingInfo=new l.a(n.e.FromArray(t.boundingBoxMinimum),n.e.FromArray(t.boundingBoxMaximum)),s._delayInfo=[],t.hasUVs&&s._delayInfo.push(a.b.UVKind),t.hasUVs2&&s._delayInfo.push(a.b.UV2Kind),t.hasUVs3&&s._delayInfo.push(a.b.UV3Kind),t.hasUVs4&&s._delayInfo.push(a.b.UV4Kind),t.hasUVs5&&s._delayInfo.push(a.b.UV5Kind),t.hasUVs6&&s._delayInfo.push(a.b.UV6Kind),t.hasColors&&s._delayInfo.push(a.b.ColorKind),t.hasMatricesIndices&&s._delayInfo.push(a.b.MatricesIndicesKind),t.hasMatricesWeights&&s._delayInfo.push(a.b.MatricesWeightsKind),s._delayLoadingFunction=o.a.ImportVertexData):o.a.ImportVertexData(t,s),i.pushGeometry(s,!0),s},e}()},function(e,t,i){"use strict";i.d(t,"e",(function(){return n})),i.d(t,"c",(function(){return s})),i.d(t,"a",(function(){return c})),i.d(t,"b",(function(){return l})),i.d(t,"f",(function(){return u})),i.d(t,"g",(function(){return h})),i.d(t,"d",(function(){return d}));var n,r=i(14),o=i(0),a=i(28);!function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(n||(n={}));var s=function(){function e(){}return e.Interpolate=function(e,t,i,n,r){for(var o=1-3*n+3*t,a=3*n-6*t,s=3*t,c=e,l=0;l<5;l++){var u=c*c;c-=(o*(u*c)+a*u+s*c-e)*(1/(3*o*u+2*a*c+s)),c=Math.min(1,Math.max(0,c))}return 3*Math.pow(1-c,2)*c*i+3*(1-c)*Math.pow(c,2)*r+Math.pow(c,3)},e}(),c=function(){function e(e){this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.prototype.degrees=function(){return 180*this._radians/Math.PI},e.prototype.radians=function(){return this._radians},e.BetweenTwoPoints=function(t,i){var n=i.subtract(t);return new e(Math.atan2(n.y,n.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}(),l=function(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var r=Math.pow(t.x,2)+Math.pow(t.y,2),a=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,s=(r-Math.pow(i.x,2)-Math.pow(i.y,2))/2,l=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new o.d((a*(t.y-i.y)-s*(e.y-t.y))/l,((e.x-t.x)*s-(t.x-i.x)*a)/l),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=c.BetweenTwoPoints(this.centerPoint,this.startPoint);var u=this.startAngle.degrees(),h=c.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),d=c.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();h-u>180&&(h-=360),h-u<-180&&(h+=360),d-h>180&&(d-=360),d-h<-180&&(d+=360),this.orientation=h-u<0?n.CW:n.CCW,this.angle=c.FromDegrees(this.orientation===n.CW?u-d:d-u)},u=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new o.d(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new o.d(e,t),n=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(n).length(),this},e.prototype.addArcTo=function(e,t,i,r,a){if(void 0===a&&(a=36),this.closed)return this;var s=this._points[this._points.length-1],c=new o.d(e,t),u=new o.d(i,r),h=new l(s,c,u),d=h.angle.radians()/a;h.orientation===n.CW&&(d*=-1);for(var f=h.startAngle.radians()+d,p=0;p1)return o.d.Zero();for(var t=e*this.length(),i=0,n=0;n=i&&t<=c){var l=s.normalize(),u=t-i;return new o.d(a.x+l.x*u,a.y+l.y*u)}i=c}return o.d.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}(),h=function(){function e(e,t,i,n){void 0===t&&(t=null),void 0===n&&(n=!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:o.e.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:o.a.Identity()};for(var r=0;ri){var n=t;t=i,i=n}var r=this.getCurve(),o=this.getPointAt(t),a=this.getPreviousPointIndexAt(t),s=this.getPointAt(i),c=this.getPreviousPointIndexAt(i)+1,l=[];return 0!==t&&(a++,l.push(o)),l.push.apply(l,r.slice(a,c)),1===i&&1!==t||l.push(s),new e(l,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)},e.prototype.update=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!1);for(var n=0;nt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},e.prototype._normalVector=function(e,t){var i,n,s=e.length();(0===s&&(s=1),null==t)?(n=r.a.WithinEpsilon(Math.abs(e.y)/s,1,a.a)?r.a.WithinEpsilon(Math.abs(e.x)/s,1,a.a)?r.a.WithinEpsilon(Math.abs(e.z)/s,1,a.a)?o.e.Zero():new o.e(0,0,1):new o.e(1,0,0):new o.e(0,-1,0),i=o.e.Cross(e,n)):(i=o.e.Cross(e,t),o.e.CrossToRef(i,e,i));return i.normalize(),i},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 i=this.getPoints();if(e<=0)return this._setPointAtData(0,0,i[0],0,t);if(e>=1)return this._setPointAtData(1,1,i[i.length-1],i.length-1,t);for(var n,r=i[0],a=0,s=e*this.length(),c=1;cs){var u=(a-s)/l,h=r.subtract(n),d=n.add(h.scaleInPlace(u));return this._setPointAtData(e,1-u,d,c-1,t)}r=n}return this._pointAtData},e.prototype._setPointAtData=function(e,t,i,n,r){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=n,this._pointAtData.interpolateReady=r,r&&this._updateInterpolationMatrix(),this._pointAtData},e.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=o.a.Identity();var e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){var t=e+1,i=this._tangents[e].clone(),n=this._normals[e].clone(),r=this._binormals[e].clone(),a=this._tangents[t].clone(),s=this._normals[t].clone(),c=this._binormals[t].clone(),l=o.b.RotationQuaternionFromAxis(n,r,i),u=o.b.RotationQuaternionFromAxis(s,c,a);o.b.Slerp(l,u,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},e}(),d=function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,n,r){r=r>2?r:3;for(var a=new Array,s=function(e,t,i,n){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*n},c=0;c<=r;c++)a.push(new o.e(s(c/r,t.x,i.x,n.x),s(c/r,t.y,i.y,n.y),s(c/r,t.z,i.z,n.z)));return new e(a)},e.CreateCubicBezier=function(t,i,n,r,a){a=a>3?a:4;for(var s=new Array,c=function(e,t,i,n,r){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*n+e*e*e*r},l=0;l<=a;l++)s.push(new o.e(c(l/a,t.x,i.x,n.x,r.x),c(l/a,t.y,i.y,n.y,r.y),c(l/a,t.z,i.z,n.z,r.z)));return new e(s)},e.CreateHermiteSpline=function(t,i,n,r,a){for(var s=new Array,c=1/a,l=0;l<=a;l++)s.push(o.e.Hermite(t,i,n,r,l*c));return new e(s)},e.CreateCatmullRomSpline=function(t,i,n){var r=new Array,a=1/i,s=0;if(n){for(var c=t.length,l=0;l1&&(this._multiview=!0,s.push("#define MULTIVIEW"),-1!==this._options.uniforms.indexOf("viewProjection")&&-1===this._options.uniforms.push("viewProjectionR")&&this._options.uniforms.push("viewProjectionR"));for(var h=0;h4&&(l.push(a.b.MatricesIndicesExtraKind),l.push(a.b.MatricesWeightsExtraKind));var p=e.skeleton;f=e.numBoneInfluencers,s.push("#define NUM_BONE_INFLUENCERS "+f),u.addCPUSkinningFallback(0,e),p.isUsingTextureForMatrices?(s.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")):(s.push("#define BonesPerMesh "+(p.bones.length+1)),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones"))}else s.push("#define NUM_BONE_INFLUENCERS 0");for(var m in this._textures)if(!this._textures[m].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&s.push("#define ALPHATEST");var g=this._shaderPath,v=this._options.uniforms,b=this._options.uniformBuffers,y=this._options.samplers;this.customShaderNameResolve&&(v=v.slice(),b=b.slice(),y=y.slice(),g=this.customShaderNameResolve(g,v,b,y,s,l));var T=this._effect,E=s.join("\n");return this._cachedDefines!==E&&(this._cachedDefines=E,this._effect=o.createEffect(g,{attributes:l,uniformsNames:v,uniformBuffersNames:b,samplers:y,defines:E,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:f}},o),this._onEffectCreatedObservable&&(_.effect=this._effect,this._onEffectCreatedObservable.notifyObservers(_))),null!==(n=!(null===(i=this._effect)||void 0===i?void 0:i.isReady()))&&void 0!==n&&!n&&(T!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),this._effect._wasPreviouslyReady=!0,!0)},t.prototype.bindOnlyWorldMatrix=function(e,t){var i=this.getScene(),n=null!=t?t:this._effect;n&&(-1!==this._options.uniforms.indexOf("world")&&n.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(i.getViewMatrix(),this._cachedWorldViewMatrix),n.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&(e.multiplyToRef(i.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),n.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)))},t.prototype.bindForSubMesh=function(e,t,i){this.bind(e,t,i._effectOverride)},t.prototype.bind=function(e,t,i){this.bindOnlyWorldMatrix(e,i);var n=null!=i?i:this._effect;if(n&&this.getScene().getCachedMaterial()!==this){var r;for(r in-1!==this._options.uniforms.indexOf("view")&&n.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&n.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&(n.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._multiview&&n.setMatrix("viewProjectionR",this.getScene()._transformMatrixR)),this.getScene().activeCamera&&-1!==this._options.uniforms.indexOf("cameraPosition")&&n.setVector3("cameraPosition",this.getScene().activeCamera.globalPosition),c.a.BindBonesParameters(t,n),this._textures)n.setTexture(r,this._textures[r]);for(r in this._textureArrays)n.setTextureArray(r,this._textureArrays[r]);for(r in this._ints)n.setInt(r,this._ints[r]);for(r in this._floats)n.setFloat(r,this._floats[r]);for(r in this._floatsArrays)n.setArray(r,this._floatsArrays[r]);for(r in this._colors3)n.setColor3(r,this._colors3[r]);for(r in this._colors3Arrays)n.setArray3(r,this._colors3Arrays[r]);for(r in this._colors4){var o=this._colors4[r];n.setFloat4(r,o.r,o.g,o.b,o.a)}for(r in this._colors4Arrays)n.setArray4(r,this._colors4Arrays[r]);for(r in this._vectors2)n.setVector2(r,this._vectors2[r]);for(r in this._vectors3)n.setVector3(r,this._vectors3[r]);for(r in this._vectors4)n.setVector4(r,this._vectors4[r]);for(r in this._matrices)n.setMatrix(r,this._matrices[r]);for(r in this._matrixArrays)n.setMatrices(r,this._matrixArrays[r]);for(r in this._matrices3x3)n.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)n.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors2Arrays)n.setArray2(r,this._vectors2Arrays[r]);for(r in this._vectors3Arrays)n.setArray3(r,this._vectors3Arrays[r]);for(r in this._vectors4Arrays)n.setArray4(r,this._vectors4Arrays[r])}var a=this._effect;this._effect=n,this._afterBind(t),this._effect=a},t.prototype._afterBind=function(t){e.prototype._afterBind.call(this,t),this.getScene()._cachedEffect=this._effect},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);for(var i in this._textures)t.push(this._textures[i]);for(var i in this._textureArrays)for(var n=this._textureArrays[i],r=0;r_.snapDistance){var t=Math.floor(Math.abs(v)/_.snapDistance);v%=_.snapDistance,e.delta.normalizeToRef(b),b.scaleInPlace(_.snapDistance*t),_.attachedNode.getWorldMatrix().addTranslationFromFloats(b.x,b.y,b.z),_.attachedNode.updateCache(),y.snapDistance=_.snapDistance*t,_.onSnapObservable.notifyObservers(y)}_._matrixChanged()}})),_.dragBehavior.onDragStartObservable.add((function(){_._dragging=!0})),_.dragBehavior.onDragEndObservable.add((function(){_._dragging=!1}));var T=a._getSharedGizmoLight();T.includedOnlyMeshes=T.includedOnlyMeshes.concat(_._rootMesh.getChildMeshes(!1));var E={gizmoMeshes:m.getChildMeshes(),colliderMeshes:g.getChildMeshes(),material:_._coloredMaterial,hoverMaterial:_._hoverMaterial,disableMaterial:_._disableMaterial,active:!1};return null===(p=_._parent)||void 0===p||p.addToAxisCache(g,E),_._pointerObserver=a.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!_._customMeshSet&&(_._isHovered=!(-1==E.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!_._parent)){var i=_._isHovered||_._dragging?_._hoverMaterial:_._coloredMaterial;E.gizmoMeshes.forEach((function(e){e.material=i,e.color&&(e.color=i.diffuseColor)}))}})),_}return Object(n.d)(t,e),t._CreateArrow=function(e,t,i,n){void 0===i&&(i=1),void 0===n&&(n=!1);var r=new a.a("arrow",e),o=c.a.CreateCylinder("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375*(1+(i-1)/4),tessellation:96},e),s=c.a.CreateCylinder("cylinder",{diameterTop:.005*i,height:.275,diameterBottom:.005*i,tessellation:96},e);return o.parent=r,o.material=t,o.rotation.x=Math.PI/2,o.position.z+=.3,s.parent=r,s.material=t,s.position.z+=.1375,s.rotation.x=Math.PI/2,n&&(s.visibility=0,o.visibility=0),r},t._CreateArrowInstance=function(e,t){for(var i=new a.a("arrow",e),n=0,r=t.getChildMeshes();ns?s:Math.floor(c);var l,u,h,d,f=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,p=e.uvs,_=e.colors,m=[],g=[],v=[],b=[],y=[],T=[],E=[],S=[],A=[],P=[];if(t.length<2){var C=[],R=[];for(h=0;h0&&(M=x[d].subtract(x[d-1]).length()+E[u],y[u].push(M),E[u]=M),d++;n&&(d--,m.push(x[0].x,x[0].y,x[0].z),M=x[d].subtract(x[0]).length()+E[u],y[u].push(M),E[u]=M),A[u]=O+L,P[u]=N,N+=O+L}var w,F,B=null,U=null;for(h=0;h=n.a.ACTION_OnPickTrigger&&i<=n.a.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),e.HasSpecificTrigger=function(t){for(var i in e.Triggers){if(e.Triggers.hasOwnProperty(i))if(parseInt(i)===t)return!0}return!1},e.Triggers={},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(1),r=i(25),o=i(3),a=i(19),s=i(15),c=function(){function e(e){this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=r.a.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){var i=t.getEngine();return!(e._areTexturesDirty&&t.texturesEnabled&&i.getCaps().standardDerivatives&&this._texture&&a.a.DetailTextureEnabled&&!this._texture.isReady())},e.prototype.prepareDefines=function(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;var i=t.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&a.a.DetailTextureEnabled&&this._isEnabled?(s.a.PrepareDefinesForMergedUV(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1},e.prototype.bindForSubMesh=function(e,t,i){this._isEnabled&&(e.useUbo&&i&&e.isSync||this._texture&&a.a.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),s.a.BindTextureMatrix(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&a.a.DetailTextureEnabled&&e.setTexture("detailSampler",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){var t;e&&(null===(t=this._texture)||void 0===t||t.dispose())},e.prototype.getClassName=function(){return"DetailMap"},e.AddUniforms=function(e){e.push("vDetailInfos")},e.AddSamplers=function(e){e.push("detailSampler")},e.PrepareUniformBuffer=function(e){e.addUniform("vDetailInfos",4),e.addUniform("detailMatrix",16)},e.prototype.copyTo=function(e){o.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return o.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;o.a.Parse((function(){return n}),e,t,i)},Object(n.c)([Object(o.m)("detailTexture"),Object(o.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),Object(n.c)([Object(o.c)()],e.prototype,"diffuseBlendLevel",void 0),Object(n.c)([Object(o.c)()],e.prototype,"roughnessBlendLevel",void 0),Object(n.c)([Object(o.c)()],e.prototype,"bumpLevel",void 0),Object(n.c)([Object(o.c)(),Object(o.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"normalBlendMethod",void 0),Object(n.c)([Object(o.c)(),Object(o.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),e}()},function(e,t,i){"use strict";var n="morphTargetsVertexGlobalDeclaration",r="#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="morphTargetsVertexDeclaration",r="#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#ifdef MORPHTARGETS_UV\nattribute vec2 uv_{X};\n#endif\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";i.d(t,"a",(function(){return a}));var n=i(25),r=i(4),o=i(2),a=function(){function e(e){this._vertexBuffers={},this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffers[r.b.PositionKind]){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[r.b.PositionKind]=new r.b(this._scene.getEngine(),e,r.b.PositionKind,!1,!1,2),this._buildIndexBuffer()}},e.prototype._buildIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)},e.prototype._rebuild=function(){var e=this._vertexBuffers[r.b.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())},e.prototype._prepareFrame=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var i=this._scene.activeCamera;return!!i&&(!(!(t=t||i._postProcesses.filter((function(e){return null!=e})))||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(i,e,null!=t),!0))},e.prototype.directRender=function(e,t,i,r,o,a){void 0===t&&(t=null),void 0===i&&(i=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=!1);for(var s=this._scene.getEngine(),c=0;c3?0:f,p);var C=o.a.CreateRibbon(e,{pathArray:S,closeArray:h,closePath:d,updatable:m,sideOrientation:g,invertUV:b,frontUVs:y||void 0,backUVs:T||void 0},_);return C._creationDataStorage.pathArray=S,C._creationDataStorage.path3D=E,C._creationDataStorage.cap=f,C},e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return h})),i.d(t,"a",(function(){return d}));var n=i(1),r=i(9),o=i(4),a=i(7),s=i(151),c=i(25),l=i(73),u=i(15),h=(i(166),i(167),function(e){function t(t,i,n,a,s,c,u){void 0===i&&(i=null),void 0===n&&(n=null),void 0===a&&(a=null);var h=e.call(this,t,i,n,a,s)||this;h.useVertexColor=c,h.useVertexAlpha=u,h.color=new r.a(1,1,1),h.alpha=1,a&&(h.color=a.color.clone(),h.alpha=a.alpha,h.useVertexColor=a.useVertexColor,h.useVertexAlpha=a.useVertexAlpha),h.intersectionThreshold=.1;var d={attributes:[o.b.PositionKind,"world0","world1","world2","world3"],uniforms:["vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","world","viewProjection"],needAlphaBlending:!0,defines:[]};return!1===u&&(d.needAlphaBlending=!1),c?(d.defines.push("#define VERTEXCOLOR"),d.attributes.push(o.b.ColorKind)):(d.uniforms.push("color"),h.color4=new r.b),h._colorShader=new l.a("colorShader",h.getScene(),"color",d),h}return Object(n.d)(t,e),t.prototype._addClipPlaneDefine=function(e){var t="#define "+e;-1===this._colorShader.options.defines.indexOf(t)&&this._colorShader.options.defines.push(t)},t.prototype._removeClipPlaneDefine=function(e){var t="#define "+e,i=this._colorShader.options.defines.indexOf(t);-1!==i&&this._colorShader.options.defines.splice(i,1)},t.prototype.isReady=function(){var t=this.getScene();return t.clipPlane?this._addClipPlaneDefine("CLIPPLANE"):this._removeClipPlaneDefine("CLIPPLANE"),t.clipPlane2?this._addClipPlaneDefine("CLIPPLANE2"):this._removeClipPlaneDefine("CLIPPLANE2"),t.clipPlane3?this._addClipPlaneDefine("CLIPPLANE3"):this._removeClipPlaneDefine("CLIPPLANE3"),t.clipPlane4?this._addClipPlaneDefine("CLIPPLANE4"):this._removeClipPlaneDefine("CLIPPLANE4"),t.clipPlane5?this._addClipPlaneDefine("CLIPPLANE5"):this._removeClipPlaneDefine("CLIPPLANE5"),t.clipPlane6?this._addClipPlaneDefine("CLIPPLANE6"):this._removeClipPlaneDefine("CLIPPLANE6"),!!this._colorShader.isReady(this)&&e.prototype.isReady.call(this)},t.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(t.prototype,"material",{get:function(){return this._colorShader},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"checkCollisions",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype._bind=function(e,t,i){if(!this._geometry)return this;var n=this._colorShader.getEffect(),r=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(this._geometry._bind(n,r),!this.useVertexColor){var o=this.color,a=o.r,s=o.g,c=o.b;this.color4.set(a,s,c,this.alpha),this._colorShader.setColor4("color",this.color4)}return u.a.BindClipPlane(n,this.getScene()),this},t.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var n=this.getScene().getEngine();return this._unIndexed?n.drawArraysType(c.a.LineListDrawMode,e.verticesStart,e.verticesCount,i):n.drawElementsType(c.a.LineListDrawMode,e.indexStart,e.indexCount,i),this},t.prototype.dispose=function(t){this._colorShader.dispose(!1,!1,!0),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e,i,n){return void 0===i&&(i=null),new t(e,this.getScene(),i,this,n)},t.prototype.createInstance=function(e){return new d(e,this)},t}(a.a)),d=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.intersectionThreshold=i.intersectionThreshold,n}return Object(n.d)(t,e),t.prototype.getClassName=function(){return"InstancedLinesMesh"},t}(s.a)},function(e,t,i){"use strict";i.r(t),i.d(t,"AxesViewer",(function(){return c})),i.d(t,"BoneAxesViewer",(function(){return h})),i.d(t,"DebugLayerTab",(function(){return n})),i.d(t,"DebugLayer",(function(){return m})),i.d(t,"PhysicsViewer",(function(){return A})),i.d(t,"RayHelper",(function(){return C})),i.d(t,"SkeletonViewer",(function(){return N}));var n,r=i(0),o=i(30),a=i(75),s=i(9),c=function(){function e(t,i,n,c,l,u){if(void 0===i&&(i=1),void 0===n&&(n=2),this._scaleLinesFactor=4,this._instanced=!1,this.scene=null,this.scaleLines=1,this.scaleLines=i,!c){var h=new o.a("",t);h.disableLighting=!0,h.emissiveColor=s.a.Red().scale(.5),c=a.a._CreateArrow(t,h)}if(!l){var d=new o.a("",t);d.disableLighting=!0,d.emissiveColor=s.a.Green().scale(.5),l=a.a._CreateArrow(t,d)}if(!u){var f=new o.a("",t);f.disableLighting=!0,f.emissiveColor=s.a.Blue().scale(.5),u=a.a._CreateArrow(t,f)}this._xAxis=c,this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis=l,this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis=u,this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),null!=n&&(e._SetRenderingGroupId(this._xAxis,n),e._SetRenderingGroupId(this._yAxis,n),e._SetRenderingGroupId(this._zAxis,n)),this.scene=t,this.update(new r.e,r.e.Right(),r.e.Up(),r.e.Forward())}return Object.defineProperty(e.prototype,"xAxis",{get:function(){return this._xAxis},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"yAxis",{get:function(){return this._yAxis},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zAxis",{get:function(){return this._zAxis},enumerable:!1,configurable:!0}),e.prototype.update=function(e,t,i,n){this._xAxis.position.copyFrom(e),this._xAxis.setDirection(t),this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis.position.copyFrom(e),this._yAxis.setDirection(i),this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis.position.copyFrom(e),this._zAxis.setDirection(n),this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor)},e.prototype.createInstance=function(){var t=a.a._CreateArrowInstance(this.scene,this._xAxis),i=a.a._CreateArrowInstance(this.scene,this._yAxis),n=a.a._CreateArrowInstance(this.scene,this._zAxis),r=new e(this.scene,this.scaleLines,null,t,i,n);return r._instanced=!0,r},e.prototype.dispose=function(){this._xAxis&&this._xAxis.dispose(!1,!this._instanced),this._yAxis&&this._yAxis.dispose(!1,!this._instanced),this._zAxis&&this._zAxis.dispose(!1,!this._instanced),this.scene=null},e._SetRenderingGroupId=function(e,t){e.getChildMeshes().forEach((function(e){e.renderingGroupId=t}))},e}(),l=i(1),u=i(23),h=function(e){function t(t,i,n,o){void 0===o&&(o=1);var a=e.call(this,t,o)||this;return a.pos=r.e.Zero(),a.xaxis=r.e.Zero(),a.yaxis=r.e.Zero(),a.zaxis=r.e.Zero(),a.mesh=n,a.bone=i,a}return Object(l.d)(t,e),t.prototype.update=function(){if(this.mesh&&this.bone){var t=this.bone;t._markAsDirtyAndCompose(),t.getAbsolutePositionToRef(this.mesh,this.pos),t.getDirectionToRef(u.a.X,this.mesh,this.xaxis),t.getDirectionToRef(u.a.Y,this.mesh,this.yaxis),t.getDirectionToRef(u.a.Z,this.mesh,this.zaxis),e.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)}},t.prototype.dispose=function(){this.mesh&&(this.mesh=null,this.bone=null,e.prototype.dispose.call(this))},t}(c),d=i(12),f=i(6),p=i(20),_=i(13);Object.defineProperty(p.a.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new m(this)),this._debugLayer},enumerable:!0,configurable:!0}),function(e){e[e.Properties=0]="Properties",e[e.Debug=1]="Debug",e[e.Statistics=2]="Statistics",e[e.Tools=3]="Tools",e[e.Settings=4]="Settings"}(n||(n={}));var m=function(){function e(e){var t=this;this.BJSINSPECTOR=this._getGlobalInspector(),this._scene=e,this._scene.onDisposeObservable.add((function(){t._scene._debugLayer&&t._scene._debugLayer.hide()}))}return Object.defineProperty(e.prototype,"onPropertyChangedObservable",{get:function(){return this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector?this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable:(this._onPropertyChangedObservable||(this._onPropertyChangedObservable=new f.c),this._onPropertyChangedObservable)},enumerable:!1,configurable:!0}),e.prototype._createInspector=function(e){if(!this.isVisible()){if(this._onPropertyChangedObservable){for(var t=0,i=this._onPropertyChangedObservable.observers;t-1&&this._debugMeshMeshes.splice(o,1),this._numMeshes--,this._numMeshes>0?(this._meshes[n]=this._meshes[this._numMeshes],this._impostors[n]=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 o.a("",e),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=s.a.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=v.a.CreateBox("physicsBodyBoxViewMesh",{size:1},e),this._debugBoxMesh.rotationQuaternion=r.b.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=b.a.CreateSphere("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=r.b.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=S.a.CreateCylinder("physicsBodyCylinderViewMesh",{diameterTop:1,diameterBottom:1,height:1},e),this._debugCylinderMesh.rotationQuaternion=r.b.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(e),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugMeshMesh=function(e,t){var i=new g.a(e.name,t,null,e);return i.position=r.e.Zero(),i.setParent(e),i.material=this._getDebugMaterial(t),this._debugMeshMeshes.push(i),i},e.prototype._getDebugMesh=function(e,t){var i=this;if(!this._utilityLayer)return null;if(t&&t.parent&&t.parent.physicsImpostor)return null;var n=null,r=this._utilityLayer.utilityLayerScene;switch(e.type){case T.a.BoxImpostor:n=this._getDebugBoxMesh(r),e.getBoxSizeToRef(n.scaling);break;case T.a.SphereImpostor:n=this._getDebugSphereMesh(r);var o=e.getRadius();n.scaling.x=2*o,n.scaling.y=2*o,n.scaling.z=2*o;break;case T.a.MeshImpostor:t&&(n=this._getDebugMeshMesh(t,r));break;case T.a.NoImpostor:if(t)t.getChildMeshes().filter((function(e){return e.physicsImpostor?1:0})).forEach((function(e){i._getDebugBoxMesh(r).parent=e}));break;case T.a.CylinderImpostor:n=this._getDebugCylinderMesh(r);var a=e.object.getBoundingInfo();n.scaling.x=a.boundingBox.maximum.x-a.boundingBox.minimum.x,n.scaling.y=a.boundingBox.maximum.y-a.boundingBox.minimum.y,n.scaling.z=a.boundingBox.maximum.z-a.boundingBox.minimum.z}return n},e.prototype.dispose=function(){for(var e=this._numMeshes,t=0;te.DISPLAY_SPHERE_AND_SPURS&&(R=e.DISPLAY_LINES),this.displayMode=R,this.update(),this._bindObs()}return e.CreateBoneWeightShader=function(e,t){var i,n,r,o,a,c,l=e.skeleton,u=null!==(i=e.colorBase)&&void 0!==i?i:s.a.Black(),h=null!==(n=e.colorZero)&&void 0!==n?n:s.a.Blue(),d=null!==(r=e.colorQuarter)&&void 0!==r?r:s.a.Green(),f=null!==(o=e.colorHalf)&&void 0!==o?o:s.a.Yellow(),p=null!==(a=e.colorFull)&&void 0!==a?a:s.a.Red(),_=null!==(c=e.targetBoneIndex)&&void 0!==c?c:0;I.a.ShadersStore["boneWeights:"+l.name+"VertexShader"]="precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n\n #include\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n\n #include\n\n varying vec3 vColor;\n\n uniform vec3 colorBase;\n uniform vec3 colorZero;\n uniform vec3 colorQuarter;\n uniform vec3 colorHalf;\n uniform vec3 colorFull;\n\n uniform float targetBoneIndex;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include\n #include\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n vec3 color = colorBase;\n float totalWeight = 0.;\n if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){\n totalWeight += matricesWeights[0];\n }\n if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){\n totalWeight += matricesWeights[1];\n }\n if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){\n totalWeight += matricesWeights[2];\n }\n if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){\n totalWeight += matricesWeights[3];\n }\n\n color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));\n color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));\n color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));\n color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));\n vColor = color;\n\n gl_Position = projection * view * worldPos;\n }",I.a.ShadersStore["boneWeights:"+l.name+"FragmentShader"]="\n precision highp float;\n varying vec3 vPosition;\n\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4(vColor, 1.0);\n gl_FragColor = color;\n }\n ";var m=new x.a("boneWeight:"+l.name,t,{vertex:"boneWeights:"+l.name,fragment:"boneWeights:"+l.name},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorBase","colorZero","colorQuarter","colorHalf","colorFull","targetBoneIndex"]});return m.setColor3("colorBase",u),m.setColor3("colorZero",h),m.setColor3("colorQuarter",d),m.setColor3("colorHalf",f),m.setColor3("colorFull",p),m.setFloat("targetBoneIndex",_),m.getClassName=function(){return"BoneWeightShader"},m.transparencyMode=R.a.MATERIAL_OPAQUE,m},e.CreateSkeletonMapShader=function(t,i){var n,r=t.skeleton,o=null!==(n=t.colorMap)&&void 0!==n?n:[{color:new s.a(1,.38,.18),location:0},{color:new s.a(.59,.18,1),location:.2},{color:new s.a(.59,1,.18),location:.4},{color:new s.a(1,.87,.17),location:.6},{color:new s.a(1,.17,.42),location:.8},{color:new s.a(.17,.68,1),location:1}],a=r.bones.length+1,c=e._CreateBoneMapColorBuffer(a,o,i),l=new x.a("boneWeights:"+r.name,i,{vertexSource:"precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n uniform float colorMap["+4*r.bones.length+"];\n\n #include\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include\n\n varying vec3 vColor;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include\n #include\n\n vec3 color = vec3(0.);\n bool first = true;\n\n for (int i = 0; i < 4; i++) {\n int boneIdx = int(matricesIndices[i]);\n float boneWgt = matricesWeights[i];\n\n vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);\n\n if (boneWgt > 0.) {\n if (first) {\n first = false;\n color = c;\n } else {\n color = mix(color, c, boneWgt);\n }\n }\n }\n\n vColor = color;\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n gl_Position = projection * view * worldPos;\n }",fragmentSource:"\n precision highp float;\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4( vColor, 1.0 );\n gl_FragColor = color;\n }\n "},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorMap"]});return l.setFloats("colorMap",c),l.getClassName=function(){return"SkeletonMapShader"},l.transparencyMode=R.a.MATERIAL_OPAQUE,l},e._CreateBoneMapColorBuffer=function(e,t,i){var n=new O.a("temp",{width:e,height:1},i,!1),r=n.getContext(),o=r.createLinearGradient(0,0,e,0);t.forEach((function(e){o.addColorStop(e.location,e.color.toHexString())})),r.fillStyle=o,r.fillRect(0,0,e,1),n.update();for(var a=[],s=r.getImageData(0,0,e,1).data,c=0;ce.DISPLAY_SPHERE_AND_SPURS&&(t=e.DISPLAY_LINES),this.options.displayMode=t},enumerable:!1,configurable:!0}),e.prototype._bindObs=function(){var t=this;switch(this.displayMode){case e.DISPLAY_LINES:this._obs=this.scene.onBeforeRenderObservable.add((function(){t._displayLinesUpdate()}))}},e.prototype.update=function(){switch(this.displayMode){case e.DISPLAY_LINES:this._displayLinesUpdate();break;case e.DISPLAY_SPHERES:this._buildSpheresAndSpurs(!0);break;case e.DISPLAY_SPHERE_AND_SPURS:this._buildSpheresAndSpurs(!1)}this._buildLocalAxes()},Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this.isEnabled!==e&&(this._isEnabled=e,this.debugMesh&&this.debugMesh.setEnabled(e),e&&!this._obs?this._bindObs():!e&&this._obs&&(this.scene.onBeforeRenderObservable.remove(this._obs),this._obs=null))},enumerable:!1,configurable:!0}),e.prototype._getBonePosition=function(e,t,i,n,o,a){void 0===n&&(n=0),void 0===o&&(o=0),void 0===a&&(a=0);var s=r.c.Matrix[0],c=t.getParent();if(s.copyFrom(t.getLocalMatrix()),0!==n||0!==o||0!==a){var l=r.c.Matrix[1];r.a.IdentityToRef(l),l.setTranslationFromFloats(n,o,a),l.multiplyToRef(s,s)}c&&s.multiplyToRef(c.getAbsoluteTransform(),s),s.multiplyToRef(i,s),e.x=s.m[12],e.y=s.m[13],e.z=s.m[14]},e.prototype._getLinesForBonesWithLength=function(e,t){for(var i=e.length,n=this.mesh._effectiveMesh.position,o=0,a=0;a=0;a--){var s=e[a],c=s.getParent();if(c&&(this._boneIndices.has(s.getIndex())||this.options.useAllBones)){var l=this._debugLines[i];l||(l=[r.e.Zero(),r.e.Zero()],this._debugLines[i]=l),s.getAbsolutePositionToRef(n,l[0]),c.getAbsolutePositionToRef(n,l[1]),l[0].subtractInPlace(o),l[1].subtractInPlace(o),i++}}},e.prototype._revert=function(e){this.options.pauseAnimations&&(this.scene.animationsEnabled=e,this.utilityLayer.utilityLayerScene.animationsEnabled=e)},e.prototype._getAbsoluteBindPoseToRef=function(e,t){null!==e&&-1!==e._index?(this._getAbsoluteBindPoseToRef(e.getParent(),t),e.getBindPose().multiplyToRef(t,t)):t.copyFrom(r.a.Identity())},e.prototype._buildSpheresAndSpurs=function(e){var t,i;void 0===e&&(e=!0),this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this._ready=!1;var n=null===(t=this.utilityLayer)||void 0===t?void 0:t.utilityLayerScene,o=this.skeleton.bones,a=[],s=[],c=this.scene.animationsEnabled;try{this.options.pauseAnimations&&(this.scene.animationsEnabled=!1,n.animationsEnabled=!1),this.options.returnToRest&&this.skeleton.returnToRest(),this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();for(var l=Number.NEGATIVE_INFINITY,u=this.options.displayOptions||{},h=function(t){var i=o[t];if(-1===i._index||!d._boneIndices.has(i.getIndex())&&!d.options.useAllBones)return"continue";var c=new r.a;d._getAbsoluteBindPoseToRef(i,c);var h=new r.e;c.decompose(void 0,void 0,h),i.children.forEach((function(t,o){var a=new r.a;t.getBindPose().multiplyToRef(c,a);var d=new r.e;a.decompose(void 0,void 0,d);var f=r.e.Distance(h,d);if(f>l&&(l=f),!e){for(var p=d.clone().subtract(h.clone()),_=p.length(),m=p.normalize().scale(_),v=u.midStep||.165,b=u.midStepFactor||.215,y=m.scale(v),T=D.a.ExtrudeShapeCustom("skeletonViewer",{shape:[new r.e(1,-1,0),new r.e(1,1,0),new r.e(-1,1,0),new r.e(-1,-1,0),new r.e(1,-1,0)],path:[r.e.Zero(),y,m],scaleFunction:function(e){switch(e){case 0:case 2:return 0;case 1:return _*b}return 0},sideOrientation:g.a.DEFAULTSIDE,updatable:!1},n),E=T.getTotalVertices(),S=[],A=[],P=0;P9?A.push(t.getIndex(),0,0,0):A.push(i.getIndex(),0,0,0);T.position=h.clone(),T.setVerticesData(M.b.MatricesWeightsKind,S,!1),T.setVerticesData(M.b.MatricesIndicesKind,A,!1),T.convertToFlatShadedMesh(),s.push(T)}}));for(var f=u.sphereBaseSize||.2,p=b.a.CreateSphere("skeletonViewer",{segments:6,diameter:f,updatable:!0},n),_=p.getTotalVertices(),m=[],v=[],y=0;y<_;y++)m.push(1,0,0,0),v.push(i.getIndex(),0,0,0);p.setVerticesData(M.b.MatricesWeightsKind,m,!1),p.setVerticesData(M.b.MatricesIndicesKind,v,!1),p.position=h.clone(),a.push([p,i])},d=this,f=0;fu-n)&&(!(c-hh-r)&&!(l-dd-a))},e.prototype.intersectsSphere=function(t){return e.IntersectsSphere(this.minimumWorld,this.maximumWorld,t.centerWorld,t.radiusWorld)},e.prototype.intersectsMinMax=function(e,t){var i=this.minimumWorld,n=this.maximumWorld,r=i.x,o=i.y,a=i.z,s=n.x,c=n.y,l=n.z,u=e.x,h=e.y,d=e.z,f=t.x,p=t.y,_=t.z;return!(sf)&&(!(cp)&&!(l_))},e.Intersects=function(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)},e.IntersectsSphere=function(t,i,n,o){var a=e.TmpVector3[0];return r.e.ClampToRef(n,t,i,a),r.e.DistanceSquared(n,a)<=o*o},e.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;++i)for(var n=t[i],r=0;r<8;++r)if(n.dotCoordinate(e[r])<0)return!1;return!0},e.IsInFrustum=function(e,t){for(var i=0;i<6;++i){for(var n=!0,r=t[i],o=0;o<8;++o)if(r.dotCoordinate(e[o])>=0){n=!1;break}if(n)return!1}return!0},e.TmpVector3=n.a.BuildArray(3,r.e.Zero),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(38),r=function(){function e(){}return e.SetImmediate=function(e){n.a.IsWindowObjectExist()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var n=i(0),r=i(2),o=function(){function e(){this.previousWorldMatrices={},this.previousBones={}}return e.AddUniforms=function(e){e.push("previousWorld","previousViewProjection")},e.AddSamplers=function(e){},e.prototype.bindForSubMesh=function(e,t,i,o,a){t.prePassRenderer&&t.prePassRenderer.enabled&&-1!==t.prePassRenderer.getIndex(r.a.PREPASS_VELOCITY_TEXTURE_TYPE)&&(this.previousWorldMatrices[i.uniqueId]||(this.previousWorldMatrices[i.uniqueId]=n.a.Identity()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix()),e.setMatrix("previousWorld",this.previousWorldMatrices[i.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[i.uniqueId]=o.clone(),this.previousViewProjection=t.getTransformMatrix().clone())},e}()},function(e,t,i){"use strict";var n="lightFragmentDeclaration",r="#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";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="lightUboDeclaration",r="#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";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="imageProcessingDeclaration",r="#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="imageProcessingFunctions",r="#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\n#define inline\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x;\n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=saturate(color);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=saturate(result.rgb);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="clipPlaneFragment",r="#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE5\nif (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nif (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="clipPlaneVertex",r="#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,vClipPlane6);\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i||(i=t(e))&&this.add(e,i),i},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=e(t,this._data[t]);if(i)return i}return null},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var n=i(44),r=i(0),o=function(){function e(e,t,i){this.center=r.e.Zero(),this.centerWorld=r.e.Zero(),this.minimum=r.e.Zero(),this.maximum=r.e.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var n=r.e.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*n,this._update(i||r.a.IdentityReadOnly)},e.prototype.scale=function(t){var i=this.radius*t,n=e.TmpVector3,r=n[0].setAll(i),o=this.center.subtractToRef(r,n[1]),a=this.center.addToRef(r,n[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{r.e.TransformCoordinatesToRef(this.center,t,this.centerWorld);var i=e.TmpVector3[0];r.e.TransformNormalFromFloatsToRef(1,1,1,t,i),this.radiusWorld=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(i.z))*this.radius}},e.prototype.isInFrustum=function(e){for(var t=this.centerWorld,i=this.radiusWorld,n=0;n<6;n++)if(e[n].dotCoordinate(t)<=-i)return!1;return!0},e.prototype.isCenterInFrustum=function(e){for(var t=this.centerWorld,i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0},e.prototype.intersectsPoint=function(e){var t=r.e.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld=r&&0===i?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(i,i+n)):(t=t instanceof ArrayBuffer?new Uint8Array(t,i,n):new Uint8Array(t.buffer,t.byteOffset+i,n),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()}},function(e,t,i){"use strict";var n="fogFragmentDeclaration",r="#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n=i(26),r=i(27);n.a.prototype.createDynamicTexture=function(e,t,i,o){var a=new r.a(this,r.b.Dynamic);return a.baseWidth=e,a.baseHeight=t,i&&(e=this.needPOTTextures?n.a.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?n.a.GetExponentOfTwo(t,this._caps.maxTextureSize):t),a.width=e,a.height=t,a.isReady=!1,a.generateMipMaps=i,a.samplingMode=o,this.updateTextureSamplingMode(o,a),this._internalTexturesCache.push(a),a},n.a.prototype.updateDynamicTexture=function(e,t,i,n,r,o){if(void 0===n&&(n=!1),void 0===o&&(o=!1),e){var a=this._gl,s=a.TEXTURE_2D,c=this._bindTextureDirectly(s,e,!0,o);this._unpackFlipY(void 0===i?e.invertY:i),n&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var l=this._getWebGLTextureType(e.type),u=this._getInternalFormat(r||e.format),h=this._getRGBABufferInternalSizedFormat(e.type,u);a.texImage2D(s,0,h,u,l,t),e.generateMipMaps&&a.generateMipmap(s),c||this._bindTextureDirectly(s,null),n&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}}},function(e,t,i){"use strict";i.r(t),i.d(t,"AbstractScene",(function(){return n.a})),i.d(t,"AbstractActionManager",(function(){return r.a})),i.d(t,"Action",(function(){return l})),i.d(t,"ActionEvent",(function(){return u.a})),i.d(t,"ActionManager",(function(){return M})),i.d(t,"Condition",(function(){return d})),i.d(t,"ValueCondition",(function(){return f})),i.d(t,"PredicateCondition",(function(){return p})),i.d(t,"StateCondition",(function(){return _})),i.d(t,"SwitchBooleanAction",(function(){return v})),i.d(t,"SetStateAction",(function(){return b})),i.d(t,"SetValueAction",(function(){return y})),i.d(t,"IncrementValueAction",(function(){return T})),i.d(t,"PlayAnimationAction",(function(){return E})),i.d(t,"StopAnimationAction",(function(){return S})),i.d(t,"DoNothingAction",(function(){return A})),i.d(t,"CombineAction",(function(){return P})),i.d(t,"ExecuteCodeAction",(function(){return C})),i.d(t,"SetParentAction",(function(){return R})),i.d(t,"PlaySoundAction",(function(){return I})),i.d(t,"StopSoundAction",(function(){return D})),i.d(t,"InterpolateValueAction",(function(){return G})),i.d(t,"Animatable",(function(){return ee})),i.d(t,"_IAnimationState",(function(){return k})),i.d(t,"Animation",(function(){return z})),i.d(t,"TargetedAnimation",(function(){return te})),i.d(t,"AnimationGroup",(function(){return ie})),i.d(t,"AnimationPropertiesOverride",(function(){return ne})),i.d(t,"EasingFunction",(function(){return oe})),i.d(t,"CircleEase",(function(){return ae})),i.d(t,"BackEase",(function(){return se})),i.d(t,"BounceEase",(function(){return ce})),i.d(t,"CubicEase",(function(){return le})),i.d(t,"ElasticEase",(function(){return ue})),i.d(t,"ExponentialEase",(function(){return he})),i.d(t,"PowerEase",(function(){return de})),i.d(t,"QuadraticEase",(function(){return fe})),i.d(t,"QuarticEase",(function(){return pe})),i.d(t,"QuinticEase",(function(){return _e})),i.d(t,"SineEase",(function(){return me})),i.d(t,"BezierCurveEase",(function(){return ge})),i.d(t,"RuntimeAnimation",(function(){return K})),i.d(t,"AnimationEvent",(function(){return ve})),i.d(t,"AnimationKeyInterpolation",(function(){return N})),i.d(t,"AnimationRange",(function(){return F})),i.d(t,"KeepAssets",(function(){return ye})),i.d(t,"InstantiatedEntries",(function(){return Te})),i.d(t,"AssetContainer",(function(){return Ee})),i.d(t,"Analyser",(function(){return Ae})),i.d(t,"AudioEngine",(function(){return Pe})),i.d(t,"AudioSceneComponent",(function(){return Ie})),i.d(t,"Sound",(function(){return xe})),i.d(t,"SoundTrack",(function(){return Oe})),i.d(t,"WeightedSound",(function(){return De})),i.d(t,"AutoRotationBehavior",(function(){return Le})),i.d(t,"BouncingBehavior",(function(){return we})),i.d(t,"FramingBehavior",(function(){return Fe})),i.d(t,"AttachToBoxBehavior",(function(){return Ue})),i.d(t,"FadeInOutBehavior",(function(){return Ve})),i.d(t,"MultiPointerScaleBehavior",(function(){return ze})),i.d(t,"PointerDragBehavior",(function(){return ke.a})),i.d(t,"SixDofDragBehavior",(function(){return He})),i.d(t,"Bone",(function(){return $})),i.d(t,"BoneIKController",(function(){return Xe})),i.d(t,"BoneLookController",(function(){return Ye})),i.d(t,"Skeleton",(function(){return tt})),i.d(t,"ArcRotateCameraGamepadInput",(function(){return st})),i.d(t,"ArcRotateCameraKeyboardMoveInput",(function(){return lt})),i.d(t,"ArcRotateCameraMouseWheelInput",(function(){return ut})),i.d(t,"ArcRotateCameraPointersInput",(function(){return dt})),i.d(t,"ArcRotateCameraVRDeviceOrientationInput",(function(){return pt})),i.d(t,"FlyCameraKeyboardInput",(function(){return _t})),i.d(t,"FlyCameraMouseInput",(function(){return mt})),i.d(t,"FollowCameraKeyboardMoveInput",(function(){return gt})),i.d(t,"FollowCameraMouseWheelInput",(function(){return vt})),i.d(t,"FollowCameraPointersInput",(function(){return bt})),i.d(t,"FreeCameraDeviceOrientationInput",(function(){return Rt})),i.d(t,"FreeCameraGamepadInput",(function(){return xt})),i.d(t,"FreeCameraKeyboardMoveInput",(function(){return yt})),i.d(t,"FreeCameraMouseInput",(function(){return Tt})),i.d(t,"FreeCameraMouseWheelInput",(function(){return At})),i.d(t,"FreeCameraTouchInput",(function(){return Pt})),i.d(t,"FreeCameraVirtualJoystickInput",(function(){return Dt})),i.d(t,"CameraInputTypes",(function(){return it})),i.d(t,"CameraInputsManager",(function(){return nt})),i.d(t,"Camera",(function(){return je.a})),i.d(t,"TargetCamera",(function(){return Lt})),i.d(t,"FreeCamera",(function(){return wt})),i.d(t,"FreeCameraInputsManager",(function(){return Ct})),i.d(t,"TouchCamera",(function(){return Ft})),i.d(t,"ArcRotateCamera",(function(){return Bt})),i.d(t,"ArcRotateCameraInputsManager",(function(){return ft})),i.d(t,"DeviceOrientationCamera",(function(){return Ut})),i.d(t,"FlyCamera",(function(){return kt})),i.d(t,"FlyCameraInputsManager",(function(){return Vt})),i.d(t,"FollowCamera",(function(){return jt})),i.d(t,"ArcFollowCamera",(function(){return Wt})),i.d(t,"FollowCameraInputsManager",(function(){return zt})),i.d(t,"GamepadCamera",(function(){return ri})),i.d(t,"AnaglyphArcRotateCamera",(function(){return mi})),i.d(t,"AnaglyphFreeCamera",(function(){return gi})),i.d(t,"AnaglyphGamepadCamera",(function(){return vi})),i.d(t,"AnaglyphUniversalCamera",(function(){return bi})),i.d(t,"StereoscopicArcRotateCamera",(function(){return Ti})),i.d(t,"StereoscopicFreeCamera",(function(){return Ei})),i.d(t,"StereoscopicGamepadCamera",(function(){return Si})),i.d(t,"StereoscopicUniversalCamera",(function(){return Ai})),i.d(t,"UniversalCamera",(function(){return ni})),i.d(t,"VirtualJoysticksCamera",(function(){return Pi})),i.d(t,"VRCameraMetrics",(function(){return Ci})),i.d(t,"VRDeviceOrientationArcRotateCamera",(function(){return Bi})),i.d(t,"VRDeviceOrientationFreeCamera",(function(){return Ui})),i.d(t,"VRDeviceOrientationGamepadCamera",(function(){return Vi})),i.d(t,"OnAfterEnteringVRObservableEvent",(function(){return hn})),i.d(t,"VRExperienceHelper",(function(){return dn})),i.d(t,"WebVRFreeCamera",(function(){return zi})),i.d(t,"Collider",(function(){return _n})),i.d(t,"DefaultCollisionCoordinator",(function(){return mn})),i.d(t,"PickingInfo",(function(){return gn.a})),i.d(t,"IntersectionInfo",(function(){return vn.a})),i.d(t,"_MeshCollisionData",(function(){return bn.a})),i.d(t,"BoundingBox",(function(){return yn.a})),i.d(t,"BoundingInfo",(function(){return Tn.a})),i.d(t,"BoundingSphere",(function(){return En.a})),i.d(t,"Octree",(function(){return An})),i.d(t,"OctreeBlock",(function(){return Sn})),i.d(t,"OctreeSceneComponent",(function(){return Mn})),i.d(t,"Ray",(function(){return Xt.a})),i.d(t,"AxesViewer",(function(){return In.AxesViewer})),i.d(t,"BoneAxesViewer",(function(){return In.BoneAxesViewer})),i.d(t,"DebugLayerTab",(function(){return In.DebugLayerTab})),i.d(t,"DebugLayer",(function(){return In.DebugLayer})),i.d(t,"PhysicsViewer",(function(){return In.PhysicsViewer})),i.d(t,"RayHelper",(function(){return In.RayHelper})),i.d(t,"SkeletonViewer",(function(){return In.SkeletonViewer})),i.d(t,"DeviceInputSystem",(function(){return Dn})),i.d(t,"DeviceType",(function(){return Pn})),i.d(t,"PointerInput",(function(){return Cn})),i.d(t,"DualShockInput",(function(){return Rn})),i.d(t,"XboxInput",(function(){return xn})),i.d(t,"SwitchInput",(function(){return On})),i.d(t,"DeviceSource",(function(){return Nn})),i.d(t,"DeviceSourceManager",(function(){return Ln})),i.d(t,"Constants",(function(){return g.a})),i.d(t,"ThinEngine",(function(){return qe.a})),i.d(t,"Engine",(function(){return Se.a})),i.d(t,"EngineStore",(function(){return x.a})),i.d(t,"NullEngineOptions",(function(){return wn.b})),i.d(t,"NullEngine",(function(){return wn.a})),i.d(t,"_OcclusionDataStorage",(function(){return Bn})),i.d(t,"_forceTransformFeedbackToBundle",(function(){return Un})),i.d(t,"EngineView",(function(){return kn})),i.d(t,"WebGLPipelineContext",(function(){return Gn.a})),i.d(t,"WebGL2ShaderProcessor",(function(){return jn.a})),i.d(t,"NativeEngine",(function(){return cr})),i.d(t,"ShaderCodeInliner",(function(){return rr})),i.d(t,"PerformanceConfigurator",(function(){return lr.a})),i.d(t,"KeyboardEventTypes",(function(){return ct.a})),i.d(t,"KeyboardInfo",(function(){return ct.b})),i.d(t,"KeyboardInfoPre",(function(){return ct.c})),i.d(t,"PointerEventTypes",(function(){return Ne.a})),i.d(t,"PointerInfoBase",(function(){return Ne.c})),i.d(t,"PointerInfoPre",(function(){return Ne.d})),i.d(t,"PointerInfo",(function(){return Ne.b})),i.d(t,"ClipboardEventTypes",(function(){return ur})),i.d(t,"ClipboardInfo",(function(){return hr})),i.d(t,"DaydreamController",(function(){return _r})),i.d(t,"GearVRController",(function(){return mr})),i.d(t,"GenericController",(function(){return gr})),i.d(t,"OculusTouchController",(function(){return vr})),i.d(t,"PoseEnabledControllerType",(function(){return Gt})),i.d(t,"PoseEnabledControllerHelper",(function(){return Qt})),i.d(t,"PoseEnabledController",(function(){return qt})),i.d(t,"ViveController",(function(){return br})),i.d(t,"WebVRController",(function(){return Gi})),i.d(t,"WindowsMotionController",(function(){return Tr})),i.d(t,"XRWindowsMotionController",(function(){return Er})),i.d(t,"StickValues",(function(){return rt})),i.d(t,"Gamepad",(function(){return ot})),i.d(t,"GenericPad",(function(){return at})),i.d(t,"GamepadManager",(function(){return ti})),i.d(t,"GamepadSystemSceneComponent",(function(){return ii})),i.d(t,"Xbox360Button",(function(){return Yt})),i.d(t,"Xbox360Dpad",(function(){return Kt})),i.d(t,"Xbox360Pad",(function(){return $t})),i.d(t,"DualShockButton",(function(){return Zt})),i.d(t,"DualShockDpad",(function(){return Jt})),i.d(t,"DualShockPad",(function(){return ei})),i.d(t,"AxisDragGizmo",(function(){return Sr.a})),i.d(t,"AxisScaleGizmo",(function(){return Rr})),i.d(t,"BoundingBoxGizmo",(function(){return Mr})),i.d(t,"Gizmo",(function(){return Pr.a})),i.d(t,"GizmoManager",(function(){return Vr})),i.d(t,"PlaneRotationGizmo",(function(){return Ir})),i.d(t,"PositionGizmo",(function(){return Fr})),i.d(t,"RotationGizmo",(function(){return Dr})),i.d(t,"ScaleGizmo",(function(){return Ur})),i.d(t,"LightGizmo",(function(){return Hr})),i.d(t,"CameraGizmo",(function(){return Kr})),i.d(t,"PlaneDragGizmo",(function(){return wr})),i.d(t,"EnvironmentHelper",(function(){return go})),i.d(t,"PhotoDome",(function(){return bo})),i.d(t,"_forceSceneHelpersToBundle",(function(){return es})),i.d(t,"VideoDome",(function(){return is})),i.d(t,"EngineInstrumentation",(function(){return rs})),i.d(t,"SceneInstrumentation",(function(){return os})),i.d(t,"_TimeToken",(function(){return Fn})),i.d(t,"EffectLayer",(function(){return cs})),i.d(t,"EffectLayerSceneComponent",(function(){return ls})),i.d(t,"GlowLayer",(function(){return ds})),i.d(t,"HighlightLayer",(function(){return _s})),i.d(t,"Layer",(function(){return bs})),i.d(t,"LayerSceneComponent",(function(){return ms})),i.d(t,"LensFlare",(function(){return ys})),i.d(t,"LensFlareSystem",(function(){return Ss})),i.d(t,"LensFlareSystemSceneComponent",(function(){return As})),i.d(t,"Light",(function(){return kr.a})),i.d(t,"ShadowLight",(function(){return zr})),i.d(t,"ShadowGenerator",(function(){return Bs})),i.d(t,"CascadedShadowGenerator",(function(){return qs})),i.d(t,"ShadowGeneratorSceneComponent",(function(){return Zs})),i.d(t,"DirectionalLight",(function(){return Gr})),i.d(t,"HemisphericLight",(function(){return ki.a})),i.d(t,"PointLight",(function(){return Js})),i.d(t,"SpotLight",(function(){return Wr})),i.d(t,"DefaultLoadingScreen",(function(){return $s})),i.d(t,"_BabylonLoaderRegistered",(function(){return Tc})),i.d(t,"BabylonFileLoaderConfiguration",(function(){return Ec})),i.d(t,"SceneLoaderAnimationGroupLoadingMode",(function(){return nr})),i.d(t,"SceneLoader",(function(){return pr})),i.d(t,"SceneLoaderFlags",(function(){return fr.a})),i.d(t,"BackgroundMaterial",(function(){return mo})),i.d(t,"ColorCurves",(function(){return xc.a})),i.d(t,"EffectFallbacks",(function(){return po.a})),i.d(t,"Effect",(function(){return ai.a})),i.d(t,"FresnelParameters",(function(){return Oc})),i.d(t,"ImageProcessingConfigurationDefines",(function(){return ji.b})),i.d(t,"ImageProcessingConfiguration",(function(){return ji.a})),i.d(t,"Material",(function(){return xo.a})),i.d(t,"MaterialDefines",(function(){return oo.a})),i.d(t,"ThinMaterialHelper",(function(){return Mc.a})),i.d(t,"MaterialHelper",(function(){return ro.a})),i.d(t,"MultiMaterial",(function(){return tc.a})),i.d(t,"PBRMaterialDefines",(function(){return pa})),i.d(t,"PBRBaseMaterial",(function(){return _a})),i.d(t,"PBRBaseSimpleMaterial",(function(){return Ic})),i.d(t,"PBRMaterial",(function(){return ma})),i.d(t,"PBRMetallicRoughnessMaterial",(function(){return Dc})),i.d(t,"PBRSpecularGlossinessMaterial",(function(){return Nc})),i.d(t,"PushMaterial",(function(){return ao.a})),i.d(t,"ShaderMaterial",(function(){return Lc.a})),i.d(t,"StandardMaterialDefines",(function(){return Wi.b})),i.d(t,"StandardMaterial",(function(){return Wi.a})),i.d(t,"BaseTexture",(function(){return Zn.a})),i.d(t,"ColorGradingTexture",(function(){return wc})),i.d(t,"CubeTexture",(function(){return no})),i.d(t,"DynamicTexture",(function(){return Hi.a})),i.d(t,"EquiRectangularCubeTexture",(function(){return Fc})),i.d(t,"HDRFiltering",(function(){return cc})),i.d(t,"HDRCubeTexture",(function(){return lc})),i.d(t,"HtmlElementTexture",(function(){return Bc})),i.d(t,"InternalTextureSource",(function(){return Qe.b})),i.d(t,"InternalTexture",(function(){return Qe.a})),i.d(t,"_DDSTextureLoader",(function(){return Sa})),i.d(t,"_ENVTextureLoader",(function(){return Aa})),i.d(t,"_KTXTextureLoader",(function(){return Oa})),i.d(t,"_TGATextureLoader",(function(){return Vc})),i.d(t,"_BasisTextureLoader",(function(){return Wc})),i.d(t,"MirrorTexture",(function(){return to})),i.d(t,"MultiRenderTarget",(function(){return Hc})),i.d(t,"TexturePacker",(function(){return Yc})),i.d(t,"TexturePackerFrame",(function(){return Xc})),i.d(t,"CustomProceduralTexture",(function(){return Zc})),i.d(t,"NoiseProceduralTexture",(function(){return $c})),i.d(t,"ProceduralTexture",(function(){return qc})),i.d(t,"ProceduralTextureSceneComponent",(function(){return Kc})),i.d(t,"RawCubeTexture",(function(){return sl})),i.d(t,"RawTexture",(function(){return et})),i.d(t,"RawTexture2DArray",(function(){return cl})),i.d(t,"RawTexture3D",(function(){return ll})),i.d(t,"RefractionTexture",(function(){return ul})),i.d(t,"RenderTargetTexture",(function(){return Ni})),i.d(t,"Texture",(function(){return Ke.a})),i.d(t,"VideoTexture",(function(){return ts})),i.d(t,"UniformBuffer",(function(){return Mi.a})),i.d(t,"MaterialFlags",(function(){return so.a})),i.d(t,"NodeMaterialBlockTargets",(function(){return el})),i.d(t,"NodeMaterialBlockConnectionPointTypes",(function(){return tl})),i.d(t,"NodeMaterialBlockConnectionPointMode",(function(){return il})),i.d(t,"NodeMaterialSystemValues",(function(){return nl})),i.d(t,"NodeMaterialModes",(function(){return rl})),i.d(t,"NodeMaterialConnectionPointCompatibilityStates",(function(){return ol})),i.d(t,"NodeMaterialConnectionPointDirection",(function(){return al})),i.d(t,"NodeMaterialConnectionPoint",(function(){return hl})),i.d(t,"NodeMaterialBlock",(function(){return fl})),i.d(t,"NodeMaterialDefines",(function(){return Ql})),i.d(t,"NodeMaterial",(function(){return ql})),i.d(t,"VertexOutputBlock",(function(){return gl})),i.d(t,"BonesBlock",(function(){return Zl})),i.d(t,"InstancesBlock",(function(){return Jl})),i.d(t,"MorphTargetsBlock",(function(){return $l})),i.d(t,"LightInformationBlock",(function(){return eu})),i.d(t,"FragmentOutputBlock",(function(){return bl})),i.d(t,"ImageProcessingBlock",(function(){return tu})),i.d(t,"PerturbNormalBlock",(function(){return iu})),i.d(t,"DiscardBlock",(function(){return nu})),i.d(t,"FrontFacingBlock",(function(){return ru})),i.d(t,"DerivativeBlock",(function(){return ou})),i.d(t,"FragCoordBlock",(function(){return au})),i.d(t,"ScreenSizeBlock",(function(){return su})),i.d(t,"FogBlock",(function(){return cu})),i.d(t,"LightBlock",(function(){return lu})),i.d(t,"TextureBlock",(function(){return uu})),i.d(t,"ReflectionTextureBlock",(function(){return du})),i.d(t,"CurrentScreenBlock",(function(){return Al})),i.d(t,"InputBlock",(function(){return Sl})),i.d(t,"AnimatedInputBlockTypes",(function(){return vl})),i.d(t,"MultiplyBlock",(function(){return Dl})),i.d(t,"AddBlock",(function(){return fu})),i.d(t,"ScaleBlock",(function(){return pu})),i.d(t,"ClampBlock",(function(){return _u})),i.d(t,"CrossBlock",(function(){return mu})),i.d(t,"DotBlock",(function(){return gu})),i.d(t,"TransformBlock",(function(){return ml})),i.d(t,"RemapBlock",(function(){return Il})),i.d(t,"NormalizeBlock",(function(){return vu})),i.d(t,"TrigonometryBlockOperations",(function(){return Hl})),i.d(t,"TrigonometryBlock",(function(){return Yl})),i.d(t,"ColorMergerBlock",(function(){return bu})),i.d(t,"VectorMergerBlock",(function(){return Ol})),i.d(t,"ColorSplitterBlock",(function(){return Wl})),i.d(t,"VectorSplitterBlock",(function(){return yu})),i.d(t,"LerpBlock",(function(){return Tu})),i.d(t,"DivideBlock",(function(){return Eu})),i.d(t,"SubtractBlock",(function(){return Su})),i.d(t,"StepBlock",(function(){return Au})),i.d(t,"OneMinusBlock",(function(){return Pu})),i.d(t,"ViewDirectionBlock",(function(){return Cu})),i.d(t,"FresnelBlock",(function(){return Ru})),i.d(t,"MaxBlock",(function(){return xu})),i.d(t,"MinBlock",(function(){return Ou})),i.d(t,"DistanceBlock",(function(){return Mu})),i.d(t,"LengthBlock",(function(){return Iu})),i.d(t,"NegateBlock",(function(){return Du})),i.d(t,"PowBlock",(function(){return Nu})),i.d(t,"RandomNumberBlock",(function(){return Lu})),i.d(t,"ArcTan2Block",(function(){return wu})),i.d(t,"SmoothStepBlock",(function(){return Fu})),i.d(t,"ReciprocalBlock",(function(){return Bu})),i.d(t,"ReplaceColorBlock",(function(){return Uu})),i.d(t,"PosterizeBlock",(function(){return ku})),i.d(t,"WaveBlockKind",(function(){return Vu})),i.d(t,"WaveBlock",(function(){return zu})),i.d(t,"GradientBlockColorStep",(function(){return Gu})),i.d(t,"GradientBlock",(function(){return ju})),i.d(t,"NLerpBlock",(function(){return Wu})),i.d(t,"WorleyNoise3DBlock",(function(){return Hu})),i.d(t,"SimplexPerlin3DBlock",(function(){return Xu})),i.d(t,"NormalBlendBlock",(function(){return Yu})),i.d(t,"Rotate2dBlock",(function(){return Ku})),i.d(t,"ReflectBlock",(function(){return Qu})),i.d(t,"RefractBlock",(function(){return qu})),i.d(t,"DesaturateBlock",(function(){return Zu})),i.d(t,"PBRMetallicRoughnessBlock",(function(){return ah})),i.d(t,"SheenBlock",(function(){return $u})),i.d(t,"AnisotropyBlock",(function(){return eh})),i.d(t,"ReflectionBlock",(function(){return th})),i.d(t,"ClearCoatBlock",(function(){return ih})),i.d(t,"RefractionBlock",(function(){return nh})),i.d(t,"SubSurfaceBlock",(function(){return rh})),i.d(t,"ParticleTextureBlock",(function(){return Pl})),i.d(t,"ParticleRampGradientBlock",(function(){return Cl})),i.d(t,"ParticleBlendMultiplyBlock",(function(){return Rl})),i.d(t,"ModBlock",(function(){return sh})),i.d(t,"NodeMaterialOptimizer",(function(){return ch})),i.d(t,"PropertyTypeForEdition",(function(){return xl})),i.d(t,"editableInPropertyPage",(function(){return Ml})),i.d(t,"EffectRenderer",(function(){return rc})),i.d(t,"EffectWrapper",(function(){return oc})),i.d(t,"ShadowDepthWrapper",(function(){return hh})),i.d(t,"Scalar",(function(){return L.a})),i.d(t,"extractMinAndMaxIndexed",(function(){return dh.b})),i.d(t,"extractMinAndMax",(function(){return dh.a})),i.d(t,"Space",(function(){return J.c})),i.d(t,"Axis",(function(){return J.a})),i.d(t,"Coordinate",(function(){return J.b})),i.d(t,"Color3",(function(){return s.a})),i.d(t,"Color4",(function(){return s.b})),i.d(t,"TmpColors",(function(){return s.c})),i.d(t,"ToGammaSpace",(function(){return Nt.b})),i.d(t,"ToLinearSpace",(function(){return Nt.c})),i.d(t,"Epsilon",(function(){return Nt.a})),i.d(t,"Frustum",(function(){return wi.a})),i.d(t,"Orientation",(function(){return re.e})),i.d(t,"BezierCurve",(function(){return re.c})),i.d(t,"Angle",(function(){return re.a})),i.d(t,"Arc2",(function(){return re.b})),i.d(t,"Path2",(function(){return re.f})),i.d(t,"Path3D",(function(){return re.g})),i.d(t,"Curve3",(function(){return re.d})),i.d(t,"Plane",(function(){return fn.a})),i.d(t,"Size",(function(){return U.a})),i.d(t,"Vector2",(function(){return a.d})),i.d(t,"Vector3",(function(){return a.e})),i.d(t,"Vector4",(function(){return a.f})),i.d(t,"Quaternion",(function(){return a.b})),i.d(t,"Matrix",(function(){return a.a})),i.d(t,"TmpVectors",(function(){return a.c})),i.d(t,"PositionNormalVertex",(function(){return Xr})),i.d(t,"PositionNormalTextureVertex",(function(){return Yr})),i.d(t,"Viewport",(function(){return yi.a})),i.d(t,"SphericalHarmonics",(function(){return Qn})),i.d(t,"SphericalPolynomial",(function(){return qn})),i.d(t,"AbstractMesh",(function(){return Ge.a})),i.d(t,"Buffer",(function(){return Qi.a})),i.d(t,"VertexBuffer",(function(){return Qi.b})),i.d(t,"DracoCompression",(function(){return mh})),i.d(t,"CSG",(function(){return Sh})),i.d(t,"Geometry",(function(){return ec.a})),i.d(t,"GroundMesh",(function(){return qi})),i.d(t,"TrailMesh",(function(){return Ah})),i.d(t,"InstancedMesh",(function(){return Ph.a})),i.d(t,"LinesMesh",(function(){return Ch.b})),i.d(t,"InstancedLinesMesh",(function(){return Ch.a})),i.d(t,"_CreationDataStorage",(function(){return be.b})),i.d(t,"_InstancesBatch",(function(){return be.c})),i.d(t,"Mesh",(function(){return be.a})),i.d(t,"VertexData",(function(){return Ki.a})),i.d(t,"MeshBuilder",(function(){return jh})),i.d(t,"SimplificationSettings",(function(){return Wh})),i.d(t,"SimplificationQueue",(function(){return Hh})),i.d(t,"SimplificationType",(function(){return zh})),i.d(t,"QuadraticErrorSimplification",(function(){return qh})),i.d(t,"SimplicationQueueSceneComponent",(function(){return Zh})),i.d(t,"Polygon",(function(){return Nh})),i.d(t,"PolygonMeshBuilder",(function(){return Lh})),i.d(t,"SubMesh",(function(){return gh.a})),i.d(t,"MeshLODLevel",(function(){return Jh.a})),i.d(t,"TransformNode",(function(){return Nr.a})),i.d(t,"BoxBuilder",(function(){return Ar.a})),i.d(t,"TiledBoxBuilder",(function(){return Oh})),i.d(t,"DiscBuilder",(function(){return xh})),i.d(t,"RibbonBuilder",(function(){return Rh.a})),i.d(t,"SphereBuilder",(function(){return xr.a})),i.d(t,"HemisphereBuilder",(function(){return jr})),i.d(t,"CylinderBuilder",(function(){return nn.a})),i.d(t,"TorusBuilder",(function(){return tn})),i.d(t,"TorusKnotBuilder",(function(){return Mh})),i.d(t,"LinesBuilder",(function(){return Or.a})),i.d(t,"PolygonBuilder",(function(){return wh})),i.d(t,"ShapeBuilder",(function(){return vc.a})),i.d(t,"LatheBuilder",(function(){return Fh})),i.d(t,"PlaneBuilder",(function(){return Lr.a})),i.d(t,"TiledPlaneBuilder",(function(){return Bh})),i.d(t,"GroundBuilder",(function(){return Ji})),i.d(t,"TubeBuilder",(function(){return Uh})),i.d(t,"PolyhedronBuilder",(function(){return Br})),i.d(t,"IcoSphereBuilder",(function(){return Vh})),i.d(t,"DecalBuilder",(function(){return kh})),i.d(t,"CapsuleBuilder",(function(){return Gh})),i.d(t,"DataBuffer",(function(){return Wn.a})),i.d(t,"WebGLDataBuffer",(function(){return $h.a})),i.d(t,"MorphTarget",(function(){return uc})),i.d(t,"MorphTargetManager",(function(){return hc})),i.d(t,"RecastJSPlugin",(function(){return ed})),i.d(t,"RecastJSCrowd",(function(){return td})),i.d(t,"Node",(function(){return B.a})),i.d(t,"Database",(function(){return nd})),i.d(t,"BaseParticleSystem",(function(){return jl})),i.d(t,"BoxParticleEmitter",(function(){return Nl})),i.d(t,"ConeParticleEmitter",(function(){return Ll})),i.d(t,"CylinderParticleEmitter",(function(){return wl})),i.d(t,"CylinderDirectedParticleEmitter",(function(){return Fl})),i.d(t,"HemisphericParticleEmitter",(function(){return Bl})),i.d(t,"PointParticleEmitter",(function(){return Ul})),i.d(t,"SphereParticleEmitter",(function(){return Vl})),i.d(t,"SphereDirectedParticleEmitter",(function(){return kl})),i.d(t,"CustomParticleEmitter",(function(){return zl})),i.d(t,"MeshParticleEmitter",(function(){return Gl})),i.d(t,"GPUParticleSystem",(function(){return vd})),i.d(t,"Particle",(function(){return cd})),i.d(t,"ParticleHelper",(function(){return yd})),i.d(t,"ParticleSystem",(function(){return dd})),i.d(t,"ParticleSystemSet",(function(){return bd})),i.d(t,"SolidParticle",(function(){return Ed})),i.d(t,"ModelShape",(function(){return Sd})),i.d(t,"DepthSortedParticle",(function(){return Ad})),i.d(t,"SolidParticleVertex",(function(){return Pd})),i.d(t,"SolidParticleSystem",(function(){return Cd})),i.d(t,"CloudPoint",(function(){return Rd})),i.d(t,"PointsGroup",(function(){return xd})),i.d(t,"PointColor",(function(){return Td})),i.d(t,"PointsCloudSystem",(function(){return Od})),i.d(t,"SubEmitterType",(function(){return id})),i.d(t,"SubEmitter",(function(){return ld})),i.d(t,"PhysicsEngine",(function(){return pc})),i.d(t,"PhysicsEngineSceneComponent",(function(){return Dd})),i.d(t,"PhysicsHelper",(function(){return Nd})),i.d(t,"PhysicsRadialExplosionEventOptions",(function(){return Ud})),i.d(t,"PhysicsUpdraftEventOptions",(function(){return Vd})),i.d(t,"PhysicsVortexEventOptions",(function(){return kd})),i.d(t,"PhysicsRadialImpulseFalloff",(function(){return Md})),i.d(t,"PhysicsUpdraftMode",(function(){return Id})),i.d(t,"PhysicsImpostor",(function(){return dc.a})),i.d(t,"PhysicsJoint",(function(){return fc.e})),i.d(t,"DistanceJoint",(function(){return fc.a})),i.d(t,"MotorEnabledJoint",(function(){return fc.d})),i.d(t,"HingeJoint",(function(){return fc.c})),i.d(t,"Hinge2Joint",(function(){return fc.b})),i.d(t,"CannonJSPlugin",(function(){return mc})),i.d(t,"AmmoJSPlugin",(function(){return bc})),i.d(t,"OimoJSPlugin",(function(){return gc})),i.d(t,"AnaglyphPostProcess",(function(){return _i})),i.d(t,"BlackAndWhitePostProcess",(function(){return Gd})),i.d(t,"BloomEffect",(function(){return Kd})),i.d(t,"BloomMergePostProcess",(function(){return Yd})),i.d(t,"BlurPostProcess",(function(){return eo})),i.d(t,"ChromaticAberrationPostProcess",(function(){return qd})),i.d(t,"CircleOfConfusionPostProcess",(function(){return Jd})),i.d(t,"ColorCorrectionPostProcess",(function(){return ef})),i.d(t,"ConvolutionPostProcess",(function(){return nf})),i.d(t,"DepthOfFieldBlurPostProcess",(function(){return rf})),i.d(t,"DepthOfFieldEffectBlurLevel",(function(){return af})),i.d(t,"DepthOfFieldEffect",(function(){return lf})),i.d(t,"DepthOfFieldMergePostProcessOptions",(function(){return sf})),i.d(t,"DepthOfFieldMergePostProcess",(function(){return cf})),i.d(t,"DisplayPassPostProcess",(function(){return hf})),i.d(t,"ExtractHighlightsPostProcess",(function(){return Hd})),i.d(t,"FilterPostProcess",(function(){return ff})),i.d(t,"FxaaPostProcess",(function(){return mf})),i.d(t,"GrainPostProcess",(function(){return vf})),i.d(t,"HighlightsPostProcess",(function(){return yf})),i.d(t,"ImageProcessingPostProcess",(function(){return Yi})),i.d(t,"MotionBlurPostProcess",(function(){return Rf})),i.d(t,"PassPostProcess",(function(){return di})),i.d(t,"PassCubePostProcess",(function(){return fi})),i.d(t,"PostProcess",(function(){return li})),i.d(t,"PostProcessManager",(function(){return Ii.a})),i.d(t,"RefractionPostProcess",(function(){return Of})),i.d(t,"DefaultRenderingPipeline",(function(){return wf})),i.d(t,"LensRenderingPipeline",(function(){return Uf})),i.d(t,"SSAO2RenderingPipeline",(function(){return Gf})),i.d(t,"SSAORenderingPipeline",(function(){return Wf})),i.d(t,"StandardRenderingPipeline",(function(){return Qf})),i.d(t,"PostProcessRenderEffect",(function(){return jd})),i.d(t,"PostProcessRenderPipeline",(function(){return Df})),i.d(t,"PostProcessRenderPipelineManager",(function(){return Nf})),i.d(t,"PostProcessRenderPipelineManagerSceneComponent",(function(){return Lf})),i.d(t,"SharpenPostProcess",(function(){return If})),i.d(t,"StereoscopicInterlacePostProcessI",(function(){return Zf})),i.d(t,"StereoscopicInterlacePostProcess",(function(){return Jf})),i.d(t,"TonemappingOperator",(function(){return ep})),i.d(t,"TonemapPostProcess",(function(){return tp})),i.d(t,"VolumetricLightScatteringPostProcess",(function(){return op})),i.d(t,"VRDistortionCorrectionPostProcess",(function(){return xi})),i.d(t,"VRMultiviewToSingleviewPostProcess",(function(){return Fi})),i.d(t,"ScreenSpaceReflectionPostProcess",(function(){return Yf})),i.d(t,"ScreenSpaceCurvaturePostProcess",(function(){return sp})),i.d(t,"ReflectionProbe",(function(){return yc})),i.d(t,"BoundingBoxRenderer",(function(){return cp})),i.d(t,"DepthRenderer",(function(){return ks})),i.d(t,"DepthRendererSceneComponent",(function(){return lp})),i.d(t,"EdgesRenderer",(function(){return dp})),i.d(t,"LineEdgesRenderer",(function(){return fp})),i.d(t,"GeometryBufferRenderer",(function(){return Sf})),i.d(t,"GeometryBufferRendererSceneComponent",(function(){return Pf})),i.d(t,"PrePassRenderer",(function(){return pp})),i.d(t,"PrePassRendererSceneComponent",(function(){return _p})),i.d(t,"SubSurfaceSceneComponent",(function(){return Tp})),i.d(t,"OutlineRenderer",(function(){return Ap})),i.d(t,"RenderingGroup",(function(){return Pp.a})),i.d(t,"RenderingGroupInfo",(function(){return Di.a})),i.d(t,"RenderingManager",(function(){return Di.b})),i.d(t,"UtilityLayerRenderer",(function(){return Cr.a})),i.d(t,"Scene",(function(){return Q.a})),i.d(t,"SceneComponentConstants",(function(){return Me.a})),i.d(t,"Stage",(function(){return Me.b})),i.d(t,"Sprite",(function(){return Cp})),i.d(t,"SpriteManager",(function(){return Ip})),i.d(t,"SpriteMap",(function(){return wp})),i.d(t,"SpritePackedManager",(function(){return Fp})),i.d(t,"SpriteSceneComponent",(function(){return Rp})),i.d(t,"AlphaState",(function(){return Bp.a})),i.d(t,"DepthCullingState",(function(){return Up.a})),i.d(t,"StencilState",(function(){return Vp.a})),i.d(t,"AndOrNotEvaluator",(function(){return kp.a})),i.d(t,"AssetTaskState",(function(){return Lp})),i.d(t,"AbstractAssetTask",(function(){return Gp})),i.d(t,"AssetsProgressEvent",(function(){return jp})),i.d(t,"ContainerAssetTask",(function(){return Wp})),i.d(t,"MeshAssetTask",(function(){return Hp})),i.d(t,"TextFileAssetTask",(function(){return Xp})),i.d(t,"BinaryFileAssetTask",(function(){return Yp})),i.d(t,"ImageAssetTask",(function(){return Kp})),i.d(t,"TextureAssetTask",(function(){return Qp})),i.d(t,"CubeTextureAssetTask",(function(){return qp})),i.d(t,"HDRCubeTextureAssetTask",(function(){return Zp})),i.d(t,"EquiRectangularCubeTextureAssetTask",(function(){return Jp})),i.d(t,"AssetsManager",(function(){return $p})),i.d(t,"BasisTranscodeConfiguration",(function(){return zc})),i.d(t,"BasisTools",(function(){return Gc})),i.d(t,"DDSTools",(function(){return Ea})),i.d(t,"expandToProperty",(function(){return w.b})),i.d(t,"serialize",(function(){return w.c})),i.d(t,"serializeAsTexture",(function(){return w.m})),i.d(t,"serializeAsColor3",(function(){return w.e})),i.d(t,"serializeAsFresnelParameters",(function(){return w.h})),i.d(t,"serializeAsVector2",(function(){return w.n})),i.d(t,"serializeAsVector3",(function(){return w.o})),i.d(t,"serializeAsMeshReference",(function(){return w.k})),i.d(t,"serializeAsColorCurves",(function(){return w.g})),i.d(t,"serializeAsColor4",(function(){return w.f})),i.d(t,"serializeAsImageProcessingConfiguration",(function(){return w.i})),i.d(t,"serializeAsQuaternion",(function(){return w.l})),i.d(t,"serializeAsMatrix",(function(){return w.j})),i.d(t,"serializeAsCameraReference",(function(){return w.d})),i.d(t,"SerializationHelper",(function(){return w.a})),i.d(t,"Deferred",(function(){return e_})),i.d(t,"EnvironmentTextureTools",(function(){return ir})),i.d(t,"MeshExploder",(function(){return t_})),i.d(t,"FilesInput",(function(){return i_})),i.d(t,"CubeMapToSphericalPolynomialTools",(function(){return $n})),i.d(t,"HDRTools",(function(){return nc})),i.d(t,"PanoramaToCubeMapTools",(function(){return ic})),i.d(t,"KhronosTextureContainer",(function(){return Pa})),i.d(t,"EventState",(function(){return o.a})),i.d(t,"Observer",(function(){return o.d})),i.d(t,"MultiObserver",(function(){return o.b})),i.d(t,"Observable",(function(){return o.c})),i.d(t,"PerformanceMonitor",(function(){return n_.a})),i.d(t,"RollingAverage",(function(){return n_.b})),i.d(t,"PromisePolyfill",(function(){return r_.a})),i.d(t,"SceneOptimization",(function(){return o_})),i.d(t,"TextureOptimization",(function(){return a_})),i.d(t,"HardwareScalingOptimization",(function(){return s_})),i.d(t,"ShadowsOptimization",(function(){return c_})),i.d(t,"PostProcessesOptimization",(function(){return l_})),i.d(t,"LensFlaresOptimization",(function(){return u_})),i.d(t,"CustomOptimization",(function(){return h_})),i.d(t,"ParticlesOptimization",(function(){return d_})),i.d(t,"RenderTargetsOptimization",(function(){return f_})),i.d(t,"MergeMeshesOptimization",(function(){return p_})),i.d(t,"SceneOptimizerOptions",(function(){return __})),i.d(t,"SceneOptimizer",(function(){return m_})),i.d(t,"SceneSerializer",(function(){return y_})),i.d(t,"SmartArray",(function(){return oi.a})),i.d(t,"SmartArrayNoDuplicate",(function(){return oi.b})),i.d(t,"StringDictionary",(function(){return Mt.a})),i.d(t,"Tags",(function(){return T_.a})),i.d(t,"TextureTools",(function(){return E_})),i.d(t,"TGATools",(function(){return Uc})),i.d(t,"Tools",(function(){return Ce.b})),i.d(t,"className",(function(){return Ce.c})),i.d(t,"AsyncLoop",(function(){return Ce.a})),i.d(t,"VideoRecorder",(function(){return S_})),i.d(t,"JoystickAxis",(function(){return Ot})),i.d(t,"VirtualJoystick",(function(){return It})),i.d(t,"WorkerPool",(function(){return Ca})),i.d(t,"Logger",(function(){return m.a})),i.d(t,"_TypeStore",(function(){return c.a})),i.d(t,"FilesInputStore",(function(){return dr.a})),i.d(t,"DeepCopier",(function(){return O.a})),i.d(t,"PivotTools",(function(){return We.a})),i.d(t,"PrecisionDate",(function(){return q.a})),i.d(t,"ScreenshotTools",(function(){return A_})),i.d(t,"WebRequest",(function(){return V.a})),i.d(t,"InspectableType",(function(){return zp})),i.d(t,"BRDFTextureTools",(function(){return To})),i.d(t,"RGBDTextureTools",(function(){return yo})),i.d(t,"ColorGradient",(function(){return rd})),i.d(t,"Color3Gradient",(function(){return od})),i.d(t,"FactorGradient",(function(){return ad})),i.d(t,"GradientHelper",(function(){return sd})),i.d(t,"PerfCounter",(function(){return ns.a})),i.d(t,"RetryStrategy",(function(){return C_.a})),i.d(t,"CanvasGenerator",(function(){return Zi.a})),i.d(t,"LoadFileError",(function(){return Vn.b})),i.d(t,"RequestFileError",(function(){return Vn.d})),i.d(t,"ReadFileError",(function(){return Vn.c})),i.d(t,"FileTools",(function(){return Vn.a})),i.d(t,"StringTools",(function(){return io.a})),i.d(t,"DataReader",(function(){return R_})),i.d(t,"MinMaxReducer",(function(){return Gs})),i.d(t,"DepthReducer",(function(){return js})),i.d(t,"DataStorage",(function(){return x_})),i.d(t,"SceneRecorder",(function(){return O_})),i.d(t,"KhronosTextureContainer2",(function(){return Ra})),i.d(t,"Trajectory",(function(){return M_})),i.d(t,"TrajectoryClassifier",(function(){return L_})),i.d(t,"TimerState",(function(){return Ha})),i.d(t,"setAndStartTimer",(function(){return Qa})),i.d(t,"AdvancedTimer",(function(){return qa})),i.d(t,"CopyTools",(function(){return w_.a})),i.d(t,"WebXRCamera",(function(){return Ma})),i.d(t,"WebXREnterExitUIButton",(function(){return Xa})),i.d(t,"WebXREnterExitUIOptions",(function(){return Ya})),i.d(t,"WebXREnterExitUI",(function(){return Ka})),i.d(t,"WebXRExperienceHelper",(function(){return Na})),i.d(t,"WebXRInput",(function(){return Ga})),i.d(t,"WebXRInputSource",(function(){return za})),i.d(t,"WebXRManagedOutputCanvasOptions",(function(){return rn})),i.d(t,"WebXRManagedOutputCanvas",(function(){return on})),i.d(t,"WebXRState",(function(){return $i})),i.d(t,"WebXRTrackingState",(function(){return en})),i.d(t,"WebXRSessionManager",(function(){return an})),i.d(t,"WebXRDefaultExperienceOptions",(function(){return Ja})),i.d(t,"WebXRDefaultExperience",(function(){return $a})),i.d(t,"WebXRFeatureName",(function(){return Ia})),i.d(t,"WebXRFeaturesManager",(function(){return Da})),i.d(t,"WebXRAbstractFeature",(function(){return ja})),i.d(t,"WebXRHitTestLegacy",(function(){return F_})),i.d(t,"WebXRAnchorSystem",(function(){return U_})),i.d(t,"WebXRPlaneDetector",(function(){return k_})),i.d(t,"WebXRBackgroundRemover",(function(){return z_})),i.d(t,"WebXRMotionControllerTeleportation",(function(){return Za})),i.d(t,"WebXRControllerPointerSelection",(function(){return Wa})),i.d(t,"IWebXRControllerPhysicsOptions",(function(){return G_})),i.d(t,"WebXRControllerPhysics",(function(){return j_})),i.d(t,"WebXRHitTest",(function(){return W_})),i.d(t,"WebXRFeaturePointSystem",(function(){return H_})),i.d(t,"WebXRHand",(function(){return X_})),i.d(t,"WebXRHandTracking",(function(){return Y_})),i.d(t,"WebXRAbstractMotionController",(function(){return wa})),i.d(t,"WebXRControllerComponent",(function(){return La})),i.d(t,"WebXRGenericTriggerMotionController",(function(){return Fa})),i.d(t,"WebXRMicrosoftMixedRealityController",(function(){return K_})),i.d(t,"WebXRMotionControllerManager",(function(){return Va})),i.d(t,"WebXROculusTouchMotionController",(function(){return q_})),i.d(t,"WebXRHTCViveMotionController",(function(){return J_})),i.d(t,"WebXRProfiledMotionController",(function(){return Ua}));var n=i(35),r=i(91),o=i(6),a=i(0),s=i(9),c=i(11),l=function(){function e(e,t){this.triggerOptions=e,this.onBeforeExecuteObservable=new o.c,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):e.trigger?this.trigger=e.trigger:this.trigger=e,this._nextActiveAction=this,this._condition=t}return e.prototype._prepare=function(){},e.prototype.getTriggerParameter=function(){return this._triggerParameter},e.prototype._executeCurrent=function(e){if(this._nextActiveAction._condition){var t=this._nextActiveAction._condition,i=this._actionManager.getScene().getRenderId();if(t._evaluationId===i){if(!t._currentResult)return}else{if(t._evaluationId=i,!t.isValid())return void(t._currentResult=!1);t._currentResult=!0}}this.onBeforeExecuteObservable.notifyObservers(this),this._nextActiveAction.execute(e),this.skipToNextActiveAction()},e.prototype.execute=function(e){},e.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},e.prototype.then=function(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(e){},e.prototype._serialize=function(e,t){var i={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(i),this._condition){var n=this._condition.serialize();return n.children.push(i),t&&t.children.push(n),n}return t&&t.children.push(i),i},e._SerializeValueAsString=function(e){return"number"==typeof e?e.toString():"boolean"==typeof e?e?"true":"false":e instanceof a.d?e.x+", "+e.y:e instanceof a.e?e.x+", "+e.y+", "+e.z:e instanceof s.a?e.r+", "+e.g+", "+e.b:e instanceof s.b?e.r+", "+e.g+", "+e.b+", "+e.a:e},e._GetTargetProperty=function(e){return{name:"target",targetType:e._isMesh?"MeshProperties":e._isLight?"LightProperties":e._isCamera?"CameraProperties":"SceneProperties",value:e._isScene?"Scene":e.name}},e}();c.a.RegisteredTypes["BABYLON.Action"]=l;var u=i(47),h=i(1),d=function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e}(),f=function(e){function t(i,n,r,o,a){void 0===a&&(a=t.IsEqual);var s=e.call(this,i)||this;return s.propertyPath=r,s.value=o,s.operator=a,s._target=n,s._effectiveTarget=s._getEffectiveTarget(n,s.propertyPath),s._property=s._getProperty(s.propertyPath),s}return Object(h.d)(t,e),Object.defineProperty(t,"IsEqual",{get:function(){return t._IsEqual},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsDifferent",{get:function(){return t._IsDifferent},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsGreater",{get:function(){return t._IsGreater},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsLesser",{get:function(){return t._IsLesser},enumerable:!1,configurable:!0}),t.prototype.isValid=function(){switch(this.operator){case t.IsGreater:return this._effectiveTarget[this._property]>this.value;case t.IsLesser:return this._effectiveTarget[this._property]-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 i=0;i=t.OnPickTrigger&&i.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t.OnPickTrigger&&i.trigger<=t.OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(m.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 i=this.actions.indexOf(e);return-1!==i&&(this.actions.splice(i,1),t.Triggers[e.trigger]-=1,0===t.Triggers[e.trigger]&&delete t.Triggers[e.trigger],e._actionManager=null,!0)},t.prototype.processTrigger=function(e,i){for(var n=0;n0;if(2===e.type?h.push(r):h.push(i),m){for(var g=new Array,v=0;v0){var _=p.properties[0].value,m=null===p.properties[0].targetType?_:n.getMeshByName(_);m._meshId&&(m.mesh=n.getMeshByID(m._meshId)),h={trigger:t[p.name],parameter:m}}else h=t[p.name];for(var g=0;g=0?i:0;var c=0,l=s._keys[0],u=s._keys.length-1,h=s._keys[u],d={referenceValue:l.value,referencePosition:a.c.Vector3[0],referenceQuaternion:a.c.Quaternion[0],referenceScaling:a.c.Vector3[1],keyPosition:a.c.Vector3[2],keyQuaternion:a.c.Quaternion[1],keyScaling:a.c.Vector3[3]},f=!1,p=l.frame,_=h.frame;if(n){var m=s.getRange(n);m&&(p=m.from,_=m.to)}var g=l.frame===p,v=h.frame===_;if(1===s._keys.length){var b=s._getKeyValue(s._keys[0]);d.referenceValue=b.clone?b.clone():b,f=!0}else if(i<=l.frame){b=s._getKeyValue(l.value);d.referenceValue=b.clone?b.clone():b,f=!0}else if(i>=h.frame){b=s._getKeyValue(h.value);d.referenceValue=b.clone?b.clone():b,f=!0}for(var y=0;!f||!g||!v&&y=T.frame&&i<=E.frame){b=void 0;if(i===T.frame)b=s._getKeyValue(T.value);else if(i===E.frame)b=s._getKeyValue(E.value);else{var S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};b=s._interpolate(i,S)}d.referenceValue=b.clone?b.clone():b,f=!0}if(!g&&p>=T.frame&&p<=E.frame){if(p===T.frame)c=y;else if(p===E.frame)c=y+1;else{S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};var A={frame:p,value:(b=s._interpolate(p,S)).clone?b.clone():b};s._keys.splice(y+1,0,A),c=y+1}g=!0}if(!v&&_>=T.frame&&_<=E.frame){if(_===T.frame)u=y;else if(_===E.frame)u=y+1;else{S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT},A={frame:_,value:(b=s._interpolate(_,S)).clone?b.clone():b};s._keys.splice(y+1,0,A),u=y+1}v=!0}y++}s.dataType===e.ANIMATIONTYPE_QUATERNION?d.referenceValue.normalize().conjugateInPlace():s.dataType===e.ANIMATIONTYPE_MATRIX&&(d.referenceValue.decompose(d.referenceScaling,d.referenceQuaternion,d.referencePosition),d.referenceQuaternion.normalize().conjugateInPlace());for(y=c;y<=u;y++){A=s._keys[y];if(!y||s.dataType===e.ANIMATIONTYPE_FLOAT||A.value!==l.value)switch(s.dataType){case e.ANIMATIONTYPE_MATRIX:A.value.decompose(d.keyScaling,d.keyQuaternion,d.keyPosition),d.keyPosition.subtractInPlace(d.referencePosition),d.keyScaling.divideInPlace(d.referenceScaling),d.referenceQuaternion.multiplyToRef(d.keyQuaternion,d.keyQuaternion),a.a.ComposeToRef(d.keyScaling,d.keyQuaternion,d.keyPosition,A.value);break;case e.ANIMATIONTYPE_QUATERNION:d.referenceValue.multiplyToRef(A.value,A.value);break;case e.ANIMATIONTYPE_VECTOR2:case e.ANIMATIONTYPE_VECTOR3:case e.ANIMATIONTYPE_COLOR3:case e.ANIMATIONTYPE_COLOR4:A.value.subtractToRef(d.referenceValue,A.value);break;case e.ANIMATIONTYPE_SIZE:A.value.width-=d.referenceValue.width,A.value.height-=d.referenceValue.height;break;default:A.value-=d.referenceValue}}return s},e.TransitionTo=function(e,t,i,n,r,o,a,s){if(void 0===s&&(s=null),a<=0)return i[e]=t,s&&s(),null;var c=r*(a/1e3);o.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:c,value:t}]),i.animations||(i.animations=[]),i.animations.push(o);var l=n.beginAnimation(i,0,c,!1);return l.onAnimationEnd=s,l},Object.defineProperty(e.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRunningRuntimeAnimations",{get:function(){for(var e=0,t=this._runtimeAnimations;e=0;o--)this._keys[o].frame>=n&&this._keys[o].frame<=r&&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,i=this._keys.length;t0)return i.highLimitValue.clone?i.highLimitValue.clone():i.highLimitValue;var n=this._keys;if(1===n.length)return this._getKeyValue(n[0].value);var r=i.key;if(n[r].frame>=t)for(;r-1>=0&&n[r].frame>=t;)r--;for(var o=r;o=t){i.key=o;var s=n[o],c=this._getKeyValue(s.value);if(s.interpolation===N.STEP)return c;var l=this._getKeyValue(a.value),u=void 0!==s.outTangent&&void 0!==a.inTangent,h=a.frame-s.frame,d=(t-s.frame)/h,f=this.getEasingFunction();switch(null!=f&&(d=f.ease(d)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var p=u?this.floatInterpolateFunctionWithTangents(c,s.outTangent*h,l,a.inTangent*h,d):this.floatInterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return p;case e.ANIMATIONLOOPMODE_RELATIVE:return i.offsetValue*i.repeatCount+p}break;case e.ANIMATIONTYPE_QUATERNION:var _=u?this.quaternionInterpolateFunctionWithTangents(c,s.outTangent.scale(h),l,a.inTangent.scale(h),d):this.quaternionInterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return _;case e.ANIMATIONLOOPMODE_RELATIVE:return _.addInPlace(i.offsetValue.scale(i.repeatCount))}return _;case e.ANIMATIONTYPE_VECTOR3:var m=u?this.vector3InterpolateFunctionWithTangents(c,s.outTangent.scale(h),l,a.inTangent.scale(h),d):this.vector3InterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return m;case e.ANIMATIONLOOPMODE_RELATIVE:return m.add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_VECTOR2:var g=u?this.vector2InterpolateFunctionWithTangents(c,s.outTangent.scale(h),l,a.inTangent.scale(h),d):this.vector2InterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return g;case e.ANIMATIONLOOPMODE_RELATIVE:return g.add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_SIZE:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,l,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,l,d).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_COLOR3:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,l,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,l,d).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_COLOR4:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color4InterpolateFunction(c,l,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color4InterpolateFunction(c,l,d).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_MATRIX:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:if(e.AllowMatricesInterpolation)return this.matrixInterpolateFunction(c,l,d,i.workValue);case e.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(n[n.length-1].value)},e.prototype.matrixInterpolateFunction=function(t,i,n,r){return e.AllowMatrixDecomposeForInterpolation?r?(a.a.DecomposeLerpToRef(t,i,n,r),r):a.a.DecomposeLerp(t,i,n):r?(a.a.LerpToRef(t,i,n,r),r):a.a.Lerp(t,i,n)},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 i in t._ranges={},this._ranges){var n=this._ranges[i];n&&(t._ranges[i]=n.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 i=this.dataType;t.keys=[];for(var n=this.getKeys(),r=0;r=1&&(l=h.values[1]),h.values.length>=2&&(u=h.values[2]);break;case e.ANIMATIONTYPE_QUATERNION:if(i=a.b.FromArray(h.values),h.values.length>=8){var d=a.b.FromArray(h.values.slice(4,8));d.equals(a.b.Zero())||(l=d)}if(h.values.length>=12){var f=a.b.FromArray(h.values.slice(8,12));f.equals(a.b.Zero())||(u=f)}break;case e.ANIMATIONTYPE_MATRIX:i=a.a.FromArray(h.values);break;case e.ANIMATIONTYPE_COLOR3:i=s.a.FromArray(h.values);break;case e.ANIMATIONTYPE_COLOR4:i=s.b.FromArray(h.values);break;case e.ANIMATIONTYPE_VECTOR3:default:i=a.e.FromArray(h.values)}var p={};p.frame=h.frame,p.value=i,null!=l&&(p.inTangent=l),null!=u&&(p.outTangent=u),c.push(p)}if(r.setKeys(c),t.ranges)for(n=0;n0&&h.forEach((function(e){r._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:!1,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._currentActiveTarget},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAdditive",{get:function(){return this._host&&this._host.isAdditive},enumerable:!1,configurable:!0}),e.prototype._preparePath=function(e,t){void 0===t&&(t=0);var i=this._animation.targetPropertyPath;if(i.length>1){for(var n=e[i[0]],r=1;r-1&&this._animation.runtimeAnimations.splice(e,1)},e.prototype.setValue=function(e,t){if(this._targetIsArray)for(var i=0;it[t.length-1].frame&&(e=t[t.length-1].frame);var i=this._events;if(i.length)for(var n=0;nthis._maxFrame)&&(t=this._minFrame),(ithis._maxFrame)&&(i=this._maxFrame);var l,u,h=i-t,d=e*(a.framePerSecond*r)/1e3+this._ratioOffset,f=0;if(this._previousDelay=e,this._previousRatio=d,!n&&i>=t&&d>=h)c=!1,f=a._getKeyValue(this._maxValue);else if(!n&&t>=i&&d<=h)c=!1,f=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==z.ANIMATIONLOOPMODE_CYCLE){var p=i.toString()+t.toString();if(!this._offsetsCache[p]){this._animationState.repeatCount=0,this._animationState.loopMode=z.ANIMATIONLOOPMODE_CYCLE;var _=a._interpolate(t,this._animationState),m=a._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case z.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=m-_;break;case z.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=m.subtract(_);break;case z.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=m.subtract(_);case z.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=m.subtract(_);case z.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=m.subtract(_);case z.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=m.subtract(_)}this._highLimitsCache[p]=m}f=this._highLimitsCache[p],l=this._offsetsCache[p]}if(void 0===l)switch(a.dataType){case z.ANIMATIONTYPE_FLOAT:l=0;break;case z.ANIMATIONTYPE_QUATERNION:l=j;break;case z.ANIMATIONTYPE_VECTOR3:l=W;break;case z.ANIMATIONTYPE_VECTOR2:l=H;break;case z.ANIMATIONTYPE_SIZE:l=X;break;case z.ANIMATIONTYPE_COLOR3:l=Y}if(this._host&&this._host.syncRoot){var g=this._host.syncRoot;u=t+(i-t)*((g.masterFrame-g.fromFrame)/(g.toFrame-g.fromFrame))}else u=c&&0!==h?t+d%h:i;var v=this._events;if((h>0&&this.currentFrame>u||h<0&&this.currentFrame>0,this._animationState.highLimitValue=f,this._animationState.offsetValue=l;var y=a._interpolate(u,this._animationState);if(this.setValue(y,o),v.length)for(b=0;b0&&u>=v[b].frame&&v[b].frame>=t||h<0&&u<=v[b].frame&&v[b].frame<=t){var T=v[b];T.isDone||(T.onlyOnce&&(v.splice(b,1),b--),T.isDone=!0,T.action(u))}return c||(this._stopped=!0),c},e}(),Q=i(20),q=i(57),Z=i(44),J=i(23),$=function(e){function t(t,i,n,r,o,s,c){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=null);var l=e.call(this,t,i.getScene())||this;return l.name=t,l.children=new Array,l.animations=new Array,l._index=null,l._absoluteTransform=new a.a,l._invertedAbsoluteTransform=new a.a,l._scalingDeterminant=1,l._worldTransform=new a.a,l._needToDecompose=!0,l._needToCompose=!1,l._linkedTransformNode=null,l._waitingTransformNodeId=null,l._skeleton=i,l._localMatrix=r?r.clone():a.a.Identity(),l._restPose=o||l._localMatrix.clone(),l._bindPose=l._localMatrix.clone(),l._baseMatrix=s||l._localMatrix.clone(),l._index=c,i.bones.push(l),l.setParent(n,!1),(s||r)&&l._updateDifferenceMatrix(),l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"_matrix",{get:function(){return this._compose(),this._localMatrix},set:function(e){this._localMatrix.copyFrom(e),this._needToDecompose=!0},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"Bone"},t.prototype.getSkeleton=function(){return this._skeleton},t.prototype.getParent=function(){return this._parent},t.prototype.getChildren=function(){return this.children},t.prototype.getIndex=function(){return null===this._index?this.getSkeleton().bones.indexOf(this):this._index},t.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i,1)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix(),this.markAsDirty()}},t.prototype.getLocalMatrix=function(){return this._compose(),this._localMatrix},t.prototype.getBaseMatrix=function(){return this._baseMatrix},t.prototype.getRestPose=function(){return this._restPose},t.prototype.setRestPose=function(e){this._restPose.copyFrom(e)},t.prototype.getBindPose=function(){return this._bindPose},t.prototype.setBindPose=function(e){this._bindPose.copyFrom(e)},t.prototype.getWorldMatrix=function(){return this._worldTransform},t.prototype.returnToRest=function(){this._skeleton._numBonesWithLinkedTransformNode>0?this.updateMatrix(this._restPose,!1,!1):this.updateMatrix(this._restPose,!1,!0)},t.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},t.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},t.prototype.linkTransformNode=function(e){this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode--,this._linkedTransformNode=e,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode++},t.prototype.getTransformNode=function(){return this._linkedTransformNode},Object.defineProperty(t.prototype,"position",{get:function(){return this._decompose(),this._localPosition},set:function(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationQuaternion",{get:function(){return this._decompose(),this._localRotation},set:function(e){this.setRotationQuaternion(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animationPropertiesOverride",{get:function(){return this._skeleton.animationPropertiesOverride},enumerable:!1,configurable:!0}),t.prototype._decompose=function(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=a.e.Zero(),this._localRotation=a.b.Zero(),this._localPosition=a.e.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))},t.prototype._compose=function(){this._needToCompose&&(this._localScaling?(this._needToCompose=!1,a.a.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix)):this._needToCompose=!1)},t.prototype.updateMatrix=function(e,t,i){void 0===t&&(t=!0),void 0===i&&(i=!0),this._baseMatrix.copyFrom(e),t&&this._updateDifferenceMatrix(),i?(this._needToCompose=!1,this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose()):this.markAsDirty()},t.prototype._updateDifferenceMatrix=function(e,t){if(void 0===t&&(t=!0),e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),t)for(var i=0;i-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 i=this,n=0;n-1){for(var n=(o=this._runtimeAnimations).length-1;n>=0;n--){var r=o[n];e&&r.animation.name!=e||(t&&!t(r.target)||(r.dispose(),o.splice(n,1)))}0==o.length&&(this._scene._activeAnimatables.splice(i,1),this._raiseOnAnimationEnd())}}else{if((n=this._scene._activeAnimatables.indexOf(this))>-1){this._scene._activeAnimatables.splice(n,1);var o=this._runtimeAnimations;for(n=0;n0)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 i=this._animationTime,n=0;ni&&r>0&&(r*=-1),s&&this.stopAnimation(e,void 0,c),a||(a=new ee(this,e,t,i,n,r,o,void 0,l,u));var h=!c||c(e);if(e.animations&&h&&a.appendAnimations(e,e.animations),e.getAnimatables)for(var d=e.getAnimatables(),f=0;fn&&o>0&&(o*=-1),new ee(this,e,i,n,r,o,a,t,s,c)},Q.a.prototype.beginDirectHierarchyAnimation=function(e,t,i,n,r,o,a,s,c,l){void 0===l&&(l=!1);var u=e.getDescendants(t),h=[];h.push(this.beginDirectAnimation(e,i,n,r,o,a,s,c,l));for(var d=0,f=u;d0)r.copyFrom(n);else if(1===e.animations.length){if(a.b.SlerpToRef(n,i.currentValue,Math.min(1,e.totalWeight),r),0===e.totalAdditiveWeight)return r}else if(e.animations.length>1){var o=1,s=void 0,c=void 0;if(e.totalWeight<1){var l=1-e.totalWeight;c=[],(s=[]).push(n),c.push(l)}else{if(2===e.animations.length&&(a.b.SlerpToRef(e.animations[0].currentValue,e.animations[1].currentValue,e.animations[1].weight/e.totalWeight,t),0===e.totalAdditiveWeight))return t;s=[],c=[],o=e.totalWeight}for(var u=0;u=l&&a.frame<=u&&(n?(c=a.value.clone(),_?(s=c.getTranslation(),c.setTranslation(s.scaleInPlace(m))):g&&r?(s=c.getTranslation(),c.setTranslation(s.multiplyInPlace(r))):c=a.value):c=a.value,v.push({frame:a.frame+i,value:c}));return this.animations[0].createRange(t,l+i,u+i),!0};var te=function(){function e(){}return e.prototype.getClassName=function(){return"TargetedAnimation"},e.prototype.serialize=function(){var e={};return e.animation=this.animation.serialize(),e.targetId=this.target.id,e},e}(),ie=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._isAdditive=!1,this.onAnimationEndObservable=new o.c,this.onAnimationLoopObservable=new o.c,this.onAnimationGroupLoopObservable=new o.c,this.onAnimationGroupEndObservable=new o.c,this.onAnimationGroupPauseObservable=new o.c,this.onAnimationGroupPlayObservable=new o.c,this._scene=t||x.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.addAnimationGroup(this)}return Object.defineProperty(e.prototype,"from",{get:function(){return this._from},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"to",{get:function(){return this._to},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPlaying",{get:function(){return this._isStarted&&!this._isPaused},enumerable:!1,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;tn[0].frame&&(this._from=n[0].frame),this._toe){var a={frame:e,value:r.value,inTangent:r.inTangent,outTangent:r.outTangent,interpolation:r.interpolation};n.splice(0,0,a)}if(o.framen&&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,i){for(var n=new e(t||this.name,this._scene),r=0,o=this._targetedAnimations;r=.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}(),ae=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(oe),se=function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return Object(h.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}(oe),ce=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var n=e.call(this)||this;return n.bounces=t,n.bounciness=i,n}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var n=Math.pow(i,t),r=1-i,o=(1-n)/r+.5*n,a=e*o,s=Math.log(-a*(1-i)+1)/Math.log(i),c=Math.floor(s),l=c+1,u=(1-Math.pow(i,c))/(r*o),h=.5*(u+(1-Math.pow(i,l))/(r*o)),d=e-h,f=h-u;return-Math.pow(1/i,t-c)/(f*f)*(d-f)*(d+f)},t}(oe),le=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e},t}(oe),ue=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var n=e.call(this)||this;return n.oscillations=t,n.springiness=i,n}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t}(oe),he=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return Object(h.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}(oe),de=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(oe),fe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e},t}(oe),pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t}(oe),_e=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(oe),me=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(oe),ge=function(e){function t(t,i,n,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=1);var o=e.call(this)||this;return o.x1=t,o.y1=i,o.x2=n,o.y2=r,o}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return re.c.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(oe),ve=function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e.prototype._clone=function(){return new e(this.frame,this.action,this.onlyOnce)},e}(),be=i(7),ye=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t}(n.a),Te=function(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]},Ee=function(e){function t(t){var i=e.call(this)||this;return i._wasAddedToScene=!1,i.scene=t,i.sounds=[],i.effectLayers=[],i.layers=[],i.lensFlareSystems=[],i.proceduralTextures=[],i.reflectionProbes=[],t.onDisposeObservable.add((function(){i._wasAddedToScene||i.dispose()})),i}return Object(h.d)(t,e),t.prototype.instantiateModelsToScene=function(e,t){var i=this;void 0===t&&(t=!1);var n={},r={},o=new Te,a=[],s=[],c={doNotInstantiate:!0},l=function(t,i){if(n[t.uniqueId]=i.uniqueId,r[i.uniqueId]=i,e&&(i.name=e(t.name)),i instanceof be.a){var o=i;if(o.morphTargetManager){var a=t.morphTargetManager;o.morphTargetManager=a.clone();for(var s=0;s-1&&t.animations.splice(o,1)}},r=0,o=e.animations;r0&&(_=!0,this._soundLoaded(i));break;case"String":p.push(i);case"Array":0===p.length&&(p=i);for(var g=0;g0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if(Se.a.audioEngine.audioContext&&this._soundSource){var i=e?Se.a.audioEngine.audioContext.currentTime+e:Se.a.audioEngine.audioContext.currentTime;this._soundSource.stop(i),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():Se.a.audioEngine.audioContext&&(this.stop(0),this._startOffset+=Se.a.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){Se.a.audioEngine.canUseWebAudio&&this._soundGain&&(t&&Se.a.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(Se.a.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,Se.a.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,Se.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(this._positionInEmitterSpace)e.worldMatrixFromCache.invertToRef(a.c.Matrix[0]),this.setPosition(a.c.Matrix[0].getTranslation());else if(e.getBoundingInfo){var t=e.getBoundingInfo();this.setPosition(t.boundingSphere.centerWorld)}else this.setPosition(e.absolutePosition);Se.a.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},e.prototype.clone=function(){var t=this;if(this._streaming)return null;var i=function(){t._isReadyToPlay?(r._audioBuffer=t.getAudioBuffer(),r._isReadyToPlay=!0,r.autoplay&&r.play(0,t._offset,t._length)):window.setTimeout(i,300)},n={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},r=new e(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,n);return this.useCustomAttenuation&&r.setAttenuationFunction(this._customAttenuationFunction),r.setPosition(this._position),r.setPlaybackRate(this._playbackRate),i(),r},e.prototype.getAudioBuffer=function(){return this._audioBuffer},e.prototype.getSoundSource=function(){return this._soundSource},e.prototype.getSoundGain=function(){return this._soundGain},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,metadata:this.metadata};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,i,n,r){var o,s=t.name;o=t.url?n+t.url:n+s;var c,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(r){var u=function(){r._isReadyToPlay?(c._audioBuffer=r.getAudioBuffer(),c._isReadyToPlay=!0,c.autoplay&&c.play(0,c._offset,c._length)):window.setTimeout(u,300)};c=new e(s,new ArrayBuffer(0),i,null,l),u()}else c=new e(s,o,i,(function(){i._removePendingData(c)}),l),i._addPendingData(c);if(t.position){var h=a.e.FromArray(t.position);c.setPosition(h)}if(t.isDirectional&&(c.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var d=a.e.FromArray(t.localDirectionToMesh);c.setLocalDirectionToMesh(d)}if(t.connectedMeshId){var f=i.getMeshByID(t.connectedMeshId);f&&c.attachToMesh(f)}return t.metadata&&(c.metadata=t.metadata),c},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport("AudioSceneComponent")},e}(),Oe=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(){Se.a.audioEngine.canUseWebAudio&&Se.a.audioEngine.audioContext&&(this._outputAudioNode=Se.a.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(Se.a.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},e.prototype.dispose=function(){if(Se.a.audioEngine&&Se.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(),Se.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){Se.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){if(Se.a.audioEngine.canUseWebAudio)for(var e=0;e0?i.activeCameras[0]:i.activeCamera){this._cachedCameraPosition.equals(o.globalPosition)||(this._cachedCameraPosition.copyFrom(o.globalPosition),n.audioContext.listener.setPosition(o.globalPosition.x,o.globalPosition.y,o.globalPosition.z)),o.rigCameras&&o.rigCameras.length>0&&(o=o.rigCameras[0]);var s=a.a.Invert(o.getViewMatrix()),c=a.e.TransformNormal(i.useRightHandedSystem?e._CameraDirectionRH:e._CameraDirectionLH,s);c.normalize(),isNaN(c.x)||isNaN(c.y)||isNaN(c.z)||this._cachedCameraDirection.equals(c)||(this._cachedCameraDirection.copyFrom(c),n.audioContext.listener.setOrientation(c.x,c.y,c.z,0,1,0))}else n.audioContext.listener.setPosition(0,0,0)}var l;for(l=0;l0?1/r:0,c=0;c0},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e;var i=this._attachedCamera.getScene();this._onPrePointerObservableObserver=i.onPrePointerObservable.add((function(e){e.type!==Ne.a.POINTERDOWN?e.type===Ne.a.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){var e=q.a.Now,i=0;null!=t._lastFrameTime&&(i=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var n=e-t._lastInteractionTime-t._idleRotationWaitTime,r=Math.max(Math.min(n/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*r,t._attachedCamera&&(t._attachedCamera.alpha-=t._cameraRotationSpeed*(i/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=q.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}(),we=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:!1,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 i=this._attachedCamera;i&&(e?this._onMeshTargetChangedObserver=i.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var i=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*i,t.upperRadiusTransitionRange=.05*i}})):this._onMeshTargetChangedObserver&&i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!1,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 i=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=z.CreateAnimation("radius",z.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 n=z.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return i._clearAnimationLocks()}));n&&this._animatables.push(n)}},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 se(.3),e.EasingMode=oe.EASINGMODE_EASEOUT,e}(),Fe=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:!1,configurable:!0}),Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var i=this;this._attachedCamera=t;var n=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=n.onPrePointerObservable.add((function(e){e.type!==Ne.a.POINTERDOWN?e.type===Ne.a.POINTERUP&&(i._isPointerDown=!1):i._isPointerDown=!0})),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){e&&i.zoomOnMesh(e)})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){i._applyUserInteraction(),i._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,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var n=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(n.minimumWorld,n.maximumWorld,t,i)},e.prototype.zoomOnMeshHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var n=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(n.min,n.max,t,i)},e.prototype.zoomOnMeshesHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null);for(var n=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new a.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o=0;ol.upperRadiusLimit?l.upperRadiusLimit:c),c):0},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var i=q.a.Now-this._lastInteractionTime,n=.5*Math.PI-this._defaultElevation,r=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>r&&i>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=z.CreateAnimation("beta",z.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=z.TransitionTo("beta",n,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 a.d.Zero();var t=e.getScene().getEngine().getAspectRatio(e),i=Math.tan(e.fov/2),n=i*t;return new a.d(n,i)},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=q.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:!1,configurable:!0}),e.EasingFunction=new he,e.EasingMode=oe.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),Be=function(e,t,i,n){void 0===t&&(t=new a.e),void 0===i&&(i=0),void 0===n&&(n=!1),this.direction=e,this.rotatedDirection=t,this.diff=i,this.ignore=n},Ue=function(){function e(e){this.ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new Be(a.e.Up()),new Be(a.e.Down()),new Be(a.e.Left()),new Be(a.e.Right()),new Be(a.e.Forward()),new Be(a.e.Forward().scaleInPlace(-1))],this._tmpMatrix=new a.a,this._tmpVector=new a.e,this._zeroVector=a.e.Zero(),this._lookAtTmpMatrix=new a.a}return e.prototype.init=function(){},e.prototype._closestFace=function(e){var t=this;return this._faceVectors.forEach((function(i){t._target.rotationQuaternion||(t._target.rotationQuaternion=a.b.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),a.e.TransformCoordinatesToRef(i.direction,t._tmpMatrix,i.rotatedDirection),i.diff=a.e.GetAngleBetweenVectors(i.rotatedDirection,e,a.e.Cross(i.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)}}}return Object.defineProperty(e.prototype,"name",{get:function(){return"FadeInOut"},enumerable:!1,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 i=this;e.visibility=t,e.getChildMeshes().forEach((function(e){i._setAllVisibility(e,t)}))},e}(),ke=i(65),ze=function(){function e(){this._startDistance=0,this._initialScale=new a.e(0,0,0),this._targetScale=new a.e(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new ke.a({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new ke.a({}),this._dragBehaviorB.moveAttached=!1}return Object.defineProperty(e.prototype,"name",{get:function(){return"MultiPointerScale"},enumerable:!1,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(i){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(i){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 i=t._targetScale.subtract(e.scaling).scaleInPlace(.1);i.length()>.01&&e.scaling.addInPlace(i)}}))},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)}))},e}(),Ge=i(31),je=i(24),We=i(60),He=function(){function e(){this._sceneRenderObserver=null,this._targetPosition=new a.e(0,0,0),this._moving=!1,this._startingOrientation=new a.b,this._attachedToElement=!1,this.zDragFactor=3,this.rotateDraggedObject=!0,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new o.c,this.onDragObservable=new o.c,this.onDragEndObservable=new o.c}return Object.defineProperty(e.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},Object.defineProperty(e.prototype,"_pointerCamera",{get:function(){return this._scene.cameraToUseForPointers?this._scene.cameraToUseForPointers:this._scene.activeCamera},enumerable:!1,configurable:!0}),e.prototype.attach=function(t){var i=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),e._virtualScene||(e._virtualScene=new Q.a(this._scene.getEngine(),{virtual:!0}),e._virtualScene.detachControl(),this._scene.getEngine().scenes.pop());var n=null,r=new a.e(0,0,0);this._virtualOriginMesh=new Ge.a("",e._virtualScene),this._virtualOriginMesh.rotationQuaternion=new a.b,this._virtualDragMesh=new Ge.a("",e._virtualScene),this._virtualDragMesh.rotationQuaternion=new a.b;this._pointerObserver=this._scene.onPointerObservable.add((function(e,t){if(e.type==Ne.a.POINTERDOWN){if(!i.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.ray&&(u=e.pickInfo.pickedMesh,i._ownerNode==u||u.isDescendantOf(i._ownerNode))){i._pointerCamera&&i._pointerCamera.cameraRigMode==je.a.RIG_MODE_NONE&&e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),n=i._ownerNode,We.a._RemoveAndStorePivotPoint(n),r.copyFrom(e.pickInfo.ray.origin),i._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),i._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),i._virtualOriginMesh.removeChild(i._virtualDragMesh),n.computeWorldMatrix(),i._virtualDragMesh.position.copyFrom(n.absolutePosition),n.rotationQuaternion||(n.rotationQuaternion=a.b.RotationYawPitchRoll(n.rotation.y,n.rotation.x,n.rotation.z));var o=n.parent;n.setParent(null),i._virtualDragMesh.rotationQuaternion.copyFrom(n.rotationQuaternion),n.setParent(o),i._virtualOriginMesh.addChild(i._virtualDragMesh),i._targetPosition.copyFrom(i._virtualDragMesh.absolutePosition),i.dragging=!0,i.currentDraggingPointerID=e.event.pointerId,i.detachCameraControls&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._pointerCamera.inputs.attachedToElement?(i._pointerCamera.detachControl(),i._attachedToElement=!0):i._attachedToElement=!1),We.a._RestorePivotPoint(n),i.onDragStartObservable.notifyObservers({})}}else if(e.type==Ne.a.POINTERUP||e.type==Ne.a.POINTERDOUBLETAP)i.currentDraggingPointerID==e.event.pointerId&&(i.dragging=!1,i._moving=!1,i.currentDraggingPointerID=-1,n=null,i._virtualOriginMesh.removeChild(i._virtualDragMesh),i.detachCameraControls&&i._attachedToElement&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._pointerCamera.attachControl(!0),i._attachedToElement=!1),i.onDragEndObservable.notifyObservers({}));else if(e.type==Ne.a.POINTERMOVE&&i.currentDraggingPointerID==e.event.pointerId&&i.dragging&&e.pickInfo&&e.pickInfo.ray&&n){var s=i.zDragFactor;i._pointerCamera&&i._pointerCamera.cameraRigMode==je.a.RIG_MODE_NONE&&(e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),s=0);var c=e.pickInfo.ray.origin.subtract(r);r.copyFrom(e.pickInfo.ray.origin);var l=-a.e.Dot(c,e.pickInfo.ray.direction);i._virtualOriginMesh.addChild(i._virtualDragMesh),i._virtualDragMesh.position.z-=i._virtualDragMesh.position.z<1?l*i.zDragFactor:l*s*i._virtualDragMesh.position.z,i._virtualDragMesh.position.z<0&&(i._virtualDragMesh.position.z=0),i._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),i._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),i._virtualOriginMesh.removeChild(i._virtualDragMesh),i._targetPosition.copyFrom(i._virtualDragMesh.absolutePosition),n.parent&&a.e.TransformCoordinatesToRef(i._targetPosition,a.a.Invert(n.parent.getWorldMatrix()),i._targetPosition),i._moving||i._startingOrientation.copyFrom(i._virtualDragMesh.rotationQuaternion),i._moving=!0}var u}));var o=new a.b;this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(i.dragging&&i._moving&&n){if(We.a._RemoveAndStorePivotPoint(n),n.position.addInPlace(i._targetPosition.subtract(n.position).scale(i.dragDeltaRatio)),i.rotateDraggedObject){o.copyFrom(i._startingOrientation),o.x=-o.x,o.y=-o.y,o.z=-o.z,i._virtualDragMesh.rotationQuaternion.multiplyToRef(o,o),a.b.RotationYawPitchRollToRef(o.toEulerAngles("xyz").y,0,0,o),o.multiplyToRef(i._startingOrientation,o);var e=n.parent;(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&(n.setParent(null),a.b.SlerpToRef(n.rotationQuaternion,o,i.dragDeltaRatio,n.rotationQuaternion),n.setParent(e))}We.a._RestorePivotPoint(n),i.onDragObservable.notifyObservers()}}))},e.prototype.detach=function(){this._scene&&(this.detachCameraControls&&this._attachedToElement&&this._pointerCamera&&!this._pointerCamera.leftCamera&&(this._pointerCamera.attachControl(!0),this._attachedToElement=!1),this._scene.onPointerObservable.remove(this._pointerObserver)),this._ownerNode&&this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),this._virtualOriginMesh&&this._virtualOriginMesh.dispose(),this._virtualDragMesh&&this._virtualDragMesh.dispose(),this.onDragEndObservable.clear(),this.onDragObservable.clear(),this.onDragStartObservable.clear()},e}(),Xe=function(){function e(e,t,i){if(this.targetPosition=a.e.Zero(),this.poleTargetPosition=a.e.Zero(),this.poleTargetLocalOffset=a.e.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=a.b.Identity(),this._bone1Mat=a.a.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=a.e.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=t,this._bone1=t.getParent(),this._bone1){this.mesh=e;var n=t.getPosition();if(t.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var r=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*r.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 s=this._bone2.children[0].getAbsolutePosition(e),c=this._bone2.getAbsolutePosition(e),l=this._bone1.getAbsolutePosition(e);this._bone1Length=a.e.Distance(s,c),this._bone2Length=a.e.Distance(c,l)}this._bone1.getRotationMatrixToRef(J.c.WORLD,e,this._bone1Mat),this.maxAngle=Math.PI,i&&(i.targetMesh&&(this.targetMesh=i.targetMesh,this.targetMesh.computeWorldMatrix(!0)),i.poleTargetMesh?(this.poleTargetMesh=i.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):i.poleTargetBone?this.poleTargetBone=i.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),i.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(i.poleTargetLocalOffset),i.poleAngle&&(this.poleAngle=i.poleAngle),i.bendAxis&&this._bendAxis.copyFrom(i.bendAxis),i.maxAngle&&(this.maxAngle=i.maxAngle),i.slerpAmount&&(this.slerpAmount=i.slerpAmount))}}return Object.defineProperty(e.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!1,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,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},e.prototype.update=function(){var t=this._bone1;if(t){var i=this.targetPosition,n=this.poleTargetPosition,r=e._tmpMats[0],o=e._tmpMats[1];this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&a.e.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var s=e._tmpVecs[0],c=e._tmpVecs[1],l=e._tmpVecs[2],u=e._tmpVecs[3],h=e._tmpVecs[4],d=e._tmpQuat;t.getAbsolutePositionToRef(this.mesh,s),n.subtractToRef(s,h),0==h.x&&0==h.y&&0==h.z?h.y=1:h.normalize(),i.subtractToRef(s,u),u.normalize(),a.e.CrossToRef(u,h,c),c.normalize(),a.e.CrossToRef(u,c,l),l.normalize(),a.a.FromXYZAxesToRef(l,u,c,r);var f=this._bone1Length,p=this._bone2Length,_=a.e.Distance(s,i);this._maxReach>0&&(_=Math.min(this._maxReach,_));var m=(p*p+_*_-f*f)/(2*p*_),g=(_*_+f*f-p*p)/(2*_*f);m>1&&(m=1),g>1&&(g=1),m<-1&&(m=-1),g<-1&&(g=-1);var v=Math.acos(m),b=Math.acos(g),y=-v-b;if(this._rightHandedSystem)a.a.RotationYawPitchRollToRef(0,0,this._adjustRoll,o),o.multiplyToRef(r,r),a.a.RotationAxisToRef(this._bendAxis,b,o),o.multiplyToRef(r,r);else{var T=e._tmpVecs[5];T.copyFrom(this._bendAxis),T.x*=-1,a.a.RotationAxisToRef(T,-b,o),o.multiplyToRef(r,r)}this.poleAngle&&(a.a.RotationAxisToRef(u,this.poleAngle,o),r.multiplyToRef(o,r)),this._bone1&&(this.slerpAmount<1?(this._slerping||a.b.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),a.b.FromRotationMatrixToRef(r,d),a.b.SlerpToRef(this._bone1Quat,d,this.slerpAmount,this._bone1Quat),y=this._bone2Ang*(1-this.slerpAmount)+y*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,J.c.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(r,J.c.WORLD,this.mesh),this._bone1Mat.copyFrom(r),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,y,J.c.LOCAL),this._bone2Ang=y}},e._tmpVecs=[a.e.Zero(),a.e.Zero(),a.e.Zero(),a.e.Zero(),a.e.Zero(),a.e.Zero()],e._tmpQuat=a.b.Identity(),e._tmpMats=[a.a.Identity(),a.a.Identity()],e}(),Ye=function(){function e(e,t,i,n){if(this.upAxis=a.e.Up(),this.upAxisSpace=J.c.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=a.b.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=a.e.Forward(),this.mesh=e,this.bone=t,this.target=i,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var r=J.a.Y,o=J.a.X;null!=n.yawAxis&&(r=n.yawAxis.clone()).normalize(),null!=n.pitchAxis&&(o=n.pitchAxis.clone()).normalize();var s=a.e.Cross(o,r);this._transformYawPitch=a.a.Identity(),a.a.FromXYZAxesToRef(o,r,s,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}t.getParent()||this.upAxisSpace!=J.c.BONE||(this.upAxisSpace=J.c.LOCAL)}return 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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!1,configurable:!0}),e.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var t=this.bone,i=e._tmpVecs[0];t.getAbsolutePositionToRef(this.mesh,i);var n=this.target,r=e._tmpMats[0],o=e._tmpMats[1],s=this.mesh,c=t.getParent(),l=e._tmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==J.c.BONE&&c?(this._transformYawPitch&&a.e.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),c.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==J.c.LOCAL&&(s.getDirectionToRef(l,l),1==s.scaling.x&&1==s.scaling.y&&1==s.scaling.z||l.normalize());var u=!1,h=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(u=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(h=!0),u||h){var d=e._tmpMats[2],f=e._tmpMats[3];if(this.upAxisSpace==J.c.BONE&&1==l.y&&c)c.getRotationMatrixToRef(J.c.WORLD,this.mesh,d);else if(this.upAxisSpace!=J.c.LOCAL||1!=l.y||c){(_=e._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&a.e.TransformCoordinatesToRef(_,this._transformYawPitchInv,_),c?c.getDirectionToRef(_,this.mesh,_):s.getDirectionToRef(_,_);var p=a.e.Cross(l,_);p.normalize();var _=a.e.Cross(p,l);a.a.FromXYZAxesToRef(p,l,_,d)}else d.copyFrom(s.getWorldMatrix());d.invertToRef(f);var m=null;if(h){var g=e._tmpVecs[3];n.subtractToRef(i,g),a.e.TransformCoordinatesToRef(g,f,g),m=Math.sqrt(g.x*g.x+g.z*g.z);var v=Math.atan2(g.y,m),b=v;v>this._maxPitch?(g.y=this._maxPitchTan*m,b=this._maxPitch):vthis._maxYaw||yMath.PI?this._isAngleBetween(y,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,T=this._maxYaw):this._isAngleBetween(y,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*m,g.x=this._minYawSin*m,T=this._minYaw):y>this._maxYaw?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,T=this._maxYaw):yMath.PI){var E=e._tmpVecs[8];E.copyFrom(J.a.Z),this._transformYawPitch&&a.e.TransformCoordinatesToRef(E,this._transformYawPitchInv,E);var S=e._tmpMats[4];this._boneQuat.toRotationMatrix(S),this.mesh.getWorldMatrix().multiplyToRef(S,S),a.e.TransformCoordinatesToRef(E,S,E),a.e.TransformCoordinatesToRef(E,f,E);var A=Math.atan2(E.x,E.z);if(this._getAngleBetween(A,y)>this._getAngleBetween(A,this._midYawConstraint)){null==m&&(m=Math.sqrt(g.x*g.x+g.z*g.z));var P=this._getAngleBetween(A,this._maxYaw);this._getAngleBetween(A,this._minYaw)Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},e.prototype._getAngleBetween=function(e,t){var i=0;return(i=(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&&(i=2*Math.PI-i),i},e.prototype._isAngleBetween=function(e,t,i){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(i=(i%=2*Math.PI)<0?i+2*Math.PI:i)){if(e>t&&ei&&e>v,y=0;y<6;y++){var T=g[v][y];m&&(T=Ze(T,b,b,r)),f.texImage2D(y,v,_,b,b,0,u,l,T)}d._bindTextureDirectly(f.TEXTURE_CUBE_MAP,null)}else d.updateRawCubeTexture(p,o,n,r,h);p.isReady=!0,null==t||t._removePendingData(p),c&&c()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,i){null==t||t._removePendingData(p),l&&e&&l(e.status+" "+e.statusText,i)})),p},qe.a.prototype.createRawTexture2DArray=Je(!1),qe.a.prototype.createRawTexture3D=Je(!0),qe.a.prototype.updateRawTexture2DArray=$e(!1),qe.a.prototype.updateRawTexture3D=$e(!0);var et=function(e){function t(t,i,n,r,o,a,s,c,l){void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===c&&(c=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=g.a.TEXTURETYPE_UNSIGNED_INT);var u=e.call(this,null,o,!a,s)||this;return u.format=r,u._engine?(u._texture=u._engine.createRawTexture(t,i,n,r,a,s,c,null,l),u.wrapU=Ke.a.CLAMP_ADDRESSMODE,u.wrapV=Ke.a.CLAMP_ADDRESSMODE,u):u}return Object(h.d)(t,e),t.prototype.update=function(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t.CreateLuminanceTexture=function(e,i,n,r,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,g.a.TEXTUREFORMAT_LUMINANCE,r,o,a,s)},t.CreateLuminanceAlphaTexture=function(e,i,n,r,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,g.a.TEXTUREFORMAT_LUMINANCE_ALPHA,r,o,a,s)},t.CreateAlphaTexture=function(e,i,n,r,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,g.a.TEXTUREFORMAT_ALPHA,r,o,a,s)},t.CreateRGBTexture=function(e,i,n,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),new t(e,i,n,g.a.TEXTUREFORMAT_RGB,r,o,a,s,c)},t.CreateRGBATexture=function(e,i,n,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),new t(e,i,n,g.a.TEXTUREFORMAT_RGBA,r,o,a,s,c)},t.CreateRTexture=function(e,i,n,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_FLOAT),new t(e,i,n,g.a.TEXTUREFORMAT_R,r,o,a,s,c)},t}(Ke.a),tt=function(){function e(e,t,i){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=a.a.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._waitingOverrideMeshId=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new o.c,this.bones=[],this._scene=i||x.a.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;var n=this._scene.getEngine().getCaps();this._canUseTextureForBones=n.textureFloat&&n.maxVertexTextureImageUnits>0}return Object.defineProperty(e.prototype,"useTextureToStoreBoneMatrices",{get:function(){return this._useTextureToStoreBoneMatrices},set:function(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTextureForMatrices",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,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 i=!0;for(var n in this._ranges)i&&(t+=", ",i=!1),t+=n;t+="}"}return t},e.prototype.getBoneIndexByName=function(e){for(var t=0,i=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)},e.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i0)for(var e=0,t=this.bones;e0&&(a.animation=r.animations[0].serialize()),i.ranges=[],this._ranges){var c=this._ranges[s];if(c){var l={};l.name=s,l.from=c.from,l.to=c.to,i.ranges.push(l)}}}return i},e.Parse=function(t,i){var n,r=new e(t.name,t.id,i);for(t.dimensionsAtRest&&(r.dimensionsAtRest=a.e.FromArray(t.dimensionsAtRest)),r.needInitialSkinMatrix=t.needInitialSkinMatrix,t.overrideMeshId&&(r._hasWaitingData=!0,r._waitingOverrideMeshId=t.overrideMeshId),n=0;n-1&&(c=r.bones[o.parentBoneIndex]);var l=o.rest?a.a.FromArray(o.rest):null,u=new $(o.name,r,c,a.a.FromArray(o.matrix),l,null,s);void 0!==o.id&&null!==o.id&&(u.id=o.id),o.length&&(u.length=o.length),o.metadata&&(u.metadata=o.metadata),o.animation&&u.animations.push(z.Parse(o.animation)),void 0!==o.linkedTransformNodeId&&null!==o.linkedTransformNodeId&&(r._hasWaitingData=!0,u._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(n=0;n0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},e.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),i=0;i=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:!1,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:!1,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:!1,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}(),at=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.onButtonDownObservable=new o.c,r.onButtonUpObservable=new o.c,r.type=ot.GENERIC,r._buttons=new Array(n.buttons.length),r}return Object(h.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,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var n=t.y/this.gamepadRotationSensibility*this._yAxisScale;0!=n&&Math.abs(n)>.005&&(e.inertialBetaOffset+=n)}}var r=this.gamepad.leftStick;if(r&&0!=r.y){var o=r.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(h.c)([Object(w.c)()],e.prototype,"gamepadRotationSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"gamepadMoveSensibility",void 0),e}();it.ArcRotateCameraGamepadInput=st;var ct=i(66),lt=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){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;r.metaKey||(i.type===ct.a.KEYDOWN?(t._ctrlPressed=r.ctrlKey,t._altPressed=r.altKey,(-1!==t.keysUp.indexOf(r.keyCode)||-1!==t.keysDown.indexOf(r.keyCode)||-1!==t.keysLeft.indexOf(r.keyCode)||-1!==t.keysRight.indexOf(r.keyCode)||-1!==t.keysReset.indexOf(r.keyCode))&&(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),r.preventDefault&&(e||r.preventDefault()))):-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysReset.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),r.preventDefault&&(e||r.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?i/(1+this.wheelDeltaPercentage):i*(1+this.wheelDeltaPercentage)},e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i,n){if(i.type===Ne.a.POINTERWHEEL){var r=i.event,o=0,a=r,s=0;if(s=a.wheelDelta?a.wheelDelta:60*-(r.deltaY||r.detail),t.wheelDeltaPercentage){if((o=t.computeDeltaFromMouseWheelLegacyEvent(s,t.camera.radius))>0){for(var c=t.camera.radius,l=t.camera.inertialRadiusOffset+o,u=0;u<20&&Math.abs(l)>.001;u++)c-=l,l*=t.camera.inertia;c=L.a.Clamp(c,0,Number.MAX_VALUE),o=t.computeDeltaFromMouseWheelLegacyEvent(s,c)}}else o=s/(40*t.wheelPrecision);o&&(t.camera.inertialRadiusOffset+=o),r.preventDefault&&(e||r.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Ne.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&(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(h.c)([Object(w.c)()],e.prototype,"wheelPrecision",void 0),Object(h.c)([Object(w.c)()],e.prototype,"wheelDeltaPercentage",void 0),e}();it.ArcRotateCameraMouseWheelInput=ut;var ht=function(){function e(){this.buttons=[0,1,2]}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments);var i=this.camera.getEngine(),n=i.getInputElement(),r=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 c=a.event,l="touch"===c.pointerType;if(!i.isInVRExclusivePointerMode&&(a.type===Ne.a.POINTERMOVE||-1!==t.buttons.indexOf(c.button))){var u=c.srcElement||c.target;if(t._altKey=c.altKey,t._ctrlKey=c.ctrlKey,t._metaKey=c.metaKey,t._shiftKey=c.shiftKey,t._buttonsPressed=c.buttons,i.isPointerLock){var h=c.movementX||c.mozMovementX||c.webkitMovementX||c.msMovementX||0,d=c.movementY||c.mozMovementY||c.webkitMovementY||c.msMovementY||0;t.onTouch(null,h,d),t.pointA=null,t.pointB=null}else if(a.type===Ne.a.POINTERDOWN&&u){try{u.setPointerCapture(c.pointerId)}catch(e){}null===t.pointA?t.pointA={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType}:null===t.pointB&&(t.pointB={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType}),t.onButtonDown(c),e||(c.preventDefault(),n&&n.focus())}else if(a.type===Ne.a.POINTERDOUBLETAP)t.onDoubleTap(c.pointerType);else if(a.type===Ne.a.POINTERUP&&u){try{u.releasePointerCapture(c.pointerId)}catch(e){}l||(t.pointB=null),i._badOS?t.pointA=t.pointB=null:t.pointB&&t.pointA&&t.pointA.pointerId==c.pointerId?(t.pointA=t.pointB,t.pointB=null):t.pointA&&t.pointB&&t.pointB.pointerId==c.pointerId?t.pointB=null:t.pointA=t.pointB=null,(0!==r||o)&&(t.onMultiTouch(t.pointA,t.pointB,r,0,o,null),r=0,o=null),t.onButtonUp(c),e||c.preventDefault()}else if(a.type===Ne.a.POINTERMOVE)if(e||c.preventDefault(),t.pointA&&null===t.pointB){h=c.clientX-t.pointA.x,d=c.clientY-t.pointA.y;t.onTouch(t.pointA,h,d),t.pointA.x=c.clientX,t.pointA.y=c.clientY}else if(t.pointA&&t.pointB){var f=t.pointA.pointerId===c.pointerId?t.pointA:t.pointB;f.x=c.clientX,f.y=c.clientY;var p=t.pointA.x-t.pointB.x,_=t.pointA.y-t.pointB.y,m=p*p+_*_,g={x:(t.pointA.x+t.pointB.x)/2,y:(t.pointA.y+t.pointB.y)/2,pointerId:c.pointerId,type:a.type};t.onMultiTouch(t.pointA,t.pointB,r,m,o,g),o=g,r=m}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Ne.a.POINTERDOWN|Ne.a.POINTERUP|Ne.a.POINTERMOVE),this._onLostFocus=function(){t.pointA=t.pointB=null,r=0,o=null,t.onLostFocus()},n&&n.addEventListener("contextmenu",this.onContextMenu.bind(this),!1);var a=this.camera.getScene().getEngine().getHostWindow();a&&Ce.b.RegisterTopRootEvents(a,[{name:"blur",handler:this._onLostFocus}])},e.prototype.detachControl=function(e){if(this._onLostFocus){var t=this.camera.getScene().getEngine().getHostWindow();t&&Ce.b.UnregisterTopRootEvents(t,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this.onContextMenu){var i=this.camera.getScene().getEngine().getInputElement();i&&i.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,i){},e.prototype.onMultiTouch=function(e,t,i,n,r,o){},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.onButtonDown=function(e){},e.prototype.onButtonUp=function(e){},e.prototype.onLostFocus=function(){},Object(h.c)([Object(w.c)()],e.prototype,"buttons",void 0),e}(),dt=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(h.d)(t,e),t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype.onTouch=function(e,t,i){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)},t.prototype.onDoubleTap=function(e){this.camera.useInputToRestoreState&&this.camera.restoreState()},t.prototype.onMultiTouch=function(e,t,i,n,r,o){if(!(0===i&&null===r||0===n&&null===o)){var a=this.pinchInwards?1:-1;if(this.multiTouchPanAndZoom){if(this.useNaturalPinchZoom?this.camera.radius=this.camera.radius*Math.sqrt(i)/Math.sqrt(n):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(n-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(n-i)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),0!==this.panningSensibility&&r&&o){var s=o.x-r.x,c=o.y-r.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=c/this.panningSensibility}}else{this._twoFingerActivityCount++;var l=Math.sqrt(i),u=Math.sqrt(n);if(this._isPinching||this._twoFingerActivityCount<20&&Math.abs(u-l)>this.camera.pinchToPanMaxDistance)this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(n-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(n-i)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),this._isPinching=!0;else if(0!==this.panningSensibility&&this.multiTouchPanning&&o&&r){s=o.x-r.x,c=o.y-r.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=c/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(h.c)([Object(w.c)()],t.prototype,"buttons",void 0),Object(h.c)([Object(w.c)()],t.prototype,"angularSensibilityX",void 0),Object(h.c)([Object(w.c)()],t.prototype,"angularSensibilityY",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchPrecision",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchDeltaPercentage",void 0),Object(h.c)([Object(w.c)()],t.prototype,"useNaturalPinchZoom",void 0),Object(h.c)([Object(w.c)()],t.prototype,"panningSensibility",void 0),Object(h.c)([Object(w.c)()],t.prototype,"multiTouchPanning",void 0),Object(h.c)([Object(w.c)()],t.prototype,"multiTouchPanAndZoom",void 0),t}(ht);it.ArcRotateCameraPointersInput=dt;var ft=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.addMouseWheel=function(){return this.add(new ut),this},t.prototype.addPointers=function(){return this.add(new dt),this},t.prototype.addKeyboard=function(){return this.add(new lt),this},t}(nt);ft.prototype.addVRDeviceOrientation=function(){return this.add(new pt),this};var pt=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){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.camera.attachControl(e);var i=this.camera.getScene().getEngine().getHostWindow();i&&("undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?i.addEventListener("deviceorientation",t._deviceOrientationHandler):Ce.b.Warn("Permission not granted.")})).catch((function(e){Ce.b.Error(e)})):i.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}();it.ArcRotateCameraVRDeviceOrientationInput=pt;var _t=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){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;i.type===ct.a.KEYDOWN?-1===t.keysForward.indexOf(r.keyCode)&&-1===t.keysBackward.indexOf(r.keyCode)&&-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)||(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),e||r.preventDefault()):-1===t.keysForward.indexOf(r.keyCode)&&-1===t.keysBackward.indexOf(r.keyCode)&&-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),e||r.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&&t._keys.splice(n,1),r.preventDefault&&(e||r.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(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetIncr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetDecr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetModifierAlt",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetModifierCtrl",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetModifierShift",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetIncr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetDecr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetModifierAlt",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetModifierCtrl",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetModifierShift",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusIncr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusDecr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusModifierAlt",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusModifierCtrl",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusModifierShift",void 0),Object(h.c)([Object(w.c)()],e.prototype,"heightSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"rotationSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"radiusSensibility",void 0),e}();it.FollowCameraKeyboardMoveInput=gt;var vt=function(){function e(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i,n){if(i.type===Ne.a.POINTERWHEEL){var r=i.event,o=0,a=Math.max(-1,Math.min(1,r.deltaY||r.wheelDelta||-r.detail));t.wheelDeltaPercentage?(console.assert(t.axisControlRadius+t.axisControlHeight+t.axisControlRotation<=1,"wheelDeltaPercentage only usable when mouse wheel controlls ONE axis. Currently enabled: axisControlRadius: "+t.axisControlRadius+", axisControlHeightOffset: "+t.axisControlHeight+", axisControlRotationOffset: "+t.axisControlRotation),t.axisControlRadius?o=.01*a*t.wheelDeltaPercentage*t.camera.radius:t.axisControlHeight?o=.01*a*t.wheelDeltaPercentage*t.camera.heightOffset:t.axisControlRotation&&(o=.01*a*t.wheelDeltaPercentage*t.camera.rotationOffset)):o=a*t.wheelPrecision,o&&(t.axisControlRadius?t.camera.radius+=o:t.axisControlHeight?t.camera.heightOffset-=o:t.axisControlRotation&&(t.camera.rotationOffset-=o)),r.preventDefault&&(e||r.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Ne.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&(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(h.c)([Object(w.c)()],e.prototype,"axisControlRadius",void 0),Object(h.c)([Object(w.c)()],e.prototype,"axisControlHeight",void 0),Object(h.c)([Object(w.c)()],e.prototype,"axisControlRotation",void 0),Object(h.c)([Object(w.c)()],e.prototype,"wheelPrecision",void 0),Object(h.c)([Object(w.c)()],e.prototype,"wheelDeltaPercentage",void 0),e}();it.FollowCameraMouseWheelInput=vt;var bt=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(h.d)(t,e),t.prototype.getClassName=function(){return"FollowCameraPointersInput"},t.prototype.onTouch=function(e,t,i){this._warning(),this.axisXControlRotation?this.camera.rotationOffset+=t/this.angularSensibilityX:this.axisYControlRotation&&(this.camera.rotationOffset+=i/this.angularSensibilityX),this.axisXControlHeight?this.camera.heightOffset+=t/this.angularSensibilityY:this.axisYControlHeight&&(this.camera.heightOffset+=i/this.angularSensibilityY),this.axisXControlRadius?this.camera.radius-=t/this.angularSensibilityY:this.axisYControlRadius&&(this.camera.radius-=i/this.angularSensibilityY)},t.prototype.onMultiTouch=function(e,t,i,n,r,o){if(!(0===i&&null===r||0===n&&null===o)){var a=(n-i)/(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(h.c)([Object(w.c)()],t.prototype,"angularSensibilityX",void 0),Object(h.c)([Object(w.c)()],t.prototype,"angularSensibilityY",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchPrecision",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchDeltaPercentage",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisXControlRadius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisXControlHeight",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisXControlRotation",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisYControlRadius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisYControlHeight",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisYControlRotation",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisPinchControlRadius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisPinchControlHeight",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisPinchControlRotation",void 0),t}(ht);it.FollowCameraPointersInput=bt;var yt=function(){function e(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;r.metaKey||(i.type===ct.a.KEYDOWN?-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysUpward.indexOf(r.keyCode)&&-1===t.keysDownward.indexOf(r.keyCode)||(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),e||r.preventDefault()):-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysUpward.indexOf(r.keyCode)&&-1===t.keysDownward.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),e||r.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(),i=new a.e(0,0,t*this._offsetY/this.touchMoveSensibility);a.a.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(a.e.TransformCoordinates(i,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},Object(h.c)([Object(w.c)()],e.prototype,"touchAngularSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"touchMoveSensibility",void 0),e}();it.FreeCameraTouchInput=Pt;var Ct=function(e){function t(t){var i=e.call(this,t)||this;return i._mouseInput=null,i._mouseWheelInput=null,i}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new yt),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this._mouseInput||(this._mouseInput=new Tt(e),this.add(this._mouseInput)),this},t.prototype.removeMouse=function(){return this._mouseInput&&this.remove(this._mouseInput),this},t.prototype.addMouseWheel=function(){return this._mouseWheelInput||(this._mouseWheelInput=new At,this.add(this._mouseWheelInput)),this},t.prototype.removeMouseWheel=function(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this},t.prototype.addTouch=function(){return this.add(new Pt),this},t.prototype.clear=function(){e.prototype.clear.call(this),this._mouseInput=null},t}(nt);Ct.prototype.addDeviceOrientation=function(){return this._deviceOrientationInput||(this._deviceOrientationInput=new Rt,this.add(this._deviceOrientationInput)),this};var Rt=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new a.b,this._alpha=0,this._beta=0,this._gamma=0,this._onDeviceOrientationChangedObservable=new o.c,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=-Ce.b.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 a.b(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return e.WaitForOrientationChangeAsync=function(e){return new Promise((function(t,i){var n=!1,r=function(){window.removeEventListener("deviceorientation",r),n=!0,t()};e&&setTimeout((function(){n||(window.removeEventListener("deviceorientation",r),i("WaitForOrientationChangeAsync timed out"))}),e),"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e?window.addEventListener("deviceorientation",r):Ce.b.Warn("Permission not granted.")})).catch((function(e){Ce.b.Error(e)})):window.addEventListener("deviceorientation",r)}))},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 a.b),this._camera&&this._camera.onDisposeObservable.add((function(){t._onDeviceOrientationChangedObservable.clear()}))},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().getEngine().getHostWindow();if(t){var i=function(){t.addEventListener("orientationchange",e._orientationChanged),t.addEventListener("deviceorientation",e._deviceOrientation),e._orientationChanged()};"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?i():Ce.b.Warn("Permission not granted.")})).catch((function(e){Ce.b.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&&(a.b.RotationYawPitchRollToRef(Ce.b.ToRadians(this._alpha),Ce.b.ToRadians(this._beta),-Ce.b.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},e.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"deviceOrientation"},e}();it.FreeCameraDeviceOrientationInput=Rt;var xt=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._yAxisScale=1,this._cameraTransform=a.a.Identity(),this._deltaTransform=a.e.Zero(),this._vector3=a.e.Zero(),this._vector2=a.d.Zero()}return Object.defineProperty(e.prototype,"invertYAxis",{get:function(){return 1!==this._yAxisScale},set:function(e){this._yAxisScale=e?-1:1},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=t.onGamepadConnectedObservable.add((function(t){t.type!==ot.POSE_ENABLED&&(e.gamepad&&t.type!==ot.XBOX||(e.gamepad=t))})),this._onGamepadDisconnectedObserver=t.onGamepadDisconnectedObservable.add((function(t){e.gamepad===t&&(e.gamepad=null)})),this.gamepad=t.getGamepadByType(ot.XBOX),!this.gamepad&&t.gamepads.length&&(this.gamepad=t.gamepads[0])},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,i=t.x/this.gamepadMoveSensibility,n=t.y/this.gamepadMoveSensibility;t.x=Math.abs(i)>.005?0+i:0,t.y=Math.abs(n)>.005?0+n:0;var r=this.gamepad.rightStick;if(r){var o=r.x/this.gamepadAngularSensibility,s=r.y/this.gamepadAngularSensibility*this._yAxisScale;r.x=Math.abs(o)>.001?0+o:0,r.y=Math.abs(s)>.001?0+s:0}else r={x:0,y:0};e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):a.a.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var c=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*c,0,-t.y*c),a.e.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(r.y,r.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},Object(h.c)([Object(w.c)()],e.prototype,"gamepadAngularSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"gamepadMoveSensibility",void 0),e}();it.FreeCameraGamepadInput=xt;var Ot,Mt=i(112);!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(Ot||(Ot={}));var It=function(){function e(t,i){var n=this,r=Object(h.a)(Object(h.a)({},e._GetDefaultOptions()),i);if(this._leftJoystick=!!t,e._globalJoystickIndex++,this._axisTargetedByLeftAndRight=Ot.X,this._axisTargetedByUpAndDown=Ot.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new Mt.a,this.deltaPosition=a.e.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.style.touchAction="none",e.Canvas.setAttribute("touch-action","none");var o=e.Canvas.getContext("2d");if(!o)throw new Error("Unable to create canvas for virtual joystick");e.vjCanvasContext=o,e.vjCanvasContext.strokeStyle="#ffffff",e.vjCanvasContext.lineWidth=2,document.body.appendChild(e.Canvas)}e.halfWidth=e.Canvas.width/2,this.pressed=!1,this.limitToContainer=r.limitToContainer,this._joystickColor=r.color,this.containerSize=r.containerSize,this.puckSize=r.puckSize,r.position&&this.setPosition(r.position.x,r.position.y),r.puckImage&&this.setPuckImage(r.puckImage),r.containerImage&&this.setContainerImage(r.containerImage),r.alwaysVisible&&e._alwaysVisibleSticks++,this.alwaysVisible=r.alwaysVisible,this._joystickPointerID=-1,this._joystickPointerPos=new a.d(0,0),this._joystickPreviousPointerPos=new a.d(0,0),this._joystickPointerStartPos=new a.d(0,0),this._deltaJoystickVector=new a.d(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._GetDefaultOptions=function(){return{puckSize:40,containerSize:60,color:"cyan",puckImage:void 0,containerImage:void 0,position:void 0,alwaysVisible:!1,limitToContainer:!1}},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._joystickPosition?(this._joystickPointerStartPos=this._joystickPosition.clone(),this._joystickPointerPos=this._joystickPosition.clone(),this._joystickPreviousPointerPos=this._joystickPosition.clone(),this._onPointerMove(t)):(this._joystickPointerStartPos.x=t.clientX,this._joystickPointerStartPos.y=t.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone()),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(t.pointerId.toString(),t)):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(t){if(this._joystickPointerID==t.pointerId){if(this.limitToContainer){var i=new a.d(t.clientX-this._joystickPointerStartPos.x,t.clientY-this._joystickPointerStartPos.y),n=i.length();n>this.containerSize&&i.scaleInPlace(this.containerSize/n),this._joystickPointerPos.x=this._joystickPointerStartPos.x+i.x,this._joystickPointerPos.y=this._joystickPointerStartPos.y+i.y}else this._joystickPointerPos.x=t.clientX,this._joystickPointerPos.y=t.clientY;this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos),0=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&&a.b.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},Object.defineProperty(t.prototype,"target",{get:function(){return this.getTarget()},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),t.prototype.getTarget=function(){return this._currentTarget},t.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(a.c.Matrix[0]),a.e.TransformNormalToRef(this.cameraDirection,a.c.Matrix[0],a.c.Vector3[0]),void this.position.addInPlace(a.c.Vector3[0]);this.position.addInPlace(this.cameraDirection)},t.prototype._checkInputs=function(){var t=this.invertRotation?-this.inverseRotationSpeed:1,i=this._decideIfNeedsToMove(),n=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),n){if(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this.rotation),this.rotation.x+=this.cameraRotation.x*t,this.rotation.y+=this.cameraRotation.y*t,!this.noRotationConstraint){this.rotation.x>1.570796&&(this.rotation.x=1.570796),this.rotation.x<-1.570796&&(this.rotation.x=-1.570796)}if(this.rotationQuaternion)this.rotation.lengthSquared()&&a.b.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}i&&(Math.abs(this.cameraDirection.x)Se.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&i&&o.onCollide(i))},o.inputs=new Ct(o),o.inputs.addKeyboard().addMouse(),o}return Object(h.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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUpward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUpward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUpward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDownward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDownward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDownward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!1,configurable:!0}),t.prototype.attachControl=function(e,t){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(e){this.inputs.detachElement(),this.cameraDirection=new a.e(0,0,0),this.cameraRotation=new a.d(0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?a.e.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 i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=a.e.Zero(),this._transformedDirection=a.e.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(h.c)([Object(w.o)()],t.prototype,"ellipsoid",void 0),Object(h.c)([Object(w.o)()],t.prototype,"ellipsoidOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"checkCollisions",void 0),Object(h.c)([Object(w.c)()],t.prototype,"applyGravity",void 0),t}(Lt);B.a.AddNodeConstructor("TouchCamera",(function(e,t){return function(){return new Ft(e,a.e.Zero(),t)}}));var Ft=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.inputs.addTouch(),r._setupInputs(),r}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.touch,t=this.inputs.attached.mouse;t?t.touchEnabled=!1:e.allowMouse=!0},t}(wt);B.a.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new Bt(e,0,0,1,a.e.Zero(),t)}}));var Bt=function(e){function t(t,i,n,r,s,c,l){void 0===l&&(l=!0);var u=e.call(this,t,a.e.Zero(),c,l)||this;return u.inertialAlphaOffset=0,u.inertialBetaOffset=0,u.inertialRadiusOffset=0,u.lowerAlphaLimit=null,u.upperAlphaLimit=null,u.lowerBetaLimit=.01,u.upperBetaLimit=Math.PI-.01,u.lowerRadiusLimit=null,u.upperRadiusLimit=null,u.inertialPanningX=0,u.inertialPanningY=0,u.pinchToPanMaxDistance=20,u.panningDistanceLimit=null,u.panningOriginTarget=a.e.Zero(),u.panningInertia=.9,u.zoomOnFactor=1,u.targetScreenOffset=a.d.Zero(),u.allowUpsideDown=!0,u.useInputToRestoreState=!0,u._viewMatrix=new a.a,u.panningAxis=new a.e(1,1,0),u.onMeshTargetChangedObservable=new o.c,u.checkCollisions=!1,u.collisionRadius=new a.e(.5,.5,.5),u._previousPosition=a.e.Zero(),u._collisionVelocity=a.e.Zero(),u._newPosition=a.e.Zero(),u._computationVector=a.e.Zero(),u._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),i?(u.setPosition(t),u.onCollide&&u.onCollide(i)):u._previousPosition.copyFrom(u._position);var n=Math.cos(u.alpha),r=Math.sin(u.alpha),o=Math.cos(u.beta),a=Math.sin(u.beta);0===a&&(a=1e-4);var s=u._getTargetPosition();u._computationVector.copyFromFloats(u.radius*n*a,u.radius*o,u.radius*r*a),s.addToRef(u._computationVector,u._newPosition),u._position.copyFrom(u._newPosition);var c=u.upVector;u.allowUpsideDown&&u.beta<0&&(c=(c=c.clone()).negate()),u._computeViewMatrix(u._position,s,c),u._viewMatrix.addAtIndex(12,u.targetScreenOffset.x),u._viewMatrix.addAtIndex(13,u.targetScreenOffset.y),u._collisionTriggered=!1},u._target=a.e.Zero(),s&&u.setTarget(s),u.alpha=i,u.beta=n,u.radius=r,u.getViewMatrix(),u.inputs=new ft(u),u.inputs.addKeyboard().addMouseWheel().addPointers(),u}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this.setPosition(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upToYMatrix||(this._YToUpMatrix=new a.a,this._upToYMatrix=new a.a,this._upVector=a.e.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!1,configurable:!0}),t.prototype.setMatUp=function(){a.a.RotationAlignToRef(a.e.UpReadOnly,this._upVector,this._YToUpMatrix),a.a.RotationAlignToRef(this._upVector,a.e.UpReadOnly,this._upToYMatrix)},Object.defineProperty(t.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pinchDeltaPercentage",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useNaturalPinchZoom",{get:function(){var e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom},set:function(e){var t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelDeltaPercentage",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new we,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new Fe,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new Le,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!1,configurable:!0}),t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache._target=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=a.d.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,i,n){var r=this;void 0===i&&(i=!0),void 0===n&&(n=2),t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._useCtrlForPanning=i,this._panningMouseButton=n,"boolean"==typeof arguments[0]&&(arguments.length>1&&(this._useCtrlForPanning=arguments[1]),arguments.length>2&&(this._panningMouseButton=arguments[2])),this.inputs.attachElement(t),this._reset=function(){r.inertialAlphaOffset=0,r.inertialBetaOffset=0,r.inertialRadiusOffset=0,r.inertialPanningX=0,r.inertialPanningY=0}},t.prototype.detachControl=function(e){this.inputs.detachElement(),this._reset&&this._reset()},t.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),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)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||a.e.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4);var e=this.alpha;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);var t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=2*t*Math.PI,this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()},t.prototype.setPosition=function(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())},t.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!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 n=e,r=this._getTargetPosition();if(r&&!i&&r.equals(n))return;this._targetHost=null,this._target=n,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}this.rebuildAnglesAndRadius()},t.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4),0===this.radius&&(this.radius=1e-4);var r=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*n,this.radius*i,this.radius*t*n),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||a.e.TransformCoordinatesToRef(this._computationVector,this._YToUpMatrix,this._computationVector),r.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 s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.negate()),this._computeViewMatrix(this._position,r,s),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=r,this._viewMatrix},t.prototype.zoomOn=function(e,t){void 0===t&&(t=!1),e=e||this.getScene().meshes;var i=be.a.MinMax(e),n=a.e.Distance(i.min,i.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:n},t)},t.prototype.focusOn=function(e,t){var i,n;if(void 0===t&&(t=!1),void 0===e.min){var r=e||this.getScene().meshes;i=be.a.MinMax(r),n=a.e.Distance(i.min,i.max)}else{i=e,n=e.distance}this._target=be.a.Center(i),t||(this.maxZ=2*n)},t.prototype.createRigCamera=function(e,i){var n=0;switch(this.cameraRigMode){case je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case je.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case je.a.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===i?1:-1);break;case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===i?-1:1)}var r=new t(e,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return r._cameraRigParams={},r.isRigCamera=!0,r.rigParent=this,r.upVector=this.upVector,r},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],i=this._rigCameras[1];switch(t.beta=i.beta=this.beta,this.cameraRigMode){case je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case je.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case je.a.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,i.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(h.c)([Object(w.c)()],t.prototype,"alpha",void 0),Object(h.c)([Object(w.c)()],t.prototype,"beta",void 0),Object(h.c)([Object(w.c)()],t.prototype,"radius",void 0),Object(h.c)([Object(w.o)("target")],t.prototype,"_target",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialAlphaOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialBetaOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialRadiusOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerAlphaLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperAlphaLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerBetaLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperBetaLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerRadiusLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperRadiusLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialPanningX",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialPanningY",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchToPanMaxDistance",void 0),Object(h.c)([Object(w.c)()],t.prototype,"panningDistanceLimit",void 0),Object(h.c)([Object(w.o)()],t.prototype,"panningOriginTarget",void 0),Object(h.c)([Object(w.c)()],t.prototype,"panningInertia",void 0),Object(h.c)([Object(w.c)()],t.prototype,"zoomOnFactor",void 0),Object(h.c)([Object(w.c)()],t.prototype,"targetScreenOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"allowUpsideDown",void 0),Object(h.c)([Object(w.c)()],t.prototype,"useInputToRestoreState",void 0),t}(Lt);B.a.AddNodeConstructor("DeviceOrientationCamera",(function(e,t){return function(){return new Ut(e,a.e.Zero(),t)}}));var Ut=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r._tmpDragQuaternion=new a.b,r._disablePointerInputWhenUsingDeviceOrientation=!0,r._dragFactor=0,r._quaternionCache=new a.b,r.inputs.addDeviceOrientation(),r.inputs._deviceOrientationInput&&r.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce((function(){r._disablePointerInputWhenUsingDeviceOrientation&&r.inputs._mouseInput&&(r.inputs._mouseInput._allowCameraRotation=!1,r.inputs._mouseInput.onPointerMovedObservable.add((function(e){0!=r._dragFactor&&(r._initialQuaternion||(r._initialQuaternion=new a.b),a.b.FromEulerAnglesToRef(0,e.offsetX*r._dragFactor,0,r._tmpDragQuaternion),r._initialQuaternion.multiplyToRef(r._tmpDragQuaternion,r._initialQuaternion))})))})),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"disablePointerInputWhenUsingDeviceOrientation",{get:function(){return this._disablePointerInputWhenUsingDeviceOrientation},set:function(e){this._disablePointerInputWhenUsingDeviceOrientation=e},enumerable:!1,configurable:!0}),t.prototype.enableHorizontalDragging=function(e){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=J.a.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new a.b),this._initialQuaternion.copyFrom(this._quaternionCache||this.rotationQuaternion),["x","y","z"].forEach((function(i){e[i]?t._initialQuaternion[i]*=-1:t._initialQuaternion[i]=0})),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},t}(wt),Vt=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new _t),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new mt(e)),this},t}(nt),kt=function(e){function t(t,i,n,r){void 0===r&&(r=!0);var o=e.call(this,t,i,n,r)||this;return o.ellipsoid=new a.e(1,1,1),o.ellipsoidOffset=new a.e(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o.cameraDirection=a.e.Zero(),o._trackRoll=0,o.rollCorrect=100,o.bankedTurn=!1,o.bankedTurnLimit=Math.PI/2,o.bankedTurnMultiplier=1,o._needMoveForGravity=!1,o._oldPosition=a.e.Zero(),o._diffPosition=a.e.Zero(),o._newPosition=a.e.Zero(),o._collisionMask=-1,o._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null);var n;n=t,o._newPosition.copyFrom(n),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>Se.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&i&&o.onCollide(i))},o.inputs=new Vt(o),o.inputs.addKeyboard().addMouse(),o}return Object(h.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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,configurable:!0}),t.prototype.attachControl=function(e,t){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new a.e(0,0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?a.e.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 i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=a.e.Zero(),this._transformedDirection=a.e.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,i=t-this.rotation.z;Math.abs(i)>=.001&&(this.rotation.z+=i/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(h.c)([Object(w.o)()],t.prototype,"ellipsoid",void 0),Object(h.c)([Object(w.o)()],t.prototype,"ellipsoidOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"checkCollisions",void 0),Object(h.c)([Object(w.c)()],t.prototype,"applyGravity",void 0),t}(Lt),zt=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new gt),this},t.prototype.addMouseWheel=function(){return this.add(new vt),this},t.prototype.addPointers=function(){return this.add(new bt),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}(nt);B.a.AddNodeConstructor("FollowCamera",(function(e,t){return function(){return new jt(e,a.e.Zero(),t)}})),B.a.AddNodeConstructor("ArcFollowCamera",(function(e,t){return function(){return new Wt(e,0,0,1,null,t)}}));var Gt,jt=function(e){function t(t,i,n,r){void 0===r&&(r=null);var o=e.call(this,t,i,n)||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=r,o.inputs=new zt(o),o.inputs.addKeyboard().addMouseWheel().addPointers(),o}return Object(h.d)(t,e),t.prototype._follow=function(e){if(e){var t;if(e.rotationQuaternion){var i=new a.a;e.rotationQuaternion.toRotationMatrix(i),t=Math.atan2(i.m[8],i.m[10])}else t=e.rotation.y;var n=Ce.b.ToRadians(this.rotationOffset)+t,r=e.getAbsolutePosition(),o=r.x+Math.sin(n)*this.radius,s=r.z+Math.cos(n)*this.radius,c=o-this.position.x,l=r.y+this.heightOffset-this.position.y,u=s-this.position.z,h=c*this.cameraAcceleration*2,d=l*this.cameraAcceleration,f=u*this.cameraAcceleration*2;(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new a.e(this.position.x+h,this.position.y+d,this.position.z+f),this.setTarget(r)}},t.prototype.attachControl=function(e,t){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t),this._reset=function(){}},t.prototype.detachControl=function(e){this.inputs.detachElement(),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(h.c)([Object(w.c)()],t.prototype,"radius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerRadiusLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperRadiusLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"rotationOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerRotationOffsetLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperRotationOffsetLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"heightOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerHeightOffsetLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperHeightOffsetLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"cameraAcceleration",void 0),Object(h.c)([Object(w.c)()],t.prototype,"maxCameraSpeed",void 0),Object(h.c)([Object(w.k)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(Lt),Wt=function(e){function t(t,i,n,r,o,s){var c=e.call(this,t,a.e.Zero(),s)||this;return c.alpha=i,c.beta=n,c.radius=r,c._cartesianCoordinates=a.e.Zero(),c._meshTarget=o,c._follow(),c}return Object(h.d)(t,e),t.prototype._follow=function(){if(this._meshTarget){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this._meshTarget.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._follow()},t.prototype.getClassName=function(){return"ArcFollowCamera"},t}(Lt),Ht=i(38),Xt=i(39);!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"}(Gt||(Gt={}));var Yt,Kt,Qt=function(){function e(){}return e.InitiateController=function(e){for(var t=0,i=this._ControllerFactories;tthis._maxRotationDistFromHeadset){var n=i-(i<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=n;var r=Math.sin(-n),o=Math.cos(-n);this._calculatedPosition.x=this._calculatedPosition.x*o-this._calculatedPosition.z*r,this._calculatedPosition.z=this._calculatedPosition.x*r+this._calculatedPosition.z*o}}a.e.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),a.b.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation),this._mesh&&(this._mesh.position.copyFrom(this.devicePosition),this._mesh.rotationQuaternion&&this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion))}},t.prototype.updateFromDevice=function(e){if(!this.isXR&&e){this.rawPose=e,e.position&&(this._deviceRoomPosition.copyFromFloats(e.position[0],e.position[1],-e.position[2]),this._mesh&&this._mesh.getScene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1),this._trackPosition&&this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor,this._calculatedPosition),this._calculatedPosition.addInPlace(this.position));var 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 a.b),!this.isXR&&(this._updatePoseAndMesh(),this._pointingPoseNode)){for(var t=[],i=this._pointingPoseNode;i.parent;)t.push(i.parent),i=i.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:!1,configurable:!0}),t.prototype.getForwardRay=function(e){if(void 0===e&&(e=100),!this.mesh)return new Xt.a(a.e.Zero(),new a.e(0,0,1),e);var t=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),i=t.getTranslation(),n=new a.e(0,0,-1),r=a.e.TransformNormal(n,t),o=a.e.Normalize(r);return new Xt.a(i,o,e)},t.POINTING_POSE="POINTING_POSE",t}(ot);!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"}(Yt||(Yt={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Kt||(Kt={}));var Zt,Jt,$t=function(e){function t(t,i,n,r){void 0===r&&(r=!1);var a=e.call(this,t,i,n,0,1,2,3)||this;return a._leftTrigger=0,a._rightTrigger=0,a.onButtonDownObservable=new o.c,a.onButtonUpObservable=new o.c,a.onPadDownObservable=new o.c,a.onPadUpObservable=new o.c,a._buttonA=0,a._buttonB=0,a._buttonX=0,a._buttonY=0,a._buttonBack=0,a._buttonStart=0,a._buttonLB=0,a._buttonRB=0,a._buttonLeftStick=0,a._buttonRightStick=0,a._dPadUp=0,a._dPadDown=0,a._dPadLeft=0,a._dPadRight=0,a._isXboxOnePad=!1,a.type=ot.XBOX,a._isXboxOnePad=r,a}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!1,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype._setDPadValue=function(e,t,i){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),0===e&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(t.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,Yt.A)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,Yt.B)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,Yt.X)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,Yt.Y)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,Yt.Start)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,Yt.Back)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,Yt.LB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,Yt.RB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Yt.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Yt.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Kt.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Kt.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Kt.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Kt.Right)},enumerable:!1,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}(ot);!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"}(Zt||(Zt={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Jt||(Jt={}));var ei=function(e){function t(t,i,n){var r=e.call(this,t.replace("STANDARD GAMEPAD","SONY PLAYSTATION DUALSHOCK"),i,n,0,1,2,3)||this;return r._leftTrigger=0,r._rightTrigger=0,r.onButtonDownObservable=new o.c,r.onButtonUpObservable=new o.c,r.onPadDownObservable=new o.c,r.onPadUpObservable=new o.c,r._buttonCross=0,r._buttonCircle=0,r._buttonSquare=0,r._buttonTriangle=0,r._buttonShare=0,r._buttonOptions=0,r._buttonL1=0,r._buttonR1=0,r._buttonLeftStick=0,r._buttonRightStick=0,r._dPadUp=0,r._dPadDown=0,r._dPadLeft=0,r._dPadRight=0,r.type=ot.DUALSHOCK,r}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!1,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype._setDPadValue=function(e,t,i){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),0===e&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(t.prototype,"buttonCross",{get:function(){return this._buttonCross},set:function(e){this._buttonCross=this._setButtonValue(e,this._buttonCross,Zt.Cross)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonCircle",{get:function(){return this._buttonCircle},set:function(e){this._buttonCircle=this._setButtonValue(e,this._buttonCircle,Zt.Circle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonSquare",{get:function(){return this._buttonSquare},set:function(e){this._buttonSquare=this._setButtonValue(e,this._buttonSquare,Zt.Square)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonTriangle",{get:function(){return this._buttonTriangle},set:function(e){this._buttonTriangle=this._setButtonValue(e,this._buttonTriangle,Zt.Triangle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonOptions",{get:function(){return this._buttonOptions},set:function(e){this._buttonOptions=this._setButtonValue(e,this._buttonOptions,Zt.Options)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonShare",{get:function(){return this._buttonShare},set:function(e){this._buttonShare=this._setButtonValue(e,this._buttonShare,Zt.Share)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonL1",{get:function(){return this._buttonL1},set:function(e){this._buttonL1=this._setButtonValue(e,this._buttonL1,Zt.L1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonR1",{get:function(){return this._buttonR1},set:function(e){this._buttonR1=this._setButtonValue(e,this._buttonR1,Zt.R1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Zt.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Zt.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Jt.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Jt.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Jt.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Jt.Right)},enumerable:!1,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}(ot),ti=function(){function e(e){var t=this;if(this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new o.c,Ht.a.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new o.c((function(e){for(var i in t._babylonGamepads){var n=t._babylonGamepads[i];n&&n._isConnected&&t.onGamepadConnectedObservable.notifyObserver(e,n)}})),this._onGamepadConnectedEvent=function(e){var i,n=e.gamepad;n.index in t._babylonGamepads&&t._babylonGamepads[n.index].isConnected||(t._babylonGamepads[n.index]?((i=t._babylonGamepads[n.index]).browserGamepad=n,i._isConnected=!0):i=t._addNewGamepad(n),t.onGamepadConnectedObservable.notifyObservers(i),t._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var i=e.gamepad;for(var n in t._babylonGamepads)if(t._babylonGamepads[n].index===i.index){var r=t._babylonGamepads[n];r._isConnected=!1,t.onGamepadDisconnectedObservable.notifyObservers(r),r.dispose&&r.dispose();break}},this._gamepadSupport)if(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported){var i=this._scene?this._scene.getEngine().getHostWindow():window;i&&(i.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),i.addEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent,!1))}else this._startMonitoringGamepads()}return Object.defineProperty(e.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!1,configurable:!0}),e.prototype.getGamepadByType=function(e){void 0===e&&(e=ot.XBOX);for(var t=0,i=this._babylonGamepads;t1&&(l=a.generateStencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24),o.is2DArray?i.texImage3D(r,0,l,o.width,o.height,n,0,c,s,null):i.texImage2D(r,0,l,o.width,o.height,0,c,s,null),this._bindTextureDirectly(r,null),o};var li=function(){function e(e,t,i,n,r,s,c,l,u,h,d,f,p,_,m){void 0===c&&(c=g.a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===h&&(h=null),void 0===d&&(d=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f="postprocess"),void 0===_&&(_=!1),void 0===m&&(m=g.a.TEXTUREFORMAT_RGBA),this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.alphaMode=g.a.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=g.a.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new oi.a(2),this._currentRenderTextureInd=0,this._scaleRatio=new a.d(1,1),this._texelSize=a.d.Zero(),this.onActivateObservable=new o.c,this.onSizeChangedObservable=new o.c,this.onApplyObservable=new o.c,this.onBeforeRenderObservable=new o.c,this.onAfterRenderObservable=new o.c,this.name=e,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=r,this.renderTargetSamplingMode=c||g.a.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=u||!1,this._textureType=d,this._textureFormat=m,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=f,this._parameters=i||[],this._parameters.push("scale"),this._indexParameters=p,_||this.updateEffect(h)}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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!1,configurable:!0}),e.prototype.restoreDefaultInputTexture=function(){this._forcedOutputTexture=null},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:!1,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 oi.a(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(e,t,i,n,r,o,a,s){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._effect=this._engine.createEffect({vertex:null!=a?a:this._vertexUrl,fragment:null!=s?s:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,null!==e?e:"",void 0,r,o,n||this._indexParameters)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype.activate=function(e,t,i){var n=this;void 0===t&&(t=null);var r=(e=e||this._camera).getScene(),o=r.getEngine(),a=o.getCaps().maxTextureSize,s=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,c=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0,l=e.parent;!l||l.leftCamera!=e&&l.rightCamera!=e||(s/=2);var u,h=this._options.width||s,d=this._options.height||c,f=this.renderTargetSamplingMode!==g.a.TEXTURE_NEAREST_LINEAR&&this.renderTargetSamplingMode!==g.a.TEXTURE_NEAREST_NEAREST&&this.renderTargetSamplingMode!==g.a.TEXTURE_LINEAR_LINEAR;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var p=o.currentViewport;p&&(h*=p.width,d*=p.height)}if((f||this.alwaysForcePOT)&&(this._options.width||(h=o.needPOTTextures?Se.a.GetExponentOfTwo(h,a,this.scaleMode):h),this._options.height||(d=o.needPOTTextures?Se.a.GetExponentOfTwo(d,a,this.scaleMode):d)),this.width!==h||this.height!==d){if(this._textures.length>0){for(var _=0;_0)for(var e=0;e0){var i=this._camera._getFirstPostProcess();i&&i.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON."+this.getClassName(),e.cameraId=this.getCamera().id,e.reusable=this._reusable,e.options=this._options,e.textureType=this._textureType,e},e.Parse=function(e,t,i){var n=c.a.GetClass(e.customType);if(!n||!n._Parse)return null;var r=t.getCameraByID(e.cameraId);return r?n._Parse(e,r,t,i):null},Object(h.c)([Object(w.c)()],e.prototype,"uniqueId",void 0),Object(h.c)([Object(w.c)()],e.prototype,"name",void 0),Object(h.c)([Object(w.c)()],e.prototype,"width",void 0),Object(h.c)([Object(w.c)()],e.prototype,"height",void 0),Object(h.c)([Object(w.c)()],e.prototype,"renderTargetSamplingMode",void 0),Object(h.c)([Object(w.f)()],e.prototype,"clearColor",void 0),Object(h.c)([Object(w.c)()],e.prototype,"autoClear",void 0),Object(h.c)([Object(w.c)()],e.prototype,"alphaMode",void 0),Object(h.c)([Object(w.c)()],e.prototype,"alphaConstants",void 0),Object(h.c)([Object(w.c)()],e.prototype,"enablePixelPerfectMode",void 0),Object(h.c)([Object(w.c)()],e.prototype,"forceFullscreenViewport",void 0),Object(h.c)([Object(w.c)()],e.prototype,"scaleMode",void 0),Object(h.c)([Object(w.c)()],e.prototype,"alwaysForcePOT",void 0),Object(h.c)([Object(w.c)("samples")],e.prototype,"_samples",void 0),Object(h.c)([Object(w.c)()],e.prototype,"adaptScaleToCurrentViewport",void 0),e}();c.a.RegisteredTypes["BABYLON.PostProcess"]=li;var ui="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";ai.a.ShadersStore.passPixelShader=ui;var hi="\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}";ai.a.ShadersStore.passCubePixelShader=hi;var di=function(e){function t(t,i,n,r,o,a,s,c){return void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1),e.call(this,t,"pass",null,null,i,n,r,o,a,void 0,s,void 0,null,c)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"PassPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);c.a.RegisteredTypes["BABYLON.PassPostProcess"]=di;var fi=function(e){function t(t,i,n,r,o,a,s,c){void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"passCube",null,null,i,n,r,o,a,"#define POSITIVEX",s,void 0,null,c)||this;return l._face=0,l}return Object(h.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:!1,configurable:!0}),t.prototype.getClassName=function(){return"PassCubePostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);Se.a._RescalePostProcessFactory=function(e){return new di("rescale",1,null,g.a.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,g.a.TEXTURETYPE_UNSIGNED_INT)};var pi="\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}";ai.a.ShadersStore.anaglyphPixelShader=pi;var _i=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,"anaglyph",null,["leftSampler"],i,n[1],r,o,a)||this;return s._passedProcess=n[0]._rigPostProcess,s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",s._passedProcess)})),s}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphPostProcess"},t}(li);c.a.RegisteredTypes["BABYLON.AnaglyphPostProcess"]=_i,je.a._setStereoscopicAnaglyphRigMode=function(e){e._rigCameras[0]._rigPostProcess=new di(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new _i(e.name+"_anaglyph",1,e._rigCameras)},B.a.AddNodeConstructor("AnaglyphArcRotateCamera",(function(e,t,i){return function(){return new mi(e,0,0,1,a.e.Zero(),i.interaxial_distance,t)}}));var mi=function(e){function t(t,i,n,r,o,a,s){var c=e.call(this,t,i,n,r,o,s)||this;return c.interaxialDistance=a,c.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a}),c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(Bt);B.a.AddNodeConstructor("AnaglyphFreeCamera",(function(e,t,i){return function(){return new gi(e,a.e.Zero(),i.interaxial_distance,t)}}));var gi=function(e){function t(t,i,n,r){var o=e.call(this,t,i,r)||this;return o.interaxialDistance=n,o.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(wt);B.a.AddNodeConstructor("AnaglyphGamepadCamera",(function(e,t,i){return function(){return new vi(e,a.e.Zero(),i.interaxial_distance,t)}}));var vi=function(e){function t(t,i,n,r){var o=e.call(this,t,i,r)||this;return o.interaxialDistance=n,o.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(ri);B.a.AddNodeConstructor("AnaglyphUniversalCamera",(function(e,t,i){return function(){return new bi(e,a.e.Zero(),i.interaxial_distance,t)}}));var bi=function(e){function t(t,i,n,r){var o=e.call(this,t,i,r)||this;return o.interaxialDistance=n,o.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(ni),yi=i(58);je.a._setStereoscopicRigMode=function(e){var t=e.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,i=e.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;e._rigCameras[i?1:0].viewport=new yi.a(0,0,t?.5:1,t?1:.5),e._rigCameras[i?0:1].viewport=new yi.a(t?.5:0,t?0:.5,t?.5:1,t?1:.5)},B.a.AddNodeConstructor("StereoscopicArcRotateCamera",(function(e,t,i){return function(){return new Ti(e,0,0,1,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ti=function(e){function t(t,i,n,r,o,a,s,c){var l=e.call(this,t,i,n,r,o,c)||this;return l.interaxialDistance=a,l.isStereoscopicSideBySide=s,l.setCameraRigMode(s?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(Bt);B.a.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new Ei(e,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ei=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,o)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(wt);B.a.AddNodeConstructor("StereoscopicGamepadCamera",(function(e,t,i){return function(){return new Si(e,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Si=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,o)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(ri);B.a.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new Ai(e,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ai=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,o)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(ni);B.a.AddNodeConstructor("VirtualJoysticksCamera",(function(e,t){return function(){return new Pi(e,a.e.Zero(),t)}}));var Pi=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.inputs.addVirtualJoystick(),r}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t}(wt),Ci=function(){function e(){this.compensateDistortion=!0,this.multiviewEnabled=!1}return Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return a.a.Translation(e,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return a.a.Translation(-e,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftPreViewMatrix",{get:function(){return a.a.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightPreViewMatrix",{get:function(){return a.a.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!1,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}(),Ri="\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}";ai.a.ShadersStore.vrDistortionCorrectionPixelShader=Ri;var xi=function(e){function t(t,i,n,r){var o=e.call(this,t,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,r.postProcessScaleFactor,i,Ke.a.BILINEAR_SAMPLINGMODE)||this;return o._isRightEye=n,o._distortionFactors=r.distortionK,o._postProcessScaleFactor=r.postProcessScaleFactor,o._lensCenterOffset=r.lensCenterOffset,o.adaptScaleToCurrentViewport=!0,o.onSizeChangedObservable.add((function(){o._scaleIn=new a.d(2,2/o.aspectRatio),o._scaleFactor=new a.d(1/o._postProcessScaleFactor*.5,1/o._postProcessScaleFactor*.5*o.aspectRatio),o._lensCenter=new a.d(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(h.d)(t,e),t.prototype.getClassName=function(){return"VRDistortionCorrectionPostProcess"},t}(li),Oi="precision mediump sampler2DArray;\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\nvoid main(void)\n{\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\n}";ai.a.ShadersStore.vrMultiviewToSingleviewPixelShader=Oi;var Mi=i(85),Ii=i(95),Di=i(96);qe.a.prototype.createRenderTargetCubeTexture=function(e,t){var i=Object(h.a)({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:g.a.TEXTURETYPE_UNSIGNED_INT,samplingMode:g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,format:g.a.TEXTUREFORMAT_RGBA},t);i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,(i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==g.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=g.a.TEXTURE_NEAREST_SAMPLINGMODE);var n=this._gl,r=new Qe.a(this,Qe.b.RenderTarget);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,r,!0);var o=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=g.a.TEXTURETYPE_UNSIGNED_INT,m.a.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,o.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,o.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);for(var a=0;a<6;a++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),e,e,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);var s=n.createFramebuffer();return this._bindUnboundFramebuffer(s),r._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,e,e),i.generateMipMaps&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),r._framebuffer=s,r.width=e,r.height=e,r.isReady=!0,r.isCube=!0,r.samples=1,r.generateMipMaps=i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r.format=i.format,r._generateDepthBuffer=i.generateDepthBuffer,r._generateStencilBuffer=i.generateStencilBuffer,this._internalTexturesCache.push(r),r};var Ni=function(e){function t(t,i,n,r,s,c,l,u,h,d,f,p,_){void 0===s&&(s=!0),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1),void 0===u&&(u=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=!0),void 0===d&&(d=!1),void 0===f&&(f=!1),void 0===p&&(p=g.a.TEXTUREFORMAT_RGBA),void 0===_&&(_=!1);var m=e.call(this,null,n,!r)||this;return m.renderParticles=!0,m.renderSprites=!1,m.ignoreCameraViewport=!1,m.onBeforeBindObservable=new o.c,m.onAfterUnbindObservable=new o.c,m.onBeforeRenderObservable=new o.c,m.onAfterRenderObservable=new o.c,m.onClearObservable=new o.c,m.onResizeObservable=new o.c,m._currentRefreshId=-1,m._refreshRate=1,m._samples=1,m.boundingBoxPosition=a.e.Zero(),(n=m.getScene())?(m._coordinatesMode=Ke.a.PROJECTION_MODE,m.renderList=new Array,m.name=t,m.isRenderTarget=!0,m._initialSizeParameter=i,m._processSizeParameter(i),m._resizeObserver=m.getScene().getEngine().onResizeObservable.add((function(){})),m._generateMipMaps=!!r,m._doNotChangeAspectRatio=s,m._renderingManager=new Di.b(n),m._renderingManager._useSceneAutoClearSetup=!0,f||(m._renderTargetOptions={generateMipMaps:r,type:c,format:p,samplingMode:u,generateDepthBuffer:h,generateStencilBuffer:d},u===Ke.a.NEAREST_SAMPLINGMODE&&(m.wrapU=Ke.a.CLAMP_ADDRESSMODE,m.wrapV=Ke.a.CLAMP_ADDRESSMODE),_||(l?(m._texture=n.getEngine().createRenderTargetCubeTexture(m.getRenderSize(),m._renderTargetOptions),m.coordinatesMode=Ke.a.INVCUBIC_MODE,m._textureMatrix=a.a.Identity()):m._texture=n.getEngine().createRenderTargetTexture(m._size,m._renderTargetOptions))),m):m}return Object(h.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:!1,configurable:!0}),t.prototype._hookArray=function(e){var t=this,i=e.push;e.push=function(){for(var n=[],r=0;r0&&(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:!1,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 i=this.getScene();i&&(this._processSizeParameter(e),this._texture=t?i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},t.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),s=this.getScene()){var i,n=s.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var r=0;r1||this.activeCamera&&this.activeCamera!==s.activeCamera)&&s.setTransformMatrix(s.activeCamera.getViewMatrix(),s.activeCamera.getProjectionMatrix(!0)),n.setViewport(s.activeCamera.viewport)),s.resetCachedMaterial()}},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var i=e*t,n=Se.a.NearestPOT(i+16384/(128+i));return Math.min(Se.a.FloorPOT(e),n)},t.prototype._prepareRenderingManager=function(e,t,i,n){var r=this.getScene();if(r){this._renderingManager.reset();for(var o=r.getRenderId(),a=0;a=0&&this._renderingManager.dispatchParticles(f))}}},t.prototype._bindFrameBuffer=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0);var i=this.getScene();if(i){var n=i.getEngine();this._texture&&n.bindFramebuffer(this._texture,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}},t.prototype.unbindFrameBuffer=function(e,t){var i=this;this._texture&&e.unBindFramebuffer(this._texture,this.isCube,(function(){i.onAfterRenderObservable.notifyObservers(t)}))},t.prototype.renderToTarget=function(e,t,i,n,r){void 0===n&&(n=0),void 0===r&&(r=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,n),this.is2DArray?this.onBeforeRenderObservable.notifyObservers(n):this.onBeforeRenderObservable.notifyObservers(e);var s=null,c=this.renderList?this.renderList:o.getActiveMeshes().data,l=this.renderList?this.renderList.length:o.getActiveMeshes().length;this.getCustomRenderList&&(s=this.getCustomRenderList(this.is2DArray?n:e,c,l)),s?this._prepareRenderingManager(s,s.length,r,!1):(this._defaultRenderListPrepared||(this._prepareRenderingManager(c,l,r,!this.renderList),this._defaultRenderListPrepared=!0),s=c),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,h=o._beforeRenderTargetDrawStage;u=0&&t.customRenderTargets.splice(i,1);for(var n=0,r=t.cameras;n=0&&o.customRenderTargets.splice(i,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}(Ke.a);Ke.a._CreateRenderTargetTexture=function(e,t,i,n){return new Ni(e,t,i,n)};var Li=function(e){function t(t,i){void 0===i&&(i=512);var n=e.call(this,"multiview rtt",i,t,!1,!0,Qe.b.Unknown,!1,void 0,!1,!1,!0,void 0,!0)||this,r=t.getEngine().createMultiviewRenderTargetTexture(n.getRenderWidth(),n.getRenderHeight());return r.isMultiview=!0,r.format=g.a.TEXTUREFORMAT_RGBA,n._texture=r,n.samples=n._getEngine().getCaps().maxSamples||n.samples,n}return Object(h.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}(Ni),wi=i(90);Se.a.prototype.createMultiviewRenderTargetTexture=function(e,t){var i=this._gl;if(!this.getCaps().multiview)throw"Multiview is not supported";var n=new Qe.a(this,Qe.b.Unknown,!0);return n.width=e,n.height=t,n._framebuffer=i.createFramebuffer(),n._colorTextureArray=i.createTexture(),i.bindTexture(i.TEXTURE_2D_ARRAY,n._colorTextureArray),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.RGBA8,e,t,2),n._depthStencilTextureArray=i.createTexture(),i.bindTexture(i.TEXTURE_2D_ARRAY,n._depthStencilTextureArray),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.DEPTH32F_STENCIL8,e,t,2),n.isReady=!0,n},Se.a.prototype.bindMultiviewFramebuffer=function(e){var t=this._gl,i=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?(i.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,e.samples,0,2),i.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,e.samples,0,2)):(i.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,0,2),i.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,0,2))},je.a.prototype._useMultiviewToSingleView=!1,je.a.prototype._multiviewTexture=null,je.a.prototype._resizeOrCreateMultiviewTexture=function(e,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==e&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new Li(this.getScene(),{width:e,height:t})):this._multiviewTexture=new Li(this.getScene(),{width:e,height:t})},Q.a.prototype._transformMatrixR=a.a.Zero(),Q.a.prototype._multiviewSceneUbo=null,Q.a.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=new Mi.a(this.getEngine(),void 0,!0),this._multiviewSceneUbo.addUniform("viewProjection",16),this._multiviewSceneUbo.addUniform("viewProjectionR",16),this._multiviewSceneUbo.addUniform("view",16)},Q.a.prototype._updateMultiviewUbo=function(e,t){e&&t&&e.multiplyToRef(t,this._transformMatrixR),e&&t&&(e.multiplyToRef(t,a.c.Matrix[0]),wi.a.GetRightPlaneToRef(a.c.Matrix[0],this._frustumPlanes[3])),this._multiviewSceneUbo&&(this._multiviewSceneUbo.updateMatrix("viewProjection",this.getTransformMatrix()),this._multiviewSceneUbo.updateMatrix("viewProjectionR",this._transformMatrixR),this._multiviewSceneUbo.updateMatrix("view",this._viewMatrix),this._multiviewSceneUbo.update())},Q.a.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}(wt),Gi=function(e){function t(t){var i=e.call(this,t)||this;return i.onTriggerStateChangedObservable=new o.c,i.onMainButtonStateChangedObservable=new o.c,i.onSecondaryButtonStateChangedObservable=new o.c,i.onPadStateChangedObservable=new o.c,i.onPadValuesChangedObservable=new o.c,i.pad={x:0,y:0},i._changes={pressChanged:!1,touchChanged:!1,valueChanged:!1,changed:!1},i._buttons=new Array(t.buttons.length),i.hand=t.hand,i}return Object(h.d)(t,e),t.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(t.prototype,"defaultModel",{get:function(){return this._defaultModel},enumerable:!1,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t\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}");ai.a.ShadersStore.imageProcessingPixelShader=Xi;var Yi=function(e){function t(t,i,n,r,o,a,s,c){void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT);var l=e.call(this,t,"imageProcessing",[],[],i,n,r,o,a,null,s,"postprocess",null,!0)||this;return l._fromLinearSpace=!0,l._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},c?(c.applyByPostProcess=!0,l._attachImageProcessingConfiguration(c,!0),l.fromLinearSpace=!1):(l._attachImageProcessingConfiguration(null,!0),l.imageProcessingConfiguration.applyByPostProcess=!0),l.onApply=function(e){l.imageProcessingConfiguration.bind(e,l.aspectRatio)},l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e,t){var i=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 n=null,r=this.getEngine(),o=this.getCamera();if(o)n=o.getScene();else if(r&&r.scenes){var a=r.scenes;n=a[a.length-1]}else n=x.a.LastCreatedScene;this._imageProcessingConfiguration=n?n.imageProcessingConfiguration:new ji.a}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){i._updateParameters()}))),t||this._updateParameters()}},Object.defineProperty(t.prototype,"isSupported",{get:function(){var e=this.getEffect();return!e||e.isSupported},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingType",{get:function(){return this._imageProcessingConfiguration.toneMappingType},set:function(e){this._imageProcessingConfiguration.toneMappingType=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"ImageProcessingPostProcess"},t.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);var e="";for(var t in this._defines)this._defines[t]&&(e+="#define "+t+";\r\n");var i=["textureSampler"],n=["scale"];ji.a&&(ji.a.PrepareSamplers(i,this._defines),ji.a.PrepareUniforms(n,this._defines)),this.updateEffect(e,n,i)},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(h.c)([Object(w.c)()],t.prototype,"_fromLinearSpace",void 0),t}(li),Ki=i(16),Qi=i(4);be.a._GroundMeshParser=function(e,t){return qi.Parse(e,t)};var qi=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.generateOctree=!1,n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(t.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!1,configurable:!0}),t.prototype.optimize=function(e,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 i=this.getWorldMatrix(),n=a.c.Matrix[5];i.invertToRef(n);var r=a.c.Vector3[8];if(a.e.TransformCoordinatesFromFloatsToRef(e,0,t,n,r),e=r.x,t=r.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),s=-(o.x*e+o.z*t+o.w)/o.y;return a.e.TransformCoordinatesFromFloatsToRef(0,s,0,i,r),r.y},t.prototype.getNormalAtCoordinates=function(e,t){var i=new a.e(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i},t.prototype.getNormalAtCoordinatesToRef=function(e,t,i){var n=this.getWorldMatrix(),r=a.c.Matrix[5];n.invertToRef(r);var o=a.c.Vector3[8];if(a.e.TransformCoordinatesFromFloatsToRef(e,0,t,r,o),e=o.x,t=o.z,ethis._maxX||tthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(e,t);return a.e.TransformNormalFromFloatsToRef(s.x,s.y,s.z,n,i),this},t.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},t.prototype._getFacetAt=function(e,t){var i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),n=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),r=this._heightQuads[n*this._subdivisionsX+i];return te.maxHeight){h=!0;var d=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=d}for(t=0;t<=e.subdivisions;t++)for(i=0;i<=e.subdivisions;i++){var f=new a.e(i*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),p=4*(((f.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(f.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),_=e.buffer[p]/255,m=e.buffer[p+1]/255,g=e.buffer[p+2]/255,v=e.buffer[p+3]/255;h&&(_=1-_,m=1-m,g=1-g);var b=_*l.r+m*l.g+g*l.b;f.y=v>=u?e.minHeight+(e.maxHeight-e.minHeight)*b:e.minHeight-Nt.a,r.push(f.x,f.y,f.z),o.push(0,0,0),c.push(i/e.subdivisions,1-t/e.subdivisions)}for(t=0;t=e.minHeight,P=r[3*T+1]>=e.minHeight,C=r[3*E+1]>=e.minHeight;A&&P&&C&&(n.push(y),n.push(T),n.push(E)),r[3*S+1]>=e.minHeight&&A&&C&&(n.push(S),n.push(y),n.push(E))}Ki.a.ComputeNormals(r,n,o);var R=new Ki.a;return R.indices=n,R.positions=r,R.normals=o,R.uvs=c,R},be.a.CreateGround=function(e,t,i,n,r,o){var a={width:t,height:i,subdivisions:n,updatable:o};return Ji.CreateGround(e,a,r)},be.a.CreateTiledGround=function(e,t,i,n,r,o,a,s,c){var l={xmin:t,zmin:i,xmax:n,zmax:r,subdivisions:o,precision:a,updatable:c};return Ji.CreateTiledGround(e,l,s)},be.a.CreateGroundFromHeightMap=function(e,t,i,n,r,o,a,s,c,l,u){var h={width:i,height:n,subdivisions:r,minHeight:o,maxHeight:a,updatable:c,onReady:l,alphaFilter:u};return Ji.CreateGroundFromHeightMap(e,t,h,s)};var Ji=function(){function e(){}return e.CreateGround=function(e,t,i){var n=new qi(e,i);return n._setReady(!1),n._subdivisionsX=t.subdivisionsX||t.subdivisions||1,n._subdivisionsY=t.subdivisionsY||t.subdivisions||1,n._width=t.width||1,n._height=t.height||1,n._maxX=n._width/2,n._maxZ=n._height/2,n._minX=-n._maxX,n._minZ=-n._maxZ,Ki.a.CreateGround(t).applyToMesh(n,t.updatable),n._setReady(!0),n},e.CreateTiledGround=function(e,t,i){void 0===i&&(i=null);var n=new be.a(e,i);return Ki.a.CreateTiledGround(t).applyToMesh(n,t.updatable),n},e.CreateGroundFromHeightMap=function(e,t,i,n){void 0===n&&(n=null);var r=i.width||10,o=i.height||10,a=i.subdivisions||1,c=i.minHeight||0,l=i.maxHeight||1,u=i.colorFilter||new s.a(.3,.59,.11),h=i.alphaFilter||0,d=i.updatable,f=i.onReady;n=n||x.a.LastCreatedScene;var p=new qi(e,n);p._subdivisionsX=a,p._subdivisionsY=a,p._width=r,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 Ce.b.LoadImage(t,(function(e){var t=e.width,i=e.height,s=Zi.a.CreateCanvas(t,i).getContext("2d");if(!s)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!n.isDisposed){s.drawImage(e,0,0);var _=s.getImageData(0,0,t,i).data;Ki.a.CreateGroundFromHeightMap({width:r,height:o,subdivisions:a,minHeight:c,maxHeight:l,colorFilter:u,buffer:_,bufferWidth:t,bufferHeight:i,alphaFilter:h}).applyToMesh(p,d),f&&f(p),p._setReady(!0)}}),(function(){}),n.offlineProvider),p},e}();Ki.a.CreateTorus=function(e){for(var t=[],i=[],n=[],r=[],o=e.diameter||1,s=e.thickness||.5,c=e.tessellation||16,l=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE,u=c+1,h=0;h<=c;h++)for(var d=h/c,f=h*Math.PI*2/c-Math.PI/2,p=a.a.Translation(o/2,0,0).multiply(a.a.RotationY(f)),_=0;_<=c;_++){var m=1-_/c,g=_*Math.PI*2/c+Math.PI,v=Math.cos(g),b=Math.sin(g),y=new a.e(v,b,0),T=y.scale(s/2),E=new a.d(d,m);T=a.e.TransformCoordinates(T,p),y=a.e.TransformNormal(y,p),i.push(T.x,T.y,T.z),n.push(y.x,y.y,y.z),r.push(E.x,E.y);var S=(h+1)%u,A=(_+1)%u;t.push(h*u+_),t.push(h*u+A),t.push(S*u+_),t.push(h*u+A),t.push(S*u+A),t.push(S*u+_)}Ki.a._ComputeSides(l,i,t,n,r,e.frontUVs,e.backUVs);var P=new Ki.a;return P.indices=t,P.positions=i,P.normals=n,P.uvs=r,P},be.a.CreateTorus=function(e,t,i,n,r,o,a){var s={diameter:t,thickness:i,tessellation:n,sideOrientation:a,updatable:o};return tn.CreateTorus(e,s,r)};var $i,en,tn=function(){function e(){}return e.CreateTorus=function(e,t,i){var n=new be.a(e,i);return t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreateTorus(t).applyToMesh(n,t.updatable),n},e}(),nn=i(53),rn=function(){function e(){}return e.GetDefaults=function(t){var i=new e;return i.canvasOptions={antialias:!0,depth:!0,stencil:!t||t.isStencilEnable,alpha:!0,multiview:!1,framebufferScaleFactor:1},i.newCanvasCssStyle="position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",i},e}(),on=function(){function e(e,t){var i=this;if(void 0===t&&(t=rn.GetDefaults()),this._options=t,this._canvas=null,this.xrLayer=null,this.onXRLayerInitObservable=new o.c,this._engine=e.scene.getEngine(),t.canvasElement)this._setManagedOutputCanvas(t.canvasElement);else{var n=document.createElement("canvas");n.style.cssText=this._options.newCanvasCssStyle||"position:absolute; bottom:0px;right:0px;",this._setManagedOutputCanvas(n)}e.onXRSessionInit.add((function(){i._addCanvas()})),e.onXRSessionEnded.add((function(){i._removeCanvas()}))}return e.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},e.prototype.initializeXRLayerAsync=function(e){var t=this,i=function(){var i=new XRWebGLLayer(e,t.canvasContext,t._options.canvasOptions);return t.onXRLayerInitObservable.notifyObservers(i),i};return this.canvasContext.makeXRCompatible?this.canvasContext.makeXRCompatible().then((function(){return t.xrLayer=i(),t.xrLayer})):(this.xrLayer=i(),Promise.resolve(this.xrLayer))},e.prototype._addCanvas=function(){var e=this;this._canvas&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.appendChild(this._canvas),this.xrLayer?this._setCanvasSize(!0):this.onXRLayerInitObservable.addOnce((function(t){e._setCanvasSize(!0,t)}))},e.prototype._removeCanvas=function(){this._canvas&&document.body.contains(this._canvas)&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.removeChild(this._canvas),this._setCanvasSize(!1)},e.prototype._setCanvasSize=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=this.xrLayer),this._canvas&&(e?t&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=t.framebufferWidth+"px",this._canvas.style.height=t.framebufferHeight+"px"):this._engine.setSize(t.framebufferWidth,t.framebufferHeight)):this._originalCanvasSize&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=this._originalCanvasSize.width+"px",this._canvas.style.height=this._originalCanvasSize.height+"px"):this._engine.setSize(this._originalCanvasSize.width,this._originalCanvasSize.height)))},e.prototype._setManagedOutputCanvas=function(e){this._removeCanvas(),e?(this._originalCanvasSize={width:e.offsetWidth,height:e.offsetHeight},this._canvas=e,this.canvasContext=this._canvas.getContext("webgl2"),this.canvasContext||(this.canvasContext=this._canvas.getContext("webgl"))):(this._canvas=null,this.canvasContext=null)},e}(),an=function(){function e(e){this.scene=e,this._sessionEnded=!1,this.baseLayer=null,this.currentTimestamp=-1,this.defaultHeightCompensation=1.7,this.onXRFrameObservable=new o.c,this.onXRReferenceSpaceChanged=new o.c,this.onXRSessionEnded=new o.c,this.onXRSessionInit=new o.c}return Object.defineProperty(e.prototype,"referenceSpace",{get:function(){return this._referenceSpace},set:function(e){this._referenceSpace=e,this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._sessionEnded||this.exitXRAsync(),this.onXRFrameObservable.clear(),this.onXRSessionEnded.clear(),this.onXRReferenceSpaceChanged.clear(),this.onXRSessionInit.clear()},e.prototype.exitXRAsync=function(){return this.session&&!this._sessionEnded?(this._sessionEnded=!0,this.session.end().catch((function(e){m.a.Warn("Could not end XR session.")}))):Promise.resolve()},e.prototype.getRenderTargetTextureForEye=function(e){return this._rttProvider.getRenderTargetForEye(e)},e.prototype.getWebXRRenderTarget=function(e){var t=this.scene.getEngine();return this._xrNavigator.xr.native?this._xrNavigator.xr.getWebXRRenderTarget(t):((e=e||rn.GetDefaults(t)).canvasElement=t.getRenderingCanvas()||void 0,new on(this,e))},e.prototype.initializeAsync=function(){return this._xrNavigator=navigator,this._xrNavigator.xr?Promise.resolve():Promise.reject("WebXR not available")},e.prototype.initializeSessionAsync=function(e,t){var i=this;return void 0===e&&(e="immersive-vr"),void 0===t&&(t={}),this._xrNavigator.xr.requestSession(e,t).then((function(e){return i.session=e,i.onXRSessionInit.notifyObservers(e),i._sessionEnded=!1,i.session.addEventListener("end",(function(){var e=i.scene.getEngine();i._sessionEnded=!0,i._rttProvider=null,e.framebufferDimensionsObject=null,e.restoreDefaultFramebuffer(),e.customAnimationFrameRequester=null,i.onXRSessionEnded.notifyObservers(null),e._renderLoop()}),{once:!0}),i.session}))},e.prototype.isSessionSupportedAsync=function(t){return e.IsSessionSupportedAsync(t)},e.prototype.resetReferenceSpace=function(){this.referenceSpace=this.baseReferenceSpace},e.prototype.runXRRenderLoop=function(){var e=this,t=this.scene.getEngine();if(t.customAnimationFrameRequester={requestAnimationFrame:this.session.requestAnimationFrame.bind(this.session),renderFunction:function(i,n){e._sessionEnded||(e.currentFrame=n,e.currentTimestamp=i,n&&(t.framebufferDimensionsObject=e.baseLayer,e.onXRFrameObservable.notifyObservers(n),t._renderLoop(),t.framebufferDimensionsObject=null))}},this._xrNavigator.xr.native)this._rttProvider=this._xrNavigator.xr.getNativeRenderTargetProvider(this.session,this._createRenderTargetTexture.bind(this));else{var i=this._createRenderTargetTexture(this.baseLayer.framebufferWidth,this.baseLayer.framebufferHeight,this.baseLayer.framebuffer);this._rttProvider={getRenderTargetForEye:function(){return i}},t.framebufferDimensionsObject=this.baseLayer}"undefined"!=typeof window&&window.cancelAnimationFrame&&window.cancelAnimationFrame(t._frameHandler),t._renderLoop()},e.prototype.setReferenceSpaceTypeAsync=function(e){var t=this;return void 0===e&&(e="local-floor"),this.session.requestReferenceSpace(e).then((function(e){return e}),(function(e){return m.a.Error("XR.requestReferenceSpace failed for the following reason: "),m.a.Error(e),m.a.Log('Defaulting to universally-supported "viewer" reference space type.'),t.session.requestReferenceSpace("viewer").then((function(e){var i=new XRRigidTransform({x:0,y:-t.defaultHeightCompensation,z:0});return e.getOffsetReferenceSpace(i)}),(function(e){throw m.a.Error(e),'XR initialization failed: required "viewer" reference space type not supported.'}))})).then((function(e){return t.session.requestReferenceSpace("viewer").then((function(i){return t.viewerReferenceSpace=i,e}))})).then((function(e){return t.referenceSpace=t.baseReferenceSpace=e,t.referenceSpace}))},e.prototype.updateRenderStateAsync=function(e){return e.baseLayer&&(this.baseLayer=e.baseLayer),this.session.updateRenderState(e)},e.IsSessionSupportedAsync=function(e){if(!navigator.xr)return Promise.resolve(!1);var t=navigator.xr.isSessionSupported||navigator.xr.supportsSession;return t?t.call(navigator.xr,e).then((function(e){var t=void 0===e||e;return Promise.resolve(t)})).catch((function(e){return m.a.Warn(e),Promise.resolve(!1)})):Promise.resolve(!1)},e.prototype._createRenderTargetTexture=function(e,t,i){void 0===i&&(i=null);var n=new Qe.a(this.scene.getEngine(),Qe.b.Unknown,!0);n.width=e,n.height=t,n._framebuffer=i;var r=new Ni("XR renderTargetTexture",{width:e,height:t},this.scene,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0);return r._texture=n,r},e}();!function(e){e[e.ENTERING_XR=0]="ENTERING_XR",e[e.EXITING_XR=1]="EXITING_XR",e[e.IN_XR=2]="IN_XR",e[e.NOT_IN_XR=3]="NOT_IN_XR"}($i||($i={})),function(e){e[e.NOT_TRACKING=0]="NOT_TRACKING",e[e.TRACKING_LOST=1]="TRACKING_LOST",e[e.TRACKING=2]="TRACKING"}(en||(en={}));var sn,cn=function(){function e(t,i){if(void 0===i&&(i=null),this.scene=t,this._pointerDownOnMeshAsked=!1,this._isActionableMesh=!1,this._teleportationRequestInitiated=!1,this._teleportationBackRequestInitiated=!1,this._rotationRightAsked=!1,this._rotationLeftAsked=!1,this._dpadPressed=!0,this._activePointer=!1,this._id=e._idCounter++,i)this._gazeTracker=i.clone("gazeTracker");else{this._gazeTracker=be.a.CreateTorus("gazeTracker",.0035,.0025,20,t,!1),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var n=new Wi.a("targetMat",t);n.specularColor=s.a.Black(),n.emissiveColor=new s.a(.7,.7,.7),n.backFaceCulling=!1,this._gazeTracker.material=n}}return e.prototype._getForwardRay=function(e){return new Xt.a(a.e.Zero(),new a.e(0,0,e))},e.prototype._selectionPointerDown=function(){this._pointerDownOnMeshAsked=!0,this._currentHit&&this.scene.simulatePointerDown(this._currentHit,{pointerId:this._id})},e.prototype._selectionPointerUp=function(){this._currentHit&&this.scene.simulatePointerUp(this._currentHit,{pointerId:this._id}),this._pointerDownOnMeshAsked=!1},e.prototype._activatePointer=function(){this._activePointer=!0},e.prototype._deactivatePointer=function(){this._activePointer=!1},e.prototype._updatePointerDistance=function(e){void 0===e&&(e=100)},e.prototype.dispose=function(){this._interactionsEnabled=!1,this._teleportationEnabled=!1,this._gazeTracker&&this._gazeTracker.dispose()},e._idCounter=0,e}(),ln=function(e){function t(t,i,n){var r=e.call(this,i,n)||this;r.webVRController=t,r._laserPointer=be.a.CreateCylinder("laserPointer",1,.004,2e-4,20,1,i,!1);var o=new Wi.a("laserPointerMat",i);if(o.emissiveColor=new s.a(.7,.7,.7),o.alpha=.6,r._laserPointer.material=o,r._laserPointer.rotation.x=Math.PI/2,r._laserPointer.position.z=-.5,r._laserPointer.isVisible=!1,r._laserPointer.isPickable=!1,!t.mesh){var a=new be.a("preloadControllerMesh",i),c=new be.a(qt.POINTING_POSE,i);c.rotation.x=-.7,a.addChild(c),t.attachToMesh(a)}return r._setLaserPointerParent(t.mesh),r._meshAttachedObserver=t._meshAttachedObservable.add((function(e){r._setLaserPointerParent(e)})),r}return Object(h.d)(t,e),t.prototype._getForwardRay=function(e){return this.webVRController.getForwardRay(e)},t.prototype._activatePointer=function(){e.prototype._activatePointer.call(this),this._laserPointer.isVisible=!0},t.prototype._deactivatePointer=function(){e.prototype._deactivatePointer.call(this),this._laserPointer.isVisible=!1},t.prototype._setLaserPointerColor=function(e){this._laserPointer.material.emissiveColor=e},t.prototype._setLaserPointerLightingDisabled=function(e){this._laserPointer.material.disableLighting=e},t.prototype._setLaserPointerParent=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach((function(e){t(e)}))};t(e);var i=e.getChildren(void 0,!1),n=e;this.webVRController._pointingPoseNode=null;for(var r=0;r=0){n=i[r],this.webVRController._pointingPoseNode=n;break}this._laserPointer.parent=n},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}(cn),un=function(e){function t(t,i){var n=e.call(this,i)||this;return n.getCamera=t,n}return Object(h.d)(t,e),t.prototype._getForwardRay=function(e){var t=this.getCamera();return t?t.getForwardRay(e):new Xt.a(a.e.Zero(),a.e.Forward())},t}(cn),hn=function(){},dn=function(){function e(t,i){var n=this;if(void 0===i&&(i={}),this.webVROptions=i,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.enableGazeEvenWhenNoPointerLock=!1,this.exitVROnDoubleTap=!0,this.onEnteringVRObservable=new o.c,this.onAfterEnteringVRObservable=new o.c,this.onExitingVRObservable=new o.c,this.onControllerMeshLoadedObservable=new o.c,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 a.e(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new a.e(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this._gazeColor=new s.a(.7,.7,.7),this._laserColor=new s.a(.7,.7,.7),this._pickedLaserColor=new s.a(.2,.2,1),this._pickedGazeColor=new s.a(0,0,1),this.onNewMeshSelected=new o.c,this.onMeshSelectedWithController=new o.c,this.onNewMeshPicked=new o.c,this.onBeforeCameraTeleport=new o.c,this.onAfterCameraTeleport=new o.c,this.onSelectedMeshUnselected=new o.c,this.teleportationEnabled=!0,this._teleportationInitialized=!1,this._interactionsEnabled=!1,this._interactionsRequested=!1,this._displayGaze=!0,this._displayLaserPointer=!0,this.updateGazeTrackerScale=!0,this.updateGazeTrackerColor=!0,this.updateControllerLaserColor=!0,this.requestPointerLockOnFullScreen=!0,this.xrTestDone=!1,this._onResize=function(){n.moveButtonToBottomRight(),n._fullscreenVRpresenting&&n._webVRready&&n.exitVR()},this._onFullscreenChange=function(){var e=document;void 0!==e.fullscreen?n._fullscreenVRpresenting=document.fullscreen:void 0!==e.mozFullScreen?n._fullscreenVRpresenting=e.mozFullScreen:void 0!==e.webkitIsFullScreen?n._fullscreenVRpresenting=e.webkitIsFullScreen:void 0!==e.msIsFullScreen?n._fullscreenVRpresenting=e.msIsFullScreen:void 0!==document.msFullscreenElement&&(n._fullscreenVRpresenting=document.msFullscreenElement),!n._fullscreenVRpresenting&&n._inputElement&&(n.exitVR(),!n._useCustomVRButton&&n._btnVR&&(n._btnVR.style.top=n._inputElement.offsetTop+n._inputElement.offsetHeight-70+"px",n._btnVR.style.left=n._inputElement.offsetLeft+n._inputElement.offsetWidth-100+"px",n.updateButtonVisibility()))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this.beforeRender=function(){n._leftController&&n._leftController._activePointer&&n._castRayAndSelectObject(n._leftController),n._rightController&&n._rightController._activePointer&&n._castRayAndSelectObject(n._rightController),n._noControllerIsActive&&(n._scene.getEngine().isPointerLock||n.enableGazeEvenWhenNoPointerLock)?n._castRayAndSelectObject(n._cameraGazer):n._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(e){if(e.type!==ot.POSE_ENABLED)e.leftStick&&e.onleftstickchanged((function(e){n._teleportationInitialized&&n.teleportationEnabled&&(!n._leftController&&!n._rightController||n._leftController&&!n._leftController._activePointer&&n._rightController&&!n._rightController._activePointer)&&(n._checkTeleportWithRay(e,n._cameraGazer),n._checkTeleportBackwards(e,n._cameraGazer))})),e.rightStick&&e.onrightstickchanged((function(e){n._teleportationInitialized&&n._checkRotate(e,n._cameraGazer)})),e.type===ot.XBOX&&(e.onbuttondown((function(e){n._interactionsEnabled&&e===Yt.A&&n._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){n._interactionsEnabled&&e===Yt.A&&n._cameraGazer._selectionPointerUp()})));else{var t=e,i=new ln(t,n._scene,n._cameraGazer._gazeTracker);"right"===t.hand||n._leftController&&n._leftController.webVRController!=t?n._rightController=i:n._leftController=i,n._tryEnableInteractionOnController(i)}},this._tryEnableInteractionOnController=function(e){n._interactionsRequested&&!e._interactionsEnabled&&n._enableInteractionOnController(e),n._teleportationRequested&&!e._teleportationEnabled&&n._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(e){e instanceof Gi&&("left"===e.hand&&null!=n._leftController&&(n._leftController.dispose(),n._leftController=null),"right"===e.hand&&null!=n._rightController&&(n._rightController.dispose(),n._rightController=null))},this._workingVector=a.e.Zero(),this._workingQuaternion=a.b.Identity(),this._workingMatrix=a.a.Identity(),this._scene=t,this._inputElement=t.getEngine().getInputElement(),"getVRDisplays"in navigator||(i.useXR=!0),void 0===i.createFallbackVRDeviceOrientationFreeCamera&&(i.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===i.createDeviceOrientationCamera&&(i.createDeviceOrientationCamera=!0),void 0===i.laserToggle&&(i.laserToggle=!0),void 0===i.defaultHeight&&(i.defaultHeight=1.7),i.useCustomVRButton&&(this._useCustomVRButton=!0,i.customVRButton&&(this._btnVR=i.customVRButton)),i.rayLength&&(this._rayLength=i.rayLength),this._defaultHeight=i.defaultHeight,i.positionScale&&(this._rayLength*=i.positionScale,this._defaultHeight*=i.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new a.e(0,this._defaultHeight,0),i.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new Ut("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 Lt&&this._scene.activeCamera.rotation)){var r=this._scene.activeCamera;r.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(r.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(a.b.RotationYawPitchRoll(r.rotation.y,r.rotation.x,r.rotation.z)),this._deviceOrientationCamera.rotation=r.rotation.clone()}this._scene.activeCamera=this._deviceOrientationCamera,this._inputElement&&this._scene.activeCamera.attachControl()}else this._existingCamera=this._scene.activeCamera;this.webVROptions.useXR&&navigator.xr?an.IsSessionSupportedAsync("immersive-vr").then((function(e){e?(m.a.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),t.createDefaultXRExperienceAsync({floorMeshes:i.floorMeshes||[]}).then((function(e){n.xr=e,n.xrTestDone=!0,n._cameraGazer=new un((function(){return n.xr.baseExperience.camera}),t),n.xr.baseExperience.onStateChangedObservable.add((function(e){switch(e){case $i.ENTERING_XR:n.onEnteringVRObservable.notifyObservers(n),n._interactionsEnabled||n.xr.pointerSelection.detach(),n.xr.pointerSelection.displayLaserPointer=n._displayLaserPointer;break;case $i.EXITING_XR:n.onExitingVRObservable.notifyObservers(n),n._scene.getEngine().resize();break;case $i.IN_XR:n._hasEnteredVR=!0;break;case $i.NOT_IN_XR:n._hasEnteredVR=!1}}))}))):n.completeVRInit(t,i)})):this.completeVRInit(t,i)}return Object.defineProperty(e.prototype,"onEnteringVR",{get:function(){return this.onEnteringVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExitingVR",{get:function(){return this.onExitingVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onControllerMeshLoaded",{get:function(){return this.onControllerMeshLoadedObservable},enumerable:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftControllerGazeTrackerMesh",{get:function(){return this._leftController?this._leftController._gazeTracker:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightControllerGazeTrackerMesh",{get:function(){return this._rightController?this._rightController._gazeTracker:null},enumerable:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"deviceOrientationCamera",{get:function(){return this._deviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentVRCamera",{get:function(){return this._webVRready?this._webVRCamera:this._scene.activeCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"webVRCamera",{get:function(){return this._webVRCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vrDeviceOrientationCamera",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vrButton",{get:function(){return this._btnVR},enumerable:!1,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:!1,configurable:!0}),e.prototype.completeVRInit=function(e,t){var i=this;if(this.xrTestDone=!0,t.createFallbackVRDeviceOrientationFreeCamera&&(t.useMultiview&&(t.vrDeviceOrientationCameraMetrics||(t.vrDeviceOrientationCameraMetrics=Ci.GetDefault()),t.vrDeviceOrientationCameraMetrics.multiviewEnabled=!0),this._vrDeviceOrientationCamera=new Ui("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new zi("WebVRHelper",this._position,this._scene,t),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new un((function(){return i.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 n=".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) }";n+=".babylonVRicon.vrdisplaypresenting { display: none; }";var r=document.createElement("style");r.appendChild(document.createTextNode(n)),document.getElementsByTagName("head")[0].appendChild(r),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",(function(){i.isInVRMode?i._scene.getEngine().disableVR():i.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&&i.displayVRButton()})),this._onKeyDown=function(e){27===e.keyCode&&i.isInVRMode&&i.exitVR()},document.addEventListener("keydown",this._onKeyDown),this._scene.onPrePointerObservable.add((function(){i._hasEnteredVR&&i.exitVROnDoubleTap&&(i.exitVR(),i._fullscreenVRpresenting&&i._scene.getEngine().exitFullscreen())}),Ne.a.POINTERDOUBLETAP,!1),this._onVRDisplayChanged=function(e){return i.onVRDisplayChanged(e)},this._onVrDisplayPresentChange=function(){return i.onVrDisplayPresentChange()},this._onVRRequestPresentStart=function(){i._webVRrequesting=!0,i.updateButtonVisibility()},this._onVRRequestPresentComplete=function(){i._webVRrequesting=!1,i.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(){i.dispose()})),this._webVRCamera.onControllerMeshLoadedObservable.add((function(e){return i._onDefaultMeshLoaded(e)})),this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),this.updateButtonVisibility(),this._circleEase=new ae,this._circleEase.setEasingMode(oe.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,e.onPointerObservable.add((function(t){i._interactionsEnabled&&e.activeCamera===i.vrDeviceOrientationCamera&&"mouse"===t.event.pointerType&&(t.type===Ne.a.POINTERDOWN?i._cameraGazer._selectionPointerDown():t.type===Ne.a.POINTERUP&&i._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){m.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===$i.IN_XR||this._webVRpresenting||this._fullscreenVRpresenting},enumerable:!1,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 m.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){m.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=a.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this.webVRCamera){var t=this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y,i=a.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y-t,n=this.webVRCamera.rotationQuaternion.toEulerAngles().y;this.webVRCamera.rotationQuaternion=a.b.FromEulerAngles(0,n+i,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._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){m.a.Warn("Error in your custom logic onExitingVR: "+e)}this._webVRpresenting&&this._scene.getEngine().disableVR(),this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone()),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._deviceOrientationCamera?(this._deviceOrientationCamera.position=this._position,this._scene.activeCamera=this._deviceOrientationCamera,this._cachedAngularSensibility.angularSensibilityX&&(this._deviceOrientationCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._deviceOrientationCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._deviceOrientationCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)):this._existingCamera&&(this._existingCamera.position=this._position,this._scene.activeCamera=this._existingCamera,this._inputElement&&this._scene.activeCamera.attachControl(),this._cachedAngularSensibility.angularSensibilityX&&(this._existingCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._existingCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._existingCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)),this.updateButtonVisibility(),this._interactionsEnabled&&(this._scene.unregisterBeforeRender(this.beforeRender),this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1)),this._scene.getEngine().resize(),[this._leftController,this._rightController].forEach((function(e){e&&e._deactivatePointer()})),this._hasEnteredVR=!1;var 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:!1,configurable:!0}),e.prototype.enableInteractions=function(){var e=this;if(!this._interactionsEnabled){if(this._interactionsRequested=!0,this.xr)return void(this.xr.baseExperience.state===$i.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:!1,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 i=e.floorMeshes||[];if(!i.length){var n=this._scene.getMeshByName(e.floorMeshName);n&&i.push(n)}if(this.xr)return i.forEach((function(e){t.xr.teleportation.addFloorMesh(e)})),void(this.xr.teleportation.attached||this.xr.teleportation.attach());if(!this.xrTestDone){var r=function(){t.xrTestDone&&(t._scene.unregisterBeforeRender(r),t.xr?t.xr.teleportation.attached||t.xr.teleportation.attach():t.enableTeleportation(e))};return void this._scene.registerBeforeRender(r)}}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 ji.a;o.vignetteColor=new s.b(0,0,0,0),o.vignetteEnabled=!0,this._postProcessMove=new Yi("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(i){t._displayLaserPointer&&1===i.value&&(e._activePointer?e._deactivatePointer():e._activatePointer(),t.displayGaze&&(e._gazeTracker.isVisible=e._activePointer))})),e.webVRController.onTriggerStateChangedObservable.add((function(i){var n=e;t._noControllerIsActive&&(n=t._cameraGazer),n._pointerDownOnMeshAsked?i.valuet._padSensibilityUp&&n._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 i=a.b.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),n=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(i=this.currentVRCamera.deviceRotationQuaternion,n=this.currentVRCamera.devicePosition),i.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,a.b.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),a.e.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var r=new Xt.a(n,this._workingVector),o=this._scene.pickWithRay(r,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===Gt.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(i){t.teleportationEnabled&&(t._checkTeleportBackwards(i,e),t._checkTeleportWithRay(i,e)),t._checkRotate(i,e)})))},e.prototype._createTeleportationCircles=function(){this._teleportationTarget=be.a.CreateGround("teleportationTarget",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var e=new Hi.a("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 i=new Wi.a("TextPlaneMaterial",this._scene);i.diffuseTexture=e,this._teleportationTarget.material=i;var n=be.a.CreateTorus("torusTeleportation",.75,.1,25,this._scene,!1);n.isPickable=!1,n.parent=this._teleportationTarget;var r=new z("animationInnerCircle","position.y",30,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:0}),o.push({frame:30,value:.4}),o.push({frame:60,value:0}),r.setKeys(o);var a=new me;a.setEasingMode(oe.EASINGMODE_EASEINOUT),r.setEasingFunction(a),n.animations=[],n.animations.push(r),this._scene.beginAnimation(n,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 wt){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var i=a.b.FromRotationMatrix(a.a.RotationY(Math.PI/4*this._rotationAngle)),n=new z("animationRotation","rotationQuaternion",90,z.ANIMATIONTYPE_QUATERNION,z.ANIMATIONLOOPMODE_CONSTANT),r=[];r.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),r.push({frame:6,value:i}),n.setKeys(r),n.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(n),this._postProcessMove.animations=[];var o=new z("animationPP","vignetteWeight",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),s=[];s.push({frame:0,value:0}),s.push({frame:3,value:4}),s.push({frame:6,value:0}),o.setKeys(s),o.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(o);var c=new z("animationPP2","vignetteStretch",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),l=[];l.push({frame:0,value:0}),l.push({frame:3,value:10}),l.push({frame:6,value:0}),c.setKeys(l),c.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(c),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,i){if(e.pickedPoint){t._teleportationRequestInitiated&&(this._displayTeleportationTarget(),this._haloCenter.copyFrom(e.pickedPoint),this._teleportationTarget.position.copyFrom(e.pickedPoint));var n=this._convertNormalToDirectionOfRay(e.getNormal(!0,!1),i);if(n){var r=a.e.Cross(J.a.Y,n),o=a.e.Cross(n,r);a.e.RotationFromAxisToRef(o,n,r,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},e.prototype.teleportCamera=function(t){var i=this;if(this.currentVRCamera instanceof wt){this.webVRCamera.leftCamera?(this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),this._workingVector.subtractInPlace(this.webVRCamera.position),t.subtractToRef(this._workingVector,this._workingVector)):this._workingVector.copyFrom(t),this.isInVRMode?this._workingVector.y+=this.webVRCamera.deviceDistanceToRoomGround()*this._webVRCamera.deviceScaleFactor:this._workingVector.y+=this._defaultHeight,this.onBeforeCameraTeleport.notifyObservers(this._workingVector);var n,r;if(this._teleportationMode==e.TELEPORTATIONMODE_CONSTANTSPEED){r=90;var o=a.e.Distance(this.currentVRCamera.position,this._workingVector);n=this._teleportationSpeed/o}else r=Math.round(90*this._teleportationTime/1e3),n=1;this.currentVRCamera.animations=[];var s=new z("animationCameraTeleportation","position",90,z.ANIMATIONTYPE_VECTOR3,z.ANIMATIONLOOPMODE_CONSTANT),c=[{frame:0,value:this.currentVRCamera.position},{frame:r,value:this._workingVector}];s.setKeys(c),s.setEasingFunction(this._teleportationEasing),this.currentVRCamera.animations.push(s),this._postProcessMove.animations=[];var l=Math.round(r/2),u=new z("animationPP","vignetteWeight",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),h=[];h.push({frame:0,value:0}),h.push({frame:l,value:8}),h.push({frame:r,value:0}),u.setKeys(h),this._postProcessMove.animations.push(u);var d=new z("animationPP2","vignetteStretch",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),f=[];f.push({frame:0,value:0}),f.push({frame:l,value:10}),f.push({frame:r,value:0}),d.setKeys(f),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,r,!1,n,(function(){i._webVRCamera.detachPostProcess(i._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,r,!1,n,(function(){i.onAfterCameraTeleport.notifyObservers(i._workingVector)})),this._hideTeleportationTarget()}},e.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(a.e.Dot(e,t.direction))s){var c=s;s=a,a=c}return a>0&&a0&&s=0))},e.prototype._canDoCollision=function(e,t,i,n){var r=a.e.Distance(this._basePointWorld,e),o=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(r>this._velocityWorldLength+o+t)&&!!function(e,t,i,n){return!(e.x>i.x+n)&&(!(i.x-n>t.x)&&(!(e.y>i.y+n)&&(!(i.y-n>t.y)&&(!(e.z>i.z+n)&&!(i.z-n>t.z)))))}(i,n,this._basePointWorld,this._velocityWorldLength+o)},e.prototype._testTriangle=function(e,t,i,n,r,o,s){var c,l=!1;t||(t=[]),t[e]||(t[e]=new fn.a(0,0,0,0),t[e].copyFromPoints(i,n,r));var u=t[e];if(o||u.isFrontFacingTo(this._normalizedVelocity,0)){var h=u.signedDistanceTo(this._basePoint),d=a.e.Dot(u.normal,this._velocity);if(0==d){if(Math.abs(h)>=1)return;l=!0,c=0}else{var f=(1-h)/d;if((c=(-1-h)/d)>f){var p=f;f=c,c=p}if(c>1||f<0)return;c<0&&(c=0),c>1&&(c=1)}this._collisionPoint.copyFromFloats(0,0,0);var _=!1,m=1;if(l||(this._basePoint.subtractToRef(u.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(c,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,i,n,r,u.normal)&&(_=!0,m=c,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!_){var g=this._velocity.lengthSquared(),v=g;this._basePoint.subtractToRef(i,this._tempVector);var b=2*a.e.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,T=pn(v,b,y,m);T.found&&(m=T.root,_=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(n,this._tempVector),b=2*a.e.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(T=pn(v,b,y,m)).found&&(m=T.root,_=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(r,this._tempVector),b=2*a.e.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(T=pn(v,b,y,m)).found&&(m=T.root,_=!0,this._collisionPoint.copyFrom(r)),n.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex);var E=this._edge.lengthSquared(),S=a.e.Dot(this._edge,this._velocity),A=a.e.Dot(this._edge,this._baseToVertex);if(v=E*-g+S*S,b=E*(2*a.e.Dot(this._velocity,this._baseToVertex))-2*S*A,y=E*(1-this._baseToVertex.lengthSquared())+A*A,(T=pn(v,b,y,m)).found){var P=(S*T.root-A)/E;P>=0&&P<=1&&(m=T.root,_=!0,this._edge.scaleInPlace(P),i.addToRef(this._edge,this._collisionPoint))}r.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex),E=this._edge.lengthSquared(),S=a.e.Dot(this._edge,this._velocity),A=a.e.Dot(this._edge,this._baseToVertex),v=E*-g+S*S,b=E*(2*a.e.Dot(this._velocity,this._baseToVertex))-2*S*A,y=E*(1-this._baseToVertex.lengthSquared())+A*A,(T=pn(v,b,y,m)).found&&(P=(S*T.root-A)/E)>=0&&P<=1&&(m=T.root,_=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint)),i.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex),E=this._edge.lengthSquared(),S=a.e.Dot(this._edge,this._velocity),A=a.e.Dot(this._edge,this._baseToVertex),v=E*-g+S*S,b=E*(2*a.e.Dot(this._velocity,this._baseToVertex))-2*S*A,y=E*(1-this._baseToVertex.lengthSquared())+A*A,(T=pn(v,b,y,m)).found&&(P=(S*T.root-A)/E)>=0&&P<=1&&(m=T.root,_=!0,this._edge.scaleInPlace(P),r.addToRef(this._edge,this._collisionPoint))}if(_){var C=m*this._velocity.length();(!this.collisionFound||C=n)r.copyFrom(e);else{var s=o?o.collisionMask:i.collisionMask;i._initialize(e,t,a);for(var c=o&&o.surroundingMeshes||this._scene.meshes,l=0;lthis.capacity&&this._depth-1&&this.entries.splice(i,1)}},e.prototype.addEntries=function(e){for(var t=0;t=n.buttons.length?r[i]=n.axes[i-n.buttons.length].valueOf():r[i]=n.buttons[i].value}},e.prototype._getGamepadDeviceType=function(e){return-1!==e.indexOf("054c")?Pn.DualShock:-1!==e.indexOf("Xbox One")||-1!==e.search("Xbox 360")||-1!==e.search("xinput")?Pn.Xbox:-1!==e.indexOf("057e")?Pn.Switch:Pn.Generic},e._MAX_KEYCODES=255,e._MAX_POINTER_INPUTS=7,e}(),Nn=function(){function e(e,t,i){void 0===i&&(i=0),this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new o.c,this._deviceInputSystem=e}return e.prototype.getInput=function(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)},e}(),Ln=function(){function e(e){var t=this;this.onDeviceConnectedObservable=new o.c((function(e){t.getDevices().forEach((function(i){t.onDeviceConnectedObservable.notifyObserver(e,i)}))})),this.onDeviceDisconnectedObservable=new o.c;var i=Object.keys(Pn).length/2;this._devices=new Array(i),this._firstDevice=new Array(i),this._deviceInputSystem=Dn.Create(e),this._deviceInputSystem.onDeviceConnected=function(e,i){t._addDevice(e,i),t.onDeviceConnectedObservable.notifyObservers(t.getDeviceSource(e,i))},this._deviceInputSystem.onDeviceDisconnected=function(e,i){var n=t.getDeviceSource(e,i);t._removeDevice(e,i),t.onDeviceDisconnectedObservable.notifyObservers(n)},this._deviceInputSystem.onInputChanged||(this._deviceInputSystem.onInputChanged=function(e,i,n,r,o){var a;null===(a=t.getDeviceSource(e,i))||void 0===a||a.onInputChangedObservable.notifyObservers({inputIndex:n,previousState:r,currentState:o})})}return e.prototype.getDeviceSource=function(e,t){if(void 0===t){if(void 0===this._firstDevice[e])return null;t=this._firstDevice[e]}return this._devices[e]&&void 0!==this._devices[e][t]?this._devices[e][t]:null},e.prototype.getDeviceSources=function(e){return this._devices[e].filter((function(e){return!!e}))},e.prototype.getDevices=function(){var e=new Array;return this._devices.forEach((function(t){e.push.apply(e,t)})),e},e.prototype.dispose=function(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._deviceInputSystem.dispose()},e.prototype._addDevice=function(e,t){this._devices[e]||(this._devices[e]=new Array),this._devices[e][t]||(this._devices[e][t]=new Nn(this._deviceInputSystem,e,t),this._updateFirstDevices(e))},e.prototype._removeDevice=function(e,t){delete this._devices[e][t],this._updateFirstDevices(e)},e.prototype._updateFirstDevices=function(e){switch(e){case Pn.Keyboard:case Pn.Mouse:this._firstDevice[e]=0;break;case Pn.Touch:case Pn.DualShock:case Pn.Xbox:case Pn.Switch:case Pn.Generic:var t=this._devices[e];delete this._firstDevice[e];for(var i=0;ie.occlusionRetryCount))return!1;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==Ge.a.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var n=this.getScene();if(n.getBoundingBoxRenderer){var r=n.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery),r.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}return e.isOccluded};var Un=!0;Se.a.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},Se.a.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},Se.a.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},Se.a.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},Se.a.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},Se.a.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},Se.a.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e?e.underlyingResource:null)};i(126);qe.a.prototype.updateVideoTexture=function(e,t,i){if(e&&!e._isDisabled){var n=this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0);this._unpackFlipY(!i);try{if(void 0===this._videoTextureSupported&&(this._gl.getError(),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),0!==this._gl.getError()?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported)this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t);else{if(!e._workingCanvas){e._workingCanvas=Zi.a.CreateCanvas(e.width,e.height);var r=e._workingCanvas.getContext("2d");if(!r)throw new Error("Unable to get 2d context");e._workingContext=r,e._workingCanvas.width=e.width,e._workingCanvas.height=e.height}e._workingContext.clearRect(0,0,e.width,e.height),e._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,e.width,e.height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,e._workingCanvas)}e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),n||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}catch(t){e._isDisabled=!0}}},qe.a.prototype.restoreSingleAttachment=function(){var e=this._gl;this.bindAttachments([e.BACK])},qe.a.prototype.buildTextureLayout=function(e){for(var t=this._gl,i=[],n=0;n1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"],n.readBuffer(r[a]),n.drawBuffers(r),n.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,n.COLOR_BUFFER_BIT,n.NEAREST)}for(a=0;a1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];n.drawBuffers(r)}for(a=0;a1?"COLOR_ATTACHMENT"+y:"COLOR_ATTACHMENT"+y+"_WEBGL"];_.push(A),v.push(P),h.activeTexture(h["TEXTURE"+y]),h.bindTexture(h.TEXTURE_2D,A._webGLTexture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,S.mag),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,S.min),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(E),f,p,0,h.RGBA,this._getWebGLTextureType(E),null),h.framebufferTexture2D(h.DRAW_FRAMEBUFFER,P,h.TEXTURE_2D,A._webGLTexture,0),i&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(h.TEXTURE_2D,null),A._framebuffer=d,A._depthStencilBuffer=b,A.baseWidth=f,A.baseHeight=p,A.width=f,A.height=p,A.isReady=!0,A.samples=1,A.generateMipMaps=i,A.samplingMode=T,A.type=E,A._generateDepthBuffer=n,A._generateStencilBuffer=r,A._attachments=v,A._textureArray=_,this._internalTexturesCache.push(A)}if(o&&this._caps.depthTextureExtension){var C=new Qe.a(this,Qe.b.MultiRenderTarget);h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,C._webGLTexture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,this.webGLVersion<2?h.DEPTH_COMPONENT:h.DEPTH_COMPONENT16,f,p,0,h.DEPTH_COMPONENT,h.UNSIGNED_SHORT,null),h.framebufferTexture2D(h.FRAMEBUFFER,h.DEPTH_ATTACHMENT,h.TEXTURE_2D,C._webGLTexture,0),C._framebuffer=d,C.baseWidth=f,C.baseHeight=p,C.width=f,C.height=p,C.isReady=!0,C.samples=1,C.generateMipMaps=i,C.samplingMode=h.NEAREST,C._generateDepthBuffer=n,C._generateStencilBuffer=r,_.push(C),this._internalTexturesCache.push(C)}return h.drawBuffers(v),this._bindUnboundFramebuffer(null),this.resetTextureCache(),_},qe.a.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e[0].samples===t)return t;var i=e[0]._attachments.length;if(0===i)return 1;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 o=n.createFramebuffer();if(!o)throw new Error("Unable to create multi sampled framebuffer");this._bindUnboundFramebuffer(o);var a=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),s=[];for(r=0;r1?"COLOR_ATTACHMENT"+r:"COLOR_ATTACHMENT"+r+"_WEBGL"],u=n.createRenderbuffer();if(!u)throw new Error("Unable to create multi sampled framebuffer");n.bindRenderbuffer(n.RENDERBUFFER,u),n.renderbufferStorageMultisample(n.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(c.type),c.width,c.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,l,n.RENDERBUFFER,u),c._MSAAFramebuffer=o,c._MSAARenderBuffer=u,c.samples=t,c._depthStencilBuffer=a,n.bindRenderbuffer(n.RENDERBUFFER,null),s.push(l)}n.drawBuffers(s)}else this._bindUnboundFramebuffer(e[0]._framebuffer);return this._bindUnboundFramebuffer(null),t};var Vn=i(56);qe.a.prototype._createDepthStencilCubeTexture=function(e,t){var i=new Qe.a(this,Qe.b.Unknown);if(i.isCube=!0,1===this.webGLVersion)return m.a.Error("Depth cube texture is not supported by WebGL 1."),i;var n=Object(h.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),r=this._gl;this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,i,!0),this._setupDepthStencilTexture(i,e,n.generateStencil,n.bilinearFiltering,n.comparisonFunction);for(var o=0;o<6;o++)n.generateStencil?r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,r.DEPTH24_STENCIL8,e,e,0,r.DEPTH_STENCIL,r.UNSIGNED_INT_24_8,null):r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,r.DEPTH_COMPONENT24,e,e,0,r.DEPTH_COMPONENT,r.UNSIGNED_INT,null);return this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),i},qe.a.prototype._partialLoadFile=function(e,t,i,n,r){void 0===r&&(r=null);this._loadFile(e,(function(e){i[t]=e,i._internalCount++,6===i._internalCount&&n(i)}),void 0,void 0,!0,(function(e,t){r&&e&&r(e.status+" "+e.statusText,t)}))},qe.a.prototype._cascadeLoadFiles=function(e,t,i,n){void 0===n&&(n=null);var r=[];r._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(i[o],o,r,t,n)},qe.a.prototype._cascadeLoadImgs=function(e,t,i,n,r){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)this._partialLoadImg(i[a],a,o,e,t,n,r)},qe.a.prototype._partialLoadImg=function(e,t,i,n,r,o,a){var s;void 0===o&&(o=null);s=Vn.a.LoadImage(e,(function(){s&&(i[t]=s,i._internalCount++,n&&n._removePendingData(s)),6===i._internalCount&&r(i)}),(function(e,t){n&&n._removePendingData(s),o&&o(e,t)}),n?n.offlineProvider:null,a),n&&s&&n._addPendingData(s)},qe.a.prototype._setCubeMapTextureParams=function(e,t){var i=this._gl;i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),e.samplingMode=t?g.a.TEXTURE_TRILINEAR_SAMPLINGMODE:g.a.TEXTURE_LINEAR_LINEAR,this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)},qe.a.prototype.createCubeTexture=function(e,t,i,n,r,o,a,s,c,l,u,h,d){var f=this;void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=!1),void 0===l&&(l=0),void 0===u&&(u=0),void 0===h&&(h=null);var p=this._gl,_=h||new Qe.a(this,Qe.b.Cube);_.isCube=!0,_.url=e,_.generateMipMaps=!n,_._lodGenerationScale=l,_._lodGenerationOffset=u,this._doNotHandleContextLost||(_._extension=s,_._files=i);var g=e;this._transformTextureUrl&&!h&&(e=this._transformTextureUrl(e));for(var v=e.lastIndexOf("."),b=s||(v>-1?e.substring(v).toLowerCase():""),y=null,T=0,E=qe.a._TextureLoaders;T-1?e.substring(i,e.length):"";return(t>-1?e.substring(0,t):e)+this._textureFormatInUse+n}Object.defineProperty(Se.a.prototype,"texturesSupported",{get:function(){var e=new Array;return this._caps.astc&&e.push("-astc.ktx"),this._caps.s3tc&&e.push("-dxt.ktx"),this._caps.pvrtc&&e.push("-pvrtc.ktx"),this._caps.etc2&&e.push("-etc2.ktx"),this._caps.etc1&&e.push("-etc1.ktx"),e},enumerable:!0,configurable:!0}),Object.defineProperty(Se.a.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse||null},enumerable:!0,configurable:!0}),Se.a.prototype.setCompressedTextureExclusions=function(e){this._excludedCompressedTextures=e},Se.a.prototype.setTextureFormatToUse=function(e){for(var t=this.texturesSupported,i=0,n=t.length;i=0&&p.push(m.substring(g+1))}"void"!==a&&p.push("return"),this._functionDescr.push({name:s,type:a,parameters:p,body:d,callIndex:0}),t=h+1;var v=i>0?this._sourceCode.substring(0,i):"",b=h+1=0},e.prototype._extractBetweenMarkers=function(e,t,i,n){for(var r=n,o=0,a="";r0?this._sourceCode.substring(0,l):"",y=h+1=0){var s=t[r[o]];if(s){var c=s.getBuffer();c&&this._native.recordVertexBuffer(e,c.nativeVertexBuffer,a,s.byteOffset,s.byteStride,s.getSize(),this._getNativeAttribType(s.type),s.normalized)}}}},t.prototype.bindBuffers=function(e,t,i){this._boundBuffersVertexArray&&this._native.deleteVertexArray(this._boundBuffersVertexArray),this._boundBuffersVertexArray=this._native.createVertexArray(),this._recordVertexArrayObject(this._boundBuffersVertexArray,e,t,i),this._native.bindVertexArray(this._boundBuffersVertexArray)},t.prototype.recordVertexArrayObject=function(e,t,i){var n=this._native.createVertexArray();return this._recordVertexArrayObject(n,e,t,i),n},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 i=e;return this._native.getAttributes(i.nativeProgram,t)},t.prototype.drawElementsType=function(e,t,i,n){this._drawCalls.addCount(1,!1),this._native.drawIndexed(e,t,i)},t.prototype.drawArraysType=function(e,t,i,n){this._drawCalls.addCount(1,!1),this._native.draw(e,t,i)},t.prototype.createPipelineContext=function(){return new or},t.prototype._preparePipelineContext=function(e,t,i,n,r,o,a){var s=e;s.nativeProgram=n?this.createRawShaderProgram(e,t,i,void 0,a):this.createShaderProgram(e,t,i,o,void 0,a)},t.prototype._isRenderingStateCompiled=function(e){return!0},t.prototype._executeWhenRenderingStateIsCompiled=function(e,t){t()},t.prototype.createRawShaderProgram=function(e,t,i,n,r){throw void 0===r&&(r=null),new Error("Not Supported")},t.prototype.createShaderProgram=function(e,t,i,n,r,o){void 0===o&&(o=null),this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=new rr(t);a.processCode(),t=a.code;var s=new rr(i);s.processCode(),i=s.code,t=qe.a._ConcatenateShader(t,n),i=qe.a._ConcatenateShader(i,n);var c=this._native.createProgram(t,i);return this.onAfterShaderCompilationObservable.notifyObservers(this),c},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 i=e;return this._native.getUniforms(i.nativeProgram,t)},t.prototype.bindUniformBlock=function(e,t,i){throw new Error("Not Implemented")},t.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.nativeProgram);for(var i=e.getSamplers(),n=0;n-1?e.substring(y).toLowerCase():""),E=null,S=0,A=Se.a._TextureLoaders;S-1?e.substring(p).toLowerCase():""))){if(i&&6===i.length)throw new Error("Multi-file loading not allowed on env files.");this._loadFile(e,(function(e){return function(e){var t=ir.GetEnvInfo(e);if(f.width=t.width,f.height=t.width,ir.UploadEnvSpherical(f,t),1!==t.version)throw new Error('Unsupported babylon environment map version "'+t.version+'"');var i=t.specular;if(!i)throw new Error("Nothing else parsed so far");f._lodGenerationScale=i.lodGenerationScale;var n=ir.CreateImageDataArrayBufferViews(e,t);f.format=g.a.TEXTUREFORMAT_RGBA,f.type=g.a.TEXTURETYPE_UNSIGNED_INT,f.generateMipMaps=!0,f.getEngine().updateTextureSamplingMode(Ke.a.TRILINEAR_SAMPLINGMODE,f),f._isRGBD=!0,f.invertY=!0,d._native.loadCubeTextureWithMips(f._webGLTexture,n,(function(){f.isReady=!0,r&&r()}),(function(){throw new Error("Could not load a native cube texture.")}))}(new Uint8Array(e))}),void 0,void 0,!0,(function(e,t){o&&e&&o(e.status+" "+e.statusText,t)}))}else{if(!i||6!==i.length)throw new Error("Cannot load cubemap because 6 files were not defined");var _=[i[0],i[3],i[1],i[4],i[2],i[5]];Promise.all(_.map((function(e){return Ce.b.LoadFileAsync(e).then((function(e){return new Uint8Array(e)}))}))).then((function(e){return new Promise((function(t,i){d._native.loadCubeTexture(f._webGLTexture,e,!n,t,i)}))})).then((function(){f.isReady=!0,r&&r()}),(function(e){o&&o("Failed to load cubemap: "+e.message,e)}))}return this._internalTexturesCache.push(f),f},t.prototype.createRenderTargetTexture=function(e,t){var i=new ci.a;void 0!==t&&"object"==typeof t?(i.generateMipMaps=t.generateMipMaps,i.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&t.generateStencilBuffer,i.type=void 0===t.type?g.a.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?g.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,i.format=void 0===t.format?g.a.TEXTUREFORMAT_RGBA:t.format):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=g.a.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,i.format=g.a.TEXTUREFORMAT_RGBA),(i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==g.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=g.a.TEXTURE_NEAREST_SAMPLINGMODE);var n=new sr(this,Qe.b.RenderTarget),r=e.width||e,o=e.height||e;i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=g.a.TEXTURETYPE_UNSIGNED_INT,m.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var a=this._native.createFramebuffer(n._webGLTexture,r,o,this._getNativeTextureFormat(i.format,i.type),i.samplingMode,!!i.generateStencilBuffer,i.generateDepthBuffer,!!i.generateMipMaps);return n._framebuffer=a,n.baseWidth=r,n.baseHeight=o,n.width=r,n.height=o,n.isReady=!0,n.samples=1,n.generateMipMaps=!!i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n.format=i.format,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(n),n},t.prototype.updateTextureSamplingMode=function(e,t){if(t._webGLTexture){var i=this._getNativeSamplingMode(e);this._native.setTextureSampling(t._webGLTexture,i)}t.samplingMode=e},t.prototype.bindFramebuffer=function(e,t,i,n,r){if(t)throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");if(i||n)throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");e._depthStencilTexture?this._bindUnboundFramebuffer(e._depthStencilTexture._framebuffer):this._bindUnboundFramebuffer(e._framebuffer)},t.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),t&&m.a.Warn("Disabling mipmap generation not yet supported in NativeEngine. Ignoring."),i&&i(),this._bindUnboundFramebuffer(null)},t.prototype.createDynamicVertexBuffer=function(e){return this.createVertexBuffer(e,!0)},t.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0);var n=e,r=this._normalizeIndexData(t);n.is32Bits=4===r.BYTES_PER_ELEMENT,this._native.updateDynamicIndexBuffer(n.nativeIndexBuffer,r,i)},t.prototype.updateDynamicVertexBuffer=function(e,t,i,n){var r=e,o=ArrayBuffer.isView(t)?t:new Float32Array(t);this._native.updateDynamicVertexBuffer(r.nativeVertexBuffer,o,null!=i?i:0,null!=n?n:o.byteLength)},t.prototype._setTexture=function(e,t,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1);var r,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(t.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;return r=n?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,this._activeChannel=e,!(!r||!r._webGLTexture)&&(this._native.setTextureWrapMode(r._webGLTexture,this._getAddressMode(t.wrapU),this._getAddressMode(t.wrapV),this._getAddressMode(t.wrapR)),this._updateAnisotropicLevel(t),this._native.setTexture(o,r._webGLTexture),!0)},t.prototype._updateAnisotropicLevel=function(e){var t=e.getInternalTexture(),i=e.anisotropicFilteringLevel;t&&t._webGLTexture&&t._cachedAnisotropicFilteringLevel!==i&&(this._native.setTextureAnisotropicLevel(t._webGLTexture,i),t._cachedAnisotropicFilteringLevel=i)},t.prototype._getAddressMode=function(e){switch(e){case g.a.TEXTURE_WRAP_ADDRESSMODE:return this._native.ADDRESS_MODE_WRAP;case g.a.TEXTURE_CLAMP_ADDRESSMODE:return this._native.ADDRESS_MODE_CLAMP;case g.a.TEXTURE_MIRROR_ADDRESSMODE:return this._native.ADDRESS_MODE_MIRROR;default:throw new Error("Unexpected wrap mode: "+e+".")}},t.prototype._bindTexture=function(e,t){var i=this._boundUniforms[e];i&&this._native.setTexture(i,t._webGLTexture)},t.prototype._deleteBuffer=function(e){e.nativeIndexBuffer&&(this._native.deleteIndexBuffer(e.nativeIndexBuffer),delete e.nativeIndexBuffer),e.nativeVertexBuffer&&(this._native.deleteVertexBuffer(e.nativeVertexBuffer),delete e.nativeVertexBuffer)},t.prototype.releaseEffects=function(){},t.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,n,r,o,a){throw void 0===o&&(o=0),void 0===a&&(a=0),new Error("_uploadCompressedDataToTextureDirectly not implemented.")},t.prototype._uploadDataToTextureDirectly=function(e,t,i,n){throw void 0===i&&(i=0),void 0===n&&(n=0),new Error("_uploadDataToTextureDirectly not implemented.")},t.prototype._uploadArrayBufferViewToTexture=function(e,t,i,n){throw void 0===i&&(i=0),void 0===n&&(n=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._uploadImageToTexture=function(e,t,i,n){throw void 0===i&&(i=0),void 0===n&&(n=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._getNativeSamplingMode=function(e){switch(e){case g.a.TEXTURE_NEAREST_NEAREST:return this._native.TEXTURE_NEAREST_NEAREST;case g.a.TEXTURE_LINEAR_LINEAR:return this._native.TEXTURE_LINEAR_LINEAR;case g.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:return this._native.TEXTURE_LINEAR_LINEAR_MIPLINEAR;case g.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:return this._native.TEXTURE_NEAREST_NEAREST_MIPNEAREST;case g.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:return this._native.TEXTURE_NEAREST_LINEAR_MIPNEAREST;case g.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:return this._native.TEXTURE_NEAREST_LINEAR_MIPLINEAR;case g.a.TEXTURE_NEAREST_LINEAR:return this._native.TEXTURE_NEAREST_LINEAR;case g.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:return this._native.TEXTURE_NEAREST_NEAREST_MIPLINEAR;case g.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:return this._native.TEXTURE_LINEAR_NEAREST_MIPNEAREST;case g.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:return this._native.TEXTURE_LINEAR_NEAREST_MIPLINEAR;case g.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:return this._native.TEXTURE_LINEAR_LINEAR_MIPNEAREST;case g.a.TEXTURE_LINEAR_NEAREST:return this._native.TEXTURE_LINEAR_NEAREST;default:throw new Error("Unsupported sampling mode: "+e+".")}},t.prototype._getNativeTextureFormat=function(e,t){if(e==g.a.TEXTUREFORMAT_RGBA&&t==g.a.TEXTURETYPE_UNSIGNED_INT)return this._native.TEXTURE_FORMAT_RGBA8;if(e==g.a.TEXTUREFORMAT_RGBA&&t==g.a.TEXTURETYPE_FLOAT)return this._native.TEXTURE_FORMAT_RGBA32F;throw new Error("Unsupported texture format or type: format "+e+", type "+t+".")},t.prototype._getNativeAlphaMode=function(e){switch(e){case g.a.ALPHA_DISABLE:return this._native.ALPHA_DISABLE;case g.a.ALPHA_ADD:return this._native.ALPHA_ADD;case g.a.ALPHA_COMBINE:return this._native.ALPHA_COMBINE;case g.a.ALPHA_SUBTRACT:return this._native.ALPHA_SUBTRACT;case g.a.ALPHA_MULTIPLY:return this._native.ALPHA_MULTIPLY;case g.a.ALPHA_MAXIMIZED:return this._native.ALPHA_MAXIMIZED;case g.a.ALPHA_ONEONE:return this._native.ALPHA_ONEONE;case g.a.ALPHA_PREMULTIPLIED:return this._native.ALPHA_PREMULTIPLIED;case g.a.ALPHA_PREMULTIPLIED_PORTERDUFF:return this._native.ALPHA_PREMULTIPLIED_PORTERDUFF;case g.a.ALPHA_INTERPOLATE:return this._native.ALPHA_INTERPOLATE;case g.a.ALPHA_SCREENMODE:return this._native.ALPHA_SCREENMODE;default:throw new Error("Unsupported alpha mode: "+e+".")}},t.prototype._getNativeAttribType=function(e){switch(e){case Qi.b.UNSIGNED_BYTE:return this._native.ATTRIB_TYPE_UINT8;case Qi.b.SHORT:return this._native.ATTRIB_TYPE_INT16;case Qi.b.FLOAT:return this._native.ATTRIB_TYPE_FLOAT;default:throw new Error("Unsupported attribute type: "+e+".")}},t}(Se.a),lr=i(74),ur=function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}(),hr=function(){function e(e,t){this.type=e,this.event=t}return e.GetTypeFromCharacter=function(e){switch(e){case 67:return ur.COPY;case 86:return ur.PASTE;case 88:return ur.CUT;default:return-1}},e}(),dr=i(83),fr=i(69);!function(e){e[e.Clean=0]="Clean",e[e.Stop=1]="Stop",e[e.Sync=2]="Sync",e[e.NoSync=3]="NoSync"}(nr||(nr={}));var pr=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return fr.a.ForceFullSceneLoadingForIncremental},set:function(e){fr.a.ForceFullSceneLoadingForIncremental=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return fr.a.ShowLoadingScreen},set:function(e){fr.a.ShowLoadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return fr.a.loggingLevel},set:function(e){fr.a.loggingLevel=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return fr.a.CleanBoneMatrixWeights},set:function(e){fr.a.CleanBoneMatrixWeights=e},enumerable:!1,configurable:!0}),e.GetDefaultPlugin=function(){return e._registeredPlugins[".babylon"]},e._GetPluginForExtension=function(t){var i=e._registeredPlugins[t];return i||(m.a.Warn("Unable to find a plugin to load "+t+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type"),e.GetDefaultPlugin())},e._GetPluginForDirectLoad=function(t){for(var i in e._registeredPlugins){var n=e._registeredPlugins[i].plugin;if(n.canDirectLoad&&n.canDirectLoad(t))return e._registeredPlugins[i]}return e.GetDefaultPlugin()},e._GetPluginForFilename=function(t){var i=t.indexOf("?");-1!==i&&(t=t.substring(0,i));var n=t.lastIndexOf("."),r=t.substring(n,t.length).toLowerCase();return e._GetPluginForExtension(r)},e._GetDirectLoad=function(e){return"data:"===e.substr(0,5)?e.substr(5):null},e._LoadData=function(t,i,n,r,o,a,s){var c,l=e._GetDirectLoad(t.name),u=s?e._GetPluginForExtension(s):l?e._GetPluginForDirectLoad(t.name):e._GetPluginForFilename(t.name);if(!(c=void 0!==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(c),l){if(c.directLoad){var h=c.directLoad(i,l);h.then?h.then((function(e){n(c,e)})).catch((function(e){o("Error in directLoad of _loadData: "+e,e)})):n(c,h)}else n(c,l);return c}var d=u.isBinary,f=function(e,t){i.isDisposed?o("Scene has been disposed"):n(c,e,t)},p=null,_=!1,m=c.onDisposeObservable;m&&m.add((function(){_=!0,p&&(p.abort(),p=null),a()}));var g=function(){if(!_){var e=function(e,t){f(e,t?t.responseURL:void 0)},n=function(e){o(e.message,e)};p=c.requestFile?c.requestFile(i,t.url,e,r,d,n):i._requestFile(t.url,e,r,!0,d,n)}},v=t.file||dr.a.FilesToLoad[t.name.toLowerCase()];if(-1===t.rootUrl.indexOf("file:")||-1!==t.rootUrl.indexOf("file:")&&!v){var b=i.getEngine(),y=b.enableOfflineSupport;if(y){for(var T=!1,E=0,S=i.disableOfflineSupportExceptionRules;Em.snapDistance?(r=Math.floor(Math.abs(C)/m.snapDistance),C<0&&(r*=-1),C%=m.snapDistance,R.scaleToRef(m.snapDistance*r,R),n=!0):R.scaleInPlace(0)),a.a.ScalingToRef(1+R.x,1+R.y,1+R.z,m._tmpMatrix2),m._tmpMatrix2.multiplyToRef(m.attachedNode.getWorldMatrix(),m._tmpMatrix),m._tmpMatrix.decompose(m._tmpVector);Math.abs(m._tmpVector.x)<1e5&&Math.abs(m._tmpVector.y)<1e5&&Math.abs(m._tmpVector.z)<1e5&&m.attachedNode.getWorldMatrix().copyFrom(m._tmpMatrix),n&&(x.snapDistance=m.snapDistance*r,m.onSnapObservable.notifyObservers(x)),m._matrixChanged()}})),m.dragBehavior.onDragStartObservable.add((function(){m._dragging=!0})),m.dragBehavior.onDragObservable.add((function(e){return A(e.dragDistance)})),m.dragBehavior.onDragEndObservable.add(P),null===(h=null===(u=null===(l=null==r?void 0:r.uniformScaleGizmo)||void 0===l?void 0:l.dragBehavior)||void 0===u?void 0:u.onDragObservable)||void 0===h||h.add((function(e){return A(e.delta.y)})),null===(p=null===(f=null===(d=null==r?void 0:r.uniformScaleGizmo)||void 0===d?void 0:d.dragBehavior)||void 0===f?void 0:f.onDragEndObservable)||void 0===p||p.add(P);var O={gizmoMeshes:[v,b],colliderMeshes:[y.arrowMesh,y.arrowTail],material:m._coloredMaterial,hoverMaterial:m._hoverMaterial,disableMaterial:m._disableMaterial,active:!1};null===(_=m._parent)||void 0===_||_.addToAxisCache(m._gizmoMesh,O),m._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!m._customMeshSet&&(m._isHovered=!(-1==O.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!m._parent)){var i=m._isHovered||m._dragging?m._hoverMaterial:m._coloredMaterial;O.gizmoMeshes.forEach((function(e){e.material=i,e.color&&(e.color=i.diffuseColor)}))}}));var M=n._getSharedGizmoLight();return M.includedOnlyMeshes=M.includedOnlyMeshes.concat(m._rootMesh.getChildMeshes()),m}return Object(h.d)(t,e),t.prototype._createGizmoMesh=function(e,t,i){void 0===i&&(i=!1);var n=Ar.a.CreateBox("yPosMesh",{size:.4*(1+(t-1)/4)},this.gizmoLayer.utilityLayerScene),r=nn.a.CreateCylinder("cylinder",{diameterTop:.005*t,height:.275,diameterBottom:.005*t,tessellation:96},this.gizmoLayer.utilityLayerScene);return n.scaling.scaleInPlace(.1),n.material=this._coloredMaterial,n.rotation.x=Math.PI/2,n.position.z+=.3,r.material=this._coloredMaterial,r.position.z+=.1375,r.rotation.x=Math.PI/2,i&&(n.visibility=0,r.visibility=0),e.addChild(n),e.addChild(r),{arrowMesh:n,arrowTail:r}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh,this.attachedNode=this._parent.attachedNode):(this.attachedMesh=null,this.attachedNode=null)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t.prototype.setCustomMesh=function(t,i){var n=this;void 0===i&&(i=!1),e.prototype.setCustomMesh.call(this,t),i&&(this._rootMesh.getChildMeshes().forEach((function(e){e.material=n._coloredMaterial,e.color&&(e.color=n._coloredMaterial.diffuseColor)})),this._customMeshSet=!1)},t}(Pr.a),xr=i(45),Or=i(40),Mr=function(e){function t(t,i){void 0===t&&(t=s.a.Gray()),void 0===i&&(i=Cr.a.DefaultKeepDepthUtilityLayer);var n=e.call(this,i)||this;n._boundingDimensions=new a.e(1,1,1),n._renderObserver=null,n._pointerObserver=null,n._scaleDragSpeed=.2,n._tmpQuaternion=new a.b,n._tmpVector=new a.e(0,0,0),n._tmpRotationMatrix=new a.a,n.ignoreChildren=!1,n.includeChildPredicate=null,n.rotationSphereSize=.1,n.scaleBoxSize=.1,n.fixedDragMeshScreenSize=!1,n.fixedDragMeshBoundsSize=!1,n.fixedDragMeshScreenSizeDistanceFactor=10,n.onDragStartObservable=new o.c,n.onScaleBoxDragObservable=new o.c,n.onScaleBoxDragEndObservable=new o.c,n.onRotationSphereDragObservable=new o.c,n.onRotationSphereDragEndObservable=new o.c,n.scalePivot=null,n._existingMeshScale=new a.e,n._dragMesh=null,n.pointerDragBehavior=new ke.a,n.updateScale=!1,n._anchorMesh=new Ge.a("anchor",i.utilityLayerScene),n.coloredMaterial=new Wi.a("",i.utilityLayerScene),n.coloredMaterial.disableLighting=!0,n.hoverColoredMaterial=new Wi.a("",i.utilityLayerScene),n.hoverColoredMaterial.disableLighting=!0,n._lineBoundingBox=new Ge.a("",i.utilityLayerScene),n._lineBoundingBox.rotationQuaternion=new a.b;var r=[];r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,0),new a.e(n._boundingDimensions.x,0,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,0),new a.e(0,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,0),new a.e(0,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,0,0),new a.e(n._boundingDimensions.x,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,0,0),new a.e(n._boundingDimensions.x,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,n._boundingDimensions.y,0),new a.e(n._boundingDimensions.x,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,n._boundingDimensions.y,0),new a.e(0,n._boundingDimensions.y,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,n._boundingDimensions.z),new a.e(n._boundingDimensions.x,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,n._boundingDimensions.z),new a.e(0,n._boundingDimensions.y,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z),new a.e(0,n._boundingDimensions.y,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z),new a.e(n._boundingDimensions.x,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z),new a.e(n._boundingDimensions.x,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.forEach((function(e){e.color=t,e.position.addInPlace(new a.e(-n._boundingDimensions.x/2,-n._boundingDimensions.y/2,-n._boundingDimensions.z/2)),e.isPickable=!1,n._lineBoundingBox.addChild(e)})),n._rootMesh.addChild(n._lineBoundingBox),n.setColor(t),n._rotateSpheresParent=new Ge.a("",i.utilityLayerScene),n._rotateSpheresParent.rotationQuaternion=new a.b;for(var c=function(e){var t=xr.a.CreateSphere("",{diameter:1},i.utilityLayerScene);t.rotationQuaternion=new a.b,t.material=l.coloredMaterial,(f=new ke.a({})).moveAttached=!1,f.updateDragPlane=!1,t.addBehavior(f);var r=new a.e(1,0,0),o=0;f.onDragStartObservable.add((function(){r.copyFrom(t.forward),o=0})),f.onDragObservable.add((function(t){if(n.onRotationSphereDragObservable.notifyObservers({}),n.attachedMesh){var i=n.attachedMesh.parent;if(i&&i.scaling&&i.scaling.isNonUniformWithinEpsilon(.001))return void m.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");We.a._RemoveAndStorePivotPoint(n.attachedMesh);var s=r,c=t.dragPlaneNormal.scale(a.e.Dot(t.dragPlaneNormal,s)),l=s.subtract(c).normalizeToNew(),u=a.e.Dot(l,t.delta)<0?Math.abs(t.delta.length()):-Math.abs(t.delta.length());u=u/n._boundingDimensions.length()*n._anchorMesh.scaling.length(),n.attachedMesh.rotationQuaternion||(n.attachedMesh.rotationQuaternion=a.b.RotationYawPitchRoll(n.attachedMesh.rotation.y,n.attachedMesh.rotation.x,n.attachedMesh.rotation.z)),n._anchorMesh.rotationQuaternion||(n._anchorMesh.rotationQuaternion=a.b.RotationYawPitchRoll(n._anchorMesh.rotation.y,n._anchorMesh.rotation.x,n._anchorMesh.rotation.z)),o+=u,Math.abs(o)<=2*Math.PI&&(e>=8?a.b.RotationYawPitchRollToRef(0,0,u,n._tmpQuaternion):e>=4?a.b.RotationYawPitchRollToRef(u,0,0,n._tmpQuaternion):a.b.RotationYawPitchRollToRef(0,u,0,n._tmpQuaternion),n._anchorMesh.addChild(n.attachedMesh),n._anchorMesh.rotationQuaternion.multiplyToRef(n._tmpQuaternion,n._anchorMesh.rotationQuaternion),n._anchorMesh.removeChild(n.attachedMesh),n.attachedMesh.setParent(i)),n.updateBoundingBox(),We.a._RestorePivotPoint(n.attachedMesh)}n._updateDummy()})),f.onDragStartObservable.add((function(){n.onDragStartObservable.notifyObservers({}),n._selectNode(t)})),f.onDragEndObservable.add((function(){n.onRotationSphereDragEndObservable.notifyObservers({}),n._selectNode(null),n._updateDummy()})),l._rotateSpheresParent.addChild(t)},l=this,u=0;u<12;u++)c(u);n._rootMesh.addChild(n._rotateSpheresParent),n._scaleBoxesParent=new Ge.a("",i.utilityLayerScene),n._scaleBoxesParent.rotationQuaternion=new a.b;for(var h=0;h<3;h++)for(var d=0;d<3;d++)for(var f,p=function(){var e=(1===h?1:0)+(1===d?1:0)+(1===g?1:0);if(1===e||3===e)return"continue";var t=Ar.a.CreateBox("",{size:1},i.utilityLayerScene);t.material=_.coloredMaterial,t.metadata=2===e;var r=new a.e(h-1,d-1,g-1).normalize();(f=new ke.a({dragAxis:r})).updateDragPlane=!1,f.moveAttached=!1,t.addBehavior(f),f.onDragObservable.add((function(i){if(n.onScaleBoxDragObservable.notifyObservers({}),n.attachedMesh){var o=n.attachedMesh.parent;if(o&&o.scaling&&o.scaling.isNonUniformWithinEpsilon(.001))return void m.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");We.a._RemoveAndStorePivotPoint(n.attachedMesh);var s=i.dragDistance/n._boundingDimensions.length()*n._anchorMesh.scaling.length(),c=new a.e(s,s,s);2===e&&(c.x*=Math.abs(r.x),c.y*=Math.abs(r.y),c.z*=Math.abs(r.z)),c.scaleInPlace(n._scaleDragSpeed),n.updateBoundingBox(),n.scalePivot?(n.attachedMesh.getWorldMatrix().getRotationMatrixToRef(n._tmpRotationMatrix),n._boundingDimensions.scaleToRef(.5,n._tmpVector),a.e.TransformCoordinatesToRef(n._tmpVector,n._tmpRotationMatrix,n._tmpVector),n._anchorMesh.position.subtractInPlace(n._tmpVector),n._boundingDimensions.multiplyToRef(n.scalePivot,n._tmpVector),a.e.TransformCoordinatesToRef(n._tmpVector,n._tmpRotationMatrix,n._tmpVector),n._anchorMesh.position.addInPlace(n._tmpVector)):(t.absolutePosition.subtractToRef(n._anchorMesh.position,n._tmpVector),n._anchorMesh.position.subtractInPlace(n._tmpVector)),n._anchorMesh.addChild(n.attachedMesh),n._anchorMesh.scaling.addInPlace(c),(n._anchorMesh.scaling.x<0||n._anchorMesh.scaling.y<0||n._anchorMesh.scaling.z<0)&&n._anchorMesh.scaling.subtractInPlace(c),n._anchorMesh.removeChild(n.attachedMesh),n.attachedMesh.setParent(o),We.a._RestorePivotPoint(n.attachedMesh)}n._updateDummy()})),f.onDragStartObservable.add((function(){n.onDragStartObservable.notifyObservers({}),n._selectNode(t)})),f.onDragEndObservable.add((function(){n.onScaleBoxDragEndObservable.notifyObservers({}),n._selectNode(null),n._updateDummy()})),_._scaleBoxesParent.addChild(t)},_=this,g=0;g<3;g++)p();n._rootMesh.addChild(n._scaleBoxesParent);var v=new Array;return n._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){v[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=v[e.event.pointerId]&&(v[e.event.pointerId].material=n.coloredMaterial,delete v[e.event.pointerId]):n._rotateSpheresParent.getChildMeshes().concat(n._scaleBoxesParent.getChildMeshes()).forEach((function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(v[e.event.pointerId]=t,t.material=n.hoverColoredMaterial)}))})),n._renderObserver=n.gizmoLayer.originalScene.onBeforeRenderObservable.add((function(){n.attachedMesh&&!n._existingMeshScale.equals(n.attachedMesh.scaling)?n.updateBoundingBox():(n.fixedDragMeshScreenSize||n.fixedDragMeshBoundsSize)&&(n._updateRotationSpheres(),n._updateScaleBoxes()),n._dragMesh&&n.attachedMesh&&n.pointerDragBehavior.dragging&&(n._lineBoundingBox.position.rotateByQuaternionToRef(n._rootMesh.rotationQuaternion,n._tmpVector),n.attachedMesh.setAbsolutePosition(n._dragMesh.position.add(n._tmpVector.scale(-1))))})),n.updateBoundingBox(),n}return Object(h.d)(t,e),t.prototype.setColor=function(e){this.coloredMaterial.emissiveColor=e,this.hoverColoredMaterial.emissiveColor=e.clone().add(new s.a(.3,.3,.3)),this._lineBoundingBox.getChildren().forEach((function(t){t.color&&(t.color=e)}))},t.prototype._attachedNodeChanged=function(e){var t=this;if(e){We.a._RemoveAndStorePivotPoint(e);var i=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(i),We.a._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){We.a._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=a.b.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=a.b.RotationYawPitchRoll(this._anchorMesh.rotation.y,this._anchorMesh.rotation.x,this._anchorMesh.rotation.z)),this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpVector.copyFrom(this.attachedMesh.position),this.attachedMesh.rotationQuaternion.set(0,0,0,1),this.attachedMesh.position.set(0,0,0);var i=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);i.max.subtractToRef(i.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((i.max.x+i.min.x)/2,(i.max.y+i.min.y)/2,(i.max.z+i.min.z)/2),this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),this._lineBoundingBox.computeWorldMatrix(),this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),this.attachedMesh.position.copyFrom(this._tmpVector),this.attachedMesh.setParent(e),this.attachedMesh.skeleton&&(this.attachedMesh.skeleton.overrideMesh=t)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),We.a._RestorePivotPoint(this.attachedMesh))},t.prototype._updateRotationSpheres=function(){for(var e=this._rotateSpheresParent.getChildMeshes(),t=0;t<3;t++)for(var i=0;i<2;i++)for(var n=0;n<2;n++){var r=4*t+2*i+n;if(0==t&&(e[r].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*i,this._boundingDimensions.z*n),e[r].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(a.e.Cross(e[r].position.normalizeToNew(),a.e.Right()).normalizeToNew().add(e[r].position))),1==t&&(e[r].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y/2,this._boundingDimensions.z*n),e[r].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(a.e.Cross(e[r].position.normalizeToNew(),a.e.Up()).normalizeToNew().add(e[r].position))),2==t&&(e[r].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y*n,this._boundingDimensions.z/2),e[r].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(a.e.Cross(e[r].position.normalizeToNew(),a.e.Forward()).normalizeToNew().add(e[r].position))),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[r].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var o=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[r].scaling.set(o,o,o)}else this.fixedDragMeshBoundsSize?e[r].scaling.set(this.rotationSphereSize*this._boundingDimensions.x,this.rotationSphereSize*this._boundingDimensions.y,this.rotationSphereSize*this._boundingDimensions.z):e[r].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}},t.prototype._updateScaleBoxes=function(){for(var e=this._scaleBoxesParent.getChildMeshes(),t=0,i=0;i<3;i++)for(var n=0;n<3;n++)for(var r=0;r<3;r++){var o=(1===i?1:0)+(1===n?1:0)+(1===r?1:0);if(1!==o&&3!==o){if(e[t])if(e[t].position.set(this._boundingDimensions.x*(i/2),this._boundingDimensions.y*(n/2),this._boundingDimensions.z*(r/2)),e[t].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[t].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var s=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[t].scaling.set(s,s,s)}else this.fixedDragMeshBoundsSize?e[t].scaling.set(this.scaleBoxSize*this._boundingDimensions.x,this.scaleBoxSize*this._boundingDimensions.y,this.scaleBoxSize*this._boundingDimensions.z):e[t].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize);t++}}},t.prototype.setEnabledRotationAxis=function(e){this._rotateSpheresParent.getChildMeshes().forEach((function(t,i){i<4?t.setEnabled(-1!=e.indexOf("x")):i<8?t.setEnabled(-1!=e.indexOf("y")):t.setEnabled(-1!=e.indexOf("z"))}))},t.prototype.setEnabledScaling=function(e,t){void 0===t&&(t=!1),this._scaleBoxesParent.getChildMeshes().forEach((function(i,n){var r=e;t&&!0===i.metadata&&(r=!1),i.setEnabled(r)}))},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=be.a.CreateBox("dummy",1,this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new a.b,this.pointerDragBehavior.useObjectOrientationForDragging=!1,this._dragMesh.addBehavior(this.pointerDragBehavior)},t.prototype.dispose=function(){this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),this._lineBoundingBox.dispose(),this._rotateSpheresParent.dispose(),this._scaleBoxesParent.dispose(),this._dragMesh&&this._dragMesh.dispose(),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=a.b.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var i=e.position.clone(),n=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var r=Ar.a.CreateBox("box",{size:1},e.getScene()),o=e.getHierarchyBoundingVectors();return o.max.subtractToRef(o.min,r.scaling),0===r.scaling.y&&(r.scaling.y=Nt.a),0===r.scaling.x&&(r.scaling.x=Nt.a),0===r.scaling.z&&(r.scaling.z=Nt.a),r.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(r),e.rotationQuaternion.copyFrom(n),e.position.copyFrom(i),e.removeChild(r),r.addChild(e),r.visibility=0,r},t.prototype.setCustomMesh=function(e){m.a.Error("Custom meshes are not supported on this gizmo")},t}(Pr.a),Ir=function(e){function t(t,i,n,r,c,l,u){var h;void 0===i&&(i=s.a.Gray()),void 0===n&&(n=Cr.a.DefaultUtilityLayer),void 0===r&&(r=32),void 0===c&&(c=null),void 0===l&&(l=!1),void 0===u&&(u=1);var d=e.call(this,n)||this;d._pointerObserver=null,d.snapDistance=0,d.onSnapObservable=new o.c,d._isEnabled=!0,d._parent=null,d._dragging=!1,d._parent=c,d._coloredMaterial=new Wi.a("",n.utilityLayerScene),d._coloredMaterial.diffuseColor=i,d._coloredMaterial.specularColor=i.subtract(new s.a(.1,.1,.1)),d._hoverMaterial=new Wi.a("",n.utilityLayerScene),d._hoverMaterial.diffuseColor=s.a.Yellow(),d._disableMaterial=new Wi.a("",n.utilityLayerScene),d._disableMaterial.diffuseColor=s.a.Gray(),d._disableMaterial.alpha=.4,d._gizmoMesh=new be.a("",n.utilityLayerScene);var f=d._createGizmoMesh(d._gizmoMesh,u,r),p=f.rotationMesh,_=f.collider,m=[];d._rotationCircle=d.setupRotationCircle(m,d._gizmoMesh),d._gizmoMesh.lookAt(d._rootMesh.position.add(t)),d._rootMesh.addChild(d._gizmoMesh),d._gizmoMesh.scaling.scaleInPlace(1/3),d.dragBehavior=new ke.a({dragPlaneNormal:t}),d.dragBehavior.moveAttached=!1,d.dragBehavior.maxDragAngle=9*Math.PI/20,d.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,d._rootMesh.addBehavior(d.dragBehavior);var g=0,v=new a.e,b=new a.e,y=new a.a,T=new a.e,E=new a.e;d.dragBehavior.onDragStartObservable.add((function(e){if(d.attachedNode){v.copyFrom(e.dragPlanePoint);var t=new a.e(0,0,1),i=d._rotationCircle.getDirection(t);i.normalize(),d._gizmoMesh.removeChild(d._rotationCircle),v.copyFrom(e.dragPlanePoint),b=e.dragPlanePoint;var n=d._rotationCircle.getAbsolutePosition().clone(),r=d._rotationCircle.getAbsolutePosition().clone().addInPlace(i),o=e.dragPlanePoint,s=a.e.GetAngleBetweenVectors(r.subtract(n),o.subtract(n),d._rotationCircle.up);d._rotationCircle.addRotation(0,s,0),d._dragging=!0}})),d.dragBehavior.onDragEndObservable.add((function(){g=0,d.updateRotationCircle(d._rotationCircle,m,g,b),d._gizmoMesh.addChild(d._rotationCircle),d._dragging=!1}));var S={snapDistance:0},A=0,P=new a.a,C=new a.b;d.dragBehavior.onDragObservable.add((function(e){if(d.attachedNode){var i=new a.e(1,1,1),r=new a.b(0,0,0,1),o=new a.e(0,0,0);d.attachedNode.getWorldMatrix().decompose(i,r,o);var s=e.dragPlanePoint.subtract(o).normalize(),c=v.subtract(o).normalize(),l=a.e.Cross(s,c),u=a.e.Dot(s,c),h=Math.atan2(l.length(),u);T.copyFrom(t),E.copyFrom(t),d.updateGizmoRotationToMatchAttachedMesh&&(r.toRotationMatrix(y),E=a.e.TransformCoordinates(T,y));var f=!1;if(n.utilityLayerScene.activeCamera){var p=n.utilityLayerScene.activeCamera.position.subtract(o);a.e.Dot(p,E)>0&&(T.scaleInPlace(-1),E.scaleInPlace(-1),f=!0)}a.e.Dot(E,l)>0&&(h=-h);var _=!1;if(0!=d.snapDistance)if(A+=h,Math.abs(A)>d.snapDistance){var R=Math.floor(Math.abs(A)/d.snapDistance);A<0&&(R*=-1),A%=d.snapDistance,h=d.snapDistance*R,_=!0}else h=0;g+=f?-h:h,d.updateRotationCircle(d._rotationCircle,m,g,b);var x=Math.sin(h/2);if(C.set(T.x*x,T.y*x,T.z*x,Math.cos(h/2)),P.determinant()>0){var O=new a.e;C.toEulerAnglesToRef(O),a.b.RotationYawPitchRollToRef(O.y,-O.x,-O.z,C)}d.updateGizmoRotationToMatchAttachedMesh?r.multiplyToRef(C,r):C.multiplyToRef(r,r),d.attachedNode.getWorldMatrix().copyFrom(a.a.Compose(i,r,o)),v.copyFrom(e.dragPlanePoint),_&&(S.snapDistance=h,d.onSnapObservable.notifyObservers(S)),d._matrixChanged()}}));var R=n._getSharedGizmoLight();R.includedOnlyMeshes=R.includedOnlyMeshes.concat(d._rootMesh.getChildMeshes(!1));var x={colliderMeshes:[_],gizmoMeshes:[p],material:d._coloredMaterial,hoverMaterial:d._hoverMaterial,disableMaterial:d._disableMaterial,active:!1};return null===(h=d._parent)||void 0===h||h.addToAxisCache(d._gizmoMesh,x),d._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!d._customMeshSet&&(d._isHovered=!(-1==x.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!d._parent)){var i=d._isHovered||d._dragging?d._hoverMaterial:d._coloredMaterial;x.gizmoMeshes.forEach((function(e){e.material=i,e.color&&(e.color=i.diffuseColor)}))}})),d}return Object(h.d)(t,e),t.prototype._createGizmoMesh=function(e,t,i){var n=be.a.CreateTorus("ignore",.6,.03*t,i,this.gizmoLayer.utilityLayerScene);n.visibility=0;var r=be.a.CreateTorus("",.6,.005*t,i,this.gizmoLayer.utilityLayerScene);return r.material=this._coloredMaterial,r.rotation.x=Math.PI/2,n.rotation.x=Math.PI/2,e.addChild(r),e.addChild(n),{rotationMesh:r,collider:n}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},t.prototype.setupRotationCircle=function(e,i){for(var n=t._CircleConstants.pi2/t._CircleConstants.tessellation,r=-Math.PI/2;r0?c:-1*c,u=i>0?o:-1*o;a[s].set(t._CircleConstants.radius*Math.sin(l)*Math.cos(u),0,t._CircleConstants.radius*Math.cos(l)*Math.cos(u))}else a[s].set(0,0,0);s++}r++}},t.prototype.updateRotationCircle=function(e,t,i,n){this.updateRotationPath(t,i),be.a.CreateRibbon("rotationCircle",t,!1,!1,0,this.gizmoLayer.utilityLayerScene,void 0,void 0,e.geometry?e:void 0)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh):this.attachedMesh=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),this._rotationCircle&&this._rotationCircle.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t._CircleConstants={radius:.3,pi2:2*Math.PI,tessellation:70,rotationCircleRange:4},t}(Pr.a),Dr=function(e){function t(t,i,n,r,c){void 0===t&&(t=Cr.a.DefaultUtilityLayer),void 0===i&&(i=32),void 0===n&&(n=!1),void 0===r&&(r=1);var l=e.call(this,t)||this;return l.onDragStartObservable=new o.c,l.onDragEndObservable=new o.c,l._observables=[],l._gizmoAxisCache=new Map,l.xGizmo=new Ir(new a.e(1,0,0),s.a.Red().scale(.5),t,i,l,n,r),l.yGizmo=new Ir(new a.e(0,1,0),s.a.Green().scale(.5),t,i,l,n,r),l.zGizmo=new Ir(new a.e(0,0,1),s.a.Blue().scale(.5),t,i,l,n,r),[l.xGizmo,l.yGizmo,l.zGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){l.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){l.onDragEndObservable.notifyObservers({})}))})),l.attachedMesh=null,l.attachedNode=null,c?c.addToAxisCache(l._gizmoAxisCache):Pr.a.GizmoAxisPointerObserver(t,l._gizmoAxisCache),l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),t.prototype._checkBillboardTransform=function(){this._nodeAttached&&this._nodeAttached.billboardMode&&console.log("Rotation Gizmo will not work with transforms in billboard mode.")},Object.defineProperty(t.prototype,"isHovered",{get:function(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){e=e||t.isHovered})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.dispose=function(){var e=this;this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear(),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)}))},t.prototype.setCustomMesh=function(e){m.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}(Pr.a),Nr=i(46),Lr=i(84),wr=function(e){function t(i,n,r,c){var l;void 0===n&&(n=s.a.Gray()),void 0===r&&(r=Cr.a.DefaultUtilityLayer),void 0===c&&(c=null);var u=e.call(this,r)||this;u._pointerObserver=null,u.snapDistance=0,u.onSnapObservable=new o.c,u._isEnabled=!1,u._parent=null,u._dragging=!1,u._parent=c,u._coloredMaterial=new Wi.a("",r.utilityLayerScene),u._coloredMaterial.diffuseColor=n,u._coloredMaterial.specularColor=n.subtract(new s.a(.1,.1,.1)),u._hoverMaterial=new Wi.a("",r.utilityLayerScene),u._hoverMaterial.diffuseColor=s.a.Yellow(),u._disableMaterial=new Wi.a("",r.utilityLayerScene),u._disableMaterial.diffuseColor=s.a.Gray(),u._disableMaterial.alpha=.4,u._gizmoMesh=t._CreatePlane(r.utilityLayerScene,u._coloredMaterial),u._gizmoMesh.lookAt(u._rootMesh.position.add(i)),u._gizmoMesh.scaling.scaleInPlace(1/3),u._gizmoMesh.parent=u._rootMesh;var h=0,d=new a.e,f={snapDistance:0};u.dragBehavior=new ke.a({dragPlaneNormal:i}),u.dragBehavior.moveAttached=!1,u._rootMesh.addBehavior(u.dragBehavior),u.dragBehavior.onDragObservable.add((function(e){if(u.attachedNode){if(0==u.snapDistance)u.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x,e.delta.y,e.delta.z);else if(h+=e.dragDistance,Math.abs(h)>u.snapDistance){var t=Math.floor(Math.abs(h)/u.snapDistance);h%=u.snapDistance,e.delta.normalizeToRef(d),d.scaleInPlace(u.snapDistance*t),u.attachedNode.getWorldMatrix().addTranslationFromFloats(d.x,d.y,d.z),f.snapDistance=u.snapDistance*t,u.onSnapObservable.notifyObservers(f)}u._matrixChanged()}})),u.dragBehavior.onDragStartObservable.add((function(){u._dragging=!0})),u.dragBehavior.onDragEndObservable.add((function(){u._dragging=!1}));var p=r._getSharedGizmoLight();p.includedOnlyMeshes=p.includedOnlyMeshes.concat(u._rootMesh.getChildMeshes(!1));var _={gizmoMeshes:u._gizmoMesh.getChildMeshes(),colliderMeshes:u._gizmoMesh.getChildMeshes(),material:u._coloredMaterial,hoverMaterial:u._hoverMaterial,disableMaterial:u._disableMaterial,active:!1};return null===(l=u._parent)||void 0===l||l.addToAxisCache(u._gizmoMesh,_),u._pointerObserver=r.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!u._customMeshSet&&(u._isHovered=!(-1==_.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!u._parent)){var i=u._isHovered||u._dragging?u._hoverMaterial:u._coloredMaterial;_.gizmoMeshes.forEach((function(e){e.material=i}))}})),u}return Object(h.d)(t,e),t._CreatePlane=function(e,t){var i=new Nr.a("plane",e),n=Lr.a.CreatePlane("dragPlane",{width:.1375,height:.1375,sideOrientation:2},e);return n.material=t,n.parent=i,i},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedNode=this._parent.attachedNode):this.attachedNode=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()}))},t}(Pr.a),Fr=function(e){function t(t,i,n){void 0===t&&(t=Cr.a.DefaultUtilityLayer),void 0===i&&(i=1);var r=e.call(this,t)||this;return r._meshAttached=null,r._nodeAttached=null,r._observables=[],r._gizmoAxisCache=new Map,r.onDragStartObservable=new o.c,r.onDragEndObservable=new o.c,r._planarGizmoEnabled=!1,r.xGizmo=new Sr.a(new a.e(1,0,0),s.a.Red().scale(.5),t,r,i),r.yGizmo=new Sr.a(new a.e(0,1,0),s.a.Green().scale(.5),t,r,i),r.zGizmo=new Sr.a(new a.e(0,0,1),s.a.Blue().scale(.5),t,r,i),r.xPlaneGizmo=new wr(new a.e(1,0,0),s.a.Red().scale(.5),r.gizmoLayer,r),r.yPlaneGizmo=new wr(new a.e(0,1,0),s.a.Green().scale(.5),r.gizmoLayer,r),r.zPlaneGizmo=new wr(new a.e(0,0,1),s.a.Blue().scale(.5),r.gizmoLayer,r),[r.xGizmo,r.yGizmo,r.zGizmo,r.xPlaneGizmo,r.yPlaneGizmo,r.zPlaneGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){r.onDragEndObservable.notifyObservers({})}))})),r.attachedMesh=null,n?n.addToAxisCache(r._gizmoAxisCache):Pr.a.GizmoAxisPointerObserver(t,r._gizmoAxisCache),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=null,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){e=e||t.isHovered})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"planarGizmoEnabled",{get:function(){return this._planarGizmoEnabled},set:function(e){var t=this;this._planarGizmoEnabled=e,[this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(i){i&&(i.isEnabled=e,e&&(i.attachedMesh?i.attachedMesh=t.attachedMesh:i.attachedNode=t.attachedNode))}),this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){this._updateGizmoRotationToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.updateGizmoRotationToMatchAttachedMesh=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this._snapDistance},set:function(e){this._snapDistance=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.snapDistance=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.scaleRatio=e)}))},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.dispose=function(){var e=this;[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(e){e&&e.dispose()})),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)})),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){m.a.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)")},t}(Pr.a);Ki.a.CreatePolyhedron=function(e){var t=[];t[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},t[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},t[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},t[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},t[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},t[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},t[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},t[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},t[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},t[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},t[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},t[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},t[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},t[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},t[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var i,n,r,o,c,l,u=e.type&&(e.type<0||e.type>=t.length)?0:e.type||0,h=e.size,d=e.sizeX||h||1,f=e.sizeY||h||1,p=e.sizeZ||h||1,_=e.custom||t[u],m=_.face.length,g=e.faceUV||new Array(m),v=e.faceColors,b=void 0===e.flat||e.flat,y=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE,T=new Array,E=new Array,S=new Array,A=new Array,P=new Array,C=0,R=0,x=new Array,O=0,M=0;if(b)for(M=0;M0&&e.forEach((function(e,i){t._gizmoAxisCache.set(i,e)}))},e.prototype.dispose=function(){var e=this;for(var t in this._pointerObservers.forEach((function(t){e.scene.onPointerObservable.remove(t)})),this.gizmos){var i=this.gizmos[t];i&&i.dispose()}this._defaultKeepDepthUtilityLayer.dispose(),this._defaultUtilityLayer.dispose(),this.boundingBoxDragBehavior.detach(),this.onAttachedToMeshObservable.clear()},e}(),kr=i(48),zr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._needProjectionMatrixCompute=!0,t}return Object(h.d)(t,e),t.prototype._setPosition=function(e){this._position=e},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._setPosition(e)},enumerable:!1,configurable:!0}),t.prototype._setDirection=function(e){this._direction=e},Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},set:function(e){this._setDirection(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),t.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=a.e.Zero()),a.e.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=a.e.Zero()),a.e.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},t.prototype.getDepthScale=function(){return 50},t.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},t.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},t.prototype.setDirectionToTarget=function(e){return this.direction=a.e.Normalize(e.subtract(this.position)),this.direction},t.prototype.getRotation=function(){this.direction.normalize();var e=a.e.Cross(this.direction,J.a.Y),t=a.e.Cross(e,this.direction);return a.e.RotationFromAxis(e,t,this.direction)},t.prototype.needCube=function(){return!1},t.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},t.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.position=a.e.Zero()},t.prototype._isSynchronized=function(){return!!this._cache.position.equals(this.position)},t.prototype.computeWorldMatrix=function(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=a.a.Identity()),a.a.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix)},t.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},t.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},t.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},Object(h.c)([Object(w.o)()],t.prototype,"position",null),Object(h.c)([Object(w.o)()],t.prototype,"direction",null),Object(h.c)([Object(w.c)()],t.prototype,"shadowMinZ",null),Object(h.c)([Object(w.c)()],t.prototype,"shadowMaxZ",null),t}(kr.a);B.a.AddNodeConstructor("Light_Type_1",(function(e,t){return function(){return new Gr(e,a.e.Zero(),t)}}));var Gr=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r._shadowFrustumSize=0,r._shadowOrthoScale=.1,r.autoUpdateExtends=!0,r.autoCalcShadowZBounds=!1,r._orthoLeft=Number.MAX_VALUE,r._orthoRight=Number.MIN_VALUE,r._orthoTop=Number.MIN_VALUE,r._orthoBottom=Number.MAX_VALUE,r.position=i.scale(-1),r.direction=i,r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DirectionalLight"},t.prototype.getTypeID=function(){return kr.a.LIGHTTYPEID_DIRECTIONALLIGHT},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},t.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(e){var t=this.getScene().activeCamera;t&&a.a.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,i){var n=this.getScene().activeCamera;if(n){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var r=a.e.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,s=Number.MIN_VALUE,c=0;cthis._orthoRight&&(this._orthoRight=r.x),r.y>this._orthoTop&&(this._orthoTop=r.y),this.autoCalcShadowZBounds&&(r.zs&&(s=r.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=o,this._shadowMaxZ=s)}var d=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;a.a.OrthoOffCenterLHToRef(this._orthoLeft-d*this.shadowOrthoScale,this._orthoRight+d*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.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(h.c)([Object(w.c)()],t.prototype,"shadowFrustumSize",null),Object(h.c)([Object(w.c)()],t.prototype,"shadowOrthoScale",null),Object(h.c)([Object(w.c)()],t.prototype,"autoUpdateExtends",void 0),Object(h.c)([Object(w.c)()],t.prototype,"autoCalcShadowZBounds",void 0),t}(zr);be.a.CreateHemisphere=function(e,t,i,n){var r={segments:t,diameter:i};return jr.CreateHemisphere(e,r,n)};var jr=function(){function e(){}return e.CreateHemisphere=function(e,t,i){t.diameter||(t.diameter=1),t.segments||(t.segments=16);var n=xr.a.CreateSphere("",{slice:.5,diameter:t.diameter,segments:t.segments},i),r=be.a.CreateDisc("",t.diameter/2,3*t.segments+(4-t.segments),i);r.rotation.x=-Math.PI/2,r.parent=n;var o=be.a.MergeMeshes([r,n],!0);return o.name=e,o},e}();B.a.AddNodeConstructor("Light_Type_2",(function(e,t){return function(){return new Wr(e,a.e.Zero(),a.e.Zero(),0,0,t)}}));var Wr=function(e){function t(t,i,n,r,o,s){var c=e.call(this,t,s)||this;return c._innerAngle=0,c._projectionTextureMatrix=a.a.Zero(),c._projectionTextureLightNear=1e-6,c._projectionTextureLightFar=1e3,c._projectionTextureUpDirection=a.e.Up(),c._projectionTextureViewLightDirty=!0,c._projectionTextureProjectionLightDirty=!0,c._projectionTextureDirty=!0,c._projectionTextureViewTargetVector=a.e.Zero(),c._projectionTextureViewLightMatrix=a.a.Zero(),c._projectionTextureProjectionLightMatrix=a.a.Zero(),c._projectionTextureScalingMatrix=a.a.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),c.position=i,c.direction=n,c.angle=r,c.exponent=o,c}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){var i=this;this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady()&&(t._IsProceduralTexture(this._projectionTexture)?this._projectionTexture.getEffect().executeWhenCompiled((function(){i._markMeshesAsLightDirty()})):t._IsTexture(this._projectionTexture)&&this._projectionTexture.onLoadObservable.addOnce((function(){i._markMeshesAsLightDirty()}))))},enumerable:!1,configurable:!0}),t._IsProceduralTexture=function(e){return void 0!==e.onGeneratedObservable},t._IsTexture=function(e){return void 0!==e.onLoadObservable},t.prototype.getClassName=function(){return"SpotLight"},t.prototype.getTypeID=function(){return kr.a.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,i){var n=this.getScene().activeCamera;if(n){this._shadowAngleScale=this._shadowAngleScale||1;var r=this._shadowAngleScale*this._angle;a.a.PerspectiveFovLHToRef(r,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),e)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),a.a.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,i=e/(e-t),n=-i*t,r=1/Math.tan(this._angle/2);a.a.FromValuesToRef(r/1,0,0,0,0,r,0,0,0,0,i,1,0,0,n,0,this._projectionTextureProjectionLightMatrix)},t.prototype._computeProjectionTextureMatrix=function(){if(this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTexture instanceof Ke.a){var e=this._projectionTexture.uScale/2,t=this._projectionTexture.vScale/2;a.a.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 i;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,t),i=a.e.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,t),i=a.e.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.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 i;return i=this.computeTransformedInformation()?a.e.Normalize(this.transformedDirection):a.e.Normalize(this.direction),this.getScene().useRightHandedSystem?e.setFloat3(t,-i.x,-i.y,-i.z):e.setFloat3(t,i.x,i.y,i.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(h.c)([Object(w.c)()],t.prototype,"angle",null),Object(h.c)([Object(w.c)()],t.prototype,"innerAngle",null),Object(h.c)([Object(w.c)()],t.prototype,"shadowAngleScale",null),Object(h.c)([Object(w.c)()],t.prototype,"exponent",void 0),Object(h.c)([Object(w.c)()],t.prototype,"projectionTextureLightNear",null),Object(h.c)([Object(w.c)()],t.prototype,"projectionTextureLightFar",null),Object(h.c)([Object(w.c)()],t.prototype,"projectionTextureUpDirection",null),Object(h.c)([Object(w.m)("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}(zr),Hr=function(e){function t(t){void 0===t&&(t=Cr.a.DefaultUtilityLayer);var i=e.call(this,t)||this;return i._cachedPosition=new a.e,i._cachedForward=new a.e(0,0,1),i._pointerObserver=null,i.onClickedObservable=new o.c,i._light=null,i.attachedMesh=new Ge.a("",i.gizmoLayer.utilityLayerScene),i._attachedMeshParent=new Nr.a("parent",i.gizmoLayer.utilityLayerScene),i.attachedMesh.parent=i._attachedMeshParent,i._material=new Wi.a("light",i.gizmoLayer.utilityLayerScene),i._material.diffuseColor=new s.a(.5,.5,.5),i._material.specularColor=new s.a(.1,.1,.1),i._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){i._light&&(i._isHovered=!(!e.pickInfo||-1==i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),i._isHovered&&0===e.event.button&&i.onClickedObservable.notifyObservers(i._light))}),Ne.a.POINTERDOWN),i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"light",{get:function(){return this._light},set:function(e){var i=this;if(this._light=e,e){this._lightMesh&&this._lightMesh.dispose(),e instanceof ki.a?this._lightMesh=t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):this._lightMesh=e instanceof Gr?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Wr?t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene):t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),this._lightMesh.getChildMeshes(!1).forEach((function(e){e.material=i._material})),this._lightMesh.parent=this._rootMesh;var n=this.gizmoLayer._getSharedGizmoLight();n.includedOnlyMeshes=n.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),this._lightMesh.rotationQuaternion=new a.b,this.attachedMesh.reservedDataStore||(this.attachedMesh.reservedDataStore={}),this.attachedMesh.reservedDataStore.lightGizmo=this,e.parent&&this._attachedMeshParent.freezeWorldMatrix(e.parent.getWorldMatrix()),e.position&&(this.attachedMesh.position.copyFrom(e.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position)),e.direction&&(this.attachedMesh.setDirection(e.direction),this.attachedMesh.computeWorldMatrix(!0),this._cachedForward.copyFrom(this.attachedMesh.forward)),this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._update=function(){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&&(a.e.DistanceSquared(this.attachedMesh.forward,this._cachedForward)>1e-4?(this._light.direction.copyFrom(this.attachedMesh.forward),this._cachedForward.copyFrom(this.attachedMesh.forward)):a.e.DistanceSquared(this.attachedMesh.forward,this._light.direction)>1e-4&&(this.attachedMesh.setDirection(this._light.direction),this.attachedMesh.computeWorldMatrix(!0),this._cachedForward.copyFrom(this.attachedMesh.forward))))},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._material.dispose(),e.prototype.dispose.call(this),this._attachedMeshParent.dispose()},t._CreateHemisphericLightMesh=function(e){var i=new be.a("hemisphereLight",e),n=jr.CreateHemisphere(i.name,{segments:10,diameter:1},e);n.position.z=-.15,n.rotation.x=Math.PI/2,n.parent=i;var r=this._CreateLightLines(3,e);return r.parent=i,r.position.z,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreatePointLightMesh=function(e){var i=new be.a("pointLight",e),n=xr.a.CreateSphere(i.name,{segments:10,diameter:1},e);return n.rotation.x=Math.PI/2,n.parent=i,this._CreateLightLines(5,e).parent=i,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreateSpotLightMesh=function(e){var i=new be.a("spotLight",e);xr.a.CreateSphere(i.name,{segments:10,diameter:1},e).parent=i;var n=jr.CreateHemisphere(i.name,{segments:10,diameter:2},e);return n.parent=i,n.rotation.x=-Math.PI/2,this._CreateLightLines(2,e).parent=i,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreateDirectionalLightMesh=function(e){var i=new be.a("directionalLight",e),n=new be.a(i.name,e);n.parent=i,xr.a.CreateSphere(i.name,{diameter:1.2,segments:10},e).parent=n;var r=be.a.CreateCylinder(i.name,6,.3,.3,6,1,e);r.parent=n,(o=r.clone(i.name)).scaling.y=.5,o.position.x+=1.25,(a=r.clone(i.name)).scaling.y=.5,a.position.x+=-1.25;var o,a,s=be.a.CreateCylinder(i.name,1,0,.6,6,1,e);return s.position.y+=3,s.parent=n,(o=s.clone(i.name)).position.y=1.5,o.position.x+=1.25,(a=s.clone(i.name)).position.y=1.5,a.position.x+=-1.25,n.scaling.scaleInPlace(t._Scale),n.rotation.z=Math.PI/2,n.rotation.y=Math.PI/2,i},t._Scale=.007,t._CreateLightLines=function(e,t){var i=new be.a("root",t);i.rotation.x=Math.PI/2;var n=new be.a("linePivot",t);n.parent=i;var r=be.a.CreateCylinder("line",2,.2,.3,6,1,t);if(r.position.y=r.scaling.y/2+1.2,r.parent=n,e<2)return n;for(var o=0;o<4;o++){(a=n.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 i;for(o=0;o<4;o++){(a=n.clone("linePivotClone")).rotation.z=Math.PI/2,a.rotation.y=Math.PI/2*o}if(e<4)return i;for(o=0;o<4;o++){var a;(a=n.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=n.clone("linePivotClone")).rotation.z=Math.PI),i},t}(Pr.a),Xr=function(){function e(e,t){void 0===e&&(e=a.e.Zero()),void 0===t&&(t=a.e.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}(),Yr=function(){function e(e,t,i){void 0===e&&(e=a.e.Zero()),void 0===t&&(t=a.e.Up()),void 0===i&&(i=a.d.Zero()),this.position=e,this.normal=t,this.uv=i}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())},e}(),Kr=function(e){function t(t){void 0===t&&(t=Cr.a.DefaultUtilityLayer);var i=e.call(this,t)||this;return i._pointerObserver=null,i.onClickedObservable=new o.c,i._camera=null,i._invProjection=new a.a,i._material=new Wi.a("cameraGizmoMaterial",i.gizmoLayer.utilityLayerScene),i._material.diffuseColor=new s.a(.5,.5,.5),i._material.specularColor=new s.a(.1,.1,.1),i._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){i._camera&&(i._isHovered=!(!e.pickInfo||-1==i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),i._isHovered&&0===e.event.button&&i.onClickedObservable.notifyObservers(i._camera))}),Ne.a.POINTERDOWN),i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"displayFrustum",{get:function(){return this._cameraLinesMesh.isEnabled()},set:function(e){this._cameraLinesMesh.setEnabled(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(e){var i=this;if(this._camera=e,this.attachedNode=e,e){this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._cameraMesh=t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene),this._cameraLinesMesh=t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene),this._cameraMesh.getChildMeshes(!1).forEach((function(e){e.material=i._material})),this._cameraMesh.parent=this._rootMesh,this._cameraLinesMesh.parent=this._rootMesh,this.gizmoLayer.utilityLayerScene.activeCamera&&this.gizmoLayer.utilityLayerScene.activeCamera.maxZ<1.5*e.maxZ&&(this.gizmoLayer.utilityLayerScene.activeCamera.maxZ=1.5*e.maxZ),this.attachedNode.reservedDataStore||(this.attachedNode.reservedDataStore={}),this.attachedNode.reservedDataStore.cameraGizmo=this;var n=this.gizmoLayer._getSharedGizmoLight();n.includedOnlyMeshes=n.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(!1)),this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._update=function(){e.prototype._update.call(this),this._camera&&(this._camera.getProjectionMatrix().invertToRef(this._invProjection),this._cameraLinesMesh.setPivotMatrix(this._invProjection,!1),this._cameraLinesMesh.scaling.x=1/this._rootMesh.scaling.x,this._cameraLinesMesh.scaling.y=1/this._rootMesh.scaling.y,this._cameraLinesMesh.scaling.z=1/this._rootMesh.scaling.z,this._cameraMesh.parent=null,this._cameraMesh.rotation.y=.5*Math.PI*(this._camera.getScene().useRightHandedSystem?1:-1),this._cameraMesh.parent=this._rootMesh)},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._material.dispose(),e.prototype.dispose.call(this)},t._CreateCameraMesh=function(e){var i=new be.a("rootCameraGizmo",e),n=new be.a(i.name,e);n.parent=i,Ar.a.CreateBox(i.name,{width:1,height:.8,depth:.5},e).parent=n;var r=nn.a.CreateCylinder(i.name,{height:.5,diameterTop:.8,diameterBottom:.8},e);r.parent=n,r.position.y=.3,r.position.x=-.6,r.rotation.x=.5*Math.PI;var o=nn.a.CreateCylinder(i.name,{height:.5,diameterTop:.6,diameterBottom:.6},e);o.parent=n,o.position.y=.5,o.position.x=.4,o.rotation.x=.5*Math.PI;var a=nn.a.CreateCylinder(i.name,{height:.5,diameterTop:.5,diameterBottom:.5},e);return a.parent=n,a.position.y=0,a.position.x=.6,a.rotation.z=.5*Math.PI,i.scaling.scaleInPlace(t._Scale),n.position.x=-.9,i},t._CreateCameraFrustum=function(e){var t=new be.a("rootCameraGizmo",e),i=new be.a(t.name,e);i.parent=t;for(var n=0;n<4;n+=2)for(var r=0;r<4;r+=2){var o;(o=Or.a.CreateLines("lines",{points:[new a.e(-1+r,-1+n,-1),new a.e(-1+r,-1+n,1)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Or.a.CreateLines("lines",{points:[new a.e(-1,-1+r,-1+n),new a.e(1,-1+r,-1+n)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Or.a.CreateLines("lines",{points:[new a.e(-1+r,-1,-1+n),new a.e(-1+r,1,-1+n)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1}return t},t._Scale=.05,t}(Pr.a);ai.a.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";var Qr="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}";ai.a.IncludesShadersStore.packingFunctions=Qr;var qr="#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";ai.a.IncludesShadersStore.kernelBlurFragment=qr;var Zr="#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";ai.a.IncludesShadersStore.kernelBlurFragment2=Zr;var Jr="\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}";ai.a.ShadersStore.kernelBlurPixelShader=Jr;ai.a.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var $r="\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}";ai.a.ShadersStore.kernelBlurVertexShader=$r;var eo=function(e){function t(t,i,n,r,o,a,s,c,l,u,h){void 0===a&&(a=Ke.a.BILINEAR_SAMPLINGMODE),void 0===l&&(l=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=""),void 0===h&&(h=!1);var d=e.call(this,t,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],r,o,a,s,c,null,l,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return d.blockCompilation=h,d._packedFloat=!1,d._staticDefines="",d._staticDefines=u,d.direction=i,d.onApplyObservable.add((function(e){d._outputTexture?e.setFloat2("delta",1/d._outputTexture.width*d.direction.x,1/d._outputTexture.height*d.direction.y):e.setFloat2("delta",1/d.width*d.direction.x,1/d.height*d.direction.y)})),d.kernel=n,d}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this.blockCompilation||this._updateParameters())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"BlurPostProcess"},t.prototype.updateEffect=function(e,t,i,n,r,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._updateParameters(r,o)},t.prototype._updateParameters=function(t,i){for(var n=this._kernel,r=(n-1)/2,o=[],a=[],s=0,c=0;c0)return Math.max(r,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._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.direction,e.kernel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,void 0,!1)}),e,n,r)},Object(h.c)([Object(w.c)("kernel")],t.prototype,"_kernel",void 0),Object(h.c)([Object(w.c)("packedFloat")],t.prototype,"_packedFloat",void 0),Object(h.c)([Object(w.n)()],t.prototype,"direction",void 0),t}(li);c.a.RegisteredTypes["BABYLON.BlurPostProcess"]=eo;var to=function(e){function t(t,i,n,r,o,s,c){void 0===o&&(o=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=Ke.a.BILINEAR_SAMPLINGMODE),void 0===c&&(c=!0);var l=e.call(this,t,i,n,r,!0,o,!1,s,c)||this;return l.scene=n,l.mirrorPlane=new fn.a(0,1,0,1),l._transformMatrix=a.a.Zero(),l._mirrorMatrix=a.a.Zero(),l._adaptiveBlurKernel=0,l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.ignoreCameraViewport=!0,l._updateGammaSpace(),l._imageProcessingConfigChangeObserver=n.imageProcessingConfiguration.onUpdateParameters.add((function(){l._updateGammaSpace})),l.onBeforeRenderObservable.add((function(){a.a.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=n.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),n.setTransformMatrix(l._transformMatrix,n.getProjectionMatrix()),n.clipPlane=l.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=a.e.TransformCoordinates(n.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){n.setTransformMatrix(l._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,n.clipPlane=null})),l}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),t.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),i=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*i},t.prototype._onRatioRescale=function(){this._sizeRatio&&(this.resize(this._initialSizeParameter),this._adaptiveBlurKernel||this._preparePostProcesses()),this._adaptiveBlurKernel&&this._autoComputeBlurKernel()},t.prototype._updateGammaSpace=function(){this.gammaSpace=!this.scene.imageProcessingConfiguration.isEnabled||!this.scene.imageProcessingConfiguration.applyByPostProcess},t.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var e=this.getScene().getEngine(),t=e.getCaps().textureFloatRender?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_HALF_FLOAT;this._blurX=new eo("horizontal blur",new a.d(1,0),this._blurKernelX,this._blurRatio,null,Ke.a.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 eo("vertical blur",new a.d(0,1),this._blurKernelY,this._blurRatio,null,Ke.a.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 i=this.getSize(),n=new t(this.name,i.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(n.renderList=this.renderList.slice(0)),n},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}(Ni);Ke.a._CreateMirror=function(e,t,i,n){return new to(e,t,i,n)};var io=i(34),no=function(e){function t(t,i,n,r,s,c,l,u,h,d,f,p,_,m){var v;void 0===n&&(n=null),void 0===r&&(r=!1),void 0===s&&(s=null),void 0===c&&(c=null),void 0===l&&(l=null),void 0===u&&(u=g.a.TEXTUREFORMAT_RGBA),void 0===h&&(h=!1),void 0===d&&(d=null),void 0===f&&(f=!1),void 0===p&&(p=.8),void 0===_&&(_=0);var b=e.call(this,i)||this;if(b.onLoadObservable=new o.c,b.boundingBoxPosition=a.e.Zero(),b._rotationY=0,b._files=null,b._forcedExtension=null,b._extensions=null,b.name=t,b.url=t,b._noMipmap=r,b.hasAlpha=!1,b._format=u,b.isCube=!0,b._textureMatrix=a.a.Identity(),b._createPolynomials=f,b.coordinatesMode=Ke.a.CUBIC_MODE,b._extensions=n,b._files=s,b._forcedExtension=d,b._loaderOptions=m,!t&&!s)return b;var y=t.lastIndexOf("."),T=d||(y>-1?t.substring(y).toLowerCase():""),E=".dds"===T,S=".env"===T;if(S?(b.gammaSpace=!1,b._prefiltered=!1,b.anisotropicFilteringLevel=1):(b._prefiltered=h,h&&(b.gammaSpace=!1,b.anisotropicFilteringLevel=1)),b._texture=b._getFromCache(t,r),!s&&(S||E||n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[],n))for(var A=0;A0,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===Ke.a.INVCUBIC_MODE&&(o.INVERTCUBICMAP=!0),o.REFLECTIONMAP_3D=s.isCube,s.coordinatesMode){case Ke.a.EXPLICIT_MODE:o.REFLECTIONMAP_EXPLICIT=!0;break;case Ke.a.PLANAR_MODE:o.REFLECTIONMAP_PLANAR=!0;break;case Ke.a.PROJECTION_MODE:o.REFLECTIONMAP_PROJECTION=!0;break;case Ke.a.SKYBOX_MODE:o.REFLECTIONMAP_SKYBOX=!0;break;case Ke.a.SPHERICAL_MODE:o.REFLECTIONMAP_SPHERICAL=!0;break;case Ke.a.EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ke.a.CUBIC_MODE:case Ke.a.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=this.alphaMode===g.a.ALPHA_PREMULTIPLIED||this.alphaMode===g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,o.USERGBCOLOR=this._useRGBColor,o.NOISE=this._enableNoise}if(o._areLightsDirty&&(o.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel),o.BACKMAT_SHADOWONLY=this._shadowOnly),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o)}if(ro.a.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),ro.a.PrepareDefinesForFrameBoundValues(r,a,o,i,null,t.getRenderingMesh().hasThinInstances),ro.a.PrepareDefinesForAttributes(e,o,!1,!0,!1)&&e&&(r.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(Qi.b.NormalKind)||(e.createNormals(!0),m.a.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),o.isDirty){o.markAsProcessed(),r.resetCachedMaterial();var c=new po.a;o.FOG&&c.addFallback(0,"FOG"),o.POINTSIZE&&c.addFallback(1,"POINTSIZE"),o.MULTIVIEW&&c.addFallback(0,"MULTIVIEW"),ro.a.HandleFallbacksForShadows(o,c,this._maxSimultaneousLights);var l=[Qi.b.PositionKind];o.NORMAL&&l.push(Qi.b.NormalKind),o.UV1&&l.push(Qi.b.UVKind),o.UV2&&l.push(Qi.b.UV2Kind),ro.a.PrepareAttributesForBones(l,e,o,c),ro.a.PrepareAttributesForInstances(l,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"],h=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],d=["Material","Scene"];ji.a&&(ji.a.PrepareUniforms(u,o),ji.a.PrepareSamplers(h,o)),ro.a.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var f=o.toString();t.setEffect(r.getEngine().createEffect("background",{attributes:l,uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:f,fallbacks:c,onCompiled:function(e){n.onCompiled&&n.onCompiled(e),n.bindSceneUniformBuffer(e,r.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},a),o),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(o._renderId=r.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,i){var n=this.getScene(),r=i._materialDefines;if(r){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),ro.a.BindBonesParameters(t,this._activeEffect);var a=this._mustRebind(n,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||(n.texturesEnabled&&(this._diffuseTexture&&so.a.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),ro.a.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),s&&so.a.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),r.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),n.texturesEnabled&&(this._diffuseTexture&&so.a.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),s&&so.a.ReflectionTextureEnabled&&(r.REFLECTIONBLUR&&r.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",s):r.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),r.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)))),ro.a.BindClipPlane(this._activeEffect,n),ro.a.BindEyePosition(o,n)}!a&&this.isFrozen||(n.lightsEnabled&&ro.a.BindLights(n,t,this._activeEffect,r,this._maxSimultaneousLights,!1),this.bindView(o),ro.a.BindFogParameters(n,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,i){void 0===t&&(t=!1),void 0===i&&(i=!1),i&&(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 i=this;return w.a.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON.BackgroundMaterial",e},t.prototype.getClassName=function(){return"BackgroundMaterial"},t.Parse=function(e,i,n){return w.a.Parse((function(){return new t(e.name,i)}),e,i,n)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,Object(h.c)([Object(w.e)()],t.prototype,"_primaryColor",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),Object(h.c)([Object(w.e)()],t.prototype,"__perceptualColor",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_primaryColorShadowLevel",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_primaryColorHighlightLevel",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),Object(h.c)([Object(w.m)()],t.prototype,"_reflectionTexture",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionBlur",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),Object(h.c)([Object(w.m)()],t.prototype,"_diffuseTexture",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_shadowLevel",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),Object(h.c)([Object(w.o)()],t.prototype,"_sceneCenter",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_opacityFresnel",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionFresnel",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionFalloffDistance",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionAmount",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionReflectance0",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionReflectance90",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_useRGBColor",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_enableNoise",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_maxSimultaneousLights",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_shadowOnly",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"shadowOnly",void 0),Object(h.c)([Object(w.i)()],t.prototype,"_imageProcessingConfiguration",void 0),t}(ao.a);c.a.RegisteredTypes["BABYLON.BackgroundMaterial"]=mo;var go=function(){function e(t,i){var n=this;this._errorHandler=function(e,t){n.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=Object(h.a)(Object(h.a)({},e._getDefaultOptions()),t),this._scene=i,this.onErrorObservable=new o.c,this._setupBackground(),this._setupImageProcessing()}return e._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new s.a(.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:g.a.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new s.a(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:a.e.Zero(),setupImageProcessing:!0,environmentTexture:this._environmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(e.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skybox",{get:function(){return this._skybox},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ground",{get:function(){return this._ground},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!1,configurable:!0}),e.prototype.updateOptions=function(e){var t=Object(h.a)(Object(h.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 s.b(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 Zn.a)this._scene.environmentTexture=this._options.environmentTexture;else{var e=no.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new be.a("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,i=this._options.skyboxSize,n=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:t,skyboxSize:i,rootPosition:n};var r=this._scene.getWorldExtends((function(t){return t!==e._ground&&t!==e._rootMesh&&t!==e._skybox})),o=r.max.subtract(r.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof Bt&&this._scene.activeCamera.upperRadiusLimit&&(i=t=2*this._scene.activeCamera.upperRadiusLimit);var a=o.length();a>t&&(i=t=2*a),t*=1.1,i*=1.5,(n=r.min.add(o.scale(.5))).y=r.min.y-this._options.groundYBias}return{groundSize:t,skyboxSize:i,rootPosition:n}},e.prototype._setupGround=function(e){var t=this;this._ground&&!this._ground.isDisposed()||(this._ground=be.a.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 mo("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,this._groundMaterial.shadowLevel=this._options.groundShadowLevel,this._groundMaterial.primaryColor=this._options.groundColor,this._groundMaterial.useRGBColor=!1,this._groundMaterial.enableNoise=!0,this._ground&&(this._ground.material=this._groundMaterial)},e.prototype._setupGroundDiffuseTexture=function(){this._groundMaterial&&(this._groundTexture||(this._options.groundTexture instanceof Zn.a?this._groundMaterial.diffuseTexture=this._options.groundTexture:(this._groundTexture=new Ke.a(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._groundTexture.gammaSpace=!1,this._groundTexture.hasAlpha=!0,this._groundMaterial.diffuseTexture=this._groundTexture)))},e.prototype._setupGroundMirrorTexture=function(e){var t=Ke.a.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new to("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Ke.a.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new fn.a(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 i=0;i0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness),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){var t,i,n,r;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(i=this._textureRoughness)||void 0===i||i.dispose(),null===(n=this._bumpTexture)||void 0===n||n.dispose(),null===(r=this._tintTexture)||void 0===r||r.dispose())},e.prototype.getClassName=function(){return"PBRClearCoatConfiguration"},e.AddFallbacks=function(e,t,i){return e.CLEARCOAT_BUMP&&t.addFallback(i++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(i++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(i++,"CLEARCOAT"),i},e.AddUniforms=function(e){e.push("vClearCoatTangentSpaceParams","vClearCoatParams","vClearCoatRefractionParams","vClearCoatTintParams","clearCoatColorAtDistance","clearCoatMatrix","clearCoatRoughnessMatrix","clearCoatBumpMatrix","clearCoatTintMatrix","vClearCoatInfos","vClearCoatBumpInfos","vClearCoatTintInfos")},e.AddSamplers=function(e){e.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")},e.PrepareUniformBuffer=function(e){e.addUniform("vClearCoatParams",2),e.addUniform("vClearCoatRefractionParams",4),e.addUniform("vClearCoatInfos",4),e.addUniform("clearCoatMatrix",16),e.addUniform("clearCoatRoughnessMatrix",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){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},e._DefaultIndexOfRefraction=1.5,Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(h.c)([Object(w.c)()],e.prototype,"intensity",void 0),Object(h.c)([Object(w.c)()],e.prototype,"roughness",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indexOfRefraction",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useRoughnessFromMainTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"textureRoughness",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"remapF0OnInterfaceChange",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"bumpTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTintEnabled",void 0),Object(h.c)([Object(w.e)()],e.prototype,"tintColor",void 0),Object(h.c)([Object(w.c)()],e.prototype,"tintColorAtDistance",void 0),Object(h.c)([Object(w.c)()],e.prototype,"tintThickness",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"tintTexture",void 0),e}(),So=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new a.d(1,0),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&&so.a.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},e.prototype.prepareDefines=function(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!t.isVerticesDataPresent(Qi.b.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&i.texturesEnabled&&(this._texture&&so.a.AnisotropicTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1)},e.prototype.bindForSubMesh=function(e,t,i){e.useUbo&&i&&e.isSync||(this._texture&&so.a.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),ro.a.BindTextureMatrix(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&so.a.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,i){return e.ANISOTROPIC&&t.addFallback(i++,"ANISOTROPIC"),i},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){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(h.c)([Object(w.c)()],e.prototype,"intensity",void 0),Object(h.c)([Object(w.n)()],e.prototype,"direction",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),e}(),Ao=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){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},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(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useEnergyConservation",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSmithVisibilityHeightCorrelated",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSphericalHarmonics",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSpecularGlossinessInputEnergyConservation",void 0),e}(),Po=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=s.a.White(),this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._roughness=null,this.roughness=null,this._textureRoughness=null,this.textureRoughness=null,this._albedoScaling=!1,this.albedoScaling=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&so.a.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._textureRoughness&&so.a.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(e,t){var i;this._isEnabled?(e.SHEEN=this._isEnabled,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e.SHEEN_ROUGHNESS=null!==this._roughness,e.SHEEN_ALBEDOSCALING=this._albedoScaling,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=null!==this._texture&&this._texture._texture===(null===(i=this._textureRoughness)||void 0===i?void 0:i._texture)&&this._texture.checkTransformsAreIdentical(this._textureRoughness),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&so.a.SheenTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._texture,e,"SHEEN_TEXTURE"):e.SHEEN_TEXTURE=!1,this._textureRoughness&&so.a.SheenTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._textureRoughness,e,"SHEEN_TEXTURE_ROUGHNESS"):e.SHEEN_TEXTURE_ROUGHNESS=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=!1)},e.prototype.bindForSubMesh=function(e,t,i,n){var r,o,a,s,c,l,u,h,d=n._materialDefines,f=d.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;e.useUbo&&i&&e.isSync||(f&&so.a.SheenTextureEnabled?(e.updateFloat4("vSheenInfos",this._texture.coordinatesIndex,this._texture.level,-1,-1),ro.a.BindTextureMatrix(this._texture,e,"sheen")):(this._texture||this._textureRoughness)&&so.a.SheenTextureEnabled&&(e.updateFloat4("vSheenInfos",null!==(o=null===(r=this._texture)||void 0===r?void 0:r.coordinatesIndex)&&void 0!==o?o:0,null!==(s=null===(a=this._texture)||void 0===a?void 0:a.level)&&void 0!==s?s:0,null!==(l=null===(c=this._textureRoughness)||void 0===c?void 0:c.coordinatesIndex)&&void 0!==l?l:0,null!==(h=null===(u=this._textureRoughness)||void 0===u?void 0:u.level)&&void 0!==h?h:0),this._texture&&ro.a.BindTextureMatrix(this._texture,e,"sheen"),!this._textureRoughness||f||d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE||ro.a.BindTextureMatrix(this._textureRoughness,e,"sheenRoughness")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity),null!==this._roughness&&e.updateFloat("vSheenRoughness",this._roughness)),t.texturesEnabled&&(this._texture&&so.a.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!f&&!d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&so.a.SheenTextureEnabled&&e.setTexture("sheenRoughnessSampler",this._textureRoughness))},e.prototype.hasTexture=function(e){return this._texture===e||this._textureRoughness===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness)},e.prototype.dispose=function(e){var t,i;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(i=this._textureRoughness)||void 0===i||i.dispose())},e.prototype.getClassName=function(){return"PBRSheenConfiguration"},e.AddFallbacks=function(e,t,i){return e.SHEEN&&t.addFallback(i++,"SHEEN"),i},e.AddUniforms=function(e){e.push("vSheenColor","vSheenRoughness","vSheenInfos","sheenMatrix","sheenRoughnessMatrix")},e.PrepareUniformBuffer=function(e){e.addUniform("vSheenColor",4),e.addUniform("vSheenRoughness",1),e.addUniform("vSheenInfos",4),e.addUniform("sheenMatrix",16),e.addUniform("sheenRoughnessMatrix",16)},e.AddSamplers=function(e){e.push("sheenSampler"),e.push("sheenRoughnessSampler")},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkSheenWithAlbedo",void 0),Object(h.c)([Object(w.c)()],e.prototype,"intensity",void 0),Object(h.c)([Object(w.e)()],e.prototype,"color",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useRoughnessFromMainTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"roughness",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"textureRoughness",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"albedoScaling",void 0),e}(),Co=function(){function e(e,t,i){this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isScatteringEnabled=!1,this.isScatteringEnabled=!1,this._scatteringDiffusionProfileIndex=0,this.refractionIntensity=1,this.translucencyIntensity=1,this.useAlbedoToTintRefraction=!1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1.5,this.indexOfRefraction=1.5,this._volumeIndexOfRefraction=-1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.tintColor=s.a.White(),this.tintColorAtDistance=1,this.diffusionDistance=s.a.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._useMaskFromThicknessTextureGltf=!1,this.useMaskFromThicknessTextureGltf=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e,this._internalMarkScenePrePassDirty=t,this._scene=i}return Object.defineProperty(e.prototype,"scatteringDiffusionProfile",{get:function(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null},set:function(e){this._scene.enableSubSurfaceForPrePass()&&e&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeIndexOfRefraction",{get:function(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction},set:function(e){this._volumeIndexOfRefraction=e>=1?e:-1},enumerable:!1,configurable:!0}),e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype._markScenePrePassDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()},e.prototype.isReadyForSubMesh=function(e,t){if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&so.a.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var i=this._getRefractionTexture(t);if(i&&so.a.RefractionTextureEnabled&&!i.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(e,t){if(e._areTexturesDirty&&(e.SUBSURFACE=!1,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=!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,e.SS_ALBEDOFORREFRACTIONTINT=!1,(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled)&&(e.SUBSURFACE=!0,e._areTexturesDirty&&t.texturesEnabled&&this._thicknessTexture&&so.a.ThicknessTextureEnabled&&ro.a.PrepareDefinesForMergedUV(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),e.SS_MASK_FROM_THICKNESS_TEXTURE=this._useMaskFromThicknessTexture,e.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=this._useMaskFromThicknessTextureGltf),this._isRefractionEnabled&&t.texturesEnabled)){var i=this._getRefractionTexture(t);i&&so.a.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=i.isCube,e.SS_GAMMAREFRACTION=i.gammaSpace,e.SS_RGBDREFRACTION=i.isRGBD,e.SS_LINEARSPECULARREFRACTION=i.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=i.invertZ,e.SS_LODINREFRACTIONALPHA=i.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this.useAlbedoToTintRefraction)}},e.prototype.bindForSubMesh=function(e,t,i,n,r,o){var a=this._getRefractionTexture(t);if(!e.useUbo||!n||!e.isSync){if(this._thicknessTexture&&so.a.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),ro.a.BindTextureMatrix(this._thicknessTexture,e,"thickness")),e.updateFloat2("vThicknessParam",this.minimumThickness,this.maximumThickness-this.minimumThickness),a&&so.a.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",a.getReflectionTextureMatrix());var s=1;a.isCube||a.depth&&(s=a.depth);var c=a.getSize().width,l=this.volumeIndexOfRefraction;e.updateFloat4("vRefractionInfos",a.level,1/l,s,this._invertRefractionY?-1:1),e.updateFloat3("vRefractionMicrosurfaceInfos",c,a.lodGenerationScale,a.lodGenerationOffset),o&&e.updateFloat2("vRefractionFilteringInfo",c,L.a.Log2(c))}this.isScatteringEnabled&&e.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),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,0)}t.texturesEnabled&&(this._thicknessTexture&&so.a.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),a&&so.a.RefractionTextureEnabled&&(r?e.setTexture("refractionSampler",a):(e.setTexture("refractionSampler",a._lodTextureMid||a),e.setTexture("refractionSamplerLow",a._lodTextureLow||a),e.setTexture("refractionSamplerHigh",a._lodTextureHigh||a))))},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:!1,configurable:!0}),e.prototype.fillRenderTargetTextures=function(e){so.a.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!!(so.a.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,i){return e.SS_SCATTERING&&t.addFallback(i++,"SS_SCATTERING"),e.SS_TRANSLUCENCY&&t.addFallback(i++,"SS_TRANSLUCENCY"),i},e.AddUniforms=function(e){e.push("vDiffusionDistance","vTintColor","vSubSurfaceIntensity","vRefractionMicrosurfaceInfos","vRefractionFilteringInfo","vRefractionInfos","vThicknessInfos","vThicknessParam","refractionMatrix","thicknessMatrix","scatteringDiffusionProfile")},e.AddSamplers=function(e){e.push("thicknessSampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh")},e.PrepareUniformBuffer=function(e){e.addUniform("vRefractionMicrosurfaceInfos",3),e.addUniform("vRefractionFilteringInfo",2),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.addUniform("scatteringDiffusionProfile",1)},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isRefractionEnabled",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTranslucencyEnabled",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markScenePrePassDirty")],e.prototype,"isScatteringEnabled",void 0),Object(h.c)([Object(w.c)()],e.prototype,"_scatteringDiffusionProfileIndex",void 0),Object(h.c)([Object(w.c)()],e.prototype,"refractionIntensity",void 0),Object(h.c)([Object(w.c)()],e.prototype,"translucencyIntensity",void 0),Object(h.c)([Object(w.c)()],e.prototype,"useAlbedoToTintRefraction",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"thicknessTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"refractionTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indexOfRefraction",void 0),Object(h.c)([Object(w.c)()],e.prototype,"_volumeIndexOfRefraction",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"volumeIndexOfRefraction",null),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"invertRefractionY",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkRefractionWithTransparency",void 0),Object(h.c)([Object(w.c)()],e.prototype,"minimumThickness",void 0),Object(h.c)([Object(w.c)()],e.prototype,"maximumThickness",void 0),Object(h.c)([Object(w.e)()],e.prototype,"tintColor",void 0),Object(h.c)([Object(w.c)()],e.prototype,"tintColorAtDistance",void 0),Object(h.c)([Object(w.e)()],e.prototype,"diffusionDistance",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useMaskFromThicknessTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useMaskFromThicknessTextureGltf",void 0),e}(),Ro=i(105),xo=i(25),Oo=(i(160),"uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec4 vMetallicReflectanceFactors;\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;\n#ifdef REALTIME_FILTERING\nuniform vec2 vReflectionFilteringInfo;\n#endif\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#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\nuniform vec4 vClearCoatInfos;\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\nuniform mat4 clearCoatRoughnessMatrix;\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_ROUGHNESS\nuniform float vSheenRoughness;\n#endif\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\nuniform vec4 vSheenInfos;\n#endif\n#ifdef SHEEN_TEXTURE\nuniform mat4 sheenMatrix;\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\nuniform mat4 sheenRoughnessMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#ifdef REALTIME_FILTERING\nuniform vec2 vRefractionFilteringInfo;\n#endif\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\n#ifdef PREPASS\n#ifdef PREPASS_IRRADIANCE\nuniform float scatteringDiffusionProfile;\n#endif\n#endif");ai.a.IncludesShadersStore.pbrFragmentDeclaration=Oo;var Mo="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 vec2 vReflectionFilteringInfo;\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 vec4 vMetallicReflectanceFactors;\nuniform vec2 vMetallicReflectanceInfos;\nuniform mat4 metallicReflectanceMatrix;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec4 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform mat4 clearCoatRoughnessMatrix;\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 float vSheenRoughness;\nuniform vec4 vSheenInfos;\nuniform mat4 sheenMatrix;\nuniform mat4 sheenRoughnessMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec2 vRefractionFilteringInfo;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\nuniform float scatteringDiffusionProfile;\nuniform vec4 vDetailInfos;\nuniform mat4 detailMatrix;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";ai.a.IncludesShadersStore.pbrUboDeclaration=Mo;var Io="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";ai.a.IncludesShadersStore.pbrFragmentExtraDeclaration=Io;var Do="#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 METALLIC_REFLECTANCE\n#if METALLIC_REFLECTANCEDIRECTUV == 1\n#define vMetallicReflectanceUV vMainUV1\n#elif METALLIC_REFLECTANCEDIRECTUV == 2\n#define vMetallicReflectanceUV vMainUV2\n#else\nvarying vec2 vMetallicReflectanceUV;\n#endif\nuniform sampler2D metallicReflectanceSampler;\n#endif\n#ifdef CLEARCOAT\n#if defined(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\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS)\n#if CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 1\n#define vClearCoatRoughnessUV vMainUV1\n#elif CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 2\n#define vClearCoatRoughnessUV vMainUV2\n#else\nvarying vec2 vClearCoatRoughnessUV;\n#endif\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform sampler2D clearCoatSampler;\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D clearCoatRoughnessSampler;\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\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\n#if SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 1\n#define vSheenRoughnessUV vMainUV1\n#elif SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 2\n#define vSheenRoughnessUV vMainUV2\n#else\nvarying vec2 vSheenRoughnessUV;\n#endif\n#endif\n#ifdef SHEEN_TEXTURE\nuniform sampler2D sheenSampler;\n#endif\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D sheenRoughnessSampler;\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 sampler2D refractionSamplerLow;\nuniform sampler2D 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";ai.a.IncludesShadersStore.pbrFragmentSamplersDeclaration=Do;i(116);ai.a.IncludesShadersStore.subSurfaceScatteringFunctions="bool testLightingForSSS(float diffusionProfile)\n{\nreturn diffusionProfile<1.;\n}";var No="\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 hemisphereCosSample(vec2 u) {\n\nfloat phi=2.*PI*u.x;\nfloat cosTheta2=1.-u.y;\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 hemisphereImportanceSampleDggx(vec2 u,float a) {\n\nfloat phi=2.*PI*u.x;\n\nfloat cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {\n\nfloat phi=2.*PI*u.x;\nfloat sinTheta=pow(u.y,a/(2.*a+1.));\nfloat cosTheta=sqrt(1.-sinTheta*sinTheta);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}";ai.a.IncludesShadersStore.importanceSampling=No;var Lo="\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";ai.a.IncludesShadersStore.pbrHelperFunctions=Lo;var wo="#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";ai.a.IncludesShadersStore.harmonicsFunctions=wo;var Fo="\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}";ai.a.IncludesShadersStore.pbrDirectLightingSetupFunctions=Fo;var Bo="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}";ai.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions=Bo;var Uo="\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 specularEnvironmentR90,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;\n\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;\n#endif\nreturn reflectance;\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\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(ENVIRONMENTBRDF)\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\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\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\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";ai.a.IncludesShadersStore.pbrBRDFFunctions=Uo;var Vo="#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\n#ifdef WEBGL2\n\n\nfloat radicalInverse_VdC(uint bits)\n{\nbits=(bits << 16u) | (bits >> 16u);\nbits=((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\nbits=((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\nbits=((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\nbits=((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\nreturn float(bits)*2.3283064365386963e-10;\n}\nvec2 hammersley(uint i,uint N)\n{\nreturn vec2(float(i)/float(N),radicalInverse_VdC(i));\n}\n#else\nfloat vanDerCorpus(int n,int base)\n{\nfloat invBase=1.0/float(base);\nfloat denom=1.0;\nfloat result=0.0;\nfor(int i=0; i<32; ++i)\n{\nif(n>0)\n{\ndenom=mod(float(n),2.0);\nresult+=denom*invBase;\ninvBase=invBase/2.0;\nn=int(float(n)/2.0);\n}\n}\nreturn result;\n}\nvec2 hammersley(int i,int N)\n{\nreturn vec2(float(i)/float(N),vanDerCorpus(i,2));\n}\n#endif\nfloat log4(float x) {\nreturn log2(x)/2.;\n}\nconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);\nconst float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;\nconst float K=4.;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n#define inline\nvec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nvec3 result=vec3(0.0);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\n#ifdef WEBGL2\nfor(uint i=0u; i0.) {\nfloat pdf_inversed=PI/NoL;\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(l,0.0,maxLevel);\nvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c;\n}\n}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\nreturn result;\n}\n#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nif (alphaG == 0.) {\nvec3 c=textureCube(inputTexture,n).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nreturn c;\n}\nvec3 result=vec3(0.);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\nfloat weight=0.;\n#ifdef WEBGL2\nfor(uint i=0u; i0.) {\nfloat pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(float(l),0.0,maxLevel);\nweight+=NoL;\nvec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c*NoL;\n}\n}\nresult=result/weight;\nreturn result;\n}\n#endif\n#endif";ai.a.IncludesShadersStore.hdrFilteringFunctions=Vo;var ko="#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}\n#define inline\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);\n\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\n\nfloat sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";ai.a.IncludesShadersStore.pbrDirectLightingFunctions=ko;var zo="#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,vec3 geometricNormal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,geometricNormal));\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";ai.a.IncludesShadersStore.pbrIBLFunctions=zo;i(132),i(133);var Go="struct albedoOpacityOutParams\n{\nvec3 surfaceAlbedo;\nfloat alpha;\n};\n#define pbr_inline\nvoid albedoOpacityBlock(\nconst in vec4 vAlbedoColor,\n#ifdef ALBEDO\nconst in vec4 albedoTexture,\nconst in vec2 albedoInfos,\n#endif\n#ifdef OPACITY\nconst in vec4 opacityMap,\nconst in vec2 vOpacityInfos,\n#endif\n#ifdef DETAIL\nconst in vec4 detailColor,\nconst in vec4 vDetailInfos,\n#endif\nout albedoOpacityOutParams outParams\n)\n{\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\n#ifdef GAMMAALBEDO\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\n#else\nsurfaceAlbedo*=albedoTexture.rgb;\n#endif\nsurfaceAlbedo*=albedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n#ifdef DETAIL\nfloat detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);\nsurfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\n\n#ifdef OPACITY\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha0?(i.NUM_SAMPLES=""+this.realTimeFilteringQuality,s.webGLVersion>1&&(i.NUM_SAMPLES=i.NUM_SAMPLES+"u"),i.REALTIME_FILTERING=!0):i.REALTIME_FILTERING=!1,c.coordinatesMode===Ke.a.INVCUBIC_MODE&&(i.INVERTCUBICMAP=!0),i.REFLECTIONMAP_3D=c.isCube,i.REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,c.coordinatesMode){case Ke.a.EXPLICIT_MODE:i.REFLECTIONMAP_EXPLICIT=!0;break;case Ke.a.PLANAR_MODE:i.REFLECTIONMAP_PLANAR=!0;break;case Ke.a.PROJECTION_MODE:i.REFLECTIONMAP_PROJECTION=!0;break;case Ke.a.SKYBOX_MODE:i.REFLECTIONMAP_SKYBOX=!0;break;case Ke.a.SPHERICAL_MODE:i.REFLECTIONMAP_SPHERICAL=!0;break;case Ke.a.EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ke.a.CUBIC_MODE:case Ke.a.INVCUBIC_MODE:default:i.REFLECTIONMAP_CUBIC=!0,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!!c.boundingBoxSize}c.coordinatesMode!==Ke.a.SKYBOX_MODE&&(c.irradianceTexture?(i.USEIRRADIANCEMAP=!0,i.USESPHERICALFROMREFLECTIONMAP=!1):c.isCube&&(i.USESPHERICALFROMREFLECTIONMAP=!0,i.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||a.getEngine().getCaps().maxVaryingVectors<=8?i.USESPHERICALINVERTEX=!1:i.USESPHERICALINVERTEX=!0))}else i.REFLECTION=!1,i.REFLECTIONMAP_3D=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_CUBIC=!1,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.INVERTCUBICMAP=!1,i.USESPHERICALFROMREFLECTIONMAP=!1,i.USEIRRADIANCEMAP=!1,i.USESPHERICALINVERTEX=!1,i.REFLECTIONMAP_OPPOSITEZ=!1,i.LODINREFLECTIONALPHA=!1,i.GAMMAREFLECTION=!1,i.RGBDREFLECTION=!1,i.LINEARSPECULARREFLECTION=!1;this._lightmapTexture&&so.a.LightmapTextureEnabled?(ro.a.PrepareDefinesForMergedUV(this._lightmapTexture,i,"LIGHTMAP"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,i.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):i.LIGHTMAP=!1,this._emissiveTexture&&so.a.EmissiveTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._emissiveTexture,i,"EMISSIVE"):i.EMISSIVE=!1,so.a.SpecularTextureEnabled?(this._metallicTexture?(ro.a.PrepareDefinesForMergedUV(this._metallicTexture,i,"REFLECTIVITY"),i.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,i.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,i.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed):this._reflectivityTexture?(ro.a.PrepareDefinesForMergedUV(this._reflectivityTexture,i,"REFLECTIVITY"),i.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,i.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):i.REFLECTIVITY=!1,this._metallicReflectanceTexture?ro.a.PrepareDefinesForMergedUV(this._metallicReflectanceTexture,i,"METALLIC_REFLECTANCE"):i.METALLIC_REFLECTANCE=!1,this._microSurfaceTexture?ro.a.PrepareDefinesForMergedUV(this._microSurfaceTexture,i,"MICROSURFACEMAP"):i.MICROSURFACEMAP=!1):(i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1),a.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&so.a.BumpTextureEnabled&&!this._disableBumpMap?(ro.a.PrepareDefinesForMergedUV(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&so.a.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):i.BUMP=!1,this._environmentBRDFTexture&&so.a.ReflectionTextureEnabled?(i.ENVIRONMENTBRDF=!0,i.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?i.ALPHAFROMALBEDO=!0:i.ALPHAFROMALBEDO=!1}i.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===t.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===t.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),i.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.SPECULARAA=a.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?".":""),i.PREMULTIPLYALPHA=this.alphaMode===g.a.ALPHA_PREMULTIPLIED||this.alphaMode===g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,i.ALPHABLEND=this.needAlphaBlendingForMesh(e),i.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,i.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(ro.a.PrepareDefinesForMisc(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,i),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(Qi.b.NormalKind),i.DEBUGMODE=this._debugMode),this.detailMap.prepareDefines(i,a),this.subSurface.prepareDefines(i,a),this.clearCoat.prepareDefines(i,a),this.anisotropy.prepareDefines(i,e,a),this.brdf.prepareDefines(i),this.sheen.prepareDefines(i,a),ro.a.PrepareDefinesForFrameBoundValues(a,s,i,!!n,r,o),ro.a.PrepareDefinesForAttributes(e,i,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE)},t.prototype.forceCompilation=function(e,t,i){var n=this,r=Object(h.a)({clipPlane:!1,useInstances:!1},i),o=new pa,a=this._prepareEffect(e,o,void 0,void 0,r.useInstances,r.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(fa.effect=a,fa.subMesh=null,this._onEffectCreatedObservable.notifyObservers(fa)),a.isReady()?t&&t(this):a.onCompileObservable.add((function(){t&&t(n)}))},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("vAlbedoInfos",2),e.addUniform("vAmbientInfos",4),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vReflectivityInfos",3),e.addUniform("vMicroSurfaceSamplerInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionFilteringInfo",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vBumpInfos",3),e.addUniform("albedoMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("reflectivityMatrix",16),e.addUniform("microSurfaceSamplerMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("reflectionMatrix",16),e.addUniform("vReflectionColor",3),e.addUniform("vAlbedoColor",4),e.addUniform("vLightingIntensity",4),e.addUniform("vReflectionMicrosurfaceInfos",3),e.addUniform("pointSize",1),e.addUniform("vReflectivityColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("visibility",1),e.addUniform("vMetallicReflectanceFactors",4),e.addUniform("vMetallicReflectanceInfos",2),e.addUniform("metallicReflectanceMatrix",16),Eo.PrepareUniformBuffer(e),So.PrepareUniformBuffer(e),Po.PrepareUniformBuffer(e),Co.PrepareUniformBuffer(e),da.a.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,i){var n=this.getScene(),r=i._materialDefines;if(r){var o=i.effect;if(o){this._activeEffect=o,r.INSTANCES&&!r.THIN_INSTANCES||this.bindOnlyWorldMatrix(e),this.prePassConfiguration.bindForSubMesh(this._activeEffect,n,t,e,this.isFrozen),r.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var a=this._mustRebind(n,o,t.visibility);ro.a.BindBonesParameters(t,this._activeEffect,this.prePassConfiguration);var c=null,l=this._uniformBuffer;if(a){var u=n.getEngine();if(l.bindToEffect(o,"Material"),this.bindViewProjection(o),c=this._getReflectionTexture(),!l.useUbo||!this.isFrozen||!l.isSync){if(n.texturesEnabled){if(this._albedoTexture&&so.a.DiffuseTextureEnabled&&(l.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),ro.a.BindTextureMatrix(this._albedoTexture,l,"albedo")),this._ambientTexture&&so.a.AmbientTextureEnabled&&(l.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),ro.a.BindTextureMatrix(this._ambientTexture,l,"ambient")),this._opacityTexture&&so.a.OpacityTextureEnabled&&(l.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),ro.a.BindTextureMatrix(this._opacityTexture,l,"opacity")),c&&so.a.ReflectionTextureEnabled){if(l.updateMatrix("reflectionMatrix",c.getReflectionTextureMatrix()),l.updateFloat2("vReflectionInfos",c.level,0),c.boundingBoxSize){var h=c;l.updateVector3("vReflectionPosition",h.boundingBoxPosition),l.updateVector3("vReflectionSize",h.boundingBoxSize)}if(this.realTimeFiltering){var d=c.getSize().width;l.updateFloat2("vReflectionFilteringInfo",d,L.a.Log2(d))}if(!r.USEIRRADIANCEMAP){var f=c.sphericalPolynomial;if(r.USESPHERICALFROMREFLECTIONMAP&&f)if(r.SPHERICAL_HARMONICS){var p=f.preScaledHarmonics;this._activeEffect.setVector3("vSphericalL00",p.l00),this._activeEffect.setVector3("vSphericalL1_1",p.l1_1),this._activeEffect.setVector3("vSphericalL10",p.l10),this._activeEffect.setVector3("vSphericalL11",p.l11),this._activeEffect.setVector3("vSphericalL2_2",p.l2_2),this._activeEffect.setVector3("vSphericalL2_1",p.l2_1),this._activeEffect.setVector3("vSphericalL20",p.l20),this._activeEffect.setVector3("vSphericalL21",p.l21),this._activeEffect.setVector3("vSphericalL22",p.l22)}else this._activeEffect.setFloat3("vSphericalX",f.x.x,f.x.y,f.x.z),this._activeEffect.setFloat3("vSphericalY",f.y.x,f.y.y,f.y.z),this._activeEffect.setFloat3("vSphericalZ",f.z.x,f.z.y,f.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",f.xx.x-f.zz.x,f.xx.y-f.zz.y,f.xx.z-f.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",f.yy.x-f.zz.x,f.yy.y-f.zz.y,f.yy.z-f.zz.z),this._activeEffect.setFloat3("vSphericalZZ",f.zz.x,f.zz.y,f.zz.z),this._activeEffect.setFloat3("vSphericalXY",f.xy.x,f.xy.y,f.xy.z),this._activeEffect.setFloat3("vSphericalYZ",f.yz.x,f.yz.y,f.yz.z),this._activeEffect.setFloat3("vSphericalZX",f.zx.x,f.zx.y,f.zx.z)}l.updateFloat3("vReflectionMicrosurfaceInfos",c.getSize().width,c.lodGenerationScale,c.lodGenerationOffset)}this._emissiveTexture&&so.a.EmissiveTextureEnabled&&(l.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),ro.a.BindTextureMatrix(this._emissiveTexture,l,"emissive")),this._lightmapTexture&&so.a.LightmapTextureEnabled&&(l.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),ro.a.BindTextureMatrix(this._lightmapTexture,l,"lightmap")),so.a.SpecularTextureEnabled&&(this._metallicTexture?(l.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),ro.a.BindTextureMatrix(this._metallicTexture,l,"reflectivity")):this._reflectivityTexture&&(l.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),ro.a.BindTextureMatrix(this._reflectivityTexture,l,"reflectivity")),this._metallicReflectanceTexture&&(l.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),ro.a.BindTextureMatrix(this._metallicReflectanceTexture,l,"metallicReflectance")),this._microSurfaceTexture&&(l.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),ro.a.BindTextureMatrix(this._microSurfaceTexture,l,"microSurfaceSampler"))),this._bumpTexture&&u.getCaps().standardDerivatives&&so.a.BumpTextureEnabled&&!this._disableBumpMap&&(l.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),ro.a.BindTextureMatrix(this._bumpTexture,l,"bump"),n._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),r.METALLICWORKFLOW){s.c.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,s.c.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness,l.updateColor4("vReflectivityColor",s.c.Color3[0],1);var _=this.subSurface.indexOfRefraction,m=Math.pow((_-1)/(_+1),2);this._metallicReflectanceColor.scaleToRef(m*this._metallicF0Factor,s.c.Color3[0]);var g=this._metallicF0Factor;l.updateColor4("vMetallicReflectanceFactors",s.c.Color3[0],g)}else l.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);l.updateColor3("vEmissiveColor",so.a.EmissiveTextureEnabled?this._emissiveColor:s.a.BlackReadOnly),l.updateColor3("vReflectionColor",this._reflectionColor),!r.SS_REFRACTION&&this.subSurface.linkRefractionWithTransparency?l.updateColor4("vAlbedoColor",this._albedoColor,1):l.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*n.environmentIntensity,this._lightingInfos.w=this._specularIntensity,l.updateVector4("vLightingIntensity",this._lightingInfos)}l.updateFloat("visibility",t.visibility),n.texturesEnabled&&(this._albedoTexture&&so.a.DiffuseTextureEnabled&&l.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&so.a.AmbientTextureEnabled&&l.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&so.a.OpacityTextureEnabled&&l.setTexture("opacitySampler",this._opacityTexture),c&&so.a.ReflectionTextureEnabled&&(r.LODBASEDMICROSFURACE?l.setTexture("reflectionSampler",c):(l.setTexture("reflectionSampler",c._lodTextureMid||c),l.setTexture("reflectionSamplerLow",c._lodTextureLow||c),l.setTexture("reflectionSamplerHigh",c._lodTextureHigh||c)),r.USEIRRADIANCEMAP&&l.setTexture("irradianceSampler",c.irradianceTexture)),r.ENVIRONMENTBRDF&&l.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&so.a.EmissiveTextureEnabled&&l.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&so.a.LightmapTextureEnabled&&l.setTexture("lightmapSampler",this._lightmapTexture),so.a.SpecularTextureEnabled&&(this._metallicTexture?l.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&l.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&l.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._microSurfaceTexture&&l.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&u.getCaps().standardDerivatives&&so.a.BumpTextureEnabled&&!this._disableBumpMap&&l.setTexture("bumpSampler",this._bumpTexture)),this.detailMap.bindForSubMesh(l,n,this.isFrozen),this.subSurface.bindForSubMesh(l,n,u,this.isFrozen,r.LODBASEDMICROSFURACE,this.realTimeFiltering),this.clearCoat.bindForSubMesh(l,n,u,this._disableBumpMap,this.isFrozen,this._invertNormalMapX,this._invertNormalMapY,i),this.anisotropy.bindForSubMesh(l,n,this.isFrozen),this.sheen.bindForSubMesh(l,n,this.isFrozen,i),ro.a.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var v=n._forcedViewPosition?n._forcedViewPosition:n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition,b=n.useRightHandedSystem===(null!=n._mirroredCameraPosition);o.setFloat4("vEyePosition",v.x,v.y,v.z,b?-1:1),o.setColor3("vAmbientColor",this._globalAmbientColor),o.setFloat2("vDebugMode",this.debugLimit,this.debugFactor)}!a&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&ro.a.BindLights(n,t,this._activeEffect,r,this._maxSimultaneousLights,this._rebuildInParallel),(n.fogEnabled&&t.applyFog&&n.fogMode!==Q.a.FOGMODE_NONE||c)&&this.bindView(o),ro.a.BindFogParameters(n,t,this._activeEffect,!0),r.NUM_MORPH_INFLUENCERS&&ro.a.BindMorphTargetParameters(t,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),ro.a.BindLogDepth(r,this._activeEffect,n)),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.detailMap.getAnimatables(e),this.subSurface.getAnimatables(e),this.clearCoat.getAnimatables(e),this.sheen.getAnimatables(e),this.anisotropy.getAnimatables(e),e},t.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},t.prototype.getActiveTextures=function(){var 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._metallicReflectanceTexture&&t.push(this._metallicReflectanceTexture),this._microSurfaceTexture&&t.push(this._microSurfaceTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this.detailMap.getActiveTextures(t),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._metallicReflectanceTexture===t||(this._microSurfaceTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||(this.detailMap.hasTexture(t)||this.subSurface.hasTexture(t)||this.clearCoat.hasTexture(t)||this.sheen.hasTexture(t)||this.anisotropy.hasTexture(t))))))))))))},t.prototype.setPrePassRenderer=function(e){if(this.subSurface.isScatteringEnabled){var t=this.getScene().enableSubSurfaceForPrePass();return t&&(t.enabled=!0),!0}return!1},t.prototype.dispose=function(t,i){var n,r,o,a,s,c,l,u,h,d,f;i&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),null===(n=this._albedoTexture)||void 0===n||n.dispose(),null===(r=this._ambientTexture)||void 0===r||r.dispose(),null===(o=this._opacityTexture)||void 0===o||o.dispose(),null===(a=this._reflectionTexture)||void 0===a||a.dispose(),null===(s=this._emissiveTexture)||void 0===s||s.dispose(),null===(c=this._metallicTexture)||void 0===c||c.dispose(),null===(l=this._reflectivityTexture)||void 0===l||l.dispose(),null===(u=this._bumpTexture)||void 0===u||u.dispose(),null===(h=this._lightmapTexture)||void 0===h||h.dispose(),null===(d=this._metallicReflectanceTexture)||void 0===d||d.dispose(),null===(f=this._microSurfaceTexture)||void 0===f||f.dispose()),this.detailMap.dispose(i),this.subSurface.dispose(i),this.clearCoat.dispose(i),this.sheen.dispose(i),this.anisotropy.dispose(i),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},t.PBRMATERIAL_OPAQUE=xo.a.MATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=xo.a.MATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=xo.a.MATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=xo.a.MATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,Object(h.c)([Object(w.i)()],t.prototype,"_imageProcessingConfiguration",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),Object(h.c)([Object(w.c)()],t.prototype,"useLogarithmicDepth",null),t}(ao.a),ma=function(e){function t(i,n){var r=e.call(this,i,n)||this;return r.directIntensity=1,r.emissiveIntensity=1,r.environmentIntensity=1,r.specularIntensity=1,r.disableBumpMap=!1,r.ambientTextureStrength=1,r.ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,r.metallicF0Factor=1,r.metallicReflectanceColor=s.a.White(),r.ambientColor=new s.a(0,0,0),r.albedoColor=new s.a(1,1,1),r.reflectivityColor=new s.a(1,1,1),r.reflectionColor=new s.a(1,1,1),r.emissiveColor=new s.a(0,0,0),r.microSurface=1,r.useLightmapAsShadowmap=!1,r.useAlphaFromAlbedoTexture=!1,r.forceAlphaTest=!1,r.alphaCutOff=.4,r.useSpecularOverAlpha=!0,r.useMicroSurfaceFromReflectivityMapAlpha=!1,r.useRoughnessFromMetallicTextureAlpha=!0,r.useRoughnessFromMetallicTextureGreen=!1,r.useMetallnessFromMetallicTextureBlue=!1,r.useAmbientOcclusionFromMetallicTextureRed=!1,r.useAmbientInGrayScale=!1,r.useAutoMicroSurfaceFromReflectivityMap=!1,r.useRadianceOverAlpha=!0,r.useObjectSpaceNormalMap=!1,r.useParallax=!1,r.useParallaxOcclusion=!1,r.parallaxScaleBias=.05,r.disableLighting=!1,r.forceIrradianceInFragment=!1,r.maxSimultaneousLights=4,r.invertNormalMapX=!1,r.invertNormalMapY=!1,r.twoSidedLighting=!1,r.useAlphaFresnel=!1,r.useLinearAlphaFresnel=!1,r.environmentBRDFTexture=null,r.forceNormalForward=!1,r.enableSpecularAntiAliasing=!1,r.useHorizonOcclusion=!0,r.useRadianceOcclusion=!0,r.unlit=!1,r._environmentBRDFTexture=To.GetEnvironmentBRDFTexture(n),r}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return this.subSurface.indexOfRefraction},set:function(e){this.subSurface.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"invertRefractionY",{get:function(){return this.subSurface.invertRefractionY},set:function(e){this.subSurface.invertRefractionY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkRefractionWithTransparency",{get:function(){return this.subSurface.linkRefractionWithTransparency},set:function(e){this.subSurface.linkRefractionWithTransparency=e,e&&(this.subSurface.isRefractionEnabled=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===_a.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?_a.LIGHTFALLOFF_PHYSICAL:_a.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===_a.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?_a.LIGHTFALLOFF_GLTF:_a.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRMaterial"},t.prototype.clone=function(e){var i=this,n=w.a.Clone((function(){return new t(e,i.getScene())}),this);return n.id=e,n.name=e,this.clearCoat.copyTo(n.clearCoat),this.anisotropy.copyTo(n.anisotropy),this.brdf.copyTo(n.brdf),this.sheen.copyTo(n.sheen),this.subSurface.copyTo(n.subSurface),n},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON.PBRMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e},t.Parse=function(e,i,n){var r=w.a.Parse((function(){return new t(e.name,i)}),e,i,n);return e.clearCoat&&r.clearCoat.parse(e.clearCoat,i,n),e.anisotropy&&r.anisotropy.parse(e.anisotropy,i,n),e.brdf&&r.brdf.parse(e.brdf,i,n),e.sheen&&r.sheen.parse(e.sheen,i,n),e.subSurface&&r.subSurface.parse(e.subSurface,i,n),r},t.PBRMATERIAL_OPAQUE=_a.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=_a.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=_a.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=_a.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=_a.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicF0Factor",void 0),Object(h.c)([Object(w.e)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceColor",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),Object(h.c)([Object(w.e)("ambient"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),Object(h.c)([Object(w.e)("albedo"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),Object(h.c)([Object(w.e)("reflectivity"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),Object(h.c)([Object(w.e)("reflection"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),Object(h.c)([Object(w.e)("emissive"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),Object(h.c)([Object(w.c)()],t.prototype,"usePhysicalLightFalloff",null),Object(h.c)([Object(w.c)()],t.prototype,"useGLTFLightFalloff",null),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),t}(_a);c.a.RegisteredTypes["BABYLON.PBRMaterial"]=ma;function ga(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var va=ga("DXT1"),ba=ga("DXT3"),ya=ga("DXT5"),Ta=ga("DX10"),Ea=function(){function e(){}return e.GetDDSInfo=function(e){var t=new Int32Array(e.buffer,e.byteOffset,31),i=new Int32Array(e.buffer,e.byteOffset,35),n=1;131072&t[2]&&(n=Math.max(1,t[7]));var r=t[21],o=r===Ta?i[32]:0,a=g.a.TEXTURETYPE_UNSIGNED_INT;switch(r){case 113:a=g.a.TEXTURETYPE_HALF_FLOAT;break;case 116:a=g.a.TEXTURETYPE_FLOAT;break;case Ta:if(10===o){a=g.a.TEXTURETYPE_HALF_FLOAT;break}if(2===o){a=g.a.TEXTURETYPE_FLOAT;break}}return{width:t[4],height:t[3],mipmapCount:n,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:131072==(131072&t[20]),isCube:512==(512&t[28]),isCompressed:r===va||r===ba||r===ya,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 i=e._Int32View[0],n=i>>16&32768,r=i>>12&2047,o=i>>23&255;return o<103?n:o>142?(n|=31744,n|=(255==o?0:1)&&8388607&i):o<113?n|=((r|=2048)>>114-o)+(r>>113-o&1):(n|=o-112<<10|r>>1,n+=1&r)},e._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,n=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(n/Math.pow(2,10)):31==i?n?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+n/Math.pow(2,10))},e._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,i,n,r,o,a){for(var s=new Float32Array(r),c=new Uint16Array(o,n),l=0,u=0;u>8)},e._GetRGBArrayBuffer=function(e,t,i,n,r,o,a,s){for(var c=new Uint8Array(n),l=new Uint8Array(r,i),u=0,h=0;h>8&255,P>>16&255,P>>24&255)))}var x=e._ExtractLongWordOrder(y[23]),O=e._ExtractLongWordOrder(y[24]),M=e._ExtractLongWordOrder(y[25]),I=e._ExtractLongWordOrder(y[26]);C&&(E=t._getRGBABufferInternalSizedFormat(r.textureType)),_=1,131072&y[2]&&!1!==o&&(_=Math.max(1,y[7]));for(var D=c||0;D0?r.sphericalPolynomial=$n.ConvertCubeMapToSphericalPolynomial({size:y[4],right:l[0],left:l[1],up:l[2],down:l[3],front:l[4],back:l[5],format:g.a.TEXTUREFORMAT_RGBA,type:g.a.TEXTURETYPE_FLOAT,gammaSpace:!1}):r.sphericalPolynomial=void 0}else m.a.Error("Compressed textures are not supported on this platform.");else m.a.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else m.a.Error("Invalid magic number in DDS header")},e.StoreLODInAlphaChannel=!1,e}();qe.a.prototype.createPrefilteredCubeTexture=function(e,t,i,n,r,o,a,s,c){var l=this;void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=!0);return this.createCubeTexture(e,t,null,!1,(function(e){if(e){var o=e.texture;if(c?e.info.sphericalPolynomial&&(o._sphericalPolynomial=e.info.sphericalPolynomial):o._sphericalPolynomial=new qn,o._source=Qe.b.CubePrefiltered,l.getCaps().textureLOD)r&&r(o);else{var a=l._gl,s=e.width;if(s){for(var u=[],h=0;h<3;h++){var d=1-h/2,f=n,p=L.a.Log2(s)*i+n,_=f+(p-f)*d,v=Math.round(Math.min(Math.max(_,0),p)),b=new Qe.a(l,Qe.b.Temp);if(b.type=o.type,b.format=o.format,b.width=Math.pow(2,Math.max(L.a.Log2(s)-v,0)),b.height=b.width,b.isCube=!0,l._bindTextureDirectly(a.TEXTURE_CUBE_MAP,b,!0),b.samplingMode=g.a.TEXTURE_LINEAR_LINEAR,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 y=e.info,T=e.data;l._unpackFlipY(y.isCompressed),Ea.UploadDDSLevels(l,b,T,y,!0,6,v)}else m.a.Warn("DDS is the only prefiltered cube map supported so far.");l._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var E=new Zn.a(t);E.isCube=!0,E._texture=b,b.isReady=!0,u.push(E)}o._lodTextureHigh=u[2],o._lodTextureMid=u[1],o._lodTextureLow=u[0],r&&r(o)}}}else r&&r(null)}),o,a,s,c,i,n)};var Sa=function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,".dds")},e.prototype.loadCubeData=function(e,t,i,n,r){var o,a=t.getEngine(),s=!1;if(Array.isArray(e))for(var c=0;c1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Ea.UploadDDSLevels(a,t,l,o,s,6,-1,c),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t)}else{var u=e;o=Ea.GetDDSInfo(u),t.width=o.width,t.height=o.height,i&&(o.sphericalPolynomial=new qn),s=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Ea.UploadDDSLevels(a,t,u,o,s,6),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t,!1)}a._setCubeMapTextureParams(t,s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n({isDDS:!0,width:t.width,info:o,data:e,texture:t})},e.prototype.loadData=function(e,t,i){var n=Ea.GetDDSInfo(e),r=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&t.generateMipMaps&&n.width>>n.mipmapCount-1==1;i(n.width,n.height,r,n.isFourCC,(function(){Ea.UploadDDSLevels(t.getEngine(),t,e,n,r,1)}))},e}();Se.a._TextureLoaders.push(new Sa);var Aa=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,".env")},e.prototype.loadCubeData=function(e,t,i,n,r){if(!Array.isArray(e)){var o=ir.GetEnvInfo(e);o?(t.width=o.width,t.height=o.width,ir.UploadEnvSpherical(t,o),ir.UploadEnvLevelsAsync(t,e,o).then((function(){t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n()}))):r&&r("Can not parse the environment file",null)}},e.prototype.loadData=function(e,t,i){throw".env not supported in 2d."},e}();Se.a._TextureLoaders.push(new Aa);var Pa=function(){function e(t,i,n,r){if(this.data=t,this.isInvalid=!1,!e.IsValid(t))return this.isInvalid=!0,void m.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===i?this.loadType=e.COMPRESSED_2D:m.a.Error("number of faces expected"+i+", but found "+this.numberOfFaces):m.a.Error("texture arrays not currently supported"):m.a.Error("only 2D textures currently supported")):m.a.Error("only compressed formats currently supported")}return e.prototype.uploadLevels=function(t,i){switch(this.loadType){case e.COMPRESSED_2D:this._upload2DCompressedLevels(t,i);break;case e.TEX_2D:case e.COMPRESSED_3D:case e.TEX_3D:}},e.prototype._upload2DCompressedLevels=function(t,i){for(var n=e.HEADER_LEN+this.bytesOfKeyValueData,r=this.pixelWidth,o=this.pixelHeight,a=i?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}(),Ca=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;e1,t.isReady=!0,this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D,null)},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.URLConfig={jsDecoderModule:"https://preview.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,jsMSCTranscoder:null,wasmMSCTranscoder:null},e.DefaultNumWorkers=e.GetDefaultNumWorkers(),e}();function xa(){var e;onmessage=function(t){switch(t.data.action){case"init":var i=t.data.urls;importScripts(i.jsDecoderModule),null!==i.wasmUASTCToASTC&&(KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL=i.wasmUASTCToASTC),null!==i.wasmUASTCToBC7&&(KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL=i.wasmUASTCToBC7),null!==i.wasmUASTCToRGBA_UNORM&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=i.wasmUASTCToRGBA_UNORM),null!==i.wasmUASTCToRGBA_SRGB&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=i.wasmUASTCToRGBA_SRGB),null!==i.jsMSCTranscoder&&(KTX2DECODER.MSCTranscoder.JSModuleURL=i.jsMSCTranscoder),null!==i.wasmMSCTranscoder&&(KTX2DECODER.MSCTranscoder.WasmModuleURL=i.wasmMSCTranscoder),e=new KTX2DECODER.KTX2Decoder,postMessage({action:"init"});break;case"decode":e.decode(t.data.data,t.data.caps,t.data.options).then((function(e){for(var t=[],i=0;i1&&t.generateMipMaps;o._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,o._setCubeMapTextureParams(t,s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n()}},e.prototype.loadData=function(e,t,i,n){if(Pa.IsValid(e)){t._invertVScale=!t.invertY;var r=new Pa(e,1);i(r.pixelWidth,r.pixelHeight,t.generateMipMaps,!0,(function(){r.uploadLevels(t,t.generateMipMaps)}),r.isInvalid)}else if(Ra.IsValid(e)){new Ra(t.getEngine()).uploadAsync(e,t,n).then((function(){i(t.width,t.height,t.generateMipMaps,!0,(function(){}),!1)}),(function(e){m.a.Warn("Failed to load KTX2 texture data: "+e.message),i(0,0,!1,!1,(function(){}),!0)}))}else m.a.Error("texture missing KTX identifier"),i(0,0,!1,!1,(function(){}),!0)},e}();Se.a._TextureLoaders.unshift(new Oa);var Ma=function(e){function t(t,i,n){var r=e.call(this,t,a.e.Zero(),i)||this;return r._xrSessionManager=n,r._firstFrame=!1,r._referenceQuaternion=a.b.Identity(),r._referencedPosition=new a.e,r._xrInvPositionCache=new a.e,r._xrInvQuaternionCache=a.b.Identity(),r._trackingState=en.NOT_TRACKING,r.onBeforeCameraTeleport=new o.c,r.onAfterCameraTeleport=new o.c,r.onTrackingStateChanged=new o.c,r.compensateOnFirstFrame=!0,r._rotate180=new a.b(0,1,0,0),r.minZ=.1,r.rotationQuaternion=new a.b,r.cameraRigMode=je.a.RIG_MODE_CUSTOM,r.updateUpVectorFromRotation=!0,r._updateNumberOfRigCameras(1),r.freezeProjectionMatrix(),r._xrSessionManager.onXRSessionInit.add((function(){r._referencedPosition.copyFromFloats(0,0,0),r._referenceQuaternion.copyFromFloats(0,0,0,1),r._firstFrame=r.compensateOnFirstFrame})),r._xrSessionManager.onXRFrameObservable.add((function(e){r._firstFrame&&r._updateFromXRSession(),r._updateReferenceSpace(),r._updateFromXRSession()}),void 0,!0),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"trackingState",{get:function(){return this._trackingState},enumerable:!1,configurable:!0}),t.prototype._setTrackingState=function(e){this._trackingState!==e&&(this._trackingState=e,this.onTrackingStateChanged.notifyObservers(e))},Object.defineProperty(t.prototype,"realWorldHeight",{get:function(){var e=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);return e&&e.transform?e.transform.position.y:0},enumerable:!1,configurable:!0}),t.prototype._updateForDualEyeDebugging=function(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new yi.a(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new yi.a(.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,a.b.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);if(t){var i=t.emulatedPosition?en.TRACKING_LOST:en.TRACKING;if(this._setTrackingState(i),t.transform){var n=t.transform.position;this._referencedPosition.set(n.x,n.y,n.z);var r=t.transform.orientation;this._referenceQuaternion.set(r.x,r.y,r.z,r.w),this._scene.useRightHandedSystem||(this._referencedPosition.z*=-1,this._referenceQuaternion.z*=-1,this._referenceQuaternion.w*=-1),this._firstFrame?(this._firstFrame=!1,this.position.y+=this._referencedPosition.y,this._referenceQuaternion.copyFromFloats(0,0,0,1)):(this.rotationQuaternion.copyFrom(this._referenceQuaternion),this.position.copyFrom(this._referencedPosition))}this.rigCameras.length!==t.views.length&&this._updateNumberOfRigCameras(t.views.length),t.views.forEach((function(t,i){var n=e.rigCameras[i];n.isLeftCamera||n.isRightCamera||("right"===t.eye?n._isRightCamera=!0:"left"===t.eye&&(n._isLeftCamera=!0));var r=t.transform.position,o=t.transform.orientation;if(n.position.set(r.x,r.y,r.z),n.rotationQuaternion.set(o.x,o.y,o.z,o.w),e._scene.useRightHandedSystem?n.rotationQuaternion.multiplyInPlace(e._rotate180):(n.position.z*=-1,n.rotationQuaternion.z*=-1,n.rotationQuaternion.w*=-1),a.a.FromFloat32ArrayToRefScaled(t.projectionMatrix,0,1,n._projectionMatrix),e._scene.useRightHandedSystem||n._projectionMatrix.toggleProjectionMatrixHandInPlace(),0===i&&e._projectionMatrix.copyFrom(n._projectionMatrix),e._xrSessionManager.session.renderState.baseLayer){var s=e._xrSessionManager.session.renderState.baseLayer.getViewport(t),c=e._xrSessionManager.session.renderState.baseLayer.framebufferWidth,l=e._xrSessionManager.session.renderState.baseLayer.framebufferHeight;n.viewport.width=s.width/c,n.viewport.height=s.height/l,n.viewport.x=s.x/c,n.viewport.y=s.y/l}n.outputRenderTarget=e._xrSessionManager.getRenderTargetTextureForEye(t.eye)}))}else this._setTrackingState(en.NOT_TRACKING)},t.prototype._updateNumberOfRigCameras=function(e){for(void 0===e&&(e=1);this.rigCameras.lengthe;){var i=this.rigCameras.pop();i&&i.dispose()}},t.prototype._updateReferenceSpace=function(){this.position.equals(this._referencedPosition)&&this.rotationQuaternion.equals(this._referenceQuaternion)||(this.position.subtractToRef(this._referencedPosition,this._referencedPosition),this._referenceQuaternion.conjugateInPlace(),this._referenceQuaternion.multiplyToRef(this.rotationQuaternion,this._referenceQuaternion),this._updateReferenceSpaceOffset(this._referencedPosition,this._referenceQuaternion.normalize()))},t.prototype._updateReferenceSpaceOffset=function(e,t,i){if(void 0===i&&(i=!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),i&&(this._xrInvPositionCache.y=0);var n=new XRRigidTransform({x:this._xrInvPositionCache.x,y:this._xrInvPositionCache.y,z:this._xrInvPositionCache.z},{x:this._xrInvQuaternionCache.x,y:this._xrInvQuaternionCache.y,z:this._xrInvQuaternionCache.z,w:this._xrInvQuaternionCache.w}),r=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(n),o=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(r);if(o){var s=new a.e(o.transform.position.x,o.transform.position.y,o.transform.position.z);this._scene.useRightHandedSystem||(s.z*=-1),this.position.subtractToRef(s,s),this._scene.useRightHandedSystem||(s.z*=-1),s.negateInPlace();var c=new XRRigidTransform({x:s.x,y:s.y,z:s.z});this._xrSessionManager.referenceSpace=r.getOffsetReferenceSpace(c)}}},t}(wt),Ia=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.FEATURE_POINTS="xr-feature-points",e.HAND_TRACKING="xr-hand-tracking",e}(),Da=function(){function e(e){var t=this;this._xrSessionManager=e,this._features={},this._xrSessionManager.onXRSessionInit.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];!i.enabled||i.featureImplementation.attached||i.featureImplementation.disableAutoAttach||t.attachFeature(e)}))})),this._xrSessionManager.onXRSessionEnded.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];i.enabled&&i.featureImplementation.attached&&t.detachFeature(e)}))}))}return e.AddWebXRFeature=function(e,t,i,n){void 0===i&&(i=1),void 0===n&&(n=!1),this._AvailableFeatures[e]=this._AvailableFeatures[e]||{latest:i},i>this._AvailableFeatures[e].latest&&(this._AvailableFeatures[e].latest=i),n&&(this._AvailableFeatures[e].stable=i),this._AvailableFeatures[e][i]=t},e.ConstructFeature=function(e,t,i,n){void 0===t&&(t=1);var r=this._AvailableFeatures[e][t];if(!r)throw new Error("feature not found");return r(i,n)},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,i=this._features[t];return!(!i||!i.enabled)&&(i.enabled=!1,this.detachFeature(t),i.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,i,n,r,o){var a=this;void 0===i&&(i="latest"),void 0===n&&(n={}),void 0===r&&(r=!0),void 0===o&&(o=!0);var s="string"==typeof t?t:t.Name,c=0;if("string"==typeof i){if(!i)throw new Error("Error in provided version - "+s+" ("+i+")");if(-1===(c="stable"===i?e.GetStableVersionOfFeature(s):"latest"===i?e.GetLatestVersionOfFeature(s):+i)||isNaN(c))throw new Error("feature not found - "+s+" ("+i+")")}else c=i;var l=this._features[s],u=e.ConstructFeature(s,c,this._xrSessionManager,n);if(!u)throw new Error("feature not found - "+s);l&&this.disableFeature(s);var h=u();if(h.dependsOn&&!h.dependsOn.every((function(e){return!!a._features[e]})))throw new Error("Dependant features missing. Make sure the following features are enabled - "+h.dependsOn.join(", "));if(h.isCompatible())return this._features[s]={featureImplementation:h,enabled:!0,version:c,required:o},r?this._xrSessionManager.session&&!this._features[s].featureImplementation.attached&&this.attachFeature(s):this._features[s].featureImplementation.disableAutoAttach=!0,this._features[s].featureImplementation;if(o)throw new Error("required feature not compatible");return Ce.b.Warn("Feature "+s+" not compatible with the current environment/browser and was not enabled."),h},e.prototype.getEnabledFeature=function(e){return this._features[e]&&this._features[e].featureImplementation},e.prototype.getEnabledFeatures=function(){return Object.keys(this._features)},e.prototype.extendXRSessionInitObject=function(e){var t=this;return this.getEnabledFeatures().forEach((function(i){var n=t._features[i],r=n.featureImplementation.xrNativeFeatureName;r&&(n.required?(e.requiredFeatures=e.requiredFeatures||[],-1===e.requiredFeatures.indexOf(r)&&e.requiredFeatures.push(r)):(e.optionalFeatures=e.optionalFeatures||[],-1===e.optionalFeatures.indexOf(r)&&e.optionalFeatures.push(r)))})),e},e._AvailableFeatures={},e}(),Na=function(){function e(e){var t=this;this.scene=e,this._nonVRCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this.onInitialXRPoseSetObservable=new o.c,this.onStateChangedObservable=new o.c,this.state=$i.NOT_IN_XR,this.sessionManager=new an(e),this.camera=new Ma("",e,this.sessionManager),this.featuresManager=new Da(this.sessionManager),e.onDisposeObservable.add((function(){t.exitXRAsync()}))}return e.CreateAsync=function(t){var i=new e(t);return i.sessionManager.initializeAsync().then((function(){return i._supported=!0,i})).catch((function(e){throw i._setState($i.NOT_IN_XR),i.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,i,n){var r=this;if(void 0===i&&(i=this.sessionManager.getWebXRRenderTarget()),void 0===n&&(n={}),!this._supported)throw"WebXR not supported in this browser or environment";return this._setState($i.ENTERING_XR),"viewer"!==t&&"local"!==t&&(n.optionalFeatures=n.optionalFeatures||[],n.optionalFeatures.push(t)),this.featuresManager.extendXRSessionInitObject(n),"immersive-ar"===e&&"unbounded"!==t&&m.a.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),this.sessionManager.initializeSessionAsync(e,n).then((function(){return r.sessionManager.setReferenceSpaceTypeAsync(t)})).then((function(){return i.initializeXRLayerAsync(r.sessionManager.session)})).then((function(){return r.sessionManager.updateRenderStateAsync({depthFar:r.camera.maxZ,depthNear:r.camera.minZ,baseLayer:i.xrLayer})})).then((function(){return r.sessionManager.runXRRenderLoop(),r._originalSceneAutoClear=r.scene.autoClear,r._nonVRCamera=r.scene.activeCamera,r.scene.activeCamera=r.camera,"immersive-ar"!==e?r._nonXRToXRCamera():(r.scene.autoClear=!1,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($i.NOT_IN_XR)})),r.sessionManager.onXRFrameObservable.addOnce((function(){r._setState($i.IN_XR)})),r.sessionManager})).catch((function(e){throw console.log(e),console.log(e.message),r._setState($i.NOT_IN_XR),e}))},e.prototype.exitXRAsync=function(){return this.state!==$i.IN_XR?Promise.resolve():(this._setState($i.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}(),La=function(){function e(e,t,i,n){void 0===i&&(i=-1),void 0===n&&(n=[]),this.id=e,this.type=t,this._buttonIndex=i,this._axesIndices=n,this._axes={x:0,y:0},this._changes={},this._currentValue=0,this._hasChanges=!1,this._pressed=!1,this._touched=!1,this.onAxisValueChangedObservable=new o.c,this.onButtonStateChangedObservable=new o.c}return Object.defineProperty(e.prototype,"axes",{get:function(){return this._axes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"changes",{get:function(){return this._changes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasChanges",{get:function(){return this._hasChanges},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pressed",{get:function(){return this._pressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"touched",{get:function(){return this._touched},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._currentValue},enumerable:!1,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,i=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){var n=e.buttons[this._buttonIndex];if(!n)return;this._currentValue!==n.value&&(this.changes.value={current:n.value,previous:this._currentValue},t=!0,this._currentValue=n.value),this._touched!==n.touched&&(this.changes.touched={current:n.touched,previous:this._touched},t=!0,this._touched=n.touched),this._pressed!==n.pressed&&(this.changes.pressed={current:n.pressed,previous:this._pressed},t=!0,this._pressed=n.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]],i=!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]],i=!0)),t&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),i&&(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}(),wa=function(){function e(e,t,i,n,r){var a=this;void 0===r&&(r=!1),this.scene=e,this.layout=t,this.gamepadObject=i,this.handedness=n,this._initComponent=function(e){if(e){var t=a.layout.components[e],i=t.type,n=t.gamepadIndices.button,r=[];void 0!==t.gamepadIndices.xAxis&&void 0!==t.gamepadIndices.yAxis&&r.push(t.gamepadIndices.xAxis,t.gamepadIndices.yAxis),a.components[e]=new La(e,i,n,r)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new o.c,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(h.b)(this,void 0,void 0,(function(){var e,t,i=this;return Object(h.e)(this,(function(n){return e=!this._getModelLoadingConstraints(),t=this._getGenericFilenameAndPath(),e?m.a.Warn("Falling back to generic models"):t=this._getFilenameAndPath(),[2,new Promise((function(n,r){pr.ImportMesh("",t.path,t.filename,i.scene,(function(t){e?i._getGenericParentMesh(t):i._setRootMesh(t),i._processLoadedModel(t),i._modelReady=!0,i.onModelLoadedObservable.notifyObservers(i),n(!0)}),null,(function(e,n){m.a.Log(n),m.a.Warn("Failed to retrieve controller model of type "+i.profileId+" from the remote server: "+t.path+t.filename),r(n)}))}))]}))}))},e.prototype.updateFromXRFrame=function(e){var t=this;this.getComponentIds().forEach((function(e){return t.getComponent(e).update(t.gamepadObject)})),this.updateModel(e)},Object.defineProperty(e.prototype,"handness",{get:function(){return this.handedness},enumerable:!1,configurable:!0}),e.prototype.pulse=function(e,t,i){return void 0===i&&(i=0),this.gamepadObject.hapticActuators&&this.gamepadObject.hapticActuators[i]?this.gamepadObject.hapticActuators[i].pulse(e,t):Promise.resolve(!1)},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,i){if(e.minMesh&&e.maxMesh&&e.valueMesh&&e.minMesh.rotationQuaternion&&e.maxMesh.rotationQuaternion&&e.valueMesh.rotationQuaternion){var n=i?.5*t+.5:t;a.b.SlerpToRef(e.minMesh.rotationQuaternion,e.maxMesh.rotationQuaternion,n,e.valueMesh.rotationQuaternion),a.e.LerpToRef(e.minMesh.position,e.maxMesh.position,n,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 be.a(this.profileId+" "+this.handedness,this.scene),e.forEach((function(e){e.parent||(e.isPickable=!1,e.setParent(t.rootMesh))})),this.rootMesh.rotationQuaternion=a.b.FromEulerAngles(0,Math.PI,0)},e}(),Fa=function(e){function t(i,n,r){var o=e.call(this,i,Ba[r],n,r)||this;return o.profileId=t.ProfileId,o}return Object(h.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 be.a(this.profileId+" "+this.handedness,this.scene),e.forEach((function(e){e.isPickable=!1,e.parent||e.setParent(t.rootMesh)})),this.rootMesh.rotationQuaternion=a.b.FromEulerAngles(0,Math.PI,0)},t.prototype._updateModel=function(){},t.ProfileId="generic-trigger",t}(wa),Ba={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"}},Ua=function(e){function t(t,i,n,r){var o=e.call(this,t,n.layouts[i.handedness||"none"],i.gamepad,i.handedness)||this;return o._repositoryUrl=r,o._buttonMeshMapping={},o._touchDots={},o.profileId=n.profileId,o}return Object(h.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=pr.IsPluginForExtensionAvailable(".glb");return e||m.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 i=t.layout.components[e];t._buttonMeshMapping[e]={mainMesh:t._getChildByName(t.rootMesh,i.rootNodeName),states:{}},Object.keys(i.visualResponses).forEach((function(n){var r=i.visualResponses[n];if("transform"===r.valueNodeProperty)t._buttonMeshMapping[e].states[n]={valueMesh:t._getChildByName(t.rootMesh,r.valueNodeName),minMesh:t._getChildByName(t.rootMesh,r.minNodeName),maxMesh:t._getChildByName(t.rootMesh,r.maxNodeName)};else{var o=i.type===La.TOUCHPAD_TYPE&&i.touchPointNodeName?i.touchPointNodeName:r.valueNodeName;if(t._buttonMeshMapping[e].states[n]={valueMesh:t._getChildByName(t.rootMesh,o)},i.type===La.TOUCHPAD_TYPE&&!t._touchDots[n]){var a=xr.a.CreateSphere(n+"dot",{diameter:.0015,segments:8},t.scene);a.material=new Wi.a(n+"mat",t.scene),a.material.diffuseColor=s.a.Red(),a.parent=t._buttonMeshMapping[e].states[n].valueMesh||null,a.isVisible=!1,t._touchDots[n]=a}}}))}))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new be.a(this.profileId+"-"+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;in/10&&(a.isVisible=!0),(s+=t._scene.getEngine().getDeltaTime())>=n)t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),c=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),a.isVisible=!1;else{var e=1-s/n;a.scaling.set(e,e,e)}else c=!1,s=0;t._scene.simulatePointerMove(i.pick,{pointerId:i.id}),o=i.pick}})),void 0!==this._options.renderingGroupId&&(a.renderingGroupId=this._options.renderingGroupId),e&&e.onDisposeObservable.addOnce((function(){i.pick&&!t._options.disablePointerUpOnTouchOut&&c&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),a.dispose()}))},t.prototype._attachScreenRayMode=function(e){var t=this,i=this._controllers[e.uniqueId],n=!1;i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){!i.pick||t._options.disablePointerUpOnTouchOut&&n||(n?t._scene.simulatePointerMove(i.pick,{pointerId:i.id}):(t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),n=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id})))})),e.onDisposeObservable.addOnce((function(){i.pick&&n&&!t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id})}))},t.prototype._attachTrackedPointerRayMode=function(e){var t=this,i=this._controllers[e.uniqueId];if(this._options.forceGazeMode)return this._attachGazeMode(e);if(i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){i.laserPointer.material.disableLighting=t.disablePointerLighting,i.selectionMesh.material.disableLighting=t.disableSelectionMeshLighting,i.pick&&t._scene.simulatePointerMove(i.pick,{pointerId:i.id})})),e.inputSource.gamepad){var n=function(n){t._options.overrideButtonId&&(i.selectionComponent=n.getComponent(t._options.overrideButtonId)),i.selectionComponent||(i.selectionComponent=n.getMainComponent()),i.onButtonChangedObserver=i.selectionComponent.onButtonStateChangedObservable.add((function(n){if(n.changes.pressed){var r=n.changes.pressed.current;i.pick?(t._options.enablePointerSelectionOnAllControllers||e.uniqueId===t._attachedController)&&(r?(t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=t.laserPointerPickedColor):(t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=t.laserPointerDefaultColor)):!r||t._options.enablePointerSelectionOnAllControllers||t._options.disableSwitchOnClick||(t._attachedController=e.uniqueId)}}))};e.motionController?n(e.motionController):e.onMotionControllerInitObservable.add(n)}else{var r=function(e){i.xrController&&e.inputSource===i.xrController.inputSource&&i.pick&&(t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=t.laserPointerPickedColor)},o=function(e){i.xrController&&e.inputSource===i.xrController.inputSource&&i.pick&&(t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=t.laserPointerDefaultColor)};i.eventListeners={selectend:o,selectstart:r},this._xrSessionManager.session.addEventListener("selectstart",r),this._xrSessionManager.session.addEventListener("selectend",o)}},t.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(a.e.Dot(e,t.direction))n},t.prototype._updatePointerDistance=function(e,t){void 0===t&&(t=100),e.scaling.y=t,this._scene.useRightHandedSystem&&(t*=-1),e.position.z=t/2+.05},Object.defineProperty(t.prototype,"lasterPointerDefaultColor",{get:function(){return this.laserPointerDefaultColor},enumerable:!1,configurable:!0}),t._idCounter=200,t.Name=Ia.POINTER_SELECTION,t.Version=1,t}(ja);Da.AddWebXRFeature(Wa.Name,(function(e,t){return function(){return new Wa(e,t)}}),Wa.Version,!0);var Ha,Xa=function(){function e(e,t,i){this.element=e,this.sessionMode=t,this.referenceSpaceType=i}return e.prototype.update=function(e){},e}(),Ya=function(){},Ka=function(){function e(e,t){var i=this;if(this.scene=e,this.options=t,this._activeButton=null,this._buttons=[],this.activeButtonChangedObservable=new o.c,this.overlay=document.createElement("div"),this.overlay.classList.add("xr-button-overlay"),this.overlay.style.cssText="z-index:11;position: absolute; right: 20px;bottom: 50px;","undefined"!=typeof window&&window.location&&"http:"===window.location.protocol&&Ce.b.Warn("WebXR can only be served over HTTPS"),t.customButtons)this._buttons=t.customButtons;else{var n=t.sessionMode||"immersive-vr",r=t.referenceSpaceType||"local-floor",a=".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url("+("undefined"==typeof SVGSVGElement?"https://cdn.babylonjs.com/Assets/vrButton.png":"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A")+"); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";a+='.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';var s=document.createElement("style");s.appendChild(document.createTextNode(a)),document.getElementsByTagName("head")[0].appendChild(s);var c=document.createElement("button");c.className="babylonVRicon",c.title=n+" - "+r,this._buttons.push(new Xa(c,n,r)),this._buttons[this._buttons.length-1].update=function(e){this.element.style.display=null===e||e===this?"":"none",c.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(){i.dispose()})))}return e.CreateAsync=function(t,i,n){var r=this,o=new e(t,n),a=o._buttons.map((function(e){return i.sessionManager.isSessionSupportedAsync(e.sessionMode)}));return i.onStateChangedObservable.add((function(e){e==$i.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(h.b)(r,void 0,void 0,(function(){var e,r,a;return Object(h.e)(this,(function(s){switch(s.label){case 0:return i.state!=$i.IN_XR?[3,2]:[4,i.exitXRAsync()];case 1:return s.sent(),o._updateButtons(null),[3,6];case 2:if(i.state!=$i.NOT_IN_XR)return[3,6];if(!n.renderTarget)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,i.enterXRAsync(o._buttons[t].sessionMode,o._buttons[t].referenceSpaceType,n.renderTarget,{optionalFeatures:n.optionalFeatures,requiredFeatures:n.requiredFeatures})];case 4:return s.sent(),o._updateButtons(o._buttons[t]),[3,6];case 5:return e=s.sent(),o._updateButtons(null),r=o._buttons[t].element,a=r.title,r.title="Error entering XR session : "+a,r.classList.add("xr-error"),n.onError&&n.onError(e),[3,6];case 6:return[2]}}))}))}):Ce.b.Warn('Session mode "'+o._buttons[t].sessionMode+'" not supported in browser')})),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}();function Qa(e){var t,i=0,n=Date.now();e.observableParameters=null!==(t=e.observableParameters)&&void 0!==t?t:{};var r=e.contextObservable.add((function(t){var o=Date.now(),a={startTime:n,currentTime:o,deltaTime:i=o-n,completeRate:i/e.timeout,payload:t};e.onTick&&e.onTick(a),e.breakCondition&&e.breakCondition()&&(e.contextObservable.remove(r),e.onAborted&&e.onAborted(a)),i>=e.timeout&&(e.contextObservable.remove(r),e.onEnded&&e.onEnded(a))}),e.observableParameters.mask,e.observableParameters.insertFirst,e.observableParameters.scope);return r}!function(e){e[e.INIT=0]="INIT",e[e.STARTED=1]="STARTED",e[e.ENDED=2]="ENDED"}(Ha||(Ha={}));var qa=function(){function e(e){var t,i,n=this;this.onEachCountObservable=new o.c,this.onTimerAbortedObservable=new o.c,this.onTimerEndedObservable=new o.c,this.onStateChangedObservable=new o.c,this._observer=null,this._breakOnNextTick=!1,this._tick=function(e){var t=Date.now();n._timer=t-n._startTime;var i={startTime:n._startTime,currentTime:t,deltaTime:n._timer,completeRate:n._timer/n._timeToEnd,payload:e},r=n._breakOnNextTick||n._breakCondition(i);r||n._timer>=n._timeToEnd?n._stop(i,r):n.onEachCountObservable.notifyObservers(i)},this._setState(Ha.INIT),this._contextObservable=e.contextObservable,this._observableParameters=null!==(t=e.observableParameters)&&void 0!==t?t:{},this._breakCondition=null!==(i=e.breakCondition)&&void 0!==i?i:function(){return!1},e.onEnded&&this.onTimerEndedObservable.add(e.onEnded),e.onTick&&this.onEachCountObservable.add(e.onTick),e.onAborted&&this.onTimerAbortedObservable.add(e.onAborted)}return Object.defineProperty(e.prototype,"breakCondition",{set:function(e){this._breakCondition=e},enumerable:!1,configurable:!0}),e.prototype.clearObservables=function(){this.onEachCountObservable.clear(),this.onTimerAbortedObservable.clear(),this.onTimerEndedObservable.clear(),this.onStateChangedObservable.clear()},e.prototype.start=function(e){if(void 0===e&&(e=this._timeToEnd),this._state===Ha.STARTED)throw new Error("Timer already started. Please stop it before starting again");this._timeToEnd=e,this._startTime=Date.now(),this._timer=0,this._observer=this._contextObservable.add(this._tick,this._observableParameters.mask,this._observableParameters.insertFirst,this._observableParameters.scope),this._setState(Ha.STARTED)},e.prototype.stop=function(){this._state===Ha.STARTED&&(this._breakOnNextTick=!0)},e.prototype.dispose=function(){this._observer&&this._contextObservable.remove(this._observer),this.clearObservables()},e.prototype._setState=function(e){this._state=e,this.onStateChangedObservable.notifyObservers(this._state)},e.prototype._stop=function(e,t){void 0===t&&(t=!1),this._contextObservable.remove(this._observer),this._setState(Ha.ENDED),t?this.onTimerAbortedObservable.notifyObservers(e):this.onTimerEndedObservable.notifyObservers(e)},e}(),Za=function(e){function t(t,i){var n=e.call(this,t)||this;return n._options=i,n._controllers={},n._snappedToPoint=!1,n._tmpRay=new Xt.a(new a.e,new a.e),n._tmpVector=new a.e,n._tmpQuaternion=new a.b,n.backwardsMovementEnabled=!0,n.backwardsTeleportationDistance=.7,n.parabolicCheckRadius=5,n.parabolicRayEnabled=!0,n.straightRayEnabled=!0,n.rotationAngle=Math.PI/8,n._rotationEnabled=!0,n._attachController=function(e){if(!(n._controllers[e.uniqueId]||n._options.forceHandedness&&e.inputSource.handedness!==n._options.forceHandedness)){n._controllers[e.uniqueId]={xrController:e,teleportationState:{forward:!1,backwards:!1,rotating:!1,currentRotation:0,baseRotation:0}};var t=n._controllers[e.uniqueId];if("tracked-pointer"===t.xrController.inputSource.targetRayMode&&t.xrController.inputSource.gamepad){var i=function(){if(e.motionController){var i=e.motionController.getComponentOfType(La.THUMBSTICK_TYPE)||e.motionController.getComponentOfType(La.TOUCHPAD_TYPE);if(!i||n._options.useMainComponentOnly){var r=e.motionController.getMainComponent();if(!r)return;t.teleportationComponent=r,t.onButtonChangedObserver=r.onButtonStateChangedObservable.add((function(){r.changes.pressed&&(r.changes.pressed.current?(t.teleportationState.forward=!0,n._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Qa({timeout:n._options.timeToTeleport||3e3,contextObservable:n._xrSessionManager.onXRFrameObservable,breakCondition:function(){return!r.pressed},onEnded:function(){n._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&n._teleportForward(e.uniqueId)}})):(t.teleportationState.forward=!1,n._currentTeleportationControllerId=""))}))}else t.teleportationComponent=i,t.onAxisChangedObserver=i.onAxisValueChangedObservable.add((function(i){if(i.y<=.7&&t.teleportationState.backwards&&(t.teleportationState.backwards=!1),i.y>.7&&!t.teleportationState.forward&&n.backwardsMovementEnabled&&!n.snapPointsOnly&&!t.teleportationState.backwards){t.teleportationState.backwards=!0,n._tmpQuaternion.copyFrom(n._options.xrInput.xrCamera.rotationQuaternion),n._tmpQuaternion.toEulerAnglesToRef(n._tmpVector),n._tmpVector.x=0,n._tmpVector.z=0,a.b.FromEulerVectorToRef(n._tmpVector,n._tmpQuaternion),n._tmpVector.set(0,0,n.backwardsTeleportationDistance*(n._xrSessionManager.scene.useRightHandedSystem?1:-1)),n._tmpVector.rotateByQuaternionToRef(n._tmpQuaternion,n._tmpVector),n._tmpVector.addInPlace(n._options.xrInput.xrCamera.position),n._tmpRay.origin.copyFrom(n._tmpVector),n._tmpRay.length=n._options.xrInput.xrCamera.realWorldHeight+.1,n._tmpRay.direction.set(0,-1,0);var r=n._xrSessionManager.scene.pickWithRay(n._tmpRay,(function(e){return-1!==n._floorMeshes.indexOf(e)}));r&&r.pickedPoint&&(n._options.xrInput.xrCamera.position.x=r.pickedPoint.x,n._options.xrInput.xrCamera.position.z=r.pickedPoint.z)}if(i.y<-.7&&!n._currentTeleportationControllerId&&!t.teleportationState.rotating&&(t.teleportationState.forward=!0,n._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),i.x){if(t.teleportationState.forward)n._currentTeleportationControllerId===t.xrController.uniqueId&&(n.rotationEnabled?setTimeout((function(){t.teleportationState.currentRotation=Math.atan2(i.x,i.y*(n._xrSessionManager.scene.useRightHandedSystem?1:-1))})):t.teleportationState.currentRotation=0);else if(!t.teleportationState.rotating&&Math.abs(i.x)>.7){t.teleportationState.rotating=!0;var o=n.rotationAngle*(i.x>0?1:-1)*(n._xrSessionManager.scene.useRightHandedSystem?-1:1);n._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(a.b.FromEulerAngles(0,o,0))}}else t.teleportationState.rotating=!1;0===i.x&&0===i.y&&t.teleportationState.forward&&n._teleportForward(e.uniqueId)}))}};e.motionController?i():e.onMotionControllerInitObservable.addOnce((function(){i()}))}else n._xrSessionManager.scene.onPointerObservable.add((function(i){i.type===Ne.a.POINTERDOWN?(t.teleportationState.forward=!0,n._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Qa({timeout:n._options.timeToTeleport||3e3,contextObservable:n._xrSessionManager.onXRFrameObservable,onEnded:function(){n._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&n._teleportForward(e.uniqueId)}})):i.type===Ne.a.POINTERUP&&(t.teleportationState.forward=!1,n._currentTeleportationControllerId="")}))}},n._options.teleportationTargetMesh||n._createDefaultTargetMesh(),n._floorMeshes=n._options.floorMeshes||[],n._snapToPositions=n._options.snapPositions||[],n._setTargetMeshVisibility(!1),n}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"rotationEnabled",{get:function(){return this._rotationEnabled},set:function(e){if(this._rotationEnabled=e,this._options.teleportationTargetMesh){var t=this._options.teleportationTargetMesh.getChildMeshes(!1,(function(e){return"rotationCone"===e.name}));t[0]&&t[0].setEnabled(e)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"teleportationTargetMesh",{get:function(){return this._options.teleportationTargetMesh||null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapPointsOnly",{get:function(){return!!this._options.snapPointsOnly},set:function(e){this._options.snapPointsOnly=e},enumerable:!1,configurable:!0}),t.prototype.addFloorMesh=function(e){this._floorMeshes.push(e)},t.prototype.addSnapPoint=function(e){this._snapToPositions.push(e)},t.prototype.attach=function(){var t=this;return!!e.prototype.attach.call(this)&&(this._currentTeleportationControllerId="",this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,(function(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),this._currentTeleportationControllerId="",this._controllers={},!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 i=0;i=c.video.HAVE_CURRENT_DATA;return!s.poster||s.autoPlay&&l?l&&c._createInternalTexture():(c._texture=c._getEngine().createTexture(s.poster,!1,!c.invertY,n),c._displayingPosterTexture=!0),c}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new o.c),this._onUserActionRequestedObservable},enumerable:!1,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 Ce.b.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement("video");return"string"==typeof e?(Ce.b.SetCorsBehavior(e,t),t.src=e):(Ce.b.SetCorsBehavior(e[0],t),e.forEach((function(e){var i=document.createElement("source");i.src=e,t.appendChild(i)}))),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,i){var n=document.createElement("video");return e.getEngine()._badOS&&(document.body.appendChild(n),n.style.transform="scale(0.0001, 0.0001)",n.style.opacity="0",n.style.position="fixed",n.style.bottom="0px",n.style.right="0px"),n.setAttribute("autoplay",""),n.setAttribute("muted","true"),n.setAttribute("playsinline",""),n.muted=!0,void 0!==n.mozSrcObject?n.mozSrcObject=i:"object"==typeof n.srcObject?n.srcObject=i:(window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,n.src=window.URL&&window.URL.createObjectURL(i)),new Promise((function(i){var r=function(){i(new t("video",n,e,!0,!0)),n.removeEventListener("playing",r)};n.addEventListener("playing",r),n.play()}))},t.CreateFromWebCamAsync=function(e,t,i){var n,r=this;return void 0===i&&(i=!1),t&&t.deviceId&&(n={exact:t.deviceId}),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:t,audio:i}).then((function(t){return r.CreateFromStreamAsync(e,t)})):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:t&&t.minWidth||256,max:t&&t.maxWidth||640},height:{min:t&&t.minHeight||256,max:t&&t.maxHeight||480}},audio:i},(function(t){return r.CreateFromStreamAsync(e,t)}),(function(e){m.a.Error(e.name)})),Promise.reject("No support for userMedia on this device"))},t.CreateFromWebCam=function(e,t,i,n){void 0===n&&(n=!1),this.CreateFromWebCamAsync(e,i,n).then((function(e){t&&t(e)})).catch((function(e){m.a.Error(e.name)}))},t}(Ke.a),is=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"videoTexture",{get:function(){return this._texture},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"videoMode",{get:function(){return this.textureMode},set:function(e){this.textureMode=e},enumerable:!1,configurable:!0}),t.prototype._initTexture=function(e,t,i){var n=this,r={loop:i.loop,autoPlay:i.autoPlay,autoUpdateTexture:!0,poster:i.poster},o=new ts((this.name||"videoDome")+"_texture",e,t,i.generateMipMaps,this._useDirectMapping,Ke.a.TRILINEAR_SAMPLINGMODE,r);return i.clickToPlay&&(t.onPointerUp=function(){n._texture.video.play()}),o},t.MODE_MONOSCOPIC=vo.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=vo.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=vo.MODE_SIDEBYSIDE,t}(vo),ns=i(55),rs=function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._gpuFrameTime=new ns.a,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new ns.a,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(e.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTime},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!1,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:!1,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},e}(),os=function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new ns.a,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new ns.a,this._captureFrameTime=!1,this._frameTime=new ns.a,this._captureRenderTime=!1,this._renderTime=new ns.a,this._captureInterFrameTime=!1,this._interFrameTime=new ns.a,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new ns.a,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new ns.a,this._capturePhysicsTime=!1,this._physicsTime=new ns.a,this._captureAnimationsTime=!1,this._animationsTime=new ns.a,this._captureCameraRenderTime=!1,this._cameraRenderTime=new ns.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&&(Ce.b.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&&(Ce.b.EndPerformanceCounter("Scene rendering"),t._frameTime.endMonitoring()),t._captureRenderTime&&t._renderTime.endMonitoring(!1),t._captureInterFrameTime&&t._interFrameTime.beginMonitoring()}))}return Object.defineProperty(e.prototype,"activeMeshesEvaluationTimeCounter",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!1,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(){Ce.b.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){Ce.b.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!1,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(){Ce.b.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){Ce.b.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!1,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(){Ce.b.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){Ce.b.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!1,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(){Ce.b.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){Ce.b.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!1,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(){Ce.b.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){Ce.b.EndPerformanceCounter("Physics"),t._physicsTime.endMonitoring()}))):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!1,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(),Ce.b.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),Ce.b.EndPerformanceCounter("Main render")}))):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraRenderTimeCounter",{get:function(){return this._cameraRenderTime},enumerable:!1,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(),Ce.b.StartPerformanceCounter("Rendering camera "+e.name)})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),Ce.b.EndPerformanceCounter("Rendering camera "+e.name)}))):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!1,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},e}(),as="#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);\n#ifdef GLOW\n\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef HIGHLIGHT\n\nfinalColor.a=albedoTexture.a;\n#endif\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(Qi.b.MatricesIndicesExtraKind),o.push(Qi.b.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers);var p=a.skeleton;p&&p.isUsingTextureForMatrices?r.push("#define BONETEXTURE"):r.push("#define BonesPerMesh "+(p?p.bones.length+1:0)),a.numBoneInfluencers>0&&f.addCPUSkinningFallback(0,a)}else r.push("#define NUM_BONE_INFLUENCERS 0");var _=a.morphTargetManager,m=0;_&&_.numInfluencers>0&&(r.push("#define MORPHTARGETS"),m=_.numInfluencers,r.push("#define NUM_MORPH_INFLUENCERS "+m),ro.a.PrepareAttributesForMorphTargetsInfluencers(o,a,m)),t&&(r.push("#define INSTANCES"),ro.a.PushAttributesForInstances(o),e.getRenderingMesh().hasThinInstances&&r.push("#define THIN_INSTANCES")),this._addCustomEffectDefines(r);var g=r.join("\n");return this._cachedDefines!==g&&(this._cachedDefines=g,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","glowColor","morphTargetInfluences","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity"],["diffuseSampler","emissiveSampler","opacitySampler","boneSampler"],g,f,void 0,void 0,{maxSimultaneousMorphTargets:m})),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,i){return Ce.b.Instantiate(e.customType).Parse(e,t,i)},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport("EffectLayerSceneComponent")},Object(h.c)([Object(w.c)()],e.prototype,"name",void 0),Object(h.c)([Object(w.f)()],e.prototype,"neutralColor",void 0),Object(h.c)([Object(w.c)()],e.prototype,"isEnabled",void 0),Object(h.c)([Object(w.d)()],e.prototype,"camera",null),Object(h.c)([Object(w.c)()],e.prototype,"renderingGroupId",null),Object(h.c)([Object(w.c)()],e.prototype,"disableBoundingBoxesFromEffectLayer",void 0),e}();n.a.AddParser(Me.a.NAME_EFFECTLAYER,(function(e,t,i,n){if(e.effectLayers){i.effectLayers||(i.effectLayers=new Array);for(var r=0;r0){this._previousStencilState=this._engine.getStencilBuffer();for(var n=0,r=i;n-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,i=0;i-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.splice(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=w.a.Serialize(this);if(t.customType="BABYLON.GlowLayer",t.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e0&&e.isBackground===t&&e.renderTargetTextures.indexOf(n)>-1&&0!=(e.layerMask&i)},e.prototype._drawRenderTargetBackground=function(e){var t=this;this._draw((function(i){return t._drawRenderTargetPredicate(i,!0,t.scene.activeCamera.layerMask,e)}))},e.prototype._drawRenderTargetForeground=function(e){var t=this;this._draw((function(i){return t._drawRenderTargetPredicate(i,!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 i=this;void 0===t&&(t=!1),e.layers&&e.layers.forEach((function(e){var n=i.scene.layers.indexOf(e);-1!==n&&i.scene.layers.splice(n,1),t&&e.dispose()}))},e}(),gs="\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}";ai.a.ShadersStore.layerPixelShader=gs;var vs="\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}";ai.a.ShadersStore.layerVertexShader=vs;var bs=function(){function e(e,t,i,n,r){this.name=e,this.scale=new a.d(1,1),this.offset=new a.d(0,0),this.alphaBlendingMode=g.a.ALPHA_COMBINE,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this._vertexBuffers={},this.onDisposeObservable=new o.c,this.onBeforeRenderObservable=new o.c,this.onAfterRenderObservable=new o.c,this.texture=t?new Ke.a(t,i,!0):null,this.isBackground=void 0===n||n,this.color=void 0===r?new s.b(1,1,1,1):r,this._scene=i||x.a.LastCreatedScene;var c=this._scene._getComponent(Me.a.NAME_LAYER);c||(c=new ms(this._scene),this._scene._addComponent(c)),this._scene.layers.push(this);var l=this._scene.getEngine(),u=[];u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1);var h=new Qi.b(l,u,Qi.b.PositionKind,!1,!1,2);this._vertexBuffers[Qi.b.PositionKind]=h,this._createIndexBuffer()}return Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,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[Qi.b.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",[Qi.b.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],t));var i=this._effect;if(i&&i.isReady()&&this.texture&&this.texture.isReady()){e=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),e.enableEffect(i),e.setState(!1),i.setTexture("textureSampler",this.texture),i.setMatrix("textureMatrix",this.texture.getTextureMatrix()),i.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),i.setVector2("offset",this.offset),i.setVector2("scale",this.scale),e.bindBuffers(this._vertexBuffers,this._indexBuffer,i),this.alphaTest?e.drawElementsType(xo.a.TriangleFillMode,0,6):(e.setAlphaMode(this.alphaBlendingMode),e.drawElementsType(xo.a.TriangleFillMode,0,6),e.setAlphaMode(g.a.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},e.prototype.dispose=function(){var e=this._vertexBuffers[Qi.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[Qi.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null),this.renderTargetTextures=[];var 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()},e}(),ys=function(){function e(e,t,i,n,r){this.size=e,this.position=t,this.alphaMode=g.a.ALPHA_ONEONE,this.color=i||new s.a(1,1,1),this.texture=n?new Ke.a(n,r.getScene(),!0):null,this._system=r,r.lensFlares.push(this)}return e.AddFlare=function(t,i,n,r,o){return new e(t,i,n,r,o)},e.prototype.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},e}(),Ts="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}";ai.a.ShadersStore.lensFlarePixelShader=Ts;var Es="\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}";ai.a.ShadersStore.lensFlareVertexShader=Es;var Ss=function(){function e(t,i,n){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=n||x.a.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._emitter=i,this.id=t,n.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return n.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&n.activeCamera.layerMask)};var r=n.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[Qi.b.PositionKind]=new Qi.b(r,o,Qi.b.PositionKind,!1,!1,2);var a=[];a.push(0),a.push(1),a.push(2),a.push(0),a.push(2),a.push(3),this._indexBuffer=r.createIndexBuffer(a),this._effect=r.createEffect("lensFlare",[Qi.b.PositionKind],["color","viewportMatrix"],["textureSampler"],"")}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!1,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=a.e.Project(t,a.a.Identity(),this._scene.getTransformMatrix(),e),this._positionX=t.x,this._positionY=t.y,t=a.e.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 i=new Xt.a(this._scene.activeCamera.globalPosition,e),n=this._scene.pickWithRay(i,this.meshesSelectionPredicate,!0);return!n||!n.hit||n.distance>t},e.prototype.render=function(){if(!this._effect.isReady()||!this._scene.activeCamera)return!1;var e,t,i=this._scene.getEngine(),n=this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0),i.getRenderHeight(!0));if(!this.computeEffectivePosition(n))return!1;if(!this._isVisible())return!1;var r=(e=this._positionXn.x+n.width-this.borderLimit?this._positionX-n.x-n.width+this.borderLimit:0)>(t=this._positionYn.y+n.height-this.borderLimit?this._positionY-n.y-n.height+this.borderLimit:0)?e:t;(r-=this.viewportBorder)>this.borderLimit&&(r=this.borderLimit);var o=1-L.a.Clamp(r/this.borderLimit,0,1);if(o<0)return!1;o>1&&(o=1),this.viewportBorder>0&&(n.x+=this.viewportBorder,n.y+=this.viewportBorder,n.width-=2*this.viewportBorder,n.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var s=n.x+n.width/2,c=n.y+n.height/2,l=s-this._positionX,u=c-this._positionY;i.enableEffect(this._effect),i.setState(!1),i.setDepthBuffer(!1),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var h=0;h0);for(var i=0,n=t;i0)}},e}();Ss._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_LENSFLARESYSTEM);t||(t=new As(e),e._addComponent(t))};var Ps="\n\n\n\n\nfloat bayerDither2(vec2 _P) {\nreturn mod(2.0*_P.y+_P.x+1.0,4.0);\n}\n\n\nfloat bayerDither4(vec2 _P) {\nvec2 P1=mod(_P,2.0);\nvec2 P2=floor(0.5*mod(_P,4.0));\nreturn 4.0*bayerDither2(P1)+bayerDither2(P2);\n}\n\nfloat bayerDither8(vec2 _P) {\nvec2 P1=mod(_P,2.0);\nvec2 P2=floor(0.5*mod(_P,4.0));\nvec2 P4=floor(0.25*mod(_P,8.0));\nreturn 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);\n}\n";ai.a.IncludesShadersStore.bayerDitherFunctions=Ps;var Cs="#if SM_FLOAT == 0\n#include\n#endif\n#if SM_SOFTTRANSPARENTSHADOW == 1\n#include\nuniform float softTransparentShadowSM;\n#endif\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE == 1\nuniform vec3 lightDataSM;\nvarying vec3 vPositionWSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\nvarying float zSM;\n#endif\n";ai.a.IncludesShadersStore.shadowMapFragmentDeclaration=Cs;var Rs=" float depthSM=vDepthMetricSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\n#if SM_USEDISTANCE == 1\ndepthSM=clamp(((length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);\n#else\ndepthSM=clamp(((zSM+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);\n#endif\ngl_FragDepth=depthSM;\n#elif SM_USEDISTANCE == 1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y)+biasAndScaleSM.x;\n#endif\n#if SM_ESM == 1\ndepthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);\n#endif\n#if SM_FLOAT == 1\ngl_FragColor=vec4(depthSM,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depthSM);\n#endif\nreturn;";ai.a.IncludesShadersStore.shadowMapFragment=Rs;var xs="#include\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include\nvoid main(void)\n{\n#include\n#ifdef ALPHATEST\nfloat alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;\nif (alphaFromAlphaTexture<0.4)\ndiscard;\n#endif\n#if SM_SOFTTRANSPARENTSHADOW == 1\n#ifdef ALPHATEST\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;\n#else\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;\n#endif\n#endif\n#include\n}";ai.a.ShadersStore.shadowMapPixelShader=xs;var Os="#if SM_NORMALBIAS == 1\nuniform vec3 lightDataSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE == 1\nvarying vec3 vPositionWSM;\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\nvarying float zSM;\n#endif\n";ai.a.IncludesShadersStore.shadowMapVertexDeclaration=Os;var Ms="\n#if SM_NORMALBIAS == 1\n#if SM_DIRECTIONINLIGHTDATA == 1\nvec3 worldLightDirSM=normalize(-lightDataSM.xyz);\n#else\nvec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;\nvec3 worldLightDirSM=normalize(directionToLightSM);\n#endif\nfloat ndlSM=dot(vNormalW,worldLightDirSM);\nfloat sinNLSM=sqrt(1.0-ndlSM*ndlSM);\nfloat normalBiasSM=biasAndScaleSM.y*sinNLSM;\nworldPos.xyz-=vNormalW*normalBiasSM;\n#endif\n";ai.a.IncludesShadersStore.shadowMapVertexNormalBias=Ms;var Is="#if SM_USEDISTANCE == 1\nvPositionWSM=worldPos.xyz;\n#endif\n#if SM_DEPTHTEXTURE == 1\n\ngl_Position.z+=biasAndScaleSM.x*gl_Position.w;\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\nzSM=gl_Position.z;\ngl_Position.z=0.0;\n#elif SM_USEDISTANCE == 0\n\nvDepthMetricSM=((gl_Position.z+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x;\n#endif\n";ai.a.IncludesShadersStore.shadowMapVertexMetric=Is;var Ds="\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n\n#include\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\n#include\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normWorldSM=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));\nvNormalW=normalize(normWorldSM*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormWorldSM=transposeMat3(inverseMat3(normWorldSM));\n#endif\nvec3 vNormalW=normalize(normWorldSM*normalUpdated);\n#endif\n#endif\n#include\n\ngl_Position=viewProjection*worldPos;\n#include\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}";ai.a.ShadersStore.shadowMapVertexShader=Ds;var Ns="\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}";ai.a.ShadersStore.depthBoxBlurPixelShader=Ns;var Ls="#if SM_SOFTTRANSPARENTSHADOW == 1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\n#endif\n";ai.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow=Ls;var ws=new a.a,Fs=new a.a,Bs=function(){function e(t,i,n){this.onBeforeShadowMapRenderObservable=new o.c,this.onAfterShadowMapRenderObservable=new o.c,this.onBeforeShadowMapRenderMeshObservable=new o.c,this.onAfterShadowMapRenderMeshObservable=new o.c,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.enableSoftTransparentShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=a.e.Zero(),this._viewMatrix=a.a.Zero(),this._projectionMatrix=a.a.Zero(),this._transformMatrix=a.a.Zero(),this._cachedPosition=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=a.a.Identity(),this._mapSize=t,this._light=i,this._scene=i.getScene(),i._shadowGenerator=this,this.id=i.id,e._SceneComponentInitialization(this._scene);var r=this._scene.getEngine().getCaps();n?r.textureFloatRender&&r.textureFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_FLOAT:r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_HALF_FLOAT:this._textureType=g.a.TEXTURETYPE_UNSIGNED_INT:r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_HALF_FLOAT:r.textureFloatRender&&r.textureFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_FLOAT:this._textureType=g.a.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(e.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalBias",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"usePoissonSampling",{get:function(){return this.filter===e.FILTER_POISSONSAMPLING},set:function(t){var i=this._validateFilter(e.FILTER_POISSONSAMPLING);(t||this.filter===e.FILTER_POISSONSAMPLING)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useExponentialShadowMap",{get:function(){return this.filter===e.FILTER_EXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_EXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_BLUREXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_CLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===e.FILTER_PCF},set:function(t){var i=this._validateFilter(e.FILTER_PCF);(t||this.filter===e.FILTER_PCF)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"useContactHardeningShadow",{get:function(){return this.filter===e.FILTER_PCSS},set:function(t){var i=this._validateFilter(e.FILTER_PCSS);(t||this.filter===e.FILTER_PCSS)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"darkness",{get:function(){return this._darkness},set:function(e){this.setDarkness(e)},enumerable:!1,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:!1,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 i;return void 0===t&&(t=!0),this._shadowMap?(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(e),t&&(i=this._shadowMap.renderList).push.apply(i,e.getChildMeshes()),this):this},e.prototype.removeShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var i=this._shadowMap.renderList.indexOf(e);if(-1!==i&&this._shadowMap.renderList.splice(i,1),t)for(var n=0,r=e.getChildren();n1?(this._shadowMap=new Ni(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture(g.a.LESS,!0)):this._shadowMap=new Ni(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=Ke.a.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(Ke.a.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.customIsReadyFunction=function(e,t){return!0};var i=this._scene.getEngine();this._shadowMap.onBeforeRenderObservable.add((function(n){if(t._currentFaceIndex=n,t._filter===e.FILTER_PCF&&i.setColorWrite(!1),t._scene.getSceneUniformBuffer().useUbo){var r=t._scene.getSceneUniformBuffer();r.updateMatrix("viewProjection",t.getTransformMatrix()),r.updateMatrix("view",t._viewMatrix),r.update()}})),this._shadowMap.onAfterUnbindObservable.add((function(){if(t._scene.getSceneUniformBuffer().useUbo){var n=t._scene.getSceneUniformBuffer();n.updateMatrix("viewProjection",t._scene.getTransformMatrix()),n.updateMatrix("view",t._scene.getViewMatrix()),n.update()}if(t._filter===e.FILTER_PCF&&i.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var r=t.getShadowMapForRendering();if(r){var o=r.getInternalTexture();t._scene.postProcessManager.directRender(t._blurPostProcesses,o,!0),i.unBindFramebuffer(o,!0)}}}));var n=new s.b(0,0,0,0),r=new s.b(1,1,1,1);this._shadowMap.onClearObservable.add((function(i){t._filter===e.FILTER_PCF?i.clear(r,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?i.clear(n,!0,!0,!1):i.clear(r,!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=Di.b.MIN_RENDERINGGROUPS;o=a.length)return void(e&&e(i));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(i){t.forceCompilation((function(){i()}),e)}))},e.prototype._isReadyCustomDefines=function(e,t,i){},e.prototype._prepareShadowDefines=function(e,t,i,n){i.push("#define SM_FLOAT "+(this._textureType!==g.a.TEXTURETYPE_UNSIGNED_INT?"1":"0")),i.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),i.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));var r=e.getMesh();return i.push("#define SM_NORMALBIAS "+(this.normalBias&&r.isVerticesDataPresent(Qi.b.NormalKind)?"1":"0")),i.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===kr.a.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),i.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),i.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&n?"1":"0")),this._isReadyCustomDefines(i,e,t),i},e.prototype.isReady=function(e,t,i){var n=e.getMaterial(),r=null==n?void 0:n.shadowDepthWrapper,o=[];if(this._prepareShadowDefines(e,t,o,i),r){if(!r.isReadyForSubMesh(e,o,this,t))return!1}else{var a=[Qi.b.PositionKind],s=e.getMesh();if(this.normalBias&&s.isVerticesDataPresent(Qi.b.NormalKind)&&(a.push(Qi.b.NormalKind),o.push("#define NORMAL"),s.nonUniformScaling&&o.push("#define NONUNIFORMSCALING")),n&&n.needAlphaTesting()){var c=n.getAlphaTestTexture();if(c){if(!c.isReady())return!1;o.push("#define ALPHATEST"),s.isVerticesDataPresent(Qi.b.UVKind)&&(a.push(Qi.b.UVKind),o.push("#define UV1")),s.isVerticesDataPresent(Qi.b.UV2Kind)&&1===c.coordinatesIndex&&(a.push(Qi.b.UV2Kind),o.push("#define UV2"))}}var l=new po.a;if(s.useBones&&s.computeBonesUsingShaders&&s.skeleton){a.push(Qi.b.MatricesIndicesKind),a.push(Qi.b.MatricesWeightsKind),s.numBoneInfluencers>4&&(a.push(Qi.b.MatricesIndicesExtraKind),a.push(Qi.b.MatricesWeightsExtraKind));var u=s.skeleton;o.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),s.numBoneInfluencers>0&&l.addCPUSkinningFallback(0,s),u.isUsingTextureForMatrices?o.push("#define BONETEXTURE"):o.push("#define BonesPerMesh "+(u.bones.length+1))}else o.push("#define NUM_BONE_INFLUENCERS 0");var h=s.morphTargetManager,d=0;h&&h.numInfluencers>0&&(o.push("#define MORPHTARGETS"),d=h.numInfluencers,o.push("#define NUM_MORPH_INFLUENCERS "+d),ro.a.PrepareAttributesForMorphTargetsInfluencers(a,s,d));var f=this._scene;if(f.clipPlane&&o.push("#define CLIPPLANE"),f.clipPlane2&&o.push("#define CLIPPLANE2"),f.clipPlane3&&o.push("#define CLIPPLANE3"),f.clipPlane4&&o.push("#define CLIPPLANE4"),f.clipPlane5&&o.push("#define CLIPPLANE5"),f.clipPlane6&&o.push("#define CLIPPLANE6"),t&&(o.push("#define INSTANCES"),ro.a.PushAttributesForInstances(a),e.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(var p=0,_=this.customShaderOptions.defines;p<_.length;p++){var m=_[p];-1===o.indexOf(m)&&o.push(m)}var g=o.join("\n");if(this._cachedDefines!==g){this._cachedDefines=g;var v="shadowMap",b=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","boneTextureWidth","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","softTransparentShadowSM"],y=["diffuseSampler","boneSampler"];if(this.customShaderOptions){if(v=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(var T=0,E=this.customShaderOptions.attributes;T4&&(r.push(Qi.b.MatricesIndicesExtraKind),r.push(Qi.b.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),n.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0");var a=o.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,n.push("#define MORPHTARGETS"),n.push("#define NUM_MORPH_INFLUENCERS "+s),ro.a.PrepareAttributesForMorphTargetsInfluencers(r,o,s)),t&&(n.push("#define INSTANCES"),ro.a.PushAttributesForInstances(r),e.getRenderingMesh().hasThinInstances&&n.push("#define THIN_INSTANCES")),this._storeNonLinearDepth&&n.push("#define NONLINEARDEPTH"),this.isPacked&&n.push("#define PACKED");var c=n.join("\n");return this._cachedDefines!==c&&(this._cachedDefines=c,this._effect=this._scene.getEngine().createEffect("depth",r,["world","mBones","viewProjection","diffuseMatrix","depthValues","morphTargetInfluences"],["diffuseSampler"],c,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 Re.a.WarnImport("DepthRendererSceneComponent")},e}(),zs="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";ai.a.ShadersStore.minmaxReduxPixelShader=zs;var Gs=function(){function e(e){this.onAfterReductionPerformed=new o.c,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new Ii.a(e.getScene())}return Object.defineProperty(e.prototype,"sourceTexture",{get:function(){return this._sourceTexture},enumerable:!1,configurable:!0}),e.prototype.setSourceTexture=function(e,t,i,n){var r=this;if(void 0===i&&(i=g.a.TEXTURETYPE_HALF_FLOAT),void 0===n&&(n=!0),e!==this._sourceTexture){this.dispose(!1),this._sourceTexture=e,this._reductionSteps=[],this._forceFullscreenViewport=n;var o=this._camera.getScene(),a=new li("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,g.a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define INITIAL"+(t?"\n#define DEPTH_REDUX":""),i,void 0,void 0,void 0,g.a.TEXTUREFORMAT_RG);a.autoClear=!1,a.forceFullscreenViewport=n;var s=this._sourceTexture.getRenderWidth(),c=this._sourceTexture.getRenderHeight();a.onApply=function(e,t){return function(i){i.setTexture("sourceTexture",r._sourceTexture),i.setFloatArray2("texSize",new Float32Array([e,t]))}}(s,c),this._reductionSteps.push(a);for(var l=1;s>1||c>1;){s=Math.max(Math.round(s/2),1),c=Math.max(Math.round(c/2),1);var u=new li("Reduction phase "+l,"minmaxRedux",["texSize"],null,{width:s,height:c},null,g.a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define "+(1==s&&1==c?"LAST":1==s||1==c?"ONEBEFORELAST":"MAIN"),i,void 0,void 0,void 0,g.a.TEXTUREFORMAT_RG);if(u.autoClear=!1,u.forceFullscreenViewport=n,u.onApply=function(e,t){return function(i){1==e||1==t?i.setIntArray2("texSize",new Int32Array([e,t])):i.setFloatArray2("texSize",new Float32Array([e,t]))}}(s,c),this._reductionSteps.push(u),l++,1==s&&1==c){u.onAfterRenderObservable.add(function(e,t,i){var n=new Float32Array(4*e*t),a={min:0,max:0};return function(){o.getEngine()._readTexturePixels(i.inputTexture,e,t,-1,0,n),a.min=n[0],a.max=n[1],r.onAfterReductionPerformed.notifyObservers(a)}}(s,c,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"activated",{get:function(){return this._activated},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxDistance",{get:function(){return this._maxDistance},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return t.CLASSNAME},t.prototype.getCascadeMinExtents=function(e){return e>=0&&e=0&&ethis._scene.activeCamera.maxZ||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthClamp",{get:function(){return this._depthClamp},set:function(e){this._depthClamp=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cascadeBlendPercentage",{get:function(){return this._cascadeBlendPercentage},set:function(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lambda",{get:function(){return this._lambda},set:function(e){var t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)},enumerable:!1,configurable:!0}),t.prototype.getCascadeViewMatrix=function(e){return e>=0&&e=0&&e=0&&e=n&&(i=0,n=1),i==t._minDistance&&n==t._maxDistance||t.setMinMaxDistance(i,n)})),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoCalcDepthBoundsRefreshRate",{get:function(){var e,t,i;return null!==(i=null===(t=null===(e=this._depthReducer)||void 0===e?void 0:e.depthRenderer)||void 0===t?void 0:t.getDepthMap().refreshRate)&&void 0!==i?i:-1},set:function(e){var t;(null===(t=this._depthReducer)||void 0===t?void 0:t.depthRenderer)&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)},enumerable:!1,configurable:!0}),t.prototype.splitFrustum=function(){this._breaksAreDirty=!0},t.prototype._splitFrustum=function(){var e=this._scene.activeCamera;if(e){for(var t=e.minZ,i=e.maxZ,n=i-t,r=this._minDistance,o=t+r*n,a=t+(this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(i-t),this._maxDistance):this._maxDistance)*n,s=a-o,c=a/o,l=0;lMath.PI;)r-=2*Math.PI;var a=r/Math.PI,s=o/Math.PI;a=.5*a+.5;var c=Math.round(a*i);c<0?c=0:c>=i&&(c=i-1);var l=Math.round(s*n);l<0?l=0:l>=n&&(l=n-1);var u=n-l-1;return{r:t[u*i*3+3*c+0],g:t[u*i*3+3*c+1],b:t[u*i*3+3*c+2]}},e.FACE_LEFT=[new a.e(-1,-1,-1),new a.e(1,-1,-1),new a.e(-1,1,-1),new a.e(1,1,-1)],e.FACE_RIGHT=[new a.e(1,-1,1),new a.e(-1,-1,1),new a.e(1,1,1),new a.e(-1,1,1)],e.FACE_FRONT=[new a.e(1,-1,-1),new a.e(1,-1,1),new a.e(1,1,-1),new a.e(1,1,1)],e.FACE_BACK=[new a.e(-1,-1,1),new a.e(-1,-1,-1),new a.e(-1,1,1),new a.e(-1,1,-1)],e.FACE_DOWN=[new a.e(1,1,-1),new a.e(1,1,1),new a.e(-1,1,-1),new a.e(-1,1,1)],e.FACE_UP=[new a.e(-1,-1,-1),new a.e(-1,-1,1),new a.e(1,-1,-1),new a.e(1,-1,1)],e}(),nc=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,i,n,r,o){r>0?(r=this.Ldexp(1,r-136),e[o+0]=t*r,e[o+1]=i*r,e[o+2]=n*r):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},e.readStringLine=function(e,t){for(var i="",n="",r=t;r32767)throw"HDR Bad header format, unsupported size";return{height:t,width:i,dataPosition:a+=n.length+1}},e.GetCubeMapTextureData=function(e,t){var i=new Uint8Array(e),n=this.RGBE_ReadHeader(i),r=this.RGBE_ReadPixels(i,n);return ic.ConvertPanoramaToCubemap(r,n.width,n.height,t)},e.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},e.RGBE_ReadPixels_RLE=function(e,t){for(var i,n,r,o,a,s=t.height,c=t.width,l=t.dataPosition,u=0,h=0,d=0,f=new ArrayBuffer(4*c),p=new Uint8Array(f),_=new ArrayBuffer(t.width*t.height*4*3),m=new Float32Array(_);s>0;){if(i=e[l++],n=e[l++],r=e[l++],o=e[l++],2!=i||2!=n||128&r||t.width<8||t.width>32767)return this.RGBE_ReadPixels_NOT_RLE(e,t);if((r<<8|o)!=c)throw"HDR Bad header format, wrong scan line width";for(u=0,d=0;d<4;d++)for(h=(d+1)*c;u128){if(0==(a=i-128)||a>h-u)throw"HDR Bad Format, bad scanline data (run)";for(;a-- >0;)p[u++]=n}else{if(0==(a=i)||a>h-u)throw"HDR Bad Format, bad scanline data (non-run)";if(p[u++]=n,--a>0)for(var g=0;g0;){for(a=0;a=2&&this._prefilterOnLoad){var n=this._onLoad,r=new cc(i);this._onLoad=function(){r.prefilter(e,n)}}this._texture=i.createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,g.a.TEXTUREFORMAT_RGB,i.getCaps().textureFloat?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,(function(n){e.lodGenerationOffset=0,e.lodGenerationScale=.8;var r=nc.GetCubeMapTextureData(n,e._size);if(e._generateHarmonics){var o=$n.ConvertCubeMapToSphericalPolynomial(r);e.sphericalPolynomial=o}for(var a=[],s=null,c=0;c<6;c++){if(!i.getCaps().textureFloat){var l=new ArrayBuffer(e._size*e._size*3);s=new Uint8Array(l)}var u=r[t._facesMapping[c]];if(e.gammaSpace||s)for(var h=0;h255){var m=255/_;d*=m,f*=m,p*=m}s[3*h+0]=d,s[3*h+1]=f,s[3*h+2]=p}s?a.push(s):a.push(u)}return a}),null,this._onLoad,this._onError)},t.prototype.clone=function(){var e=new t(this.url,this.getScene()||this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e},t.prototype.delayLoad=function(){this.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=g.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var t,i=this;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&(null===(t=this.getScene())||void 0===t||t.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(e){return-1!==e.getActiveTextures().indexOf(i)})))},t.Parse=function(e,i,n){var r=null;return e.name&&!e.isRenderTarget&&((r=new t(n+e.name,i,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name=e.name,r.hasAlpha=e.hasAlpha,r.level=e.level,r.coordinatesMode=e.coordinatesMode,r.isBlocking=e.isBlocking),r&&(e.boundingBoxPosition&&(r.boundingBoxPosition=a.e.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(r.boundingBoxSize=a.e.FromArray(e.boundingBoxSize)),e.rotationY&&(r.rotationY=e.rotationY)),r},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}(Zn.a);c.a.RegisteredTypes["BABYLON.HDRCubeTexture"]=lc;var uc=function(){function e(e,t,i){void 0===t&&(t=0),void 0===i&&(i=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 o.c,this._onDataLayoutChanged=new o.c,this._animationPropertiesOverride=null,this._scene=i||x.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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPositions",{get:function(){return!!this._positions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNormals",{get:function(){return!!this._normals},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTangents",{get:function(){return!!this._tangents},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasUVs",{get:function(){return!!this._uvs},enumerable:!1,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,i=w.a.Clone((function(){return new e(t.name,t.influence,t._scene)}),this);return i._positions=this._positions,i._normals=this._normals,i._tangents=this._tangents,i._uvs=this._uvs,i},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())),w.a.AppendSerializedAnimations(this,e),e},e.prototype.getClassName=function(){return"MorphTarget"},e.Parse=function(t){var i=new e(t.name,t.influence);if(i.setPositions(t.positions),null!=t.id&&(i.id=t.id),t.normals&&i.setNormals(t.normals),t.tangents&&i.setTangents(t.tangents),t.uvs&&i.setUVs(t.uvs),t.animations)for(var n=0;n=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),i=0,n=this._targets;i-1&&(this._impostors.splice(t,1).length&&this.getPhysicsPlugin().removePhysicsBody(e))},e.prototype.addJoint=function(e,t,i){var n={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(n),this._physicsPlugin.generateJoint(n)},e.prototype.removeJoint=function(e,t,i){var n=this._joints.filter((function(n){return n.connectedImpostor===t&&n.joint===i&&n.mainImpostor===e}));n.length&&this._physicsPlugin.removeJoint(n[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,i){var n=new this.BJSCANNON.Vec3(i.x,i.y,i.z),r=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(r,n)},e.prototype.applyForce=function(e,t,i){var n=new this.BJSCANNON.Vec3(i.x,i.y,i.z),r=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(r,n)},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),i=e.physicsBody;i&&this.removePhysicsBody(e);var n=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),r={mass:e.getParam("mass"),material:n},o=e.getParam("nativeOptions");for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);e.physicsBody=new this.BJSCANNON.Body(r),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),i&&["force","torque","velocity","angularVelocity"].forEach((function(t){var n=i[t];e.physicsBody[t].set(n.x,n.y,n.z)})),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)}},e.prototype._processChildMeshes=function(e){var t=this,i=e.object.getChildMeshes?e.object.getChildMeshes(!0):[],n=e.object.rotationQuaternion;if(i.length){var r=function(i){if(n&&i.rotationQuaternion){var o=i.getPhysicsImpostor();if(o)if(o.parent!==e){var a=i.getAbsolutePosition().subtract(i.parent.getAbsolutePosition()),s=i.rotationQuaternion;o.physicsBody&&(t.removePhysicsBody(o),o.physicsBody=null),o.parent=e,o.resetUpdateFlags(),e.physicsBody.addShape(t._createShape(o),new t.BJSCANNON.Vec3(a.x,a.y,a.z),new t.BJSCANNON.Quaternion(s.x,s.y,s.z,s.w)),e.physicsBody.mass+=o.getParam("mass")}n.multiplyInPlace(i.rotationQuaternion),i.getChildMeshes(!0).filter((function(e){return!!e.physicsImpostor})).forEach(r)}};i.filter((function(e){return!!e.physicsImpostor})).forEach(r)}},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,i=e.connectedImpostor.physicsBody;if(t&&i){var n,r=e.joint.jointData,o={pivotA:r.mainPivot?(new this.BJSCANNON.Vec3).set(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z):null,pivotB:r.connectedPivot?(new this.BJSCANNON.Vec3).set(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z):null,axisA:r.mainAxis?(new this.BJSCANNON.Vec3).set(r.mainAxis.x,r.mainAxis.y,r.mainAxis.z):null,axisB:r.connectedAxis?(new this.BJSCANNON.Vec3).set(r.connectedAxis.x,r.connectedAxis.y,r.connectedAxis.z):null,maxForce:r.nativeParams.maxForce,collideConnected:!!r.collision};switch(e.joint.type){case fc.e.HingeJoint:case fc.e.Hinge2Joint:n=new this.BJSCANNON.HingeConstraint(t,i,o);break;case fc.e.DistanceJoint:n=new this.BJSCANNON.DistanceConstraint(t,i,r.maxDistance||2);break;case fc.e.SpringJoint:var a=r;n=new this.BJSCANNON.Spring(t,i,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:o.pivotA,localAnchorB:o.pivotB});break;case fc.e.LockJoint:n=new this.BJSCANNON.LockConstraint(t,i,o);break;case fc.e.PointToPointJoint:case fc.e.BallAndSocketJoint:default:n=new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,i,o.pivotB,o.maxForce)}n.collideConnected=!!r.collision,e.joint.physicsJoint=n,e.joint.type!==fc.e.SpringJoint?this.world.addConstraint(n):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){n.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},e.prototype.removeJoint=function(e){e.joint.type!==fc.e.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},e.prototype._addMaterial=function(e,t,i){var n,r;for(n=0;n1e3*i));s++);this.time+=n;for(var c=this.time%i/i,l=e,u=this.bodies,h=0;h!==u.length;h++){var d=u[h];d.type!==t.Body.STATIC&&d.sleepState!==t.Body.SLEEPING?(d.position.vsub(d.previousPosition,l),l.scale(c,l),d.position.vadd(l,d.interpolatedPosition)):(d.interpolatedPosition.set(d.position.x,d.position.y,d.position.z),d.interpolatedQuaternion.set(d.quaternion.x,d.quaternion.y,d.quaternion.z,d.quaternion.w))}}}},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}();pc.DefaultPluginFactory=function(){return new mc};var gc=function(){function e(e,t,i){void 0===e&&(e=!0),void 0===i&&(i=OIMO),this._useDeltaForWorldStep=e,this.name="OimoJSPlugin",this._fixedTimeStep=1/60,this._tmpImpostorsArray=[],this._tmpPositionVector=a.e.Zero(),this.BJSOIMO=i,this.world=new this.BJSOIMO.World({iterations:t}),this.world.clear(),this._raycastResult=new _c}return e.prototype.setGravity=function(e){this.world.gravity.set(e.x,e.y,e.z)},e.prototype.setTimeStep=function(e){this.world.timeStep=e},e.prototype.getTimeStep=function(){return this.world.timeStep},e.prototype.executeStep=function(e,t){var i=this;t.forEach((function(e){e.beforeStep()})),this.world.timeStep=this._useDeltaForWorldStep?e:this._fixedTimeStep,this.world.step(),t.forEach((function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e}));for(var n=this.world.contacts;null!==n;)if(!n.touching||n.body1.sleeping||n.body2.sleeping){var r=this._tmpImpostorsArray[+n.body1.name],o=this._tmpImpostorsArray[+n.body2.name];r&&o?(r.onCollide({body:o.physicsBody,point:null}),o.onCollide({body:r.physicsBody,point:null}),n=n.next):n=n.next}else n=n.next},e.prototype.applyImpulse=function(e,t,i){var n=e.physicsBody.mass;e.physicsBody.applyImpulse(i.scale(this.world.invScale),t.scale(this.world.invScale*n))},e.prototype.applyForce=function(e,t,i){m.a.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(e,t,i)},e.prototype.generatePhysicsBody=function(e){var t=this;if(e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var i={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},n=[e];(s=e.object).getChildMeshes&&s.getChildMeshes().forEach((function(e){e.physicsImpostor&&n.push(e.physicsImpostor)}));var r=function(e){return Math.max(e,pc.Epsilon)},o=new a.b;n.forEach((function(n){if(n.object.rotationQuaternion){var a=n.object.rotationQuaternion;o.copyFrom(a),n.object.rotationQuaternion.set(0,0,0,1),n.object.computeWorldMatrix(!0);var s=o.toEulerAngles(),c=n.getObjectExtendSize();if(n===e){var l=e.getObjectCenter();e.object.getAbsolutePivotPoint().subtractToRef(l,t._tmpPositionVector),t._tmpPositionVector.divideInPlace(e.object.scaling),i.pos.push(l.x),i.pos.push(l.y),i.pos.push(l.z),i.posShape.push(0,0,0),i.rotShape.push(0,0,0)}else{var u=n.object.position.clone();i.posShape.push(u.x),i.posShape.push(u.y),i.posShape.push(u.z),i.rotShape.push(57.29577951308232*s.x,57.29577951308232*s.y,57.29577951308232*s.z)}switch(n.object.rotationQuaternion.copyFrom(o),n.type){case dc.a.ParticleImpostor:m.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case dc.a.SphereImpostor:var h=c.x,d=c.y,f=c.z,p=Math.max(r(h),r(d),r(f))/2;i.type.push("sphere"),i.size.push(p),i.size.push(p),i.size.push(p);break;case dc.a.CylinderImpostor:var _=r(c.x)/2,g=r(c.y);i.type.push("cylinder"),i.size.push(_),i.size.push(g),i.size.push(g);break;case dc.a.PlaneImpostor:case dc.a.BoxImpostor:default:_=r(c.x),g=r(c.y);var v=r(c.z);i.type.push("box"),i.size.push(_),i.size.push(g),i.size.push(v)}n.object.rotationQuaternion=a}})),e.physicsBody=this.world.add(i),e.physicsBody.resetQuaternion(o),e.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);var s;e.setDeltaPosition(this._tmpPositionVector)}},e.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var n,r=e.joint.jointData,o=r.nativeParams||{},a={body1:t,body2:i,axe1:o.axe1||(r.mainAxis?r.mainAxis.asArray():null),axe2:o.axe2||(r.connectedAxis?r.connectedAxis.asArray():null),pos1:o.pos1||(r.mainPivot?r.mainPivot.asArray():null),pos2:o.pos2||(r.connectedPivot?r.connectedPivot.asArray():null),min:o.min,max:o.max,collision:o.collision||r.collision,spring:o.spring,world:this.world};switch(e.joint.type){case fc.e.BallAndSocketJoint:n="jointBall";break;case fc.e.SpringJoint:m.a.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var s=r;a.min=s.length||a.min,a.max=Math.max(a.min,a.max);case fc.e.DistanceJoint:n="jointDistance",a.max=r.maxDistance;break;case fc.e.PrismaticJoint:n="jointPrisme";break;case fc.e.SliderJoint:n="jointSlide";break;case fc.e.WheelJoint:n="jointWheel";break;case fc.e.HingeJoint:default:n="jointHinge"}a.type=n,e.joint.physicsJoint=this.world.add(a)}},e.prototype.removeJoint=function(e){try{this.world.removeJoint(e.joint.physicsJoint)}catch(e){m.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.set(t.position.x,t.position.y,t.position.z)}else{var i=e.physicsBody.getPosition();e.object.position.set(i.x,i.y,i.z)}if(e.object.rotationQuaternion){var n=e.physicsBody.getQuaternion();e.object.rotationQuaternion.set(n.x,n.y,n.z,n.w)}}},e.prototype.setPhysicsBodyTransformation=function(e,t,i){var n=e.physicsBody;e.physicsBody.shapes.next||(n.position.set(t.x,t.y,t.z),n.orientation.set(i.x,i.y,i.z,i.w),n.syncShapes(),n.awake())},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.set(t.x,t.y,t.z)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.set(t.x,t.y,t.z)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.linearVelocity;return t?new a.e(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new a.e(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){var i=0===t;e.physicsBody.shapes.density=i?1:t,e.physicsBody.setupMass(i?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,i){e.physicsJoint.limitMotor.upperLimit=t,void 0!==i&&(e.physicsJoint.limitMotor.lowerLimit=i)},e.prototype.setMotor=function(e,t,i,n){void 0!==i?m.a.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter"):i=1e6,t*=-1;var r=n?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.setMotor(t,i)},e.prototype.setLimit=function(e,t,i,n){var r=n?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.setLimit(t,void 0===i?-t:i)},e.prototype.syncMeshWithImpostor=function(e,t){var i=t.physicsBody;e.position.x=i.position.x,e.position.y=i.position.y,e.position.z=i.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=i.orientation.x,e.rotationQuaternion.y=i.orientation.y,e.rotationQuaternion.z=i.orientation.z,e.rotationQuaternion.w=i.orientation.s)},e.prototype.getRadius=function(e){return e.physicsBody.shapes.radius},e.prototype.getBoxSizeToRef=function(e,t){var i=e.physicsBody.shapes;t.x=2*i.halfWidth,t.y=2*i.halfHeight,t.z=2*i.halfDepth},e.prototype.dispose=function(){this.world.clear()},e.prototype.raycast=function(e,t){return m.a.Warn("raycast is not currently supported by the Oimo physics plugin"),this._raycastResult.reset(e,t),this._raycastResult},e}(),vc=i(97),bc=function(){function e(e,t,i){var n=this;void 0===e&&(e=!0),void 0===t&&(t=Ammo),void 0===i&&(i=null),this._useDeltaForWorldStep=e,this.bjsAMMO={},this.name="AmmoJSPlugin",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new a.b,this._tmpContactCallbackResult=!1,this._tmpContactPoint=new a.e,this._tmpMatrix=new a.a,"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=i||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(e,t,i,r){var o=(e=n.bjsAMMO.wrapPointer(e,Ammo.btManifoldPoint)).getPositionWorldOnA();n._tmpContactPoint.x=o.x(),n._tmpContactPoint.y=o.y(),n._tmpContactPoint.z=o.z(),n._tmpContactCallbackResult=!0},this._raycastResult=new _c,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)):m.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,i){if(void 0===e&&(e=1/60),void 0===t&&(t=10),void 0===i&&(i=1/60),0==t)this.world.stepSimulation(e,0);else for(;t>0&&e>0;)e-i0&&this._isImpostorInContact(s))for(var c=0,l=s._onPhysicsCollideCallbacks;c3?3:s;var c=(new this.bjsAMMO.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,i-1,s);return c.get_m_cfg().set_collisions(17),c},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,i){var n=this,r=0;if(i&&i.getIndices&&i.getWorldMatrix&&i.getChildMeshes){var o=i.getIndices();o||(o=[]);var s=i.getVerticesData(Qi.b.PositionKind);s||(s=[]),i.computeWorldMatrix(!1);for(var c=o.length/3,l=0;l0){if(e.type!=dc.a.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),n.addChildShape(this._tmpAmmoTransform,l))}return n}this.bjsAMMO.destroy(n),n=null}switch(e.type){case dc.a.SphereImpostor:if(L.a.WithinEpsilon(o.x,o.y,1e-4)&&L.a.WithinEpsilon(o.x,o.z,1e-4))n=new this.bjsAMMO.btSphereShape(o.x/2);else{var u=[new this.bjsAMMO.btVector3(0,0,0)];(n=new this.bjsAMMO.btMultiSphereShape(u,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x/2,o.y/2,o.z/2))}break;case dc.a.CapsuleImpostor:n=new this.bjsAMMO.btCapsuleShape(o.x/2,o.y/2);break;case dc.a.CylinderImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),n=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case dc.a.PlaneImpostor:case dc.a.BoxImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),n=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case dc.a.MeshImpostor:if(0==e.getParam("mass")){var h=new this.bjsAMMO.btTriangleMesh;e._pluginData.toDispose.push(h);var d=this._addMeshVerts(h,r,r);n=0==d?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(h);break}case dc.a.ConvexHullImpostor:var f=new this.bjsAMMO.btConvexHullShape;0==(d=this._addHullVerts(f,r,r))?(e._pluginData.toDispose.push(f),n=new this.bjsAMMO.btCompoundShape):n=f;break;case dc.a.NoImpostor:n=new this.bjsAMMO.btSphereShape(o.x/2);break;case dc.a.CustomImpostor:n=this._createCustom(e);break;case dc.a.SoftbodyImpostor:n=this._createSoftbody(e);break;case dc.a.ClothImpostor:n=this._createCloth(e);break;case dc.a.RopeImpostor:n=this._createRope(e);break;default:m.a.Warn("The impostor type is not currently supported by the ammo plugin.")}return n},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,i){var n=e.physicsBody.getWorldTransform();if(Math.abs(n.getOrigin().x()-t.x)>Nt.a||Math.abs(n.getOrigin().y()-t.y)>Nt.a||Math.abs(n.getOrigin().z()-t.z)>Nt.a||Math.abs(n.getRotation().x()-i.x)>Nt.a||Math.abs(n.getRotation().y()-i.y)>Nt.a||Math.abs(n.getRotation().z()-i.z)>Nt.a||Math.abs(n.getRotation().w()-i.w)>Nt.a)if(this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),n.setOrigin(this._tmpAmmoVectorA),this._tmpAmmoQuaternion.setValue(i.x,i.y,i.z,i.w),n.setRotation(this._tmpAmmoQuaternion),e.physicsBody.setWorldTransform(n),0==e.mass){var r=e.physicsBody.getMotionState();r&&r.setWorldTransform(n)}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 i=new a.e(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),i},e.prototype.getAngularVelocity=function(e){if(e.soft)var t=e.physicsBody.angularVelocity();else t=e.physicsBody.getAngularVelocity();if(!t)return null;var i=new a.e(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),i},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:(m.a.Warn("Pressure is not a property of a rigid body"),0)},e.prototype.setBodyPressure=function(e,t){e.soft?e.type===dc.a.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):m.a.Warn("Pressure can only be applied to a softbody")},e.prototype.getBodyStiffness=function(e){return e.soft?e._pluginData.stiffness||0:(m.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):m.a.Warn("Stiffness cannot be applied to a rigid body")},e.prototype.getBodyVelocityIterations=function(e){return e.soft?e._pluginData.velocityIterations||0:(m.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):m.a.Warn("Velocity iterations cannot be applied to a rigid body")},e.prototype.getBodyPositionIterations=function(e){return e.soft?e._pluginData.positionIterations||0:(m.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):m.a.Warn("Position iterations cannot be applied to a rigid body")},e.prototype.appendAnchor=function(e,t,i,n,r,o){void 0===r&&(r=1),void 0===o&&(o=!1);var a=e.segments,s=Math.round((a-1)*i)+a*(a-1-Math.round((a-1)*n));e.physicsBody.appendAnchor(s,t.physicsBody,o,r)},e.prototype.appendHook=function(e,t,i,n,r){void 0===n&&(n=1),void 0===r&&(r=!1);var o=Math.round(e.segments*i);e.physicsBody.appendAnchor(o,t.physicsBody,r,n)},e.prototype.sleepBody=function(e){m.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,i){m.a.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")},e.prototype.setMotor=function(e,t,i,n){e.physicsJoint.enableAngularMotor(!0,t,i)},e.prototype.setLimit=function(e,t,i){m.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 i=e.getObjectExtendSize();t.x=i.x,t.y=i.y,t.z=i.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 i=new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);return this.world.rayTest(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB,i),this._raycastResult.reset(e,t),i.hasHit()&&(this._raycastResult.setHitData({x:i.get_m_hitNormalWorld().x(),y:i.get_m_hitNormalWorld().y(),z:i.get_m_hitNormalWorld().z()},{x:i.get_m_hitPointWorld().x(),y:i.get_m_hitPointWorld().y(),z:i.get_m_hitPointWorld().z()}),this._raycastResult.calculateHitDistance()),this.bjsAMMO.destroy(i),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}();n.a.prototype.removeReflectionProbe=function(e){if(!this.reflectionProbes)return-1;var t=this.reflectionProbes.indexOf(e);return-1!==t&&this.reflectionProbes.splice(t,1),t},n.a.prototype.addReflectionProbe=function(e){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(e)};var yc=function(){function e(e,t,i,n,r){var o=this;void 0===n&&(n=!0),void 0===r&&(r=!1),this.name=e,this._viewMatrix=a.a.Identity(),this._target=a.e.Zero(),this._add=a.e.Zero(),this._invertYAxis=!1,this.position=a.e.Zero(),this._scene=i,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this);var s=g.a.TEXTURETYPE_UNSIGNED_BYTE;if(r){var c=this._scene.getEngine().getCaps();c.textureHalfFloatRender?s=g.a.TEXTURETYPE_HALF_FLOAT:c.textureFloatRender&&(s=g.a.TEXTURETYPE_FLOAT)}this._renderTargetTexture=new Ni(e,t,i,n,!0,s,!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),a.a.LookAtLHToRef(o.position,o._target,a.e.Up(),o._viewMatrix),i.activeCamera&&(o._projectionMatrix=a.a.PerspectiveFovLH(Math.PI/2,1,i.activeCamera.minZ,i.activeCamera.maxZ),i.setTransformMatrix(o._viewMatrix,o._projectionMatrix)),i._forcedViewPosition=o.position})),this._renderTargetTexture.onAfterUnbindObservable.add((function(){i._forcedViewPosition=null,i.updateTransformMatrix(!0)}))}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._renderTargetTexture.samples},set:function(e){this._renderTargetTexture.samples=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},enumerable:!1,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=w.a.Serialize(this,this._renderTargetTexture.serialize());return e.isReflectionProbe=!0,e},e.Parse=function(t,i,n){var r=null;if(i.reflectionProbes)for(var o=0;o0){var n=t._waitingData.lods.ids,r=i.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=n.length){var a=o.length>n.length?o[o.length-1]:0;i.setEnabled(!1);for(var s=0;s0&&i.addLODLevel(a,null),!0===r&&i.setEnabled(!0)}else Ce.b.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},Rc=function(e,t,i,r,o){void 0===o&&(o=!1);var a=new Ee(e),s="importScene has failed JSON parse";try{var l=JSON.parse(t);s="";var u,h,d=pr.loggingLevel===pr.DETAILED_LOGGING;if(void 0!==l.environmentTexture&&null!==l.environmentTexture){var f=void 0===l.isPBR||l.isPBR;if(l.environmentTextureType&&"BABYLON.HDRCubeTexture"===l.environmentTextureType){var p=l.environmentTextureSize?l.environmentTextureSize:128,_=new lc((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e,p,!0,!f);l.environmentTextureRotationY&&(_.rotationY=l.environmentTextureRotationY),e.environmentTexture=_}else if(io.a.EndsWith(l.environmentTexture,".env")){var g=new no((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e);l.environmentTextureRotationY&&(g.rotationY=l.environmentTextureRotationY),e.environmentTexture=g}else{var v=no.CreateFromPrefilteredData((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e);l.environmentTextureRotationY&&(v.rotationY=l.environmentTextureRotationY),e.environmentTexture=v}if(!0===l.createDefaultSkybox){var b=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,y=l.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,f,b,y)}a.environmentTexture=e.environmentTexture}if(void 0!==l.environmentIntensity&&null!==l.environmentIntensity&&(e.environmentIntensity=l.environmentIntensity),void 0!==l.lights&&null!==l.lights)for(u=0,h=l.lights.length;u0){for(var ae=0;ae0){for(var ce=0;ce-1&&void 0!==u.skeletons&&null!==u.skeletons)if(!1===g.indexOf(b.skeletonId)>-1)for(var M=0,I=u.skeletons.length;M1,this.wrapU=g.a.TEXTURE_CLAMP_ADDRESSMODE,this.wrapV=g.a.TEXTURE_CLAMP_ADDRESSMODE,this.wrapR=g.a.TEXTURE_CLAMP_ADDRESSMODE,this.anisotropicFilteringLevel=1;var r=function(r){if("string"==typeof r){for(var o,a=null,s=null,c=r.split("\n"),l=0,u=0,h=0,d=0,f=0,p=0;p0&&(p+1)%4==0)a[p]=255;else{var T=s[p];a[p]=T/f*255}e.is3D?(e.updateSize(l,l,l),n.updateRawTexture3D(e,a,g.a.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(l*l,l),n.updateRawTexture(e,a,g.a.TEXTUREFORMAT_RGBA,!1)),e.isReady=!0,i._triggerOnLoad()}},o=this.getScene();return o?o._loadFile(this.url,r):n._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()||this._getEngine());return e.level=this.level,e},t.prototype.delayLoad=function(){this.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=g.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},t.Parse=function(e,i){var n=null;return e.name&&!e.isRenderTarget&&((n=new t(e.name,i)).name=e.name,n.level=e.level),n},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}(Zn.a);c.a.RegisteredTypes["BABYLON.ColorGradingTexture"]=wc;var Fc=function(e){function t(t,i,n,r,o,a,s){void 0===r&&(r=!1),void 0===o&&(o=!0),void 0===a&&(a=null),void 0===s&&(s=null);var c=e.call(this,i)||this;if(c._onLoad=null,c._onError=null,!t)throw new Error("Image url is not set");return c._coordinatesMode=Ke.a.CUBIC_MODE,c.name=t,c.url=t,c._size=n,c._noMipmap=r,c.gammaSpace=o,c._onLoad=a,c._onError=s,c.hasAlpha=!1,c.isCube=!0,c._texture=c._getFromCache(t,c._noMipmap),c._texture?a&&(c._texture.isReady?Ce.b.SetImmediate((function(){return a()})):c._texture.onLoadedObservable.add(a)):i.useDelayedTextureLoading?c.delayLoadState=g.a.DELAYLOADSTATE_NOTLOADED:c.loadImage(c.loadTexture.bind(c),c._onError),c}return Object(h.d)(t,e),t.prototype.loadImage=function(e,t){var i=this,n=document.createElement("canvas"),r=new Image;r.addEventListener("load",(function(){i._width=r.width,i._height=r.height,n.width=i._width,n.height=i._height;var t=n.getContext("2d");t.drawImage(r,0,0);var o=t.getImageData(0,0,r.width,r.height);i._buffer=o.data.buffer,n.remove(),e()})),r.addEventListener("error",(function(e){t&&t(i.getClassName()+" could not be loaded",e)})),r.src=this.url},t.prototype.loadTexture=function(){var e=this,i=this.getScene();i&&(this._texture=i.getEngine().createRawCubeTextureFromUrl(this.url,i,this._size,g.a.TEXTUREFORMAT_RGB,i.getEngine().getCaps().textureFloat?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_UNSIGNED_INTEGER,this._noMipmap,(function(){for(var i=e.getFloat32ArrayFromArrayBuffer(e._buffer),n=ic.ConvertPanoramaToCubemap(i,e._width,e._height,e._size),r=[],o=0;o<6;o++){var a=n[t._FacesMapping[o]];r.push(a)}return r}),null,this._onLoad,this._onError))},t.prototype.getFloat32ArrayFromArrayBuffer=function(e){for(var t=new DataView(e),i=new Float32Array(3*e.byteLength/4),n=0,r=0;ri.length)m.a.Error("Unable to load TGA file - Not enough data");else{n+=r.id_length;var o,a=!1,s=!1,c=!1;switch(r.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:c=!0}var l,u,h,d,f,p,_,g=r.pixel_size>>3,v=r.width*r.height*g;if(s&&(l=i.subarray(n,n+=r.colormap_length*(r.colormap_size>>3))),a){var b,y,T;o=new Uint8Array(v);for(var E=0,S=new Uint8Array(g);n>e._ORIGIN_SHIFT){default:case e._ORIGIN_UL:u=0,d=1,_=r.width,h=0,f=1,p=r.height;break;case e._ORIGIN_BL:u=0,d=1,_=r.width,h=r.height-1,f=-1,p=-1;break;case e._ORIGIN_UR:u=r.width-1,d=-1,_=-1,h=0,f=1,p=r.height;break;case e._ORIGIN_BR:u=r.width-1,d=-1,_=-1,h=r.height-1,f=-1,p=-1}var A=e["_getImageData"+(c?"Grey":"")+r.pixel_size+"bits"](r,l,o,h,f,p,u,d,_);t.getEngine()._uploadDataToTextureDirectly(t,A)}}},e._getImageData8bits=function(e,t,i,n,r,o,a,s,c){var l,u,h,d=i,f=t,p=e.width,_=e.height,m=0,g=new Uint8Array(p*_*4);for(h=n;h!==o;h+=r)for(u=a;u!==c;u+=s,m++)l=d[m],g[4*(u+p*h)+3]=255,g[4*(u+p*h)+2]=f[3*l+0],g[4*(u+p*h)+1]=f[3*l+1],g[4*(u+p*h)+0]=f[3*l+2];return g},e._getImageData16bits=function(e,t,i,n,r,o,a,s,c){var l,u,h,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(h=n;h!==o;h+=r)for(u=a;u!==c;u+=s,_+=2){var g=255*((31744&(l=d[_+0]+(d[_+1]<<8)))>>10)/31|0,v=255*((992&l)>>5)/31|0,b=255*(31&l)/31|0;m[4*(u+f*h)+0]=g,m[4*(u+f*h)+1]=v,m[4*(u+f*h)+2]=b,m[4*(u+f*h)+3]=32768&l?0:255}return m},e._getImageData24bits=function(e,t,i,n,r,o,a,s,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=n;u!==o;u+=r)for(l=a;l!==c;l+=s,p+=3)_[4*(l+d*u)+3]=255,_[4*(l+d*u)+2]=h[p+0],_[4*(l+d*u)+1]=h[p+1],_[4*(l+d*u)+0]=h[p+2];return _},e._getImageData32bits=function(e,t,i,n,r,o,a,s,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=n;u!==o;u+=r)for(l=a;l!==c;l+=s,p+=4)_[4*(l+d*u)+2]=h[p+0],_[4*(l+d*u)+1]=h[p+1],_[4*(l+d*u)+0]=h[p+2],_[4*(l+d*u)+3]=h[p+3];return _},e._getImageDataGrey8bits=function(e,t,i,n,r,o,a,s,c){var l,u,h,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(h=n;h!==o;h+=r)for(u=a;u!==c;u+=s,_++)l=d[_],m[4*(u+f*h)+0]=l,m[4*(u+f*h)+1]=l,m[4*(u+f*h)+2]=l,m[4*(u+f*h)+3]=255;return m},e._getImageDataGrey16bits=function(e,t,i,n,r,o,a,s,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=n;u!==o;u+=r)for(l=a;l!==c;l+=s,p+=2)_[4*(l+d*u)+0]=h[p+0],_[4*(l+d*u)+1]=h[p+0],_[4*(l+d*u)+2]=h[p+0],_[4*(l+d*u)+3]=h[p+1];return _},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}(),Vc=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,".tga")},e.prototype.loadCubeData=function(e,t,i,n,r){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,i){var n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=Uc.GetTGAHeader(n);i(r.width,r.height,t.generateMipMaps,!1,(function(){Uc.UploadContent(t,n)}))},e}();Se.a._TextureLoaders.push(new Vc);var kc,zc=function(){};!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"}(kc||(kc={}));var Gc=function(){function e(){}return e.GetInternalFormatFromBasisFormat=function(e){if(e===kc.cTFETC1)return 36196;if(e===kc.cTFBC1)return 33776;if(e===kc.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(i){t._Worker?i(t._Worker):Ce.b.LoadFileAsync(e.WasmModuleURL).then((function(n){var r=URL.createObjectURL(new Blob(["("+jc+")()"],{type:"application/javascript"}));t._Worker=new Worker(r);var o=function(e){"init"===e.data.action&&(t._Worker.removeEventListener("message",o),i(t._Worker))};t._Worker.addEventListener("message",o),t._Worker.postMessage({action:"init",url:e.JSModuleURL,wasmBinary:n})}))}))),this._WorkerPromise},e.TranscodeAsync=function(e,t){var i=this,n=e instanceof ArrayBuffer?new Uint8Array(e):e;return new Promise((function(e,r){i._CreateWorkerAsync().then((function(){var o=i._actionId++,a=function(t){"transcode"===t.data.action&&t.data.id===o&&(i._Worker.removeEventListener("message",a),t.data.success?e(t.data):r("Transcode is not supported on this device"))};i._Worker.addEventListener("message",a);var s=new Uint8Array(n.byteLength);s.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),i._Worker.postMessage({action:"transcode",id:o,imageData:s,config:t,ignoreSupportedFormats:i._IgnoreSupportedFormats},[s.buffer])}))}))},e.LoadTextureFromTranscodeResult=function(t,i){for(var n,r=t.getEngine(),o=function(){if(n=i.fileInfo.images[a].levels[0],t._invertVScale=t.invertY,-1===i.format)if(t.type=g.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.format=g.a.TEXTUREFORMAT_RGB,r.webGLVersion<2&&(L.a.Log2(n.width)%1!=0||L.a.Log2(n.height)%1!=0)){var o=new Qe.a(r,Qe.b.Temp);t._invertVScale=t.invertY,o.type=g.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,o.format=g.a.TEXTUREFORMAT_RGB,o.width=n.width+3&-4,o.height=n.height+3&-4,r._bindTextureDirectly(r._gl.TEXTURE_2D,o,!0),r._uploadDataToTextureDirectly(o,n.transcodedPixels,a,0,g.a.TEXTUREFORMAT_RGB,!0),r._rescaleTexture(o,t,r.scenes[0],r._getInternalFormat(g.a.TEXTUREFORMAT_RGB),(function(){r._releaseTexture(o),r._bindTextureDirectly(r._gl.TEXTURE_2D,t,!0)}))}else t._invertVScale=!t.invertY,t.width=n.width+3&-4,t.height=n.height+3&-4,r._uploadDataToTextureDirectly(t,n.transcodedPixels,a,0,g.a.TEXTUREFORMAT_RGB,!0);else t.width=n.width,t.height=n.height,i.fileInfo.images[a].levels.forEach((function(n,o){r._uploadCompressedDataToTextureDirectly(t,e.GetInternalFormatFromBasisFormat(i.format),n.width,n.height,n.transcodedPixels,a,o)})),r.webGLVersion<2&&(L.a.Log2(t.width)%1!=0||L.a.Log2(t.height)%1!=0)&&(Ce.b.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1."),t._cachedWrapU=Ke.a.CLAMP_ADDRESSMODE,t._cachedWrapV=Ke.a.CLAMP_ADDRESSMODE)},a=0;a>2&3],o[f++]=r[d>>4&3],o[f++]=r[d>>6&3]}}return o}(a,0,e.getImageWidth(t,i)+3&-4,e.getImageHeight(t,i)+3&-4));return a}onmessage=function(a){if("init"===a.data.action)r||(Module={wasmBinary:a.data.wasmBinary},importScripts(a.data.url),r=new Promise((function(e){Module.onRuntimeInitialized=function(){Module.initializeBasis(),e()}}))),r.then((function(){postMessage({action:"init"})}));else if("transcode"===a.data.action){var s=a.data.config,c=a.data.imageData,l=new Module.BasisFile(c),u=function(e){for(var t=e.getHasAlpha(),i=e.getNumImages(),n=[],r=0;r1&&t.generateMipMaps;Gc.LoadTextureFromTranscodeResult(t,e),t.getEngine()._setCubeMapTextureParams(t,i),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n()})).catch((function(e){Ce.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),t.isReady=!0}))}},e.prototype.loadData=function(e,t,i){var n=t.getEngine().getCaps(),r={supportedCompressionFormats:{etc1:!!n.etc1,s3tc:!!n.s3tc,pvrtc:!!n.pvrtc,etc2:!!n.etc2}};Gc.TranscodeAsync(e,r).then((function(e){var n=e.fileInfo.images[0].levels[0],r=e.fileInfo.images[0].levels.length>1&&t.generateMipMaps;i(n.width,n.height,r,-1!==e.format,(function(){Gc.LoadTextureFromTranscodeResult(t,e)}))})).catch((function(e){Ce.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),i(0,0,!1,!1,(function(){}))}))},e}();Se.a._TextureLoaders.push(new Wc);var Hc=function(e){function t(t,i,n,r,o){var a=this,s=!(!o||!o.generateMipMaps)&&o.generateMipMaps,c=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,l=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio;if((a=e.call(this,t,i,r,s,l)||this).isSupported){var u=[],h=[];a._initTypes(n,u,h,o);var d=!o||void 0===o.generateDepthBuffer||o.generateDepthBuffer,f=!(!o||void 0===o.generateStencilBuffer)&&o.generateStencilBuffer;return a._size=i,a._multiRenderTargetOptions={samplingModes:h,generateMipMaps:s,generateDepthBuffer:d,generateStencilBuffer:f,generateDepthTexture:c,types:u,textureCount:n},a._count=n,a._createInternalTextures(),a._createTextures(),a}a.dispose()}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"isSupported",{get:function(){return this._getEngine().webGLVersion>1||this._getEngine().getCaps().drawBuffersExtension},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wrapU",{set:function(e){if(this._textures)for(var t=0;t=0;e--)void 0!==this._internalTextures[e]&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},t}(Ni),Xc=function(e,t,i){this.id=e,this.scale=t,this.offset=i},Yc=function(){function e(t,i,n,r){var o,a,c,l,u,h,d,f,p,_,m,g,v;return this.name=t,this.meshes=i,this.scene=r,this.options=n,this.options.map=null!==(o=this.options.map)&&void 0!==o?o:["ambientTexture","bumpTexture","diffuseTexture","emissiveTexture","lightmapTexture","opacityTexture","reflectionTexture","refractionTexture","specularTexture"],this.options.uvsIn=null!==(a=this.options.uvsIn)&&void 0!==a?a:Qi.b.UVKind,this.options.uvsOut=null!==(c=this.options.uvsOut)&&void 0!==c?c:Qi.b.UVKind,this.options.layout=null!==(l=this.options.layout)&&void 0!==l?l:e.LAYOUT_STRIP,this.options.layout===e.LAYOUT_COLNUM&&(this.options.colnum=null!==(u=this.options.colnum)&&void 0!==u?u:8),this.options.updateInputMeshes=null===(h=this.options.updateInputMeshes)||void 0===h||h,this.options.disposeSources=null===(d=this.options.disposeSources)||void 0===d||d,this._expecting=0,this.options.fillBlanks=null===(f=this.options.fillBlanks)||void 0===f||f,!0===this.options.fillBlanks&&(this.options.customFillColor=null!==(p=this.options.customFillColor)&&void 0!==p?p:"black"),this.options.frameSize=null!==(_=this.options.frameSize)&&void 0!==_?_:256,this.options.paddingRatio=null!==(m=this.options.paddingRatio)&&void 0!==m?m:.0115,this._paddingValue=Math.ceil(this.options.frameSize*this.options.paddingRatio),this._paddingValue%2!=0&&this._paddingValue++,this.options.paddingMode=null!==(g=this.options.paddingMode)&&void 0!==g?g:e.SUBUV_WRAP,this.options.paddingMode===e.SUBUV_COLOR&&(this.options.paddingColor=null!==(v=this.options.paddingColor)&&void 0!==v?v:new s.b(0,0,0,1)),this.sets={},this.frames=[],this}return e.prototype._createFrames=function(e){for(var t=this,i=this._calculateSize(),n=new a.d(1,1).divide(i),r=0,o=this._expecting,c=this.meshes.length,l=Object.keys(this.sets),u=0;u0);for(var e=0;e0)}},e}(),Qc="\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}";ai.a.ShadersStore.proceduralVertexShader=Qc;var qc=function(e){function t(t,i,n,r,a,s,c,l){void 0===a&&(a=null),void 0===s&&(s=!0),void 0===c&&(c=!1),void 0===l&&(l=g.a.TEXTURETYPE_UNSIGNED_INT);var u=e.call(this,null,r,!s)||this;u.isEnabled=!0,u.autoClear=!0,u.onGeneratedObservable=new o.c,u.onBeforeGenerationObservable=new o.c,u.nodeMaterialSource=null,u._textures={},u._currentRefreshId=-1,u._frameId=-1,u._refreshRate=1,u._vertexBuffers={},u._uniforms=new Array,u._samplers=new Array,u._floats={},u._ints={},u._floatsArrays={},u._colors3={},u._colors4={},u._vectors2={},u._vectors3={},u._matrices={},u._fallbackTextureUsed=!1,u._cachedDefines="",u._contentUpdateId=-1;var h=(r=u.getScene()||x.a.LastCreatedScene)._getComponent(Me.a.NAME_PROCEDURALTEXTURE);h||(h=new Kc(r),r._addComponent(h)),r.proceduralTextures.push(u),u._fullEngine=r.getEngine(),u.name=t,u.isRenderTarget=!0,u._size=i,u._generateMipMaps=s,u.setFragment(n),u._fallbackTexture=a,c?(u._texture=u._fullEngine.createRenderTargetCubeTexture(i,{generateMipMaps:s,generateDepthBuffer:!1,generateStencilBuffer:!1,type:l}),u.setFloat("face",0)):u._texture=u._fullEngine.createRenderTargetTexture(i,{generateMipMaps:s,generateDepthBuffer:!1,generateStencilBuffer:!1,type:l});var d=[];return d.push(1,1),d.push(-1,1),d.push(-1,-1),d.push(1,-1),u._vertexBuffers[Qi.b.PositionKind]=new Qi.b(u._fullEngine,d,Qi.b.PositionKind,!1,!1,2),u._createIndexBuffer(),u}return Object(h.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._fullEngine,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[Qi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===Ni.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Ni.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,i=this._fullEngine;if(this.nodeMaterialSource)return this._effect.isReady();if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;var n=this._getDefines();return!(!this._effect||n!==this._cachedDefines||!this._effect.isReady())||(e=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._cachedDefines=n,this._effect=i.createEffect(e,[Qi.b.PositionKind],this._uniforms,this._samplers,n,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:!1,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._fullEngine.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 i=this._fullEngine;if(i.enableEffect(this._effect),this.onBeforeGenerationObservable.notifyObservers(this),i.setState(!1),!this.nodeMaterialSource){for(var n in this._textures)this._effect.setTexture(n,this._textures[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._colors4){var r=this._colors4[n];this._effect.setFloat4(n,r.r,r.g,r.b,r.a)}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._matrices)this._effect.setMatrix(n,this._matrices[n])}if(this._texture){if(this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(xo.a.TriangleFillMode,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture,0,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(xo.a.TriangleFillMode,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},t.prototype.clone=function(){var e=this.getSize(),i=new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.coordinatesMode=this.coordinatesMode,i},t.prototype.dispose=function(){var t=this.getScene();if(t){var i=t.proceduralTextures.indexOf(this);i>=0&&t.proceduralTextures.splice(i,1);var n=this._vertexBuffers[Qi.b.PositionKind];n&&(n.dispose(),this._vertexBuffers[Qi.b.PositionKind]=null),this._indexBuffer&&this._fullEngine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),this.onGeneratedObservable.clear(),this.onBeforeGenerationObservable.clear(),e.prototype.dispose.call(this)}},Object(h.c)([Object(w.c)()],t.prototype,"isEnabled",void 0),Object(h.c)([Object(w.c)()],t.prototype,"autoClear",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_generateMipMaps",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_size",void 0),Object(h.c)([Object(w.c)()],t.prototype,"refreshRate",null),t}(Ke.a);c.a.RegisteredTypes["BABYLON.ProceduralTexture"]=qc;var Zc=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,n,null,r,o,a)||this;return s._animate=!0,s._time=0,s._texturePath=i,s._loadJson(i),s.refreshRate=1,s}return Object(h.d)(t,e),t.prototype._loadJson=function(e){var t=this,i=function(){try{t.setFragment(t._texturePath)}catch(e){m.a.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},n=e+"/config.json",r=new V.a;r.open("GET",n),r.addEventListener("load",(function(){if(200===r.status||r.responseText&&r.responseText.length>0)try{t._config=JSON.parse(r.response),t.updateShaderUniforms(),t.updateTextures(),t.setFragment(t._texturePath+"/custom"),t._animate=t._config.animate,t.refreshRate=t._config.refreshrate}catch(e){i()}else i()}),!1),r.addEventListener("error",(function(){i()}),!1);try{r.send()}catch(e){m.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 i=this.getScene();this._animate&&i&&(this._time+=.03*i.getAnimationRatio(),this.updateShaderUniforms()),e.prototype.render.call(this,t)},t.prototype.updateTextures=function(){for(var e=0;e0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnectedInVertexShader",{get:function(){if(this.target===el.Vertex)return!0;if(!this.hasEndpoints)return!1;for(var e=0,t=this._endpoints;e=0)&&(t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),t},e.prototype.dispose=function(){this.onConnectionObservable.clear()},e}(),dl=i(152),fl=function(){function e(e,t,i,n){void 0===t&&(t=el.Vertex),void 0===i&&(i=!1),void 0===n&&(n=!1),this._isFinalMerger=!1,this._isInput=!1,this._name="",this._isUnique=!1,this.inputsAreExclusive=!1,this._codeVariableName="",this._inputs=new Array,this._outputs=new Array,this.comments="",this.visibleInInspector=!1,this._target=t,this._isFinalMerger=i,this._isInput=n,this._name=e,this.uniqueId=dl.a.UniqueId}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},set:function(e){this.validateBlockName(e)&&(this._name=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUnique",{get:function(){return this._isUnique},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isFinalMerger",{get:function(){return this._isFinalMerger},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInput",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buildId",{get:function(){return this._buildId},set:function(e){this._buildId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(e){0==(this._target&e)&&(this._target=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputs",{get:function(){return this._inputs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outputs",{get:function(){return this._outputs},enumerable:!1,configurable:!0}),e.prototype.getInputByName=function(e){var t=this._inputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype.getOutputByName=function(e){var t=this._outputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype.initialize=function(e){},e.prototype.bind=function(e,t,i,n){},e.prototype._declareOutput=function(e,t){return t._getGLType(e.type)+" "+e.associatedVariableName},e.prototype._writeVariable=function(e){return e.connectedPoint?""+e.associatedVariableName:"0."},e.prototype._writeFloat=function(e){var t=e.toString();return-1===t.indexOf(".")&&(t+=".0"),""+t},e.prototype.getClassName=function(){return"NodeMaterialBlock"},e.prototype.registerInput=function(e,t,i,n,r){return void 0===i&&(i=!1),(r=null!=r?r:new hl(e,this,al.Input)).type=t,r.isOptional=i,n&&(r.target=n),this._inputs.push(r),this},e.prototype.registerOutput=function(e,t,i,n){return(n=null!=n?n:new hl(e,this,al.Output)).type=t,i&&(n.target=i),this._outputs.push(n),this},e.prototype.getFirstAvailableInput=function(e){void 0===e&&(e=null);for(var t=0,i=this._inputs;t=this._outputs.length?null:this._outputs[t+1]},e.prototype.connectTo=function(e,t){if(0!==this._outputs.length){for(var i=t&&t.output?this.getOutputByName(t.output):this.getFirstAvailableOutput(e),n=!0;n;){var r=t&&t.input?e.getInputByName(t.input):e.getFirstAvailableInput(i);if(i&&r&&i.canConnectTo(r))i.connectTo(r),n=!1;else{if(!i)throw"Unable to find a compatible match";i=this.getSiblingOutput(i)}}return this}},e.prototype._buildBlock=function(e){},e.prototype.updateUniformsAndSamples=function(e,t,i,n){},e.prototype.provideFallbacks=function(e,t){},e.prototype.initializeDefines=function(e,t,i,n){void 0===n&&(n=!1)},e.prototype.prepareDefines=function(e,t,i,n,r){void 0===n&&(n=!1)},e.prototype.autoConfigure=function(e){},e.prototype.replaceRepeatableContent=function(e,t,i,n){},e.prototype.isReady=function(e,t,i,n){return void 0===n&&(n=!1),!0},e.prototype._linkConnectionTypes=function(e,t,i){void 0===i&&(i=!1),i?this._inputs[t]._acceptedConnectionPointType=this._inputs[e]:this._inputs[e]._linkedConnectionSource=this._inputs[t],this._inputs[t]._linkedConnectionSource=this._inputs[e]},e.prototype._processBuild=function(e,t,i,n){e.build(t,n);var r=null!=t._vertexState,o=e._buildTarget===el.Vertex&&e.target!==el.VertexAndFragment;if(r&&(0==(e.target&e._buildTarget)||0==(e.target&i.target)||this.target!==el.VertexAndFragment&&o)&&(!e.isInput&&t.target!==e._buildTarget||e.isInput&&e.isAttribute&&!e._noContextSwitch)){var a=i.connectedPoint;t._vertexState._emitVaryingFromString("v_"+a.associatedVariableName,t._getGLType(a.type))&&(t._vertexState.compilationString+="v_"+a.associatedVariableName+" = "+a.associatedVariableName+";\r\n"),i.associatedVariableName="v_"+a.associatedVariableName,i._enforceAssociatedVariableName=!0}},e.prototype.validateBlockName=function(e){for(var t=0,i=["position","normal","tangent","particle_positionw","uv","uv2","position2d","particle_uv","matricesIndices","matricesWeights","world0","world1","world2","world3","particle_color","particle_texturemask"];t[0.."+i.repeatKey+"]\r\n";var n=ai.a.IncludesShadersStore[e]+"\r\n";if(this.sharedData.emitComments&&(n=t+"\r\n"+n),!i)return n;if(i.replaceStrings)for(var r=0;r[0.."+i.repeatKey+"]\r\n":this.functions[r]="#include<"+e+">\r\n",void(this.sharedData.emitComments&&(this.functions[r]=t+"\r\n"+this.functions[r]));if(this.functions[r]=ai.a.IncludesShadersStore[e],this.sharedData.emitComments&&(this.functions[r]=t+"\r\n"+this.functions[r]),i.removeIfDef&&(this.functions[r]=this.functions[r].replace(/^\s*?#ifdef.+$/gm,""),this.functions[r]=this.functions[r].replace(/^\s*?#endif.*$/gm,""),this.functions[r]=this.functions[r].replace(/^\s*?#else.*$/gm,""),this.functions[r]=this.functions[r].replace(/^\s*?#elif.*$/gm,"")),i.removeAttributes&&(this.functions[r]=this.functions[r].replace(/^\s*?attribute.+$/gm,"")),i.removeUniforms&&(this.functions[r]=this.functions[r].replace(/^\s*?uniform.+$/gm,"")),i.removeVaryings&&(this.functions[r]=this.functions[r].replace(/^\s*?varying.+$/gm,"")),i.replaceStrings)for(var o=0;o0||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:a.e.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:a.e.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:a.e.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:a.e.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!1,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(!e&&this._scene?this._imageProcessingConfiguration=this._scene.imageProcessingConfiguration:this._imageProcessingConfiguration=e)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,i){if(!t)return this;for(var n=0,r=0,o=t;r-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&el.Vertex)&&this._addVertexOutputNode(e),0!=(e.target&el.Fragment)&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return null===e.target||(0!=(e.target&el.Vertex)&&this._removeVertexOutputNode(e),0!=(e.target&el.Fragment)&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(-1===this._vertexOutputNodes.indexOf(e))return e.target=el.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=el.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,i){if(e.initialize(t),e.autoConfigure(this),e._preparationId=this._buildId,-1===this.attachedBlocks.indexOf(e)){if(e.isUnique)for(var n=e.getClassName(),r=0,o=this.attachedBlocks;r-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 i=this.getScene().getEngine(),n=this._mode===rl.Particle;if(0===this._vertexOutputNodes.length&&!n)throw"You must define at least one vertexOutputNode";if(0===this._fragmentOutputNodes.length)throw"You must define at least one fragmentOutputNode";this._vertexCompilationState=new pl,this._vertexCompilationState.supportUniformBuffers=i.supportsUniformBuffers,this._vertexCompilationState.target=el.Vertex,this._fragmentCompilationState=new pl,this._fragmentCompilationState.supportUniformBuffers=i.supportsUniformBuffers,this._fragmentCompilationState.target=el.Fragment,this._sharedData=new _l,this._vertexCompilationState.sharedData=this._sharedData,this._fragmentCompilationState.sharedData=this._sharedData,this._sharedData.buildId=this._buildId,this._sharedData.emitComments=this._options.emitComments,this._sharedData.verbose=e,this._sharedData.scene=this.getScene(),this._sharedData.allowEmptyVertexProgram=n;for(var r=[],o=[],a=0,s=this._vertexOutputNodes;a0&&ro.a.BindMorphTargetParameters(i,e)},t.prototype.replaceRepeatableContent=function(e,t,i,n){for(var r=this.position,o=this.normal,a=this.tangent,s=this.uv,c=this.positionOutput,l=this.normalOutput,u=this.tangentOutput,h=this.uvOutput,d=e,f=n.NUM_MORPH_INFLUENCERS,p=i.morphTargetManager,_=p&&p.supportsNormals&&n.NORMAL,m=p&&p.supportsTangents&&n.TANGENT,g=p&&p.supportsUVs&&n.UV1,v="",b=0;b0)for(b=0;b=0;ro.a.PrepareUniformsAndSamplersForLight(r,e.uniforms,e.samplers,i["PROJECTEDLIGHTTEXTURE"+r],n,o)}},t.prototype.bind=function(e,t,i){if(i){var n=i.getScene();this.light?ro.a.BindLight(this.light,this._lightId,n,e,!0):ro.a.BindLights(n,i,e,!0,t.maxSimultaneousLights)}},t.prototype._injectVertexCode=function(e){var t=this.worldPosition,i="//"+this.name;this.light?(this._lightId=(void 0!==e.counters.lightCounter?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var n="v_"+t.associatedVariableName;e._emitVaryingFromString(n,"vec4")&&(e.compilationString+=n+" = "+t.associatedVariableName+";\r\n"),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:t.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = "+t.associatedVariableName+";\r\n",this.view.isConnected&&(e.compilationString+="mat4 view = "+this.view.associatedVariableName+";\r\n"),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{repeatKey:"maxSimultaneousLights"}))},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target===el.Fragment){t.sharedData.bindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this);var i="//"+this.name,n=this.worldPosition;t._emitFunctionFromInclude("helperFunctions",i),t._emitFunctionFromInclude("lightsFragmentFunctions",i,{replaceStrings:[{search:/vPositionW/g,replace:"v_"+n.associatedVariableName+".xyz"}]}),t._emitFunctionFromInclude("shadowsFragmentFunctions",i,{replaceStrings:[{search:/vPositionW/g,replace:"v_"+n.associatedVariableName+".xyz"}]}),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{repeatKey:"maxSimultaneousLights"}),0===this._lightId&&(t._registerTempVariable("viewDirectionW")&&(t.compilationString+="vec3 viewDirectionW = normalize("+this.cameraPosition.associatedVariableName+" - v_"+n.associatedVariableName+".xyz);\r\n"),t.compilationString+="lightingInfo info;\r\n",t.compilationString+="float shadow = 1.;\r\n",t.compilationString+="float glossiness = "+(this.glossiness.isConnected?this.glossiness.associatedVariableName:"1.0")+" * "+(this.glossPower.isConnected?this.glossPower.associatedVariableName:"1024.0")+";\r\n",t.compilationString+="vec3 diffuseBase = vec3(0., 0., 0.);\r\n",t.compilationString+="vec3 specularBase = vec3(0., 0., 0.);\r\n",t.compilationString+="vec3 normalW = "+this.worldNormal.associatedVariableName+".xyz;\r\n"),this.light?t.compilationString+=t._emitCodeFromInclude("lightFragment",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):t.compilationString+=t._emitCodeFromInclude("lightFragment",i,{repeatKey:"maxSimultaneousLights"});var r=this.diffuseOutput,o=this.specularOutput;return t.compilationString+=this._declareOutput(r,t)+" = diffuseBase"+(this.diffuseColor.isConnected?" * "+this.diffuseColor.associatedVariableName:"")+";\r\n",o.hasEndpoints&&(t.compilationString+=this._declareOutput(o,t)+" = specularBase"+(this.specularColor.isConnected?" * "+this.specularColor.associatedVariableName:"")+";\r\n"),this.shadow.hasEndpoints&&(t.compilationString+=this._declareOutput(this.shadow,t)+" = shadow;\r\n"),this}this._injectVertexCode(t)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return this.light&&(t.lightId=this.light.id),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),t.lightId&&(this.light=i.getLightByID(t.lightId))},t}(fl);c.a.RegisteredTypes["BABYLON.LightBlock"]=lu;var uu=function(e){function t(t,i){void 0===i&&(i=!1);var n=e.call(this,t,i?el.Fragment:el.VertexAndFragment)||this;return n.convertToGammaSpace=!1,n.convertToLinearSpace=!1,n._fragmentOnly=i,n.registerInput("uv",tl.Vector2,!1,el.VertexAndFragment),n.registerOutput("rgba",tl.Color4,el.Neutral),n.registerOutput("rgb",tl.Color3,el.Neutral),n.registerOutput("r",tl.Float,el.Neutral),n.registerOutput("g",tl.Float,el.Neutral),n.registerOutput("b",tl.Float,el.Neutral),n.registerOutput("a",tl.Float,el.Neutral),n._inputs[0].acceptedConnectionPointTypes.push(tl.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),n._inputs[0]._prioritizeVertex=!i,n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"TextureBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){if(this._fragmentOnly)return el.Fragment;if(!this.uv.isConnected)return el.VertexAndFragment;if(this.uv.sourceBlock.isInput)return el.VertexAndFragment;for(var e=this.uv.connectedPoint;e;){if(e.target===el.Fragment)return el.Fragment;if(e.target===el.Vertex)return el.VertexAndFragment;if(e.target===el.Neutral||e.target===el.VertexAndFragment){var t=e.ownerBlock;e=null;for(var i=0,n=t.inputs;i1?i.setValue("NUM_SAMPLES",this.realTimeFilteringQuality+"u",!0):i.setValue("NUM_SAMPLES",""+this.realTimeFilteringQuality,!0),i.setValue("BRDF_V_HEIGHT_CORRELATED",!0),i.setValue("MS_BRDF_ENERGY_CONSERVATION",this.useEnergyConservation,!0),i.setValue("RADIANCEOCCLUSION",this.useRadianceOcclusion,!0),i.setValue("HORIZONOCCLUSION",this.useHorizonOcclusion,!0),i.setValue("UNLIT",this.unlit,!0),i.setValue("FORCENORMALFORWARD",this.forceNormalForward,!0),this._environmentBRDFTexture&&so.a.ReflectionTextureEnabled?(i.setValue("ENVIRONMENTBRDF",!0),i.setValue("ENVIRONMENTBRDF_RGBD",this._environmentBRDFTexture.isRGBD,!0)):(i.setValue("ENVIRONMENTBRDF",!1),i.setValue("ENVIRONMENTBRDF_RGBD",!1)),i._areLightsDirty){var r=e.getScene();if(this.light){var o={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};ro.a.PrepareDefinesForLight(r,e,this.light,this._lightId,i,!0,o),o.needRebuild&&i.rebuild()}else ro.a.PrepareDefinesForLights(r,e,i,!0,t.maxSimultaneousLights),i._needNormals=!0,ro.a.PrepareDefinesForMultiview(r,i)}},t.prototype.updateUniformsAndSamples=function(e,t,i,n){for(var r=0;r=0;ro.a.PrepareUniformsAndSamplersForLight(r,e.uniforms,e.samplers,i["PROJECTEDLIGHTTEXTURE"+r],n,o)}},t.prototype.bind=function(e,t,i){var n,r;if(i){var o=i.getScene();this.light?ro.a.BindLight(this.light,this._lightId,o,e,!0):ro.a.BindLights(o,i,e,!0,t.maxSimultaneousLights),e.setTexture(this._environmentBrdfSamplerName,this._environmentBRDFTexture),e.setFloat2("vDebugMode",this.debugLimit,this.debugFactor);var a=this._scene.ambientColor;a&&e.setColor3("ambientFromScene",a);var c=o.useRightHandedSystem===(null!=o._mirroredCameraPosition);e.setFloat(this._invertNormalName,c?-1:1),e.setFloat4("vLightingIntensity",this.directIntensity,1,this.environmentIntensity*this._scene.environmentIntensity,this.specularIntensity);var l=null!==(r=null===(n=this.indexOfRefraction.connectInputBlock)||void 0===n?void 0:n.value)&&void 0!==r?r:1.5,u=Math.pow((l-1)/(l+1),2);this._metallicReflectanceColor.scaleToRef(u*this._metallicF0Factor,s.c.Color3[0]);var h=this._metallicF0Factor;e.setColor4(this._vMetallicReflectanceFactorsName,s.c.Color3[0],h)}},t.prototype._injectVertexCode=function(e){var t,i,n=this.worldPosition,r="//"+this.name;this.light?(this._lightId=(void 0!==e.counters.lightCounter?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",r,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",r,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var o="v_"+n.associatedVariableName;e._emitVaryingFromString(o,"vec4")&&(e.compilationString+=o+" = "+n.associatedVariableName+";\r\n");var a=this.reflection.isConnected?null===(t=this.reflection.connectedPoint)||void 0===t?void 0:t.ownerBlock:null;a&&(a.viewConnectionPoint=this.view),e.compilationString+=null!==(i=null==a?void 0:a.handleVertexSide(e))&&void 0!==i?i:"",e._emitUniformFromString("vDebugMode","vec2","defined(IGNORE) || DEBUGMODE > 0"),e._emitUniformFromString("ambientFromScene","vec3"),e._emitVaryingFromString("vClipSpacePosition","vec4","defined(IGNORE) || DEBUGMODE > 0")&&(e._injectAtEnd+="#if DEBUGMODE > 0\r\n",e._injectAtEnd+="vClipSpacePosition = gl_Position;\r\n",e._injectAtEnd+="#endif\r\n"),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",r,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:n.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = "+n.associatedVariableName+";\r\n",this.view.isConnected&&(e.compilationString+="mat4 view = "+this.view.associatedVariableName+";\r\n"),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",r,{repeatKey:"maxSimultaneousLights"}))},t.prototype._getAlbedoOpacityCode=function(){var e="albedoOpacityOutParams albedoOpacityOut;\r\n";return e+="albedoOpacityBlock(\n vec4("+(this.baseColor.isConnected?this.baseColor.associatedVariableName:"vec3(1.)")+", 1.),\n #ifdef ALBEDO\n vec4(1.),\n vec2(1., 1.),\n #endif\n #ifdef OPACITY\n vec4("+(this.opacity.isConnected?this.opacity.associatedVariableName:"1.")+"),\n vec2(1., 1.),\n #endif\n albedoOpacityOut\n );\n\n vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;\n float alpha = albedoOpacityOut.alpha;\r\n"},t.prototype._getAmbientOcclusionCode=function(){var e="ambientOcclusionOutParams aoOut;\r\n";return e+="ambientOcclusionBlock(\n #ifdef AMBIENT\n vec3("+(this.ambientOcc.isConnected?this.ambientOcc.associatedVariableName:"1.")+"),\n vec4(0., 1.0, 1.0, 0.),\n #endif\n aoOut\n );\r\n"},t.prototype._getReflectivityCode=function(e){var t="reflectivityOutParams reflectivityOut;\r\n";return this._vMetallicReflectanceFactorsName=e._getFreeVariableName("vMetallicReflectanceFactors"),e._emitUniformFromString(this._vMetallicReflectanceFactorsName,"vec4"),t+="vec3 baseColor = surfaceAlbedo;\n\n reflectivityBlock(\n vec4("+this.metallic.associatedVariableName+", "+this.roughness.associatedVariableName+", 0., 0.),\n #ifdef METALLICWORKFLOW\n surfaceAlbedo,\n "+this._vMetallicReflectanceFactorsName+",\n #endif\n #ifdef REFLECTIVITY\n vec3(0., 0., 1.),\n vec4(1.),\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor,\n #endif\n #ifdef MICROSURFACEMAP\n microSurfaceTexel, <== not handled!\n #endif\n reflectivityOut\n );\n\n float microSurface = reflectivityOut.microSurface;\n float roughness = reflectivityOut.roughness;\n\n #ifdef METALLICWORKFLOW\n surfaceAlbedo = reflectivityOut.surfaceAlbedo;\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;\n #endif\r\n"},t.prototype._buildBlock=function(t){var i,n,r,o,a,s,c,l,u,h,d,f,p,_,m,g,v,b,y,T,E,S,A,P,C,R,x,O,M,I,D,N,L,w,F,B,U,V,k;e.prototype._buildBlock.call(this,t),this._scene=t.sharedData.scene,this._environmentBRDFTexture||(this._environmentBRDFTexture=To.GetEnvironmentBRDFTexture(this._scene));var z=this.reflection.isConnected?null===(i=this.reflection.connectedPoint)||void 0===i?void 0:i.ownerBlock:null;if(z&&(z.worldPositionConnectionPoint=this.worldPosition,z.cameraPositionConnectionPoint=this.cameraPosition,z.worldNormalConnectionPoint=this.worldNormal),t.target!==el.Fragment)return this._injectVertexCode(t),this;t.sharedData.bindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this);var G="//"+this.name,j="v_"+this.worldPosition.associatedVariableName,W=this.perturbedNormal;this._environmentBrdfSamplerName=t._getFreeVariableName("environmentBrdfSampler"),t._emit2DSampler(this._environmentBrdfSamplerName),t.sharedData.hints.needAlphaBlending=t.sharedData.hints.needAlphaBlending||this.useAlphaBlending,t.sharedData.hints.needAlphaTesting=t.sharedData.hints.needAlphaTesting||this.useAlphaTest,t._emitExtension("lod","#extension GL_EXT_shader_texture_lod : enable","defined(LODBASEDMICROSFURACE)"),t._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable"),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",G,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",G,{repeatKey:"maxSimultaneousLights"}),t._emitFunctionFromInclude("helperFunctions",G),t._emitFunctionFromInclude("importanceSampling",G),t._emitFunctionFromInclude("pbrHelperFunctions",G),t._emitFunctionFromInclude("imageProcessingFunctions",G),t._emitFunctionFromInclude("shadowsFragmentFunctions",G,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"}]}),t._emitFunctionFromInclude("pbrDirectLightingSetupFunctions",G,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"}]}),t._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions",G),t._emitFunctionFromInclude("pbrBRDFFunctions",G,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(n=null==z?void 0:z._defineSkyboxName)&&void 0!==n?n:"REFLECTIONMAP_SKYBOX"}]}),t._emitFunctionFromInclude("hdrFilteringFunctions",G),t._emitFunctionFromInclude("pbrDirectLightingFunctions",G,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"}]}),t._emitFunctionFromInclude("pbrIBLFunctions",G),t._emitFunctionFromInclude("pbrBlockAlbedoOpacity",G),t._emitFunctionFromInclude("pbrBlockReflectivity",G),t._emitFunctionFromInclude("pbrBlockAmbientOcclusion",G),t._emitFunctionFromInclude("pbrBlockAlphaFresnel",G),t._emitFunctionFromInclude("pbrBlockAnisotropic",G),t._emitUniformFromString("vLightingIntensity","vec4"),this._vNormalWName=t._getFreeVariableName("vNormalW"),t.compilationString+="vec4 "+this._vNormalWName+" = normalize("+this.worldNormal.associatedVariableName+");\r\n",t._registerTempVariable("viewDirectionW")&&(t.compilationString+="vec3 viewDirectionW = normalize("+this.cameraPosition.associatedVariableName+" - "+j+".xyz);\r\n"),t.compilationString+="vec3 geometricNormalW = "+this._vNormalWName+".xyz;\r\n",t.compilationString+="vec3 normalW = "+(W.isConnected?"normalize("+W.associatedVariableName+".xyz)":"geometricNormalW")+";\r\n",this._invertNormalName=t._getFreeVariableName("invertNormal"),t._emitUniformFromString(this._invertNormalName,"float"),t.compilationString+=t._emitCodeFromInclude("pbrBlockNormalFinal",G,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"},{search:/vEyePosition.w/g,replace:this._invertNormalName}]}),t.compilationString+=this._getAlbedoOpacityCode(),t.compilationString+=t._emitCodeFromInclude("depthPrePass",G),t.compilationString+=this._getAmbientOcclusionCode(),t.compilationString+=t._emitCodeFromInclude("pbrBlockLightmapInit",G),t.compilationString+="#ifdef UNLIT\n vec3 diffuseBase = vec3(1., 1., 1.);\n #else\r\n",t.compilationString+=this._getReflectivityCode(t),t.compilationString+=t._emitCodeFromInclude("pbrBlockGeometryInfo",G,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(r=null==z?void 0:z._defineSkyboxName)&&void 0!==r?r:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:null!==(o=null==z?void 0:z._define3DName)&&void 0!==o?o:"REFLECTIONMAP_3D"}]});var H=this.anisotropy.isConnected?null===(a=this.anisotropy.connectedPoint)||void 0===a?void 0:a.ownerBlock:null;H&&(H.worldPositionConnectionPoint=this.worldPosition,H.worldNormalConnectionPoint=this.worldNormal,t.compilationString+=H.getCode(t,!this.perturbedNormal.isConnected)),z&&z.hasTexture&&(t.compilationString+=z.getCode(t,H?"anisotropicOut.anisotropicNormal":"normalW")),t._emitFunctionFromInclude("pbrBlockReflection",G,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:null!==(s=null==z?void 0:z._define3DName)&&void 0!==s?s:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(c=null==z?void 0:z._defineOppositeZ)&&void 0!==c?c:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(l=null==z?void 0:z._defineProjectionName)&&void 0!==l?l:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(u=null==z?void 0:z._defineSkyboxName)&&void 0!==u?u:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(h=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==h?h:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(d=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==d?d:"LINEARSPECULARREFLECTION"},{search:/vReflectionFilteringInfo/g,replace:null!==(f=null==z?void 0:z._vReflectionFilteringInfoName)&&void 0!==f?f:"vReflectionFilteringInfo"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockReflectance0",G,{replaceStrings:[{search:/metallicReflectanceFactors/g,replace:this._vMetallicReflectanceFactorsName}]});var X=this.sheen.isConnected?null===(p=this.sheen.connectedPoint)||void 0===p?void 0:p.ownerBlock:null;X&&(t.compilationString+=X.getCode(z)),t._emitFunctionFromInclude("pbrBlockSheen",G,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:null!==(_=null==z?void 0:z._define3DName)&&void 0!==_?_:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(m=null==z?void 0:z._defineSkyboxName)&&void 0!==m?m:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(g=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==g?g:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(v=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==v?v:"LINEARSPECULARREFLECTION"}]});var Y=this.clearcoat.isConnected?null===(b=this.clearcoat.connectedPoint)||void 0===b?void 0:b.ownerBlock:null,K=!this.perturbedNormal.isConnected&&!this.anisotropy.isConnected,Q=this.perturbedNormal.isConnected&&(null===(y=this.perturbedNormal.connectedPoint)||void 0===y?void 0:y.ownerBlock).worldTangent.isConnected,q=this.anisotropy.isConnected&&(null===(T=this.anisotropy.connectedPoint)||void 0===T?void 0:T.ownerBlock).worldTangent.isConnected,Z=Q||!this.perturbedNormal.isConnected&&q;t.compilationString+=ih.GetCode(t,Y,z,j,K,Z,this.worldNormal.associatedVariableName),K&&(Z=null!==(E=null==Y?void 0:Y.worldTangent.isConnected)&&void 0!==E&&E),t._emitFunctionFromInclude("pbrBlockClearcoat",G,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:null!==(S=null==z?void 0:z._define3DName)&&void 0!==S?S:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(A=null==z?void 0:z._defineOppositeZ)&&void 0!==A?A:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(P=null==z?void 0:z._defineProjectionName)&&void 0!==P?P:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(C=null==z?void 0:z._defineSkyboxName)&&void 0!==C?C:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(R=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==R?R:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(x=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==x?x:"LINEARSPECULARREFLECTION"},{search:/defined\(TANGENT\)/g,replace:Z?"defined(TANGENT)":"defined(IGNORE)"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockReflectance",G,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(O=null==z?void 0:z._defineSkyboxName)&&void 0!==O?O:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:null!==(M=null==z?void 0:z._define3DName)&&void 0!==M?M:"REFLECTIONMAP_3D"}]});var J=this.subsurface.isConnected?null===(I=this.subsurface.connectedPoint)||void 0===I?void 0:I.ownerBlock:null,$=this.subsurface.isConnected?null===(N=(null===(D=this.subsurface.connectedPoint)||void 0===D?void 0:D.ownerBlock).refraction.connectedPoint)||void 0===N?void 0:N.ownerBlock:null;$&&($.viewConnectionPoint=this.view,$.indexOfRefractionConnectionPoint=this.indexOfRefraction),t.compilationString+=rh.GetCode(t,J,z,j),t._emitFunctionFromInclude("pbrBlockSubSurface",G,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:null!==(L=null==z?void 0:z._define3DName)&&void 0!==L?L:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(w=null==z?void 0:z._defineOppositeZ)&&void 0!==w?w:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(F=null==z?void 0:z._defineProjectionName)&&void 0!==F?F:"REFLECTIONMAP_PROJECTION"},{search:/SS_REFRACTIONMAP_3D/g,replace:null!==(B=null==$?void 0:$._define3DName)&&void 0!==B?B:"SS_REFRACTIONMAP_3D"},{search:/SS_LODINREFRACTIONALPHA/g,replace:null!==(U=null==$?void 0:$._defineLODRefractionAlpha)&&void 0!==U?U:"SS_LODINREFRACTIONALPHA"},{search:/SS_LINEARSPECULARREFRACTION/g,replace:null!==(V=null==$?void 0:$._defineLinearSpecularRefraction)&&void 0!==V?V:"SS_LINEARSPECULARREFRACTION"},{search:/SS_REFRACTIONMAP_OPPOSITEZ/g,replace:null!==(k=null==$?void 0:$._defineOppositeZ)&&void 0!==k?k:"SS_REFRACTIONMAP_OPPOSITEZ"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockDirectLighting",G),this.light?t.compilationString+=t._emitCodeFromInclude("lightFragment",G,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):t.compilationString+=t._emitCodeFromInclude("lightFragment",G,{repeatKey:"maxSimultaneousLights"}),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalLitComponents",G),t.compilationString+="#endif\r\n";var ee=this.ambientColor.isConnected?this.ambientColor.associatedVariableName:"vec3(0., 0., 0.)",te=_a.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();-1===te.indexOf(".")&&(te+="."),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalUnlitComponents",G,{replaceStrings:[{search:/vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,replace:""},{search:/vAmbientColor/g,replace:ee+" * ambientFromScene"},{search:/vAmbientInfos\.w/g,replace:te}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalColorComposition",G,{replaceStrings:[{search:/finalEmissive/g,replace:"vec3(0.)"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockImageProcessing",G,{replaceStrings:[{search:/visibility/g,replace:"1."}]}),t.compilationString+=t._emitCodeFromInclude("pbrDebug",G,{replaceStrings:[{search:/vNormalW/g,replace:this._vNormalWName},{search:/vPositionW/g,replace:j},{search:/albedoTexture\.rgb;/g,replace:"vec3(1.);\r\ngl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r\n"}]});for(var ie=0,ne=this._outputs;ie("+this._options.remappedVariables.join(",")+")":ai.a.IncludesShadersStore.shadowMapVertexNormalBias,u=this._options&&this._options.remappedVariables?"#include("+this._options.remappedVariables.join(",")+")":ai.a.IncludesShadersStore.shadowMapVertexMetric,h=this._options&&this._options.remappedVariables?"#include("+this._options.remappedVariables.join(",")+")":ai.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow,d=ai.a.IncludesShadersStore.shadowMapFragment;s=(s=-1!==(s=(s=s.replace(/void\s+?main/g,ai.a.IncludesShadersStore.shadowMapVertexDeclaration+"\r\nvoid main")).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g,l)).indexOf("#define SHADOWDEPTH_METRIC")?s.replace(/#define SHADOWDEPTH_METRIC/g,u):s.replace(/}\s*$/g,u+"\r\n}")).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var f=c.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW")>=0||c.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG")>=0,p=-1!==c.indexOf("#define SHADOWDEPTH_FRAGMENT"),_="";f?c=c.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g,h):_=h+"\r\n",c=c.replace(/void\s+?main/g,ai.a.IncludesShadersStore.shadowMapFragmentDeclaration+"\r\nvoid main"),p?c=c.replace(/#define SHADOWDEPTH_FRAGMENT/g,d):_+=d+"\r\n",_&&(c=c.replace(/}\s*$/g,_+"}")),c=c.replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var m=r.getUniformNames().slice();return m.push("biasAndScaleSM","depthValuesSM","lightDataSM","softTransparentShadowSM"),o.depthEffect=this._scene.getEngine().createEffect({vertexSource:s,fragmentSource:c,vertexToken:o.token,fragmentToken:o.token},{attributes:r.getAttributesNames(),uniformsNames:m,uniformBuffersNames:r.getUniformBuffersNames(),samplers:r.getSamplers(),defines:a+"\n"+r.defines.replace("#define SHADOWS","").replace(/#define SHADOW\d/g,""),indexParameters:r.getIndexParameters()},this._scene.getEngine()),o.depthEffect},e}(),dh=i(101);function fh(e,t,i,n,r){var o=new e.DecoderBuffer;o.Init(t,t.byteLength);var a,s,c=new e.Decoder;try{var l=c.GetEncodedGeometryType(o);switch(l){case e.TRIANGULAR_MESH:a=new e.Mesh,s=c.DecodeBufferToMesh(o,a);break;case e.POINT_CLOUD:a=new e.PointCloud,s=c.DecodeBufferToPointCloud(o,a);break;default:throw new Error("Invalid geometry type "+l)}if(!s.ok()||!a.ptr)throw new Error(s.error_msg());if(l===e.TRIANGULAR_MESH){var u=3*a.num_faces(),h=4*u,d=e._malloc(h);try{c.GetTrianglesUInt32Array(a,h,d);var f=new Uint32Array(u);f.set(new Uint32Array(e.HEAPF32.buffer,d,u)),n(f)}finally{e._free(d)}}var p=function(t,i){var n=i.num_components(),o=a.num_points(),s=o*n,l=s*Float32Array.BYTES_PER_ELEMENT,u=e._malloc(l);try{c.GetAttributeDataArrayForAllPoints(a,i,e.DT_FLOAT32,l,u);var h=new Float32Array(e.HEAPF32.buffer,u,s);if("color"===t&&3===n){for(var d=new Float32Array(4*o),f=0,p=0;fe.EPSILON?1:0;l|=h,u.push(h)}switch(l){case 0:(a.e.Dot(this.normal,t.plane.normal)>0?i:n).push(t);break;case 1:r.push(t);break;case 2:o.push(t);break;case 3:var d,f=[],p=[];for(s=0;s=3&&(d=new Th(f,t.shared)).plane&&r.push(d),p.length>=3&&(d=new Th(p,t.shared)).plane&&o.push(d)}},e.EPSILON=1e-5,e}(),Th=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=yh.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}(),Eh=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,c=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE;t.push(0,0,0),r.push(.5,.5);for(var l=2*Math.PI*s,u=1===s?l/a:l/(a-1),h=0,d=0;dt.x&&(t.x=i.x),i.yt.y&&(t.y=i.y)})),{min:e,max:t,width:t.x-e.x,height:t.y-e.y}},e}(),Nh=function(){function e(){}return e.Rectangle=function(e,t,i,n){return[new a.d(e,t),new a.d(i,t),new a.d(i,n),new a.d(e,n)]},e.Circle=function(e,t,i,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=32);for(var r=new Array,o=0,s=2*Math.PI/n,c=0;c0){var u=r.length/3;this._points.elements.forEach((function(t){n.push(0,-1,0),r.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 h=s.length;for(l=0;lo.elements.length-1?o.elements[0]:o.elements[h+1],e.push(f.x,0,f.y),e.push(f.x,-s,f.y),e.push(d.x,0,d.y),e.push(d.x,-s,d.y);var p=new a.e(f.x,0,f.y),_=new a.e(d.x,0,d.y).subtract(p),m=new a.e(0,1,0),g=a.e.Cross(_,m);g=g.normalize(),i.push(u/r.width,0),i.push(u/r.width,1),u+=_.length(),i.push(u/r.width,0),i.push(u/r.width,1),c?(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),n.push(l),n.push(l+2),n.push(l+1),n.push(l+1),n.push(l+2),n.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),n.push(l),n.push(l+1),n.push(l+2),n.push(l+1),n.push(l+3),n.push(l+2)),l+=4}},e}();Ki.a.CreatePolygon=function(e,t,i,n,r,o,c){for(var l=i||new Array(3),u=n,h=[],d=c||!1,f=0;f<3;f++)void 0===l[f]&&(l[f]=new a.f(0,0,1,1)),u&&void 0===u[f]&&(u[f]=new s.b(1,1,1,1));var p=e.getVerticesData(Qi.b.PositionKind),_=e.getVerticesData(Qi.b.NormalKind),m=e.getVerticesData(Qi.b.UVKind),g=e.getIndices(),v=p.length/9,b=0,y=0,T=0,E=0,S=[0];if(d)for(var A=v;A1?1:t.arc:1,o=void 0===t.closed||t.closed,s=t.shape,c=t.radius||1,l=t.tessellation||64,u=t.clip||0,h=t.updatable,d=be.a._GetDefaultSideOrientation(t.sideOrientation),f=t.cap||be.a.NO_CAP,p=2*Math.PI,_=new Array,m=t.invertUV||!1,g=0,v=0,b=p/l*r,y=new Array;for(g=0;g<=l-u;g++){y=[];for(f!=be.a.CAP_START&&f!=be.a.CAP_ALL||(y.push(new a.e(0,s[0].y,0)),y.push(new a.e(Math.cos(g*b)*s[0].x*c,s[0].y,Math.sin(g*b)*s[0].x*c))),v=0;v0||h>0){m=-d,g=-f;v=d,b=f;switch(r){case be.a.CENTER:m-=c/=2,v+=c;break;case be.a.LEFT:v+=c,p=-c/2;break;case be.a.RIGHT:m-=c,p=c/2}switch(o){case be.a.CENTER:g-=h/=2,b+=h;break;case be.a.BOTTOM:b+=h,_=-h/2;break;case be.a.TOP:g-=h,_=h/2}}var y=[],T=[],E=[];E[0]=[0,0,1,0,1,1,0,1],E[1]=[0,0,1,0,1,1,0,1],t!==be.a.ROTATE_TILE&&t!==be.a.ROTATE_ROW||(E[1]=[1,1,0,1,0,0,1,0]),t!==be.a.FLIP_TILE&&t!==be.a.FLIP_ROW||(E[1]=[1,0,0,0,0,1,1,1]),t!==be.a.FLIP_N_ROTATE_TILE&&t!==be.a.FLIP_N_ROTATE_ROW||(E[1]=[0,1,1,1,1,0,0,0]);for(var S=[],A=[],P=[],C=0,R=0;R0||h>0){var O,M,I,D,N=h>0&&(o===be.a.CENTER||o===be.a.TOP),L=h>0&&(o===be.a.CENTER||o===be.a.BOTTOM),w=c>0&&(r===be.a.CENTER||r===be.a.RIGHT),F=c>0&&(r===be.a.CENTER||r===be.a.LEFT),B=[];if(N&&w&&(y.push(m+p,g+_,0),y.push(-d+p,g+_,0),y.push(-d+p,g+h+_,0),y.push(m+p,g+h+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=1-c/i,M=1-h/n,I=1,M,I,D=1,O,D],t===be.a.ROTATE_ROW&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t===be.a.FLIP_ROW&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),t===be.a.FLIP_N_ROTATE_ROW&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),N&&F&&(y.push(d+p,g+_,0),y.push(v+p,g+_,0),y.push(v+p,g+h+_,0),y.push(d+p,g+h+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=0,M=1-h/n,I=c/i,M,I,D=1,O,D],(t===be.a.ROTATE_ROW||t===be.a.ROTATE_TILE&&s%2==0)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===be.a.FLIP_ROW||t===be.a.FLIP_TILE&&s%2==0)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===be.a.FLIP_N_ROTATE_ROW||t===be.a.FLIP_N_ROTATE_TILE&&s%2==0)&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L&&w&&(y.push(m+p,f+_,0),y.push(-d+p,f+_,0),y.push(-d+p,b+_,0),y.push(m+p,b+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=1-c/i,M=0,I=1,M,I,D=h/n,O,D],(t===be.a.ROTATE_ROW&&u%2==1||t===be.a.ROTATE_TILE&&u%1==0)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===be.a.FLIP_ROW&&u%2==1||t===be.a.FLIP_TILE&&u%2==0)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===be.a.FLIP_N_ROTATE_ROW&&u%2==1||t===be.a.FLIP_N_ROTATE_TILE&&u%2==0)&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L&&F&&(y.push(d+p,f+_,0),y.push(v+p,f+_,0),y.push(v+p,b+_,0),y.push(d+p,b+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=0,M=0,I=c/i,M,I,D=h/n,O,D],(t===be.a.ROTATE_ROW&&u%2==1||t===be.a.ROTATE_TILE&&(u+s)%2==1)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===be.a.FLIP_ROW&&u%2==1||t===be.a.FLIP_TILE&&(u+s)%2==1)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===be.a.FLIP_N_ROTATE_ROW&&u%2==1||t===be.a.FLIP_N_ROTATE_TILE&&(u+s)%2==1)&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),N){var U=[];O=0,M=1-h/n,I=1,D=1,U[0]=[O,M,I,M,I,D,O,D],U[1]=[O,M,I,M,I,D,O,D],t!==be.a.ROTATE_TILE&&t!==be.a.ROTATE_ROW||(U[1]=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t!==be.a.FLIP_TILE&&t!==be.a.FLIP_ROW||(U[1]=[1-O,M,1-I,M,1-I,D,1-O,D]),t!==be.a.FLIP_N_ROTATE_TILE&&t!==be.a.FLIP_N_ROTATE_ROW||(U[1]=[O,1-M,I,1-M,I,1-D,O,1-D]);for(x=0;x1)?1:t.arc||1;var f,p,_=function(e,t,i,n,r,o,s,c){for(var l,u,h,d,f=t.getTangents(),p=t.getNormals(),_=t.getDistances(),m=2*Math.PI/r*c,g=o||function(){return n},v=a.c.Matrix[0],b=s===be.a.NO_CAP||s===be.a.CAP_END?0:2,y=0;y3?0:l,t.arc);var v=Rh.a.CreateRibbon(e,{pathArray:p,closePath:!0,closeArray:!1,updatable:h,sideOrientation:d,invertUV:u,frontUVs:t.frontUVs,backUVs:t.backUVs},i);return v._creationDataStorage.pathArray=p,v._creationDataStorage.path3D=f,v._creationDataStorage.tessellation=s,v._creationDataStorage.cap=l,v._creationDataStorage.arc=t.arc,v._creationDataStorage.radius=o,v},e}();Ki.a.CreateIcoSphere=function(e){var t,i=e.sideOrientation||Ki.a.DEFAULTSIDE,n=e.radius||1,r=void 0===e.flat||e.flat,o=e.subdivisions||4,s=e.radiusX||n,c=e.radiusY||n,l=e.radiusZ||n,u=(1+Math.sqrt(5))/2,h=[-1,u,-0,1,u,0,-1,-u,0,1,-u,0,0,-1,-u,0,1,-u,0,-1,u,0,1,u,u,0,1,u,0,-1,-u,0,1,-u,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],f=[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],_=[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,v=new Array,b=new Array,y=0,T=new Array(3),E=new Array(3);for(t=0;t<3;t++)T[t]=a.e.Zero(),E[t]=a.d.Zero();for(var S=0;S<20;S++){for(t=0;t<3;t++){var A=d[3*S+t];T[t].copyFromFloats(h[3*f[A]],h[3*f[A]+1],h[3*f[A]+2]),T[t].normalize().scaleInPlace(n),E[t].copyFromFloats(p[2*A]*(138/1024)+60/1024+_[S]*(-40/1024),p[2*A+1]*(239/1024)+26/1024+_[S]*(20/1024))}for(var P=function(e,t,i,n){var u,h=a.e.Lerp(T[0],T[2],t/o),d=a.e.Lerp(T[1],T[2],t/o),f=o===t?T[2]:a.e.Lerp(h,d,e/(o-t));if(f.normalize(),r){var p=a.e.Lerp(T[0],T[2],n/o),_=a.e.Lerp(T[1],T[2],n/o);u=a.e.Lerp(p,_,i/(o-n))}else u=new a.e(f.x,f.y,f.z);u.x/=s,u.y/=c,u.z/=l,u.normalize();var S=a.d.Lerp(E[0],E[2],t/o),A=a.d.Lerp(E[1],E[2],t/o),P=o===t?E[2]:a.d.Lerp(S,A,e/(o-t));g.push(f.x*s,f.y*c,f.z*l),v.push(u.x,u.y,u.z),b.push(P.x,P.y),m.push(y),y++},C=0;C0)?1:0)+((c=a.e.Dot(e[o+1].position,t)-i>0)?1:0)+((u=a.e.Dot(e[o+2].position,t)-i>0)?1:0)){case 0:r.push(e[o]),r.push(e[o+1]),r.push(e[o+2]);break;case 1:if(s&&(h=e[o+1],d=e[o+2],f=n(e[o],h),p=n(e[o],d)),c){h=e[o],d=e[o+2],f=n(e[o+1],h),p=n(e[o+1],d),r.push(f),r.push(d.clone()),r.push(h.clone()),r.push(d.clone()),r.push(f.clone()),r.push(p);break}u&&(h=e[o],d=e[o+1],f=n(e[o+2],h),p=n(e[o+2],d)),h&&d&&f&&p&&(r.push(h.clone()),r.push(d.clone()),r.push(f),r.push(p),r.push(f.clone()),r.push(d.clone()));break;case 2:s||(d=n(h=e[o].clone(),e[o+1]),f=n(h,e[o+2]),r.push(h),r.push(d),r.push(f)),c||(d=n(h=e[o+1].clone(),e[o+2]),f=n(h,e[o]),r.push(h),r.push(d),r.push(f)),u||(d=n(h=e[o+2].clone(),e[o]),f=n(h,e[o+1]),r.push(h),r.push(d),r.push(f))}}return r},A=0;Ac||i.deleted||i.isDirty))for(var r=0;r<3;++r)if(i.error[r]>0,(function(e){if(r){var t=e+s.verticesStart,o=a.e.FromArray(r,3*t),l=function(e){if(i)for(var t=0;t0&&this._reconstructedMesh.setVerticesData(Qi.b.NormalKind,a),s.length>0&&this._reconstructedMesh.setVerticesData(Qi.b.UVKind,s),c.length>0&&this._reconstructedMesh.setVerticesData(Qi.b.ColorKind,c);var b=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],m.forEach((function(e){gh.a.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),gh.a.AddToMesh(b.materialIndex,_,d,p,3*r.length,this._reconstructedMesh))},e.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new be.a(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},e.prototype.isFlipped=function(e,t,i,n,r){for(var o=0;o.999)return!0;var f=a.e.Cross(h,d).normalize();if(n[o]=!1,a.e.Dot(f,s.normal)<.2)return!0}else n[o]=!0,r.push(s)}}return!1},e.prototype.updateTriangles=function(e,t,i,n){for(var r=n,o=0;o=this._thinInstanceDataStorage.instancesCount)return!1;var n=this._thinInstanceDataStorage.matrixData;return t.copyToArray(n,16*e),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[e]=t),i&&(this.thinInstanceBufferUpdated("matrix"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0},be.a.prototype.thinInstanceSetAttributeAt=function(e,t,i,n){return void 0===n&&(n=!0),!(!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.data[e]||t>=this._thinInstanceDataStorage.instancesCount)&&(this._thinInstanceUpdateBufferSize(e,0),this._userThinInstanceBuffersStorage.data[e].set(i,t*this._userThinInstanceBuffersStorage.strides[e]),n&&this.thinInstanceBufferUpdated(e),!0)},Object.defineProperty(be.a.prototype,"thinInstanceCount",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(e){var t,i;e<=(null!==(i=null===(t=this._thinInstanceDataStorage.matrixData)||void 0===t?void 0:t.length)&&void 0!==i?i:0)/16&&(this._thinInstanceDataStorage.instancesCount=e)},enumerable:!0,configurable:!0}),be.a.prototype.thinInstanceSetBuffer=function(e,t,i,n){var r,o;if(void 0===i&&(i=0),void 0===n&&(n=!1),i=i||16,"matrix"===e)if(null===(r=this._thinInstanceDataStorage.matrixBuffer)||void 0===r||r.dispose(),this._thinInstanceDataStorage.matrixBuffer=null,this._thinInstanceDataStorage.matrixBufferSize=t?t.length:32*i,this._thinInstanceDataStorage.matrixData=t,this._thinInstanceDataStorage.worldMatrices=null,null!==t){this._thinInstanceDataStorage.instancesCount=t.length/i;var a=new Qi.a(this.getEngine(),t,!n,i,!1,!0);this._thinInstanceDataStorage.matrixBuffer=a,this.setVerticesBuffer(a.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(a.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(a.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(a.createVertexBuffer("world3",12,4)),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)}else this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo(!0);else null===t?(null===(o=this._userThinInstanceBuffersStorage)||void 0===o?void 0:o.data[e])&&(this.removeVerticesData(e),delete this._userThinInstanceBuffersStorage.data[e],delete this._userThinInstanceBuffersStorage.strides[e],delete this._userThinInstanceBuffersStorage.sizes[e],delete this._userThinInstanceBuffersStorage.vertexBuffers[e]):(this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.data[e]=t,this._userThinInstanceBuffersStorage.strides[e]=i,this._userThinInstanceBuffersStorage.sizes[e]=t.length,this._userThinInstanceBuffersStorage.vertexBuffers[e]=new Qi.b(this.getEngine(),t,e,!n,!1,i,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e]))},be.a.prototype.thinInstanceBufferUpdated=function(e){var t;"matrix"===e?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount):(null===(t=this._userThinInstanceBuffersStorage)||void 0===t?void 0:t.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e],0)},be.a.prototype.thinInstancePartialBufferUpdate=function(e,t,i){var n;"matrix"===e?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t,i):(null===(n=this._userThinInstanceBuffersStorage)||void 0===n?void 0:n.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t,i)},be.a.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];var e=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=new Array;for(var t=0;t-1&&(this.agents.splice(t,1),this.transforms.splice(t,1))},e.prototype.getAgents=function(){return this.agents},e.prototype.update=function(e){var t=this.bjsRECASTPlugin.getTimeStep(),i=this.bjsRECASTPlugin.getMaximumSubStepCount();if(t<=Nt.a)this.recastCrowd.update(e);else{var n=e/t;i&&n>i&&(n=i),n<1&&(n=1);for(var r=0;r=400&&o?o(l):i()}),!1),l.addEventListener("error",(function(){m.a.Error("error on XHR request."),i()}),!1),l.send()}else m.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),i()},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 i=Uc.GetTGAHeader(e.response);if(i.width&&i.height&&i.width>0&&i.height>0)return!0;if(2===t)return!1}if(4&t){var n=new Uint8Array(e.response,0,3);return 68===n[0]&&68===n[1]&&83===n[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("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},e._ReturnFullUrlLocation=function(t){return-1===t.indexOf("http:/")&&-1===t.indexOf("https:/")&&"undefined"!=typeof window?e._ParseURL(window.location.href)+t:t},e}(),rd=function(){function e(e,t,i){this.gradient=e,this.color1=t,this.color2=i}return e.prototype.getColorToRef=function(e){this.color2?s.b.LerpToRef(this.color1,this.color2,Math.random(),e):e.copyFrom(this.color1)},e}(),od=function(e,t){this.gradient=e,this.color=t},ad=function(){function e(e,t,i){this.gradient=e,this.factor1=t,this.factor2=i}return e.prototype.getFactor=function(){return void 0===this.factor2||this.factor2===this.factor1?this.factor1:this.factor1+(this.factor2-this.factor1)*Math.random()},e}(),sd=function(){function e(){}return e.GetCurrentGradient=function(e,t,i){if(t[0].gradient>e)i(t[0],t[0],1);else{for(var n=0;n=r.gradient&&e<=o.gradient)return void i(r,o,(e-r.gradient)/(o.gradient-r.gradient))}var a=t.length-1;i(t[a],t[a],1)}},e}(),cd=function(){function e(t){this.particleSystem=t,this.position=a.e.Zero(),this.direction=a.e.Zero(),this.color=new s.b(0,0,0,0),this.colorStep=new s.b(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new a.d(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new s.b(0,0,0,0),this._currentColor2=new s.b(0,0,0,0),this._currentSize1=0,this._currentSize2=0,this._currentAngularSpeed1=0,this._currentAngularSpeed2=0,this._currentVelocity1=0,this._currentVelocity2=0,this._currentLimitVelocity1=0,this._currentLimitVelocity2=0,this._currentDrag1=0,this._currentDrag2=0,this.id=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 i=this._initialEndSpriteCellID-this._initialStartSpriteCellID,n=L.a.Clamp(e*t%this.lifeTime/this.lifeTime);this.cellIndex=this._initialStartSpriteCellID+n*i|0},e.prototype._inheritParticleInfoToSubEmitter=function(e){if(e.particleSystem.emitter.position){var t=e.particleSystem.emitter;if(t.position.copyFrom(this.position),e.inheritDirection){var i=a.c.Vector3[0];this.direction.normalizeToRef(i),t.setDirection(i,0,Math.PI/2)}}else{e.particleSystem.emitter.copyFrom(this.position)}this.direction.scaleToRef(e.inheritedVelocityAmount/2,a.c.Vector3[0]),e.particleSystem._inheritedVelocityOffset.copyFrom(a.c.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&&this.remapData?e.remapData.copyFrom(this.remapData):e.remapData=new a.f(0,0,0,0)),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"}(id||(id={}));var ld=function(){function e(e){if(this.particleSystem=e,this.type=id.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,!e.emitter||!e.emitter.dispose){var t=c.a.GetClass("BABYLON.AbstractMesh");e.emitter=new t("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;if(t){if(t instanceof a.e)t=t.clone();else if(-1!==t.getClassName().indexOf("Mesh")){(t=new(c.a.GetClass("BABYLON.Mesh"))("",t.getScene())).isVisible=!1}}else t=new a.e;var i=new e(this.particleSystem.clone("",t));return i.particleSystem.name+="Clone",i.type=this.type,i.inheritDirection=this.inheritDirection,i.inheritedVelocityAmount=this.inheritedVelocityAmount,i.particleSystem._disposeEmitterOnDispose=!0,i.particleSystem.disposeOnStop=!0,i},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,i){throw Re.a.WarnImport("ParseParticle")},e.Parse=function(t,i,n){var r=t.particleSystem,o=new e(e._ParseParticleSystem(r,i,n));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}(),ud="\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}";ai.a.ShadersStore.particlesPixelShader=ud;var hd="\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;\nvarying vec3 vPositionW;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\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.;\nvPositionW=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(vPositionW,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;\nvPositionW=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(vPositionW,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;\nvPositionW=(invView*vec4(viewPos,1)).xyz;\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);\nvPositionW=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(vPositionW,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=vec4(vPositionW,1.0);\n#endif\n#include\n}";ai.a.ShadersStore.particlesVertexShader=hd;var dd=function(e){function t(t,i,n,r,c,l){void 0===r&&(r=null),void 0===c&&(c=!1),void 0===l&&(l=.01);var u=e.call(this,t)||this;return u._inheritedVelocityOffset=new a.e,u.onDisposeObservable=new o.c,u.onStoppedObservable=new o.c,u._particles=new Array,u._stockParticles=new Array,u._newPartsExcess=0,u._vertexBuffers={},u._scaledColorStep=new s.b(0,0,0,0),u._colorDiff=new s.b(0,0,0,0),u._scaledDirection=a.e.Zero(),u._scaledGravity=a.e.Zero(),u._currentRenderId=-1,u._useInstancing=!1,u._started=!1,u._stopped=!1,u._actualFrame=0,u._currentEmitRate1=0,u._currentEmitRate2=0,u._currentStartSize1=0,u._currentStartSize2=0,u._rawTextureWidth=256,u._useRampGradients=!1,u._disposeEmitterOnDispose=!1,u.isLocal=!1,u._onBeforeDrawParticlesObservable=null,u.recycleParticle=function(e){var t=u._particles.pop();t!==e&&t.copyTo(e),u._stockParticles.push(t)},u._createParticle=function(){var e;if(0!==u._stockParticles.length?(e=u._stockParticles.pop())._reset():e=new cd(u),u._subEmitters&&u._subEmitters.length>0){var t=u._subEmitters[Math.floor(Math.random()*u._subEmitters.length)];e._attachedSubEmitters=[],t.forEach((function(t){if(t.type===id.ATTACHED){var i=t.clone();e._attachedSubEmitters.push(i),i.particleSystem.start()}}))}return e},u._emitFromParticle=function(e){if(u._subEmitters&&0!==u._subEmitters.length){var t=Math.floor(Math.random()*u._subEmitters.length);u._subEmitters[t].forEach((function(t){if(t.type===id.END){var i=t.clone();e._inheritParticleInfoToSubEmitter(i),i.particleSystem._rootParticleSystem=u,u.activeSubSystems.push(i.particleSystem),i.particleSystem.start()}}))}},u._capacity=i,u._epsilon=l,u._isAnimationSheetEnabled=c,n&&"Scene"!==n.getClassName()?(u._engine=n,u.defaultProjectionMatrix=a.a.PerspectiveFovLH(.8,1,.1,100)):(u._scene=n||x.a.LastCreatedScene,u._engine=u._scene.getEngine(),u.uniqueId=u._scene.getUniqueId(),u._scene.particleSystems.push(u)),u._engine.getCaps().vertexArrayObject&&(u._vertexArrayObject=null),u._attachImageProcessingConfiguration(null),u._customEffect={0:r},u._useInstancing=u._engine.getCaps().instancedArrays,u._createIndexBuffer(),u._createVertexBuffers(),u.particleEmitterType=new Nl,u.updateFunction=function(e){var t=null,i=null;u.noiseTexture&&(t=u.noiseTexture.getSize(),i=u.noiseTexture.getContent());for(var n,r=function(){n=e[o];var r=u._scaledUpdateSpeed,c=n.age;if(n.age+=r,n.age>n.lifeTime){var l=n.age-c;r=(n.lifeTime-c)*r/l,n.age=n.lifeTime}var h=n.age/n.lifeTime;u._colorGradients&&u._colorGradients.length>0?sd.GetCurrentGradient(h,u._colorGradients,(function(e,t,i){e!==n._currentColorGradient&&(n._currentColor1.copyFrom(n._currentColor2),t.getColorToRef(n._currentColor2),n._currentColorGradient=e),s.b.LerpToRef(n._currentColor1,n._currentColor2,i,n.color)})):(n.colorStep.scaleToRef(r,u._scaledColorStep),n.color.addInPlace(u._scaledColorStep),n.color.a<0&&(n.color.a=0)),u._angularSpeedGradients&&u._angularSpeedGradients.length>0&&sd.GetCurrentGradient(h,u._angularSpeedGradients,(function(e,t,i){e!==n._currentAngularSpeedGradient&&(n._currentAngularSpeed1=n._currentAngularSpeed2,n._currentAngularSpeed2=t.getFactor(),n._currentAngularSpeedGradient=e),n.angularSpeed=L.a.Lerp(n._currentAngularSpeed1,n._currentAngularSpeed2,i)})),n.angle+=n.angularSpeed*r;var d=r;if(u._velocityGradients&&u._velocityGradients.length>0&&sd.GetCurrentGradient(h,u._velocityGradients,(function(e,t,i){e!==n._currentVelocityGradient&&(n._currentVelocity1=n._currentVelocity2,n._currentVelocity2=t.getFactor(),n._currentVelocityGradient=e),d*=L.a.Lerp(n._currentVelocity1,n._currentVelocity2,i)})),n.direction.scaleToRef(d,u._scaledDirection),u._limitVelocityGradients&&u._limitVelocityGradients.length>0&&sd.GetCurrentGradient(h,u._limitVelocityGradients,(function(e,t,i){e!==n._currentLimitVelocityGradient&&(n._currentLimitVelocity1=n._currentLimitVelocity2,n._currentLimitVelocity2=t.getFactor(),n._currentLimitVelocityGradient=e);var r=L.a.Lerp(n._currentLimitVelocity1,n._currentLimitVelocity2,i);n.direction.length()>r&&n.direction.scaleInPlace(u.limitVelocityDamping)})),u._dragGradients&&u._dragGradients.length>0&&sd.GetCurrentGradient(h,u._dragGradients,(function(e,t,i){e!==n._currentDragGradient&&(n._currentDrag1=n._currentDrag2,n._currentDrag2=t.getFactor(),n._currentDragGradient=e);var r=L.a.Lerp(n._currentDrag1,n._currentDrag2,i);u._scaledDirection.scaleInPlace(1-r)})),u.isLocal&&n._localPosition?(n._localPosition.addInPlace(u._scaledDirection),a.e.TransformCoordinatesToRef(n._localPosition,u._emitterWorldMatrix,n.position)):n.position.addInPlace(u._scaledDirection),i&&t&&n._randomNoiseCoordinates1){var f=u._fetchR(n._randomNoiseCoordinates1.x,n._randomNoiseCoordinates1.y,t.width,t.height,i),p=u._fetchR(n._randomNoiseCoordinates1.z,n._randomNoiseCoordinates2.x,t.width,t.height,i),_=u._fetchR(n._randomNoiseCoordinates2.y,n._randomNoiseCoordinates2.z,t.width,t.height,i),m=a.c.Vector3[0],g=a.c.Vector3[1];m.copyFromFloats((2*f-1)*u.noiseStrength.x,(2*p-1)*u.noiseStrength.y,(2*_-1)*u.noiseStrength.z),m.scaleToRef(r,g),n.direction.addInPlace(g)}if(u.gravity.scaleToRef(r,u._scaledGravity),n.direction.addInPlace(u._scaledGravity),u._sizeGradients&&u._sizeGradients.length>0&&sd.GetCurrentGradient(h,u._sizeGradients,(function(e,t,i){e!==n._currentSizeGradient&&(n._currentSize1=n._currentSize2,n._currentSize2=t.getFactor(),n._currentSizeGradient=e),n.size=L.a.Lerp(n._currentSize1,n._currentSize2,i)})),u._useRampGradients&&(u._colorRemapGradients&&u._colorRemapGradients.length>0&&sd.GetCurrentGradient(h,u._colorRemapGradients,(function(e,t,i){var r=L.a.Lerp(e.factor1,t.factor1,i),o=L.a.Lerp(e.factor2,t.factor2,i);n.remapData.x=r,n.remapData.y=o-r})),u._alphaRemapGradients&&u._alphaRemapGradients.length>0&&sd.GetCurrentGradient(h,u._alphaRemapGradients,(function(e,t,i){var r=L.a.Lerp(e.factor1,t.factor1,i),o=L.a.Lerp(e.factor2,t.factor2,i);n.remapData.z=r,n.remapData.w=o-r}))),u._isAnimationSheetEnabled&&n.updateCellIndex(),n._inheritParticleInfoToSubEmitters(),n.age>=n.lifeTime)return u._emitFromParticle(n),n._attachedSubEmitters&&(n._attachedSubEmitters.forEach((function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()})),n._attachedSubEmitters=null),u.recycleParticle(n),o--,"continue"},o=0;ot.gradient?1:0}))},t.prototype._removeFactorGradient=function(e,t){if(e)for(var i=0,n=0,r=e;nt.gradient?1:0})),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture())},t.prototype.addRampGradient=function(e,t){this._rampGradients||(this._rampGradients=[]);var i=new od(e,t);return this._rampGradients.push(i),this._syncRampGradientTexture(),this},t.prototype.removeRampGradient=function(e){return this._removeGradientAndTexture(e,this._rampGradients,this._rampGradientsTexture),this._rampGradientsTexture=null,this._rampGradients&&this._rampGradients.length>0&&this._createRampGradientTexture(),this},t.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var n=new rd(e,t,i);return this._colorGradients.push(n),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,i=0,n=this._colorGradients;i0&&(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){-1!==(null===(t=this.emitter)||void 0===t?void 0:t.getClassName().indexOf("Mesh"))&&this.emitter.computeWorldMatrix(!0);var n=this.noiseTexture;if(n&&n.onGeneratedObservable)n.onGeneratedObservable.addOnce((function(){setTimeout((function(){for(var e=0;e0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped||(this.onStoppedObservable.notifyObservers(this),this._stopped=!0,e&&this._stopSubEmitters())},t.prototype.reset=function(){this._stockParticles=[],this._particles=[]},t.prototype._appendParticleVertex=function(e,i,n,r){var o=e*this._vertexBufferSize;if(this._vertexData[o++]=i.position.x+this.worldOffset.x,this._vertexData[o++]=i.position.y+this.worldOffset.y,this._vertexData[o++]=i.position.z+this.worldOffset.z,this._vertexData[o++]=i.color.r,this._vertexData[o++]=i.color.g,this._vertexData[o++]=i.color.b,this._vertexData[o++]=i.color.a,this._vertexData[o++]=i.angle,this._vertexData[o++]=i.scale.x*i.size,this._vertexData[o++]=i.scale.y*i.size,this._isAnimationSheetEnabled&&(this._vertexData[o++]=i.cellIndex),this._isBillboardBased)this.billboardMode===t.BILLBOARDMODE_STRETCHED&&(this._vertexData[o++]=i.direction.x,this._vertexData[o++]=i.direction.y,this._vertexData[o++]=i.direction.z);else if(i._initialDirection){var s=i._initialDirection;this.isLocal&&(a.e.TransformNormalToRef(s,this._emitterWorldMatrix,a.c.Vector3[0]),s=a.c.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}else{var c=i.direction;this.isLocal&&(a.e.TransformNormalToRef(c,this._emitterWorldMatrix,a.c.Vector3[0]),c=a.c.Vector3[0]),0===c.x&&0===c.z&&(c.x=.001),this._vertexData[o++]=c.x,this._vertexData[o++]=c.y,this._vertexData[o++]=c.z}this._useRampGradients&&i.remapData&&(this._vertexData[o++]=i.remapData.x,this._vertexData[o++]=i.remapData.y,this._vertexData[o++]=i.remapData.z,this._vertexData[o++]=i.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(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++]=n,this._vertexData[o++]=r)},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,i=this;if(this._alive=this._particles.length>0,this.emitter.position){var n=this.emitter;this._emitterWorldMatrix=n.getWorldMatrix()}else{var r=this.emitter;this._emitterWorldMatrix=a.a.Translation(r.x,r.y,r.z)}this.updateFunction(this._particles);for(var o,c=function(){if(l._particles.length===l._capacity)return"break";if(t=l._createParticle(),l._particles.push(t),l.targetStopDuration&&l._lifeTimeGradients&&l._lifeTimeGradients.length>0){var e=L.a.Clamp(l._actualFrame/l.targetStopDuration);sd.GetCurrentGradient(e,l._lifeTimeGradients,(function(i,n){var r=i,o=n,a=r.getFactor(),s=o.getFactor(),c=(e-r.gradient)/(o.gradient-r.gradient);t.lifeTime=L.a.Lerp(a,s,c)}))}else t.lifeTime=L.a.RandomRange(l.minLifeTime,l.maxLifeTime);var n=L.a.RandomRange(l.minEmitPower,l.maxEmitPower);if(l.startPositionFunction?l.startPositionFunction(l._emitterWorldMatrix,t.position,t,l.isLocal):l.particleEmitterType.startPositionFunction(l._emitterWorldMatrix,t.position,t,l.isLocal),l.isLocal&&(t._localPosition?t._localPosition.copyFrom(t.position):t._localPosition=t.position.clone(),a.e.TransformCoordinatesToRef(t._localPosition,l._emitterWorldMatrix,t.position)),l.startDirectionFunction?l.startDirectionFunction(l._emitterWorldMatrix,t.direction,t,l.isLocal):l.particleEmitterType.startDirectionFunction(l._emitterWorldMatrix,t.direction,t,l.isLocal),0===n?t._initialDirection?t._initialDirection.copyFrom(t.direction):t._initialDirection=t.direction.clone():t._initialDirection=null,t.direction.scaleInPlace(n),l._sizeGradients&&0!==l._sizeGradients.length?(t._currentSizeGradient=l._sizeGradients[0],t._currentSize1=t._currentSizeGradient.getFactor(),t.size=t._currentSize1,l._sizeGradients.length>1?t._currentSize2=l._sizeGradients[1].getFactor():t._currentSize2=t._currentSize1):t.size=L.a.RandomRange(l.minSize,l.maxSize),t.scale.copyFromFloats(L.a.RandomRange(l.minScaleX,l.maxScaleX),L.a.RandomRange(l.minScaleY,l.maxScaleY)),l._startSizeGradients&&l._startSizeGradients[0]&&l.targetStopDuration){var r=l._actualFrame/l.targetStopDuration;sd.GetCurrentGradient(r,l._startSizeGradients,(function(e,n,r){e!==i._currentStartSizeGradient&&(i._currentStartSize1=i._currentStartSize2,i._currentStartSize2=n.getFactor(),i._currentStartSizeGradient=e);var o=L.a.Lerp(i._currentStartSize1,i._currentStartSize2,r);t.scale.scaleInPlace(o)}))}l._angularSpeedGradients&&0!==l._angularSpeedGradients.length?(t._currentAngularSpeedGradient=l._angularSpeedGradients[0],t.angularSpeed=t._currentAngularSpeedGradient.getFactor(),t._currentAngularSpeed1=t.angularSpeed,l._angularSpeedGradients.length>1?t._currentAngularSpeed2=l._angularSpeedGradients[1].getFactor():t._currentAngularSpeed2=t._currentAngularSpeed1):t.angularSpeed=L.a.RandomRange(l.minAngularSpeed,l.maxAngularSpeed),t.angle=L.a.RandomRange(l.minInitialRotation,l.maxInitialRotation),l._velocityGradients&&l._velocityGradients.length>0&&(t._currentVelocityGradient=l._velocityGradients[0],t._currentVelocity1=t._currentVelocityGradient.getFactor(),l._velocityGradients.length>1?t._currentVelocity2=l._velocityGradients[1].getFactor():t._currentVelocity2=t._currentVelocity1),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&(t._currentLimitVelocityGradient=l._limitVelocityGradients[0],t._currentLimitVelocity1=t._currentLimitVelocityGradient.getFactor(),l._limitVelocityGradients.length>1?t._currentLimitVelocity2=l._limitVelocityGradients[1].getFactor():t._currentLimitVelocity2=t._currentLimitVelocity1),l._dragGradients&&l._dragGradients.length>0&&(t._currentDragGradient=l._dragGradients[0],t._currentDrag1=t._currentDragGradient.getFactor(),l._dragGradients.length>1?t._currentDrag2=l._dragGradients[1].getFactor():t._currentDrag2=t._currentDrag1),l._colorGradients&&0!==l._colorGradients.length?(t._currentColorGradient=l._colorGradients[0],t._currentColorGradient.getColorToRef(t.color),t._currentColor1.copyFrom(t.color),l._colorGradients.length>1?l._colorGradients[1].getColorToRef(t._currentColor2):t._currentColor2.copyFrom(t.color)):(o=L.a.RandomRange(0,1),s.b.LerpToRef(l.color1,l.color2,o,t.color),l.colorDead.subtractToRef(t.color,l._colorDiff),l._colorDiff.scaleToRef(1/t.lifeTime,t.colorStep)),l._isAnimationSheetEnabled&&(t._initialStartSpriteCellID=l.startSpriteCellID,t._initialEndSpriteCellID=l.endSpriteCellID),t.direction.addInPlace(l._inheritedVelocityOffset),l._useRampGradients&&(t.remapData=new a.f(0,1,0,1)),l.noiseTexture&&(t._randomNoiseCoordinates1?(t._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(t._randomNoiseCoordinates1=new a.e(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2=new a.e(Math.random(),Math.random(),Math.random()))),t._inheritParticleInfoToSubEmitters()},l=this,u=0;u-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 o=this._actualFrame/this.targetStopDuration;sd.GetCurrentGradient(o,this._emitRateGradients,(function(e,t,n){e!==i._currentEmitRateGradient&&(i._currentEmitRate1=i._currentEmitRate2,i._currentEmitRate2=t.getFactor(),i._currentEmitRateGradient=e),r=L.a.Lerp(i._currentEmitRate1,i._currentEmitRate2,n)}))}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&&this._scene._toBeDisposed.push(this))),!e){for(var a=0,s=0;s=0&&(s.invertToRef(a.c.Matrix[0]),r.setMatrix("invView",a.c.Matrix[0])),void 0!==this._vertexArrayObject?(this._vertexArrayObject||(this._vertexArrayObject=this._engine.recordVertexArrayObject(this._vertexBuffers,this._indexBuffer,r)),this._engine.bindVertexArrayObject(this._vertexArrayObject,this._indexBuffer)):o.bindBuffers(this._vertexBuffers,this._indexBuffer,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(r),e){case t.BLENDMODE_ADD:o.setAlphaMode(g.a.ALPHA_ADD);break;case t.BLENDMODE_ONEONE:o.setAlphaMode(g.a.ALPHA_ONEONE);break;case t.BLENDMODE_STANDARD:o.setAlphaMode(g.a.ALPHA_COMBINE);break;case t.BLENDMODE_MULTIPLY:o.setAlphaMode(g.a.ALPHA_MULTIPLY)}return this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(r),this._useInstancing?o.drawArraysType(g.a.MATERIAL_TriangleFanDrawMode,0,4,this._particles.length):o.drawElementsType(g.a.MATERIAL_TriangleFillMode,0,6*this._particles.length),this._particles.length},t.prototype.render=function(){if(!this.isReady()||!this._particles.length)return 0;var e=this._engine;e.setState&&(e.setState(!1),this.forceDepthWrite&&e.setDepthWrite(!0));var i=0;return i=this.blendMode===t.BLENDMODE_MULTIPLYADD?this._render(t.BLENDMODE_MULTIPLY)+this._render(t.BLENDMODE_ADD):this._render(this.blendMode),this._engine.unbindInstanceAttributes(),this._engine.setAlphaMode(g.a.ALPHA_DISABLE),i},t.prototype.dispose=function(e){if(void 0===e&&(e=!0),this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._removeFromRoot(),this._subEmitters&&this._subEmitters.length){for(var t=0;t-1&&this._scene.particleSystems.splice(t,1),this._scene._activeParticleSystems.dispose());this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onStoppedObservable.clear(),this.reset()},t.prototype.clone=function(e,i){var n=Object(h.a)({},this._customEffect),r=null,o=this._engine;if(o.createEffectForParticles&&null!=this.customShader){var a=(r=this.customShader).shaderOptions.defines.length>0?r.shaderOptions.defines.join("\n"):"";n[0]=o.createEffectForParticles(r.shaderPath.fragmentElement,r.shaderOptions.uniforms,r.shaderOptions.samplers,a)}var s=this.serialize(),c=t.Parse(s,this._scene||this._engine,"");return c.name=e,c.customShader=r,c._customEffect=n,void 0===i&&(i=this.emitter),this.noiseTexture&&(c.noiseTexture=this.noiseTexture.clone()),c.emitter=i,this.preventAutoStart||c.start(),c},t.prototype.serialize=function(e){void 0===e&&(e=!1);var i={};if(t._Serialize(i,this,e),i.textureMask=this.textureMask.asArray(),i.customShader=this.customShader,i.preventAutoStart=this.preventAutoStart,this.subEmitters){i.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var n=0,r=this._subEmitters;n0?l.shaderOptions.defines.join("\n"):"";c=o.createEffectForParticles(l.shaderPath.fragmentElement,l.shaderOptions.uniforms,l.shaderOptions.samplers,u)}var h=new t(a,e.capacity,i,c,e.isAnimationSheetEnabled);if(h.customShader=l,e.id&&(h.id=e.id),e.subEmitters){h.subEmitters=[];for(var d=0,f=e.subEmitters;d1},enumerable:!1,configurable:!0}),t.prototype.getCapacity=function(){return this._capacity},Object.defineProperty(t.prototype,"activeParticleCount",{get:function(){return this._activeCount},set:function(e){this._activeCount=Math.min(e,this._capacity)},enumerable:!1,configurable:!0}),t.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&(!this._imageProcessingConfiguration||this._imageProcessingConfiguration.isReady())&&this._getEffect().isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.isStopped=function(){return this._stopped},t.prototype.isStopping=function(){return!1},t.prototype.getActiveCount=function(){return this._currentActiveCount},t.prototype.start=function(e){var 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._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){this._stopped||(this._stopped=!0)},t.prototype.reset=function(){this._releaseBuffers(),this._releaseVAOs(),this._currentActiveCount=0,this._targetIndex=0},t.prototype.getClassName=function(){return"GPUParticleSystem"},t.prototype.getCustomEffect=function(e){var t;return void 0===e&&(e=0),null!==(t=this._customEffect[e])&&void 0!==t?t:this._customEffect[0]},t.prototype.setCustomEffect=function(e,t){void 0===t&&(t=0),this._customEffect[t]=e},Object.defineProperty(t.prototype,"onBeforeDrawParticlesObservable",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new o.c),this._onBeforeDrawParticlesObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShaderName",{get:function(){return"gpuRenderParticles"},enumerable:!1,configurable:!0}),t.prototype._removeGradientAndTexture=function(t,i,n){return e.prototype._removeGradientAndTexture.call(this,t,i,n),this._releaseBuffers(),this},t.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var n=new rd(e,t);return this._colorGradients.push(n),this._refreshColorGradient(!0),this._releaseBuffers(),this},t.prototype._refreshColorGradient=function(e){void 0===e&&(e=!1),this._colorGradients&&(e&&this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null))},t.prototype.forceRefreshGradients=function(){this._refreshColorGradient(),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture"),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture"),this._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture"),this._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture"),this._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture"),this.reset()},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype._addFactorGradient=function(e,t,i){var n=new ad(t,i);e.push(n),this._releaseBuffers()},t.prototype.addSizeGradient=function(e,t){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},t.prototype._refreshFactorGradient=function(e,t,i){if(void 0===i&&(i=!1),e){i&&e.sort((function(e,t){return e.gradientt.gradient?1:0}));this[t]&&(this[t].dispose(),this[t]=null)}},t.prototype.addAngularSpeedGradient=function(e,t){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeAngularSpeedGradient=function(e){return this._removeGradientAndTexture(e,this._angularSpeedGradients,this._angularSpeedGradientsTexture),this._angularSpeedGradientsTexture=null,this},t.prototype.addVelocityGradient=function(e,t){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t),this._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._velocityGradients,this._velocityGradientsTexture),this._velocityGradientsTexture=null,this},t.prototype.addLimitVelocityGradient=function(e,t){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t),this._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeLimitVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._limitVelocityGradients,this._limitVelocityGradientsTexture),this._limitVelocityGradientsTexture=null,this},t.prototype.addDragGradient=function(e,t){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t),this._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeDragGradient=function(e){return this._removeGradientAndTexture(e,this._dragGradients,this._dragGradientsTexture),this._dragGradientsTexture=null,this},t.prototype.addEmitRateGradient=function(e,t,i){return this},t.prototype.removeEmitRateGradient=function(e){return this},t.prototype.addStartSizeGradient=function(e,t,i){return this},t.prototype.removeStartSizeGradient=function(e){return this},t.prototype.addColorRemapGradient=function(e,t,i){return this},t.prototype.removeColorRemapGradient=function(){return this},t.prototype.addAlphaRemapGradient=function(e,t,i){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:!1,configurable:!0}),t.prototype.addLifeTimeGradient=function(e,t,i){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 i=3;this.particleEmitterType instanceof zl&&(t.initialPosition=e.createVertexBuffer("initialPosition",i,3),i+=3),t.age=e.createVertexBuffer("age",i,1),i+=1,t.life=e.createVertexBuffer("life",i,1),i+=1,t.seed=e.createVertexBuffer("seed",i,4),i+=4,t.size=e.createVertexBuffer("size",i,3),i+=3,this._colorGradientsTexture||(t.color=e.createVertexBuffer("color",i,4),i+=4),t.direction=e.createVertexBuffer("direction",i,3),i+=3,this._isBillboardBased||(t.initialDirection=e.createVertexBuffer("initialDirection",i,3),i+=3),this._angularSpeedGradientsTexture?(t.angle=e.createVertexBuffer("angle",i,1),i+=1):(t.angle=e.createVertexBuffer("angle",i,2),i+=2),this._isAnimationSheetEnabled&&(t.cellIndex=e.createVertexBuffer("cellIndex",i,1),i+=1,this.spriteRandomStartCell&&(t.cellStartOffset=e.createVertexBuffer("cellStartOffset",i,1),i+=1)),this.noiseTexture&&(t.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",i,3),i+=3,t.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",i,3),i+=3);var n=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),n},t.prototype._createRenderVAO=function(e,t){var i={};i.position=e.createVertexBuffer("position",0,3,this._attributesStrideSize,!0);var n=3;this.particleEmitterType instanceof zl&&(n+=3),i.age=e.createVertexBuffer("age",n,1,this._attributesStrideSize,!0),n+=1,i.life=e.createVertexBuffer("life",n,1,this._attributesStrideSize,!0),n+=5,i.size=e.createVertexBuffer("size",n,3,this._attributesStrideSize,!0),n+=3,this._colorGradientsTexture||(i.color=e.createVertexBuffer("color",n,4,this._attributesStrideSize,!0),n+=4),this.billboardMode===dd.BILLBOARDMODE_STRETCHED&&(i.direction=e.createVertexBuffer("direction",n,3,this._attributesStrideSize,!0)),n+=3,this._isBillboardBased||(i.initialDirection=e.createVertexBuffer("initialDirection",n,3,this._attributesStrideSize,!0),n+=3),i.angle=e.createVertexBuffer("angle",n,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?n++:n+=2,this._isAnimationSheetEnabled&&(i.cellIndex=e.createVertexBuffer("cellIndex",n,1,this._attributesStrideSize,!0),n+=1,this.spriteRandomStartCell&&(i.cellStartOffset=e.createVertexBuffer("cellStartOffset",n,1,this._attributesStrideSize,!0),n+=1)),this.noiseTexture&&(i.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",n,3,this._attributesStrideSize,!0),n+=3,i.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",n,3,this._attributesStrideSize,!0),n+=3),i.offset=t.createVertexBuffer("offset",0,2),i.uv=t.createVertexBuffer("uv",2,2);var r=this._engine.recordVertexArrayObject(i,null,this._getEffect());return this._engine.bindArrayBuffer(null),r},t.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._engine,i=new Array;this._attributesStrideSize=21,this._targetIndex=0,this.particleEmitterType instanceof zl&&(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 n=this.particleEmitterType instanceof zl,r=a.c.Vector3[0],o=0;o=this.targetStopDuration&&this.stop()},t.prototype._createFactorGradientTexture=function(e,t){var i=this[t];if(e&&e.length&&!i){for(var n=new Float32Array(this._rawTextureWidth),r=0;r1){var r=0|this._accumulatedCount;this._accumulatedCount-=r,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+r)}if(!this._currentActiveCount)return 0;this._engine.enableEffect(this._updateEffect);var o,s=this._engine;if(!s.setState)throw new Error("GPU particles cannot work with a full Engine. ThinEngine is not supported");if(this._updateEffect.setFloat("currentCount",this._currentActiveCount),this._updateEffect.setFloat("timeDelta",this._timeDelta),this._updateEffect.setFloat("stopFactor",this._stopped?0:1),this._updateEffect.setTexture("randomSampler",this._randomTexture),this._updateEffect.setTexture("randomSampler2",this._randomTexture2),this._updateEffect.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateEffect.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateEffect.setDirectColor4("color1",this.color1),this._updateEffect.setDirectColor4("color2",this.color2)),this._updateEffect.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateEffect.setFloat4("scaleRange",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateEffect.setFloat4("angleRange",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateEffect.setVector3("gravity",this.gravity),this._sizeGradientsTexture&&this._updateEffect.setTexture("sizeGradientSampler",this._sizeGradientsTexture),this._angularSpeedGradientsTexture&&this._updateEffect.setTexture("angularSpeedGradientSampler",this._angularSpeedGradientsTexture),this._velocityGradientsTexture&&this._updateEffect.setTexture("velocityGradientSampler",this._velocityGradientsTexture),this._limitVelocityGradientsTexture&&(this._updateEffect.setTexture("limitVelocityGradientSampler",this._limitVelocityGradientsTexture),this._updateEffect.setFloat("limitVelocityDamping",this.limitVelocityDamping)),this._dragGradientsTexture&&this._updateEffect.setTexture("dragGradientSampler",this._dragGradientsTexture),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateEffect),this._isAnimationSheetEnabled&&this._updateEffect.setFloat3("cellInfos",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed),this.noiseTexture&&(this._updateEffect.setTexture("noiseSampler",this.noiseTexture),this._updateEffect.setVector3("noiseStrength",this.noiseStrength)),this.emitter.position){o=this.emitter.getWorldMatrix()}else{var c=this.emitter;o=a.a.Translation(c.x,c.y,c.z)}if(this.isLocal||this._updateEffect.setMatrix("emitterWM",o),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),s.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),s.setRasterizerState(!1),s.beginTransformFeedback(!0),s.drawArraysType(g.a.MATERIAL_PointListDrawMode,0,this._currentActiveCount),s.endTransformFeedback(),s.setRasterizerState(!0),s.bindTransformFeedbackBuffer(null),!e){var l=this._getEffect();this._engine.enableEffect(l);var u=(null===(t=this._scene)||void 0===t?void 0:t.getViewMatrix())||a.a.IdentityReadOnly;if(l.setMatrix("view",u),l.setMatrix("projection",null!==(i=this.defaultProjectionMatrix)&&void 0!==i?i:this._scene.getProjectionMatrix()),l.setTexture("diffuseSampler",this.particleTexture),l.setVector2("translationPivot",this.translationPivot),l.setVector3("worldOffset",this.worldOffset),this.isLocal&&l.setMatrix("emitterWM",o),this._colorGradientsTexture?l.setTexture("colorGradientSampler",this._colorGradientsTexture):l.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var h=this.particleTexture.getBaseSize();l.setFloat3("sheetInfos",this.spriteCellWidth/h.width,this.spriteCellHeight/h.height,h.width/this.spriteCellWidth)}if(this._isBillboardBased&&this._scene){var d=this._scene.activeCamera;l.setVector3("eyePosition",d.globalPosition)}var f=l.defines;if(this._scene&&(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4||this._scene.clipPlane5||this._scene.clipPlane6)&&ro.a.BindClipPlane(l,this._scene),f.indexOf("#define BILLBOARDMODE_ALL")>=0){var p=u.clone();p.invert(),l.setMatrix("invView",p)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(l),this.blendMode){case dd.BLENDMODE_ADD:this._engine.setAlphaMode(g.a.ALPHA_ADD);break;case dd.BLENDMODE_ONEONE:this._engine.setAlphaMode(g.a.ALPHA_ONEONE);break;case dd.BLENDMODE_STANDARD:this._engine.setAlphaMode(g.a.ALPHA_COMBINE);break;case dd.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(g.a.ALPHA_MULTIPLY)}this.forceDepthWrite&&s.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(l),this._engine.drawArraysType(g.a.MATERIAL_TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(g.a.ALPHA_DISABLE)}this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var _=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=_,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.onStoppedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,i){var n=this.serialize(),r=t.Parse(n,this._scene||this._engine,""),o=Object(h.a)({},this._customEffect);return r.name=e,r._customEffect=o,void 0===i&&(i=this.emitter),r.emitter=i,r.noiseTexture=this.noiseTexture,r},t.prototype.serialize=function(e){void 0===e&&(e=!1);var t={};return dd._Serialize(t,this,e),t.activeParticleCount=this.activeParticleCount,t.randomTextureSize=this._randomTextureSize,t},t.Parse=function(e,i,n,r){void 0===r&&(r=!1);var o=new t(e.name,{capacity:e.capacity,randomTextureSize:e.randomTextureSize},i);return e.activeParticleCount&&(o.activeParticleCount=e.activeParticleCount),dd._Parse(e,o,i,n),e.preventAutoStart&&(o.preventAutoStart=e.preventAutoStart),r||o.preventAutoStart||o.start(),o},t}(jl),bd=function(){function e(){this.systems=new Array}return Object.defineProperty(e.prototype,"emitterNode",{get:function(){return this._emitterNode},enumerable:!1,configurable:!0}),e.prototype.setEmitterAsSphere=function(e,t,i){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:"Sphere",options:e,renderingGroupId:t};var n=xr.a.CreateSphere("emitterSphere",{diameter:e.diameter,segments:e.segments},i);n.renderingGroupId=t;var r=new Wi.a("emitterSphereMaterial",i);r.emissiveColor=e.color,n.material=r;for(var o=0,a=this.systems;o0&&i.set(this._uvs32,Qi.b.UVKind),this._colors32.length>0&&i.set(this._colors32,Qi.b.ColorKind),i.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,this._pickable)for(var n=0,r=0;rf?f:n,i=Math.round(f/n),r=0):i=i>f?f:i;for(var p=[],_=[],m=[],g=[],v=[],b=a.e.Zero(),y=i;df-(i=y+Math.floor((1+r)*Math.random()))&&(i=f-d),p.length=0,_.length=0,m.length=0,g.length=0,v.length=0;for(var T=0,E=3*d;E<3*(d+i);E++){m.push(T);var S=s[E],A=3*S;if(p.push(o[A],o[A+1],o[A+2]),_.push(u[A],u[A+1],u[A+2]),c){var P=2*S;g.push(c[P],c[P+1])}if(l){var C=4*S;v.push(l[C],l[C+1],l[C+2],l[C+3])}T++}var R,x=this.nbParticles,O=this._posToShape(p),M=this._uvsToShapeUV(g),I=Ce.b.Slice(m),D=Ce.b.Slice(v),N=Ce.b.Slice(_);for(b.copyFromFloats(0,0,0),R=0;R65535&&(this._needs32Bits=!0)}if(this._depthSort||this._multimaterialEnabled){var U=null!==T.materialIndex?T.materialIndex:0;this.depthSortedParticles.push(new Ad(f,t,r.length,U))}return T},e.prototype._posToShape=function(e){for(var t=[],i=0;i=this.nbParticles||!this._updatable)return[];var n=this.particles,r=this.nbParticles;if(t=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var L=this.mesh._boundingInfo;L&&(v.copyFrom(L.minimum),b.copyFrom(L.maximum))}var w=(x=this.particles[e]._pos)/3|0;M=4*w,D=2*w;for(var F=e;F<=t;F++){var B=this.particles[F];this.updateParticle(B);var U=B._model._shape,V=B._model._shapeUV,k=B._rotationMatrix,z=B.position,G=B.rotation,j=B.scaling,W=B._globalPosition;if(this._depthSort&&this._depthSortParticles){var H=this.depthSortedParticles[F];H.idx=B.idx,H.ind=B._ind,H.indicesLength=B._model._indicesLength,H.sqDistance=a.e.DistanceSquared(B.position,y)}if(!B.alive||B._stillInvisible&&!B.isVisible)x+=3*(N=U.length),M+=4*N,D+=2*N;else{if(B.isVisible){B._stillInvisible=!1;var X=p[12];if(B.pivot.multiplyToRef(j,X),this.billboard&&(G.x=0,G.y=0),(this._computeParticleRotation||this.billboard)&&B.getRotationMatrix(n),null!==B.parentId){var Y=this.getParticleById(B.parentId);if(Y){var K=Y._rotationMatrix,Q=Y._globalPosition,q=z.x*K[1]+z.y*K[4]+z.z*K[7],Z=z.x*K[0]+z.y*K[3]+z.z*K[6],$=z.x*K[2]+z.y*K[5]+z.z*K[8];if(W.x=Q.x+Z,W.y=Q.y+q,W.z=Q.z+$,this._computeParticleRotation||this.billboard){var ee=n.m;k[0]=ee[0]*K[0]+ee[1]*K[3]+ee[2]*K[6],k[1]=ee[0]*K[1]+ee[1]*K[4]+ee[2]*K[7],k[2]=ee[0]*K[2]+ee[1]*K[5]+ee[2]*K[8],k[3]=ee[4]*K[0]+ee[5]*K[3]+ee[6]*K[6],k[4]=ee[4]*K[1]+ee[5]*K[4]+ee[6]*K[7],k[5]=ee[4]*K[2]+ee[5]*K[5]+ee[6]*K[8],k[6]=ee[8]*K[0]+ee[9]*K[3]+ee[10]*K[6],k[7]=ee[8]*K[1]+ee[9]*K[4]+ee[10]*K[7],k[8]=ee[8]*K[2]+ee[9]*K[5]+ee[10]*K[8]}}else B.parentId=null}else if(W.x=z.x,W.y=z.y,W.z=z.z,this._computeParticleRotation||this.billboard){ee=n.m;k[0]=ee[0],k[1]=ee[1],k[2]=ee[2],k[3]=ee[4],k[4]=ee[5],k[5]=ee[6],k[6]=ee[8],k[7]=ee[9],k[8]=ee[10]}var te=p[11];for(B.translateFromPivot?te.setAll(0):te.copyFrom(X),N=0;N0)for(var t=0;t0&&e.set(this._uvs32,Qi.b.UVKind);var t=0;this._colors32.length>0&&(t=1,e.set(this._colors32,Qi.b.ColorKind));var i=new be.a(this.name,this._scene);e.applyToMesh(i,this._updatable),this.mesh=i,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);var n=new Wi.a("point cloud material",this._scene);return n.emissiveColor=new s.a(t,t,t),n.disableLighting=!0,n.pointsCloud=!0,n.pointSize=this._size,i.material=n,new Promise((function(e){return e(i)}))},e.prototype._addParticle=function(e,t,i,n){var r=new Rd(e,t,i,n,this);return this.particles.push(r),r},e.prototype._randomUnitVector=function(e){e.position=new a.e(Math.random(),Math.random(),Math.random()),e.color=new s.b(1,1,1,1)},e.prototype._getColorIndicesForCoord=function(e,t,i,n){var r=e._groupImageData,o=i*(4*n)+4*t,a=[o,o+1,o+2,o+3],c=a[1],l=a[2],u=a[3],h=r[a[0]],d=r[c],f=r[l],p=r[u];return new s.b(h/255,d/255,f/255,p)},e.prototype._setPointsColorOrUV=function(e,t,i,n,r,o,c){i&&e.updateFacetData();var l=2*e.getBoundingInfo().boundingSphere.radius,u=e.getVerticesData(Qi.b.PositionKind),h=e.getIndices(),d=e.getVerticesData(Qi.b.UVKind),f=e.getVerticesData(Qi.b.ColorKind),p=a.e.Zero();e.computeWorldMatrix();var _=e.getWorldMatrix();if(!_.isIdentity())for(var m=0;m1&&(Ie=1),(De=Ne.b+Oe)<0&&(De=0),De>1&&(De=1),s.a.HSVtoRGBToRef(Me,Ie,De,Be),me.set(Be.r,Be.g,Be.b,1)):me=ce.set(Math.random(),Math.random(),Math.random(),1),we.color=new s.b(me.x,me.y,me.z,me.w),this._colors.push(me.x,me.y,me.z,me.w))}},e.prototype._colorFromTexture=function(e,t,i){var n=this;if(null===e.material)return m.a.Warn(e.name+"has no material."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,i,!0,!1);var r=e.material.getActiveTextures();if(0===r.length)return m.a.Warn(e.name+"has no useable texture."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,i,!0,!1);var o=e.clone();o.setEnabled(!1),this._promises.push(new Promise((function(e){Zn.a.WhenAllReady(r,(function(){var a=t._textureNb;return a<0&&(a=0),a>r.length-1&&(a=r.length-1),t._groupImageData=r[a].readPixels(),t._groupImgWidth=r[a].getSize().width,t._groupImgHeight=r[a].getSize().height,n._setPointsColorOrUV(o,t,i,!0,!0),o.dispose(),e()}))})))},e.prototype._calculateDensity=function(e,t,i){for(var n,r,o,s,c,l,u,h,d,f,p,_,m,g,v,b,y,T=new Array,E=a.e.Zero(),S=a.e.Zero(),A=a.e.Zero(),P=a.e.Zero(),C=a.e.Zero(),R=a.e.Zero(),x=new Array,O=0,M=i.length/3,I=0;I0&&(T=T.map((function(e){return e+L})));for(I=0;I3)&&(o=Td.Random);var a=e.getVerticesData(Qi.b.PositionKind),c=e.getIndices();this._groups.push(this._groupCounter);var l=new xd(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,c),o===Td.Color?l._textureNb=n||0:n=n||new s.b(1,1,1,1),o){case Td.Color:this._colorFromTexture(e,l,!1);break;case Td.UV:this._setPointsColorOrUV(e,l,!1,!1,!1);break;case Td.Random:this._setPointsColorOrUV(e,l,!1);break;case Td.Stated:this._setPointsColorOrUV(e,l,!1,void 0,void 0,n,r)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.addVolumePoints=function(e,t,i,n,r){var o=i||Td.Random;(isNaN(o)||o<0||o>3)&&(o=Td.Random);var a=e.getVerticesData(Qi.b.PositionKind),c=e.getIndices();this._groups.push(this._groupCounter);var l=new xd(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,c),o===Td.Color?l._textureNb=n||0:n=n||new s.b(1,1,1,1),o){case Td.Color:this._colorFromTexture(e,l,!0);break;case Td.UV:this._setPointsColorOrUV(e,l,!0,!1,!1);break;case Td.Random:this._setPointsColorOrUV(e,l,!0);break;case Td.Stated:this._setPointsColorOrUV(e,l,!0,void 0,void 0,n,r)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.setParticles=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=this.nbParticles-1),void 0===i&&(i=!0),!this._updatable||!this._isReady)return this;this.beforeUpdateParticles(e,t,i);var n=a.c.Matrix[0],r=this.mesh,o=this._colors32,s=this._positions32,c=this._uvs32,l=a.c.Vector3,u=l[5].copyFromFloats(1,0,0),h=l[6].copyFromFloats(0,1,0),d=l[7].copyFromFloats(0,0,1),f=l[8].setAll(Number.MAX_VALUE),p=l[9].setAll(-Number.MAX_VALUE);a.a.IdentityToRef(n);var _=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&&(f.copyFrom(m.minimum),p.copyFrom(m.maximum))}_=0;for(var g=0,v=0,b=0,y=e;y<=t;y++){var T=this.particles[y];g=3*(_=T.idx),v=4*_,b=2*_,this.updateParticle(T);var E=T._rotationMatrix,S=T.position,A=T._globalPosition;if(this._computeParticleRotation&&T.getRotationMatrix(n),null!==T.parentId){var P=this.particles[T.parentId],C=P._rotationMatrix,R=P._globalPosition,x=S.x*C[1]+S.y*C[4]+S.z*C[7],O=S.x*C[0]+S.y*C[3]+S.z*C[6],M=S.x*C[2]+S.y*C[5]+S.z*C[8];if(A.x=R.x+O,A.y=R.y+x,A.z=R.z+M,this._computeParticleRotation){var I=n.m;E[0]=I[0]*C[0]+I[1]*C[3]+I[2]*C[6],E[1]=I[0]*C[1]+I[1]*C[4]+I[2]*C[7],E[2]=I[0]*C[2]+I[1]*C[5]+I[2]*C[8],E[3]=I[4]*C[0]+I[5]*C[3]+I[6]*C[6],E[4]=I[4]*C[1]+I[5]*C[4]+I[6]*C[7],E[5]=I[4]*C[2]+I[5]*C[5]+I[6]*C[8],E[6]=I[8]*C[0]+I[9]*C[3]+I[10]*C[6],E[7]=I[8]*C[1]+I[9]*C[4]+I[10]*C[7],E[8]=I[8]*C[2]+I[9]*C[5]+I[10]*C[8]}}else if(A.x=0,A.y=0,A.z=0,this._computeParticleRotation){I=n.m;E[0]=I[0],E[1]=I[1],E[2]=I[2],E[3]=I[4],E[4]=I[5],E[5]=I[6],E[6]=I[8],E[7]=I[9],E[8]=I[10]}var D=l[11];T.translateFromPivot?D.setAll(0):D.copyFrom(T.pivot);var N=l[0];N.copyFrom(T.position);var L=N.x-T.pivot.x,w=N.y-T.pivot.y,F=N.z-T.pivot.z,B=L*E[0]+w*E[3]+F*E[6],U=L*E[1]+w*E[4]+F*E[7],V=L*E[2]+w*E[5]+F*E[8];B+=D.x,U+=D.y,V+=D.z;var k=s[g]=A.x+u.x*B+h.x*U+d.x*V,z=s[g+1]=A.y+u.y*B+h.y*U+d.y*V,G=s[g+2]=A.z+u.z*B+h.z*U+d.z*V;if(this._computeBoundingBox&&(f.minimizeInPlaceFromFloats(k,z,G),p.maximizeInPlaceFromFloats(k,z,G)),this._computeParticleColor&&T.color){var j=T.color,W=this._colors32;W[v]=j.r,W[v+1]=j.g,W[v+2]=j.b,W[v+3]=j.a}if(this._computeParticleTexture&&T.uv){var H=T.uv,X=this._uvs32;X[b]=H.x,X[b+1]=H.y}}return i&&(this._computeParticleColor&&r.updateVerticesData(Qi.b.ColorKind,o,!1,!1),this._computeParticleTexture&&r.updateVerticesData(Qi.b.UVKind,c,!1,!1),r.updateVerticesData(Qi.b.PositionKind,s,!1,!1)),this._computeBoundingBox&&(r._boundingInfo?r._boundingInfo.reConstruct(f,p,r._worldMatrix):r._boundingInfo=new Tn.a(f,p,r._worldMatrix)),this.afterUpdateParticles(e,t,i),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 Tn.a(new a.e(-t,-t,-t),new a.e(t,t,t))},Object.defineProperty(e.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleRotation",{set:function(e){this._computeParticleRotation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!1,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,i){},e.prototype.afterUpdateParticles=function(e,t,i){},e}();Q.a.prototype.getPhysicsEngine=function(){return this._physicsEngine},Q.a.prototype.enablePhysics=function(e,t){if(void 0===e&&(e=null),this._physicsEngine)return!0;var i=this._getComponent(Me.a.NAME_PHYSICSENGINE);i||(i=new Dd(this),this._addComponent(i));try{return this._physicsEngine=new pc(e,t),this._physicsTimeAccumulator=0,!0}catch(e){return m.a.Error(e.message),!1}},Q.a.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},Q.a.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},Q.a.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},Q.a.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(Ge.a.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}),Ge.a.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},Ge.a.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},Ge.a.prototype.setPhysicsLinkWith=function(e,t,i,n){return this.physicsImpostor&&e.physicsImpostor?(this.physicsImpostor.createJoint(e.physicsImpostor,fc.e.HingeJoint,{mainPivot:t,connectedPivot:i,nativeParams:n}),this):this};var Md,Id,Dd=function(){function e(e){var t=this;this.name=Me.a.NAME_PHYSICSENGINE,this.scene=e,this.scene.onBeforePhysicsObservable=new o.c,this.scene.onAfterPhysicsObservable=new o.c,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}(),Nd=function(){function e(e){this._scene=e,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||m.a.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}return e.prototype.applyRadialExplosionImpulse=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;var r=this._physicsEngine.getImpostors();if(0===r.length)return null;"number"==typeof t&&((t=new Ud).radius=t,t.strength=i||t.strength,t.falloff=n||t.falloff);var o=new Ld(this._scene,t),a=Array();return r.forEach((function(t){var i=o.getImpostorHitData(t,e);i&&(t.applyImpulse(i.force,i.contactPoint),a.push({impostor:t,hitData:i}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.applyRadialExplosionForce=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;var r=this._physicsEngine.getImpostors();if(0===r.length)return null;"number"==typeof t&&((t=new Ud).radius=t,t.strength=i||t.strength,t.falloff=n||t.falloff);var o=new Ld(this._scene,t),a=Array();return r.forEach((function(t){var i=o.getImpostorHitData(t,e);i&&(t.applyForce(i.force,i.contactPoint),a.push({impostor:t,hitData:i}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.gravitationalField=function(e,t,i,n){if(!this._physicsEngine)return m.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 Ud).radius=t,t.strength=i||t.strength,t.falloff=n||t.falloff);var r=new wd(this,this._scene,e,t);return r.dispose(!1),r},e.prototype.updraft=function(e,t,i,n,r){if(!this._physicsEngine)return m.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 Vd).radius=t,t.strength=i||t.strength,t.height=n||t.height,t.updraftMode=r||t.updraftMode);var o=new Fd(this._scene,e,t);return o.dispose(!1),o},e.prototype.vortex=function(e,t,i,n){if(!this._physicsEngine)return m.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 kd).radius=t,t.strength=i||t.strength,t.height=n||t.height);var r=new Bd(this._scene,e,t);return r.dispose(!1),r},e}(),Ld=function(){function e(e,t){this._scene=e,this._options=t,this._dataFetched=!1,this._options=Object(h.a)(Object(h.a)({},new Ud),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 i=e.getObjectCenter().subtract(t),n=new Xt.a(t,i,this._options.radius).intersectsMesh(e.object).pickedPoint;if(!n)return null;var r=a.e.Distance(t,n);if(r>this._options.radius)return null;var o=this._options.falloff===Md.Constant?this._options.strength:this._options.strength*(1-r/this._options.radius);return{force:i.multiplyByFloats(o,o,o),contactPoint:n,distanceFromOrigin:r}},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=xr.a.CreateSphere("radialExplosionEventSphere",this._options.sphere,this._scene),this._sphere.isVisible=!1)},e.prototype._intersectsWithSphere=function(e,t,i){var n=e.object;return this._prepareSphere(),this._sphere.position=t,this._sphere.scaling=new a.e(2*i,2*i,2*i),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(n,!0)},e}(),wd=function(){function e(e,t,i,n){this._physicsHelper=e,this._scene=t,this._origin=i,this._options=n,this._dataFetched=!1,this._options=Object(h.a)(Object(h.a)({},new Ud),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}(),Fd=function(){function e(e,t,i){this._scene=e,this._origin=t,this._options=i,this._originTop=a.e.Zero(),this._originDirection=a.e.Zero(),this._cylinderPosition=a.e.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(h.a)(Object(h.a)({},new Vd),this._options),this._origin.addToRef(new a.e(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new a.e(0,this._options.height,0),this._originTop),this._options.updraftMode===Id.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===Id.Perpendicular)var i=this._originDirection;else i=t.subtract(this._originTop);var n=a.e.Distance(this._origin,t),r=-1*this._options.strength;return{force:i.multiplyByFloats(r,r,r),contactPoint:t,distanceFromOrigin:n}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var i=e.getImpostorHitData(t);i&&t.applyForce(i.force,i.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=nn.a.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}(),Bd=function(){function e(e,t,i){this._scene=e,this._origin=t,this._options=i,this._originTop=a.e.Zero(),this._cylinderPosition=a.e.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(h.a)(Object(h.a)({},new kd),this._options),this._origin.addToRef(new a.e(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new a.e(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(),i=new a.e(this._origin.x,t.y,this._origin.z),n=t.subtract(i),r=new Xt.a(i,n,this._options.radius).intersectsMesh(e.object),o=r.pickedPoint;if(!o)return null;var s=r.distance/this._options.radius,c=o.normalize();if(s>this._options.centripetalForceThreshold&&(c=c.negate()),s>this._options.centripetalForceThreshold)var l=c.x*this._options.centripetalForceMultiplier,u=c.y*this._options.updraftForceMultiplier,h=c.z*this._options.centripetalForceMultiplier;else{var d=a.e.Cross(i,t).normalize();l=(d.x+c.x)*this._options.centrifugalForceMultiplier,u=this._originTop.y*this._options.updraftForceMultiplier,h=(d.z+c.z)*this._options.centrifugalForceMultiplier}var f=new a.e(l,u,h);return{force:f=f.multiplyByFloats(this._options.strength,this._options.strength,this._options.strength),contactPoint:t,distanceFromOrigin:s}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var i=e.getImpostorHitData(t);i&&t.applyForce(i.force,i.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=nn.a.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}(),Ud=function(){this.radius=5,this.strength=10,this.falloff=Md.Constant,this.sphere={segments:32,diameter:1}},Vd=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=Id.Center},kd=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"}(Md||(Md={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(Id||(Id={}));var zd="\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}";ai.a.ShadersStore.blackAndWhitePixelShader=zd;var Gd=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,"blackAndWhite",["degree"],null,i,n,r,o,a)||this;return s.degree=1,s.onApplyObservable.add((function(e){e.setFloat("degree",s.degree)})),s}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"BlackAndWhitePostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"degree",void 0),t}(li);c.a.RegisteredTypes["BABYLON.BlackAndWhitePostProcess"]=Gd;var jd=function(){function e(e,t,i,n){this._name=t,this._singleInstance=n||!0,this._getPostProcesses=i,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],i=0;i-1?"#define MALI 1\n":null},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);c.a.RegisteredTypes["BABYLON.FxaaPostProcess"]=mf;var gf="#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}";ai.a.ShadersStore.grainPixelShader=gf;var vf=function(e){function t(t,i,n,r,o,a,s,c){void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"grain",["intensity","animatedSeed"],[],i,n,r,o,a,null,s,void 0,null,c)||this;return l.intensity=30,l.animated=!1,l.onApplyObservable.add((function(e){e.setFloat("intensity",l.intensity),e.setFloat("animatedSeed",l.animated?Math.random()+1:1)})),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"GrainPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"intensity",void 0),Object(h.c)([Object(w.c)()],t.prototype,"animated",void 0),t}(li);c.a.RegisteredTypes["BABYLON.GrainPostProcess"]=vf;var bf="\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}";ai.a.ShadersStore.highlightsPixelShader=bf;var yf=function(e){function t(t,i,n,r,o,a,s){return void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),e.call(this,t,"highlights",null,null,i,n,r,o,a,null,s)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"HighlightsPostProcess"},t}(li);ai.a.IncludesShadersStore.mrtFragmentDeclaration="#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";var Tf="#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\n#include\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nvec3 normalOutput;\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\n#else\nnormalOutput=normalize(vNormalV);\n#endif\n#ifdef PREPASS\n#ifdef PREPASS_DEPTHNORMAL\ngl_FragData[DEPTHNORMAL_INDEX]=vec4(vViewPos.z/vViewPos.w,normalOutput);\n#endif\n#else\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\ngl_FragData[1]=vec4(normalOutput,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}";ai.a.ShadersStore.geometryPixelShader=Tf;var Ef="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";ai.a.ShadersStore.geometryVertexShader=Ef;var Sf=function(){function e(t,i){void 0===i&&(i=1),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this._resizeObserver=null,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._depthNormalIndex=-1,this._linkedWithPrePass=!1,this._scene=t,this._ratio=i,e._SceneComponentInitialization(this._scene),this._createRenderTargets()}return e.prototype._linkPrePassRenderer=function(e){this._linkedWithPrePass=!0,this._prePassRenderer=e,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add((function(e){})))},e.prototype._unlinkPrePassRenderer=function(){this._linkedWithPrePass=!1,this._createRenderTargets()},e.prototype._resetLayout=function(){this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._attachments=[]},e.prototype._forceTextureType=function(t,i){t===e.POSITION_TEXTURE_TYPE?(this._positionIndex=i,this._enablePosition=!0):t===e.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=i,this._enableVelocity=!0):t===e.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=i,this._enableReflectivity=!0):t===e.DEPTHNORMAL_TEXTURE_TYPE&&(this._depthNormalIndex=i)},e.prototype._setAttachments=function(e){this._attachments=e},e.prototype._linkInternalTexture=function(e){this._multiRenderTarget._texture=e},Object.defineProperty(e.prototype,"renderList",{get:function(){return this._multiRenderTarget.renderList},set:function(e){this._multiRenderTarget.renderList=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!1,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._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableVelocity",{get:function(){return this._enableVelocity},set:function(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableReflectivity",{get:function(){return this._enableReflectivity},set:function(e){this._enableReflectivity=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ratio",{get:function(){return this._ratio},enumerable:!1,configurable:!0}),e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;var n=[],r=[Qi.b.PositionKind,Qi.b.NormalKind],o=e.getMesh();if(i){var a=!1;i.needAlphaTesting()&&(n.push("#define ALPHATEST"),a=!0),i.bumpTexture&&Wi.a.BumpTextureEnabled&&(n.push("#define BUMP"),n.push("#define BUMPDIRECTUV 0"),a=!0),this._enableReflectivity&&(i instanceof Wi.a&&i.specularTexture?(n.push("#define HAS_SPECULAR"),a=!0):i instanceof ma&&i.reflectivityTexture&&(n.push("#define HAS_REFLECTIVITY"),a=!0)),a&&(n.push("#define NEED_UV"),o.isVerticesDataPresent(Qi.b.UVKind)&&(r.push(Qi.b.UVKind),n.push("#define UV1")),o.isVerticesDataPresent(Qi.b.UV2Kind)&&(r.push(Qi.b.UV2Kind),n.push("#define UV2")))}this._linkedWithPrePass&&(n.push("#define PREPASS"),-1!==this._depthNormalIndex&&(n.push("#define DEPTHNORMAL_INDEX "+this._depthNormalIndex),n.push("#define PREPASS_DEPTHNORMAL"))),this._enablePosition&&(n.push("#define POSITION"),n.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(n.push("#define VELOCITY"),n.push("#define VELOCITY_INDEX "+this._velocityIndex),-1===this.excludedSkinnedMeshesFromVelocity.indexOf(o)&&n.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(n.push("#define REFLECTIVITY"),n.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),o.useBones&&o.computeBonesUsingShaders?(r.push(Qi.b.MatricesIndicesKind),r.push(Qi.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(r.push(Qi.b.MatricesIndicesExtraKind),r.push(Qi.b.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),n.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0");var s=o.morphTargetManager,c=0;s&&s.numInfluencers>0&&(c=s.numInfluencers,n.push("#define MORPHTARGETS"),n.push("#define NUM_MORPH_INFLUENCERS "+c),ro.a.PrepareAttributesForMorphTargetsInfluencers(r,o,c)),t&&(n.push("#define INSTANCES"),ro.a.PushAttributesForInstances(r),e.getRenderingMesh().hasThinInstances&&n.push("#define THIN_INSTANCES")),this._linkedWithPrePass?n.push("#define RENDER_TARGET_COUNT "+this._attachments.length):n.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length);var l=n.join("\n");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this._scene.getEngine().createEffect("geometry",r,["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","morphTargetInfluences","bumpMatrix","reflectivityMatrix","vTangentSpaceParams","vBumpInfos"],["diffuseSampler","bumpSampler","reflectivitySampler"],l,void 0,void 0,void 0,{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:c})),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:!1,configurable:!0}),e.prototype.dispose=function(){this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null);this.getGBuffer().dispose()},e.prototype._assignRenderTargetIndices=function(){var e=2;return this._enablePosition&&(this._positionIndex=e,e++),this._enableVelocity&&(this._velocityIndex=e,e++),this._enableReflectivity&&(this._reflectivityIndex=e,e++),e},e.prototype._createRenderTargets=function(){var e=this,t=this._scene.getEngine(),i=this._assignRenderTargetIndices();if(this._multiRenderTarget=new Hc("gBuffer",{width:t.getRenderWidth()*this._ratio,height:t.getRenderHeight()*this._ratio},i,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:g.a.TEXTURETYPE_FLOAT}),this.isSupported){this._multiRenderTarget.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(e){e.clear(new s.b(0,0,0,1),!0,!0,!0)})),this._resizeObserver=t.onResizeObservable.add((function(){e._multiRenderTarget&&e._multiRenderTarget.resize({width:t.getRenderWidth()*e._ratio,height:t.getRenderHeight()*e._ratio})}));var n=function(t){var i=t.getRenderingMesh(),n=t.getEffectiveMesh(),r=e._scene,o=r.getEngine(),s=t.getMaterial();if(s){if(n._internalAbstractMeshDataInfo._isActiveIntermediate=!1,e._enableVelocity&&!e._previousTransformationMatrices[n.uniqueId]&&(e._previousTransformationMatrices[n.uniqueId]={world:a.a.Identity(),viewProjection:r.getTransformMatrix()},i.skeleton)){var c=i.skeleton.getTransformMatrices(i);e._previousBonesTransformationMatrices[i.uniqueId]=e._copyBonesTransformationMatrices(c,new Float32Array(c.length))}var l=i._getInstancesRenderList(t._id,!!t.getReplacementMesh());if(!l.mustReturn){var u=o.getCaps().instancedArrays&&(null!==l.visibleInstances[t._id]||i.hasThinInstances),h=n.getWorldMatrix();if(e.isReady(t,u)){if(o.enableEffect(e._effect),i._bind(t,e._effect,s.fillMode),e._effect.setMatrix("viewProjection",r.getTransformMatrix()),e._effect.setMatrix("view",r.getViewMatrix()),s){var d,f=n._instanceDataStorage;if(f.isFrozen||!s.backFaceCulling&&null===s.overrideMaterialSideOrientation)d=f.sideOrientation;else{var p=n._getWorldMatrixDeterminant();null==(d=s.overrideMaterialSideOrientation)&&(d=s.sideOrientation),p<0&&(d=d===xo.a.ClockWiseSideOrientation?xo.a.CounterClockWiseSideOrientation:xo.a.ClockWiseSideOrientation)}if(s._preBind(e._effect,d),s.needAlphaTesting()){var _=s.getAlphaTestTexture();_&&(e._effect.setTexture("diffuseSampler",_),e._effect.setMatrix("diffuseMatrix",_.getTextureMatrix()))}s.bumpTexture&&r.getEngine().getCaps().standardDerivatives&&Wi.a.BumpTextureEnabled&&(e._effect.setFloat3("vBumpInfos",s.bumpTexture.coordinatesIndex,1/s.bumpTexture.level,s.parallaxScaleBias),e._effect.setMatrix("bumpMatrix",s.bumpTexture.getTextureMatrix()),e._effect.setTexture("bumpSampler",s.bumpTexture),e._effect.setFloat2("vTangentSpaceParams",s.invertNormalMapX?-1:1,s.invertNormalMapY?-1:1)),e._enableReflectivity&&(s instanceof Wi.a&&s.specularTexture?(e._effect.setMatrix("reflectivityMatrix",s.specularTexture.getTextureMatrix()),e._effect.setTexture("reflectivitySampler",s.specularTexture)):s instanceof ma&&s.reflectivityTexture&&(e._effect.setMatrix("reflectivityMatrix",s.reflectivityTexture.getTextureMatrix()),e._effect.setTexture("reflectivitySampler",s.reflectivityTexture)))}i.useBones&&i.computeBonesUsingShaders&&i.skeleton&&(e._effect.setMatrices("mBones",i.skeleton.getTransformMatrices(i)),e._enableVelocity&&e._effect.setMatrices("mPreviousBones",e._previousBonesTransformationMatrices[i.uniqueId])),ro.a.BindMorphTargetParameters(i,e._effect),e._enableVelocity&&(e._effect.setMatrix("previousWorld",e._previousTransformationMatrices[n.uniqueId].world),e._effect.setMatrix("previousViewProjection",e._previousTransformationMatrices[n.uniqueId].viewProjection)),i._processRendering(n,t,e._effect,s.fillMode,l,u,(function(t,i){return e._effect.setMatrix("world",i)}))}e._enableVelocity&&(e._previousTransformationMatrices[n.uniqueId].world=h.clone(),e._previousTransformationMatrices[n.uniqueId].viewProjection=e._scene.getTransformMatrix().clone(),i.skeleton&&e._copyBonesTransformationMatrices(i.skeleton.getTransformMatrices(i),e._previousBonesTransformationMatrices[n.uniqueId]))}}};this._multiRenderTarget.customRenderFunction=function(i,r,o,a){var s;if(e._linkedWithPrePass){if(!e._prePassRenderer.enabled)return;e._scene.getEngine().bindAttachments(e._attachments)}if(a.length){for(t.setColorWrite(!1),s=0;s0){var i=this._renderEffects[t[0]].getPostProcesses();i&&(i[0].samples=e)}return!0},e.prototype.setPrePassRenderer=function(e){return!1},e.prototype.dispose=function(){},Object(h.c)([Object(w.c)()],e.prototype,"_name",void 0),e}(),Nf=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 i=this._renderPipelines[t];i.isSupported&&e.push(i)}return e},enumerable:!1,configurable:!0}),e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){void 0===i&&(i=!1);var n=this._renderPipelines[e];n&&n._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var n=this._renderPipelines[e];n&&n._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var n=this._renderPipelines[e];n&&n._disableEffect(t,i)},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(Q.a.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var e=this._getComponent(Me.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER);e||(e=new Lf(this),this._addComponent(e)),this._postProcessRenderPipelineManager=new Nf}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var Lf=function(){function e(e){this.name=Me.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Me.a.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}(),wf=function(e){function t(t,i,n,r,a){void 0===t&&(t=""),void 0===i&&(i=!0),void 0===n&&(n=x.a.LastCreatedScene),void 0===a&&(a=!0);var s=e.call(this,n.getEngine(),t)||this;s._camerasToBeAttached=[],s.SharpenPostProcessId="SharpenPostProcessEffect",s.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",s.FxaaPostProcessId="FxaaPostProcessEffect",s.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",s.GrainPostProcessId="GrainPostProcessEffect",s._glowLayer=null,s.animations=[],s._imageProcessingConfigurationObserver=null,s._sharpenEnabled=!1,s._bloomEnabled=!1,s._depthOfFieldEnabled=!1,s._depthOfFieldBlurLevel=af.Low,s._fxaaEnabled=!1,s._imageProcessingEnabled=!0,s._bloomScale=.5,s._chromaticAberrationEnabled=!1,s._grainEnabled=!1,s._buildAllowed=!0,s.onBuildObservable=new o.c,s._resizeObserver=null,s._hardwareScaleLevel=1,s._bloomKernel=64,s._bloomWeight=.15,s._bloomThreshold=.9,s._samples=1,s._hasCleared=!1,s._prevPostProcess=null,s._prevPrevPostProcess=null,s._depthOfFieldSceneObserver=null,s._cameras=r||n.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._buildAllowed=a,s._scene=n;var c=s._scene.getEngine().getCaps();s._hdr=i&&(c.textureHalfFloatRender||c.textureFloatRender),s._hdr?c.textureHalfFloatRender?s._defaultPipelineTextureType=g.a.TEXTURETYPE_HALF_FLOAT:c.textureFloatRender&&(s._defaultPipelineTextureType=g.a.TEXTURETYPE_FLOAT):s._defaultPipelineTextureType=g.a.TEXTURETYPE_UNSIGNED_INT,n.postProcessRenderPipelineManager.addPipeline(s);var l=s._scene.getEngine();return s.sharpen=new If("sharpen",1,null,Ke.a.BILINEAR_SAMPLINGMODE,l,!1,s._defaultPipelineTextureType,!0),s._sharpenEffect=new jd(l,s.SharpenPostProcessId,(function(){return s.sharpen}),!0),s.depthOfField=new lf(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),s.bloom=new Kd(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel,s._defaultPipelineTextureType,!0),s.chromaticAberration=new qd("ChromaticAberration",l.getRenderWidth(),l.getRenderHeight(),1,null,Ke.a.BILINEAR_SAMPLINGMODE,l,!1,s._defaultPipelineTextureType,!0),s._chromaticAberrationEffect=new jd(l,s.ChromaticAberrationPostProcessId,(function(){return s.chromaticAberration}),!0),s.grain=new vf("Grain",1,null,Ke.a.BILINEAR_SAMPLINGMODE,l,!1,s._defaultPipelineTextureType,!0),s._grainEffect=new jd(l,s.GrainPostProcessId,(function(){return s.grain}),!0),s._resizeObserver=l.onResizeObservable.add((function(){s._hardwareScaleLevel=l.getHardwareScalingLevel(),s.bloomKernel=s.bloomKernel})),s._imageProcessingConfigurationObserver=s._scene.imageProcessingConfiguration.onUpdateParameters.add((function(){s.bloom._downscale._exposure=s._scene.imageProcessingConfiguration.exposure,s.imageProcessingEnabled!==s._scene.imageProcessingConfiguration.isEnabled&&(s._imageProcessingEnabled=s._scene.imageProcessingConfiguration.isEnabled,s._buildPipeline())})),s._buildPipeline(),s}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomKernel",{get:function(){return this._bloomKernel},set:function(e){this._bloomKernel=e,this.bloom.kernel=e/this._hardwareScaleLevel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomWeight",{get:function(){return this._bloomWeight},set:function(e){this._bloomWeight!==e&&(this.bloom.weight=e,this._bloomWeight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomThreshold",{get:function(){return this._bloomThreshold},set:function(e){this._bloomThreshold!==e&&(this.bloom.threshold=e,this._bloomThreshold=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomScale",{get:function(){return this._bloomScale},set:function(e){this._bloomScale!==e&&(this._bloomScale=e,this._rebuildBloom(),this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new Kd(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var t=0;t1){for(var i=0,n=this._cameras;i-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 Yi("imageProcessing",1,null,Ke.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new jd(t,this.ImageProcessingPostProcessId,(function(){return e.imageProcessing}),!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1,this.cameras&&0!==this.cameras.length||(this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.imageProcessing.getEffect()||this.imageProcessing._updateParameters()),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new mf("fxaa",1,null,Ke.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new jd(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&&m.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),this.onBuildObservable.notifyObservers(this)}},t.prototype._disposePostProcesses=function(e){void 0===e&&(e=!1);for(var t=0;t1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);\nvec3 tangent=normalize(rvec-normal*dot(rvec,normal));\nvec3 bitangent=cross(normal,tangent);\nmat3 tbn=mat3(tangent,bitangent,normal);\nfloat difference;\nfor (int i=0; i1.0 || offset.y>1.0) {\ncontinue;\n}\n\n#ifndef GEOMETRYBUFFER\nfloat sampleDepth=abs(texture2D(depthNormalSampler,offset.xy).r);\n#else\nfloat sampleDepth=abs(texture2D(depthSampler,offset.xy).r);\n#endif\n\ndifference=depthSign*samplePosition.z-sampleDepth;\nfloat rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);\nocclusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;\n}\nocclusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor=vec4(vec3(result),1.0);\n}\n#endif\n#ifdef BILATERAL_BLUR\nuniform sampler2D depthNormalSampler;\nuniform float outSize;\nuniform float samplerOffsets[SAMPLES];\nvec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.3846153846)*direction;\nvec2 off2=vec2(3.2307692308)*direction;\ncolor+=texture2D(image,uv)*0.2270270270;\ncolor+=texture2D(image,uv+(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv-(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv+(off2/resolution))*0.0702702703;\ncolor+=texture2D(image,uv-(off2/resolution))*0.0702702703;\nreturn color;\n}\nvec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\ncolor+=texture2D(image,uv)*0.1964825501511404;\ncolor+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;\ncolor+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;\nreturn color;\n}\nvec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\nfloat compareDepth=abs(texture2D(depthNormalSampler,uv).r);\nfloat sampleDepth;\nfloat weight;\nfloat weightSum=30.0;\ncolor+=texture2D(image,uv)*30.0;\nsampleDepth=abs(texture2D(depthNormalSampler,uv+(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthNormalSampler,uv-(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthNormalSampler,uv+(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthNormalSampler,uv-(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthNormalSampler,uv+(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off3/resolution))*weight;\nsampleDepth=abs(texture2D(depthNormalSampler,uv-(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off3/resolution))*weight;\nreturn color/weightSum;\n}\nvoid main()\n{\n#if EXPENSIVE\nfloat compareDepth=abs(texture2D(depthNormalSampler,vUV).r);\nfloat texelsize=1.0/outSize;\nfloat result=0.0;\nfloat weightSum=0.0;\nfor (int i=0; i=2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SSAO2RenderingPipeline"},t.prototype.dispose=function(t){void 0===t&&(t=!1);for(var i=0;i0?i._ssaoCombinePostProcess.width:i._originalColorPostProcess.width),e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ),e.setFloat("radius",i.radius),i._forceGeometryBuffer?e.setTexture("depthNormalSampler",i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]):e.setTexture("depthNormalSampler",i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),e.setArray("samplerOffsets",i._samplerOffsets))},this._blurVPostProcess=new li("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthNormalSampler"],t,null,Ke.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(n?"1":"0")+"\n"),this._blurVPostProcess.onApply=function(e){i._scene.activeCamera&&(e.setFloat("outSize",i._ssaoCombinePostProcess.height>0?i._ssaoCombinePostProcess.height:i._originalColorPostProcess.height),e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ),e.setFloat("radius",i.radius),i._forceGeometryBuffer?e.setTexture("depthNormalSampler",i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]):e.setTexture("depthNormalSampler",i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),e.setArray("samplerOffsets",i._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 i=2*t*Math.PI,n=1-(.85*e+.15),r=Math.sqrt(1-n*n);return new a.e(Math.cos(i)*r,Math.sin(i)*r,n)},t.prototype._generateHemisphere=function(){for(var e,t=this.samples,i=[],n=0;n0.0)\nhitCoord-=dir;\nelse\nhitCoord+=dir;\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\n}\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\n\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,1.0);\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.color/=float(SMOOTH_STEPS+1);\nreturn info;\n}\n\nReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)\n{\nReflectionInfo info;\nvec4 projectedCoord;\nfloat sampledDepth;\ndir*=step;\nfor(int i=0; i>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join("\n"))},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"threshold",void 0),Object(h.c)([Object(w.c)()],t.prototype,"strength",void 0),Object(h.c)([Object(w.c)()],t.prototype,"reflectionSpecularFalloffExponent",void 0),Object(h.c)([Object(w.c)()],t.prototype,"step",void 0),Object(h.c)([Object(w.c)()],t.prototype,"roughnessFactor",void 0),Object(h.c)([Object(w.c)()],t.prototype,"enableSmoothReflections",null),Object(h.c)([Object(w.c)()],t.prototype,"reflectionSamples",null),Object(h.c)([Object(w.c)()],t.prototype,"smoothSteps",null),t}(li);c.a.RegisteredTypes["BABYLON.ScreenSpaceReflectionPostProcess"]=Yf;var Kf="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";ai.a.ShadersStore.standardPixelShader=Kf;var Qf=function(e){function t(t,i,n,r,o){void 0===r&&(r=null);var a=e.call(this,i.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||i.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._scene=i,a._basePostProcess=r,a._ratio=n,a._floatTextureType=i.getEngine().getCaps().textureFloatRender?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_HALF_FLOAT,i.postProcessRenderPipelineManager.addPipeline(a),a._buildPipeline(),a}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"exposure",{get:function(){return this._fixedExposure},set:function(e){this._fixedExposure=e,this._currentExposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hdrAutoExposure",{get:function(){return this._hdrAutoExposure},set:function(e){if(this._hdrAutoExposure=e,this.hdrPostProcess){var t=["#define HDR"];e&&t.push("#define AUTO_EXPOSURE"),this.hdrPostProcess.updateEffect(t.join("\n"))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionStrength",{get:function(){return this._motionStrength},set:function(e){this._motionStrength=e,this._isObjectBasedMotionBlur&&this.motionBlurPostProcess&&(this.motionBlurPostProcess.motionStrength=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"objectBasedMotionBlur",{get:function(){return this._isObjectBasedMotionBlur},set:function(e){var t=this._isObjectBasedMotionBlur!==e;this._isObjectBasedMotionBlur=e,t&&this._buildPipeline()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"VLSEnabled",{get:function(){return this._vlsEnabled},set:function(e){if(this._vlsEnabled!==e){if(e)if(!this._scene.enableGeometryBufferRenderer())return void m.a.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");this._vlsEnabled=e,this._buildPipeline()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"MotionBlurEnabled",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"screenSpaceReflectionsEnabled",{get:function(){return this._screenSpaceReflectionsEnabled},set:function(e){this._screenSpaceReflectionsEnabled!==e&&(this._screenSpaceReflectionsEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"volumetricLightStepsCount",{get:function(){return this._volumetricLightStepsCount},set:function(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS "+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this.motionBlurPostProcess&&(this._isObjectBasedMotionBlur?this.motionBlurPostProcess.motionBlurSamples=e:this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+e.toFixed(1))),this._motionBlurSamples=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._buildPipeline=function(){var e=this,t=this._ratio,i=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 Yf("HDRPass",i,t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.screenSpaceReflectionPostProcess})),this.addEffect(new jd(i.getEngine(),"HDRScreenSpaceReflections",(function(){return e.screenSpaceReflectionPostProcess}),!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new li("HDRPass","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),this.originalPostProcess.autoClear=!this.screenSpaceReflectionPostProcess,this.originalPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.originalPostProcess})),this.addEffect(new jd(i.getEngine(),"HDRPassPostProcess",(function(){return e.originalPostProcess}),!0)),this._bloomEnabled&&(this._createDownSampleX4PostProcess(i,t/4),this._createBrightPassPostProcess(i,t/4),this._createBlurPostProcesses(i,t/4,1),this._createTextureAdderPostProcess(i,t),this.textureAdderFinalPostProcess=new li("HDRDepthOfFieldSource","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),"HDRBaseDepthOfFieldSource",(function(){return e.textureAdderFinalPostProcess}),!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(i,t),this.volumetricLightFinalPostProcess=new li("HDRVLSFinal","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),"HDRVLSFinal",(function(){return e.volumetricLightFinalPostProcess}),!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(i,t),this.lensFlareFinalPostProcess=new li("HDRPostLensFlareDepthOfFieldSource","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),"HDRPostLensFlareDepthOfFieldSource",(function(){return e.lensFlareFinalPostProcess}),!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(i,this._floatTextureType),this._createHdrPostProcess(i,t),this.hdrFinalPostProcess=new li("HDRPostHDReDepthOfFieldSource","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),"HDRPostHDReDepthOfFieldSource",(function(){return e.hdrFinalPostProcess}),!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(i,t/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(i,t)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(i,t),this._fxaaEnabled&&(this.fxaaPostProcess=new mf("fxaa",1,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.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&&m.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")},t.prototype._createDownSampleX4PostProcess=function(e,t){var i=this,n=new Array(32);this.downSampleX4PostProcess=new li("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,r=i.downSampleX4PostProcess.width,o=i.downSampleX4PostProcess.height,a=-2;a<2;a++)for(var s=-2;s<2;s++)n[t]=(a+.5)*(1/r),n[t+1]=(s+.5)*(1/o),t+=2;e.setArray2("dsOffsets",n)},this.addEffect(new jd(e.getEngine(),"HDRDownSampleX4",(function(){return i.downSampleX4PostProcess}),!0))},t.prototype._createBrightPassPostProcess=function(e,t){var i=this,n=new Array(8);this.brightPassPostProcess=new li("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),this.brightPassPostProcess.onApply=function(e){var t=1/i.brightPassPostProcess.width,r=1/i.brightPassPostProcess.height;n[0]=-.5*t,n[1]=.5*r,n[2]=.5*t,n[3]=.5*r,n[4]=-.5*t,n[5]=-.5*r,n[6]=.5*t,n[7]=-.5*r,e.setArray2("dsOffsets",n),e.setFloat("brightThreshold",i.brightThreshold)},this.addEffect(new jd(e.getEngine(),"HDRBrightPass",(function(){return i.brightPassPostProcess}),!0))},t.prototype._createBlurPostProcesses=function(e,t,i,n){var r=this;void 0===n&&(n="blurWidth");var o=e.getEngine(),s=new eo("HDRBlurH_"+i,new a.d(1,0),this[n],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),c=new eo("HDRBlurV_"+i,new a.d(0,1),this[n],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);s.onActivateObservable.add((function(){var e=s.width/o.getRenderWidth();s.kernel=r[n]*e})),c.onActivateObservable.add((function(){var e=c.height/o.getRenderHeight();c.kernel=r.horizontalBlur?64*e:r[n]*e})),this.addEffect(new jd(e.getEngine(),"HDRBlurH"+i,(function(){return s}),!0)),this.addEffect(new jd(e.getEngine(),"HDRBlurV"+i,(function(){return c}),!0)),this.blurHPostProcesses.push(s),this.blurVPostProcesses.push(c)},t.prototype._createTextureAdderPostProcess=function(e,t){var i=this;this.textureAdderPostProcess=new li("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",i._vlsEnabled?i._currentDepthOfFieldSource:i.originalPostProcess),e.setTexture("lensSampler",i.lensTexture),e.setFloat("exposure",i._currentExposure),i._currentDepthOfFieldSource=i.textureAdderFinalPostProcess},this.addEffect(new jd(e.getEngine(),"HDRTextureAdder",(function(){return i.textureAdderPostProcess}),!0))},t.prototype._createVolumetricLightPostProcess=function(e,t){var i=this,n=e.enableGeometryBufferRenderer();n.enablePosition=!0;var r=n.getGBuffer();this.volumetricLightPostProcess=new li("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var o=a.d.Zero();this.volumetricLightPostProcess.onApply=function(e){if(i.sourceLight&&i.sourceLight.getShadowGenerator()&&i._scene.activeCamera){var t=i.sourceLight.getShadowGenerator();e.setTexture("shadowMapSampler",t.getShadowMap()),e.setTexture("positionSampler",r.textures[2]),e.setColor3("sunColor",i.sourceLight.diffuse),e.setVector3("sunDirection",i.sourceLight.getShadowDirection()),e.setVector3("cameraPosition",i._scene.activeCamera.globalPosition),e.setMatrix("shadowViewProjection",t.getTransformMatrix()),e.setFloat("scatteringCoefficient",i.volumetricLightCoefficient),e.setFloat("scatteringPower",i.volumetricLightPower),o.x=i.sourceLight.getDepthMinZ(i._scene.activeCamera),o.y=i.sourceLight.getDepthMaxZ(i._scene.activeCamera),e.setVector2("depthValues",o)}},this.addEffect(new jd(e.getEngine(),"HDRVLS",(function(){return i.volumetricLightPostProcess}),!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new li("HDRVLSMerge","standard",[],["originalSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(e){e.setTextureFromPostProcess("originalSampler",i._bloomEnabled?i.textureAdderFinalPostProcess:i.originalPostProcess),i._currentDepthOfFieldSource=i.volumetricLightFinalPostProcess},this.addEffect(new jd(e.getEngine(),"HDRVLSMerge",(function(){return i.volumetricLightMergePostProces}),!0))},t.prototype._createLuminancePostProcesses=function(e,i){var n=this,r=Math.pow(3,t.LuminanceSteps);this.luminancePostProcess=new li("HDRLuminance","standard",["lumOffsets"],[],{width:r,height:r},null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",i);var o=[];this.luminancePostProcess.onApply=function(e){var t=1/n.luminancePostProcess.width,i=1/n.luminancePostProcess.height;o[0]=-.5*t,o[1]=.5*i,o[2]=.5*t,o[3]=.5*i,o[4]=-.5*t,o[5]=-.5*i,o[6]=.5*t,o[7]=-.5*i,e.setArray2("lumOffsets",o)},this.addEffect(new jd(e.getEngine(),"HDRLuminance",(function(){return n.luminancePostProcess}),!0));for(var s=t.LuminanceSteps-1;s>=0;s--){r=Math.pow(3,s);var c="#define LUMINANCE_DOWN_SAMPLE\n";0===s&&(c+="#define FINAL_DOWN_SAMPLER");var l=new li("HDRLuminanceDownSample"+s,"standard",["dsOffsets","halfDestPixelSize"],[],{width:r,height:r},null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,c,i);this.luminanceDownSamplePostProcesses.push(l)}var u=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(t,i){var r=new Array(18);t.onApply=function(e){if(u){for(var o=0,a=-1;a<2;a++)for(var s=-1;s<2;s++)r[o]=a/u.width,r[o+1]=s/u.height,o+=2;e.setArray2("dsOffsets",r),e.setFloat("halfDestPixelSize",.5/u.width),u=i===n.luminanceDownSamplePostProcesses.length-1?n.luminancePostProcess:t}},i===n.luminanceDownSamplePostProcesses.length-1&&(t.onAfterRender=function(){var t=e.getEngine().readPixels(0,0,1,1),i=new a.f(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(t[0]*i.x+t[1]*i.y+t[2]*i.z+t[3]*i.w)/100}),n.addEffect(new jd(e.getEngine(),"HDRLuminanceDownSample"+i,(function(){return t}),!0))}))},t.prototype._createHdrPostProcess=function(e,t){var i=this,n=["#define HDR"];this._hdrAutoExposure&&n.push("#define AUTO_EXPOSURE"),this.hdrPostProcess=new li("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,n.join("\n"),g.a.TEXTURETYPE_UNSIGNED_INT);var r=1,o=0,a=0;this.hdrPostProcess.onApply=function(t){if(t.setTextureFromPostProcess("textureAdderSampler",i._currentDepthOfFieldSource),o+=e.getEngine().getDeltaTime(),r<0)r=i._hdrCurrentLuminance;else{var n=(a-o)/1e3;i._hdrCurrentLuminancer-i.hdrIncreaseRate*n?r-=i.hdrIncreaseRate*n:r=i._hdrCurrentLuminance}i.hdrAutoExposure?i._currentExposure=i._fixedExposure/r:(r=L.a.Clamp(r,i.hdrMinimumLuminance,1e20),t.setFloat("averageLuminance",r)),a=o,i._currentDepthOfFieldSource=i.hdrFinalPostProcess},this.addEffect(new jd(e.getEngine(),"HDR",(function(){return i.hdrPostProcess}),!0))},t.prototype._createLensFlarePostProcess=function(e,t){var i=this;this.lensFlarePostProcess=new li("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(e.getEngine(),"HDRLensFlare",(function(){return i.lensFlarePostProcess}),!0)),this._createBlurPostProcesses(e,t/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new li("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(e.getEngine(),"HDRLensFlareCompose",(function(){return i.lensFlareComposePostProcess}),!0));var n=new a.d(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",i._bloomEnabled?i.blurHPostProcesses[0]:i.originalPostProcess),e.setTexture("lensColorSampler",i.lensColorTexture),e.setFloat("strength",i.lensFlareStrength),e.setFloat("ghostDispersal",i.lensFlareGhostDispersal),e.setFloat("haloWidth",i.lensFlareHaloWidth),n.x=i.lensFlarePostProcess.width,n.y=i.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",i.lensFlareDistortionStrength)};var r=a.a.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),o=a.a.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(e){if(i._scene.activeCamera){e.setTextureFromPostProcess("otherSampler",i.lensFlarePostProcess),e.setTexture("lensDirtSampler",i.lensFlareDirtTexture),e.setTexture("lensStarSampler",i.lensStarTexture);var t=i._scene.activeCamera.getViewMatrix().getRow(0),n=i._scene.activeCamera.getViewMatrix().getRow(2),s=a.e.Dot(t.toVector3(),new a.e(1,0,0))+a.e.Dot(n.toVector3(),new a.e(0,0,1));s*=4;var c=a.a.FromValues(.5*Math.cos(s),-Math.sin(s),0,0,Math.sin(s),.5*Math.cos(s),0,0,0,0,1,0,0,0,0,1),l=o.multiply(c).multiply(r);e.setMatrix("lensStarMatrix",l),i._currentDepthOfFieldSource=i.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,t){var i=this;this.depthOfFieldPostProcess=new li("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",g.a.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",i._currentDepthOfFieldSource),e.setTexture("depthSampler",i._getDepthTexture()),e.setFloat("distance",i.depthOfFieldDistance)},this.addEffect(new jd(e.getEngine(),"HDRDepthOfField",(function(){return i.depthOfFieldPostProcess}),!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var i=this;if(this._isObjectBasedMotionBlur){var n=new Rf("HDRMotionBlur",e,t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,g.a.TEXTURETYPE_UNSIGNED_INT);n.motionStrength=this.motionStrength,n.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=n}else{this.motionBlurPostProcess=new li("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),g.a.TEXTURETYPE_UNSIGNED_INT);var r=0,o=a.a.Identity(),s=a.a.Identity(),c=a.a.Identity(),l=a.d.Zero();this.motionBlurPostProcess.onApply=function(t){(c=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(s),t.setMatrix("inverseViewProjection",s),t.setMatrix("prevViewProjection",o),o=c,l.x=i.motionBlurPostProcess.width,l.y=i.motionBlurPostProcess.height,t.setVector2("screenSize",l),r=e.getEngine().getFps()/60,t.setFloat("motionScale",r),t.setFloat("motionStrength",i.motionStrength),t.setTexture("depthSampler",i._getDepthTexture())}}this.addEffect(new jd(e.getEngine(),"HDRMotionBlur",(function(){return i.motionBlurPostProcess}),!0))},t.prototype._getDepthTexture=function(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},t.prototype._disposePostProcesses=function(){for(var e=0;e0&&-1!==this.excludedMeshes.indexOf(e)},t.prototype._createPass=function(e,t){var i=this,n=e.getEngine();this._volumetricLightScatteringRTT=new Ni("volumetricLightScatteringMap",{width:n.getRenderWidth()*t,height:n.getRenderHeight()*t},e,!1,!0,g.a.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var r=this.getCamera();r?r.customRenderTargets.push(this._volumetricLightScatteringRTT):e.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,a=function(e){var t=e.getRenderingMesh(),n=e.getEffectiveMesh();if(!i._meshExcluded(t)){n._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var r=e.getMaterial();if(r){var o=t.getScene(),a=o.getEngine();a.setState(r.backFaceCulling);var s=t._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(!s.mustReturn){var c=a.getCaps().instancedArrays&&(null!==s.visibleInstances[e._id]||t.hasThinInstances);if(i._isReady(e,c)){var l=i._volumetricLightScatteringPass;if(t===i.mesh&&(l=e.effect?e.effect:r.getEffect()),a.enableEffect(l),t._bind(e,l,r.fillMode),t===i.mesh)r.bind(n.getWorldMatrix(),t);else{if(i._volumetricLightScatteringPass.setMatrix("viewProjection",o.getTransformMatrix()),r&&r.needAlphaTesting()){var u=r.getAlphaTestTexture();i._volumetricLightScatteringPass.setTexture("diffuseSampler",u),u&&i._volumetricLightScatteringPass.setMatrix("diffuseMatrix",u.getTextureMatrix())}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&i._volumetricLightScatteringPass.setMatrices("mBones",t.skeleton.getTransformMatrices(t))}t._processRendering(n,e,i._volumetricLightScatteringPass,xo.a.TriangleFillMode,s,c,(function(e,t){return l.setMatrix("world",t)}))}}}}},c=new s.b(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=e.clearColor,e.clearColor=c})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){e.clearColor=o})),this._volumetricLightScatteringRTT.customRenderFunction=function(t,i,n,r){var o,s=e.getEngine();if(r.length){for(s.setColorWrite(!1),o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),s.setAlphaMode(g.a.ALPHA_COMBINE),o=0;o1||e.getCaps().drawBuffersExtension)},enumerable:!1,configurable:!0}),t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"ridge",void 0),Object(h.c)([Object(w.c)()],t.prototype,"valley",void 0),t}(li);c.a.RegisteredTypes["BABYLON.ScreenSpaceCurvaturePostProcess"]=sp;i(166),i(167);Object.defineProperty(Q.a.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(e){this._forceShowBoundingBoxes=e,e&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),Q.a.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new cp(this)),this._boundingBoxRenderer},Object.defineProperty(Ge.a.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(e){this._showBoundingBox=e,e&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});var cp=function(){function e(e){this.name=Me.a.NAME_BOUNDINGBOXRENDERER,this.frontColor=new s.a(1,1,1),this.backColor=new s.a(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new o.c,this.onAfterBoxRenderingObservable=new o.c,this.onResourcesReadyObservable=new o.c,this.enabled=!0,this.renderList=new oi.a(32),this._vertexBuffers={},this._fillIndexBuffer=null,this._fillIndexData=null,this.scene=e,e._addComponent(this)}return e.prototype.register=function(){this.scene._beforeEvaluateActiveMeshStage.registerStep(Me.a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(Me.a.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(Me.a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(Me.a.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)},e.prototype._evaluateSubMesh=function(e,t){if(e.showSubMeshesBoundingBox){var i=t.getBoundingInfo();null!=i&&(i.boundingBox._tag=e.renderingGroupId,this.renderList.push(i.boundingBox))}},e.prototype._preActiveMesh=function(e){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){var t=e.getBoundingInfo();t.boundingBox._tag=e.renderingGroupId,this.renderList.push(t.boundingBox)}},e.prototype._prepareResources=function(){if(!this._colorShader){this._colorShader=new Lc.a("colorShader",this.scene,"color",{attributes:[Qi.b.PositionKind],uniforms:["world","viewProjection","color"]}),this._colorShader.reservedDataStore={hidden:!0};var e=this.scene.getEngine(),t=Ki.a.CreateBox({size:1});this._vertexBuffers[Qi.b.PositionKind]=new Qi.b(e,t.positions,Qi.b.PositionKind,!1),this._createIndexBuffer(),this._fillIndexData=t.indices,this.onResourcesReadyObservable.notifyObservers(this)}},e.prototype._createIndexBuffer=function(){var e=this.scene.getEngine();this._indexBuffer=e.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])},e.prototype.rebuild=function(){var e=this._vertexBuffers[Qi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.reset=function(){this.renderList.reset()},e.prototype.render=function(e){if(0!==this.renderList.length&&this.enabled&&(this._prepareResources(),this._colorShader.isReady())){var t=this.scene.getEngine();t.setDepthWrite(!1),this._colorShader._preBind();for(var i=0;i=0&&t.push(i);for(var n=0;n=e[0].length&&e[1].length>=e[2].length?o=1:e[2].length>=e[0].length&&e[2].length>=e[1].length&&(o=2);for(var a=0;a<3;++a)a===o?e[a].sort((function(e,t){return e[1]t[1]?1:0})):e[a].sort((function(e,t){return e[1]>t[1]?-1:e[1]=o+1;--u)r(e[u%3],c,u!==o+2?n[i[t+(u+1)%3]]:-1);var h=c.length;i.push(n[i[t+o]],s[0],c[0]),i.push(n[i[t+(o+1)%3]],c[h-1],s[l-1]);for(var d=l<=h,f=d?l:h,p=d?h:l,_=d?l-1:h-1,m=d?0:1,g=l+h-2,v=0,b=0,y=d?s:c,T=d?c:s,E=0;g-- >0;){m?i.push(y[v],T[b]):i.push(T[b],y[v]);var S=void 0;(E+=f)>=p&&v<_?(S=y[++v],E-=p):S=T[++b],i.push(S)}i[t+0]=i[i.length-3],i[t+1]=i[i.length-2],i[t+2]=i[i.length-1],i.length=i.length-3},e.prototype._generateEdgesLinesAlternate=function(){var e,t,i,n,r,o,s,c,l,u=this._source.getVerticesData(Qi.b.PositionKind),h=this._source.getIndices();if(h&&u){Array.isArray(h)||(h=Ce.b.SliceToArray(h));var d=null===(t=null===(e=this._options)||void 0===e?void 0:e.useFastVertexMerger)||void 0===t||t,f=d?Math.round(-Math.log(null!==(n=null===(i=this._options)||void 0===i?void 0:i.epsilonVertexMerge)&&void 0!==n?n:1e-6)/Math.log(10)):null!==(o=null===(r=this._options)||void 0===r?void 0:r.epsilonVertexMerge)&&void 0!==o?o:1e-6,p=[],_=[];if(d)for(var m={},g=0;gN){var $=D;D=N,N=$}if(te=Z[ee=D+"_"+N]){if(!te.done)a.e.Dot(J,te.normal)0||this._source.hasThinInstances)},e.prototype.render=function(){var e=this._source.getScene();if(this.isReady()&&e.activeCamera){var t=e.getEngine();this._lineShader._preBind(),1!==this._source.edgesColor.a?t.setAlphaMode(g.a.ALPHA_COMBINE):t.setAlphaMode(g.a.ALPHA_DISABLE);var i=this._source.hasInstances&&this.customInstances.length>0,n=i||this._source.hasThinInstances,r=0;if(n)if(this._buffersForInstances.world0=this._source.getVertexBuffer("world0"),this._buffersForInstances.world1=this._source.getVertexBuffer("world1"),this._buffersForInstances.world2=this._source.getVertexBuffer("world2"),this._buffersForInstances.world3=this._source.getVertexBuffer("world3"),i){var o=this._source._instanceDataStorage;if(r=this.customInstances.length,!o.isFrozen){for(var a=0,s=0;s0&&(t.push(!0),i.push(!1));this._multiRenderAttachments=this._engine.buildTextureLayout(e),this._clearAttachments=this._engine.buildTextureLayout(t),this._defaultAttachments=this._engine.buildTextureLayout(i)},e.prototype._createCompositionEffect=function(){this.prePassRT=new Hc("sceneprePassRT",{width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()},this.mrtCount,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:g.a.TEXTURETYPE_UNSIGNED_INT,types:this._mrtFormats}),this.prePassRT.samples=1,this._initializeAttachments(),this._useGeometryBufferFallback&&!this._geometryBuffer&&(this.useGeometryBufferFallback=!0),this.imageProcessingPostProcess=new Yi("sceneCompositionPass",1,null,void 0,this._engine),this.imageProcessingPostProcess.autoClear=!1},Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._engine.webGLVersion>1||this._scene.getEngine().getCaps().drawBuffersExtension},enumerable:!1,configurable:!0}),e.prototype.bindAttachmentsForEffect=function(e,t){if(this.enabled)if(e._multiTarget)this._engine.bindAttachments(this._multiRenderAttachments);else if(this._engine.bindAttachments(this._defaultAttachments),this._geometryBuffer){var i=t.getMaterial();i&&-1===this.excludedMaterials.indexOf(i)&&this._geometryBuffer.renderList.push(t.getRenderingMesh())}},e.prototype.restoreAttachments=function(){this.enabled&&this._defaultAttachments&&this._engine.bindAttachments(this._defaultAttachments)},e.prototype._beforeCameraDraw=function(){this._isDirty&&this._update(),this._geometryBuffer&&(this._geometryBuffer.renderList.length=0),this._bindFrameBuffer()},e.prototype._afterCameraDraw=function(){if(this._enabled){var e=this._scene.activeCamera&&this._scene.activeCamera._getFirstPostProcess();e&&this._postProcesses.length&&this._scene.postProcessManager._prepareFrame(),this._scene.postProcessManager.directRender(this._postProcesses,e?e.inputTexture:null)}},e.prototype._checkRTSize=function(){var e=this._engine.getRenderWidth(!0),t=this._engine.getRenderHeight(!0),i=this.prePassRT.getRenderWidth(),n=this.prePassRT.getRenderHeight();i===e&&n===t||(this.prePassRT.resize({width:e,height:t}),this._updateGeometryBufferLayout(),this._bindPostProcessChain())},e.prototype._bindFrameBuffer=function(){if(this._enabled){this._checkRTSize();var e=this.prePassRT.getInternalTexture();e&&this._engine.bindFramebuffer(e)}},e.prototype.clear=function(){this._enabled&&(this._bindFrameBuffer(),this._engine.clear(this._scene.clearColor,this._scene.autoClear||this._scene.forceWireframe||this._scene.forcePointsCloud,this._scene.autoClearDepthAndStencil,this._scene.autoClearDepthAndStencil),this._engine.bindAttachments(this._clearAttachments),this._engine.clear(this._clearColor,!0,!1,!1),this._engine.bindAttachments(this._defaultAttachments))},e.prototype._setState=function(e){this._enabled=e,this._scene.prePass=e,this.imageProcessingPostProcess&&(this.imageProcessingPostProcess.imageProcessingConfiguration.applyByPostProcess=e)},e.prototype._updateGeometryBufferLayout=function(){if(this._geometryBuffer){this._geometryBuffer._resetLayout();for(var e=[],t=0;t=5)return m.a.Error("You already reached the maximum number of diffusion profiles."),0;for(var t=0;t4&&(n.push(Qi.b.MatricesIndicesExtraKind),n.push(Qi.b.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),i.push("#define BonesPerMesh "+(r.skeleton?r.skeleton.bones.length+1:0))):i.push("#define NUM_BONE_INFLUENCERS 0");var a=r.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,i.push("#define MORPHTARGETS"),i.push("#define NUM_MORPH_INFLUENCERS "+s),ro.a.PrepareAttributesForMorphTargetsInfluencers(n,r,s)),t&&(i.push("#define INSTANCES"),ro.a.PushAttributesForInstances(n),e.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES"));var c=i.join("\n");return this._cachedDefines!==c&&(this._cachedDefines=c,this._effect=this.scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences"],["diffuseSampler"],c,void 0,void 0,void 0,{maxSimultaneousMorphTargets:s})),this._effect.isReady()},e.prototype._beforeRenderingMesh=function(t,i,n){if(this._savedDepthWrite=this._engine.getDepthWrite(),t.renderOutline){var r=i.getMaterial();r&&r.needAlphaBlendingForMesh(t)&&(this._engine.cacheStencilState(),this._engine.setDepthWrite(!1),this._engine.setColorWrite(!1),this._engine.setStencilBuffer(!0),this._engine.setStencilOperationPass(g.a.REPLACE),this._engine.setStencilFunction(g.a.ALWAYS),this._engine.setStencilMask(e._StencilReference),this._engine.setStencilFunctionReference(e._StencilReference),this.render(i,n,!0),this._engine.setColorWrite(!0),this._engine.setStencilFunction(g.a.NOTEQUAL)),this._engine.setDepthWrite(!1),this.render(i,n),this._engine.setDepthWrite(this._savedDepthWrite),r&&r.needAlphaBlendingForMesh(t)&&this._engine.restoreStencilState()}},e.prototype._afterRenderingMesh=function(e,t,i){if(e.renderOverlay){var n=this._engine.getAlphaMode(),r=this._engine.alphaState.alphaBlend;this._engine.setAlphaMode(g.a.ALPHA_COMBINE),this.render(t,i,!0),this._engine.setAlphaMode(n),this._engine.setDepthWrite(this._savedDepthWrite),this._engine.alphaState.alphaBlend=r}e.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(t,i),this._engine.setColorWrite(!0))},e._StencilReference=4,e}(),Pp=i(148),Cp=function(e){function t(t,i){var n=e.call(this)||this;return n.name=t,n.animations=new Array,n.isPickable=!1,n.useAlphaForPicking=!1,n.onDisposeObservable=new o.c,n._onAnimationEnd=null,n._endAnimation=function(){n._onAnimationEnd&&n._onAnimationEnd(),n.disposeWhenFinishedAnimating&&n.dispose()},n.color=new s.b(1,1,1,1),n.position=a.e.Zero(),n._manager=i,n._manager.sprites.push(n),n.uniqueId=n._manager.scene.getUniqueId(),n}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manager",{get:function(){return this._manager},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"Sprite"},Object.defineProperty(t.prototype,"fromIndex",{get:function(){return this._fromIndex},set:function(e){this.playAnimation(e,this._toIndex,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toIndex",{get:function(){return this._toIndex},set:function(e){this.playAnimation(this._fromIndex,e,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loopAnimation",{get:function(){return this._loopAnimation},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,e,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"delay",{get:function(){return Math.max(this._delay,1)},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,this._loopAnimation,e,this._onAnimationEnd)},enumerable:!1,configurable:!0}),t.prototype.playAnimation=function(t,i,n,r,o){void 0===o&&(o=null),this._onAnimationEnd=o,e.prototype.playAnimation.call(this,t,i,n,r,this._endAnimation)},t.prototype.dispose=function(){for(var e=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._onBaseAnimationEnd&&this._onBaseAnimationEnd()))))},e}());Q.a.prototype._internalPickSprites=function(e,t,i,n){if(!gn.a)return null;var r=null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}if(this.spriteManagers.length>0)for(var o=0;o=r.distance))&&(r=s,i))break}}return r||new gn.a},Q.a.prototype._internalMultiPickSprites=function(e,t,i){if(!gn.a)return null;var n=new Array;if(!i){if(!this.activeCamera)return null;i=this.activeCamera}if(this.spriteManagers.length>0)for(var r=0;r0&&(i=r.pickSprite(e,t,this._spritePredicate,!1,r.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite&&i.pickedSprite.actionManager){switch(r._pickedDownSprite=i.pickedSprite,n.button){case 0:i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnLeftPickTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n));break;case 1:i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnCenterPickTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n));break;case 2:i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnRightPickTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n))}i.pickedSprite.actionManager&&i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickDownTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n))}return i},e.prototype._pointerUp=function(e,t,i,n){var r=this.scene;if(r.spriteManagers.length>0){var o=r.pickSprite(e,t,this._spritePredicate,!1,r.cameraToUseForPointers||void 0);o&&(o.hit&&o.pickedSprite&&o.pickedSprite.actionManager&&(o.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickUpTrigger,u.a.CreateNewFromSprite(o.pickedSprite,r,n)),o.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||o.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickTrigger,u.a.CreateNewFromSprite(o.pickedSprite,r,n)))),r._pickedDownSprite&&r._pickedDownSprite.actionManager&&r._pickedDownSprite!==o.pickedSprite&&r._pickedDownSprite.actionManager.processTrigger(g.a.ACTION_OnPickOutTrigger,u.a.CreateNewFromSprite(r._pickedDownSprite,r,n)))}return i},e}();ai.a.IncludesShadersStore.imageProcessingCompatibility="#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\n#endif";var xp="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#include\n}";ai.a.ShadersStore.spritesPixelShader=xp;var Op="\nattribute vec4 position;\nattribute vec2 options;\nattribute vec2 offsets;\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=offsets.xy;\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}";ai.a.ShadersStore.spritesVertexShader=Op;var Mp=function(){function e(e,t,i,n){if(void 0===i&&(i=.01),void 0===n&&(n=null),this.blendMode=g.a.ALPHA_COMBINE,this.autoResetAlpha=!0,this.disableDepthWrite=!1,this.fogEnabled=!0,this._useVAO=!1,this._useInstancing=!1,this._vertexBuffers={},this._capacity=t,this._epsilon=i,this._engine=e,this._useInstancing=e.getCaps().instancedArrays,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects,this._scene=n,!this._useInstancing){for(var r=[],o=0,a=0;a>0;t._xOffset=(t.cellIndex-l*c)*this.cellWidth/r.width,t._yOffset=l*this.cellHeight/r.height,t._xSize=this.cellWidth,t._ySize=this.cellHeight}this._vertexData[s]=t.position.x,this._vertexData[s+1]=t.position.y,this._vertexData[s+2]=t.position.z,this._vertexData[s+3]=t.angle,this._vertexData[s+4]=t.width,this._vertexData[s+5]=t.height,this._useInstancing?s-=2:(this._vertexData[s+6]=i,this._vertexData[s+7]=n),this._vertexData[s+8]=o?t.invertU?0:1:t.invertU?1:0,this._vertexData[s+9]=t.invertV?1:0,this._vertexData[s+10]=t._xOffset,this._vertexData[s+11]=t._yOffset,this._vertexData[s+12]=t._xSize/r.width,this._vertexData[s+13]=t._ySize/r.height,this._vertexData[s+14]=t.color.r,this._vertexData[s+15]=t.color.g,this._vertexData[s+16]=t.color.b,this._vertexData[s+17]=t.color.a},e.prototype.dispose=function(){this._buffer&&(this._buffer.dispose(),this._buffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),this.texture&&(this.texture.dispose(),this.texture=null)},e}(),Ip=function(){function e(e,t,i,n,r,a,s,c,l){var u=this;void 0===a&&(a=.01),void 0===s&&(s=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=!1),void 0===l&&(l=null),this.name=e,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.isPickable=!1,this.onDisposeObservable=new o.c,this.disableDepthWrite=!1,this._packedAndReady=!1,this._customUpdate=function(e,t){e.cellRef||(e.cellIndex=0);var i=e.cellIndex;"number"==typeof i&&isFinite(i)&&Math.floor(i)===i&&(e.cellRef=u._spriteMap[e.cellIndex]),e._xOffset=u._cellData[e.cellRef].frame.x/t.width,e._yOffset=u._cellData[e.cellRef].frame.y/t.height,e._xSize=u._cellData[e.cellRef].frame.w,e._ySize=u._cellData[e.cellRef].frame.h},r||(r=Se.a.LastCreatedScene),r._getComponent(Me.a.NAME_SPRITE)||r._addComponent(new Rp(r)),this._fromPacked=c,this._scene=r;var h=this._scene.getEngine();if(this._spriteRenderer=new Mp(h,i,a,r),n.width&&n.height)this.cellWidth=n.width,this.cellHeight=n.height;else{if(void 0===n)return void(this._spriteRenderer=null);this.cellWidth=n,this.cellHeight=n}this._scene.spriteManagers.push(this),this.uniqueId=this.scene.getUniqueId(),t&&(this.texture=new Ke.a(t,r,!0,!1,s)),this._fromPacked&&this._makePacked(t,l)}return Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this.sprites},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capacity",{get:function(){return this._spriteRenderer.capacity},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texture",{get:function(){return this._spriteRenderer.texture},set:function(e){e.wrapU=Ke.a.CLAMP_ADDRESSMODE,e.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._spriteRenderer.texture=e,this._textureContent=null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellWidth",{get:function(){return this._spriteRenderer.cellWidth},set:function(e){this._spriteRenderer.cellWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellHeight",{get:function(){return this._spriteRenderer.cellHeight},set:function(e){this._spriteRenderer.cellHeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fogEnabled",{get:function(){return this._spriteRenderer.fogEnabled},set:function(e){this._spriteRenderer.fogEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blendMode",{get:function(){return this._spriteRenderer.blendMode},set:function(e){this._spriteRenderer.blendMode=e},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"SpriteManager"},e.prototype._makePacked=function(e,t){var i=this;if(null!==t)try{var n=void 0;if((n="string"==typeof t?JSON.parse(t):t).frames.length){for(var r={},o=0;o0);var u=e.substring(0,l-1)+".json",h=new XMLHttpRequest;h.open("GET",u,!0),h.onerror=function(){m.a.Error("JSON ERROR: Unable to load JSON file."),i._fromPacked=!1,i._packedAndReady=!1},h.onload=function(){try{var e=JSON.parse(h.response),t=Reflect.ownKeys(e.frames);i._spriteMap=t,i._packedAndReady=!0,i._cellData=e.frames}catch(e){throw i._fromPacked=!1,i._packedAndReady=!1,new Error("Invalid JSON format. Please check documentation for format specifications.")}},h.send()}},e.prototype._checkTextureAlpha=function(e,t,i,n,r){if(!e.useAlphaForPicking||!this.texture)return!0;var o=this.texture.getSize();this._textureContent||(this._textureContent=new Uint8Array(o.width*o.height*4),this.texture.readPixels(0,0,this._textureContent));var s=a.c.Vector3[0];s.copyFrom(t.direction),s.normalize(),s.scaleInPlace(i),s.addInPlace(t.origin);var c=(s.x-n.x)/(r.x-n.x)-.5,l=1-(s.y-n.y)/(r.y-n.y)-.5,u=e.angle,h=c*Math.cos(u)-l*Math.sin(u)+.5,d=c*Math.sin(u)+l*Math.cos(u)+.5,f=e._xOffset*o.width+h*e._xSize|0,p=e._yOffset*o.height+d*e._ySize|0;return this._textureContent[4*(f+p*o.width)+3]>.5},e.prototype.intersects=function(e,t,i,n){for(var r=Math.min(this.capacity,this.sprites.length),o=a.e.Zero(),s=a.e.Zero(),c=Number.MAX_VALUE,l=null,u=a.c.Vector3[0],h=a.c.Vector3[1],d=t.getViewMatrix(),f=0;f_){if(!this._checkTextureAlpha(p,e,_,o,s))continue;if(c=_,l=p,n)break}}}}if(l){var m=new gn.a;d.invertToRef(a.c.Matrix[0]),m.hit=!0,m.pickedSprite=l,m.distance=c;var g=a.c.Vector3[2];return g.copyFrom(e.direction),g.normalize(),g.scaleInPlace(c),e.origin.addToRef(g,u),m.pickedPoint=a.e.TransformCoordinates(u,a.c.Matrix[0]),m}return null},e.prototype.multiIntersects=function(e,t,i){for(var n,r=Math.min(this.capacity,this.sprites.length),o=a.e.Zero(),s=a.e.Zero(),c=[],l=a.c.Vector3[0].copyFromFloats(0,0,0),u=a.c.Vector3[1].copyFromFloats(0,0,0),h=t.getViewMatrix(),d=0;d0&&(e+="\n\r"),e+=this._tileMaps[t]._texture._bufferView.toString();var i=document.createElement("a");i.href="data:octet/stream;charset=utf-8,"+encodeURI(e),i.target="_blank",i.download=this.name+".tilemaps",i.click(),i.remove()},e.prototype.loadTileMaps=function(e){var t=this,i=new XMLHttpRequest;i.open("GET",e);var n=this.options.layerCount||0;i.onload=function(){for(var e=i.response.split("\n\r"),r=0;r-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 jp(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){m.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 i=0,n=t;i-1&&this._tasks.splice(r,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(e){m.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,i=function(i,n){e._setErrorObject(i,n),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){i("Error executing task success callbacks",e)}}),i)},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(i,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var n=0;n0&&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,i,n){var r=this,o=e.createReader(),a=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");o.readEntries((function(e){i.count+=e.length;for(var o=0,s=e;o0)){for(var i=new Array,n=[],r=e.dataTransfer?e.dataTransfer.items:null,o=0;o0&&m.a.ClearLogCache(),this._engine.stopRenderLoop()),pr.ShowLoadingScreen=!1,this._engine.displayLoadingUI(),pr.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.hideLoadingUI(),e._engine.runRenderLoop((function(){e.renderFunction()}))}))})).catch((function(t){e._engine.hideLoadingUI(),e._errorCallback&&e._errorCallback(e._sceneFileToLoad,e._currentScene,t.message)}))):m.a.Error("Please provide a valid .babylon file.")},e}(),n_=i(146),r_=i(145),o_=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,i,n){void 0===t&&(t=0),void 0===i&&(i=1024),void 0===n&&(n=.5);var r=e.call(this,t)||this;return r.priority=t,r.maximumSize=i,r.step=n,r}return Object(h.d)(t,e),t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,t){for(var i=!0,n=0;nthis.maximumSize&&(r.scale(this.step),i=!1)}}return i},t}(o_),s_=function(e){function t(t,i,n){void 0===t&&(t=0),void 0===i&&(i=2),void 0===n&&(n=.25);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r.step=n,r._currentScale=-1,r._directionOffset=1,r}return Object(h.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}(o_),c_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),l_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),u_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),h_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),d_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),f_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),p_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof be.a))return!1;var t=e;return!t.isDisposed()&&(!(!t.isVisible||!t.isEnabled())&&(!(t.instances.length>0)&&(!t.skeleton&&!t.hasLODLevels)))},t}return Object(h.d)(t,e),Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!1,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,i,n){for(var r=e.meshes.slice(0),o=r.length,a=0;a=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var n=!0,r=!0,o=0;o0){o.animationGroups=[];for(var h=0;h0)for(o.reflectionProbes=[],i=0;i0&&setTimeout((function(){i.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){i._resolve=e,i._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&&Ce.b.Download(e,this._fileName)},e._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},e}(),A_=function(){function e(){}return e.CreateScreenshot=function(t,i,n,r,o){void 0===o&&(o="image/png");var a=e._getScreenshotSize(t,i,n),s=a.height,c=a.width;if(s&&c){Ce.b._ScreenshotCanvas||(Ce.b._ScreenshotCanvas=document.createElement("canvas")),Ce.b._ScreenshotCanvas.width=c,Ce.b._ScreenshotCanvas.height=s;var l=Ce.b._ScreenshotCanvas.getContext("2d"),u=t.getRenderWidth()/t.getRenderHeight(),h=c,d=h/u;d>s&&(h=(d=s)*u);var f=Math.max(0,c-h)/2,p=Math.max(0,s-d)/2,_=t.getRenderingCanvas();l&&_&&l.drawImage(_,f,p,h,d),Ce.b.EncodeScreenshotCanvasData(r,o)}else m.a.Error("Invalid 'size' parameter !")},e.CreateScreenshotAsync=function(t,i,n,r){return void 0===r&&(r="image/png"),new Promise((function(o,a){e.CreateScreenshot(t,i,n,(function(e){void 0!==e?o(e):a(new Error("Data is undefined"))}),r)}))},e.CreateScreenshotUsingRenderTarget=function(t,i,n,r,o,a,s,c,l,u){void 0===o&&(o="image/png"),void 0===a&&(a=1),void 0===s&&(s=!1),void 0===l&&(l=!1),void 0===u&&(u=!1);var h=e._getScreenshotSize(t,i,n),d=h.height,f=h.width,p={width:f,height:d};if(d&&f){var _=t.getRenderingCanvas();if(_){var v={width:_.width,height:_.height};t.setSize(f,d);var b=i.getScene(),y=null,T=b.activeCameras;(b.activeCamera!==i||b.activeCameras&&b.activeCameras.length)&&(y=b.activeCamera,b.activeCamera=i),b.render();var E=new Ni("screenShot",p,b,!1,!1,g.a.TEXTURETYPE_UNSIGNED_INT,!1,Ke.a.NEAREST_SAMPLINGMODE,void 0,u);E.renderList=null,E.samples=a,E.renderSprites=l,E.onAfterRenderObservable.add((function(){Ce.b.DumpFramebuffer(f,d,t,r,o,c)}));var S=function(){b.incrementRenderId(),b.resetCachedMaterial(),E.render(!0),E.dispose(),y&&(b.activeCamera=y),b.activeCameras=T,t.setSize(v.width,v.height),i.getProjectionMatrix(!0)};if(s){var A=new mf("antialiasing",1,b.activeCamera);E.addPostProcess(A),A.getEffect().isReady()?S():A.getEffect().onCompiled=function(){S()}}else S()}else m.a.Error("No rendering canvas found !")}else m.a.Error("Invalid 'size' parameter !")},e.CreateScreenshotUsingRenderTargetAsync=function(t,i,n,r,o,a,s,c){return void 0===r&&(r="image/png"),void 0===o&&(o=1),void 0===a&&(a=!1),void 0===c&&(c=!1),new Promise((function(l,u){e.CreateScreenshotUsingRenderTarget(t,i,n,(function(e){void 0!==e?l(e):u(new Error("Data is undefined"))}),r,o,a,s,c)}))},e._getScreenshotSize=function(e,t,i){var n=0,r=0;if("object"==typeof i){var o=i.precision?Math.abs(i.precision):1;i.width&&i.height?(n=i.height*o,r=i.width*o):i.width&&!i.height?(r=i.width*o,n=Math.round(r/e.getAspectRatio(t))):i.height&&!i.width?(n=i.height*o,r=Math.round(n*e.getAspectRatio(t))):(r=Math.round(e.getRenderWidth()*o),n=Math.round(r/e.getAspectRatio(t)))}else isNaN(i)||(n=i,r=i);return r&&(r=Math.floor(r)),n&&(n=Math.floor(n)),{height:0|n,width:0|r}},e}();Ce.b.CreateScreenshot=A_.CreateScreenshot,Ce.b.CreateScreenshotAsync=A_.CreateScreenshotAsync,Ce.b.CreateScreenshotUsingRenderTarget=A_.CreateScreenshotUsingRenderTarget,Ce.b.CreateScreenshotUsingRenderTargetAsync=A_.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"}(zp||(zp={}));var P_,C_=i(140),R_=function(){function e(e){this.byteOffset=0,this.buffer=e}return e.prototype.loadAsync=function(e){var t=this;return 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 io.a.Decode(this.readUint8Array(e))},e.prototype.skipBytes=function(e){this._dataByteOffset+=e,this.byteOffset+=e},e}(),x_=function(){function e(){}return e._GetStorage=function(){try{return localStorage.setItem("test",""),localStorage.removeItem("test"),localStorage}catch(t){var e={};return{getItem:function(t){var i=e[t];return void 0===i?null:i},setItem:function(t,i){e[t]=i}}}},e.ReadString=function(e,t){var i=this._Storage.getItem(e);return null!==i?i:t},e.WriteString=function(e,t){this._Storage.setItem(e,t)},e.ReadBoolean=function(e,t){var i=this._Storage.getItem(e);return null!==i?"true"===i:t},e.WriteBoolean=function(e,t){this._Storage.setItem(e,t?"true":"false")},e.ReadNumber=function(e,t){var i=this._Storage.getItem(e);return null!==i?parseFloat(i):t},e.WriteNumber=function(e,t){this._Storage.setItem(e,t.toString())},e._Storage=e._GetStorage(),e}(),O_=function(){function e(){this._trackedScene=null}return e.prototype.track=function(e){this._trackedScene=e,this._savedJSON=y_.Serialize(e)},e.prototype.getDelta=function(){if(!this._trackedScene)return null;var e=y_.Serialize(this._trackedScene),t={};for(var i in e)this._compareCollections(i,this._savedJSON[i],e[i],t);return t},e.prototype._compareArray=function(e,t,i,n){if(0===t.length&&0===i.length)return!0;if(t.length&&!isNaN(t[0])||i.length&&!isNaN(i[0])){if(t.length!==i.length)return!1;if(0===t.length)return!0;for(var r=0;re.MAX_SEQUENCE_LENGTH)throw new Error("Sequences longer than "+e.MAX_SEQUENCE_LENGTH+" not supported.");this._alphabet=i,this._characters=t.map((function(e){return n._alphabet.getCharacterIdx(e)}))}return e.prototype.serialize=function(){return JSON.stringify(this._characters)},e.Deserialize=function(t,i){var n=new e([],i);return n._characters=JSON.parse(t),n},e.prototype.distance=function(t){return e._distance(this,t)},e._distance=function(t,i){var n=t._alphabet;if(n!==i._alphabet)throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");var r=t._characters,o=i._characters,a=r.length,s=o.length,c=e._costMatrix;c[0][0]=0;for(var l=0;l.98)&&(a.e.CrossToRef(e._forwardDir,e._inverseFromVec,e._upDir),e._upDir.normalize(),a.a.LookAtLHToRef(t,i,e._upDir,e._lookMatrix),n.subtractToRef(i,e._fromToVec),e._fromToVec.normalize(),a.e.TransformNormalToRef(e._fromToVec,e._lookMatrix,r),!0)},e._tokenizeSegment=function(t,i){e._bestMatch=0,e._score=a.e.Dot(t,i[0]),e._bestScore=e._score;for(var n=1;ne._bestScore&&(e._bestMatch=n,e._bestScore=e._score);return e._bestMatch},e._forwardDir=new a.e,e._inverseFromVec=new a.e,e._upDir=new a.e,e._fromToVec=new a.e,e._lookMatrix=new a.a,e}(),I_=function(){function e(e){this.chars=new Array(e)}return e.Generate=function(t,i,n,r,o){void 0===t&&(t=64),void 0===i&&(i=256),void 0===n&&(n=.1),void 0===r&&(r=.001),void 0===o&&(o=[]);for(var s,c,l=new e(t),u=0;u1e-6&&f.scaleAndAddToRef(1/(f.lengthSquared()*c),d)})),d.scaleInPlace(s),l.chars[e].addInPlace(d),l.chars[e].normalize()};for(u=o.length;u4;o=Math.floor(o/2))r.push(t.resampleAtTargetResolution(o).tokenize(i.chars));return r},e.prototype.distance=function(e){for(var t=0,i=0;i0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,e.MIN_AVERAGE_DISTANCE))},e.MIN_AVERAGE_DISTANCE=1,e}(),L_=function(){function e(){this._maximumAllowableMatchCost=4,this._nameToDescribedTrajectory=new Map}return e.prototype.serialize=function(){var e={};return e.maximumAllowableMatchCost=this._maximumAllowableMatchCost,e.vector3Alphabet=this._vector3Alphabet.serialize(),e.levenshteinAlphabet=this._levenshteinAlphabet.serialize(),e.nameToDescribedTrajectory=[],this._nameToDescribedTrajectory.forEach((function(t,i){e.nameToDescribedTrajectory.push(i),e.nameToDescribedTrajectory.push(t.serialize())})),JSON.stringify(e)},e.Deserialize=function(t){var i=JSON.parse(t),n=new e;n._maximumAllowableMatchCost=i.maximumAllowableMatchCost,n._vector3Alphabet=I_.Deserialize(i.vector3Alphabet),n._levenshteinAlphabet=P_.Alphabet.Deserialize(i.levenshteinAlphabet);for(var r=0;r0&&this.onFeaturePointsAddedObservable.notifyObservers(r),n.length>0&&this.onFeaturePointsUpdatedObservable.notifyObservers(n)}}},t.prototype._init=function(){this._xrSessionManager.session.trySetFeaturePointCloudEnabled&&this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0)&&(this._enabled=!0)},t.Name=Ia.FEATURE_POINTS,t.Version=1,t}(ja);Da.AddWebXRFeature(H_.Name,(function(e){return function(){return new H_(e)}}),H_.Version);var X_=function(){function e(e,t,i,n,r){this.xrController=e,this.trackedMeshes=t,this._handMesh=i,this._rigMapping=n,this._defaultHandMesh=!1,this._transformNodeMapping=[],this.handPartsDefinition=this.generateHandPartsDefinition(e.inputSource.hand),this._scene=t[0].getScene(),this._handMesh&&this._rigMapping?this._defaultHandMesh=!1:r||this._generateDefaultHandMesh(),this.xrController.motionController&&(this.xrController.motionController.rootMesh?this.xrController.motionController.rootMesh.setEnabled(!1):this.xrController.motionController.onModelLoadedObservable.add((function(e){e.rootMesh&&e.rootMesh.setEnabled(!1)}))),this.xrController.onMotionControllerInitObservable.add((function(e){e.onModelLoadedObservable.add((function(e){e.rootMesh&&e.rootMesh.setEnabled(!1)})),e.rootMesh&&e.rootMesh.setEnabled(!1)}))}return e.prototype.generateHandPartsDefinition=function(e){var t;return(t={}).wrist=[e.WRIST],t.thumb=[e.THUMB_METACARPAL,e.THUMB_PHALANX_PROXIMAL,e.THUMB_PHALANX_DISTAL,e.THUMB_PHALANX_TIP],t.index=[e.INDEX_METACARPAL,e.INDEX_PHALANX_PROXIMAL,e.INDEX_PHALANX_INTERMEDIATE,e.INDEX_PHALANX_DISTAL,e.INDEX_PHALANX_TIP],t.middle=[e.MIDDLE_METACARPAL,e.MIDDLE_PHALANX_PROXIMAL,e.MIDDLE_PHALANX_INTERMEDIATE,e.MIDDLE_PHALANX_DISTAL,e.MIDDLE_PHALANX_TIP],t.ring=[e.RING_METACARPAL,e.RING_PHALANX_PROXIMAL,e.RING_PHALANX_INTERMEDIATE,e.RING_PHALANX_DISTAL,e.RING_PHALANX_TIP],t.little=[e.LITTLE_METACARPAL,e.LITTLE_PHALANX_PROXIMAL,e.LITTLE_PHALANX_INTERMEDIATE,e.LITTLE_PHALANX_DISTAL,e.LITTLE_PHALANX_TIP],t},e.prototype.updateFromXRFrame=function(e,t,i){var n=this;void 0===i&&(i=2);var r=this.xrController.inputSource.hand;r&&this.trackedMeshes.forEach((function(o,a){var s=r[a];if(s){var c=e.getJointPose(s,t);if(!c||!c.transform)return;var l=c.transform.position,u=c.transform.orientation;o.position.set(l.x,l.y,l.z),o.rotationQuaternion.set(u.x,u.y,u.z,u.w);var h=(c.radius||.008)*i;o.scaling.set(h,h,h),n._handMesh&&n._rigMapping&&n._rigMapping[a]&&(n._transformNodeMapping[a]=n._transformNodeMapping[a]||n._scene.getTransformNodeByName(n._rigMapping[a]),n._transformNodeMapping[a]&&(n._transformNodeMapping[a].position.copyFrom(o.position),n._transformNodeMapping[a].rotationQuaternion.copyFrom(o.rotationQuaternion),o.isVisible=!1)),o.getScene().useRightHandedSystem||(o.position.z*=-1,o.rotationQuaternion.z*=-1,o.rotationQuaternion.w*=-1)}}))},e.prototype.getHandPartMeshes=function(e){var t=this;return this.handPartsDefinition[e].map((function(e){return t.trackedMeshes[e]}))},e.prototype.dispose=function(){this.trackedMeshes.forEach((function(e){return e.dispose()})),this._defaultHandMesh&&this._handMesh&&this._handMesh.dispose()},e.prototype._generateDefaultHandMesh=function(){return Object(h.b)(this,void 0,void 0,(function(){var e,t,i,n,r,o,a,c;return Object(h.e)(this,(function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),e="right"===this.xrController.inputSource.handedness?"right":"left",t=("right"===e?"r":"l")+"_hand_"+(this._scene.useRightHandedSystem?"r":"l")+"hs.glb",[4,pr.ImportMeshAsync("","https://assets.babylonjs.com/meshes/HandMeshes/",t,this._scene)];case 1:return i=l.sent(),n={base:s.a.FromInts(116,63,203),fresnel:s.a.FromInts(149,102,229),fingerColor:s.a.FromInts(177,130,255),tipFresnel:s.a.FromInts(220,200,255)},[4,(r=new ql("leftHandShader",this._scene,{emitComments:!1})).loadAsync("https://patrickryanms.github.io/BabylonJStextures/Demos/xrHandMesh/handsShader.json")];case 2:if(l.sent(),r.build(!1),r.needDepthPrePass=!0,r.transparencyMode=xo.a.MATERIAL_ALPHABLEND,r.alphaMode=Se.a.ALPHA_COMBINE,(o={base:r.getBlockByName("baseColor"),fresnel:r.getBlockByName("fresnelColor"),fingerColor:r.getBlockByName("fingerColor"),tipFresnel:r.getBlockByName("tipFresnelColor")}).base.value=n.base,o.fresnel.value=n.fresnel,o.fingerColor.value=n.fingerColor,o.tipFresnel.value=n.tipFresnel,i.meshes[1].material=r,this._defaultHandMesh=!0,this._handMesh=i.meshes[0],this._rigMapping=["wrist_","thumb_metacarpal_","thumb_proxPhalanx_","thumb_distPhalanx_","thumb_tip_","index_metacarpal_","index_proxPhalanx_","index_intPhalanx_","index_distPhalanx_","index_tip_","middle_metacarpal_","middle_proxPhalanx_","middle_intPhalanx_","middle_distPhalanx_","middle_tip_","ring_metacarpal_","ring_proxPhalanx_","ring_intPhalanx_","ring_distPhalanx_","ring_tip_","little_metacarpal_","little_proxPhalanx_","little_intPhalanx_","little_distPhalanx_","little_tip_"].map((function(t){return t+("right"===e?"R":"L")})),!(a=this._scene.getTransformNodeByName(this._rigMapping[0])))throw new Error("could not find the wrist node");return a.parent&&a.parent.rotate(J.a.Y,Math.PI),[3,4];case 3:return c=l.sent(),Ce.b.Error("error loading hand mesh"),console.log(c),[3,4];case 4:return[2]}}))}))},e}(),Y_=function(e){function t(i,n){var r=e.call(this,i)||this;return r.options=n,r.onHandAddedObservable=new o.c,r.onHandRemovedObservable=new o.c,r._hands={},r._attachHand=function(e){var i,n,o,s,c,l,u,d,f,p;if(e.inputSource.hand&&!r._hands[e.uniqueId]){var _=e.inputSource.hand,m=[],g=(null===(i=r.options.jointMeshes)||void 0===i?void 0:i.sourceMesh)||xr.a.CreateSphere("jointParent",{diameter:1});g.isVisible=!!(null===(n=r.options.jointMeshes)||void 0===n?void 0:n.keepOriginalVisible);for(var v=0;v<_.length;++v){var b=g.createInstance(e.uniqueId+"-handJoint-"+v);if(null===(o=r.options.jointMeshes)||void 0===o?void 0:o.onHandJointMeshGenerated){var y=r.options.jointMeshes.onHandJointMeshGenerated(b,v,e.uniqueId);y&&y!==b&&(b.dispose(),b=y)}if(b.isPickable=!1,null===(s=r.options.jointMeshes)||void 0===s?void 0:s.enablePhysics){var T=r.options.jointMeshes.physicsProps||{},E=void 0!==T.impostorType?T.impostorType:dc.a.SphereImpostor;b.physicsImpostor=new dc.a(b,E,Object(h.a)({mass:0},T))}b.rotationQuaternion=new a.b,(null===(c=r.options.jointMeshes)||void 0===c?void 0:c.invisible)&&(b.isVisible=!1),m.push(b)}var S="right"===e.inputSource.handedness?"right":"left",A=(null===(l=r.options.jointMeshes)||void 0===l?void 0:l.handMeshes)&&(null===(u=r.options.jointMeshes)||void 0===u?void 0:u.handMeshes[S]),P=(null===(d=r.options.jointMeshes)||void 0===d?void 0:d.rigMapping)&&(null===(f=r.options.jointMeshes)||void 0===f?void 0:f.rigMapping[S]),C=new X_(e,m,A,P,null===(p=r.options.jointMeshes)||void 0===p?void 0:p.disableDefaultHandMesh);r._hands[e.uniqueId]={handObject:C,id:t._idCounter++},r.onHandAddedObservable.notifyObservers(C)}},r.xrNativeFeatureName="hand-tracking",r}return Object(h.d)(t,e),t.prototype.isCompatible=function(){return"undefined"!=typeof XRHand},t.prototype.attach=function(){var t=this;return!!e.prototype.attach.call(this)&&(this.options.xrInput.controllers.forEach(this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable,this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable,(function(e){t._detachHand(e.uniqueId)})),!0)},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._hands).forEach((function(e){t._detachHand(e)})),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onHandAddedObservable.clear()},t.prototype.getHandByControllerId=function(e){var t;return(null===(t=this._hands[e])||void 0===t?void 0:t.handObject)||null},t.prototype.getHandByHandedness=function(e){var t=this,i=Object.keys(this._hands).map((function(e){return t._hands[e].handObject.xrController.inputSource.handedness})).indexOf(e);return-1!==i?this._hands[i].handObject:null},t.prototype._onXRFrame=function(e){var t=this;Object.keys(this._hands).forEach((function(i){var n;t._hands[i].handObject.updateFromXRFrame(e,t._xrSessionManager.referenceSpace,null===(n=t.options.jointMeshes)||void 0===n?void 0:n.scaleFactor)}))},t.prototype._detachHand=function(e){this._hands[e]&&(this.onHandRemovedObservable.notifyObservers(this._hands[e].handObject),this._hands[e].handObject.dispose())},t._idCounter=0,t.Name=Ia.HAND_TRACKING,t.Version=1,t}(ja);Da.AddWebXRFeature(Y_.Name,(function(e,t){return function(){return new Y_(e,t)}}),Y_.Version,!1);var K_=function(e){function t(t,i,n){var r=e.call(this,t,Q_["left-right"],i,n)||this;return r._mapping={defaultButton:{valueNodeName:"VALUE",unpressedNodeName:"UNPRESSED",pressedNodeName:"PRESSED"},defaultAxis:{valueNodeName:"VALUE",minNodeName:"MIN",maxNodeName:"MAX"},buttons:{"xr-standard-trigger":{rootNodeName:"SELECT",componentProperty:"button",states:["default","touched","pressed"]},"xr-standard-squeeze":{rootNodeName:"GRASP",componentProperty:"state",states:["pressed"]},"xr-standard-touchpad":{rootNodeName:"TOUCHPAD_PRESS",labelAnchorNodeName:"squeeze-label",touchPointNodeName:"TOUCH"},"xr-standard-thumbstick":{rootNodeName:"THUMBSTICK_PRESS",componentProperty:"state",states:["pressed"]}},axes:{"xr-standard-touchpad":{"x-axis":{rootNodeName:"TOUCHPAD_TOUCH_X"},"y-axis":{rootNodeName:"TOUCHPAD_TOUCH_Y"}},"xr-standard-thumbstick":{"x-axis":{rootNodeName:"THUMBSTICK_X"},"y-axis":{rootNodeName:"THUMBSTICK_Y"}}}},r.profileId="microsoft-mixed-reality",r}return Object(h.d)(t,e),t.prototype._getFilenameAndPath=function(){return{filename:"left"===this.handedness?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,path:t.MODEL_BASE_URL+"default/"}},t.prototype._getModelLoadingConstraints=function(){var e=pr.IsPluginForExtensionAvailable(".glb");return e||m.a.Warn("glTF / glb loaded was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var t=this;this.rootMesh&&(this.getComponentIds().forEach((function(e,i){if(!t.disableAnimation&&e&&t.rootMesh){var n=t._mapping.buttons[e],r=n.rootNodeName;if(!r)return void m.a.Log("Skipping unknown button at index: "+i+" with mapped name: "+e);var o=t._getChildByName(t.rootMesh,r);if(!o)return void m.a.Warn("Missing button mesh with name: "+r);if(n.valueMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.valueNodeName),n.pressedMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.pressedNodeName),n.unpressedMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.unpressedNodeName),n.valueMesh&&n.pressedMesh&&n.unpressedMesh){var a=t.getComponent(e);a&&a.onButtonStateChangedObservable.add((function(e){t._lerpTransform(n,e.value)}),void 0,!0)}else m.a.Warn("Missing button submesh under mesh with name: "+r)}})),this.getComponentIds().forEach((function(e,i){var n=t.getComponent(e);n.isAxes()&&["x-axis","y-axis"].forEach((function(i){if(t.rootMesh){var r=t._mapping.axes[e][i],o=t._getChildByName(t.rootMesh,r.rootNodeName);o?(r.valueMesh=t._getImmediateChildByName(o,t._mapping.defaultAxis.valueNodeName),r.minMesh=t._getImmediateChildByName(o,t._mapping.defaultAxis.minNodeName),r.maxMesh=t._getImmediateChildByName(o,t._mapping.defaultAxis.maxNodeName),r.valueMesh&&r.minMesh&&r.maxMesh?n&&n.onAxisValueChangedObservable.add((function(e){var n="x-axis"===i?e.x:e.y;t._lerpTransform(r,n,!0)}),void 0,!0):m.a.Warn("Missing axis submesh under mesh with name: "+r.rootNodeName)):m.a.Warn("Missing axis mesh with name: "+r.rootNodeName)}}))})))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new be.a(this.profileId+" "+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;i1){for(r();-1!==n&&e._OperatorPriority[a()]>=e._OperatorPriority[h];)i.push(s());o(h),c++}else l+=u;c++}for(r();-1!==n;)"("===a()?s():i.push(s());return i},e._OperatorPriority={")":0,"(":1,"||":2,"&&":3},e._Stack=["","","","","","","","","","","","","","","","","","","",""],e}(),u=function(e){function t(t,i){void 0===i&&(i=!1);var n=e.call(this)||this;return n.define=t,n.not=i,n}return Object(a.d)(t,e),t.prototype.isTrue=function(e){var t=void 0!==e[this.define];return this.not&&(t=!t),t},t}(l),h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(a.d)(t,e),t.prototype.isTrue=function(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)},t}(l),d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(a.d)(t,e),t.prototype.isTrue=function(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)},t}(l),f=function(e){function t(t,i,n){var r=e.call(this)||this;return r.define=t,r.operand=i,r.testValue=n,r}return Object(a.d)(t,e),t.prototype.isTrue=function(e){var t=e[this.define];void 0===t&&(t=this.define);var i=!1,n=parseInt(t),r=parseInt(this.testValue);switch(this.operand){case">":i=n>r;break;case"<":i=n=":i=n>=r;break;case"==":i=n===r}return i},t}(l),p=i(21),_=/defined\s*?\((.+?)\)/g,m=/defined\s*?\[(.+?)\]/g,g=function(){function e(){}return e.Process=function(e,t,i,n){var r=this;this._ProcessIncludes(e,t,(function(e){var o=r._ProcessShaderConversion(e,t,n);i(o)}))},e._ProcessPrecision=function(e,t){var i=t.shouldUseHighPrecisionShader;return-1===e.indexOf("precision highp float")?e=i?"precision highp float;\n"+e:"precision mediump float;\n"+e:i||(e=e.replace("precision highp float","precision mediump float")),e},e._ExtractOperation=function(e){var t=/defined\((.+)\)/.exec(e);if(t&&t.length)return new u(t[1].trim(),"!"===e[0]);for(var i="",n=0,r=0,o=["==",">=","<=","<",">"];r-1));r++);if(-1===n)return new u(e);var a=e.substring(0,n).trim(),s=e.substring(n+i.length).trim();return new f(a,i,s)},e._BuildSubExpression=function(e){e=e.replace(_,"defined[$1]");for(var t=[],i=0,n=l.infixToPostfix(e);i=2){var o=t[t.length-1],a=t[t.length-2];t.length-=2;var s="&&"==r?new d:new h;"string"==typeof o&&(o=o.replace(m,"defined($1)")),"string"==typeof a&&(a=a.replace(m,"defined($1)")),s.leftOperand="string"==typeof a?this._ExtractOperation(a):a,s.rightOperand="string"==typeof o?this._ExtractOperation(o):o,t.push(s)}}var c=t[t.length-1];return"string"==typeof c&&(c=c.replace(m,"defined($1)")),"string"==typeof c?this._ExtractOperation(c):c},e._BuildExpression=function(e,t){var i=new c,n=e.substring(0,t),r=e.substring(t);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),i.testExpression="#ifdef"===n?new u(r):"#ifndef"===n?new u(r,!0):this._BuildSubExpression(r),i},e._MoveCursorWithinIf=function(e,t,i){for(var n=e.currentLine;this._MoveCursor(e,i);){var o=(n=e.currentLine).substring(0,5).toLowerCase();if("#else"===o){var a=new r;return t.children.push(a),void this._MoveCursor(e,a)}if("#elif"===o){var s=this._BuildExpression(n,5);t.children.push(s),i=s}}},e._MoveCursor=function(e,t){for(;e.canRead;){e.lineIndex++;var i=e.currentLine,n=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/.exec(i);if(n&&n.length){switch(n[0]){case"#ifdef":var o=new s;t.children.push(o);var a=this._BuildExpression(i,6);o.children.push(a),this._MoveCursorWithinIf(e,o,a);break;case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":o=new s;t.children.push(o);a=this._BuildExpression(i,7);o.children.push(a),this._MoveCursorWithinIf(e,o,a);break;case"#if":o=new s,a=this._BuildExpression(i,3);t.children.push(o),o.children.push(a),this._MoveCursorWithinIf(e,o,a)}}else{var c=new r;if(c.line=i,t.children.push(c),"#"===i[0]&&"d"===i[1]){var l=i.replace(";","").split(" ");c.additionalDefineKey=l[1],3===l.length&&(c.additionalDefineValue=l[2])}}}return!1},e._EvaluatePreProcessors=function(e,t,i){var n=new r,a=new o;return a.lineIndex=-1,a.lines=e.split("\n"),this._MoveCursor(a,n),n.process(t,i)},e._PreparePreProcessors=function(e){for(var t={},i=0,n=e.defines;i1?r[1]:""}return t.GL_ES="true",t.__VERSION__=e.version,t[e.platformName]="true",t},e._ProcessShaderConversion=function(e,t,i){var n=this._ProcessPrecision(e,t);if(!t.processor)return n;if(-1!==n.indexOf("#version 3"))return n.replace("#version 300 es","");var r=t.defines,o=this._PreparePreProcessors(t);return t.processor.preProcessor&&(n=t.processor.preProcessor(n,r,t.isFragment)),n=this._EvaluatePreProcessors(n,o,t),t.processor.postProcessor&&(n=t.processor.postProcessor(n,r,t.isFragment,i)),n},e._ProcessIncludes=function(t,i,n){for(var r=this,o=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,a=o.exec(t),s=new String(t),c=!1;null!=a;){var l=a[1];if(-1!==l.indexOf("__decl__")&&(l=l.replace(/__decl__/,""),i.supportsUniformBuffers&&(l=(l=l.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),l+="Declaration"),!i.includesShadersStore[l]){var u=i.shadersRepository+"ShadersInclude/"+l+".fx";return void e._FileToolsLoadFile(u,(function(e){i.includesShadersStore[l]=e,r._ProcessIncludes(s,i,n)}))}var h=i.includesShadersStore[l];if(a[2])for(var d=a[3].split(","),f=0;f=0,a=o.exec(t)}c?this._ProcessIncludes(s.toString(),i,n):n(s)},e._FileToolsLoadFile=function(e,t,i,n,r,o){throw p.a.WarnImport("FileTools")},e}()},function(e,t,i){"use strict";i(26).a.prototype._readTexturePixels=function(e,t,i,n,r,o){void 0===n&&(n=-1),void 0===r&&(r=0),void 0===o&&(o=null);var a=this._gl;if(!a)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){var s=a.createFramebuffer();if(!s)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=s}a.bindFramebuffer(a.FRAMEBUFFER,this._dummyFramebuffer),n>-1?a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+n,e._webGLTexture,r):a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,e._webGLTexture,r);var c=void 0!==e.type?this._getWebGLTextureType(e.type):a.UNSIGNED_BYTE;switch(c){case a.UNSIGNED_BYTE:o||(o=new Uint8Array(4*t*i)),c=a.UNSIGNED_BYTE;break;default:o||(o=new Float32Array(4*t*i)),c=a.FLOAT}return a.readPixels(0,0,t,i,a.RGBA,c,o),a.bindFramebuffer(a.FRAMEBUFFER,this._currentFramebuffer),o}},function(e,t,i){"use strict";var n="shadowsFragmentFunctions",r="#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}\n#define inline\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\nreturn depth>shadow ? darkness : 1.0;\n}\n#define inline\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 ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n#endif\n#define inline\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}\nelse\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\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n}\n#define inline\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}\nelse\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}\nelse\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}\n}\n#define inline\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}\nelse\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}\n#ifdef WEBGL2\n#define GREATEST_LESS_THAN_ONE 0.99999994\n\n#define inline\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\n#define inline\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\n#define inline\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\n#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\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\n\n#define inline\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}\nelse\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\n\n#define inline\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}\nelse\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}\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\n#define inline\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}\nelse\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; i1)for(var c=0;c=e||-1!==i.indexOf("file:")?-1:Math.pow(2,r)*t}},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zOffset",{get:function(){return this._zOffset},set:function(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cullFace",{get:function(){return this._cullFace},set:function(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cull",{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthMask",{get:function(){return this._depthMask},set:function(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthTest",{get:function(){return this._depthTest},set:function(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frontFace",{get:function(){return this._frontFace},set:function(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,0)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(2),r=function(){function e(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.KEEP,this._stencilOpDepthFail=e.KEEP,this._stencilOpStencilDepthPass=e.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},e.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},e.ALWAYS=n.a.ALWAYS,e.KEEP=n.a.KEEP,e.REPLACE=n.a.REPLACE,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!1,configurable:!0}),e.prototype.setAlphaBlendConstants=function(e,t,i,n){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===n||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=n,this._isBlendConstantsDirty=!0)},e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,n){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===n||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=n,this._isBlendFunctionParametersDirty=!0)},e.prototype.setAlphaEquationParameters=function(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null}return Object.defineProperty(e.prototype,"isAsync",{get:function(){return this.isParallelCompiled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return!!this.program&&(!this.isParallelCompiled||this.engine._isRenderingStateCompiled(this))},enumerable:!1,configurable:!0}),e.prototype._handlesSpectorRebuildCallback=function(e){e&&this.program&&e(this.program)},e.prototype._getVertexShaderCode=function(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null},e.prototype._getFragmentShaderCode=function(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null},e}()},function(e,t,i){"use strict";var n;i.d(t,"a",(function(){return a})),function(e){e[e.Pending=0]="Pending",e[e.Fulfilled=1]="Fulfilled",e[e.Rejected=2]="Rejected"}(n||(n={}));var r=function(){this.count=0,this.target=0,this.results=[]},o=function(){function e(e){var t=this;if(this._state=n.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:!1,configurable:!0}),e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.then=function(t,i){var r=this,o=new e;return o._onFulfilled=t,o._onRejected=i,this._children.push(o),o._parent=this,this._state!==n.Pending&&setTimeout((function(){if(r._state===n.Fulfilled||r._rejectWasConsumed){var e=o._resolve(r._result);if(null!=e)if(void 0!==e._state){var t=e;o._children.push(t),t._parent=o,o=t}else o._result=e}else o._reject(r._reason)})),o},e.prototype._moveChildren=function(e){var t,i=this;if((t=this._children).push.apply(t,e.splice(0,e.length)),this._children.forEach((function(e){e._parent=i})),this._state===n.Fulfilled)for(var r=0,o=this._children;r=this._sampleCount||e>=this._samples.length)return 0;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(0),r=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new n.e(0,0,0),this._diffPositionForCollisions=new n.e(0,0,0),this._collisionResponse=!0}},function(e,t,i){"use strict";i.d(t,"a",(function(){return a}));var n=i(33),r=i(0),o=i(2),a=function(){function e(e,t,i,r,o){void 0===i&&(i=null),void 0===r&&(r=null),void 0===o&&(o=null),this.index=e,this._opaqueSubMeshes=new n.a(256),this._transparentSubMeshes=new n.a(256),this._alphaTestSubMeshes=new n.a(256),this._depthOnlySubMeshes=new n.a(256),this._particleSystems=new n.a(256),this._spriteManagers=new n.a(256),this._edgesRenderers=new n.b(16),this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=o}return Object.defineProperty(e.prototype,"opaqueSortCompareFn",{set:function(t){this._opaqueSortCompareFn=t,this._renderOpaque=t?this.renderOpaqueSorted:e.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaTestSortCompareFn",{set:function(t){this._alphaTestSortCompareFn=t,this._renderAlphaTest=t?this.renderAlphaTestSorted:e.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparentSortCompareFn",{set:function(t){this._transparentSortCompareFn=t||e.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!1,configurable:!0}),e.prototype.render=function(e,t,i,n){if(e)e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{var r=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(r.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),r.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);var a=r.getStencilBuffer();if(r.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(n),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length&&(r.setStencilBuffer(a),this._renderTransparent(this._transparentSubMeshes),r.setAlphaMode(o.a.ALPHA_DISABLE)),r.setStencilBuffer(!1),this._edgesRenderers.length){for(var s=0;si._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,i){void 0===t&&(t=e.getMesh()),void 0===i&&(i=e.getMaterial()),null!=i&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTesting()?(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(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 i=0;i=0;){var u=r[c];u<0?u=0:u>1&&(u=1),l[c]=255*u}r=l}var h=document.createElement("canvas");h.width=a,h.height=s;var d=h.getContext("2d");if(!d)return null;var f=d.createImageData(a,s);if(f.data.set(r),d.putImageData(f,0,0),n.invertY){var p=document.createElement("canvas");p.width=a,p.height=s;var _=p.getContext("2d");return _?(_.translate(0,s),_.scale(1,-1),_.drawImage(h,0,0),p.toDataURL("image/png")):null}return h.toDataURL("image/png")},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return f}));var n=i(1),r=i(0),o=i(8),a=i(31),s=i(7),c=i(41),l=i(46),u=i(4),h=i(43),d=i(12);s.a._instancedMeshFactory=function(e,t){var i=new f(e,t);if(t.instancedBuffers)for(var n in i.instancedBuffers={},t.instancedBuffers)i.instancedBuffers[n]=t.instancedBuffers[n];return i};var f=function(e){function t(t,i){var n=e.call(this,t,i.getScene())||this;n._indexInSourceMeshInstanceArray=-1,i.addInstance(n),n._sourceMesh=i,n._unIndexed=i._unIndexed,n.position.copyFrom(i.position),n.rotation.copyFrom(i.rotation),n.scaling.copyFrom(i.scaling),i.rotationQuaternion&&(n.rotationQuaternion=i.rotationQuaternion.clone()),n.animations=d.b.Slice(i.animations);for(var r=0,o=i.getAnimationRanges();r0!=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._sourceMesh.edgesShareWithInstances&&this._sourceMesh._edgesRenderer&&this._sourceMesh._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup?(this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())):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!==l.a.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){var t=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,r.c.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),r.c.Matrix[0].copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(r.c.Vector3[7]),this._currentLOD._masterMesh=t,r.c.Matrix[0]}return e.prototype.getWorldMatrix.call(this)},Object.defineProperty(t.prototype,"isAnInstance",{get:function(){return!0},enumerable:!1,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;e\nvoid main(void) {\n#include\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";n.a.ShadersStore[r]=o},function(e,t,i){"use strict";var n=i(5),r=(i(78),i(117),i(79),i(80),i(81),i(111),"colorVertexShader"),o="\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n#include\n\n#include\nuniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include\n#include\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#include\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";n.a.ShadersStore[r]=o},function(e,t,i){"use strict";(function(e){i.d(t,"b",(function(){return h})),i.d(t,"a",(function(){return d}));var n=i(1),r=i(8),o=i(13),a=i(102),s=i(27),c=i(2),l=i(89),u=i(74),h=function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4},d=function(t){function i(i){void 0===i&&(i=new h);var n=t.call(this,null)||this;o.a.Instances.push(n),void 0===i.deterministicLockstep&&(i.deterministicLockstep=!1),void 0===i.lockstepMaxSteps&&(i.lockstepMaxSteps=4),n._options=i,u.a.SetMatrixPrecision(!!i.useHighPrecisionMatrix),n._caps={maxTexturesImageUnits:16,maxVertexTextureImageUnits:16,maxCombinedTexturesImageUnits:32,maxTextureSize:512,maxCubemapTextureSize:512,maxRenderTextureSize:512,maxVertexAttribs:16,maxVaryingVectors:16,maxFragmentUniformVectors:16,maxVertexUniformVectors:16,standardDerivatives:!1,astc:null,pvrtc:null,etc1:null,etc2:null,bptc:null,maxAnisotropy:0,uintIndices:!1,fragmentDepthSupported:!1,highPrecisionShaderSupported:!0,colorBufferFloat:!1,textureFloat:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloat:!1,textureHalfFloatLinearFiltering:!1,textureHalfFloatRender:!1,textureLOD:!1,drawBuffersExtension:!1,depthTextureExtension:!1,vertexArrayObject:!1,instancedArrays:!1,canUseTimestampForTimerQuery:!1,maxMSAASamples:1,blendMinMax:!1},r.a.Log("Babylon.js v"+o.a.Version+" - Null engine");var a="undefined"!=typeof self?self:void 0!==e?e:window;return"undefined"==typeof URL&&(a.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(a.Blob=function(){}),n}return Object(n.d)(i,t),i.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},i.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},i.prototype.getHardwareScalingLevel=function(){return 1},i.prototype.createVertexBuffer=function(e){var t=new l.a;return t.references=1,t},i.prototype.createIndexBuffer=function(e){var t=new l.a;return t.references=1,t},i.prototype.clear=function(e,t,i,n){void 0===n&&(n=!1)},i.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},i.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},i.prototype.setViewport=function(e,t,i){this._cachedViewport=e},i.prototype.createShaderProgram=function(e,t,i,n,r){return{__SPECTOR_rebuildProgram:null}},i.prototype.getUniforms=function(e,t){return[]},i.prototype.getAttributes=function(e,t){return[]},i.prototype.bindSamplers=function(e){this._currentEffect=null},i.prototype.enableEffect=function(e){this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e)},i.prototype.setState=function(e,t,i,n){void 0===t&&(t=0),void 0===n&&(n=!1)},i.prototype.setIntArray=function(e,t){return!0},i.prototype.setIntArray2=function(e,t){return!0},i.prototype.setIntArray3=function(e,t){return!0},i.prototype.setIntArray4=function(e,t){return!0},i.prototype.setFloatArray=function(e,t){return!0},i.prototype.setFloatArray2=function(e,t){return!0},i.prototype.setFloatArray3=function(e,t){return!0},i.prototype.setFloatArray4=function(e,t){return!0},i.prototype.setArray=function(e,t){return!0},i.prototype.setArray2=function(e,t){return!0},i.prototype.setArray3=function(e,t){return!0},i.prototype.setArray4=function(e,t){return!0},i.prototype.setMatrices=function(e,t){return!0},i.prototype.setMatrix3x3=function(e,t){return!0},i.prototype.setMatrix2x2=function(e,t){return!0},i.prototype.setFloat=function(e,t){return!0},i.prototype.setFloat2=function(e,t,i){return!0},i.prototype.setFloat3=function(e,t,i,n){return!0},i.prototype.setBool=function(e,t){return!0},i.prototype.setFloat4=function(e,t,i,n,r){return!0},i.prototype.setAlphaMode=function(e,t){void 0===t&&(t=!1),this._alphaMode!==e&&(this.alphaState.alphaBlend=e!==c.a.ALPHA_DISABLE,t||this.setDepthWrite(e===c.a.ALPHA_DISABLE),this._alphaMode=e)},i.prototype.bindBuffers=function(e,t,i){},i.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this.stencilState.reset(),this.depthCullingState.reset(),this.alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},i.prototype.draw=function(e,t,i,n){},i.prototype.drawElementsType=function(e,t,i,n){},i.prototype.drawArraysType=function(e,t,i,n){},i.prototype._createTexture=function(){return{}},i.prototype._releaseTexture=function(e){},i.prototype.createTexture=function(e,t,i,n,r,o,a,l,u,h,d,f){void 0===r&&(r=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===a&&(a=null),void 0===l&&(l=null),void 0===u&&(u=null),void 0===h&&(h=null),void 0===d&&(d=null);var p=new s.a(this,s.b.Url),_=String(e);return p.url=_,p.generateMipMaps=!t,p.samplingMode=r,p.invertY=i,p.baseWidth=this._options.textureSize,p.baseHeight=this._options.textureSize,p.width=this._options.textureSize,p.height=this._options.textureSize,h&&(p.format=h),p.isReady=!0,o&&o(),this._internalTexturesCache.push(p),p},i.prototype.createRenderTargetTexture=function(e,t){var i=new a.a;void 0!==t&&"object"==typeof t?(i.generateMipMaps=t.generateMipMaps,i.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&t.generateStencilBuffer,i.type=void 0===t.type?c.a.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?c.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=c.a.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var n=new s.a(this,s.b.RenderTarget),r=e.width||e,o=e.height||e;return n._depthStencilBuffer={},n._framebuffer={},n.baseWidth=r,n.baseHeight=o,n.width=r,n.height=o,n.isReady=!0,n.samples=1,n.generateMipMaps=!!i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(n),n},i.prototype.updateTextureSamplingMode=function(e,t){t.samplingMode=e},i.prototype.bindFramebuffer=function(e,t,i,n,r){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer,this._cachedViewport&&!r&&this.setViewport(this._cachedViewport,i,n)},i.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null,i&&(e._MSAAFramebuffer&&(this._currentFramebuffer=e._framebuffer),i()),this._currentFramebuffer=null},i.prototype.createDynamicVertexBuffer=function(e){var t=new l.a;return t.references=1,t.capacity=1,t},i.prototype.updateDynamicTexture=function(e,t,i,n,r){void 0===n&&(n=!1)},i.prototype.areAllEffectsReady=function(){return!0},i.prototype.getError=function(){return 0},i.prototype._getUnpackAlignement=function(){return 1},i.prototype._unpackFlipY=function(e){},i.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0)},i.prototype.updateDynamicVertexBuffer=function(e,t,i,n){},i.prototype._bindTextureDirectly=function(e,t){return this._boundTexturesCache[this._activeChannel]!==t&&(this._boundTexturesCache[this._activeChannel]=t,!0)},i.prototype._bindTexture=function(e,t){e<0||this._bindTextureDirectly(0,t)},i.prototype._deleteBuffer=function(e){},i.prototype.releaseEffects=function(){},i.prototype.displayLoadingUI=function(){},i.prototype.hideLoadingUI=function(){},i.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,n,r,o,a){void 0===o&&(o=0),void 0===a&&(a=0)},i.prototype._uploadDataToTextureDirectly=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0)},i.prototype._uploadArrayBufferViewToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0)},i.prototype._uploadImageToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0)},i}(o.a)}).call(this,i(159))},function(e,t,i){"use strict";i.r(t),function(e){i.d(t,"Debug",(function(){return l}));var n=i(127),r=i(99);i.d(t,"AbstractScene",(function(){return n.AbstractScene})),i.d(t,"AbstractActionManager",(function(){return n.AbstractActionManager})),i.d(t,"Action",(function(){return n.Action})),i.d(t,"ActionEvent",(function(){return n.ActionEvent})),i.d(t,"ActionManager",(function(){return n.ActionManager})),i.d(t,"Condition",(function(){return n.Condition})),i.d(t,"ValueCondition",(function(){return n.ValueCondition})),i.d(t,"PredicateCondition",(function(){return n.PredicateCondition})),i.d(t,"StateCondition",(function(){return n.StateCondition})),i.d(t,"SwitchBooleanAction",(function(){return n.SwitchBooleanAction})),i.d(t,"SetStateAction",(function(){return n.SetStateAction})),i.d(t,"SetValueAction",(function(){return n.SetValueAction})),i.d(t,"IncrementValueAction",(function(){return n.IncrementValueAction})),i.d(t,"PlayAnimationAction",(function(){return n.PlayAnimationAction})),i.d(t,"StopAnimationAction",(function(){return n.StopAnimationAction})),i.d(t,"DoNothingAction",(function(){return n.DoNothingAction})),i.d(t,"CombineAction",(function(){return n.CombineAction})),i.d(t,"ExecuteCodeAction",(function(){return n.ExecuteCodeAction})),i.d(t,"SetParentAction",(function(){return n.SetParentAction})),i.d(t,"PlaySoundAction",(function(){return n.PlaySoundAction})),i.d(t,"StopSoundAction",(function(){return n.StopSoundAction})),i.d(t,"InterpolateValueAction",(function(){return n.InterpolateValueAction})),i.d(t,"Animatable",(function(){return n.Animatable})),i.d(t,"_IAnimationState",(function(){return n._IAnimationState})),i.d(t,"Animation",(function(){return n.Animation})),i.d(t,"TargetedAnimation",(function(){return n.TargetedAnimation})),i.d(t,"AnimationGroup",(function(){return n.AnimationGroup})),i.d(t,"AnimationPropertiesOverride",(function(){return n.AnimationPropertiesOverride})),i.d(t,"EasingFunction",(function(){return n.EasingFunction})),i.d(t,"CircleEase",(function(){return n.CircleEase})),i.d(t,"BackEase",(function(){return n.BackEase})),i.d(t,"BounceEase",(function(){return n.BounceEase})),i.d(t,"CubicEase",(function(){return n.CubicEase})),i.d(t,"ElasticEase",(function(){return n.ElasticEase})),i.d(t,"ExponentialEase",(function(){return n.ExponentialEase})),i.d(t,"PowerEase",(function(){return n.PowerEase})),i.d(t,"QuadraticEase",(function(){return n.QuadraticEase})),i.d(t,"QuarticEase",(function(){return n.QuarticEase})),i.d(t,"QuinticEase",(function(){return n.QuinticEase})),i.d(t,"SineEase",(function(){return n.SineEase})),i.d(t,"BezierCurveEase",(function(){return n.BezierCurveEase})),i.d(t,"RuntimeAnimation",(function(){return n.RuntimeAnimation})),i.d(t,"AnimationEvent",(function(){return n.AnimationEvent})),i.d(t,"AnimationKeyInterpolation",(function(){return n.AnimationKeyInterpolation})),i.d(t,"AnimationRange",(function(){return n.AnimationRange})),i.d(t,"KeepAssets",(function(){return n.KeepAssets})),i.d(t,"InstantiatedEntries",(function(){return n.InstantiatedEntries})),i.d(t,"AssetContainer",(function(){return n.AssetContainer})),i.d(t,"Analyser",(function(){return n.Analyser})),i.d(t,"AudioEngine",(function(){return n.AudioEngine})),i.d(t,"AudioSceneComponent",(function(){return n.AudioSceneComponent})),i.d(t,"Sound",(function(){return n.Sound})),i.d(t,"SoundTrack",(function(){return n.SoundTrack})),i.d(t,"WeightedSound",(function(){return n.WeightedSound})),i.d(t,"AutoRotationBehavior",(function(){return n.AutoRotationBehavior})),i.d(t,"BouncingBehavior",(function(){return n.BouncingBehavior})),i.d(t,"FramingBehavior",(function(){return n.FramingBehavior})),i.d(t,"AttachToBoxBehavior",(function(){return n.AttachToBoxBehavior})),i.d(t,"FadeInOutBehavior",(function(){return n.FadeInOutBehavior})),i.d(t,"MultiPointerScaleBehavior",(function(){return n.MultiPointerScaleBehavior})),i.d(t,"PointerDragBehavior",(function(){return n.PointerDragBehavior})),i.d(t,"SixDofDragBehavior",(function(){return n.SixDofDragBehavior})),i.d(t,"Bone",(function(){return n.Bone})),i.d(t,"BoneIKController",(function(){return n.BoneIKController})),i.d(t,"BoneLookController",(function(){return n.BoneLookController})),i.d(t,"Skeleton",(function(){return n.Skeleton})),i.d(t,"ArcRotateCameraGamepadInput",(function(){return n.ArcRotateCameraGamepadInput})),i.d(t,"ArcRotateCameraKeyboardMoveInput",(function(){return n.ArcRotateCameraKeyboardMoveInput})),i.d(t,"ArcRotateCameraMouseWheelInput",(function(){return n.ArcRotateCameraMouseWheelInput})),i.d(t,"ArcRotateCameraPointersInput",(function(){return n.ArcRotateCameraPointersInput})),i.d(t,"ArcRotateCameraVRDeviceOrientationInput",(function(){return n.ArcRotateCameraVRDeviceOrientationInput})),i.d(t,"FlyCameraKeyboardInput",(function(){return n.FlyCameraKeyboardInput})),i.d(t,"FlyCameraMouseInput",(function(){return n.FlyCameraMouseInput})),i.d(t,"FollowCameraKeyboardMoveInput",(function(){return n.FollowCameraKeyboardMoveInput})),i.d(t,"FollowCameraMouseWheelInput",(function(){return n.FollowCameraMouseWheelInput})),i.d(t,"FollowCameraPointersInput",(function(){return n.FollowCameraPointersInput})),i.d(t,"FreeCameraDeviceOrientationInput",(function(){return n.FreeCameraDeviceOrientationInput})),i.d(t,"FreeCameraGamepadInput",(function(){return n.FreeCameraGamepadInput})),i.d(t,"FreeCameraKeyboardMoveInput",(function(){return n.FreeCameraKeyboardMoveInput})),i.d(t,"FreeCameraMouseInput",(function(){return n.FreeCameraMouseInput})),i.d(t,"FreeCameraMouseWheelInput",(function(){return n.FreeCameraMouseWheelInput})),i.d(t,"FreeCameraTouchInput",(function(){return n.FreeCameraTouchInput})),i.d(t,"FreeCameraVirtualJoystickInput",(function(){return n.FreeCameraVirtualJoystickInput})),i.d(t,"CameraInputTypes",(function(){return n.CameraInputTypes})),i.d(t,"CameraInputsManager",(function(){return n.CameraInputsManager})),i.d(t,"Camera",(function(){return n.Camera})),i.d(t,"TargetCamera",(function(){return n.TargetCamera})),i.d(t,"FreeCamera",(function(){return n.FreeCamera})),i.d(t,"FreeCameraInputsManager",(function(){return n.FreeCameraInputsManager})),i.d(t,"TouchCamera",(function(){return n.TouchCamera})),i.d(t,"ArcRotateCamera",(function(){return n.ArcRotateCamera})),i.d(t,"ArcRotateCameraInputsManager",(function(){return n.ArcRotateCameraInputsManager})),i.d(t,"DeviceOrientationCamera",(function(){return n.DeviceOrientationCamera})),i.d(t,"FlyCamera",(function(){return n.FlyCamera})),i.d(t,"FlyCameraInputsManager",(function(){return n.FlyCameraInputsManager})),i.d(t,"FollowCamera",(function(){return n.FollowCamera})),i.d(t,"ArcFollowCamera",(function(){return n.ArcFollowCamera})),i.d(t,"FollowCameraInputsManager",(function(){return n.FollowCameraInputsManager})),i.d(t,"GamepadCamera",(function(){return n.GamepadCamera})),i.d(t,"AnaglyphArcRotateCamera",(function(){return n.AnaglyphArcRotateCamera})),i.d(t,"AnaglyphFreeCamera",(function(){return n.AnaglyphFreeCamera})),i.d(t,"AnaglyphGamepadCamera",(function(){return n.AnaglyphGamepadCamera})),i.d(t,"AnaglyphUniversalCamera",(function(){return n.AnaglyphUniversalCamera})),i.d(t,"StereoscopicArcRotateCamera",(function(){return n.StereoscopicArcRotateCamera})),i.d(t,"StereoscopicFreeCamera",(function(){return n.StereoscopicFreeCamera})),i.d(t,"StereoscopicGamepadCamera",(function(){return n.StereoscopicGamepadCamera})),i.d(t,"StereoscopicUniversalCamera",(function(){return n.StereoscopicUniversalCamera})),i.d(t,"UniversalCamera",(function(){return n.UniversalCamera})),i.d(t,"VirtualJoysticksCamera",(function(){return n.VirtualJoysticksCamera})),i.d(t,"VRCameraMetrics",(function(){return n.VRCameraMetrics})),i.d(t,"VRDeviceOrientationArcRotateCamera",(function(){return n.VRDeviceOrientationArcRotateCamera})),i.d(t,"VRDeviceOrientationFreeCamera",(function(){return n.VRDeviceOrientationFreeCamera})),i.d(t,"VRDeviceOrientationGamepadCamera",(function(){return n.VRDeviceOrientationGamepadCamera})),i.d(t,"OnAfterEnteringVRObservableEvent",(function(){return n.OnAfterEnteringVRObservableEvent})),i.d(t,"VRExperienceHelper",(function(){return n.VRExperienceHelper})),i.d(t,"WebVRFreeCamera",(function(){return n.WebVRFreeCamera})),i.d(t,"Collider",(function(){return n.Collider})),i.d(t,"DefaultCollisionCoordinator",(function(){return n.DefaultCollisionCoordinator})),i.d(t,"PickingInfo",(function(){return n.PickingInfo})),i.d(t,"IntersectionInfo",(function(){return n.IntersectionInfo})),i.d(t,"_MeshCollisionData",(function(){return n._MeshCollisionData})),i.d(t,"BoundingBox",(function(){return n.BoundingBox})),i.d(t,"BoundingInfo",(function(){return n.BoundingInfo})),i.d(t,"BoundingSphere",(function(){return n.BoundingSphere})),i.d(t,"Octree",(function(){return n.Octree})),i.d(t,"OctreeBlock",(function(){return n.OctreeBlock})),i.d(t,"OctreeSceneComponent",(function(){return n.OctreeSceneComponent})),i.d(t,"Ray",(function(){return n.Ray})),i.d(t,"AxesViewer",(function(){return n.AxesViewer})),i.d(t,"BoneAxesViewer",(function(){return n.BoneAxesViewer})),i.d(t,"DebugLayerTab",(function(){return n.DebugLayerTab})),i.d(t,"DebugLayer",(function(){return n.DebugLayer})),i.d(t,"PhysicsViewer",(function(){return n.PhysicsViewer})),i.d(t,"RayHelper",(function(){return n.RayHelper})),i.d(t,"SkeletonViewer",(function(){return n.SkeletonViewer})),i.d(t,"DeviceInputSystem",(function(){return n.DeviceInputSystem})),i.d(t,"DeviceType",(function(){return n.DeviceType})),i.d(t,"PointerInput",(function(){return n.PointerInput})),i.d(t,"DualShockInput",(function(){return n.DualShockInput})),i.d(t,"XboxInput",(function(){return n.XboxInput})),i.d(t,"SwitchInput",(function(){return n.SwitchInput})),i.d(t,"DeviceSource",(function(){return n.DeviceSource})),i.d(t,"DeviceSourceManager",(function(){return n.DeviceSourceManager})),i.d(t,"Constants",(function(){return n.Constants})),i.d(t,"ThinEngine",(function(){return n.ThinEngine})),i.d(t,"Engine",(function(){return n.Engine})),i.d(t,"EngineStore",(function(){return n.EngineStore})),i.d(t,"NullEngineOptions",(function(){return n.NullEngineOptions})),i.d(t,"NullEngine",(function(){return n.NullEngine})),i.d(t,"_OcclusionDataStorage",(function(){return n._OcclusionDataStorage})),i.d(t,"_forceTransformFeedbackToBundle",(function(){return n._forceTransformFeedbackToBundle})),i.d(t,"EngineView",(function(){return n.EngineView})),i.d(t,"WebGLPipelineContext",(function(){return n.WebGLPipelineContext})),i.d(t,"WebGL2ShaderProcessor",(function(){return n.WebGL2ShaderProcessor})),i.d(t,"NativeEngine",(function(){return n.NativeEngine})),i.d(t,"ShaderCodeInliner",(function(){return n.ShaderCodeInliner})),i.d(t,"PerformanceConfigurator",(function(){return n.PerformanceConfigurator})),i.d(t,"KeyboardEventTypes",(function(){return n.KeyboardEventTypes})),i.d(t,"KeyboardInfo",(function(){return n.KeyboardInfo})),i.d(t,"KeyboardInfoPre",(function(){return n.KeyboardInfoPre})),i.d(t,"PointerEventTypes",(function(){return n.PointerEventTypes})),i.d(t,"PointerInfoBase",(function(){return n.PointerInfoBase})),i.d(t,"PointerInfoPre",(function(){return n.PointerInfoPre})),i.d(t,"PointerInfo",(function(){return n.PointerInfo})),i.d(t,"ClipboardEventTypes",(function(){return n.ClipboardEventTypes})),i.d(t,"ClipboardInfo",(function(){return n.ClipboardInfo})),i.d(t,"DaydreamController",(function(){return n.DaydreamController})),i.d(t,"GearVRController",(function(){return n.GearVRController})),i.d(t,"GenericController",(function(){return n.GenericController})),i.d(t,"OculusTouchController",(function(){return n.OculusTouchController})),i.d(t,"PoseEnabledControllerType",(function(){return n.PoseEnabledControllerType})),i.d(t,"PoseEnabledControllerHelper",(function(){return n.PoseEnabledControllerHelper})),i.d(t,"PoseEnabledController",(function(){return n.PoseEnabledController})),i.d(t,"ViveController",(function(){return n.ViveController})),i.d(t,"WebVRController",(function(){return n.WebVRController})),i.d(t,"WindowsMotionController",(function(){return n.WindowsMotionController})),i.d(t,"XRWindowsMotionController",(function(){return n.XRWindowsMotionController})),i.d(t,"StickValues",(function(){return n.StickValues})),i.d(t,"Gamepad",(function(){return n.Gamepad})),i.d(t,"GenericPad",(function(){return n.GenericPad})),i.d(t,"GamepadManager",(function(){return n.GamepadManager})),i.d(t,"GamepadSystemSceneComponent",(function(){return n.GamepadSystemSceneComponent})),i.d(t,"Xbox360Button",(function(){return n.Xbox360Button})),i.d(t,"Xbox360Dpad",(function(){return n.Xbox360Dpad})),i.d(t,"Xbox360Pad",(function(){return n.Xbox360Pad})),i.d(t,"DualShockButton",(function(){return n.DualShockButton})),i.d(t,"DualShockDpad",(function(){return n.DualShockDpad})),i.d(t,"DualShockPad",(function(){return n.DualShockPad})),i.d(t,"AxisDragGizmo",(function(){return n.AxisDragGizmo})),i.d(t,"AxisScaleGizmo",(function(){return n.AxisScaleGizmo})),i.d(t,"BoundingBoxGizmo",(function(){return n.BoundingBoxGizmo})),i.d(t,"Gizmo",(function(){return n.Gizmo})),i.d(t,"GizmoManager",(function(){return n.GizmoManager})),i.d(t,"PlaneRotationGizmo",(function(){return n.PlaneRotationGizmo})),i.d(t,"PositionGizmo",(function(){return n.PositionGizmo})),i.d(t,"RotationGizmo",(function(){return n.RotationGizmo})),i.d(t,"ScaleGizmo",(function(){return n.ScaleGizmo})),i.d(t,"LightGizmo",(function(){return n.LightGizmo})),i.d(t,"CameraGizmo",(function(){return n.CameraGizmo})),i.d(t,"PlaneDragGizmo",(function(){return n.PlaneDragGizmo})),i.d(t,"EnvironmentHelper",(function(){return n.EnvironmentHelper})),i.d(t,"PhotoDome",(function(){return n.PhotoDome})),i.d(t,"_forceSceneHelpersToBundle",(function(){return n._forceSceneHelpersToBundle})),i.d(t,"VideoDome",(function(){return n.VideoDome})),i.d(t,"EngineInstrumentation",(function(){return n.EngineInstrumentation})),i.d(t,"SceneInstrumentation",(function(){return n.SceneInstrumentation})),i.d(t,"_TimeToken",(function(){return n._TimeToken})),i.d(t,"EffectLayer",(function(){return n.EffectLayer})),i.d(t,"EffectLayerSceneComponent",(function(){return n.EffectLayerSceneComponent})),i.d(t,"GlowLayer",(function(){return n.GlowLayer})),i.d(t,"HighlightLayer",(function(){return n.HighlightLayer})),i.d(t,"Layer",(function(){return n.Layer})),i.d(t,"LayerSceneComponent",(function(){return n.LayerSceneComponent})),i.d(t,"LensFlare",(function(){return n.LensFlare})),i.d(t,"LensFlareSystem",(function(){return n.LensFlareSystem})),i.d(t,"LensFlareSystemSceneComponent",(function(){return n.LensFlareSystemSceneComponent})),i.d(t,"Light",(function(){return n.Light})),i.d(t,"ShadowLight",(function(){return n.ShadowLight})),i.d(t,"ShadowGenerator",(function(){return n.ShadowGenerator})),i.d(t,"CascadedShadowGenerator",(function(){return n.CascadedShadowGenerator})),i.d(t,"ShadowGeneratorSceneComponent",(function(){return n.ShadowGeneratorSceneComponent})),i.d(t,"DirectionalLight",(function(){return n.DirectionalLight})),i.d(t,"HemisphericLight",(function(){return n.HemisphericLight})),i.d(t,"PointLight",(function(){return n.PointLight})),i.d(t,"SpotLight",(function(){return n.SpotLight})),i.d(t,"DefaultLoadingScreen",(function(){return n.DefaultLoadingScreen})),i.d(t,"_BabylonLoaderRegistered",(function(){return n._BabylonLoaderRegistered})),i.d(t,"BabylonFileLoaderConfiguration",(function(){return n.BabylonFileLoaderConfiguration})),i.d(t,"SceneLoaderAnimationGroupLoadingMode",(function(){return n.SceneLoaderAnimationGroupLoadingMode})),i.d(t,"SceneLoader",(function(){return n.SceneLoader})),i.d(t,"SceneLoaderFlags",(function(){return n.SceneLoaderFlags})),i.d(t,"BackgroundMaterial",(function(){return n.BackgroundMaterial})),i.d(t,"ColorCurves",(function(){return n.ColorCurves})),i.d(t,"EffectFallbacks",(function(){return n.EffectFallbacks})),i.d(t,"Effect",(function(){return n.Effect})),i.d(t,"FresnelParameters",(function(){return n.FresnelParameters})),i.d(t,"ImageProcessingConfigurationDefines",(function(){return n.ImageProcessingConfigurationDefines})),i.d(t,"ImageProcessingConfiguration",(function(){return n.ImageProcessingConfiguration})),i.d(t,"Material",(function(){return n.Material})),i.d(t,"MaterialDefines",(function(){return n.MaterialDefines})),i.d(t,"ThinMaterialHelper",(function(){return n.ThinMaterialHelper})),i.d(t,"MaterialHelper",(function(){return n.MaterialHelper})),i.d(t,"MultiMaterial",(function(){return n.MultiMaterial})),i.d(t,"PBRMaterialDefines",(function(){return n.PBRMaterialDefines})),i.d(t,"PBRBaseMaterial",(function(){return n.PBRBaseMaterial})),i.d(t,"PBRBaseSimpleMaterial",(function(){return n.PBRBaseSimpleMaterial})),i.d(t,"PBRMaterial",(function(){return n.PBRMaterial})),i.d(t,"PBRMetallicRoughnessMaterial",(function(){return n.PBRMetallicRoughnessMaterial})),i.d(t,"PBRSpecularGlossinessMaterial",(function(){return n.PBRSpecularGlossinessMaterial})),i.d(t,"PushMaterial",(function(){return n.PushMaterial})),i.d(t,"ShaderMaterial",(function(){return n.ShaderMaterial})),i.d(t,"StandardMaterialDefines",(function(){return n.StandardMaterialDefines})),i.d(t,"StandardMaterial",(function(){return n.StandardMaterial})),i.d(t,"BaseTexture",(function(){return n.BaseTexture})),i.d(t,"ColorGradingTexture",(function(){return n.ColorGradingTexture})),i.d(t,"CubeTexture",(function(){return n.CubeTexture})),i.d(t,"DynamicTexture",(function(){return n.DynamicTexture})),i.d(t,"EquiRectangularCubeTexture",(function(){return n.EquiRectangularCubeTexture})),i.d(t,"HDRFiltering",(function(){return n.HDRFiltering})),i.d(t,"HDRCubeTexture",(function(){return n.HDRCubeTexture})),i.d(t,"HtmlElementTexture",(function(){return n.HtmlElementTexture})),i.d(t,"InternalTextureSource",(function(){return n.InternalTextureSource})),i.d(t,"InternalTexture",(function(){return n.InternalTexture})),i.d(t,"_DDSTextureLoader",(function(){return n._DDSTextureLoader})),i.d(t,"_ENVTextureLoader",(function(){return n._ENVTextureLoader})),i.d(t,"_KTXTextureLoader",(function(){return n._KTXTextureLoader})),i.d(t,"_TGATextureLoader",(function(){return n._TGATextureLoader})),i.d(t,"_BasisTextureLoader",(function(){return n._BasisTextureLoader})),i.d(t,"MirrorTexture",(function(){return n.MirrorTexture})),i.d(t,"MultiRenderTarget",(function(){return n.MultiRenderTarget})),i.d(t,"TexturePacker",(function(){return n.TexturePacker})),i.d(t,"TexturePackerFrame",(function(){return n.TexturePackerFrame})),i.d(t,"CustomProceduralTexture",(function(){return n.CustomProceduralTexture})),i.d(t,"NoiseProceduralTexture",(function(){return n.NoiseProceduralTexture})),i.d(t,"ProceduralTexture",(function(){return n.ProceduralTexture})),i.d(t,"ProceduralTextureSceneComponent",(function(){return n.ProceduralTextureSceneComponent})),i.d(t,"RawCubeTexture",(function(){return n.RawCubeTexture})),i.d(t,"RawTexture",(function(){return n.RawTexture})),i.d(t,"RawTexture2DArray",(function(){return n.RawTexture2DArray})),i.d(t,"RawTexture3D",(function(){return n.RawTexture3D})),i.d(t,"RefractionTexture",(function(){return n.RefractionTexture})),i.d(t,"RenderTargetTexture",(function(){return n.RenderTargetTexture})),i.d(t,"Texture",(function(){return n.Texture})),i.d(t,"VideoTexture",(function(){return n.VideoTexture})),i.d(t,"UniformBuffer",(function(){return n.UniformBuffer})),i.d(t,"MaterialFlags",(function(){return n.MaterialFlags})),i.d(t,"NodeMaterialBlockTargets",(function(){return n.NodeMaterialBlockTargets})),i.d(t,"NodeMaterialBlockConnectionPointTypes",(function(){return n.NodeMaterialBlockConnectionPointTypes})),i.d(t,"NodeMaterialBlockConnectionPointMode",(function(){return n.NodeMaterialBlockConnectionPointMode})),i.d(t,"NodeMaterialSystemValues",(function(){return n.NodeMaterialSystemValues})),i.d(t,"NodeMaterialModes",(function(){return n.NodeMaterialModes})),i.d(t,"NodeMaterialConnectionPointCompatibilityStates",(function(){return n.NodeMaterialConnectionPointCompatibilityStates})),i.d(t,"NodeMaterialConnectionPointDirection",(function(){return n.NodeMaterialConnectionPointDirection})),i.d(t,"NodeMaterialConnectionPoint",(function(){return n.NodeMaterialConnectionPoint})),i.d(t,"NodeMaterialBlock",(function(){return n.NodeMaterialBlock})),i.d(t,"NodeMaterialDefines",(function(){return n.NodeMaterialDefines})),i.d(t,"NodeMaterial",(function(){return n.NodeMaterial})),i.d(t,"VertexOutputBlock",(function(){return n.VertexOutputBlock})),i.d(t,"BonesBlock",(function(){return n.BonesBlock})),i.d(t,"InstancesBlock",(function(){return n.InstancesBlock})),i.d(t,"MorphTargetsBlock",(function(){return n.MorphTargetsBlock})),i.d(t,"LightInformationBlock",(function(){return n.LightInformationBlock})),i.d(t,"FragmentOutputBlock",(function(){return n.FragmentOutputBlock})),i.d(t,"ImageProcessingBlock",(function(){return n.ImageProcessingBlock})),i.d(t,"PerturbNormalBlock",(function(){return n.PerturbNormalBlock})),i.d(t,"DiscardBlock",(function(){return n.DiscardBlock})),i.d(t,"FrontFacingBlock",(function(){return n.FrontFacingBlock})),i.d(t,"DerivativeBlock",(function(){return n.DerivativeBlock})),i.d(t,"FragCoordBlock",(function(){return n.FragCoordBlock})),i.d(t,"ScreenSizeBlock",(function(){return n.ScreenSizeBlock})),i.d(t,"FogBlock",(function(){return n.FogBlock})),i.d(t,"LightBlock",(function(){return n.LightBlock})),i.d(t,"TextureBlock",(function(){return n.TextureBlock})),i.d(t,"ReflectionTextureBlock",(function(){return n.ReflectionTextureBlock})),i.d(t,"CurrentScreenBlock",(function(){return n.CurrentScreenBlock})),i.d(t,"InputBlock",(function(){return n.InputBlock})),i.d(t,"AnimatedInputBlockTypes",(function(){return n.AnimatedInputBlockTypes})),i.d(t,"MultiplyBlock",(function(){return n.MultiplyBlock})),i.d(t,"AddBlock",(function(){return n.AddBlock})),i.d(t,"ScaleBlock",(function(){return n.ScaleBlock})),i.d(t,"ClampBlock",(function(){return n.ClampBlock})),i.d(t,"CrossBlock",(function(){return n.CrossBlock})),i.d(t,"DotBlock",(function(){return n.DotBlock})),i.d(t,"TransformBlock",(function(){return n.TransformBlock})),i.d(t,"RemapBlock",(function(){return n.RemapBlock})),i.d(t,"NormalizeBlock",(function(){return n.NormalizeBlock})),i.d(t,"TrigonometryBlockOperations",(function(){return n.TrigonometryBlockOperations})),i.d(t,"TrigonometryBlock",(function(){return n.TrigonometryBlock})),i.d(t,"ColorMergerBlock",(function(){return n.ColorMergerBlock})),i.d(t,"VectorMergerBlock",(function(){return n.VectorMergerBlock})),i.d(t,"ColorSplitterBlock",(function(){return n.ColorSplitterBlock})),i.d(t,"VectorSplitterBlock",(function(){return n.VectorSplitterBlock})),i.d(t,"LerpBlock",(function(){return n.LerpBlock})),i.d(t,"DivideBlock",(function(){return n.DivideBlock})),i.d(t,"SubtractBlock",(function(){return n.SubtractBlock})),i.d(t,"StepBlock",(function(){return n.StepBlock})),i.d(t,"OneMinusBlock",(function(){return n.OneMinusBlock})),i.d(t,"ViewDirectionBlock",(function(){return n.ViewDirectionBlock})),i.d(t,"FresnelBlock",(function(){return n.FresnelBlock})),i.d(t,"MaxBlock",(function(){return n.MaxBlock})),i.d(t,"MinBlock",(function(){return n.MinBlock})),i.d(t,"DistanceBlock",(function(){return n.DistanceBlock})),i.d(t,"LengthBlock",(function(){return n.LengthBlock})),i.d(t,"NegateBlock",(function(){return n.NegateBlock})),i.d(t,"PowBlock",(function(){return n.PowBlock})),i.d(t,"RandomNumberBlock",(function(){return n.RandomNumberBlock})),i.d(t,"ArcTan2Block",(function(){return n.ArcTan2Block})),i.d(t,"SmoothStepBlock",(function(){return n.SmoothStepBlock})),i.d(t,"ReciprocalBlock",(function(){return n.ReciprocalBlock})),i.d(t,"ReplaceColorBlock",(function(){return n.ReplaceColorBlock})),i.d(t,"PosterizeBlock",(function(){return n.PosterizeBlock})),i.d(t,"WaveBlockKind",(function(){return n.WaveBlockKind})),i.d(t,"WaveBlock",(function(){return n.WaveBlock})),i.d(t,"GradientBlockColorStep",(function(){return n.GradientBlockColorStep})),i.d(t,"GradientBlock",(function(){return n.GradientBlock})),i.d(t,"NLerpBlock",(function(){return n.NLerpBlock})),i.d(t,"WorleyNoise3DBlock",(function(){return n.WorleyNoise3DBlock})),i.d(t,"SimplexPerlin3DBlock",(function(){return n.SimplexPerlin3DBlock})),i.d(t,"NormalBlendBlock",(function(){return n.NormalBlendBlock})),i.d(t,"Rotate2dBlock",(function(){return n.Rotate2dBlock})),i.d(t,"ReflectBlock",(function(){return n.ReflectBlock})),i.d(t,"RefractBlock",(function(){return n.RefractBlock})),i.d(t,"DesaturateBlock",(function(){return n.DesaturateBlock})),i.d(t,"PBRMetallicRoughnessBlock",(function(){return n.PBRMetallicRoughnessBlock})),i.d(t,"SheenBlock",(function(){return n.SheenBlock})),i.d(t,"AnisotropyBlock",(function(){return n.AnisotropyBlock})),i.d(t,"ReflectionBlock",(function(){return n.ReflectionBlock})),i.d(t,"ClearCoatBlock",(function(){return n.ClearCoatBlock})),i.d(t,"RefractionBlock",(function(){return n.RefractionBlock})),i.d(t,"SubSurfaceBlock",(function(){return n.SubSurfaceBlock})),i.d(t,"ParticleTextureBlock",(function(){return n.ParticleTextureBlock})),i.d(t,"ParticleRampGradientBlock",(function(){return n.ParticleRampGradientBlock})),i.d(t,"ParticleBlendMultiplyBlock",(function(){return n.ParticleBlendMultiplyBlock})),i.d(t,"ModBlock",(function(){return n.ModBlock})),i.d(t,"NodeMaterialOptimizer",(function(){return n.NodeMaterialOptimizer})),i.d(t,"PropertyTypeForEdition",(function(){return n.PropertyTypeForEdition})),i.d(t,"editableInPropertyPage",(function(){return n.editableInPropertyPage})),i.d(t,"EffectRenderer",(function(){return n.EffectRenderer})),i.d(t,"EffectWrapper",(function(){return n.EffectWrapper})),i.d(t,"ShadowDepthWrapper",(function(){return n.ShadowDepthWrapper})),i.d(t,"Scalar",(function(){return n.Scalar})),i.d(t,"extractMinAndMaxIndexed",(function(){return n.extractMinAndMaxIndexed})),i.d(t,"extractMinAndMax",(function(){return n.extractMinAndMax})),i.d(t,"Space",(function(){return n.Space})),i.d(t,"Axis",(function(){return n.Axis})),i.d(t,"Coordinate",(function(){return n.Coordinate})),i.d(t,"Color3",(function(){return n.Color3})),i.d(t,"Color4",(function(){return n.Color4})),i.d(t,"TmpColors",(function(){return n.TmpColors})),i.d(t,"ToGammaSpace",(function(){return n.ToGammaSpace})),i.d(t,"ToLinearSpace",(function(){return n.ToLinearSpace})),i.d(t,"Epsilon",(function(){return n.Epsilon})),i.d(t,"Frustum",(function(){return n.Frustum})),i.d(t,"Orientation",(function(){return n.Orientation})),i.d(t,"BezierCurve",(function(){return n.BezierCurve})),i.d(t,"Angle",(function(){return n.Angle})),i.d(t,"Arc2",(function(){return n.Arc2})),i.d(t,"Path2",(function(){return n.Path2})),i.d(t,"Path3D",(function(){return n.Path3D})),i.d(t,"Curve3",(function(){return n.Curve3})),i.d(t,"Plane",(function(){return n.Plane})),i.d(t,"Size",(function(){return n.Size})),i.d(t,"Vector2",(function(){return n.Vector2})),i.d(t,"Vector3",(function(){return n.Vector3})),i.d(t,"Vector4",(function(){return n.Vector4})),i.d(t,"Quaternion",(function(){return n.Quaternion})),i.d(t,"Matrix",(function(){return n.Matrix})),i.d(t,"TmpVectors",(function(){return n.TmpVectors})),i.d(t,"PositionNormalVertex",(function(){return n.PositionNormalVertex})),i.d(t,"PositionNormalTextureVertex",(function(){return n.PositionNormalTextureVertex})),i.d(t,"Viewport",(function(){return n.Viewport})),i.d(t,"SphericalHarmonics",(function(){return n.SphericalHarmonics})),i.d(t,"SphericalPolynomial",(function(){return n.SphericalPolynomial})),i.d(t,"AbstractMesh",(function(){return n.AbstractMesh})),i.d(t,"Buffer",(function(){return n.Buffer})),i.d(t,"VertexBuffer",(function(){return n.VertexBuffer})),i.d(t,"DracoCompression",(function(){return n.DracoCompression})),i.d(t,"CSG",(function(){return n.CSG})),i.d(t,"Geometry",(function(){return n.Geometry})),i.d(t,"GroundMesh",(function(){return n.GroundMesh})),i.d(t,"TrailMesh",(function(){return n.TrailMesh})),i.d(t,"InstancedMesh",(function(){return n.InstancedMesh})),i.d(t,"LinesMesh",(function(){return n.LinesMesh})),i.d(t,"InstancedLinesMesh",(function(){return n.InstancedLinesMesh})),i.d(t,"_CreationDataStorage",(function(){return n._CreationDataStorage})),i.d(t,"_InstancesBatch",(function(){return n._InstancesBatch})),i.d(t,"Mesh",(function(){return n.Mesh})),i.d(t,"VertexData",(function(){return n.VertexData})),i.d(t,"MeshBuilder",(function(){return n.MeshBuilder})),i.d(t,"SimplificationSettings",(function(){return n.SimplificationSettings})),i.d(t,"SimplificationQueue",(function(){return n.SimplificationQueue})),i.d(t,"SimplificationType",(function(){return n.SimplificationType})),i.d(t,"QuadraticErrorSimplification",(function(){return n.QuadraticErrorSimplification})),i.d(t,"SimplicationQueueSceneComponent",(function(){return n.SimplicationQueueSceneComponent})),i.d(t,"Polygon",(function(){return n.Polygon})),i.d(t,"PolygonMeshBuilder",(function(){return n.PolygonMeshBuilder})),i.d(t,"SubMesh",(function(){return n.SubMesh})),i.d(t,"MeshLODLevel",(function(){return n.MeshLODLevel})),i.d(t,"TransformNode",(function(){return n.TransformNode})),i.d(t,"BoxBuilder",(function(){return n.BoxBuilder})),i.d(t,"TiledBoxBuilder",(function(){return n.TiledBoxBuilder})),i.d(t,"DiscBuilder",(function(){return n.DiscBuilder})),i.d(t,"RibbonBuilder",(function(){return n.RibbonBuilder})),i.d(t,"SphereBuilder",(function(){return n.SphereBuilder})),i.d(t,"HemisphereBuilder",(function(){return n.HemisphereBuilder})),i.d(t,"CylinderBuilder",(function(){return n.CylinderBuilder})),i.d(t,"TorusBuilder",(function(){return n.TorusBuilder})),i.d(t,"TorusKnotBuilder",(function(){return n.TorusKnotBuilder})),i.d(t,"LinesBuilder",(function(){return n.LinesBuilder})),i.d(t,"PolygonBuilder",(function(){return n.PolygonBuilder})),i.d(t,"ShapeBuilder",(function(){return n.ShapeBuilder})),i.d(t,"LatheBuilder",(function(){return n.LatheBuilder})),i.d(t,"PlaneBuilder",(function(){return n.PlaneBuilder})),i.d(t,"TiledPlaneBuilder",(function(){return n.TiledPlaneBuilder})),i.d(t,"GroundBuilder",(function(){return n.GroundBuilder})),i.d(t,"TubeBuilder",(function(){return n.TubeBuilder})),i.d(t,"PolyhedronBuilder",(function(){return n.PolyhedronBuilder})),i.d(t,"IcoSphereBuilder",(function(){return n.IcoSphereBuilder})),i.d(t,"DecalBuilder",(function(){return n.DecalBuilder})),i.d(t,"CapsuleBuilder",(function(){return n.CapsuleBuilder})),i.d(t,"DataBuffer",(function(){return n.DataBuffer})),i.d(t,"WebGLDataBuffer",(function(){return n.WebGLDataBuffer})),i.d(t,"MorphTarget",(function(){return n.MorphTarget})),i.d(t,"MorphTargetManager",(function(){return n.MorphTargetManager})),i.d(t,"RecastJSPlugin",(function(){return n.RecastJSPlugin})),i.d(t,"RecastJSCrowd",(function(){return n.RecastJSCrowd})),i.d(t,"Node",(function(){return n.Node})),i.d(t,"Database",(function(){return n.Database})),i.d(t,"BaseParticleSystem",(function(){return n.BaseParticleSystem})),i.d(t,"BoxParticleEmitter",(function(){return n.BoxParticleEmitter})),i.d(t,"ConeParticleEmitter",(function(){return n.ConeParticleEmitter})),i.d(t,"CylinderParticleEmitter",(function(){return n.CylinderParticleEmitter})),i.d(t,"CylinderDirectedParticleEmitter",(function(){return n.CylinderDirectedParticleEmitter})),i.d(t,"HemisphericParticleEmitter",(function(){return n.HemisphericParticleEmitter})),i.d(t,"PointParticleEmitter",(function(){return n.PointParticleEmitter})),i.d(t,"SphereParticleEmitter",(function(){return n.SphereParticleEmitter})),i.d(t,"SphereDirectedParticleEmitter",(function(){return n.SphereDirectedParticleEmitter})),i.d(t,"CustomParticleEmitter",(function(){return n.CustomParticleEmitter})),i.d(t,"MeshParticleEmitter",(function(){return n.MeshParticleEmitter})),i.d(t,"GPUParticleSystem",(function(){return n.GPUParticleSystem})),i.d(t,"Particle",(function(){return n.Particle})),i.d(t,"ParticleHelper",(function(){return n.ParticleHelper})),i.d(t,"ParticleSystem",(function(){return n.ParticleSystem})),i.d(t,"ParticleSystemSet",(function(){return n.ParticleSystemSet})),i.d(t,"SolidParticle",(function(){return n.SolidParticle})),i.d(t,"ModelShape",(function(){return n.ModelShape})),i.d(t,"DepthSortedParticle",(function(){return n.DepthSortedParticle})),i.d(t,"SolidParticleVertex",(function(){return n.SolidParticleVertex})),i.d(t,"SolidParticleSystem",(function(){return n.SolidParticleSystem})),i.d(t,"CloudPoint",(function(){return n.CloudPoint})),i.d(t,"PointsGroup",(function(){return n.PointsGroup})),i.d(t,"PointColor",(function(){return n.PointColor})),i.d(t,"PointsCloudSystem",(function(){return n.PointsCloudSystem})),i.d(t,"SubEmitterType",(function(){return n.SubEmitterType})),i.d(t,"SubEmitter",(function(){return n.SubEmitter})),i.d(t,"PhysicsEngine",(function(){return n.PhysicsEngine})),i.d(t,"PhysicsEngineSceneComponent",(function(){return n.PhysicsEngineSceneComponent})),i.d(t,"PhysicsHelper",(function(){return n.PhysicsHelper})),i.d(t,"PhysicsRadialExplosionEventOptions",(function(){return n.PhysicsRadialExplosionEventOptions})),i.d(t,"PhysicsUpdraftEventOptions",(function(){return n.PhysicsUpdraftEventOptions})),i.d(t,"PhysicsVortexEventOptions",(function(){return n.PhysicsVortexEventOptions})),i.d(t,"PhysicsRadialImpulseFalloff",(function(){return n.PhysicsRadialImpulseFalloff})),i.d(t,"PhysicsUpdraftMode",(function(){return n.PhysicsUpdraftMode})),i.d(t,"PhysicsImpostor",(function(){return n.PhysicsImpostor})),i.d(t,"PhysicsJoint",(function(){return n.PhysicsJoint})),i.d(t,"DistanceJoint",(function(){return n.DistanceJoint})),i.d(t,"MotorEnabledJoint",(function(){return n.MotorEnabledJoint})),i.d(t,"HingeJoint",(function(){return n.HingeJoint})),i.d(t,"Hinge2Joint",(function(){return n.Hinge2Joint})),i.d(t,"CannonJSPlugin",(function(){return n.CannonJSPlugin})),i.d(t,"AmmoJSPlugin",(function(){return n.AmmoJSPlugin})),i.d(t,"OimoJSPlugin",(function(){return n.OimoJSPlugin})),i.d(t,"AnaglyphPostProcess",(function(){return n.AnaglyphPostProcess})),i.d(t,"BlackAndWhitePostProcess",(function(){return n.BlackAndWhitePostProcess})),i.d(t,"BloomEffect",(function(){return n.BloomEffect})),i.d(t,"BloomMergePostProcess",(function(){return n.BloomMergePostProcess})),i.d(t,"BlurPostProcess",(function(){return n.BlurPostProcess})),i.d(t,"ChromaticAberrationPostProcess",(function(){return n.ChromaticAberrationPostProcess})),i.d(t,"CircleOfConfusionPostProcess",(function(){return n.CircleOfConfusionPostProcess})),i.d(t,"ColorCorrectionPostProcess",(function(){return n.ColorCorrectionPostProcess})),i.d(t,"ConvolutionPostProcess",(function(){return n.ConvolutionPostProcess})),i.d(t,"DepthOfFieldBlurPostProcess",(function(){return n.DepthOfFieldBlurPostProcess})),i.d(t,"DepthOfFieldEffectBlurLevel",(function(){return n.DepthOfFieldEffectBlurLevel})),i.d(t,"DepthOfFieldEffect",(function(){return n.DepthOfFieldEffect})),i.d(t,"DepthOfFieldMergePostProcessOptions",(function(){return n.DepthOfFieldMergePostProcessOptions})),i.d(t,"DepthOfFieldMergePostProcess",(function(){return n.DepthOfFieldMergePostProcess})),i.d(t,"DisplayPassPostProcess",(function(){return n.DisplayPassPostProcess})),i.d(t,"ExtractHighlightsPostProcess",(function(){return n.ExtractHighlightsPostProcess})),i.d(t,"FilterPostProcess",(function(){return n.FilterPostProcess})),i.d(t,"FxaaPostProcess",(function(){return n.FxaaPostProcess})),i.d(t,"GrainPostProcess",(function(){return n.GrainPostProcess})),i.d(t,"HighlightsPostProcess",(function(){return n.HighlightsPostProcess})),i.d(t,"ImageProcessingPostProcess",(function(){return n.ImageProcessingPostProcess})),i.d(t,"MotionBlurPostProcess",(function(){return n.MotionBlurPostProcess})),i.d(t,"PassPostProcess",(function(){return n.PassPostProcess})),i.d(t,"PassCubePostProcess",(function(){return n.PassCubePostProcess})),i.d(t,"PostProcess",(function(){return n.PostProcess})),i.d(t,"PostProcessManager",(function(){return n.PostProcessManager})),i.d(t,"RefractionPostProcess",(function(){return n.RefractionPostProcess})),i.d(t,"DefaultRenderingPipeline",(function(){return n.DefaultRenderingPipeline})),i.d(t,"LensRenderingPipeline",(function(){return n.LensRenderingPipeline})),i.d(t,"SSAO2RenderingPipeline",(function(){return n.SSAO2RenderingPipeline})),i.d(t,"SSAORenderingPipeline",(function(){return n.SSAORenderingPipeline})),i.d(t,"StandardRenderingPipeline",(function(){return n.StandardRenderingPipeline})),i.d(t,"PostProcessRenderEffect",(function(){return n.PostProcessRenderEffect})),i.d(t,"PostProcessRenderPipeline",(function(){return n.PostProcessRenderPipeline})),i.d(t,"PostProcessRenderPipelineManager",(function(){return n.PostProcessRenderPipelineManager})),i.d(t,"PostProcessRenderPipelineManagerSceneComponent",(function(){return n.PostProcessRenderPipelineManagerSceneComponent})),i.d(t,"SharpenPostProcess",(function(){return n.SharpenPostProcess})),i.d(t,"StereoscopicInterlacePostProcessI",(function(){return n.StereoscopicInterlacePostProcessI})),i.d(t,"StereoscopicInterlacePostProcess",(function(){return n.StereoscopicInterlacePostProcess})),i.d(t,"TonemappingOperator",(function(){return n.TonemappingOperator})),i.d(t,"TonemapPostProcess",(function(){return n.TonemapPostProcess})),i.d(t,"VolumetricLightScatteringPostProcess",(function(){return n.VolumetricLightScatteringPostProcess})),i.d(t,"VRDistortionCorrectionPostProcess",(function(){return n.VRDistortionCorrectionPostProcess})),i.d(t,"VRMultiviewToSingleviewPostProcess",(function(){return n.VRMultiviewToSingleviewPostProcess})),i.d(t,"ScreenSpaceReflectionPostProcess",(function(){return n.ScreenSpaceReflectionPostProcess})),i.d(t,"ScreenSpaceCurvaturePostProcess",(function(){return n.ScreenSpaceCurvaturePostProcess})),i.d(t,"ReflectionProbe",(function(){return n.ReflectionProbe})),i.d(t,"BoundingBoxRenderer",(function(){return n.BoundingBoxRenderer})),i.d(t,"DepthRenderer",(function(){return n.DepthRenderer})),i.d(t,"DepthRendererSceneComponent",(function(){return n.DepthRendererSceneComponent})),i.d(t,"EdgesRenderer",(function(){return n.EdgesRenderer})),i.d(t,"LineEdgesRenderer",(function(){return n.LineEdgesRenderer})),i.d(t,"GeometryBufferRenderer",(function(){return n.GeometryBufferRenderer})),i.d(t,"GeometryBufferRendererSceneComponent",(function(){return n.GeometryBufferRendererSceneComponent})),i.d(t,"PrePassRenderer",(function(){return n.PrePassRenderer})),i.d(t,"PrePassRendererSceneComponent",(function(){return n.PrePassRendererSceneComponent})),i.d(t,"SubSurfaceSceneComponent",(function(){return n.SubSurfaceSceneComponent})),i.d(t,"OutlineRenderer",(function(){return n.OutlineRenderer})),i.d(t,"RenderingGroup",(function(){return n.RenderingGroup})),i.d(t,"RenderingGroupInfo",(function(){return n.RenderingGroupInfo})),i.d(t,"RenderingManager",(function(){return n.RenderingManager})),i.d(t,"UtilityLayerRenderer",(function(){return n.UtilityLayerRenderer})),i.d(t,"Scene",(function(){return n.Scene})),i.d(t,"SceneComponentConstants",(function(){return n.SceneComponentConstants})),i.d(t,"Stage",(function(){return n.Stage})),i.d(t,"Sprite",(function(){return n.Sprite})),i.d(t,"SpriteManager",(function(){return n.SpriteManager})),i.d(t,"SpriteMap",(function(){return n.SpriteMap})),i.d(t,"SpritePackedManager",(function(){return n.SpritePackedManager})),i.d(t,"SpriteSceneComponent",(function(){return n.SpriteSceneComponent})),i.d(t,"AlphaState",(function(){return n.AlphaState})),i.d(t,"DepthCullingState",(function(){return n.DepthCullingState})),i.d(t,"StencilState",(function(){return n.StencilState})),i.d(t,"AndOrNotEvaluator",(function(){return n.AndOrNotEvaluator})),i.d(t,"AssetTaskState",(function(){return n.AssetTaskState})),i.d(t,"AbstractAssetTask",(function(){return n.AbstractAssetTask})),i.d(t,"AssetsProgressEvent",(function(){return n.AssetsProgressEvent})),i.d(t,"ContainerAssetTask",(function(){return n.ContainerAssetTask})),i.d(t,"MeshAssetTask",(function(){return n.MeshAssetTask})),i.d(t,"TextFileAssetTask",(function(){return n.TextFileAssetTask})),i.d(t,"BinaryFileAssetTask",(function(){return n.BinaryFileAssetTask})),i.d(t,"ImageAssetTask",(function(){return n.ImageAssetTask})),i.d(t,"TextureAssetTask",(function(){return n.TextureAssetTask})),i.d(t,"CubeTextureAssetTask",(function(){return n.CubeTextureAssetTask})),i.d(t,"HDRCubeTextureAssetTask",(function(){return n.HDRCubeTextureAssetTask})),i.d(t,"EquiRectangularCubeTextureAssetTask",(function(){return n.EquiRectangularCubeTextureAssetTask})),i.d(t,"AssetsManager",(function(){return n.AssetsManager})),i.d(t,"BasisTranscodeConfiguration",(function(){return n.BasisTranscodeConfiguration})),i.d(t,"BasisTools",(function(){return n.BasisTools})),i.d(t,"DDSTools",(function(){return n.DDSTools})),i.d(t,"expandToProperty",(function(){return n.expandToProperty})),i.d(t,"serialize",(function(){return n.serialize})),i.d(t,"serializeAsTexture",(function(){return n.serializeAsTexture})),i.d(t,"serializeAsColor3",(function(){return n.serializeAsColor3})),i.d(t,"serializeAsFresnelParameters",(function(){return n.serializeAsFresnelParameters})),i.d(t,"serializeAsVector2",(function(){return n.serializeAsVector2})),i.d(t,"serializeAsVector3",(function(){return n.serializeAsVector3})),i.d(t,"serializeAsMeshReference",(function(){return n.serializeAsMeshReference})),i.d(t,"serializeAsColorCurves",(function(){return n.serializeAsColorCurves})),i.d(t,"serializeAsColor4",(function(){return n.serializeAsColor4})),i.d(t,"serializeAsImageProcessingConfiguration",(function(){return n.serializeAsImageProcessingConfiguration})),i.d(t,"serializeAsQuaternion",(function(){return n.serializeAsQuaternion})),i.d(t,"serializeAsMatrix",(function(){return n.serializeAsMatrix})),i.d(t,"serializeAsCameraReference",(function(){return n.serializeAsCameraReference})),i.d(t,"SerializationHelper",(function(){return n.SerializationHelper})),i.d(t,"Deferred",(function(){return n.Deferred})),i.d(t,"EnvironmentTextureTools",(function(){return n.EnvironmentTextureTools})),i.d(t,"MeshExploder",(function(){return n.MeshExploder})),i.d(t,"FilesInput",(function(){return n.FilesInput})),i.d(t,"CubeMapToSphericalPolynomialTools",(function(){return n.CubeMapToSphericalPolynomialTools})),i.d(t,"HDRTools",(function(){return n.HDRTools})),i.d(t,"PanoramaToCubeMapTools",(function(){return n.PanoramaToCubeMapTools})),i.d(t,"KhronosTextureContainer",(function(){return n.KhronosTextureContainer})),i.d(t,"EventState",(function(){return n.EventState})),i.d(t,"Observer",(function(){return n.Observer})),i.d(t,"MultiObserver",(function(){return n.MultiObserver})),i.d(t,"Observable",(function(){return n.Observable})),i.d(t,"PerformanceMonitor",(function(){return n.PerformanceMonitor})),i.d(t,"RollingAverage",(function(){return n.RollingAverage})),i.d(t,"PromisePolyfill",(function(){return n.PromisePolyfill})),i.d(t,"SceneOptimization",(function(){return n.SceneOptimization})),i.d(t,"TextureOptimization",(function(){return n.TextureOptimization})),i.d(t,"HardwareScalingOptimization",(function(){return n.HardwareScalingOptimization})),i.d(t,"ShadowsOptimization",(function(){return n.ShadowsOptimization})),i.d(t,"PostProcessesOptimization",(function(){return n.PostProcessesOptimization})),i.d(t,"LensFlaresOptimization",(function(){return n.LensFlaresOptimization})),i.d(t,"CustomOptimization",(function(){return n.CustomOptimization})),i.d(t,"ParticlesOptimization",(function(){return n.ParticlesOptimization})),i.d(t,"RenderTargetsOptimization",(function(){return n.RenderTargetsOptimization})),i.d(t,"MergeMeshesOptimization",(function(){return n.MergeMeshesOptimization})),i.d(t,"SceneOptimizerOptions",(function(){return n.SceneOptimizerOptions})),i.d(t,"SceneOptimizer",(function(){return n.SceneOptimizer})),i.d(t,"SceneSerializer",(function(){return n.SceneSerializer})),i.d(t,"SmartArray",(function(){return n.SmartArray})),i.d(t,"SmartArrayNoDuplicate",(function(){return n.SmartArrayNoDuplicate})),i.d(t,"StringDictionary",(function(){return n.StringDictionary})),i.d(t,"Tags",(function(){return n.Tags})),i.d(t,"TextureTools",(function(){return n.TextureTools})),i.d(t,"TGATools",(function(){return n.TGATools})),i.d(t,"Tools",(function(){return n.Tools})),i.d(t,"className",(function(){return n.className})),i.d(t,"AsyncLoop",(function(){return n.AsyncLoop})),i.d(t,"VideoRecorder",(function(){return n.VideoRecorder})),i.d(t,"JoystickAxis",(function(){return n.JoystickAxis})),i.d(t,"VirtualJoystick",(function(){return n.VirtualJoystick})),i.d(t,"WorkerPool",(function(){return n.WorkerPool})),i.d(t,"Logger",(function(){return n.Logger})),i.d(t,"_TypeStore",(function(){return n._TypeStore})),i.d(t,"FilesInputStore",(function(){return n.FilesInputStore})),i.d(t,"DeepCopier",(function(){return n.DeepCopier})),i.d(t,"PivotTools",(function(){return n.PivotTools})),i.d(t,"PrecisionDate",(function(){return n.PrecisionDate})),i.d(t,"ScreenshotTools",(function(){return n.ScreenshotTools})),i.d(t,"WebRequest",(function(){return n.WebRequest})),i.d(t,"InspectableType",(function(){return n.InspectableType})),i.d(t,"BRDFTextureTools",(function(){return n.BRDFTextureTools})),i.d(t,"RGBDTextureTools",(function(){return n.RGBDTextureTools})),i.d(t,"ColorGradient",(function(){return n.ColorGradient})),i.d(t,"Color3Gradient",(function(){return n.Color3Gradient})),i.d(t,"FactorGradient",(function(){return n.FactorGradient})),i.d(t,"GradientHelper",(function(){return n.GradientHelper})),i.d(t,"PerfCounter",(function(){return n.PerfCounter})),i.d(t,"RetryStrategy",(function(){return n.RetryStrategy})),i.d(t,"CanvasGenerator",(function(){return n.CanvasGenerator})),i.d(t,"LoadFileError",(function(){return n.LoadFileError})),i.d(t,"RequestFileError",(function(){return n.RequestFileError})),i.d(t,"ReadFileError",(function(){return n.ReadFileError})),i.d(t,"FileTools",(function(){return n.FileTools})),i.d(t,"StringTools",(function(){return n.StringTools})),i.d(t,"DataReader",(function(){return n.DataReader})),i.d(t,"MinMaxReducer",(function(){return n.MinMaxReducer})),i.d(t,"DepthReducer",(function(){return n.DepthReducer})),i.d(t,"DataStorage",(function(){return n.DataStorage})),i.d(t,"SceneRecorder",(function(){return n.SceneRecorder})),i.d(t,"KhronosTextureContainer2",(function(){return n.KhronosTextureContainer2})),i.d(t,"Trajectory",(function(){return n.Trajectory})),i.d(t,"TrajectoryClassifier",(function(){return n.TrajectoryClassifier})),i.d(t,"TimerState",(function(){return n.TimerState})),i.d(t,"setAndStartTimer",(function(){return n.setAndStartTimer})),i.d(t,"AdvancedTimer",(function(){return n.AdvancedTimer})),i.d(t,"CopyTools",(function(){return n.CopyTools})),i.d(t,"WebXRCamera",(function(){return n.WebXRCamera})),i.d(t,"WebXREnterExitUIButton",(function(){return n.WebXREnterExitUIButton})),i.d(t,"WebXREnterExitUIOptions",(function(){return n.WebXREnterExitUIOptions})),i.d(t,"WebXREnterExitUI",(function(){return n.WebXREnterExitUI})),i.d(t,"WebXRExperienceHelper",(function(){return n.WebXRExperienceHelper})),i.d(t,"WebXRInput",(function(){return n.WebXRInput})),i.d(t,"WebXRInputSource",(function(){return n.WebXRInputSource})),i.d(t,"WebXRManagedOutputCanvasOptions",(function(){return n.WebXRManagedOutputCanvasOptions})),i.d(t,"WebXRManagedOutputCanvas",(function(){return n.WebXRManagedOutputCanvas})),i.d(t,"WebXRState",(function(){return n.WebXRState})),i.d(t,"WebXRTrackingState",(function(){return n.WebXRTrackingState})),i.d(t,"WebXRSessionManager",(function(){return n.WebXRSessionManager})),i.d(t,"WebXRDefaultExperienceOptions",(function(){return n.WebXRDefaultExperienceOptions})),i.d(t,"WebXRDefaultExperience",(function(){return n.WebXRDefaultExperience})),i.d(t,"WebXRFeatureName",(function(){return n.WebXRFeatureName})),i.d(t,"WebXRFeaturesManager",(function(){return n.WebXRFeaturesManager})),i.d(t,"WebXRAbstractFeature",(function(){return n.WebXRAbstractFeature})),i.d(t,"WebXRHitTestLegacy",(function(){return n.WebXRHitTestLegacy})),i.d(t,"WebXRAnchorSystem",(function(){return n.WebXRAnchorSystem})),i.d(t,"WebXRPlaneDetector",(function(){return n.WebXRPlaneDetector})),i.d(t,"WebXRBackgroundRemover",(function(){return n.WebXRBackgroundRemover})),i.d(t,"WebXRMotionControllerTeleportation",(function(){return n.WebXRMotionControllerTeleportation})),i.d(t,"WebXRControllerPointerSelection",(function(){return n.WebXRControllerPointerSelection})),i.d(t,"IWebXRControllerPhysicsOptions",(function(){return n.IWebXRControllerPhysicsOptions})),i.d(t,"WebXRControllerPhysics",(function(){return n.WebXRControllerPhysics})),i.d(t,"WebXRHitTest",(function(){return n.WebXRHitTest})),i.d(t,"WebXRFeaturePointSystem",(function(){return n.WebXRFeaturePointSystem})),i.d(t,"WebXRHand",(function(){return n.WebXRHand})),i.d(t,"WebXRHandTracking",(function(){return n.WebXRHandTracking})),i.d(t,"WebXRAbstractMotionController",(function(){return n.WebXRAbstractMotionController})),i.d(t,"WebXRControllerComponent",(function(){return n.WebXRControllerComponent})),i.d(t,"WebXRGenericTriggerMotionController",(function(){return n.WebXRGenericTriggerMotionController})),i.d(t,"WebXRMicrosoftMixedRealityController",(function(){return n.WebXRMicrosoftMixedRealityController})),i.d(t,"WebXRMotionControllerManager",(function(){return n.WebXRMotionControllerManager})),i.d(t,"WebXROculusTouchMotionController",(function(){return n.WebXROculusTouchMotionController})),i.d(t,"WebXRHTCViveMotionController",(function(){return n.WebXRHTCViveMotionController})),i.d(t,"WebXRProfiledMotionController",(function(){return n.WebXRProfiledMotionController}));var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o){o.BABYLON=a,o.BABYLON=o.BABYLON||{};var a=o.BABYLON;a.Debug=a.Debug||{};var s=[];for(var c in r)a.Debug[c]=r[c],s.push(c);for(var c in n)a[c]=n[c]}var l={AxesViewer:r.AxesViewer,BoneAxesViewer:r.BoneAxesViewer,PhysicsViewer:r.PhysicsViewer,SkeletonViewer:r.SkeletonViewer}}.call(this,i(159))}])})); \ No newline at end of file diff --git a/src/static/babylonjs-4.2.0.loaders.min.js b/src/static/babylonjs-4.2.0.loaders.min.js new file mode 100644 index 0000000..9212339 --- /dev/null +++ b/src/static/babylonjs-4.2.0.loaders.min.js @@ -0,0 +1,16 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}([function(t,n){t.exports=e},function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return i}));var r=n(0),o=n(2),a=function(){function e(){}return e.Get=function(e,t,n){if(!t||null==n||!t[n])throw new Error(e+": Failed to find index ("+n+")");return t[n]},e.Assign=function(e){if(e)for(var t=0;t "+o.GLTFLoaderState[o.GLTFLoaderState.READY],s=o.GLTFLoaderState[o.GLTFLoaderState.LOADING]+" => "+o.GLTFLoaderState[o.GLTFLoaderState.COMPLETE];n._parent._startPerformanceCounter(i),n._parent._startPerformanceCounter(s),n._setState(o.GLTFLoaderState.LOADING),n._extensionsOnLoading();var l=new Array,u=n._babylonScene.blockMaterialDirtyMechanism;if(n._babylonScene.blockMaterialDirtyMechanism=!0,e)l.push(n.loadSceneAsync("/nodes",{nodes:e,index:-1}));else if(null!=n._gltf.scene||n._gltf.scenes&&n._gltf.scenes[0]){var c=a.Get("/scene",n._gltf.scenes,n._gltf.scene||0);l.push(n.loadSceneAsync("/scenes/"+c.index,c))}if(n.parent.loadAllMaterials&&n._gltf.materials)for(var d=0;de.bin.byteLength)&&r.Logger.Warn("Binary buffer length ("+n.byteLength+") from JSON does not match chunk length ("+e.bin.byteLength+")"),this._bin=e.bin}else r.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(a.Assign(this._gltf.accessors),a.Assign(this._gltf.animations),a.Assign(this._gltf.buffers),a.Assign(this._gltf.bufferViews),a.Assign(this._gltf.cameras),a.Assign(this._gltf.images),a.Assign(this._gltf.materials),a.Assign(this._gltf.meshes),a.Assign(this._gltf.nodes),a.Assign(this._gltf.samplers),a.Assign(this._gltf.scenes),a.Assign(this._gltf.skins),a.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 s=a.Get(t+"/index",this._gltf.textures,n.index);s._textureInfo=n;var l=this._loadTextureAsync("/textures/"+n.index,s,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),l},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen(t+" "+(n.name||""));var i=null==n.sampler?e.DefaultSampler:a.Get(t+"/sampler",this._gltf.samplers,n.sampler),s=a.Get(t+"/source",this._gltf.images,n.source),l=this._createTextureAsync(t,i,s,r);return this.logClose(),l},e.prototype._createTextureAsync=function(e,t,n,o,a){var i=this;void 0===o&&(o=function(){});var s=this._loadSampler("/samplers/"+t.index,t),l=new Array,u=new r.Deferred;this._babylonScene._blockEntityCollection=this._forAssetContainer;var c=new r.Texture(null,this._babylonScene,s.noMipMaps,!1,s.samplingMode,(function(){i._disposed||u.resolve()}),(function(t,n){i._disposed||u.reject(new Error(e+": "+(n&&n.message?n.message:t||"Failed to load texture")))}),void 0,void 0,void 0,n.mimeType,a);return this._babylonScene._blockEntityCollection=!1,l.push(u.promise),l.push(this.loadImageAsync("/images/"+n.index,n).then((function(e){var t=n.uri||i._fileName+"#image"+n.index,r="data:"+i._uniqueRootUrl+t;c.updateURL(r,e)}))),c.wrapU=s.wrapU,c.wrapV=s.wrapV,o(c),Promise.all(l).then((function(){return c}))},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=a.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,o){var a=this,i=this._extensionsLoadUriAsync(t,n,o);if(i)return i;if(!e._ValidateUri(o))throw new Error(t+": '"+o+"' is invalid");if(r.Tools.IsBase64(o)){var s=new Uint8Array(r.Tools.DecodeBase64(o));return this.log("Decoded "+o.substr(0,64)+"... ("+s.length+" bytes)"),Promise.resolve(s)}return this.log("Loading "+o),this._parent.preprocessUrlAsync(this._rootUrl+o).then((function(e){return new Promise((function(n,i){a._parent._loadFile(e,a._babylonScene,(function(e){a._disposed||(a.log("Loaded "+o+" ("+e.byteLength+" bytes)"),n(new Uint8Array(e)))}),!0,(function(e){i(new r.LoadFileError(t+": Failed to load '"+o+"'"+(e?": "+e.status+" "+e.statusText:""),e))}))}))}))},e.AddPointerMetadata=function(e,t){var n=e.metadata=e.metadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return r.Texture.CLAMP_ADDRESSMODE;case 33648:return r.Texture.MIRROR_ADDRESSMODE;case 10497:return r.Texture.WRAP_ADDRESSMODE;default:return r.Logger.Warn(e+": Invalid value ("+t+")"),r.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,o=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(o){case 9728:return r.Texture.LINEAR_NEAREST;case 9729:return r.Texture.LINEAR_LINEAR;case 9984:return r.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return r.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return r.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return r.Texture.LINEAR_LINEAR_MIPLINEAR;default:return r.Logger.Warn(e+"/minFilter: Invalid value ("+o+")"),r.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&r.Logger.Warn(e+"/magFilter: Invalid value ("+n+")"),o){case 9728:return r.Texture.NEAREST_NEAREST;case 9729:return r.Texture.NEAREST_LINEAR;case 9984:return r.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return r.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return r.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return r.Texture.NEAREST_LINEAR_MIPLINEAR;default:return r.Logger.Warn(e+"/minFilter: Invalid value ("+o+")"),r.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error(e+": Invalid component type "+t)}},e._GetTypedArray=function(t,n,r,o,a){var i=r.buffer;o=r.byteOffset+(o||0);var s=e._GetTypedArrayConstructor(t+"/componentType",n);try{return new s(i,o,a)}catch(e){throw new Error(t+": "+e)}},e._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error(e+": Invalid type ("+t+")")},e._ValidateUri=function(e){return r.Tools.IsBase64(e)||-1===e.indexOf("..")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return r.Material.PointListDrawMode;case 1:return r.Material.LineListDrawMode;case 2:return r.Material.LineLoopDrawMode;case 3:return r.Material.LineStripDrawMode;case 4:return r.Material.TriangleFillMode;case 5:return r.Material.TriangleStripDrawMode;case 6:return r.Material.TriangleFanDrawMode}throw new Error(e+": Invalid mesh primitive mode ("+t+")")},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n-1&&s.materials.splice(t,1),(t=l.indexOf(e))>-1&&l.splice(t,1)}))}));var u=[];a.onTextureLoadedObservable.add((function(e){u.push(e),e.onDisposeObservable.addOnce((function(){var t=s.textures.indexOf(e);t>-1&&s.textures.splice(t,1),(t=u.indexOf(e))>-1&&u.splice(t,1)}))}));var c=[];return a.onCameraLoadedObservable.add((function(e){c.push(e)})),a._loader.importMeshAsync(null,e,!0,t,n,r,o).then((function(e){return Array.prototype.push.apply(s.geometries,e.geometries),Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,l),Array.prototype.push.apply(s.textures,u),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),s}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||i.StringTools.StartsWith(t,"data:base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(t,"data:application/octet-stream;base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(t,"data:model/gltf-binary;base64,"+e.magicBase64Encoded)},e.prototype.directLoad=function(t,n){if(i.StringTools.StartsWith(n,"base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,"application/octet-stream;base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,"model/gltf-binary;base64,"+e.magicBase64Encoded)){var r=i.Tools.DecodeBase64(n);return this._validate(t,r),this._unpackBinaryAsync(new i.DataReader({readAsync:function(e,t){return Promise.resolve(new Uint8Array(r,e,t))},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._loader?this._loader.state:null},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._loadFile=function(e,t,n,r,o){var a=this,i=t._loadFile(e,n,(function(e){a._onProgress(e,i)}),void 0,r,o);return i.onCompleteObservable.add((function(e){a._requests.splice(a._requests.indexOf(e),1)})),this._requests.push(i),i},e.prototype._requestFile=function(e,t,n,r,o,a){var i=this,s=t._requestFile(e,n,(function(e){i._onProgress(e,s)}),void 0,r,o,a);return s.onCompleteObservable.add((function(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(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 o,a=e.readUint32();if(0!==e.buffer.byteLength&&a!==e.buffer.byteLength)throw new Error("Length in header does not match actual data length: "+a+" != "+e.buffer.byteLength);switch(r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: "+r);var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=5130562,a=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+a===t?e.loadAsync(a).then((function(){return{json:n._parseJson(e.readString(a)),bin:null}})):e.loadAsync(a+8).then((function(){var i={json:n._parseJson(e.readString(a)),bin:null},s=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case o:var a=e.byteOffset;i.bin={readAsync:function(t,n){return e.buffer.readAsync(a+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(s):Promise.resolve(i)};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=0&&l.renderTargetTextures.splice(a,1)}if(this._opaqueRenderTarget&&(t=this._scene.customRenderTargets.indexOf(this._opaqueRenderTarget),this._opaqueRenderTarget.dispose()),this._opaqueRenderTarget=new r.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,!0),this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.gammaSpace=!0,this._opaqueRenderTarget.lodGenerationScale=1,this._opaqueRenderTarget.lodGenerationOffset=-4,t>=0?this._scene.customRenderTargets.splice(t,0,this._opaqueRenderTarget):(t=this._scene.customRenderTargets.length,this._scene.customRenderTargets.push(this._opaqueRenderTarget)),this._scene.layers&&this._opaqueRenderTarget)for(var i=0,s=this._scene.layers;i=0;i--)if(a.push(o.a.Get(e+"/ids/"+r[i],n,r[i])),a.length===this.maxLODsToLoad)return a;return a.push(t),a},e.prototype._disposeTransformNode=function(e){var t=this,n=new Array,r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();o.b.RegisterExtension("ExtrasAsMetadata",(function(e){return new w(e)}))},function(e,t,n){"use strict";n.r(t),n.d(t,"GLTFBinaryExtension",(function(){return k})),n.d(t,"GLTFLoaderBase",(function(){return D})),n.d(t,"GLTFLoader",(function(){return G})),n.d(t,"GLTFLoaderExtension",(function(){return U})),n.d(t,"EComponentType",(function(){return r})),n.d(t,"EShaderType",(function(){return o})),n.d(t,"EParameterType",(function(){return a})),n.d(t,"ETextureWrapMode",(function(){return i})),n.d(t,"ETextureFilterType",(function(){return s})),n.d(t,"ETextureFormat",(function(){return l})),n.d(t,"ECullingType",(function(){return u})),n.d(t,"EBlendingFunction",(function(){return c})),n.d(t,"GLTFUtils",(function(){return p})),n.d(t,"GLTFMaterialsCommonExtension",(function(){return H}));var r,o,a,i,s,l,u,c,d=n(4);!function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"}(r||(r={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(o||(o={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"}(a||(a={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(i||(i={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(s||(s={})),function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(l||(l={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(u||(u={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(c||(c={}));var f,h=n(0),p=function(){function e(){}return e.SetMatrix=function(e,t,n,r,o){var i=null;if("MODEL"===n.semantic?i=t.getWorldMatrix():"PROJECTION"===n.semantic?i=e.getProjectionMatrix():"VIEW"===n.semantic?i=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===n.semantic?i=h.Matrix.Transpose(t.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===n.semantic?i=t.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===n.semantic?i=t.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===n.semantic?i=t.getWorldMatrix().invert():"VIEWINVERSE"===n.semantic?i=e.getViewMatrix().invert():"PROJECTIONINVERSE"===n.semantic?i=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===n.semantic?i=t.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===n.semantic?i=t.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===n.semantic&&(i=h.Matrix.Transpose(t.getWorldMatrix().invert())),i)switch(n.type){case a.FLOAT_MAT2:o.setMatrix2x2(r,h.Matrix.GetAsMatrix2x2(i));break;case a.FLOAT_MAT3:o.setMatrix3x3(r,h.Matrix.GetAsMatrix3x3(i));break;case a.FLOAT_MAT4:o.setMatrix(r,i)}},e.SetUniform=function(e,t,n,r){switch(r){case a.FLOAT:return e.setFloat(t,n),!0;case a.FLOAT_VEC2:return e.setVector2(t,h.Vector2.FromArray(n)),!0;case a.FLOAT_VEC3:return e.setVector3(t,h.Vector3.FromArray(n)),!0;case a.FLOAT_VEC4:return e.setVector4(t,h.Vector4.FromArray(n)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case i.CLAMP_TO_EDGE:return h.Texture.CLAMP_ADDRESSMODE;case i.MIRRORED_REPEAT:return h.Texture.MIRROR_ADDRESSMODE;case i.REPEAT:default:return h.Texture.WRAP_ADDRESSMODE}},e.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},e.GetTextureFilterMode=function(e){switch(e){case s.LINEAR:case s.LINEAR_MIPMAP_NEAREST:case s.LINEAR_MIPMAP_LINEAR:return h.Texture.TRILINEAR_SAMPLINGMODE;case s.NEAREST:case s.NEAREST_MIPMAP_NEAREST:return h.Texture.NEAREST_SAMPLINGMODE;default:return h.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,n,o,a){n=t.byteOffset+n;var i=e.loadedBufferViews[t.buffer];if(n+o>i.byteLength)throw new Error("Buffer access is out of range");var s=i.buffer;switch(n+=i.byteOffset,a){case r.BYTE:return new Int8Array(s,n,o);case r.UNSIGNED_BYTE:return new Uint8Array(s,n,o);case r.SHORT:return new Int16Array(s,n,o);case r.UNSIGNED_SHORT:return new Uint16Array(s,n,o);default:return new Float32Array(s,n,o)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r=this._maxPos},e}(),y=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],b=["world","view","projection","worldView","worldViewProjection","mBones"],v=["translation","rotation","scale"],g=["position","rotationQuaternion","scaling"],A=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},T=function(e){if(e)for(var t=0;t0&&(d=O(a,o))&&-1===i.indexOf(d)&&i.push(d),new h.Bone(l.jointName||"",r,d,b).id=o}}else h.Tools.Warn("Joint named "+t.jointNames[s]+" does not exist")}}var v=r.bones;r.bones=[];for(s=0;s1?(a=new h.MultiMaterial("multimat"+r,e.scene)).subMaterials=i:a=new h.StandardMaterial("multimat"+r,e.scene),1===i.length&&(a=i[0]),o.material||(o.material=a),new h.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var C=0;for(f=0;f0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var a=e.skins[t.skin];(i=R(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonByID(t.skin),null===i.skeleton&&(i.skeleton=w(e,a,0,a.babylonSkeleton,t.skin),a.babylonSkeleton||(a.babylonSkeleton=i.skeleton)),o=i}}else if(t.meshes){var i;o=i=R(e,t,t.mesh?[t.mesh]:t.meshes,n,t.babylonNode)}else if(!t.light||t.babylonNode||e.importOnlyMeshes){if(t.camera&&!t.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[t.camera];if(s){if(e.scene._blockEntityCollection=e.forAssetContainer,"orthographic"===s.type){var l=new h.FreeCamera(t.camera,h.Vector3.Zero(),e.scene,!1);l.name=t.name||"",l.mode=h.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(),o=l}else if("perspective"===s.type){var u=s[s.type],c=new h.FreeCamera(t.camera,h.Vector3.Zero(),e.scene,!1);c.name=t.name||"",c.attachControl(),u.aspectRatio||(u.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),u.znear&&u.zfar&&(c.maxZ=u.zfar,c.minZ=u.znear),o=c}e.scene._blockEntityCollection=!1}}}else{var d=e.lights[t.light];if(d)if("ambient"===d.type){var f=d[d.type],p=new h.HemisphericLight(t.light,h.Vector3.Zero(),e.scene);p.name=t.name||"",f.color&&(p.diffuse=h.Color3.FromArray(f.color)),o=p}else if("directional"===d.type){var _=d[d.type],m=new h.DirectionalLight(t.light,h.Vector3.Zero(),e.scene);m.name=t.name||"",_.color&&(m.diffuse=h.Color3.FromArray(_.color)),o=m}else if("point"===d.type){var y=d[d.type],b=new h.PointLight(t.light,h.Vector3.Zero(),e.scene);b.name=t.name||"",y.color&&(b.diffuse=h.Color3.FromArray(y.color)),o=b}else if("spot"===d.type){var v=d[d.type],g=new h.SpotLight(t.light,h.Vector3.Zero(),h.Vector3.Zero(),0,0,e.scene);g.name=t.name||"",v.color&&(g.diffuse=h.Color3.FromArray(v.color)),v.fallOfAngle&&(g.angle=v.fallOfAngle),v.fallOffExponent&&(g.exponent=v.fallOffExponent),o=g}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===o){e.scene._blockEntityCollection=e.forAssetContainer;var A=new h.Mesh(t.name||"",e.scene);e.scene._blockEntityCollection=!1,t.babylonNode=A,o=A}}if(null!==o){if(t.matrix&&o instanceof h.Mesh)!function(e,t,n){if(t.matrix){var r=new h.Vector3(0,0,0),o=new h.Quaternion,a=new h.Vector3(0,0,0);h.Matrix.FromArray(t.matrix).decompose(a,o,r),C(e,r,o,a)}else t.translation&&t.rotation&&t.scale&&C(e,h.Vector3.FromArray(t.translation),h.Quaternion.FromArray(t.rotation),h.Vector3.FromArray(t.scale));e.computeWorldMatrix(!0)}(o,t);else{var T=t.translation||[0,0,0],x=t.rotation||[0,0,0,1],E=t.scale||[1,1,1];C(o,h.Vector3.FromArray(T),h.Quaternion.FromArray(x),h.Vector3.FromArray(E))}o.updateCache(!0),t.babylonNode=o}return o},P=function(e,t,n,r){void 0===r&&(r=!1);var o=e.nodes[t],a=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||(-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length),!o.jointName&&r&&null!==(a=N(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var i=0;i=0?d.substring(0,f):d;h=h.toLowerCase();var p=f>=0?d.substring(f+1).trim():"";"newmtl"===h?(u&&this.materials.push(u),t._blockEntityCollection=a,u=new r.StandardMaterial(p,t),t._blockEntityCollection=!1):"kd"===h&&u?(i=p.split(l,3).map(parseFloat),u.diffuseColor=r.Color3.FromArray(i)):"ka"===h&&u?(i=p.split(l,3).map(parseFloat),u.ambientColor=r.Color3.FromArray(i)):"ks"===h&&u?(i=p.split(l,3).map(parseFloat),u.specularColor=r.Color3.FromArray(i)):"ke"===h&&u?(i=p.split(l,3).map(parseFloat),u.emissiveColor=r.Color3.FromArray(i)):"ns"===h&&u?u.specularPower=parseFloat(p):"d"===h&&u?u.alpha=parseFloat(p):"map_ka"===h&&u?u.ambientTexture=e._getTexture(o,p,t):"map_kd"===h&&u?u.diffuseTexture=e._getTexture(o,p,t):"map_ks"===h&&u?u.specularTexture=e._getTexture(o,p,t):"map_ns"===h||("map_bump"===h&&u?u.bumpTexture=e._getTexture(o,p,t):"map_d"===h&&u&&(u.opacityTexture=e._getTexture(o,p,t)))}}u&&this.materials.push(u)}},e._getTexture=function(t,n,o){if(!n)return null;var a=t;if("file:"===t){var i=n.lastIndexOf("\\");-1===i&&(i=n.lastIndexOf("/")),a+=i>-1?n.substr(i+1):n}else a+=n;return new r.Texture(a,o,!1,e.INVERT_TEXTURE_Y)},e.INVERT_TEXTURE_Y=!0,e}(),a=function(){function e(t){this.name="obj",this.extensions=".obj",this.obj=/^o/,this.group=/^g/,this.mtllib=/^mtllib /,this.usemtl=/^usemtl /,this.smooth=/^s /,this.vertexPattern=/v(\s+[\d|\.|\+|\-|e|E]+){3,7}/,this.normalPattern=/vn(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.uvPattern=/vt(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.facePattern1=/f\s+(([\d]{1,}[\s]?){3,})+/,this.facePattern2=/f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern3=/f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern4=/f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,this.facePattern5=/f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,this._forAssetContainer=!1,this._meshLoadOptions=t||e.currentMeshLoadOptions}return Object.defineProperty(e,"INVERT_TEXTURE_Y",{get:function(){return o.INVERT_TEXTURE_Y},set:function(e){o.INVERT_TEXTURE_Y=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"currentMeshLoadOptions",{get:function(){return{ComputeNormals:e.COMPUTE_NORMALS,ImportVertexColors:e.IMPORT_VERTEX_COLORS,InvertY:e.INVERT_Y,InvertTextureY:e.INVERT_TEXTURE_Y,UVScaling:e.UV_SCALING,MaterialLoadingFailsSilently:e.MATERIAL_LOADING_FAILS_SILENTLY,OptimizeWithUV:e.OPTIMIZE_WITH_UV,SkipMaterials:e.SKIP_MATERIALS}},enumerable:!1,configurable:!0}),e.prototype._loadMTL=function(e,t,n,o){var a=r.Tools.BaseUrl+t+e;r.Tools.LoadFile(a,n,void 0,void 0,!1,(function(e,t){o(a,t)}))},e.prototype.createPlugin=function(){return new e(e.currentMeshLoadOptions)},e.prototype.canDirectLoad=function(e){return!1},e.prototype.importMeshAsync=function(e,t,n,r,o,a){return this._parseSolid(e,t,n,r).then((function(e){return{meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[]}}))},e.prototype.loadAsync=function(e,t,n,r,o){return this.importMeshAsync(null,e,t,n,r).then((function(){}))},e.prototype.loadAssetContainerAsync=function(e,t,n,o,a){var i=this;return this._forAssetContainer=!0,this.importMeshAsync(null,e,t,n).then((function(t){var n=new r.AssetContainer(e);return t.meshes.forEach((function(e){return n.meshes.push(e)})),t.meshes.forEach((function(e){var t=e.material;t&&(-1==n.materials.indexOf(t)&&(n.materials.push(t),t.getActiveTextures().forEach((function(e){-1==n.textures.indexOf(e)&&n.textures.push(e)}))))})),i._forAssetContainer=!1,n})).catch((function(e){throw i._forAssetContainer=!1,e}))},e.prototype._parseSolid=function(t,n,a,i){for(var s,l=this,u=[],c=[],d=[],f=[],h=[],p=[],_=[],m=[],y=[],b=[],v=[],g=0,A=!1,T=[],x=[],E=[],L=[],O=[],M="",S="",w=new o,R=1,C=!0,N=new r.Color4(.5,.5,.5,1),P=function(e,t,n,r,o,a,i){var s;-1===(s=l._meshLoadOptions.OptimizeWithUV?function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var n=e[t[0]].normals.indexOf(t[1]);return 1!=n&&t[2]===e[t[0]].uv[n]?e[t[0]].idx[n]:-1}(v,[e,n,t]):function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var n=e[t[0]].normals.indexOf(t[1]);return-1===n?-1:e[t[0]].idx[n]}(v,[e,n]))?(p.push(_.length),_.push(r),m.push(o),b.push(a),void 0!==i&&y.push(i),v[e].normals.push(n),v[e].idx.push(g++),l._meshLoadOptions.OptimizeWithUV&&v[e].uv.push(t)):p.push(s)},I=function(){for(var e=0;e<_.length;e++)T.push(_[e].x,_[e].y,_[e].z),E.push(b[e].x,b[e].y,b[e].z),L.push(m[e].x,m[e].y),!0===l._meshLoadOptions.ImportVertexColors&&x.push(y[e].r,y[e].g,y[e].b,y[e].a);_=[],b=[],m=[],y=[],v=[],g=0},F=function(e,t){for(var n=t;n0&&(s=h[h.length-1],I(),p.reverse(),s.indices=p.slice(),s.positions=T.slice(),s.normals=E.slice(),s.uvs=L.slice(),!0===l._meshLoadOptions.ImportVertexColors&&(s.colors=x.slice()),p=[],T=[],x=[],E=[],L=[])},H=a.split("\n"),K=0;K=7?f.push(new r.Color4(parseFloat(j[4]),parseFloat(j[5]),parseFloat(j[6]),7===j.length||void 0===j[7]?1:parseFloat(j[7]))):f.push(N));else if(null!==(j=this.normalPattern.exec(W)))c.push(new r.Vector3(parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3])));else if(null!==(j=this.uvPattern.exec(W)))d.push(new r.Vector2(parseFloat(j[1])*e.UV_SCALING.x,parseFloat(j[2])*e.UV_SCALING.y));else if(null!==(j=this.facePattern3.exec(W)))D(j[1].trim().split(" "),1);else if(null!==(j=this.facePattern4.exec(W)))G(j[1].trim().split(" "),1);else if(null!==(j=this.facePattern5.exec(W)))U(j[1].trim().split(" "),1);else if(null!==(j=this.facePattern2.exec(W)))V(j[1].trim().split(" "),1);else if(null!==(j=this.facePattern1.exec(W)))B(j[1].trim().split(" "),1);else if(this.group.test(W)||this.obj.test(W)){var q={name:W.substring(2).trim(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:""};k(),h.push(q),A=!0,C=!0,R=1}else if(this.usemtl.test(W)){if(M=W.substring(7).trim(),!C||!A){k();q={name:"mesh_mm"+R.toString(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:M};R++,h.push(q),A=!0}A&&C&&(h[h.length-1].materialName=M,C=!1)}else this.mtllib.test(W)?S=W.substring(7).trim():this.smooth.test(W)||console.log("Unhandled expression at line : "+W)}A&&(s=h[h.length-1],p.reverse(),I(),s.indices=p,s.positions=T,s.normals=E,s.uvs=L,!0===this._meshLoadOptions.ImportVertexColors&&(s.colors=x)),A||(p.reverse(),I(),h.push({name:r.Geometry.RandomId(),indices:p,positions:T,colors:x,normals:E,uvs:L,materialName:M}));for(var Y=[],X=new Array,J=0;J-1;)c.push(s),u=s+1;if(-1===s&&0===c.length)w.materials[a].dispose();else for(var d=0;d127)return!0;return!1},e.prototype._parseBinary=function(e,t){for(var n=new DataView(t),o=n.getUint32(80,!0),a=0,i=new Float32Array(3*o*3),s=new Float32Array(3*o*3),l=new Uint32Array(3*o),u=0,c=0;c-1||(s.GLTF2[u]=a[u])}}).call(this,n(5))},function(e,t,n){"use strict";n.r(t),function(e){var r=n(10);n.d(t,"MTLFileLoader",(function(){return r.MTLFileLoader})),n.d(t,"OBJFileLoader",(function(){return r.OBJFileLoader}));var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var a in r)o.BABYLON[a]=r[a]}.call(this,n(5))},function(e,t,n){"use strict";n.r(t),function(e){var r=n(11);n.d(t,"STLFileLoader",(function(){return r.STLFileLoader}));var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var a in r)o.BABYLON[a]=r[a]}.call(this,n(5))},,,,function(e,t,n){"use strict";n.r(t),n.d(t,"GLTFLoaderCoordinateSystemMode",(function(){return r.c})),n.d(t,"GLTFLoaderAnimationStartMode",(function(){return r.b})),n.d(t,"GLTFLoaderState",(function(){return r.d})),n.d(t,"GLTFFileLoader",(function(){return r.a})),n.d(t,"GLTFValidation",(function(){return r.e})),n.d(t,"GLTF1",(function(){return o.a})),n.d(t,"GLTF2",(function(){return a.a})),n.d(t,"MTLFileLoader",(function(){return i.MTLFileLoader})),n.d(t,"OBJFileLoader",(function(){return i.OBJFileLoader})),n.d(t,"STLFileLoader",(function(){return s.STLFileLoader}));n(2),n(3),n(8),n(9),n(10),n(11);var r=n(12),o=n(13),a=n(14),i=n(15),s=n(16)}])})); \ No newline at end of file diff --git a/src/static/kavea.css b/src/static/kavea.css new file mode 100644 index 0000000..6586ccd --- /dev/null +++ b/src/static/kavea.css @@ -0,0 +1,13 @@ +html, body { + overflow: hidden; + width: 100%; + height: 100%; + margin: 0; + padding: 0; +} + +#renderCanvas { + width: 100%; + height: 100%; + touch-action: none; +} diff --git a/src/survex b/src/survex new file mode 160000 index 0000000..738af38 --- /dev/null +++ b/src/survex @@ -0,0 +1 @@ +Subproject commit 738af383b59aff8ffd2056a3228418f4d3201054 diff --git a/src/templates/index.html.tmpl b/src/templates/index.html.tmpl new file mode 100644 index 0000000..2f1341d --- /dev/null +++ b/src/templates/index.html.tmpl @@ -0,0 +1,44 @@ + + + + kavea + + + + + + + + + + diff --git a/src/web.go b/src/web.go new file mode 100644 index 0000000..3381a04 --- /dev/null +++ b/src/web.go @@ -0,0 +1,16 @@ +package main + +import ( + "html/template" + "net/http" +) + +func GetHome(w http.ResponseWriter, r *http.Request) { + t, err := template.ParseFS(templatesHTML, "templates/index.html.tmpl") + if !checkWebError(w, err) { + return + } + + err = t.Execute(w, nil) + checkError(err) +}