var De = Object.defineProperty
, Ne = Object.defineProperties;
var we = Object.getOwnPropertyDescriptors;
var be = Object.getOwnPropertySymbols;
var Me = Object.prototype.hasOwnProperty
, Ie = Object.prototype.propertyIsEnumerable;
var Se = (i,e,t)=>e in i ? De(i, e, {
enumerable: !0,
configurable: !0,
writable: !0,
value: t
}) : i[e] = t
, oe = (i,e)=>{
for (var t in e || (e = {}))
Me.call(e, t) && Se(i, t, e[t]);
if (be)
for (var t of be(e))
Ie.call(e, t) && Se(i, t, e[t]);
return i
}
, le = (i,e)=>Ne(i, we(e));
var Oe = (i,e)=>{
var t = {};
for (var r in i)
Me.call(i, r) && e.indexOf(r) < 0 && (t[r] = i[r]);
if (i != null && be)
for (var r of be(i))
e.indexOf(r) < 0 && Ie.call(i, r) && (t[r] = i[r]);
return t
}
;
var E = (i,e,t)=>(Se(i, typeof e != "symbol" ? e + "" : e, t),
t);
import {_ as __extends, a as __awaiter, b as __generator, c as __assign, d as __decorate, D as Dexie$1, e as commonjsGlobal, f as commonjsRequire, n as nipplejs, j as jsxRuntime, r as react, R as ReactDOM, g as React} from "./vendor.03350293.js";
const p = function() {
const e = document.createElement("link").relList;
if (e && e.supports && e.supports("modulepreload"))
return;
for (const n of document.querySelectorAll('link[rel="modulepreload"]'))
r(n);
new MutationObserver(n=>{
for (const o of n)
if (o.type === "childList")
for (const a of o.addedNodes)
a.tagName === "LINK" && a.rel === "modulepreload" && r(a)
}
).observe(document, {
childList: !0,
subtree: !0
});
function t(n) {
const o = {};
return n.integrity && (o.integrity = n.integrity),
n.referrerpolicy && (o.referrerPolicy = n.referrerpolicy),
n.crossorigin === "use-credentials" ? o.credentials = "include" : n.crossorigin === "anonymous" ? o.credentials = "omit" : o.credentials = "same-origin",
o
}
function r(n) {
if (n.ep)
return;
n.ep = !0;
const o = t(n);
fetch(n.href, o)
}
};
p();
Promise.prototype._timeout = function(i, e) {
let t;
return new Promise((r,n)=>(t = window.setTimeout(()=>{
n(e)
}
, i),
this.then(o=>{
clearTimeout(t),
r(o)
}
, o=>{
clearTimeout(t),
n(o)
}
)))
}
;
function clear() {
const i = console.log;
console.log = function(...e) {
typeof e[0] == "string" && e[0].indexOf("Babylon.js") == 0 || i(...e)
}
}
clear();
var EventState = function() {
function i(e, t, r, n) {
t === void 0 && (t = !1),
this.initialize(e, t, r, n)
}
return i.prototype.initialize = function(e, t, r, n) {
return t === void 0 && (t = !1),
this.mask = e,
this.skipNextObservers = t,
this.target = r,
this.currentTarget = n,
this
}
,
i
}()
, Observer = function() {
function i(e, t, r) {
r === void 0 && (r = null),
this.callback = e,
this.mask = t,
this.scope = r,
this._willBeUnregistered = !1,
this.unregisterOnNextCall = !1
}
return i
}()
, Observable = function() {
function i(e) {
this._observers = new Array,
this._eventState = new EventState(0),
e && (this._onObserverAdded = e)
}
return i.FromPromise = function(e, t) {
var r = new i;
return e.then(function(n) {
r.notifyObservers(n)
}).catch(function(n) {
if (t)
t.notifyObservers(n);
else
throw n
}),
r
}
,
Object.defineProperty(i.prototype, "observers", {
get: function() {
return this._observers
},
enumerable: !1,
configurable: !0
}),
i.prototype.add = function(e, t, r, n, o) {
if (t === void 0 && (t = -1),
r === void 0 && (r = !1),
n === void 0 && (n = null),
o === void 0 && (o = !1),
!e)
return null;
var a = new Observer(e,t,n);
return a.unregisterOnNextCall = o,
r ? this._observers.unshift(a) : this._observers.push(a),
this._onObserverAdded && this._onObserverAdded(a),
a
}
,
i.prototype.addOnce = function(e) {
return this.add(e, void 0, void 0, void 0, !0)
}
,
i.prototype.remove = function(e) {
if (!e)
return !1;
var t = this._observers.indexOf(e);
return t !== -1 ? (this._deferUnregister(e),
!0) : !1
}
,
i.prototype.removeCallback = function(e, t) {
for (var r = 0; r < this._observers.length; r++) {
var n = this._observers[r];
if (!n._willBeUnregistered && n.callback === e && (!t || t === n.scope))
return this._deferUnregister(n),
!0
}
return !1
}
,
i.prototype._deferUnregister = function(e) {
var t = this;
e.unregisterOnNextCall = !1,
e._willBeUnregistered = !0,
setTimeout(function() {
t._remove(e)
}, 0)
}
,
i.prototype._remove = function(e) {
if (!e)
return !1;
var t = this._observers.indexOf(e);
return t !== -1 ? (this._observers.splice(t, 1),
!0) : !1
}
,
i.prototype.makeObserverTopPriority = function(e) {
this._remove(e),
this._observers.unshift(e)
}
,
i.prototype.makeObserverBottomPriority = function(e) {
this._remove(e),
this._observers.push(e)
}
,
i.prototype.notifyObservers = function(e, t, r, n, o) {
if (t === void 0 && (t = -1),
!this._observers.length)
return !0;
var a = this._eventState;
a.mask = t,
a.target = r,
a.currentTarget = n,
a.skipNextObservers = !1,
a.lastReturnValue = e,
a.userInfo = o;
for (var s = 0, l = this._observers; s < l.length; s++) {
var u = l[s];
if (!u._willBeUnregistered && (u.mask & t && (u.scope ? a.lastReturnValue = u.callback.apply(u.scope, [e, a]) : a.lastReturnValue = u.callback(e, a),
u.unregisterOnNextCall && this._deferUnregister(u)),
a.skipNextObservers))
return !1
}
return !0
}
,
i.prototype.notifyObserversWithPromise = function(e, t, r, n, o) {
var a = this;
t === void 0 && (t = -1);
var s = Promise.resolve(e);
if (!this._observers.length)
return s;
var l = this._eventState;
return l.mask = t,
l.target = r,
l.currentTarget = n,
l.skipNextObservers = !1,
l.userInfo = o,
this._observers.forEach(function(u) {
l.skipNextObservers || u._willBeUnregistered || u.mask & t && (u.scope ? s = s.then(function(c) {
return l.lastReturnValue = c,
u.callback.apply(u.scope, [e, l])
}) : s = s.then(function(c) {
return l.lastReturnValue = c,
u.callback(e, l)
}),
u.unregisterOnNextCall && a._deferUnregister(u))
}),
s.then(function() {
return e
})
}
,
i.prototype.notifyObserver = function(e, t, r) {
if (r === void 0 && (r = -1),
!e._willBeUnregistered) {
var n = this._eventState;
n.mask = r,
n.skipNextObservers = !1,
e.callback(t, n),
e.unregisterOnNextCall && this._deferUnregister(e)
}
}
,
i.prototype.hasObservers = function() {
return this._observers.length > 0
}
,
i.prototype.clear = function() {
this._observers = new Array,
this._onObserverAdded = null
}
,
i.prototype.clone = function() {
var e = new i;
return e._observers = this._observers.slice(0),
e
}
,
i.prototype.hasSpecificMask = function(e) {
e === void 0 && (e = -1);
for (var t = 0, r = this._observers; t < r.length; t++) {
var n = r[t];
if (n.mask & e || n.mask === e)
return !0
}
return !1
}
,
i
}();
function IsWindowObjectExist() {
return typeof window != "undefined"
}
function IsNavigatorAvailable() {
return typeof navigator != "undefined"
}
function IsDocumentAvailable() {
return typeof document != "undefined"
}
function GetDOMTextContent(i) {
for (var e = "", t = i.firstChild; t; )
t.nodeType === 3 && (e += t.textContent),
t = t.nextSibling;
return e
}
var DomManagement = {
IsWindowObjectExist,
IsNavigatorAvailable,
IsDocumentAvailable,
GetDOMTextContent
}
, Logger$2 = function() {
function i() {}
return i._CheckLimit = function(e, t) {
var r = i._LogLimitOutputs[e];
return r ? r.current++ : (r = {
limit: t,
current: 1
},
i._LogLimitOutputs[e] = r),
r.current <= r.limit
}
,
i._GenerateLimitMessage = function(e, t) {
var r = i._LogLimitOutputs[e];
if (!(!r || !i.MessageLimitReached) && r.current === r.limit)
switch (t) {
case 0:
i.Log(i.MessageLimitReached.replace(/%LIMIT%/g, "" + r.limit).replace(/%TYPE%/g, "log"));
break;
case 1:
i.Warn(i.MessageLimitReached.replace(/%LIMIT%/g, "" + r.limit).replace(/%TYPE%/g, "warning"));
break;
case 2:
i.Error(i.MessageLimitReached.replace(/%LIMIT%/g, "" + r.limit).replace(/%TYPE%/g, "error"));
break
}
}
,
i._AddLogEntry = function(e) {
i._LogCache = e + i._LogCache,
i.OnNewCacheEntry && i.OnNewCacheEntry(e)
}
,
i._FormatMessage = function(e) {
var t = function(n) {
return n < 10 ? "0" + n : "" + n
}
, r = new Date;
return "[" + t(r.getHours()) + ":" + t(r.getMinutes()) + ":" + t(r.getSeconds()) + "]: " + e
}
,
i._LogDisabled = function(e, t) {}
,
i._LogEnabled = function(e, t) {
if (!(t !== void 0 && !i._CheckLimit(e, t))) {
var r = i._FormatMessage(e);
console.log("BJS - " + r);
var n = "
" + r + "
";
i._AddLogEntry(n),
i._GenerateLimitMessage(e, 0)
}
}
,
i._WarnDisabled = function(e, t) {}
,
i._WarnEnabled = function(e, t) {
if (!(t !== void 0 && !i._CheckLimit(e, t))) {
var r = i._FormatMessage(e);
console.warn("BJS - " + r);
var n = "" + e + "
";
i._AddLogEntry(n),
i._GenerateLimitMessage(e, 1)
}
}
,
i._ErrorDisabled = function(e, t) {}
,
i._ErrorEnabled = function(e, t) {
if (!(t !== void 0 && !i._CheckLimit(e, t))) {
var r = i._FormatMessage(e);
i.errorsCount++,
console.error("BJS - " + r);
var n = "" + r + "
";
i._AddLogEntry(n),
i._GenerateLimitMessage(e, 2)
}
}
,
Object.defineProperty(i, "LogCache", {
get: function() {
return i._LogCache
},
enumerable: !1,
configurable: !0
}),
i.ClearLogCache = function() {
i._LogCache = "",
i._LogLimitOutputs = {},
i.errorsCount = 0
}
,
Object.defineProperty(i, "LogLevels", {
set: function(e) {
(e & i.MessageLogLevel) === i.MessageLogLevel ? i.Log = i._LogEnabled : i.Log = i._LogDisabled,
(e & i.WarningLogLevel) === i.WarningLogLevel ? i.Warn = i._WarnEnabled : i.Warn = i._WarnDisabled,
(e & i.ErrorLogLevel) === i.ErrorLogLevel ? i.Error = i._ErrorEnabled : i.Error = i._ErrorDisabled
},
enumerable: !1,
configurable: !0
}),
i.NoneLogLevel = 0,
i.MessageLogLevel = 1,
i.WarningLogLevel = 2,
i.ErrorLogLevel = 4,
i.AllLogLevel = 7,
i.MessageLimitReached = "Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",
i._LogCache = "",
i._LogLimitOutputs = {},
i.errorsCount = 0,
i.Log = i._LogEnabled,
i.Warn = i._WarnEnabled,
i.Error = i._ErrorEnabled,
i
}()
, EndsWith = function(i, e) {
return i.indexOf(e, i.length - e.length) !== -1
}
, StartsWith = function(i, e) {
return i ? i.indexOf(e) === 0 : !1
}
, Decode = function(i) {
if (typeof TextDecoder != "undefined")
return new TextDecoder().decode(i);
for (var e = "", t = 0; t < i.byteLength; t++)
e += String.fromCharCode(i[t]);
return e
}
, EncodeArrayBufferToBase64 = function(i) {
for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", t = "", r, n, o, a, s, l, u, c = 0, h = ArrayBuffer.isView(i) ? new Uint8Array(i.buffer,i.byteOffset,i.byteLength) : new Uint8Array(i); c < h.length; )
r = h[c++],
n = c < h.length ? h[c++] : Number.NaN,
o = c < h.length ? h[c++] : Number.NaN,
a = r >> 2,
s = (r & 3) << 4 | n >> 4,
l = (n & 15) << 2 | o >> 6,
u = o & 63,
isNaN(n) ? l = u = 64 : isNaN(o) && (u = 64),
t += e.charAt(a) + e.charAt(s) + e.charAt(l) + e.charAt(u);
return t
}
, DecodeBase64ToString = function(i) {
return atob(i)
}
, DecodeBase64ToBinary = function(i) {
for (var e = DecodeBase64ToString(i), t = e.length, r = new Uint8Array(new ArrayBuffer(t)), n = 0; n < t; n++)
r[n] = e.charCodeAt(n);
return r.buffer
}
, PadNumber = function(i, e) {
for (var t = String(i); t.length < e; )
t = "0" + t;
return t
}
, StringTools = {
EndsWith,
StartsWith,
Decode,
EncodeArrayBufferToBase64,
DecodeBase64ToString,
DecodeBase64ToBinary,
PadNumber
}
, cloneValue = function(i, e) {
return !i || i.getClassName && i.getClassName() === "Mesh" ? null : i.getClassName && i.getClassName() === "SubMesh" ? i.clone(e) : i.clone ? i.clone() : null
};
function getAllPropertyNames(i) {
var e = [];
do
Object.getOwnPropertyNames(i).forEach(function(t) {
e.indexOf(t) === -1 && e.push(t)
});
while (i = Object.getPrototypeOf(i));
return e
}
var DeepCopier = function() {
function i() {}
return i.DeepCopy = function(e, t, r, n) {
for (var o = getAllPropertyNames(e), a = 0, s = o; a < s.length; a++) {
var l = s[a];
if (!(l[0] === "_" && (!n || n.indexOf(l) === -1)) && !EndsWith(l, "Observable") && !(r && r.indexOf(l) !== -1)) {
var u = e[l]
, c = typeof u;
if (c !== "function")
try {
if (c === "object")
if (u instanceof Array) {
if (t[l] = [],
u.length > 0)
if (typeof u[0] == "object")
for (var h = 0; h < u.length; h++) {
var f = cloneValue(u[h], t);
t[l].indexOf(f) === -1 && t[l].push(f)
}
else
t[l] = u.slice(0)
} else
t[l] = cloneValue(u, t);
else
t[l] = u
} catch (d) {
Logger$2.Warn(d.message)
}
}
}
}
,
i
}()
, PrecisionDate = function() {
function i() {}
return Object.defineProperty(i, "Now", {
get: function() {
return DomManagement.IsWindowObjectExist() && window.performance && window.performance.now ? window.performance.now() : Date.now()
},
enumerable: !1,
configurable: !0
}),
i
}();
function _WarnImport(i) {
return i + " needs to be imported before as it contains a side-effect required by your code."
}
function createXMLHttpRequest() {
return typeof _native != "undefined" && _native.XMLHttpRequest ? new _native.XMLHttpRequest : new XMLHttpRequest
}
var WebRequest = function() {
function i() {
this._xhr = createXMLHttpRequest()
}
return i.prototype._injectCustomRequestHeaders = function() {
for (var e in i.CustomRequestHeaders) {
var t = i.CustomRequestHeaders[e];
t && this._xhr.setRequestHeader(e, t)
}
}
,
Object.defineProperty(i.prototype, "onprogress", {
get: function() {
return this._xhr.onprogress
},
set: function(e) {
this._xhr.onprogress = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "readyState", {
get: function() {
return this._xhr.readyState
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "status", {
get: function() {
return this._xhr.status
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "statusText", {
get: function() {
return this._xhr.statusText
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "response", {
get: function() {
return this._xhr.response
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "responseURL", {
get: function() {
return this._xhr.responseURL
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "responseText", {
get: function() {
return this._xhr.responseText
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "responseType", {
get: function() {
return this._xhr.responseType
},
set: function(e) {
this._xhr.responseType = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "timeout", {
get: function() {
return this._xhr.timeout
},
set: function(e) {
this._xhr.timeout = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.addEventListener = function(e, t, r) {
this._xhr.addEventListener(e, t, r)
}
,
i.prototype.removeEventListener = function(e, t, r) {
this._xhr.removeEventListener(e, t, r)
}
,
i.prototype.abort = function() {
this._xhr.abort()
}
,
i.prototype.send = function(e) {
i.CustomRequestHeaders && this._injectCustomRequestHeaders(),
this._xhr.send(e)
}
,
i.prototype.open = function(e, t) {
for (var r = 0, n = i.CustomRequestModifiers; r < n.length; r++) {
var o = n[r];
o(this._xhr, t)
}
return t = t.replace("file:http:", "http:"),
t = t.replace("file:https:", "https:"),
this._xhr.open(e, t, !0)
}
,
i.prototype.setRequestHeader = function(e, t) {
this._xhr.setRequestHeader(e, t)
}
,
i.prototype.getResponseHeader = function(e) {
return this._xhr.getResponseHeader(e)
}
,
i.CustomRequestHeaders = {},
i.CustomRequestModifiers = new Array,
i
}(), EngineStore = function() {
function i() {}
return Object.defineProperty(i, "LastCreatedEngine", {
get: function() {
return this.Instances.length === 0 ? null : this.Instances[this.Instances.length - 1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "LastCreatedScene", {
get: function() {
return this._LastCreatedScene
},
enumerable: !1,
configurable: !0
}),
i.Instances = new Array,
i._LastCreatedScene = null,
i.UseFallbackTexture = !0,
i.FallbackTexture = "",
i
}(), FilesInputStore = function() {
function i() {}
return i.FilesToLoad = {},
i
}(), RetryStrategy = function() {
function i() {}
return i.ExponentialBackoff = function(e, t) {
return e === void 0 && (e = 3),
t === void 0 && (t = 500),
function(r, n, o) {
return n.status !== 0 || o >= e || r.indexOf("file:") !== -1 ? -1 : Math.pow(2, o) * t
}
}
,
i
}(), BaseError = function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e._setPrototypeOf = Object.setPrototypeOf || function(t, r) {
return t.__proto__ = r,
t
}
,
e
}(Error), ShaderCodeNode = function() {
function i() {
this.children = []
}
return i.prototype.isValid = function(e) {
return !0
}
,
i.prototype.process = function(e, t) {
var r = "";
if (this.line) {
var n = this.line
, o = t.processor;
if (o) {
if (o.lineProcessor && (n = o.lineProcessor(n, t.isFragment, t.processingContext)),
o.attributeProcessor && StartsWith(this.line, "attribute"))
n = o.attributeProcessor(this.line, e, t.processingContext);
else if (o.varyingProcessor && StartsWith(this.line, "varying"))
n = o.varyingProcessor(this.line, t.isFragment, e, t.processingContext);
else if (o.uniformProcessor && o.uniformRegexp && o.uniformRegexp.test(this.line))
t.lookForClosingBracketForUniformBuffer || (n = o.uniformProcessor(this.line, t.isFragment, e, t.processingContext));
else if (o.uniformBufferProcessor && o.uniformBufferRegexp && o.uniformBufferRegexp.test(this.line))
t.lookForClosingBracketForUniformBuffer || (n = o.uniformBufferProcessor(this.line, t.isFragment, t.processingContext),
t.lookForClosingBracketForUniformBuffer = !0);
else if (o.textureProcessor && o.textureRegexp && o.textureRegexp.test(this.line))
n = o.textureProcessor(this.line, t.isFragment, e, t.processingContext);
else if ((o.uniformProcessor || o.uniformBufferProcessor) && StartsWith(this.line, "uniform") && !t.lookForClosingBracketForUniformBuffer) {
var a = /uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/;
a.test(this.line) ? o.uniformProcessor && (n = o.uniformProcessor(this.line, t.isFragment, e, t.processingContext)) : o.uniformBufferProcessor && (n = o.uniformBufferProcessor(this.line, t.isFragment, t.processingContext),
t.lookForClosingBracketForUniformBuffer = !0)
}
t.lookForClosingBracketForUniformBuffer && this.line.indexOf("}") !== -1 && (t.lookForClosingBracketForUniformBuffer = !1,
o.endOfUniformBufferProcessor && (n = o.endOfUniformBufferProcessor(this.line, t.isFragment, t.processingContext)))
}
r += n + `\r
`
}
return this.children.forEach(function(s) {
r += s.process(e, t)
}),
this.additionalDefineKey && (e[this.additionalDefineKey] = this.additionalDefineValue || "true"),
r
}
,
i
}(), ShaderCodeCursor = function() {
function i() {}
return Object.defineProperty(i.prototype, "currentLine", {
get: function() {
return this._lines[this.lineIndex]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "canRead", {
get: function() {
return this.lineIndex < this._lines.length - 1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "lines", {
set: function(e) {
this._lines = [];
for (var t = 0, r = e; t < r.length; t++) {
var n = r[t];
if (n[0] === "#") {
this._lines.push(n);
continue
}
for (var o = n.split(";"), a = 0; a < o.length; a++) {
var s = o[a];
s = s.trim(),
s && this._lines.push(s + (a !== o.length - 1 ? ";" : ""))
}
}
},
enumerable: !1,
configurable: !0
}),
i
}(), ShaderCodeConditionNode = function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.process = function(t, r) {
for (var n = 0; n < this.children.length; n++) {
var o = this.children[n];
if (o.isValid(t))
return o.process(t, r)
}
return ""
}
,
e
}(ShaderCodeNode), ShaderCodeTestNode = function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.isValid = function(t) {
return this.testExpression.isTrue(t)
}
,
e
}(ShaderCodeNode), ShaderDefineExpression = function() {
function i() {}
return i.prototype.isTrue = function(e) {
return !0
}
,
i.postfixToInfix = function(e) {
for (var t = [], r = 0, n = e; r < n.length; r++) {
var o = n[r];
if (i._OperatorPriority[o] === void 0)
t.push(o);
else {
var a = t[t.length - 1]
, s = t[t.length - 2];
t.length -= 2,
t.push("(" + s + o + a + ")")
}
}
return t[t.length - 1]
}
,
i.infixToPostfix = function(e) {
for (var t = [], r = -1, n = function() {
u = u.trim(),
u !== "" && (t.push(u),
u = "")
}, o = function(f) {
r < i._Stack.length - 1 && (i._Stack[++r] = f)
}, a = function() {
return i._Stack[r]
}, s = function() {
return r === -1 ? "!!INVALID EXPRESSION!!" : i._Stack[r--]
}, l = 0, u = ""; l < e.length; ) {
var c = e.charAt(l)
, h = l < e.length - 1 ? e.substr(l, 2) : "";
if (c === "(")
u = "",
o(c);
else if (c === ")") {
for (n(); r !== -1 && a() !== "("; )
t.push(s());
s()
} else if (i._OperatorPriority[h] > 1) {
for (n(); r !== -1 && i._OperatorPriority[a()] >= i._OperatorPriority[h]; )
t.push(s());
o(h),
l++
} else
u += c;
l++
}
for (n(); r !== -1; )
a() === "(" ? s() : t.push(s());
return t
}
,
i._OperatorPriority = {
")": 0,
"(": 1,
"||": 2,
"&&": 3
},
i._Stack = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
i
}(), ShaderDefineIsDefinedOperator = function(i) {
__extends(e, i);
function e(t, r) {
r === void 0 && (r = !1);
var n = i.call(this) || this;
return n.define = t,
n.not = r,
n
}
return e.prototype.isTrue = function(t) {
var r = t[this.define] !== void 0;
return this.not && (r = !r),
r
}
,
e
}(ShaderDefineExpression), ShaderDefineOrOperator = function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.isTrue = function(t) {
return this.leftOperand.isTrue(t) || this.rightOperand.isTrue(t)
}
,
e
}(ShaderDefineExpression), ShaderDefineAndOperator = function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.isTrue = function(t) {
return this.leftOperand.isTrue(t) && this.rightOperand.isTrue(t)
}
,
e
}(ShaderDefineExpression), ShaderDefineArithmeticOperator = function(i) {
__extends(e, i);
function e(t, r, n) {
var o = i.call(this) || this;
return o.define = t,
o.operand = r,
o.testValue = n,
o
}
return e.prototype.isTrue = function(t) {
var r = t[this.define];
r === void 0 && (r = this.define);
var n = !1
, o = parseInt(r)
, a = parseInt(this.testValue);
switch (this.operand) {
case ">":
n = o > a;
break;
case "<":
n = o < a;
break;
case "<=":
n = o <= a;
break;
case ">=":
n = o >= a;
break;
case "==":
n = o === a;
break
}
return n
}
,
e
}(ShaderDefineExpression), ShaderLanguage;
(function(i) {
i[i.GLSL = 0] = "GLSL",
i[i.WGSL = 1] = "WGSL"
}
)(ShaderLanguage || (ShaderLanguage = {}));
var regexSE = /defined\s*?\((.+?)\)/g, regexSERevert = /defined\s*?\[(.+?)\]/g, ShaderProcessor = function() {
function i() {}
return i.Initialize = function(e) {
e.processor && e.processor.initializeShaders && e.processor.initializeShaders(e.processingContext)
}
,
i.Process = function(e, t, r, n) {
var o = this, a;
!((a = t.processor) === null || a === void 0) && a.preProcessShaderCode && (e = t.processor.preProcessShaderCode(e)),
this._ProcessIncludes(e, t, function(s) {
var l = o._ProcessShaderConversion(s, t, n);
r(l)
})
}
,
i.PreProcess = function(e, t, r, n) {
var o = this, a;
!((a = t.processor) === null || a === void 0) && a.preProcessShaderCode && (e = t.processor.preProcessShaderCode(e)),
this._ProcessIncludes(e, t, function(s) {
var l = o._ApplyPreProcessing(s, t, n);
r(l)
})
}
,
i.Finalize = function(e, t, r) {
return !r.processor || !r.processor.finalizeShaders ? {
vertexCode: e,
fragmentCode: t
} : r.processor.finalizeShaders(e, t, r.processingContext)
}
,
i._ProcessPrecision = function(e, t) {
var r;
if (!((r = t.processor) === null || r === void 0) && r.noPrecision)
return e;
var n = t.shouldUseHighPrecisionShader;
return e.indexOf("precision highp float") === -1 ? n ? e = `precision highp float;
` + e : e = `precision mediump float;
` + e : n || (e = e.replace("precision highp float", "precision mediump float")),
e
}
,
i._ExtractOperation = function(e) {
var t = /defined\((.+)\)/
, r = t.exec(e);
if (r && r.length)
return new ShaderDefineIsDefinedOperator(r[1].trim(),e[0] === "!");
for (var n = ["==", ">=", "<=", "<", ">"], o = "", a = 0, s = 0, l = n; s < l.length && (o = l[s],
a = e.indexOf(o),
!(a > -1)); s++)
;
if (a === -1)
return new ShaderDefineIsDefinedOperator(e);
var u = e.substring(0, a).trim()
, c = e.substring(a + o.length).trim();
return new ShaderDefineArithmeticOperator(u,o,c)
}
,
i._BuildSubExpression = function(e) {
e = e.replace(regexSE, "defined[$1]");
for (var t = ShaderDefineExpression.infixToPostfix(e), r = [], n = 0, o = t; n < o.length; n++) {
var a = o[n];
if (a !== "||" && a !== "&&")
r.push(a);
else if (r.length >= 2) {
var s = r[r.length - 1]
, l = r[r.length - 2];
r.length -= 2;
var u = a == "&&" ? new ShaderDefineAndOperator : new ShaderDefineOrOperator;
typeof s == "string" && (s = s.replace(regexSERevert, "defined($1)")),
typeof l == "string" && (l = l.replace(regexSERevert, "defined($1)")),
u.leftOperand = typeof l == "string" ? this._ExtractOperation(l) : l,
u.rightOperand = typeof s == "string" ? this._ExtractOperation(s) : s,
r.push(u)
}
}
var c = r[r.length - 1];
return typeof c == "string" && (c = c.replace(regexSERevert, "defined($1)")),
typeof c == "string" ? this._ExtractOperation(c) : c
}
,
i._BuildExpression = function(e, t) {
var r = new ShaderCodeTestNode
, n = e.substring(0, t)
, o = e.substring(t);
return o = o.substring(0, (o.indexOf("//") + 1 || o.length + 1) - 1).trim(),
n === "#ifdef" ? r.testExpression = new ShaderDefineIsDefinedOperator(o) : n === "#ifndef" ? r.testExpression = new ShaderDefineIsDefinedOperator(o,!0) : r.testExpression = this._BuildSubExpression(o),
r
}
,
i._MoveCursorWithinIf = function(e, t, r) {
for (var n = e.currentLine; this._MoveCursor(e, r); ) {
n = e.currentLine;
var o = n.substring(0, 5).toLowerCase();
if (o === "#else") {
var a = new ShaderCodeNode;
t.children.push(a),
this._MoveCursor(e, a);
return
} else if (o === "#elif") {
var s = this._BuildExpression(n, 5);
t.children.push(s),
r = s
}
}
}
,
i._MoveCursor = function(e, t) {
for (; e.canRead; ) {
e.lineIndex++;
var r = e.currentLine
, n = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/
, o = n.exec(r);
if (o && o.length) {
var a = o[0];
switch (a) {
case "#ifdef":
{
var s = new ShaderCodeConditionNode;
t.children.push(s);
var l = this._BuildExpression(r, 6);
s.children.push(l),
this._MoveCursorWithinIf(e, s, l);
break
}
case "#else":
case "#elif":
return !0;
case "#endif":
return !1;
case "#ifndef":
{
var s = new ShaderCodeConditionNode;
t.children.push(s);
var l = this._BuildExpression(r, 7);
s.children.push(l),
this._MoveCursorWithinIf(e, s, l);
break
}
case "#if":
{
var s = new ShaderCodeConditionNode
, l = this._BuildExpression(r, 3);
t.children.push(s),
s.children.push(l),
this._MoveCursorWithinIf(e, s, l);
break
}
}
} else {
var u = new ShaderCodeNode;
if (u.line = r,
t.children.push(u),
r[0] === "#" && r[1] === "d") {
var c = r.replace(";", "").split(" ");
u.additionalDefineKey = c[1],
c.length === 3 && (u.additionalDefineValue = c[2])
}
}
}
return !1
}
,
i._EvaluatePreProcessors = function(e, t, r) {
var n = new ShaderCodeNode
, o = new ShaderCodeCursor;
return o.lineIndex = -1,
o.lines = e.split(`
`),
this._MoveCursor(o, n),
n.process(t, r)
}
,
i._PreparePreProcessors = function(e, t) {
for (var r, n = e.defines, o = {}, a = 0, s = n; a < s.length; a++) {
var l = s[a]
, u = l.replace("#define", "").replace(";", "").trim()
, c = u.split(" ");
o[c[0]] = c.length > 1 ? c[1] : ""
}
return ((r = e.processor) === null || r === void 0 ? void 0 : r.shaderLanguage) === ShaderLanguage.GLSL && (o.GL_ES = "true"),
o.__VERSION__ = e.version,
o[e.platformName] = "true",
t._getGlobalDefines(o),
o
}
,
i._ProcessShaderConversion = function(e, t, r) {
var n = this._ProcessPrecision(e, t);
if (!t.processor)
return n;
if (t.processor.shaderLanguage === ShaderLanguage.GLSL && n.indexOf("#version 3") !== -1)
return n.replace("#version 300 es", "");
var o = t.defines
, a = this._PreparePreProcessors(t, r);
return t.processor.preProcessor && (n = t.processor.preProcessor(n, o, t.isFragment, t.processingContext)),
n = this._EvaluatePreProcessors(n, a, t),
t.processor.postProcessor && (n = t.processor.postProcessor(n, o, t.isFragment, t.processingContext, r)),
r._features.needShaderCodeInlining && (n = r.inlineShaderCode(n)),
n
}
,
i._ApplyPreProcessing = function(e, t, r) {
var n, o, a = e, s = t.defines, l = this._PreparePreProcessors(t, r);
return !((n = t.processor) === null || n === void 0) && n.preProcessor && (a = t.processor.preProcessor(a, s, t.isFragment, t.processingContext)),
a = this._EvaluatePreProcessors(a, l, t),
!((o = t.processor) === null || o === void 0) && o.postProcessor && (a = t.processor.postProcessor(a, s, t.isFragment, t.processingContext, r)),
r._features.needShaderCodeInlining && (a = r.inlineShaderCode(a)),
a
}
,
i._ProcessIncludes = function(e, t, r) {
for (var n = this, o = /#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g, a = o.exec(e), s = new String(e), l = !1; a != null; ) {
var u = a[1];
if (u.indexOf("__decl__") !== -1 && (u = u.replace(/__decl__/, ""),
t.supportsUniformBuffers && (u = u.replace(/Vertex/, "Ubo"),
u = u.replace(/Fragment/, "Ubo")),
u = u + "Declaration"),
t.includesShadersStore[u]) {
var c = t.includesShadersStore[u];
if (a[2])
for (var h = a[3].split(","), f = 0; f < h.length; f += 2) {
var d = new RegExp(h[f],"g")
, _ = h[f + 1];
c = c.replace(d, _)
}
if (a[4]) {
var g = a[5];
if (g.indexOf("..") !== -1) {
var m = g.split("..")
, v = parseInt(m[0])
, y = parseInt(m[1])
, b = c.slice(0);
c = "",
isNaN(y) && (y = t.indexParameters[m[1]]);
for (var T = v; T < y; T++)
t.supportsUniformBuffers || (b = b.replace(/light\{X\}.(\w*)/g, function(A, S) {
return S + "{X}"
})),
c += b.replace(/\{X\}/g, T.toString()) + `
`
} else
t.supportsUniformBuffers || (c = c.replace(/light\{X\}.(\w*)/g, function(A, S) {
return S + "{X}"
})),
c = c.replace(/\{X\}/g, g)
}
s = s.replace(a[0], c),
l = l || c.indexOf("#include<") >= 0 || c.indexOf("#include <") >= 0
} else {
var C = t.shadersRepository + "ShadersInclude/" + u + ".fx";
i._FileToolsLoadFile(C, function(A) {
t.includesShadersStore[u] = A,
n._ProcessIncludes(s, t, r)
});
return
}
a = o.exec(e)
}
l ? this._ProcessIncludes(s.toString(), t, r) : r(s)
}
,
i._FileToolsLoadFile = function(e, t, r, n, o, a) {
throw _WarnImport("FileTools")
}
,
i
}(), ShaderStore = function() {
function i() {}
return i.GetShadersRepository = function(e) {
return e === void 0 && (e = ShaderLanguage.GLSL),
e === ShaderLanguage.GLSL ? i.ShadersRepository : i.ShadersRepositoryWGSL
}
,
i.GetShadersStore = function(e) {
return e === void 0 && (e = ShaderLanguage.GLSL),
e === ShaderLanguage.GLSL ? i.ShadersStore : i.ShadersStoreWGSL
}
,
i.GetIncludesShadersStore = function(e) {
return e === void 0 && (e = ShaderLanguage.GLSL),
e === ShaderLanguage.GLSL ? i.IncludesShadersStore : i.IncludesShadersStoreWGSL
}
,
i.ShadersRepository = "src/Shaders/",
i.ShadersStore = {},
i.IncludesShadersStore = {},
i.ShadersRepositoryWGSL = "src/ShadersWGSL/",
i.ShadersStoreWGSL = {},
i.IncludesShadersStoreWGSL = {},
i
}(), Effect = function() {
function i(e, t, r, n, o, a, s, l, u, c, h, f) {
var d = this;
n === void 0 && (n = null),
a === void 0 && (a = null),
s === void 0 && (s = null),
l === void 0 && (l = null),
u === void 0 && (u = null),
h === void 0 && (h = ""),
f === void 0 && (f = ShaderLanguage.GLSL);
var _, g;
this.name = null,
this.defines = "",
this.onCompiled = null,
this.onError = null,
this.onBind = null,
this.uniqueId = 0,
this.onCompileObservable = new Observable,
this.onErrorObservable = new Observable,
this._onBindObservable = null,
this._wasPreviouslyReady = !1,
this._bonesComputationForcedToCPU = !1,
this._uniformBuffersNames = {},
this._multiTarget = !1,
this._samplers = {},
this._isReady = !1,
this._compilationError = "",
this._allFallbacksProcessed = !1,
this._uniforms = {},
this._key = "",
this._fallbacks = null,
this._vertexSourceCodeOverride = "",
this._fragmentSourceCodeOverride = "",
this._transformFeedbackVaryings = null,
this._pipelineContext = null,
this._vertexSourceCode = "",
this._fragmentSourceCode = "",
this._rawVertexSourceCode = "",
this._rawFragmentSourceCode = "",
this.name = e,
this._key = h;
var m = null;
if (t.attributes) {
var v = t;
if (this._engine = r,
this._attributesNames = v.attributes,
this._uniformsNames = v.uniformsNames.concat(v.samplers),
this._samplerList = v.samplers.slice(),
this.defines = v.defines,
this.onError = v.onError,
this.onCompiled = v.onCompiled,
this._fallbacks = v.fallbacks,
this._indexParameters = v.indexParameters,
this._transformFeedbackVaryings = v.transformFeedbackVaryings || null,
this._multiTarget = !!v.multiTarget,
this._shaderLanguage = (_ = v.shaderLanguage) !== null && _ !== void 0 ? _ : ShaderLanguage.GLSL,
v.uniformBuffersNames) {
this._uniformBuffersNamesList = v.uniformBuffersNames.slice();
for (var y = 0; y < v.uniformBuffersNames.length; y++)
this._uniformBuffersNames[v.uniformBuffersNames[y]] = y
}
m = (g = v.processFinalCode) !== null && g !== void 0 ? g : null
} else
this._engine = o,
this.defines = a == null ? "" : a,
this._uniformsNames = r.concat(n),
this._samplerList = n ? n.slice() : [],
this._attributesNames = t,
this._uniformBuffersNamesList = [],
this._shaderLanguage = f,
this.onError = u,
this.onCompiled = l,
this._indexParameters = c,
this._fallbacks = s;
this._attributeLocationByName = {},
this.uniqueId = i._uniqueIdSeed++;
var b, T, C = IsWindowObjectExist() ? this._engine.getHostDocument() : null;
e.vertexSource ? b = "source:" + e.vertexSource : e.vertexElement ? (b = C ? C.getElementById(e.vertexElement) : null,
b || (b = e.vertexElement)) : b = e.vertex || e,
e.fragmentSource ? T = "source:" + e.fragmentSource : e.fragmentElement ? (T = C ? C.getElementById(e.fragmentElement) : null,
T || (T = e.fragmentElement)) : T = e.fragment || e,
this._processingContext = this._engine._getShaderProcessingContext(this._shaderLanguage);
var A = {
defines: this.defines.split(`
`),
indexParameters: this._indexParameters,
isFragment: !1,
shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader,
processor: this._engine._getShaderProcessor(this._shaderLanguage),
supportsUniformBuffers: this._engine.supportsUniformBuffers,
shadersRepository: ShaderStore.GetShadersRepository(this._shaderLanguage),
includesShadersStore: ShaderStore.GetIncludesShadersStore(this._shaderLanguage),
version: (this._engine.version * 100).toString(),
platformName: this._engine.shaderPlatformName,
processingContext: this._processingContext,
isNDCHalfZRange: this._engine.isNDCHalfZRange,
useReverseDepthBuffer: this._engine.useReverseDepthBuffer
}
, S = [void 0, void 0]
, P = function() {
if (S[0] && S[1]) {
A.isFragment = !0;
var R = S[0]
, M = S[1];
ShaderProcessor.Process(M, A, function(x) {
m && (x = m("fragment", x));
var I = ShaderProcessor.Finalize(R, x, A);
d._useFinalCode(I.vertexCode, I.fragmentCode, e)
}, d._engine)
}
};
this._loadShader(b, "Vertex", "", function(R) {
ShaderProcessor.Initialize(A),
ShaderProcessor.Process(R, A, function(M) {
d._rawVertexSourceCode = R,
m && (M = m("vertex", M)),
S[0] = M,
P()
}, d._engine)
}),
this._loadShader(T, "Fragment", "Pixel", function(R) {
d._rawFragmentSourceCode = R,
S[1] = R,
P()
})
}
return Object.defineProperty(i, "ShadersRepository", {
get: function() {
return ShaderStore.ShadersRepository
},
set: function(e) {
ShaderStore.ShadersRepository = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onBindObservable", {
get: function() {
return this._onBindObservable || (this._onBindObservable = new Observable),
this._onBindObservable
},
enumerable: !1,
configurable: !0
}),
i.prototype._useFinalCode = function(e, t, r) {
if (r) {
var n = r.vertexElement || r.vertex || r.spectorName || r
, o = r.fragmentElement || r.fragment || r.spectorName || r;
this._vertexSourceCode = (this._shaderLanguage === ShaderLanguage.WGSL ? "//" : "") + "#define SHADER_NAME vertex:" + n + `
` + e,
this._fragmentSourceCode = (this._shaderLanguage === ShaderLanguage.WGSL ? "//" : "") + "#define SHADER_NAME fragment:" + o + `
` + t
} else
this._vertexSourceCode = e,
this._fragmentSourceCode = t;
this._prepareEffect()
}
,
Object.defineProperty(i.prototype, "key", {
get: function() {
return this._key
},
enumerable: !1,
configurable: !0
}),
i.prototype.isReady = function() {
try {
return this._isReadyInternal()
} catch {
return !1
}
}
,
i.prototype._isReadyInternal = function() {
return this._isReady ? !0 : this._pipelineContext ? this._pipelineContext.isReady : !1
}
,
i.prototype.getEngine = function() {
return this._engine
}
,
i.prototype.getPipelineContext = function() {
return this._pipelineContext
}
,
i.prototype.getAttributesNames = function() {
return this._attributesNames
}
,
i.prototype.getAttributeLocation = function(e) {
return this._attributes[e]
}
,
i.prototype.getAttributeLocationByName = function(e) {
return this._attributeLocationByName[e]
}
,
i.prototype.getAttributesCount = function() {
return this._attributes.length
}
,
i.prototype.getUniformIndex = function(e) {
return this._uniformsNames.indexOf(e)
}
,
i.prototype.getUniform = function(e) {
return this._uniforms[e]
}
,
i.prototype.getSamplers = function() {
return this._samplerList
}
,
i.prototype.getUniformNames = function() {
return this._uniformsNames
}
,
i.prototype.getUniformBuffersNames = function() {
return this._uniformBuffersNamesList
}
,
i.prototype.getIndexParameters = function() {
return this._indexParameters
}
,
i.prototype.getCompilationError = function() {
return this._compilationError
}
,
i.prototype.allFallbacksProcessed = function() {
return this._allFallbacksProcessed
}
,
i.prototype.executeWhenCompiled = function(e) {
var t = this;
if (this.isReady()) {
e(this);
return
}
this.onCompileObservable.add(function(r) {
e(r)
}),
(!this._pipelineContext || this._pipelineContext.isAsync) && setTimeout(function() {
t._checkIsReady(null)
}, 16)
}
,
i.prototype._checkIsReady = function(e) {
var t = this;
try {
if (this._isReadyInternal())
return
} catch (r) {
this._processCompilationErrors(r, e);
return
}
setTimeout(function() {
t._checkIsReady(e)
}, 16)
}
,
i.prototype._loadShader = function(e, t, r, n) {
if (typeof HTMLElement != "undefined" && e instanceof HTMLElement) {
var o = GetDOMTextContent(e);
n(o);
return
}
if (e.substr(0, 7) === "source:") {
n(e.substr(7));
return
}
if (e.substr(0, 7) === "base64:") {
var a = window.atob(e.substr(7));
n(a);
return
}
var s = ShaderStore.GetShadersStore(this._shaderLanguage);
if (s[e + t + "Shader"]) {
n(s[e + t + "Shader"]);
return
}
if (r && s[e + r + "Shader"]) {
n(s[e + r + "Shader"]);
return
}
var l;
e[0] === "." || e[0] === "/" || e.indexOf("http") > -1 ? l = e : l = ShaderStore.GetShadersRepository(this._shaderLanguage) + e,
this._engine._loadFile(l + "." + t.toLowerCase() + ".fx", n)
}
,
Object.defineProperty(i.prototype, "vertexSourceCode", {
get: function() {
var e, t;
return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._vertexSourceCodeOverride : (t = (e = this._pipelineContext) === null || e === void 0 ? void 0 : e._getVertexShaderCode()) !== null && t !== void 0 ? t : this._vertexSourceCode
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "fragmentSourceCode", {
get: function() {
var e, t;
return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._fragmentSourceCodeOverride : (t = (e = this._pipelineContext) === null || e === void 0 ? void 0 : e._getFragmentShaderCode()) !== null && t !== void 0 ? t : this._fragmentSourceCode
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "rawVertexSourceCode", {
get: function() {
return this._rawVertexSourceCode
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "rawFragmentSourceCode", {
get: function() {
return this._rawFragmentSourceCode
},
enumerable: !1,
configurable: !0
}),
i.prototype._rebuildProgram = function(e, t, r, n) {
var o = this;
this._isReady = !1,
this._vertexSourceCodeOverride = e,
this._fragmentSourceCodeOverride = t,
this.onError = function(a, s) {
n && n(s)
}
,
this.onCompiled = function() {
var a = o.getEngine().scenes;
if (a)
for (var s = 0; s < a.length; s++)
a[s].markAllMaterialsAsDirty(63);
o._pipelineContext._handlesSpectorRebuildCallback(r)
}
,
this._fallbacks = null,
this._prepareEffect()
}
,
i.prototype._prepareEffect = function() {
var e = this
, t = this._attributesNames
, r = this.defines
, n = this._pipelineContext;
this._isReady = !1;
try {
var o = this._engine;
this._pipelineContext = o.createPipelineContext(this._processingContext),
this._pipelineContext._name = this._key;
var a = this._rebuildProgram.bind(this);
this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? o._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, !0, this._rawVertexSourceCode, this._rawFragmentSourceCode, a, null, this._transformFeedbackVaryings, this._key) : o._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, !1, this._rawVertexSourceCode, this._rawFragmentSourceCode, a, r, this._transformFeedbackVaryings, this._key),
o._executeWhenRenderingStateIsCompiled(this._pipelineContext, function() {
if (e._attributes = [],
e._pipelineContext._fillEffectInformation(e, e._uniformBuffersNames, e._uniformsNames, e._uniforms, e._samplerList, e._samplers, t, e._attributes),
t)
for (var s = 0; s < t.length; s++) {
var l = t[s];
e._attributeLocationByName[l] = e._attributes[s]
}
o.bindSamplers(e),
e._compilationError = "",
e._isReady = !0,
e.onCompiled && e.onCompiled(e),
e.onCompileObservable.notifyObservers(e),
e.onCompileObservable.clear(),
e._fallbacks && e._fallbacks.unBindMesh(),
n && e.getEngine()._deletePipelineContext(n)
}),
this._pipelineContext.isAsync && this._checkIsReady(n)
} catch (s) {
this._processCompilationErrors(s, n)
}
}
,
i.prototype._getShaderCodeAndErrorLine = function(e, t, r) {
var n = r ? /FRAGMENT SHADER ERROR: 0:(\d+?):/ : /VERTEX SHADER ERROR: 0:(\d+?):/
, o = null;
if (t && e) {
var a = t.match(n);
if (a && a.length === 2) {
var s = parseInt(a[1])
, l = e.split(`
`, -1);
l.length >= s && (o = "Offending line [" + s + "] in " + (r ? "fragment" : "vertex") + " code: " + l[s - 1])
}
}
return [e, o]
}
,
i.prototype._processCompilationErrors = function(e, t) {
var r, n, o, a, s;
t === void 0 && (t = null),
this._compilationError = e.message;
var l = this._attributesNames
, u = this._fallbacks;
if (Logger$2.Error("Unable to compile effect:"),
Logger$2.Error("Uniforms: " + this._uniformsNames.map(function(d) {
return " " + d
})),
Logger$2.Error("Attributes: " + l.map(function(d) {
return " " + d
})),
Logger$2.Error(`Defines:\r
` + this.defines),
i.LogShaderCodeOnCompilationError) {
var c = null
, h = null
, f = null;
!((o = this._pipelineContext) === null || o === void 0) && o._getVertexShaderCode() && (r = this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(), this._compilationError, !1),
f = r[0],
c = r[1],
f && (Logger$2.Error("Vertex code:"),
Logger$2.Error(f))),
!((a = this._pipelineContext) === null || a === void 0) && a._getFragmentShaderCode() && (n = this._getShaderCodeAndErrorLine((s = this._pipelineContext) === null || s === void 0 ? void 0 : s._getFragmentShaderCode(), this._compilationError, !0),
f = n[0],
h = n[1],
f && (Logger$2.Error("Fragment code:"),
Logger$2.Error(f))),
c && Logger$2.Error(c),
h && Logger$2.Error(h)
}
Logger$2.Error("Error: " + this._compilationError),
t && (this._pipelineContext = t,
this._isReady = !0,
this.onError && this.onError(this, this._compilationError),
this.onErrorObservable.notifyObservers(this)),
u ? (this._pipelineContext = null,
u.hasMoreFallbacks ? (this._allFallbacksProcessed = !1,
Logger$2.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(i.prototype, "isSupported", {
get: function() {
return this._compilationError === ""
},
enumerable: !1,
configurable: !0
}),
i.prototype._bindTexture = function(e, t) {
this._engine._bindTexture(this._samplers[e], t, e)
}
,
i.prototype.setTexture = function(e, t) {
this._engine.setTexture(this._samplers[e], this._uniforms[e], t, e)
}
,
i.prototype.setDepthStencilTexture = function(e, t) {
this._engine.setDepthStencilTexture(this._samplers[e], this._uniforms[e], t, e)
}
,
i.prototype.setTextureArray = function(e, t) {
var r = e + "Ex";
if (this._samplerList.indexOf(r + "0") === -1) {
for (var n = this._samplerList.indexOf(e), o = 1; o < t.length; o++) {
var a = r + (o - 1).toString();
this._samplerList.splice(n + o, 0, a)
}
for (var s = 0, l = 0, u = this._samplerList; l < u.length; l++) {
var c = u[l];
this._samplers[c] = s,
s += 1
}
}
this._engine.setTextureArray(this._samplers[e], this._uniforms[e], t, e)
}
,
i.prototype.setTextureFromPostProcess = function(e, t) {
this._engine.setTextureFromPostProcess(this._samplers[e], t, e)
}
,
i.prototype.setTextureFromPostProcessOutput = function(e, t) {
this._engine.setTextureFromPostProcessOutput(this._samplers[e], t, e)
}
,
i.prototype.bindUniformBuffer = function(e, t) {
var r = this._uniformBuffersNames[t];
r === void 0 || i._baseCache[r] === e && this._engine._features.useUBOBindingCache || (i._baseCache[r] = e,
this._engine.bindUniformBufferBase(e, r, t))
}
,
i.prototype.bindUniformBlock = function(e, t) {
this._engine.bindUniformBlock(this._pipelineContext, e, t)
}
,
i.prototype.setInt = function(e, t) {
return this._pipelineContext.setInt(e, t),
this
}
,
i.prototype.setInt2 = function(e, t, r) {
return this._pipelineContext.setInt2(e, t, r),
this
}
,
i.prototype.setInt3 = function(e, t, r, n) {
return this._pipelineContext.setInt3(e, t, r, n),
this
}
,
i.prototype.setInt4 = function(e, t, r, n, o) {
return this._pipelineContext.setInt4(e, t, r, n, o),
this
}
,
i.prototype.setIntArray = function(e, t) {
return this._pipelineContext.setIntArray(e, t),
this
}
,
i.prototype.setIntArray2 = function(e, t) {
return this._pipelineContext.setIntArray2(e, t),
this
}
,
i.prototype.setIntArray3 = function(e, t) {
return this._pipelineContext.setIntArray3(e, t),
this
}
,
i.prototype.setIntArray4 = function(e, t) {
return this._pipelineContext.setIntArray4(e, t),
this
}
,
i.prototype.setFloatArray = function(e, t) {
return this._pipelineContext.setArray(e, t),
this
}
,
i.prototype.setFloatArray2 = function(e, t) {
return this._pipelineContext.setArray2(e, t),
this
}
,
i.prototype.setFloatArray3 = function(e, t) {
return this._pipelineContext.setArray3(e, t),
this
}
,
i.prototype.setFloatArray4 = function(e, t) {
return this._pipelineContext.setArray4(e, t),
this
}
,
i.prototype.setArray = function(e, t) {
return this._pipelineContext.setArray(e, t),
this
}
,
i.prototype.setArray2 = function(e, t) {
return this._pipelineContext.setArray2(e, t),
this
}
,
i.prototype.setArray3 = function(e, t) {
return this._pipelineContext.setArray3(e, t),
this
}
,
i.prototype.setArray4 = function(e, t) {
return this._pipelineContext.setArray4(e, t),
this
}
,
i.prototype.setMatrices = function(e, t) {
return this._pipelineContext.setMatrices(e, t),
this
}
,
i.prototype.setMatrix = function(e, t) {
return this._pipelineContext.setMatrix(e, t),
this
}
,
i.prototype.setMatrix3x3 = function(e, t) {
return this._pipelineContext.setMatrix3x3(e, t),
this
}
,
i.prototype.setMatrix2x2 = function(e, t) {
return this._pipelineContext.setMatrix2x2(e, t),
this
}
,
i.prototype.setFloat = function(e, t) {
return this._pipelineContext.setFloat(e, t),
this
}
,
i.prototype.setBool = function(e, t) {
return this._pipelineContext.setInt(e, t ? 1 : 0),
this
}
,
i.prototype.setVector2 = function(e, t) {
return this._pipelineContext.setVector2(e, t),
this
}
,
i.prototype.setFloat2 = function(e, t, r) {
return this._pipelineContext.setFloat2(e, t, r),
this
}
,
i.prototype.setVector3 = function(e, t) {
return this._pipelineContext.setVector3(e, t),
this
}
,
i.prototype.setFloat3 = function(e, t, r, n) {
return this._pipelineContext.setFloat3(e, t, r, n),
this
}
,
i.prototype.setVector4 = function(e, t) {
return this._pipelineContext.setVector4(e, t),
this
}
,
i.prototype.setFloat4 = function(e, t, r, n, o) {
return this._pipelineContext.setFloat4(e, t, r, n, o),
this
}
,
i.prototype.setColor3 = function(e, t) {
return this._pipelineContext.setColor3(e, t),
this
}
,
i.prototype.setColor4 = function(e, t, r) {
return this._pipelineContext.setColor4(e, t, r),
this
}
,
i.prototype.setDirectColor4 = function(e, t) {
return this._pipelineContext.setDirectColor4(e, t),
this
}
,
i.prototype.dispose = function() {
this._pipelineContext && this._pipelineContext.dispose(),
this._engine._releaseEffect(this)
}
,
i.RegisterShader = function(e, t, r, n) {
n === void 0 && (n = ShaderLanguage.GLSL),
t && (ShaderStore.GetShadersStore(n)[e + "PixelShader"] = t),
r && (ShaderStore.GetShadersStore(n)[e + "VertexShader"] = r)
}
,
i.ResetCache = function() {
i._baseCache = {}
}
,
i.LogShaderCodeOnCompilationError = !0,
i._uniqueIdSeed = 0,
i._baseCache = {},
i.ShadersStore = ShaderStore.ShadersStore,
i.IncludesShadersStore = ShaderStore.IncludesShadersStore,
i
}(), DepthCullingState = function() {
function i(e) {
e === void 0 && (e = !0),
this._isDepthTestDirty = !1,
this._isDepthMaskDirty = !1,
this._isDepthFuncDirty = !1,
this._isCullFaceDirty = !1,
this._isCullDirty = !1,
this._isZOffsetDirty = !1,
this._isFrontFaceDirty = !1,
e && this.reset()
}
return Object.defineProperty(i.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(i.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(i.prototype, "zOffsetUnits", {
get: function() {
return this._zOffsetUnits
},
set: function(e) {
this._zOffsetUnits !== e && (this._zOffsetUnits = e,
this._isZOffsetDirty = !0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.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(i.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(i.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(i.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(i.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(i.prototype, "frontFace", {
get: function() {
return this._frontFace
},
set: function(e) {
this._frontFace !== e && (this._frontFace = e,
this._isFrontFaceDirty = !0)
},
enumerable: !1,
configurable: !0
}),
i.prototype.reset = function() {
this._depthMask = !0,
this._depthTest = !0,
this._depthFunc = null,
this._cullFace = null,
this._cull = null,
this._zOffset = 0,
this._zOffsetUnits = 0,
this._frontFace = null,
this._isDepthTestDirty = !0,
this._isDepthMaskDirty = !0,
this._isDepthFuncDirty = !1,
this._isCullFaceDirty = !1,
this._isCullDirty = !1,
this._isZOffsetDirty = !0,
this._isFrontFaceDirty = !1
}
,
i.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 || this.zOffsetUnits ? (e.enable(e.POLYGON_OFFSET_FILL),
e.polygonOffset(this.zOffset, this.zOffsetUnits)) : e.disable(e.POLYGON_OFFSET_FILL),
this._isZOffsetDirty = !1),
this._isFrontFaceDirty && (e.frontFace(this.frontFace),
this._isFrontFaceDirty = !1))
}
,
i
}(), StencilState = function() {
function i() {
this.reset()
}
return i.prototype.reset = function() {
this.enabled = !1,
this.mask = 255,
this.func = i.ALWAYS,
this.funcRef = 1,
this.funcMask = 255,
this.opStencilFail = i.KEEP,
this.opDepthFail = i.KEEP,
this.opStencilDepthPass = i.REPLACE
}
,
Object.defineProperty(i.prototype, "stencilFunc", {
get: function() {
return this.func
},
set: function(e) {
this.func = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "stencilFuncRef", {
get: function() {
return this.funcRef
},
set: function(e) {
this.funcRef = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "stencilFuncMask", {
get: function() {
return this.funcMask
},
set: function(e) {
this.funcMask = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "stencilOpStencilFail", {
get: function() {
return this.opStencilFail
},
set: function(e) {
this.opStencilFail = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "stencilOpDepthFail", {
get: function() {
return this.opDepthFail
},
set: function(e) {
this.opDepthFail = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "stencilOpStencilDepthPass", {
get: function() {
return this.opStencilDepthPass
},
set: function(e) {
this.opStencilDepthPass = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "stencilMask", {
get: function() {
return this.mask
},
set: function(e) {
this.mask = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "stencilTest", {
get: function() {
return this.enabled
},
set: function(e) {
this.enabled = e
},
enumerable: !1,
configurable: !0
}),
i.ALWAYS = 519,
i.KEEP = 7680,
i.REPLACE = 7681,
i
}(), AlphaState = function() {
function i() {
this._blendFunctionParameters = new Array(4),
this._blendEquationParameters = new Array(2),
this._blendConstants = new Array(4),
this._isBlendConstantsDirty = !1,
this._alphaBlend = !1,
this._isAlphaBlendDirty = !1,
this._isBlendFunctionParametersDirty = !1,
this._isBlendEquationParametersDirty = !1,
this.reset()
}
return Object.defineProperty(i.prototype, "isDirty", {
get: function() {
return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty || this._isBlendEquationParametersDirty
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "alphaBlend", {
get: function() {
return this._alphaBlend
},
set: function(e) {
this._alphaBlend !== e && (this._alphaBlend = e,
this._isAlphaBlendDirty = !0)
},
enumerable: !1,
configurable: !0
}),
i.prototype.setAlphaBlendConstants = function(e, t, r, n) {
this._blendConstants[0] === e && this._blendConstants[1] === t && this._blendConstants[2] === r && this._blendConstants[3] === n || (this._blendConstants[0] = e,
this._blendConstants[1] = t,
this._blendConstants[2] = r,
this._blendConstants[3] = n,
this._isBlendConstantsDirty = !0)
}
,
i.prototype.setAlphaBlendFunctionParameters = function(e, t, r, n) {
this._blendFunctionParameters[0] === e && this._blendFunctionParameters[1] === t && this._blendFunctionParameters[2] === r && this._blendFunctionParameters[3] === n || (this._blendFunctionParameters[0] = e,
this._blendFunctionParameters[1] = t,
this._blendFunctionParameters[2] = r,
this._blendFunctionParameters[3] = n,
this._isBlendFunctionParametersDirty = !0)
}
,
i.prototype.setAlphaEquationParameters = function(e, t) {
this._blendEquationParameters[0] === e && this._blendEquationParameters[1] === t || (this._blendEquationParameters[0] = e,
this._blendEquationParameters[1] = t,
this._isBlendEquationParametersDirty = !0)
}
,
i.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
}
,
i.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))
}
,
i
}(), TextureSampler = function() {
function i() {
this.samplingMode = -1,
this._useMipMaps = !0,
this._cachedWrapU = null,
this._cachedWrapV = null,
this._cachedWrapR = null,
this._cachedAnisotropicFilteringLevel = null,
this._comparisonFunction = 0
}
return Object.defineProperty(i.prototype, "wrapU", {
get: function() {
return this._cachedWrapU
},
set: function(e) {
this._cachedWrapU = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "wrapV", {
get: function() {
return this._cachedWrapV
},
set: function(e) {
this._cachedWrapV = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "wrapR", {
get: function() {
return this._cachedWrapR
},
set: function(e) {
this._cachedWrapR = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "anisotropicFilteringLevel", {
get: function() {
return this._cachedAnisotropicFilteringLevel
},
set: function(e) {
this._cachedAnisotropicFilteringLevel = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "comparisonFunction", {
get: function() {
return this._comparisonFunction
},
set: function(e) {
this._comparisonFunction = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "useMipMaps", {
get: function() {
return this._useMipMaps
},
set: function(e) {
this._useMipMaps = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.setParameters = function(e, t, r, n, o, a) {
return e === void 0 && (e = 1),
t === void 0 && (t = 1),
r === void 0 && (r = 1),
n === void 0 && (n = 1),
o === void 0 && (o = 2),
a === void 0 && (a = 0),
this._cachedWrapU = e,
this._cachedWrapV = t,
this._cachedWrapR = r,
this._cachedAnisotropicFilteringLevel = n,
this.samplingMode = o,
this._comparisonFunction = a,
this
}
,
i.prototype.compareSampler = function(e) {
return this._cachedWrapU === e._cachedWrapU && this._cachedWrapV === e._cachedWrapV && this._cachedWrapR === e._cachedWrapR && this._cachedAnisotropicFilteringLevel === e._cachedAnisotropicFilteringLevel && this.samplingMode === e.samplingMode && this._comparisonFunction === e._comparisonFunction && this._useMipMaps === e._useMipMaps
}
,
i
}(), InternalTextureSource;
(function(i) {
i[i.Unknown = 0] = "Unknown",
i[i.Url = 1] = "Url",
i[i.Temp = 2] = "Temp",
i[i.Raw = 3] = "Raw",
i[i.Dynamic = 4] = "Dynamic",
i[i.RenderTarget = 5] = "RenderTarget",
i[i.MultiRenderTarget = 6] = "MultiRenderTarget",
i[i.Cube = 7] = "Cube",
i[i.CubeRaw = 8] = "CubeRaw",
i[i.CubePrefiltered = 9] = "CubePrefiltered",
i[i.Raw3D = 10] = "Raw3D",
i[i.Raw2DArray = 11] = "Raw2DArray",
i[i.DepthStencil = 12] = "DepthStencil",
i[i.CubeRawRGBD = 13] = "CubeRawRGBD",
i[i.Depth = 14] = "Depth"
}
)(InternalTextureSource || (InternalTextureSource = {}));
var InternalTexture = function(i) {
__extends(e, i);
function e(t, r, n) {
n === void 0 && (n = !1);
var o = i.call(this) || this;
return o.isReady = !1,
o.isCube = !1,
o.is3D = !1,
o.is2DArray = !1,
o.isMultiview = !1,
o.url = "",
o.generateMipMaps = !1,
o.samples = 0,
o.type = -1,
o.format = -1,
o.onLoadedObservable = new Observable,
o.onErrorObservable = new Observable,
o.onRebuildCallback = null,
o.width = 0,
o.height = 0,
o.depth = 0,
o.baseWidth = 0,
o.baseHeight = 0,
o.baseDepth = 0,
o.invertY = !1,
o._invertVScale = !1,
o._associatedChannel = -1,
o._source = InternalTextureSource.Unknown,
o._buffer = null,
o._bufferView = null,
o._bufferViewArray = null,
o._bufferViewArrayArray = null,
o._size = 0,
o._extension = "",
o._files = null,
o._workingCanvas = null,
o._workingContext = null,
o._cachedCoordinatesMode = null,
o._isDisabled = !1,
o._compression = null,
o._sphericalPolynomial = null,
o._sphericalPolynomialPromise = null,
o._sphericalPolynomialComputed = !1,
o._lodGenerationScale = 0,
o._lodGenerationOffset = 0,
o._useSRGBBuffer = !1,
o._lodTextureHigh = null,
o._lodTextureMid = null,
o._lodTextureLow = null,
o._isRGBD = !1,
o._linearSpecularLOD = !1,
o._irradianceTexture = null,
o._hardwareTexture = null,
o._references = 1,
o._gammaSpace = null,
o._engine = t,
o._source = r,
o._uniqueId = e._Counter++,
n || (o._hardwareTexture = t._createHardwareTexture()),
o
}
return Object.defineProperty(e.prototype, "useMipMaps", {
get: function() {
return this.generateMipMaps
},
set: function(t) {
this.generateMipMaps = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "uniqueId", {
get: function() {
return this._uniqueId
},
enumerable: !1,
configurable: !0
}),
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(t, r, n) {
n === void 0 && (n = 1),
this._engine.updateTextureDimensions(this, t, r, n),
this.width = t,
this.height = r,
this.depth = n,
this.baseWidth = t,
this.baseHeight = r,
this.baseDepth = n,
this._size = t * r * n
}
,
e.prototype._rebuild = function() {
var t = this, r;
if (this.isReady = !1,
this._cachedCoordinatesMode = null,
this._cachedWrapU = null,
this._cachedWrapV = null,
this._cachedWrapR = null,
this._cachedAnisotropicFilteringLevel = null,
this.onRebuildCallback) {
var n = this.onRebuildCallback(this)
, o = function(s) {
s._swapAndDie(t, !1),
t.isReady = n.isReady
};
n.isAsync ? n.proxy.then(o) : o(n.proxy);
return
}
var a;
switch (this.source) {
case InternalTextureSource.Temp:
break;
case InternalTextureSource.Url:
a = this._engine.createTexture((r = this._originalUrl) !== null && r !== void 0 ? r : this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function() {
a._swapAndDie(t, !1),
t.isReady = !0
}, null, this._buffer, void 0, this.format, this._extension, void 0, void 0, void 0, this._useSRGBBuffer);
return;
case InternalTextureSource.Raw:
a = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type),
a._swapAndDie(this, !1),
this.isReady = !0;
break;
case InternalTextureSource.Raw3D:
a = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type),
a._swapAndDie(this, !1),
this.isReady = !0;
break;
case InternalTextureSource.Raw2DArray:
a = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type),
a._swapAndDie(this, !1),
this.isReady = !0;
break;
case InternalTextureSource.Dynamic:
a = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode),
a._swapAndDie(this, !1),
this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, void 0, void 0, !0);
break;
case InternalTextureSource.Cube:
a = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function() {
a._swapAndDie(t, !1),
t.isReady = !0
}, null, this.format, this._extension, !1, 0, 0, null, void 0, this._useSRGBBuffer);
return;
case InternalTextureSource.CubeRaw:
a = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression),
a._swapAndDie(this, !1),
this.isReady = !0;
break;
case InternalTextureSource.CubeRawRGBD:
return;
case InternalTextureSource.CubePrefiltered:
a = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function(s) {
s && s._swapAndDie(t, !1),
t.isReady = !0
}, null, this.format, this._extension),
a._sphericalPolynomial = this._sphericalPolynomial;
return
}
}
,
e.prototype._swapAndDie = function(t, r) {
var n;
r === void 0 && (r = !0),
(n = this._hardwareTexture) === null || n === void 0 || n.setUsage(t._source, this.generateMipMaps, this.isCube, this.width, this.height),
t._hardwareTexture = this._hardwareTexture,
r && (t._isRGBD = this._isRGBD),
this._lodTextureHigh && (t._lodTextureHigh && t._lodTextureHigh.dispose(),
t._lodTextureHigh = this._lodTextureHigh),
this._lodTextureMid && (t._lodTextureMid && t._lodTextureMid.dispose(),
t._lodTextureMid = this._lodTextureMid),
this._lodTextureLow && (t._lodTextureLow && t._lodTextureLow.dispose(),
t._lodTextureLow = this._lodTextureLow),
this._irradianceTexture && (t._irradianceTexture && t._irradianceTexture.dispose(),
t._irradianceTexture = this._irradianceTexture);
var o = this._engine.getLoadedTexturesCache()
, a = o.indexOf(this);
a !== -1 && o.splice(a, 1);
var a = o.indexOf(t);
a === -1 && o.push(t)
}
,
e.prototype.dispose = function() {
this._references--,
this.onLoadedObservable.clear(),
this.onErrorObservable.clear(),
this._references === 0 && (this._engine._releaseTexture(this),
this._hardwareTexture = null)
}
,
e._Counter = 0,
e
}(TextureSampler), WebGLShaderProcessor = function() {
function i() {
this.shaderLanguage = ShaderLanguage.GLSL
}
return i.prototype.postProcessor = function(e, t, r, n, o) {
if (!o.getCaps().drawBuffersExtension) {
var a = /#extension.+GL_EXT_draw_buffers.+(enable|require)/g;
e = e.replace(a, "")
}
return e
}
,
i
}(), WebGL2ShaderProcessor = function() {
function i() {
this.shaderLanguage = ShaderLanguage.GLSL
}
return i.prototype.attributeProcessor = function(e) {
return e.replace("attribute", "in")
}
,
i.prototype.varyingProcessor = function(e, t) {
return e.replace("varying", t ? "in" : "out")
}
,
i.prototype.postProcessor = function(e, t, r, n, o) {
var a = e.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1
, s = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
if (e = e.replace(s, ""),
e = e.replace(/texture2D\s*\(/g, "texture("),
r)
e = e.replace(/texture2DLodEXT\s*\(/g, "textureLod("),
e = e.replace(/textureCubeLodEXT\s*\(/g, "textureLod("),
e = e.replace(/textureCube\s*\(/g, "texture("),
e = e.replace(/gl_FragDepthEXT/g, "gl_FragDepth"),
e = e.replace(/gl_FragColor/g, "glFragColor"),
e = e.replace(/gl_FragData/g, "glFragData"),
e = e.replace(/void\s+?main\s*\(/g, (a ? "" : `out vec4 glFragColor;
`) + "void main(");
else {
var l = t.indexOf("#define MULTIVIEW") !== -1;
if (l)
return `#extension GL_OVR_multiview2 : require
layout (num_views = 2) in;
` + e
}
return e
}
,
i
}(), DataBuffer = function() {
function i() {
this.references = 0,
this.capacity = 0,
this.is32Bits = !1,
this.uniqueId = i._Counter++
}
return Object.defineProperty(i.prototype, "underlyingResource", {
get: function() {
return null
},
enumerable: !1,
configurable: !0
}),
i._Counter = 0,
i
}(), WebGLDataBuffer = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this) || this;
return r._buffer = t,
r
}
return Object.defineProperty(e.prototype, "underlyingResource", {
get: function() {
return this._buffer
},
enumerable: !1,
configurable: !0
}),
e
}(DataBuffer), WebGLPipelineContext = function() {
function i() {
this._valueCache = {},
this.vertexCompilationError = null,
this.fragmentCompilationError = null,
this.programLinkError = null,
this.programValidationError = null
}
return Object.defineProperty(i.prototype, "isAsync", {
get: function() {
return this.isParallelCompiled
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isReady", {
get: function() {
return this.program ? this.isParallelCompiled ? this.engine._isRenderingStateCompiled(this) : !0 : !1
},
enumerable: !1,
configurable: !0
}),
i.prototype._handlesSpectorRebuildCallback = function(e) {
e && this.program && e(this.program)
}
,
i.prototype._fillEffectInformation = function(e, t, r, n, o, a, s, l) {
var u = this.engine;
if (u.supportsUniformBuffers)
for (var c in t)
e.bindUniformBlock(c, t[c]);
var h = this.engine.getUniforms(this, r);
h.forEach(function(v, y) {
n[r[y]] = v
}),
this._uniforms = n;
var f;
for (f = 0; f < o.length; f++) {
var d = e.getUniform(o[f]);
d == null && (o.splice(f, 1),
f--)
}
o.forEach(function(v, y) {
a[v] = y
});
for (var _ = 0, g = u.getAttributes(this, s); _ < g.length; _++) {
var m = g[_];
l.push(m)
}
}
,
i.prototype.dispose = function() {
this._uniforms = {}
}
,
i.prototype._cacheMatrix = function(e, t) {
var r = this._valueCache[e]
, n = t.updateFlag;
return r !== void 0 && r === n ? !1 : (this._valueCache[e] = n,
!0)
}
,
i.prototype._cacheFloat2 = function(e, t, r) {
var n = this._valueCache[e];
if (!n || n.length !== 2)
return n = [t, r],
this._valueCache[e] = n,
!0;
var o = !1;
return n[0] !== t && (n[0] = t,
o = !0),
n[1] !== r && (n[1] = r,
o = !0),
o
}
,
i.prototype._cacheFloat3 = function(e, t, r, n) {
var o = this._valueCache[e];
if (!o || o.length !== 3)
return o = [t, r, n],
this._valueCache[e] = o,
!0;
var a = !1;
return o[0] !== t && (o[0] = t,
a = !0),
o[1] !== r && (o[1] = r,
a = !0),
o[2] !== n && (o[2] = n,
a = !0),
a
}
,
i.prototype._cacheFloat4 = function(e, t, r, n, o) {
var a = this._valueCache[e];
if (!a || a.length !== 4)
return a = [t, r, n, o],
this._valueCache[e] = a,
!0;
var s = !1;
return a[0] !== t && (a[0] = t,
s = !0),
a[1] !== r && (a[1] = r,
s = !0),
a[2] !== n && (a[2] = n,
s = !0),
a[3] !== o && (a[3] = o,
s = !0),
s
}
,
i.prototype.setInt = function(e, t) {
var r = this._valueCache[e];
r !== void 0 && r === t || this.engine.setInt(this._uniforms[e], t) && (this._valueCache[e] = t)
}
,
i.prototype.setInt2 = function(e, t, r) {
this._cacheFloat2(e, t, r) && (this.engine.setInt2(this._uniforms[e], t, r) || (this._valueCache[e] = null))
}
,
i.prototype.setInt3 = function(e, t, r, n) {
this._cacheFloat3(e, t, r, n) && (this.engine.setInt3(this._uniforms[e], t, r, n) || (this._valueCache[e] = null))
}
,
i.prototype.setInt4 = function(e, t, r, n, o) {
this._cacheFloat4(e, t, r, n, o) && (this.engine.setInt4(this._uniforms[e], t, r, n, o) || (this._valueCache[e] = null))
}
,
i.prototype.setIntArray = function(e, t) {
this._valueCache[e] = null,
this.engine.setIntArray(this._uniforms[e], t)
}
,
i.prototype.setIntArray2 = function(e, t) {
this._valueCache[e] = null,
this.engine.setIntArray2(this._uniforms[e], t)
}
,
i.prototype.setIntArray3 = function(e, t) {
this._valueCache[e] = null,
this.engine.setIntArray3(this._uniforms[e], t)
}
,
i.prototype.setIntArray4 = function(e, t) {
this._valueCache[e] = null,
this.engine.setIntArray4(this._uniforms[e], t)
}
,
i.prototype.setArray = function(e, t) {
this._valueCache[e] = null,
this.engine.setArray(this._uniforms[e], t)
}
,
i.prototype.setArray2 = function(e, t) {
this._valueCache[e] = null,
this.engine.setArray2(this._uniforms[e], t)
}
,
i.prototype.setArray3 = function(e, t) {
this._valueCache[e] = null,
this.engine.setArray3(this._uniforms[e], t)
}
,
i.prototype.setArray4 = function(e, t) {
this._valueCache[e] = null,
this.engine.setArray4(this._uniforms[e], t)
}
,
i.prototype.setMatrices = function(e, t) {
!t || (this._valueCache[e] = null,
this.engine.setMatrices(this._uniforms[e], t))
}
,
i.prototype.setMatrix = function(e, t) {
this._cacheMatrix(e, t) && (this.engine.setMatrices(this._uniforms[e], t.toArray()) || (this._valueCache[e] = null))
}
,
i.prototype.setMatrix3x3 = function(e, t) {
this._valueCache[e] = null,
this.engine.setMatrix3x3(this._uniforms[e], t)
}
,
i.prototype.setMatrix2x2 = function(e, t) {
this._valueCache[e] = null,
this.engine.setMatrix2x2(this._uniforms[e], t)
}
,
i.prototype.setFloat = function(e, t) {
var r = this._valueCache[e];
r !== void 0 && r === t || this.engine.setFloat(this._uniforms[e], t) && (this._valueCache[e] = t)
}
,
i.prototype.setVector2 = function(e, t) {
this._cacheFloat2(e, t.x, t.y) && (this.engine.setFloat2(this._uniforms[e], t.x, t.y) || (this._valueCache[e] = null))
}
,
i.prototype.setFloat2 = function(e, t, r) {
this._cacheFloat2(e, t, r) && (this.engine.setFloat2(this._uniforms[e], t, r) || (this._valueCache[e] = null))
}
,
i.prototype.setVector3 = function(e, t) {
this._cacheFloat3(e, t.x, t.y, t.z) && (this.engine.setFloat3(this._uniforms[e], t.x, t.y, t.z) || (this._valueCache[e] = null))
}
,
i.prototype.setFloat3 = function(e, t, r, n) {
this._cacheFloat3(e, t, r, n) && (this.engine.setFloat3(this._uniforms[e], t, r, n) || (this._valueCache[e] = null))
}
,
i.prototype.setVector4 = function(e, t) {
this._cacheFloat4(e, t.x, t.y, t.z, t.w) && (this.engine.setFloat4(this._uniforms[e], t.x, t.y, t.z, t.w) || (this._valueCache[e] = null))
}
,
i.prototype.setFloat4 = function(e, t, r, n, o) {
this._cacheFloat4(e, t, r, n, o) && (this.engine.setFloat4(this._uniforms[e], t, r, n, o) || (this._valueCache[e] = null))
}
,
i.prototype.setColor3 = function(e, t) {
this._cacheFloat3(e, t.r, t.g, t.b) && (this.engine.setFloat3(this._uniforms[e], t.r, t.g, t.b) || (this._valueCache[e] = null))
}
,
i.prototype.setColor4 = function(e, t, r) {
this._cacheFloat4(e, t.r, t.g, t.b, r) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, r) || (this._valueCache[e] = null))
}
,
i.prototype.setDirectColor4 = function(e, t) {
this._cacheFloat4(e, t.r, t.g, t.b, t.a) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, t.a) || (this._valueCache[e] = null))
}
,
i.prototype._getVertexShaderCode = function() {
return this.vertexShader ? this.engine._getShaderSource(this.vertexShader) : null
}
,
i.prototype._getFragmentShaderCode = function() {
return this.fragmentShader ? this.engine._getShaderSource(this.fragmentShader) : null
}
,
i
}(), PerformanceConfigurator = function() {
function i() {}
return i.SetMatrixPrecision = function(e) {
if (i.MatrixTrackPrecisionChange = !1,
e && !i.MatrixUse64Bits && i.MatrixTrackedMatrices)
for (var t = 0; t < i.MatrixTrackedMatrices.length; ++t) {
var r = i.MatrixTrackedMatrices[t]
, n = r._m;
r._m = new Array(16);
for (var o = 0; o < 16; ++o)
r._m[o] = n[o]
}
i.MatrixUse64Bits = e,
i.MatrixCurrentType = i.MatrixUse64Bits ? Array : Float32Array,
i.MatrixTrackedMatrices = null
}
,
i.MatrixUse64Bits = !1,
i.MatrixTrackPrecisionChange = !0,
i.MatrixCurrentType = Float32Array,
i.MatrixTrackedMatrices = [],
i
}(), WebGLHardwareTexture = function() {
function i(e, t) {
if (e === void 0 && (e = null),
this._MSAARenderBuffer = null,
this._context = t,
!e && (e = t.createTexture(),
!e))
throw new Error("Unable to create webGL texture");
this.set(e)
}
return Object.defineProperty(i.prototype, "underlyingResource", {
get: function() {
return this._webGLTexture
},
enumerable: !1,
configurable: !0
}),
i.prototype.setUsage = function(e, t, r, n, o) {}
,
i.prototype.set = function(e) {
this._webGLTexture = e
}
,
i.prototype.reset = function() {
this._webGLTexture = null,
this._MSAARenderBuffer = null
}
,
i.prototype.release = function() {
this._MSAARenderBuffer && (this._context.deleteRenderbuffer(this._MSAARenderBuffer),
this._MSAARenderBuffer = null),
this._webGLTexture && this._context.deleteTexture(this._webGLTexture),
this.reset()
}
,
i
}(), DrawWrapper = function() {
function i(e, t) {
t === void 0 && (t = !0),
this.effect = null,
this.defines = null,
this.drawContext = e.createDrawContext(),
t && (this.materialContext = e.createMaterialContext())
}
return i.IsWrapper = function(e) {
return e.getPipelineContext === void 0
}
,
i.GetEffect = function(e) {
return e.getPipelineContext === void 0 ? e.effect : e
}
,
i.prototype.setEffect = function(e, t, r) {
var n;
r === void 0 && (r = !0),
this.effect = e,
t !== void 0 && (this.defines = t),
r && ((n = this.drawContext) === null || n === void 0 || n.reset())
}
,
i.prototype.dispose = function() {
var e;
(e = this.drawContext) === null || e === void 0 || e.dispose()
}
,
i
}(), StencilStateComposer = function() {
function i(e) {
e === void 0 && (e = !0),
this._isStencilTestDirty = !1,
this._isStencilMaskDirty = !1,
this._isStencilFuncDirty = !1,
this._isStencilOpDirty = !1,
this.useStencilGlobalOnly = !1,
e && this.reset()
}
return Object.defineProperty(i.prototype, "isDirty", {
get: function() {
return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "func", {
get: function() {
return this._func
},
set: function(e) {
this._func !== e && (this._func = e,
this._isStencilFuncDirty = !0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "funcRef", {
get: function() {
return this._funcRef
},
set: function(e) {
this._funcRef !== e && (this._funcRef = e,
this._isStencilFuncDirty = !0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "funcMask", {
get: function() {
return this._funcMask
},
set: function(e) {
this._funcMask !== e && (this._funcMask = e,
this._isStencilFuncDirty = !0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "opStencilFail", {
get: function() {
return this._opStencilFail
},
set: function(e) {
this._opStencilFail !== e && (this._opStencilFail = e,
this._isStencilOpDirty = !0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "opDepthFail", {
get: function() {
return this._opDepthFail
},
set: function(e) {
this._opDepthFail !== e && (this._opDepthFail = e,
this._isStencilOpDirty = !0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "opStencilDepthPass", {
get: function() {
return this._opStencilDepthPass
},
set: function(e) {
this._opStencilDepthPass !== e && (this._opStencilDepthPass = e,
this._isStencilOpDirty = !0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "mask", {
get: function() {
return this._mask
},
set: function(e) {
this._mask !== e && (this._mask = e,
this._isStencilMaskDirty = !0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "enabled", {
get: function() {
return this._enabled
},
set: function(e) {
this._enabled !== e && (this._enabled = e,
this._isStencilTestDirty = !0)
},
enumerable: !1,
configurable: !0
}),
i.prototype.reset = function() {
var e;
this.stencilMaterial = void 0,
(e = this.stencilGlobal) === null || e === void 0 || e.reset(),
this._isStencilTestDirty = !0,
this._isStencilMaskDirty = !0,
this._isStencilFuncDirty = !0,
this._isStencilOpDirty = !0
}
,
i.prototype.apply = function(e) {
var t;
if (!!e) {
var r = !this.useStencilGlobalOnly && !!(!((t = this.stencilMaterial) === null || t === void 0) && t.enabled);
this.enabled = r ? this.stencilMaterial.enabled : this.stencilGlobal.enabled,
this.func = r ? this.stencilMaterial.func : this.stencilGlobal.func,
this.funcRef = r ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef,
this.funcMask = r ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask,
this.opStencilFail = r ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail,
this.opDepthFail = r ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail,
this.opStencilDepthPass = r ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass,
this.mask = r ? this.stencilMaterial.mask : this.stencilGlobal.mask,
this.isDirty && (this._isStencilTestDirty && (this.enabled ? e.enable(e.STENCIL_TEST) : e.disable(e.STENCIL_TEST),
this._isStencilTestDirty = !1),
this._isStencilMaskDirty && (e.stencilMask(this.mask),
this._isStencilMaskDirty = !1),
this._isStencilFuncDirty && (e.stencilFunc(this.func, this.funcRef, this.funcMask),
this._isStencilFuncDirty = !1),
this._isStencilOpDirty && (e.stencilOp(this.opStencilFail, this.opDepthFail, this.opStencilDepthPass),
this._isStencilOpDirty = !1))
}
}
,
i
}(), BufferPointer = function() {
function i() {}
return i
}(), ThinEngine = function() {
function i(e, t, r, n) {
var o = this;
this.forcePOTTextures = !1,
this.isFullscreen = !1,
this.cullBackFaces = null,
this.renderEvenInBackground = !0,
this.preventCacheWipeBetweenFrames = !1,
this.validateShaderPrograms = !1,
this._useReverseDepthBuffer = !1,
this.isNDCHalfZRange = !1,
this.hasOriginBottomLeft = !0,
this.disableUniformBuffers = !1,
this.onDisposeObservable = new Observable,
this._frameId = 0,
this._uniformBuffers = new Array,
this._storageBuffers = new Array,
this._webGLVersion = 1,
this._windowIsBackground = !1,
this._highPrecisionShadersAllowed = !0,
this._badOS = !1,
this._badDesktopOS = !1,
this._renderingQueueLaunched = !1,
this._activeRenderLoops = new Array,
this.onContextLostObservable = new Observable,
this.onContextRestoredObservable = new Observable,
this._contextWasLost = !1,
this._doNotHandleContextLost = !1,
this.disableVertexArrayObjects = !1,
this._colorWrite = !0,
this._colorWriteChanged = !0,
this._depthCullingState = new DepthCullingState,
this._stencilStateComposer = new StencilStateComposer,
this._stencilState = new StencilState,
this._alphaState = new AlphaState,
this._alphaMode = 1,
this._alphaEquation = 0,
this._internalTexturesCache = new Array,
this._renderTargetWrapperCache = new Array,
this._activeChannel = 0,
this._currentTextureChannel = -1,
this._boundTexturesCache = {},
this._compiledEffects = {},
this._vertexAttribArraysEnabled = [],
this._uintIndicesCurrentlySet = !1,
this._currentBoundBuffer = new Array,
this._currentFramebuffer = null,
this._dummyFramebuffer = null,
this._currentBufferPointers = new Array,
this._currentInstanceLocations = new Array,
this._currentInstanceBuffers = new Array,
this._vaoRecordInProgress = !1,
this._mustWipeVertexAttributes = !1,
this._nextFreeTextureSlots = new Array,
this._maxSimultaneousTextures = 0,
this._activeRequests = new Array,
this._transformTextureUrl = null,
this.hostInformation = {
isMobile: !1
},
this.premultipliedAlpha = !0,
this.onBeforeTextureInitObservable = new Observable,
this._isWebGPU = !1,
this._snapshotRenderingMode = 0,
this._viewportCached = {
x: 0,
y: 0,
z: 0,
w: 0
},
this._unpackFlipYCached = null,
this.enableUnpackFlipYCached = !0,
this._boundUniforms = {};
var a = null;
if (r = r || {},
this._stencilStateComposer.stencilGlobal = this._stencilState,
PerformanceConfigurator.SetMatrixPrecision(!!r.useHighPrecisionMatrix),
!!e) {
if (n = n || r.adaptToDeviceRatio || !1,
e.getContext) {
if (a = e,
this._renderingCanvas = a,
t !== void 0 && (r.antialias = t),
r.deterministicLockstep === void 0 && (r.deterministicLockstep = !1),
r.lockstepMaxSteps === void 0 && (r.lockstepMaxSteps = 4),
r.timeStep === void 0 && (r.timeStep = 1 / 60),
r.preserveDrawingBuffer === void 0 && (r.preserveDrawingBuffer = !1),
r.audioEngine === void 0 && (r.audioEngine = !0),
r.audioEngineOptions !== void 0 && r.audioEngineOptions.audioContext !== void 0 && (this._audioContext = r.audioEngineOptions.audioContext),
r.audioEngineOptions !== void 0 && r.audioEngineOptions.audioDestination !== void 0 && (this._audioDestination = r.audioEngineOptions.audioDestination),
r.stencil === void 0 && (r.stencil = !0),
r.premultipliedAlpha === !1 && (this.premultipliedAlpha = !1),
r.xrCompatible === void 0 && (r.xrCompatible = !0),
this._doNotHandleContextLost = !!r.doNotHandleContextLost,
navigator && navigator.userAgent) {
this._checkForMobile = function() {
var x = navigator.userAgent;
o.hostInformation.isMobile = x.indexOf("Mobile") !== -1 || x.indexOf("Mac") !== -1 && IsDocumentAvailable() && "ontouchend"in document
}
,
this._checkForMobile(),
IsWindowObjectExist() && window.addEventListener("resize", this._checkForMobile);
for (var s = navigator.userAgent, l = 0, u = i.ExceptionList; l < u.length; l++) {
var c = u[l]
, h = c.key
, f = c.targets
, d = new RegExp(h);
if (d.test(s)) {
if (c.capture && c.captureConstraint) {
var _ = c.capture
, g = c.captureConstraint
, m = new RegExp(_)
, v = m.exec(s);
if (v && v.length > 0) {
var y = parseInt(v[v.length - 1]);
if (y >= g)
continue
}
}
for (var b = 0, T = f; b < T.length; b++) {
var C = T[b];
switch (C) {
case "uniformBuffer":
this.disableUniformBuffers = !0;
break;
case "vao":
this.disableVertexArrayObjects = !0;
break
}
}
}
}
}
if (this._doNotHandleContextLost || (this._onContextLost = function(x) {
x.preventDefault(),
o._contextWasLost = !0,
Logger$2.Warn("WebGL context lost."),
o.onContextLostObservable.notifyObservers(o)
}
,
this._onContextRestored = function() {
o._restoreEngineAfterContextLost(o._initGLContext.bind(o))
}
,
a.addEventListener("webglcontextlost", this._onContextLost, !1),
a.addEventListener("webglcontextrestored", this._onContextRestored, !1),
r.powerPreference = "high-performance"),
this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent),
this._badDesktopOS && (r.xrCompatible = !1),
!r.disableWebGL2Support)
try {
this._gl = a.getContext("webgl2", r) || a.getContext("experimental-webgl2", r),
this._gl && (this._webGLVersion = 2,
this._shaderPlatformName = "WEBGL2",
this._gl.deleteQuery || (this._webGLVersion = 1,
this._shaderPlatformName = "WEBGL1"))
} catch {}
if (!this._gl) {
if (!a)
throw new Error("The provided canvas is null or undefined.");
try {
this._gl = a.getContext("webgl", r) || a.getContext("experimental-webgl", r)
} catch {
throw new Error("WebGL not supported")
}
}
if (!this._gl)
throw new Error("WebGL not supported")
} else {
this._gl = e,
this._renderingCanvas = this._gl.canvas,
this._gl.renderbufferStorageMultisample ? (this._webGLVersion = 2,
this._shaderPlatformName = "WEBGL2") : this._shaderPlatformName = "WEBGL1";
var A = this._gl.getContextAttributes();
A && (r.stencil = A.stencil)
}
this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
r.useHighPrecisionFloats !== void 0 && (this._highPrecisionShadersAllowed = r.useHighPrecisionFloats);
var S = IsWindowObjectExist() && window.devicePixelRatio || 1
, P = r.limitDeviceRatio || S;
this._hardwareScalingLevel = n ? 1 / Math.min(P, S) : 1,
this.resize(),
this._isStencilEnable = !!r.stencil,
this._initGLContext(),
this._initFeatures();
for (var R = 0; R < this._caps.maxVertexAttribs; R++)
this._currentBufferPointers[R] = new BufferPointer;
this._shaderProcessor = this.webGLVersion > 1 ? new WebGL2ShaderProcessor : new WebGLShaderProcessor,
this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent),
this._creationOptions = r;
var M = "Babylon.js v" + i.Version;
console.log(M + (" - " + this.description)),
this._renderingCanvas && this._renderingCanvas.setAttribute && this._renderingCanvas.setAttribute("data-engine", M)
}
}
return Object.defineProperty(i, "NpmPackage", {
get: function() {
return "babylonjs@5.0.0-alpha.63"
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "Version", {
get: function() {
return "5.0.0-alpha.63"
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "description", {
get: function() {
var e = this.name + this.webGLVersion;
return this._caps.parallelShaderCompile && (e += " - Parallel shader compilation"),
e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "name", {
get: function() {
return "WebGL"
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "version", {
get: function() {
return this._webGLVersion
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ShadersRepository", {
get: function() {
return Effect.ShadersRepository
},
set: function(e) {
Effect.ShadersRepository = e
},
enumerable: !1,
configurable: !0
}),
i.prototype._getShaderProcessor = function(e) {
return this._shaderProcessor
}
,
Object.defineProperty(i.prototype, "useReverseDepthBuffer", {
get: function() {
return this._useReverseDepthBuffer
},
set: function(e) {
e !== this._useReverseDepthBuffer && (this._useReverseDepthBuffer = e,
e ? this._depthCullingState.depthFunc = 518 : this._depthCullingState.depthFunc = 515)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "frameId", {
get: function() {
return this._frameId
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "supportsUniformBuffers", {
get: function() {
return this.webGLVersion > 1 && !this.disableUniformBuffers
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "_shouldUseHighPrecisionShader", {
get: function() {
return !!(this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "needPOTTextures", {
get: function() {
return this._webGLVersion < 2 || this.forcePOTTextures
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "activeRenderLoops", {
get: function() {
return this._activeRenderLoops
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "doNotHandleContextLost", {
get: function() {
return this._doNotHandleContextLost
},
set: function(e) {
this._doNotHandleContextLost = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "_supportsHardwareTextureRescaling", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "framebufferDimensionsObject", {
set: function(e) {
this._framebufferDimensionsObject = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "currentViewport", {
get: function() {
return this._cachedViewport
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "emptyTexture", {
get: function() {
return this._emptyTexture || (this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, 5, !1, !1, 1)),
this._emptyTexture
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "emptyTexture3D", {
get: function() {
return this._emptyTexture3D || (this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, 5, !1, !1, 1)),
this._emptyTexture3D
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "emptyTexture2DArray", {
get: function() {
return this._emptyTexture2DArray || (this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, 5, !1, !1, 1)),
this._emptyTexture2DArray
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.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, 5, 0, !1, !1, 1)
}
return this._emptyCubeTexture
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isWebGPU", {
get: function() {
return this._isWebGPU
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "shaderPlatformName", {
get: function() {
return this._shaderPlatformName
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "snapshotRendering", {
get: function() {
return !1
},
set: function(e) {},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "snapshotRenderingMode", {
get: function() {
return this._snapshotRenderingMode
},
set: function(e) {
this._snapshotRenderingMode = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.snapshotRenderingReset = function() {
this.snapshotRendering = !1
}
,
i._createCanvas = function(e, t) {
if (typeof document == "undefined")
return new OffscreenCanvas(e,t);
var r = document.createElement("canvas");
return r.width = e,
r.height = t,
r
}
,
i.prototype.createCanvas = function(e, t) {
return i._createCanvas(e, t)
}
,
i.prototype.createCanvasImage = function() {
return document.createElement("img")
}
,
i.prototype._restoreEngineAfterContextLost = function(e) {
var t = this;
setTimeout(function() {
return __awaiter(t, void 0, void 0, function() {
var r, n, o, a, s;
return __generator(this, function(l) {
switch (l.label) {
case 0:
return this._dummyFramebuffer = null,
r = this._depthCullingState.depthTest,
n = this._depthCullingState.depthFunc,
o = this._depthCullingState.depthMask,
a = this._stencilState.stencilTest,
[4, e()];
case 1:
return l.sent(),
this._rebuildEffects(),
(s = this._rebuildComputeEffects) === null || s === void 0 || s.call(this),
this._rebuildInternalTextures(),
this._rebuildRenderTargetWrappers(),
this._rebuildBuffers(),
this.wipeCaches(!0),
this._depthCullingState.depthTest = r,
this._depthCullingState.depthFunc = n,
this._depthCullingState.depthMask = o,
this._stencilState.stencilTest = a,
Logger$2.Warn(this.name + " context successfully restored."),
this.onContextRestoredObservable.notifyObservers(this),
this._contextWasLost = !1,
[2]
}
})
})
}, 0)
}
,
i.prototype._sharedInit = function(e, t, r) {
this._renderingCanvas = e
}
,
i.prototype._getShaderProcessingContext = function(e) {
return null
}
,
i.prototype._rebuildInternalTextures = function() {
for (var e = this._internalTexturesCache.slice(), t = 0, r = e; t < r.length; t++) {
var n = r[t];
n._rebuild()
}
}
,
i.prototype._rebuildRenderTargetWrappers = function() {
for (var e = this._renderTargetWrapperCache.slice(), t = 0, r = e; t < r.length; t++) {
var n = r[t];
n._rebuild()
}
}
,
i.prototype._rebuildEffects = function() {
for (var e in this._compiledEffects) {
var t = this._compiledEffects[e];
t._pipelineContext = null,
t._wasPreviouslyReady = !1,
t._prepareEffect()
}
Effect.ResetCache()
}
,
i.prototype.areAllEffectsReady = function() {
for (var e in this._compiledEffects) {
var t = this._compiledEffects[e];
if (!t.isReady())
return !1
}
return !0
}
,
i.prototype._rebuildBuffers = function() {
for (var e = 0, t = this._uniformBuffers; e < t.length; e++) {
var r = t[e];
r._rebuild()
}
for (var n = 0, o = this._storageBuffers; n < o.length; n++) {
var a = o[n];
a._rebuild()
}
}
,
i.prototype._initGLContext = function() {
this._caps = {
maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),
maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),
maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1,
maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),
maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),
maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),
maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),
maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),
maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),
parallelShaderCompile: this._gl.getExtension("KHR_parallel_shader_compile") || void 0,
standardDerivatives: this._webGLVersion > 1 || this._gl.getExtension("OES_standard_derivatives") !== null,
maxAnisotropy: 1,
astc: this._gl.getExtension("WEBGL_compressed_texture_astc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),
bptc: this._gl.getExtension("EXT_texture_compression_bptc") || this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),
s3tc: this._gl.getExtension("WEBGL_compressed_texture_s3tc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),
s3tc_srgb: this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),
pvrtc: this._gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
etc1: this._gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),
etc2: this._gl.getExtension("WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBGL_compressed_texture_es3_0"),
textureAnisotropicFilterExtension: this._gl.getExtension("EXT_texture_filter_anisotropic") || this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),
uintIndices: this._webGLVersion > 1 || this._gl.getExtension("OES_element_index_uint") !== null,
fragmentDepthSupported: this._webGLVersion > 1 || this._gl.getExtension("EXT_frag_depth") !== null,
highPrecisionShaderSupported: !1,
timerQuery: this._gl.getExtension("EXT_disjoint_timer_query_webgl2") || this._gl.getExtension("EXT_disjoint_timer_query"),
supportOcclusionQuery: this._webGLVersion > 1,
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,
canUseGLInstanceID: this._webGLVersion > 1,
canUseGLVertexID: this._webGLVersion > 1,
supportComputeShaders: !1,
supportSRGBBuffers: !1
},
this._glVersion = this._gl.getParameter(this._gl.VERSION);
var e = this._gl.getExtension("WEBGL_debug_renderer_info");
if (e != null && (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"),
this._gl.HALF_FLOAT_OES !== 36193 && (this._gl.HALF_FLOAT_OES = 36193),
this._gl.RGBA16F !== 34842 && (this._gl.RGBA16F = 34842),
this._gl.RGBA32F !== 34836 && (this._gl.RGBA32F = 34836),
this._gl.DEPTH24_STENCIL8 !== 35056 && (this._gl.DEPTH24_STENCIL8 = 35056),
this._caps.timerQuery && (this._webGLVersion === 1 && (this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),
this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0),
this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0,
this._caps.textureFloatLinearFiltering = !!(this._caps.textureFloat && this._gl.getExtension("OES_texture_float_linear")),
this._caps.textureFloatRender = !!(this._caps.textureFloat && this._canRenderToFloatFramebuffer()),
this._caps.textureHalfFloatLinearFiltering = !!(this._webGLVersion > 1 || this._caps.textureHalfFloat && this._gl.getExtension("OES_texture_half_float_linear")),
this._caps.astc && (this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),
this._caps.bptc && (this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),
this._caps.s3tc_srgb && (this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),
this._webGLVersion > 1 && this._gl.HALF_FLOAT_OES !== 5131 && (this._gl.HALF_FLOAT_OES = 5131),
this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer(),
this._webGLVersion > 1)
this._caps.drawBuffersExtension = !0,
this._caps.maxMSAASamples = this._gl.getParameter(this._gl.MAX_SAMPLES);
else {
var t = this._gl.getExtension("WEBGL_draw_buffers");
if (t !== null) {
this._caps.drawBuffersExtension = !0,
this._gl.drawBuffers = t.drawBuffersWEBGL.bind(t),
this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
for (var r = 0; r < 16; r++)
this._gl["COLOR_ATTACHMENT" + r + "_WEBGL"] = t["COLOR_ATTACHMENT" + r + "_WEBGL"]
}
}
if (this._webGLVersion > 1)
this._caps.depthTextureExtension = !0;
else {
var n = this._gl.getExtension("WEBGL_depth_texture");
n != null && (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 o = this._gl.getExtension("OES_vertex_array_object");
o != null && (this._caps.vertexArrayObject = !0,
this._gl.createVertexArray = o.createVertexArrayOES.bind(o),
this._gl.bindVertexArray = o.bindVertexArrayOES.bind(o),
this._gl.deleteVertexArray = o.deleteVertexArrayOES.bind(o))
}
if (this._webGLVersion > 1)
this._caps.instancedArrays = !0;
else {
var a = this._gl.getExtension("ANGLE_instanced_arrays");
a != null ? (this._caps.instancedArrays = !0,
this._gl.drawArraysInstanced = a.drawArraysInstancedANGLE.bind(a),
this._gl.drawElementsInstanced = a.drawElementsInstancedANGLE.bind(a),
this._gl.vertexAttribDivisor = a.vertexAttribDivisorANGLE.bind(a)) : this._caps.instancedArrays = !1
}
if (this._gl.getShaderPrecisionFormat) {
var s = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT)
, l = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
s && l && (this._caps.highPrecisionShaderSupported = s.precision !== 0 && l.precision !== 0)
}
if (this._webGLVersion > 1)
this._caps.blendMinMax = !0;
else {
var u = this._gl.getExtension("EXT_blend_minmax");
u != null && (this._caps.blendMinMax = !0,
this._gl.MAX = u.MAX_EXT,
this._gl.MIN = u.MIN_EXT)
}
if (this._webGLVersion > 1)
this._caps.supportSRGBBuffers = !0;
else {
var c = this._gl.getExtension("EXT_sRGB");
c != null && (this._caps.supportSRGBBuffers = !0,
this._gl.SRGB = c.SRGB_EXT,
this._gl.SRGB8 = c.SRGB_ALPHA_EXT,
this._gl.SRGB8_ALPHA8 = c.SRGB_ALPHA_EXT)
}
this._depthCullingState.depthTest = !0,
this._depthCullingState.depthFunc = this._gl.LEQUAL,
this._depthCullingState.depthMask = !0,
this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
for (var h = 0; h < this._maxSimultaneousTextures; h++)
this._nextFreeTextureSlots.push(h)
}
,
i.prototype._initFeatures = function() {
this._features = {
forceBitmapOverHTMLImageElement: !1,
supportRenderAndCopyToLodForFloatTextures: this._webGLVersion !== 1,
supportDepthStencilTexture: this._webGLVersion !== 1,
supportShadowSamplers: this._webGLVersion !== 1,
uniformBufferHardCheckMatrix: !1,
allowTexturePrefiltering: this._webGLVersion !== 1,
trackUbosInFrame: !1,
checkUbosContentBeforeUpload: !1,
supportCSM: this._webGLVersion !== 1,
basisNeedsPOT: this._webGLVersion === 1,
support3DTextures: this._webGLVersion !== 1,
needTypeSuffixInShaderConstants: this._webGLVersion !== 1,
supportMSAA: this._webGLVersion !== 1,
supportSSAO2: this._webGLVersion !== 1,
supportExtendedTextureFormats: this._webGLVersion !== 1,
supportSwitchCaseInShader: this._webGLVersion !== 1,
supportSyncTextureRead: !0,
needsInvertingBitmap: !0,
useUBOBindingCache: !0,
needShaderCodeInlining: !1,
needToAlwaysBindUniformBuffers: !1,
supportRenderPasses: !1,
_collectUbosUpdatedInFrame: !1
}
}
,
Object.defineProperty(i.prototype, "webGLVersion", {
get: function() {
return this._webGLVersion
},
enumerable: !1,
configurable: !0
}),
i.prototype.getClassName = function() {
return "ThinEngine"
}
,
Object.defineProperty(i.prototype, "isStencilEnable", {
get: function() {
return this._isStencilEnable
},
enumerable: !1,
configurable: !0
}),
i.prototype._prepareWorkingCanvas = function() {
if (!this._workingCanvas) {
this._workingCanvas = this.createCanvas(1, 1);
var e = this._workingCanvas.getContext("2d");
e && (this._workingContext = e)
}
}
,
i.prototype.resetTextureCache = function() {
for (var e in this._boundTexturesCache)
!this._boundTexturesCache.hasOwnProperty(e) || (this._boundTexturesCache[e] = null);
this._currentTextureChannel = -1
}
,
i.prototype.getInfo = function() {
return this.getGlInfo()
}
,
i.prototype.getGlInfo = function() {
return {
vendor: this._glVendor,
renderer: this._glRenderer,
version: this._glVersion
}
}
,
i.prototype.setHardwareScalingLevel = function(e) {
this._hardwareScalingLevel = e,
this.resize()
}
,
i.prototype.getHardwareScalingLevel = function() {
return this._hardwareScalingLevel
}
,
i.prototype.getLoadedTexturesCache = function() {
return this._internalTexturesCache
}
,
i.prototype.getCaps = function() {
return this._caps
}
,
i.prototype.stopRenderLoop = function(e) {
if (!e) {
this._activeRenderLoops = [];
return
}
var t = this._activeRenderLoops.indexOf(e);
t >= 0 && this._activeRenderLoops.splice(t, 1)
}
,
i.prototype._renderLoop = function() {
if (!this._contextWasLost) {
var e = !0;
if (!this.renderEvenInBackground && this._windowIsBackground && (e = !1),
e) {
this.beginFrame();
for (var t = 0; t < this._activeRenderLoops.length; t++) {
var r = this._activeRenderLoops[t];
r()
}
this.endFrame()
}
}
this._activeRenderLoops.length > 0 ? this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1
}
,
i.prototype.getRenderingCanvas = function() {
return this._renderingCanvas
}
,
i.prototype.getAudioContext = function() {
return this._audioContext
}
,
i.prototype.getAudioDestination = function() {
return this._audioDestination
}
,
i.prototype.getHostWindow = function() {
return IsWindowObjectExist() ? this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView ? this._renderingCanvas.ownerDocument.defaultView : window : null
}
,
i.prototype.getRenderWidth = function(e) {
return e === void 0 && (e = !1),
!e && this._currentRenderTarget ? this._currentRenderTarget.width : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth
}
,
i.prototype.getRenderHeight = function(e) {
return e === void 0 && (e = !1),
!e && this._currentRenderTarget ? this._currentRenderTarget.height : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight
}
,
i.prototype._queueNewFrame = function(e, t) {
return i.QueueNewFrame(e, t)
}
,
i.prototype.runRenderLoop = function(e) {
this._activeRenderLoops.indexOf(e) === -1 && (this._activeRenderLoops.push(e),
this._renderingQueueLaunched || (this._renderingQueueLaunched = !0,
this._boundRenderFunction = this._renderLoop.bind(this),
this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow())))
}
,
i.prototype.clear = function(e, t, r, n) {
n === void 0 && (n = !1);
var o = this.stencilStateComposer.useStencilGlobalOnly;
this.stencilStateComposer.useStencilGlobalOnly = !0,
this.applyStates(),
this.stencilStateComposer.useStencilGlobalOnly = o;
var a = 0;
t && e && (this._gl.clearColor(e.r, e.g, e.b, e.a !== void 0 ? e.a : 1),
a |= this._gl.COLOR_BUFFER_BIT),
r && (this.useReverseDepthBuffer ? (this._depthCullingState.depthFunc = this._gl.GEQUAL,
this._gl.clearDepth(0)) : this._gl.clearDepth(1),
a |= this._gl.DEPTH_BUFFER_BIT),
n && (this._gl.clearStencil(0),
a |= this._gl.STENCIL_BUFFER_BIT),
this._gl.clear(a)
}
,
i.prototype._viewport = function(e, t, r, n) {
(e !== this._viewportCached.x || t !== this._viewportCached.y || r !== this._viewportCached.z || n !== this._viewportCached.w) && (this._viewportCached.x = e,
this._viewportCached.y = t,
this._viewportCached.z = r,
this._viewportCached.w = n,
this._gl.viewport(e, t, r, n))
}
,
i.prototype.setViewport = function(e, t, r) {
var n = t || this.getRenderWidth()
, o = r || this.getRenderHeight()
, a = e.x || 0
, s = e.y || 0;
this._cachedViewport = e,
this._viewport(a * n, s * o, n * e.width, o * e.height)
}
,
i.prototype.beginFrame = function() {}
,
i.prototype.endFrame = function() {
this._badOS && this.flushFramebuffer(),
this._frameId++
}
,
i.prototype.resize = function(e) {
e === void 0 && (e = !1);
var t, r;
IsWindowObjectExist() ? (t = this._renderingCanvas ? this._renderingCanvas.clientWidth || this._renderingCanvas.width : window.innerWidth,
r = this._renderingCanvas ? this._renderingCanvas.clientHeight || this._renderingCanvas.height : window.innerHeight) : (t = this._renderingCanvas ? this._renderingCanvas.width : 100,
r = this._renderingCanvas ? this._renderingCanvas.height : 100),
this.setSize(t / this._hardwareScalingLevel, r / this._hardwareScalingLevel, e)
}
,
i.prototype.setSize = function(e, t, r) {
return r === void 0 && (r = !1),
!this._renderingCanvas || (e = e | 0,
t = t | 0,
!r && this._renderingCanvas.width === e && this._renderingCanvas.height === t) ? !1 : (this._renderingCanvas.width = e,
this._renderingCanvas.height = t,
!0)
}
,
i.prototype.bindFramebuffer = function(e, t, r, n, o, a, s) {
var l, u, c, h, f;
t === void 0 && (t = 0),
a === void 0 && (a = 0),
s === void 0 && (s = 0);
var d = e;
this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
this._currentRenderTarget = e,
this._bindUnboundFramebuffer(d._MSAAFramebuffer ? d._MSAAFramebuffer : d._framebuffer);
var _ = this._gl;
e.is2DArray ? _.framebufferTextureLayer(_.FRAMEBUFFER, _.COLOR_ATTACHMENT0, (l = e.texture._hardwareTexture) === null || l === void 0 ? void 0 : l.underlyingResource, a, s) : e.isCube && _.framebufferTexture2D(_.FRAMEBUFFER, _.COLOR_ATTACHMENT0, _.TEXTURE_CUBE_MAP_POSITIVE_X + t, (u = e.texture._hardwareTexture) === null || u === void 0 ? void 0 : u.underlyingResource, a);
var g = e._depthStencilTexture;
if (g) {
var m = e._depthStencilTextureWithStencil ? _.DEPTH_STENCIL_ATTACHMENT : _.DEPTH_ATTACHMENT;
e.is2DArray ? _.framebufferTextureLayer(_.FRAMEBUFFER, m, (c = g._hardwareTexture) === null || c === void 0 ? void 0 : c.underlyingResource, a, s) : e.isCube ? _.framebufferTexture2D(_.FRAMEBUFFER, m, _.TEXTURE_CUBE_MAP_POSITIVE_X + t, (h = g._hardwareTexture) === null || h === void 0 ? void 0 : h.underlyingResource, a) : _.framebufferTexture2D(_.FRAMEBUFFER, m, _.TEXTURE_2D, (f = g._hardwareTexture) === null || f === void 0 ? void 0 : f.underlyingResource, a)
}
this._cachedViewport && !o ? this.setViewport(this._cachedViewport, r, n) : (r || (r = e.width,
a && (r = r / Math.pow(2, a))),
n || (n = e.height,
a && (n = n / Math.pow(2, a))),
this._viewport(0, 0, r, n)),
this.wipeCaches()
}
,
i.prototype.setState = function(e, t, r, n, o, a, s) {
var l, u;
t === void 0 && (t = 0),
n === void 0 && (n = !1),
s === void 0 && (s = 0),
(this._depthCullingState.cull !== e || r) && (this._depthCullingState.cull = e);
var c = !((u = (l = this.cullBackFaces) !== null && l !== void 0 ? l : o) !== null && u !== void 0) || u ? this._gl.BACK : this._gl.FRONT;
(this._depthCullingState.cullFace !== c || r) && (this._depthCullingState.cullFace = c),
this.setZOffset(t),
this.setZOffsetUnits(s);
var h = n ? this._gl.CW : this._gl.CCW;
(this._depthCullingState.frontFace !== h || r) && (this._depthCullingState.frontFace = h),
this._stencilStateComposer.stencilMaterial = a
}
,
i.prototype.setZOffset = function(e) {
this._depthCullingState.zOffset = this.useReverseDepthBuffer ? -e : e
}
,
i.prototype.getZOffset = function() {
var e = this._depthCullingState.zOffset;
return this.useReverseDepthBuffer ? -e : e
}
,
i.prototype.setZOffsetUnits = function(e) {
this._depthCullingState.zOffsetUnits = this.useReverseDepthBuffer ? -e : e
}
,
i.prototype.getZOffsetUnits = function() {
var e = this._depthCullingState.zOffsetUnits;
return this.useReverseDepthBuffer ? -e : e
}
,
i.prototype._bindUnboundFramebuffer = function(e) {
this._currentFramebuffer !== e && (this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, e),
this._currentFramebuffer = e)
}
,
i.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
return this._currentFramebuffer === null
}
,
i.prototype.generateMipmaps = function(e) {
this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0),
this._gl.generateMipmap(this._gl.TEXTURE_2D),
this._bindTextureDirectly(this._gl.TEXTURE_2D, null)
}
,
i.prototype.unBindFramebuffer = function(e, t, r) {
var n;
t === void 0 && (t = !1);
var o = e;
this._currentRenderTarget = null;
var a = this._gl;
if (o._MSAAFramebuffer) {
if (e.isMulti) {
this.unBindMultiColorAttachmentFramebuffer(e, t, r);
return
}
a.bindFramebuffer(a.READ_FRAMEBUFFER, o._MSAAFramebuffer),
a.bindFramebuffer(a.DRAW_FRAMEBUFFER, o._framebuffer),
a.blitFramebuffer(0, 0, e.width, e.height, 0, 0, e.width, e.height, a.COLOR_BUFFER_BIT, a.NEAREST)
}
((n = e.texture) === null || n === void 0 ? void 0 : n.generateMipMaps) && !t && !e.isCube && this.generateMipmaps(e.texture),
r && (o._MSAAFramebuffer && this._bindUnboundFramebuffer(o._framebuffer),
r()),
this._bindUnboundFramebuffer(null)
}
,
i.prototype.flushFramebuffer = function() {
this._gl.flush()
}
,
i.prototype.restoreDefaultFramebuffer = function() {
this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : this._bindUnboundFramebuffer(null),
this._cachedViewport && this.setViewport(this._cachedViewport),
this.wipeCaches()
}
,
i.prototype._resetVertexBufferBinding = function() {
this.bindArrayBuffer(null),
this._cachedVertexBuffers = null
}
,
i.prototype.createVertexBuffer = function(e) {
return this._createVertexBuffer(e, this._gl.STATIC_DRAW)
}
,
i.prototype._createVertexBuffer = function(e, t) {
var r = this._gl.createBuffer();
if (!r)
throw new Error("Unable to create vertex buffer");
var n = new WebGLDataBuffer(r);
return this.bindArrayBuffer(n),
e instanceof Array ? this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(e), t) : this._gl.bufferData(this._gl.ARRAY_BUFFER, e, t),
this._resetVertexBufferBinding(),
n.references = 1,
n
}
,
i.prototype.createDynamicVertexBuffer = function(e) {
return this._createVertexBuffer(e, this._gl.DYNAMIC_DRAW)
}
,
i.prototype._resetIndexBufferBinding = function() {
this.bindIndexBuffer(null),
this._cachedIndexBuffer = null
}
,
i.prototype.createIndexBuffer = function(e, t) {
var r = this._gl.createBuffer()
, n = new WebGLDataBuffer(r);
if (!r)
throw new Error("Unable to create index buffer");
this.bindIndexBuffer(n);
var o = this._normalizeIndexData(e);
return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, o, t ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW),
this._resetIndexBufferBinding(),
n.references = 1,
n.is32Bits = o.BYTES_PER_ELEMENT === 4,
n
}
,
i.prototype._normalizeIndexData = function(e) {
var t = e.BYTES_PER_ELEMENT;
if (t === 2)
return e;
if (this._caps.uintIndices) {
if (e instanceof Uint32Array)
return e;
for (var r = 0; r < e.length; r++)
if (e[r] >= 65535)
return new Uint32Array(e);
return new Uint16Array(e)
}
return new Uint16Array(e)
}
,
i.prototype.bindArrayBuffer = function(e) {
this._vaoRecordInProgress || this._unbindVertexArrayObject(),
this.bindBuffer(e, this._gl.ARRAY_BUFFER)
}
,
i.prototype.bindUniformBlock = function(e, t, r) {
var n = e.program
, o = this._gl.getUniformBlockIndex(n, t);
this._gl.uniformBlockBinding(n, o, r)
}
,
i.prototype.bindIndexBuffer = function(e) {
this._vaoRecordInProgress || this._unbindVertexArrayObject(),
this.bindBuffer(e, this._gl.ELEMENT_ARRAY_BUFFER)
}
,
i.prototype.bindBuffer = function(e, t) {
(this._vaoRecordInProgress || this._currentBoundBuffer[t] !== e) && (this._gl.bindBuffer(t, e ? e.underlyingResource : null),
this._currentBoundBuffer[t] = e)
}
,
i.prototype.updateArrayBuffer = function(e) {
this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, e)
}
,
i.prototype._vertexAttribPointer = function(e, t, r, n, o, a, s) {
var l = this._currentBufferPointers[t];
if (!!l) {
var u = !1;
l.active ? (l.buffer !== e && (l.buffer = e,
u = !0),
l.size !== r && (l.size = r,
u = !0),
l.type !== n && (l.type = n,
u = !0),
l.normalized !== o && (l.normalized = o,
u = !0),
l.stride !== a && (l.stride = a,
u = !0),
l.offset !== s && (l.offset = s,
u = !0)) : (u = !0,
l.active = !0,
l.index = t,
l.size = r,
l.type = n,
l.normalized = o,
l.stride = a,
l.offset = s,
l.buffer = e),
(u || this._vaoRecordInProgress) && (this.bindArrayBuffer(e),
this._gl.vertexAttribPointer(t, r, n, o, a, s))
}
}
,
i.prototype._bindIndexBufferWithCache = function(e) {
e != null && this._cachedIndexBuffer !== e && (this._cachedIndexBuffer = e,
this.bindIndexBuffer(e),
this._uintIndicesCurrentlySet = e.is32Bits)
}
,
i.prototype._bindVertexBuffersAttributes = function(e, t, r) {
var n = t.getAttributesNames();
this._vaoRecordInProgress || this._unbindVertexArrayObject(),
this.unbindAllAttributes();
for (var o = 0; o < n.length; o++) {
var a = t.getAttributeLocation(o);
if (a >= 0) {
var s = n[o]
, l = null;
if (r && (l = r[s]),
l || (l = e[s]),
!l)
continue;
this._gl.enableVertexAttribArray(a),
this._vaoRecordInProgress || (this._vertexAttribArraysEnabled[a] = !0);
var u = l.getBuffer();
u && (this._vertexAttribPointer(u, a, l.getSize(), l.type, l.normalized, l.byteStride, l.byteOffset),
l.getIsInstanced() && (this._gl.vertexAttribDivisor(a, l.getInstanceDivisor()),
this._vaoRecordInProgress || (this._currentInstanceLocations.push(a),
this._currentInstanceBuffers.push(u))))
}
}
}
,
i.prototype.recordVertexArrayObject = function(e, t, r, n) {
var o = this._gl.createVertexArray();
return this._vaoRecordInProgress = !0,
this._gl.bindVertexArray(o),
this._mustWipeVertexAttributes = !0,
this._bindVertexBuffersAttributes(e, r, n),
this.bindIndexBuffer(t),
this._vaoRecordInProgress = !1,
this._gl.bindVertexArray(null),
o
}
,
i.prototype.bindVertexArrayObject = function(e, t) {
this._cachedVertexArrayObject !== e && (this._cachedVertexArrayObject = e,
this._gl.bindVertexArray(e),
this._cachedVertexBuffers = null,
this._cachedIndexBuffer = null,
this._uintIndicesCurrentlySet = t != null && t.is32Bits,
this._mustWipeVertexAttributes = !0)
}
,
i.prototype.bindBuffersDirectly = function(e, t, r, n, o) {
if (this._cachedVertexBuffers !== e || this._cachedEffectForVertexBuffers !== o) {
this._cachedVertexBuffers = e,
this._cachedEffectForVertexBuffers = o;
var a = o.getAttributesCount();
this._unbindVertexArrayObject(),
this.unbindAllAttributes();
for (var s = 0, l = 0; l < a; l++)
if (l < r.length) {
var u = o.getAttributeLocation(l);
u >= 0 && (this._gl.enableVertexAttribArray(u),
this._vertexAttribArraysEnabled[u] = !0,
this._vertexAttribPointer(e, u, r[l], this._gl.FLOAT, !1, n, s)),
s += r[l] * 4
}
}
this._bindIndexBufferWithCache(t)
}
,
i.prototype._unbindVertexArrayObject = function() {
!this._cachedVertexArrayObject || (this._cachedVertexArrayObject = null,
this._gl.bindVertexArray(null))
}
,
i.prototype.bindBuffers = function(e, t, r, n) {
(this._cachedVertexBuffers !== e || this._cachedEffectForVertexBuffers !== r) && (this._cachedVertexBuffers = e,
this._cachedEffectForVertexBuffers = r,
this._bindVertexBuffersAttributes(e, r, n)),
this._bindIndexBufferWithCache(t)
}
,
i.prototype.unbindInstanceAttributes = function() {
for (var e, t = 0, r = this._currentInstanceLocations.length; t < r; t++) {
var n = this._currentInstanceBuffers[t];
e != n && n.references && (e = n,
this.bindArrayBuffer(n));
var o = this._currentInstanceLocations[t];
this._gl.vertexAttribDivisor(o, 0)
}
this._currentInstanceBuffers.length = 0,
this._currentInstanceLocations.length = 0
}
,
i.prototype.releaseVertexArrayObject = function(e) {
this._gl.deleteVertexArray(e)
}
,
i.prototype._releaseBuffer = function(e) {
return e.references--,
e.references === 0 ? (this._deleteBuffer(e),
!0) : !1
}
,
i.prototype._deleteBuffer = function(e) {
this._gl.deleteBuffer(e.underlyingResource)
}
,
i.prototype.updateAndBindInstancesBuffer = function(e, t, r) {
if (this.bindArrayBuffer(e),
t && this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, t),
r[0].index !== void 0)
this.bindInstancesBuffer(e, r, !0);
else
for (var n = 0; n < 4; n++) {
var o = r[n];
this._vertexAttribArraysEnabled[o] || (this._gl.enableVertexAttribArray(o),
this._vertexAttribArraysEnabled[o] = !0),
this._vertexAttribPointer(e, o, 4, this._gl.FLOAT, !1, 64, n * 16),
this._gl.vertexAttribDivisor(o, 1),
this._currentInstanceLocations.push(o),
this._currentInstanceBuffers.push(e)
}
}
,
i.prototype.bindInstancesBuffer = function(e, t, r) {
r === void 0 && (r = !0),
this.bindArrayBuffer(e);
var n = 0;
if (r)
for (var o = 0; o < t.length; o++) {
var a = t[o];
n += a.attributeSize * 4
}
for (var o = 0; o < t.length; o++) {
var a = t[o];
a.index === void 0 && (a.index = this._currentEffect.getAttributeLocationByName(a.attributeName)),
!(a.index < 0) && (this._vertexAttribArraysEnabled[a.index] || (this._gl.enableVertexAttribArray(a.index),
this._vertexAttribArraysEnabled[a.index] = !0),
this._vertexAttribPointer(e, a.index, a.attributeSize, a.attributeType || this._gl.FLOAT, a.normalized || !1, n, a.offset),
this._gl.vertexAttribDivisor(a.index, a.divisor === void 0 ? 1 : a.divisor),
this._currentInstanceLocations.push(a.index),
this._currentInstanceBuffers.push(e))
}
}
,
i.prototype.disableInstanceAttributeByName = function(e) {
if (!!this._currentEffect) {
var t = this._currentEffect.getAttributeLocationByName(e);
this.disableInstanceAttribute(t)
}
}
,
i.prototype.disableInstanceAttribute = function(e) {
for (var t = !1, r; (r = this._currentInstanceLocations.indexOf(e)) !== -1; )
this._currentInstanceLocations.splice(r, 1),
this._currentInstanceBuffers.splice(r, 1),
t = !0,
r = this._currentInstanceLocations.indexOf(e);
t && (this._gl.vertexAttribDivisor(e, 0),
this.disableAttributeByIndex(e))
}
,
i.prototype.disableAttributeByIndex = function(e) {
this._gl.disableVertexAttribArray(e),
this._vertexAttribArraysEnabled[e] = !1,
this._currentBufferPointers[e].active = !1
}
,
i.prototype.draw = function(e, t, r, n) {
this.drawElementsType(e ? 0 : 1, t, r, n)
}
,
i.prototype.drawPointClouds = function(e, t, r) {
this.drawArraysType(2, e, t, r)
}
,
i.prototype.drawUnIndexed = function(e, t, r, n) {
this.drawArraysType(e ? 0 : 1, t, r, n)
}
,
i.prototype.drawElementsType = function(e, t, r, n) {
this.applyStates(),
this._reportDrawCall();
var o = this._drawMode(e)
, a = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT
, s = this._uintIndicesCurrentlySet ? 4 : 2;
n ? this._gl.drawElementsInstanced(o, r, a, t * s, n) : this._gl.drawElements(o, r, a, t * s)
}
,
i.prototype.drawArraysType = function(e, t, r, n) {
this.applyStates(),
this._reportDrawCall();
var o = this._drawMode(e);
n ? this._gl.drawArraysInstanced(o, t, r, n) : this._gl.drawArrays(o, t, r)
}
,
i.prototype._drawMode = function(e) {
switch (e) {
case 0:
return this._gl.TRIANGLES;
case 2:
return this._gl.POINTS;
case 1:
return this._gl.LINES;
case 3:
return this._gl.POINTS;
case 4:
return this._gl.LINES;
case 5:
return this._gl.LINE_LOOP;
case 6:
return this._gl.LINE_STRIP;
case 7:
return this._gl.TRIANGLE_STRIP;
case 8:
return this._gl.TRIANGLE_FAN;
default:
return this._gl.TRIANGLES
}
}
,
i.prototype._reportDrawCall = function() {}
,
i.prototype._releaseEffect = function(e) {
if (this._compiledEffects[e._key]) {
delete this._compiledEffects[e._key];
var t = e.getPipelineContext();
t && this._deletePipelineContext(t)
}
}
,
i.prototype._deletePipelineContext = function(e) {
var t = e;
t && t.program && (t.program.__SPECTOR_rebuildProgram = null,
this._gl.deleteProgram(t.program))
}
,
i.prototype._getGlobalDefines = function(e) {
if (e) {
this.isNDCHalfZRange ? e.IS_NDC_HALF_ZRANGE = "" : delete e.IS_NDC_HALF_ZRANGE,
this.useReverseDepthBuffer ? e.USE_REVERSE_DEPTHBUFFER = "" : delete e.USE_REVERSE_DEPTHBUFFER;
return
} else {
var t = "";
return this.isNDCHalfZRange && (t += "#define IS_NDC_HALF_ZRANGE"),
this.useReverseDepthBuffer && (t && (t += `
`),
t += "#define USE_REVERSE_DEPTHBUFFER"),
t
}
}
,
i.prototype.createEffect = function(e, t, r, n, o, a, s, l, u, c) {
var h;
c === void 0 && (c = ShaderLanguage.GLSL);
var f = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e
, d = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e
, _ = this._getGlobalDefines()
, g = (h = o != null ? o : t.defines) !== null && h !== void 0 ? h : "";
_ && (g += _);
var m = f + "+" + d + "@" + g;
if (this._compiledEffects[m]) {
var v = this._compiledEffects[m];
return s && v.isReady() && s(v),
v
}
var y = new Effect(e,t,r,n,this,o,a,s,l,u,m,c);
return this._compiledEffects[m] = y,
y
}
,
i._ConcatenateShader = function(e, t, r) {
return r === void 0 && (r = ""),
r + (t ? t + `
` : "") + e
}
,
i.prototype._compileShader = function(e, t, r, n) {
return this._compileRawShader(i._ConcatenateShader(e, r, n), t)
}
,
i.prototype._compileRawShader = function(e, t) {
for (var r = this._gl; r.getError() != r.NO_ERROR; )
;
var n = r.createShader(t === "vertex" ? r.VERTEX_SHADER : r.FRAGMENT_SHADER);
if (!n)
throw new Error("Something went wrong while creating a gl " + t + " shader object. gl error=" + r.getError() + ", gl isContextLost=" + r.isContextLost() + ", _contextWasLost=" + this._contextWasLost);
return r.shaderSource(n, e),
r.compileShader(n),
n
}
,
i.prototype._getShaderSource = function(e) {
return this._gl.getShaderSource(e)
}
,
i.prototype.createRawShaderProgram = function(e, t, r, n, o) {
o === void 0 && (o = null),
n = n || this._gl;
var a = this._compileRawShader(t, "vertex")
, s = this._compileRawShader(r, "fragment");
return this._createShaderProgram(e, a, s, n, o)
}
,
i.prototype.createShaderProgram = function(e, t, r, n, o, a) {
a === void 0 && (a = null),
o = o || this._gl;
var s = this._webGLVersion > 1 ? `#version 300 es
#define WEBGL2
` : ""
, l = this._compileShader(t, "vertex", n, s)
, u = this._compileShader(r, "fragment", n, s);
return this._createShaderProgram(e, l, u, o, a)
}
,
i.prototype.inlineShaderCode = function(e) {
return e
}
,
i.prototype.createPipelineContext = function(e) {
var t = new WebGLPipelineContext;
return t.engine = this,
this._caps.parallelShaderCompile && (t.isParallelCompiled = !0),
t
}
,
i.prototype.createMaterialContext = function() {}
,
i.prototype.createDrawContext = function() {}
,
i.prototype._createShaderProgram = function(e, t, r, n, o) {
var a = n.createProgram();
if (e.program = a,
!a)
throw new Error("Unable to create program");
return n.attachShader(a, t),
n.attachShader(a, r),
n.linkProgram(a),
e.context = n,
e.vertexShader = t,
e.fragmentShader = r,
e.isParallelCompiled || this._finalizePipelineContext(e),
a
}
,
i.prototype._finalizePipelineContext = function(e) {
var t = e.context
, r = e.vertexShader
, n = e.fragmentShader
, o = e.program
, a = t.getProgramParameter(o, t.LINK_STATUS);
if (!a) {
if (!this._gl.getShaderParameter(r, this._gl.COMPILE_STATUS)) {
var s = this._gl.getShaderInfoLog(r);
if (s)
throw e.vertexCompilationError = s,
new Error("VERTEX SHADER " + s)
}
if (!this._gl.getShaderParameter(n, this._gl.COMPILE_STATUS)) {
var s = this._gl.getShaderInfoLog(n);
if (s)
throw e.fragmentCompilationError = s,
new Error("FRAGMENT SHADER " + s)
}
var l = t.getProgramInfoLog(o);
if (l)
throw e.programLinkError = l,
new Error(l)
}
if (this.validateShaderPrograms) {
t.validateProgram(o);
var u = t.getProgramParameter(o, t.VALIDATE_STATUS);
if (!u) {
var l = t.getProgramInfoLog(o);
if (l)
throw e.programValidationError = l,
new Error(l)
}
}
t.deleteShader(r),
t.deleteShader(n),
e.vertexShader = void 0,
e.fragmentShader = void 0,
e.onCompiled && (e.onCompiled(),
e.onCompiled = void 0)
}
,
i.prototype._preparePipelineContext = function(e, t, r, n, o, a, s, l, u, c) {
var h = e;
n ? h.program = this.createRawShaderProgram(h, t, r, void 0, u) : h.program = this.createShaderProgram(h, t, r, l, void 0, u),
h.program.__SPECTOR_rebuildProgram = s
}
,
i.prototype._isRenderingStateCompiled = function(e) {
var t = e;
return this._gl.getProgramParameter(t.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR) ? (this._finalizePipelineContext(t),
!0) : !1
}
,
i.prototype._executeWhenRenderingStateIsCompiled = function(e, t) {
var r = e;
if (!r.isParallelCompiled) {
t();
return
}
var n = r.onCompiled;
n ? r.onCompiled = function() {
n(),
t()
}
: r.onCompiled = t
}
,
i.prototype.getUniforms = function(e, t) {
for (var r = new Array, n = e, o = 0; o < t.length; o++)
r.push(this._gl.getUniformLocation(n.program, t[o]));
return r
}
,
i.prototype.getAttributes = function(e, t) {
for (var r = [], n = e, o = 0; o < t.length; o++)
try {
r.push(this._gl.getAttribLocation(n.program, t[o]))
} catch {
r.push(-1)
}
return r
}
,
i.prototype.enableEffect = function(e) {
e = e !== null && DrawWrapper.IsWrapper(e) ? e.effect : e,
!(!e || e === this._currentEffect) && (this._stencilStateComposer.stencilMaterial = void 0,
e = e,
this.bindSamplers(e),
this._currentEffect = e,
e.onBind && e.onBind(e),
e._onBindObservable && e._onBindObservable.notifyObservers(e))
}
,
i.prototype.setInt = function(e, t) {
return e ? (this._gl.uniform1i(e, t),
!0) : !1
}
,
i.prototype.setInt2 = function(e, t, r) {
return e ? (this._gl.uniform2i(e, t, r),
!0) : !1
}
,
i.prototype.setInt3 = function(e, t, r, n) {
return e ? (this._gl.uniform3i(e, t, r, n),
!0) : !1
}
,
i.prototype.setInt4 = function(e, t, r, n, o) {
return e ? (this._gl.uniform4i(e, t, r, n, o),
!0) : !1
}
,
i.prototype.setIntArray = function(e, t) {
return e ? (this._gl.uniform1iv(e, t),
!0) : !1
}
,
i.prototype.setIntArray2 = function(e, t) {
return !e || t.length % 2 !== 0 ? !1 : (this._gl.uniform2iv(e, t),
!0)
}
,
i.prototype.setIntArray3 = function(e, t) {
return !e || t.length % 3 !== 0 ? !1 : (this._gl.uniform3iv(e, t),
!0)
}
,
i.prototype.setIntArray4 = function(e, t) {
return !e || t.length % 4 !== 0 ? !1 : (this._gl.uniform4iv(e, t),
!0)
}
,
i.prototype.setArray = function(e, t) {
return !e || t.length < 1 ? !1 : (this._gl.uniform1fv(e, t),
!0)
}
,
i.prototype.setArray2 = function(e, t) {
return !e || t.length % 2 !== 0 ? !1 : (this._gl.uniform2fv(e, t),
!0)
}
,
i.prototype.setArray3 = function(e, t) {
return !e || t.length % 3 !== 0 ? !1 : (this._gl.uniform3fv(e, t),
!0)
}
,
i.prototype.setArray4 = function(e, t) {
return !e || t.length % 4 !== 0 ? !1 : (this._gl.uniform4fv(e, t),
!0)
}
,
i.prototype.setMatrices = function(e, t) {
return e ? (this._gl.uniformMatrix4fv(e, !1, t),
!0) : !1
}
,
i.prototype.setMatrix3x3 = function(e, t) {
return e ? (this._gl.uniformMatrix3fv(e, !1, t),
!0) : !1
}
,
i.prototype.setMatrix2x2 = function(e, t) {
return e ? (this._gl.uniformMatrix2fv(e, !1, t),
!0) : !1
}
,
i.prototype.setFloat = function(e, t) {
return e ? (this._gl.uniform1f(e, t),
!0) : !1
}
,
i.prototype.setFloat2 = function(e, t, r) {
return e ? (this._gl.uniform2f(e, t, r),
!0) : !1
}
,
i.prototype.setFloat3 = function(e, t, r, n) {
return e ? (this._gl.uniform3f(e, t, r, n),
!0) : !1
}
,
i.prototype.setFloat4 = function(e, t, r, n, o) {
return e ? (this._gl.uniform4f(e, t, r, n, o),
!0) : !1
}
,
i.prototype.applyStates = function() {
if (this._depthCullingState.apply(this._gl),
this._stencilStateComposer.apply(this._gl),
this._alphaState.apply(this._gl),
this._colorWriteChanged) {
this._colorWriteChanged = !1;
var e = this._colorWrite;
this._gl.colorMask(e, e, e, e)
}
}
,
i.prototype.setColorWrite = function(e) {
e !== this._colorWrite && (this._colorWriteChanged = !0,
this._colorWrite = e)
}
,
i.prototype.getColorWrite = function() {
return this._colorWrite
}
,
Object.defineProperty(i.prototype, "depthCullingState", {
get: function() {
return this._depthCullingState
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "alphaState", {
get: function() {
return this._alphaState
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "stencilState", {
get: function() {
return this._stencilState
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "stencilStateComposer", {
get: function() {
return this._stencilStateComposer
},
enumerable: !1,
configurable: !0
}),
i.prototype.clearInternalTexturesCache = function() {
this._internalTexturesCache = []
}
,
i.prototype.wipeCaches = function(e) {
this.preventCacheWipeBetweenFrames && !e || (this._currentEffect = null,
this._viewportCached.x = 0,
this._viewportCached.y = 0,
this._viewportCached.z = 0,
this._viewportCached.w = 0,
this._unbindVertexArrayObject(),
e && (this._currentProgram = null,
this.resetTextureCache(),
this._stencilStateComposer.reset(),
this._depthCullingState.reset(),
this._depthCullingState.depthFunc = this._gl.LEQUAL,
this._alphaState.reset(),
this._alphaMode = 1,
this._alphaEquation = 0,
this._colorWrite = !0,
this._colorWriteChanged = !0,
this._unpackFlipYCached = null,
this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
this._mustWipeVertexAttributes = !0,
this.unbindAllAttributes()),
this._resetVertexBufferBinding(),
this._cachedIndexBuffer = null,
this._cachedEffectForVertexBuffers = null,
this.bindIndexBuffer(null))
}
,
i.prototype._getSamplingParameters = function(e, t) {
var r = this._gl
, n = r.NEAREST
, o = r.NEAREST;
switch (e) {
case 11:
n = r.LINEAR,
t ? o = r.LINEAR_MIPMAP_NEAREST : o = r.LINEAR;
break;
case 3:
n = r.LINEAR,
t ? o = r.LINEAR_MIPMAP_LINEAR : o = r.LINEAR;
break;
case 8:
n = r.NEAREST,
t ? o = r.NEAREST_MIPMAP_LINEAR : o = r.NEAREST;
break;
case 4:
n = r.NEAREST,
t ? o = r.NEAREST_MIPMAP_NEAREST : o = r.NEAREST;
break;
case 5:
n = r.NEAREST,
t ? o = r.LINEAR_MIPMAP_NEAREST : o = r.LINEAR;
break;
case 6:
n = r.NEAREST,
t ? o = r.LINEAR_MIPMAP_LINEAR : o = r.LINEAR;
break;
case 7:
n = r.NEAREST,
o = r.LINEAR;
break;
case 1:
n = r.NEAREST,
o = r.NEAREST;
break;
case 9:
n = r.LINEAR,
t ? o = r.NEAREST_MIPMAP_NEAREST : o = r.NEAREST;
break;
case 10:
n = r.LINEAR,
t ? o = r.NEAREST_MIPMAP_LINEAR : o = r.NEAREST;
break;
case 2:
n = r.LINEAR,
o = r.LINEAR;
break;
case 12:
n = r.LINEAR,
o = r.NEAREST;
break
}
return {
min: o,
mag: n
}
}
,
i.prototype._createTexture = function() {
var e = this._gl.createTexture();
if (!e)
throw new Error("Unable to create texture");
return e
}
,
i.prototype._createHardwareTexture = function() {
return new WebGLHardwareTexture(this._createTexture(),this._gl)
}
,
i.prototype._createInternalTexture = function(e, t, r, n) {
n === void 0 && (n = InternalTextureSource.Unknown);
var o = {};
t !== void 0 && typeof t == "object" ? (o.generateMipMaps = t.generateMipMaps,
o.type = t.type === void 0 ? 0 : t.type,
o.samplingMode = t.samplingMode === void 0 ? 3 : t.samplingMode,
o.format = t.format === void 0 ? 5 : t.format) : (o.generateMipMaps = t,
o.type = 0,
o.samplingMode = 3,
o.format = 5),
(o.type === 1 && !this._caps.textureFloatLinearFiltering || o.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (o.samplingMode = 1),
o.type === 1 && !this._caps.textureFloat && (o.type = 0,
Logger$2.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
var a = this._gl
, s = new InternalTexture(this,n)
, l = e.width || e
, u = e.height || e
, c = e.layers || 0
, h = this._getSamplingParameters(o.samplingMode, !!o.generateMipMaps)
, f = c !== 0 ? a.TEXTURE_2D_ARRAY : a.TEXTURE_2D
, d = this._getRGBABufferInternalSizedFormat(o.type, o.format)
, _ = this._getInternalFormat(o.format)
, g = this._getWebGLTextureType(o.type);
return this._bindTextureDirectly(f, s),
c !== 0 ? (s.is2DArray = !0,
a.texImage3D(f, 0, d, l, u, c, 0, _, g, null)) : a.texImage2D(f, 0, d, l, u, 0, _, g, null),
a.texParameteri(f, a.TEXTURE_MAG_FILTER, h.mag),
a.texParameteri(f, a.TEXTURE_MIN_FILTER, h.min),
a.texParameteri(f, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE),
a.texParameteri(f, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE),
o.generateMipMaps && this._gl.generateMipmap(f),
this._bindTextureDirectly(f, null),
s.baseWidth = l,
s.baseHeight = u,
s.width = l,
s.height = u,
s.depth = c,
s.isReady = !0,
s.samples = 1,
s.generateMipMaps = !!o.generateMipMaps,
s.samplingMode = o.samplingMode,
s.type = o.type,
s.format = o.format,
this._internalTexturesCache.push(s),
s
}
,
i.prototype._getUseSRGBBuffer = function(e, t) {
return e && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || t)
}
,
i.prototype._createTextureBase = function(e, t, r, n, o, a, s, l, u, c, h, f, d, _, g, m) {
var v = this;
o === void 0 && (o = 3),
a === void 0 && (a = null),
s === void 0 && (s = null),
c === void 0 && (c = null),
h === void 0 && (h = null),
f === void 0 && (f = null),
d === void 0 && (d = null),
e = e || "";
var y = e.substr(0, 5) === "data:"
, b = e.substr(0, 5) === "blob:"
, T = y && e.indexOf(";base64,") !== -1
, C = h || new InternalTexture(this,InternalTextureSource.Url)
, A = e;
this._transformTextureUrl && !T && !h && !c && (e = this._transformTextureUrl(e)),
A !== e && (C._originalUrl = A);
var S = e.lastIndexOf(".")
, P = d || (S > -1 ? e.substring(S).toLowerCase() : "")
, R = null
, M = P.indexOf("?");
M > -1 && (P = P.split("?")[0]);
for (var x = 0, I = i._TextureLoaders; x < I.length; x++) {
var w = I[x];
if (w.canLoad(P, _)) {
R = w;
break
}
}
n && n._addPendingData(C),
C.url = e,
C.generateMipMaps = !t,
C.samplingMode = o,
C.invertY = r,
C._useSRGBBuffer = this._getUseSRGBBuffer(!!m, t),
this._doNotHandleContextLost || (C._buffer = c);
var O = null;
a && !h && (O = C.onLoadedObservable.add(a)),
h || this._internalTexturesCache.push(C);
var D = function(N, L) {
n && n._removePendingData(C),
e === A ? (O && C.onLoadedObservable.remove(O),
EngineStore.UseFallbackTexture && v._createTextureBase(EngineStore.FallbackTexture, t, C.invertY, n, o, null, s, l, u, c, C),
N = (N || "Unknown error") + (EngineStore.UseFallbackTexture ? " - Fallback texture was used" : ""),
C.onErrorObservable.notifyObservers({
message: N,
exception: L
}),
s && s(N, L)) : (Logger$2.Warn("Failed to load " + e + ", falling back to " + A),
v._createTextureBase(A, t, C.invertY, n, o, a, s, l, u, c, C, f, d, _, g, m))
};
if (R) {
var F = function(N) {
R.loadData(N, C, function(L, k, U, z, H, G) {
G ? D("TextureLoader failed to load data") : l(C, P, n, {
width: L,
height: k
}, C.invertY, !U, z, function() {
return H(),
!1
}, o)
}, g)
};
c ? c instanceof ArrayBuffer ? F(new Uint8Array(c)) : ArrayBuffer.isView(c) ? F(c) : s && s("Unable to load: only ArrayBuffer or ArrayBufferView is supported", null) : this._loadFile(e, function(N) {
return F(new Uint8Array(N))
}, void 0, n ? n.offlineProvider : void 0, !0, function(N, L) {
D("Unable to load " + (N && N.responseURL,
L))
})
} else {
var V = function(N) {
b && !v._doNotHandleContextLost && (C._buffer = N),
l(C, P, n, N, C.invertY, t, !1, u, o)
};
!y || T ? c && (typeof c.decoding == "string" || c.close) ? V(c) : i._FileToolsLoadImage(e, V, D, n ? n.offlineProvider : null, _, C.invertY && this._features.needsInvertingBitmap ? {
imageOrientation: "flipY"
} : void 0) : typeof c == "string" || c instanceof ArrayBuffer || ArrayBuffer.isView(c) || c instanceof Blob ? i._FileToolsLoadImage(c, V, D, n ? n.offlineProvider : null, _, C.invertY && this._features.needsInvertingBitmap ? {
imageOrientation: "flipY"
} : void 0) : c && V(c)
}
return C
}
,
i.prototype.createTexture = function(e, t, r, n, o, a, s, l, u, c, h, f, d, _, g) {
var m = this;
return o === void 0 && (o = 3),
a === void 0 && (a = null),
s === void 0 && (s = null),
l === void 0 && (l = null),
u === void 0 && (u = null),
c === void 0 && (c = null),
h === void 0 && (h = null),
this._createTextureBase(e, t, r, n, o, a, s, this._prepareWebGLTexture.bind(this), function(v, y, b, T, C, A) {
var S = m._gl
, P = b.width === v && b.height === y
, R = c ? m._getInternalFormat(c, C._useSRGBBuffer) : T === ".jpg" && !C._useSRGBBuffer ? S.RGB : C._useSRGBBuffer ? S.SRGB8_ALPHA8 : S.RGBA
, M = c ? m._getInternalFormat(c) : T === ".jpg" && !C._useSRGBBuffer ? S.RGB : S.RGBA;
if (C._useSRGBBuffer && m.webGLVersion === 1 && (M = R),
P)
return S.texImage2D(S.TEXTURE_2D, 0, R, M, S.UNSIGNED_BYTE, b),
!1;
var x = m._caps.maxTextureSize;
if (b.width > x || b.height > x || !m._supportsHardwareTextureRescaling)
return m._prepareWorkingCanvas(),
!m._workingCanvas || !m._workingContext || (m._workingCanvas.width = v,
m._workingCanvas.height = y,
m._workingContext.drawImage(b, 0, 0, b.width, b.height, 0, 0, v, y),
S.texImage2D(S.TEXTURE_2D, 0, R, M, S.UNSIGNED_BYTE, m._workingCanvas),
C.width = v,
C.height = y),
!1;
var I = new InternalTexture(m,InternalTextureSource.Temp);
return m._bindTextureDirectly(S.TEXTURE_2D, I, !0),
S.texImage2D(S.TEXTURE_2D, 0, R, M, S.UNSIGNED_BYTE, b),
m._rescaleTexture(I, C, n, R, function() {
m._releaseTexture(I),
m._bindTextureDirectly(S.TEXTURE_2D, C, !0),
A()
}),
!0
}, l, u, c, h, f, d, g)
}
,
i._FileToolsLoadImage = function(e, t, r, n, o, a) {
throw _WarnImport("FileTools")
}
,
i.prototype._rescaleTexture = function(e, t, r, n, o) {}
,
i.prototype.createRawTexture = function(e, t, r, n, o, a, s, l, u) {
throw _WarnImport("Engine.RawTexture")
}
,
i.prototype.createRawCubeTexture = function(e, t, r, n, o, a, s, l) {
throw _WarnImport("Engine.RawTexture")
}
,
i.prototype.createRawTexture3D = function(e, t, r, n, o, a, s, l, u, c) {
throw _WarnImport("Engine.RawTexture")
}
,
i.prototype.createRawTexture2DArray = function(e, t, r, n, o, a, s, l, u, c) {
throw _WarnImport("Engine.RawTexture")
}
,
i.prototype._unpackFlipY = function(e) {
this._unpackFlipYCached !== e && (this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, e ? 1 : 0),
this.enableUnpackFlipYCached && (this._unpackFlipYCached = e))
}
,
i.prototype._getUnpackAlignement = function() {
return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)
}
,
i.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
}
,
i.prototype.updateTextureSamplingMode = function(e, t, r) {
r === void 0 && (r = !1);
var n = this._getTextureTarget(t)
, o = this._getSamplingParameters(e, t.generateMipMaps || r);
this._setTextureParameterInteger(n, this._gl.TEXTURE_MAG_FILTER, o.mag, t),
this._setTextureParameterInteger(n, this._gl.TEXTURE_MIN_FILTER, o.min),
r && (t.generateMipMaps = !0,
this._gl.generateMipmap(n)),
this._bindTextureDirectly(n, null),
t.samplingMode = e
}
,
i.prototype.updateTextureDimensions = function(e, t, r, n) {}
,
i.prototype.updateTextureWrappingMode = function(e, t, r, n) {
r === void 0 && (r = null),
n === void 0 && (n = null);
var o = this._getTextureTarget(e);
t !== null && (this._setTextureParameterInteger(o, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(t), e),
e._cachedWrapU = t),
r !== null && (this._setTextureParameterInteger(o, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(r), e),
e._cachedWrapV = r),
(e.is2DArray || e.is3D) && n !== null && (this._setTextureParameterInteger(o, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(n), e),
e._cachedWrapR = n),
this._bindTextureDirectly(o, null)
}
,
i.prototype._setupDepthStencilTexture = function(e, t, r, n, o, a) {
a === void 0 && (a = 1);
var s = t.width || t
, l = t.height || t
, u = t.layers || 0;
e.baseWidth = s,
e.baseHeight = l,
e.width = s,
e.height = l,
e.is2DArray = u > 0,
e.depth = u,
e.isReady = !0,
e.samples = a,
e.generateMipMaps = !1,
e.samplingMode = n ? 2 : 1,
e.type = 0,
e._comparisonFunction = o;
var c = this._gl
, h = this._getTextureTarget(e)
, f = this._getSamplingParameters(e.samplingMode, !1);
c.texParameteri(h, c.TEXTURE_MAG_FILTER, f.mag),
c.texParameteri(h, c.TEXTURE_MIN_FILTER, f.min),
c.texParameteri(h, c.TEXTURE_WRAP_S, c.CLAMP_TO_EDGE),
c.texParameteri(h, c.TEXTURE_WRAP_T, c.CLAMP_TO_EDGE),
o === 0 ? (c.texParameteri(h, c.TEXTURE_COMPARE_FUNC, 515),
c.texParameteri(h, c.TEXTURE_COMPARE_MODE, c.NONE)) : (c.texParameteri(h, c.TEXTURE_COMPARE_FUNC, o),
c.texParameteri(h, c.TEXTURE_COMPARE_MODE, c.COMPARE_REF_TO_TEXTURE))
}
,
i.prototype._uploadCompressedDataToTextureDirectly = function(e, t, r, n, o, a, s) {
a === void 0 && (a = 0),
s === void 0 && (s = 0);
var l = this._gl
, u = l.TEXTURE_2D;
if (e.isCube && (u = l.TEXTURE_CUBE_MAP_POSITIVE_X + a),
e._useSRGBBuffer)
switch (t) {
case 36492:
t = l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
break;
case 37808:
t = l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
break;
case 33776:
this._caps.s3tc_srgb ? t = l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT : e._useSRGBBuffer = !1;
break;
case 33779:
this._caps.s3tc_srgb ? t = l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : e._useSRGBBuffer = !1;
break;
default:
e._useSRGBBuffer = !1;
break
}
this._gl.compressedTexImage2D(u, s, t, r, n, 0, o)
}
,
i.prototype._uploadDataToTextureDirectly = function(e, t, r, n, o, a) {
r === void 0 && (r = 0),
n === void 0 && (n = 0),
a === void 0 && (a = !1);
var s = this._gl
, l = this._getWebGLTextureType(e.type)
, u = this._getInternalFormat(e.format)
, c = o === void 0 ? this._getRGBABufferInternalSizedFormat(e.type, e.format, e._useSRGBBuffer) : this._getInternalFormat(o, e._useSRGBBuffer);
this._unpackFlipY(e.invertY);
var h = s.TEXTURE_2D;
e.isCube && (h = s.TEXTURE_CUBE_MAP_POSITIVE_X + r);
var f = Math.round(Math.log(e.width) * Math.LOG2E)
, d = Math.round(Math.log(e.height) * Math.LOG2E)
, _ = a ? e.width : Math.pow(2, Math.max(f - n, 0))
, g = a ? e.height : Math.pow(2, Math.max(d - n, 0));
s.texImage2D(h, n, c, _, g, 0, u, l, t)
}
,
i.prototype.updateTextureData = function(e, t, r, n, o, a, s, l) {
s === void 0 && (s = 0),
l === void 0 && (l = 0);
var u = this._gl
, c = this._getWebGLTextureType(e.type)
, h = this._getInternalFormat(e.format);
this._unpackFlipY(e.invertY);
var f = u.TEXTURE_2D;
e.isCube && (f = u.TEXTURE_CUBE_MAP_POSITIVE_X + s),
u.texSubImage2D(f, l, r, n, o, a, h, c, t)
}
,
i.prototype._uploadArrayBufferViewToTexture = function(e, t, r, n) {
r === void 0 && (r = 0),
n === void 0 && (n = 0);
var o = this._gl
, a = e.isCube ? o.TEXTURE_CUBE_MAP : o.TEXTURE_2D;
this._bindTextureDirectly(a, e, !0),
this._uploadDataToTextureDirectly(e, t, r, n),
this._bindTextureDirectly(a, null, !0)
}
,
i.prototype._prepareWebGLTextureContinuation = function(e, t, r, n, o) {
var a = this._gl;
if (!!a) {
var s = this._getSamplingParameters(o, !r);
a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, s.mag),
a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, s.min),
!r && !n && a.generateMipmap(a.TEXTURE_2D),
this._bindTextureDirectly(a.TEXTURE_2D, null),
t && t._removePendingData(e),
e.onLoadedObservable.notifyObservers(e),
e.onLoadedObservable.clear()
}
}
,
i.prototype._prepareWebGLTexture = function(e, t, r, n, o, a, s, l, u) {
var c = this;
u === void 0 && (u = 3);
var h = this.getCaps().maxTextureSize
, f = Math.min(h, this.needPOTTextures ? i.GetExponentOfTwo(n.width, h) : n.width)
, d = Math.min(h, this.needPOTTextures ? i.GetExponentOfTwo(n.height, h) : n.height)
, _ = this._gl;
if (!!_) {
if (!e._hardwareTexture) {
r && r._removePendingData(e);
return
}
this._bindTextureDirectly(_.TEXTURE_2D, e, !0),
this._unpackFlipY(o === void 0 ? !0 : !!o),
e.baseWidth = n.width,
e.baseHeight = n.height,
e.width = f,
e.height = d,
e.isReady = !0,
!l(f, d, n, t, e, function() {
c._prepareWebGLTextureContinuation(e, r, a, s, u)
}) && this._prepareWebGLTextureContinuation(e, r, a, s, u)
}
}
,
i.prototype._setupFramebufferDepthAttachments = function(e, t, r, n, o) {
o === void 0 && (o = 1);
var a = this._gl;
if (e && t)
return this._createRenderBuffer(r, n, o, a.DEPTH_STENCIL, a.DEPTH24_STENCIL8, a.DEPTH_STENCIL_ATTACHMENT);
if (t) {
var s = a.DEPTH_COMPONENT16;
return this._webGLVersion > 1 && (s = a.DEPTH_COMPONENT32F),
this._createRenderBuffer(r, n, o, s, s, a.DEPTH_ATTACHMENT)
}
return e ? this._createRenderBuffer(r, n, o, a.STENCIL_INDEX8, a.STENCIL_INDEX8, a.STENCIL_ATTACHMENT) : null
}
,
i.prototype._createRenderBuffer = function(e, t, r, n, o, a, s) {
s === void 0 && (s = !0);
var l = this._gl
, u = l.createRenderbuffer();
return l.bindRenderbuffer(l.RENDERBUFFER, u),
r > 1 && l.renderbufferStorageMultisample ? l.renderbufferStorageMultisample(l.RENDERBUFFER, r, o, e, t) : l.renderbufferStorage(l.RENDERBUFFER, n, e, t),
l.framebufferRenderbuffer(l.FRAMEBUFFER, a, l.RENDERBUFFER, u),
s && l.bindRenderbuffer(l.RENDERBUFFER, null),
u
}
,
i.prototype._releaseTexture = function(e) {
var t;
this._deleteTexture((t = e._hardwareTexture) === null || t === void 0 ? void 0 : t.underlyingResource),
this.unbindAllTextures();
var r = this._internalTexturesCache.indexOf(e);
r !== -1 && this._internalTexturesCache.splice(r, 1),
e._lodTextureHigh && e._lodTextureHigh.dispose(),
e._lodTextureMid && e._lodTextureMid.dispose(),
e._lodTextureLow && e._lodTextureLow.dispose(),
e._irradianceTexture && e._irradianceTexture.dispose()
}
,
i.prototype._releaseRenderTargetWrapper = function(e) {
var t = this._renderTargetWrapperCache.indexOf(e);
t !== -1 && this._renderTargetWrapperCache.splice(t, 1)
}
,
i.prototype._deleteTexture = function(e) {
e && this._gl.deleteTexture(e)
}
,
i.prototype._setProgram = function(e) {
this._currentProgram !== e && (this._gl.useProgram(e),
this._currentProgram = e)
}
,
i.prototype.bindSamplers = function(e) {
var t = e.getPipelineContext();
this._setProgram(t.program);
for (var r = e.getSamplers(), n = 0; n < r.length; n++) {
var o = e.getUniform(r[n]);
o && (this._boundUniforms[n] = o)
}
this._currentEffect = null
}
,
i.prototype._activateCurrentTexture = function() {
this._currentTextureChannel !== this._activeChannel && (this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel),
this._currentTextureChannel = this._activeChannel)
}
,
i.prototype._bindTextureDirectly = function(e, t, r, n) {
var o, a;
r === void 0 && (r = !1),
n === void 0 && (n = !1);
var s = !1
, l = t && t._associatedChannel > -1;
r && l && (this._activeChannel = t._associatedChannel);
var u = this._boundTexturesCache[this._activeChannel];
if (u !== t || n) {
if (this._activateCurrentTexture(),
t && t.isMultiview)
throw console.error(e, t),
"_bindTextureDirectly called with a multiview texture!";
this._gl.bindTexture(e, (a = (o = t == null ? void 0 : t._hardwareTexture) === null || o === void 0 ? void 0 : o.underlyingResource) !== null && a !== void 0 ? a : null),
this._boundTexturesCache[this._activeChannel] = t,
t && (t._associatedChannel = this._activeChannel)
} else
r && (s = !0,
this._activateCurrentTexture());
return l && !r && this._bindSamplerUniformToChannel(t._associatedChannel, this._activeChannel),
s
}
,
i.prototype._bindTexture = function(e, t, r) {
if (e !== void 0) {
t && (t._associatedChannel = e),
this._activeChannel = e;
var n = t ? this._getTextureTarget(t) : this._gl.TEXTURE_2D;
this._bindTextureDirectly(n, t)
}
}
,
i.prototype.unbindAllTextures = function() {
for (var e = 0; e < this._maxSimultaneousTextures; 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))
}
,
i.prototype.setTexture = function(e, t, r, n) {
e !== void 0 && (t && (this._boundUniforms[e] = t),
this._setTexture(e, r))
}
,
i.prototype._bindSamplerUniformToChannel = function(e, t) {
var r = this._boundUniforms[e];
!r || r._currentState === t || (this._gl.uniform1i(r, t),
r._currentState = t)
}
,
i.prototype._getTextureWrapMode = function(e) {
switch (e) {
case 1:
return this._gl.REPEAT;
case 0:
return this._gl.CLAMP_TO_EDGE;
case 2:
return this._gl.MIRRORED_REPEAT
}
return this._gl.REPEAT
}
,
i.prototype._setTexture = function(e, t, r, n, o) {
if (r === void 0 && (r = !1),
n === void 0 && (n = !1),
!t)
return this._boundTexturesCache[e] != null && (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 === 4)
return t.delayLoad(),
!1;
var a;
n ? a = t.depthStencilTexture : t.isReady() ? a = t.getInternalTexture() : t.isCube ? a = this.emptyCubeTexture : t.is3D ? a = this.emptyTexture3D : t.is2DArray ? a = this.emptyTexture2DArray : a = this.emptyTexture,
!r && a && (a._associatedChannel = e);
var s = !0;
this._boundTexturesCache[e] === a && (r || this._bindSamplerUniformToChannel(a._associatedChannel, e),
s = !1),
this._activeChannel = e;
var l = this._getTextureTarget(a);
if (s && this._bindTextureDirectly(l, a, r),
a && !a.isMultiview) {
if (a.isCube && a._cachedCoordinatesMode !== t.coordinatesMode) {
a._cachedCoordinatesMode = t.coordinatesMode;
var u = t.coordinatesMode !== 3 && t.coordinatesMode !== 5 ? 1 : 0;
t.wrapU = u,
t.wrapV = u
}
a._cachedWrapU !== t.wrapU && (a._cachedWrapU = t.wrapU,
this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(t.wrapU), a)),
a._cachedWrapV !== t.wrapV && (a._cachedWrapV = t.wrapV,
this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(t.wrapV), a)),
a.is3D && a._cachedWrapR !== t.wrapR && (a._cachedWrapR = t.wrapR,
this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(t.wrapR), a)),
this._setAnisotropicLevel(l, a, t.anisotropicFilteringLevel)
}
return !0
}
,
i.prototype.setTextureArray = function(e, t, r, n) {
if (!(e === void 0 || !t)) {
(!this._textureUnits || this._textureUnits.length !== r.length) && (this._textureUnits = new Int32Array(r.length));
for (var o = 0; o < r.length; o++) {
var a = r[o].getInternalTexture();
a ? (this._textureUnits[o] = e + o,
a._associatedChannel = e + o) : this._textureUnits[o] = -1
}
this._gl.uniform1iv(t, this._textureUnits);
for (var s = 0; s < r.length; s++)
this._setTexture(this._textureUnits[s], r[s], !0)
}
}
,
i.prototype._setAnisotropicLevel = function(e, t, r) {
var n = this._caps.textureAnisotropicFilterExtension;
t.samplingMode !== 11 && t.samplingMode !== 3 && t.samplingMode !== 2 && (r = 1),
n && t._cachedAnisotropicFilteringLevel !== r && (this._setTextureParameterFloat(e, n.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(r, this._caps.maxAnisotropy), t),
t._cachedAnisotropicFilteringLevel = r)
}
,
i.prototype._setTextureParameterFloat = function(e, t, r, n) {
this._bindTextureDirectly(e, n, !0, !0),
this._gl.texParameterf(e, t, r)
}
,
i.prototype._setTextureParameterInteger = function(e, t, r, n) {
n && this._bindTextureDirectly(e, n, !0, !0),
this._gl.texParameteri(e, t, r)
}
,
i.prototype.unbindAllAttributes = function() {
if (this._mustWipeVertexAttributes) {
this._mustWipeVertexAttributes = !1;
for (var e = 0; e < this._caps.maxVertexAttribs; e++)
this.disableAttributeByIndex(e);
return
}
for (var e = 0, t = this._vertexAttribArraysEnabled.length; e < t; e++)
e >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[e] || this.disableAttributeByIndex(e)
}
,
i.prototype.releaseEffects = function() {
for (var e in this._compiledEffects) {
var t = this._compiledEffects[e].getPipelineContext();
this._deletePipelineContext(t)
}
this._compiledEffects = {}
}
,
i.prototype.dispose = function() {
var e;
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(),
(e = this.releaseComputeEffects) === null || e === void 0 || e.call(this),
this.unbindAllAttributes(),
this._boundUniforms = [],
IsWindowObjectExist() && this._renderingCanvas && (this._doNotHandleContextLost || (this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost),
this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored)),
window.removeEventListener("resize", this._checkForMobile)),
this._workingCanvas = null,
this._workingContext = null,
this._currentBufferPointers = [],
this._renderingCanvas = null,
this._currentProgram = null,
this._boundRenderFunction = null,
Effect.ResetCache();
for (var t = 0, r = this._activeRequests; t < r.length; t++) {
var n = r[t];
n.abort()
}
this.onDisposeObservable.notifyObservers(this),
this.onDisposeObservable.clear()
}
,
i.prototype.attachContextLostEvent = function(e) {
this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextlost", e, !1)
}
,
i.prototype.attachContextRestoredEvent = function(e) {
this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextrestored", e, !1)
}
,
i.prototype.getError = function() {
return this._gl.getError()
}
,
i.prototype._canRenderToFloatFramebuffer = function() {
return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(1)
}
,
i.prototype._canRenderToHalfFloatFramebuffer = function() {
return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(2)
}
,
i.prototype._canRenderToFramebuffer = function(e) {
for (var t = this._gl; t.getError() !== t.NO_ERROR; )
;
var r = !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 o = t.createFramebuffer();
t.bindFramebuffer(t.FRAMEBUFFER, o),
t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, n, 0);
var a = t.checkFramebufferStatus(t.FRAMEBUFFER);
if (r = r && a === t.FRAMEBUFFER_COMPLETE,
r = r && t.getError() === t.NO_ERROR,
r && (t.clear(t.COLOR_BUFFER_BIT),
r = r && t.getError() === t.NO_ERROR),
r) {
t.bindFramebuffer(t.FRAMEBUFFER, null);
var s = t.RGBA
, l = t.UNSIGNED_BYTE
, u = new Uint8Array(4);
t.readPixels(0, 0, 1, 1, s, l, u),
r = r && t.getError() === t.NO_ERROR
}
for (t.deleteTexture(n),
t.deleteFramebuffer(o),
t.bindFramebuffer(t.FRAMEBUFFER, null); !r && t.getError() !== t.NO_ERROR; )
;
return r
}
,
i.prototype._getWebGLTextureType = function(e) {
if (this._webGLVersion === 1) {
switch (e) {
case 1:
return this._gl.FLOAT;
case 2:
return this._gl.HALF_FLOAT_OES;
case 0:
return this._gl.UNSIGNED_BYTE;
case 8:
return this._gl.UNSIGNED_SHORT_4_4_4_4;
case 9:
return this._gl.UNSIGNED_SHORT_5_5_5_1;
case 10:
return this._gl.UNSIGNED_SHORT_5_6_5
}
return this._gl.UNSIGNED_BYTE
}
switch (e) {
case 3:
return this._gl.BYTE;
case 0:
return this._gl.UNSIGNED_BYTE;
case 4:
return this._gl.SHORT;
case 5:
return this._gl.UNSIGNED_SHORT;
case 6:
return this._gl.INT;
case 7:
return this._gl.UNSIGNED_INT;
case 1:
return this._gl.FLOAT;
case 2:
return this._gl.HALF_FLOAT;
case 8:
return this._gl.UNSIGNED_SHORT_4_4_4_4;
case 9:
return this._gl.UNSIGNED_SHORT_5_5_5_1;
case 10:
return this._gl.UNSIGNED_SHORT_5_6_5;
case 11:
return this._gl.UNSIGNED_INT_2_10_10_10_REV;
case 12:
return this._gl.UNSIGNED_INT_24_8;
case 13:
return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
case 14:
return this._gl.UNSIGNED_INT_5_9_9_9_REV;
case 15:
return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV
}
return this._gl.UNSIGNED_BYTE
}
,
i.prototype._getInternalFormat = function(e, t) {
t === void 0 && (t = !1);
var r = t ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA;
switch (e) {
case 0:
r = this._gl.ALPHA;
break;
case 1:
r = this._gl.LUMINANCE;
break;
case 2:
r = this._gl.LUMINANCE_ALPHA;
break;
case 6:
r = this._gl.RED;
break;
case 7:
r = this._gl.RG;
break;
case 4:
r = t ? this._gl.SRGB : this._gl.RGB;
break;
case 5:
r = t ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA;
break
}
if (this._webGLVersion > 1)
switch (e) {
case 8:
r = this._gl.RED_INTEGER;
break;
case 9:
r = this._gl.RG_INTEGER;
break;
case 10:
r = this._gl.RGB_INTEGER;
break;
case 11:
r = this._gl.RGBA_INTEGER;
break
}
return r
}
,
i.prototype._getRGBABufferInternalSizedFormat = function(e, t, r) {
if (r === void 0 && (r = !1),
this._webGLVersion === 1) {
if (t !== void 0)
switch (t) {
case 0:
return this._gl.ALPHA;
case 1:
return this._gl.LUMINANCE;
case 2:
return this._gl.LUMINANCE_ALPHA;
case 4:
return r ? this._gl.SRGB : this._gl.RGB
}
return this._gl.RGBA
}
switch (e) {
case 3:
switch (t) {
case 6:
return this._gl.R8_SNORM;
case 7:
return this._gl.RG8_SNORM;
case 4:
return this._gl.RGB8_SNORM;
case 8:
return this._gl.R8I;
case 9:
return this._gl.RG8I;
case 10:
return this._gl.RGB8I;
case 11:
return this._gl.RGBA8I;
default:
return this._gl.RGBA8_SNORM
}
case 0:
switch (t) {
case 6:
return this._gl.R8;
case 7:
return this._gl.RG8;
case 4:
return r ? this._gl.SRGB8 : this._gl.RGB8;
case 5:
return r ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8;
case 8:
return this._gl.R8UI;
case 9:
return this._gl.RG8UI;
case 10:
return this._gl.RGB8UI;
case 11:
return this._gl.RGBA8UI;
case 0:
return this._gl.ALPHA;
case 1:
return this._gl.LUMINANCE;
case 2:
return this._gl.LUMINANCE_ALPHA;
default:
return this._gl.RGBA8
}
case 4:
switch (t) {
case 8:
return this._gl.R16I;
case 9:
return this._gl.RG16I;
case 10:
return this._gl.RGB16I;
case 11:
return this._gl.RGBA16I;
default:
return this._gl.RGBA16I
}
case 5:
switch (t) {
case 8:
return this._gl.R16UI;
case 9:
return this._gl.RG16UI;
case 10:
return this._gl.RGB16UI;
case 11:
return this._gl.RGBA16UI;
default:
return this._gl.RGBA16UI
}
case 6:
switch (t) {
case 8:
return this._gl.R32I;
case 9:
return this._gl.RG32I;
case 10:
return this._gl.RGB32I;
case 11:
return this._gl.RGBA32I;
default:
return this._gl.RGBA32I
}
case 7:
switch (t) {
case 8:
return this._gl.R32UI;
case 9:
return this._gl.RG32UI;
case 10:
return this._gl.RGB32UI;
case 11:
return this._gl.RGBA32UI;
default:
return this._gl.RGBA32UI
}
case 1:
switch (t) {
case 6:
return this._gl.R32F;
case 7:
return this._gl.RG32F;
case 4:
return this._gl.RGB32F;
case 5:
return this._gl.RGBA32F;
default:
return this._gl.RGBA32F
}
case 2:
switch (t) {
case 6:
return this._gl.R16F;
case 7:
return this._gl.RG16F;
case 4:
return this._gl.RGB16F;
case 5:
return this._gl.RGBA16F;
default:
return this._gl.RGBA16F
}
case 10:
return this._gl.RGB565;
case 13:
return this._gl.R11F_G11F_B10F;
case 14:
return this._gl.RGB9_E5;
case 8:
return this._gl.RGBA4;
case 9:
return this._gl.RGB5_A1;
case 11:
switch (t) {
case 5:
return this._gl.RGB10_A2;
case 11:
return this._gl.RGB10_A2UI;
default:
return this._gl.RGB10_A2
}
}
return r ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8
}
,
i.prototype._getRGBAMultiSampleBufferFormat = function(e) {
return e === 1 ? this._gl.RGBA32F : e === 2 ? this._gl.RGBA16F : this._gl.RGBA8
}
,
i.prototype._loadFile = function(e, t, r, n, o, a) {
var s = this
, l = i._FileToolsLoadFile(e, t, r, n, o, a);
return this._activeRequests.push(l),
l.onCompleteObservable.add(function(u) {
s._activeRequests.splice(s._activeRequests.indexOf(u), 1)
}),
l
}
,
i._FileToolsLoadFile = function(e, t, r, n, o, a) {
throw _WarnImport("FileTools")
}
,
i.prototype.readPixels = function(e, t, r, n, o, a) {
o === void 0 && (o = !0),
a === void 0 && (a = !0);
var s = o ? 4 : 3
, l = o ? this._gl.RGBA : this._gl.RGB
, u = new Uint8Array(n * r * s);
return a && this.flushFramebuffer(),
this._gl.readPixels(e, t, r, n, l, this._gl.UNSIGNED_BYTE, u),
Promise.resolve(u)
}
,
Object.defineProperty(i, "IsSupportedAsync", {
get: function() {
return Promise.resolve(this.isSupported())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "IsSupported", {
get: function() {
return this.isSupported()
},
enumerable: !1,
configurable: !0
}),
i.isSupported = function() {
if (this._HasMajorPerformanceCaveat !== null)
return !this._HasMajorPerformanceCaveat;
if (this._IsSupported === null)
try {
var e = this._createCanvas(1, 1)
, t = e.getContext("webgl") || e.getContext("experimental-webgl");
this._IsSupported = t != null && !!window.WebGLRenderingContext
} catch {
this._IsSupported = !1
}
return this._IsSupported
}
,
Object.defineProperty(i, "HasMajorPerformanceCaveat", {
get: function() {
if (this._HasMajorPerformanceCaveat === null)
try {
var e = this._createCanvas(1, 1)
, t = e.getContext("webgl", {
failIfMajorPerformanceCaveat: !0
}) || e.getContext("experimental-webgl", {
failIfMajorPerformanceCaveat: !0
});
this._HasMajorPerformanceCaveat = !t
} catch {
this._HasMajorPerformanceCaveat = !1
}
return this._HasMajorPerformanceCaveat
},
enumerable: !1,
configurable: !0
}),
i.CeilingPOT = function(e) {
return e--,
e |= e >> 1,
e |= e >> 2,
e |= e >> 4,
e |= e >> 8,
e |= e >> 16,
e++,
e
}
,
i.FloorPOT = function(e) {
return e = e | e >> 1,
e = e | e >> 2,
e = e | e >> 4,
e = e | e >> 8,
e = e | e >> 16,
e - (e >> 1)
}
,
i.NearestPOT = function(e) {
var t = i.CeilingPOT(e)
, r = i.FloorPOT(e);
return t - e > e - r ? r : t
}
,
i.GetExponentOfTwo = function(e, t, r) {
r === void 0 && (r = 2);
var n;
switch (r) {
case 1:
n = i.FloorPOT(e);
break;
case 2:
n = i.NearestPOT(e);
break;
case 3:
default:
n = i.CeilingPOT(e);
break
}
return Math.min(n, t)
}
,
i.QueueNewFrame = function(e, t) {
return 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)) : typeof requestAnimationFrame != "undefined" ? requestAnimationFrame(e) : setTimeout(e, 16)
}
,
i.prototype.getHostDocument = function() {
return this._renderingCanvas && this._renderingCanvas.ownerDocument ? this._renderingCanvas.ownerDocument : document
}
,
i.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"]
}],
i._TextureLoaders = [],
i.CollisionsEpsilon = .001,
i._IsSupported = null,
i._HasMajorPerformanceCaveat = null,
i
}(), TimingTools = function() {
function i() {}
return i.SetImmediate = function(e) {
IsWindowObjectExist() && window.setImmediate ? window.setImmediate(e) : setTimeout(e, 1)
}
,
i
}(), FileTools, _injectLTSFileTools = function(i, e, t, r, n, o, a, s, l, u) {
FileTools = {
DecodeBase64UrlToBinary: i,
DecodeBase64UrlToString: e,
DefaultRetryStrategy: t.DefaultRetryStrategy,
BaseUrl: t.BaseUrl,
CorsBehavior: t.CorsBehavior,
PreprocessUrl: t.PreprocessUrl,
IsBase64DataUrl: r,
IsFileURL: n,
LoadFile: o,
LoadImage: a,
ReadFile: s,
RequestFile: l,
SetCorsBehavior: u
},
Object.defineProperty(FileTools, "DefaultRetryStrategy", {
get: function() {
return t.DefaultRetryStrategy
},
set: function(c) {
t.DefaultRetryStrategy = c
}
}),
Object.defineProperty(FileTools, "BaseUrl", {
get: function() {
return t.BaseUrl
},
set: function(c) {
t.BaseUrl = c
}
}),
Object.defineProperty(FileTools, "PreprocessUrl", {
get: function() {
return t.PreprocessUrl
},
set: function(c) {
t.PreprocessUrl = c
}
}),
Object.defineProperty(FileTools, "CorsBehavior", {
get: function() {
return t.CorsBehavior
},
set: function(c) {
t.CorsBehavior = c
}
})
}, base64DataUrlRegEx = new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i), LoadFileError = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t) || this;
return n.name = "LoadFileError",
BaseError._setPrototypeOf(n, e.prototype),
r instanceof WebRequest ? n.request = r : n.file = r,
n
}
return e
}(BaseError), RequestFileError = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t) || this;
return n.request = r,
n.name = "RequestFileError",
BaseError._setPrototypeOf(n, e.prototype),
n
}
return e
}(BaseError), ReadFileError = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t) || this;
return n.file = r,
n.name = "ReadFileError",
BaseError._setPrototypeOf(n, e.prototype),
n
}
return e
}(BaseError), FileToolsOptions = {
DefaultRetryStrategy: RetryStrategy.ExponentialBackoff(),
BaseUrl: "",
CorsBehavior: "anonymous",
PreprocessUrl: function(i) {
return i
}
}, _CleanUrl = function(i) {
return i = i.replace(/#/mg, "%23"),
i
}, SetCorsBehavior = function(i, e) {
if (!(i && i.indexOf("data:") === 0) && FileToolsOptions.CorsBehavior)
if (typeof FileToolsOptions.CorsBehavior == "string" || FileToolsOptions.CorsBehavior instanceof String)
e.crossOrigin = FileToolsOptions.CorsBehavior;
else {
var t = FileToolsOptions.CorsBehavior(i);
t && (e.crossOrigin = t)
}
}, LoadImage = function(i, e, t, r, n, o) {
var a;
n === void 0 && (n = "");
var s, l = !1;
i instanceof ArrayBuffer || ArrayBuffer.isView(i) ? typeof Blob != "undefined" ? (s = URL.createObjectURL(new Blob([i],{
type: n
})),
l = !0) : s = "data:" + n + ";base64," + EncodeArrayBufferToBase64(i) : i instanceof Blob ? (s = URL.createObjectURL(i),
l = !0) : (s = _CleanUrl(i),
s = FileToolsOptions.PreprocessUrl(i));
var u = EngineStore.LastCreatedEngine
, c = function(y) {
if (t) {
var b = s || i.toString();
t("Error while trying to load image: " + (b.indexOf("http") === 0 || b.length <= 128 ? b : b.slice(0, 128) + "..."), y)
}
};
if (typeof Image == "undefined" || ((a = u == null ? void 0 : u._features.forceBitmapOverHTMLImageElement) !== null && a !== void 0 ? a : !1))
return LoadFile(s, function(y) {
u.createImageBitmap(new Blob([y],{
type: n
}), __assign({
premultiplyAlpha: "none"
}, o)).then(function(b) {
e(b),
l && URL.revokeObjectURL(s)
}).catch(function(b) {
t && t("Error while trying to load image: " + i, b)
})
}, void 0, r || void 0, !0, function(y, b) {
c(b)
}),
null;
var h = new Image;
SetCorsBehavior(s, h);
var f = function() {
h.removeEventListener("load", f),
h.removeEventListener("error", d),
e(h),
l && h.src && URL.revokeObjectURL(h.src)
}
, d = function(y) {
h.removeEventListener("load", f),
h.removeEventListener("error", d),
c(y),
l && h.src && URL.revokeObjectURL(h.src)
};
h.addEventListener("load", f),
h.addEventListener("error", d);
var _ = function() {
h.src = s
}
, g = function() {
r && r.loadImage(s, h)
};
if (s.substr(0, 5) !== "data:" && r && r.enableTexturesOffline)
r.open(g, _);
else {
if (s.indexOf("file:") !== -1) {
var m = decodeURIComponent(s.substring(5).toLowerCase());
if (FilesInputStore.FilesToLoad[m]) {
try {
var v;
try {
v = URL.createObjectURL(FilesInputStore.FilesToLoad[m])
} catch {
v = URL.createObjectURL(FilesInputStore.FilesToLoad[m])
}
h.src = v,
l = !0
} catch {
h.src = ""
}
return h
}
}
_()
}
return h
}, ReadFile = function(i, e, t, r, n) {
var o = new FileReader
, a = {
onCompleteObservable: new Observable,
abort: function() {
return o.abort()
}
};
return o.onloadend = function(s) {
return a.onCompleteObservable.notifyObservers(a)
}
,
n && (o.onerror = function(s) {
n(new ReadFileError("Unable to read " + i.name,i))
}
),
o.onload = function(s) {
e(s.target.result)
}
,
t && (o.onprogress = t),
r ? o.readAsArrayBuffer(i) : o.readAsText(i),
a
}, LoadFile = function(i, e, t, r, n, o, a) {
if (i.name)
return ReadFile(i, e, t, n, o ? function(h) {
o(void 0, h)
}
: void 0);
var s = i;
if (s.indexOf("file:") !== -1) {
var l = decodeURIComponent(s.substring(5).toLowerCase());
l.indexOf("./") === 0 && (l = l.substring(2));
var u = FilesInputStore.FilesToLoad[l];
if (u)
return ReadFile(u, e, t, n, o ? function(h) {
return o(void 0, new LoadFileError(h.message,h.file))
}
: void 0)
}
if (IsBase64DataUrl(s)) {
var c = {
onCompleteObservable: new Observable,
abort: function() {
return function() {}
}
};
try {
e(n ? DecodeBase64UrlToBinary(s) : DecodeBase64UrlToString(s))
} catch (h) {
o ? o(void 0, h) : Logger$2.Error(h.message || "Failed to parse the Data URL")
}
return TimingTools.SetImmediate(function() {
c.onCompleteObservable.notifyObservers(c)
}),
c
}
return RequestFile(s, function(h, f) {
e(h, f ? f.responseURL : void 0)
}, t, r, n, o ? function(h) {
o(h.request, new LoadFileError(h.message,h.request))
}
: void 0, a)
}, RequestFile = function(i, e, t, r, n, o, a) {
i = _CleanUrl(i),
i = FileToolsOptions.PreprocessUrl(i);
var s = FileToolsOptions.BaseUrl + i
, l = !1
, u = {
onCompleteObservable: new Observable,
abort: function() {
return l = !0
}
}
, c = function() {
var d = new WebRequest
, _ = null;
u.abort = function() {
l = !0,
d.readyState !== (XMLHttpRequest.DONE || 4) && d.abort(),
_ !== null && (clearTimeout(_),
_ = null)
}
;
var g = function(v) {
var y = v.message || "Unknown error";
o ? o(new RequestFileError(y,d)) : Logger$2.Error(y)
}
, m = function(v) {
if (d.open("GET", s),
a)
try {
a(d)
} catch (T) {
g(T);
return
}
n && (d.responseType = "arraybuffer"),
t && d.addEventListener("progress", t);
var y = function() {
d.removeEventListener("loadend", y),
u.onCompleteObservable.notifyObservers(u),
u.onCompleteObservable.clear()
};
d.addEventListener("loadend", y);
var b = function() {
if (!l && d.readyState === (XMLHttpRequest.DONE || 4)) {
if (d.removeEventListener("readystatechange", b),
d.status >= 200 && d.status < 300 || d.status === 0 && (!IsWindowObjectExist() || IsFileURL())) {
try {
e(n ? d.response : d.responseText, d)
} catch (S) {
g(S)
}
return
}
var T = FileToolsOptions.DefaultRetryStrategy;
if (T) {
var C = T(s, d, v);
if (C !== -1) {
d.removeEventListener("loadend", y),
d = new WebRequest,
_ = setTimeout(function() {
return m(v + 1)
}, C);
return
}
}
var A = new RequestFileError("Error status: " + d.status + " " + d.statusText + " - Unable to load " + s,d);
o && o(A)
}
};
d.addEventListener("readystatechange", b),
d.send()
};
m(0)
};
if (r && r.enableSceneOffline) {
var h = function(d) {
d && d.status > 400 ? o && o(d) : c()
}
, f = function() {
r && r.loadFile(FileToolsOptions.BaseUrl + i, function(d) {
l || e(d),
u.onCompleteObservable.notifyObservers(u)
}, t ? function(d) {
l || t(d)
}
: void 0, h, n)
};
r.open(f, h)
} else
c();
return u
}, IsFileURL = function() {
return typeof location != "undefined" && location.protocol === "file:"
}, IsBase64DataUrl = function(i) {
return base64DataUrlRegEx.test(i)
};
function DecodeBase64UrlToBinary(i) {
return DecodeBase64ToBinary(i.split(",")[1])
}
var DecodeBase64UrlToString = function(i) {
return DecodeBase64ToString(i.split(",")[1])
}
, initSideEffects$1 = function() {
ThinEngine._FileToolsLoadImage = LoadImage,
ThinEngine._FileToolsLoadFile = LoadFile,
ShaderProcessor._FileToolsLoadFile = LoadFile
};
initSideEffects$1();
_injectLTSFileTools(DecodeBase64UrlToBinary, DecodeBase64UrlToString, FileToolsOptions, IsBase64DataUrl, IsFileURL, LoadFile, LoadImage, ReadFile, RequestFile, SetCorsBehavior);
var PromiseStates;
(function(i) {
i[i.Pending = 0] = "Pending",
i[i.Fulfilled = 1] = "Fulfilled",
i[i.Rejected = 2] = "Rejected"
}
)(PromiseStates || (PromiseStates = {}));
var FulFillmentAgregator = function() {
function i() {
this.count = 0,
this.target = 0,
this.results = []
}
return i
}()
, InternalPromise = function() {
function i(e) {
var t = this;
if (this._state = PromiseStates.Pending,
this._children = new Array,
this._rejectWasConsumed = !1,
!!e)
try {
e(function(r) {
t._resolve(r)
}, function(r) {
t._reject(r)
})
} catch (r) {
this._reject(r)
}
}
return Object.defineProperty(i.prototype, "_result", {
get: function() {
return this._resultValue
},
set: function(e) {
this._resultValue = e,
this._parent && this._parent._result === void 0 && (this._parent._result = e)
},
enumerable: !1,
configurable: !0
}),
i.prototype.catch = function(e) {
return this.then(void 0, e)
}
,
i.prototype.then = function(e, t) {
var r = this
, n = new i;
return n._onFulfilled = e,
n._onRejected = t,
this._children.push(n),
n._parent = this,
this._state !== PromiseStates.Pending && setTimeout(function() {
r._state === PromiseStates.Fulfilled || r._rejectWasConsumed ? n._resolve(r._result) : n._reject(r._reason)
}),
n
}
,
i.prototype._moveChildren = function(e) {
var t, r = this;
if ((t = this._children).push.apply(t, e.splice(0, e.length)),
this._children.forEach(function(u) {
u._parent = r
}),
this._state === PromiseStates.Fulfilled)
for (var n = 0, o = this._children; n < o.length; n++) {
var a = o[n];
a._resolve(this._result)
}
else if (this._state === PromiseStates.Rejected)
for (var s = 0, l = this._children; s < l.length; s++) {
var a = l[s];
a._reject(this._reason)
}
}
,
i.prototype._resolve = function(e) {
try {
this._state = PromiseStates.Fulfilled;
var t = null;
if (this._onFulfilled && (t = this._onFulfilled(e)),
t != null)
if (t._state !== void 0) {
var r = t;
r._parent = this,
r._moveChildren(this._children),
e = r._result
} else
e = t;
this._result = e;
for (var n = 0, o = this._children; n < o.length; n++) {
var a = o[n];
a._resolve(e)
}
this._children.length = 0,
delete this._onFulfilled,
delete this._onRejected
} catch (s) {
this._reject(s, !0)
}
}
,
i.prototype._reject = function(e, t) {
if (t === void 0 && (t = !1),
this._state = PromiseStates.Rejected,
this._reason = e,
this._onRejected && !t)
try {
this._onRejected(e),
this._rejectWasConsumed = !0
} catch (a) {
e = a
}
for (var r = 0, n = this._children; r < n.length; r++) {
var o = n[r];
this._rejectWasConsumed ? o._resolve(null) : o._reject(e)
}
this._children.length = 0,
delete this._onFulfilled,
delete this._onRejected
}
,
i.resolve = function(e) {
var t = new i;
return t._resolve(e),
t
}
,
i._RegisterForFulfillment = function(e, t, r) {
e.then(function(n) {
return t.results[r] = n,
t.count++,
t.count === t.target && t.rootPromise._resolve(t.results),
null
}, function(n) {
t.rootPromise._state !== PromiseStates.Rejected && t.rootPromise._reject(n)
})
}
,
i.all = function(e) {
var t = new i
, r = new FulFillmentAgregator;
if (r.target = e.length,
r.rootPromise = t,
e.length)
for (var n = 0; n < e.length; n++)
i._RegisterForFulfillment(e[n], r, n);
else
t._resolve([]);
return t
}
,
i.race = function(e) {
var t = new i;
if (e.length)
for (var r = 0, n = e; r < n.length; r++) {
var o = n[r];
o.then(function(a) {
return t && (t._resolve(a),
t = null),
null
}, function(a) {
t && (t._reject(a),
t = null)
})
}
return t
}
,
i
}()
, PromisePolyfill = function() {
function i() {}
return i.Apply = function(e) {
if (e === void 0 && (e = !1),
e || typeof Promise == "undefined") {
var t = window;
t.Promise = InternalPromise
}
}
,
i
}()
, _RegisteredTypes = {};
function RegisterClass(i, e) {
_RegisteredTypes[i] = e
}
function GetClass(i) {
return _RegisteredTypes[i]
}
var InstantiationTools = function() {
function i() {}
return i.Instantiate = function(e) {
if (this.RegisteredExternalClasses && this.RegisteredExternalClasses[e])
return this.RegisteredExternalClasses[e];
var t = GetClass(e);
if (t)
return t;
Logger$2.Warn(e + " not found, you may have missed an import.");
for (var r = e.split("."), n = window || this, o = 0, a = r.length; o < a; o++)
n = n[r[o]];
return typeof n != "function" ? null : n
}
,
i.RegisteredExternalClasses = {},
i
}();
function RandomGUID() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(i) {
var e = Math.random() * 16 | 0
, t = i === "x" ? e : e & 3 | 8;
return t.toString(16)
})
}
var SliceTools = function() {
function i() {}
return i.Slice = function(e, t, r) {
return e.slice ? e.slice(t, r) : Array.prototype.slice.call(e, t, r)
}
,
i.SliceToArray = function(e, t, r) {
return Array.isArray(e) ? e.slice(t, r) : Array.prototype.slice.call(e, t, r)
}
,
i
}()
, Tools = function() {
function i() {}
return Object.defineProperty(i, "BaseUrl", {
get: function() {
return FileToolsOptions.BaseUrl
},
set: function(e) {
FileToolsOptions.BaseUrl = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "DefaultRetryStrategy", {
get: function() {
return FileToolsOptions.DefaultRetryStrategy
},
set: function(e) {
FileToolsOptions.DefaultRetryStrategy = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "CorsBehavior", {
get: function() {
return FileToolsOptions.CorsBehavior
},
set: function(e) {
FileToolsOptions.CorsBehavior = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "UseFallbackTexture", {
get: function() {
return EngineStore.UseFallbackTexture
},
set: function(e) {
EngineStore.UseFallbackTexture = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "RegisteredExternalClasses", {
get: function() {
return InstantiationTools.RegisteredExternalClasses
},
set: function(e) {
InstantiationTools.RegisteredExternalClasses = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "fallbackTexture", {
get: function() {
return EngineStore.FallbackTexture
},
set: function(e) {
EngineStore.FallbackTexture = e
},
enumerable: !1,
configurable: !0
}),
i.FetchToRef = function(e, t, r, n, o, a) {
var s = Math.abs(e) * r % r | 0
, l = Math.abs(t) * n % n | 0
, u = (s + l * r) * 4;
a.r = o[u] / 255,
a.g = o[u + 1] / 255,
a.b = o[u + 2] / 255,
a.a = o[u + 3] / 255
}
,
i.Mix = function(e, t, r) {
return e * (1 - r) + t * r
}
,
i.Instantiate = function(e) {
return InstantiationTools.Instantiate(e)
}
,
i.Slice = function(e, t, r) {
return SliceTools.Slice(e, t, r)
}
,
i.SliceToArray = function(e, t, r) {
return SliceTools.SliceToArray(e, t, r)
}
,
i.SetImmediate = function(e) {
TimingTools.SetImmediate(e)
}
,
i.IsExponentOfTwo = function(e) {
var t = 1;
do
t *= 2;
while (t < e);
return t === e
}
,
i.FloatRound = function(e) {
return Math.fround ? Math.fround(e) : (i._tmpFloatArray[0] = e,
i._tmpFloatArray[0])
}
,
i.GetFilename = function(e) {
var t = e.lastIndexOf("/");
return t < 0 ? e : e.substring(t + 1)
}
,
i.GetFolderPath = function(e, t) {
t === void 0 && (t = !1);
var r = e.lastIndexOf("/");
return r < 0 ? t ? e : "" : e.substring(0, r + 1)
}
,
i.ToDegrees = function(e) {
return e * 180 / Math.PI
}
,
i.ToRadians = function(e) {
return e * Math.PI / 180
}
,
i.MakeArray = function(e, t) {
return t !== !0 && (e === void 0 || e == null) ? null : Array.isArray(e) ? e : [e]
}
,
i.GetPointerPrefix = function(e) {
var t = "pointer";
return IsWindowObjectExist() && !window.PointerEvent && IsNavigatorAvailable() && !navigator.pointerEnabled && (t = "mouse"),
e._badDesktopOS && !e._badOS && !(document && "ontouchend"in document) && (t = "mouse"),
t
}
,
i.SetCorsBehavior = function(e, t) {
SetCorsBehavior(e, t)
}
,
i.CleanUrl = function(e) {
return e = e.replace(/#/gm, "%23"),
e
}
,
Object.defineProperty(i, "PreprocessUrl", {
get: function() {
return FileToolsOptions.PreprocessUrl
},
set: function(e) {
FileToolsOptions.PreprocessUrl = e
},
enumerable: !1,
configurable: !0
}),
i.LoadImage = function(e, t, r, n, o, a) {
return LoadImage(e, t, r, n, o, a)
}
,
i.LoadFile = function(e, t, r, n, o, a) {
return LoadFile(e, t, r, n, o, a)
}
,
i.LoadFileAsync = function(e, t) {
return t === void 0 && (t = !0),
new Promise(function(r, n) {
LoadFile(e, function(o) {
r(o)
}, void 0, void 0, t, function(o, a) {
n(a)
})
}
)
}
,
i.LoadScript = function(e, t, r, n) {
if (!!IsWindowObjectExist()) {
var o = document.getElementsByTagName("head")[0]
, a = document.createElement("script");
a.setAttribute("type", "text/javascript"),
a.setAttribute("src", e),
n && (a.id = n),
a.onload = function() {
t && t()
}
,
a.onerror = function(s) {
r && r("Unable to load script '" + e + "'", s)
}
,
o.appendChild(a)
}
}
,
i.LoadScriptAsync = function(e, t) {
var r = this;
return new Promise(function(n, o) {
r.LoadScript(e, function() {
n()
}, function(a, s) {
o(s)
})
}
)
}
,
i.ReadFileAsDataURL = function(e, t, r) {
var n = new FileReader
, o = {
onCompleteObservable: new Observable,
abort: function() {
return n.abort()
}
};
return n.onloadend = function(a) {
o.onCompleteObservable.notifyObservers(o)
}
,
n.onload = function(a) {
t(a.target.result)
}
,
n.onprogress = r,
n.readAsDataURL(e),
o
}
,
i.ReadFile = function(e, t, r, n, o) {
return ReadFile(e, t, r, n, o)
}
,
i.FileAsURL = function(e) {
var t = new Blob([e])
, r = window.URL || window.webkitURL
, n = r.createObjectURL(t);
return n
}
,
i.Format = function(e, t) {
return t === void 0 && (t = 2),
e.toFixed(t)
}
,
i.DeepCopy = function(e, t, r, n) {
DeepCopier.DeepCopy(e, t, r, n)
}
,
i.IsEmpty = function(e) {
for (var t in e)
if (e.hasOwnProperty(t))
return !1;
return !0
}
,
i.RegisterTopRootEvents = function(e, t) {
for (var r = 0; r < t.length; r++) {
var n = t[r];
e.addEventListener(n.name, n.handler, !1);
try {
window.parent && window.parent.addEventListener(n.name, n.handler, !1)
} catch {}
}
}
,
i.UnregisterTopRootEvents = function(e, t) {
for (var r = 0; r < t.length; r++) {
var n = t[r];
e.removeEventListener(n.name, n.handler);
try {
e.parent && e.parent.removeEventListener(n.name, n.handler)
} catch {}
}
}
,
i.DumpFramebuffer = function(e, t, r, n, o, a) {
return o === void 0 && (o = "image/png"),
__awaiter(this, void 0, void 0, function() {
var s, l;
return __generator(this, function(u) {
switch (u.label) {
case 0:
return [4, r.readPixels(0, 0, e, t)];
case 1:
return s = u.sent(),
l = new Uint8Array(s.buffer),
i.DumpData(e, t, l, n, o, a, !0),
[2]
}
})
})
}
,
i.DumpData = function(e, t, r, n, o, a, s, l, u) {
o === void 0 && (o = "image/png"),
s === void 0 && (s = !1),
l === void 0 && (l = !1),
i._ScreenshotCanvas || (i._ScreenshotCanvas = document.createElement("canvas")),
i._ScreenshotCanvas.width = e,
i._ScreenshotCanvas.height = t;
var c = i._ScreenshotCanvas.getContext("2d");
if (c) {
if (r instanceof Float32Array) {
for (var h = new Uint8Array(r.length), f = r.length; f--; ) {
var d = r[f];
h[f] = d < 0 ? 0 : d > 1 ? 1 : Math.round(d * 255)
}
r = h
}
var _ = c.createImageData(e, t)
, g = _.data;
g.set(r),
c.putImageData(_, 0, 0);
var m = i._ScreenshotCanvas;
if (s) {
var v = document.createElement("canvas");
v.width = e,
v.height = t;
var y = v.getContext("2d");
if (!y)
return;
y.translate(0, t),
y.scale(1, -1),
y.drawImage(i._ScreenshotCanvas, 0, 0),
m = v
}
l ? i.ToBlob(m, function(b) {
var T = new FileReader;
T.onload = function(C) {
var A = C.target.result;
n && n(A)
}
,
T.readAsArrayBuffer(b)
}, o, u) : i.EncodeScreenshotCanvasData(n, o, a, m, u)
}
}
,
i.DumpDataAsync = function(e, t, r, n, o, a, s, l) {
return n === void 0 && (n = "image/png"),
a === void 0 && (a = !1),
s === void 0 && (s = !1),
new Promise(function(u) {
i.DumpData(e, t, r, function(c) {
return u(c)
}, n, o, a, s, l)
}
)
}
,
i.ToBlob = function(e, t, r, n) {
r === void 0 && (r = "image/png"),
e.toBlob || (e.toBlob = function(o, a, s) {
var l = this;
setTimeout(function() {
for (var u = atob(l.toDataURL(a, s).split(",")[1]), c = u.length, h = new Uint8Array(c), f = 0; f < c; f++)
h[f] = u.charCodeAt(f);
o(new Blob([h]))
})
}
),
e.toBlob(function(o) {
t(o)
}, r, n)
}
,
i.EncodeScreenshotCanvasData = function(e, t, r, n, o) {
if (t === void 0 && (t = "image/png"),
e) {
var a = (n != null ? n : i._ScreenshotCanvas).toDataURL(t, o);
e(a)
} else
this.ToBlob(n != null ? n : i._ScreenshotCanvas, function(s) {
if ("download"in document.createElement("a")) {
if (!r) {
var l = new Date
, u = (l.getFullYear() + "-" + (l.getMonth() + 1)).slice(2) + "-" + l.getDate() + "_" + l.getHours() + "-" + ("0" + l.getMinutes()).slice(-2);
r = "screenshot_" + u + ".png"
}
i.Download(s, r)
} else {
var c = URL.createObjectURL(s)
, h = window.open("");
if (!h)
return;
var f = h.document.createElement("img");
f.onload = function() {
URL.revokeObjectURL(c)
}
,
f.src = c,
h.document.body.appendChild(f)
}
}, t, o)
}
,
i.Download = function(e, t) {
if (navigator && navigator.msSaveBlob) {
navigator.msSaveBlob(e, t);
return
}
var r = window.URL.createObjectURL(e)
, n = document.createElement("a");
document.body.appendChild(n),
n.style.display = "none",
n.href = r,
n.download = t,
n.addEventListener("click", function() {
n.parentElement && n.parentElement.removeChild(n)
}),
n.click(),
window.URL.revokeObjectURL(r)
}
,
i.BackCompatCameraNoPreventDefault = function(e) {
return typeof e[0] == "boolean" ? e[0] : typeof e[1] == "boolean" ? e[1] : !1
}
,
i.CreateScreenshot = function(e, t, r, n, o) {
throw _WarnImport("ScreenshotTools")
}
,
i.CreateScreenshotAsync = function(e, t, r, n) {
throw _WarnImport("ScreenshotTools")
}
,
i.CreateScreenshotUsingRenderTarget = function(e, t, r, n, o, a, s, l) {
throw _WarnImport("ScreenshotTools")
}
,
i.CreateScreenshotUsingRenderTargetAsync = function(e, t, r, n, o, a, s) {
throw _WarnImport("ScreenshotTools")
}
,
i.RandomId = function() {
return RandomGUID()
}
,
i.IsBase64 = function(e) {
return IsBase64DataUrl(e)
}
,
i.DecodeBase64 = function(e) {
return DecodeBase64UrlToBinary(e)
}
,
Object.defineProperty(i, "errorsCount", {
get: function() {
return Logger$2.errorsCount
},
enumerable: !1,
configurable: !0
}),
i.Log = function(e) {
Logger$2.Log(e)
}
,
i.Warn = function(e) {
Logger$2.Warn(e)
}
,
i.Error = function(e) {
Logger$2.Error(e)
}
,
Object.defineProperty(i, "LogCache", {
get: function() {
return Logger$2.LogCache
},
enumerable: !1,
configurable: !0
}),
i.ClearLogCache = function() {
Logger$2.ClearLogCache()
}
,
Object.defineProperty(i, "LogLevels", {
set: function(e) {
Logger$2.LogLevels = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "PerformanceLogLevel", {
set: function(e) {
if ((e & i.PerformanceUserMarkLogLevel) === i.PerformanceUserMarkLogLevel) {
i.StartPerformanceCounter = i._StartUserMark,
i.EndPerformanceCounter = i._EndUserMark;
return
}
if ((e & i.PerformanceConsoleLogLevel) === i.PerformanceConsoleLogLevel) {
i.StartPerformanceCounter = i._StartPerformanceConsole,
i.EndPerformanceCounter = i._EndPerformanceConsole;
return
}
i.StartPerformanceCounter = i._StartPerformanceCounterDisabled,
i.EndPerformanceCounter = i._EndPerformanceCounterDisabled
},
enumerable: !1,
configurable: !0
}),
i._StartPerformanceCounterDisabled = function(e, t) {}
,
i._EndPerformanceCounterDisabled = function(e, t) {}
,
i._StartUserMark = function(e, t) {
if (t === void 0 && (t = !0),
!i._performance) {
if (!IsWindowObjectExist())
return;
i._performance = window.performance
}
!t || !i._performance.mark || i._performance.mark(e + "-Begin")
}
,
i._EndUserMark = function(e, t) {
t === void 0 && (t = !0),
!(!t || !i._performance.mark) && (i._performance.mark(e + "-End"),
i._performance.measure(e, e + "-Begin", e + "-End"))
}
,
i._StartPerformanceConsole = function(e, t) {
t === void 0 && (t = !0),
t && (i._StartUserMark(e, t),
console.time && console.time(e))
}
,
i._EndPerformanceConsole = function(e, t) {
t === void 0 && (t = !0),
t && (i._EndUserMark(e, t),
console.timeEnd(e))
}
,
Object.defineProperty(i, "Now", {
get: function() {
return PrecisionDate.Now
},
enumerable: !1,
configurable: !0
}),
i.GetClassName = function(e, t) {
t === void 0 && (t = !1);
var r = null;
if (!t && e.getClassName)
r = e.getClassName();
else {
if (e instanceof Object) {
var n = t ? e : Object.getPrototypeOf(e);
r = n.constructor.__bjsclassName__
}
r || (r = typeof e)
}
return r
}
,
i.First = function(e, t) {
for (var r = 0, n = e; r < n.length; r++) {
var o = n[r];
if (t(o))
return o
}
return null
}
,
i.getFullClassName = function(e, t) {
t === void 0 && (t = !1);
var r = null
, n = null;
if (!t && e.getClassName)
r = e.getClassName();
else {
if (e instanceof Object) {
var o = t ? e : Object.getPrototypeOf(e);
r = o.constructor.__bjsclassName__,
n = o.constructor.__bjsmoduleName__
}
r || (r = typeof e)
}
return r ? (n != null ? n + "." : "") + r : null
}
,
i.DelayAsync = function(e) {
return new Promise(function(t) {
setTimeout(function() {
t()
}, e)
}
)
}
,
i.IsSafari = function() {
return IsNavigatorAvailable() ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : !1
}
,
i.UseCustomRequestHeaders = !1,
i.CustomRequestHeaders = WebRequest.CustomRequestHeaders,
i._tmpFloatArray = new Float32Array(1),
i.GetDOMTextContent = GetDOMTextContent,
i.GetAbsoluteUrl = typeof document == "object" ? function(e) {
var t = document.createElement("a");
return t.href = e,
t.href
}
: typeof URL == "function" && typeof location == "object" ? function(e) {
return new URL(e,location.origin).href
}
: function(e) {
throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")
}
,
i.NoneLogLevel = Logger$2.NoneLogLevel,
i.MessageLogLevel = Logger$2.MessageLogLevel,
i.WarningLogLevel = Logger$2.WarningLogLevel,
i.ErrorLogLevel = Logger$2.ErrorLogLevel,
i.AllLogLevel = Logger$2.AllLogLevel,
i.IsWindowObjectExist = IsWindowObjectExist,
i.PerformanceNoneLogLevel = 0,
i.PerformanceUserMarkLogLevel = 1,
i.PerformanceConsoleLogLevel = 2,
i.StartPerformanceCounter = i._StartPerformanceCounterDisabled,
i.EndPerformanceCounter = i._EndPerformanceCounterDisabled,
i
}()
, AsyncLoop = function() {
function i(e, t, r, n) {
n === void 0 && (n = 0),
this.iterations = e,
this.index = n - 1,
this._done = !1,
this._fn = t,
this._successCallback = r
}
return i.prototype.executeNext = function() {
this._done || (this.index + 1 < this.iterations ? (++this.index,
this._fn(this)) : this.breakLoop())
}
,
i.prototype.breakLoop = function() {
this._done = !0,
this._successCallback()
}
,
i.Run = function(e, t, r, n) {
n === void 0 && (n = 0);
var o = new i(e,t,r,n);
return o.executeNext(),
o
}
,
i.SyncAsyncForLoop = function(e, t, r, n, o, a) {
return a === void 0 && (a = 0),
i.Run(Math.ceil(e / t), function(s) {
o && o() ? s.breakLoop() : setTimeout(function() {
for (var l = 0; l < t; ++l) {
var u = s.index * t + l;
if (u >= e)
break;
if (r(u),
o && o()) {
s.breakLoop();
break
}
}
s.executeNext()
}, a)
}, n)
}
,
i
}();
EngineStore.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";
PromisePolyfill.Apply();
var SmartArray = function() {
function i(e) {
this.length = 0,
this.data = new Array(e),
this._id = i._GlobalId++
}
return i.prototype.push = function(e) {
this.data[this.length++] = e,
this.length > this.data.length && (this.data.length *= 2)
}
,
i.prototype.forEach = function(e) {
for (var t = 0; t < this.length; t++)
e(this.data[t])
}
,
i.prototype.sort = function(e) {
this.data.sort(e)
}
,
i.prototype.reset = function() {
this.length = 0
}
,
i.prototype.dispose = function() {
this.reset(),
this.data && (this.data.length = 0,
this.data = [])
}
,
i.prototype.concat = function(e) {
if (e.length !== 0) {
this.length + e.length > this.data.length && (this.data.length = (this.length + e.length) * 2);
for (var t = 0; t < e.length; t++)
this.data[this.length++] = (e.data || e)[t]
}
}
,
i.prototype.indexOf = function(e) {
var t = this.data.indexOf(e);
return t >= this.length ? -1 : t
}
,
i.prototype.contains = function(e) {
return this.indexOf(e) !== -1
}
,
i._GlobalId = 0,
i
}()
, SmartArrayNoDuplicate = function(i) {
__extends(e, i);
function e() {
var t = i !== null && i.apply(this, arguments) || this;
return t._duplicateId = 0,
t
}
return e.prototype.push = function(t) {
i.prototype.push.call(this, t),
t.__smartArrayFlags || (t.__smartArrayFlags = {}),
t.__smartArrayFlags[this._id] = this._duplicateId
}
,
e.prototype.pushNoDuplicate = function(t) {
return t.__smartArrayFlags && t.__smartArrayFlags[this._id] === this._duplicateId ? !1 : (this.push(t),
!0)
}
,
e.prototype.reset = function() {
i.prototype.reset.call(this),
this._duplicateId++
}
,
e.prototype.concatWithNoDuplicate = function(t) {
if (t.length !== 0) {
this.length + t.length > this.data.length && (this.data.length = (this.length + t.length) * 2);
for (var r = 0; r < t.length; r++) {
var n = (t.data || t)[r];
this.pushNoDuplicate(n)
}
}
}
,
e
}(SmartArray)
, StringDictionary = function() {
function i() {
this._count = 0,
this._data = {}
}
return i.prototype.copyFrom = function(e) {
var t = this;
this.clear(),
e.forEach(function(r, n) {
return t.add(r, n)
})
}
,
i.prototype.get = function(e) {
var t = this._data[e];
if (t !== void 0)
return t
}
,
i.prototype.getOrAddWithFactory = function(e, t) {
var r = this.get(e);
return r !== void 0 || (r = t(e),
r && this.add(e, r)),
r
}
,
i.prototype.getOrAdd = function(e, t) {
var r = this.get(e);
return r !== void 0 ? r : (this.add(e, t),
t)
}
,
i.prototype.contains = function(e) {
return this._data[e] !== void 0
}
,
i.prototype.add = function(e, t) {
return this._data[e] !== void 0 ? !1 : (this._data[e] = t,
++this._count,
!0)
}
,
i.prototype.set = function(e, t) {
return this._data[e] === void 0 ? !1 : (this._data[e] = t,
!0)
}
,
i.prototype.getAndRemove = function(e) {
var t = this.get(e);
return t !== void 0 ? (delete this._data[e],
--this._count,
t) : null
}
,
i.prototype.remove = function(e) {
return this.contains(e) ? (delete this._data[e],
--this._count,
!0) : !1
}
,
i.prototype.clear = function() {
this._data = {},
this._count = 0
}
,
Object.defineProperty(i.prototype, "count", {
get: function() {
return this._count
},
enumerable: !1,
configurable: !0
}),
i.prototype.forEach = function(e) {
for (var t in this._data) {
var r = this._data[t];
e(t, r)
}
}
,
i.prototype.first = function(e) {
for (var t in this._data) {
var r = this._data[t]
, n = e(t, r);
if (n)
return n
}
return null
}
,
i
}()
, AndOrNotEvaluator = function() {
function i() {}
return i.Eval = function(e, t) {
return e.match(/\([^\(\)]*\)/g) ? e = e.replace(/\([^\(\)]*\)/g, function(r) {
return r = r.slice(1, r.length - 1),
i._HandleParenthesisContent(r, t)
}) : e = i._HandleParenthesisContent(e, t),
e === "true" ? !0 : e === "false" ? !1 : i.Eval(e, t)
}
,
i._HandleParenthesisContent = function(e, t) {
t = t || function(c) {
return c === "true"
}
;
var r, n = e.split("||");
for (var o in n)
if (n.hasOwnProperty(o)) {
var a = i._SimplifyNegation(n[o].trim())
, s = a.split("&&");
if (s.length > 1)
for (var l = 0; l < s.length; ++l) {
var u = i._SimplifyNegation(s[l].trim());
if (u !== "true" && u !== "false" ? u[0] === "!" ? r = !t(u.substring(1)) : r = t(u) : r = u === "true",
!r) {
a = "false";
break
}
}
if (r || a === "true") {
r = !0;
break
}
a !== "true" && a !== "false" ? a[0] === "!" ? r = !t(a.substring(1)) : r = t(a) : r = a === "true"
}
return r ? "true" : "false"
}
,
i._SimplifyNegation = function(e) {
return e = e.replace(/^[\s!]+/, function(t) {
return t = t.replace(/[\s]/g, function() {
return ""
}),
t.length % 2 ? "!" : ""
}),
e = e.trim(),
e === "!true" ? e = "false" : e === "!false" && (e = "true"),
e
}
,
i
}()
, Tags = function() {
function i() {}
return i.EnableFor = function(e) {
e._tags = e._tags || {},
e.hasTags = function() {
return i.HasTags(e)
}
,
e.addTags = function(t) {
return i.AddTagsTo(e, t)
}
,
e.removeTags = function(t) {
return i.RemoveTagsFrom(e, t)
}
,
e.matchesTagsQuery = function(t) {
return i.MatchesQuery(e, t)
}
}
,
i.DisableFor = function(e) {
delete e._tags,
delete e.hasTags,
delete e.addTags,
delete e.removeTags,
delete e.matchesTagsQuery
}
,
i.HasTags = function(e) {
if (!e._tags)
return !1;
var t = e._tags;
for (var r in t)
if (t.hasOwnProperty(r))
return !0;
return !1
}
,
i.GetTags = function(e, t) {
if (t === void 0 && (t = !0),
!e._tags)
return null;
if (t) {
var r = [];
for (var n in e._tags)
e._tags.hasOwnProperty(n) && e._tags[n] === !0 && r.push(n);
return r.join(" ")
} else
return e._tags
}
,
i.AddTagsTo = function(e, t) {
if (!!t && typeof t == "string") {
var r = t.split(" ");
r.forEach(function(n, o, a) {
i._AddTagTo(e, n)
})
}
}
,
i._AddTagTo = function(e, t) {
t = t.trim(),
!(t === "" || t === "true" || t === "false") && (t.match(/[\s]/) || t.match(/^([!]|([|]|[&]){2})/) || (i.EnableFor(e),
e._tags[t] = !0))
}
,
i.RemoveTagsFrom = function(e, t) {
if (!!i.HasTags(e)) {
var r = t.split(" ");
for (var n in r)
i._RemoveTagFrom(e, r[n])
}
}
,
i._RemoveTagFrom = function(e, t) {
delete e._tags[t]
}
,
i.MatchesQuery = function(e, t) {
return t === void 0 ? !0 : t === "" ? i.HasTags(e) : AndOrNotEvaluator.Eval(t, function(r) {
return i.HasTags(e) && e._tags[r]
})
}
,
i
}()
, Scalar = function() {
function i() {}
return i.WithinEpsilon = function(e, t, r) {
return r === void 0 && (r = 1401298e-51),
Math.abs(e - t) <= r
}
,
i.ToHex = function(e) {
var t = e.toString(16);
return e <= 15 ? ("0" + t).toUpperCase() : t.toUpperCase()
}
,
i.Sign = function(e) {
return e = +e,
e === 0 || isNaN(e) ? e : e > 0 ? 1 : -1
}
,
i.Clamp = function(e, t, r) {
return t === void 0 && (t = 0),
r === void 0 && (r = 1),
Math.min(r, Math.max(t, e))
}
,
i.Log2 = function(e) {
return Math.log(e) * Math.LOG2E
}
,
i.ILog2 = function(e) {
if (Math.log2)
return Math.floor(Math.log2(e));
if (e < 0)
return NaN;
if (e === 0)
return -1 / 0;
var t = 0;
if (e < 1) {
for (; e < 1; )
t++,
e = e * 2;
t = -t
} else if (e > 1)
for (; e > 1; )
t++,
e = Math.floor(e / 2);
return t
}
,
i.Repeat = function(e, t) {
return e - Math.floor(e / t) * t
}
,
i.Normalize = function(e, t, r) {
return (e - t) / (r - t)
}
,
i.Denormalize = function(e, t, r) {
return e * (r - t) + t
}
,
i.DeltaAngle = function(e, t) {
var r = i.Repeat(t - e, 360);
return r > 180 && (r -= 360),
r
}
,
i.PingPong = function(e, t) {
var r = i.Repeat(e, t * 2);
return t - Math.abs(r - t)
}
,
i.SmoothStep = function(e, t, r) {
var n = i.Clamp(r);
return n = -2 * n * n * n + 3 * n * n,
t * n + e * (1 - n)
}
,
i.MoveTowards = function(e, t, r) {
var n = 0;
return Math.abs(t - e) <= r ? n = t : n = e + i.Sign(t - e) * r,
n
}
,
i.MoveTowardsAngle = function(e, t, r) {
var n = i.DeltaAngle(e, t)
, o = 0;
return -r < n && n < r ? o = t : (t = e + n,
o = i.MoveTowards(e, t, r)),
o
}
,
i.Lerp = function(e, t, r) {
return e + (t - e) * r
}
,
i.LerpAngle = function(e, t, r) {
var n = i.Repeat(t - e, 360);
return n > 180 && (n -= 360),
e + n * i.Clamp(r)
}
,
i.InverseLerp = function(e, t, r) {
var n = 0;
return e != t ? n = i.Clamp((r - e) / (t - e)) : n = 0,
n
}
,
i.Hermite = function(e, t, r, n, o) {
var a = o * o
, s = o * a
, l = 2 * s - 3 * a + 1
, u = -2 * s + 3 * a
, c = s - 2 * a + o
, h = s - a;
return e * l + r * u + t * c + n * h
}
,
i.Hermite1stDerivative = function(e, t, r, n, o) {
var a = o * o;
return (a - o) * 6 * e + (3 * a - 4 * o + 1) * t + (-a + o) * 6 * r + (3 * a - 2 * o) * n
}
,
i.RandomRange = function(e, t) {
return e === t ? e : Math.random() * (t - e) + e
}
,
i.RangeToPercent = function(e, t, r) {
return (e - t) / (r - t)
}
,
i.PercentToRange = function(e, t, r) {
return (r - t) * e + t
}
,
i.NormalizeRadians = function(e) {
return e -= i.TwoPi * Math.floor((e + Math.PI) / i.TwoPi),
e
}
,
i.HCF = function(e, t) {
var r = e % t;
return r === 0 ? t : i.HCF(t, r)
}
,
i.TwoPi = Math.PI * 2,
i
}()
, ToGammaSpace = 1 / 2.2
, ToLinearSpace = 2.2
, PHI = (1 + Math.sqrt(5)) / 2
, Epsilon = .001
, ArrayTools = function() {
function i() {}
return i.BuildArray = function(e, t) {
for (var r = [], n = 0; n < e; ++n)
r.push(t());
return r
}
,
i.BuildTuple = function(e, t) {
return i.BuildArray(e, t)
}
,
i
}()
, Vector2 = function() {
function i(e, t) {
e === void 0 && (e = 0),
t === void 0 && (t = 0),
this.x = e,
this.y = t
}
return i.prototype.toString = function() {
return "{X: " + this.x + " Y: " + this.y + "}"
}
,
i.prototype.getClassName = function() {
return "Vector2"
}
,
i.prototype.getHashCode = function() {
var e = this.x | 0;
return e = e * 397 ^ (this.y | 0),
e
}
,
i.prototype.toArray = function(e, t) {
return t === void 0 && (t = 0),
e[t] = this.x,
e[t + 1] = this.y,
this
}
,
i.prototype.fromArray = function(e, t) {
return t === void 0 && (t = 0),
i.FromArrayToRef(e, t, this),
this
}
,
i.prototype.asArray = function() {
var e = new Array;
return this.toArray(e, 0),
e
}
,
i.prototype.copyFrom = function(e) {
return this.x = e.x,
this.y = e.y,
this
}
,
i.prototype.copyFromFloats = function(e, t) {
return this.x = e,
this.y = t,
this
}
,
i.prototype.set = function(e, t) {
return this.copyFromFloats(e, t)
}
,
i.prototype.add = function(e) {
return new i(this.x + e.x,this.y + e.y)
}
,
i.prototype.addToRef = function(e, t) {
return t.x = this.x + e.x,
t.y = this.y + e.y,
this
}
,
i.prototype.addInPlace = function(e) {
return this.x += e.x,
this.y += e.y,
this
}
,
i.prototype.addVector3 = function(e) {
return new i(this.x + e.x,this.y + e.y)
}
,
i.prototype.subtract = function(e) {
return new i(this.x - e.x,this.y - e.y)
}
,
i.prototype.subtractToRef = function(e, t) {
return t.x = this.x - e.x,
t.y = this.y - e.y,
this
}
,
i.prototype.subtractInPlace = function(e) {
return this.x -= e.x,
this.y -= e.y,
this
}
,
i.prototype.multiplyInPlace = function(e) {
return this.x *= e.x,
this.y *= e.y,
this
}
,
i.prototype.multiply = function(e) {
return new i(this.x * e.x,this.y * e.y)
}
,
i.prototype.multiplyToRef = function(e, t) {
return t.x = this.x * e.x,
t.y = this.y * e.y,
this
}
,
i.prototype.multiplyByFloats = function(e, t) {
return new i(this.x * e,this.y * t)
}
,
i.prototype.divide = function(e) {
return new i(this.x / e.x,this.y / e.y)
}
,
i.prototype.divideToRef = function(e, t) {
return t.x = this.x / e.x,
t.y = this.y / e.y,
this
}
,
i.prototype.divideInPlace = function(e) {
return this.divideToRef(e, this)
}
,
i.prototype.negate = function() {
return new i(-this.x,-this.y)
}
,
i.prototype.negateInPlace = function() {
return this.x *= -1,
this.y *= -1,
this
}
,
i.prototype.negateToRef = function(e) {
return e.copyFromFloats(this.x * -1, this.y * -1)
}
,
i.prototype.scaleInPlace = function(e) {
return this.x *= e,
this.y *= e,
this
}
,
i.prototype.scale = function(e) {
var t = new i(0,0);
return this.scaleToRef(e, t),
t
}
,
i.prototype.scaleToRef = function(e, t) {
return t.x = this.x * e,
t.y = this.y * e,
this
}
,
i.prototype.scaleAndAddToRef = function(e, t) {
return t.x += this.x * e,
t.y += this.y * e,
this
}
,
i.prototype.equals = function(e) {
return e && this.x === e.x && this.y === e.y
}
,
i.prototype.equalsWithEpsilon = function(e, t) {
return t === void 0 && (t = Epsilon),
e && Scalar.WithinEpsilon(this.x, e.x, t) && Scalar.WithinEpsilon(this.y, e.y, t)
}
,
i.prototype.floor = function() {
return new i(Math.floor(this.x),Math.floor(this.y))
}
,
i.prototype.fract = function() {
return new i(this.x - Math.floor(this.x),this.y - Math.floor(this.y))
}
,
i.prototype.rotateToRef = function(e, t) {
var r = Math.cos(e)
, n = Math.sin(e);
return t.x = r * this.x - n * this.y,
t.y = n * this.x + r * this.y,
this
}
,
i.prototype.length = function() {
return Math.sqrt(this.x * this.x + this.y * this.y)
}
,
i.prototype.lengthSquared = function() {
return this.x * this.x + this.y * this.y
}
,
i.prototype.normalize = function() {
return i.NormalizeToRef(this, this),
this
}
,
i.prototype.clone = function() {
return new i(this.x,this.y)
}
,
i.Zero = function() {
return new i(0,0)
}
,
i.One = function() {
return new i(1,1)
}
,
i.FromArray = function(e, t) {
return t === void 0 && (t = 0),
new i(e[t],e[t + 1])
}
,
i.FromArrayToRef = function(e, t, r) {
r.x = e[t],
r.y = e[t + 1]
}
,
i.CatmullRom = function(e, t, r, n, o) {
var a = o * o
, s = o * a
, l = .5 * (2 * t.x + (-e.x + r.x) * o + (2 * e.x - 5 * t.x + 4 * r.x - n.x) * a + (-e.x + 3 * t.x - 3 * r.x + n.x) * s)
, u = .5 * (2 * t.y + (-e.y + r.y) * o + (2 * e.y - 5 * t.y + 4 * r.y - n.y) * a + (-e.y + 3 * t.y - 3 * r.y + n.y) * s);
return new i(l,u)
}
,
i.Clamp = function(e, t, r) {
var n = e.x;
n = n > r.x ? r.x : n,
n = n < t.x ? t.x : n;
var o = e.y;
return o = o > r.y ? r.y : o,
o = o < t.y ? t.y : o,
new i(n,o)
}
,
i.Hermite = function(e, t, r, n, o) {
var a = o * o
, s = o * a
, l = 2 * s - 3 * a + 1
, u = -2 * s + 3 * a
, c = s - 2 * a + o
, h = s - a
, f = e.x * l + r.x * u + t.x * c + n.x * h
, d = e.y * l + r.y * u + t.y * c + n.y * h;
return new i(f,d)
}
,
i.Hermite1stDerivative = function(e, t, r, n, o) {
var a = i.Zero();
return this.Hermite1stDerivativeToRef(e, t, r, n, o, a),
a
}
,
i.Hermite1stDerivativeToRef = function(e, t, r, n, o, a) {
var s = o * o;
a.x = (s - o) * 6 * e.x + (3 * s - 4 * o + 1) * t.x + (-s + o) * 6 * r.x + (3 * s - 2 * o) * n.x,
a.y = (s - o) * 6 * e.y + (3 * s - 4 * o + 1) * t.y + (-s + o) * 6 * r.y + (3 * s - 2 * o) * n.y
}
,
i.Lerp = function(e, t, r) {
var n = e.x + (t.x - e.x) * r
, o = e.y + (t.y - e.y) * r;
return new i(n,o)
}
,
i.Dot = function(e, t) {
return e.x * t.x + e.y * t.y
}
,
i.Normalize = function(e) {
var t = i.Zero();
return this.NormalizeToRef(e, t),
t
}
,
i.NormalizeToRef = function(e, t) {
var r = e.length();
r !== 0 && (t.x = e.x / r,
t.y = e.y / r)
}
,
i.Minimize = function(e, t) {
var r = e.x < t.x ? e.x : t.x
, n = e.y < t.y ? e.y : t.y;
return new i(r,n)
}
,
i.Maximize = function(e, t) {
var r = e.x > t.x ? e.x : t.x
, n = e.y > t.y ? e.y : t.y;
return new i(r,n)
}
,
i.Transform = function(e, t) {
var r = i.Zero();
return i.TransformToRef(e, t, r),
r
}
,
i.TransformToRef = function(e, t, r) {
var n = t.m
, o = e.x * n[0] + e.y * n[4] + n[12]
, a = e.x * n[1] + e.y * n[5] + n[13];
r.x = o,
r.y = a
}
,
i.PointInTriangle = function(e, t, r, n) {
var o = .5 * (-r.y * n.x + t.y * (-r.x + n.x) + t.x * (r.y - n.y) + r.x * n.y)
, a = o < 0 ? -1 : 1
, s = (t.y * n.x - t.x * n.y + (n.y - t.y) * e.x + (t.x - n.x) * e.y) * a
, l = (t.x * r.y - t.y * r.x + (t.y - r.y) * e.x + (r.x - t.x) * e.y) * a;
return s > 0 && l > 0 && s + l < 2 * o * a
}
,
i.Distance = function(e, t) {
return Math.sqrt(i.DistanceSquared(e, t))
}
,
i.DistanceSquared = function(e, t) {
var r = e.x - t.x
, n = e.y - t.y;
return r * r + n * n
}
,
i.Center = function(e, t) {
return i.CenterToRef(e, t, i.Zero())
}
,
i.CenterToRef = function(e, t, r) {
return r.copyFromFloats((e.x + t.x) / 2, (e.y + t.y) / 2)
}
,
i.DistanceOfPointFromSegment = function(e, t, r) {
var n = i.DistanceSquared(t, r);
if (n === 0)
return i.Distance(e, t);
var o = r.subtract(t)
, a = Math.max(0, Math.min(1, i.Dot(e.subtract(t), o) / n))
, s = t.add(o.multiplyByFloats(a, a));
return i.Distance(e, s)
}
,
i
}()
, Vector3 = function() {
function i(e, t, r) {
e === void 0 && (e = 0),
t === void 0 && (t = 0),
r === void 0 && (r = 0),
this._isDirty = !0,
this._x = e,
this._y = t,
this._z = r
}
return Object.defineProperty(i.prototype, "x", {
get: function() {
return this._x
},
set: function(e) {
this._x = e,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "y", {
get: function() {
return this._y
},
set: function(e) {
this._y = e,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "z", {
get: function() {
return this._z
},
set: function(e) {
this._z = e,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
i.prototype.toString = function() {
return "{X: " + this._x + " Y: " + this._y + " Z: " + this._z + "}"
}
,
i.prototype.getClassName = function() {
return "Vector3"
}
,
i.prototype.getHashCode = function() {
var e = this._x | 0;
return e = e * 397 ^ (this._y | 0),
e = e * 397 ^ (this._z | 0),
e
}
,
i.prototype.asArray = function() {
var e = [];
return this.toArray(e, 0),
e
}
,
i.prototype.toArray = function(e, t) {
return t === void 0 && (t = 0),
e[t] = this._x,
e[t + 1] = this._y,
e[t + 2] = this._z,
this
}
,
i.prototype.fromArray = function(e, t) {
return t === void 0 && (t = 0),
i.FromArrayToRef(e, t, this),
this
}
,
i.prototype.toQuaternion = function() {
return Quaternion.RotationYawPitchRoll(this._y, this._x, this._z)
}
,
i.prototype.addInPlace = function(e) {
return this.addInPlaceFromFloats(e._x, e._y, e._z)
}
,
i.prototype.addInPlaceFromFloats = function(e, t, r) {
return this.x += e,
this.y += t,
this.z += r,
this
}
,
i.prototype.add = function(e) {
return new i(this._x + e._x,this._y + e._y,this._z + e._z)
}
,
i.prototype.addToRef = function(e, t) {
return t.copyFromFloats(this._x + e._x, this._y + e._y, this._z + e._z)
}
,
i.prototype.subtractInPlace = function(e) {
return this.x -= e._x,
this.y -= e._y,
this.z -= e._z,
this
}
,
i.prototype.subtract = function(e) {
return new i(this._x - e._x,this._y - e._y,this._z - e._z)
}
,
i.prototype.subtractToRef = function(e, t) {
return this.subtractFromFloatsToRef(e._x, e._y, e._z, t)
}
,
i.prototype.subtractFromFloats = function(e, t, r) {
return new i(this._x - e,this._y - t,this._z - r)
}
,
i.prototype.subtractFromFloatsToRef = function(e, t, r, n) {
return n.copyFromFloats(this._x - e, this._y - t, this._z - r)
}
,
i.prototype.negate = function() {
return new i(-this._x,-this._y,-this._z)
}
,
i.prototype.negateInPlace = function() {
return this.x *= -1,
this.y *= -1,
this.z *= -1,
this
}
,
i.prototype.negateToRef = function(e) {
return e.copyFromFloats(this._x * -1, this._y * -1, this._z * -1)
}
,
i.prototype.scaleInPlace = function(e) {
return this.x *= e,
this.y *= e,
this.z *= e,
this
}
,
i.prototype.scale = function(e) {
return new i(this._x * e,this._y * e,this._z * e)
}
,
i.prototype.scaleToRef = function(e, t) {
return t.copyFromFloats(this._x * e, this._y * e, this._z * e)
}
,
i.prototype.scaleAndAddToRef = function(e, t) {
return t.addInPlaceFromFloats(this._x * e, this._y * e, this._z * e)
}
,
i.prototype.projectOnPlane = function(e, t) {
var r = i.Zero();
return this.projectOnPlaneToRef(e, t, r),
r
}
,
i.prototype.projectOnPlaneToRef = function(e, t, r) {
var n = e.normal
, o = e.d
, a = MathTmp.Vector3[0];
this.subtractToRef(t, a),
a.normalize();
var s = i.Dot(a, n)
, l = -(i.Dot(t, n) + o) / s
, u = a.scaleInPlace(l);
t.addToRef(u, r)
}
,
i.prototype.equals = function(e) {
return e && this._x === e._x && this._y === e._y && this._z === e._z
}
,
i.prototype.equalsWithEpsilon = function(e, t) {
return t === void 0 && (t = Epsilon),
e && Scalar.WithinEpsilon(this._x, e._x, t) && Scalar.WithinEpsilon(this._y, e._y, t) && Scalar.WithinEpsilon(this._z, e._z, t)
}
,
i.prototype.equalsToFloats = function(e, t, r) {
return this._x === e && this._y === t && this._z === r
}
,
i.prototype.multiplyInPlace = function(e) {
return this.x *= e._x,
this.y *= e._y,
this.z *= e._z,
this
}
,
i.prototype.multiply = function(e) {
return this.multiplyByFloats(e._x, e._y, e._z)
}
,
i.prototype.multiplyToRef = function(e, t) {
return t.copyFromFloats(this._x * e._x, this._y * e._y, this._z * e._z)
}
,
i.prototype.multiplyByFloats = function(e, t, r) {
return new i(this._x * e,this._y * t,this._z * r)
}
,
i.prototype.divide = function(e) {
return new i(this._x / e._x,this._y / e._y,this._z / e._z)
}
,
i.prototype.divideToRef = function(e, t) {
return t.copyFromFloats(this._x / e._x, this._y / e._y, this._z / e._z)
}
,
i.prototype.divideInPlace = function(e) {
return this.divideToRef(e, this)
}
,
i.prototype.minimizeInPlace = function(e) {
return this.minimizeInPlaceFromFloats(e._x, e._y, e._z)
}
,
i.prototype.maximizeInPlace = function(e) {
return this.maximizeInPlaceFromFloats(e._x, e._y, e._z)
}
,
i.prototype.minimizeInPlaceFromFloats = function(e, t, r) {
return e < this._x && (this.x = e),
t < this._y && (this.y = t),
r < this._z && (this.z = r),
this
}
,
i.prototype.maximizeInPlaceFromFloats = function(e, t, r) {
return e > this._x && (this.x = e),
t > this._y && (this.y = t),
r > this._z && (this.z = r),
this
}
,
i.prototype.isNonUniformWithinEpsilon = function(e) {
var t = Math.abs(this._x)
, r = Math.abs(this._y);
if (!Scalar.WithinEpsilon(t, r, e))
return !0;
var n = Math.abs(this._z);
return !Scalar.WithinEpsilon(t, n, e) || !Scalar.WithinEpsilon(r, n, e)
}
,
Object.defineProperty(i.prototype, "isNonUniform", {
get: function() {
var e = Math.abs(this._x)
, t = Math.abs(this._y);
if (e !== t)
return !0;
var r = Math.abs(this._z);
return e !== r
},
enumerable: !1,
configurable: !0
}),
i.prototype.floor = function() {
return new i(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))
}
,
i.prototype.fract = function() {
return new i(this._x - Math.floor(this._x),this._y - Math.floor(this._y),this._z - Math.floor(this._z))
}
,
i.prototype.length = function() {
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z)
}
,
i.prototype.lengthSquared = function() {
return this._x * this._x + this._y * this._y + this._z * this._z
}
,
i.prototype.normalize = function() {
return this.normalizeFromLength(this.length())
}
,
i.prototype.reorderInPlace = function(e) {
var t = this;
return e = e.toLowerCase(),
e === "xyz" ? this : (MathTmp.Vector3[0].copyFrom(this),
["x", "y", "z"].forEach(function(r, n) {
t[r] = MathTmp.Vector3[0][e[n]]
}),
this)
}
,
i.prototype.rotateByQuaternionToRef = function(e, t) {
return e.toRotationMatrix(MathTmp.Matrix[0]),
i.TransformCoordinatesToRef(this, MathTmp.Matrix[0], t),
t
}
,
i.prototype.rotateByQuaternionAroundPointToRef = function(e, t, r) {
return this.subtractToRef(t, MathTmp.Vector3[0]),
MathTmp.Vector3[0].rotateByQuaternionToRef(e, MathTmp.Vector3[0]),
t.addToRef(MathTmp.Vector3[0], r),
r
}
,
i.prototype.cross = function(e) {
return i.Cross(this, e)
}
,
i.prototype.normalizeFromLength = function(e) {
return e === 0 || e === 1 ? this : this.scaleInPlace(1 / e)
}
,
i.prototype.normalizeToNew = function() {
var e = new i(0,0,0);
return this.normalizeToRef(e),
e
}
,
i.prototype.normalizeToRef = function(e) {
var t = this.length();
return t === 0 || t === 1 ? e.copyFromFloats(this._x, this._y, this._z) : this.scaleToRef(1 / t, e)
}
,
i.prototype.clone = function() {
return new i(this._x,this._y,this._z)
}
,
i.prototype.copyFrom = function(e) {
return this.copyFromFloats(e._x, e._y, e._z)
}
,
i.prototype.copyFromFloats = function(e, t, r) {
return this.x = e,
this.y = t,
this.z = r,
this
}
,
i.prototype.set = function(e, t, r) {
return this.copyFromFloats(e, t, r)
}
,
i.prototype.setAll = function(e) {
return this.x = this.y = this.z = e,
this
}
,
i.GetClipFactor = function(e, t, r, n) {
var o = i.Dot(e, r) - n
, a = i.Dot(t, r) - n
, s = o / (o - a);
return s
}
,
i.GetAngleBetweenVectors = function(e, t, r) {
var n = e.normalizeToRef(MathTmp.Vector3[1])
, o = t.normalizeToRef(MathTmp.Vector3[2])
, a = i.Dot(n, o)
, s = Math.acos(a)
, l = MathTmp.Vector3[3];
return i.CrossToRef(n, o, l),
i.Dot(l, r) > 0 ? isNaN(s) ? 0 : s : isNaN(s) ? -Math.PI : -Math.acos(a)
}
,
i.GetAngleBetweenVectorsOnPlane = function(e, t, r) {
MathTmp.Vector3[0].copyFrom(e);
var n = MathTmp.Vector3[0];
MathTmp.Vector3[1].copyFrom(t);
var o = MathTmp.Vector3[1];
MathTmp.Vector3[2].copyFrom(r);
var a = MathTmp.Vector3[2]
, s = MathTmp.Vector3[3]
, l = MathTmp.Vector3[4];
n.normalize(),
o.normalize(),
a.normalize(),
i.CrossToRef(a, n, s),
i.CrossToRef(s, a, l);
var u = Math.atan2(i.Dot(o, s), i.Dot(o, l));
return Scalar.NormalizeRadians(u)
}
,
i.SlerpToRef = function(e, t, r, n) {
r = Scalar.Clamp(r, 0, 1);
var o = MathTmp.Vector3[0], a = MathTmp.Vector3[1], s, l;
o.copyFrom(e),
s = o.length(),
o.normalizeFromLength(s),
a.copyFrom(t),
l = a.length(),
a.normalizeFromLength(l);
var u = i.Dot(o, a), c, h;
if (u < 1 - Epsilon) {
var f = Math.acos(u)
, d = 1 / Math.sin(f);
c = Math.sin((1 - r) * f) * d,
h = Math.sin(r * f) * d
} else
c = 1 - r,
h = r;
o.scaleInPlace(c),
a.scaleInPlace(h),
n.copyFrom(o).addInPlace(a),
n.scaleInPlace(Scalar.Lerp(s, l, r))
}
,
i.SmoothToRef = function(e, t, r, n, o) {
i.SlerpToRef(e, t, n === 0 ? 1 : r / n, o)
}
,
i.FromArray = function(e, t) {
return t === void 0 && (t = 0),
new i(e[t],e[t + 1],e[t + 2])
}
,
i.FromFloatArray = function(e, t) {
return i.FromArray(e, t)
}
,
i.FromArrayToRef = function(e, t, r) {
r.x = e[t],
r.y = e[t + 1],
r.z = e[t + 2]
}
,
i.FromFloatArrayToRef = function(e, t, r) {
return i.FromArrayToRef(e, t, r)
}
,
i.FromFloatsToRef = function(e, t, r, n) {
n.copyFromFloats(e, t, r)
}
,
i.Zero = function() {
return new i(0,0,0)
}
,
i.One = function() {
return new i(1,1,1)
}
,
i.Up = function() {
return new i(0,1,0)
}
,
Object.defineProperty(i, "UpReadOnly", {
get: function() {
return i._UpReadOnly
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "RightReadOnly", {
get: function() {
return i._RightReadOnly
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "LeftHandedForwardReadOnly", {
get: function() {
return i._LeftHandedForwardReadOnly
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "RightHandedForwardReadOnly", {
get: function() {
return i._RightHandedForwardReadOnly
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ZeroReadOnly", {
get: function() {
return i._ZeroReadOnly
},
enumerable: !1,
configurable: !0
}),
i.Down = function() {
return new i(0,-1,0)
}
,
i.Forward = function(e) {
return e === void 0 && (e = !1),
new i(0,0,e ? -1 : 1)
}
,
i.Backward = function(e) {
return e === void 0 && (e = !1),
new i(0,0,e ? 1 : -1)
}
,
i.Right = function() {
return new i(1,0,0)
}
,
i.Left = function() {
return new i(-1,0,0)
}
,
i.TransformCoordinates = function(e, t) {
var r = i.Zero();
return i.TransformCoordinatesToRef(e, t, r),
r
}
,
i.TransformCoordinatesToRef = function(e, t, r) {
i.TransformCoordinatesFromFloatsToRef(e._x, e._y, e._z, t, r)
}
,
i.TransformCoordinatesFromFloatsToRef = function(e, t, r, n, o) {
var a = n.m
, s = e * a[0] + t * a[4] + r * a[8] + a[12]
, l = e * a[1] + t * a[5] + r * a[9] + a[13]
, u = e * a[2] + t * a[6] + r * a[10] + a[14]
, c = 1 / (e * a[3] + t * a[7] + r * a[11] + a[15]);
o.x = s * c,
o.y = l * c,
o.z = u * c
}
,
i.TransformNormal = function(e, t) {
var r = i.Zero();
return i.TransformNormalToRef(e, t, r),
r
}
,
i.TransformNormalToRef = function(e, t, r) {
this.TransformNormalFromFloatsToRef(e._x, e._y, e._z, t, r)
}
,
i.TransformNormalFromFloatsToRef = function(e, t, r, n, o) {
var a = n.m;
o.x = e * a[0] + t * a[4] + r * a[8],
o.y = e * a[1] + t * a[5] + r * a[9],
o.z = e * a[2] + t * a[6] + r * a[10]
}
,
i.CatmullRom = function(e, t, r, n, o) {
var a = o * o
, s = o * a
, l = .5 * (2 * t._x + (-e._x + r._x) * o + (2 * e._x - 5 * t._x + 4 * r._x - n._x) * a + (-e._x + 3 * t._x - 3 * r._x + n._x) * s)
, u = .5 * (2 * t._y + (-e._y + r._y) * o + (2 * e._y - 5 * t._y + 4 * r._y - n._y) * a + (-e._y + 3 * t._y - 3 * r._y + n._y) * s)
, c = .5 * (2 * t._z + (-e._z + r._z) * o + (2 * e._z - 5 * t._z + 4 * r._z - n._z) * a + (-e._z + 3 * t._z - 3 * r._z + n._z) * s);
return new i(l,u,c)
}
,
i.Clamp = function(e, t, r) {
var n = new i;
return i.ClampToRef(e, t, r, n),
n
}
,
i.ClampToRef = function(e, t, r, n) {
var o = e._x;
o = o > r._x ? r._x : o,
o = o < t._x ? t._x : o;
var a = e._y;
a = a > r._y ? r._y : a,
a = a < t._y ? t._y : a;
var s = e._z;
s = s > r._z ? r._z : s,
s = s < t._z ? t._z : s,
n.copyFromFloats(o, a, s)
}
,
i.CheckExtends = function(e, t, r) {
t.minimizeInPlace(e),
r.maximizeInPlace(e)
}
,
i.Hermite = function(e, t, r, n, o) {
var a = o * o
, s = o * a
, l = 2 * s - 3 * a + 1
, u = -2 * s + 3 * a
, c = s - 2 * a + o
, h = s - a
, f = e._x * l + r._x * u + t._x * c + n._x * h
, d = e._y * l + r._y * u + t._y * c + n._y * h
, _ = e._z * l + r._z * u + t._z * c + n._z * h;
return new i(f,d,_)
}
,
i.Hermite1stDerivative = function(e, t, r, n, o) {
var a = i.Zero();
return this.Hermite1stDerivativeToRef(e, t, r, n, o, a),
a
}
,
i.Hermite1stDerivativeToRef = function(e, t, r, n, o, a) {
var s = o * o;
a.x = (s - o) * 6 * e.x + (3 * s - 4 * o + 1) * t.x + (-s + o) * 6 * r.x + (3 * s - 2 * o) * n.x,
a.y = (s - o) * 6 * e.y + (3 * s - 4 * o + 1) * t.y + (-s + o) * 6 * r.y + (3 * s - 2 * o) * n.y,
a.z = (s - o) * 6 * e.z + (3 * s - 4 * o + 1) * t.z + (-s + o) * 6 * r.z + (3 * s - 2 * o) * n.z
}
,
i.Lerp = function(e, t, r) {
var n = new i(0,0,0);
return i.LerpToRef(e, t, r, n),
n
}
,
i.LerpToRef = function(e, t, r, n) {
n.x = e._x + (t._x - e._x) * r,
n.y = e._y + (t._y - e._y) * r,
n.z = e._z + (t._z - e._z) * r
}
,
i.Dot = function(e, t) {
return e._x * t._x + e._y * t._y + e._z * t._z
}
,
i.Cross = function(e, t) {
var r = i.Zero();
return i.CrossToRef(e, t, r),
r
}
,
i.CrossToRef = function(e, t, r) {
var n = e._y * t._z - e._z * t._y
, o = e._z * t._x - e._x * t._z
, a = e._x * t._y - e._y * t._x;
r.copyFromFloats(n, o, a)
}
,
i.Normalize = function(e) {
var t = i.Zero();
return i.NormalizeToRef(e, t),
t
}
,
i.NormalizeToRef = function(e, t) {
e.normalizeToRef(t)
}
,
i.Project = function(e, t, r, n) {
var o = new i;
return i.ProjectToRef(e, t, r, n, o),
o
}
,
i.ProjectToRef = function(e, t, r, n, o) {
var a = n.width
, s = n.height
, l = n.x
, u = n.y
, c = MathTmp.Matrix[1];
Matrix.FromValuesToRef(a / 2, 0, 0, 0, 0, -s / 2, 0, 0, 0, 0, .5, 0, l + a / 2, s / 2 + u, .5, 1, c);
var h = MathTmp.Matrix[0];
return t.multiplyToRef(r, h),
h.multiplyToRef(c, h),
i.TransformCoordinatesToRef(e, h, o),
o
}
,
i._UnprojectFromInvertedMatrixToRef = function(e, t, r) {
i.TransformCoordinatesToRef(e, t, r);
var n = t.m
, o = e._x * n[3] + e._y * n[7] + e._z * n[11] + n[15];
Scalar.WithinEpsilon(o, 1) && r.scaleInPlace(1 / o)
}
,
i.UnprojectFromTransform = function(e, t, r, n, o) {
var a = MathTmp.Matrix[0];
n.multiplyToRef(o, a),
a.invert(),
e.x = e._x / t * 2 - 1,
e.y = -(e._y / r * 2 - 1);
var s = new i;
return i._UnprojectFromInvertedMatrixToRef(e, a, s),
s
}
,
i.Unproject = function(e, t, r, n, o, a) {
var s = i.Zero();
return i.UnprojectToRef(e, t, r, n, o, a, s),
s
}
,
i.UnprojectToRef = function(e, t, r, n, o, a, s) {
i.UnprojectFloatsToRef(e._x, e._y, e._z, t, r, n, o, a, s)
}
,
i.UnprojectFloatsToRef = function(e, t, r, n, o, a, s, l, u) {
var c = MathTmp.Matrix[0];
a.multiplyToRef(s, c),
c.multiplyToRef(l, c),
c.invert();
var h = MathTmp.Vector3[0];
h.x = e / n * 2 - 1,
h.y = -(t / o * 2 - 1),
h.z = 2 * r - 1,
i._UnprojectFromInvertedMatrixToRef(h, c, u)
}
,
i.Minimize = function(e, t) {
var r = e.clone();
return r.minimizeInPlace(t),
r
}
,
i.Maximize = function(e, t) {
var r = e.clone();
return r.maximizeInPlace(t),
r
}
,
i.Distance = function(e, t) {
return Math.sqrt(i.DistanceSquared(e, t))
}
,
i.DistanceSquared = function(e, t) {
var r = e._x - t._x
, n = e._y - t._y
, o = e._z - t._z;
return r * r + n * n + o * o
}
,
i.ProjectOnTriangleToRef = function(e, t, r, n, o) {
var a = MathTmp.Vector3[0]
, s = MathTmp.Vector3[1]
, l = MathTmp.Vector3[2]
, u = MathTmp.Vector3[3]
, c = MathTmp.Vector3[4];
r.subtractToRef(t, a),
n.subtractToRef(t, s),
n.subtractToRef(r, l);
var h = a.length()
, f = s.length()
, d = l.length();
if (h < Epsilon || f < Epsilon || d < Epsilon)
return o.copyFrom(t),
i.Distance(e, t);
e.subtractToRef(t, c),
i.CrossToRef(a, s, u);
var _ = u.length();
if (_ < Epsilon)
return o.copyFrom(t),
i.Distance(e, t);
u.normalizeFromLength(_);
var g = c.length();
if (g < Epsilon)
return o.copyFrom(t),
0;
c.normalizeFromLength(g);
var m = i.Dot(u, c)
, v = MathTmp.Vector3[5]
, y = MathTmp.Vector3[6];
v.copyFrom(u).scaleInPlace(-g * m),
y.copyFrom(e).addInPlace(v);
var b = MathTmp.Vector3[4]
, T = MathTmp.Vector3[5]
, C = MathTmp.Vector3[7]
, A = MathTmp.Vector3[8];
b.copyFrom(a).scaleInPlace(1 / h),
A.copyFrom(s).scaleInPlace(1 / f),
b.addInPlace(A).scaleInPlace(-1),
T.copyFrom(a).scaleInPlace(-1 / h),
A.copyFrom(l).scaleInPlace(1 / d),
T.addInPlace(A).scaleInPlace(-1),
C.copyFrom(l).scaleInPlace(-1 / d),
A.copyFrom(s).scaleInPlace(-1 / f),
C.addInPlace(A).scaleInPlace(-1);
var S = MathTmp.Vector3[9], P, R, M, x;
S.copyFrom(y).subtractInPlace(t),
i.CrossToRef(b, S, A),
P = i.Dot(A, u),
R = P,
S.copyFrom(y).subtractInPlace(r),
i.CrossToRef(T, S, A),
P = i.Dot(A, u),
M = P,
S.copyFrom(y).subtractInPlace(n),
i.CrossToRef(C, S, A),
P = i.Dot(A, u),
x = P;
var I = MathTmp.Vector3[10], w, O;
R > 0 && M < 0 ? (I.copyFrom(a),
w = t,
O = r) : M > 0 && x < 0 ? (I.copyFrom(l),
w = r,
O = n) : (I.copyFrom(s).scaleInPlace(-1),
w = n,
O = t);
var D = MathTmp.Vector3[9]
, F = MathTmp.Vector3[4];
w.subtractToRef(y, A),
O.subtractToRef(y, D),
i.CrossToRef(A, D, F);
var V = i.Dot(F, u) < 0;
if (!V)
return o.copyFrom(y),
Math.abs(g * m);
var N = MathTmp.Vector3[5];
i.CrossToRef(I, F, N),
N.normalize();
var L = MathTmp.Vector3[9];
L.copyFrom(w).subtractInPlace(y);
var k = L.length();
if (k < Epsilon)
return o.copyFrom(w),
i.Distance(e, w);
L.normalizeFromLength(k);
var U = i.Dot(N, L)
, z = MathTmp.Vector3[7];
z.copyFrom(y).addInPlace(N.scaleInPlace(k * U)),
A.copyFrom(z).subtractInPlace(w),
g = I.length(),
I.normalizeFromLength(g);
var H = i.Dot(A, I) / Math.max(g, Epsilon);
return H = Scalar.Clamp(H, 0, 1),
z.copyFrom(w).addInPlace(I.scaleInPlace(H * g)),
o.copyFrom(z),
i.Distance(e, z)
}
,
i.Center = function(e, t) {
return i.CenterToRef(e, t, i.Zero())
}
,
i.CenterToRef = function(e, t, r) {
return r.copyFromFloats((e._x + t._x) / 2, (e._y + t._y) / 2, (e._z + t._z) / 2)
}
,
i.RotationFromAxis = function(e, t, r) {
var n = i.Zero();
return i.RotationFromAxisToRef(e, t, r, n),
n
}
,
i.RotationFromAxisToRef = function(e, t, r, n) {
var o = MathTmp.Quaternion[0];
Quaternion.RotationQuaternionFromAxisToRef(e, t, r, o),
o.toEulerAnglesToRef(n)
}
,
i._UpReadOnly = i.Up(),
i._LeftHandedForwardReadOnly = i.Forward(!1),
i._RightHandedForwardReadOnly = i.Forward(!0),
i._RightReadOnly = i.Right(),
i._ZeroReadOnly = i.Zero(),
i
}()
, Vector4 = function() {
function i(e, t, r, n) {
this.x = e,
this.y = t,
this.z = r,
this.w = n
}
return i.prototype.toString = function() {
return "{X: " + this.x + " Y: " + this.y + " Z: " + this.z + " W: " + this.w + "}"
}
,
i.prototype.getClassName = function() {
return "Vector4"
}
,
i.prototype.getHashCode = function() {
var e = this.x | 0;
return e = e * 397 ^ (this.y | 0),
e = e * 397 ^ (this.z | 0),
e = e * 397 ^ (this.w | 0),
e
}
,
i.prototype.asArray = function() {
var e = new Array;
return this.toArray(e, 0),
e
}
,
i.prototype.toArray = function(e, t) {
return t === void 0 && (t = 0),
e[t] = this.x,
e[t + 1] = this.y,
e[t + 2] = this.z,
e[t + 3] = this.w,
this
}
,
i.prototype.fromArray = function(e, t) {
return t === void 0 && (t = 0),
i.FromArrayToRef(e, t, this),
this
}
,
i.prototype.addInPlace = function(e) {
return this.x += e.x,
this.y += e.y,
this.z += e.z,
this.w += e.w,
this
}
,
i.prototype.add = function(e) {
return new i(this.x + e.x,this.y + e.y,this.z + e.z,this.w + e.w)
}
,
i.prototype.addToRef = function(e, t) {
return t.x = this.x + e.x,
t.y = this.y + e.y,
t.z = this.z + e.z,
t.w = this.w + e.w,
this
}
,
i.prototype.subtractInPlace = function(e) {
return this.x -= e.x,
this.y -= e.y,
this.z -= e.z,
this.w -= e.w,
this
}
,
i.prototype.subtract = function(e) {
return new i(this.x - e.x,this.y - e.y,this.z - e.z,this.w - e.w)
}
,
i.prototype.subtractToRef = function(e, t) {
return t.x = this.x - e.x,
t.y = this.y - e.y,
t.z = this.z - e.z,
t.w = this.w - e.w,
this
}
,
i.prototype.subtractFromFloats = function(e, t, r, n) {
return new i(this.x - e,this.y - t,this.z - r,this.w - n)
}
,
i.prototype.subtractFromFloatsToRef = function(e, t, r, n, o) {
return o.x = this.x - e,
o.y = this.y - t,
o.z = this.z - r,
o.w = this.w - n,
this
}
,
i.prototype.negate = function() {
return new i(-this.x,-this.y,-this.z,-this.w)
}
,
i.prototype.negateInPlace = function() {
return this.x *= -1,
this.y *= -1,
this.z *= -1,
this.w *= -1,
this
}
,
i.prototype.negateToRef = function(e) {
return e.copyFromFloats(this.x * -1, this.y * -1, this.z * -1, this.w * -1)
}
,
i.prototype.scaleInPlace = function(e) {
return this.x *= e,
this.y *= e,
this.z *= e,
this.w *= e,
this
}
,
i.prototype.scale = function(e) {
return new i(this.x * e,this.y * e,this.z * e,this.w * e)
}
,
i.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
}
,
i.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
}
,
i.prototype.equals = function(e) {
return e && this.x === e.x && this.y === e.y && this.z === e.z && this.w === e.w
}
,
i.prototype.equalsWithEpsilon = function(e, t) {
return t === void 0 && (t = Epsilon),
e && Scalar.WithinEpsilon(this.x, e.x, t) && Scalar.WithinEpsilon(this.y, e.y, t) && Scalar.WithinEpsilon(this.z, e.z, t) && Scalar.WithinEpsilon(this.w, e.w, t)
}
,
i.prototype.equalsToFloats = function(e, t, r, n) {
return this.x === e && this.y === t && this.z === r && this.w === n
}
,
i.prototype.multiplyInPlace = function(e) {
return this.x *= e.x,
this.y *= e.y,
this.z *= e.z,
this.w *= e.w,
this
}
,
i.prototype.multiply = function(e) {
return new i(this.x * e.x,this.y * e.y,this.z * e.z,this.w * e.w)
}
,
i.prototype.multiplyToRef = function(e, t) {
return t.x = this.x * e.x,
t.y = this.y * e.y,
t.z = this.z * e.z,
t.w = this.w * e.w,
this
}
,
i.prototype.multiplyByFloats = function(e, t, r, n) {
return new i(this.x * e,this.y * t,this.z * r,this.w * n)
}
,
i.prototype.divide = function(e) {
return new i(this.x / e.x,this.y / e.y,this.z / e.z,this.w / e.w)
}
,
i.prototype.divideToRef = function(e, t) {
return t.x = this.x / e.x,
t.y = this.y / e.y,
t.z = this.z / e.z,
t.w = this.w / e.w,
this
}
,
i.prototype.divideInPlace = function(e) {
return this.divideToRef(e, this)
}
,
i.prototype.minimizeInPlace = function(e) {
return e.x < 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
}
,
i.prototype.maximizeInPlace = function(e) {
return e.x > 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
}
,
i.prototype.floor = function() {
return new i(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))
}
,
i.prototype.fract = function() {
return new i(this.x - Math.floor(this.x),this.y - Math.floor(this.y),this.z - Math.floor(this.z),this.w - Math.floor(this.w))
}
,
i.prototype.length = function() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
}
,
i.prototype.lengthSquared = function() {
return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
}
,
i.prototype.normalize = function() {
var e = this.length();
return e === 0 ? this : this.scaleInPlace(1 / e)
}
,
i.prototype.toVector3 = function() {
return new Vector3(this.x,this.y,this.z)
}
,
i.prototype.clone = function() {
return new i(this.x,this.y,this.z,this.w)
}
,
i.prototype.copyFrom = function(e) {
return this.x = e.x,
this.y = e.y,
this.z = e.z,
this.w = e.w,
this
}
,
i.prototype.copyFromFloats = function(e, t, r, n) {
return this.x = e,
this.y = t,
this.z = r,
this.w = n,
this
}
,
i.prototype.set = function(e, t, r, n) {
return this.copyFromFloats(e, t, r, n)
}
,
i.prototype.setAll = function(e) {
return this.x = this.y = this.z = this.w = e,
this
}
,
i.FromArray = function(e, t) {
return t || (t = 0),
new i(e[t],e[t + 1],e[t + 2],e[t + 3])
}
,
i.FromArrayToRef = function(e, t, r) {
r.x = e[t],
r.y = e[t + 1],
r.z = e[t + 2],
r.w = e[t + 3]
}
,
i.FromFloatArrayToRef = function(e, t, r) {
i.FromArrayToRef(e, t, r)
}
,
i.FromFloatsToRef = function(e, t, r, n, o) {
o.x = e,
o.y = t,
o.z = r,
o.w = n
}
,
i.Zero = function() {
return new i(0,0,0,0)
}
,
i.One = function() {
return new i(1,1,1,1)
}
,
i.Normalize = function(e) {
var t = i.Zero();
return i.NormalizeToRef(e, t),
t
}
,
i.NormalizeToRef = function(e, t) {
t.copyFrom(e),
t.normalize()
}
,
i.Minimize = function(e, t) {
var r = e.clone();
return r.minimizeInPlace(t),
r
}
,
i.Maximize = function(e, t) {
var r = e.clone();
return r.maximizeInPlace(t),
r
}
,
i.Distance = function(e, t) {
return Math.sqrt(i.DistanceSquared(e, t))
}
,
i.DistanceSquared = function(e, t) {
var r = e.x - t.x
, n = e.y - t.y
, o = e.z - t.z
, a = e.w - t.w;
return r * r + n * n + o * o + a * a
}
,
i.Center = function(e, t) {
return i.CenterToRef(e, t, i.Zero())
}
,
i.CenterToRef = function(e, t, r) {
return r.copyFromFloats((e.x + t.x) / 2, (e.y + t.y) / 2, (e.z + t.z) / 2, (e.w + t.w) / 2)
}
,
i.TransformCoordinates = function(e, t) {
var r = i.Zero();
return i.TransformCoordinatesToRef(e, t, r),
r
}
,
i.TransformCoordinatesToRef = function(e, t, r) {
i.TransformCoordinatesFromFloatsToRef(e._x, e._y, e._z, t, r)
}
,
i.TransformCoordinatesFromFloatsToRef = function(e, t, r, n, o) {
var a = n.m
, s = e * a[0] + t * a[4] + r * a[8] + a[12]
, l = e * a[1] + t * a[5] + r * a[9] + a[13]
, u = e * a[2] + t * a[6] + r * a[10] + a[14]
, c = e * a[3] + t * a[7] + r * a[11] + a[15];
o.x = s,
o.y = l,
o.z = u,
o.w = c
}
,
i.TransformNormal = function(e, t) {
var r = i.Zero();
return i.TransformNormalToRef(e, t, r),
r
}
,
i.TransformNormalToRef = function(e, t, r) {
var n = t.m
, o = e.x * n[0] + e.y * n[4] + e.z * n[8]
, a = e.x * n[1] + e.y * n[5] + e.z * n[9]
, s = e.x * n[2] + e.y * n[6] + e.z * n[10];
r.x = o,
r.y = a,
r.z = s,
r.w = e.w
}
,
i.TransformNormalFromFloatsToRef = function(e, t, r, n, o, a) {
var s = o.m;
a.x = e * s[0] + t * s[4] + r * s[8],
a.y = e * s[1] + t * s[5] + r * s[9],
a.z = e * s[2] + t * s[6] + r * s[10],
a.w = n
}
,
i.FromVector3 = function(e, t) {
return t === void 0 && (t = 0),
new i(e._x,e._y,e._z,t)
}
,
i
}()
, Quaternion = function() {
function i(e, t, r, n) {
e === void 0 && (e = 0),
t === void 0 && (t = 0),
r === void 0 && (r = 0),
n === void 0 && (n = 1),
this._isDirty = !0,
this._x = e,
this._y = t,
this._z = r,
this._w = n
}
return Object.defineProperty(i.prototype, "x", {
get: function() {
return this._x
},
set: function(e) {
this._x = e,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "y", {
get: function() {
return this._y
},
set: function(e) {
this._y = e,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "z", {
get: function() {
return this._z
},
set: function(e) {
this._z = e,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "w", {
get: function() {
return this._w
},
set: function(e) {
this._w = e,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
i.prototype.toString = function() {
return "{X: " + this._x + " Y: " + this._y + " Z: " + this._z + " W: " + this._w + "}"
}
,
i.prototype.getClassName = function() {
return "Quaternion"
}
,
i.prototype.getHashCode = function() {
var e = this._x | 0;
return e = e * 397 ^ (this._y | 0),
e = e * 397 ^ (this._z | 0),
e = e * 397 ^ (this._w | 0),
e
}
,
i.prototype.asArray = function() {
return [this._x, this._y, this._z, this._w]
}
,
i.prototype.equals = function(e) {
return e && this._x === e._x && this._y === e._y && this._z === e._z && this._w === e._w
}
,
i.prototype.equalsWithEpsilon = function(e, t) {
return t === void 0 && (t = Epsilon),
e && Scalar.WithinEpsilon(this._x, e._x, t) && Scalar.WithinEpsilon(this._y, e._y, t) && Scalar.WithinEpsilon(this._z, e._z, t) && Scalar.WithinEpsilon(this._w, e._w, t)
}
,
i.prototype.clone = function() {
return new i(this._x,this._y,this._z,this._w)
}
,
i.prototype.copyFrom = function(e) {
return this.x = e._x,
this.y = e._y,
this.z = e._z,
this.w = e._w,
this
}
,
i.prototype.copyFromFloats = function(e, t, r, n) {
return this.x = e,
this.y = t,
this.z = r,
this.w = n,
this
}
,
i.prototype.set = function(e, t, r, n) {
return this.copyFromFloats(e, t, r, n)
}
,
i.prototype.add = function(e) {
return new i(this._x + e._x,this._y + e._y,this._z + e._z,this._w + e._w)
}
,
i.prototype.addInPlace = function(e) {
return this._x += e._x,
this._y += e._y,
this._z += e._z,
this._w += e._w,
this
}
,
i.prototype.subtract = function(e) {
return new i(this._x - e._x,this._y - e._y,this._z - e._z,this._w - e._w)
}
,
i.prototype.scale = function(e) {
return new i(this._x * e,this._y * e,this._z * e,this._w * e)
}
,
i.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
}
,
i.prototype.scaleInPlace = function(e) {
return this.x *= e,
this.y *= e,
this.z *= e,
this.w *= e,
this
}
,
i.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
}
,
i.prototype.multiply = function(e) {
var t = new i(0,0,0,1);
return this.multiplyToRef(e, t),
t
}
,
i.prototype.multiplyToRef = function(e, t) {
var r = 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
, o = this._x * e._y - this._y * e._x + this._z * e._w + this._w * e._z
, a = -this._x * e._x - this._y * e._y - this._z * e._z + this._w * e._w;
return t.copyFromFloats(r, n, o, a),
this
}
,
i.prototype.multiplyInPlace = function(e) {
return this.multiplyToRef(e, this),
this
}
,
i.prototype.conjugateToRef = function(e) {
return e.copyFromFloats(-this._x, -this._y, -this._z, this._w),
this
}
,
i.prototype.conjugateInPlace = function() {
return this.x *= -1,
this.y *= -1,
this.z *= -1,
this
}
,
i.prototype.conjugate = function() {
var e = new i(-this._x,-this._y,-this._z,this._w);
return e
}
,
i.prototype.length = function() {
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w)
}
,
i.prototype.normalize = function() {
var e = this.length();
if (e === 0)
return this;
var t = 1 / e;
return this.x *= t,
this.y *= t,
this.z *= t,
this.w *= t,
this
}
,
i.prototype.toEulerAngles = function() {
var e = Vector3.Zero();
return this.toEulerAnglesToRef(e),
e
}
,
i.prototype.toEulerAnglesToRef = function(e) {
var t = this._z
, r = this._x
, n = this._y
, o = this._w
, a = o * o
, s = t * t
, l = r * r
, u = n * n
, c = n * t - r * o
, h = .4999999;
return c < -h ? (e.y = 2 * Math.atan2(n, o),
e.x = Math.PI / 2,
e.z = 0) : c > h ? (e.y = 2 * Math.atan2(n, o),
e.x = -Math.PI / 2,
e.z = 0) : (e.z = Math.atan2(2 * (r * n + t * o), -s - l + u + a),
e.x = Math.asin(-2 * (t * n - r * o)),
e.y = Math.atan2(2 * (t * r + n * o), s - l - u + a)),
this
}
,
i.prototype.toRotationMatrix = function(e) {
return Matrix.FromQuaternionToRef(this, e),
this
}
,
i.prototype.fromRotationMatrix = function(e) {
return i.FromRotationMatrixToRef(e, this),
this
}
,
i.FromRotationMatrix = function(e) {
var t = new i;
return i.FromRotationMatrixToRef(e, t),
t
}
,
i.FromRotationMatrixToRef = function(e, t) {
var r = e.m, n = r[0], o = r[4], a = r[8], s = r[1], l = r[5], u = r[9], c = r[2], h = r[6], f = r[10], d = n + l + f, _;
d > 0 ? (_ = .5 / Math.sqrt(d + 1),
t.w = .25 / _,
t.x = (h - u) * _,
t.y = (a - c) * _,
t.z = (s - o) * _) : n > l && n > f ? (_ = 2 * Math.sqrt(1 + n - l - f),
t.w = (h - u) / _,
t.x = .25 * _,
t.y = (o + s) / _,
t.z = (a + c) / _) : l > f ? (_ = 2 * Math.sqrt(1 + l - n - f),
t.w = (a - c) / _,
t.x = (o + s) / _,
t.y = .25 * _,
t.z = (u + h) / _) : (_ = 2 * Math.sqrt(1 + f - n - l),
t.w = (s - o) / _,
t.x = (a + c) / _,
t.y = (u + h) / _,
t.z = .25 * _)
}
,
i.Dot = function(e, t) {
return e._x * t._x + e._y * t._y + e._z * t._z + e._w * t._w
}
,
i.AreClose = function(e, t) {
var r = i.Dot(e, t);
return r >= 0
}
,
i.SmoothToRef = function(e, t, r, n, o) {
var a = n === 0 ? 1 : r / n;
a = Scalar.Clamp(a, 0, 1),
i.SlerpToRef(e, t, a, o)
}
,
i.Zero = function() {
return new i(0,0,0,0)
}
,
i.Inverse = function(e) {
return new i(-e._x,-e._y,-e._z,e._w)
}
,
i.InverseToRef = function(e, t) {
return t.set(-e._x, -e._y, -e._z, e._w),
t
}
,
i.Identity = function() {
return new i(0,0,0,1)
}
,
i.IsIdentity = function(e) {
return e && e._x === 0 && e._y === 0 && e._z === 0 && e._w === 1
}
,
i.RotationAxis = function(e, t) {
return i.RotationAxisToRef(e, t, new i)
}
,
i.RotationAxisToRef = function(e, t, r) {
var n = Math.sin(t / 2);
return e.normalize(),
r.w = Math.cos(t / 2),
r.x = e._x * n,
r.y = e._y * n,
r.z = e._z * n,
r
}
,
i.FromArray = function(e, t) {
return t || (t = 0),
new i(e[t],e[t + 1],e[t + 2],e[t + 3])
}
,
i.FromArrayToRef = function(e, t, r) {
r.x = e[t],
r.y = e[t + 1],
r.z = e[t + 2],
r.w = e[t + 3]
}
,
i.FromEulerAngles = function(e, t, r) {
var n = new i;
return i.RotationYawPitchRollToRef(t, e, r, n),
n
}
,
i.FromEulerAnglesToRef = function(e, t, r, n) {
return i.RotationYawPitchRollToRef(t, e, r, n),
n
}
,
i.FromEulerVector = function(e) {
var t = new i;
return i.RotationYawPitchRollToRef(e._y, e._x, e._z, t),
t
}
,
i.FromEulerVectorToRef = function(e, t) {
return i.RotationYawPitchRollToRef(e._y, e._x, e._z, t),
t
}
,
i.FromUnitVectorsToRef = function(e, t, r) {
var n = Vector3.Dot(e, t) + 1;
return n < Epsilon ? Math.abs(e.x) > Math.abs(e.z) ? r.set(-e.y, e.x, 0, 0) : r.set(0, -e.z, e.y, 0) : (Vector3.CrossToRef(e, t, TmpVectors.Vector3[0]),
r.set(TmpVectors.Vector3[0].x, TmpVectors.Vector3[0].y, TmpVectors.Vector3[0].z, n)),
r.normalize()
}
,
i.RotationYawPitchRoll = function(e, t, r) {
var n = new i;
return i.RotationYawPitchRollToRef(e, t, r, n),
n
}
,
i.RotationYawPitchRollToRef = function(e, t, r, n) {
var o = r * .5
, a = t * .5
, s = e * .5
, l = Math.sin(o)
, u = Math.cos(o)
, c = Math.sin(a)
, h = Math.cos(a)
, f = Math.sin(s)
, d = Math.cos(s);
n.x = d * c * u + f * h * l,
n.y = f * h * u - d * c * l,
n.z = d * h * l - f * c * u,
n.w = d * h * u + f * c * l
}
,
i.RotationAlphaBetaGamma = function(e, t, r) {
var n = new i;
return i.RotationAlphaBetaGammaToRef(e, t, r, n),
n
}
,
i.RotationAlphaBetaGammaToRef = function(e, t, r, n) {
var o = (r + e) * .5
, a = (r - e) * .5
, s = t * .5;
n.x = Math.cos(a) * Math.sin(s),
n.y = Math.sin(a) * Math.sin(s),
n.z = Math.sin(o) * Math.cos(s),
n.w = Math.cos(o) * Math.cos(s)
}
,
i.RotationQuaternionFromAxis = function(e, t, r) {
var n = new i(0,0,0,0);
return i.RotationQuaternionFromAxisToRef(e, t, r, n),
n
}
,
i.RotationQuaternionFromAxisToRef = function(e, t, r, n) {
var o = MathTmp.Matrix[0];
Matrix.FromXYZAxesToRef(e.normalize(), t.normalize(), r.normalize(), o),
i.FromRotationMatrixToRef(o, n)
}
,
i.FromLookDirectionLH = function(e, t) {
var r = new i;
return i.FromLookDirectionLHToRef(e, t, r),
r
}
,
i.FromLookDirectionLHToRef = function(e, t, r) {
var n = MathTmp.Matrix[0];
Matrix.LookDirectionLHToRef(e, t, n),
i.FromRotationMatrixToRef(n, r)
}
,
i.FromLookDirectionRH = function(e, t) {
var r = new i;
return i.FromLookDirectionRHToRef(e, t, r),
r
}
,
i.FromLookDirectionRHToRef = function(e, t, r) {
var n = MathTmp.Matrix[0];
return Matrix.LookDirectionRHToRef(e, t, n),
i.FromRotationMatrixToRef(n, r)
}
,
i.Slerp = function(e, t, r) {
var n = i.Identity();
return i.SlerpToRef(e, t, r, n),
n
}
,
i.SlerpToRef = function(e, t, r, n) {
var o, a, s = e._x * t._x + e._y * t._y + e._z * t._z + e._w * t._w, l = !1;
if (s < 0 && (l = !0,
s = -s),
s > .999999)
a = 1 - r,
o = l ? -r : r;
else {
var u = Math.acos(s)
, c = 1 / Math.sin(u);
a = Math.sin((1 - r) * u) * c,
o = l ? -Math.sin(r * u) * c : Math.sin(r * u) * c
}
n.x = a * e._x + o * t._x,
n.y = a * e._y + o * t._y,
n.z = a * e._z + o * t._z,
n.w = a * e._w + o * t._w
}
,
i.Hermite = function(e, t, r, n, o) {
var a = o * o
, s = o * a
, l = 2 * s - 3 * a + 1
, u = -2 * s + 3 * a
, c = s - 2 * a + o
, h = s - a
, f = e._x * l + r._x * u + t._x * c + n._x * h
, d = e._y * l + r._y * u + t._y * c + n._y * h
, _ = e._z * l + r._z * u + t._z * c + n._z * h
, g = e._w * l + r._w * u + t._w * c + n._w * h;
return new i(f,d,_,g)
}
,
i.Hermite1stDerivative = function(e, t, r, n, o) {
var a = i.Zero();
return this.Hermite1stDerivativeToRef(e, t, r, n, o, a),
a
}
,
i.Hermite1stDerivativeToRef = function(e, t, r, n, o, a) {
var s = o * o;
a.x = (s - o) * 6 * e.x + (3 * s - 4 * o + 1) * t.x + (-s + o) * 6 * r.x + (3 * s - 2 * o) * n.x,
a.y = (s - o) * 6 * e.y + (3 * s - 4 * o + 1) * t.y + (-s + o) * 6 * r.y + (3 * s - 2 * o) * n.y,
a.z = (s - o) * 6 * e.z + (3 * s - 4 * o + 1) * t.z + (-s + o) * 6 * r.z + (3 * s - 2 * o) * n.z,
a.w = (s - o) * 6 * e.w + (3 * s - 4 * o + 1) * t.w + (-s + o) * 6 * r.w + (3 * s - 2 * o) * n.w
}
,
i
}()
, Matrix = function() {
function i() {
this._isIdentity = !1,
this._isIdentityDirty = !0,
this._isIdentity3x2 = !0,
this._isIdentity3x2Dirty = !0,
this.updateFlag = -1,
PerformanceConfigurator.MatrixTrackPrecisionChange && PerformanceConfigurator.MatrixTrackedMatrices.push(this),
this._m = new PerformanceConfigurator.MatrixCurrentType(16),
this._markAsUpdated()
}
return Object.defineProperty(i, "Use64Bits", {
get: function() {
return PerformanceConfigurator.MatrixUse64Bits
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "m", {
get: function() {
return this._m
},
enumerable: !1,
configurable: !0
}),
i.prototype._markAsUpdated = function() {
this.updateFlag = i._updateFlagSeed++,
this._isIdentity = !1,
this._isIdentity3x2 = !1,
this._isIdentityDirty = !0,
this._isIdentity3x2Dirty = !0
}
,
i.prototype._updateIdentityStatus = function(e, t, r, n) {
t === void 0 && (t = !1),
r === void 0 && (r = !1),
n === void 0 && (n = !0),
this._isIdentity = e,
this._isIdentity3x2 = e || r,
this._isIdentityDirty = this._isIdentity ? !1 : t,
this._isIdentity3x2Dirty = this._isIdentity3x2 ? !1 : n
}
,
i.prototype.isIdentity = function() {
if (this._isIdentityDirty) {
this._isIdentityDirty = !1;
var e = this._m;
this._isIdentity = e[0] === 1 && e[1] === 0 && e[2] === 0 && e[3] === 0 && e[4] === 0 && e[5] === 1 && e[6] === 0 && e[7] === 0 && e[8] === 0 && e[9] === 0 && e[10] === 1 && e[11] === 0 && e[12] === 0 && e[13] === 0 && e[14] === 0 && e[15] === 1
}
return this._isIdentity
}
,
i.prototype.isIdentityAs3x2 = function() {
return this._isIdentity3x2Dirty && (this._isIdentity3x2Dirty = !1,
this._m[0] !== 1 || this._m[5] !== 1 || this._m[15] !== 1 ? this._isIdentity3x2 = !1 : this._m[1] !== 0 || this._m[2] !== 0 || this._m[3] !== 0 || this._m[4] !== 0 || this._m[6] !== 0 || this._m[7] !== 0 || this._m[8] !== 0 || this._m[9] !== 0 || this._m[10] !== 0 || this._m[11] !== 0 || this._m[12] !== 0 || this._m[13] !== 0 || this._m[14] !== 0 ? this._isIdentity3x2 = !1 : this._isIdentity3x2 = !0),
this._isIdentity3x2
}
,
i.prototype.determinant = function() {
if (this._isIdentity === !0)
return 1;
var e = this._m
, t = e[0]
, r = e[1]
, n = e[2]
, o = e[3]
, a = e[4]
, s = e[5]
, l = e[6]
, u = e[7]
, c = e[8]
, h = e[9]
, f = e[10]
, d = e[11]
, _ = e[12]
, g = e[13]
, m = e[14]
, v = e[15]
, y = f * v - m * d
, b = h * v - g * d
, T = h * m - g * f
, C = c * v - _ * d
, A = c * m - f * _
, S = c * g - _ * h
, P = +(s * y - l * b + u * T)
, R = -(a * y - l * C + u * A)
, M = +(a * b - s * C + u * S)
, x = -(a * T - s * A + l * S);
return t * P + r * R + n * M + o * x
}
,
i.prototype.toArray = function() {
return this._m
}
,
i.prototype.asArray = function() {
return this._m
}
,
i.prototype.invert = function() {
return this.invertToRef(this),
this
}
,
i.prototype.reset = function() {
return i.FromValuesToRef(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, this),
this._updateIdentityStatus(!1),
this
}
,
i.prototype.add = function(e) {
var t = new i;
return this.addToRef(e, t),
t
}
,
i.prototype.addToRef = function(e, t) {
for (var r = this._m, n = t._m, o = e.m, a = 0; a < 16; a++)
n[a] = r[a] + o[a];
return t._markAsUpdated(),
this
}
,
i.prototype.addToSelf = function(e) {
for (var t = this._m, r = e.m, n = 0; n < 16; n++)
t[n] += r[n];
return this._markAsUpdated(),
this
}
,
i.prototype.invertToRef = function(e) {
if (this._isIdentity === !0)
return i.IdentityToRef(e),
this;
var t = this._m
, r = t[0]
, n = t[1]
, o = t[2]
, a = t[3]
, s = t[4]
, l = t[5]
, u = t[6]
, c = t[7]
, h = t[8]
, f = t[9]
, d = t[10]
, _ = t[11]
, g = t[12]
, m = t[13]
, v = t[14]
, y = t[15]
, b = d * y - v * _
, T = f * y - m * _
, C = f * v - m * d
, A = h * y - g * _
, S = h * v - d * g
, P = h * m - g * f
, R = +(l * b - u * T + c * C)
, M = -(s * b - u * A + c * S)
, x = +(s * T - l * A + c * P)
, I = -(s * C - l * S + u * P)
, w = r * R + n * M + o * x + a * I;
if (w === 0)
return e.copyFrom(this),
this;
var O = 1 / w
, D = u * y - v * c
, F = l * y - m * c
, V = l * v - m * u
, N = s * y - g * c
, L = s * v - g * u
, k = s * m - g * l
, U = u * _ - d * c
, z = l * _ - f * c
, H = l * d - f * u
, G = s * _ - h * c
, W = s * d - h * u
, j = s * f - h * l
, B = -(n * b - o * T + a * C)
, X = +(r * b - o * A + a * S)
, $ = -(r * T - n * A + a * P)
, Y = +(r * C - n * S + o * P)
, K = +(n * D - o * F + a * V)
, Z = -(r * D - o * N + a * L)
, q = +(r * F - n * N + a * k)
, J = -(r * V - n * L + o * k)
, Q = -(n * U - o * z + a * H)
, te = +(r * U - o * G + a * W)
, re = -(r * z - n * G + a * j)
, ie = +(r * H - n * W + o * j);
return i.FromValuesToRef(R * O, B * O, K * O, Q * O, M * O, X * O, Z * O, te * O, x * O, $ * O, q * O, re * O, I * O, Y * O, J * O, ie * O, e),
this
}
,
i.prototype.addAtIndex = function(e, t) {
return this._m[e] += t,
this._markAsUpdated(),
this
}
,
i.prototype.multiplyAtIndex = function(e, t) {
return this._m[e] *= t,
this._markAsUpdated(),
this
}
,
i.prototype.setTranslationFromFloats = function(e, t, r) {
return this._m[12] = e,
this._m[13] = t,
this._m[14] = r,
this._markAsUpdated(),
this
}
,
i.prototype.addTranslationFromFloats = function(e, t, r) {
return this._m[12] += e,
this._m[13] += t,
this._m[14] += r,
this._markAsUpdated(),
this
}
,
i.prototype.setTranslation = function(e) {
return this.setTranslationFromFloats(e._x, e._y, e._z)
}
,
i.prototype.getTranslation = function() {
return new Vector3(this._m[12],this._m[13],this._m[14])
}
,
i.prototype.getTranslationToRef = function(e) {
return e.x = this._m[12],
e.y = this._m[13],
e.z = this._m[14],
this
}
,
i.prototype.removeRotationAndScaling = function() {
var e = this.m;
return i.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, e[12], e[13], e[14], e[15], this),
this._updateIdentityStatus(e[12] === 0 && e[13] === 0 && e[14] === 0 && e[15] === 1),
this
}
,
i.prototype.multiply = function(e) {
var t = new i;
return this.multiplyToRef(e, t),
t
}
,
i.prototype.copyFrom = function(e) {
e.copyToArray(this._m);
var t = e;
return this.updateFlag = t.updateFlag,
this._updateIdentityStatus(t._isIdentity, t._isIdentityDirty, t._isIdentity3x2, t._isIdentity3x2Dirty),
this
}
,
i.prototype.copyToArray = function(e, t) {
t === void 0 && (t = 0);
var r = this._m;
return e[t] = r[0],
e[t + 1] = r[1],
e[t + 2] = r[2],
e[t + 3] = r[3],
e[t + 4] = r[4],
e[t + 5] = r[5],
e[t + 6] = r[6],
e[t + 7] = r[7],
e[t + 8] = r[8],
e[t + 9] = r[9],
e[t + 10] = r[10],
e[t + 11] = r[11],
e[t + 12] = r[12],
e[t + 13] = r[13],
e[t + 14] = r[14],
e[t + 15] = r[15],
this
}
,
i.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)
}
,
i.prototype.multiplyToArray = function(e, t, r) {
var n = this._m
, o = e.m
, a = n[0]
, s = n[1]
, l = n[2]
, u = n[3]
, c = n[4]
, h = n[5]
, f = n[6]
, d = n[7]
, _ = n[8]
, g = n[9]
, m = n[10]
, v = n[11]
, y = n[12]
, b = n[13]
, T = n[14]
, C = n[15]
, A = o[0]
, S = o[1]
, P = o[2]
, R = o[3]
, M = o[4]
, x = o[5]
, I = o[6]
, w = o[7]
, O = o[8]
, D = o[9]
, F = o[10]
, V = o[11]
, N = o[12]
, L = o[13]
, k = o[14]
, U = o[15];
return t[r] = a * A + s * M + l * O + u * N,
t[r + 1] = a * S + s * x + l * D + u * L,
t[r + 2] = a * P + s * I + l * F + u * k,
t[r + 3] = a * R + s * w + l * V + u * U,
t[r + 4] = c * A + h * M + f * O + d * N,
t[r + 5] = c * S + h * x + f * D + d * L,
t[r + 6] = c * P + h * I + f * F + d * k,
t[r + 7] = c * R + h * w + f * V + d * U,
t[r + 8] = _ * A + g * M + m * O + v * N,
t[r + 9] = _ * S + g * x + m * D + v * L,
t[r + 10] = _ * P + g * I + m * F + v * k,
t[r + 11] = _ * R + g * w + m * V + v * U,
t[r + 12] = y * A + b * M + T * O + C * N,
t[r + 13] = y * S + b * x + T * D + C * L,
t[r + 14] = y * P + b * I + T * F + C * k,
t[r + 15] = y * R + b * w + T * V + C * U,
this
}
,
i.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 r = this.m
, n = t.m;
return r[0] === n[0] && r[1] === n[1] && r[2] === n[2] && r[3] === n[3] && r[4] === n[4] && r[5] === n[5] && r[6] === n[6] && r[7] === n[7] && r[8] === n[8] && r[9] === n[9] && r[10] === n[10] && r[11] === n[11] && r[12] === n[12] && r[13] === n[13] && r[14] === n[14] && r[15] === n[15]
}
,
i.prototype.clone = function() {
var e = new i;
return e.copyFrom(this),
e
}
,
i.prototype.getClassName = function() {
return "Matrix"
}
,
i.prototype.getHashCode = function() {
for (var e = this._m[0] | 0, t = 1; t < 16; t++)
e = e * 397 ^ (this._m[t] | 0);
return e
}
,
i.prototype.decomposeToTransformNode = function(e) {
return e.rotationQuaternion = e.rotationQuaternion || new Quaternion,
this.decompose(e.scaling, e.rotationQuaternion, e.position)
}
,
i.prototype.decompose = function(e, t, r, n) {
if (this._isIdentity)
return r && r.setAll(0),
e && e.setAll(1),
t && t.copyFromFloats(0, 0, 0, 1),
!0;
var o = this._m;
if (r && r.copyFromFloats(o[12], o[13], o[14]),
e = e || MathTmp.Vector3[0],
e.x = Math.sqrt(o[0] * o[0] + o[1] * o[1] + o[2] * o[2]),
e.y = Math.sqrt(o[4] * o[4] + o[5] * o[5] + o[6] * o[6]),
e.z = Math.sqrt(o[8] * o[8] + o[9] * o[9] + o[10] * o[10]),
n) {
var a = n.scaling.x < 0 ? -1 : 1
, s = n.scaling.y < 0 ? -1 : 1
, l = n.scaling.z < 0 ? -1 : 1;
e.x *= a,
e.y *= s,
e.z *= l
} else
this.determinant() <= 0 && (e.y *= -1);
if (e._x === 0 || e._y === 0 || e._z === 0)
return t && t.copyFromFloats(0, 0, 0, 1),
!1;
if (t) {
var u = 1 / e._x
, c = 1 / e._y
, h = 1 / e._z;
i.FromValuesToRef(o[0] * u, o[1] * u, o[2] * u, 0, o[4] * c, o[5] * c, o[6] * c, 0, o[8] * h, o[9] * h, o[10] * h, 0, 0, 0, 0, 1, MathTmp.Matrix[0]),
Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], t)
}
return !0
}
,
i.prototype.getRow = function(e) {
if (e < 0 || e > 3)
return null;
var t = e * 4;
return new Vector4(this._m[t + 0],this._m[t + 1],this._m[t + 2],this._m[t + 3])
}
,
i.prototype.setRow = function(e, t) {
return this.setRowFromFloats(e, t.x, t.y, t.z, t.w)
}
,
i.prototype.transpose = function() {
return i.Transpose(this)
}
,
i.prototype.transposeToRef = function(e) {
return i.TransposeToRef(this, e),
this
}
,
i.prototype.setRowFromFloats = function(e, t, r, n, o) {
if (e < 0 || e > 3)
return this;
var a = e * 4;
return this._m[a + 0] = t,
this._m[a + 1] = r,
this._m[a + 2] = n,
this._m[a + 3] = o,
this._markAsUpdated(),
this
}
,
i.prototype.scale = function(e) {
var t = new i;
return this.scaleToRef(e, t),
t
}
,
i.prototype.scaleToRef = function(e, t) {
for (var r = 0; r < 16; r++)
t._m[r] = this._m[r] * e;
return t._markAsUpdated(),
this
}
,
i.prototype.scaleAndAddToRef = function(e, t) {
for (var r = 0; r < 16; r++)
t._m[r] += this._m[r] * e;
return t._markAsUpdated(),
this
}
,
i.prototype.toNormalMatrix = function(e) {
var t = MathTmp.Matrix[0];
this.invertToRef(t),
t.transposeToRef(e);
var r = e._m;
i.FromValuesToRef(r[0], r[1], r[2], 0, r[4], r[5], r[6], 0, r[8], r[9], r[10], 0, 0, 0, 0, 1, e)
}
,
i.prototype.getRotationMatrix = function() {
var e = new i;
return this.getRotationMatrixToRef(e),
e
}
,
i.prototype.getRotationMatrixToRef = function(e) {
var t = MathTmp.Vector3[0];
if (!this.decompose(t))
return i.IdentityToRef(e),
this;
var r = this._m
, n = 1 / t._x
, o = 1 / t._y
, a = 1 / t._z;
return i.FromValuesToRef(r[0] * n, r[1] * n, r[2] * n, 0, r[4] * o, r[5] * o, r[6] * o, 0, r[8] * a, r[9] * a, r[10] * a, 0, 0, 0, 0, 1, e),
this
}
,
i.prototype.toggleModelMatrixHandInPlace = function() {
var e = this._m;
e[2] *= -1,
e[6] *= -1,
e[8] *= -1,
e[9] *= -1,
e[14] *= -1,
this._markAsUpdated()
}
,
i.prototype.toggleProjectionMatrixHandInPlace = function() {
var e = this._m;
e[8] *= -1,
e[9] *= -1,
e[10] *= -1,
e[11] *= -1,
this._markAsUpdated()
}
,
i.FromArray = function(e, t) {
t === void 0 && (t = 0);
var r = new i;
return i.FromArrayToRef(e, t, r),
r
}
,
i.FromArrayToRef = function(e, t, r) {
for (var n = 0; n < 16; n++)
r._m[n] = e[n + t];
r._markAsUpdated()
}
,
i.FromFloat32ArrayToRefScaled = function(e, t, r, n) {
for (var o = 0; o < 16; o++)
n._m[o] = e[o + t] * r;
n._markAsUpdated()
}
,
Object.defineProperty(i, "IdentityReadOnly", {
get: function() {
return i._identityReadOnly
},
enumerable: !1,
configurable: !0
}),
i.FromValuesToRef = function(e, t, r, n, o, a, s, l, u, c, h, f, d, _, g, m, v) {
var y = v._m;
y[0] = e,
y[1] = t,
y[2] = r,
y[3] = n,
y[4] = o,
y[5] = a,
y[6] = s,
y[7] = l,
y[8] = u,
y[9] = c,
y[10] = h,
y[11] = f,
y[12] = d,
y[13] = _,
y[14] = g,
y[15] = m,
v._markAsUpdated()
}
,
i.FromValues = function(e, t, r, n, o, a, s, l, u, c, h, f, d, _, g, m) {
var v = new i
, y = v._m;
return y[0] = e,
y[1] = t,
y[2] = r,
y[3] = n,
y[4] = o,
y[5] = a,
y[6] = s,
y[7] = l,
y[8] = u,
y[9] = c,
y[10] = h,
y[11] = f,
y[12] = d,
y[13] = _,
y[14] = g,
y[15] = m,
v._markAsUpdated(),
v
}
,
i.Compose = function(e, t, r) {
var n = new i;
return i.ComposeToRef(e, t, r, n),
n
}
,
i.ComposeToRef = function(e, t, r, n) {
var o = n._m
, a = t._x
, s = t._y
, l = t._z
, u = t._w
, c = a + a
, h = s + s
, f = l + l
, d = a * c
, _ = a * h
, g = a * f
, m = s * h
, v = s * f
, y = l * f
, b = u * c
, T = u * h
, C = u * f
, A = e._x
, S = e._y
, P = e._z;
o[0] = (1 - (m + y)) * A,
o[1] = (_ + C) * A,
o[2] = (g - T) * A,
o[3] = 0,
o[4] = (_ - C) * S,
o[5] = (1 - (d + y)) * S,
o[6] = (v + b) * S,
o[7] = 0,
o[8] = (g + T) * P,
o[9] = (v - b) * P,
o[10] = (1 - (d + m)) * P,
o[11] = 0,
o[12] = r._x,
o[13] = r._y,
o[14] = r._z,
o[15] = 1,
n._markAsUpdated()
}
,
i.Identity = function() {
var e = i.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
return e._updateIdentityStatus(!0),
e
}
,
i.IdentityToRef = function(e) {
i.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, e),
e._updateIdentityStatus(!0)
}
,
i.Zero = function() {
var e = i.FromValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
return e._updateIdentityStatus(!1),
e
}
,
i.RotationX = function(e) {
var t = new i;
return i.RotationXToRef(e, t),
t
}
,
i.Invert = function(e) {
var t = new i;
return e.invertToRef(t),
t
}
,
i.RotationXToRef = function(e, t) {
var r = Math.sin(e)
, n = Math.cos(e);
i.FromValuesToRef(1, 0, 0, 0, 0, n, r, 0, 0, -r, n, 0, 0, 0, 0, 1, t),
t._updateIdentityStatus(n === 1 && r === 0)
}
,
i.RotationY = function(e) {
var t = new i;
return i.RotationYToRef(e, t),
t
}
,
i.RotationYToRef = function(e, t) {
var r = Math.sin(e)
, n = Math.cos(e);
i.FromValuesToRef(n, 0, -r, 0, 0, 1, 0, 0, r, 0, n, 0, 0, 0, 0, 1, t),
t._updateIdentityStatus(n === 1 && r === 0)
}
,
i.RotationZ = function(e) {
var t = new i;
return i.RotationZToRef(e, t),
t
}
,
i.RotationZToRef = function(e, t) {
var r = Math.sin(e)
, n = Math.cos(e);
i.FromValuesToRef(n, r, 0, 0, -r, n, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, t),
t._updateIdentityStatus(n === 1 && r === 0)
}
,
i.RotationAxis = function(e, t) {
var r = new i;
return i.RotationAxisToRef(e, t, r),
r
}
,
i.RotationAxisToRef = function(e, t, r) {
var n = Math.sin(-t)
, o = Math.cos(-t)
, a = 1 - o;
e.normalize();
var s = r._m;
s[0] = e._x * e._x * a + o,
s[1] = e._x * e._y * a - e._z * n,
s[2] = e._x * e._z * a + e._y * n,
s[3] = 0,
s[4] = e._y * e._x * a + e._z * n,
s[5] = e._y * e._y * a + o,
s[6] = e._y * e._z * a - e._x * n,
s[7] = 0,
s[8] = e._z * e._x * a - e._y * n,
s[9] = e._z * e._y * a + e._x * n,
s[10] = e._z * e._z * a + o,
s[11] = 0,
s[12] = 0,
s[13] = 0,
s[14] = 0,
s[15] = 1,
r._markAsUpdated()
}
,
i.RotationAlignToRef = function(e, t, r) {
var n = Vector3.Dot(t, e)
, o = r._m;
if (n < -1 + Epsilon)
o[0] = -1,
o[1] = 0,
o[2] = 0,
o[3] = 0,
o[4] = 0,
o[5] = -1,
o[6] = 0,
o[7] = 0,
o[8] = 0,
o[9] = 0,
o[10] = 1,
o[11] = 0;
else {
var a = Vector3.Cross(t, e)
, s = 1 / (1 + n);
o[0] = a._x * a._x * s + n,
o[1] = a._y * a._x * s - a._z,
o[2] = a._z * a._x * s + a._y,
o[3] = 0,
o[4] = a._x * a._y * s + a._z,
o[5] = a._y * a._y * s + n,
o[6] = a._z * a._y * s - a._x,
o[7] = 0,
o[8] = a._x * a._z * s - a._y,
o[9] = a._y * a._z * s + a._x,
o[10] = a._z * a._z * s + n,
o[11] = 0
}
o[12] = 0,
o[13] = 0,
o[14] = 0,
o[15] = 1,
r._markAsUpdated()
}
,
i.RotationYawPitchRoll = function(e, t, r) {
var n = new i;
return i.RotationYawPitchRollToRef(e, t, r, n),
n
}
,
i.RotationYawPitchRollToRef = function(e, t, r, n) {
Quaternion.RotationYawPitchRollToRef(e, t, r, MathTmp.Quaternion[0]),
MathTmp.Quaternion[0].toRotationMatrix(n)
}
,
i.Scaling = function(e, t, r) {
var n = new i;
return i.ScalingToRef(e, t, r, n),
n
}
,
i.ScalingToRef = function(e, t, r, n) {
i.FromValuesToRef(e, 0, 0, 0, 0, t, 0, 0, 0, 0, r, 0, 0, 0, 0, 1, n),
n._updateIdentityStatus(e === 1 && t === 1 && r === 1)
}
,
i.Translation = function(e, t, r) {
var n = new i;
return i.TranslationToRef(e, t, r, n),
n
}
,
i.TranslationToRef = function(e, t, r, n) {
i.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, e, t, r, 1, n),
n._updateIdentityStatus(e === 0 && t === 0 && r === 0)
}
,
i.Lerp = function(e, t, r) {
var n = new i;
return i.LerpToRef(e, t, r, n),
n
}
,
i.LerpToRef = function(e, t, r, n) {
for (var o = n._m, a = e.m, s = t.m, l = 0; l < 16; l++)
o[l] = a[l] * (1 - r) + s[l] * r;
n._markAsUpdated()
}
,
i.DecomposeLerp = function(e, t, r) {
var n = new i;
return i.DecomposeLerpToRef(e, t, r, n),
n
}
,
i.DecomposeLerpToRef = function(e, t, r, n) {
var o = MathTmp.Vector3[0]
, a = MathTmp.Quaternion[0]
, s = MathTmp.Vector3[1];
e.decompose(o, a, s);
var l = MathTmp.Vector3[2]
, u = MathTmp.Quaternion[1]
, c = MathTmp.Vector3[3];
t.decompose(l, u, c);
var h = MathTmp.Vector3[4];
Vector3.LerpToRef(o, l, r, h);
var f = MathTmp.Quaternion[2];
Quaternion.SlerpToRef(a, u, r, f);
var d = MathTmp.Vector3[5];
Vector3.LerpToRef(s, c, r, d),
i.ComposeToRef(h, f, d, n)
}
,
i.LookAtLH = function(e, t, r) {
var n = new i;
return i.LookAtLHToRef(e, t, r, n),
n
}
,
i.LookAtLHToRef = function(e, t, r, n) {
var o = MathTmp.Vector3[0]
, a = MathTmp.Vector3[1]
, s = MathTmp.Vector3[2];
t.subtractToRef(e, s),
s.normalize(),
Vector3.CrossToRef(r, s, o);
var l = o.lengthSquared();
l === 0 ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)),
Vector3.CrossToRef(s, o, a),
a.normalize();
var u = -Vector3.Dot(o, e)
, c = -Vector3.Dot(a, e)
, h = -Vector3.Dot(s, e);
i.FromValuesToRef(o._x, a._x, s._x, 0, o._y, a._y, s._y, 0, o._z, a._z, s._z, 0, u, c, h, 1, n)
}
,
i.LookAtRH = function(e, t, r) {
var n = new i;
return i.LookAtRHToRef(e, t, r, n),
n
}
,
i.LookAtRHToRef = function(e, t, r, n) {
var o = MathTmp.Vector3[0]
, a = MathTmp.Vector3[1]
, s = MathTmp.Vector3[2];
e.subtractToRef(t, s),
s.normalize(),
Vector3.CrossToRef(r, s, o);
var l = o.lengthSquared();
l === 0 ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)),
Vector3.CrossToRef(s, o, a),
a.normalize();
var u = -Vector3.Dot(o, e)
, c = -Vector3.Dot(a, e)
, h = -Vector3.Dot(s, e);
i.FromValuesToRef(o._x, a._x, s._x, 0, o._y, a._y, s._y, 0, o._z, a._z, s._z, 0, u, c, h, 1, n)
}
,
i.LookDirectionLH = function(e, t) {
var r = new i;
return i.LookDirectionLHToRef(e, t, r),
r
}
,
i.LookDirectionLHToRef = function(e, t, r) {
var n = MathTmp.Vector3[0];
n.copyFrom(e),
n.scaleInPlace(-1);
var o = MathTmp.Vector3[1];
Vector3.CrossToRef(t, n, o),
i.FromValuesToRef(o._x, o._y, o._z, 0, t._x, t._y, t._z, 0, n._x, n._y, n._z, 0, 0, 0, 0, 1, r)
}
,
i.LookDirectionRH = function(e, t) {
var r = new i;
return i.LookDirectionRHToRef(e, t, r),
r
}
,
i.LookDirectionRHToRef = function(e, t, r) {
var n = MathTmp.Vector3[2];
Vector3.CrossToRef(t, e, n),
i.FromValuesToRef(n._x, n._y, n._z, 0, t._x, t._y, t._z, 0, e._x, e._y, e._z, 0, 0, 0, 0, 1, r)
}
,
i.OrthoLH = function(e, t, r, n, o) {
var a = new i;
return i.OrthoLHToRef(e, t, r, n, a, o),
a
}
,
i.OrthoLHToRef = function(e, t, r, n, o, a) {
var s = r
, l = n
, u = 2 / e
, c = 2 / t
, h = 2 / (l - s)
, f = -(l + s) / (l - s);
i.FromValuesToRef(u, 0, 0, 0, 0, c, 0, 0, 0, 0, h, 0, 0, 0, f, 1, o),
a && o.multiplyToRef(mtxConvertNDCToHalfZRange, o),
o._updateIdentityStatus(u === 1 && c === 1 && h === 1 && f === 0)
}
,
i.OrthoOffCenterLH = function(e, t, r, n, o, a, s) {
var l = new i;
return i.OrthoOffCenterLHToRef(e, t, r, n, o, a, l, s),
l
}
,
i.OrthoOffCenterLHToRef = function(e, t, r, n, o, a, s, l) {
var u = o
, c = a
, h = 2 / (t - e)
, f = 2 / (n - r)
, d = 2 / (c - u)
, _ = -(c + u) / (c - u)
, g = (e + t) / (e - t)
, m = (n + r) / (r - n);
i.FromValuesToRef(h, 0, 0, 0, 0, f, 0, 0, 0, 0, d, 0, g, m, _, 1, s),
l && s.multiplyToRef(mtxConvertNDCToHalfZRange, s),
s._markAsUpdated()
}
,
i.OrthoOffCenterRH = function(e, t, r, n, o, a, s) {
var l = new i;
return i.OrthoOffCenterRHToRef(e, t, r, n, o, a, l, s),
l
}
,
i.OrthoOffCenterRHToRef = function(e, t, r, n, o, a, s, l) {
i.OrthoOffCenterLHToRef(e, t, r, n, o, a, s, l),
s._m[10] *= -1
}
,
i.PerspectiveLH = function(e, t, r, n, o, a) {
a === void 0 && (a = 0);
var s = new i
, l = r
, u = n
, c = 2 * l / e
, h = 2 * l / t
, f = (u + l) / (u - l)
, d = -2 * u * l / (u - l)
, _ = Math.tan(a);
return i.FromValuesToRef(c, 0, 0, 0, 0, h, 0, _, 0, 0, f, 1, 0, 0, d, 0, s),
o && s.multiplyToRef(mtxConvertNDCToHalfZRange, s),
s._updateIdentityStatus(!1),
s
}
,
i.PerspectiveFovLH = function(e, t, r, n, o, a, s) {
a === void 0 && (a = 0),
s === void 0 && (s = !1);
var l = new i;
return i.PerspectiveFovLHToRef(e, t, r, n, l, !0, o, a, s),
l
}
,
i.PerspectiveFovLHToRef = function(e, t, r, n, o, a, s, l, u) {
a === void 0 && (a = !0),
l === void 0 && (l = 0),
u === void 0 && (u = !1);
var c = r
, h = n
, f = 1 / Math.tan(e * .5)
, d = a ? f / t : f
, _ = a ? f : f * t
, g = u && c === 0 ? -1 : h !== 0 ? (h + c) / (h - c) : 1
, m = u && c === 0 ? 2 * h : h !== 0 ? -2 * h * c / (h - c) : -2 * c
, v = Math.tan(l);
i.FromValuesToRef(d, 0, 0, 0, 0, _, 0, v, 0, 0, g, 1, 0, 0, m, 0, o),
s && o.multiplyToRef(mtxConvertNDCToHalfZRange, o),
o._updateIdentityStatus(!1)
}
,
i.PerspectiveFovReverseLHToRef = function(e, t, r, n, o, a, s, l) {
a === void 0 && (a = !0),
l === void 0 && (l = 0);
var u = 1 / Math.tan(e * .5)
, c = a ? u / t : u
, h = a ? u : u * t
, f = Math.tan(l);
i.FromValuesToRef(c, 0, 0, 0, 0, h, 0, f, 0, 0, -r, 1, 0, 0, 1, 0, o),
s && o.multiplyToRef(mtxConvertNDCToHalfZRange, o),
o._updateIdentityStatus(!1)
}
,
i.PerspectiveFovRH = function(e, t, r, n, o, a, s) {
a === void 0 && (a = 0),
s === void 0 && (s = !1);
var l = new i;
return i.PerspectiveFovRHToRef(e, t, r, n, l, !0, o, a, s),
l
}
,
i.PerspectiveFovRHToRef = function(e, t, r, n, o, a, s, l, u) {
a === void 0 && (a = !0),
l === void 0 && (l = 0),
u === void 0 && (u = !1);
var c = r
, h = n
, f = 1 / Math.tan(e * .5)
, d = a ? f / t : f
, _ = a ? f : f * t
, g = u && c === 0 ? 1 : h !== 0 ? -(h + c) / (h - c) : -1
, m = u && c === 0 ? 2 * h : h !== 0 ? -2 * h * c / (h - c) : -2 * c
, v = Math.tan(l);
i.FromValuesToRef(d, 0, 0, 0, 0, _, 0, v, 0, 0, g, -1, 0, 0, m, 0, o),
s && o.multiplyToRef(mtxConvertNDCToHalfZRange, o),
o._updateIdentityStatus(!1)
}
,
i.PerspectiveFovReverseRHToRef = function(e, t, r, n, o, a, s, l) {
a === void 0 && (a = !0),
l === void 0 && (l = 0);
var u = 1 / Math.tan(e * .5)
, c = a ? u / t : u
, h = a ? u : u * t
, f = Math.tan(l);
i.FromValuesToRef(c, 0, 0, 0, 0, h, 0, f, 0, 0, -r, -1, 0, 0, -1, 0, o),
s && o.multiplyToRef(mtxConvertNDCToHalfZRange, o),
o._updateIdentityStatus(!1)
}
,
i.PerspectiveFovWebVRToRef = function(e, t, r, n, o, a, s) {
o === void 0 && (o = !1),
s === void 0 && (s = 0);
var l = o ? -1 : 1
, u = Math.tan(e.upDegrees * Math.PI / 180)
, c = Math.tan(e.downDegrees * Math.PI / 180)
, h = Math.tan(e.leftDegrees * Math.PI / 180)
, f = Math.tan(e.rightDegrees * Math.PI / 180)
, d = 2 / (h + f)
, _ = 2 / (u + c)
, g = Math.tan(s)
, m = n._m;
m[0] = d,
m[1] = m[2] = m[3] = m[4] = 0,
m[5] = _,
m[6] = 0,
m[7] = g,
m[8] = (h - f) * d * .5,
m[9] = -((u - c) * _ * .5),
m[10] = -r / (t - r),
m[11] = 1 * l,
m[12] = m[13] = m[15] = 0,
m[14] = -(2 * r * t) / (r - t),
a && n.multiplyToRef(mtxConvertNDCToHalfZRange, n),
n._markAsUpdated()
}
,
i.GetFinalMatrix = function(e, t, r, n, o, a) {
var s = e.width
, l = e.height
, u = e.x
, c = e.y
, h = i.FromValues(s / 2, 0, 0, 0, 0, -l / 2, 0, 0, 0, 0, a - o, 0, u + s / 2, l / 2 + c, o, 1)
, f = MathTmp.Matrix[0];
return t.multiplyToRef(r, f),
f.multiplyToRef(n, f),
f.multiply(h)
}
,
i.GetAsMatrix2x2 = function(e) {
var t = e.m
, r = [t[0], t[1], t[4], t[5]];
return PerformanceConfigurator.MatrixUse64Bits ? r : new Float32Array(r)
}
,
i.GetAsMatrix3x3 = function(e) {
var t = e.m
, r = [t[0], t[1], t[2], t[4], t[5], t[6], t[8], t[9], t[10]];
return PerformanceConfigurator.MatrixUse64Bits ? r : new Float32Array(r)
}
,
i.Transpose = function(e) {
var t = new i;
return i.TransposeToRef(e, t),
t
}
,
i.TransposeToRef = function(e, t) {
var r = t._m
, n = e.m;
r[0] = n[0],
r[1] = n[4],
r[2] = n[8],
r[3] = n[12],
r[4] = n[1],
r[5] = n[5],
r[6] = n[9],
r[7] = n[13],
r[8] = n[2],
r[9] = n[6],
r[10] = n[10],
r[11] = n[14],
r[12] = n[3],
r[13] = n[7],
r[14] = n[11],
r[15] = n[15],
t._markAsUpdated(),
t._updateIdentityStatus(e._isIdentity, e._isIdentityDirty)
}
,
i.Reflection = function(e) {
var t = new i;
return i.ReflectionToRef(e, t),
t
}
,
i.ReflectionToRef = function(e, t) {
e.normalize();
var r = e.normal.x
, n = e.normal.y
, o = e.normal.z
, a = -2 * r
, s = -2 * n
, l = -2 * o;
i.FromValuesToRef(a * r + 1, s * r, l * r, 0, a * n, s * n + 1, l * n, 0, a * o, s * o, l * o + 1, 0, a * e.d, s * e.d, l * e.d, 1, t)
}
,
i.FromXYZAxesToRef = function(e, t, r, n) {
i.FromValuesToRef(e._x, e._y, e._z, 0, t._x, t._y, t._z, 0, r._x, r._y, r._z, 0, 0, 0, 0, 1, n)
}
,
i.FromQuaternionToRef = function(e, t) {
var r = e._x * e._x
, n = e._y * e._y
, o = e._z * e._z
, a = e._x * e._y
, s = e._z * e._w
, l = e._z * e._x
, u = e._y * e._w
, c = e._y * e._z
, h = e._x * e._w;
t._m[0] = 1 - 2 * (n + o),
t._m[1] = 2 * (a + s),
t._m[2] = 2 * (l - u),
t._m[3] = 0,
t._m[4] = 2 * (a - s),
t._m[5] = 1 - 2 * (o + r),
t._m[6] = 2 * (c + h),
t._m[7] = 0,
t._m[8] = 2 * (l + u),
t._m[9] = 2 * (c - h),
t._m[10] = 1 - 2 * (n + r),
t._m[11] = 0,
t._m[12] = 0,
t._m[13] = 0,
t._m[14] = 0,
t._m[15] = 1,
t._markAsUpdated()
}
,
i._updateFlagSeed = 0,
i._identityReadOnly = i.Identity(),
i
}()
, MathTmp = function() {
function i() {}
return i.Vector3 = ArrayTools.BuildTuple(11, Vector3.Zero),
i.Matrix = ArrayTools.BuildTuple(2, Matrix.Identity),
i.Quaternion = ArrayTools.BuildTuple(3, Quaternion.Zero),
i
}()
, TmpVectors = function() {
function i() {}
return i.Vector2 = ArrayTools.BuildTuple(3, Vector2.Zero),
i.Vector3 = ArrayTools.BuildTuple(13, Vector3.Zero),
i.Vector4 = ArrayTools.BuildTuple(3, Vector4.Zero),
i.Quaternion = ArrayTools.BuildTuple(2, Quaternion.Zero),
i.Matrix = ArrayTools.BuildTuple(8, Matrix.Identity),
i
}();
RegisterClass("BABYLON.Vector2", Vector2);
RegisterClass("BABYLON.Vector3", Vector3);
RegisterClass("BABYLON.Vector4", Vector4);
RegisterClass("BABYLON.Matrix", Matrix);
var mtxConvertNDCToHalfZRange = Matrix.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, 0, 0, 0, .5, 1)
, AbstractScene = function() {
function i() {
this.rootNodes = new Array,
this.cameras = new Array,
this.lights = new Array,
this.meshes = new Array,
this.skeletons = new Array,
this.particleSystems = new Array,
this.animations = [],
this.animationGroups = new Array,
this.multiMaterials = new Array,
this.materials = new Array,
this.morphTargetManagers = new Array,
this.geometries = new Array,
this.transformNodes = new Array,
this.actionManagers = new Array,
this.textures = new Array,
this._environmentTexture = null,
this.postProcesses = new Array
}
return i.AddParser = function(e, t) {
this._BabylonFileParsers[e] = t
}
,
i.GetParser = function(e) {
return this._BabylonFileParsers[e] ? this._BabylonFileParsers[e] : null
}
,
i.AddIndividualParser = function(e, t) {
this._IndividualBabylonFileParsers[e] = t
}
,
i.GetIndividualParser = function(e) {
return this._IndividualBabylonFileParsers[e] ? this._IndividualBabylonFileParsers[e] : null
}
,
i.Parse = function(e, t, r, n) {
for (var o in this._BabylonFileParsers)
this._BabylonFileParsers.hasOwnProperty(o) && this._BabylonFileParsers[o](e, t, r, n)
}
,
Object.defineProperty(i.prototype, "environmentTexture", {
get: function() {
return this._environmentTexture
},
set: function(e) {
this._environmentTexture = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.getNodes = function() {
var e = new Array;
return e = e.concat(this.meshes),
e = e.concat(this.lights),
e = e.concat(this.cameras),
e = e.concat(this.transformNodes),
this.skeletons.forEach(function(t) {
return e = e.concat(t.bones)
}),
e
}
,
i._BabylonFileParsers = {},
i._IndividualBabylonFileParsers = {},
i
}()
, Color3 = function() {
function i(e, t, r) {
e === void 0 && (e = 0),
t === void 0 && (t = 0),
r === void 0 && (r = 0),
this.r = e,
this.g = t,
this.b = r
}
return i.prototype.toString = function() {
return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}"
}
,
i.prototype.getClassName = function() {
return "Color3"
}
,
i.prototype.getHashCode = function() {
var e = this.r * 255 | 0;
return e = e * 397 ^ (this.g * 255 | 0),
e = e * 397 ^ (this.b * 255 | 0),
e
}
,
i.prototype.toArray = function(e, t) {
return t === void 0 && (t = 0),
e[t] = this.r,
e[t + 1] = this.g,
e[t + 2] = this.b,
this
}
,
i.prototype.fromArray = function(e, t) {
return t === void 0 && (t = 0),
i.FromArrayToRef(e, t, this),
this
}
,
i.prototype.toColor4 = function(e) {
return e === void 0 && (e = 1),
new Color4(this.r,this.g,this.b,e)
}
,
i.prototype.asArray = function() {
var e = new Array;
return this.toArray(e, 0),
e
}
,
i.prototype.toLuminance = function() {
return this.r * .3 + this.g * .59 + this.b * .11
}
,
i.prototype.multiply = function(e) {
return new i(this.r * e.r,this.g * e.g,this.b * e.b)
}
,
i.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
}
,
i.prototype.equals = function(e) {
return e && this.r === e.r && this.g === e.g && this.b === e.b
}
,
i.prototype.equalsFloats = function(e, t, r) {
return this.r === e && this.g === t && this.b === r
}
,
i.prototype.scale = function(e) {
return new i(this.r * e,this.g * e,this.b * e)
}
,
i.prototype.scaleToRef = function(e, t) {
return t.r = this.r * e,
t.g = this.g * e,
t.b = this.b * e,
this
}
,
i.prototype.scaleAndAddToRef = function(e, t) {
return t.r += this.r * e,
t.g += this.g * e,
t.b += this.b * e,
this
}
,
i.prototype.clampToRef = function(e, t, r) {
return e === void 0 && (e = 0),
t === void 0 && (t = 1),
r.r = Scalar.Clamp(this.r, e, t),
r.g = Scalar.Clamp(this.g, e, t),
r.b = Scalar.Clamp(this.b, e, t),
this
}
,
i.prototype.add = function(e) {
return new i(this.r + e.r,this.g + e.g,this.b + e.b)
}
,
i.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
}
,
i.prototype.subtract = function(e) {
return new i(this.r - e.r,this.g - e.g,this.b - e.b)
}
,
i.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
}
,
i.prototype.clone = function() {
return new i(this.r,this.g,this.b)
}
,
i.prototype.copyFrom = function(e) {
return this.r = e.r,
this.g = e.g,
this.b = e.b,
this
}
,
i.prototype.copyFromFloats = function(e, t, r) {
return this.r = e,
this.g = t,
this.b = r,
this
}
,
i.prototype.set = function(e, t, r) {
return this.copyFromFloats(e, t, r)
}
,
i.prototype.toHexString = function() {
var e = Math.round(this.r * 255)
, t = Math.round(this.g * 255)
, r = Math.round(this.b * 255);
return "#" + Scalar.ToHex(e) + Scalar.ToHex(t) + Scalar.ToHex(r)
}
,
i.prototype.toLinearSpace = function() {
var e = new i;
return this.toLinearSpaceToRef(e),
e
}
,
i.prototype.toHSV = function() {
var e = new i;
return this.toHSVToRef(e),
e
}
,
i.prototype.toHSVToRef = function(e) {
var t = this.r
, r = this.g
, n = this.b
, o = Math.max(t, r, n)
, a = Math.min(t, r, n)
, s = 0
, l = 0
, u = o
, c = o - a;
o !== 0 && (l = c / o),
o != a && (o == t ? (s = (r - n) / c,
r < n && (s += 6)) : o == r ? s = (n - t) / c + 2 : o == n && (s = (t - r) / c + 4),
s *= 60),
e.r = s,
e.g = l,
e.b = u
}
,
i.prototype.toLinearSpaceToRef = function(e) {
return e.r = Math.pow(this.r, ToLinearSpace),
e.g = Math.pow(this.g, ToLinearSpace),
e.b = Math.pow(this.b, ToLinearSpace),
this
}
,
i.prototype.toGammaSpace = function() {
var e = new i;
return this.toGammaSpaceToRef(e),
e
}
,
i.prototype.toGammaSpaceToRef = function(e) {
return e.r = Math.pow(this.r, ToGammaSpace),
e.g = Math.pow(this.g, ToGammaSpace),
e.b = Math.pow(this.b, ToGammaSpace),
this
}
,
i.HSVtoRGBToRef = function(e, t, r, n) {
var o = r * t
, a = e / 60
, s = o * (1 - Math.abs(a % 2 - 1))
, l = 0
, u = 0
, c = 0;
a >= 0 && a <= 1 ? (l = o,
u = s) : a >= 1 && a <= 2 ? (l = s,
u = o) : a >= 2 && a <= 3 ? (u = o,
c = s) : a >= 3 && a <= 4 ? (u = s,
c = o) : a >= 4 && a <= 5 ? (l = s,
c = o) : a >= 5 && a <= 6 && (l = o,
c = s);
var h = r - o;
n.set(l + h, u + h, c + h)
}
,
i.FromHexString = function(e) {
if (e.substring(0, 1) !== "#" || e.length !== 7)
return new i(0,0,0);
var t = parseInt(e.substring(1, 3), 16)
, r = parseInt(e.substring(3, 5), 16)
, n = parseInt(e.substring(5, 7), 16);
return i.FromInts(t, r, n)
}
,
i.FromArray = function(e, t) {
return t === void 0 && (t = 0),
new i(e[t],e[t + 1],e[t + 2])
}
,
i.FromArrayToRef = function(e, t, r) {
t === void 0 && (t = 0),
r.r = e[t],
r.g = e[t + 1],
r.b = e[t + 2]
}
,
i.FromInts = function(e, t, r) {
return new i(e / 255,t / 255,r / 255)
}
,
i.Lerp = function(e, t, r) {
var n = new i(0,0,0);
return i.LerpToRef(e, t, r, n),
n
}
,
i.LerpToRef = function(e, t, r, n) {
n.r = e.r + (t.r - e.r) * r,
n.g = e.g + (t.g - e.g) * r,
n.b = e.b + (t.b - e.b) * r
}
,
i.Hermite = function(e, t, r, n, o) {
var a = o * o
, s = o * a
, l = 2 * s - 3 * a + 1
, u = -2 * s + 3 * a
, c = s - 2 * a + o
, h = s - a
, f = e.r * l + r.r * u + t.r * c + n.r * h
, d = e.g * l + r.g * u + t.g * c + n.g * h
, _ = e.b * l + r.b * u + t.b * c + n.b * h;
return new i(f,d,_)
}
,
i.Hermite1stDerivative = function(e, t, r, n, o) {
var a = i.Black();
return this.Hermite1stDerivativeToRef(e, t, r, n, o, a),
a
}
,
i.Hermite1stDerivativeToRef = function(e, t, r, n, o, a) {
var s = o * o;
a.r = (s - o) * 6 * e.r + (3 * s - 4 * o + 1) * t.r + (-s + o) * 6 * r.r + (3 * s - 2 * o) * n.r,
a.g = (s - o) * 6 * e.g + (3 * s - 4 * o + 1) * t.g + (-s + o) * 6 * r.g + (3 * s - 2 * o) * n.g,
a.b = (s - o) * 6 * e.b + (3 * s - 4 * o + 1) * t.b + (-s + o) * 6 * r.b + (3 * s - 2 * o) * n.b
}
,
i.Red = function() {
return new i(1,0,0)
}
,
i.Green = function() {
return new i(0,1,0)
}
,
i.Blue = function() {
return new i(0,0,1)
}
,
i.Black = function() {
return new i(0,0,0)
}
,
Object.defineProperty(i, "BlackReadOnly", {
get: function() {
return i._BlackReadOnly
},
enumerable: !1,
configurable: !0
}),
i.White = function() {
return new i(1,1,1)
}
,
i.Purple = function() {
return new i(.5,0,.5)
}
,
i.Magenta = function() {
return new i(1,0,1)
}
,
i.Yellow = function() {
return new i(1,1,0)
}
,
i.Gray = function() {
return new i(.5,.5,.5)
}
,
i.Teal = function() {
return new i(0,1,1)
}
,
i.Random = function() {
return new i(Math.random(),Math.random(),Math.random())
}
,
i._BlackReadOnly = i.Black(),
i
}()
, Color4 = function() {
function i(e, t, r, n) {
e === void 0 && (e = 0),
t === void 0 && (t = 0),
r === void 0 && (r = 0),
n === void 0 && (n = 1),
this.r = e,
this.g = t,
this.b = r,
this.a = n
}
return i.prototype.addInPlace = function(e) {
return this.r += e.r,
this.g += e.g,
this.b += e.b,
this.a += e.a,
this
}
,
i.prototype.asArray = function() {
var e = new Array;
return this.toArray(e, 0),
e
}
,
i.prototype.toArray = function(e, t) {
return t === void 0 && (t = 0),
e[t] = this.r,
e[t + 1] = this.g,
e[t + 2] = this.b,
e[t + 3] = this.a,
this
}
,
i.prototype.fromArray = function(e, t) {
return t === void 0 && (t = 0),
i.FromArrayToRef(e, t, this),
this
}
,
i.prototype.equals = function(e) {
return e && this.r === e.r && this.g === e.g && this.b === e.b && this.a === e.a
}
,
i.prototype.add = function(e) {
return new i(this.r + e.r,this.g + e.g,this.b + e.b,this.a + e.a)
}
,
i.prototype.subtract = function(e) {
return new i(this.r - e.r,this.g - e.g,this.b - e.b,this.a - e.a)
}
,
i.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
}
,
i.prototype.scale = function(e) {
return new i(this.r * e,this.g * e,this.b * e,this.a * e)
}
,
i.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
}
,
i.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
}
,
i.prototype.clampToRef = function(e, t, r) {
return e === void 0 && (e = 0),
t === void 0 && (t = 1),
r.r = Scalar.Clamp(this.r, e, t),
r.g = Scalar.Clamp(this.g, e, t),
r.b = Scalar.Clamp(this.b, e, t),
r.a = Scalar.Clamp(this.a, e, t),
this
}
,
i.prototype.multiply = function(e) {
return new i(this.r * e.r,this.g * e.g,this.b * e.b,this.a * e.a)
}
,
i.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
}
,
i.prototype.toString = function() {
return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}"
}
,
i.prototype.getClassName = function() {
return "Color4"
}
,
i.prototype.getHashCode = function() {
var e = this.r * 255 | 0;
return e = e * 397 ^ (this.g * 255 | 0),
e = e * 397 ^ (this.b * 255 | 0),
e = e * 397 ^ (this.a * 255 | 0),
e
}
,
i.prototype.clone = function() {
return new i(this.r,this.g,this.b,this.a)
}
,
i.prototype.copyFrom = function(e) {
return this.r = e.r,
this.g = e.g,
this.b = e.b,
this.a = e.a,
this
}
,
i.prototype.copyFromFloats = function(e, t, r, n) {
return this.r = e,
this.g = t,
this.b = r,
this.a = n,
this
}
,
i.prototype.set = function(e, t, r, n) {
return this.copyFromFloats(e, t, r, n)
}
,
i.prototype.toHexString = function(e) {
e === void 0 && (e = !1);
var t = Math.round(this.r * 255)
, r = Math.round(this.g * 255)
, n = Math.round(this.b * 255);
if (e)
return "#" + Scalar.ToHex(t) + Scalar.ToHex(r) + Scalar.ToHex(n);
var o = Math.round(this.a * 255);
return "#" + Scalar.ToHex(t) + Scalar.ToHex(r) + Scalar.ToHex(n) + Scalar.ToHex(o)
}
,
i.prototype.toLinearSpace = function() {
var e = new i;
return this.toLinearSpaceToRef(e),
e
}
,
i.prototype.toLinearSpaceToRef = function(e) {
return e.r = Math.pow(this.r, ToLinearSpace),
e.g = Math.pow(this.g, ToLinearSpace),
e.b = Math.pow(this.b, ToLinearSpace),
e.a = this.a,
this
}
,
i.prototype.toGammaSpace = function() {
var e = new i;
return this.toGammaSpaceToRef(e),
e
}
,
i.prototype.toGammaSpaceToRef = function(e) {
return e.r = Math.pow(this.r, ToGammaSpace),
e.g = Math.pow(this.g, ToGammaSpace),
e.b = Math.pow(this.b, ToGammaSpace),
e.a = this.a,
this
}
,
i.FromHexString = function(e) {
if (e.substring(0, 1) !== "#" || e.length !== 9 && e.length !== 7)
return new i(0,0,0,0);
var t = parseInt(e.substring(1, 3), 16)
, r = parseInt(e.substring(3, 5), 16)
, n = parseInt(e.substring(5, 7), 16)
, o = e.length === 9 ? parseInt(e.substring(7, 9), 16) : 255;
return i.FromInts(t, r, n, o)
}
,
i.Lerp = function(e, t, r) {
var n = new i(0,0,0,0);
return i.LerpToRef(e, t, r, n),
n
}
,
i.LerpToRef = function(e, t, r, n) {
n.r = e.r + (t.r - e.r) * r,
n.g = e.g + (t.g - e.g) * r,
n.b = e.b + (t.b - e.b) * r,
n.a = e.a + (t.a - e.a) * r
}
,
i.Hermite = function(e, t, r, n, o) {
var a = o * o
, s = o * a
, l = 2 * s - 3 * a + 1
, u = -2 * s + 3 * a
, c = s - 2 * a + o
, h = s - a
, f = e.r * l + r.r * u + t.r * c + n.r * h
, d = e.g * l + r.g * u + t.g * c + n.g * h
, _ = e.b * l + r.b * u + t.b * c + n.b * h
, g = e.a * l + r.a * u + t.a * c + n.a * h;
return new i(f,d,_,g)
}
,
i.Hermite1stDerivative = function(e, t, r, n, o) {
var a = new i;
return this.Hermite1stDerivativeToRef(e, t, r, n, o, a),
a
}
,
i.Hermite1stDerivativeToRef = function(e, t, r, n, o, a) {
var s = o * o;
a.r = (s - o) * 6 * e.r + (3 * s - 4 * o + 1) * t.r + (-s + o) * 6 * r.r + (3 * s - 2 * o) * n.r,
a.g = (s - o) * 6 * e.g + (3 * s - 4 * o + 1) * t.g + (-s + o) * 6 * r.g + (3 * s - 2 * o) * n.g,
a.b = (s - o) * 6 * e.b + (3 * s - 4 * o + 1) * t.b + (-s + o) * 6 * r.b + (3 * s - 2 * o) * n.b,
a.a = (s - o) * 6 * e.a + (3 * s - 4 * o + 1) * t.a + (-s + o) * 6 * r.a + (3 * s - 2 * o) * n.a
}
,
i.FromColor3 = function(e, t) {
return t === void 0 && (t = 1),
new i(e.r,e.g,e.b,t)
}
,
i.FromArray = function(e, t) {
return t === void 0 && (t = 0),
new i(e[t],e[t + 1],e[t + 2],e[t + 3])
}
,
i.FromArrayToRef = function(e, t, r) {
t === void 0 && (t = 0),
r.r = e[t],
r.g = e[t + 1],
r.b = e[t + 2],
r.a = e[t + 3]
}
,
i.FromInts = function(e, t, r, n) {
return new i(e / 255,t / 255,r / 255,n / 255)
}
,
i.CheckColors4 = function(e, t) {
if (e.length === t * 3) {
for (var r = [], n = 0; n < e.length; n += 3) {
var o = n / 3 * 4;
r[o] = e[n],
r[o + 1] = e[n + 1],
r[o + 2] = e[n + 2],
r[o + 3] = 1
}
return r
}
return e
}
,
i
}()
, TmpColors = function() {
function i() {}
return i.Color3 = ArrayTools.BuildArray(3, Color3.Black),
i.Color4 = ArrayTools.BuildArray(3, function() {
return new Color4(0,0,0,0)
}),
i
}();
RegisterClass("BABYLON.Color3", Color3);
RegisterClass("BABYLON.Color4", Color4);
var __decoratorInitialStore = {}
, __mergedStore = {}
, _copySource = function(i, e, t) {
var r = i();
Tags && Tags.AddTagsTo(r, e.tags);
var n = getMergedStore(r);
for (var o in n) {
var a = n[o]
, s = e[o]
, l = a.type;
if (s != null && (o !== "uniqueId" || SerializationHelper.AllowLoadingUniqueId))
switch (l) {
case 0:
case 6:
case 11:
r[o] = s;
break;
case 1:
r[o] = t || s.isRenderTarget ? s : s.clone();
break;
case 2:
case 3:
case 4:
case 5:
case 7:
case 10:
case 12:
r[o] = t ? s : s.clone();
break
}
}
return r
};
function getDirectStore(i) {
var e = i.getClassName();
return __decoratorInitialStore[e] || (__decoratorInitialStore[e] = {}),
__decoratorInitialStore[e]
}
function getMergedStore(i) {
var e = i.getClassName();
if (__mergedStore[e])
return __mergedStore[e];
__mergedStore[e] = {};
for (var t = __mergedStore[e], r = i, n = e; n; ) {
var o = __decoratorInitialStore[n];
for (var a in o)
t[a] = o[a];
var s = void 0
, l = !1;
do {
if (s = Object.getPrototypeOf(r),
!s.getClassName) {
l = !0;
break
}
if (s.getClassName() !== n)
break;
r = s
} while (s);
if (l)
break;
n = s.getClassName(),
r = s
}
return t
}
function generateSerializableMember(i, e) {
return function(t, r) {
var n = getDirectStore(t);
n[r] || (n[r] = {
type: i,
sourceName: e
})
}
}
function generateExpandMember(i, e) {
return e === void 0 && (e = null),
function(t, r) {
var n = e || "_" + r;
Object.defineProperty(t, r, {
get: function() {
return this[n]
},
set: function(o) {
this[n] !== o && (this[n] = o,
t[i].apply(this))
},
enumerable: !0,
configurable: !0
})
}
}
function expandToProperty(i, e) {
return e === void 0 && (e = null),
generateExpandMember(i, e)
}
function serialize(i) {
return generateSerializableMember(0, i)
}
function serializeAsTexture(i) {
return generateSerializableMember(1, i)
}
function serializeAsColor3(i) {
return generateSerializableMember(2, i)
}
function serializeAsFresnelParameters(i) {
return generateSerializableMember(3, i)
}
function serializeAsVector2(i) {
return generateSerializableMember(4, i)
}
function serializeAsVector3(i) {
return generateSerializableMember(5, i)
}
function serializeAsMeshReference(i) {
return generateSerializableMember(6, i)
}
function serializeAsColorCurves(i) {
return generateSerializableMember(7, i)
}
function serializeAsColor4(i) {
return generateSerializableMember(8, i)
}
function serializeAsImageProcessingConfiguration(i) {
return generateSerializableMember(9, i)
}
function serializeAsQuaternion(i) {
return generateSerializableMember(10, i)
}
function serializeAsMatrix(i) {
return generateSerializableMember(12, i)
}
function serializeAsCameraReference(i) {
return generateSerializableMember(11, i)
}
var SerializationHelper = function() {
function i() {}
return i.AppendSerializedAnimations = function(e, t) {
if (e.animations) {
t.animations = [];
for (var r = 0; r < e.animations.length; r++) {
var n = e.animations[r];
t.animations.push(n.serialize())
}
}
}
,
i.Serialize = function(e, t) {
t || (t = {}),
Tags && (t.tags = Tags.GetTags(e));
var r = getMergedStore(e);
for (var n in r) {
var o = r[n]
, a = o.sourceName || n
, s = o.type
, l = e[n];
if (l != null && (n !== "uniqueId" || i.AllowLoadingUniqueId))
switch (s) {
case 0:
t[a] = l;
break;
case 1:
t[a] = l.serialize();
break;
case 2:
t[a] = l.asArray();
break;
case 3:
t[a] = l.serialize();
break;
case 4:
t[a] = l.asArray();
break;
case 5:
t[a] = l.asArray();
break;
case 6:
t[a] = l.id;
break;
case 7:
t[a] = l.serialize();
break;
case 8:
t[a] = l.asArray();
break;
case 9:
t[a] = l.serialize();
break;
case 10:
t[a] = l.asArray();
break;
case 11:
t[a] = l.id;
break;
case 12:
t[a] = l.asArray();
break
}
}
return t
}
,
i.Parse = function(e, t, r, n) {
n === void 0 && (n = null);
var o = e();
n || (n = ""),
Tags && Tags.AddTagsTo(o, t.tags);
var a = getMergedStore(o);
for (var s in a) {
var l = a[s]
, u = t[l.sourceName || s]
, c = l.type;
if (u != null && (s !== "uniqueId" || i.AllowLoadingUniqueId)) {
var h = o;
switch (c) {
case 0:
h[s] = u;
break;
case 1:
r && (h[s] = i._TextureParser(u, r, n));
break;
case 2:
h[s] = Color3.FromArray(u);
break;
case 3:
h[s] = i._FresnelParametersParser(u);
break;
case 4:
h[s] = Vector2.FromArray(u);
break;
case 5:
h[s] = Vector3.FromArray(u);
break;
case 6:
r && (h[s] = r.getLastMeshById(u));
break;
case 7:
h[s] = i._ColorCurvesParser(u);
break;
case 8:
h[s] = Color4.FromArray(u);
break;
case 9:
h[s] = i._ImageProcessingConfigurationParser(u);
break;
case 10:
h[s] = Quaternion.FromArray(u);
break;
case 11:
r && (h[s] = r.getCameraById(u));
case 12:
h[s] = Matrix.FromArray(u);
break
}
}
}
return o
}
,
i.Clone = function(e, t) {
return _copySource(e, t, !1)
}
,
i.Instanciate = function(e, t) {
return _copySource(e, t, !0)
}
,
i.AllowLoadingUniqueId = !1,
i._ImageProcessingConfigurationParser = function(e) {
throw _WarnImport("ImageProcessingConfiguration")
}
,
i._FresnelParametersParser = function(e) {
throw _WarnImport("FresnelParameters")
}
,
i._ColorCurvesParser = function(e) {
throw _WarnImport("ColorCurves")
}
,
i._TextureParser = function(e, t, r) {
throw _WarnImport("Texture")
}
,
i
}();
function nativeOverride(i, e, t, r) {
var n = t.value;
t.value = function() {
for (var o = [], a = 0; a < arguments.length; a++)
o[a] = arguments[a];
var s = n;
if (typeof _native != "undefined" && _native[e]) {
var l = _native[e];
r ? s = function() {
for (var u = [], c = 0; c < arguments.length; c++)
u[c] = arguments[c];
return r.apply(void 0, u) ? l.apply(void 0, u) : n.apply(void 0, u)
}
: s = l
}
return i[e] = s,
s.apply(void 0, o)
}
}
nativeOverride.filter = function(i) {
return function(e, t, r) {
return nativeOverride(e, t, r, i)
}
}
;
var MaterialDefines = function() {
function i() {
this._isDirty = !0,
this._areLightsDirty = !0,
this._areLightsDisposed = !1,
this._areAttributesDirty = !0,
this._areTexturesDirty = !0,
this._areFresnelDirty = !0,
this._areMiscDirty = !0,
this._arePrePassDirty = !0,
this._areImageProcessingDirty = !0,
this._normals = !1,
this._uvs = !1,
this._needNormals = !1,
this._needUVs = !1
}
return Object.defineProperty(i.prototype, "isDirty", {
get: function() {
return this._isDirty
},
enumerable: !1,
configurable: !0
}),
i.prototype.markAsProcessed = function() {
this._isDirty = !1,
this._areAttributesDirty = !1,
this._areTexturesDirty = !1,
this._areFresnelDirty = !1,
this._areLightsDirty = !1,
this._areLightsDisposed = !1,
this._areMiscDirty = !1,
this._arePrePassDirty = !1,
this._areImageProcessingDirty = !1
}
,
i.prototype.markAsUnprocessed = function() {
this._isDirty = !0
}
,
i.prototype.markAllAsDirty = function() {
this._areTexturesDirty = !0,
this._areAttributesDirty = !0,
this._areLightsDirty = !0,
this._areFresnelDirty = !0,
this._areMiscDirty = !0,
this._areImageProcessingDirty = !0,
this._isDirty = !0
}
,
i.prototype.markAsImageProcessingDirty = function() {
this._areImageProcessingDirty = !0,
this._isDirty = !0
}
,
i.prototype.markAsLightDirty = function(e) {
e === void 0 && (e = !1),
this._areLightsDirty = !0,
this._areLightsDisposed = this._areLightsDisposed || e,
this._isDirty = !0
}
,
i.prototype.markAsAttributesDirty = function() {
this._areAttributesDirty = !0,
this._isDirty = !0
}
,
i.prototype.markAsTexturesDirty = function() {
this._areTexturesDirty = !0,
this._isDirty = !0
}
,
i.prototype.markAsFresnelDirty = function() {
this._areFresnelDirty = !0,
this._isDirty = !0
}
,
i.prototype.markAsMiscDirty = function() {
this._areMiscDirty = !0,
this._isDirty = !0
}
,
i.prototype.markAsPrePassDirty = function() {
this._arePrePassDirty = !0,
this._isDirty = !0
}
,
i.prototype.rebuild = function() {
this._keys = [];
for (var e = 0, t = Object.keys(this); e < t.length; e++) {
var r = t[e];
r[0] !== "_" && this._keys.push(r)
}
}
,
i.prototype.isEqual = function(e) {
if (this._keys.length !== e._keys.length)
return !1;
for (var t = 0; t < this._keys.length; t++) {
var r = this._keys[t];
if (this[r] !== e[r])
return !1
}
return !0
}
,
i.prototype.cloneTo = function(e) {
this._keys.length !== e._keys.length && (e._keys = this._keys.slice(0));
for (var t = 0; t < this._keys.length; t++) {
var r = this._keys[t];
e[r] = this[r]
}
}
,
i.prototype.reset = function() {
for (var e = 0; e < this._keys.length; e++) {
var t = this._keys[e]
, r = typeof this[t];
switch (r) {
case "number":
this[t] = 0;
break;
case "string":
this[t] = "";
break;
default:
this[t] = !1;
break
}
}
}
,
i.prototype.toString = function() {
for (var e = "", t = 0; t < this._keys.length; t++) {
var r = this._keys[t]
, n = this[r]
, o = typeof n;
switch (o) {
case "number":
case "string":
e += "#define " + r + " " + n + `
`;
break;
default:
n && (e += "#define " + r + `
`);
break
}
}
return e
}
,
i
}()
, ColorCurves = function() {
function i() {
this._dirty = !0,
this._tempColor = new Color4(0,0,0,0),
this._globalCurve = new Color4(0,0,0,0),
this._highlightsCurve = new Color4(0,0,0,0),
this._midtonesCurve = new Color4(0,0,0,0),
this._shadowsCurve = new Color4(0,0,0,0),
this._positiveCurve = new Color4(0,0,0,0),
this._negativeCurve = new Color4(0,0,0,0),
this._globalHue = 30,
this._globalDensity = 0,
this._globalSaturation = 0,
this._globalExposure = 0,
this._highlightsHue = 30,
this._highlightsDensity = 0,
this._highlightsSaturation = 0,
this._highlightsExposure = 0,
this._midtonesHue = 30,
this._midtonesDensity = 0,
this._midtonesSaturation = 0,
this._midtonesExposure = 0,
this._shadowsHue = 30,
this._shadowsDensity = 0,
this._shadowsSaturation = 0,
this._shadowsExposure = 0
}
return Object.defineProperty(i.prototype, "globalHue", {
get: function() {
return this._globalHue
},
set: function(e) {
this._globalHue = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "globalDensity", {
get: function() {
return this._globalDensity
},
set: function(e) {
this._globalDensity = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "globalSaturation", {
get: function() {
return this._globalSaturation
},
set: function(e) {
this._globalSaturation = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "globalExposure", {
get: function() {
return this._globalExposure
},
set: function(e) {
this._globalExposure = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "highlightsHue", {
get: function() {
return this._highlightsHue
},
set: function(e) {
this._highlightsHue = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "highlightsDensity", {
get: function() {
return this._highlightsDensity
},
set: function(e) {
this._highlightsDensity = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "highlightsSaturation", {
get: function() {
return this._highlightsSaturation
},
set: function(e) {
this._highlightsSaturation = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "highlightsExposure", {
get: function() {
return this._highlightsExposure
},
set: function(e) {
this._highlightsExposure = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "midtonesHue", {
get: function() {
return this._midtonesHue
},
set: function(e) {
this._midtonesHue = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "midtonesDensity", {
get: function() {
return this._midtonesDensity
},
set: function(e) {
this._midtonesDensity = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "midtonesSaturation", {
get: function() {
return this._midtonesSaturation
},
set: function(e) {
this._midtonesSaturation = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "midtonesExposure", {
get: function() {
return this._midtonesExposure
},
set: function(e) {
this._midtonesExposure = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "shadowsHue", {
get: function() {
return this._shadowsHue
},
set: function(e) {
this._shadowsHue = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "shadowsDensity", {
get: function() {
return this._shadowsDensity
},
set: function(e) {
this._shadowsDensity = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "shadowsSaturation", {
get: function() {
return this._shadowsSaturation
},
set: function(e) {
this._shadowsSaturation = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "shadowsExposure", {
get: function() {
return this._shadowsExposure
},
set: function(e) {
this._shadowsExposure = e,
this._dirty = !0
},
enumerable: !1,
configurable: !0
}),
i.prototype.getClassName = function() {
return "ColorCurves"
}
,
i.Bind = function(e, t, r, n, o) {
r === void 0 && (r = "vCameraColorCurvePositive"),
n === void 0 && (n = "vCameraColorCurveNeutral"),
o === void 0 && (o = "vCameraColorCurveNegative"),
e._dirty && (e._dirty = !1,
e.getColorGradingDataToRef(e._globalHue, e._globalDensity, e._globalSaturation, e._globalExposure, e._globalCurve),
e.getColorGradingDataToRef(e._highlightsHue, e._highlightsDensity, e._highlightsSaturation, e._highlightsExposure, e._tempColor),
e._tempColor.multiplyToRef(e._globalCurve, e._highlightsCurve),
e.getColorGradingDataToRef(e._midtonesHue, e._midtonesDensity, e._midtonesSaturation, e._midtonesExposure, e._tempColor),
e._tempColor.multiplyToRef(e._globalCurve, e._midtonesCurve),
e.getColorGradingDataToRef(e._shadowsHue, e._shadowsDensity, e._shadowsSaturation, e._shadowsExposure, e._tempColor),
e._tempColor.multiplyToRef(e._globalCurve, e._shadowsCurve),
e._highlightsCurve.subtractToRef(e._midtonesCurve, e._positiveCurve),
e._midtonesCurve.subtractToRef(e._shadowsCurve, e._negativeCurve)),
t && (t.setFloat4(r, e._positiveCurve.r, e._positiveCurve.g, e._positiveCurve.b, e._positiveCurve.a),
t.setFloat4(n, e._midtonesCurve.r, e._midtonesCurve.g, e._midtonesCurve.b, e._midtonesCurve.a),
t.setFloat4(o, e._negativeCurve.r, e._negativeCurve.g, e._negativeCurve.b, e._negativeCurve.a))
}
,
i.PrepareUniforms = function(e) {
e.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative")
}
,
i.prototype.getColorGradingDataToRef = function(e, t, r, n, o) {
e != null && (e = i.clamp(e, 0, 360),
t = i.clamp(t, -100, 100),
r = i.clamp(r, -100, 100),
n = i.clamp(n, -100, 100),
t = i.applyColorGradingSliderNonlinear(t),
t *= .5,
n = i.applyColorGradingSliderNonlinear(n),
t < 0 && (t *= -1,
e = (e + 180) % 360),
i.fromHSBToRef(e, t, 50 + .25 * n, o),
o.scaleToRef(2, o),
o.a = 1 + .01 * r)
}
,
i.applyColorGradingSliderNonlinear = function(e) {
e /= 100;
var t = Math.abs(e);
return t = Math.pow(t, 2),
e < 0 && (t *= -1),
t *= 100,
t
}
,
i.fromHSBToRef = function(e, t, r, n) {
var o = i.clamp(e, 0, 360)
, a = i.clamp(t / 100, 0, 1)
, s = i.clamp(r / 100, 0, 1);
if (a === 0)
n.r = s,
n.g = s,
n.b = s;
else {
o /= 60;
var l = Math.floor(o)
, u = o - l
, c = s * (1 - a)
, h = s * (1 - a * u)
, f = s * (1 - a * (1 - u));
switch (l) {
case 0:
n.r = s,
n.g = f,
n.b = c;
break;
case 1:
n.r = h,
n.g = s,
n.b = c;
break;
case 2:
n.r = c,
n.g = s,
n.b = f;
break;
case 3:
n.r = c,
n.g = h,
n.b = s;
break;
case 4:
n.r = f,
n.g = c,
n.b = s;
break;
default:
n.r = s,
n.g = c,
n.b = h;
break
}
}
n.a = 1
}
,
i.clamp = function(e, t, r) {
return Math.min(Math.max(e, t), r)
}
,
i.prototype.clone = function() {
return SerializationHelper.Clone(function() {
return new i
}, this)
}
,
i.prototype.serialize = function() {
return SerializationHelper.Serialize(this)
}
,
i.Parse = function(e) {
return SerializationHelper.Parse(function() {
return new i
}, e, null, null)
}
,
__decorate([serialize()], i.prototype, "_globalHue", void 0),
__decorate([serialize()], i.prototype, "_globalDensity", void 0),
__decorate([serialize()], i.prototype, "_globalSaturation", void 0),
__decorate([serialize()], i.prototype, "_globalExposure", void 0),
__decorate([serialize()], i.prototype, "_highlightsHue", void 0),
__decorate([serialize()], i.prototype, "_highlightsDensity", void 0),
__decorate([serialize()], i.prototype, "_highlightsSaturation", void 0),
__decorate([serialize()], i.prototype, "_highlightsExposure", void 0),
__decorate([serialize()], i.prototype, "_midtonesHue", void 0),
__decorate([serialize()], i.prototype, "_midtonesDensity", void 0),
__decorate([serialize()], i.prototype, "_midtonesSaturation", void 0),
__decorate([serialize()], i.prototype, "_midtonesExposure", void 0),
i
}();
SerializationHelper._ColorCurvesParser = ColorCurves.Parse;
var ImageProcessingConfigurationDefines = function(i) {
__extends(e, i);
function e() {
var t = i.call(this) || this;
return t.IMAGEPROCESSING = !1,
t.VIGNETTE = !1,
t.VIGNETTEBLENDMODEMULTIPLY = !1,
t.VIGNETTEBLENDMODEOPAQUE = !1,
t.TONEMAPPING = !1,
t.TONEMAPPING_ACES = !1,
t.CONTRAST = !1,
t.COLORCURVES = !1,
t.COLORGRADING = !1,
t.COLORGRADING3D = !1,
t.SAMPLER3DGREENDEPTH = !1,
t.SAMPLER3DBGRMAP = !1,
t.IMAGEPROCESSINGPOSTPROCESS = !1,
t.EXPOSURE = !1,
t.SKIPFINALCOLORCLAMP = !1,
t.rebuild(),
t
}
return e
}(MaterialDefines)
, ImageProcessingConfiguration = function() {
function i() {
this.colorCurves = new ColorCurves,
this._colorCurvesEnabled = !1,
this._colorGradingEnabled = !1,
this._colorGradingWithGreenDepth = !0,
this._colorGradingBGR = !0,
this._exposure = 1,
this._toneMappingEnabled = !1,
this._toneMappingType = i.TONEMAPPING_STANDARD,
this._contrast = 1,
this.vignetteStretch = 0,
this.vignetteCentreX = 0,
this.vignetteCentreY = 0,
this.vignetteWeight = 1.5,
this.vignetteColor = new Color4(0,0,0,0),
this.vignetteCameraFov = .5,
this._vignetteBlendMode = i.VIGNETTEMODE_MULTIPLY,
this._vignetteEnabled = !1,
this._skipFinalColorClamp = !1,
this._applyByPostProcess = !1,
this._isEnabled = !0,
this.onUpdateParameters = new Observable
}
return Object.defineProperty(i.prototype, "colorCurvesEnabled", {
get: function() {
return this._colorCurvesEnabled
},
set: function(e) {
this._colorCurvesEnabled !== e && (this._colorCurvesEnabled = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "colorGradingTexture", {
get: function() {
return this._colorGradingTexture
},
set: function(e) {
this._colorGradingTexture !== e && (this._colorGradingTexture = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "colorGradingEnabled", {
get: function() {
return this._colorGradingEnabled
},
set: function(e) {
this._colorGradingEnabled !== e && (this._colorGradingEnabled = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "colorGradingWithGreenDepth", {
get: function() {
return this._colorGradingWithGreenDepth
},
set: function(e) {
this._colorGradingWithGreenDepth !== e && (this._colorGradingWithGreenDepth = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "colorGradingBGR", {
get: function() {
return this._colorGradingBGR
},
set: function(e) {
this._colorGradingBGR !== e && (this._colorGradingBGR = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "exposure", {
get: function() {
return this._exposure
},
set: function(e) {
this._exposure !== e && (this._exposure = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "toneMappingEnabled", {
get: function() {
return this._toneMappingEnabled
},
set: function(e) {
this._toneMappingEnabled !== e && (this._toneMappingEnabled = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "toneMappingType", {
get: function() {
return this._toneMappingType
},
set: function(e) {
this._toneMappingType !== e && (this._toneMappingType = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "contrast", {
get: function() {
return this._contrast
},
set: function(e) {
this._contrast !== e && (this._contrast = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "vignetteBlendMode", {
get: function() {
return this._vignetteBlendMode
},
set: function(e) {
this._vignetteBlendMode !== e && (this._vignetteBlendMode = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "vignetteEnabled", {
get: function() {
return this._vignetteEnabled
},
set: function(e) {
this._vignetteEnabled !== e && (this._vignetteEnabled = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "skipFinalColorClamp", {
get: function() {
return this._skipFinalColorClamp
},
set: function(e) {
this._skipFinalColorClamp !== e && (this._skipFinalColorClamp = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "applyByPostProcess", {
get: function() {
return this._applyByPostProcess
},
set: function(e) {
this._applyByPostProcess !== e && (this._applyByPostProcess = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isEnabled", {
get: function() {
return this._isEnabled
},
set: function(e) {
this._isEnabled !== e && (this._isEnabled = e,
this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
i.prototype._updateParameters = function() {
this.onUpdateParameters.notifyObservers(this)
}
,
i.prototype.getClassName = function() {
return "ImageProcessingConfiguration"
}
,
i.PrepareUniforms = function(e, t) {
t.EXPOSURE && e.push("exposureLinear"),
t.CONTRAST && e.push("contrast"),
t.COLORGRADING && e.push("colorTransformSettings"),
t.VIGNETTE && (e.push("vInverseScreenSize"),
e.push("vignetteSettings1"),
e.push("vignetteSettings2")),
t.COLORCURVES && ColorCurves.PrepareUniforms(e)
}
,
i.PrepareSamplers = function(e, t) {
t.COLORGRADING && e.push("txColorTransform")
}
,
i.prototype.prepareDefines = function(e, t) {
if (t === void 0 && (t = !1),
t !== this.applyByPostProcess || !this._isEnabled) {
e.VIGNETTE = !1,
e.TONEMAPPING = !1,
e.TONEMAPPING_ACES = !1,
e.CONTRAST = !1,
e.EXPOSURE = !1,
e.COLORCURVES = !1,
e.COLORGRADING = !1,
e.COLORGRADING3D = !1,
e.IMAGEPROCESSING = !1,
e.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
e.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
return
}
switch (e.VIGNETTE = this.vignetteEnabled,
e.VIGNETTEBLENDMODEMULTIPLY = this.vignetteBlendMode === i._VIGNETTEMODE_MULTIPLY,
e.VIGNETTEBLENDMODEOPAQUE = !e.VIGNETTEBLENDMODEMULTIPLY,
e.TONEMAPPING = this.toneMappingEnabled,
this._toneMappingType) {
case i.TONEMAPPING_ACES:
e.TONEMAPPING_ACES = !0;
break;
default:
e.TONEMAPPING_ACES = !1;
break
}
e.CONTRAST = this.contrast !== 1,
e.EXPOSURE = this.exposure !== 1,
e.COLORCURVES = this.colorCurvesEnabled && !!this.colorCurves,
e.COLORGRADING = this.colorGradingEnabled && !!this.colorGradingTexture,
e.COLORGRADING ? e.COLORGRADING3D = this.colorGradingTexture.is3D : e.COLORGRADING3D = !1,
e.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth,
e.SAMPLER3DBGRMAP = this.colorGradingBGR,
e.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess,
e.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
e.IMAGEPROCESSING = e.VIGNETTE || e.TONEMAPPING || e.CONTRAST || e.EXPOSURE || e.COLORCURVES || e.COLORGRADING
}
,
i.prototype.isReady = function() {
return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady()
}
,
i.prototype.bind = function(e, t) {
if (this._colorCurvesEnabled && this.colorCurves && ColorCurves.Bind(this.colorCurves, e),
this._vignetteEnabled) {
var r = 1 / e.getEngine().getRenderWidth()
, n = 1 / e.getEngine().getRenderHeight();
e.setFloat2("vInverseScreenSize", r, n);
var o = t != null ? t : n / r
, a = Math.tan(this.vignetteCameraFov * .5)
, s = a * o
, l = Math.sqrt(s * a);
s = Tools.Mix(s, l, this.vignetteStretch),
a = Tools.Mix(a, l, this.vignetteStretch),
e.setFloat4("vignetteSettings1", s, a, -s * this.vignetteCentreX, -a * this.vignetteCentreY);
var u = -2 * this.vignetteWeight;
e.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, u)
}
if (e.setFloat("exposureLinear", this.exposure),
e.setFloat("contrast", this.contrast),
this.colorGradingTexture) {
e.setTexture("txColorTransform", this.colorGradingTexture);
var c = this.colorGradingTexture.getSize().height;
e.setFloat4("colorTransformSettings", (c - 1) / c, .5 / c, c, this.colorGradingTexture.level)
}
}
,
i.prototype.clone = function() {
return SerializationHelper.Clone(function() {
return new i
}, this)
}
,
i.prototype.serialize = function() {
return SerializationHelper.Serialize(this)
}
,
i.Parse = function(e) {
return SerializationHelper.Parse(function() {
return new i
}, e, null, null)
}
,
Object.defineProperty(i, "VIGNETTEMODE_MULTIPLY", {
get: function() {
return this._VIGNETTEMODE_MULTIPLY
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "VIGNETTEMODE_OPAQUE", {
get: function() {
return this._VIGNETTEMODE_OPAQUE
},
enumerable: !1,
configurable: !0
}),
i.TONEMAPPING_STANDARD = 0,
i.TONEMAPPING_ACES = 1,
i._VIGNETTEMODE_MULTIPLY = 0,
i._VIGNETTEMODE_OPAQUE = 1,
__decorate([serializeAsColorCurves()], i.prototype, "colorCurves", void 0),
__decorate([serialize()], i.prototype, "_colorCurvesEnabled", void 0),
__decorate([serializeAsTexture("colorGradingTexture")], i.prototype, "_colorGradingTexture", void 0),
__decorate([serialize()], i.prototype, "_colorGradingEnabled", void 0),
__decorate([serialize()], i.prototype, "_colorGradingWithGreenDepth", void 0),
__decorate([serialize()], i.prototype, "_colorGradingBGR", void 0),
__decorate([serialize()], i.prototype, "_exposure", void 0),
__decorate([serialize()], i.prototype, "_toneMappingEnabled", void 0),
__decorate([serialize()], i.prototype, "_toneMappingType", void 0),
__decorate([serialize()], i.prototype, "_contrast", void 0),
__decorate([serialize()], i.prototype, "vignetteStretch", void 0),
__decorate([serialize()], i.prototype, "vignetteCentreX", void 0),
__decorate([serialize()], i.prototype, "vignetteCentreY", void 0),
__decorate([serialize()], i.prototype, "vignetteWeight", void 0),
__decorate([serializeAsColor4()], i.prototype, "vignetteColor", void 0),
__decorate([serialize()], i.prototype, "vignetteCameraFov", void 0),
__decorate([serialize()], i.prototype, "_vignetteBlendMode", void 0),
__decorate([serialize()], i.prototype, "_vignetteEnabled", void 0),
__decorate([serialize()], i.prototype, "_skipFinalColorClamp", void 0),
__decorate([serialize()], i.prototype, "_applyByPostProcess", void 0),
__decorate([serialize()], i.prototype, "_isEnabled", void 0),
i
}();
SerializationHelper._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
ThinEngine.prototype.createUniformBuffer = function(i) {
var e = this._gl.createBuffer();
if (!e)
throw new Error("Unable to create uniform buffer");
var t = new WebGLDataBuffer(e);
return this.bindUniformBuffer(t),
i instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, i, this._gl.STATIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(i), this._gl.STATIC_DRAW),
this.bindUniformBuffer(null),
t.references = 1,
t
}
;
ThinEngine.prototype.createDynamicUniformBuffer = function(i) {
var e = this._gl.createBuffer();
if (!e)
throw new Error("Unable to create dynamic uniform buffer");
var t = new WebGLDataBuffer(e);
return this.bindUniformBuffer(t),
i instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, i, this._gl.DYNAMIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(i), this._gl.DYNAMIC_DRAW),
this.bindUniformBuffer(null),
t.references = 1,
t
}
;
ThinEngine.prototype.updateUniformBuffer = function(i, e, t, r) {
this.bindUniformBuffer(i),
t === void 0 && (t = 0),
r === void 0 ? e instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, t, e) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, t, new Float32Array(e)) : e instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, e.subarray(t, t + r)) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(e).subarray(t, t + r)),
this.bindUniformBuffer(null)
}
;
ThinEngine.prototype.bindUniformBuffer = function(i) {
this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, i ? i.underlyingResource : null)
}
;
ThinEngine.prototype.bindUniformBufferBase = function(i, e, t) {
this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, e, i ? i.underlyingResource : null)
}
;
ThinEngine.prototype.bindUniformBlock = function(i, e, t) {
var r = i.program
, n = this._gl.getUniformBlockIndex(r, e);
this._gl.uniformBlockBinding(r, n, t)
}
;
var UniformBuffer = function() {
function i(e, t, r, n) {
this._valueCache = {},
this._engine = e,
this._noUBO = !e.supportsUniformBuffers,
this._dynamic = r,
this._name = n != null ? n : "no-name",
this._data = t || [],
this._uniformLocations = {},
this._uniformSizes = {},
this._uniformArraySizes = {},
this._uniformLocationPointer = 0,
this._needSync = !1,
this._engine._features.trackUbosInFrame && (this._buffers = [],
this._bufferIndex = -1,
this._createBufferOnWrite = !1,
this._currentFrameId = 0),
this._noUBO ? (this.updateMatrix3x3 = this._updateMatrix3x3ForEffect,
this.updateMatrix2x2 = this._updateMatrix2x2ForEffect,
this.updateFloat = this._updateFloatForEffect,
this.updateFloat2 = this._updateFloat2ForEffect,
this.updateFloat3 = this._updateFloat3ForEffect,
this.updateFloat4 = this._updateFloat4ForEffect,
this.updateFloatArray = this._updateFloatArrayForEffect,
this.updateArray = this._updateArrayForEffect,
this.updateIntArray = this._updateIntArrayForEffect,
this.updateMatrix = this._updateMatrixForEffect,
this.updateMatrices = this._updateMatricesForEffect,
this.updateVector3 = this._updateVector3ForEffect,
this.updateVector4 = this._updateVector4ForEffect,
this.updateColor3 = this._updateColor3ForEffect,
this.updateColor4 = this._updateColor4ForEffect,
this.updateDirectColor4 = this._updateDirectColor4ForEffect,
this.updateInt = this._updateIntForEffect,
this.updateInt2 = this._updateInt2ForEffect,
this.updateInt3 = this._updateInt3ForEffect,
this.updateInt4 = this._updateInt4ForEffect) : (this._engine._uniformBuffers.push(this),
this.updateMatrix3x3 = this._updateMatrix3x3ForUniform,
this.updateMatrix2x2 = this._updateMatrix2x2ForUniform,
this.updateFloat = this._updateFloatForUniform,
this.updateFloat2 = this._updateFloat2ForUniform,
this.updateFloat3 = this._updateFloat3ForUniform,
this.updateFloat4 = this._updateFloat4ForUniform,
this.updateFloatArray = this._updateFloatArrayForUniform,
this.updateArray = this._updateArrayForUniform,
this.updateIntArray = this._updateIntArrayForUniform,
this.updateMatrix = this._updateMatrixForUniform,
this.updateMatrices = this._updateMatricesForUniform,
this.updateVector3 = this._updateVector3ForUniform,
this.updateVector4 = this._updateVector4ForUniform,
this.updateColor3 = this._updateColor3ForUniform,
this.updateColor4 = this._updateColor4ForUniform,
this.updateDirectColor4 = this._updateDirectColor4ForUniform,
this.updateInt = this._updateIntForUniform,
this.updateInt2 = this._updateInt2ForUniform,
this.updateInt3 = this._updateInt3ForUniform,
this.updateInt4 = this._updateInt4ForUniform)
}
return Object.defineProperty(i.prototype, "useUbo", {
get: function() {
return !this._noUBO
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isSync", {
get: function() {
return !this._needSync
},
enumerable: !1,
configurable: !0
}),
i.prototype.isDynamic = function() {
return this._dynamic !== void 0
}
,
i.prototype.getData = function() {
return this._bufferData
}
,
i.prototype.getBuffer = function() {
return this._buffer
}
,
i.prototype._fillAlignment = function(e) {
var t;
if (e <= 2 ? t = e : t = 4,
this._uniformLocationPointer % t !== 0) {
var r = this._uniformLocationPointer;
this._uniformLocationPointer += t - this._uniformLocationPointer % t;
for (var n = this._uniformLocationPointer - r, o = 0; o < n; o++)
this._data.push(0)
}
}
,
i.prototype.addUniform = function(e, t, r) {
if (r === void 0 && (r = 0),
!this._noUBO && this._uniformLocations[e] === void 0) {
var n;
if (r > 0) {
if (t instanceof Array)
throw "addUniform should not be use with Array in UBO: " + e;
if (this._fillAlignment(4),
this._uniformArraySizes[e] = {
strideSize: t,
arraySize: r
},
t == 16)
t = t * r;
else {
var o = 4 - t
, a = o * r;
t = t * r + a
}
n = [];
for (var s = 0; s < t; s++)
n.push(0)
} else {
if (t instanceof Array)
n = t,
t = n.length;
else {
t = t,
n = [];
for (var s = 0; s < t; s++)
n.push(0)
}
this._fillAlignment(t)
}
this._uniformSizes[e] = t,
this._uniformLocations[e] = this._uniformLocationPointer,
this._uniformLocationPointer += t;
for (var s = 0; s < t; s++)
this._data.push(n[s]);
this._needSync = !0
}
}
,
i.prototype.addMatrix = function(e, t) {
this.addUniform(e, Array.prototype.slice.call(t.toArray()))
}
,
i.prototype.addFloat2 = function(e, t, r) {
var n = [t, r];
this.addUniform(e, n)
}
,
i.prototype.addFloat3 = function(e, t, r, n) {
var o = [t, r, n];
this.addUniform(e, o)
}
,
i.prototype.addColor3 = function(e, t) {
var r = [t.r, t.g, t.b];
this.addUniform(e, r)
}
,
i.prototype.addColor4 = function(e, t, r) {
var n = [t.r, t.g, t.b, r];
this.addUniform(e, n)
}
,
i.prototype.addVector3 = function(e, t) {
var r = [t.x, t.y, t.z];
this.addUniform(e, r)
}
,
i.prototype.addMatrix3x3 = function(e) {
this.addUniform(e, 12)
}
,
i.prototype.addMatrix2x2 = function(e) {
this.addUniform(e, 8)
}
,
i.prototype.create = function() {
this._noUBO || this._buffer || (this._fillAlignment(4),
this._bufferData = new Float32Array(this._data),
this._rebuild(),
this._needSync = !0)
}
,
i.prototype._rebuild = function() {
this._noUBO || !this._bufferData || (this._dynamic ? this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData) : this._buffer = this._engine.createUniformBuffer(this._bufferData),
this._engine._features.trackUbosInFrame && (this._buffers.push([this._buffer, this._engine._features.checkUbosContentBeforeUpload ? this._bufferData.slice() : void 0]),
this._bufferIndex = this._buffers.length - 1,
this._createBufferOnWrite = !1))
}
,
Object.defineProperty(i.prototype, "_numBuffers", {
get: function() {
return this._buffers.length
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "_indexBuffer", {
get: function() {
return this._bufferIndex
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "name", {
get: function() {
return this._name
},
enumerable: !1,
configurable: !0
}),
i.prototype._buffersEqual = function(e, t) {
for (var r = 0; r < e.length; ++r)
if (e[r] !== t[r])
return !1;
return !0
}
,
i.prototype._copyBuffer = function(e, t) {
for (var r = 0; r < e.length; ++r)
t[r] = e[r]
}
,
i.prototype.update = function() {
if (this.bindUniformBuffer(),
!this._buffer) {
this.create();
return
}
if (!this._dynamic && !this._needSync) {
this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
return
}
if (this._buffers && this._buffers.length > 1 && this._buffers[this._bufferIndex][1])
if (this._buffersEqual(this._bufferData, this._buffers[this._bufferIndex][1])) {
this._needSync = !1,
this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
return
} else
this._copyBuffer(this._bufferData, this._buffers[this._bufferIndex][1]);
this._engine.updateUniformBuffer(this._buffer, this._bufferData),
this._engine._features._collectUbosUpdatedInFrame && (i._updatedUbosInFrame[this._name] || (i._updatedUbosInFrame[this._name] = 0),
i._updatedUbosInFrame[this._name]++),
this._needSync = !1,
this._createBufferOnWrite = this._engine._features.trackUbosInFrame
}
,
i.prototype._createNewBuffer = function() {
this._bufferIndex + 1 < this._buffers.length ? (this._bufferIndex++,
this._buffer = this._buffers[this._bufferIndex][0],
this._createBufferOnWrite = !1,
this._needSync = !0) : this._rebuild()
}
,
i.prototype._checkNewFrame = function() {
this._engine._features.trackUbosInFrame && this._currentFrameId !== this._engine.frameId && (this._currentFrameId = this._engine.frameId,
this._createBufferOnWrite = !1,
this._buffers && this._buffers.length > 0 ? (this._needSync = this._bufferIndex !== 0,
this._bufferIndex = 0,
this._buffer = this._buffers[this._bufferIndex][0]) : this._bufferIndex = -1)
}
,
i.prototype.updateUniform = function(e, t, r) {
this._checkNewFrame();
var n = this._uniformLocations[e];
if (n === void 0) {
if (this._buffer) {
Logger$2.Error("Cannot add an uniform after UBO has been created.");
return
}
this.addUniform(e, r),
n = this._uniformLocations[e]
}
if (this._buffer || this.create(),
this._dynamic)
for (var a = 0; a < r; a++)
this._bufferData[n + a] = t[a];
else {
for (var o = !1, a = 0; a < r; a++)
(r === 16 && !this._engine._features.uniformBufferHardCheckMatrix || this._bufferData[n + a] !== Tools.FloatRound(t[a])) && (o = !0,
this._createBufferOnWrite && this._createNewBuffer(),
this._bufferData[n + a] = t[a]);
this._needSync = this._needSync || o
}
}
,
i.prototype.updateUniformArray = function(e, t, r) {
this._checkNewFrame();
var n = this._uniformLocations[e];
if (n === void 0) {
Logger$2.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform.");
return
}
this._buffer || this.create();
var o = this._uniformArraySizes[e];
if (this._dynamic)
for (var u = 0; u < r; u++)
this._bufferData[n + u] = t[u];
else {
for (var a = !1, s = 0, l = 0, u = 0; u < r; u++)
if (this._bufferData[n + l * 4 + s] !== Tools.FloatRound(t[u]) && (a = !0,
this._createBufferOnWrite && this._createNewBuffer(),
this._bufferData[n + l * 4 + s] = t[u]),
s++,
s === o.strideSize) {
for (; s < 4; s++)
this._bufferData[n + l * 4 + s] = 0;
s = 0,
l++
}
this._needSync = this._needSync || a
}
}
,
i.prototype._cacheMatrix = function(e, t) {
this._checkNewFrame();
var r = this._valueCache[e]
, n = t.updateFlag;
return r !== void 0 && r === n ? !1 : (this._valueCache[e] = n,
!0)
}
,
i.prototype._updateMatrix3x3ForUniform = function(e, t) {
for (var r = 0; r < 3; r++)
i._tempBuffer[r * 4] = t[r * 3],
i._tempBuffer[r * 4 + 1] = t[r * 3 + 1],
i._tempBuffer[r * 4 + 2] = t[r * 3 + 2],
i._tempBuffer[r * 4 + 3] = 0;
this.updateUniform(e, i._tempBuffer, 12)
}
,
i.prototype._updateMatrix3x3ForEffect = function(e, t) {
this._currentEffect.setMatrix3x3(e, t)
}
,
i.prototype._updateMatrix2x2ForEffect = function(e, t) {
this._currentEffect.setMatrix2x2(e, t)
}
,
i.prototype._updateMatrix2x2ForUniform = function(e, t) {
for (var r = 0; r < 2; r++)
i._tempBuffer[r * 4] = t[r * 2],
i._tempBuffer[r * 4 + 1] = t[r * 2 + 1],
i._tempBuffer[r * 4 + 2] = 0,
i._tempBuffer[r * 4 + 3] = 0;
this.updateUniform(e, i._tempBuffer, 8)
}
,
i.prototype._updateFloatForEffect = function(e, t) {
this._currentEffect.setFloat(e, t)
}
,
i.prototype._updateFloatForUniform = function(e, t) {
i._tempBuffer[0] = t,
this.updateUniform(e, i._tempBuffer, 1)
}
,
i.prototype._updateFloat2ForEffect = function(e, t, r, n) {
n === void 0 && (n = ""),
this._currentEffect.setFloat2(e + n, t, r)
}
,
i.prototype._updateFloat2ForUniform = function(e, t, r) {
i._tempBuffer[0] = t,
i._tempBuffer[1] = r,
this.updateUniform(e, i._tempBuffer, 2)
}
,
i.prototype._updateFloat3ForEffect = function(e, t, r, n, o) {
o === void 0 && (o = ""),
this._currentEffect.setFloat3(e + o, t, r, n)
}
,
i.prototype._updateFloat3ForUniform = function(e, t, r, n) {
i._tempBuffer[0] = t,
i._tempBuffer[1] = r,
i._tempBuffer[2] = n,
this.updateUniform(e, i._tempBuffer, 3)
}
,
i.prototype._updateFloat4ForEffect = function(e, t, r, n, o, a) {
a === void 0 && (a = ""),
this._currentEffect.setFloat4(e + a, t, r, n, o)
}
,
i.prototype._updateFloat4ForUniform = function(e, t, r, n, o) {
i._tempBuffer[0] = t,
i._tempBuffer[1] = r,
i._tempBuffer[2] = n,
i._tempBuffer[3] = o,
this.updateUniform(e, i._tempBuffer, 4)
}
,
i.prototype._updateFloatArrayForEffect = function(e, t) {
this._currentEffect.setFloatArray(e, t)
}
,
i.prototype._updateFloatArrayForUniform = function(e, t) {
this.updateUniformArray(e, t, t.length)
}
,
i.prototype._updateArrayForEffect = function(e, t) {
this._currentEffect.setArray(e, t)
}
,
i.prototype._updateArrayForUniform = function(e, t) {
this.updateUniformArray(e, t, t.length)
}
,
i.prototype._updateIntArrayForEffect = function(e, t) {
this._currentEffect.setIntArray(e, t)
}
,
i.prototype._updateIntArrayForUniform = function(e, t) {
i._tempBufferInt32View.set(t),
this.updateUniformArray(e, i._tempBuffer, t.length)
}
,
i.prototype._updateMatrixForEffect = function(e, t) {
this._currentEffect.setMatrix(e, t)
}
,
i.prototype._updateMatrixForUniform = function(e, t) {
this._cacheMatrix(e, t) && this.updateUniform(e, t.toArray(), 16)
}
,
i.prototype._updateMatricesForEffect = function(e, t) {
this._currentEffect.setMatrices(e, t)
}
,
i.prototype._updateMatricesForUniform = function(e, t) {
this.updateUniform(e, t, t.length)
}
,
i.prototype._updateVector3ForEffect = function(e, t) {
this._currentEffect.setVector3(e, t)
}
,
i.prototype._updateVector3ForUniform = function(e, t) {
i._tempBuffer[0] = t.x,
i._tempBuffer[1] = t.y,
i._tempBuffer[2] = t.z,
this.updateUniform(e, i._tempBuffer, 3)
}
,
i.prototype._updateVector4ForEffect = function(e, t) {
this._currentEffect.setVector4(e, t)
}
,
i.prototype._updateVector4ForUniform = function(e, t) {
i._tempBuffer[0] = t.x,
i._tempBuffer[1] = t.y,
i._tempBuffer[2] = t.z,
i._tempBuffer[3] = t.w,
this.updateUniform(e, i._tempBuffer, 4)
}
,
i.prototype._updateColor3ForEffect = function(e, t, r) {
r === void 0 && (r = ""),
this._currentEffect.setColor3(e + r, t)
}
,
i.prototype._updateColor3ForUniform = function(e, t) {
i._tempBuffer[0] = t.r,
i._tempBuffer[1] = t.g,
i._tempBuffer[2] = t.b,
this.updateUniform(e, i._tempBuffer, 3)
}
,
i.prototype._updateColor4ForEffect = function(e, t, r, n) {
n === void 0 && (n = ""),
this._currentEffect.setColor4(e + n, t, r)
}
,
i.prototype._updateDirectColor4ForEffect = function(e, t, r) {
r === void 0 && (r = ""),
this._currentEffect.setDirectColor4(e + r, t)
}
,
i.prototype._updateColor4ForUniform = function(e, t, r) {
i._tempBuffer[0] = t.r,
i._tempBuffer[1] = t.g,
i._tempBuffer[2] = t.b,
i._tempBuffer[3] = r,
this.updateUniform(e, i._tempBuffer, 4)
}
,
i.prototype._updateDirectColor4ForUniform = function(e, t) {
i._tempBuffer[0] = t.r,
i._tempBuffer[1] = t.g,
i._tempBuffer[2] = t.b,
i._tempBuffer[3] = t.a,
this.updateUniform(e, i._tempBuffer, 4)
}
,
i.prototype._updateIntForEffect = function(e, t, r) {
r === void 0 && (r = ""),
this._currentEffect.setInt(e + r, t)
}
,
i.prototype._updateIntForUniform = function(e, t) {
i._tempBufferInt32View[0] = t,
this.updateUniform(e, i._tempBuffer, 1)
}
,
i.prototype._updateInt2ForEffect = function(e, t, r, n) {
n === void 0 && (n = ""),
this._currentEffect.setInt2(e + n, t, r)
}
,
i.prototype._updateInt2ForUniform = function(e, t, r) {
i._tempBufferInt32View[0] = t,
i._tempBufferInt32View[1] = r,
this.updateUniform(e, i._tempBuffer, 2)
}
,
i.prototype._updateInt3ForEffect = function(e, t, r, n, o) {
o === void 0 && (o = ""),
this._currentEffect.setInt3(e + o, t, r, n)
}
,
i.prototype._updateInt3ForUniform = function(e, t, r, n) {
i._tempBufferInt32View[0] = t,
i._tempBufferInt32View[1] = r,
i._tempBufferInt32View[2] = n,
this.updateUniform(e, i._tempBuffer, 3)
}
,
i.prototype._updateInt4ForEffect = function(e, t, r, n, o, a) {
a === void 0 && (a = ""),
this._currentEffect.setInt4(e + a, t, r, n, o)
}
,
i.prototype._updateInt4ForUniform = function(e, t, r, n, o) {
i._tempBufferInt32View[0] = t,
i._tempBufferInt32View[1] = r,
i._tempBufferInt32View[2] = n,
i._tempBufferInt32View[3] = o,
this.updateUniform(e, i._tempBuffer, 4)
}
,
i.prototype.setTexture = function(e, t) {
this._currentEffect.setTexture(e, t)
}
,
i.prototype.updateUniformDirectly = function(e, t) {
this.updateUniform(e, t, t.length),
this.update()
}
,
i.prototype.bindToEffect = function(e, t) {
this._currentEffect = e,
this._currentEffectName = t
}
,
i.prototype.bindUniformBuffer = function() {
!this._noUBO && this._buffer && this._currentEffect && this._currentEffect.bindUniformBuffer(this._buffer, this._currentEffectName)
}
,
i.prototype.unbindEffect = function() {
this._currentEffect = void 0,
this._currentEffectName = void 0
}
,
i.prototype.dispose = function() {
if (!this._noUBO) {
var e = this._engine._uniformBuffers
, t = e.indexOf(this);
if (t !== -1 && (e[t] = e[e.length - 1],
e.pop()),
this._engine._features.trackUbosInFrame && this._buffers)
for (var r = 0; r < this._buffers.length; ++r) {
var n = this._buffers[r][0];
this._engine._releaseBuffer(n)
}
else
this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null)
}
}
,
i._updatedUbosInFrame = {},
i._MAX_UNIFORM_SIZE = 256,
i._tempBuffer = new Float32Array(i._MAX_UNIFORM_SIZE),
i._tempBufferInt32View = new Uint32Array(i._tempBuffer.buffer),
i
}(), Buffer = function() {
function i(e, t, r, n, o, a, s, l) {
n === void 0 && (n = 0),
o === void 0 && (o = !1),
a === void 0 && (a = !1),
s === void 0 && (s = !1),
this._isAlreadyOwned = !1,
e.getScene ? this._engine = e.getScene().getEngine() : this._engine = e,
this._updatable = r,
this._instanced = a,
this._divisor = l || 1,
t instanceof DataBuffer ? (this._data = null,
this._buffer = t) : (this._data = t,
this._buffer = null),
this.byteStride = s ? n : n * Float32Array.BYTES_PER_ELEMENT,
o || this.create()
}
return i.prototype.createVertexBuffer = function(e, t, r, n, o, a, s) {
a === void 0 && (a = !1);
var l = a ? t : t * Float32Array.BYTES_PER_ELEMENT
, u = n ? a ? n : n * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
return new VertexBuffer(this._engine,this,e,this._updatable,!0,u,o === void 0 ? this._instanced : o,l,r,void 0,void 0,!0,this._divisor || s)
}
,
i.prototype.isUpdatable = function() {
return this._updatable
}
,
i.prototype.getData = function() {
return this._data
}
,
i.prototype.getBuffer = function() {
return this._buffer
}
,
i.prototype.getStrideSize = function() {
return this.byteStride / Float32Array.BYTES_PER_ELEMENT
}
,
i.prototype.create = function(e) {
e === void 0 && (e = null),
!(!e && this._buffer) && (e = e || this._data,
e && (this._buffer ? this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e),
this._data = e) : this._updatable ? (this._buffer = this._engine.createDynamicVertexBuffer(e),
this._data = e) : this._buffer = this._engine.createVertexBuffer(e)))
}
,
i.prototype._rebuild = function() {
this._buffer = null,
this.create(this._data)
}
,
i.prototype.update = function(e) {
this.create(e)
}
,
i.prototype.updateDirectly = function(e, t, r, n) {
n === void 0 && (n = !1),
!!this._buffer && this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e, n ? t : t * Float32Array.BYTES_PER_ELEMENT, r ? r * this.byteStride : void 0),
this._data = null)
}
,
i.prototype._increaseReferences = function() {
if (!!this._buffer) {
if (!this._isAlreadyOwned) {
this._isAlreadyOwned = !0;
return
}
this._buffer.references++
}
}
,
i.prototype.dispose = function() {
!this._buffer || this._engine._releaseBuffer(this._buffer) && (this._buffer = null,
this._data = null)
}
,
i
}(), VertexBuffer = function() {
function i(e, t, r, n, o, a, s, l, u, c, h, f, d, _) {
if (h === void 0 && (h = !1),
f === void 0 && (f = !1),
d === void 0 && (d = 1),
_ === void 0 && (_ = !1),
t instanceof Buffer ? (this._buffer = t,
this._ownsBuffer = _) : (this._buffer = new Buffer(e,t,n,a,o,s,f),
this._ownsBuffer = !0),
this.uniqueId = i._Counter++,
this._kind = r,
c == null) {
var g = this.getData();
this.type = i.FLOAT,
g instanceof Int8Array ? this.type = i.BYTE : g instanceof Uint8Array ? this.type = i.UNSIGNED_BYTE : g instanceof Int16Array ? this.type = i.SHORT : g instanceof Uint16Array ? this.type = i.UNSIGNED_SHORT : g instanceof Int32Array ? this.type = i.INT : g instanceof Uint32Array && (this.type = i.UNSIGNED_INT)
} else
this.type = c;
var m = i.GetTypeByteLength(this.type);
f ? (this._size = u || (a ? a / m : i.DeduceStride(r)),
this.byteStride = a || this._buffer.byteStride || this._size * m,
this.byteOffset = l || 0) : (this._size = u || a || i.DeduceStride(r),
this.byteStride = a ? a * m : this._buffer.byteStride || this._size * m,
this.byteOffset = (l || 0) * m),
this.normalized = h,
this._instanced = s !== void 0 ? s : !1,
this._instanceDivisor = s ? d : 0,
this._computeHashCode()
}
return Object.defineProperty(i.prototype, "instanceDivisor", {
get: function() {
return this._instanceDivisor
},
set: function(e) {
this._instanceDivisor = e,
e == 0 ? this._instanced = !1 : this._instanced = !0,
this._computeHashCode()
},
enumerable: !1,
configurable: !0
}),
i.prototype._computeHashCode = function() {
this.hashCode = (this.type - 5120 << 0) + ((this.normalized ? 1 : 0) << 3) + (this._size << 4) + ((this._instanced ? 1 : 0) << 6) + (this.byteStride << 12)
}
,
i.prototype._rebuild = function() {
!this._buffer || this._buffer._rebuild()
}
,
i.prototype.getKind = function() {
return this._kind
}
,
i.prototype.isUpdatable = function() {
return this._buffer.isUpdatable()
}
,
i.prototype.getData = function() {
return this._buffer.getData()
}
,
i.prototype.getFloatData = function(e, t) {
var r = this.getData();
if (!r)
return null;
var n = this.getSize() * i.GetTypeByteLength(this.type)
, o = e * this.getSize();
if (this.type !== i.FLOAT || this.byteStride !== n) {
var a = new Float32Array(o);
return this.forEach(o, function(h, f) {
return a[f] = h
}),
a
}
if (!(r instanceof Array || r instanceof Float32Array) || this.byteOffset !== 0 || r.length !== o)
if (r instanceof Array) {
var s = this.byteOffset / 4;
return SliceTools.Slice(r, s, s + o)
} else {
if (r instanceof ArrayBuffer)
return new Float32Array(r,this.byteOffset,o);
var s = r.byteOffset + this.byteOffset;
if (t) {
var l = new Float32Array(o)
, u = new Float32Array(r.buffer,s,o);
return l.set(u),
l
}
var c = s % 4;
return c && (s = Math.max(0, s - c)),
new Float32Array(r.buffer,s,o)
}
return t ? SliceTools.Slice(r) : r
}
,
i.prototype.getBuffer = function() {
return this._buffer.getBuffer()
}
,
i.prototype.getStrideSize = function() {
return this.byteStride / i.GetTypeByteLength(this.type)
}
,
i.prototype.getOffset = function() {
return this.byteOffset / i.GetTypeByteLength(this.type)
}
,
i.prototype.getSize = function(e) {
return e === void 0 && (e = !1),
e ? this._size * i.GetTypeByteLength(this.type) : this._size
}
,
i.prototype.getIsInstanced = function() {
return this._instanced
}
,
i.prototype.getInstanceDivisor = function() {
return this._instanceDivisor
}
,
i.prototype.create = function(e) {
this._buffer.create(e)
}
,
i.prototype.update = function(e) {
this._buffer.update(e)
}
,
i.prototype.updateDirectly = function(e, t, r) {
r === void 0 && (r = !1),
this._buffer.updateDirectly(e, t, void 0, r)
}
,
i.prototype.dispose = function() {
this._ownsBuffer && this._buffer.dispose()
}
,
i.prototype.forEach = function(e, t) {
i.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, e, this.normalized, t)
}
,
i.DeduceStride = function(e) {
switch (e) {
case i.UVKind:
case i.UV2Kind:
case i.UV3Kind:
case i.UV4Kind:
case i.UV5Kind:
case i.UV6Kind:
return 2;
case i.NormalKind:
case i.PositionKind:
return 3;
case i.ColorKind:
case i.MatricesIndicesKind:
case i.MatricesIndicesExtraKind:
case i.MatricesWeightsKind:
case i.MatricesWeightsExtraKind:
case i.TangentKind:
return 4;
default:
throw new Error("Invalid kind '" + e + "'")
}
}
,
i.GetTypeByteLength = function(e) {
switch (e) {
case i.BYTE:
case i.UNSIGNED_BYTE:
return 1;
case i.SHORT:
case i.UNSIGNED_SHORT:
return 2;
case i.INT:
case i.UNSIGNED_INT:
case i.FLOAT:
return 4;
default:
throw new Error("Invalid type '" + e + "'")
}
}
,
i.ForEach = function(e, t, r, n, o, a, s, l) {
if (e instanceof Array)
for (var u = t / 4, c = r / 4, h = 0; h < a; h += n) {
for (var f = 0; f < n; f++)
l(e[u + f], h + f);
u += c
}
else
for (var d = e instanceof ArrayBuffer ? new DataView(e) : new DataView(e.buffer,e.byteOffset,e.byteLength), _ = i.GetTypeByteLength(o), h = 0; h < a; h += n) {
for (var g = t, f = 0; f < n; f++) {
var m = i._GetFloatValue(d, o, g, s);
l(m, h + f),
g += _
}
t += r
}
}
,
i._GetFloatValue = function(e, t, r, n) {
switch (t) {
case i.BYTE:
{
var o = e.getInt8(r);
return n && (o = Math.max(o / 127, -1)),
o
}
case i.UNSIGNED_BYTE:
{
var o = e.getUint8(r);
return n && (o = o / 255),
o
}
case i.SHORT:
{
var o = e.getInt16(r, !0);
return n && (o = Math.max(o / 32767, -1)),
o
}
case i.UNSIGNED_SHORT:
{
var o = e.getUint16(r, !0);
return n && (o = o / 65535),
o
}
case i.INT:
return e.getInt32(r, !0);
case i.UNSIGNED_INT:
return e.getUint32(r, !0);
case i.FLOAT:
return e.getFloat32(r, !0);
default:
throw new Error("Invalid component type " + t)
}
}
,
i._Counter = 0,
i.BYTE = 5120,
i.UNSIGNED_BYTE = 5121,
i.SHORT = 5122,
i.UNSIGNED_SHORT = 5123,
i.INT = 5124,
i.UNSIGNED_INT = 5125,
i.FLOAT = 5126,
i.PositionKind = "position",
i.NormalKind = "normal",
i.TangentKind = "tangent",
i.UVKind = "uv",
i.UV2Kind = "uv2",
i.UV3Kind = "uv3",
i.UV4Kind = "uv4",
i.UV5Kind = "uv5",
i.UV6Kind = "uv6",
i.ColorKind = "color",
i.MatricesIndicesKind = "matricesIndices",
i.MatricesWeightsKind = "matricesWeights",
i.MatricesIndicesExtraKind = "matricesIndicesExtra",
i.MatricesWeightsExtraKind = "matricesWeightsExtra",
i
}(), PickingInfo = function() {
function i() {
this._pickingUnavailable = !1,
this.hit = !1,
this.distance = 0,
this.pickedPoint = null,
this.pickedMesh = null,
this.bu = 0,
this.bv = 0,
this.faceId = -1,
this.subMeshFaceId = -1,
this.subMeshId = 0,
this.pickedSprite = null,
this.thinInstanceIndex = -1,
this.ray = null,
this.originMesh = null,
this.aimTransform = null,
this.gripTransform = null
}
return i.prototype.getNormal = function(e, t) {
if (e === void 0 && (e = !1),
t === void 0 && (t = !0),
!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(VertexBuffer.NormalKind))
return null;
var r = this.pickedMesh.getIndices();
if (!r)
return null;
var n;
if (t) {
var o = this.pickedMesh.getVerticesData(VertexBuffer.NormalKind)
, a = Vector3.FromArray(o, r[this.faceId * 3] * 3)
, s = Vector3.FromArray(o, r[this.faceId * 3 + 1] * 3)
, l = Vector3.FromArray(o, r[this.faceId * 3 + 2] * 3);
a = a.scale(this.bu),
s = s.scale(this.bv),
l = l.scale(1 - this.bu - this.bv),
n = new Vector3(a.x + s.x + l.x,a.y + s.y + l.y,a.z + s.z + l.z)
} else {
var u = this.pickedMesh.getVerticesData(VertexBuffer.PositionKind)
, c = Vector3.FromArray(u, r[this.faceId * 3] * 3)
, h = Vector3.FromArray(u, r[this.faceId * 3 + 1] * 3)
, f = Vector3.FromArray(u, r[this.faceId * 3 + 2] * 3)
, d = c.subtract(h)
, _ = f.subtract(h);
n = Vector3.Cross(d, _)
}
if (e) {
var g = this.pickedMesh.getWorldMatrix();
this.pickedMesh.nonUniformScaling && (TmpVectors.Matrix[0].copyFrom(g),
g = TmpVectors.Matrix[0],
g.setTranslationFromFloats(0, 0, 0),
g.invert(),
g.transposeToRef(TmpVectors.Matrix[1]),
g = TmpVectors.Matrix[1]),
n = Vector3.TransformNormal(n, g)
}
return n.normalize(),
n
}
,
i.prototype.getTextureCoordinates = function() {
if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(VertexBuffer.UVKind))
return null;
var e = this.pickedMesh.getIndices();
if (!e)
return null;
var t = this.pickedMesh.getVerticesData(VertexBuffer.UVKind);
if (!t)
return null;
var r = Vector2.FromArray(t, e[this.faceId * 3] * 2)
, n = Vector2.FromArray(t, e[this.faceId * 3 + 1] * 2)
, o = Vector2.FromArray(t, e[this.faceId * 3 + 2] * 2);
return r = r.scale(this.bu),
n = n.scale(this.bv),
o = o.scale(1 - this.bu - this.bv),
new Vector2(r.x + n.x + o.x,r.y + n.y + o.y)
}
,
i
}(), ActionEvent = function() {
function i(e, t, r, n, o, a) {
this.source = e,
this.pointerX = t,
this.pointerY = r,
this.meshUnderPointer = n,
this.sourceEvent = o,
this.additionalData = a
}
return i.CreateNew = function(e, t, r) {
var n = e.getScene();
return new i(e,n.pointerX,n.pointerY,n.meshUnderPointer || e,t,r)
}
,
i.CreateNewFromSprite = function(e, t, r, n) {
return new i(e,t.pointerX,t.pointerY,t.meshUnderPointer,r,n)
}
,
i.CreateNewFromScene = function(e, t) {
return new i(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)
}
,
i.CreateNewFromPrimitive = function(e, t, r, n) {
return new i(e,t.x,t.y,null,r,n)
}
,
i
}(), PostProcessManager = function() {
function i(e) {
this._vertexBuffers = {},
this._scene = e
}
return i.prototype._prepareBuffers = function() {
if (!this._vertexBuffers[VertexBuffer.PositionKind]) {
var e = [];
e.push(1, 1),
e.push(-1, 1),
e.push(-1, -1),
e.push(1, -1),
this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(this._scene.getEngine(),e,VertexBuffer.PositionKind,!1,!1,2),
this._buildIndexBuffer()
}
}
,
i.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)
}
,
i.prototype._rebuild = function() {
var e = this._vertexBuffers[VertexBuffer.PositionKind];
!e || (e._rebuild(),
this._buildIndexBuffer())
}
,
i.prototype._prepareFrame = function(e, t) {
e === void 0 && (e = null),
t === void 0 && (t = null);
var r = this._scene.activeCamera;
return !r || (t = t || r._postProcesses.filter(function(n) {
return n != null
}),
!t || t.length === 0 || !this._scene.postProcessesEnabled) ? !1 : (t[0].activate(r, e, t != null),
!0)
}
,
i.prototype.directRender = function(e, t, r, n, o, a) {
var s;
t === void 0 && (t = null),
r === void 0 && (r = !1),
n === void 0 && (n = 0),
o === void 0 && (o = 0),
a === void 0 && (a = !1);
for (var l = this._scene.getEngine(), u = 0; u < e.length; u++) {
u < e.length - 1 ? e[u + 1].activate(this._scene.activeCamera, t == null ? void 0 : t.texture) : (t ? l.bindFramebuffer(t, n, void 0, void 0, r, o) : a || l.restoreDefaultFramebuffer(),
(s = l._debugInsertMarker) === null || s === void 0 || s.call(l, "post process " + e[u].name + " output"));
var c = e[u]
, h = c.apply();
h && (c.onBeforeRenderObservable.notifyObservers(h),
this._prepareBuffers(),
l.bindBuffers(this._vertexBuffers, this._indexBuffer, h),
l.drawElementsType(0, 0, 6),
c.onAfterRenderObservable.notifyObservers(h))
}
l.setDepthBuffer(!0),
l.setDepthWrite(!0)
}
,
i.prototype._finalizeFrame = function(e, t, r, n, o) {
var a;
o === void 0 && (o = !1);
var s = this._scene.activeCamera;
if (!!s && (n = n || s._postProcesses.filter(function(d) {
return d != null
}),
!(n.length === 0 || !this._scene.postProcessesEnabled))) {
for (var l = this._scene.getEngine(), u = 0, c = n.length; u < c; u++) {
var h = n[u];
if (u < c - 1 ? h._outputTexture = n[u + 1].activate(s, t == null ? void 0 : t.texture) : (t ? (l.bindFramebuffer(t, r, void 0, void 0, o),
h._outputTexture = t) : (l.restoreDefaultFramebuffer(),
h._outputTexture = null),
(a = l._debugInsertMarker) === null || a === void 0 || a.call(l, "post process " + n[u].name + " output")),
e)
break;
var f = h.apply();
f && (h.onBeforeRenderObservable.notifyObservers(f),
this._prepareBuffers(),
l.bindBuffers(this._vertexBuffers, this._indexBuffer, f),
l.drawElementsType(0, 0, 6),
h.onAfterRenderObservable.notifyObservers(f))
}
l.setDepthBuffer(!0),
l.setDepthWrite(!0),
l.setAlphaMode(0)
}
}
,
i.prototype.dispose = function() {
var e = this._vertexBuffers[VertexBuffer.PositionKind];
e && (e.dispose(),
this._vertexBuffers[VertexBuffer.PositionKind] = null),
this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
this._indexBuffer = null)
}
,
i
}(), RenderingGroup = function() {
function i(e, t, r, n, o) {
r === void 0 && (r = null),
n === void 0 && (n = null),
o === void 0 && (o = null),
this.index = e,
this._opaqueSubMeshes = new SmartArray(256),
this._transparentSubMeshes = new SmartArray(256),
this._alphaTestSubMeshes = new SmartArray(256),
this._depthOnlySubMeshes = new SmartArray(256),
this._particleSystems = new SmartArray(256),
this._spriteManagers = new SmartArray(256),
this._edgesRenderers = new SmartArrayNoDuplicate(16),
this._scene = t,
this.opaqueSortCompareFn = r,
this.alphaTestSortCompareFn = n,
this.transparentSortCompareFn = o
}
return Object.defineProperty(i.prototype, "opaqueSortCompareFn", {
set: function(e) {
this._opaqueSortCompareFn = e,
e ? this._renderOpaque = this.renderOpaqueSorted : this._renderOpaque = i.renderUnsorted
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "alphaTestSortCompareFn", {
set: function(e) {
this._alphaTestSortCompareFn = e,
e ? this._renderAlphaTest = this.renderAlphaTestSorted : this._renderAlphaTest = i.renderUnsorted
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "transparentSortCompareFn", {
set: function(e) {
e ? this._transparentSortCompareFn = e : this._transparentSortCompareFn = i.defaultTransparentSortCompare,
this._renderTransparent = this.renderTransparentSorted
},
enumerable: !1,
configurable: !0
}),
i.prototype.render = function(e, t, r, n) {
if (e) {
e(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
return
}
var o = this._scene.getEngine();
this._depthOnlySubMeshes.length !== 0 && (o.setColorWrite(!1),
this._renderAlphaTest(this._depthOnlySubMeshes),
o.setColorWrite(!0)),
this._opaqueSubMeshes.length !== 0 && this._renderOpaque(this._opaqueSubMeshes),
this._alphaTestSubMeshes.length !== 0 && this._renderAlphaTest(this._alphaTestSubMeshes);
var a = o.getStencilBuffer();
if (o.setStencilBuffer(!1),
t && this._renderSprites(),
r && this._renderParticles(n),
this.onBeforeTransparentRendering && this.onBeforeTransparentRendering(),
(this._transparentSubMeshes.length !== 0 || this._scene.useOrderIndependentTransparency) && (o.setStencilBuffer(a),
this._scene.useOrderIndependentTransparency ? this._scene.depthPeelingRenderer.render(this._transparentSubMeshes) : this._renderTransparent(this._transparentSubMeshes),
o.setAlphaMode(0)),
o.setStencilBuffer(!1),
this._edgesRenderers.length) {
for (var s = 0; s < this._edgesRenderers.length; s++)
this._edgesRenderers.data[s].render();
o.setAlphaMode(0)
}
o.setStencilBuffer(a)
}
,
i.prototype.renderOpaqueSorted = function(e) {
return i.renderSorted(e, this._opaqueSortCompareFn, this._scene.activeCamera, !1)
}
,
i.prototype.renderAlphaTestSorted = function(e) {
return i.renderSorted(e, this._alphaTestSortCompareFn, this._scene.activeCamera, !1)
}
,
i.prototype.renderTransparentSorted = function(e) {
return i.renderSorted(e, this._transparentSortCompareFn, this._scene.activeCamera, !0)
}
,
i.renderSorted = function(e, t, r, n) {
for (var o = 0, a, s = r ? r.globalPosition : i._zeroVector; o < e.length; o++)
a = e.data[o],
a._alphaIndex = a.getMesh().alphaIndex,
a._distanceToCamera = Vector3.Distance(a.getBoundingInfo().boundingSphere.centerWorld, s);
var l = e.data.slice(0, e.length);
for (t && l.sort(t),
o = 0; o < l.length; o++) {
if (a = l[o],
n) {
var u = a.getMaterial();
if (u && u.needDepthPrePass) {
var c = u.getScene().getEngine();
c.setColorWrite(!1),
c.setAlphaMode(0),
a.render(!1),
c.setColorWrite(!0)
}
}
a.render(n)
}
}
,
i.renderUnsorted = function(e) {
for (var t = 0; t < e.length; t++) {
var r = e.data[t];
r.render(!1)
}
}
,
i.defaultTransparentSortCompare = function(e, t) {
return e._alphaIndex > t._alphaIndex ? 1 : e._alphaIndex < t._alphaIndex ? -1 : i.backToFrontSortCompare(e, t)
}
,
i.backToFrontSortCompare = function(e, t) {
return e._distanceToCamera < t._distanceToCamera ? 1 : e._distanceToCamera > t._distanceToCamera ? -1 : 0
}
,
i.frontToBackSortCompare = function(e, t) {
return e._distanceToCamera < t._distanceToCamera ? -1 : e._distanceToCamera > t._distanceToCamera ? 1 : 0
}
,
i.prototype.prepare = function() {
this._opaqueSubMeshes.reset(),
this._transparentSubMeshes.reset(),
this._alphaTestSubMeshes.reset(),
this._depthOnlySubMeshes.reset(),
this._particleSystems.reset(),
this._spriteManagers.reset(),
this._edgesRenderers.reset()
}
,
i.prototype.dispose = function() {
this._opaqueSubMeshes.dispose(),
this._transparentSubMeshes.dispose(),
this._alphaTestSubMeshes.dispose(),
this._depthOnlySubMeshes.dispose(),
this._particleSystems.dispose(),
this._spriteManagers.dispose(),
this._edgesRenderers.dispose()
}
,
i.prototype.dispatch = function(e, t, r) {
t === void 0 && (t = e.getMesh()),
r === void 0 && (r = e.getMaterial()),
r != null && (r.needAlphaBlendingForMesh(t) ? this._transparentSubMeshes.push(e) : r.needAlphaTesting() ? (r.needDepthPrePass && this._depthOnlySubMeshes.push(e),
this._alphaTestSubMeshes.push(e)) : (r.needDepthPrePass && this._depthOnlySubMeshes.push(e),
this._opaqueSubMeshes.push(e)),
t._renderingGroup = this,
t._edgesRenderer && t._edgesRenderer.isEnabled && this._edgesRenderers.pushNoDuplicate(t._edgesRenderer))
}
,
i.prototype.dispatchSprites = function(e) {
this._spriteManagers.push(e)
}
,
i.prototype.dispatchParticles = function(e) {
this._particleSystems.push(e)
}
,
i.prototype._renderParticles = function(e) {
if (this._particleSystems.length !== 0) {
var t = this._scene.activeCamera;
this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
for (var r = 0; r < this._particleSystems.length; r++) {
var n = this._particleSystems.data[r];
if ((t && t.layerMask & n.layerMask) !== 0) {
var o = n.emitter;
(!o.position || !e || e.indexOf(o) !== -1) && this._scene._activeParticles.addCount(n.render(), !1)
}
}
this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)
}
}
,
i.prototype._renderSprites = function() {
if (!(!this._scene.spritesEnabled || this._spriteManagers.length === 0)) {
var e = this._scene.activeCamera;
this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
for (var t = 0; t < this._spriteManagers.length; t++) {
var r = this._spriteManagers.data[t];
(e && e.layerMask & r.layerMask) !== 0 && r.render()
}
this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)
}
}
,
i._zeroVector = Vector3.Zero(),
i
}(), RenderingGroupInfo = function() {
function i() {}
return i
}(), RenderingManager = function() {
function i(e) {
this._useSceneAutoClearSetup = !1,
this._renderingGroups = new Array,
this._autoClearDepthStencil = {},
this._customOpaqueSortCompareFn = {},
this._customAlphaTestSortCompareFn = {},
this._customTransparentSortCompareFn = {},
this._renderingGroupInfo = new RenderingGroupInfo,
this._scene = e;
for (var t = i.MIN_RENDERINGGROUPS; t < i.MAX_RENDERINGGROUPS; t++)
this._autoClearDepthStencil[t] = {
autoClear: !0,
depth: !0,
stencil: !0
}
}
return i.prototype._clearDepthStencilBuffer = function(e, t) {
e === void 0 && (e = !0),
t === void 0 && (t = !0),
!this._depthStencilBufferAlreadyCleaned && (this._scene.getEngine().clear(null, !1, e, t),
this._depthStencilBufferAlreadyCleaned = !0)
}
,
i.prototype.render = function(e, t, r, n) {
var o = this._renderingGroupInfo;
if (o.scene = this._scene,
o.camera = this._scene.activeCamera,
this._scene.spriteManagers && n)
for (var a = 0; a < this._scene.spriteManagers.length; a++) {
var s = this._scene.spriteManagers[a];
this.dispatchSprites(s)
}
for (var a = i.MIN_RENDERINGGROUPS; a < i.MAX_RENDERINGGROUPS; a++) {
this._depthStencilBufferAlreadyCleaned = a === i.MIN_RENDERINGGROUPS;
var l = this._renderingGroups[a];
if (!!l) {
var u = Math.pow(2, a);
if (o.renderingGroupId = a,
this._scene.onBeforeRenderingGroupObservable.notifyObservers(o, u),
i.AUTOCLEAR) {
var c = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(a) : this._autoClearDepthStencil[a];
c && c.autoClear && this._clearDepthStencilBuffer(c.depth, c.stencil)
}
for (var h = 0, f = this._scene._beforeRenderingGroupDrawStage; h < f.length; h++) {
var d = f[h];
d.action(a)
}
l.render(e, n, r, t);
for (var _ = 0, g = this._scene._afterRenderingGroupDrawStage; _ < g.length; _++) {
var d = g[_];
d.action(a)
}
this._scene.onAfterRenderingGroupObservable.notifyObservers(o, u)
}
}
}
,
i.prototype.reset = function() {
for (var e = i.MIN_RENDERINGGROUPS; e < i.MAX_RENDERINGGROUPS; e++) {
var t = this._renderingGroups[e];
t && t.prepare()
}
}
,
i.prototype.dispose = function() {
this.freeRenderingGroups(),
this._renderingGroups.length = 0,
this._renderingGroupInfo = null
}
,
i.prototype.freeRenderingGroups = function() {
for (var e = i.MIN_RENDERINGGROUPS; e < i.MAX_RENDERINGGROUPS; e++) {
var t = this._renderingGroups[e];
t && t.dispose()
}
}
,
i.prototype._prepareRenderingGroup = function(e) {
this._renderingGroups[e] === void 0 && (this._renderingGroups[e] = new RenderingGroup(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))
}
,
i.prototype.dispatchSprites = function(e) {
var t = e.renderingGroupId || 0;
this._prepareRenderingGroup(t),
this._renderingGroups[t].dispatchSprites(e)
}
,
i.prototype.dispatchParticles = function(e) {
var t = e.renderingGroupId || 0;
this._prepareRenderingGroup(t),
this._renderingGroups[t].dispatchParticles(e)
}
,
i.prototype.dispatch = function(e, t, r) {
t === void 0 && (t = e.getMesh());
var n = t.renderingGroupId || 0;
this._prepareRenderingGroup(n),
this._renderingGroups[n].dispatch(e, t, r)
}
,
i.prototype.setRenderingOrder = function(e, t, r, n) {
if (t === void 0 && (t = null),
r === void 0 && (r = null),
n === void 0 && (n = null),
this._customOpaqueSortCompareFn[e] = t,
this._customAlphaTestSortCompareFn[e] = r,
this._customTransparentSortCompareFn[e] = n,
this._renderingGroups[e]) {
var o = this._renderingGroups[e];
o.opaqueSortCompareFn = this._customOpaqueSortCompareFn[e],
o.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[e],
o.transparentSortCompareFn = this._customTransparentSortCompareFn[e]
}
}
,
i.prototype.setRenderingAutoClearDepthStencil = function(e, t, r, n) {
r === void 0 && (r = !0),
n === void 0 && (n = !0),
this._autoClearDepthStencil[e] = {
autoClear: t,
depth: r,
stencil: n
}
}
,
i.prototype.getAutoClearDepthStencilSetup = function(e) {
return this._autoClearDepthStencil[e]
}
,
i.MAX_RENDERINGGROUPS = 4,
i.MIN_RENDERINGGROUPS = 0,
i.AUTOCLEAR = !0,
i
}(), SceneComponentConstants = function() {
function i() {}
return i.NAME_EFFECTLAYER = "EffectLayer",
i.NAME_LAYER = "Layer",
i.NAME_LENSFLARESYSTEM = "LensFlareSystem",
i.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer",
i.NAME_PARTICLESYSTEM = "ParticleSystem",
i.NAME_GAMEPAD = "Gamepad",
i.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue",
i.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer",
i.NAME_PREPASSRENDERER = "PrePassRenderer",
i.NAME_DEPTHRENDERER = "DepthRenderer",
i.NAME_DEPTHPEELINGRENDERER = "DepthPeelingRenderer",
i.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager",
i.NAME_SPRITE = "Sprite",
i.NAME_SUBSURFACE = "SubSurface",
i.NAME_OUTLINERENDERER = "Outline",
i.NAME_PROCEDURALTEXTURE = "ProceduralTexture",
i.NAME_SHADOWGENERATOR = "ShadowGenerator",
i.NAME_OCTREE = "Octree",
i.NAME_PHYSICSENGINE = "PhysicsEngine",
i.NAME_AUDIO = "Audio",
i.STEP_ISREADYFORMESH_EFFECTLAYER = 0,
i.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0,
i.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0,
i.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0,
i.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1,
i.STEP_BEFORECAMERADRAW_PREPASS = 0,
i.STEP_BEFORECAMERADRAW_EFFECTLAYER = 1,
i.STEP_BEFORECAMERADRAW_LAYER = 2,
i.STEP_BEFORERENDERTARGETDRAW_PREPASS = 0,
i.STEP_BEFORERENDERTARGETDRAW_LAYER = 1,
i.STEP_BEFORERENDERINGMESH_PREPASS = 0,
i.STEP_BEFORERENDERINGMESH_OUTLINE = 1,
i.STEP_AFTERRENDERINGMESH_PREPASS = 0,
i.STEP_AFTERRENDERINGMESH_OUTLINE = 1,
i.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0,
i.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1,
i.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0,
i.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1,
i.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0,
i.STEP_AFTERRENDERTARGETDRAW_PREPASS = 0,
i.STEP_AFTERRENDERTARGETDRAW_LAYER = 1,
i.STEP_AFTERCAMERADRAW_PREPASS = 0,
i.STEP_AFTERCAMERADRAW_EFFECTLAYER = 1,
i.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2,
i.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3,
i.STEP_AFTERCAMERADRAW_LAYER = 4,
i.STEP_AFTERRENDER_AUDIO = 0,
i.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0,
i.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1,
i.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2,
i.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3,
i.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0,
i.STEP_BEFORECLEARSTAGE_PREPASS = 0,
i.STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS = 0,
i.STEP_POINTERMOVE_SPRITE = 0,
i.STEP_POINTERDOWN_SPRITE = 0,
i.STEP_POINTERUP_SPRITE = 0,
i
}(), Stage = function(i) {
__extends(e, i);
function e(t) {
return i.apply(this, t) || this
}
return e.Create = function() {
return Object.create(e.prototype)
}
,
e.prototype.registerStep = function(t, r, n) {
for (var o = 0, a = Number.MAX_VALUE; o < this.length; o++) {
var s = this[o];
if (a = s.index,
t < a)
break
}
this.splice(o, 0, {
index: t,
component: r,
action: n.bind(r)
})
}
,
e.prototype.clear = function() {
this.length = 0
}
,
e
}(Array), PointerEventTypes = function() {
function i() {}
return i.POINTERDOWN = 1,
i.POINTERUP = 2,
i.POINTERMOVE = 4,
i.POINTERWHEEL = 8,
i.POINTERPICK = 16,
i.POINTERTAP = 32,
i.POINTERDOUBLETAP = 64,
i
}(), PointerInfoBase = function() {
function i(e, t) {
this.type = e,
this.event = t
}
return i
}(), PointerInfoPre = function(i) {
__extends(e, i);
function e(t, r, n, o) {
var a = i.call(this, t, r) || this;
return a.ray = null,
a.skipOnPointerObservable = !1,
a.localPosition = new Vector2(n,o),
a
}
return e
}(PointerInfoBase), PointerInfo = function(i) {
__extends(e, i);
function e(t, r, n) {
var o = i.call(this, t, r) || this;
return o.pickInfo = n,
o
}
return e
}(PointerInfoBase), AbstractActionManager = function() {
function i() {
this.hoverCursor = "",
this.actions = new Array,
this.isRecursive = !1
}
return Object.defineProperty(i, "HasTriggers", {
get: function() {
for (var e in i.Triggers)
if (i.Triggers.hasOwnProperty(e))
return !0;
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "HasPickTriggers", {
get: function() {
for (var e in i.Triggers)
if (i.Triggers.hasOwnProperty(e)) {
var t = parseInt(e);
if (t >= 1 && t <= 7)
return !0
}
return !1
},
enumerable: !1,
configurable: !0
}),
i.HasSpecificTrigger = function(e) {
for (var t in i.Triggers)
if (i.Triggers.hasOwnProperty(t)) {
var r = parseInt(t);
if (r === e)
return !0
}
return !1
}
,
i.Triggers = {},
i
}(), KeyboardEventTypes = function() {
function i() {}
return i.KEYDOWN = 1,
i.KEYUP = 2,
i
}(), KeyboardInfo = function() {
function i(e, t) {
this.type = e,
this.event = t
}
return i
}(), KeyboardInfoPre = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t, r) || this;
return n.type = t,
n.event = r,
n.skipOnPointerObservable = !1,
n
}
return e
}(KeyboardInfo), DeviceType;
(function(i) {
i[i.Generic = 0] = "Generic",
i[i.Keyboard = 1] = "Keyboard",
i[i.Mouse = 2] = "Mouse",
i[i.Touch = 3] = "Touch",
i[i.DualShock = 4] = "DualShock",
i[i.Xbox = 5] = "Xbox",
i[i.Switch = 6] = "Switch"
}
)(DeviceType || (DeviceType = {}));
var PointerInput;
(function(i) {
i[i.Horizontal = 0] = "Horizontal",
i[i.Vertical = 1] = "Vertical",
i[i.LeftClick = 2] = "LeftClick",
i[i.MiddleClick = 3] = "MiddleClick",
i[i.RightClick = 4] = "RightClick",
i[i.BrowserBack = 5] = "BrowserBack",
i[i.BrowserForward = 6] = "BrowserForward",
i[i.MouseWheelX = 7] = "MouseWheelX",
i[i.MouseWheelY = 8] = "MouseWheelY",
i[i.MouseWheelZ = 9] = "MouseWheelZ",
i[i.DeltaHorizontal = 10] = "DeltaHorizontal",
i[i.DeltaVertical = 11] = "DeltaVertical"
}
)(PointerInput || (PointerInput = {}));
var DualShockInput;
(function(i) {
i[i.Cross = 0] = "Cross",
i[i.Circle = 1] = "Circle",
i[i.Square = 2] = "Square",
i[i.Triangle = 3] = "Triangle",
i[i.L1 = 4] = "L1",
i[i.R1 = 5] = "R1",
i[i.L2 = 6] = "L2",
i[i.R2 = 7] = "R2",
i[i.Share = 8] = "Share",
i[i.Options = 9] = "Options",
i[i.L3 = 10] = "L3",
i[i.R3 = 11] = "R3",
i[i.DPadUp = 12] = "DPadUp",
i[i.DPadDown = 13] = "DPadDown",
i[i.DPadLeft = 14] = "DPadLeft",
i[i.DPadRight = 15] = "DPadRight",
i[i.Home = 16] = "Home",
i[i.TouchPad = 17] = "TouchPad",
i[i.LStickXAxis = 18] = "LStickXAxis",
i[i.LStickYAxis = 19] = "LStickYAxis",
i[i.RStickXAxis = 20] = "RStickXAxis",
i[i.RStickYAxis = 21] = "RStickYAxis"
}
)(DualShockInput || (DualShockInput = {}));
var XboxInput;
(function(i) {
i[i.A = 0] = "A",
i[i.B = 1] = "B",
i[i.X = 2] = "X",
i[i.Y = 3] = "Y",
i[i.LB = 4] = "LB",
i[i.RB = 5] = "RB",
i[i.LT = 6] = "LT",
i[i.RT = 7] = "RT",
i[i.Back = 8] = "Back",
i[i.Start = 9] = "Start",
i[i.LS = 10] = "LS",
i[i.RS = 11] = "RS",
i[i.DPadUp = 12] = "DPadUp",
i[i.DPadDown = 13] = "DPadDown",
i[i.DPadLeft = 14] = "DPadLeft",
i[i.DPadRight = 15] = "DPadRight",
i[i.Home = 16] = "Home",
i[i.LStickXAxis = 17] = "LStickXAxis",
i[i.LStickYAxis = 18] = "LStickYAxis",
i[i.RStickXAxis = 19] = "RStickXAxis",
i[i.RStickYAxis = 20] = "RStickYAxis"
}
)(XboxInput || (XboxInput = {}));
var SwitchInput;
(function(i) {
i[i.B = 0] = "B",
i[i.A = 1] = "A",
i[i.Y = 2] = "Y",
i[i.X = 3] = "X",
i[i.L = 4] = "L",
i[i.R = 5] = "R",
i[i.ZL = 6] = "ZL",
i[i.ZR = 7] = "ZR",
i[i.Minus = 8] = "Minus",
i[i.Plus = 9] = "Plus",
i[i.LS = 10] = "LS",
i[i.RS = 11] = "RS",
i[i.DPadUp = 12] = "DPadUp",
i[i.DPadDown = 13] = "DPadDown",
i[i.DPadLeft = 14] = "DPadLeft",
i[i.DPadRight = 15] = "DPadRight",
i[i.Home = 16] = "Home",
i[i.Capture = 17] = "Capture",
i[i.LStickXAxis = 18] = "LStickXAxis",
i[i.LStickYAxis = 19] = "LStickYAxis",
i[i.RStickXAxis = 20] = "RStickXAxis",
i[i.RStickYAxis = 21] = "RStickYAxis"
}
)(SwitchInput || (SwitchInput = {}));
var DeviceInputEventType;
(function(i) {
i[i.PointerMove = 0] = "PointerMove",
i[i.PointerDown = 1] = "PointerDown",
i[i.PointerUp = 2] = "PointerUp"
}
)(DeviceInputEventType || (DeviceInputEventType = {}));
var EventConstants = function() {
function i() {}
return i.DOM_DELTA_PIXEL = 0,
i.DOM_DELTA_LINE = 1,
i.DOM_DELTA_PAGE = 2,
i
}()
, DeviceEventFactory = function() {
function i() {}
return i.CreateDeviceEvent = function(e, t, r, n, o, a) {
switch (e) {
case DeviceType.Keyboard:
return this._createKeyboardEvent(r, n, o, a);
case DeviceType.Mouse:
if (r === PointerInput.MouseWheelX || r === PointerInput.MouseWheelY || r === PointerInput.MouseWheelZ)
return this._createWheelEvent(e, t, r, n, o, a);
case DeviceType.Touch:
return this._createPointerEvent(e, t, r, n, o, a);
default:
throw "Unable to generate event for device " + DeviceType[e]
}
}
,
i._createPointerEvent = function(e, t, r, n, o, a) {
var s = this._createMouseEvent(e, t, r, n, o, a);
return s.pointerId = e === DeviceType.Mouse ? 1 : t,
r === PointerInput.Horizontal || r === PointerInput.Vertical || r === PointerInput.DeltaHorizontal || r === PointerInput.DeltaVertical ? s.type = "pointermove" : r >= PointerInput.LeftClick && r <= PointerInput.RightClick && (s.type = n === 1 ? "pointerdown" : "pointerup",
s.button = r - 2),
s
}
,
i._createWheelEvent = function(e, t, r, n, o, a) {
var s = this._createMouseEvent(e, t, r, n, o, a);
return s.type = "wheel",
s.deltaMode = EventConstants.DOM_DELTA_PIXEL,
s.deltaX = r === PointerInput.MouseWheelX ? n : o.pollInput(e, t, PointerInput.MouseWheelX),
s.deltaY = r === PointerInput.MouseWheelY ? n : o.pollInput(e, t, PointerInput.MouseWheelY),
s.deltaZ = r === PointerInput.MouseWheelZ ? n : o.pollInput(e, t, PointerInput.MouseWheelZ),
s
}
,
i._createMouseEvent = function(e, t, r, n, o, a) {
var s = this._createEvent(a)
, l = o.pollInput(e, t, PointerInput.Horizontal)
, u = o.pollInput(e, t, PointerInput.Vertical)
, c = r === PointerInput.DeltaHorizontal ? n : 0
, h = r === PointerInput.DeltaVertical ? n : 0
, f = r === PointerInput.DeltaHorizontal && a ? c - a.getBoundingClientRect().x : 0
, d = r === PointerInput.DeltaVertical && a ? h - a.getBoundingClientRect().y : 0;
return this._checkNonCharacterKeys(s, o),
s.clientX = l,
s.clientY = u,
s.movementX = c,
s.movementY = h,
s.offsetX = f,
s.offsetY = d,
s.x = l,
s.y = u,
s
}
,
i._createKeyboardEvent = function(e, t, r, n) {
var o = this._createEvent(n);
return this._checkNonCharacterKeys(o, r),
o.type = t === 1 ? "keydown" : "keyup",
o.key = String.fromCharCode(e),
o.keyCode = e,
o
}
,
i._checkNonCharacterKeys = function(e, t) {
var r = t.isDeviceAvailable(DeviceType.Keyboard)
, n = r && t.pollInput(DeviceType.Keyboard, 0, 18) === 1
, o = r && t.pollInput(DeviceType.Keyboard, 0, 17) === 1
, a = r && (t.pollInput(DeviceType.Keyboard, 0, 91) === 1 || t.pollInput(DeviceType.Keyboard, 0, 92) === 1 || t.pollInput(DeviceType.Keyboard, 0, 93) === 1)
, s = r && t.pollInput(DeviceType.Keyboard, 0, 16) === 1;
e.altKey = n,
e.ctrlKey = o,
e.metaKey = a,
e.shiftKey = s
}
,
i._createEvent = function(e) {
var t = {};
return t.preventDefault = function() {}
,
t.target = e,
t
}
,
i
}()
, NativeDeviceInputSystemImpl = function() {
function i(e) {
var t = this;
this.onDeviceConnected = function(r, n) {}
,
this.onDeviceDisconnected = function(r, n) {}
,
this.onInputChanged = function(r) {}
,
this._nativeInput = e || this._createDummyNativeInput(),
this._nativeInput.onDeviceConnected = function(r, n) {
t.onDeviceConnected(r, n)
}
,
this._nativeInput.onDeviceDisconnected = function(r, n) {
t.onDeviceDisconnected(r, n)
}
,
this._nativeInput.onInputChanged = function(r, n, o, a, s, l) {
var u = DeviceEventFactory.CreateDeviceEvent(r, n, o, s, t)
, c = u;
c.deviceType = r,
c.deviceSlot = n,
c.inputIndex = o,
c.previousState = a,
c.currentState = s,
t.onInputChanged(c)
}
}
return i.prototype.configureEvents = function() {}
,
i.prototype.pollInput = function(e, t, r) {
return this._nativeInput.pollInput(e, t, r)
}
,
i.prototype.isDeviceAvailable = function(e) {
return e === DeviceType.Mouse || e === DeviceType.Touch
}
,
i.prototype.dispose = function() {
this.onDeviceConnected = function() {}
,
this.onDeviceDisconnected = function() {}
,
this.onInputChanged = function() {}
}
,
i.prototype._createDummyNativeInput = function() {
var e = {
onDeviceConnected: function(t, r) {},
onDeviceDisconnected: function(t, r) {},
onInputChanged: function(t, r, n, o, a, s) {},
pollInput: function() {
return 0
},
isDeviceAvailable: function() {
return !1
},
dispose: function() {}
};
return e
}
,
i
}()
, WebDeviceInputSystemImpl = function() {
function i(e) {
this._inputs = [],
this._keyboardActive = !1,
this._pointerActive = !1,
this._usingSafari = Tools.IsSafari(),
this._keyboardDownEvent = function(t) {}
,
this._keyboardUpEvent = function(t) {}
,
this._keyboardBlurEvent = function(t) {}
,
this._pointerMoveEvent = function(t) {}
,
this._pointerDownEvent = function(t) {}
,
this._pointerUpEvent = function(t) {}
,
this._pointerWheelEvent = function(t) {}
,
this._pointerBlurEvent = function(t) {}
,
this._mouseId = -1,
this._isUsingFirefox = navigator && navigator.userAgent && navigator.userAgent.indexOf("Firefox") !== -1,
this._activeTouchIds = [],
this._rollingTouchId = 0,
this._pointerInputClearObserver = null,
this._gamepadConnectedEvent = function(t) {}
,
this._gamepadDisconnectedEvent = function(t) {}
,
this._eventPrefix = Tools.GetPointerPrefix(e),
this._engine = e,
this.onDeviceConnected = function(t, r) {}
,
this.onDeviceDisconnected = function(t, r) {}
,
this.onInputChanged = function(t) {}
,
this.configureEvents()
}
return Object.defineProperty(i.prototype, "onDeviceConnected", {
get: function() {
return this._onDeviceConnected
},
set: function(e) {
this._onDeviceConnected = e;
for (var t = 0; t < this._inputs.length; t++) {
var r = this._inputs[t];
if (r)
for (var n in r) {
var o = +n;
this._inputs[t][o] && this._onDeviceConnected(t, o)
}
}
},
enumerable: !1,
configurable: !0
}),
i.prototype.configureEvents = function() {
var e = this._engine.getInputElement();
e && this._elementToAttachTo !== e && (this._elementToAttachTo && this._removeEvents(),
this._elementToAttachTo = e,
this._elementToAttachTo.tabIndex = this._elementToAttachTo.tabIndex !== -1 ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex,
this._handleKeyActions(),
this._handlePointerActions(),
this._handleGamepadActions(),
this._checkForConnectedDevices())
}
,
i.prototype.pollInput = function(e, t, r) {
var n = this._inputs[e][t];
if (!n)
throw "Unable to find device " + DeviceType[e];
e >= DeviceType.Xbox && e <= DeviceType.Switch && navigator.getGamepads && this._updateDevice(e, t, r);
var o = n[r];
if (o === void 0)
throw "Unable to find input " + r + " for device " + DeviceType[e] + " in slot " + t;
return o
}
,
i.prototype.isDeviceAvailable = function(e) {
return this._inputs[e] !== void 0
}
,
i.prototype.dispose = function() {
this.onDeviceConnected = function() {}
,
this.onDeviceDisconnected = function() {}
,
this.onInputChanged = function() {}
,
this._elementToAttachTo && (this._removeEvents(),
window.removeEventListener("gamepadconnected", this._gamepadConnectedEvent),
window.removeEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent))
}
,
i.prototype._checkForConnectedDevices = function() {
if (navigator.getGamepads)
for (var e = navigator.getGamepads(), t = 0, r = e; t < r.length; t++) {
var n = r[t];
n && this._addGamePad(n)
}
matchMedia("(pointer:fine)").matches && this._addPointerDevice(DeviceType.Mouse, 0, 0, 0)
}
,
i.prototype._addGamePad = function(e) {
var t = this._getGamepadDeviceType(e.id)
, r = e.index;
this._registerDevice(t, r, e.buttons.length + e.axes.length),
this._gamepads = this._gamepads || new Array(e.index + 1),
this._gamepads[r] = t
}
,
i.prototype._addPointerDevice = function(e, t, r, n) {
this._pointerActive = !0,
this._registerDevice(e, t, i.MAX_POINTER_INPUTS);
var o = this._inputs[e][t];
o[0] = r,
o[1] = n
}
,
i.prototype._registerDevice = function(e, t, r) {
if (t === void 0)
throw "Unable to register device " + DeviceType[e] + " to undefined slot.";
if (this._inputs[e] || (this._inputs[e] = {}),
!this._inputs[e][t]) {
for (var n = new Array(r), o = 0; o < r; o++)
n[o] = 0;
this._inputs[e][t] = n,
this.onDeviceConnected(e, t)
}
}
,
i.prototype._unregisterDevice = function(e, t) {
this._inputs[e][t] && (delete this._inputs[e][t],
this.onDeviceDisconnected(e, t))
}
,
i.prototype._handleKeyActions = function() {
var e = this;
this._keyboardDownEvent = function(t) {
e._keyboardActive || (e._keyboardActive = !0,
e._registerDevice(DeviceType.Keyboard, 0, i.MAX_KEYCODES));
var r = e._inputs[DeviceType.Keyboard][0];
if (r) {
r[t.keyCode] = 1;
var n = t;
n.deviceType = DeviceType.Keyboard,
n.deviceSlot = 0,
n.inputIndex = t.keyCode,
n.previousState = 0,
n.currentState = r[t.keyCode],
e.onInputChanged(n)
}
}
,
this._keyboardUpEvent = function(t) {
e._keyboardActive || (e._keyboardActive = !0,
e._registerDevice(DeviceType.Keyboard, 0, i.MAX_KEYCODES));
var r = e._inputs[DeviceType.Keyboard][0];
if (r) {
r[t.keyCode] = 0;
var n = t;
n.deviceType = DeviceType.Keyboard,
n.deviceSlot = 0,
n.inputIndex = t.keyCode,
n.previousState = 1,
n.currentState = r[t.keyCode],
e.onInputChanged(n)
}
}
,
this._keyboardBlurEvent = function(t) {
if (e._keyboardActive) {
for (var r = e._inputs[DeviceType.Keyboard][0], n = 0; n < r.length; n++)
if (r[n] !== 0) {
r[n] = 0;
var o = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, n, 1, e, e._elementToAttachTo)
, a = o;
a.deviceType = DeviceType.Keyboard,
a.deviceSlot = 0,
a.inputIndex = n,
a.currentState = 0,
a.previousState = 1,
e.onInputChanged(a)
}
}
}
,
this._elementToAttachTo.addEventListener("keydown", this._keyboardDownEvent),
this._elementToAttachTo.addEventListener("keyup", this._keyboardUpEvent),
this._elementToAttachTo.addEventListener("blur", this._keyboardBlurEvent)
}
,
i.prototype._handlePointerActions = function() {
var e = this;
this._pointerMoveEvent = function(o) {
var a = e._getPointerType(o)
, s = a === DeviceType.Mouse ? 0 : e._activeTouchIds.indexOf(o.pointerId);
e._inputs[a] || (e._inputs[a] = {}),
e._inputs[a][s] || e._addPointerDevice(a, s, o.clientX, o.clientY);
var l = e._inputs[a][s];
if (l) {
var u = l[PointerInput.Horizontal]
, c = l[PointerInput.Vertical]
, h = l[PointerInput.DeltaHorizontal]
, f = l[PointerInput.DeltaVertical];
l[PointerInput.Horizontal] = o.clientX,
l[PointerInput.Vertical] = o.clientY,
l[PointerInput.DeltaHorizontal] = o.movementX,
l[PointerInput.DeltaVertical] = o.movementY;
var d = o;
d.deviceType = a,
d.deviceSlot = s,
u !== o.clientX && (d.inputIndex = PointerInput.Horizontal,
d.previousState = u,
d.currentState = l[PointerInput.Horizontal],
e.onInputChanged(d)),
c !== o.clientY && (d.inputIndex = PointerInput.Vertical,
d.previousState = c,
d.currentState = l[PointerInput.Vertical],
e.onInputChanged(d)),
l[PointerInput.DeltaHorizontal] !== 0 && (d.inputIndex = PointerInput.DeltaHorizontal,
d.previousState = h,
d.currentState = l[PointerInput.DeltaHorizontal],
e.onInputChanged(d)),
l[PointerInput.DeltaVertical] !== 0 && (d.inputIndex = PointerInput.DeltaVertical,
d.previousState = f,
d.currentState = l[PointerInput.DeltaVertical],
e.onInputChanged(d)),
!e._usingSafari && o.button !== -1 && (d.inputIndex = o.button + 2,
d.previousState = l[o.button + 2],
l[o.button + 2] = l[o.button + 2] ? 0 : 1,
d.currentState = l[o.button + 2],
e.onInputChanged(d))
}
}
,
this._pointerDownEvent = function(o) {
var a = e._getPointerType(o)
, s = a === DeviceType.Mouse ? 0 : o.pointerId;
a === DeviceType.Touch && (s = e._rollingTouchId++,
e._activeTouchIds[s] = o.pointerId),
e._inputs[a] || (e._inputs[a] = {}),
e._inputs[a][s] || e._addPointerDevice(a, s, o.clientX, o.clientY);
var l = e._inputs[a][s];
if (l) {
var u = l[PointerInput.Horizontal]
, c = l[PointerInput.Vertical]
, h = l[o.button + 2];
if (a === DeviceType.Mouse) {
if (e._mouseId === -1 && (o.pointerId === void 0 ? e._mouseId = e._isUsingFirefox ? 0 : 1 : e._mouseId = o.pointerId),
!document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
try {
e._elementToAttachTo.setPointerCapture(e._mouseId)
} catch {}
} else if (o.pointerId && !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
try {
e._elementToAttachTo.setPointerCapture(o.pointerId)
} catch {}
l[PointerInput.Horizontal] = o.clientX,
l[PointerInput.Vertical] = o.clientY,
l[o.button + 2] = 1;
var f = o;
f.deviceType = a,
f.deviceSlot = s,
u !== o.clientX && (f.inputIndex = PointerInput.Horizontal,
f.previousState = u,
f.currentState = l[PointerInput.Horizontal],
e.onInputChanged(f)),
c !== o.clientY && (f.inputIndex = PointerInput.Vertical,
f.previousState = c,
f.currentState = l[PointerInput.Vertical],
e.onInputChanged(f)),
f.inputIndex = o.button + 2,
f.previousState = h,
f.currentState = l[o.button + 2],
e.onInputChanged(f)
}
}
,
this._pointerUpEvent = function(o) {
var a, s, l, u, c, h = e._getPointerType(o), f = h === DeviceType.Mouse ? 0 : e._activeTouchIds.indexOf(o.pointerId), d = (a = e._inputs[h]) === null || a === void 0 ? void 0 : a[f];
if (d && d[o.button + 2] !== 0) {
var _ = d[PointerInput.Horizontal]
, g = d[PointerInput.Vertical]
, m = d[o.button + 2];
d[PointerInput.Horizontal] = o.clientX,
d[PointerInput.Vertical] = o.clientY,
d[o.button + 2] = 0;
var v = o;
if (v.deviceType = h,
v.deviceSlot = f,
_ !== o.clientX && (v.inputIndex = PointerInput.Horizontal,
v.previousState = _,
v.currentState = d[PointerInput.Horizontal],
e.onInputChanged(v)),
g !== o.clientY && (v.inputIndex = PointerInput.Vertical,
v.previousState = g,
v.currentState = d[PointerInput.Vertical],
e.onInputChanged(v)),
v.inputIndex = o.button + 2,
v.previousState = m,
v.currentState = d[o.button + 2],
h === DeviceType.Mouse && e._mouseId >= 0 && ((l = (s = e._elementToAttachTo).hasPointerCapture) === null || l === void 0 ? void 0 : l.call(s, e._mouseId)) ? e._elementToAttachTo.releasePointerCapture(e._mouseId) : o.pointerId && ((c = (u = e._elementToAttachTo).hasPointerCapture) === null || c === void 0 ? void 0 : c.call(u, o.pointerId)) && e._elementToAttachTo.releasePointerCapture(o.pointerId),
e.onInputChanged(v),
h !== DeviceType.Mouse) {
var y = e._activeTouchIds.indexOf(o.pointerId);
delete e._activeTouchIds[y],
e._unregisterDevice(h, f)
}
}
}
,
this._wheelEventName = "onwheel"in document.createElement("div") ? "wheel" : document.onmousewheel !== void 0 ? "mousewheel" : "DOMMouseScroll";
var t = !1
, r = function() {};
try {
var n = {
passive: {
get: function() {
t = !0
}
}
};
this._elementToAttachTo.addEventListener("test", r, n),
this._elementToAttachTo.removeEventListener("test", r, n)
} catch {}
this._pointerBlurEvent = function(o) {
var a, s, l, u, c;
if (e.isDeviceAvailable(DeviceType.Mouse)) {
var h = e._inputs[DeviceType.Mouse][0];
e._mouseId >= 0 && ((s = (a = e._elementToAttachTo).hasPointerCapture) === null || s === void 0 ? void 0 : s.call(a, e._mouseId)) && e._elementToAttachTo.releasePointerCapture(e._mouseId);
for (var f = 0; f <= PointerInput.BrowserForward; f++)
if (h[f + 2] === 1) {
h[f + 2] = 0;
var d = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, f + 2, 1, e, e._elementToAttachTo)
, _ = d;
_.deviceType = DeviceType.Mouse,
_.deviceSlot = 0,
_.inputIndex = f + 2,
_.currentState = h[f + 2],
_.previousState = 1,
e.onInputChanged(_)
}
}
if (e.isDeviceAvailable(DeviceType.Touch)) {
var h = e._inputs[DeviceType.Touch];
for (var g in Object.keys(e._activeTouchIds)) {
var m = +g
, v = e._activeTouchIds[m];
if (!((u = (l = e._elementToAttachTo).hasPointerCapture) === null || u === void 0) && u.call(l, v) && e._elementToAttachTo.releasePointerCapture(v),
((c = h[m]) === null || c === void 0 ? void 0 : c[PointerInput.LeftClick]) === 1) {
h[m][PointerInput.LeftClick] = 0;
var y = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, v, PointerInput.LeftClick, 1, e, e._elementToAttachTo)
, _ = y;
_.deviceType = DeviceType.Mouse,
_.deviceSlot = m,
_.inputIndex = PointerInput.LeftClick,
_.currentState = h[m][PointerInput.LeftClick],
_.previousState = 1,
e.onInputChanged(_),
e._unregisterDevice(DeviceType.Touch, m)
}
}
for (; e._activeTouchIds.pop() !== void 0; )
;
}
}
,
this._pointerWheelEvent = function(o) {
var a = DeviceType.Mouse
, s = 0;
e._inputs[a] || (e._inputs[a] = []),
e._inputs[a][s] || (e._pointerActive = !0,
e._registerDevice(a, s, i.MAX_POINTER_INPUTS));
var l = e._inputs[a][s];
if (l) {
var u = l[PointerInput.MouseWheelX]
, c = l[PointerInput.MouseWheelY]
, h = l[PointerInput.MouseWheelZ];
l[PointerInput.MouseWheelX] = o.deltaX || 0,
l[PointerInput.MouseWheelY] = o.deltaY || o.wheelDelta || 0,
l[PointerInput.MouseWheelZ] = o.deltaZ || 0;
var f = o;
f.deviceType = a,
f.deviceSlot = s,
l[PointerInput.MouseWheelX] !== 0 && (f.inputIndex = PointerInput.MouseWheelX,
f.previousState = u,
f.currentState = l[PointerInput.MouseWheelX],
e.onInputChanged(f)),
l[PointerInput.MouseWheelY] !== 0 && (f.inputIndex = PointerInput.MouseWheelY,
f.previousState = c,
f.currentState = l[PointerInput.MouseWheelY],
e.onInputChanged(f)),
l[PointerInput.MouseWheelZ] !== 0 && (f.inputIndex = PointerInput.MouseWheelZ,
f.previousState = h,
f.currentState = l[PointerInput.MouseWheelZ],
e.onInputChanged(f))
}
}
,
this._elementToAttachTo.addEventListener(this._eventPrefix + "move", this._pointerMoveEvent),
this._elementToAttachTo.addEventListener(this._eventPrefix + "down", this._pointerDownEvent),
this._elementToAttachTo.addEventListener(this._eventPrefix + "up", this._pointerUpEvent),
this._elementToAttachTo.addEventListener("blur", this._pointerBlurEvent),
this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, t ? {
passive: !1
} : !1),
this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(function() {
if (e.isDeviceAvailable(DeviceType.Mouse)) {
var o = e._inputs[DeviceType.Mouse][0];
o[PointerInput.MouseWheelX] = 0,
o[PointerInput.MouseWheelY] = 0,
o[PointerInput.MouseWheelZ] = 0,
o[PointerInput.DeltaHorizontal] = 0,
o[PointerInput.DeltaVertical] = 0
}
})
}
,
i.prototype._handleGamepadActions = function() {
var e = this;
this._gamepadConnectedEvent = function(t) {
e._addGamePad(t.gamepad)
}
,
this._gamepadDisconnectedEvent = function(t) {
if (e._gamepads) {
var r = e._getGamepadDeviceType(t.gamepad.id)
, n = t.gamepad.index;
e._unregisterDevice(r, n),
delete e._gamepads[n]
}
}
,
window.addEventListener("gamepadconnected", this._gamepadConnectedEvent),
window.addEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)
}
,
i.prototype._updateDevice = function(e, t, r) {
var n = navigator.getGamepads()[t];
if (n && e === this._gamepads[t]) {
var o = this._inputs[e][t];
r >= n.buttons.length ? o[r] = n.axes[r - n.buttons.length].valueOf() : o[r] = n.buttons[r].value
}
}
,
i.prototype._getGamepadDeviceType = function(e) {
return e.indexOf("054c") !== -1 && e.indexOf("0ce6") === -1 ? DeviceType.DualShock : e.indexOf("Xbox One") !== -1 || e.search("Xbox 360") !== -1 || e.search("xinput") !== -1 ? DeviceType.Xbox : e.indexOf("057e") !== -1 ? DeviceType.Switch : DeviceType.Generic
}
,
i.prototype._getPointerType = function(e) {
var t = DeviceType.Mouse;
return (e.pointerType === "touch" || e.pointerType === "pen" || e.touches) && (t = DeviceType.Touch),
t
}
,
i.prototype._removeEvents = function() {
this._elementToAttachTo.removeEventListener("blur", this._keyboardBlurEvent),
this._elementToAttachTo.removeEventListener("blur", this._pointerBlurEvent),
this._keyboardActive && (this._elementToAttachTo.removeEventListener("keydown", this._keyboardDownEvent),
this._elementToAttachTo.removeEventListener("keyup", this._keyboardUpEvent)),
this._pointerActive && (this._elementToAttachTo.removeEventListener(this._eventPrefix + "move", this._pointerMoveEvent),
this._elementToAttachTo.removeEventListener(this._eventPrefix + "down", this._pointerDownEvent),
this._elementToAttachTo.removeEventListener(this._eventPrefix + "up", this._pointerUpEvent),
this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent),
this._pointerInputClearObserver && this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver))
}
,
i.MAX_KEYCODES = 255,
i.MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2,
i
}()
, DeviceInputSystem = function() {
function i(e) {
var t = this;
this._deviceInputSystem = e,
this.onDeviceConnectedObservable = new Observable,
this.onDeviceDisconnectedObservable = new Observable,
this.onInputChangedObservable = new Observable,
this._deviceInputSystem.onDeviceConnected = function(r, n) {
t.onDeviceConnectedObservable.notifyObservers({
deviceType: r,
deviceSlot: n
})
}
,
this._deviceInputSystem.onDeviceDisconnected = function(r, n) {
t.onDeviceDisconnectedObservable.notifyObservers({
deviceType: r,
deviceSlot: n
})
}
,
this._deviceInputSystem.onInputChanged = function(r) {
t.onInputChangedObservable.notifyObservers(r)
}
}
return i._Create = function(e) {
if (!e.deviceInputSystem) {
var t = void 0;
typeof _native != "undefined" ? t = _native.DeviceInputSystem ? new NativeDeviceInputSystemImpl(new _native.DeviceInputSystem) : new NativeDeviceInputSystemImpl : t = new WebDeviceInputSystemImpl(e),
t && (e.deviceInputSystem = new i(t))
}
return e.deviceInputSystem
}
,
i.prototype.configureEvents = function() {
this._deviceInputSystem.configureEvents()
}
,
i.prototype.pollInput = function(e, t, r) {
return this._deviceInputSystem.pollInput(e, t, r)
}
,
i.prototype.isDeviceAvailable = function(e) {
return this._deviceInputSystem.isDeviceAvailable(e)
}
,
i.prototype.dispose = function() {
this.onDeviceConnectedObservable.clear(),
this.onDeviceDisconnectedObservable.clear(),
this.onInputChangedObservable.clear(),
this._deviceInputSystem.dispose()
}
,
i
}()
, _ClickInfo = function() {
function i() {
this._singleClick = !1,
this._doubleClick = !1,
this._hasSwiped = !1,
this._ignore = !1
}
return Object.defineProperty(i.prototype, "singleClick", {
get: function() {
return this._singleClick
},
set: function(e) {
this._singleClick = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "doubleClick", {
get: function() {
return this._doubleClick
},
set: function(e) {
this._doubleClick = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "hasSwiped", {
get: function() {
return this._hasSwiped
},
set: function(e) {
this._hasSwiped = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "ignore", {
get: function() {
return this._ignore
},
set: function(e) {
this._ignore = e
},
enumerable: !1,
configurable: !0
}),
i
}()
, InputManager = function() {
function i(e) {
this._alreadyAttached = !1,
this._meshPickProceed = !1,
this._currentPickResult = null,
this._previousPickResult = null,
this._totalPointersPressed = 0,
this._doubleClickOccured = !1,
this._pointerX = 0,
this._pointerY = 0,
this._startingPointerPosition = new Vector2(0,0),
this._previousStartingPointerPosition = new Vector2(0,0),
this._startingPointerTime = 0,
this._previousStartingPointerTime = 0,
this._pointerCaptures = {},
this._meshUnderPointerId = {},
this._scene = e
}
return Object.defineProperty(i.prototype, "meshUnderPointer", {
get: function() {
return this._pointerOverMesh
},
enumerable: !1,
configurable: !0
}),
i.prototype.getMeshUnderPointerByPointerId = function(e) {
return this._meshUnderPointerId[e] || null
}
,
Object.defineProperty(i.prototype, "unTranslatedPointer", {
get: function() {
return new Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "pointerX", {
get: function() {
return this._pointerX
},
set: function(e) {
this._pointerX = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "pointerY", {
get: function() {
return this._pointerY
},
set: function(e) {
this._pointerY = e
},
enumerable: !1,
configurable: !0
}),
i.prototype._updatePointerPosition = function(e) {
var t = this._scene.getEngine().getInputElementClientRect();
!t || (this._pointerX = e.clientX - t.left,
this._pointerY = e.clientY - t.top,
this._unTranslatedPointerX = this._pointerX,
this._unTranslatedPointerY = this._pointerY)
}
,
i.prototype._processPointerMove = function(e, t) {
var r = this._scene
, n = r.getEngine()
, o = n.getInputElement();
o && (o.tabIndex = n.canvasTabIndex,
r.doNotHandleCursors || (o.style.cursor = r.defaultCursor));
var a = !!(e && e.hit && e.pickedMesh);
a ? (r.setPointerOverMesh(e.pickedMesh, t.pointerId, e),
this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers && !r.doNotHandleCursors && o && (this._pointerOverMesh.actionManager.hoverCursor ? o.style.cursor = this._pointerOverMesh.actionManager.hoverCursor : o.style.cursor = r.hoverCursor)) : r.setPointerOverMesh(null, t.pointerId, e);
for (var s = 0, l = r._pointerMoveStage; s < l.length; s++) {
var u = l[s];
e = u.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, a, o)
}
if (e) {
var c = t.type === "wheel" || t.type === "mousewheel" || t.type === "DOMMouseScroll" ? PointerEventTypes.POINTERWHEEL : PointerEventTypes.POINTERMOVE;
if (r.onPointerMove && r.onPointerMove(t, e, c),
r.onPointerObservable.hasObservers()) {
var h = new PointerInfo(c,t,e);
this._setRayOnPointerInfo(h),
r.onPointerObservable.notifyObservers(h, c)
}
}
}
,
i.prototype._setRayOnPointerInfo = function(e) {
var t = this._scene;
e.pickInfo && !e.pickInfo._pickingUnavailable && (e.pickInfo.ray || (e.pickInfo.ray = t.createPickingRay(e.event.offsetX, e.event.offsetY, Matrix.Identity(), t.activeCamera)))
}
,
i.prototype._checkPrePointerObservable = function(e, t, r) {
var n = this._scene
, o = new PointerInfoPre(r,t,this._unTranslatedPointerX,this._unTranslatedPointerY);
return e && (o.ray = e.ray,
e.originMesh && (o.nearInteractionPickingInfo = e)),
n.onPrePointerObservable.notifyObservers(o, r),
!!o.skipOnPointerObservable
}
,
i.prototype.simulatePointerMove = function(e, t) {
var r = new PointerEvent("pointermove",t);
this._checkPrePointerObservable(e, r, PointerEventTypes.POINTERMOVE) || this._processPointerMove(e, r)
}
,
i.prototype.simulatePointerDown = function(e, t) {
var r = new PointerEvent("pointerdown",t);
this._checkPrePointerObservable(e, r, PointerEventTypes.POINTERDOWN) || this._processPointerDown(e, r)
}
,
i.prototype._processPointerDown = function(e, t) {
var r = this
, n = this._scene;
if (e && e.hit && e.pickedMesh) {
this._pickedDownMesh = e.pickedMesh;
var o = e.pickedMesh._getActionManagerForTrigger();
if (o) {
if (o.hasPickTriggers)
switch (o.processTrigger(5, ActionEvent.CreateNew(e.pickedMesh, t)),
t.button) {
case 0:
o.processTrigger(2, ActionEvent.CreateNew(e.pickedMesh, t));
break;
case 1:
o.processTrigger(4, ActionEvent.CreateNew(e.pickedMesh, t));
break;
case 2:
o.processTrigger(3, ActionEvent.CreateNew(e.pickedMesh, t));
break
}
o.hasSpecificTrigger(8) && window.setTimeout(function() {
var h = n.pick(r._unTranslatedPointerX, r._unTranslatedPointerY, function(f) {
return f.isPickable && f.isVisible && f.isReady() && f.actionManager && f.actionManager.hasSpecificTrigger(8) && f === r._pickedDownMesh
}, !1, n.cameraToUseForPointers);
h && h.hit && h.pickedMesh && o && r._totalPointersPressed !== 0 && Date.now() - r._startingPointerTime > i.LongPressDelay && !r._isPointerSwiping() && (r._startingPointerTime = 0,
o.processTrigger(8, ActionEvent.CreateNew(h.pickedMesh, t)))
}, i.LongPressDelay)
}
} else
for (var a = 0, s = n._pointerDownStage; a < s.length; a++) {
var l = s[a];
e = l.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, t)
}
if (e) {
var u = PointerEventTypes.POINTERDOWN;
if (n.onPointerDown && n.onPointerDown(t, e, u),
n.onPointerObservable.hasObservers()) {
var c = new PointerInfo(u,t,e);
this._setRayOnPointerInfo(c),
n.onPointerObservable.notifyObservers(c, u)
}
}
}
,
i.prototype._isPointerSwiping = function() {
return Math.abs(this._startingPointerPosition.x - this._pointerX) > i.DragMovementThreshold || Math.abs(this._startingPointerPosition.y - this._pointerY) > i.DragMovementThreshold
}
,
i.prototype.simulatePointerUp = function(e, t, r) {
var n = new PointerEvent("pointerup",t)
, o = new _ClickInfo;
r ? o.doubleClick = !0 : o.singleClick = !0,
!this._checkPrePointerObservable(e, n, PointerEventTypes.POINTERUP) && this._processPointerUp(e, n, o)
}
,
i.prototype._processPointerUp = function(e, t, r) {
var n = this._scene;
if (e && e && e.pickedMesh) {
if (this._pickedUpMesh = e.pickedMesh,
this._pickedDownMesh === this._pickedUpMesh && (n.onPointerPick && n.onPointerPick(t, e),
r.singleClick && !r.ignore && n.onPointerObservable.hasObservers())) {
var o = PointerEventTypes.POINTERPICK
, a = new PointerInfo(o,t,e);
this._setRayOnPointerInfo(a),
n.onPointerObservable.notifyObservers(a, o)
}
var s = e.pickedMesh._getActionManagerForTrigger();
if (s && !r.ignore) {
s.processTrigger(7, ActionEvent.CreateNew(e.pickedMesh, t, e)),
!r.hasSwiped && r.singleClick && s.processTrigger(1, ActionEvent.CreateNew(e.pickedMesh, t, e));
var l = e.pickedMesh._getActionManagerForTrigger(6);
r.doubleClick && l && l.processTrigger(6, ActionEvent.CreateNew(e.pickedMesh, t, e))
}
} else if (!r.ignore)
for (var u = 0, c = n._pointerUpStage; u < c.length; u++) {
var h = c[u];
e = h.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, t)
}
if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
var f = this._pickedDownMesh._getActionManagerForTrigger(16);
f && f.processTrigger(16, ActionEvent.CreateNew(this._pickedDownMesh, t))
}
var d = 0;
if (n.onPointerObservable.hasObservers()) {
if (!r.ignore && !r.hasSwiped && (r.singleClick && n.onPointerObservable.hasSpecificMask(PointerEventTypes.POINTERTAP) ? d = PointerEventTypes.POINTERTAP : r.doubleClick && n.onPointerObservable.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) && (d = PointerEventTypes.POINTERDOUBLETAP),
d)) {
var a = new PointerInfo(d,t,e);
this._setRayOnPointerInfo(a),
n.onPointerObservable.notifyObservers(a, d)
}
if (!r.ignore) {
d = PointerEventTypes.POINTERUP;
var a = new PointerInfo(d,t,e);
this._setRayOnPointerInfo(a),
n.onPointerObservable.notifyObservers(a, d)
}
}
n.onPointerUp && !r.ignore && n.onPointerUp(t, e, d)
}
,
i.prototype.isPointerCaptured = function(e) {
return e === void 0 && (e = 0),
this._pointerCaptures[e]
}
,
i.prototype.attachControl = function(e, t, r, n) {
var o = this;
e === void 0 && (e = !0),
t === void 0 && (t = !0),
r === void 0 && (r = !0),
n === void 0 && (n = null);
var a = this._scene
, s = a.getEngine();
n || (n = s.getInputElement()),
this._alreadyAttached && this.detachControl(),
n && (this._alreadyAttachedTo = n),
this._deviceInputSystem ? this._deviceInputSystem.configureEvents() : this._deviceInputSystem = DeviceInputSystem._Create(s),
this._initActionManager = function(l, u) {
if (!o._meshPickProceed) {
var c = a.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, a.pointerDownPredicate, !1, a.cameraToUseForPointers);
o._currentPickResult = c,
c && (l = c.hit && c.pickedMesh ? c.pickedMesh._getActionManagerForTrigger() : null),
o._meshPickProceed = !0
}
return l
}
,
this._delayedSimpleClick = function(l, u, c) {
(Date.now() - o._previousStartingPointerTime > i.DoubleClickDelay && !o._doubleClickOccured || l !== o._previousButtonPressed) && (o._doubleClickOccured = !1,
u.singleClick = !0,
u.ignore = !1,
c(u, o._currentPickResult))
}
,
this._initClickEvent = function(l, u, c, h) {
var f = new _ClickInfo;
o._currentPickResult = null;
var d = null
, _ = l.hasSpecificMask(PointerEventTypes.POINTERPICK) || u.hasSpecificMask(PointerEventTypes.POINTERPICK) || l.hasSpecificMask(PointerEventTypes.POINTERTAP) || u.hasSpecificMask(PointerEventTypes.POINTERTAP) || l.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) || u.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP);
!_ && AbstractActionManager && (d = o._initActionManager(d, f),
d && (_ = d.hasPickTriggers));
var g = !1;
if (_) {
var m = c.button;
if (f.hasSwiped = o._isPointerSwiping(),
!f.hasSwiped) {
var v = !i.ExclusiveDoubleClickMode;
v || (v = !l.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) && !u.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP),
v && !AbstractActionManager.HasSpecificTrigger(6) && (d = o._initActionManager(d, f),
d && (v = !d.hasSpecificTrigger(6)))),
v ? (Date.now() - o._previousStartingPointerTime > i.DoubleClickDelay || m !== o._previousButtonPressed) && (f.singleClick = !0,
h(f, o._currentPickResult),
g = !0) : (o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
o._delayedSimpleClickTimeout = window.setTimeout(o._delayedSimpleClick.bind(o, m, f, h), i.DoubleClickDelay));
var y = l.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) || u.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP);
!y && AbstractActionManager.HasSpecificTrigger(6) && (d = o._initActionManager(d, f),
d && (y = d.hasSpecificTrigger(6))),
y && (m === o._previousButtonPressed && Date.now() - o._previousStartingPointerTime < i.DoubleClickDelay && !o._doubleClickOccured ? (!f.hasSwiped && !o._isPointerSwiping() ? (o._previousStartingPointerTime = 0,
o._doubleClickOccured = !0,
f.doubleClick = !0,
f.ignore = !1,
i.ExclusiveDoubleClickMode && o._previousDelayedSimpleClickTimeout && clearTimeout(o._previousDelayedSimpleClickTimeout),
o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
h(f, o._currentPickResult)) : (o._doubleClickOccured = !1,
o._previousStartingPointerTime = o._startingPointerTime,
o._previousStartingPointerPosition.x = o._startingPointerPosition.x,
o._previousStartingPointerPosition.y = o._startingPointerPosition.y,
o._previousButtonPressed = m,
i.ExclusiveDoubleClickMode ? (o._previousDelayedSimpleClickTimeout && clearTimeout(o._previousDelayedSimpleClickTimeout),
o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
h(f, o._previousPickResult)) : h(f, o._currentPickResult)),
g = !0) : (o._doubleClickOccured = !1,
o._previousStartingPointerTime = o._startingPointerTime,
o._previousStartingPointerPosition.x = o._startingPointerPosition.x,
o._previousStartingPointerPosition.y = o._startingPointerPosition.y,
o._previousButtonPressed = m))
}
}
g || h(f, o._currentPickResult)
}
,
this._onPointerMove = function(l) {
if (l.pointerId === void 0 && (l.pointerId = 0),
o._updatePointerPosition(l),
!o._checkPrePointerObservable(null, l, l.type === "wheel" || l.type === "mousewheel" || l.type === "DOMMouseScroll" ? PointerEventTypes.POINTERWHEEL : PointerEventTypes.POINTERMOVE) && !(!a.cameraToUseForPointers && !a.activeCamera)) {
if (a.skipPointerMovePicking) {
o._processPointerMove(new PickingInfo, l);
return
}
a.pointerMovePredicate || (a.pointerMovePredicate = function(c) {
return c.isPickable && c.isVisible && c.isReady() && c.isEnabled() && (c.enablePointerMoveEvents || a.constantlyUpdateMeshUnderPointer || c._getActionManagerForTrigger() !== null) && (!a.cameraToUseForPointers || (a.cameraToUseForPointers.layerMask & c.layerMask) !== 0)
}
);
var u = a.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, a.pointerMovePredicate, !1, a.cameraToUseForPointers, a.pointerMoveTrianglePredicate);
o._processPointerMove(u, l)
}
}
,
this._onPointerDown = function(l) {
if (o._totalPointersPressed++,
o._pickedDownMesh = null,
o._meshPickProceed = !1,
l.pointerId === void 0 && (l.pointerId = 0),
o._updatePointerPosition(l),
a.preventDefaultOnPointerDown && n && (l.preventDefault(),
n.focus()),
o._startingPointerPosition.x = o._pointerX,
o._startingPointerPosition.y = o._pointerY,
o._startingPointerTime = Date.now(),
!o._checkPrePointerObservable(null, l, PointerEventTypes.POINTERDOWN) && !(!a.cameraToUseForPointers && !a.activeCamera)) {
o._pointerCaptures[l.pointerId] = !0,
a.pointerDownPredicate || (a.pointerDownPredicate = function(c) {
return c.isPickable && c.isVisible && c.isReady() && c.isEnabled() && (!a.cameraToUseForPointers || (a.cameraToUseForPointers.layerMask & c.layerMask) !== 0)
}
),
o._pickedDownMesh = null;
var u = a.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, a.pointerDownPredicate, !1, a.cameraToUseForPointers);
o._processPointerDown(u, l)
}
}
,
this._onPointerUp = function(l) {
o._totalPointersPressed !== 0 && (o._totalPointersPressed--,
o._pickedUpMesh = null,
o._meshPickProceed = !1,
l.pointerId === void 0 && (l.pointerId = 0),
o._updatePointerPosition(l),
a.preventDefaultOnPointerUp && n && (l.preventDefault(),
n.focus()),
o._initClickEvent(a.onPrePointerObservable, a.onPointerObservable, l, function(u, c) {
a.onPrePointerObservable.hasObservers() && !u.ignore && (!u.hasSwiped && (u.singleClick && a.onPrePointerObservable.hasSpecificMask(PointerEventTypes.POINTERTAP) && o._checkPrePointerObservable(null, l, PointerEventTypes.POINTERTAP) || u.doubleClick && a.onPrePointerObservable.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) && o._checkPrePointerObservable(null, l, PointerEventTypes.POINTERDOUBLETAP)) || o._checkPrePointerObservable(null, l, PointerEventTypes.POINTERUP)) || !o._pointerCaptures[l.pointerId] && l.buttons > 0 || (o._pointerCaptures[l.pointerId] = !1,
!(!a.cameraToUseForPointers && !a.activeCamera) && (a.pointerUpPredicate || (a.pointerUpPredicate = function(h) {
return h.isPickable && h.isVisible && h.isReady() && h.isEnabled() && (!a.cameraToUseForPointers || (a.cameraToUseForPointers.layerMask & h.layerMask) !== 0)
}
),
!o._meshPickProceed && (AbstractActionManager && AbstractActionManager.HasTriggers || a.onPointerObservable.hasObservers()) && o._initActionManager(null, u),
c || (c = o._currentPickResult),
o._processPointerUp(c, l, u),
o._previousPickResult = o._currentPickResult))
}))
}
,
this._onKeyDown = function(l) {
var u = KeyboardEventTypes.KEYDOWN;
if (a.onPreKeyboardObservable.hasObservers()) {
var c = new KeyboardInfoPre(u,l);
if (a.onPreKeyboardObservable.notifyObservers(c, u),
c.skipOnPointerObservable)
return
}
if (a.onKeyboardObservable.hasObservers()) {
var c = new KeyboardInfo(u,l);
a.onKeyboardObservable.notifyObservers(c, u)
}
a.actionManager && a.actionManager.processTrigger(14, ActionEvent.CreateNewFromScene(a, l))
}
,
this._onKeyUp = function(l) {
var u = KeyboardEventTypes.KEYUP;
if (a.onPreKeyboardObservable.hasObservers()) {
var c = new KeyboardInfoPre(u,l);
if (a.onPreKeyboardObservable.notifyObservers(c, u),
c.skipOnPointerObservable)
return
}
if (a.onKeyboardObservable.hasObservers()) {
var c = new KeyboardInfo(u,l);
a.onKeyboardObservable.notifyObservers(c, u)
}
a.actionManager && a.actionManager.processTrigger(15, ActionEvent.CreateNewFromScene(a, l))
}
,
this._onInputObserver = this._deviceInputSystem.onInputChangedObservable.add(function(l) {
var u = l;
l.deviceType === DeviceType.Keyboard && (l.currentState === 1 && o._onKeyDown(u),
l.currentState === 0 && o._onKeyUp(u)),
(l.deviceType === DeviceType.Mouse || l.deviceType === DeviceType.Touch) && (t && l.inputIndex >= PointerInput.LeftClick && l.inputIndex <= PointerInput.RightClick && l.currentState === 1 && o._onPointerDown(u),
e && l.inputIndex >= PointerInput.LeftClick && l.inputIndex <= PointerInput.RightClick && l.currentState === 0 && o._onPointerUp(u),
r && (l.inputIndex === PointerInput.Horizontal || l.inputIndex === PointerInput.Vertical || l.inputIndex === PointerInput.DeltaHorizontal || l.inputIndex === PointerInput.DeltaVertical || l.inputIndex === PointerInput.MouseWheelX || l.inputIndex === PointerInput.MouseWheelY || l.inputIndex === PointerInput.MouseWheelZ) && o._onPointerMove(u))
}),
this._alreadyAttached = !0
}
,
i.prototype.detachControl = function() {
this._alreadyAttached && (this._deviceInputSystem.onInputChangedObservable.remove(this._onInputObserver),
this._alreadyAttachedTo && !this._scene.doNotHandleCursors && (this._alreadyAttachedTo.style.cursor = this._scene.defaultCursor),
this._alreadyAttached = !1)
}
,
i.prototype.setPointerOverMesh = function(e, t, r) {
if (t === void 0 && (t = 0),
this._meshUnderPointerId[t] !== e) {
var n = this._meshUnderPointerId[t], o;
n && (o = n._getActionManagerForTrigger(10),
o && o.processTrigger(10, ActionEvent.CreateNew(n, void 0, {
pointerId: t
}))),
e ? (this._meshUnderPointerId[t] = e,
this._pointerOverMesh = e,
o = e._getActionManagerForTrigger(9),
o && o.processTrigger(9, ActionEvent.CreateNew(e, void 0, {
pointerId: t,
pickResult: r
}))) : (delete this._meshUnderPointerId[t],
this._pointerOverMesh = null)
}
}
,
i.prototype.getPointerOverMesh = function() {
return this._pointerOverMesh
}
,
i.prototype._invalidateMesh = function(e) {
this._pointerOverMesh === e && (this._pointerOverMesh = null),
this._pickedDownMesh === e && (this._pickedDownMesh = null),
this._pickedUpMesh === e && (this._pickedUpMesh = null);
for (var t in this._meshUnderPointerId)
this._meshUnderPointerId[t] === e && delete this._meshUnderPointerId[t]
}
,
i.DragMovementThreshold = 10,
i.LongPressDelay = 500,
i.DoubleClickDelay = 300,
i.ExclusiveDoubleClickMode = !1,
i
}()
, PerfCounter = function() {
function i() {
this._startMonitoringTime = 0,
this._min = 0,
this._max = 0,
this._average = 0,
this._lastSecAverage = 0,
this._current = 0,
this._totalValueCount = 0,
this._totalAccumulated = 0,
this._lastSecAccumulated = 0,
this._lastSecTime = 0,
this._lastSecValueCount = 0
}
return Object.defineProperty(i.prototype, "min", {
get: function() {
return this._min
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "max", {
get: function() {
return this._max
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "average", {
get: function() {
return this._average
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "lastSecAverage", {
get: function() {
return this._lastSecAverage
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "current", {
get: function() {
return this._current
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "total", {
get: function() {
return this._totalAccumulated
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "count", {
get: function() {
return this._totalValueCount
},
enumerable: !1,
configurable: !0
}),
i.prototype.fetchNewFrame = function() {
this._totalValueCount++,
this._current = 0,
this._lastSecValueCount++
}
,
i.prototype.addCount = function(e, t) {
!i.Enabled || (this._current += e,
t && this._fetchResult())
}
,
i.prototype.beginMonitoring = function() {
!i.Enabled || (this._startMonitoringTime = PrecisionDate.Now)
}
,
i.prototype.endMonitoring = function(e) {
if (e === void 0 && (e = !0),
!!i.Enabled) {
e && this.fetchNewFrame();
var t = PrecisionDate.Now;
this._current = t - this._startMonitoringTime,
e && this._fetchResult()
}
}
,
i.prototype._fetchResult = function() {
this._totalAccumulated += this._current,
this._lastSecAccumulated += this._current,
this._min = Math.min(this._min, this._current),
this._max = Math.max(this._max, this._current),
this._average = this._totalAccumulated / this._totalValueCount;
var e = PrecisionDate.Now;
e - this._lastSecTime > 1e3 && (this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount,
this._lastSecTime = e,
this._lastSecAccumulated = 0,
this._lastSecValueCount = 0)
}
,
i.Enabled = !0,
i
}()
, Plane = function() {
function i(e, t, r, n) {
this.normal = new Vector3(e,t,r),
this.d = n
}
return i.prototype.asArray = function() {
return [this.normal.x, this.normal.y, this.normal.z, this.d]
}
,
i.prototype.clone = function() {
return new i(this.normal.x,this.normal.y,this.normal.z,this.d)
}
,
i.prototype.getClassName = function() {
return "Plane"
}
,
i.prototype.getHashCode = function() {
var e = this.normal.getHashCode();
return e = e * 397 ^ (this.d | 0),
e
}
,
i.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 e !== 0 && (t = 1 / e),
this.normal.x *= t,
this.normal.y *= t,
this.normal.z *= t,
this.d *= t,
this
}
,
i.prototype.transform = function(e) {
var t = i._TmpMatrix;
e.invertToRef(t);
var r = t.m
, n = this.normal.x
, o = this.normal.y
, a = this.normal.z
, s = this.d
, l = n * r[0] + o * r[1] + a * r[2] + s * r[3]
, u = n * r[4] + o * r[5] + a * r[6] + s * r[7]
, c = n * r[8] + o * r[9] + a * r[10] + s * r[11]
, h = n * r[12] + o * r[13] + a * r[14] + s * r[15];
return new i(l,u,c,h)
}
,
i.prototype.dotCoordinate = function(e) {
return this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z + this.d
}
,
i.prototype.copyFromPoints = function(e, t, r) {
var n = t.x - e.x, o = t.y - e.y, a = t.z - e.z, s = r.x - e.x, l = r.y - e.y, u = r.z - e.z, c = o * u - a * l, h = a * s - n * u, f = n * l - o * s, d = Math.sqrt(c * c + h * h + f * f), _;
return d !== 0 ? _ = 1 / d : _ = 0,
this.normal.x = c * _,
this.normal.y = h * _,
this.normal.z = f * _,
this.d = -(this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z),
this
}
,
i.prototype.isFrontFacingTo = function(e, t) {
var r = Vector3.Dot(this.normal, e);
return r <= t
}
,
i.prototype.signedDistanceTo = function(e) {
return Vector3.Dot(e, this.normal) + this.d
}
,
i.FromArray = function(e) {
return new i(e[0],e[1],e[2],e[3])
}
,
i.FromPoints = function(e, t, r) {
var n = new i(0,0,0,0);
return n.copyFromPoints(e, t, r),
n
}
,
i.FromPositionAndNormal = function(e, t) {
var r = new i(0,0,0,0);
return t.normalize(),
r.normal = t,
r.d = -(t.x * e.x + t.y * e.y + t.z * e.z),
r
}
,
i.SignedDistanceToPlaneFromPositionAndNormal = function(e, t, r) {
var n = -(t.x * e.x + t.y * e.y + t.z * e.z);
return Vector3.Dot(r, t) + n
}
,
i._TmpMatrix = Matrix.Identity(),
i
}()
, Frustum = function() {
function i() {}
return i.GetPlanes = function(e) {
for (var t = [], r = 0; r < 6; r++)
t.push(new Plane(0,0,0,0));
return i.GetPlanesToRef(e, t),
t
}
,
i.GetNearPlaneToRef = function(e, t) {
var r = e.m;
t.normal.x = r[3] + r[2],
t.normal.y = r[7] + r[6],
t.normal.z = r[11] + r[10],
t.d = r[15] + r[14],
t.normalize()
}
,
i.GetFarPlaneToRef = function(e, t) {
var r = e.m;
t.normal.x = r[3] - r[2],
t.normal.y = r[7] - r[6],
t.normal.z = r[11] - r[10],
t.d = r[15] - r[14],
t.normalize()
}
,
i.GetLeftPlaneToRef = function(e, t) {
var r = e.m;
t.normal.x = r[3] + r[0],
t.normal.y = r[7] + r[4],
t.normal.z = r[11] + r[8],
t.d = r[15] + r[12],
t.normalize()
}
,
i.GetRightPlaneToRef = function(e, t) {
var r = e.m;
t.normal.x = r[3] - r[0],
t.normal.y = r[7] - r[4],
t.normal.z = r[11] - r[8],
t.d = r[15] - r[12],
t.normalize()
}
,
i.GetTopPlaneToRef = function(e, t) {
var r = e.m;
t.normal.x = r[3] - r[1],
t.normal.y = r[7] - r[5],
t.normal.z = r[11] - r[9],
t.d = r[15] - r[13],
t.normalize()
}
,
i.GetBottomPlaneToRef = function(e, t) {
var r = e.m;
t.normal.x = r[3] + r[1],
t.normal.y = r[7] + r[5],
t.normal.z = r[11] + r[9],
t.d = r[15] + r[13],
t.normalize()
}
,
i.GetPlanesToRef = function(e, t) {
i.GetNearPlaneToRef(e, t[0]),
i.GetFarPlaneToRef(e, t[1]),
i.GetLeftPlaneToRef(e, t[2]),
i.GetRightPlaneToRef(e, t[3]),
i.GetTopPlaneToRef(e, t[4]),
i.GetBottomPlaneToRef(e, t[5])
}
,
i
}()
, UniqueIdGenerator = function() {
function i() {}
return Object.defineProperty(i, "UniqueId", {
get: function() {
var e = this._UniqueIdCounter;
return this._UniqueIdCounter++,
e
},
enumerable: !1,
configurable: !0
}),
i._UniqueIdCounter = 0,
i
}()
, LightConstants = function() {
function i() {}
return i.CompareLightsPriority = function(e, t) {
return e.shadowEnabled !== t.shadowEnabled ? (t.shadowEnabled ? 1 : 0) - (e.shadowEnabled ? 1 : 0) : t.renderPriority - e.renderPriority
}
,
i.FALLOFF_DEFAULT = 0,
i.FALLOFF_PHYSICAL = 1,
i.FALLOFF_GLTF = 2,
i.FALLOFF_STANDARD = 3,
i.LIGHTMAP_DEFAULT = 0,
i.LIGHTMAP_SPECULAR = 1,
i.LIGHTMAP_SHADOWSONLY = 2,
i.INTENSITYMODE_AUTOMATIC = 0,
i.INTENSITYMODE_LUMINOUSPOWER = 1,
i.INTENSITYMODE_LUMINOUSINTENSITY = 2,
i.INTENSITYMODE_ILLUMINANCE = 3,
i.INTENSITYMODE_LUMINANCE = 4,
i.LIGHTTYPEID_POINTLIGHT = 0,
i.LIGHTTYPEID_DIRECTIONALLIGHT = 1,
i.LIGHTTYPEID_SPOTLIGHT = 2,
i.LIGHTTYPEID_HEMISPHERICLIGHT = 3,
i
}()
, ComputePressureObserverWrapper = function() {
function i(e, t) {
i.IsAvailable && (this._observer = new window.ComputePressureObserver(e,t))
}
return Object.defineProperty(i, "IsAvailable", {
get: function() {
return IsWindowObjectExist() && "ComputePressureObserver"in window
},
enumerable: !1,
configurable: !0
}),
i.prototype.observe = function() {
var e, t;
!((e = this._observer) === null || e === void 0) && e.observe && ((t = this._observer) === null || t === void 0 || t.observe())
}
,
i.prototype.unobserve = function() {
var e, t;
!((e = this._observer) === null || e === void 0) && e.unobserve && ((t = this._observer) === null || t === void 0 || t.unobserve())
}
,
i
}()
, _injectLTSScene = function(i) {
i.prototype.setActiveCameraByID = function(e) {
return this.setActiveCameraById(e)
}
,
i.prototype.getLastMaterialByID = function(e) {
return this.getLastMaterialById(e)
}
,
i.prototype.getMaterialByID = function(e) {
return this.getMaterialById(e)
}
,
i.prototype.getTextureByUniqueID = function(e) {
return this.getTextureByUniqueId(e)
}
,
i.prototype.getCameraByID = function(e) {
return this.getCameraById(e)
}
,
i.prototype.getCameraByUniqueID = function(e) {
return this.getCameraByUniqueId(e)
}
,
i.prototype.getBoneByID = function(e) {
return this.getBoneById(e)
}
,
i.prototype.getLightByID = function(e) {
return this.getLightById(e)
}
,
i.prototype.getLightByUniqueID = function(e) {
return this.getLightByUniqueId(e)
}
,
i.prototype.getParticleSystemByID = function(e) {
return this.getParticleSystemById(e)
}
,
i.prototype.getGeometryByID = function(e) {
return this.getGeometryById(e)
}
,
i.prototype.getMeshByID = function(e) {
return this.getMeshById(e)
}
,
i.prototype.getMeshesByID = function(e) {
return this.getMeshesById(e)
}
,
i.prototype.getTransformNodeByID = function(e) {
return this.getTransformNodeById(e)
}
,
i.prototype.getTransformNodeByUniqueID = function(e) {
return this.getTransformNodeByUniqueId(e)
}
,
i.prototype.getTransformNodesByID = function(e) {
return this.getTransformNodesById(e)
}
,
i.prototype.getMeshByUniqueID = function(e) {
return this.getMeshByUniqueId(e)
}
,
i.prototype.getLastMeshByID = function(e) {
return this.getLastMeshById(e)
}
,
i.prototype.getLastEntryByID = function(e) {
return this.getLastEntryById(e)
}
,
i.prototype.getNodeByID = function(e) {
return this.getNodeById(e)
}
,
i.prototype.getLastSkeletonByID = function(e) {
return this.getLastSkeletonById(e)
}
}
, Scene = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this) || this;
n._inputManager = new InputManager(n),
n.cameraToUseForPointers = null,
n._isScene = !0,
n._blockEntityCollection = !1,
n.autoClear = !0,
n.autoClearDepthAndStencil = !0,
n.clearColor = new Color4(.2,.2,.3,1),
n.ambientColor = new Color3(0,0,0),
n._environmentIntensity = 1,
n._forceWireframe = !1,
n._skipFrustumClipping = !1,
n._forcePointsCloud = !1,
n.animationsEnabled = !0,
n._animationPropertiesOverride = null,
n.useConstantAnimationDeltaTime = !1,
n.constantlyUpdateMeshUnderPointer = !1,
n.hoverCursor = "pointer",
n.defaultCursor = "",
n.doNotHandleCursors = !1,
n.preventDefaultOnPointerDown = !0,
n.preventDefaultOnPointerUp = !0,
n.metadata = null,
n.reservedDataStore = null,
n.disableOfflineSupportExceptionRules = new Array,
n.onDisposeObservable = new Observable,
n._onDisposeObserver = null,
n.onBeforeRenderObservable = new Observable,
n._onBeforeRenderObserver = null,
n.onAfterRenderObservable = new Observable,
n.onBeforeRunRegisterBeforeRenderObservable = new Observable,
n.onAfterRunRegisterBeforeRenderObservable = new Observable,
n.onBeforeRunRegisterAfterRenderObservable = new Observable,
n.onAfterRunRegisterAfterRenderObservable = new Observable,
n.onBeforeRTT1Observable = new Observable,
n.onAfterRTT1Observable = new Observable,
n.onAfterRenderCameraObservable = new Observable,
n._onAfterRenderObserver = null,
n.onBeforeAnimationsObservable = new Observable,
n.onAfterAnimationsObservable = new Observable,
n.onBeforeDrawPhaseObservable = new Observable,
n.onAfterDrawPhaseObservable = new Observable,
n.onReadyObservable = new Observable,
n.onBeforeCameraRenderObservable = new Observable,
n._onBeforeCameraRenderObserver = null,
n.onAfterCameraRenderObservable = new Observable,
n._onAfterCameraRenderObserver = null,
n.onBeforeActiveMeshesEvaluationObservable = new Observable,
n.onAfterActiveMeshesEvaluationObservable = new Observable,
n.onBeforeParticlesRenderingObservable = new Observable,
n.onAfterParticlesRenderingObservable = new Observable,
n.onDataLoadedObservable = new Observable,
n.onNewCameraAddedObservable = new Observable,
n.onCameraRemovedObservable = new Observable,
n.onNewLightAddedObservable = new Observable,
n.onLightRemovedObservable = new Observable,
n.onNewGeometryAddedObservable = new Observable,
n.onGeometryRemovedObservable = new Observable,
n.onNewTransformNodeAddedObservable = new Observable,
n.onTransformNodeRemovedObservable = new Observable,
n.onNewMeshAddedObservable = new Observable,
n.onMeshRemovedObservable = new Observable,
n.onNewSkeletonAddedObservable = new Observable,
n.onSkeletonRemovedObservable = new Observable,
n.onNewMaterialAddedObservable = new Observable,
n.onNewMultiMaterialAddedObservable = new Observable,
n.onMaterialRemovedObservable = new Observable,
n.onMultiMaterialRemovedObservable = new Observable,
n.onNewTextureAddedObservable = new Observable,
n.onTextureRemovedObservable = new Observable,
n.onBeforeRenderTargetsRenderObservable = new Observable,
n.onAfterRenderTargetsRenderObservable = new Observable,
n.onBeforeStepObservable = new Observable,
n.onAfterStepObservable = new Observable,
n.onActiveCameraChanged = new Observable,
n.onBeforeRenderingGroupObservable = new Observable,
n.onAfterRenderingGroupObservable = new Observable,
n.onMeshImportedObservable = new Observable,
n.onAnimationFileImportedObservable = new Observable,
n._registeredForLateAnimationBindings = new SmartArrayNoDuplicate(256),
n.skipPointerMovePicking = !1,
n.onPrePointerObservable = new Observable,
n.onPointerObservable = new Observable,
n.onPreKeyboardObservable = new Observable,
n.onKeyboardObservable = new Observable,
n._useRightHandedSystem = !1,
n._timeAccumulator = 0,
n._currentStepId = 0,
n._currentInternalStep = 0,
n._fogEnabled = !0,
n._fogMode = e.FOGMODE_NONE,
n.fogColor = new Color3(.2,.2,.3),
n.fogDensity = .1,
n.fogStart = 0,
n.fogEnd = 1e3,
n.needsPreviousWorldMatrices = !1,
n._shadowsEnabled = !0,
n._lightsEnabled = !0,
n.activeCameras = new Array,
n._texturesEnabled = !0,
n.physicsEnabled = !0,
n.particlesEnabled = !0,
n.spritesEnabled = !0,
n._skeletonsEnabled = !0,
n.lensFlaresEnabled = !0,
n.collisionsEnabled = !0,
n.gravity = new Vector3(0,-9.807,0),
n.postProcessesEnabled = !0,
n.renderTargetsEnabled = !0,
n.dumpNextRenderTargets = !1,
n.customRenderTargets = new Array,
n.importedMeshesFiles = new Array,
n.probesEnabled = !0,
n._meshesForIntersections = new SmartArrayNoDuplicate(256),
n.proceduralTexturesEnabled = !0,
n._totalVertices = new PerfCounter,
n._activeIndices = new PerfCounter,
n._activeParticles = new PerfCounter,
n._activeBones = new PerfCounter,
n._animationTime = 0,
n.animationTimeScale = 1,
n._renderId = 0,
n._frameId = 0,
n._executeWhenReadyTimeoutId = -1,
n._intermediateRendering = !1,
n._defaultFrameBufferCleared = !1,
n._viewUpdateFlag = -1,
n._projectionUpdateFlag = -1,
n._toBeDisposed = new Array(256),
n._activeRequests = new Array,
n._pendingData = new Array,
n._isDisposed = !1,
n.dispatchAllSubMeshesOfActiveMeshes = !1,
n._activeMeshes = new SmartArray(256),
n._processedMaterials = new SmartArray(256),
n._renderTargets = new SmartArrayNoDuplicate(256),
n._activeParticleSystems = new SmartArray(256),
n._activeSkeletons = new SmartArrayNoDuplicate(32),
n._softwareSkinnedMeshes = new SmartArrayNoDuplicate(32),
n._activeAnimatables = new Array,
n._transformMatrix = Matrix.Zero(),
n.requireLightSorting = !1,
n._components = [],
n._serializableComponents = [],
n._transientComponents = [],
n._beforeCameraUpdateStage = Stage.Create(),
n._beforeClearStage = Stage.Create(),
n._beforeRenderTargetClearStage = Stage.Create(),
n._gatherRenderTargetsStage = Stage.Create(),
n._gatherActiveCameraRenderTargetsStage = Stage.Create(),
n._isReadyForMeshStage = Stage.Create(),
n._beforeEvaluateActiveMeshStage = Stage.Create(),
n._evaluateSubMeshStage = Stage.Create(),
n._preActiveMeshStage = Stage.Create(),
n._cameraDrawRenderTargetStage = Stage.Create(),
n._beforeCameraDrawStage = Stage.Create(),
n._beforeRenderTargetDrawStage = Stage.Create(),
n._beforeRenderingGroupDrawStage = Stage.Create(),
n._beforeRenderingMeshStage = Stage.Create(),
n._afterRenderingMeshStage = Stage.Create(),
n._afterRenderingGroupDrawStage = Stage.Create(),
n._afterCameraDrawStage = Stage.Create(),
n._afterRenderTargetDrawStage = Stage.Create(),
n._afterRenderStage = Stage.Create(),
n._pointerMoveStage = Stage.Create(),
n._pointerDownStage = Stage.Create(),
n._pointerUpStage = Stage.Create(),
n.geometriesByUniqueId = null,
n._defaultMeshCandidates = {
data: [],
length: 0
},
n._defaultSubMeshCandidates = {
data: [],
length: 0
},
n._preventFreeActiveMeshesAndRenderingGroups = !1,
n._activeMeshesFrozen = !1,
n._skipEvaluateActiveMeshesCompletely = !1,
n._allowPostProcessClearColor = !0,
n.getDeterministicFrameTime = function() {
return n._engine.getTimeStep()
}
,
n._blockMaterialDirtyMechanism = !1,
n._perfCollector = null,
n.onComputePressureChanged = new Observable;
var o = __assign({
useGeometryUniqueIdsMap: !0,
useMaterialMeshMap: !0,
useClonedMeshMap: !0,
virtual: !1
}, r);
return n._engine = t || EngineStore.LastCreatedEngine,
o.virtual ? n._engine._virtualScenes.push(n) : (EngineStore._LastCreatedScene = n,
n._engine.scenes.push(n)),
n._uid = null,
n._renderingManager = new RenderingManager(n),
PostProcessManager && (n.postProcessManager = new PostProcessManager(n)),
IsWindowObjectExist() && n.attachControl(),
n._createUbo(),
ImageProcessingConfiguration && (n._imageProcessingConfiguration = new ImageProcessingConfiguration),
n.setDefaultCandidateProviders(),
o.useGeometryUniqueIdsMap && (n.geometriesByUniqueId = {}),
n.useMaterialMeshMap = o.useMaterialMeshMap,
n.useClonedMeshMap = o.useClonedMeshMap,
(!r || !r.virtual) && n._engine.onNewSceneAddedObservable.notifyObservers(n),
ComputePressureObserverWrapper.IsAvailable && (n._computePressureObserver = new ComputePressureObserverWrapper(function(a) {
n.onComputePressureChanged.notifyObservers(a)
}
,{
cpuUtilizationThresholds: [.25, .5, .75, .9],
cpuSpeedThresholds: [.5]
}),
n._computePressureObserver.observe()),
n
}
return e.DefaultMaterialFactory = function(t) {
throw _WarnImport("StandardMaterial")
}
,
e.CollisionCoordinatorFactory = function() {
throw _WarnImport("DefaultCollisionCoordinator")
}
,
Object.defineProperty(e.prototype, "environmentTexture", {
get: function() {
return this._environmentTexture
},
set: function(t) {
this._environmentTexture !== t && (this._environmentTexture = t,
this.markAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "environmentIntensity", {
get: function() {
return this._environmentIntensity
},
set: function(t) {
this._environmentIntensity !== t && (this._environmentIntensity = t,
this.markAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
get: function() {
return this._imageProcessingConfiguration
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "forceWireframe", {
get: function() {
return this._forceWireframe
},
set: function(t) {
this._forceWireframe !== t && (this._forceWireframe = t,
this.markAllMaterialsAsDirty(16))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "skipFrustumClipping", {
get: function() {
return this._skipFrustumClipping
},
set: function(t) {
this._skipFrustumClipping !== t && (this._skipFrustumClipping = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "forcePointsCloud", {
get: function() {
return this._forcePointsCloud
},
set: function(t) {
this._forcePointsCloud !== t && (this._forcePointsCloud = t,
this.markAllMaterialsAsDirty(16))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "animationPropertiesOverride", {
get: function() {
return this._animationPropertiesOverride
},
set: function(t) {
this._animationPropertiesOverride = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onDispose", {
set: function(t) {
this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
this._onDisposeObserver = this.onDisposeObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "beforeRender", {
set: function(t) {
this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
t && (this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(t))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "afterRender", {
set: function(t) {
this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
t && (this._onAfterRenderObserver = this.onAfterRenderObservable.add(t))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "beforeCameraRender", {
set: function(t) {
this._onBeforeCameraRenderObserver && this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "afterCameraRender", {
set: function(t) {
this._onAfterCameraRenderObserver && this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "unTranslatedPointer", {
get: function() {
return this._inputManager.unTranslatedPointer
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "DragMovementThreshold", {
get: function() {
return InputManager.DragMovementThreshold
},
set: function(t) {
InputManager.DragMovementThreshold = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "LongPressDelay", {
get: function() {
return InputManager.LongPressDelay
},
set: function(t) {
InputManager.LongPressDelay = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "DoubleClickDelay", {
get: function() {
return InputManager.DoubleClickDelay
},
set: function(t) {
InputManager.DoubleClickDelay = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "ExclusiveDoubleClickMode", {
get: function() {
return InputManager.ExclusiveDoubleClickMode
},
set: function(t) {
InputManager.ExclusiveDoubleClickMode = t
},
enumerable: !1,
configurable: !0
}),
e.prototype.bindEyePosition = function(t, r, n) {
var o;
r === void 0 && (r = "vEyePosition"),
n === void 0 && (n = !1);
var a = this._forcedViewPosition ? this._forcedViewPosition : this._mirroredCameraPosition ? this._mirroredCameraPosition : (o = this.activeCamera.globalPosition) !== null && o !== void 0 ? o : this.activeCamera.devicePosition
, s = this.useRightHandedSystem === (this._mirroredCameraPosition != null);
return TmpVectors.Vector4[0].set(a.x, a.y, a.z, s ? -1 : 1),
t && (n ? t.setFloat3(r, TmpVectors.Vector4[0].x, TmpVectors.Vector4[0].y, TmpVectors.Vector4[0].z) : t.setVector4(r, TmpVectors.Vector4[0])),
TmpVectors.Vector4[0]
}
,
e.prototype.finalizeSceneUbo = function() {
var t = this.getSceneUniformBuffer()
, r = this.bindEyePosition(null);
return t.updateFloat4("vEyePosition", r.x, r.y, r.z, r.w),
t.update(),
t
}
,
Object.defineProperty(e.prototype, "useRightHandedSystem", {
get: function() {
return this._useRightHandedSystem
},
set: function(t) {
this._useRightHandedSystem !== t && (this._useRightHandedSystem = t,
this.markAllMaterialsAsDirty(16))
},
enumerable: !1,
configurable: !0
}),
e.prototype.setStepId = function(t) {
this._currentStepId = t
}
,
e.prototype.getStepId = function() {
return this._currentStepId
}
,
e.prototype.getInternalStep = function() {
return this._currentInternalStep
}
,
Object.defineProperty(e.prototype, "fogEnabled", {
get: function() {
return this._fogEnabled
},
set: function(t) {
this._fogEnabled !== t && (this._fogEnabled = t,
this.markAllMaterialsAsDirty(16))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "fogMode", {
get: function() {
return this._fogMode
},
set: function(t) {
this._fogMode !== t && (this._fogMode = t,
this.markAllMaterialsAsDirty(16))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "prePass", {
get: function() {
return !!this.prePassRenderer && this.prePassRenderer.defaultRT.enabled
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "shadowsEnabled", {
get: function() {
return this._shadowsEnabled
},
set: function(t) {
this._shadowsEnabled !== t && (this._shadowsEnabled = t,
this.markAllMaterialsAsDirty(2))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "lightsEnabled", {
get: function() {
return this._lightsEnabled
},
set: function(t) {
this._lightsEnabled !== t && (this._lightsEnabled = t,
this.markAllMaterialsAsDirty(2))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "activeCamera", {
get: function() {
return this._activeCamera
},
set: function(t) {
t !== this._activeCamera && (this._activeCamera = t,
this.onActiveCameraChanged.notifyObservers(this))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "defaultMaterial", {
get: function() {
return this._defaultMaterial || (this._defaultMaterial = e.DefaultMaterialFactory(this)),
this._defaultMaterial
},
set: function(t) {
this._defaultMaterial = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "texturesEnabled", {
get: function() {
return this._texturesEnabled
},
set: function(t) {
this._texturesEnabled !== t && (this._texturesEnabled = t,
this.markAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "skeletonsEnabled", {
get: function() {
return this._skeletonsEnabled
},
set: function(t) {
this._skeletonsEnabled !== t && (this._skeletonsEnabled = t,
this.markAllMaterialsAsDirty(8))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "collisionCoordinator", {
get: function() {
return this._collisionCoordinator || (this._collisionCoordinator = e.CollisionCoordinatorFactory(),
this._collisionCoordinator.init(this)),
this._collisionCoordinator
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "frustumPlanes", {
get: function() {
return this._frustumPlanes
},
enumerable: !1,
configurable: !0
}),
e.prototype._registerTransientComponents = function() {
if (this._transientComponents.length > 0) {
for (var t = 0, r = this._transientComponents; t < r.length; t++) {
var n = r[t];
n.register()
}
this._transientComponents = []
}
}
,
e.prototype._addComponent = function(t) {
this._components.push(t),
this._transientComponents.push(t);
var r = t;
r.addFromContainer && r.serialize && this._serializableComponents.push(r)
}
,
e.prototype._getComponent = function(t) {
for (var r = 0, n = this._components; r < n.length; r++) {
var o = n[r];
if (o.name === t)
return o
}
return null
}
,
e.prototype.getClassName = function() {
return "Scene"
}
,
e.prototype._getDefaultMeshCandidates = function() {
return this._defaultMeshCandidates.data = this.meshes,
this._defaultMeshCandidates.length = this.meshes.length,
this._defaultMeshCandidates
}
,
e.prototype._getDefaultSubMeshCandidates = function(t) {
return this._defaultSubMeshCandidates.data = t.subMeshes,
this._defaultSubMeshCandidates.length = t.subMeshes.length,
this._defaultSubMeshCandidates
}
,
e.prototype.setDefaultCandidateProviders = function() {
this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this),
this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this),
this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this),
this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this)
}
,
Object.defineProperty(e.prototype, "meshUnderPointer", {
get: function() {
return this._inputManager.meshUnderPointer
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "pointerX", {
get: function() {
return this._inputManager.pointerX
},
set: function(t) {
this._inputManager.pointerX = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "pointerY", {
get: function() {
return this._inputManager.pointerY
},
set: function(t) {
this._inputManager.pointerY = t
},
enumerable: !1,
configurable: !0
}),
e.prototype.getCachedMaterial = function() {
return this._cachedMaterial
}
,
e.prototype.getCachedEffect = function() {
return this._cachedEffect
}
,
e.prototype.getCachedVisibility = function() {
return this._cachedVisibility
}
,
e.prototype.isCachedMaterialInvalid = function(t, r, n) {
return n === void 0 && (n = 1),
this._cachedEffect !== r || this._cachedMaterial !== t || this._cachedVisibility !== n
}
,
e.prototype.getEngine = function() {
return this._engine
}
,
e.prototype.getTotalVertices = function() {
return this._totalVertices.current
}
,
Object.defineProperty(e.prototype, "totalVerticesPerfCounter", {
get: function() {
return this._totalVertices
},
enumerable: !1,
configurable: !0
}),
e.prototype.getActiveIndices = function() {
return this._activeIndices.current
}
,
Object.defineProperty(e.prototype, "totalActiveIndicesPerfCounter", {
get: function() {
return this._activeIndices
},
enumerable: !1,
configurable: !0
}),
e.prototype.getActiveParticles = function() {
return this._activeParticles.current
}
,
Object.defineProperty(e.prototype, "activeParticlesPerfCounter", {
get: function() {
return this._activeParticles
},
enumerable: !1,
configurable: !0
}),
e.prototype.getActiveBones = function() {
return this._activeBones.current
}
,
Object.defineProperty(e.prototype, "activeBonesPerfCounter", {
get: function() {
return this._activeBones
},
enumerable: !1,
configurable: !0
}),
e.prototype.getActiveMeshes = function() {
return this._activeMeshes
}
,
e.prototype.getAnimationRatio = function() {
return this._animationRatio !== void 0 ? this._animationRatio : 1
}
,
e.prototype.getRenderId = function() {
return this._renderId
}
,
e.prototype.getFrameId = function() {
return this._frameId
}
,
e.prototype.incrementRenderId = function() {
this._renderId++
}
,
e.prototype._createUbo = function() {
this.setSceneUniformBuffer(this.createSceneUniformBuffer())
}
,
e.prototype.simulatePointerMove = function(t, r) {
return this._inputManager.simulatePointerMove(t, r),
this
}
,
e.prototype.simulatePointerDown = function(t, r) {
return this._inputManager.simulatePointerDown(t, r),
this
}
,
e.prototype.simulatePointerUp = function(t, r, n) {
return this._inputManager.simulatePointerUp(t, r, n),
this
}
,
e.prototype.isPointerCaptured = function(t) {
return t === void 0 && (t = 0),
this._inputManager.isPointerCaptured(t)
}
,
e.prototype.attachControl = function(t, r, n) {
t === void 0 && (t = !0),
r === void 0 && (r = !0),
n === void 0 && (n = !0),
this._inputManager.attachControl(t, r, n)
}
,
e.prototype.detachControl = function() {
this._inputManager.detachControl()
}
,
e.prototype.isReady = function(t) {
if (t === void 0 && (t = !0),
this._isDisposed)
return !1;
var r, n = this.getEngine();
if (!n.areAllEffectsReady() || this._pendingData.length > 0)
return !1;
for (t && (this._processedMaterials.reset(),
this._renderTargets.reset()),
r = 0; r < this.meshes.length; r++) {
var o = this.meshes[r];
if (!!o.isEnabled() && !(!o.subMeshes || o.subMeshes.length === 0)) {
if (!o.isReady(!0))
return !1;
for (var a = o.hasThinInstances || o.getClassName() === "InstancedMesh" || o.getClassName() === "InstancedLinesMesh" || n.getCaps().instancedArrays && o.instances.length > 0, s = 0, l = this._isReadyForMeshStage; s < l.length; s++) {
var u = l[s];
if (!u.action(o, a))
return !1
}
if (!!t) {
var c = o.material || this.defaultMaterial;
if (c)
if (c._storeEffectOnSubMeshes)
for (var h = 0, f = o.subMeshes; h < f.length; h++) {
var d = f[h]
, _ = d.getMaterial();
_ && _.hasRenderTargetTextures && _.getRenderTargetTextures != null && this._processedMaterials.indexOf(_) === -1 && (this._processedMaterials.push(_),
this._renderTargets.concatWithNoDuplicate(_.getRenderTargetTextures()))
}
else
c.hasRenderTargetTextures && c.getRenderTargetTextures != null && this._processedMaterials.indexOf(c) === -1 && (this._processedMaterials.push(c),
this._renderTargets.concatWithNoDuplicate(c.getRenderTargetTextures()))
}
}
}
if (t)
for (r = 0; r < this._renderTargets.length; ++r) {
var g = this._renderTargets.data[r];
if (!g.isReadyForRendering())
return !1
}
for (r = 0; r < this.geometries.length; r++) {
var m = this.geometries[r];
if (m.delayLoadState === 2)
return !1
}
if (this.activeCameras && this.activeCameras.length > 0)
for (var v = 0, y = this.activeCameras; v < y.length; v++) {
var b = y[v];
if (!b.isReady(!0))
return !1
}
else if (this.activeCamera && !this.activeCamera.isReady(!0))
return !1;
for (var T = 0, C = this.particleSystems; T < C.length; T++) {
var A = C[T];
if (!A.isReady())
return !1
}
return !0
}
,
e.prototype.resetCachedMaterial = function() {
this._cachedMaterial = null,
this._cachedEffect = null,
this._cachedVisibility = null
}
,
e.prototype.registerBeforeRender = function(t) {
this.onBeforeRenderObservable.add(t)
}
,
e.prototype.unregisterBeforeRender = function(t) {
this.onBeforeRenderObservable.removeCallback(t)
}
,
e.prototype.registerAfterRender = function(t) {
this.onAfterRenderObservable.add(t)
}
,
e.prototype.unregisterAfterRender = function(t) {
this.onAfterRenderObservable.removeCallback(t)
}
,
e.prototype._executeOnceBeforeRender = function(t) {
var r = this
, n = function() {
t(),
setTimeout(function() {
r.unregisterBeforeRender(n)
})
};
this.registerBeforeRender(n)
}
,
e.prototype.executeOnceBeforeRender = function(t, r) {
var n = this;
r !== void 0 ? setTimeout(function() {
n._executeOnceBeforeRender(t)
}, r) : this._executeOnceBeforeRender(t)
}
,
e.prototype._addPendingData = function(t) {
this._pendingData.push(t)
}
,
e.prototype._removePendingData = function(t) {
var r = this.isLoading
, n = this._pendingData.indexOf(t);
n !== -1 && this._pendingData.splice(n, 1),
r && !this.isLoading && this.onDataLoadedObservable.notifyObservers(this)
}
,
e.prototype.getWaitingItemsCount = function() {
return this._pendingData.length
}
,
Object.defineProperty(e.prototype, "isLoading", {
get: function() {
return this._pendingData.length > 0
},
enumerable: !1,
configurable: !0
}),
e.prototype.executeWhenReady = function(t, r) {
var n = this;
r === void 0 && (r = !1),
this.onReadyObservable.add(t),
this._executeWhenReadyTimeoutId === -1 && (this._executeWhenReadyTimeoutId = setTimeout(function() {
n._checkIsReady(r)
}, 150))
}
,
e.prototype.whenReadyAsync = function(t) {
var r = this;
return t === void 0 && (t = !1),
new Promise(function(n) {
r.executeWhenReady(function() {
n()
}, t)
}
)
}
,
e.prototype._checkIsReady = function(t) {
var r = this;
if (t === void 0 && (t = !1),
this._registerTransientComponents(),
this.isReady(t)) {
this.onReadyObservable.notifyObservers(this),
this.onReadyObservable.clear(),
this._executeWhenReadyTimeoutId = -1;
return
}
if (this._isDisposed) {
this.onReadyObservable.clear(),
this._executeWhenReadyTimeoutId = -1;
return
}
this._executeWhenReadyTimeoutId = setTimeout(function() {
r._checkIsReady(t)
}, 150)
}
,
Object.defineProperty(e.prototype, "animatables", {
get: function() {
return this._activeAnimatables
},
enumerable: !1,
configurable: !0
}),
e.prototype.resetLastAnimationTimeFrame = function() {
this._animationTimeLast = PrecisionDate.Now
}
,
e.prototype.getViewMatrix = function() {
return this._viewMatrix
}
,
e.prototype.getProjectionMatrix = function() {
return this._projectionMatrix
}
,
e.prototype.getTransformMatrix = function() {
return this._transformMatrix
}
,
e.prototype.setTransformMatrix = function(t, r, n, o) {
this._viewUpdateFlag === t.updateFlag && this._projectionUpdateFlag === r.updateFlag || (this._viewUpdateFlag = t.updateFlag,
this._projectionUpdateFlag = r.updateFlag,
this._viewMatrix = t,
this._projectionMatrix = r,
this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
this._frustumPlanes ? Frustum.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = Frustum.GetPlanes(this._transformMatrix),
this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo ? this._updateMultiviewUbo(n, o) : this._sceneUbo.useUbo && (this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix),
this._sceneUbo.updateMatrix("view", this._viewMatrix),
this._sceneUbo.updateMatrix("projection", this._projectionMatrix)))
}
,
e.prototype.getSceneUniformBuffer = function() {
return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo
}
,
e.prototype.createSceneUniformBuffer = function(t) {
var r = new UniformBuffer(this._engine,void 0,!1,t != null ? t : "scene");
return r.addUniform("viewProjection", 16),
r.addUniform("view", 16),
r.addUniform("projection", 16),
r.addUniform("vEyePosition", 4),
r
}
,
e.prototype.setSceneUniformBuffer = function(t) {
this._sceneUbo = t,
this._viewUpdateFlag = -1,
this._projectionUpdateFlag = -1
}
,
e.prototype.getUniqueId = function() {
return UniqueIdGenerator.UniqueId
}
,
e.prototype.addMesh = function(t, r) {
var n = this;
r === void 0 && (r = !1),
!this._blockEntityCollection && (this.meshes.push(t),
t._resyncLightSources(),
t.parent || t._addToSceneRootNodes(),
this.onNewMeshAddedObservable.notifyObservers(t),
r && t.getChildMeshes().forEach(function(o) {
n.addMesh(o)
}))
}
,
e.prototype.removeMesh = function(t, r) {
var n = this;
r === void 0 && (r = !1);
var o = this.meshes.indexOf(t);
return o !== -1 && (this.meshes[o] = this.meshes[this.meshes.length - 1],
this.meshes.pop(),
t.parent || t._removeFromSceneRootNodes()),
this._inputManager._invalidateMesh(t),
this.onMeshRemovedObservable.notifyObservers(t),
r && t.getChildMeshes().forEach(function(a) {
n.removeMesh(a)
}),
o
}
,
e.prototype.addTransformNode = function(t) {
this._blockEntityCollection || (t._indexInSceneTransformNodesArray = this.transformNodes.length,
this.transformNodes.push(t),
t.parent || t._addToSceneRootNodes(),
this.onNewTransformNodeAddedObservable.notifyObservers(t))
}
,
e.prototype.removeTransformNode = function(t) {
var r = t._indexInSceneTransformNodesArray;
if (r !== -1) {
if (r !== this.transformNodes.length - 1) {
var n = this.transformNodes[this.transformNodes.length - 1];
this.transformNodes[r] = n,
n._indexInSceneTransformNodesArray = r
}
t._indexInSceneTransformNodesArray = -1,
this.transformNodes.pop(),
t.parent || t._removeFromSceneRootNodes()
}
return this.onTransformNodeRemovedObservable.notifyObservers(t),
r
}
,
e.prototype.removeSkeleton = function(t) {
var r = this.skeletons.indexOf(t);
return r !== -1 && (this.skeletons.splice(r, 1),
this.onSkeletonRemovedObservable.notifyObservers(t)),
r
}
,
e.prototype.removeMorphTargetManager = function(t) {
var r = this.morphTargetManagers.indexOf(t);
return r !== -1 && this.morphTargetManagers.splice(r, 1),
r
}
,
e.prototype.removeLight = function(t) {
var r = this.lights.indexOf(t);
if (r !== -1) {
for (var n = 0, o = this.meshes; n < o.length; n++) {
var a = o[n];
a._removeLightSource(t, !1)
}
this.lights.splice(r, 1),
this.sortLightsByPriority(),
t.parent || t._removeFromSceneRootNodes()
}
return this.onLightRemovedObservable.notifyObservers(t),
r
}
,
e.prototype.removeCamera = function(t) {
var r = this.cameras.indexOf(t);
if (r !== -1 && (this.cameras.splice(r, 1),
t.parent || t._removeFromSceneRootNodes()),
this.activeCameras) {
var n = this.activeCameras.indexOf(t);
n !== -1 && this.activeCameras.splice(n, 1)
}
return this.activeCamera === t && (this.cameras.length > 0 ? this.activeCamera = this.cameras[0] : this.activeCamera = null),
this.onCameraRemovedObservable.notifyObservers(t),
r
}
,
e.prototype.removeParticleSystem = function(t) {
var r = this.particleSystems.indexOf(t);
return r !== -1 && this.particleSystems.splice(r, 1),
r
}
,
e.prototype.removeAnimation = function(t) {
var r = this.animations.indexOf(t);
return r !== -1 && this.animations.splice(r, 1),
r
}
,
e.prototype.stopAnimation = function(t, r, n) {}
,
e.prototype.removeAnimationGroup = function(t) {
var r = this.animationGroups.indexOf(t);
return r !== -1 && this.animationGroups.splice(r, 1),
r
}
,
e.prototype.removeMultiMaterial = function(t) {
var r = this.multiMaterials.indexOf(t);
return r !== -1 && this.multiMaterials.splice(r, 1),
this.onMultiMaterialRemovedObservable.notifyObservers(t),
r
}
,
e.prototype.removeMaterial = function(t) {
var r = t._indexInSceneMaterialArray;
if (r !== -1 && r < this.materials.length) {
if (r !== this.materials.length - 1) {
var n = this.materials[this.materials.length - 1];
this.materials[r] = n,
n._indexInSceneMaterialArray = r
}
t._indexInSceneMaterialArray = -1,
this.materials.pop()
}
return this.onMaterialRemovedObservable.notifyObservers(t),
r
}
,
e.prototype.removeActionManager = function(t) {
var r = this.actionManagers.indexOf(t);
return r !== -1 && this.actionManagers.splice(r, 1),
r
}
,
e.prototype.removeTexture = function(t) {
var r = this.textures.indexOf(t);
return r !== -1 && this.textures.splice(r, 1),
this.onTextureRemovedObservable.notifyObservers(t),
r
}
,
e.prototype.addLight = function(t) {
if (!this._blockEntityCollection) {
this.lights.push(t),
this.sortLightsByPriority(),
t.parent || t._addToSceneRootNodes();
for (var r = 0, n = this.meshes; r < n.length; r++) {
var o = n[r];
o.lightSources.indexOf(t) === -1 && (o.lightSources.push(t),
o._resyncLightSources())
}
this.onNewLightAddedObservable.notifyObservers(t)
}
}
,
e.prototype.sortLightsByPriority = function() {
this.requireLightSorting && this.lights.sort(LightConstants.CompareLightsPriority)
}
,
e.prototype.addCamera = function(t) {
this._blockEntityCollection || (this.cameras.push(t),
this.onNewCameraAddedObservable.notifyObservers(t),
t.parent || t._addToSceneRootNodes())
}
,
e.prototype.addSkeleton = function(t) {
this._blockEntityCollection || (this.skeletons.push(t),
this.onNewSkeletonAddedObservable.notifyObservers(t))
}
,
e.prototype.addParticleSystem = function(t) {
this._blockEntityCollection || this.particleSystems.push(t)
}
,
e.prototype.addAnimation = function(t) {
this._blockEntityCollection || this.animations.push(t)
}
,
e.prototype.addAnimationGroup = function(t) {
this._blockEntityCollection || this.animationGroups.push(t)
}
,
e.prototype.addMultiMaterial = function(t) {
this._blockEntityCollection || (this.multiMaterials.push(t),
this.onNewMultiMaterialAddedObservable.notifyObservers(t))
}
,
e.prototype.addMaterial = function(t) {
this._blockEntityCollection || (t._indexInSceneMaterialArray = this.materials.length,
this.materials.push(t),
this.onNewMaterialAddedObservable.notifyObservers(t))
}
,
e.prototype.addMorphTargetManager = function(t) {
this._blockEntityCollection || this.morphTargetManagers.push(t)
}
,
e.prototype.addGeometry = function(t) {
this._blockEntityCollection || (this.geometriesByUniqueId && (this.geometriesByUniqueId[t.uniqueId] = this.geometries.length),
this.geometries.push(t))
}
,
e.prototype.addActionManager = function(t) {
this.actionManagers.push(t)
}
,
e.prototype.addTexture = function(t) {
this._blockEntityCollection || (this.textures.push(t),
this.onNewTextureAddedObservable.notifyObservers(t))
}
,
e.prototype.switchActiveCamera = function(t, r) {
r === void 0 && (r = !0);
var n = this._engine.getInputElement();
!n || (this.activeCamera && this.activeCamera.detachControl(),
this.activeCamera = t,
r && t.attachControl())
}
,
e.prototype.setActiveCameraById = function(t) {
var r = this.getCameraById(t);
return r ? (this.activeCamera = r,
r) : null
}
,
e.prototype.setActiveCameraByName = function(t) {
var r = this.getCameraByName(t);
return r ? (this.activeCamera = r,
r) : null
}
,
e.prototype.getAnimationGroupByName = function(t) {
for (var r = 0; r < this.animationGroups.length; r++)
if (this.animationGroups[r].name === t)
return this.animationGroups[r];
return null
}
,
e.prototype.getMaterialByUniqueID = function(t) {
for (var r = 0; r < this.materials.length; r++)
if (this.materials[r].uniqueId === t)
return this.materials[r];
return null
}
,
e.prototype.getMaterialById = function(t) {
for (var r = 0; r < this.materials.length; r++)
if (this.materials[r].id === t)
return this.materials[r];
return null
}
,
e.prototype.getLastMaterialById = function(t) {
for (var r = this.materials.length - 1; r >= 0; r--)
if (this.materials[r].id === t)
return this.materials[r];
return null
}
,
e.prototype.getMaterialByName = function(t) {
for (var r = 0; r < this.materials.length; r++)
if (this.materials[r].name === t)
return this.materials[r];
return null
}
,
e.prototype.getTextureByUniqueId = function(t) {
for (var r = 0; r < this.textures.length; r++)
if (this.textures[r].uniqueId === t)
return this.textures[r];
return null
}
,
e.prototype.getTextureByName = function(t) {
for (var r = 0; r < this.textures.length; r++)
if (this.textures[r].name === t)
return this.textures[r];
return null
}
,
e.prototype.getCameraById = function(t) {
for (var r = 0; r < this.cameras.length; r++)
if (this.cameras[r].id === t)
return this.cameras[r];
return null
}
,
e.prototype.getCameraByUniqueId = function(t) {
for (var r = 0; r < this.cameras.length; r++)
if (this.cameras[r].uniqueId === t)
return this.cameras[r];
return null
}
,
e.prototype.getCameraByName = function(t) {
for (var r = 0; r < this.cameras.length; r++)
if (this.cameras[r].name === t)
return this.cameras[r];
return null
}
,
e.prototype.getBoneById = function(t) {
for (var r = 0; r < this.skeletons.length; r++)
for (var n = this.skeletons[r], o = 0; o < n.bones.length; o++)
if (n.bones[o].id === t)
return n.bones[o];
return null
}
,
e.prototype.getBoneByName = function(t) {
for (var r = 0; r < this.skeletons.length; r++)
for (var n = this.skeletons[r], o = 0; o < n.bones.length; o++)
if (n.bones[o].name === t)
return n.bones[o];
return null
}
,
e.prototype.getLightByName = function(t) {
for (var r = 0; r < this.lights.length; r++)
if (this.lights[r].name === t)
return this.lights[r];
return null
}
,
e.prototype.getLightById = function(t) {
for (var r = 0; r < this.lights.length; r++)
if (this.lights[r].id === t)
return this.lights[r];
return null
}
,
e.prototype.getLightByUniqueId = function(t) {
for (var r = 0; r < this.lights.length; r++)
if (this.lights[r].uniqueId === t)
return this.lights[r];
return null
}
,
e.prototype.getParticleSystemById = function(t) {
for (var r = 0; r < this.particleSystems.length; r++)
if (this.particleSystems[r].id === t)
return this.particleSystems[r];
return null
}
,
e.prototype.getGeometryById = function(t) {
for (var r = 0; r < this.geometries.length; r++)
if (this.geometries[r].id === t)
return this.geometries[r];
return null
}
,
e.prototype._getGeometryByUniqueId = function(t) {
if (this.geometriesByUniqueId) {
var r = this.geometriesByUniqueId[t];
if (r !== void 0)
return this.geometries[r]
} else
for (var n = 0; n < this.geometries.length; n++)
if (this.geometries[n].uniqueId === t)
return this.geometries[n];
return null
}
,
e.prototype.pushGeometry = function(t, r) {
return !r && this._getGeometryByUniqueId(t.uniqueId) ? !1 : (this.addGeometry(t),
this.onNewGeometryAddedObservable.notifyObservers(t),
!0)
}
,
e.prototype.removeGeometry = function(t) {
var r;
if (this.geometriesByUniqueId) {
if (r = this.geometriesByUniqueId[t.uniqueId],
r === void 0)
return !1
} else if (r = this.geometries.indexOf(t),
r < 0)
return !1;
if (r !== this.geometries.length - 1) {
var n = this.geometries[this.geometries.length - 1];
n && (this.geometries[r] = n,
this.geometriesByUniqueId && (this.geometriesByUniqueId[n.uniqueId] = r,
this.geometriesByUniqueId[t.uniqueId] = void 0))
}
return this.geometries.pop(),
this.onGeometryRemovedObservable.notifyObservers(t),
!0
}
,
e.prototype.getGeometries = function() {
return this.geometries
}
,
e.prototype.getMeshById = function(t) {
for (var r = 0; r < this.meshes.length; r++)
if (this.meshes[r].id === t)
return this.meshes[r];
return null
}
,
e.prototype.getMeshesById = function(t) {
return this.meshes.filter(function(r) {
return r.id === t
})
}
,
e.prototype.getTransformNodeById = function(t) {
for (var r = 0; r < this.transformNodes.length; r++)
if (this.transformNodes[r].id === t)
return this.transformNodes[r];
return null
}
,
e.prototype.getTransformNodeByUniqueId = function(t) {
for (var r = 0; r < this.transformNodes.length; r++)
if (this.transformNodes[r].uniqueId === t)
return this.transformNodes[r];
return null
}
,
e.prototype.getTransformNodesById = function(t) {
return this.transformNodes.filter(function(r) {
return r.id === t
})
}
,
e.prototype.getMeshByUniqueId = function(t) {
for (var r = 0; r < this.meshes.length; r++)
if (this.meshes[r].uniqueId === t)
return this.meshes[r];
return null
}
,
e.prototype.getLastMeshById = function(t) {
for (var r = this.meshes.length - 1; r >= 0; r--)
if (this.meshes[r].id === t)
return this.meshes[r];
return null
}
,
e.prototype.getLastEntryById = function(t) {
var r;
for (r = this.meshes.length - 1; r >= 0; r--)
if (this.meshes[r].id === t)
return this.meshes[r];
for (r = this.transformNodes.length - 1; r >= 0; r--)
if (this.transformNodes[r].id === t)
return this.transformNodes[r];
for (r = this.cameras.length - 1; r >= 0; r--)
if (this.cameras[r].id === t)
return this.cameras[r];
for (r = this.lights.length - 1; r >= 0; r--)
if (this.lights[r].id === t)
return this.lights[r];
return null
}
,
e.prototype.getNodeById = function(t) {
var r = this.getMeshById(t);
if (r)
return r;
var n = this.getTransformNodeById(t);
if (n)
return n;
var o = this.getLightById(t);
if (o)
return o;
var a = this.getCameraById(t);
if (a)
return a;
var s = this.getBoneById(t);
return s || null
}
,
e.prototype.getNodeByName = function(t) {
var r = this.getMeshByName(t);
if (r)
return r;
var n = this.getTransformNodeByName(t);
if (n)
return n;
var o = this.getLightByName(t);
if (o)
return o;
var a = this.getCameraByName(t);
if (a)
return a;
var s = this.getBoneByName(t);
return s || null
}
,
e.prototype.getMeshByName = function(t) {
for (var r = 0; r < this.meshes.length; r++)
if (this.meshes[r].name === t)
return this.meshes[r];
return null
}
,
e.prototype.getTransformNodeByName = function(t) {
for (var r = 0; r < this.transformNodes.length; r++)
if (this.transformNodes[r].name === t)
return this.transformNodes[r];
return null
}
,
e.prototype.getLastSkeletonById = function(t) {
for (var r = this.skeletons.length - 1; r >= 0; r--)
if (this.skeletons[r].id === t)
return this.skeletons[r];
return null
}
,
e.prototype.getSkeletonByUniqueId = function(t) {
for (var r = 0; r < this.skeletons.length; r++)
if (this.skeletons[r].uniqueId === t)
return this.skeletons[r];
return null
}
,
e.prototype.getSkeletonById = function(t) {
for (var r = 0; r < this.skeletons.length; r++)
if (this.skeletons[r].id === t)
return this.skeletons[r];
return null
}
,
e.prototype.getSkeletonByName = function(t) {
for (var r = 0; r < this.skeletons.length; r++)
if (this.skeletons[r].name === t)
return this.skeletons[r];
return null
}
,
e.prototype.getMorphTargetManagerById = function(t) {
for (var r = 0; r < this.morphTargetManagers.length; r++)
if (this.morphTargetManagers[r].uniqueId === t)
return this.morphTargetManagers[r];
return null
}
,
e.prototype.getMorphTargetById = function(t) {
for (var r = 0; r < this.morphTargetManagers.length; ++r)
for (var n = this.morphTargetManagers[r], o = 0; o < n.numTargets; ++o) {
var a = n.getTarget(o);
if (a.id === t)
return a
}
return null
}
,
e.prototype.getMorphTargetByName = function(t) {
for (var r = 0; r < this.morphTargetManagers.length; ++r)
for (var n = this.morphTargetManagers[r], o = 0; o < n.numTargets; ++o) {
var a = n.getTarget(o);
if (a.name === t)
return a
}
return null
}
,
e.prototype.getPostProcessByName = function(t) {
for (var r = 0; r < this.postProcesses.length; ++r) {
var n = this.postProcesses[r];
if (n.name === t)
return n
}
return null
}
,
e.prototype.isActiveMesh = function(t) {
return this._activeMeshes.indexOf(t) !== -1
}
,
Object.defineProperty(e.prototype, "uid", {
get: function() {
return this._uid || (this._uid = Tools.RandomId()),
this._uid
},
enumerable: !1,
configurable: !0
}),
e.prototype.addExternalData = function(t, r) {
return this._externalData || (this._externalData = new StringDictionary),
this._externalData.add(t, r)
}
,
e.prototype.getExternalData = function(t) {
return this._externalData ? this._externalData.get(t) : null
}
,
e.prototype.getOrAddExternalDataWithFactory = function(t, r) {
return this._externalData || (this._externalData = new StringDictionary),
this._externalData.getOrAddWithFactory(t, r)
}
,
e.prototype.removeExternalData = function(t) {
return this._externalData.remove(t)
}
,
e.prototype._evaluateSubMesh = function(t, r, n) {
if (n.hasInstances || n.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || this._skipFrustumClipping || r.alwaysSelectAsActiveMesh || r.subMeshes.length === 1 || t.isInFrustum(this._frustumPlanes)) {
for (var o = 0, a = this._evaluateSubMeshStage; o < a.length; o++) {
var s = a[o];
s.action(r, t)
}
var l = t.getMaterial();
l != null && (l.hasRenderTargetTextures && l.getRenderTargetTextures != null && this._processedMaterials.indexOf(l) === -1 && (this._processedMaterials.push(l),
this._renderTargets.concatWithNoDuplicate(l.getRenderTargetTextures())),
this._renderingManager.dispatch(t, r, l))
}
}
,
e.prototype.freeProcessedMaterials = function() {
this._processedMaterials.dispose()
}
,
Object.defineProperty(e.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
get: function() {
return this._preventFreeActiveMeshesAndRenderingGroups
},
set: function(t) {
this._preventFreeActiveMeshesAndRenderingGroups !== t && (t && (this.freeActiveMeshes(),
this.freeRenderingGroups()),
this._preventFreeActiveMeshesAndRenderingGroups = t)
},
enumerable: !1,
configurable: !0
}),
e.prototype.freeActiveMeshes = function() {
if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._activeMeshes.dispose(),
this.activeCamera && this.activeCamera._activeMeshes && this.activeCamera._activeMeshes.dispose(),
this.activeCameras))
for (var t = 0; t < this.activeCameras.length; t++) {
var r = this.activeCameras[t];
r && r._activeMeshes && r._activeMeshes.dispose()
}
}
,
e.prototype.freeRenderingGroups = function() {
if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._renderingManager && this._renderingManager.freeRenderingGroups(),
this.textures))
for (var t = 0; t < this.textures.length; t++) {
var r = this.textures[t];
r && r.renderList && r.freeRenderingGroups()
}
}
,
e.prototype._isInIntermediateRendering = function() {
return this._intermediateRendering
}
,
e.prototype.freezeActiveMeshes = function(t, r, n, o) {
var a = this;
return t === void 0 && (t = !1),
o === void 0 && (o = !0),
this.executeWhenReady(function() {
if (!a.activeCamera) {
n && n("No active camera found");
return
}
if (a._frustumPlanes || a.setTransformMatrix(a.activeCamera.getViewMatrix(), a.activeCamera.getProjectionMatrix()),
a._evaluateActiveMeshes(),
a._activeMeshesFrozen = !0,
a._skipEvaluateActiveMeshesCompletely = t,
o)
for (var s = 0; s < a._activeMeshes.length; s++)
a._activeMeshes.data[s]._freeze();
r && r()
}),
this
}
,
e.prototype.unfreezeActiveMeshes = function() {
for (var t = 0; t < this.meshes.length; t++) {
var r = this.meshes[t];
r._internalAbstractMeshDataInfo && (r._internalAbstractMeshDataInfo._isActive = !1)
}
for (var t = 0; t < this._activeMeshes.length; t++)
this._activeMeshes.data[t]._unFreeze();
return this._activeMeshesFrozen = !1,
this
}
,
e.prototype._evaluateActiveMeshes = function() {
var t;
if (this._engine.snapshotRendering && this._engine.snapshotRenderingMode === 1) {
this._activeMeshes.length > 0 && ((t = this.activeCamera) === null || t === void 0 || t._activeMeshes.reset(),
this._activeMeshes.reset(),
this._renderingManager.reset(),
this._processedMaterials.reset(),
this._activeParticleSystems.reset(),
this._activeSkeletons.reset(),
this._softwareSkinnedMeshes.reset());
return
}
if (this._activeMeshesFrozen && this._activeMeshes.length) {
if (!this._skipEvaluateActiveMeshesCompletely)
for (var r = this._activeMeshes.length, n = 0; n < r; n++) {
var o = this._activeMeshes.data[n];
o.computeWorldMatrix()
}
if (this._activeParticleSystems)
for (var a = this._activeParticleSystems.length, n = 0; n < a; n++)
this._activeParticleSystems.data[n].animate();
return
}
if (!!this.activeCamera) {
this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),
this.activeCamera._activeMeshes.reset(),
this._activeMeshes.reset(),
this._renderingManager.reset(),
this._processedMaterials.reset(),
this._activeParticleSystems.reset(),
this._activeSkeletons.reset(),
this._softwareSkinnedMeshes.reset();
for (var s = 0, l = this._beforeEvaluateActiveMeshStage; s < l.length; s++) {
var u = l[s];
u.action()
}
for (var c = this.getActiveMeshCandidates(), h = c.length, n = 0; n < h; n++) {
var o = c.data[n];
if (o._internalAbstractMeshDataInfo._currentLODIsUpToDate = !1,
!o.isBlocked && (this._totalVertices.addCount(o.getTotalVertices(), !1),
!(!o.isReady() || !o.isEnabled() || o.scaling.lengthSquared() === 0))) {
o.computeWorldMatrix(),
o.actionManager && o.actionManager.hasSpecificTriggers2(12, 13) && this._meshesForIntersections.pushNoDuplicate(o);
var f = this.customLODSelector ? this.customLODSelector(o, this.activeCamera) : o.getLOD(this.activeCamera);
if (o._internalAbstractMeshDataInfo._currentLOD = f,
o._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0,
f != null && (f !== o && f.billboardMode !== 0 && f.computeWorldMatrix(),
o._preActivate(),
o.isVisible && o.visibility > 0 && (o.layerMask & this.activeCamera.layerMask) !== 0 && (this._skipFrustumClipping || o.alwaysSelectAsActiveMesh || o.isInFrustum(this._frustumPlanes)))) {
this._activeMeshes.push(o),
this.activeCamera._activeMeshes.push(o),
f !== o && f._activate(this._renderId, !1);
for (var d = 0, _ = this._preActiveMeshStage; d < _.length; d++) {
var u = _[d];
u.action(o)
}
o._activate(this._renderId, !1) && (o.isAnInstance ? o._internalAbstractMeshDataInfo._actAsRegularMesh && (f = o) : f._internalAbstractMeshDataInfo._onlyForInstances = !1,
f._internalAbstractMeshDataInfo._isActive = !0,
this._activeMesh(o, f)),
o._postActivate()
}
}
}
if (this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),
this.particlesEnabled) {
this.onBeforeParticlesRenderingObservable.notifyObservers(this);
for (var g = 0; g < this.particleSystems.length; g++) {
var m = this.particleSystems[g];
if (!(!m.isStarted() || !m.emitter)) {
var v = m.emitter;
(!v.position || v.isEnabled()) && (this._activeParticleSystems.push(m),
m.animate(),
this._renderingManager.dispatchParticles(m))
}
}
this.onAfterParticlesRenderingObservable.notifyObservers(this)
}
}
}
,
e.prototype._activeMesh = function(t, r) {
if (this._skeletonsEnabled && r.skeleton !== null && r.skeleton !== void 0 && (this._activeSkeletons.pushNoDuplicate(r.skeleton) && r.skeleton.prepare(),
r.computeBonesUsingShaders || this._softwareSkinnedMeshes.pushNoDuplicate(r)),
r != null && r.subMeshes !== void 0 && r.subMeshes !== null && r.subMeshes.length > 0)
for (var n = this.getActiveSubMeshCandidates(r), o = n.length, a = 0; a < o; a++) {
var s = n.data[a];
this._evaluateSubMesh(s, r, t)
}
}
,
e.prototype.updateTransformMatrix = function(t) {
!this.activeCamera || this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(t))
}
,
e.prototype._bindFrameBuffer = function(t, r) {
r === void 0 && (r = !0),
t && t._multiviewTexture ? t._multiviewTexture._bindFrameBuffer() : t && t.outputRenderTarget ? t.outputRenderTarget._bindFrameBuffer() : this._engine._currentFrameBufferIsDefaultFrameBuffer() || this._engine.restoreDefaultFramebuffer(),
r && this._clearFrameBuffer(t)
}
,
e.prototype._clearFrameBuffer = function(t) {
if (!(t && t._multiviewTexture))
if (t && t.outputRenderTarget) {
var r = t.outputRenderTarget;
r.onClearObservable.hasObservers() ? r.onClearObservable.notifyObservers(this._engine) : r.skipInitialClear || (this._engine.clear(r.clearColor || this.clearColor, !r._cleared, !0, !0),
r._cleared = !0)
} else
this._defaultFrameBufferCleared ? this._engine.clear(null, !1, !0, !0) : (this._defaultFrameBufferCleared = !0,
this._clear())
}
,
e.prototype._renderForCamera = function(t, r, n) {
var o, a, s;
if (n === void 0 && (n = !0),
!(t && t._skipRendering)) {
var l = this._engine;
if (this._activeCamera = t,
!this.activeCamera)
throw new Error("Active camera not set");
l.setViewport(this.activeCamera.viewport),
this.resetCachedMaterial(),
this._renderId++,
!this.prePass && n && this._bindFrameBuffer(this._activeCamera);
var u = this.getEngine().getCaps().multiview && t.outputRenderTarget && t.outputRenderTarget.getViewCount() > 1;
u ? this.setTransformMatrix(t._rigCameras[0].getViewMatrix(), t._rigCameras[0].getProjectionMatrix(), t._rigCameras[1].getViewMatrix(), t._rigCameras[1].getProjectionMatrix()) : this.updateTransformMatrix(),
this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),
this._evaluateActiveMeshes();
for (var c = 0; c < this._softwareSkinnedMeshes.length; c++) {
var h = this._softwareSkinnedMeshes.data[c];
h.applySkeleton(h.skeleton)
}
this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),
t.customRenderTargets && t.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),
r && r.customRenderTargets && r.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(r.customRenderTargets),
this.environmentTexture && this.environmentTexture.isRenderTarget && this._renderTargets.pushNoDuplicate(this.environmentTexture);
for (var f = 0, d = this._gatherActiveCameraRenderTargetsStage; f < d.length; f++) {
var _ = d[f];
_.action(this._renderTargets)
}
var g = !1;
if (this.renderTargetsEnabled) {
if (this._intermediateRendering = !0,
this._renderTargets.length > 0) {
Tools.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
for (var m = 0; m < this._renderTargets.length; m++) {
var v = this._renderTargets.data[m];
if (v._shouldRender()) {
this._renderId++;
var y = v.activeCamera && v.activeCamera !== this.activeCamera;
v.render(y, this.dumpNextRenderTargets),
g = !0
}
}
Tools.EndPerformanceCounter("Render targets", this._renderTargets.length > 0),
this._renderId++
}
for (var b = 0, T = this._cameraDrawRenderTargetStage; b < T.length; b++) {
var _ = T[b];
g = _.action(this.activeCamera) || g
}
this._intermediateRendering = !1
}
this._engine.currentRenderPassId = (s = (a = (o = t.outputRenderTarget) === null || o === void 0 ? void 0 : o.renderPassId) !== null && a !== void 0 ? a : t.renderPassId) !== null && s !== void 0 ? s : 0,
g && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
this.onAfterRenderTargetsRenderObservable.notifyObservers(this),
this.postProcessManager && !t._multiviewTexture && !this.prePass && this.postProcessManager._prepareFrame();
for (var C = 0, A = this._beforeCameraDrawStage; C < A.length; C++) {
var _ = A[C];
_.action(this.activeCamera)
}
this.onBeforeDrawPhaseObservable.notifyObservers(this),
l.snapshotRendering && l.snapshotRenderingMode === 1 && this.finalizeSceneUbo(),
this._renderingManager.render(null, null, !0, !0),
this.onAfterDrawPhaseObservable.notifyObservers(this);
for (var S = 0, P = this._afterCameraDrawStage; S < P.length; S++) {
var _ = P[S];
_.action(this.activeCamera)
}
if (this.postProcessManager && !t._multiviewTexture) {
var R = t.outputRenderTarget ? t.outputRenderTarget.renderTarget : void 0;
this.postProcessManager._finalizeFrame(t.isIntermediate, R)
}
this._renderTargets.reset(),
this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)
}
}
,
e.prototype._processSubCameras = function(t, r) {
if (r === void 0 && (r = !0),
t.cameraRigMode === 0 || t.outputRenderTarget && t.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview) {
this._renderForCamera(t, void 0, r),
this.onAfterRenderCameraObservable.notifyObservers(t);
return
}
if (t._useMultiviewToSingleView)
this._renderMultiviewToSingleView(t);
else {
this.onBeforeCameraRenderObservable.notifyObservers(t);
for (var n = 0; n < t._rigCameras.length; n++)
this._renderForCamera(t._rigCameras[n], t)
}
this._activeCamera = t,
this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix()),
this.onAfterRenderCameraObservable.notifyObservers(t)
}
,
e.prototype._checkIntersections = function() {
for (var t = 0; t < this._meshesForIntersections.length; t++) {
var r = this._meshesForIntersections.data[t];
if (!!r.actionManager)
for (var n = 0; r.actionManager && n < r.actionManager.actions.length; n++) {
var o = r.actionManager.actions[n];
if (o.trigger === 12 || o.trigger === 13) {
var a = o.getTriggerParameter()
, s = a.mesh ? a.mesh : a
, l = s.intersectsMesh(r, a.usePreciseIntersection)
, u = r._intersectionsInProgress.indexOf(s);
l && u === -1 ? o.trigger === 12 ? (o._executeCurrent(ActionEvent.CreateNew(r, void 0, s)),
r._intersectionsInProgress.push(s)) : o.trigger === 13 && r._intersectionsInProgress.push(s) : !l && u > -1 && (o.trigger === 13 && o._executeCurrent(ActionEvent.CreateNew(r, void 0, s)),
(!r.actionManager.hasSpecificTrigger(13, function(c) {
var h = c.mesh ? c.mesh : c;
return s === h
}) || o.trigger === 13) && r._intersectionsInProgress.splice(u, 1))
}
}
}
}
,
e.prototype._advancePhysicsEngineStep = function(t) {}
,
e.prototype._animate = function() {}
,
e.prototype.animate = function() {
if (this._engine.isDeterministicLockStep()) {
var t = Math.max(e.MinDeltaTime, Math.min(this._engine.getDeltaTime(), e.MaxDeltaTime)) + this._timeAccumulator
, r = this._engine.getTimeStep()
, n = 1e3 / r / 1e3
, o = 0
, a = this._engine.getLockstepMaxSteps()
, s = Math.floor(t / r);
for (s = Math.min(s, a); t > 0 && o < s; )
this.onBeforeStepObservable.notifyObservers(this),
this._animationRatio = r * n,
this._animate(),
this.onAfterAnimationsObservable.notifyObservers(this),
this.physicsEnabled && this._advancePhysicsEngineStep(r),
this.onAfterStepObservable.notifyObservers(this),
this._currentStepId++,
o++,
t -= r;
this._timeAccumulator = t < 0 ? 0 : t
} else {
var t = this.useConstantAnimationDeltaTime ? 16 : Math.max(e.MinDeltaTime, Math.min(this._engine.getDeltaTime(), e.MaxDeltaTime));
this._animationRatio = t * (60 / 1e3),
this._animate(),
this.onAfterAnimationsObservable.notifyObservers(this),
this.physicsEnabled && this._advancePhysicsEngineStep(t)
}
}
,
e.prototype._clear = function() {
(this.autoClearDepthAndStencil || this.autoClear) && this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil)
}
,
e.prototype.checkCameraRenderTarget = function(t) {
var r;
if ((t == null ? void 0 : t.outputRenderTarget) && !(t != null && t.isRigCamera) && (t.outputRenderTarget._cleared = !1),
!((r = t == null ? void 0 : t.rigCameras) === null || r === void 0) && r.length)
for (var n = 0; n < t.rigCameras.length; ++n) {
var o = t.rigCameras[n].outputRenderTarget;
o && (o._cleared = !1)
}
}
,
e.prototype.resetDrawCache = function() {
if (!!this.meshes)
for (var t = 0, r = this.meshes; t < r.length; t++) {
var n = r[t];
n.resetDrawCache()
}
}
,
e.prototype.render = function(t, r) {
var n, o, a;
if (t === void 0 && (t = !0),
r === void 0 && (r = !1),
!this.isDisposed) {
this.onReadyObservable.hasObservers() && this._executeWhenReadyTimeoutId === -1 && this._checkIsReady(),
this._frameId++,
this._defaultFrameBufferCleared = !1,
this.checkCameraRenderTarget(this.activeCamera),
!((n = this.activeCameras) === null || n === void 0) && n.length && this.activeCameras.forEach(this.checkCameraRenderTarget),
this._registerTransientComponents(),
this._activeParticles.fetchNewFrame(),
this._totalVertices.fetchNewFrame(),
this._activeIndices.fetchNewFrame(),
this._activeBones.fetchNewFrame(),
this._meshesForIntersections.reset(),
this.resetCachedMaterial(),
this.onBeforeAnimationsObservable.notifyObservers(this),
this.actionManager && this.actionManager.processTrigger(11),
r || this.animate();
for (var s = 0, l = this._beforeCameraUpdateStage; s < l.length; s++) {
var u = l[s];
u.action()
}
if (t) {
if (this.activeCameras && this.activeCameras.length > 0)
for (var c = 0; c < this.activeCameras.length; c++) {
var h = this.activeCameras[c];
if (h.update(),
h.cameraRigMode !== 0)
for (var f = 0; f < h._rigCameras.length; f++)
h._rigCameras[f].update()
}
else if (this.activeCamera && (this.activeCamera.update(),
this.activeCamera.cameraRigMode !== 0))
for (var f = 0; f < this.activeCamera._rigCameras.length; f++)
this.activeCamera._rigCameras[f].update()
}
this.onBeforeRunRegisterBeforeRenderObservable.notifyObservers(this),
this.onBeforeRenderObservable.notifyObservers(this),
this.onAfterRunRegisterBeforeRenderObservable.notifyObservers(this),
this.onBeforeRTT1Observable.notifyObservers(this);
var d = this.getEngine();
this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
var _ = !((o = this.activeCameras) === null || o === void 0) && o.length ? this.activeCameras[0] : this.activeCamera;
if (this.renderTargetsEnabled) {
Tools.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
this._intermediateRendering = !0;
for (var g = 0; g < this.customRenderTargets.length; g++) {
var m = this.customRenderTargets[g];
if (m._shouldRender()) {
if (this._renderId++,
this.activeCamera = m.activeCamera || this.activeCamera,
!this.activeCamera)
throw new Error("Active camera not set");
d.setViewport(this.activeCamera.viewport),
this.updateTransformMatrix(),
m.render(_ !== this.activeCamera, this.dumpNextRenderTargets)
}
}
Tools.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
this._intermediateRendering = !1,
this._renderId++
}
this._engine.currentRenderPassId = (a = _ == null ? void 0 : _.renderPassId) !== null && a !== void 0 ? a : 0,
this.activeCamera = _,
this._activeCamera && this._activeCamera.cameraRigMode !== 22 && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
for (var v = 0, y = this._beforeClearStage; v < y.length; v++) {
var u = y[v];
u.action()
}
this._clearFrameBuffer(this.activeCamera);
for (var b = 0, T = this._gatherRenderTargetsStage; b < T.length; b++) {
var u = T[b];
u.action(this._renderTargets)
}
if (this.onAfterRTT1Observable.notifyObservers(this),
this.activeCameras && this.activeCameras.length > 0)
for (var c = 0; c < this.activeCameras.length; c++)
this._processSubCameras(this.activeCameras[c], c > 0);
else {
if (!this.activeCamera)
throw new Error("No camera defined");
this._processSubCameras(this.activeCamera, !1)
}
this.onBeforeRunRegisterAfterRenderObservable.notifyObservers(this),
this._checkIntersections();
for (var C = 0, A = this._afterRenderStage; C < A.length; C++) {
var u = A[C];
u.action()
}
if (this.afterRender && this.afterRender(),
this.onAfterRenderObservable.notifyObservers(this),
this.onAfterRunRegisterAfterRenderObservable.notifyObservers(this),
this._toBeDisposed.length) {
for (var f = 0; f < this._toBeDisposed.length; f++) {
var S = this._toBeDisposed[f];
S && S.dispose()
}
this._toBeDisposed = []
}
this.dumpNextRenderTargets && (this.dumpNextRenderTargets = !1),
this._activeBones.addCount(0, !0),
this._activeIndices.addCount(0, !0),
this._activeParticles.addCount(0, !0),
this._engine.restoreDefaultFramebuffer()
}
}
,
e.prototype.freezeMaterials = function() {
for (var t = 0; t < this.materials.length; t++)
this.materials[t].freeze()
}
,
e.prototype.unfreezeMaterials = function() {
for (var t = 0; t < this.materials.length; t++)
this.materials[t].unfreeze()
}
,
e.prototype.dispose = function() {
var t;
if (!this.isDisposed) {
this.beforeRender = null,
this.afterRender = null,
this.metadata = null,
this.skeletons = [],
this.morphTargetManagers = [],
this._transientComponents = [],
this._isReadyForMeshStage.clear(),
this._beforeEvaluateActiveMeshStage.clear(),
this._evaluateSubMeshStage.clear(),
this._preActiveMeshStage.clear(),
this._cameraDrawRenderTargetStage.clear(),
this._beforeCameraDrawStage.clear(),
this._beforeRenderTargetDrawStage.clear(),
this._beforeRenderingGroupDrawStage.clear(),
this._beforeRenderingMeshStage.clear(),
this._afterRenderingMeshStage.clear(),
this._afterRenderingGroupDrawStage.clear(),
this._afterCameraDrawStage.clear(),
this._afterRenderTargetDrawStage.clear(),
this._afterRenderStage.clear(),
this._beforeCameraUpdateStage.clear(),
this._beforeClearStage.clear(),
this._gatherRenderTargetsStage.clear(),
this._gatherActiveCameraRenderTargetsStage.clear(),
this._pointerMoveStage.clear(),
this._pointerDownStage.clear(),
this._pointerUpStage.clear();
for (var r = 0, n = this._components; r < n.length; r++) {
var o = n[r];
o.dispose()
}
this.importedMeshesFiles = new Array,
this.stopAllAnimations && this.stopAllAnimations(),
this.resetCachedMaterial(),
this.activeCamera && (this.activeCamera._activeMeshes.dispose(),
this.activeCamera = null),
this._activeMeshes.dispose(),
this._renderingManager.dispose(),
this._processedMaterials.dispose(),
this._activeParticleSystems.dispose(),
this._activeSkeletons.dispose(),
this._softwareSkinnedMeshes.dispose(),
this._renderTargets.dispose(),
this._registeredForLateAnimationBindings.dispose(),
this._meshesForIntersections.dispose(),
this._toBeDisposed = [];
for (var a = 0, s = this._activeRequests; a < s.length; a++) {
var l = s[a];
l.abort()
}
this.onBeforeRunRegisterBeforeRenderObservable.clear(),
this.onAfterRunRegisterBeforeRenderObservable.clear(),
this.onBeforeRTT1Observable.clear(),
this.onAfterRTT1Observable.clear(),
this.onBeforeRunRegisterAfterRenderObservable.clear(),
this.onAfterRunRegisterAfterRenderObservable.clear(),
this.onDisposeObservable.notifyObservers(this),
this.onDisposeObservable.clear(),
this.onBeforeRenderObservable.clear(),
this.onAfterRenderObservable.clear(),
this.onBeforeRenderTargetsRenderObservable.clear(),
this.onAfterRenderTargetsRenderObservable.clear(),
this.onAfterStepObservable.clear(),
this.onBeforeStepObservable.clear(),
this.onBeforeActiveMeshesEvaluationObservable.clear(),
this.onAfterActiveMeshesEvaluationObservable.clear(),
this.onBeforeParticlesRenderingObservable.clear(),
this.onAfterParticlesRenderingObservable.clear(),
this.onBeforeDrawPhaseObservable.clear(),
this.onAfterDrawPhaseObservable.clear(),
this.onBeforeAnimationsObservable.clear(),
this.onAfterAnimationsObservable.clear(),
this.onDataLoadedObservable.clear(),
this.onBeforeRenderingGroupObservable.clear(),
this.onAfterRenderingGroupObservable.clear(),
this.onMeshImportedObservable.clear(),
this.onBeforeCameraRenderObservable.clear(),
this.onAfterCameraRenderObservable.clear(),
this.onReadyObservable.clear(),
this.onNewCameraAddedObservable.clear(),
this.onCameraRemovedObservable.clear(),
this.onNewLightAddedObservable.clear(),
this.onLightRemovedObservable.clear(),
this.onNewGeometryAddedObservable.clear(),
this.onGeometryRemovedObservable.clear(),
this.onNewTransformNodeAddedObservable.clear(),
this.onTransformNodeRemovedObservable.clear(),
this.onNewMeshAddedObservable.clear(),
this.onMeshRemovedObservable.clear(),
this.onNewSkeletonAddedObservable.clear(),
this.onSkeletonRemovedObservable.clear(),
this.onNewMaterialAddedObservable.clear(),
this.onNewMultiMaterialAddedObservable.clear(),
this.onMaterialRemovedObservable.clear(),
this.onMultiMaterialRemovedObservable.clear(),
this.onNewTextureAddedObservable.clear(),
this.onTextureRemovedObservable.clear(),
this.onPrePointerObservable.clear(),
this.onPointerObservable.clear(),
this.onPreKeyboardObservable.clear(),
this.onKeyboardObservable.clear(),
this.onActiveCameraChanged.clear(),
this.onComputePressureChanged.clear(),
(t = this._computePressureObserver) === null || t === void 0 || t.unobserve(),
this._computePressureObserver = void 0,
this.detachControl();
var u = this._engine.getInputElement();
if (u) {
var c;
for (c = 0; c < this.cameras.length; c++)
this.cameras[c].detachControl()
}
for (; this.animationGroups.length; )
this.animationGroups[0].dispose();
for (; this.lights.length; )
this.lights[0].dispose();
for (; this.meshes.length; )
this.meshes[0].dispose(!0);
for (; this.transformNodes.length; )
this.transformNodes[0].dispose(!0);
for (; this.cameras.length; )
this.cameras[0].dispose();
for (this._defaultMaterial && this._defaultMaterial.dispose(); this.multiMaterials.length; )
this.multiMaterials[0].dispose();
for (; this.materials.length; )
this.materials[0].dispose();
for (; this.particleSystems.length; )
this.particleSystems[0].dispose();
for (; this.postProcesses.length; )
this.postProcesses[0].dispose();
for (; this.textures.length; )
this.textures[0].dispose();
for (; this.morphTargetManagers.length; )
this.morphTargetManagers[0].dispose();
this._sceneUbo.dispose(),
this._multiviewSceneUbo && this._multiviewSceneUbo.dispose(),
this.postProcessManager.dispose(),
c = this._engine.scenes.indexOf(this),
c > -1 && this._engine.scenes.splice(c, 1),
EngineStore._LastCreatedScene === this && (this._engine.scenes.length > 0 ? EngineStore._LastCreatedScene = this._engine.scenes[this._engine.scenes.length - 1] : EngineStore._LastCreatedScene = null),
c = this._engine._virtualScenes.indexOf(this),
c > -1 && this._engine._virtualScenes.splice(c, 1),
this._engine.wipeCaches(!0),
this._isDisposed = !0
}
}
,
Object.defineProperty(e.prototype, "isDisposed", {
get: function() {
return this._isDisposed
},
enumerable: !1,
configurable: !0
}),
e.prototype.clearCachedVertexData = function() {
for (var t = 0; t < this.meshes.length; t++) {
var r = this.meshes[t]
, n = r.geometry;
n && n.clearCachedData()
}
}
,
e.prototype.cleanCachedTextureBuffer = function() {
for (var t = 0, r = this.textures; t < r.length; t++) {
var n = r[t]
, o = n._buffer;
o && (n._buffer = null)
}
}
,
e.prototype.getWorldExtends = function(t) {
var r = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
, n = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
return t = t || function() {
return !0
}
,
this.meshes.filter(t).forEach(function(o) {
if (o.computeWorldMatrix(!0),
!(!o.subMeshes || o.subMeshes.length === 0 || o.infiniteDistance)) {
var a = o.getBoundingInfo()
, s = a.boundingBox.minimumWorld
, l = a.boundingBox.maximumWorld;
Vector3.CheckExtends(s, r, n),
Vector3.CheckExtends(l, r, n)
}
}),
{
min: r,
max: n
}
}
,
e.prototype.createPickingRay = function(t, r, n, o, a) {
throw _WarnImport("Ray")
}
,
e.prototype.createPickingRayToRef = function(t, r, n, o, a, s) {
throw _WarnImport("Ray")
}
,
e.prototype.createPickingRayInCameraSpace = function(t, r, n) {
throw _WarnImport("Ray")
}
,
e.prototype.createPickingRayInCameraSpaceToRef = function(t, r, n, o) {
throw _WarnImport("Ray")
}
,
e.prototype.pick = function(t, r, n, o, a, s) {
var l = new PickingInfo;
return l._pickingUnavailable = !0,
l
}
,
e.prototype.pickWithBoundingInfo = function(t, r, n, o, a) {
var s = new PickingInfo;
return s._pickingUnavailable = !0,
s
}
,
e.prototype.pickWithRay = function(t, r, n, o) {
throw _WarnImport("Ray")
}
,
e.prototype.multiPick = function(t, r, n, o, a) {
throw _WarnImport("Ray")
}
,
e.prototype.multiPickWithRay = function(t, r, n) {
throw _WarnImport("Ray")
}
,
e.prototype.setPointerOverMesh = function(t, r, n) {
this._inputManager.setPointerOverMesh(t, r, n)
}
,
e.prototype.getPointerOverMesh = function() {
return this._inputManager.getPointerOverMesh()
}
,
e.prototype._rebuildGeometries = function() {
for (var t = 0, r = this.geometries; t < r.length; t++) {
var n = r[t];
n._rebuild()
}
for (var o = 0, a = this.meshes; o < a.length; o++) {
var s = a[o];
s._rebuild()
}
this.postProcessManager && this.postProcessManager._rebuild();
for (var l = 0, u = this._components; l < u.length; l++) {
var c = u[l];
c.rebuild()
}
for (var h = 0, f = this.particleSystems; h < f.length; h++) {
var d = f[h];
d.rebuild()
}
if (this.spriteManagers)
for (var _ = 0, g = this.spriteManagers; _ < g.length; _++) {
var m = g[_];
m.rebuild()
}
}
,
e.prototype._rebuildTextures = function() {
for (var t = 0, r = this.textures; t < r.length; t++) {
var n = r[t];
n._rebuild()
}
this.markAllMaterialsAsDirty(1)
}
,
e.prototype._getByTags = function(t, r, n) {
if (r === void 0)
return t;
var o = [];
n = n || function(l) {}
;
for (var a in t) {
var s = t[a];
Tags && Tags.MatchesQuery(s, r) && (o.push(s),
n(s))
}
return o
}
,
e.prototype.getMeshesByTags = function(t, r) {
return this._getByTags(this.meshes, t, r)
}
,
e.prototype.getCamerasByTags = function(t, r) {
return this._getByTags(this.cameras, t, r)
}
,
e.prototype.getLightsByTags = function(t, r) {
return this._getByTags(this.lights, t, r)
}
,
e.prototype.getMaterialByTags = function(t, r) {
return this._getByTags(this.materials, t, r).concat(this._getByTags(this.multiMaterials, t, r))
}
,
e.prototype.getTransformNodesByTags = function(t, r) {
return this._getByTags(this.transformNodes, t, r)
}
,
e.prototype.setRenderingOrder = function(t, r, n, o) {
r === void 0 && (r = null),
n === void 0 && (n = null),
o === void 0 && (o = null),
this._renderingManager.setRenderingOrder(t, r, n, o)
}
,
e.prototype.setRenderingAutoClearDepthStencil = function(t, r, n, o) {
n === void 0 && (n = !0),
o === void 0 && (o = !0),
this._renderingManager.setRenderingAutoClearDepthStencil(t, r, n, o)
}
,
e.prototype.getAutoClearDepthStencilSetup = function(t) {
return this._renderingManager.getAutoClearDepthStencilSetup(t)
}
,
Object.defineProperty(e.prototype, "blockMaterialDirtyMechanism", {
get: function() {
return this._blockMaterialDirtyMechanism
},
set: function(t) {
this._blockMaterialDirtyMechanism !== t && (this._blockMaterialDirtyMechanism = t,
t || this.markAllMaterialsAsDirty(63))
},
enumerable: !1,
configurable: !0
}),
e.prototype.markAllMaterialsAsDirty = function(t, r) {
if (!this._blockMaterialDirtyMechanism)
for (var n = 0, o = this.materials; n < o.length; n++) {
var a = o[n];
r && !r(a) || a.markAsDirty(t)
}
}
,
e.prototype._loadFile = function(t, r, n, o, a, s, l) {
var u = this
, c = LoadFile(t, r, n, o ? this.offlineProvider : void 0, a, s, l);
return this._activeRequests.push(c),
c.onCompleteObservable.add(function(h) {
u._activeRequests.splice(u._activeRequests.indexOf(h), 1)
}),
c
}
,
e.prototype._loadFileAsync = function(t, r, n, o, a) {
var s = this;
return new Promise(function(l, u) {
s._loadFile(t, function(c) {
l(c)
}, r, n, o, function(c, h) {
u(h)
}, a)
}
)
}
,
e.prototype._requestFile = function(t, r, n, o, a, s, l) {
var u = this
, c = RequestFile(t, r, n, o ? this.offlineProvider : void 0, a, s, l);
return this._activeRequests.push(c),
c.onCompleteObservable.add(function(h) {
u._activeRequests.splice(u._activeRequests.indexOf(h), 1)
}),
c
}
,
e.prototype._requestFileAsync = function(t, r, n, o, a) {
var s = this;
return new Promise(function(l, u) {
s._requestFile(t, function(c) {
l(c)
}, r, n, o, function(c) {
u(c)
}, a)
}
)
}
,
e.prototype._readFile = function(t, r, n, o, a) {
var s = this
, l = ReadFile(t, r, n, o, a);
return this._activeRequests.push(l),
l.onCompleteObservable.add(function(u) {
s._activeRequests.splice(s._activeRequests.indexOf(u), 1)
}),
l
}
,
e.prototype._readFileAsync = function(t, r, n) {
var o = this;
return new Promise(function(a, s) {
o._readFile(t, function(l) {
a(l)
}, r, n, function(l) {
s(l)
})
}
)
}
,
e.prototype.getPerfCollector = function() {
throw _WarnImport("performanceViewerSceneExtension")
}
,
e.FOGMODE_NONE = 0,
e.FOGMODE_EXP = 1,
e.FOGMODE_EXP2 = 2,
e.FOGMODE_LINEAR = 3,
e.MinDeltaTime = 1,
e.MaxDeltaTime = 1e3,
e
}(AbstractScene);
_injectLTSScene(Scene);
var PerformanceMonitor = function() {
function i(e) {
e === void 0 && (e = 30),
this._enabled = !0,
this._rollingFrameTime = new RollingAverage(e)
}
return i.prototype.sampleFrame = function(e) {
if (e === void 0 && (e = PrecisionDate.Now),
!!this._enabled) {
if (this._lastFrameTimeMs != null) {
var t = e - this._lastFrameTimeMs;
this._rollingFrameTime.add(t)
}
this._lastFrameTimeMs = e
}
}
,
Object.defineProperty(i.prototype, "averageFrameTime", {
get: function() {
return this._rollingFrameTime.average
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "averageFrameTimeVariance", {
get: function() {
return this._rollingFrameTime.variance
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "instantaneousFrameTime", {
get: function() {
return this._rollingFrameTime.history(0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "averageFPS", {
get: function() {
return 1e3 / this._rollingFrameTime.average
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "instantaneousFPS", {
get: function() {
var e = this._rollingFrameTime.history(0);
return e === 0 ? 0 : 1e3 / e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isSaturated", {
get: function() {
return this._rollingFrameTime.isSaturated()
},
enumerable: !1,
configurable: !0
}),
i.prototype.enable = function() {
this._enabled = !0
}
,
i.prototype.disable = function() {
this._enabled = !1,
this._lastFrameTimeMs = null
}
,
Object.defineProperty(i.prototype, "isEnabled", {
get: function() {
return this._enabled
},
enumerable: !1,
configurable: !0
}),
i.prototype.reset = function() {
this._lastFrameTimeMs = null,
this._rollingFrameTime.reset()
}
,
i
}()
, RollingAverage = function() {
function i(e) {
this._samples = new Array(e),
this.reset()
}
return i.prototype.add = function(e) {
var t;
if (this.isSaturated()) {
var r = this._samples[this._pos];
t = r - this.average,
this.average -= t / (this._sampleCount - 1),
this._m2 -= t * (r - this.average)
} else
this._sampleCount++;
t = e - this.average,
this.average += t / this._sampleCount,
this._m2 += t * (e - this.average),
this.variance = this._m2 / (this._sampleCount - 1),
this._samples[this._pos] = e,
this._pos++,
this._pos %= this._samples.length
}
,
i.prototype.history = function(e) {
if (e >= this._sampleCount || e >= this._samples.length)
return 0;
var t = this._wrapPosition(this._pos - 1);
return this._samples[this._wrapPosition(t - e)]
}
,
i.prototype.isSaturated = function() {
return this._sampleCount >= this._samples.length
}
,
i.prototype.reset = function() {
this.average = 0,
this.variance = 0,
this._sampleCount = 0,
this._pos = 0,
this._m2 = 0
}
,
i.prototype._wrapPosition = function(e) {
var t = this._samples.length;
return (e % t + t) % t
}
,
i
}();
ThinEngine.prototype.setAlphaConstants = function(i, e, t, r) {
this._alphaState.setAlphaBlendConstants(i, e, t, r)
}
;
ThinEngine.prototype.setAlphaMode = function(i, e) {
if (e === void 0 && (e = !1),
this._alphaMode !== i) {
switch (i) {
case 0:
this._alphaState.alphaBlend = !1;
break;
case 7:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE),
this._alphaState.alphaBlend = !0;
break;
case 8:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
this._alphaState.alphaBlend = !0;
break;
case 2:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE),
this._alphaState.alphaBlend = !0;
break;
case 6:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
this._alphaState.alphaBlend = !0;
break;
case 1:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
this._alphaState.alphaBlend = !0;
break;
case 3:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE),
this._alphaState.alphaBlend = !0;
break;
case 4:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE),
this._alphaState.alphaBlend = !0;
break;
case 5:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE),
this._alphaState.alphaBlend = !0;
break;
case 9:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA),
this._alphaState.alphaBlend = !0;
break;
case 10:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
this._alphaState.alphaBlend = !0;
break;
case 11:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ONE),
this._alphaState.alphaBlend = !0;
break;
case 12:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ZERO),
this._alphaState.alphaBlend = !0;
break;
case 13:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE_MINUS_DST_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA),
this._alphaState.alphaBlend = !0;
break;
case 14:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
this._alphaState.alphaBlend = !0;
break;
case 15:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ZERO),
this._alphaState.alphaBlend = !0;
break;
case 16:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ZERO, this._gl.ONE),
this._alphaState.alphaBlend = !0;
break;
case 17:
this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
this._alphaState.alphaBlend = !0;
break
}
e || (this.depthCullingState.depthMask = i === 0),
this._alphaMode = i
}
}
;
ThinEngine.prototype.getAlphaMode = function() {
return this._alphaMode
}
;
ThinEngine.prototype.setAlphaEquation = function(i) {
if (this._alphaEquation !== i) {
switch (i) {
case 0:
this._alphaState.setAlphaEquationParameters(32774, 32774);
break;
case 1:
this._alphaState.setAlphaEquationParameters(32778, 32778);
break;
case 2:
this._alphaState.setAlphaEquationParameters(32779, 32779);
break;
case 3:
this._alphaState.setAlphaEquationParameters(32776, 32776);
break;
case 4:
this._alphaState.setAlphaEquationParameters(32775, 32775);
break;
case 5:
this._alphaState.setAlphaEquationParameters(32775, 32774);
break
}
this._alphaEquation = i
}
}
;
ThinEngine.prototype.getAlphaEquation = function() {
return this._alphaEquation
}
;
function allocateAndCopyTypedBuffer(i, e, t, r) {
switch (t === void 0 && (t = !1),
i) {
case 3:
{
var n = e instanceof ArrayBuffer ? new Int8Array(e) : new Int8Array(e);
return r && n.set(new Int8Array(r)),
n
}
case 0:
{
var o = e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e);
return r && o.set(new Uint8Array(r)),
o
}
case 4:
{
var a = e instanceof ArrayBuffer ? new Int16Array(e) : new Int16Array(t ? e / 2 : e);
return r && a.set(new Int16Array(r)),
a
}
case 5:
case 8:
case 9:
case 10:
case 2:
{
var s = e instanceof ArrayBuffer ? new Uint16Array(e) : new Uint16Array(t ? e / 2 : e);
return r && s.set(new Uint16Array(r)),
s
}
case 6:
{
var l = e instanceof ArrayBuffer ? new Int32Array(e) : new Int32Array(t ? e / 4 : e);
return r && l.set(new Int32Array(r)),
l
}
case 7:
case 11:
case 12:
case 13:
case 14:
case 15:
{
var u = e instanceof ArrayBuffer ? new Uint32Array(e) : new Uint32Array(t ? e / 4 : e);
return r && u.set(new Uint32Array(r)),
u
}
case 1:
{
var c = e instanceof ArrayBuffer ? new Float32Array(e) : new Float32Array(t ? e / 4 : e);
return r && c.set(new Float32Array(r)),
c
}
}
var h = e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e);
return r && h.set(new Uint8Array(r)),
h
}
ThinEngine.prototype._readTexturePixelsSync = function(i, e, t, r, n, o, a, s) {
var l, u;
r === void 0 && (r = -1),
n === void 0 && (n = 0),
o === void 0 && (o = null),
a === void 0 && (a = !0),
s === void 0 && (s = !1);
var c = this._gl;
if (!c)
throw new Error("Engine does not have gl rendering context.");
if (!this._dummyFramebuffer) {
var h = c.createFramebuffer();
if (!h)
throw new Error("Unable to create dummy framebuffer");
this._dummyFramebuffer = h
}
c.bindFramebuffer(c.FRAMEBUFFER, this._dummyFramebuffer),
r > -1 ? c.framebufferTexture2D(c.FRAMEBUFFER, c.COLOR_ATTACHMENT0, c.TEXTURE_CUBE_MAP_POSITIVE_X + r, (l = i._hardwareTexture) === null || l === void 0 ? void 0 : l.underlyingResource, n) : c.framebufferTexture2D(c.FRAMEBUFFER, c.COLOR_ATTACHMENT0, c.TEXTURE_2D, (u = i._hardwareTexture) === null || u === void 0 ? void 0 : u.underlyingResource, n);
var f = i.type !== void 0 ? this._getWebGLTextureType(i.type) : c.UNSIGNED_BYTE;
if (s)
o || (o = allocateAndCopyTypedBuffer(i.type, 4 * e * t));
else
switch (f) {
case c.UNSIGNED_BYTE:
o || (o = new Uint8Array(4 * e * t)),
f = c.UNSIGNED_BYTE;
break;
default:
o || (o = new Float32Array(4 * e * t)),
f = c.FLOAT;
break
}
return a && this.flushFramebuffer(),
c.readPixels(0, 0, e, t, c.RGBA, f, o),
c.bindFramebuffer(c.FRAMEBUFFER, this._currentFramebuffer),
o
}
;
ThinEngine.prototype._readTexturePixels = function(i, e, t, r, n, o, a, s) {
return r === void 0 && (r = -1),
n === void 0 && (n = 0),
o === void 0 && (o = null),
a === void 0 && (a = !0),
s === void 0 && (s = !1),
Promise.resolve(this._readTexturePixelsSync(i, e, t, r, n, o, a, s))
}
;
ThinEngine.prototype.updateDynamicIndexBuffer = function(i, e, t) {
this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null,
this.bindIndexBuffer(i);
var r;
e instanceof Uint16Array || e instanceof Uint32Array ? r = e : r = i.is32Bits ? new Uint32Array(e) : new Uint16Array(e),
this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, r, this._gl.DYNAMIC_DRAW),
this._resetIndexBufferBinding()
}
;
ThinEngine.prototype.updateDynamicVertexBuffer = function(i, e, t, r) {
this.bindArrayBuffer(i),
t === void 0 && (t = 0);
var n = e.length || e.byteLength;
r === void 0 || r >= n && t === 0 ? e instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, t, new Float32Array(e)) : this._gl.bufferSubData(this._gl.ARRAY_BUFFER, t, e) : e instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(e).subarray(t, t + r)) : (e instanceof ArrayBuffer ? e = new Uint8Array(e,t,r) : e = new Uint8Array(e.buffer,e.byteOffset + t,r),
this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, e)),
this._resetVertexBufferBinding()
}
;
var Engine = function(i) {
__extends(e, i);
function e(t, r, n, o) {
o === void 0 && (o = !1);
var a = i.call(this, t, r, n, o) || this;
if (a.enableOfflineSupport = !1,
a.disableManifestCheck = !1,
a.scenes = new Array,
a._virtualScenes = new Array,
a.onNewSceneAddedObservable = new Observable,
a.postProcesses = new Array,
a.isPointerLock = !1,
a.onResizeObservable = new Observable,
a.onCanvasBlurObservable = new Observable,
a.onCanvasFocusObservable = new Observable,
a.onCanvasPointerOutObservable = new Observable,
a.onBeginFrameObservable = new Observable,
a.customAnimationFrameRequester = null,
a.onEndFrameObservable = new Observable,
a.onBeforeShaderCompilationObservable = new Observable,
a.onAfterShaderCompilationObservable = new Observable,
a._deterministicLockstep = !1,
a._lockstepMaxSteps = 4,
a._timeStep = 1 / 60,
a._fps = 60,
a._deltaTime = 0,
a._drawCalls = new PerfCounter,
a.canvasTabIndex = 1,
a.disablePerformanceMonitorInBackground = !1,
a._performanceMonitor = new PerformanceMonitor,
a._compatibilityMode = !0,
a.currentRenderPassId = 0,
a._renderPassNames = ["main"],
e.Instances.push(a),
!t)
return a;
if (a._features.supportRenderPasses = !0,
n = a._creationOptions,
t.getContext) {
var s = t;
if (a._sharedInit(s, !!n.doNotHandleTouchAction, n.audioEngine),
IsWindowObjectExist()) {
var l = document;
a._onFullscreenChange = function() {
l.fullscreen !== void 0 ? a.isFullscreen = l.fullscreen : l.mozFullScreen !== void 0 ? a.isFullscreen = l.mozFullScreen : l.webkitIsFullScreen !== void 0 ? a.isFullscreen = l.webkitIsFullScreen : l.msIsFullScreen !== void 0 && (a.isFullscreen = l.msIsFullScreen),
a.isFullscreen && a._pointerLockRequested && s && e._RequestPointerlock(s)
}
,
document.addEventListener("fullscreenchange", a._onFullscreenChange, !1),
document.addEventListener("mozfullscreenchange", a._onFullscreenChange, !1),
document.addEventListener("webkitfullscreenchange", a._onFullscreenChange, !1),
document.addEventListener("msfullscreenchange", a._onFullscreenChange, !1),
a._onPointerLockChange = function() {
a.isPointerLock = l.mozPointerLockElement === s || l.webkitPointerLockElement === s || l.msPointerLockElement === s || l.pointerLockElement === s
}
,
document.addEventListener("pointerlockchange", a._onPointerLockChange, !1),
document.addEventListener("mspointerlockchange", a._onPointerLockChange, !1),
document.addEventListener("mozpointerlockchange", a._onPointerLockChange, !1),
document.addEventListener("webkitpointerlockchange", a._onPointerLockChange, !1),
!e.audioEngine && n.audioEngine && e.AudioEngineFactory && (e.audioEngine = e.AudioEngineFactory(a.getRenderingCanvas(), a.getAudioContext(), a.getAudioDestination()))
}
a._connectVREvents(),
a.enableOfflineSupport = e.OfflineProviderFactory !== void 0,
a._deterministicLockstep = !!n.deterministicLockstep,
a._lockstepMaxSteps = n.lockstepMaxSteps || 0,
a._timeStep = n.timeStep || 1 / 60
}
return a._prepareVRComponent(),
n.autoEnableWebVR && a.initWebVR(),
a
}
return Object.defineProperty(e, "NpmPackage", {
get: function() {
return ThinEngine.NpmPackage
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "Version", {
get: function() {
return ThinEngine.Version
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "Instances", {
get: function() {
return EngineStore.Instances
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "LastCreatedEngine", {
get: function() {
return EngineStore.LastCreatedEngine
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "LastCreatedScene", {
get: function() {
return EngineStore.LastCreatedScene
},
enumerable: !1,
configurable: !0
}),
e.prototype.createImageBitmap = function(t, r) {
return createImageBitmap(t, r)
}
,
e.prototype.resizeImageBitmap = function(t, r, n) {
var o = this.createCanvas(r, n)
, a = o.getContext("2d");
if (!a)
throw new Error("Unable to get 2d context for resizeImageBitmap");
a.drawImage(t, 0, 0);
var s = a.getImageData(0, 0, r, n).data;
return s
}
,
e.MarkAllMaterialsAsDirty = function(t, r) {
for (var n = 0; n < e.Instances.length; n++)
for (var o = e.Instances[n], a = 0; a < o.scenes.length; a++)
o.scenes[a].markAllMaterialsAsDirty(t, r)
}
,
e.DefaultLoadingScreenFactory = function(t) {
throw _WarnImport("LoadingScreen")
}
,
Object.defineProperty(e.prototype, "_supportsHardwareTextureRescaling", {
get: function() {
return !!e._RescalePostProcessFactory
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "performanceMonitor", {
get: function() {
return this._performanceMonitor
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "compatibilityMode", {
get: function() {
return this._compatibilityMode
},
set: function(t) {
this._compatibilityMode = !0
},
enumerable: !1,
configurable: !0
}),
e.prototype.getInputElement = function() {
return this._renderingCanvas
}
,
e.prototype._sharedInit = function(t, r, n) {
var o = this;
if (i.prototype._sharedInit.call(this, t, r, n),
this._onCanvasFocus = function() {
o.onCanvasFocusObservable.notifyObservers(o)
}
,
this._onCanvasBlur = function() {
o.onCanvasBlurObservable.notifyObservers(o)
}
,
t.addEventListener("focus", this._onCanvasFocus),
t.addEventListener("blur", this._onCanvasBlur),
this._onBlur = function() {
o.disablePerformanceMonitorInBackground && o._performanceMonitor.disable(),
o._windowIsBackground = !0
}
,
this._onFocus = function() {
o.disablePerformanceMonitorInBackground && o._performanceMonitor.enable(),
o._windowIsBackground = !1
}
,
this._onCanvasPointerOut = function(s) {
document.elementFromPoint(s.clientX, s.clientY) !== t && o.onCanvasPointerOutObservable.notifyObservers(s)
}
,
IsWindowObjectExist()) {
var a = this.getHostWindow();
a && (a.addEventListener("blur", this._onBlur),
a.addEventListener("focus", this._onFocus))
}
t.addEventListener("pointerout", this._onCanvasPointerOut),
r || this._disableTouchAction(),
!e.audioEngine && n && e.AudioEngineFactory && (e.audioEngine = e.AudioEngineFactory(this.getRenderingCanvas(), this.getAudioContext(), this.getAudioDestination()))
}
,
e.prototype.getAspectRatio = function(t, r) {
r === void 0 && (r = !1);
var n = t.viewport;
return this.getRenderWidth(r) * n.width / (this.getRenderHeight(r) * n.height)
}
,
e.prototype.getScreenAspectRatio = function() {
return this.getRenderWidth(!0) / this.getRenderHeight(!0)
}
,
e.prototype.getRenderingCanvasClientRect = function() {
return this._renderingCanvas ? this._renderingCanvas.getBoundingClientRect() : null
}
,
e.prototype.getInputElementClientRect = function() {
return this._renderingCanvas ? this.getInputElement().getBoundingClientRect() : null
}
,
e.prototype.isDeterministicLockStep = function() {
return this._deterministicLockstep
}
,
e.prototype.getLockstepMaxSteps = function() {
return this._lockstepMaxSteps
}
,
e.prototype.getTimeStep = function() {
return this._timeStep * 1e3
}
,
e.prototype.generateMipMapsForCubemap = function(t, r) {
if (r === void 0 && (r = !0),
t.generateMipMaps) {
var n = this._gl;
this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, t, !0),
n.generateMipmap(n.TEXTURE_CUBE_MAP),
r && this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, null)
}
}
,
e.prototype.getDepthBuffer = function() {
return this._depthCullingState.depthTest
}
,
e.prototype.setDepthBuffer = function(t) {
this._depthCullingState.depthTest = t
}
,
e.prototype.getDepthWrite = function() {
return this._depthCullingState.depthMask
}
,
e.prototype.setDepthWrite = function(t) {
this._depthCullingState.depthMask = t
}
,
e.prototype.getStencilBuffer = function() {
return this._stencilState.stencilTest
}
,
e.prototype.setStencilBuffer = function(t) {
this._stencilState.stencilTest = t
}
,
e.prototype.getStencilMask = function() {
return this._stencilState.stencilMask
}
,
e.prototype.setStencilMask = function(t) {
this._stencilState.stencilMask = t
}
,
e.prototype.getStencilFunction = function() {
return this._stencilState.stencilFunc
}
,
e.prototype.getStencilFunctionReference = function() {
return this._stencilState.stencilFuncRef
}
,
e.prototype.getStencilFunctionMask = function() {
return this._stencilState.stencilFuncMask
}
,
e.prototype.setStencilFunction = function(t) {
this._stencilState.stencilFunc = t
}
,
e.prototype.setStencilFunctionReference = function(t) {
this._stencilState.stencilFuncRef = t
}
,
e.prototype.setStencilFunctionMask = function(t) {
this._stencilState.stencilFuncMask = t
}
,
e.prototype.getStencilOperationFail = function() {
return this._stencilState.stencilOpStencilFail
}
,
e.prototype.getStencilOperationDepthFail = function() {
return this._stencilState.stencilOpDepthFail
}
,
e.prototype.getStencilOperationPass = function() {
return this._stencilState.stencilOpStencilDepthPass
}
,
e.prototype.setStencilOperationFail = function(t) {
this._stencilState.stencilOpStencilFail = t
}
,
e.prototype.setStencilOperationDepthFail = function(t) {
this._stencilState.stencilOpDepthFail = t
}
,
e.prototype.setStencilOperationPass = function(t) {
this._stencilState.stencilOpStencilDepthPass = t
}
,
e.prototype.setDitheringState = function(t) {
t ? this._gl.enable(this._gl.DITHER) : this._gl.disable(this._gl.DITHER)
}
,
e.prototype.setRasterizerState = function(t) {
t ? this._gl.disable(this._gl.RASTERIZER_DISCARD) : this._gl.enable(this._gl.RASTERIZER_DISCARD)
}
,
e.prototype.getDepthFunction = function() {
return this._depthCullingState.depthFunc
}
,
e.prototype.setDepthFunction = function(t) {
this._depthCullingState.depthFunc = t
}
,
e.prototype.setDepthFunctionToGreater = function() {
this.setDepthFunction(516)
}
,
e.prototype.setDepthFunctionToGreaterOrEqual = function() {
this.setDepthFunction(518)
}
,
e.prototype.setDepthFunctionToLess = function() {
this.setDepthFunction(513)
}
,
e.prototype.setDepthFunctionToLessOrEqual = function() {
this.setDepthFunction(515)
}
,
e.prototype.cacheStencilState = function() {
this._cachedStencilBuffer = this.getStencilBuffer(),
this._cachedStencilFunction = this.getStencilFunction(),
this._cachedStencilMask = this.getStencilMask(),
this._cachedStencilOperationPass = this.getStencilOperationPass(),
this._cachedStencilOperationFail = this.getStencilOperationFail(),
this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail(),
this._cachedStencilReference = this.getStencilFunctionReference()
}
,
e.prototype.restoreStencilState = function() {
this.setStencilFunction(this._cachedStencilFunction),
this.setStencilMask(this._cachedStencilMask),
this.setStencilBuffer(this._cachedStencilBuffer),
this.setStencilOperationPass(this._cachedStencilOperationPass),
this.setStencilOperationFail(this._cachedStencilOperationFail),
this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),
this.setStencilFunctionReference(this._cachedStencilReference)
}
,
e.prototype.setDirectViewport = function(t, r, n, o) {
var a = this._cachedViewport;
return this._cachedViewport = null,
this._viewport(t, r, n, o),
a
}
,
e.prototype.scissorClear = function(t, r, n, o, a) {
this.enableScissor(t, r, n, o),
this.clear(a, !0, !0, !0),
this.disableScissor()
}
,
e.prototype.enableScissor = function(t, r, n, o) {
var a = this._gl;
a.enable(a.SCISSOR_TEST),
a.scissor(t, r, n, o)
}
,
e.prototype.disableScissor = function() {
var t = this._gl;
t.disable(t.SCISSOR_TEST)
}
,
e.prototype._reportDrawCall = function(t) {
t === void 0 && (t = 1),
this._drawCalls.addCount(t, !1)
}
,
e.prototype.initWebVR = function() {
throw _WarnImport("WebVRCamera")
}
,
e.prototype._prepareVRComponent = function() {}
,
e.prototype._connectVREvents = function(t, r) {}
,
e.prototype._submitVRFrame = function() {}
,
e.prototype.disableVR = function() {}
,
e.prototype.isVRPresenting = function() {
return !1
}
,
e.prototype._requestVRFrame = function() {}
,
e.prototype._loadFileAsync = function(t, r, n) {
var o = this;
return new Promise(function(a, s) {
o._loadFile(t, function(l) {
a(l)
}, void 0, r, n, function(l, u) {
s(u)
})
}
)
}
,
e.prototype.getVertexShaderSource = function(t) {
var r = this._gl.getAttachedShaders(t);
return r ? this._gl.getShaderSource(r[0]) : null
}
,
e.prototype.getFragmentShaderSource = function(t) {
var r = this._gl.getAttachedShaders(t);
return r ? this._gl.getShaderSource(r[1]) : null
}
,
e.prototype.setDepthStencilTexture = function(t, r, n, o) {
t !== void 0 && (r && (this._boundUniforms[t] = r),
!n || !n.depthStencilTexture ? this._setTexture(t, null, void 0, void 0, o) : this._setTexture(t, n, !1, !0, o))
}
,
e.prototype.setTextureFromPostProcess = function(t, r, n) {
var o, a = null;
r && (r._textures.data[r._currentRenderTextureInd] ? a = r._textures.data[r._currentRenderTextureInd] : r._forcedOutputTexture && (a = r._forcedOutputTexture)),
this._bindTexture(t, (o = a == null ? void 0 : a.texture) !== null && o !== void 0 ? o : null, n)
}
,
e.prototype.setTextureFromPostProcessOutput = function(t, r, n) {
var o, a;
this._bindTexture(t, (a = (o = r == null ? void 0 : r._outputTexture) === null || o === void 0 ? void 0 : o.texture) !== null && a !== void 0 ? a : null, n)
}
,
e.prototype._rebuildBuffers = function() {
for (var t = 0, r = this.scenes; t < r.length; t++) {
var n = r[t];
n.resetCachedMaterial(),
n._rebuildGeometries(),
n._rebuildTextures()
}
for (var o = 0, a = this._virtualScenes; o < a.length; o++) {
var n = a[o];
n.resetCachedMaterial(),
n._rebuildGeometries(),
n._rebuildTextures()
}
i.prototype._rebuildBuffers.call(this)
}
,
e.prototype._renderFrame = function() {
for (var t = 0; t < this._activeRenderLoops.length; t++) {
var r = this._activeRenderLoops[t];
r()
}
}
,
e.prototype._renderLoop = function() {
if (!this._contextWasLost) {
var t = !0;
!this.renderEvenInBackground && this._windowIsBackground && (t = !1),
t && (this.beginFrame(),
this._renderViews() || this._renderFrame(),
this.endFrame())
}
this._activeRenderLoops.length > 0 ? this.customAnimationFrameRequester ? (this.customAnimationFrameRequester.requestID = this._queueNewFrame(this.customAnimationFrameRequester.renderFunction || this._boundRenderFunction, this.customAnimationFrameRequester),
this._frameHandler = this.customAnimationFrameRequester.requestID) : this.isVRPresenting() ? this._requestVRFrame() : this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1
}
,
e.prototype._renderViews = function() {
return !1
}
,
e.prototype.switchFullscreen = function(t) {
this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen(t)
}
,
e.prototype.enterFullscreen = function(t) {
this.isFullscreen || (this._pointerLockRequested = t,
this._renderingCanvas && e._RequestFullscreen(this._renderingCanvas))
}
,
e.prototype.exitFullscreen = function() {
this.isFullscreen && e._ExitFullscreen()
}
,
e.prototype.enterPointerlock = function() {
this._renderingCanvas && e._RequestPointerlock(this._renderingCanvas)
}
,
e.prototype.exitPointerlock = function() {
e._ExitPointerlock()
}
,
e.prototype.beginFrame = function() {
this._measureFps(),
this.onBeginFrameObservable.notifyObservers(this),
i.prototype.beginFrame.call(this)
}
,
e.prototype.endFrame = function() {
i.prototype.endFrame.call(this),
this._submitVRFrame(),
this.onEndFrameObservable.notifyObservers(this)
}
,
e.prototype.resize = function(t) {
t === void 0 && (t = !1),
!this.isVRPresenting() && i.prototype.resize.call(this, t)
}
,
e.prototype.setSize = function(t, r, n) {
if (n === void 0 && (n = !1),
!this._renderingCanvas || !i.prototype.setSize.call(this, t, r, n))
return !1;
if (this.scenes) {
for (var o = 0; o < this.scenes.length; o++)
for (var a = this.scenes[o], s = 0; s < a.cameras.length; s++) {
var l = a.cameras[s];
l._currentRenderId = 0
}
this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this)
}
return !0
}
,
e.prototype._deletePipelineContext = function(t) {
var r = t;
r && r.program && r.transformFeedback && (this.deleteTransformFeedback(r.transformFeedback),
r.transformFeedback = null),
i.prototype._deletePipelineContext.call(this, t)
}
,
e.prototype.createShaderProgram = function(t, r, n, o, a, s) {
s === void 0 && (s = null),
a = a || this._gl,
this.onBeforeShaderCompilationObservable.notifyObservers(this);
var l = i.prototype.createShaderProgram.call(this, t, r, n, o, a, s);
return this.onAfterShaderCompilationObservable.notifyObservers(this),
l
}
,
e.prototype._createShaderProgram = function(t, r, n, o, a) {
a === void 0 && (a = null);
var s = o.createProgram();
if (t.program = s,
!s)
throw new Error("Unable to create program");
if (o.attachShader(s, r),
o.attachShader(s, n),
this.webGLVersion > 1 && a) {
var l = this.createTransformFeedback();
this.bindTransformFeedback(l),
this.setTranformFeedbackVaryings(s, a),
t.transformFeedback = l
}
return o.linkProgram(s),
this.webGLVersion > 1 && a && this.bindTransformFeedback(null),
t.context = o,
t.vertexShader = r,
t.fragmentShader = n,
t.isParallelCompiled || this._finalizePipelineContext(t),
s
}
,
e.prototype._releaseTexture = function(t) {
i.prototype._releaseTexture.call(this, t)
}
,
e.prototype._releaseRenderTargetWrapper = function(t) {
i.prototype._releaseRenderTargetWrapper.call(this, t),
this.scenes.forEach(function(r) {
r.postProcesses.forEach(function(n) {
n._outputTexture === t && (n._outputTexture = null)
}),
r.cameras.forEach(function(n) {
n._postProcesses.forEach(function(o) {
o && o._outputTexture === t && (o._outputTexture = null)
})
})
})
}
,
e.prototype.getRenderPassNames = function() {
return this._renderPassNames
}
,
e.prototype.getCurrentRenderPassName = function() {
return this._renderPassNames[this.currentRenderPassId]
}
,
e.prototype.createRenderPassId = function(t) {
var r = ++e._RenderPassIdCounter;
return this._renderPassNames[r] = t != null ? t : "NONAME",
r
}
,
e.prototype.releaseRenderPassId = function(t) {
this._renderPassNames[t] = void 0;
for (var r = 0; r < this.scenes.length; ++r)
for (var n = this.scenes[r], o = 0; o < n.meshes.length; ++o) {
var a = n.meshes[o];
if (a.subMeshes)
for (var s = 0; s < a.subMeshes.length; ++s) {
var l = a.subMeshes[s];
l._removeDrawWrapper(t)
}
}
}
,
e.prototype._rescaleTexture = function(t, r, n, o, a) {
var s = 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 l = this.createRenderTargetTexture({
width: r.width,
height: r.height
}, {
generateMipMaps: !1,
type: 0,
samplingMode: 2,
generateDepthBuffer: !1,
generateStencilBuffer: !1
});
!this._rescalePostProcess && e._RescalePostProcessFactory && (this._rescalePostProcess = e._RescalePostProcessFactory(this)),
this._rescalePostProcess.externalTextureSamplerBinding = !0,
this._rescalePostProcess.getEffect().executeWhenCompiled(function() {
s._rescalePostProcess.onApply = function(c) {
c._bindTexture("textureSampler", t)
}
;
var u = n;
u || (u = s.scenes[s.scenes.length - 1]),
u.postProcessManager.directRender([s._rescalePostProcess], l, !0),
s._bindTextureDirectly(s._gl.TEXTURE_2D, r, !0),
s._gl.copyTexImage2D(s._gl.TEXTURE_2D, 0, o, 0, 0, r.width, r.height, 0),
s.unBindFramebuffer(l),
l.dispose(),
a && a()
})
}
,
e.prototype.getFps = function() {
return this._fps
}
,
e.prototype.getDeltaTime = function() {
return this._deltaTime
}
,
e.prototype._measureFps = function() {
this._performanceMonitor.sampleFrame(),
this._fps = this._performanceMonitor.averageFPS,
this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0
}
,
e.prototype._uploadImageToTexture = function(t, r, n, o) {
n === void 0 && (n = 0),
o === void 0 && (o = 0);
var a = this._gl
, s = this._getWebGLTextureType(t.type)
, l = this._getInternalFormat(t.format)
, u = this._getRGBABufferInternalSizedFormat(t.type, l)
, c = t.isCube ? a.TEXTURE_CUBE_MAP : a.TEXTURE_2D;
this._bindTextureDirectly(c, t, !0),
this._unpackFlipY(t.invertY);
var h = a.TEXTURE_2D;
t.isCube && (h = a.TEXTURE_CUBE_MAP_POSITIVE_X + n),
a.texImage2D(h, o, u, l, s, r),
this._bindTextureDirectly(c, null, !0)
}
,
e.prototype.updateTextureComparisonFunction = function(t, r) {
if (this.webGLVersion === 1) {
Logger$2.Error("WebGL 1 does not support texture comparison.");
return
}
var n = this._gl;
t.isCube ? (this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, t, !0),
r === 0 ? (n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_COMPARE_FUNC, 515),
n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_COMPARE_MODE, n.NONE)) : (n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_COMPARE_FUNC, r),
n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_COMPARE_MODE, n.COMPARE_REF_TO_TEXTURE)),
this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null)) : (this._bindTextureDirectly(this._gl.TEXTURE_2D, t, !0),
r === 0 ? (n.texParameteri(n.TEXTURE_2D, n.TEXTURE_COMPARE_FUNC, 515),
n.texParameteri(n.TEXTURE_2D, n.TEXTURE_COMPARE_MODE, n.NONE)) : (n.texParameteri(n.TEXTURE_2D, n.TEXTURE_COMPARE_FUNC, r),
n.texParameteri(n.TEXTURE_2D, n.TEXTURE_COMPARE_MODE, n.COMPARE_REF_TO_TEXTURE)),
this._bindTextureDirectly(this._gl.TEXTURE_2D, null)),
t._comparisonFunction = r
}
,
e.prototype.createInstancesBuffer = function(t) {
var r = this._gl.createBuffer();
if (!r)
throw new Error("Unable to create instance buffer");
var n = new WebGLDataBuffer(r);
return n.capacity = t,
this.bindArrayBuffer(n),
this._gl.bufferData(this._gl.ARRAY_BUFFER, t, this._gl.DYNAMIC_DRAW),
n.references = 1,
n
}
,
e.prototype.deleteInstancesBuffer = function(t) {
this._gl.deleteBuffer(t)
}
,
e.prototype._clientWaitAsync = function(t, r, n) {
r === void 0 && (r = 0),
n === void 0 && (n = 10);
var o = this._gl;
return new Promise(function(a, s) {
var l = function() {
var u = o.clientWaitSync(t, r, 0);
if (u == o.WAIT_FAILED) {
s();
return
}
if (u == o.TIMEOUT_EXPIRED) {
setTimeout(l, n);
return
}
a()
};
l()
}
)
}
,
e.prototype._readPixelsAsync = function(t, r, n, o, a, s, l) {
if (this._webGLVersion < 2)
throw new Error("_readPixelsAsync only work on WebGL2+");
var u = this._gl
, c = u.createBuffer();
u.bindBuffer(u.PIXEL_PACK_BUFFER, c),
u.bufferData(u.PIXEL_PACK_BUFFER, l.byteLength, u.STREAM_READ),
u.readPixels(t, r, n, o, a, s, 0),
u.bindBuffer(u.PIXEL_PACK_BUFFER, null);
var h = u.fenceSync(u.SYNC_GPU_COMMANDS_COMPLETE, 0);
return h ? (u.flush(),
this._clientWaitAsync(h, 0, 10).then(function() {
return u.deleteSync(h),
u.bindBuffer(u.PIXEL_PACK_BUFFER, c),
u.getBufferSubData(u.PIXEL_PACK_BUFFER, 0, l),
u.bindBuffer(u.PIXEL_PACK_BUFFER, null),
u.deleteBuffer(c),
l
})) : null
}
,
e.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();
for (; this._virtualScenes.length; )
this._virtualScenes[0].dispose();
e.Instances.length === 1 && e.audioEngine && (e.audioEngine.dispose(),
e.audioEngine = null),
this.disableVR(),
this.deviceInputSystem && this.deviceInputSystem.dispose(),
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)),
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))),
i.prototype.dispose.call(this);
var t = e.Instances.indexOf(this);
t >= 0 && e.Instances.splice(t, 1),
this.onResizeObservable.clear(),
this.onCanvasBlurObservable.clear(),
this.onCanvasFocusObservable.clear(),
this.onCanvasPointerOutObservable.clear(),
this.onBeginFrameObservable.clear(),
this.onEndFrameObservable.clear()
}
,
e.prototype._disableTouchAction = function() {
!this._renderingCanvas || !this._renderingCanvas.setAttribute || (this._renderingCanvas.setAttribute("touch-action", "none"),
this._renderingCanvas.style.touchAction = "none",
this._renderingCanvas.style.msTouchAction = "none")
}
,
e.prototype.displayLoadingUI = function() {
if (!!IsWindowObjectExist()) {
var t = this.loadingScreen;
t && t.displayLoadingUI()
}
}
,
e.prototype.hideLoadingUI = function() {
if (!!IsWindowObjectExist()) {
var t = this._loadingScreen;
t && t.hideLoadingUI()
}
}
,
Object.defineProperty(e.prototype, "loadingScreen", {
get: function() {
return !this._loadingScreen && this._renderingCanvas && (this._loadingScreen = e.DefaultLoadingScreenFactory(this._renderingCanvas)),
this._loadingScreen
},
set: function(t) {
this._loadingScreen = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "loadingUIText", {
set: function(t) {
this.loadingScreen.loadingUIText = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "loadingUIBackgroundColor", {
set: function(t) {
this.loadingScreen.loadingUIBackgroundColor = t
},
enumerable: !1,
configurable: !0
}),
e.prototype.createVideoElement = function(t) {
return document.createElement("video")
}
,
e._RequestPointerlock = function(t) {
t.requestPointerLock = t.requestPointerLock || t.msRequestPointerLock || t.mozRequestPointerLock || t.webkitRequestPointerLock,
t.requestPointerLock && t.requestPointerLock()
}
,
e._ExitPointerlock = function() {
var t = document;
document.exitPointerLock = document.exitPointerLock || t.msExitPointerLock || t.mozExitPointerLock || t.webkitExitPointerLock,
document.exitPointerLock && document.exitPointerLock()
}
,
e._RequestFullscreen = function(t) {
var r = t.requestFullscreen || t.msRequestFullscreen || t.webkitRequestFullscreen || t.mozRequestFullScreen;
!r || r.call(t)
}
,
e._ExitFullscreen = function() {
var t = document;
document.exitFullscreen ? document.exitFullscreen() : t.mozCancelFullScreen ? t.mozCancelFullScreen() : t.webkitCancelFullScreen ? t.webkitCancelFullScreen() : t.msCancelFullScreen && t.msCancelFullScreen()
}
,
e.prototype.getFontOffset = function(t) {
var r = document.createElement("span");
r.innerHTML = "Hg",
r.setAttribute("style", "font: " + t + " !important");
var n = document.createElement("div");
n.style.display = "inline-block",
n.style.width = "1px",
n.style.height = "0px",
n.style.verticalAlign = "bottom";
var o = document.createElement("div");
o.style.whiteSpace = "nowrap",
o.appendChild(r),
o.appendChild(n),
document.body.appendChild(o);
var a = 0
, s = 0;
try {
s = n.getBoundingClientRect().top - r.getBoundingClientRect().top,
n.style.verticalAlign = "baseline",
a = n.getBoundingClientRect().top - r.getBoundingClientRect().top
} finally {
document.body.removeChild(o)
}
return {
ascent: a,
height: s,
descent: s - a
}
}
,
e.ALPHA_DISABLE = 0,
e.ALPHA_ADD = 1,
e.ALPHA_COMBINE = 2,
e.ALPHA_SUBTRACT = 3,
e.ALPHA_MULTIPLY = 4,
e.ALPHA_MAXIMIZED = 5,
e.ALPHA_ONEONE = 6,
e.ALPHA_PREMULTIPLIED = 7,
e.ALPHA_PREMULTIPLIED_PORTERDUFF = 8,
e.ALPHA_INTERPOLATE = 9,
e.ALPHA_SCREENMODE = 10,
e.DELAYLOADSTATE_NONE = 0,
e.DELAYLOADSTATE_LOADED = 1,
e.DELAYLOADSTATE_LOADING = 2,
e.DELAYLOADSTATE_NOTLOADED = 4,
e.NEVER = 512,
e.ALWAYS = 519,
e.LESS = 513,
e.EQUAL = 514,
e.LEQUAL = 515,
e.GREATER = 516,
e.GEQUAL = 518,
e.NOTEQUAL = 517,
e.KEEP = 7680,
e.REPLACE = 7681,
e.INCR = 7682,
e.DECR = 7683,
e.INVERT = 5386,
e.INCR_WRAP = 34055,
e.DECR_WRAP = 34056,
e.TEXTURE_CLAMP_ADDRESSMODE = 0,
e.TEXTURE_WRAP_ADDRESSMODE = 1,
e.TEXTURE_MIRROR_ADDRESSMODE = 2,
e.TEXTUREFORMAT_ALPHA = 0,
e.TEXTUREFORMAT_LUMINANCE = 1,
e.TEXTUREFORMAT_LUMINANCE_ALPHA = 2,
e.TEXTUREFORMAT_RGB = 4,
e.TEXTUREFORMAT_RGBA = 5,
e.TEXTUREFORMAT_RED = 6,
e.TEXTUREFORMAT_R = 6,
e.TEXTUREFORMAT_RG = 7,
e.TEXTUREFORMAT_RED_INTEGER = 8,
e.TEXTUREFORMAT_R_INTEGER = 8,
e.TEXTUREFORMAT_RG_INTEGER = 9,
e.TEXTUREFORMAT_RGB_INTEGER = 10,
e.TEXTUREFORMAT_RGBA_INTEGER = 11,
e.TEXTURETYPE_UNSIGNED_BYTE = 0,
e.TEXTURETYPE_UNSIGNED_INT = 0,
e.TEXTURETYPE_FLOAT = 1,
e.TEXTURETYPE_HALF_FLOAT = 2,
e.TEXTURETYPE_BYTE = 3,
e.TEXTURETYPE_SHORT = 4,
e.TEXTURETYPE_UNSIGNED_SHORT = 5,
e.TEXTURETYPE_INT = 6,
e.TEXTURETYPE_UNSIGNED_INTEGER = 7,
e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8,
e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9,
e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10,
e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11,
e.TEXTURETYPE_UNSIGNED_INT_24_8 = 12,
e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13,
e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14,
e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15,
e.TEXTURE_NEAREST_SAMPLINGMODE = 1,
e.TEXTURE_BILINEAR_SAMPLINGMODE = 2,
e.TEXTURE_TRILINEAR_SAMPLINGMODE = 3,
e.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8,
e.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11,
e.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3,
e.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4,
e.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5,
e.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6,
e.TEXTURE_NEAREST_LINEAR = 7,
e.TEXTURE_NEAREST_NEAREST = 1,
e.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9,
e.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10,
e.TEXTURE_LINEAR_LINEAR = 2,
e.TEXTURE_LINEAR_NEAREST = 12,
e.TEXTURE_EXPLICIT_MODE = 0,
e.TEXTURE_SPHERICAL_MODE = 1,
e.TEXTURE_PLANAR_MODE = 2,
e.TEXTURE_CUBIC_MODE = 3,
e.TEXTURE_PROJECTION_MODE = 4,
e.TEXTURE_SKYBOX_MODE = 5,
e.TEXTURE_INVCUBIC_MODE = 6,
e.TEXTURE_EQUIRECTANGULAR_MODE = 7,
e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8,
e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9,
e.SCALEMODE_FLOOR = 1,
e.SCALEMODE_NEAREST = 2,
e.SCALEMODE_CEILING = 3,
e._RescalePostProcessFactory = null,
e._RenderPassIdCounter = 0,
e
}(ThinEngine), SceneLoaderFlags = function() {
function i() {}
return Object.defineProperty(i, "ForceFullSceneLoadingForIncremental", {
get: function() {
return i._ForceFullSceneLoadingForIncremental
},
set: function(e) {
i._ForceFullSceneLoadingForIncremental = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ShowLoadingScreen", {
get: function() {
return i._ShowLoadingScreen
},
set: function(e) {
i._ShowLoadingScreen = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "loggingLevel", {
get: function() {
return i._loggingLevel
},
set: function(e) {
i._loggingLevel = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "CleanBoneMatrixWeights", {
get: function() {
return i._CleanBoneMatrixWeights
},
set: function(e) {
i._CleanBoneMatrixWeights = e
},
enumerable: !1,
configurable: !0
}),
i._ForceFullSceneLoadingForIncremental = !1,
i._ShowLoadingScreen = !0,
i._CleanBoneMatrixWeights = !1,
i._loggingLevel = 0,
i
}(), SceneLoaderAnimationGroupLoadingMode;
(function(i) {
i[i.Clean = 0] = "Clean",
i[i.Stop = 1] = "Stop",
i[i.Sync = 2] = "Sync",
i[i.NoSync = 3] = "NoSync"
}
)(SceneLoaderAnimationGroupLoadingMode || (SceneLoaderAnimationGroupLoadingMode = {}));
var SceneLoader = function() {
function i() {}
return Object.defineProperty(i, "ForceFullSceneLoadingForIncremental", {
get: function() {
return SceneLoaderFlags.ForceFullSceneLoadingForIncremental
},
set: function(e) {
SceneLoaderFlags.ForceFullSceneLoadingForIncremental = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ShowLoadingScreen", {
get: function() {
return SceneLoaderFlags.ShowLoadingScreen
},
set: function(e) {
SceneLoaderFlags.ShowLoadingScreen = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "loggingLevel", {
get: function() {
return SceneLoaderFlags.loggingLevel
},
set: function(e) {
SceneLoaderFlags.loggingLevel = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "CleanBoneMatrixWeights", {
get: function() {
return SceneLoaderFlags.CleanBoneMatrixWeights
},
set: function(e) {
SceneLoaderFlags.CleanBoneMatrixWeights = e
},
enumerable: !1,
configurable: !0
}),
i.GetDefaultPlugin = function() {
return i._registeredPlugins[".babylon"]
}
,
i._GetPluginForExtension = function(e) {
var t = i._registeredPlugins[e];
return t || (Logger$2.Warn("Unable to find a plugin to load " + e + " 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"),
i.GetDefaultPlugin())
}
,
i._GetPluginForDirectLoad = function(e) {
for (var t in i._registeredPlugins) {
var r = i._registeredPlugins[t].plugin;
if (r.canDirectLoad && r.canDirectLoad(e))
return i._registeredPlugins[t]
}
return i.GetDefaultPlugin()
}
,
i._GetPluginForFilename = function(e) {
var t = e.indexOf("?");
t !== -1 && (e = e.substring(0, t));
var r = e.lastIndexOf(".")
, n = e.substring(r, e.length).toLowerCase();
return i._GetPluginForExtension(n)
}
,
i._GetDirectLoad = function(e) {
return e.substr(0, 5) === "data:" ? e.substr(5) : null
}
,
i._FormatErrorMessage = function(e, t, r) {
var n = "Unable to load from " + e.url;
return t ? n += ": " + t : r && (n += ": " + r),
n
}
,
i._LoadData = function(e, t, r, n, o, a, s) {
var l = i._GetDirectLoad(e.url), u = s ? i._GetPluginForExtension(s) : l ? i._GetPluginForDirectLoad(e.url) : i._GetPluginForFilename(e.url), c;
if (u.plugin.createPlugin !== void 0 ? c = u.plugin.createPlugin() : c = u.plugin,
!c)
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 (i.OnPluginActivatedObservable.notifyObservers(c),
l && (c.canDirectLoad && c.canDirectLoad(e.url) || !IsBase64DataUrl(e.url))) {
if (c.directLoad) {
var h = c.directLoad(t, l);
h.then ? h.then(function(P) {
r(c, P)
}).catch(function(P) {
o("Error in directLoad of _loadData: " + P, P)
}) : r(c, h)
} else
r(c, l);
return c
}
var f = u.isBinary
, d = function(P, R) {
if (t.isDisposed) {
o("Scene has been disposed");
return
}
r(c, P, R)
}
, _ = null
, g = !1
, m = c.onDisposeObservable;
m && m.add(function() {
g = !0,
_ && (_.abort(),
_ = null),
a()
});
var v = function() {
if (!g) {
var P = function(M, x) {
o(M == null ? void 0 : M.statusText, x)
}
, R = e.file || e.url;
_ = c.loadFile ? c.loadFile(t, R, d, n, f, P) : t._loadFile(R, d, n, !0, f, P)
}
}
, y = t.getEngine()
, b = y.enableOfflineSupport;
if (b) {
for (var T = !1, C = 0, A = t.disableOfflineSupportExceptionRules; C < A.length; C++) {
var S = A[C];
if (S.test(e.url)) {
T = !0;
break
}
}
b = !T
}
return b && Engine.OfflineProviderFactory ? t.offlineProvider = Engine.OfflineProviderFactory(e.url, v, y.disableManifestCheck) : v(),
c
}
,
i._GetFileInfo = function(e, t) {
var r, n, o = null;
if (!t)
r = e,
n = Tools.GetFilename(e),
e = Tools.GetFolderPath(e);
else if (t.name) {
var a = t;
r = "file:" + a.name,
n = a.name,
o = a
} else if (typeof t == "string" && StartsWith(t, "data:"))
r = t,
n = "";
else {
var s = t;
if (s.substr(0, 1) === "/")
return Tools.Error("Wrong sceneFilename parameter"),
null;
r = e + s,
n = s
}
return {
url: r,
rootUrl: e,
name: n,
file: o
}
}
,
i.GetPluginForExtension = function(e) {
return i._GetPluginForExtension(e).plugin
}
,
i.IsPluginForExtensionAvailable = function(e) {
return !!i._registeredPlugins[e]
}
,
i.RegisterPlugin = function(e) {
if (typeof e.extensions == "string") {
var t = e.extensions;
i._registeredPlugins[t.toLowerCase()] = {
plugin: e,
isBinary: !1
}
} else {
var r = e.extensions;
Object.keys(r).forEach(function(n) {
i._registeredPlugins[n.toLowerCase()] = {
plugin: e,
isBinary: r[n].isBinary
}
})
}
}
,
i.ImportMesh = function(e, t, r, n, o, a, s, l) {
if (r === void 0 && (r = ""),
n === void 0 && (n = EngineStore.LastCreatedScene),
o === void 0 && (o = null),
a === void 0 && (a = null),
s === void 0 && (s = null),
l === void 0 && (l = null),
!n)
return Logger$2.Error("No scene available to import mesh to"),
null;
var u = i._GetFileInfo(t, r);
if (!u)
return null;
var c = {};
n._addPendingData(c);
var h = function() {
n._removePendingData(c)
}
, f = function(g, m) {
var v = i._FormatErrorMessage(u, g, m);
s ? s(n, v, new Error(v)) : Logger$2.Error(v),
h()
}
, d = a ? function(g) {
try {
a(g)
} catch (m) {
f("Error in onProgress callback: " + m, m)
}
}
: void 0
, _ = function(g, m, v, y, b, T, C) {
if (n.importedMeshesFiles.push(u.url),
o)
try {
o(g, m, v, y, b, T, C)
} catch (A) {
f("Error in onSuccess callback: " + A, A)
}
n._removePendingData(c)
};
return i._LoadData(u, n, function(g, m, v) {
if (g.rewriteRootURL && (u.rootUrl = g.rewriteRootURL(u.rootUrl, v)),
g.importMesh) {
var y = g
, b = new Array
, T = new Array
, C = new Array;
if (!y.importMesh(e, n, m, u.rootUrl, b, T, C, f))
return;
n.loadingPluginName = g.name,
_(b, T, C, [], [], [], [])
} else {
var A = g;
A.importMeshAsync(e, n, m, u.rootUrl, d, u.name).then(function(S) {
n.loadingPluginName = g.name,
_(S.meshes, S.particleSystems, S.skeletons, S.animationGroups, S.transformNodes, S.geometries, S.lights)
}).catch(function(S) {
f(S.message, S)
})
}
}, d, f, h, l)
}
,
i.ImportMeshAsync = function(e, t, r, n, o, a) {
return r === void 0 && (r = ""),
n === void 0 && (n = EngineStore.LastCreatedScene),
o === void 0 && (o = null),
a === void 0 && (a = null),
new Promise(function(s, l) {
i.ImportMesh(e, t, r, n, function(u, c, h, f, d, _, g) {
s({
meshes: u,
particleSystems: c,
skeletons: h,
animationGroups: f,
transformNodes: d,
geometries: _,
lights: g
})
}, o, function(u, c, h) {
l(h || new Error(c))
}, a)
}
)
}
,
i.Load = function(e, t, r, n, o, a, s) {
return t === void 0 && (t = ""),
r === void 0 && (r = EngineStore.LastCreatedEngine),
n === void 0 && (n = null),
o === void 0 && (o = null),
a === void 0 && (a = null),
s === void 0 && (s = null),
r ? i.Append(e, t, new Scene(r), n, o, a, s) : (Tools.Error("No engine available"),
null)
}
,
i.LoadAsync = function(e, t, r, n, o) {
return t === void 0 && (t = ""),
r === void 0 && (r = EngineStore.LastCreatedEngine),
n === void 0 && (n = null),
o === void 0 && (o = null),
new Promise(function(a, s) {
i.Load(e, t, r, function(l) {
a(l)
}, n, function(l, u, c) {
s(c || new Error(u))
}, o)
}
)
}
,
i.Append = function(e, t, r, n, o, a, s) {
var l = this;
if (t === void 0 && (t = ""),
r === void 0 && (r = EngineStore.LastCreatedScene),
n === void 0 && (n = null),
o === void 0 && (o = null),
a === void 0 && (a = null),
s === void 0 && (s = null),
!r)
return Logger$2.Error("No scene available to append to"),
null;
var u = i._GetFileInfo(e, t);
if (!u)
return null;
i.ShowLoadingScreen && !this._showingLoadingScreen && (this._showingLoadingScreen = !0,
r.getEngine().displayLoadingUI(),
r.executeWhenReady(function() {
r.getEngine().hideLoadingUI(),
l._showingLoadingScreen = !1
}));
var c = {};
r._addPendingData(c);
var h = function() {
r._removePendingData(c)
}
, f = function(g, m) {
var v = i._FormatErrorMessage(u, g, m);
a ? a(r, v, new Error(v)) : Logger$2.Error(v),
h()
}
, d = o ? function(g) {
try {
o(g)
} catch (m) {
f("Error in onProgress callback", m)
}
}
: void 0
, _ = function() {
if (n)
try {
n(r)
} catch (g) {
f("Error in onSuccess callback", g)
}
r._removePendingData(c)
};
return i._LoadData(u, r, function(g, m) {
if (g.load) {
var v = g;
if (!v.load(r, m, u.rootUrl, f))
return;
r.loadingPluginName = g.name,
_()
} else {
var y = g;
y.loadAsync(r, m, u.rootUrl, d, u.name).then(function() {
r.loadingPluginName = g.name,
_()
}).catch(function(b) {
f(b.message, b)
})
}
}, d, f, h, s)
}
,
i.AppendAsync = function(e, t, r, n, o) {
return t === void 0 && (t = ""),
r === void 0 && (r = EngineStore.LastCreatedScene),
n === void 0 && (n = null),
o === void 0 && (o = null),
new Promise(function(a, s) {
i.Append(e, t, r, function(l) {
a(l)
}, n, function(l, u, c) {
s(c || new Error(u))
}, o)
}
)
}
,
i.LoadAssetContainer = function(e, t, r, n, o, a, s) {
if (t === void 0 && (t = ""),
r === void 0 && (r = EngineStore.LastCreatedScene),
n === void 0 && (n = null),
o === void 0 && (o = null),
a === void 0 && (a = null),
s === void 0 && (s = null),
!r)
return Logger$2.Error("No scene available to load asset container to"),
null;
var l = i._GetFileInfo(e, t);
if (!l)
return null;
var u = {};
r._addPendingData(u);
var c = function() {
r._removePendingData(u)
}
, h = function(_, g) {
var m = i._FormatErrorMessage(l, _, g);
a ? a(r, m, new Error(m)) : Logger$2.Error(m),
c()
}
, f = o ? function(_) {
try {
o(_)
} catch (g) {
h("Error in onProgress callback", g)
}
}
: void 0
, d = function(_) {
if (n)
try {
n(_)
} catch (g) {
h("Error in onSuccess callback", g)
}
r._removePendingData(u)
};
return i._LoadData(l, r, function(_, g) {
if (_.loadAssetContainer) {
var m = _
, v = m.loadAssetContainer(r, g, l.rootUrl, h);
if (!v)
return;
r.loadingPluginName = _.name,
d(v)
} else if (_.loadAssetContainerAsync) {
var y = _;
y.loadAssetContainerAsync(r, g, l.rootUrl, f, l.name).then(function(b) {
r.loadingPluginName = _.name,
d(b)
}).catch(function(b) {
h(b.message, b)
})
} else
h("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")
}, f, h, c, s)
}
,
i.LoadAssetContainerAsync = function(e, t, r, n, o) {
return t === void 0 && (t = ""),
r === void 0 && (r = EngineStore.LastCreatedScene),
n === void 0 && (n = null),
o === void 0 && (o = null),
new Promise(function(a, s) {
i.LoadAssetContainer(e, t, r, function(l) {
a(l)
}, n, function(l, u, c) {
s(c || new Error(u))
}, o)
}
)
}
,
i.ImportAnimations = function(e, t, r, n, o, a, s, l, u, c) {
if (t === void 0 && (t = ""),
r === void 0 && (r = EngineStore.LastCreatedScene),
n === void 0 && (n = !0),
o === void 0 && (o = SceneLoaderAnimationGroupLoadingMode.Clean),
a === void 0 && (a = null),
s === void 0 && (s = null),
l === void 0 && (l = null),
u === void 0 && (u = null),
c === void 0 && (c = null),
!r) {
Logger$2.Error("No scene available to load animations to");
return
}
if (n) {
for (var h = 0, f = r.animatables; h < f.length; h++) {
var d = f[h];
d.reset()
}
r.stopAllAnimations(),
r.animationGroups.slice().forEach(function(v) {
v.dispose()
});
var _ = r.getNodes();
_.forEach(function(v) {
v.animations && (v.animations = [])
})
} else
switch (o) {
case SceneLoaderAnimationGroupLoadingMode.Clean:
r.animationGroups.slice().forEach(function(v) {
v.dispose()
});
break;
case SceneLoaderAnimationGroupLoadingMode.Stop:
r.animationGroups.forEach(function(v) {
v.stop()
});
break;
case SceneLoaderAnimationGroupLoadingMode.Sync:
r.animationGroups.forEach(function(v) {
v.reset(),
v.restart()
});
break;
case SceneLoaderAnimationGroupLoadingMode.NoSync:
break;
default:
Logger$2.Error("Unknown animation group loading mode value '" + o + "'");
return
}
var g = r.animatables.length
, m = function(v) {
v.mergeAnimationsTo(r, r.animatables.slice(g), a),
v.dispose(),
r.onAnimationFileImportedObservable.notifyObservers(r),
s && s(r)
};
this.LoadAssetContainer(e, t, r, m, l, u, c)
}
,
i.ImportAnimationsAsync = function(e, t, r, n, o, a, s, l, u, c) {
return t === void 0 && (t = ""),
r === void 0 && (r = EngineStore.LastCreatedScene),
n === void 0 && (n = !0),
o === void 0 && (o = SceneLoaderAnimationGroupLoadingMode.Clean),
a === void 0 && (a = null),
l === void 0 && (l = null),
c === void 0 && (c = null),
new Promise(function(h, f) {
i.ImportAnimations(e, t, r, n, o, a, function(d) {
h(d)
}, l, function(d, _, g) {
f(g || new Error(_))
}, c)
}
)
}
,
i.NO_LOGGING = 0,
i.MINIMAL_LOGGING = 1,
i.SUMMARY_LOGGING = 2,
i.DETAILED_LOGGING = 3,
i.OnPluginActivatedObservable = new Observable,
i._registeredPlugins = {},
i._showingLoadingScreen = !1,
i
}(), AnimationKeyInterpolation;
(function(i) {
i[i.NONE = 0] = "NONE",
i[i.STEP = 1] = "STEP"
}
)(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
var AnimationRange = function() {
function i(e, t, r) {
this.name = e,
this.from = t,
this.to = r
}
return i.prototype.clone = function() {
return new i(this.name,this.from,this.to)
}
,
i
}()
, _InternalNodeDataInfo = function() {
function i() {
this._doNotSerialize = !1,
this._isDisposed = !1,
this._sceneRootNodesIndex = -1,
this._isEnabled = !0,
this._isParentEnabled = !0,
this._isReady = !0,
this._onEnabledStateChangedObservable = new Observable,
this._onClonedObservable = new Observable
}
return i
}()
, Node$2 = function() {
function i(e, t) {
t === void 0 && (t = null),
this._isDirty = !1,
this._nodeDataStorage = new _InternalNodeDataInfo,
this.state = "",
this.metadata = null,
this.reservedDataStore = null,
this._parentContainer = null,
this.animations = new Array,
this._ranges = {},
this.onReady = null,
this._currentRenderId = -1,
this._parentUpdateId = -1,
this._childUpdateId = -1,
this._waitingParentId = null,
this._cache = {},
this._parentNode = null,
this._children = null,
this._worldMatrix = Matrix.Identity(),
this._worldMatrixDeterminant = 0,
this._worldMatrixDeterminantIsDirty = !0,
this._animationPropertiesOverride = null,
this._isNode = !0,
this.onDisposeObservable = new Observable,
this._onDisposeObserver = null,
this._behaviors = new Array,
this.name = e,
this.id = e,
this._scene = t || EngineStore.LastCreatedScene,
this.uniqueId = this._scene.getUniqueId(),
this._initCache()
}
return i.AddNodeConstructor = function(e, t) {
this._NodeConstructors[e] = t
}
,
i.Construct = function(e, t, r, n) {
var o = this._NodeConstructors[e];
return o ? o(t, r, n) : null
}
,
Object.defineProperty(i.prototype, "doNotSerialize", {
get: function() {
return this._nodeDataStorage._doNotSerialize ? !0 : this._parentNode ? this._parentNode.doNotSerialize : !1
},
set: function(e) {
this._nodeDataStorage._doNotSerialize = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.isDisposed = function() {
return this._nodeDataStorage._isDisposed
}
,
Object.defineProperty(i.prototype, "parent", {
get: function() {
return this._parentNode
},
set: function(e) {
if (this._parentNode !== e) {
var t = this._parentNode;
if (this._parentNode && this._parentNode._children !== void 0 && this._parentNode._children !== null) {
var r = this._parentNode._children.indexOf(this);
r !== -1 && this._parentNode._children.splice(r, 1),
!e && !this._nodeDataStorage._isDisposed && this._addToSceneRootNodes()
}
this._parentNode = e,
this._parentNode && ((this._parentNode._children === void 0 || this._parentNode._children === null) && (this._parentNode._children = new Array),
this._parentNode._children.push(this),
t || this._removeFromSceneRootNodes()),
this._syncParentEnabledState()
}
},
enumerable: !1,
configurable: !0
}),
i.prototype._addToSceneRootNodes = function() {
this._nodeDataStorage._sceneRootNodesIndex === -1 && (this._nodeDataStorage._sceneRootNodesIndex = this._scene.rootNodes.length,
this._scene.rootNodes.push(this))
}
,
i.prototype._removeFromSceneRootNodes = function() {
if (this._nodeDataStorage._sceneRootNodesIndex !== -1) {
var e = this._scene.rootNodes
, t = e.length - 1;
e[this._nodeDataStorage._sceneRootNodesIndex] = e[t],
e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex = this._nodeDataStorage._sceneRootNodesIndex,
this._scene.rootNodes.pop(),
this._nodeDataStorage._sceneRootNodesIndex = -1
}
}
,
Object.defineProperty(i.prototype, "animationPropertiesOverride", {
get: function() {
return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
},
set: function(e) {
this._animationPropertiesOverride = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.getClassName = function() {
return "Node"
}
,
Object.defineProperty(i.prototype, "onDispose", {
set: function(e) {
this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
this._onDisposeObserver = this.onDisposeObservable.add(e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onEnabledStateChangedObservable", {
get: function() {
return this._nodeDataStorage._onEnabledStateChangedObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onClonedObservable", {
get: function() {
return this._nodeDataStorage._onClonedObservable
},
enumerable: !1,
configurable: !0
}),
i.prototype.getScene = function() {
return this._scene
}
,
i.prototype.getEngine = function() {
return this._scene.getEngine()
}
,
i.prototype.addBehavior = function(e, t) {
var r = this;
t === void 0 && (t = !1);
var n = this._behaviors.indexOf(e);
return n !== -1 ? this : (e.init(),
this._scene.isLoading && !t ? this._scene.onDataLoadedObservable.addOnce(function() {
e.attach(r)
}) : e.attach(this),
this._behaviors.push(e),
this)
}
,
i.prototype.removeBehavior = function(e) {
var t = this._behaviors.indexOf(e);
return t === -1 ? this : (this._behaviors[t].detach(),
this._behaviors.splice(t, 1),
this)
}
,
Object.defineProperty(i.prototype, "behaviors", {
get: function() {
return this._behaviors
},
enumerable: !1,
configurable: !0
}),
i.prototype.getBehaviorByName = function(e) {
for (var t = 0, r = this._behaviors; t < r.length; t++) {
var n = r[t];
if (n.name === e)
return n
}
return null
}
,
i.prototype.getWorldMatrix = function() {
return this._currentRenderId !== this._scene.getRenderId() && this.computeWorldMatrix(),
this._worldMatrix
}
,
i.prototype._getWorldMatrixDeterminant = function() {
return this._worldMatrixDeterminantIsDirty && (this._worldMatrixDeterminantIsDirty = !1,
this._worldMatrixDeterminant = this._worldMatrix.determinant()),
this._worldMatrixDeterminant
}
,
Object.defineProperty(i.prototype, "worldMatrixFromCache", {
get: function() {
return this._worldMatrix
},
enumerable: !1,
configurable: !0
}),
i.prototype._initCache = function() {
this._cache = {},
this._cache.parent = void 0
}
,
i.prototype.updateCache = function(e) {
!e && this.isSynchronized() || (this._cache.parent = this.parent,
this._updateCache())
}
,
i.prototype._getActionManagerForTrigger = function(e, t) {
return this.parent ? this.parent._getActionManagerForTrigger(e, !1) : null
}
,
i.prototype._updateCache = function(e) {}
,
i.prototype._isSynchronized = function() {
return !0
}
,
i.prototype._markSyncedWithParent = function() {
this._parentNode && (this._parentUpdateId = this._parentNode._childUpdateId)
}
,
i.prototype.isSynchronizedWithParent = function() {
return this._parentNode ? this._parentUpdateId !== this._parentNode._childUpdateId ? !1 : this._parentNode.isSynchronized() : !0
}
,
i.prototype.isSynchronized = function() {
return this._cache.parent != this._parentNode ? (this._cache.parent = this._parentNode,
!1) : this._parentNode && !this.isSynchronizedWithParent() ? !1 : this._isSynchronized()
}
,
i.prototype.isReady = function(e) {
return this._nodeDataStorage._isReady
}
,
i.prototype.markAsDirty = function(e) {
return this._currentRenderId = Number.MAX_VALUE,
this._isDirty = !0,
this
}
,
i.prototype.isEnabled = function(e) {
return e === void 0 && (e = !0),
e === !1 ? this._nodeDataStorage._isEnabled : this._nodeDataStorage._isEnabled ? this._nodeDataStorage._isParentEnabled : !1
}
,
i.prototype._syncParentEnabledState = function() {
this._nodeDataStorage._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : !0,
this._children && this._children.forEach(function(e) {
e._syncParentEnabledState()
})
}
,
i.prototype.setEnabled = function(e) {
this._nodeDataStorage._isEnabled !== e && (this._nodeDataStorage._isEnabled = e,
this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e),
this._syncParentEnabledState())
}
,
i.prototype.isDescendantOf = function(e) {
return this.parent ? this.parent === e ? !0 : this.parent.isDescendantOf(e) : !1
}
,
i.prototype._getDescendants = function(e, t, r) {
if (t === void 0 && (t = !1),
!!this._children)
for (var n = 0; n < this._children.length; n++) {
var o = this._children[n];
(!r || r(o)) && e.push(o),
t || o._getDescendants(e, !1, r)
}
}
,
i.prototype.getDescendants = function(e, t) {
var r = new Array;
return this._getDescendants(r, e, t),
r
}
,
i.prototype.getChildMeshes = function(e, t) {
var r = [];
return this._getDescendants(r, e, function(n) {
return (!t || t(n)) && n.cullingStrategy !== void 0
}),
r
}
,
i.prototype.getChildren = function(e, t) {
return t === void 0 && (t = !0),
this.getDescendants(t, e)
}
,
i.prototype._setReady = function(e) {
if (e !== this._nodeDataStorage._isReady) {
if (!e) {
this._nodeDataStorage._isReady = !1;
return
}
this.onReady && this.onReady(this),
this._nodeDataStorage._isReady = !0
}
}
,
i.prototype.getAnimationByName = function(e) {
for (var t = 0; t < this.animations.length; t++) {
var r = this.animations[t];
if (r.name === e)
return r
}
return null
}
,
i.prototype.createAnimationRange = function(e, t, r) {
if (!this._ranges[e]) {
this._ranges[e] = i._AnimationRangeFactory(e, t, r);
for (var n = 0, o = this.animations.length; n < o; n++)
this.animations[n] && this.animations[n].createRange(e, t, r)
}
}
,
i.prototype.deleteAnimationRange = function(e, t) {
t === void 0 && (t = !0);
for (var r = 0, n = this.animations.length; r < n; r++)
this.animations[r] && this.animations[r].deleteRange(e, t);
this._ranges[e] = null
}
,
i.prototype.getAnimationRange = function(e) {
return this._ranges[e] || null
}
,
i.prototype.getAnimationRanges = function() {
var e = [], t;
for (t in this._ranges)
e.push(this._ranges[t]);
return e
}
,
i.prototype.beginAnimation = function(e, t, r, n) {
var o = this.getAnimationRange(e);
return o ? this._scene.beginAnimation(this, o.from, o.to, t, r, n) : null
}
,
i.prototype.serializeAnimationRanges = function() {
var e = [];
for (var t in this._ranges) {
var r = this._ranges[t];
if (!!r) {
var n = {};
n.name = t,
n.from = r.from,
n.to = r.to,
e.push(n)
}
}
return e
}
,
i.prototype.computeWorldMatrix = function(e) {
return this._worldMatrix || (this._worldMatrix = Matrix.Identity()),
this._worldMatrix
}
,
i.prototype.dispose = function(e, t) {
if (t === void 0 && (t = !1),
this._nodeDataStorage._isDisposed = !0,
!e)
for (var r = this.getDescendants(!0), n = 0, o = r; n < o.length; n++) {
var a = o[n];
a.dispose(e, t)
}
this.parent ? this.parent = null : this._removeFromSceneRootNodes(),
this.onDisposeObservable.notifyObservers(this),
this.onDisposeObservable.clear(),
this.onEnabledStateChangedObservable.clear(),
this.onClonedObservable.clear();
for (var s = 0, l = this._behaviors; s < l.length; s++) {
var u = l[s];
u.detach()
}
this._behaviors = [],
this.metadata = null
}
,
i.ParseAnimationRanges = function(e, t, r) {
if (t.ranges)
for (var n = 0; n < t.ranges.length; n++) {
var o = t.ranges[n];
e.createAnimationRange(o.name, o.from, o.to)
}
}
,
i.prototype.getHierarchyBoundingVectors = function(e, t) {
e === void 0 && (e = !0),
t === void 0 && (t = null),
this.getScene().incrementRenderId(),
this.computeWorldMatrix(!0);
var r, n, o = this;
if (o.getBoundingInfo && o.subMeshes) {
var a = o.getBoundingInfo();
r = a.boundingBox.minimumWorld.clone(),
n = a.boundingBox.maximumWorld.clone()
} else
r = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
n = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
if (e)
for (var s = this.getDescendants(!1), l = 0, u = s; l < u.length; l++) {
var c = u[l]
, h = c;
if (h.computeWorldMatrix(!0),
!(t && !t(h)) && !(!h.getBoundingInfo || h.getTotalVertices() === 0)) {
var f = h.getBoundingInfo()
, d = f.boundingBox
, _ = d.minimumWorld
, g = d.maximumWorld;
Vector3.CheckExtends(_, r, n),
Vector3.CheckExtends(g, r, n)
}
}
return {
min: r,
max: n
}
}
,
i._AnimationRangeFactory = function(e, t, r) {
throw _WarnImport("AnimationRange")
}
,
i._NodeConstructors = {},
__decorate([serialize()], i.prototype, "name", void 0),
__decorate([serialize()], i.prototype, "id", void 0),
__decorate([serialize()], i.prototype, "uniqueId", void 0),
__decorate([serialize()], i.prototype, "state", void 0),
__decorate([serialize()], i.prototype, "metadata", void 0),
i
}()
, Size = function() {
function i(e, t) {
this.width = e,
this.height = t
}
return i.prototype.toString = function() {
return "{W: " + this.width + ", H: " + this.height + "}"
}
,
i.prototype.getClassName = function() {
return "Size"
}
,
i.prototype.getHashCode = function() {
var e = this.width | 0;
return e = e * 397 ^ (this.height | 0),
e
}
,
i.prototype.copyFrom = function(e) {
this.width = e.width,
this.height = e.height
}
,
i.prototype.copyFromFloats = function(e, t) {
return this.width = e,
this.height = t,
this
}
,
i.prototype.set = function(e, t) {
return this.copyFromFloats(e, t)
}
,
i.prototype.multiplyByFloats = function(e, t) {
return new i(this.width * e,this.height * t)
}
,
i.prototype.clone = function() {
return new i(this.width,this.height)
}
,
i.prototype.equals = function(e) {
return e ? this.width === e.width && this.height === e.height : !1
}
,
Object.defineProperty(i.prototype, "surface", {
get: function() {
return this.width * this.height
},
enumerable: !1,
configurable: !0
}),
i.Zero = function() {
return new i(0,0)
}
,
i.prototype.add = function(e) {
var t = new i(this.width + e.width,this.height + e.height);
return t
}
,
i.prototype.subtract = function(e) {
var t = new i(this.width - e.width,this.height - e.height);
return t
}
,
i.Lerp = function(e, t, r) {
var n = e.width + (t.width - e.width) * r
, o = e.height + (t.height - e.height) * r;
return new i(n,o)
}
,
i
}()
, Animation = function() {
function i(e, t, r, n, o, a) {
this.name = e,
this.targetProperty = t,
this.framePerSecond = r,
this.dataType = n,
this.loopMode = o,
this.enableBlending = a,
this._runtimeAnimations = new Array,
this._events = new Array,
this.blendingSpeed = .01,
this._ranges = {},
this.targetPropertyPath = t.split("."),
this.dataType = n,
this.loopMode = o === void 0 ? i.ANIMATIONLOOPMODE_CYCLE : o,
this.uniqueId = i._UniqueIdGenerator++
}
return i._PrepareAnimation = function(e, t, r, n, o, a, s, l) {
var u = void 0;
if (!isNaN(parseFloat(o)) && isFinite(o) ? u = i.ANIMATIONTYPE_FLOAT : o instanceof Quaternion ? u = i.ANIMATIONTYPE_QUATERNION : o instanceof Vector3 ? u = i.ANIMATIONTYPE_VECTOR3 : o instanceof Vector2 ? u = i.ANIMATIONTYPE_VECTOR2 : o instanceof Color3 ? u = i.ANIMATIONTYPE_COLOR3 : o instanceof Color4 ? u = i.ANIMATIONTYPE_COLOR4 : o instanceof Size && (u = i.ANIMATIONTYPE_SIZE),
u == null)
return null;
var c = new i(e,t,r,u,s)
, h = [{
frame: 0,
value: o
}, {
frame: n,
value: a
}];
return c.setKeys(h),
l !== void 0 && c.setEasingFunction(l),
c
}
,
i.CreateAnimation = function(e, t, r, n) {
var o = new i(e + "Animation",e,r,t,i.ANIMATIONLOOPMODE_CONSTANT);
return o.setEasingFunction(n),
o
}
,
i.CreateAndStartAnimation = function(e, t, r, n, o, a, s, l, u, c, h) {
var f = i._PrepareAnimation(e, r, n, o, a, s, l, u);
return !f || (t.getScene && (h = t.getScene()),
!h) ? null : h.beginDirectAnimation(t, [f], 0, o, f.loopMode === 1, 1, c)
}
,
i.CreateAndStartHierarchyAnimation = function(e, t, r, n, o, a, s, l, u, c, h) {
var f = i._PrepareAnimation(e, n, o, a, s, l, u, c);
if (!f)
return null;
var d = t.getScene();
return d.beginDirectHierarchyAnimation(t, r, [f], 0, a, f.loopMode === 1, 1, h)
}
,
i.CreateMergeAndStartAnimation = function(e, t, r, n, o, a, s, l, u, c) {
var h = i._PrepareAnimation(e, r, n, o, a, s, l, u);
return h ? (t.animations.push(h),
t.getScene().beginAnimation(t, 0, o, h.loopMode === 1, 1, c)) : null
}
,
i.MakeAnimationAdditive = function(e, t, r, n, o) {
t === void 0 && (t = 0),
n === void 0 && (n = !1);
var a = e;
if (n && (a = e.clone(),
a.name = o || a.name),
!a._keys.length)
return a;
t = t >= 0 ? t : 0;
var s = 0
, l = a._keys[0]
, u = a._keys.length - 1
, c = a._keys[u]
, h = {
referenceValue: l.value,
referencePosition: TmpVectors.Vector3[0],
referenceQuaternion: TmpVectors.Quaternion[0],
referenceScaling: TmpVectors.Vector3[1],
keyPosition: TmpVectors.Vector3[2],
keyQuaternion: TmpVectors.Quaternion[1],
keyScaling: TmpVectors.Vector3[3]
}
, f = !1
, d = l.frame
, _ = c.frame;
if (r) {
var g = a.getRange(r);
g && (d = g.from,
_ = g.to)
}
var m = l.frame === d
, v = c.frame === _;
if (a._keys.length === 1) {
var y = a._getKeyValue(a._keys[0]);
h.referenceValue = y.clone ? y.clone() : y,
f = !0
} else if (t <= l.frame) {
var y = a._getKeyValue(l.value);
h.referenceValue = y.clone ? y.clone() : y,
f = !0
} else if (t >= c.frame) {
var y = a._getKeyValue(c.value);
h.referenceValue = y.clone ? y.clone() : y,
f = !0
}
for (var b = 0; !f || !m || !v && b < a._keys.length - 1; ) {
var T = a._keys[b]
, C = a._keys[b + 1];
if (!f && t >= T.frame && t <= C.frame) {
var y = void 0;
if (t === T.frame)
y = a._getKeyValue(T.value);
else if (t === C.frame)
y = a._getKeyValue(C.value);
else {
var A = {
key: b,
repeatCount: 0,
loopMode: this.ANIMATIONLOOPMODE_CONSTANT
};
y = a._interpolate(t, A)
}
h.referenceValue = y.clone ? y.clone() : y,
f = !0
}
if (!m && d >= T.frame && d <= C.frame) {
if (d === T.frame)
s = b;
else if (d === C.frame)
s = b + 1;
else {
var A = {
key: b,
repeatCount: 0,
loopMode: this.ANIMATIONLOOPMODE_CONSTANT
}
, y = a._interpolate(d, A)
, S = {
frame: d,
value: y.clone ? y.clone() : y
};
a._keys.splice(b + 1, 0, S),
s = b + 1
}
m = !0
}
if (!v && _ >= T.frame && _ <= C.frame) {
if (_ === T.frame)
u = b;
else if (_ === C.frame)
u = b + 1;
else {
var A = {
key: b,
repeatCount: 0,
loopMode: this.ANIMATIONLOOPMODE_CONSTANT
}
, y = a._interpolate(_, A)
, S = {
frame: _,
value: y.clone ? y.clone() : y
};
a._keys.splice(b + 1, 0, S),
u = b + 1
}
v = !0
}
b++
}
a.dataType === i.ANIMATIONTYPE_QUATERNION ? h.referenceValue.normalize().conjugateInPlace() : a.dataType === i.ANIMATIONTYPE_MATRIX && (h.referenceValue.decompose(h.referenceScaling, h.referenceQuaternion, h.referencePosition),
h.referenceQuaternion.normalize().conjugateInPlace());
for (var b = s; b <= u; b++) {
var S = a._keys[b];
if (!(b && a.dataType !== i.ANIMATIONTYPE_FLOAT && S.value === l.value))
switch (a.dataType) {
case i.ANIMATIONTYPE_MATRIX:
S.value.decompose(h.keyScaling, h.keyQuaternion, h.keyPosition),
h.keyPosition.subtractInPlace(h.referencePosition),
h.keyScaling.divideInPlace(h.referenceScaling),
h.referenceQuaternion.multiplyToRef(h.keyQuaternion, h.keyQuaternion),
Matrix.ComposeToRef(h.keyScaling, h.keyQuaternion, h.keyPosition, S.value);
break;
case i.ANIMATIONTYPE_QUATERNION:
h.referenceValue.multiplyToRef(S.value, S.value);
break;
case i.ANIMATIONTYPE_VECTOR2:
case i.ANIMATIONTYPE_VECTOR3:
case i.ANIMATIONTYPE_COLOR3:
case i.ANIMATIONTYPE_COLOR4:
S.value.subtractToRef(h.referenceValue, S.value);
break;
case i.ANIMATIONTYPE_SIZE:
S.value.width -= h.referenceValue.width,
S.value.height -= h.referenceValue.height;
break;
default:
S.value -= h.referenceValue
}
}
return a
}
,
i.TransitionTo = function(e, t, r, n, o, a, s, l) {
if (l === void 0 && (l = null),
s <= 0)
return r[e] = t,
l && l(),
null;
var u = o * (s / 1e3);
a.setKeys([{
frame: 0,
value: r[e].clone ? r[e].clone() : r[e]
}, {
frame: u,
value: t
}]),
r.animations || (r.animations = []),
r.animations.push(a);
var c = n.beginAnimation(r, 0, u, !1);
return c.onAnimationEnd = l,
c
}
,
Object.defineProperty(i.prototype, "runtimeAnimations", {
get: function() {
return this._runtimeAnimations
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "hasRunningRuntimeAnimations", {
get: function() {
for (var e = 0, t = this._runtimeAnimations; e < t.length; e++) {
var r = t[e];
if (!r.isStopped())
return !0
}
return !1
},
enumerable: !1,
configurable: !0
}),
i.prototype.toString = function(e) {
var t = "Name: " + this.name + ", property: " + this.targetProperty;
if (t += ", datatype: " + ["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"][this.dataType],
t += ", nKeys: " + (this._keys ? this._keys.length : "none"),
t += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"),
e) {
t += ", Ranges: {";
var r = !0;
for (var n in this._ranges)
r && (t += ", ",
r = !1),
t += n;
t += "}"
}
return t
}
,
i.prototype.addEvent = function(e) {
this._events.push(e),
this._events.sort(function(t, r) {
return t.frame - r.frame
})
}
,
i.prototype.removeEvents = function(e) {
for (var t = 0; t < this._events.length; t++)
this._events[t].frame === e && (this._events.splice(t, 1),
t--)
}
,
i.prototype.getEvents = function() {
return this._events
}
,
i.prototype.createRange = function(e, t, r) {
this._ranges[e] || (this._ranges[e] = new AnimationRange(e,t,r))
}
,
i.prototype.deleteRange = function(e, t) {
t === void 0 && (t = !0);
var r = this._ranges[e];
if (!!r) {
if (t)
for (var n = r.from, o = r.to, a = this._keys.length - 1; a >= 0; a--)
this._keys[a].frame >= n && this._keys[a].frame <= o && this._keys.splice(a, 1);
this._ranges[e] = null
}
}
,
i.prototype.getRange = function(e) {
return this._ranges[e]
}
,
i.prototype.getKeys = function() {
return this._keys
}
,
i.prototype.getHighestFrame = function() {
for (var e = 0, t = 0, r = this._keys.length; t < r; t++)
e < this._keys[t].frame && (e = this._keys[t].frame);
return e
}
,
i.prototype.getEasingFunction = function() {
return this._easingFunction
}
,
i.prototype.setEasingFunction = function(e) {
this._easingFunction = e
}
,
i.prototype.floatInterpolateFunction = function(e, t, r) {
return Scalar.Lerp(e, t, r)
}
,
i.prototype.floatInterpolateFunctionWithTangents = function(e, t, r, n, o) {
return Scalar.Hermite(e, t, r, n, o)
}
,
i.prototype.quaternionInterpolateFunction = function(e, t, r) {
return Quaternion.Slerp(e, t, r)
}
,
i.prototype.quaternionInterpolateFunctionWithTangents = function(e, t, r, n, o) {
return Quaternion.Hermite(e, t, r, n, o).normalize()
}
,
i.prototype.vector3InterpolateFunction = function(e, t, r) {
return Vector3.Lerp(e, t, r)
}
,
i.prototype.vector3InterpolateFunctionWithTangents = function(e, t, r, n, o) {
return Vector3.Hermite(e, t, r, n, o)
}
,
i.prototype.vector2InterpolateFunction = function(e, t, r) {
return Vector2.Lerp(e, t, r)
}
,
i.prototype.vector2InterpolateFunctionWithTangents = function(e, t, r, n, o) {
return Vector2.Hermite(e, t, r, n, o)
}
,
i.prototype.sizeInterpolateFunction = function(e, t, r) {
return Size.Lerp(e, t, r)
}
,
i.prototype.color3InterpolateFunction = function(e, t, r) {
return Color3.Lerp(e, t, r)
}
,
i.prototype.color3InterpolateFunctionWithTangents = function(e, t, r, n, o) {
return Color3.Hermite(e, t, r, n, o)
}
,
i.prototype.color4InterpolateFunction = function(e, t, r) {
return Color4.Lerp(e, t, r)
}
,
i.prototype.color4InterpolateFunctionWithTangents = function(e, t, r, n, o) {
return Color4.Hermite(e, t, r, n, o)
}
,
i.prototype._getKeyValue = function(e) {
return typeof e == "function" ? e() : e
}
,
i.prototype.evaluate = function(e) {
return this._interpolate(e, {
key: 0,
repeatCount: 0,
loopMode: i.ANIMATIONLOOPMODE_CONSTANT
})
}
,
i.prototype._interpolate = function(e, t) {
if (t.loopMode === i.ANIMATIONLOOPMODE_CONSTANT && t.repeatCount > 0)
return t.highLimitValue.clone ? t.highLimitValue.clone() : t.highLimitValue;
var r = this._keys;
if (r.length === 1)
return this._getKeyValue(r[0].value);
var n = t.key;
if (r[n].frame >= e)
for (; n - 1 >= 0 && r[n].frame >= e; )
n--;
for (var o = n; o < r.length - 1; o++) {
var a = r[o + 1];
if (a.frame >= e) {
t.key = o;
var s = r[o]
, l = this._getKeyValue(s.value)
, u = this._getKeyValue(a.value);
if (s.interpolation === AnimationKeyInterpolation.STEP)
return a.frame > e ? l : u;
var c = s.outTangent !== void 0 && a.inTangent !== void 0
, h = a.frame - s.frame
, f = (e - s.frame) / h
, d = this.getEasingFunction();
switch (d != null && (f = d.ease(f)),
this.dataType) {
case i.ANIMATIONTYPE_FLOAT:
var _ = c ? this.floatInterpolateFunctionWithTangents(l, s.outTangent * h, u, a.inTangent * h, f) : this.floatInterpolateFunction(l, u, f);
switch (t.loopMode) {
case i.ANIMATIONLOOPMODE_CYCLE:
case i.ANIMATIONLOOPMODE_CONSTANT:
return _;
case i.ANIMATIONLOOPMODE_RELATIVE:
return t.offsetValue * t.repeatCount + _
}
break;
case i.ANIMATIONTYPE_QUATERNION:
var g = c ? this.quaternionInterpolateFunctionWithTangents(l, s.outTangent.scale(h), u, a.inTangent.scale(h), f) : this.quaternionInterpolateFunction(l, u, f);
switch (t.loopMode) {
case i.ANIMATIONLOOPMODE_CYCLE:
case i.ANIMATIONLOOPMODE_CONSTANT:
return g;
case i.ANIMATIONLOOPMODE_RELATIVE:
return g.addInPlace(t.offsetValue.scale(t.repeatCount))
}
return g;
case i.ANIMATIONTYPE_VECTOR3:
var m = c ? this.vector3InterpolateFunctionWithTangents(l, s.outTangent.scale(h), u, a.inTangent.scale(h), f) : this.vector3InterpolateFunction(l, u, f);
switch (t.loopMode) {
case i.ANIMATIONLOOPMODE_CYCLE:
case i.ANIMATIONLOOPMODE_CONSTANT:
return m;
case i.ANIMATIONLOOPMODE_RELATIVE:
return m.add(t.offsetValue.scale(t.repeatCount))
}
case i.ANIMATIONTYPE_VECTOR2:
var v = c ? this.vector2InterpolateFunctionWithTangents(l, s.outTangent.scale(h), u, a.inTangent.scale(h), f) : this.vector2InterpolateFunction(l, u, f);
switch (t.loopMode) {
case i.ANIMATIONLOOPMODE_CYCLE:
case i.ANIMATIONLOOPMODE_CONSTANT:
return v;
case i.ANIMATIONLOOPMODE_RELATIVE:
return v.add(t.offsetValue.scale(t.repeatCount))
}
case i.ANIMATIONTYPE_SIZE:
switch (t.loopMode) {
case i.ANIMATIONLOOPMODE_CYCLE:
case i.ANIMATIONLOOPMODE_CONSTANT:
return this.sizeInterpolateFunction(l, u, f);
case i.ANIMATIONLOOPMODE_RELATIVE:
return this.sizeInterpolateFunction(l, u, f).add(t.offsetValue.scale(t.repeatCount))
}
case i.ANIMATIONTYPE_COLOR3:
var y = c ? this.color3InterpolateFunctionWithTangents(l, s.outTangent.scale(h), u, a.inTangent.scale(h), f) : this.color3InterpolateFunction(l, u, f);
switch (t.loopMode) {
case i.ANIMATIONLOOPMODE_CYCLE:
case i.ANIMATIONLOOPMODE_CONSTANT:
return y;
case i.ANIMATIONLOOPMODE_RELATIVE:
return y.add(t.offsetValue.scale(t.repeatCount))
}
case i.ANIMATIONTYPE_COLOR4:
var b = c ? this.color4InterpolateFunctionWithTangents(l, s.outTangent.scale(h), u, a.inTangent.scale(h), f) : this.color4InterpolateFunction(l, u, f);
switch (t.loopMode) {
case i.ANIMATIONLOOPMODE_CYCLE:
case i.ANIMATIONLOOPMODE_CONSTANT:
return b;
case i.ANIMATIONLOOPMODE_RELATIVE:
return b.add(t.offsetValue.scale(t.repeatCount))
}
case i.ANIMATIONTYPE_MATRIX:
switch (t.loopMode) {
case i.ANIMATIONLOOPMODE_CYCLE:
case i.ANIMATIONLOOPMODE_CONSTANT:
if (i.AllowMatricesInterpolation)
return this.matrixInterpolateFunction(l, u, f, t.workValue);
case i.ANIMATIONLOOPMODE_RELATIVE:
return l
}
}
break
}
}
return this._getKeyValue(r[r.length - 1].value)
}
,
i.prototype.matrixInterpolateFunction = function(e, t, r, n) {
return i.AllowMatrixDecomposeForInterpolation ? n ? (Matrix.DecomposeLerpToRef(e, t, r, n),
n) : Matrix.DecomposeLerp(e, t, r) : n ? (Matrix.LerpToRef(e, t, r, n),
n) : Matrix.Lerp(e, t, r)
}
,
i.prototype.clone = function() {
var e = new i(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);
if (e.enableBlending = this.enableBlending,
e.blendingSpeed = this.blendingSpeed,
this._keys && e.setKeys(this._keys),
this._ranges) {
e._ranges = {};
for (var t in this._ranges) {
var r = this._ranges[t];
!r || (e._ranges[t] = r.clone())
}
}
return e
}
,
i.prototype.setKeys = function(e) {
this._keys = e.slice(0)
}
,
i.prototype.serialize = function() {
var e = {};
e.name = this.name,
e.property = this.targetProperty,
e.framePerSecond = this.framePerSecond,
e.dataType = this.dataType,
e.loopBehavior = this.loopMode,
e.enableBlending = this.enableBlending,
e.blendingSpeed = this.blendingSpeed;
var t = this.dataType;
e.keys = [];
for (var r = this.getKeys(), n = 0; n < r.length; n++) {
var o = r[n]
, a = {};
switch (a.frame = o.frame,
t) {
case i.ANIMATIONTYPE_FLOAT:
a.values = [o.value],
o.inTangent !== void 0 && a.values.push(o.inTangent),
o.outTangent !== void 0 && (o.inTangent === void 0 && a.values.push(void 0),
a.values.push(o.outTangent));
break;
case i.ANIMATIONTYPE_QUATERNION:
case i.ANIMATIONTYPE_MATRIX:
case i.ANIMATIONTYPE_VECTOR3:
case i.ANIMATIONTYPE_COLOR3:
case i.ANIMATIONTYPE_COLOR4:
a.values = o.value.asArray(),
o.inTangent != null && a.values.push(o.inTangent.asArray()),
o.outTangent != null && (o.inTangent === void 0 && a.values.push(void 0),
a.values.push(o.outTangent.asArray()));
break
}
e.keys.push(a)
}
e.ranges = [];
for (var s in this._ranges) {
var l = this._ranges[s];
if (!!l) {
var u = {};
u.name = s,
u.from = l.from,
u.to = l.to,
e.ranges.push(u)
}
}
return e
}
,
i._UniversalLerp = function(e, t, r) {
var n = e.constructor;
return n.Lerp ? n.Lerp(e, t, r) : n.Slerp ? n.Slerp(e, t, r) : e.toFixed ? e * (1 - r) + r * t : t
}
,
i.Parse = function(e) {
var t = new i(e.name,e.property,e.framePerSecond,e.dataType,e.loopBehavior), r = e.dataType, n = [], o, a;
for (e.enableBlending && (t.enableBlending = e.enableBlending),
e.blendingSpeed && (t.blendingSpeed = e.blendingSpeed),
a = 0; a < e.keys.length; a++) {
var s = e.keys[a]
, l = void 0
, u = void 0;
switch (r) {
case i.ANIMATIONTYPE_FLOAT:
o = s.values[0],
s.values.length >= 1 && (l = s.values[1]),
s.values.length >= 2 && (u = s.values[2]);
break;
case i.ANIMATIONTYPE_QUATERNION:
if (o = Quaternion.FromArray(s.values),
s.values.length >= 8) {
var c = Quaternion.FromArray(s.values.slice(4, 8));
c.equals(Quaternion.Zero()) || (l = c)
}
if (s.values.length >= 12) {
var h = Quaternion.FromArray(s.values.slice(8, 12));
h.equals(Quaternion.Zero()) || (u = h)
}
break;
case i.ANIMATIONTYPE_MATRIX:
o = Matrix.FromArray(s.values);
break;
case i.ANIMATIONTYPE_COLOR3:
o = Color3.FromArray(s.values),
s.values[3] && (l = Color3.FromArray(s.values[3])),
s.values[4] && (u = Color3.FromArray(s.values[4]));
break;
case i.ANIMATIONTYPE_COLOR4:
o = Color4.FromArray(s.values),
s.values[4] && (l = Color4.FromArray(s.values[4])),
s.values[5] && (u = Color4.FromArray(s.values[5]));
break;
case i.ANIMATIONTYPE_VECTOR3:
default:
o = Vector3.FromArray(s.values),
s.values[3] && (l = Vector3.FromArray(s.values[3])),
s.values[4] && (u = Vector3.FromArray(s.values[4]));
break
}
var f = {};
f.frame = s.frame,
f.value = o,
l != null && (f.inTangent = l),
u != null && (f.outTangent = u),
n.push(f)
}
if (t.setKeys(n),
e.ranges)
for (a = 0; a < e.ranges.length; a++)
o = e.ranges[a],
t.createRange(o.name, o.from, o.to);
return t
}
,
i.AppendSerializedAnimations = function(e, t) {
SerializationHelper.AppendSerializedAnimations(e, t)
}
,
i.ParseFromFileAsync = function(e, t) {
var r = this;
return new Promise(function(n, o) {
var a = new WebRequest;
a.addEventListener("readystatechange", function() {
if (a.readyState == 4)
if (a.status == 200) {
var s = JSON.parse(a.responseText);
if (s.length) {
for (var l = new Array, u = 0, c = s; u < c.length; u++) {
var h = c[u];
l.push(r.Parse(h))
}
n(l)
} else {
var l = r.Parse(s);
e && (l.name = e),
n(l)
}
} else
o("Unable to load the animation")
}),
a.open("GET", t),
a.send()
}
)
}
,
i.CreateFromSnippetAsync = function(e) {
var t = this;
return new Promise(function(r, n) {
var o = new WebRequest;
o.addEventListener("readystatechange", function() {
if (o.readyState == 4)
if (o.status == 200) {
var a = JSON.parse(JSON.parse(o.responseText).jsonPayload);
if (a.animations) {
for (var s = JSON.parse(a.animations), l = new Array, u = 0, c = s.animations; u < c.length; u++) {
var h = c[u]
, f = t.Parse(h);
f.snippetId = e,
l.push(f)
}
r(l)
} else {
var s = JSON.parse(a.animation)
, f = t.Parse(s);
f.snippetId = e,
r(f)
}
} else
n("Unable to load the snippet " + e)
}),
o.open("GET", t.SnippetUrl + "/" + e.replace(/#/g, "/")),
o.send()
}
)
}
,
i._UniqueIdGenerator = 0,
i.AllowMatricesInterpolation = !1,
i.AllowMatrixDecomposeForInterpolation = !0,
i.SnippetUrl = "https://snippet.babylonjs.com",
i.ANIMATIONTYPE_FLOAT = 0,
i.ANIMATIONTYPE_VECTOR3 = 1,
i.ANIMATIONTYPE_QUATERNION = 2,
i.ANIMATIONTYPE_MATRIX = 3,
i.ANIMATIONTYPE_COLOR3 = 4,
i.ANIMATIONTYPE_COLOR4 = 7,
i.ANIMATIONTYPE_VECTOR2 = 5,
i.ANIMATIONTYPE_SIZE = 6,
i.ANIMATIONLOOPMODE_RELATIVE = 0,
i.ANIMATIONLOOPMODE_CYCLE = 1,
i.ANIMATIONLOOPMODE_CONSTANT = 2,
i
}();
RegisterClass("BABYLON.Animation", Animation);
Node$2._AnimationRangeFactory = function(i, e, t) {
return new AnimationRange(i,e,t)
}
;
var _staticOffsetValueQuaternion = Object.freeze(new Quaternion(0,0,0,0)), _staticOffsetValueVector3 = Object.freeze(Vector3.Zero()), _staticOffsetValueVector2 = Object.freeze(Vector2.Zero()), _staticOffsetValueSize = Object.freeze(Size.Zero()), _staticOffsetValueColor3 = Object.freeze(Color3.Black()), RuntimeAnimation = function() {
function i(e, t, r, n) {
var o = this;
if (this._events = new Array,
this._currentFrame = 0,
this._originalValue = new Array,
this._originalBlendValue = null,
this._offsetsCache = {},
this._highLimitsCache = {},
this._stopped = !1,
this._blendingFactor = 0,
this._currentValue = null,
this._currentActiveTarget = null,
this._directTarget = null,
this._targetPath = "",
this._weight = 1,
this._ratioOffset = 0,
this._previousDelay = 0,
this._previousRatio = 0,
this._targetIsArray = !1,
this._animation = t,
this._target = e,
this._scene = r,
this._host = n,
this._activeTargets = [],
t._runtimeAnimations.push(this),
this._animationState = {
key: 0,
repeatCount: 0,
loopMode: this._getCorrectLoopMode()
},
this._animation.dataType === Animation.ANIMATIONTYPE_MATRIX && (this._animationState.workValue = Matrix.Zero()),
this._keys = this._animation.getKeys(),
this._minFrame = this._keys[0].frame,
this._maxFrame = this._keys[this._keys.length - 1].frame,
this._minValue = this._keys[0].value,
this._maxValue = this._keys[this._keys.length - 1].value,
this._minFrame !== 0) {
var a = {
frame: 0,
value: this._minValue
};
this._keys.splice(0, 0, a)
}
if (this._target instanceof Array) {
for (var s = 0, l = 0, u = this._target; l < u.length; l++) {
var c = u[l];
this._preparePath(c, s),
this._getOriginalValues(s),
s++
}
this._targetIsArray = !0
} else
this._preparePath(this._target),
this._getOriginalValues(),
this._targetIsArray = !1,
this._directTarget = this._activeTargets[0];
var h = t.getEvents();
h && h.length > 0 && h.forEach(function(f) {
o._events.push(f._clone())
}),
this._enableBlending = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.enableBlending : this._animation.enableBlending
}
return Object.defineProperty(i.prototype, "currentFrame", {
get: function() {
return this._currentFrame
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "weight", {
get: function() {
return this._weight
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "currentValue", {
get: function() {
return this._currentValue
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "targetPath", {
get: function() {
return this._targetPath
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "target", {
get: function() {
return this._currentActiveTarget
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isAdditive", {
get: function() {
return this._host && this._host.isAdditive
},
enumerable: !1,
configurable: !0
}),
i.prototype._preparePath = function(e, t) {
t === void 0 && (t = 0);
var r = this._animation.targetPropertyPath;
if (r.length > 1) {
for (var n = e[r[0]], o = 1; o < r.length - 1; o++)
n = n[r[o]];
this._targetPath = r[r.length - 1],
this._activeTargets[t] = n
} else
this._targetPath = r[0],
this._activeTargets[t] = e
}
,
Object.defineProperty(i.prototype, "animation", {
get: function() {
return this._animation
},
enumerable: !1,
configurable: !0
}),
i.prototype.reset = function(e) {
if (e === void 0 && (e = !1),
e)
if (this._target instanceof Array)
for (var t = 0, r = 0, n = this._target; r < n.length; r++) {
var o = n[r];
this._originalValue[t] !== void 0 && this._setValue(o, this._activeTargets[t], this._originalValue[t], -1, t),
t++
}
else
this._originalValue[0] !== void 0 && this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
this._offsetsCache = {},
this._highLimitsCache = {},
this._currentFrame = 0,
this._blendingFactor = 0;
for (var t = 0; t < this._events.length; t++)
this._events[t].isDone = !1
}
,
i.prototype.isStopped = function() {
return this._stopped
}
,
i.prototype.dispose = function() {
var e = this._animation.runtimeAnimations.indexOf(this);
e > -1 && this._animation.runtimeAnimations.splice(e, 1)
}
,
i.prototype.setValue = function(e, t) {
if (this._targetIsArray) {
for (var r = 0; r < this._target.length; r++) {
var n = this._target[r];
this._setValue(n, this._activeTargets[r], e, t, r)
}
return
}
this._setValue(this._target, this._directTarget, e, t, 0)
}
,
i.prototype._getOriginalValues = function(e) {
e === void 0 && (e = 0);
var t, r = this._activeTargets[e];
r.getRestPose && this._targetPath === "_matrix" ? t = r.getRestPose() : t = r[this._targetPath],
t && t.clone ? this._originalValue[e] = t.clone() : this._originalValue[e] = t
}
,
i.prototype._setValue = function(e, t, r, n, o) {
if (this._currentActiveTarget = t,
this._weight = n,
this._enableBlending && this._blendingFactor <= 1) {
if (!this._originalBlendValue) {
var a = t[this._targetPath];
a.clone ? this._originalBlendValue = a.clone() : this._originalBlendValue = a
}
this._originalBlendValue.m ? Animation.AllowMatrixDecomposeForInterpolation ? this._currentValue ? Matrix.DecomposeLerpToRef(this._originalBlendValue, r, this._blendingFactor, this._currentValue) : this._currentValue = Matrix.DecomposeLerp(this._originalBlendValue, r, this._blendingFactor) : this._currentValue ? Matrix.LerpToRef(this._originalBlendValue, r, this._blendingFactor, this._currentValue) : this._currentValue = Matrix.Lerp(this._originalBlendValue, r, this._blendingFactor) : this._currentValue = Animation._UniversalLerp(this._originalBlendValue, r, this._blendingFactor);
var s = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
this._blendingFactor += s
} else
this._currentValue ? this._currentValue.copyFrom ? this._currentValue.copyFrom(r) : this._currentValue = r : r != null && r.clone ? this._currentValue = r.clone() : this._currentValue = r;
n !== -1 ? this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[o]) : t[this._targetPath] = this._currentValue,
e.markAsDirty && e.markAsDirty(this._animation.targetProperty)
}
,
i.prototype._getCorrectLoopMode = function() {
return this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.loopMode : this._animation.loopMode
}
,
i.prototype.goToFrame = function(e) {
var t = this._animation.getKeys();
e < t[0].frame ? e = t[0].frame : e > t[t.length - 1].frame && (e = t[t.length - 1].frame);
var r = this._events;
if (r.length)
for (var n = 0; n < r.length; n++)
r[n].onlyOnce || (r[n].isDone = r[n].frame < e);
this._currentFrame = e;
var o = this._animation._interpolate(e, this._animationState);
this.setValue(o, -1)
}
,
i.prototype._prepareForSpeedRatioChange = function(e) {
var t = this._previousDelay * (this._animation.framePerSecond * e) / 1e3;
this._ratioOffset = this._previousRatio - t
}
,
i.prototype.animate = function(e, t, r, n, o, a) {
a === void 0 && (a = -1);
var s = this._animation
, l = s.targetPropertyPath;
if (!l || l.length < 1)
return this._stopped = !0,
!1;
var u = !0;
(t < this._minFrame || t > this._maxFrame) && (t = this._minFrame),
(r < this._minFrame || r > this._maxFrame) && (r = this._maxFrame);
var c = r - t, h, f = e * (s.framePerSecond * o) / 1e3 + this._ratioOffset, d = 0;
if (this._previousDelay = e,
this._previousRatio = f,
!n && r >= t && f >= c)
u = !1,
d = s._getKeyValue(this._maxValue);
else if (!n && t >= r && f <= c)
u = !1,
d = s._getKeyValue(this._minValue);
else if (this._animationState.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {
var _ = r.toString() + t.toString();
if (!this._offsetsCache[_]) {
this._animationState.repeatCount = 0,
this._animationState.loopMode = Animation.ANIMATIONLOOPMODE_CYCLE;
var g = s._interpolate(t, this._animationState)
, m = s._interpolate(r, this._animationState);
switch (this._animationState.loopMode = this._getCorrectLoopMode(),
s.dataType) {
case Animation.ANIMATIONTYPE_FLOAT:
this._offsetsCache[_] = m - g;
break;
case Animation.ANIMATIONTYPE_QUATERNION:
this._offsetsCache[_] = m.subtract(g);
break;
case Animation.ANIMATIONTYPE_VECTOR3:
this._offsetsCache[_] = m.subtract(g);
break;
case Animation.ANIMATIONTYPE_VECTOR2:
this._offsetsCache[_] = m.subtract(g);
break;
case Animation.ANIMATIONTYPE_SIZE:
this._offsetsCache[_] = m.subtract(g);
break;
case Animation.ANIMATIONTYPE_COLOR3:
this._offsetsCache[_] = m.subtract(g);
break
}
this._highLimitsCache[_] = m
}
d = this._highLimitsCache[_],
h = this._offsetsCache[_]
}
if (h === void 0)
switch (s.dataType) {
case Animation.ANIMATIONTYPE_FLOAT:
h = 0;
break;
case Animation.ANIMATIONTYPE_QUATERNION:
h = _staticOffsetValueQuaternion;
break;
case Animation.ANIMATIONTYPE_VECTOR3:
h = _staticOffsetValueVector3;
break;
case Animation.ANIMATIONTYPE_VECTOR2:
h = _staticOffsetValueVector2;
break;
case Animation.ANIMATIONTYPE_SIZE:
h = _staticOffsetValueSize;
break;
case Animation.ANIMATIONTYPE_COLOR3:
h = _staticOffsetValueColor3
}
var v;
if (this._host && this._host.syncRoot) {
var y = this._host.syncRoot
, b = (y.masterFrame - y.fromFrame) / (y.toFrame - y.fromFrame);
v = t + (r - t) * b
} else
f > 0 && t > r || f < 0 && t < r ? v = u && c !== 0 ? r + f % c : t : v = u && c !== 0 ? t + f % c : r;
var T = this._events;
if ((o > 0 && this.currentFrame > v || o < 0 && this.currentFrame < v) && (this._onLoop(),
T.length))
for (var C = 0; C < T.length; C++)
T[C].onlyOnce || (T[C].isDone = !1);
this._currentFrame = v,
this._animationState.repeatCount = c === 0 ? 0 : f / c >> 0,
this._animationState.highLimitValue = d,
this._animationState.offsetValue = h;
var A = s._interpolate(v, this._animationState);
if (this.setValue(A, a),
T.length) {
for (var C = 0; C < T.length; C++)
if (c > 0 && v >= T[C].frame && T[C].frame >= t || c < 0 && v <= T[C].frame && T[C].frame <= t) {
var S = T[C];
S.isDone || (S.onlyOnce && (T.splice(C, 1),
C--),
S.isDone = !0,
S.action(v))
}
}
return u || (this._stopped = !0),
u
}
,
i
}(), Space;
(function(i) {
i[i.LOCAL = 0] = "LOCAL",
i[i.WORLD = 1] = "WORLD",
i[i.BONE = 2] = "BONE"
}
)(Space || (Space = {}));
var Axis = function() {
function i() {}
return i.X = new Vector3(1,0,0),
i.Y = new Vector3(0,1,0),
i.Z = new Vector3(0,0,1),
i
}(), Coordinate;
(function(i) {
i[i.X = 0] = "X",
i[i.Y = 1] = "Y",
i[i.Z = 2] = "Z"
}
)(Coordinate || (Coordinate = {}));
var Bone = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l) {
n === void 0 && (n = null),
o === void 0 && (o = null),
a === void 0 && (a = null),
s === void 0 && (s = null),
l === void 0 && (l = null);
var u = i.call(this, t, r.getScene()) || this;
return u.name = t,
u.children = new Array,
u.animations = new Array,
u._index = null,
u._absoluteTransform = new Matrix,
u._invertedAbsoluteTransform = new Matrix,
u._scalingDeterminant = 1,
u._worldTransform = new Matrix,
u._needToDecompose = !0,
u._needToCompose = !1,
u._linkedTransformNode = null,
u._waitingTransformNodeId = null,
u._skeleton = r,
u._localMatrix = o ? o.clone() : Matrix.Identity(),
u._restPose = a || u._localMatrix.clone(),
u._baseMatrix = s || u._localMatrix.clone(),
u._index = l,
r.bones.push(u),
u.setParent(n, !1),
(s || o) && u._updateDifferenceMatrix(),
u
}
return Object.defineProperty(e.prototype, "_matrix", {
get: function() {
return this._compose(),
this._localMatrix
},
set: function(t) {
this._needToCompose = !1,
t.updateFlag !== this._localMatrix.updateFlag && (this._localMatrix.copyFrom(t),
this._markAsDirtyAndDecompose())
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "Bone"
}
,
e.prototype.getSkeleton = function() {
return this._skeleton
}
,
e.prototype.getParent = function() {
return this._parent
}
,
e.prototype.getChildren = function() {
return this.children
}
,
e.prototype.getIndex = function() {
return this._index === null ? this.getSkeleton().bones.indexOf(this) : this._index
}
,
e.prototype.setParent = function(t, r) {
if (r === void 0 && (r = !0),
this._parent !== t) {
if (this._parent) {
var n = this._parent.children.indexOf(this);
n !== -1 && this._parent.children.splice(n, 1)
}
this._parent = t,
this._parent && this._parent.children.push(this),
r && this._updateDifferenceMatrix(),
this.markAsDirty()
}
}
,
e.prototype.getLocalMatrix = function() {
return this._compose(),
this._localMatrix
}
,
e.prototype.getBaseMatrix = function() {
return this._baseMatrix
}
,
e.prototype.getRestPose = function() {
return this._restPose
}
,
e.prototype.setRestPose = function(t) {
this._restPose.copyFrom(t)
}
,
e.prototype.getBindPose = function() {
return this._baseMatrix
}
,
e.prototype.setBindPose = function(t) {
this.updateMatrix(t)
}
,
e.prototype.getWorldMatrix = function() {
return this._worldTransform
}
,
e.prototype.returnToRest = function() {
var t;
if (this._linkedTransformNode) {
var r = TmpVectors.Vector3[0]
, n = TmpVectors.Quaternion[0]
, o = TmpVectors.Vector3[1];
this.getRestPose().decompose(r, n, o),
this._linkedTransformNode.position.copyFrom(o),
this._linkedTransformNode.rotationQuaternion = (t = this._linkedTransformNode.rotationQuaternion) !== null && t !== void 0 ? t : Quaternion.Identity(),
this._linkedTransformNode.rotationQuaternion.copyFrom(n),
this._linkedTransformNode.scaling.copyFrom(r)
} else
this._matrix = this._restPose
}
,
e.prototype.getInvertedAbsoluteTransform = function() {
return this._invertedAbsoluteTransform
}
,
e.prototype.getAbsoluteTransform = function() {
return this._absoluteTransform
}
,
e.prototype.linkTransformNode = function(t) {
this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode--,
this._linkedTransformNode = t,
this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode++
}
,
e.prototype.getTransformNode = function() {
return this._linkedTransformNode
}
,
Object.defineProperty(e.prototype, "position", {
get: function() {
return this._decompose(),
this._localPosition
},
set: function(t) {
this._decompose(),
this._localPosition.copyFrom(t),
this._markAsDirtyAndCompose()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rotation", {
get: function() {
return this.getRotation()
},
set: function(t) {
this.setRotation(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rotationQuaternion", {
get: function() {
return this._decompose(),
this._localRotation
},
set: function(t) {
this.setRotationQuaternion(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "scaling", {
get: function() {
return this.getScale()
},
set: function(t) {
this.setScale(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "animationPropertiesOverride", {
get: function() {
return this._skeleton.animationPropertiesOverride
},
enumerable: !1,
configurable: !0
}),
e.prototype._decompose = function() {
!this._needToDecompose || (this._needToDecompose = !1,
this._localScaling || (this._localScaling = Vector3.Zero(),
this._localRotation = Quaternion.Zero(),
this._localPosition = Vector3.Zero()),
this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition))
}
,
e.prototype._compose = function() {
if (!!this._needToCompose) {
if (!this._localScaling) {
this._needToCompose = !1;
return
}
this._needToCompose = !1,
Matrix.ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix)
}
}
,
e.prototype.updateMatrix = function(t, r, n) {
r === void 0 && (r = !0),
n === void 0 && (n = !0),
this._baseMatrix.copyFrom(t),
r && this._updateDifferenceMatrix(),
n ? this._matrix = t : this.markAsDirty()
}
,
e.prototype._updateDifferenceMatrix = function(t, r) {
if (r === void 0 && (r = !0),
t || (t = this._baseMatrix),
this._parent ? t.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform) : this._absoluteTransform.copyFrom(t),
this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),
r)
for (var n = 0; n < this.children.length; n++)
this.children[n]._updateDifferenceMatrix();
this._scalingDeterminant = this._absoluteTransform.determinant() < 0 ? -1 : 1
}
,
e.prototype.markAsDirty = function(t) {
return this._currentRenderId++,
this._childUpdateId++,
this._skeleton._markAsDirty(),
this
}
,
e.prototype._markAsDirtyAndCompose = function() {
this.markAsDirty(),
this._needToCompose = !0
}
,
e.prototype._markAsDirtyAndDecompose = function() {
this.markAsDirty(),
this._needToDecompose = !0
}
,
e.prototype.translate = function(t, r, n) {
r === void 0 && (r = Space.LOCAL);
var o = this.getLocalMatrix();
if (r == Space.LOCAL)
o.addAtIndex(12, t.x),
o.addAtIndex(13, t.y),
o.addAtIndex(14, t.z);
else {
var a = null;
n && (a = n.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var s = e._tmpMats[0]
, l = e._tmpVecs[0];
this._parent ? n && a ? (s.copyFrom(this._parent.getAbsoluteTransform()),
s.multiplyToRef(a, s)) : s.copyFrom(this._parent.getAbsoluteTransform()) : Matrix.IdentityToRef(s),
s.setTranslationFromFloats(0, 0, 0),
s.invert(),
Vector3.TransformCoordinatesToRef(t, s, l),
o.addAtIndex(12, l.x),
o.addAtIndex(13, l.y),
o.addAtIndex(14, l.z)
}
this._markAsDirtyAndDecompose()
}
,
e.prototype.setPosition = function(t, r, n) {
r === void 0 && (r = Space.LOCAL);
var o = this.getLocalMatrix();
if (r == Space.LOCAL)
o.setTranslationFromFloats(t.x, t.y, t.z);
else {
var a = null;
n && (a = n.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var s = e._tmpMats[0]
, l = e._tmpVecs[0];
this._parent ? (n && a ? (s.copyFrom(this._parent.getAbsoluteTransform()),
s.multiplyToRef(a, s)) : s.copyFrom(this._parent.getAbsoluteTransform()),
s.invert()) : Matrix.IdentityToRef(s),
Vector3.TransformCoordinatesToRef(t, s, l),
o.setTranslationFromFloats(l.x, l.y, l.z)
}
this._markAsDirtyAndDecompose()
}
,
e.prototype.setAbsolutePosition = function(t, r) {
this.setPosition(t, Space.WORLD, r)
}
,
e.prototype.scale = function(t, r, n, o) {
o === void 0 && (o = !1);
var a = this.getLocalMatrix()
, s = e._tmpMats[0];
Matrix.ScalingToRef(t, r, n, s),
s.multiplyToRef(a, a),
s.invert();
for (var l = 0, u = this.children; l < u.length; l++) {
var c = u[l]
, h = c.getLocalMatrix();
h.multiplyToRef(s, h),
h.multiplyAtIndex(12, t),
h.multiplyAtIndex(13, r),
h.multiplyAtIndex(14, n),
c._markAsDirtyAndDecompose()
}
if (this._markAsDirtyAndDecompose(),
o)
for (var f = 0, d = this.children; f < d.length; f++) {
var c = d[f];
c.scale(t, r, n, o)
}
}
,
e.prototype.setScale = function(t) {
this._decompose(),
this._localScaling.copyFrom(t),
this._markAsDirtyAndCompose()
}
,
e.prototype.getScale = function() {
return this._decompose(),
this._localScaling
}
,
e.prototype.getScaleToRef = function(t) {
this._decompose(),
t.copyFrom(this._localScaling)
}
,
e.prototype.setYawPitchRoll = function(t, r, n, o, a) {
if (o === void 0 && (o = Space.LOCAL),
o === Space.LOCAL) {
var s = e._tmpQuat;
Quaternion.RotationYawPitchRollToRef(t, r, n, s),
this.setRotationQuaternion(s, o, a);
return
}
var l = e._tmpMats[0];
if (!!this._getNegativeRotationToRef(l, a)) {
var u = e._tmpMats[1];
Matrix.RotationYawPitchRollToRef(t, r, n, u),
l.multiplyToRef(u, u),
this._rotateWithMatrix(u, o, a)
}
}
,
e.prototype.rotate = function(t, r, n, o) {
n === void 0 && (n = Space.LOCAL);
var a = e._tmpMats[0];
a.setTranslationFromFloats(0, 0, 0),
Matrix.RotationAxisToRef(t, r, a),
this._rotateWithMatrix(a, n, o)
}
,
e.prototype.setAxisAngle = function(t, r, n, o) {
if (n === void 0 && (n = Space.LOCAL),
n === Space.LOCAL) {
var a = e._tmpQuat;
Quaternion.RotationAxisToRef(t, r, a),
this.setRotationQuaternion(a, n, o);
return
}
var s = e._tmpMats[0];
if (!!this._getNegativeRotationToRef(s, o)) {
var l = e._tmpMats[1];
Matrix.RotationAxisToRef(t, r, l),
s.multiplyToRef(l, l),
this._rotateWithMatrix(l, n, o)
}
}
,
e.prototype.setRotation = function(t, r, n) {
r === void 0 && (r = Space.LOCAL),
this.setYawPitchRoll(t.y, t.x, t.z, r, n)
}
,
e.prototype.setRotationQuaternion = function(t, r, n) {
if (r === void 0 && (r = Space.LOCAL),
r === Space.LOCAL) {
this._decompose(),
this._localRotation.copyFrom(t),
this._markAsDirtyAndCompose();
return
}
var o = e._tmpMats[0];
if (!!this._getNegativeRotationToRef(o, n)) {
var a = e._tmpMats[1];
Matrix.FromQuaternionToRef(t, a),
o.multiplyToRef(a, a),
this._rotateWithMatrix(a, r, n)
}
}
,
e.prototype.setRotationMatrix = function(t, r, n) {
if (r === void 0 && (r = Space.LOCAL),
r === Space.LOCAL) {
var o = e._tmpQuat;
Quaternion.FromRotationMatrixToRef(t, o),
this.setRotationQuaternion(o, r, n);
return
}
var a = e._tmpMats[0];
if (!!this._getNegativeRotationToRef(a, n)) {
var s = e._tmpMats[1];
s.copyFrom(t),
a.multiplyToRef(t, s),
this._rotateWithMatrix(s, r, n)
}
}
,
e.prototype._rotateWithMatrix = function(t, r, n) {
r === void 0 && (r = Space.LOCAL);
var o = this.getLocalMatrix()
, a = o.m[12]
, s = o.m[13]
, l = o.m[14]
, u = this.getParent()
, c = e._tmpMats[3]
, h = e._tmpMats[4];
u && r == Space.WORLD ? (n ? (c.copyFrom(n.getWorldMatrix()),
u.getAbsoluteTransform().multiplyToRef(c, c)) : c.copyFrom(u.getAbsoluteTransform()),
h.copyFrom(c),
h.invert(),
o.multiplyToRef(c, o),
o.multiplyToRef(t, o),
o.multiplyToRef(h, o)) : r == Space.WORLD && n ? (c.copyFrom(n.getWorldMatrix()),
h.copyFrom(c),
h.invert(),
o.multiplyToRef(c, o),
o.multiplyToRef(t, o),
o.multiplyToRef(h, o)) : o.multiplyToRef(t, o),
o.setTranslationFromFloats(a, s, l),
this.computeAbsoluteTransforms(),
this._markAsDirtyAndDecompose()
}
,
e.prototype._getNegativeRotationToRef = function(t, r) {
var n = e._tmpMats[2];
return t.copyFrom(this.getAbsoluteTransform()),
r && (t.multiplyToRef(r.getWorldMatrix(), t),
Matrix.ScalingToRef(r.scaling.x, r.scaling.y, r.scaling.z, n)),
t.invert(),
isNaN(t.m[0]) ? !1 : (n.multiplyAtIndex(0, this._scalingDeterminant),
t.multiplyToRef(n, t),
!0)
}
,
e.prototype.getPosition = function(t, r) {
t === void 0 && (t = Space.LOCAL),
r === void 0 && (r = null);
var n = Vector3.Zero();
return this.getPositionToRef(t, r, n),
n
}
,
e.prototype.getPositionToRef = function(t, r, n) {
if (t === void 0 && (t = Space.LOCAL),
t == Space.LOCAL) {
var o = this.getLocalMatrix();
n.x = o.m[12],
n.y = o.m[13],
n.z = o.m[14]
} else {
var a = null;
r && (a = r.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var s = e._tmpMats[0];
r && a ? (s.copyFrom(this.getAbsoluteTransform()),
s.multiplyToRef(a, s)) : s = this.getAbsoluteTransform(),
n.x = s.m[12],
n.y = s.m[13],
n.z = s.m[14]
}
}
,
e.prototype.getAbsolutePosition = function(t) {
t === void 0 && (t = null);
var r = Vector3.Zero();
return this.getPositionToRef(Space.WORLD, t, r),
r
}
,
e.prototype.getAbsolutePositionToRef = function(t, r) {
this.getPositionToRef(Space.WORLD, t, r)
}
,
e.prototype.computeAbsoluteTransforms = function() {
if (this._compose(),
this._parent)
this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
else {
this._absoluteTransform.copyFrom(this._localMatrix);
var t = this._skeleton.getPoseMatrix();
t && this._absoluteTransform.multiplyToRef(t, this._absoluteTransform)
}
for (var r = this.children, n = r.length, o = 0; o < n; o++)
r[o].computeAbsoluteTransforms()
}
,
e.prototype.getDirection = function(t, r) {
r === void 0 && (r = null);
var n = Vector3.Zero();
return this.getDirectionToRef(t, r, n),
n
}
,
e.prototype.getDirectionToRef = function(t, r, n) {
r === void 0 && (r = null);
var o = null;
r && (o = r.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var a = e._tmpMats[0];
a.copyFrom(this.getAbsoluteTransform()),
r && o && a.multiplyToRef(o, a),
Vector3.TransformNormalToRef(t, a, n),
n.normalize()
}
,
e.prototype.getRotation = function(t, r) {
t === void 0 && (t = Space.LOCAL),
r === void 0 && (r = null);
var n = Vector3.Zero();
return this.getRotationToRef(t, r, n),
n
}
,
e.prototype.getRotationToRef = function(t, r, n) {
t === void 0 && (t = Space.LOCAL),
r === void 0 && (r = null);
var o = e._tmpQuat;
this.getRotationQuaternionToRef(t, r, o),
o.toEulerAnglesToRef(n)
}
,
e.prototype.getRotationQuaternion = function(t, r) {
t === void 0 && (t = Space.LOCAL),
r === void 0 && (r = null);
var n = Quaternion.Identity();
return this.getRotationQuaternionToRef(t, r, n),
n
}
,
e.prototype.getRotationQuaternionToRef = function(t, r, n) {
if (t === void 0 && (t = Space.LOCAL),
r === void 0 && (r = null),
t == Space.LOCAL)
this._decompose(),
n.copyFrom(this._localRotation);
else {
var o = e._tmpMats[0]
, a = this.getAbsoluteTransform();
r ? a.multiplyToRef(r.getWorldMatrix(), o) : o.copyFrom(a),
o.multiplyAtIndex(0, this._scalingDeterminant),
o.multiplyAtIndex(1, this._scalingDeterminant),
o.multiplyAtIndex(2, this._scalingDeterminant),
o.decompose(void 0, n, void 0)
}
}
,
e.prototype.getRotationMatrix = function(t, r) {
t === void 0 && (t = Space.LOCAL);
var n = Matrix.Identity();
return this.getRotationMatrixToRef(t, r, n),
n
}
,
e.prototype.getRotationMatrixToRef = function(t, r, n) {
if (t === void 0 && (t = Space.LOCAL),
t == Space.LOCAL)
this.getLocalMatrix().getRotationMatrixToRef(n);
else {
var o = e._tmpMats[0]
, a = this.getAbsoluteTransform();
r ? a.multiplyToRef(r.getWorldMatrix(), o) : o.copyFrom(a),
o.multiplyAtIndex(0, this._scalingDeterminant),
o.multiplyAtIndex(1, this._scalingDeterminant),
o.multiplyAtIndex(2, this._scalingDeterminant),
o.getRotationMatrixToRef(n)
}
}
,
e.prototype.getAbsolutePositionFromLocal = function(t, r) {
r === void 0 && (r = null);
var n = Vector3.Zero();
return this.getAbsolutePositionFromLocalToRef(t, r, n),
n
}
,
e.prototype.getAbsolutePositionFromLocalToRef = function(t, r, n) {
r === void 0 && (r = null);
var o = null;
r && (o = r.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var a = e._tmpMats[0];
r && o ? (a.copyFrom(this.getAbsoluteTransform()),
a.multiplyToRef(o, a)) : a = this.getAbsoluteTransform(),
Vector3.TransformCoordinatesToRef(t, a, n)
}
,
e.prototype.getLocalPositionFromAbsolute = function(t, r) {
r === void 0 && (r = null);
var n = Vector3.Zero();
return this.getLocalPositionFromAbsoluteToRef(t, r, n),
n
}
,
e.prototype.getLocalPositionFromAbsoluteToRef = function(t, r, n) {
r === void 0 && (r = null);
var o = null;
r && (o = r.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var a = e._tmpMats[0];
a.copyFrom(this.getAbsoluteTransform()),
r && o && a.multiplyToRef(o, a),
a.invert(),
Vector3.TransformCoordinatesToRef(t, a, n)
}
,
e.prototype.setCurrentPoseAsRest = function() {
this.setRestPose(this.getLocalMatrix())
}
,
e._tmpVecs = ArrayTools.BuildArray(2, Vector3.Zero),
e._tmpQuat = Quaternion.Identity(),
e._tmpMats = ArrayTools.BuildArray(5, Matrix.Identity),
e
}(Node$2)
, Animatable = function() {
function i(e, t, r, n, o, a, s, l, u, c) {
r === void 0 && (r = 0),
n === void 0 && (n = 100),
o === void 0 && (o = !1),
a === void 0 && (a = 1),
c === void 0 && (c = !1),
this.target = t,
this.fromFrame = r,
this.toFrame = n,
this.loopAnimation = o,
this.onAnimationEnd = s,
this.onAnimationLoop = u,
this.isAdditive = c,
this._localDelayOffset = null,
this._pausedDelay = null,
this._manualJumpDelay = null,
this._runtimeAnimations = new Array,
this._paused = !1,
this._speedRatio = 1,
this._weight = -1,
this._syncRoot = null,
this._frameToSyncFromJump = 0,
this.disposeOnEnd = !0,
this.animationStarted = !1,
this.onAnimationEndObservable = new Observable,
this.onAnimationLoopObservable = new Observable,
this._scene = e,
l && this.appendAnimations(t, l),
this._speedRatio = a,
e._activeAnimatables.push(this)
}
return Object.defineProperty(i.prototype, "syncRoot", {
get: function() {
return this._syncRoot
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "masterFrame", {
get: function() {
return this._runtimeAnimations.length === 0 ? 0 : this._runtimeAnimations[0].currentFrame
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "weight", {
get: function() {
return this._weight
},
set: function(e) {
if (e === -1) {
this._weight = -1;
return
}
this._weight = Math.min(Math.max(e, 0), 1)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "speedRatio", {
get: function() {
return this._speedRatio
},
set: function(e) {
for (var t = 0; t < this._runtimeAnimations.length; t++) {
var r = this._runtimeAnimations[t];
r._prepareForSpeedRatioChange(e)
}
this._speedRatio = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.syncWith = function(e) {
if (this._syncRoot = e,
e) {
var t = this._scene._activeAnimatables.indexOf(this);
t > -1 && (this._scene._activeAnimatables.splice(t, 1),
this._scene._activeAnimatables.push(this))
}
return this
}
,
i.prototype.getAnimations = function() {
return this._runtimeAnimations
}
,
i.prototype.appendAnimations = function(e, t) {
for (var r = this, n = 0; n < t.length; n++) {
var o = t[n]
, a = new RuntimeAnimation(e,o,this._scene,this);
a._onLoop = function() {
r.onAnimationLoopObservable.notifyObservers(r),
r.onAnimationLoop && r.onAnimationLoop()
}
,
this._runtimeAnimations.push(a)
}
}
,
i.prototype.getAnimationByTargetProperty = function(e) {
for (var t = this._runtimeAnimations, r = 0; r < t.length; r++)
if (t[r].animation.targetProperty === e)
return t[r].animation;
return null
}
,
i.prototype.getRuntimeAnimationByTargetProperty = function(e) {
for (var t = this._runtimeAnimations, r = 0; r < t.length; r++)
if (t[r].animation.targetProperty === e)
return t[r];
return null
}
,
i.prototype.reset = function() {
for (var e = this._runtimeAnimations, t = 0; t < e.length; t++)
e[t].reset(!0);
this._localDelayOffset = null,
this._pausedDelay = null
}
,
i.prototype.enableBlending = function(e) {
for (var t = this._runtimeAnimations, r = 0; r < t.length; r++)
t[r].animation.enableBlending = !0,
t[r].animation.blendingSpeed = e
}
,
i.prototype.disableBlending = function() {
for (var e = this._runtimeAnimations, t = 0; t < e.length; t++)
e[t].animation.enableBlending = !1
}
,
i.prototype.goToFrame = function(e) {
var t, r = this._runtimeAnimations;
if (r[0]) {
var n = r[0].animation.framePerSecond;
this._frameToSyncFromJump = (t = this._frameToSyncFromJump) !== null && t !== void 0 ? t : r[0].currentFrame;
var o = this.speedRatio === 0 ? 0 : (e - this._frameToSyncFromJump) / n * 1e3 / this.speedRatio;
this._manualJumpDelay = -o
}
for (var a = 0; a < r.length; a++)
r[a].goToFrame(e)
}
,
i.prototype.pause = function() {
this._paused || (this._paused = !0)
}
,
i.prototype.restart = function() {
this._paused = !1
}
,
i.prototype._raiseOnAnimationEnd = function() {
this.onAnimationEnd && this.onAnimationEnd(),
this.onAnimationEndObservable.notifyObservers(this)
}
,
i.prototype.stop = function(e, t) {
if (e || t) {
var r = this._scene._activeAnimatables.indexOf(this);
if (r > -1) {
for (var n = this._runtimeAnimations, o = n.length - 1; o >= 0; o--) {
var a = n[o];
e && a.animation.name != e || t && !t(a.target) || (a.dispose(),
n.splice(o, 1))
}
n.length == 0 && (this._scene._activeAnimatables.splice(r, 1),
this._raiseOnAnimationEnd())
}
} else {
var o = this._scene._activeAnimatables.indexOf(this);
if (o > -1) {
this._scene._activeAnimatables.splice(o, 1);
for (var n = this._runtimeAnimations, o = 0; o < n.length; o++)
n[o].dispose();
this._raiseOnAnimationEnd()
}
}
}
,
i.prototype.waitAsync = function() {
var e = this;
return new Promise(function(t, r) {
e.onAnimationEndObservable.add(function() {
t(e)
}, void 0, void 0, e, !0)
}
)
}
,
i.prototype._animate = function(e) {
if (this._paused)
return this.animationStarted = !1,
this._pausedDelay === null && (this._pausedDelay = e),
!0;
if (this._localDelayOffset === null ? (this._localDelayOffset = e,
this._pausedDelay = null) : this._pausedDelay !== null && (this._localDelayOffset += e - this._pausedDelay,
this._pausedDelay = null),
this._manualJumpDelay !== null && (this._localDelayOffset += this._manualJumpDelay,
this._manualJumpDelay = null,
this._frameToSyncFromJump = null),
this._weight === 0)
return !0;
var t = !1, r = this._runtimeAnimations, n;
for (n = 0; n < r.length; n++) {
var o = r[n]
, a = o.animate(e - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
t = t || a
}
if (this.animationStarted = t,
!t) {
if (this.disposeOnEnd)
for (n = this._scene._activeAnimatables.indexOf(this),
this._scene._activeAnimatables.splice(n, 1),
n = 0; n < r.length; n++)
r[n].dispose();
this._raiseOnAnimationEnd(),
this.disposeOnEnd && (this.onAnimationEnd = null,
this.onAnimationLoop = null,
this.onAnimationLoopObservable.clear(),
this.onAnimationEndObservable.clear())
}
return t
}
,
i
}();
Scene.prototype._animate = function() {
if (!!this.animationsEnabled) {
var i = PrecisionDate.Now;
if (!this._animationTimeLast) {
if (this._pendingData.length > 0)
return;
this._animationTimeLast = i
}
this.deltaTime = this.useConstantAnimationDeltaTime ? 16 : (i - this._animationTimeLast) * this.animationTimeScale,
this._animationTimeLast = i;
var e = this._activeAnimatables;
if (e.length !== 0) {
this._animationTime += this.deltaTime;
for (var t = this._animationTime, r = 0; r < e.length; r++) {
var n = e[r];
!n._animate(t) && n.disposeOnEnd && r--
}
this._processLateAnimationBindings()
}
}
}
;
Scene.prototype.beginWeightedAnimation = function(i, e, t, r, n, o, a, s, l, u, c) {
r === void 0 && (r = 1),
o === void 0 && (o = 1),
c === void 0 && (c = !1);
var h = this.beginAnimation(i, e, t, n, o, a, s, !1, l, u, c);
return h.weight = r,
h
}
;
Scene.prototype.beginAnimation = function(i, e, t, r, n, o, a, s, l, u, c) {
n === void 0 && (n = 1),
s === void 0 && (s = !0),
c === void 0 && (c = !1),
e > t && n > 0 && (n *= -1),
s && this.stopAnimation(i, void 0, l),
a || (a = new Animatable(this,i,e,t,r,n,o,void 0,u,c));
var h = l ? l(i) : !0;
if (i.animations && h && a.appendAnimations(i, i.animations),
i.getAnimatables)
for (var f = i.getAnimatables(), d = 0; d < f.length; d++)
this.beginAnimation(f[d], e, t, r, n, o, a, s, l, u);
return a.reset(),
a
}
;
Scene.prototype.beginHierarchyAnimation = function(i, e, t, r, n, o, a, s, l, u, c, h) {
o === void 0 && (o = 1),
l === void 0 && (l = !0),
h === void 0 && (h = !1);
var f = i.getDescendants(e)
, d = [];
d.push(this.beginAnimation(i, t, r, n, o, a, s, l, u, void 0, h));
for (var _ = 0, g = f; _ < g.length; _++) {
var m = g[_];
d.push(this.beginAnimation(m, t, r, n, o, a, s, l, u, void 0, h))
}
return d
}
;
Scene.prototype.beginDirectAnimation = function(i, e, t, r, n, o, a, s, l) {
if (l === void 0 && (l = !1),
o === void 0 && (o = 1),
t > r && o > 0)
o *= -1;
else if (r > t && o < 0) {
var u = r;
r = t,
t = u
}
var c = new Animatable(this,i,t,r,n,o,a,e,s,l);
return c
}
;
Scene.prototype.beginDirectHierarchyAnimation = function(i, e, t, r, n, o, a, s, l, u) {
u === void 0 && (u = !1);
var c = i.getDescendants(e)
, h = [];
h.push(this.beginDirectAnimation(i, t, r, n, o, a, s, l, u));
for (var f = 0, d = c; f < d.length; f++) {
var _ = d[f];
h.push(this.beginDirectAnimation(_, t, r, n, o, a, s, l, u))
}
return h
}
;
Scene.prototype.getAnimatableByTarget = function(i) {
for (var e = 0; e < this._activeAnimatables.length; e++)
if (this._activeAnimatables[e].target === i)
return this._activeAnimatables[e];
return null
}
;
Scene.prototype.getAllAnimatablesByTarget = function(i) {
for (var e = [], t = 0; t < this._activeAnimatables.length; t++)
this._activeAnimatables[t].target === i && e.push(this._activeAnimatables[t]);
return e
}
;
Scene.prototype.stopAnimation = function(i, e, t) {
for (var r = this.getAllAnimatablesByTarget(i), n = 0, o = r; n < o.length; n++) {
var a = o[n];
a.stop(e, t)
}
}
;
Scene.prototype.stopAllAnimations = function() {
if (this._activeAnimatables) {
for (var i = 0; i < this._activeAnimatables.length; i++)
this._activeAnimatables[i].stop();
this._activeAnimatables = []
}
for (var e = 0, t = this.animationGroups; e < t.length; e++) {
var r = t[e];
r.stop()
}
}
;
Scene.prototype._registerTargetForLateAnimationBinding = function(i, e) {
var t = i.target;
this._registeredForLateAnimationBindings.pushNoDuplicate(t),
t._lateAnimationHolders || (t._lateAnimationHolders = {}),
t._lateAnimationHolders[i.targetPath] || (t._lateAnimationHolders[i.targetPath] = {
totalWeight: 0,
totalAdditiveWeight: 0,
animations: [],
additiveAnimations: [],
originalValue: e
}),
i.isAdditive ? (t._lateAnimationHolders[i.targetPath].additiveAnimations.push(i),
t._lateAnimationHolders[i.targetPath].totalAdditiveWeight += i.weight) : (t._lateAnimationHolders[i.targetPath].animations.push(i),
t._lateAnimationHolders[i.targetPath].totalWeight += i.weight)
}
;
Scene.prototype._processLateAnimationBindingsForMatrices = function(i) {
if (i.totalWeight === 0 && i.totalAdditiveWeight === 0)
return i.originalValue;
var e = 1
, t = TmpVectors.Vector3[0]
, r = TmpVectors.Vector3[1]
, n = TmpVectors.Quaternion[0]
, o = 0
, a = i.animations[0]
, s = i.originalValue
, l = 1
, u = !1;
if (i.totalWeight < 1)
l = 1 - i.totalWeight,
s.decompose(r, n, t);
else {
if (o = 1,
e = i.totalWeight,
l = a.weight / e,
l == 1)
if (i.totalAdditiveWeight)
u = !0;
else
return a.currentValue;
a.currentValue.decompose(r, n, t)
}
if (!u) {
r.scaleInPlace(l),
t.scaleInPlace(l),
n.scaleInPlace(l);
for (var c = o; c < i.animations.length; c++) {
var h = i.animations[c];
if (h.weight !== 0) {
var l = h.weight / e
, f = TmpVectors.Vector3[2]
, d = TmpVectors.Vector3[3]
, _ = TmpVectors.Quaternion[1];
h.currentValue.decompose(d, _, f),
d.scaleAndAddToRef(l, r),
_.scaleAndAddToRef(l, n),
f.scaleAndAddToRef(l, t)
}
}
}
for (var g = 0; g < i.additiveAnimations.length; g++) {
var h = i.additiveAnimations[g];
if (h.weight !== 0) {
var f = TmpVectors.Vector3[2]
, d = TmpVectors.Vector3[3]
, _ = TmpVectors.Quaternion[1];
h.currentValue.decompose(d, _, f),
d.multiplyToRef(r, d),
Vector3.LerpToRef(r, d, h.weight, r),
n.multiplyToRef(_, _),
Quaternion.SlerpToRef(n, _, h.weight, n),
f.scaleAndAddToRef(h.weight, t)
}
}
var m = a ? a._animationState.workValue : TmpVectors.Matrix[0].clone();
return Matrix.ComposeToRef(r, n, t, m),
m
}
;
Scene.prototype._processLateAnimationBindingsForQuaternions = function(i, e) {
if (i.totalWeight === 0 && i.totalAdditiveWeight === 0)
return e;
var t = i.animations[0]
, r = i.originalValue
, n = e;
if (i.totalWeight === 0 && i.totalAdditiveWeight > 0)
n.copyFrom(r);
else if (i.animations.length === 1) {
if (Quaternion.SlerpToRef(r, t.currentValue, Math.min(1, i.totalWeight), n),
i.totalAdditiveWeight === 0)
return n
} else if (i.animations.length > 1) {
var o = 1
, a = void 0
, s = void 0;
if (i.totalWeight < 1) {
var l = 1 - i.totalWeight;
a = [],
s = [],
a.push(r),
s.push(l)
} else {
if (i.animations.length === 2 && (Quaternion.SlerpToRef(i.animations[0].currentValue, i.animations[1].currentValue, i.animations[1].weight / i.totalWeight, e),
i.totalAdditiveWeight === 0))
return e;
a = [],
s = [],
o = i.totalWeight
}
for (var u = 0; u < i.animations.length; u++) {
var c = i.animations[u];
a.push(c.currentValue),
s.push(c.weight / o)
}
for (var h = 0, f = 0; f < a.length; ) {
if (!f) {
Quaternion.SlerpToRef(a[f], a[f + 1], s[f + 1] / (s[f] + s[f + 1]), e),
n = e,
h = s[f] + s[f + 1],
f += 2;
continue
}
h += s[f],
Quaternion.SlerpToRef(n, a[f], s[f] / h, n),
f++
}
}
for (var d = 0; d < i.additiveAnimations.length; d++) {
var c = i.additiveAnimations[d];
c.weight !== 0 && (n.multiplyToRef(c.currentValue, TmpVectors.Quaternion[0]),
Quaternion.SlerpToRef(n, TmpVectors.Quaternion[0], c.weight, n))
}
return n
}
;
Scene.prototype._processLateAnimationBindings = function() {
if (!!this._registeredForLateAnimationBindings.length) {
for (var i = 0; i < this._registeredForLateAnimationBindings.length; i++) {
var e = this._registeredForLateAnimationBindings.data[i];
for (var t in e._lateAnimationHolders) {
var r = e._lateAnimationHolders[t]
, n = r.animations[0]
, o = r.originalValue
, a = Animation.AllowMatrixDecomposeForInterpolation && o.m
, s = e[t];
if (a)
s = this._processLateAnimationBindingsForMatrices(r);
else {
var l = o.w !== void 0;
if (l)
s = this._processLateAnimationBindingsForQuaternions(r, s || Quaternion.Identity());
else {
var u = 0
, c = 1;
if (r.totalWeight < 1)
n && o.scale ? s = o.scale(1 - r.totalWeight) : n ? s = o * (1 - r.totalWeight) : o.clone ? s = o.clone() : s = o;
else if (n) {
c = r.totalWeight;
var h = n.weight / c;
h !== 1 ? n.currentValue.scale ? s = n.currentValue.scale(h) : s = n.currentValue * h : s = n.currentValue,
u = 1
}
for (var f = u; f < r.animations.length; f++) {
var d = r.animations[f]
, _ = d.weight / c;
if (_)
d.currentValue.scaleAndAddToRef ? d.currentValue.scaleAndAddToRef(_, s) : s += d.currentValue * _;
else
continue
}
for (var g = 0; g < r.additiveAnimations.length; g++) {
var d = r.additiveAnimations[g]
, _ = d.weight;
if (_)
d.currentValue.scaleAndAddToRef ? d.currentValue.scaleAndAddToRef(_, s) : s += d.currentValue * _;
else
continue
}
}
}
e[t] = s
}
e._lateAnimationHolders = {}
}
this._registeredForLateAnimationBindings.reset()
}
}
;
Bone.prototype.copyAnimationRange = function(i, e, t, r, n) {
r === void 0 && (r = !1),
n === void 0 && (n = null),
this.animations.length === 0 && (this.animations.push(new Animation(this.name,"_matrix",i.animations[0].framePerSecond,Animation.ANIMATIONTYPE_MATRIX,0)),
this.animations[0].setKeys([]));
var o = i.animations[0].getRange(e);
if (!o)
return !1;
for (var a = o.from, s = o.to, l = i.animations[0].getKeys(), u = i.length, c = i.getParent(), h = this.getParent(), f = r && c && u && this.length && u !== this.length, d = f && h && c ? h.length / c.length : 1, _ = r && !h && n && (n.x !== 1 || n.y !== 1 || n.z !== 1), g = this.animations[0].getKeys(), m, v, y, b = 0, T = l.length; b < T; b++)
m = l[b],
m.frame >= a && m.frame <= s && (r ? (y = m.value.clone(),
f ? (v = y.getTranslation(),
y.setTranslation(v.scaleInPlace(d))) : _ && n ? (v = y.getTranslation(),
y.setTranslation(v.multiplyInPlace(n))) : y = m.value) : y = m.value,
g.push({
frame: m.frame + t,
value: y
}));
return this.animations[0].createRange(e, a + t, s + t),
!0
}
;
var TargetedAnimation = function() {
function i() {}
return i.prototype.getClassName = function() {
return "TargetedAnimation"
}
,
i.prototype.serialize = function() {
var e = {};
return e.animation = this.animation.serialize(),
e.targetId = this.target.id,
e
}
,
i
}()
, AnimationGroup = function() {
function i(e, t) {
t === void 0 && (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._parentContainer = null,
this.onAnimationEndObservable = new Observable,
this.onAnimationLoopObservable = new Observable,
this.onAnimationGroupLoopObservable = new Observable,
this.onAnimationGroupEndObservable = new Observable,
this.onAnimationGroupPauseObservable = new Observable,
this.onAnimationGroupPlayObservable = new Observable,
this.metadata = null,
this._scene = t || EngineStore.LastCreatedScene,
this.uniqueId = this._scene.getUniqueId(),
this._scene.addAnimationGroup(this)
}
return Object.defineProperty(i.prototype, "from", {
get: function() {
return this._from
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "to", {
get: function() {
return this._to
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isStarted", {
get: function() {
return this._isStarted
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isPlaying", {
get: function() {
return this._isStarted && !this._isPaused
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "speedRatio", {
get: function() {
return this._speedRatio
},
set: function(e) {
if (this._speedRatio !== e) {
this._speedRatio = e;
for (var t = 0; t < this._animatables.length; t++) {
var r = this._animatables[t];
r.speedRatio = this._speedRatio
}
}
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "loopAnimation", {
get: function() {
return this._loopAnimation
},
set: function(e) {
if (this._loopAnimation !== e) {
this._loopAnimation = e;
for (var t = 0; t < this._animatables.length; t++) {
var r = this._animatables[t];
r.loopAnimation = this._loopAnimation
}
}
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isAdditive", {
get: function() {
return this._isAdditive
},
set: function(e) {
if (this._isAdditive !== e) {
this._isAdditive = e;
for (var t = 0; t < this._animatables.length; t++) {
var r = this._animatables[t];
r.isAdditive = this._isAdditive
}
}
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "targetedAnimations", {
get: function() {
return this._targetedAnimations
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "animatables", {
get: function() {
return this._animatables
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "children", {
get: function() {
return this._targetedAnimations
},
enumerable: !1,
configurable: !0
}),
i.prototype.addTargetedAnimation = function(e, t) {
var r = new TargetedAnimation;
r.animation = e,
r.target = t;
var n = e.getKeys();
return this._from > n[0].frame && (this._from = n[0].frame),
this._to < n[n.length - 1].frame && (this._to = n[n.length - 1].frame),
this._targetedAnimations.push(r),
r
}
,
i.prototype.normalize = function(e, t) {
e === void 0 && (e = null),
t === void 0 && (t = null),
e == null && (e = this._from),
t == null && (t = this._to);
for (var r = 0; r < this._targetedAnimations.length; r++) {
var n = this._targetedAnimations[r]
, o = n.animation.getKeys()
, a = o[0]
, s = o[o.length - 1];
if (a.frame > e) {
var l = {
frame: e,
value: a.value,
inTangent: a.inTangent,
outTangent: a.outTangent,
interpolation: a.interpolation
};
o.splice(0, 0, l)
}
if (s.frame < t) {
var l = {
frame: t,
value: s.value,
inTangent: s.inTangent,
outTangent: s.outTangent,
interpolation: s.interpolation
};
o.push(l)
}
}
return this._from = e,
this._to = t,
this
}
,
i.prototype._processLoop = function(e, t, r) {
var n = this;
e.onAnimationLoop = function() {
n.onAnimationLoopObservable.notifyObservers(t),
!n._animationLoopFlags[r] && (n._animationLoopFlags[r] = !0,
n._animationLoopCount++,
n._animationLoopCount === n._targetedAnimations.length && (n.onAnimationGroupLoopObservable.notifyObservers(n),
n._animationLoopCount = 0,
n._animationLoopFlags = []))
}
}
,
i.prototype.start = function(e, t, r, n, o) {
var a = this;
if (e === void 0 && (e = !1),
t === void 0 && (t = 1),
this._isStarted || this._targetedAnimations.length === 0)
return this;
this._loopAnimation = e,
this._animationLoopCount = 0,
this._animationLoopFlags = [];
for (var s = function() {
var c = l._targetedAnimations[u]
, h = l._scene.beginDirectAnimation(c.target, [c.animation], r !== void 0 ? r : l._from, n !== void 0 ? n : l._to, e, t, void 0, void 0, o !== void 0 ? o : l._isAdditive);
h.onAnimationEnd = function() {
a.onAnimationEndObservable.notifyObservers(c),
a._checkAnimationGroupEnded(h)
}
,
l._processLoop(h, c, u),
l._animatables.push(h)
}, l = this, u = 0; u < this._targetedAnimations.length; u++)
s();
return this._speedRatio = t,
this._isStarted = !0,
this._isPaused = !1,
this.onAnimationGroupPlayObservable.notifyObservers(this),
this
}
,
i.prototype.pause = function() {
if (!this._isStarted)
return this;
this._isPaused = !0;
for (var e = 0; e < this._animatables.length; e++) {
var t = this._animatables[e];
t.pause()
}
return this.onAnimationGroupPauseObservable.notifyObservers(this),
this
}
,
i.prototype.play = function(e) {
return this.isStarted && this._animatables.length === this._targetedAnimations.length ? (e !== void 0 && (this.loopAnimation = e),
this.restart()) : (this.stop(),
this.start(e, this._speedRatio)),
this._isPaused = !1,
this
}
,
i.prototype.reset = function() {
if (!this._isStarted)
return this.play(),
this.goToFrame(0),
this.stop(),
this;
for (var e = 0; e < this._animatables.length; e++) {
var t = this._animatables[e];
t.reset()
}
return this
}
,
i.prototype.restart = function() {
if (!this._isStarted)
return this;
for (var e = 0; e < this._animatables.length; e++) {
var t = this._animatables[e];
t.restart()
}
return this.onAnimationGroupPlayObservable.notifyObservers(this),
this
}
,
i.prototype.stop = function() {
if (!this._isStarted)
return this;
for (var e = this._animatables.slice(), t = 0; t < e.length; t++)
e[t].stop();
return this._isStarted = !1,
this
}
,
i.prototype.setWeightForAllAnimatables = function(e) {
for (var t = 0; t < this._animatables.length; t++) {
var r = this._animatables[t];
r.weight = e
}
return this
}
,
i.prototype.syncAllAnimationsWith = function(e) {
for (var t = 0; t < this._animatables.length; t++) {
var r = this._animatables[t];
r.syncWith(e)
}
return this
}
,
i.prototype.goToFrame = function(e) {
if (!this._isStarted)
return this;
for (var t = 0; t < this._animatables.length; t++) {
var r = this._animatables[t];
r.goToFrame(e)
}
return this
}
,
i.prototype.dispose = function() {
this._targetedAnimations = [],
this._animatables = [];
var e = this._scene.animationGroups.indexOf(this);
if (e > -1 && this._scene.animationGroups.splice(e, 1),
this._parentContainer) {
var t = this._parentContainer.animationGroups.indexOf(this);
t > -1 && this._parentContainer.animationGroups.splice(t, 1),
this._parentContainer = null
}
this.onAnimationEndObservable.clear(),
this.onAnimationGroupEndObservable.clear(),
this.onAnimationGroupPauseObservable.clear(),
this.onAnimationGroupPlayObservable.clear(),
this.onAnimationLoopObservable.clear(),
this.onAnimationGroupLoopObservable.clear()
}
,
i.prototype._checkAnimationGroupEnded = function(e) {
var t = this._animatables.indexOf(e);
t > -1 && this._animatables.splice(t, 1),
this._animatables.length === 0 && (this._isStarted = !1,
this.onAnimationGroupEndObservable.notifyObservers(this))
}
,
i.prototype.clone = function(e, t, r) {
r === void 0 && (r = !1);
for (var n = new i(e || this.name,this._scene), o = 0, a = this._targetedAnimations; o < a.length; o++) {
var s = a[o];
n.addTargetedAnimation(r ? s.animation.clone() : s.animation, t ? t(s.target) : s.target)
}
return n
}
,
i.prototype.serialize = function() {
var e = {};
e.name = this.name,
e.from = this.from,
e.to = this.to,
e.targetedAnimations = [];
for (var t = 0; t < this.targetedAnimations.length; t++) {
var r = this.targetedAnimations[t];
e.targetedAnimations[t] = r.serialize()
}
return Tags && Tags.HasTags(this) && (e.tags = Tags.GetTags(this)),
this.metadata && (e.metadata = this.metadata),
e
}
,
i.Parse = function(e, t) {
for (var r = new i(e.name,t), n = 0; n < e.targetedAnimations.length; n++) {
var o = e.targetedAnimations[n]
, a = Animation.Parse(o.animation)
, s = o.targetId;
if (o.animation.property === "influence") {
var l = t.getMorphTargetById(s);
l && r.addTargetedAnimation(a, l)
} else {
var u = t.getNodeById(s);
u != null && r.addTargetedAnimation(a, u)
}
}
return e.from !== null && e.to !== null && r.normalize(e.from, e.to),
Tags && Tags.AddTagsTo(r, e.tags),
e.metadata !== void 0 && (r.metadata = e.metadata),
r
}
,
i.MakeAnimationAdditive = function(e, t, r, n, o) {
t === void 0 && (t = 0),
n === void 0 && (n = !1);
var a = e;
n && (a = e.clone(o || a.name));
for (var s = a.targetedAnimations, l = 0; l < s.length; l++) {
var u = s[l];
Animation.MakeAnimationAdditive(u.animation, t, r)
}
return a.isAdditive = !0,
a
}
,
i.prototype.getClassName = function() {
return "AnimationGroup"
}
,
i.prototype.toString = function(e) {
var t = "Name: " + this.name;
return t += ", type: " + this.getClassName(),
e && (t += ", from: " + this._from,
t += ", to: " + this._to,
t += ", isStarted: " + this._isStarted,
t += ", speedRatio: " + this._speedRatio,
t += ", targetedAnimations length: " + this._targetedAnimations.length,
t += ", animatables length: " + this._animatables),
t
}
,
i
}()
, ThinTexture = function() {
function i(e) {
this._wrapU = 1,
this._wrapV = 1,
this.wrapR = 1,
this.anisotropicFilteringLevel = 4,
this.delayLoadState = 0,
this._texture = null,
this._engine = null,
this._cachedSize = Size.Zero(),
this._cachedBaseSize = Size.Zero(),
this._initialSamplingMode = 2,
this._texture = e,
this._texture && (this._engine = this._texture.getEngine())
}
return Object.defineProperty(i.prototype, "wrapU", {
get: function() {
return this._wrapU
},
set: function(e) {
this._wrapU = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "wrapV", {
get: function() {
return this._wrapV
},
set: function(e) {
this._wrapV = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "coordinatesMode", {
get: function() {
return 0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isCube", {
get: function() {
return this._texture ? this._texture.isCube : !1
},
set: function(e) {
!this._texture || (this._texture.isCube = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "is3D", {
get: function() {
return this._texture ? this._texture.is3D : !1
},
set: function(e) {
!this._texture || (this._texture.is3D = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "is2DArray", {
get: function() {
return this._texture ? this._texture.is2DArray : !1
},
set: function(e) {
!this._texture || (this._texture.is2DArray = e)
},
enumerable: !1,
configurable: !0
}),
i.prototype.getClassName = function() {
return "ThinTexture"
}
,
i.prototype.isReady = function() {
return this.delayLoadState === 4 ? (this.delayLoad(),
!1) : this._texture ? this._texture.isReady : !1
}
,
i.prototype.delayLoad = function() {}
,
i.prototype.getInternalTexture = function() {
return this._texture
}
,
i.prototype.getSize = function() {
if (this._texture) {
if (this._texture.width)
return this._cachedSize.width = this._texture.width,
this._cachedSize.height = this._texture.height,
this._cachedSize;
if (this._texture._size)
return this._cachedSize.width = this._texture._size,
this._cachedSize.height = this._texture._size,
this._cachedSize
}
return this._cachedSize
}
,
i.prototype.getBaseSize = function() {
return !this.isReady() || !this._texture ? (this._cachedBaseSize.width = 0,
this._cachedBaseSize.height = 0,
this._cachedBaseSize) : this._texture._size ? (this._cachedBaseSize.width = this._texture._size,
this._cachedBaseSize.height = this._texture._size,
this._cachedBaseSize) : (this._cachedBaseSize.width = this._texture.baseWidth,
this._cachedBaseSize.height = this._texture.baseHeight,
this._cachedBaseSize)
}
,
Object.defineProperty(i.prototype, "samplingMode", {
get: function() {
return this._texture ? this._texture.samplingMode : this._initialSamplingMode
},
enumerable: !1,
configurable: !0
}),
i.prototype.updateSamplingMode = function(e) {
this._texture && this._engine && this._engine.updateTextureSamplingMode(e, this._texture)
}
,
i.prototype.releaseInternalTexture = function() {
this._texture && (this._texture.dispose(),
this._texture = null)
}
,
i.prototype.dispose = function() {
this._texture && (this.releaseInternalTexture(),
this._engine = null)
}
,
i
}()
, BaseTexture = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, null) || this;
return r.metadata = null,
r.reservedDataStore = null,
r._hasAlpha = !1,
r.getAlphaFromRGB = !1,
r.level = 1,
r.coordinatesIndex = 0,
r._coordinatesMode = 0,
r.wrapR = 1,
r.anisotropicFilteringLevel = e.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,
r._isCube = !1,
r._gammaSpace = !0,
r.invertZ = !1,
r.lodLevelInAlpha = !1,
r.isRenderTarget = !1,
r._prefiltered = !1,
r._forceSerialize = !1,
r.animations = new Array,
r.onDisposeObservable = new Observable,
r._onDisposeObserver = null,
r._scene = null,
r._uid = null,
r._parentContainer = null,
r._loadingError = !1,
t ? e._isScene(t) ? r._scene = t : r._engine = t : r._scene = EngineStore.LastCreatedScene,
r._scene && (r.uniqueId = r._scene.getUniqueId(),
r._scene.addTexture(r),
r._engine = r._scene.getEngine()),
r._uid = null,
r
}
return Object.defineProperty(e.prototype, "hasAlpha", {
get: function() {
return this._hasAlpha
},
set: function(t) {
this._hasAlpha !== t && (this._hasAlpha = t,
this._scene && this._scene.markAllMaterialsAsDirty(17))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "coordinatesMode", {
get: function() {
return this._coordinatesMode
},
set: function(t) {
this._coordinatesMode !== t && (this._coordinatesMode = t,
this._scene && this._scene.markAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wrapU", {
get: function() {
return this._wrapU
},
set: function(t) {
this._wrapU = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wrapV", {
get: function() {
return this._wrapV
},
set: function(t) {
this._wrapV = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isCube", {
get: function() {
return this._texture ? this._texture.isCube : this._isCube
},
set: function(t) {
this._texture ? this._texture.isCube = t : this._isCube = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "is3D", {
get: function() {
return this._texture ? this._texture.is3D : !1
},
set: function(t) {
!this._texture || (this._texture.is3D = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "is2DArray", {
get: function() {
return this._texture ? this._texture.is2DArray : !1
},
set: function(t) {
!this._texture || (this._texture.is2DArray = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "gammaSpace", {
get: function() {
if (this._texture)
this._texture._gammaSpace === null && (this._texture._gammaSpace = this._gammaSpace);
else
return this._gammaSpace;
return this._texture._gammaSpace && !this._texture._useSRGBBuffer
},
set: function(t) {
if (this._texture) {
if (this._texture._gammaSpace === t)
return;
this._texture._gammaSpace = t
} else {
if (this._gammaSpace === t)
return;
this._gammaSpace = t
}
this._markAllSubMeshesAsTexturesDirty()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isRGBD", {
get: function() {
return this._texture != null && this._texture._isRGBD
},
set: function(t) {
this._texture && (this._texture._isRGBD = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "noMipmap", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "lodGenerationOffset", {
get: function() {
return this._texture ? this._texture._lodGenerationOffset : 0
},
set: function(t) {
this._texture && (this._texture._lodGenerationOffset = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "lodGenerationScale", {
get: function() {
return this._texture ? this._texture._lodGenerationScale : 0
},
set: function(t) {
this._texture && (this._texture._lodGenerationScale = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "linearSpecularLOD", {
get: function() {
return this._texture ? this._texture._linearSpecularLOD : !1
},
set: function(t) {
this._texture && (this._texture._linearSpecularLOD = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "irradianceTexture", {
get: function() {
return this._texture ? this._texture._irradianceTexture : null
},
set: function(t) {
this._texture && (this._texture._irradianceTexture = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "uid", {
get: function() {
return this._uid || (this._uid = RandomGUID()),
this._uid
},
enumerable: !1,
configurable: !0
}),
e.prototype.toString = function() {
return this.name
}
,
e.prototype.getClassName = function() {
return "BaseTexture"
}
,
Object.defineProperty(e.prototype, "onDispose", {
set: function(t) {
this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
this._onDisposeObserver = this.onDisposeObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isBlocking", {
get: function() {
return !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "loadingError", {
get: function() {
return this._loadingError
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "errorObject", {
get: function() {
return this._errorObject
},
enumerable: !1,
configurable: !0
}),
e.prototype.getScene = function() {
return this._scene
}
,
e.prototype._getEngine = function() {
return this._engine
}
,
e.prototype.checkTransformsAreIdentical = function(t) {
return t !== null
}
,
e.prototype.getTextureMatrix = function() {
return Matrix.IdentityReadOnly
}
,
e.prototype.getReflectionTextureMatrix = function() {
return Matrix.IdentityReadOnly
}
,
e.prototype.isReadyOrNotBlocking = function() {
return !this.isBlocking || this.isReady() || this.loadingError
}
,
e.prototype.scale = function(t) {}
,
Object.defineProperty(e.prototype, "canRescale", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
e.prototype._getFromCache = function(t, r, n, o, a) {
var s = this._getEngine();
if (!s)
return null;
for (var l = s._getUseSRGBBuffer(!!a, r), u = s.getLoadedTexturesCache(), c = 0; c < u.length; c++) {
var h = u[c];
if ((a === void 0 || l === h._useSRGBBuffer) && (o === void 0 || o === h.invertY) && h.url === t && h.generateMipMaps === !r && (!n || n === h.samplingMode))
return h.incrementReferences(),
h
}
return null
}
,
e.prototype._rebuild = function() {}
,
e.prototype.clone = function() {
return null
}
,
Object.defineProperty(e.prototype, "textureType", {
get: function() {
return this._texture && this._texture.type !== void 0 ? this._texture.type : 0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "textureFormat", {
get: function() {
return this._texture && this._texture.format !== void 0 ? this._texture.format : 5
},
enumerable: !1,
configurable: !0
}),
e.prototype._markAllSubMeshesAsTexturesDirty = function() {
var t = this.getScene();
!t || t.markAllMaterialsAsDirty(1)
}
,
e.prototype.readPixels = function(t, r, n, o, a) {
if (t === void 0 && (t = 0),
r === void 0 && (r = 0),
n === void 0 && (n = null),
o === void 0 && (o = !0),
a === void 0 && (a = !1),
!this._texture)
return null;
var s = this.getSize()
, l = s.width
, u = s.height
, c = this._getEngine();
if (!c)
return null;
r != 0 && (l = l / Math.pow(2, r),
u = u / Math.pow(2, r),
l = Math.round(l),
u = Math.round(u));
try {
return this._texture.isCube ? c._readTexturePixels(this._texture, l, u, t, r, n, o, a) : c._readTexturePixels(this._texture, l, u, -1, r, n, o, a)
} catch {
return null
}
}
,
e.prototype._readPixelsSync = function(t, r, n, o, a) {
if (t === void 0 && (t = 0),
r === void 0 && (r = 0),
n === void 0 && (n = null),
o === void 0 && (o = !0),
a === void 0 && (a = !1),
!this._texture)
return null;
var s = this.getSize()
, l = s.width
, u = s.height
, c = this._getEngine();
if (!c)
return null;
r != 0 && (l = l / Math.pow(2, r),
u = u / Math.pow(2, r),
l = Math.round(l),
u = Math.round(u));
try {
return this._texture.isCube ? c._readTexturePixelsSync(this._texture, l, u, t, r, n, o, a) : c._readTexturePixelsSync(this._texture, l, u, -1, r, n, o, a)
} catch {
return null
}
}
,
Object.defineProperty(e.prototype, "_lodTextureHigh", {
get: function() {
return this._texture ? this._texture._lodTextureHigh : null
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "_lodTextureMid", {
get: function() {
return this._texture ? this._texture._lodTextureMid : null
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "_lodTextureLow", {
get: function() {
return this._texture ? this._texture._lodTextureLow : null
},
enumerable: !1,
configurable: !0
}),
e.prototype.dispose = function() {
if (this._scene) {
this._scene.stopAnimation && this._scene.stopAnimation(this),
this._scene._removePendingData(this);
var t = this._scene.textures.indexOf(this);
if (t >= 0 && this._scene.textures.splice(t, 1),
this._scene.onTextureRemovedObservable.notifyObservers(this),
this._scene = null,
this._parentContainer) {
var r = this._parentContainer.textures.indexOf(this);
r > -1 && this._parentContainer.textures.splice(r, 1),
this._parentContainer = null
}
}
this.onDisposeObservable.notifyObservers(this),
this.onDisposeObservable.clear(),
this.metadata = null,
i.prototype.dispose.call(this)
}
,
e.prototype.serialize = function() {
if (!this.name)
return null;
var t = SerializationHelper.Serialize(this);
return SerializationHelper.AppendSerializedAnimations(this, t),
t
}
,
e.WhenAllReady = function(t, r) {
var n = t.length;
if (n === 0) {
r();
return
}
for (var o = 0; o < t.length; o++) {
var a = t[o];
if (a.isReady())
--n === 0 && r();
else {
var s = a.onLoadObservable;
s && s.addOnce(function() {
--n === 0 && r()
})
}
}
}
,
e._isScene = function(t) {
return t.getClassName() === "Scene"
}
,
e.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4,
__decorate([serialize()], e.prototype, "uniqueId", void 0),
__decorate([serialize()], e.prototype, "name", void 0),
__decorate([serialize()], e.prototype, "metadata", void 0),
__decorate([serialize("hasAlpha")], e.prototype, "_hasAlpha", void 0),
__decorate([serialize()], e.prototype, "getAlphaFromRGB", void 0),
__decorate([serialize()], e.prototype, "level", void 0),
__decorate([serialize()], e.prototype, "coordinatesIndex", void 0),
__decorate([serialize("coordinatesMode")], e.prototype, "_coordinatesMode", void 0),
__decorate([serialize()], e.prototype, "wrapU", null),
__decorate([serialize()], e.prototype, "wrapV", null),
__decorate([serialize()], e.prototype, "wrapR", void 0),
__decorate([serialize()], e.prototype, "anisotropicFilteringLevel", void 0),
__decorate([serialize()], e.prototype, "isCube", null),
__decorate([serialize()], e.prototype, "is3D", null),
__decorate([serialize()], e.prototype, "is2DArray", null),
__decorate([serialize()], e.prototype, "gammaSpace", null),
__decorate([serialize()], e.prototype, "invertZ", void 0),
__decorate([serialize()], e.prototype, "lodLevelInAlpha", void 0),
__decorate([serialize()], e.prototype, "lodGenerationOffset", null),
__decorate([serialize()], e.prototype, "lodGenerationScale", null),
__decorate([serialize()], e.prototype, "linearSpecularLOD", null),
__decorate([serializeAsTexture()], e.prototype, "irradianceTexture", null),
__decorate([serialize()], e.prototype, "isRenderTarget", void 0),
e
}(ThinTexture);
function GenerateBase64StringFromPixelData(i, e, t) {
t === void 0 && (t = !1);
var r = e.width
, n = e.height;
if (i instanceof Float32Array) {
for (var o = i.byteLength / i.BYTES_PER_ELEMENT, a = new Uint8Array(o); --o >= 0; ) {
var s = i[o];
s < 0 ? s = 0 : s > 1 && (s = 1),
a[o] = s * 255
}
i = a
}
var l = document.createElement("canvas");
l.width = r,
l.height = n;
var u = l.getContext("2d");
if (!u)
return null;
var c = u.createImageData(r, n)
, h = c.data;
if (h.set(i),
u.putImageData(c, 0, 0),
t) {
var f = document.createElement("canvas");
f.width = r,
f.height = n;
var d = f.getContext("2d");
return d ? (d.translate(0, n),
d.scale(1, -1),
d.drawImage(l, 0, 0),
f.toDataURL("image/png")) : null
}
return l.toDataURL("image/png")
}
function GenerateBase64StringFromTexture(i, e, t) {
e === void 0 && (e = 0),
t === void 0 && (t = 0);
var r = i.getInternalTexture();
if (!r)
return null;
var n = i._readPixelsSync(e, t);
return n ? GenerateBase64StringFromPixelData(n, i.getSize(), r.invertY) : null
}
function GenerateBase64StringFromTextureAsync(i, e, t) {
return e === void 0 && (e = 0),
t === void 0 && (t = 0),
__awaiter(this, void 0, void 0, function() {
var r, n;
return __generator(this, function(o) {
switch (o.label) {
case 0:
return r = i.getInternalTexture(),
r ? [4, i.readPixels(e, t)] : [2, null];
case 1:
return n = o.sent(),
n ? [2, GenerateBase64StringFromPixelData(n, i.getSize(), r.invertY)] : [2, null]
}
})
})
}
var Texture = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u, c, h, f, d, _) {
o === void 0 && (o = !0),
a === void 0 && (a = e.TRILINEAR_SAMPLINGMODE),
s === void 0 && (s = null),
l === void 0 && (l = null),
u === void 0 && (u = null),
c === void 0 && (c = !1);
var g, m, v, y, b, T, C, A, S = i.call(this, r) || this;
S.url = null,
S.uOffset = 0,
S.vOffset = 0,
S.uScale = 1,
S.vScale = 1,
S.uAng = 0,
S.vAng = 0,
S.wAng = 0,
S.uRotationCenter = .5,
S.vRotationCenter = .5,
S.wRotationCenter = .5,
S.homogeneousRotationInUVTransform = !1,
S.inspectableCustomProperties = null,
S._noMipmap = !1,
S._invertY = !1,
S._rowGenerationMatrix = null,
S._cachedTextureMatrix = null,
S._projectionModeMatrix = null,
S._t0 = null,
S._t1 = null,
S._t2 = null,
S._cachedUOffset = -1,
S._cachedVOffset = -1,
S._cachedUScale = 0,
S._cachedVScale = 0,
S._cachedUAng = -1,
S._cachedVAng = -1,
S._cachedWAng = -1,
S._cachedProjectionMatrixId = -1,
S._cachedURotationCenter = -1,
S._cachedVRotationCenter = -1,
S._cachedWRotationCenter = -1,
S._cachedHomogeneousRotationInUVTransform = !1,
S._cachedCoordinatesMode = -1,
S._buffer = null,
S._deleteBuffer = !1,
S._format = null,
S._delayedOnLoad = null,
S._delayedOnError = null,
S.onLoadObservable = new Observable,
S._isBlocking = !0,
S.name = t || "",
S.url = t;
var P, R = !1;
typeof n == "object" && n !== null ? (P = (g = n.noMipmap) !== null && g !== void 0 ? g : !1,
o = (m = n.invertY) !== null && m !== void 0 ? m : !0,
a = (v = n.samplingMode) !== null && v !== void 0 ? v : e.TRILINEAR_SAMPLINGMODE,
s = (y = n.onLoad) !== null && y !== void 0 ? y : null,
l = (b = n.onError) !== null && b !== void 0 ? b : null,
u = (T = n.buffer) !== null && T !== void 0 ? T : null,
c = (C = n.deleteBuffer) !== null && C !== void 0 ? C : !1,
h = n.format,
f = n.mimeType,
d = n.loaderOptions,
_ = n.creationFlags,
R = (A = n.useSRGBBuffer) !== null && A !== void 0 ? A : !1) : P = !!n,
S._noMipmap = P,
S._invertY = o,
S._initialSamplingMode = a,
S._buffer = u,
S._deleteBuffer = c,
S._mimeType = f,
S._loaderOptions = d,
S._creationFlags = _,
S._useSRGBBuffer = R,
h && (S._format = h);
var M = S.getScene()
, x = S._getEngine();
if (!x)
return S;
x.onBeforeTextureInitObservable.notifyObservers(S);
var I = function() {
S._texture && (S._texture._invertVScale && (S.vScale *= -1,
S.vOffset += 1),
S._texture._cachedWrapU !== null && (S.wrapU = S._texture._cachedWrapU,
S._texture._cachedWrapU = null),
S._texture._cachedWrapV !== null && (S.wrapV = S._texture._cachedWrapV,
S._texture._cachedWrapV = null),
S._texture._cachedWrapR !== null && (S.wrapR = S._texture._cachedWrapR,
S._texture._cachedWrapR = null)),
S.onLoadObservable.hasObservers() && S.onLoadObservable.notifyObservers(S),
s && s(),
!S.isBlocking && M && M.resetCachedMaterial()
}
, w = function(D, F) {
S._loadingError = !0,
S._errorObject = {
message: D,
exception: F
},
l && l(D, F),
e.OnTextureLoadErrorObservable.notifyObservers(S)
};
if (!S.url)
return S._delayedOnLoad = I,
S._delayedOnError = w,
S;
if (S._texture = S._getFromCache(S.url, P, a, o, R),
S._texture)
if (S._texture.isReady)
TimingTools.SetImmediate(function() {
return I()
});
else {
var O = S._texture.onLoadedObservable.add(I);
S._texture.onErrorObservable.add(function(D) {
var F;
w(D.message, D.exception),
(F = S._texture) === null || F === void 0 || F.onLoadedObservable.remove(O)
})
}
else if (!M || !M.useDelayedTextureLoading) {
try {
S._texture = x.createTexture(S.url, P, o, M, a, I, w, S._buffer, void 0, S._format, null, f, d, _, R)
} catch (D) {
throw w("error loading", D),
D
}
c && (S._buffer = null)
} else
S.delayLoadState = 4,
S._delayedOnLoad = I,
S._delayedOnError = w;
return S
}
return Object.defineProperty(e.prototype, "noMipmap", {
get: function() {
return this._noMipmap
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "mimeType", {
get: function() {
return this._mimeType
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isBlocking", {
get: function() {
return this._isBlocking
},
set: function(t) {
this._isBlocking = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "invertY", {
get: function() {
return this._invertY
},
enumerable: !1,
configurable: !0
}),
e.prototype.updateURL = function(t, r, n) {
r === void 0 && (r = null),
this.url && (this.releaseInternalTexture(),
this.getScene().markAllMaterialsAsDirty(1)),
(!this.name || StartsWith(this.name, "data:")) && (this.name = t),
this.url = t,
this._buffer = r,
this.delayLoadState = 4,
n && (this._delayedOnLoad = n),
this.delayLoad()
}
,
e.prototype.delayLoad = function() {
if (this.delayLoadState === 4) {
var t = this.getScene();
!t || (this.delayLoadState = 1,
this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY, this._useSRGBBuffer),
this._texture ? this._delayedOnLoad && (this._texture.isReady ? TimingTools.SetImmediate(this._delayedOnLoad) : this._texture.onLoadedObservable.add(this._delayedOnLoad)) : (this._texture = t.getEngine().createTexture(this.url, this._noMipmap, this._invertY, t, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format, null, this._mimeType, this._loaderOptions, this._creationFlags, this._useSRGBBuffer),
this._deleteBuffer && (this._buffer = null)),
this._delayedOnLoad = null,
this._delayedOnError = null)
}
}
,
e.prototype._prepareRowForTextureGeneration = function(t, r, n, o) {
t *= this._cachedUScale,
r *= this._cachedVScale,
t -= this.uRotationCenter * this._cachedUScale,
r -= this.vRotationCenter * this._cachedVScale,
n -= this.wRotationCenter,
Vector3.TransformCoordinatesFromFloatsToRef(t, r, n, this._rowGenerationMatrix, o),
o.x += this.uRotationCenter * this._cachedUScale + this._cachedUOffset,
o.y += this.vRotationCenter * this._cachedVScale + this._cachedVOffset,
o.z += this.wRotationCenter
}
,
e.prototype.checkTransformsAreIdentical = function(t) {
return t !== null && this.uOffset === t.uOffset && this.vOffset === t.vOffset && this.uScale === t.uScale && this.vScale === t.vScale && this.uAng === t.uAng && this.vAng === t.vAng && this.wAng === t.wAng
}
,
e.prototype.getTextureMatrix = function(t) {
var r = this;
if (t === void 0 && (t = 1),
this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale * t === this._cachedUScale && this.vScale === this._cachedVScale && this.uAng === this._cachedUAng && this.vAng === this._cachedVAng && this.wAng === this._cachedWAng && this.uRotationCenter === this._cachedURotationCenter && this.vRotationCenter === this._cachedVRotationCenter && this.wRotationCenter === this._cachedWRotationCenter && this.homogeneousRotationInUVTransform === this._cachedHomogeneousRotationInUVTransform)
return this._cachedTextureMatrix;
this._cachedUOffset = this.uOffset,
this._cachedVOffset = this.vOffset,
this._cachedUScale = this.uScale * t,
this._cachedVScale = this.vScale,
this._cachedUAng = this.uAng,
this._cachedVAng = this.vAng,
this._cachedWAng = this.wAng,
this._cachedURotationCenter = this.uRotationCenter,
this._cachedVRotationCenter = this.vRotationCenter,
this._cachedWRotationCenter = this.wRotationCenter,
this._cachedHomogeneousRotationInUVTransform = this.homogeneousRotationInUVTransform,
(!this._cachedTextureMatrix || !this._rowGenerationMatrix) && (this._cachedTextureMatrix = Matrix.Zero(),
this._rowGenerationMatrix = new Matrix,
this._t0 = Vector3.Zero(),
this._t1 = Vector3.Zero(),
this._t2 = Vector3.Zero()),
Matrix.RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix),
this.homogeneousRotationInUVTransform ? (Matrix.TranslationToRef(-this._cachedURotationCenter, -this._cachedVRotationCenter, -this._cachedWRotationCenter, TmpVectors.Matrix[0]),
Matrix.TranslationToRef(this._cachedURotationCenter, this._cachedVRotationCenter, this._cachedWRotationCenter, TmpVectors.Matrix[1]),
Matrix.ScalingToRef(this._cachedUScale, this._cachedVScale, 0, TmpVectors.Matrix[2]),
Matrix.TranslationToRef(this._cachedUOffset, this._cachedVOffset, 0, TmpVectors.Matrix[3]),
TmpVectors.Matrix[0].multiplyToRef(this._rowGenerationMatrix, this._cachedTextureMatrix),
this._cachedTextureMatrix.multiplyToRef(TmpVectors.Matrix[1], this._cachedTextureMatrix),
this._cachedTextureMatrix.multiplyToRef(TmpVectors.Matrix[2], this._cachedTextureMatrix),
this._cachedTextureMatrix.multiplyToRef(TmpVectors.Matrix[3], this._cachedTextureMatrix),
this._cachedTextureMatrix.setRowFromFloats(2, this._cachedTextureMatrix.m[12], this._cachedTextureMatrix.m[13], this._cachedTextureMatrix.m[14], 1)) : (this._prepareRowForTextureGeneration(0, 0, 0, this._t0),
this._prepareRowForTextureGeneration(1, 0, 0, this._t1),
this._prepareRowForTextureGeneration(0, 1, 0, this._t2),
this._t1.subtractInPlace(this._t0),
this._t2.subtractInPlace(this._t0),
Matrix.FromValuesToRef(this._t1.x, this._t1.y, this._t1.z, 0, this._t2.x, this._t2.y, this._t2.z, 0, this._t0.x, this._t0.y, this._t0.z, 0, 0, 0, 0, 1, this._cachedTextureMatrix));
var n = this.getScene();
return n ? (n.markAllMaterialsAsDirty(1, function(o) {
return o.hasTexture(r)
}),
this._cachedTextureMatrix) : this._cachedTextureMatrix
}
,
e.prototype.getReflectionTextureMatrix = function() {
var t = this
, r = this.getScene();
if (!r)
return this._cachedTextureMatrix;
if (this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale === this._cachedUScale && this.vScale === this._cachedVScale && this.coordinatesMode === this._cachedCoordinatesMode)
if (this.coordinatesMode === e.PROJECTION_MODE) {
if (this._cachedProjectionMatrixId === r.getProjectionMatrix().updateFlag)
return this._cachedTextureMatrix
} else
return this._cachedTextureMatrix;
this._cachedTextureMatrix || (this._cachedTextureMatrix = Matrix.Zero()),
this._projectionModeMatrix || (this._projectionModeMatrix = Matrix.Zero());
var n = this._cachedCoordinatesMode !== this.coordinatesMode;
switch (this._cachedUOffset = this.uOffset,
this._cachedVOffset = this.vOffset,
this._cachedUScale = this.uScale,
this._cachedVScale = this.vScale,
this._cachedCoordinatesMode = this.coordinatesMode,
this.coordinatesMode) {
case e.PLANAR_MODE:
Matrix.IdentityToRef(this._cachedTextureMatrix),
this._cachedTextureMatrix[0] = this.uScale,
this._cachedTextureMatrix[5] = this.vScale,
this._cachedTextureMatrix[12] = this.uOffset,
this._cachedTextureMatrix[13] = this.vOffset;
break;
case e.PROJECTION_MODE:
Matrix.FromValuesToRef(.5, 0, 0, 0, 0, -.5, 0, 0, 0, 0, 0, 0, .5, .5, 1, 1, this._projectionModeMatrix);
var o = r.getProjectionMatrix();
this._cachedProjectionMatrixId = o.updateFlag,
o.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
break;
default:
Matrix.IdentityToRef(this._cachedTextureMatrix);
break
}
return n && r.markAllMaterialsAsDirty(1, function(a) {
return a.getActiveTextures().indexOf(t) !== -1
}),
this._cachedTextureMatrix
}
,
e.prototype.clone = function() {
var t = this
, r = {
noMipmap: this._noMipmap,
invertY: this._invertY,
samplingMode: this.samplingMode,
onLoad: void 0,
onError: void 0,
buffer: this._texture ? this._texture._buffer : void 0,
deleteBuffer: this._deleteBuffer,
format: this.textureFormat,
mimeType: this.mimeType,
loaderOptions: this._loaderOptions,
creationFlags: this._creationFlags,
useSRGBBuffer: this._useSRGBBuffer
};
return SerializationHelper.Clone(function() {
return new e(t._texture ? t._texture.url : null,t.getScene(),r)
}, this)
}
,
e.prototype.serialize = function() {
var t = this.name;
e.SerializeBuffers || StartsWith(this.name, "data:") && (this.name = ""),
StartsWith(this.name, "data:") && this.url === this.name && (this.url = "");
var r = i.prototype.serialize.call(this);
return r ? ((e.SerializeBuffers || e.ForceSerializeBuffers) && (typeof this._buffer == "string" && this._buffer.substr(0, 5) === "data:" ? (r.base64String = this._buffer,
r.name = r.name.replace("data:", "")) : this.url && StartsWith(this.url, "data:") && this._buffer instanceof Uint8Array ? r.base64String = "data:image/png;base64," + EncodeArrayBufferToBase64(this._buffer) : (e.ForceSerializeBuffers || this.url && StartsWith(this.url, "blob:") || this._forceSerialize) && (r.base64String = !this._engine || this._engine._features.supportSyncTextureRead ? GenerateBase64StringFromTexture(this) : GenerateBase64StringFromTextureAsync(this))),
r.invertY = this._invertY,
r.samplingMode = this.samplingMode,
r._creationFlags = this._creationFlags,
r._useSRGBBuffer = this._useSRGBBuffer,
this.name = t,
r) : null
}
,
e.prototype.getClassName = function() {
return "Texture"
}
,
e.prototype.dispose = function() {
i.prototype.dispose.call(this),
this.onLoadObservable.clear(),
this._delayedOnLoad = null,
this._delayedOnError = null
}
,
e.Parse = function(t, r, n) {
if (t.customType) {
var o = InstantiationTools.Instantiate(t.customType)
, a = o.Parse(t, r, n);
return t.samplingMode && a.updateSamplingMode && a._samplingMode && a._samplingMode !== t.samplingMode && a.updateSamplingMode(t.samplingMode),
a
}
if (t.isCube && !t.isRenderTarget)
return e._CubeTextureParser(t, r, n);
if (!t.name && !t.isRenderTarget)
return null;
var s = function() {
if (l && l._texture && (l._texture._cachedWrapU = null,
l._texture._cachedWrapV = null,
l._texture._cachedWrapR = null),
t.samplingMode) {
var u = t.samplingMode;
l && l.samplingMode !== u && l.updateSamplingMode(u)
}
if (l && t.animations)
for (var c = 0; c < t.animations.length; c++) {
var h = t.animations[c]
, f = GetClass("BABYLON.Animation");
f && l.animations.push(f.Parse(h))
}
}
, l = SerializationHelper.Parse(function() {
var u, c, h, f = !0;
if (t.noMipmap && (f = !1),
t.mirrorPlane) {
var d = e._CreateMirror(t.name, t.renderTargetSize, r, f);
return d._waitingRenderList = t.renderList,
d.mirrorPlane = Plane.FromArray(t.mirrorPlane),
s(),
d
} else if (t.isRenderTarget) {
var _ = null;
if (t.isCube) {
if (r.reflectionProbes)
for (var g = 0; g < r.reflectionProbes.length; g++) {
var m = r.reflectionProbes[g];
if (m.name === t.name)
return m.cubeTexture
}
} else
_ = e._CreateRenderTargetTexture(t.name, t.renderTargetSize, r, f, (u = t._creationFlags) !== null && u !== void 0 ? u : 0),
_._waitingRenderList = t.renderList;
return s(),
_
} else {
var v;
if (t.base64String)
v = e.CreateFromBase64String(t.base64String, t.name, r, !f, t.invertY, t.samplingMode, s, (c = t._creationFlags) !== null && c !== void 0 ? c : 0, (h = t._useSRGBBuffer) !== null && h !== void 0 ? h : !1);
else {
var y = void 0;
t.name && t.name.indexOf("://") > 0 ? y = t.name : y = n + t.name,
(StartsWith(t.url, "data:") || e.UseSerializedUrlIfAny && t.url) && (y = t.url),
v = new e(y,r,!f,t.invertY,t.samplingMode,s)
}
return v
}
}, t, r);
return l
}
,
e.CreateFromBase64String = function(t, r, n, o, a, s, l, u, c, h) {
return s === void 0 && (s = e.TRILINEAR_SAMPLINGMODE),
l === void 0 && (l = null),
u === void 0 && (u = null),
c === void 0 && (c = 5),
new e("data:" + r,n,o,a,s,l,u,t,!1,c,void 0,void 0,h)
}
,
e.LoadFromDataString = function(t, r, n, o, a, s, l, u, c, h, f) {
return o === void 0 && (o = !1),
s === void 0 && (s = !0),
l === void 0 && (l = e.TRILINEAR_SAMPLINGMODE),
u === void 0 && (u = null),
c === void 0 && (c = null),
h === void 0 && (h = 5),
t.substr(0, 5) !== "data:" && (t = "data:" + t),
new e(t,n,a,s,l,u,c,r,o,h,void 0,void 0,f)
}
,
e.SerializeBuffers = !0,
e.ForceSerializeBuffers = !1,
e.OnTextureLoadErrorObservable = new Observable,
e._CubeTextureParser = function(t, r, n) {
throw _WarnImport("CubeTexture")
}
,
e._CreateMirror = function(t, r, n, o) {
throw _WarnImport("MirrorTexture")
}
,
e._CreateRenderTargetTexture = function(t, r, n, o, a) {
throw _WarnImport("RenderTargetTexture")
}
,
e.NEAREST_SAMPLINGMODE = 1,
e.NEAREST_NEAREST_MIPLINEAR = 8,
e.BILINEAR_SAMPLINGMODE = 2,
e.LINEAR_LINEAR_MIPNEAREST = 11,
e.TRILINEAR_SAMPLINGMODE = 3,
e.LINEAR_LINEAR_MIPLINEAR = 3,
e.NEAREST_NEAREST_MIPNEAREST = 4,
e.NEAREST_LINEAR_MIPNEAREST = 5,
e.NEAREST_LINEAR_MIPLINEAR = 6,
e.NEAREST_LINEAR = 7,
e.NEAREST_NEAREST = 1,
e.LINEAR_NEAREST_MIPNEAREST = 9,
e.LINEAR_NEAREST_MIPLINEAR = 10,
e.LINEAR_LINEAR = 2,
e.LINEAR_NEAREST = 12,
e.EXPLICIT_MODE = 0,
e.SPHERICAL_MODE = 1,
e.PLANAR_MODE = 2,
e.CUBIC_MODE = 3,
e.PROJECTION_MODE = 4,
e.SKYBOX_MODE = 5,
e.INVCUBIC_MODE = 6,
e.EQUIRECTANGULAR_MODE = 7,
e.FIXED_EQUIRECTANGULAR_MODE = 8,
e.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9,
e.CLAMP_ADDRESSMODE = 0,
e.WRAP_ADDRESSMODE = 1,
e.MIRROR_ADDRESSMODE = 2,
e.UseSerializedUrlIfAny = !1,
__decorate([serialize()], e.prototype, "url", void 0),
__decorate([serialize()], e.prototype, "uOffset", void 0),
__decorate([serialize()], e.prototype, "vOffset", void 0),
__decorate([serialize()], e.prototype, "uScale", void 0),
__decorate([serialize()], e.prototype, "vScale", void 0),
__decorate([serialize()], e.prototype, "uAng", void 0),
__decorate([serialize()], e.prototype, "vAng", void 0),
__decorate([serialize()], e.prototype, "wAng", void 0),
__decorate([serialize()], e.prototype, "uRotationCenter", void 0),
__decorate([serialize()], e.prototype, "vRotationCenter", void 0),
__decorate([serialize()], e.prototype, "wRotationCenter", void 0),
__decorate([serialize()], e.prototype, "homogeneousRotationInUVTransform", void 0),
__decorate([serialize()], e.prototype, "isBlocking", null),
e
}(BaseTexture);
RegisterClass("BABYLON.Texture", Texture);
SerializationHelper._TextureParser = Texture.Parse;
ThinEngine.prototype.updateRawTexture = function(i, e, t, r, n, o) {
if (n === void 0 && (n = null),
o === void 0 && (o = 0),
!!i) {
var a = this._getRGBABufferInternalSizedFormat(o, t)
, s = this._getInternalFormat(t)
, l = this._getWebGLTextureType(o);
this._bindTextureDirectly(this._gl.TEXTURE_2D, i, !0),
this._unpackFlipY(r === void 0 ? !0 : !!r),
this._doNotHandleContextLost || (i._bufferView = e,
i.format = t,
i.type = o,
i.invertY = r,
i._compression = n),
i.width % 4 !== 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
n && e ? this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[n], i.width, i.height, 0, e) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, a, i.width, i.height, 0, s, l, e),
i.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
i.isReady = !0
}
}
;
ThinEngine.prototype.createRawTexture = function(i, e, t, r, n, o, a, s, l, u) {
s === void 0 && (s = null),
l === void 0 && (l = 0);
var c = new InternalTexture(this,InternalTextureSource.Raw);
c.baseWidth = e,
c.baseHeight = t,
c.width = e,
c.height = t,
c.format = r,
c.generateMipMaps = n,
c.samplingMode = a,
c.invertY = o,
c._compression = s,
c.type = l,
this._doNotHandleContextLost || (c._bufferView = i),
this.updateRawTexture(c, i, r, o, s, l),
this._bindTextureDirectly(this._gl.TEXTURE_2D, c, !0);
var h = this._getSamplingParameters(a, n);
return this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, h.mag),
this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, h.min),
n && this._gl.generateMipmap(this._gl.TEXTURE_2D),
this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
this._internalTexturesCache.push(c),
c
}
;
ThinEngine.prototype.createRawCubeTexture = function(i, e, t, r, n, o, a, s) {
s === void 0 && (s = null);
var l = this._gl
, u = new InternalTexture(this,InternalTextureSource.CubeRaw);
u.isCube = !0,
u.format = t,
u.type = r,
this._doNotHandleContextLost || (u._bufferViewArray = i);
var c = this._getWebGLTextureType(r)
, h = this._getInternalFormat(t);
h === l.RGB && (h = l.RGBA),
c === l.FLOAT && !this._caps.textureFloatLinearFiltering ? (n = !1,
a = 1,
Logger$2.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : c === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering ? (n = !1,
a = 1,
Logger$2.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : c === l.FLOAT && !this._caps.textureFloatRender ? (n = !1,
Logger$2.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : c === l.HALF_FLOAT && !this._caps.colorBufferFloat && (n = !1,
Logger$2.Warn("Render to half float textures is not supported. Mipmap generation forced to false."));
var f = e
, d = f;
u.width = f,
u.height = d;
var _ = !this.needPOTTextures || Tools.IsExponentOfTwo(u.width) && Tools.IsExponentOfTwo(u.height);
_ || (n = !1),
i && this.updateRawCubeTexture(u, i, t, r, o, s),
this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, u, !0),
i && n && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
var g = this._getSamplingParameters(a, n);
return l.texParameteri(l.TEXTURE_CUBE_MAP, l.TEXTURE_MAG_FILTER, g.mag),
l.texParameteri(l.TEXTURE_CUBE_MAP, l.TEXTURE_MIN_FILTER, g.min),
l.texParameteri(l.TEXTURE_CUBE_MAP, l.TEXTURE_WRAP_S, l.CLAMP_TO_EDGE),
l.texParameteri(l.TEXTURE_CUBE_MAP, l.TEXTURE_WRAP_T, l.CLAMP_TO_EDGE),
this._bindTextureDirectly(l.TEXTURE_CUBE_MAP, null),
u.generateMipMaps = n,
u.samplingMode = a,
u
}
;
ThinEngine.prototype.updateRawCubeTexture = function(i, e, t, r, n, o, a) {
o === void 0 && (o = null),
a === void 0 && (a = 0),
i._bufferViewArray = e,
i.format = t,
i.type = r,
i.invertY = n,
i._compression = o;
var s = this._gl
, l = this._getWebGLTextureType(r)
, u = this._getInternalFormat(t)
, c = this._getRGBABufferInternalSizedFormat(r)
, h = !1;
u === s.RGB && (u = s.RGBA,
h = !0),
this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, i, !0),
this._unpackFlipY(n === void 0 ? !0 : !!n),
i.width % 4 !== 0 && s.pixelStorei(s.UNPACK_ALIGNMENT, 1);
for (var f = 0; f < 6; f++) {
var d = e[f];
o ? s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + f, a, this.getCaps().s3tc[o], i.width, i.height, 0, d) : (h && (d = _convertRGBtoRGBATextureData$1(d, i.width, i.height, r)),
s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + f, a, c, i.width, i.height, 0, u, l, d))
}
var _ = !this.needPOTTextures || Tools.IsExponentOfTwo(i.width) && Tools.IsExponentOfTwo(i.height);
_ && i.generateMipMaps && a === 0 && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),
this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
i.isReady = !0
}
;
ThinEngine.prototype.createRawCubeTextureFromUrl = function(i, e, t, r, n, o, a, s, l, u, c, h) {
var f = this;
l === void 0 && (l = null),
u === void 0 && (u = null),
c === void 0 && (c = 3),
h === void 0 && (h = !1);
var d = this._gl
, _ = this.createRawCubeTexture(null, t, r, n, !o, h, c, null);
e == null || e._addPendingData(_),
_.url = i,
this._internalTexturesCache.push(_);
var g = function(v, y) {
e == null || e._removePendingData(_),
u && v && u(v.status + " " + v.statusText, y)
}
, m = function(v) {
var y = _.width
, b = a(v);
if (!!b) {
if (s) {
var T = f._getWebGLTextureType(n)
, C = f._getInternalFormat(r)
, A = f._getRGBABufferInternalSizedFormat(n)
, S = !1;
C === d.RGB && (C = d.RGBA,
S = !0),
f._bindTextureDirectly(d.TEXTURE_CUBE_MAP, _, !0),
f._unpackFlipY(!1);
for (var P = s(b), R = 0; R < P.length; R++)
for (var M = y >> R, x = 0; x < 6; x++) {
var I = P[R][x];
S && (I = _convertRGBtoRGBATextureData$1(I, M, M, n)),
d.texImage2D(x, R, A, M, M, 0, C, T, I)
}
f._bindTextureDirectly(d.TEXTURE_CUBE_MAP, null)
} else
f.updateRawCubeTexture(_, b, r, n, h);
_.isReady = !0,
e == null || e._removePendingData(_),
l && l()
}
};
return this._loadFile(i, function(v) {
m(v)
}, void 0, e == null ? void 0 : e.offlineProvider, !0, g),
_
}
;
function _convertRGBtoRGBATextureData$1(i, e, t, r) {
var n, o = 1;
r === 1 ? n = new Float32Array(e * t * 4) : r === 2 ? (n = new Uint16Array(e * t * 4),
o = 15360) : r === 7 ? n = new Uint32Array(e * t * 4) : n = new Uint8Array(e * t * 4);
for (var a = 0; a < e; a++)
for (var s = 0; s < t; s++) {
var l = (s * e + a) * 3
, u = (s * e + a) * 4;
n[u + 0] = i[l + 0],
n[u + 1] = i[l + 1],
n[u + 2] = i[l + 2],
n[u + 3] = o
}
return n
}
function _makeCreateRawTextureFunction(i) {
return function(e, t, r, n, o, a, s, l, u, c) {
u === void 0 && (u = null),
c === void 0 && (c = 0);
var h = i ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
, f = i ? InternalTextureSource.Raw3D : InternalTextureSource.Raw2DArray
, d = new InternalTexture(this,f);
d.baseWidth = t,
d.baseHeight = r,
d.baseDepth = n,
d.width = t,
d.height = r,
d.depth = n,
d.format = o,
d.type = c,
d.generateMipMaps = a,
d.samplingMode = l,
i ? d.is3D = !0 : d.is2DArray = !0,
this._doNotHandleContextLost || (d._bufferView = e),
i ? this.updateRawTexture3D(d, e, o, s, u, c) : this.updateRawTexture2DArray(d, e, o, s, u, c),
this._bindTextureDirectly(h, d, !0);
var _ = this._getSamplingParameters(l, a);
return this._gl.texParameteri(h, this._gl.TEXTURE_MAG_FILTER, _.mag),
this._gl.texParameteri(h, this._gl.TEXTURE_MIN_FILTER, _.min),
a && this._gl.generateMipmap(h),
this._bindTextureDirectly(h, null),
this._internalTexturesCache.push(d),
d
}
}
ThinEngine.prototype.createRawTexture2DArray = _makeCreateRawTextureFunction(!1);
ThinEngine.prototype.createRawTexture3D = _makeCreateRawTextureFunction(!0);
function _makeUpdateRawTextureFunction(i) {
return function(e, t, r, n, o, a) {
o === void 0 && (o = null),
a === void 0 && (a = 0);
var s = i ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
, l = this._getWebGLTextureType(a)
, u = this._getInternalFormat(r)
, c = this._getRGBABufferInternalSizedFormat(a, r);
this._bindTextureDirectly(s, e, !0),
this._unpackFlipY(n === void 0 ? !0 : !!n),
this._doNotHandleContextLost || (e._bufferView = t,
e.format = r,
e.invertY = n,
e._compression = o),
e.width % 4 !== 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
o && t ? this._gl.compressedTexImage3D(s, 0, this.getCaps().s3tc[o], e.width, e.height, e.depth, 0, t) : this._gl.texImage3D(s, 0, c, e.width, e.height, e.depth, 0, u, l, t),
e.generateMipMaps && this._gl.generateMipmap(s),
this._bindTextureDirectly(s, null),
e.isReady = !0
}
}
ThinEngine.prototype.updateRawTexture2DArray = _makeUpdateRawTextureFunction(!1);
ThinEngine.prototype.updateRawTexture3D = _makeUpdateRawTextureFunction(!0);
var RawTexture = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u, c, h) {
s === void 0 && (s = !0),
l === void 0 && (l = !1),
u === void 0 && (u = 3),
c === void 0 && (c = 0);
var f = i.call(this, null, a, !s, l, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, h) || this;
return f.format = o,
f._engine && (!f._engine._caps.textureFloatLinearFiltering && c === 1 && (u = 1),
!f._engine._caps.textureHalfFloatLinearFiltering && c === 2 && (u = 1),
f._texture = f._engine.createRawTexture(t, r, n, o, s, l, u, null, c, h != null ? h : 0),
f.wrapU = Texture.CLAMP_ADDRESSMODE,
f.wrapV = Texture.CLAMP_ADDRESSMODE),
f
}
return e.prototype.update = function(t) {
this._getEngine().updateRawTexture(this._texture, t, this._texture.format, this._texture.invertY, null, this._texture.type)
}
,
e.CreateLuminanceTexture = function(t, r, n, o, a, s, l) {
return a === void 0 && (a = !0),
s === void 0 && (s = !1),
l === void 0 && (l = 3),
new e(t,r,n,1,o,a,s,l)
}
,
e.CreateLuminanceAlphaTexture = function(t, r, n, o, a, s, l) {
return a === void 0 && (a = !0),
s === void 0 && (s = !1),
l === void 0 && (l = 3),
new e(t,r,n,2,o,a,s,l)
}
,
e.CreateAlphaTexture = function(t, r, n, o, a, s, l) {
return a === void 0 && (a = !0),
s === void 0 && (s = !1),
l === void 0 && (l = 3),
new e(t,r,n,0,o,a,s,l)
}
,
e.CreateRGBTexture = function(t, r, n, o, a, s, l, u) {
return a === void 0 && (a = !0),
s === void 0 && (s = !1),
l === void 0 && (l = 3),
u === void 0 && (u = 0),
new e(t,r,n,4,o,a,s,l,u)
}
,
e.CreateRGBATexture = function(t, r, n, o, a, s, l, u) {
return a === void 0 && (a = !0),
s === void 0 && (s = !1),
l === void 0 && (l = 3),
u === void 0 && (u = 0),
new e(t,r,n,5,o,a,s,l,u)
}
,
e.CreateRGBAStorageTexture = function(t, r, n, o, a, s, l, u) {
return a === void 0 && (a = !0),
s === void 0 && (s = !1),
l === void 0 && (l = 3),
u === void 0 && (u = 0),
new e(t,r,n,5,o,a,s,l,u,1)
}
,
e.CreateRTexture = function(t, r, n, o, a, s, l, u) {
return a === void 0 && (a = !0),
s === void 0 && (s = !1),
l === void 0 && (l = Texture.TRILINEAR_SAMPLINGMODE),
u === void 0 && (u = 1),
new e(t,r,n,6,o,a,s,l,u)
}
,
e.CreateRStorageTexture = function(t, r, n, o, a, s, l, u) {
return a === void 0 && (a = !0),
s === void 0 && (s = !1),
l === void 0 && (l = Texture.TRILINEAR_SAMPLINGMODE),
u === void 0 && (u = 1),
new e(t,r,n,6,o,a,s,l,u,1)
}
,
e
}(Texture)
, Skeleton = function() {
function i(e, t, r) {
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 = Matrix.Identity(),
this._ranges = {},
this._lastAbsoluteTransformsUpdateId = -1,
this._canUseTextureForBones = !1,
this._uniqueId = 0,
this._numBonesWithLinkedTransformNode = 0,
this._hasWaitingData = null,
this._waitingOverrideMeshId = null,
this._parentContainer = null,
this.doNotSerialize = !1,
this._useTextureToStoreBoneMatrices = !0,
this._animationPropertiesOverride = null,
this.onBeforeComputeObservable = new Observable,
this.bones = [],
this._scene = r || EngineStore.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(i.prototype, "useTextureToStoreBoneMatrices", {
get: function() {
return this._useTextureToStoreBoneMatrices
},
set: function(e) {
this._useTextureToStoreBoneMatrices = e,
this._markAsDirty()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "animationPropertiesOverride", {
get: function() {
return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
},
set: function(e) {
this._animationPropertiesOverride = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isUsingTextureForMatrices", {
get: function() {
return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "uniqueId", {
get: function() {
return this._uniqueId
},
enumerable: !1,
configurable: !0
}),
i.prototype.getClassName = function() {
return "Skeleton"
}
,
i.prototype.getChildren = function() {
return this.bones.filter(function(e) {
return !e.getParent()
})
}
,
i.prototype.getTransformMatrices = function(e) {
return this.needInitialSkinMatrix && e._bonesTransformMatrices ? e._bonesTransformMatrices : (this._transformMatrices || this.prepare(),
this._transformMatrices)
}
,
i.prototype.getTransformMatrixTexture = function(e) {
return this.needInitialSkinMatrix && e._transformMatrixTexture ? e._transformMatrixTexture : this._transformMatrixTexture
}
,
i.prototype.getScene = function() {
return this._scene
}
,
i.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 r = !0;
for (var n in this._ranges)
r && (t += ", ",
r = !1),
t += n;
t += "}"
}
return t
}
,
i.prototype.getBoneIndexByName = function(e) {
for (var t = 0, r = this.bones.length; t < r; t++)
if (this.bones[t].name === e)
return t;
return -1
}
,
i.prototype.createAnimationRange = function(e, t, r) {
if (!this._ranges[e]) {
this._ranges[e] = new AnimationRange(e,t,r);
for (var n = 0, o = this.bones.length; n < o; n++)
this.bones[n].animations[0] && this.bones[n].animations[0].createRange(e, t, r)
}
}
,
i.prototype.deleteAnimationRange = function(e, t) {
t === void 0 && (t = !0);
for (var r = 0, n = this.bones.length; r < n; r++)
this.bones[r].animations[0] && this.bones[r].animations[0].deleteRange(e, t);
this._ranges[e] = null
}
,
i.prototype.getAnimationRange = function(e) {
return this._ranges[e] || null
}
,
i.prototype.getAnimationRanges = function() {
var e = [], t;
for (t in this._ranges)
e.push(this._ranges[t]);
return e
}
,
i.prototype.copyAnimationRange = function(e, t, r) {
if (r === void 0 && (r = !1),
this._ranges[t] || !e.getAnimationRange(t))
return !1;
var n = !0, o = this._getHighestAnimationFrame() + 1, a = {}, s = e.bones, l, u;
for (u = 0,
l = s.length; u < l; u++)
a[s[u].name] = s[u];
this.bones.length !== s.length && (Logger$2.Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + s.length),
n = !1);
var c = r && this.dimensionsAtRest && e.dimensionsAtRest ? this.dimensionsAtRest.divide(e.dimensionsAtRest) : null;
for (u = 0,
l = this.bones.length; u < l; u++) {
var h = this.bones[u].name
, f = a[h];
f ? n = n && this.bones[u].copyAnimationRange(f, t, o, r, c) : (Logger$2.Warn("copyAnimationRange: not same rig, missing source bone " + h),
n = !1)
}
var d = e.getAnimationRange(t);
return d && (this._ranges[t] = new AnimationRange(t,d.from + o,d.to + o)),
n
}
,
i.prototype.returnToRest = function() {
for (var e = 0, t = this.bones; e < t.length; e++) {
var r = t[e];
r._index !== -1 && r.returnToRest()
}
}
,
i.prototype._getHighestAnimationFrame = function() {
for (var e = 0, t = 0, r = this.bones.length; t < r; t++)
if (this.bones[t].animations[0]) {
var n = this.bones[t].animations[0].getHighestFrame();
e < n && (e = n)
}
return e
}
,
i.prototype.beginAnimation = function(e, t, r, n) {
var o = this.getAnimationRange(e);
return o ? this._scene.beginAnimation(this, o.from, o.to, t, r, n) : null
}
,
i.MakeAnimationAdditive = function(e, t, r) {
t === void 0 && (t = 0);
var n = e.getAnimationRange(r);
if (!n)
return null;
for (var o = e._scene.getAllAnimatablesByTarget(e), a = null, s = 0; s < o.length; s++) {
var l = o[s];
if (l.fromFrame === (n == null ? void 0 : n.from) && l.toFrame === (n == null ? void 0 : n.to)) {
a = l;
break
}
}
for (var u = e.getAnimatables(), s = 0; s < u.length; s++) {
var c = u[s]
, h = c.animations;
if (!!h)
for (var f = 0; f < h.length; f++)
Animation.MakeAnimationAdditive(h[f], t, r)
}
return a && (a.isAdditive = !0),
e
}
,
i.prototype._markAsDirty = function() {
this._isDirty = !0
}
,
i.prototype._registerMeshWithPoseMatrix = function(e) {
this._meshesWithPoseMatrix.push(e)
}
,
i.prototype._unregisterMeshWithPoseMatrix = function(e) {
var t = this._meshesWithPoseMatrix.indexOf(e);
t > -1 && this._meshesWithPoseMatrix.splice(t, 1)
}
,
i.prototype._computeTransformMatrices = function(e, t) {
this.onBeforeComputeObservable.notifyObservers(this);
for (var r = 0; r < this.bones.length; r++) {
var n = this.bones[r];
n._childUpdateId++;
var o = n.getParent();
if (o ? n.getLocalMatrix().multiplyToRef(o.getWorldMatrix(), n.getWorldMatrix()) : t ? n.getLocalMatrix().multiplyToRef(t, n.getWorldMatrix()) : n.getWorldMatrix().copyFrom(n.getLocalMatrix()),
n._index !== -1) {
var a = n._index === null ? r : n._index;
n.getInvertedAbsoluteTransform().multiplyToArray(n.getWorldMatrix(), e, a * 16)
}
}
this._identity.copyToArray(e, this.bones.length * 16)
}
,
i.prototype.prepare = function() {
if (this._numBonesWithLinkedTransformNode > 0)
for (var e = 0, t = this.bones; e < t.length; e++) {
var r = t[e];
r._linkedTransformNode && (r._linkedTransformNode.computeWorldMatrix(),
r._matrix = r._linkedTransformNode._localMatrix)
}
if (!!this._isDirty) {
if (this.needInitialSkinMatrix)
for (var n = 0; n < this._meshesWithPoseMatrix.length; n++) {
var o = this._meshesWithPoseMatrix[n]
, a = o.getPoseMatrix();
if ((!o._bonesTransformMatrices || o._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) && (o._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1))),
this._synchronizedWithMesh !== o) {
this._synchronizedWithMesh = o;
for (var s = 0; s < this.bones.length; s++) {
var l = this.bones[s];
if (!l.getParent()) {
var u = l.getBaseMatrix();
u.multiplyToRef(a, TmpVectors.Matrix[1]),
l._updateDifferenceMatrix(TmpVectors.Matrix[1])
}
}
if (this.isUsingTextureForMatrices) {
var c = (this.bones.length + 1) * 4;
(!o._transformMatrixTexture || o._transformMatrixTexture.getSize().width !== c) && (o._transformMatrixTexture && o._transformMatrixTexture.dispose(),
o._transformMatrixTexture = RawTexture.CreateRGBATexture(o._bonesTransformMatrices, (this.bones.length + 1) * 4, 1, this._scene, !1, !1, 1, 1))
}
}
this._computeTransformMatrices(o._bonesTransformMatrices, a),
this.isUsingTextureForMatrices && o._transformMatrixTexture && o._transformMatrixTexture.update(o._bonesTransformMatrices)
}
else
(!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) && (this._transformMatrices = new Float32Array(16 * (this.bones.length + 1)),
this.isUsingTextureForMatrices && (this._transformMatrixTexture && this._transformMatrixTexture.dispose(),
this._transformMatrixTexture = RawTexture.CreateRGBATexture(this._transformMatrices, (this.bones.length + 1) * 4, 1, this._scene, !1, !1, 1, 1))),
this._computeTransformMatrices(this._transformMatrices, null),
this.isUsingTextureForMatrices && this._transformMatrixTexture && this._transformMatrixTexture.update(this._transformMatrices);
this._isDirty = !1,
this._scene._activeBones.addCount(this.bones.length, !1)
}
}
,
i.prototype.getAnimatables = function() {
if (!this._animatables || this._animatables.length !== this.bones.length) {
this._animatables = [];
for (var e = 0; e < this.bones.length; e++)
this._animatables.push(this.bones[e])
}
return this._animatables
}
,
i.prototype.clone = function(e, t) {
var r = new i(e,t || e,this._scene);
r.needInitialSkinMatrix = this.needInitialSkinMatrix,
r.overrideMesh = this.overrideMesh;
for (var n = 0; n < this.bones.length; n++) {
var o = this.bones[n]
, a = null
, s = o.getParent();
if (s) {
var l = this.bones.indexOf(s);
a = r.bones[l]
}
var u = new Bone(o.name,r,a,o.getBaseMatrix().clone(),o.getRestPose().clone());
u._index = o._index,
o._linkedTransformNode && u.linkTransformNode(o._linkedTransformNode),
DeepCopier.DeepCopy(o.animations, u.animations)
}
if (this._ranges) {
r._ranges = {};
for (var c in this._ranges) {
var h = this._ranges[c];
h && (r._ranges[c] = h.clone())
}
}
return this._isDirty = !0,
r
}
,
i.prototype.enableBlending = function(e) {
e === void 0 && (e = .01),
this.bones.forEach(function(t) {
t.animations.forEach(function(r) {
r.enableBlending = !0,
r.blendingSpeed = e
})
})
}
,
i.prototype.dispose = function() {
if (this._meshesWithPoseMatrix = [],
this.getScene().stopAnimation(this),
this.getScene().removeSkeleton(this),
this._parentContainer) {
var e = this._parentContainer.skeletons.indexOf(this);
e > -1 && this._parentContainer.skeletons.splice(e, 1),
this._parentContainer = null
}
this._transformMatrixTexture && (this._transformMatrixTexture.dispose(),
this._transformMatrixTexture = null)
}
,
i.prototype.serialize = function() {
var e, t, r = {};
r.name = this.name,
r.id = this.id,
this.dimensionsAtRest && (r.dimensionsAtRest = this.dimensionsAtRest.asArray()),
r.bones = [],
r.needInitialSkinMatrix = this.needInitialSkinMatrix,
r.overrideMeshId = (e = this.overrideMesh) === null || e === void 0 ? void 0 : e.id;
for (var n = 0; n < this.bones.length; n++) {
var o = this.bones[n]
, a = o.getParent()
, s = {
parentBoneIndex: a ? this.bones.indexOf(a) : -1,
index: o.getIndex(),
name: o.name,
id: o.id,
matrix: o.getBaseMatrix().toArray(),
rest: o.getRestPose().toArray(),
linkedTransformNodeId: (t = o.getTransformNode()) === null || t === void 0 ? void 0 : t.id
};
r.bones.push(s),
o.length && (s.length = o.length),
o.metadata && (s.metadata = o.metadata),
o.animations && o.animations.length > 0 && (s.animation = o.animations[0].serialize()),
r.ranges = [];
for (var l in this._ranges) {
var u = this._ranges[l];
if (!!u) {
var c = {};
c.name = l,
c.from = u.from,
c.to = u.to,
r.ranges.push(c)
}
}
}
return r
}
,
i.Parse = function(e, t) {
var r = new i(e.name,e.id,t);
e.dimensionsAtRest && (r.dimensionsAtRest = Vector3.FromArray(e.dimensionsAtRest)),
r.needInitialSkinMatrix = e.needInitialSkinMatrix,
e.overrideMeshId && (r._hasWaitingData = !0,
r._waitingOverrideMeshId = e.overrideMeshId);
var n;
for (n = 0; n < e.bones.length; n++) {
var o = e.bones[n]
, a = e.bones[n].index
, s = null;
o.parentBoneIndex > -1 && (s = r.bones[o.parentBoneIndex]);
var l = o.rest ? Matrix.FromArray(o.rest) : null
, u = new Bone(o.name,r,s,Matrix.FromArray(o.matrix),l,null,a);
o.id !== void 0 && o.id !== null && (u.id = o.id),
o.length && (u.length = o.length),
o.metadata && (u.metadata = o.metadata),
o.animation && u.animations.push(Animation.Parse(o.animation)),
o.linkedTransformNodeId !== void 0 && o.linkedTransformNodeId !== null && (r._hasWaitingData = !0,
u._waitingTransformNodeId = o.linkedTransformNodeId)
}
if (e.ranges)
for (n = 0; n < e.ranges.length; n++) {
var c = e.ranges[n];
r.createAnimationRange(c.name, c.from, c.to)
}
return r
}
,
i.prototype.computeAbsoluteTransforms = function(e) {
e === void 0 && (e = !1);
var t = this._scene.getRenderId();
(this._lastAbsoluteTransformsUpdateId != t || e) && (this.bones[0].computeAbsoluteTransforms(),
this._lastAbsoluteTransformsUpdateId = t)
}
,
i.prototype.getPoseMatrix = function() {
var e = null;
return this._meshesWithPoseMatrix.length > 0 && (e = this._meshesWithPoseMatrix[0].getPoseMatrix()),
e
}
,
i.prototype.sortBones = function() {
for (var e = new Array, t = new Array(this.bones.length), r = 0; r < this.bones.length; r++)
this._sortBones(r, e, t);
this.bones = e
}
,
i.prototype._sortBones = function(e, t, r) {
if (!r[e]) {
r[e] = !0;
var n = this.bones[e];
n._index === void 0 && (n._index = e);
var o = n.getParent();
o && this._sortBones(this.bones.indexOf(o), t, r),
t.push(n)
}
}
,
i.prototype.setCurrentPoseAsRest = function() {
this.bones.forEach(function(e) {
e.setCurrentPoseAsRest()
})
}
,
i
}();
function inlineScheduler(i, e, t) {
try {
var r = i.next();
r.done ? e(r) : r.value ? r.value.then(function() {
r.value = void 0,
e(r)
}, t) : e(r)
} catch (n) {
t(n)
}
}
function createYieldingScheduler(i) {
i === void 0 && (i = 25);
var e;
return function(t, r, n) {
var o = performance.now();
e === void 0 || o - e > i ? (e = o,
setTimeout(function() {
inlineScheduler(t, r, n)
}, 0)) : inlineScheduler(t, r, n)
}
}
function runCoroutine(i, e, t, r, n) {
var o = function() {
var a, s = function(l) {
l.done ? t(l.value) : a === void 0 ? a = !0 : o()
};
do
a = void 0,
!n || !n.aborted ? e(i, s, r) : r(new Error("Aborted")),
a === void 0 && (a = !1);
while (a)
};
o()
}
function runCoroutineSync(i, e) {
var t;
return runCoroutine(i, inlineScheduler, function(r) {
return t = r
}, function(r) {
throw r
}, e),
t
}
function runCoroutineAsync(i, e, t) {
return new Promise(function(r, n) {
runCoroutine(i, e, r, n, t)
}
)
}
function makeSyncFunction(i, e) {
return function() {
for (var t = [], r = 0; r < arguments.length; r++)
t[r] = arguments[r];
return runCoroutineSync(i.apply(void 0, t), e)
}
}
var VertexData = function() {
function i() {
this._applyTo = makeSyncFunction(this._applyToCoroutine.bind(this))
}
return i.prototype.set = function(e, t) {
switch (e.length || Logger$2.Warn("Setting vertex data kind '" + t + "' with an empty array"),
t) {
case VertexBuffer.PositionKind:
this.positions = e;
break;
case VertexBuffer.NormalKind:
this.normals = e;
break;
case VertexBuffer.TangentKind:
this.tangents = e;
break;
case VertexBuffer.UVKind:
this.uvs = e;
break;
case VertexBuffer.UV2Kind:
this.uvs2 = e;
break;
case VertexBuffer.UV3Kind:
this.uvs3 = e;
break;
case VertexBuffer.UV4Kind:
this.uvs4 = e;
break;
case VertexBuffer.UV5Kind:
this.uvs5 = e;
break;
case VertexBuffer.UV6Kind:
this.uvs6 = e;
break;
case VertexBuffer.ColorKind:
this.colors = e;
break;
case VertexBuffer.MatricesIndicesKind:
this.matricesIndices = e;
break;
case VertexBuffer.MatricesWeightsKind:
this.matricesWeights = e;
break;
case VertexBuffer.MatricesIndicesExtraKind:
this.matricesIndicesExtra = e;
break;
case VertexBuffer.MatricesWeightsExtraKind:
this.matricesWeightsExtra = e;
break
}
}
,
i.prototype.applyToMesh = function(e, t) {
return this._applyTo(e, t, !1),
this
}
,
i.prototype.applyToGeometry = function(e, t) {
return this._applyTo(e, t, !1),
this
}
,
i.prototype.updateMesh = function(e) {
return this._update(e),
this
}
,
i.prototype.updateGeometry = function(e) {
return this._update(e),
this
}
,
i.prototype._applyToCoroutine = function(e, t, r) {
return t === void 0 && (t = !1),
__generator(this, function(n) {
switch (n.label) {
case 0:
return this.positions ? (e.setVerticesData(VertexBuffer.PositionKind, this.positions, t),
r ? [4] : [3, 2]) : [3, 2];
case 1:
n.sent(),
n.label = 2;
case 2:
return this.normals ? (e.setVerticesData(VertexBuffer.NormalKind, this.normals, t),
r ? [4] : [3, 4]) : [3, 4];
case 3:
n.sent(),
n.label = 4;
case 4:
return this.tangents ? (e.setVerticesData(VertexBuffer.TangentKind, this.tangents, t),
r ? [4] : [3, 6]) : [3, 6];
case 5:
n.sent(),
n.label = 6;
case 6:
return this.uvs ? (e.setVerticesData(VertexBuffer.UVKind, this.uvs, t),
r ? [4] : [3, 8]) : [3, 8];
case 7:
n.sent(),
n.label = 8;
case 8:
return this.uvs2 ? (e.setVerticesData(VertexBuffer.UV2Kind, this.uvs2, t),
r ? [4] : [3, 10]) : [3, 10];
case 9:
n.sent(),
n.label = 10;
case 10:
return this.uvs3 ? (e.setVerticesData(VertexBuffer.UV3Kind, this.uvs3, t),
r ? [4] : [3, 12]) : [3, 12];
case 11:
n.sent(),
n.label = 12;
case 12:
return this.uvs4 ? (e.setVerticesData(VertexBuffer.UV4Kind, this.uvs4, t),
r ? [4] : [3, 14]) : [3, 14];
case 13:
n.sent(),
n.label = 14;
case 14:
return this.uvs5 ? (e.setVerticesData(VertexBuffer.UV5Kind, this.uvs5, t),
r ? [4] : [3, 16]) : [3, 16];
case 15:
n.sent(),
n.label = 16;
case 16:
return this.uvs6 ? (e.setVerticesData(VertexBuffer.UV6Kind, this.uvs6, t),
r ? [4] : [3, 18]) : [3, 18];
case 17:
n.sent(),
n.label = 18;
case 18:
return this.colors ? (e.setVerticesData(VertexBuffer.ColorKind, this.colors, t),
r ? [4] : [3, 20]) : [3, 20];
case 19:
n.sent(),
n.label = 20;
case 20:
return this.matricesIndices ? (e.setVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, t),
r ? [4] : [3, 22]) : [3, 22];
case 21:
n.sent(),
n.label = 22;
case 22:
return this.matricesWeights ? (e.setVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, t),
r ? [4] : [3, 24]) : [3, 24];
case 23:
n.sent(),
n.label = 24;
case 24:
return this.matricesIndicesExtra ? (e.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, t),
r ? [4] : [3, 26]) : [3, 26];
case 25:
n.sent(),
n.label = 26;
case 26:
return this.matricesWeightsExtra ? (e.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, t),
r ? [4] : [3, 28]) : [3, 28];
case 27:
n.sent(),
n.label = 28;
case 28:
return this.indices ? (e.setIndices(this.indices, null, t),
r ? [4] : [3, 30]) : [3, 31];
case 29:
n.sent(),
n.label = 30;
case 30:
return [3, 32];
case 31:
e.setIndices([], null),
n.label = 32;
case 32:
return [2, this]
}
})
}
,
i.prototype._update = function(e, t, r) {
return this.positions && e.updateVerticesData(VertexBuffer.PositionKind, this.positions, t, r),
this.normals && e.updateVerticesData(VertexBuffer.NormalKind, this.normals, t, r),
this.tangents && e.updateVerticesData(VertexBuffer.TangentKind, this.tangents, t, r),
this.uvs && e.updateVerticesData(VertexBuffer.UVKind, this.uvs, t, r),
this.uvs2 && e.updateVerticesData(VertexBuffer.UV2Kind, this.uvs2, t, r),
this.uvs3 && e.updateVerticesData(VertexBuffer.UV3Kind, this.uvs3, t, r),
this.uvs4 && e.updateVerticesData(VertexBuffer.UV4Kind, this.uvs4, t, r),
this.uvs5 && e.updateVerticesData(VertexBuffer.UV5Kind, this.uvs5, t, r),
this.uvs6 && e.updateVerticesData(VertexBuffer.UV6Kind, this.uvs6, t, r),
this.colors && e.updateVerticesData(VertexBuffer.ColorKind, this.colors, t, r),
this.matricesIndices && e.updateVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, t, r),
this.matricesWeights && e.updateVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, t, r),
this.matricesIndicesExtra && e.updateVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, t, r),
this.matricesWeightsExtra && e.updateVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, t, r),
this.indices && e.setIndices(this.indices, null),
this
}
,
i._TransformVector3Coordinates = function(e, t) {
for (var r = TmpVectors.Vector3[0], n = TmpVectors.Vector3[1], o = 0; o < e.length; o += 3)
Vector3.FromArrayToRef(e, o, r),
Vector3.TransformCoordinatesToRef(r, t, n),
e[o] = n.x,
e[o + 1] = n.y,
e[o + 2] = n.z
}
,
i._TransformVector3Normals = function(e, t) {
for (var r = TmpVectors.Vector3[0], n = TmpVectors.Vector3[1], o = 0; o < e.length; o += 3)
Vector3.FromArrayToRef(e, o, r),
Vector3.TransformNormalToRef(r, t, n),
e[o] = n.x,
e[o + 1] = n.y,
e[o + 2] = n.z
}
,
i._TransformVector4Normals = function(e, t) {
for (var r = TmpVectors.Vector4[0], n = TmpVectors.Vector4[1], o = 0; o < e.length; o += 4)
Vector4.FromArrayToRef(e, o, r),
Vector4.TransformNormalToRef(r, t, n),
e[o] = n.x,
e[o + 1] = n.y,
e[o + 2] = n.z,
e[o + 3] = n.w
}
,
i._FlipFaces = function(e) {
for (var t = 0; t < e.length; t += 3) {
var r = e[t + 1];
e[t + 1] = e[t + 2],
e[t + 2] = r
}
}
,
i.prototype.transform = function(e) {
var t = e.determinant() < 0;
return this.positions && i._TransformVector3Coordinates(this.positions, e),
this.normals && i._TransformVector3Normals(this.normals, e),
this.tangents && i._TransformVector4Normals(this.tangents, e),
t && this.indices && i._FlipFaces(this.indices),
this
}
,
i.prototype.merge = function(e, t) {
return t === void 0 && (t = !1),
runCoroutineSync(this._mergeCoroutine(e, t, !1))
}
,
i.prototype._mergeCoroutine = function(e, t, r) {
var n, o, f, a, s, l, u, c, h, f, d, _, g, m, v;
return t === void 0 && (t = !1),
__generator(this, function(y) {
switch (y.label) {
case 0:
for (this._validate(),
e = Array.isArray(e) ? e : [e],
n = 0,
o = e; n < o.length; n++)
if (f = o[n],
f._validate(),
!this.normals != !f.normals || !this.tangents != !f.tangents || !this.uvs != !f.uvs || !this.uvs2 != !f.uvs2 || !this.uvs3 != !f.uvs3 || !this.uvs4 != !f.uvs4 || !this.uvs5 != !f.uvs5 || !this.uvs6 != !f.uvs6 || !this.colors != !f.colors || !this.matricesIndices != !f.matricesIndices || !this.matricesWeights != !f.matricesWeights || !this.matricesIndicesExtra != !f.matricesIndicesExtra || !this.matricesWeightsExtra != !f.matricesWeightsExtra)
throw new Error("Cannot merge vertex data that do not have the same set of attributes");
if (a = e.reduce(function(b, T) {
var C, A;
return b + ((A = (C = T.indices) === null || C === void 0 ? void 0 : C.length) !== null && A !== void 0 ? A : 0)
}, (g = (_ = this.indices) === null || _ === void 0 ? void 0 : _.length) !== null && g !== void 0 ? g : 0),
!(a > 0))
return [3, 4];
s = (v = (m = this.indices) === null || m === void 0 ? void 0 : m.length) !== null && v !== void 0 ? v : 0,
this.indices || (this.indices = new Array(a)),
this.indices.length !== a && (Array.isArray(this.indices) ? this.indices.length = a : (l = t || this.indices instanceof Uint32Array ? new Uint32Array(a) : new Uint16Array(a),
l.set(this.indices),
this.indices = l)),
u = this.positions ? this.positions.length / 3 : 0,
c = 0,
h = e,
y.label = 1;
case 1:
if (!(c < h.length))
return [3, 4];
if (f = h[c],
!f.indices)
return [3, 3];
for (d = 0; d < f.indices.length; d++)
this.indices[s + d] = f.indices[d] + u;
return u += f.positions.length / 3,
s += f.indices.length,
r ? [4] : [3, 3];
case 2:
y.sent(),
y.label = 3;
case 3:
return c++,
[3, 1];
case 4:
return this.positions = i._mergeElement(this.positions, e.map(function(b) {
return b.positions
})),
r ? [4] : [3, 6];
case 5:
y.sent(),
y.label = 6;
case 6:
return this.normals = i._mergeElement(this.normals, e.map(function(b) {
return b.normals
})),
r ? [4] : [3, 8];
case 7:
y.sent(),
y.label = 8;
case 8:
return this.tangents = i._mergeElement(this.tangents, e.map(function(b) {
return b.tangents
})),
r ? [4] : [3, 10];
case 9:
y.sent(),
y.label = 10;
case 10:
return this.uvs = i._mergeElement(this.uvs, e.map(function(b) {
return b.uvs
})),
r ? [4] : [3, 12];
case 11:
y.sent(),
y.label = 12;
case 12:
return this.uvs2 = i._mergeElement(this.uvs2, e.map(function(b) {
return b.uvs2
})),
r ? [4] : [3, 14];
case 13:
y.sent(),
y.label = 14;
case 14:
return this.uvs3 = i._mergeElement(this.uvs3, e.map(function(b) {
return b.uvs3
})),
r ? [4] : [3, 16];
case 15:
y.sent(),
y.label = 16;
case 16:
return this.uvs4 = i._mergeElement(this.uvs4, e.map(function(b) {
return b.uvs4
})),
r ? [4] : [3, 18];
case 17:
y.sent(),
y.label = 18;
case 18:
return this.uvs5 = i._mergeElement(this.uvs5, e.map(function(b) {
return b.uvs5
})),
r ? [4] : [3, 20];
case 19:
y.sent(),
y.label = 20;
case 20:
return this.uvs6 = i._mergeElement(this.uvs6, e.map(function(b) {
return b.uvs6
})),
r ? [4] : [3, 22];
case 21:
y.sent(),
y.label = 22;
case 22:
return this.colors = i._mergeElement(this.colors, e.map(function(b) {
return b.colors
})),
r ? [4] : [3, 24];
case 23:
y.sent(),
y.label = 24;
case 24:
return this.matricesIndices = i._mergeElement(this.matricesIndices, e.map(function(b) {
return b.matricesIndices
})),
r ? [4] : [3, 26];
case 25:
y.sent(),
y.label = 26;
case 26:
return this.matricesWeights = i._mergeElement(this.matricesWeights, e.map(function(b) {
return b.matricesWeights
})),
r ? [4] : [3, 28];
case 27:
y.sent(),
y.label = 28;
case 28:
return this.matricesIndicesExtra = i._mergeElement(this.matricesIndicesExtra, e.map(function(b) {
return b.matricesIndicesExtra
})),
r ? [4] : [3, 30];
case 29:
y.sent(),
y.label = 30;
case 30:
return this.matricesWeightsExtra = i._mergeElement(this.matricesWeightsExtra, e.map(function(b) {
return b.matricesWeightsExtra
})),
[2, this]
}
})
}
,
i._mergeElement = function(e, t) {
var r = t.filter(function(_) {
return _ != null
});
if (r.length === 0)
return e;
if (!e)
return this._mergeElement(r[0], r.slice(1));
var n = r.reduce(function(_, g) {
return _ + g.length
}, e.length);
if (e instanceof Float32Array) {
var o = new Float32Array(n);
o.set(e);
for (var a = e.length, s = 0, l = r; s < l.length; s++) {
var u = l[s];
o.set(u, a),
a += u.length
}
return o
} else {
for (var c = new Array(n), h = 0; h < e.length; h++)
c[h] = e[h];
for (var a = e.length, f = 0, d = r; f < d.length; f++) {
for (var u = d[f], h = 0; h < u.length; h++)
c[a + h] = u[h];
a += u.length
}
return c
}
}
,
i.prototype._validate = function() {
if (!this.positions)
throw new Error("Positions are required");
var e = function(n, o) {
var a = VertexBuffer.DeduceStride(n);
if (o.length % a !== 0)
throw new Error("The " + n + "s array count must be a multiple of " + a);
return o.length / a
}
, t = e(VertexBuffer.PositionKind, this.positions)
, r = function(n, o) {
var a = e(n, o);
if (a !== t)
throw new Error("The " + n + "s element count (" + a + ") does not match the positions count (" + t + ")")
};
this.normals && r(VertexBuffer.NormalKind, this.normals),
this.tangents && r(VertexBuffer.TangentKind, this.tangents),
this.uvs && r(VertexBuffer.UVKind, this.uvs),
this.uvs2 && r(VertexBuffer.UV2Kind, this.uvs2),
this.uvs3 && r(VertexBuffer.UV3Kind, this.uvs3),
this.uvs4 && r(VertexBuffer.UV4Kind, this.uvs4),
this.uvs5 && r(VertexBuffer.UV5Kind, this.uvs5),
this.uvs6 && r(VertexBuffer.UV6Kind, this.uvs6),
this.colors && r(VertexBuffer.ColorKind, this.colors),
this.matricesIndices && r(VertexBuffer.MatricesIndicesKind, this.matricesIndices),
this.matricesWeights && r(VertexBuffer.MatricesWeightsKind, this.matricesWeights),
this.matricesIndicesExtra && r(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra),
this.matricesWeightsExtra && r(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra)
}
,
i.prototype.serialize = function() {
var e = {};
return this.positions && (e.positions = this.positions),
this.normals && (e.normals = this.normals),
this.tangents && (e.tangents = this.tangents),
this.uvs && (e.uvs = this.uvs),
this.uvs2 && (e.uvs2 = this.uvs2),
this.uvs3 && (e.uvs3 = this.uvs3),
this.uvs4 && (e.uvs4 = this.uvs4),
this.uvs5 && (e.uvs5 = this.uvs5),
this.uvs6 && (e.uvs6 = this.uvs6),
this.colors && (e.colors = this.colors),
this.matricesIndices && (e.matricesIndices = this.matricesIndices,
e.matricesIndices._isExpanded = !0),
this.matricesWeights && (e.matricesWeights = this.matricesWeights),
this.matricesIndicesExtra && (e.matricesIndicesExtra = this.matricesIndicesExtra,
e.matricesIndicesExtra._isExpanded = !0),
this.matricesWeightsExtra && (e.matricesWeightsExtra = this.matricesWeightsExtra),
e.indices = this.indices,
e
}
,
i.ExtractFromMesh = function(e, t, r) {
return i._ExtractFrom(e, t, r)
}
,
i.ExtractFromGeometry = function(e, t, r) {
return i._ExtractFrom(e, t, r)
}
,
i._ExtractFrom = function(e, t, r) {
var n = new i;
return e.isVerticesDataPresent(VertexBuffer.PositionKind) && (n.positions = e.getVerticesData(VertexBuffer.PositionKind, t, r)),
e.isVerticesDataPresent(VertexBuffer.NormalKind) && (n.normals = e.getVerticesData(VertexBuffer.NormalKind, t, r)),
e.isVerticesDataPresent(VertexBuffer.TangentKind) && (n.tangents = e.getVerticesData(VertexBuffer.TangentKind, t, r)),
e.isVerticesDataPresent(VertexBuffer.UVKind) && (n.uvs = e.getVerticesData(VertexBuffer.UVKind, t, r)),
e.isVerticesDataPresent(VertexBuffer.UV2Kind) && (n.uvs2 = e.getVerticesData(VertexBuffer.UV2Kind, t, r)),
e.isVerticesDataPresent(VertexBuffer.UV3Kind) && (n.uvs3 = e.getVerticesData(VertexBuffer.UV3Kind, t, r)),
e.isVerticesDataPresent(VertexBuffer.UV4Kind) && (n.uvs4 = e.getVerticesData(VertexBuffer.UV4Kind, t, r)),
e.isVerticesDataPresent(VertexBuffer.UV5Kind) && (n.uvs5 = e.getVerticesData(VertexBuffer.UV5Kind, t, r)),
e.isVerticesDataPresent(VertexBuffer.UV6Kind) && (n.uvs6 = e.getVerticesData(VertexBuffer.UV6Kind, t, r)),
e.isVerticesDataPresent(VertexBuffer.ColorKind) && (n.colors = e.getVerticesData(VertexBuffer.ColorKind, t, r)),
e.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && (n.matricesIndices = e.getVerticesData(VertexBuffer.MatricesIndicesKind, t, r)),
e.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) && (n.matricesWeights = e.getVerticesData(VertexBuffer.MatricesWeightsKind, t, r)),
e.isVerticesDataPresent(VertexBuffer.MatricesIndicesExtraKind) && (n.matricesIndicesExtra = e.getVerticesData(VertexBuffer.MatricesIndicesExtraKind, t, r)),
e.isVerticesDataPresent(VertexBuffer.MatricesWeightsExtraKind) && (n.matricesWeightsExtra = e.getVerticesData(VertexBuffer.MatricesWeightsExtraKind, t, r)),
n.indices = e.getIndices(t, r),
n
}
,
i.CreateRibbon = function(e) {
throw _WarnImport("ribbonBuilder")
}
,
i.CreateBox = function(e) {
throw _WarnImport("boxBuilder")
}
,
i.CreateTiledBox = function(e) {
throw _WarnImport("tiledBoxBuilder")
}
,
i.CreateTiledPlane = function(e) {
throw _WarnImport("tiledPlaneBuilder")
}
,
i.CreateSphere = function(e) {
throw _WarnImport("sphereBuilder")
}
,
i.CreateCylinder = function(e) {
throw _WarnImport("cylinderBuilder")
}
,
i.CreateTorus = function(e) {
throw _WarnImport("torusBuilder")
}
,
i.CreateLineSystem = function(e) {
throw _WarnImport("linesBuilder")
}
,
i.CreateDashedLines = function(e) {
throw _WarnImport("linesBuilder")
}
,
i.CreateGround = function(e) {
throw _WarnImport("groundBuilder")
}
,
i.CreateTiledGround = function(e) {
throw _WarnImport("groundBuilder")
}
,
i.CreateGroundFromHeightMap = function(e) {
throw _WarnImport("groundBuilder")
}
,
i.CreatePlane = function(e) {
throw _WarnImport("planeBuilder")
}
,
i.CreateDisc = function(e) {
throw _WarnImport("discBuilder")
}
,
i.CreatePolygon = function(e, t, r, n, o, a, s) {
throw _WarnImport("polygonBuilder")
}
,
i.CreateIcoSphere = function(e) {
throw _WarnImport("icoSphereBuilder")
}
,
i.CreatePolyhedron = function(e) {
throw _WarnImport("polyhedronBuilder")
}
,
i.CreateCapsule = function(e) {
throw e === void 0 && (e = {
orientation: Vector3.Up(),
subdivisions: 2,
tessellation: 16,
height: 1,
radius: .25,
capSubdivisions: 6
}),
_WarnImport("capsuleBuilder")
}
,
i.CreateTorusKnot = function(e) {
throw _WarnImport("torusKnotBuilder")
}
,
i.ComputeNormals = function(e, t, r, n) {
var o = 0
, a = 0
, s = 0
, l = 0
, u = 0
, c = 0
, h = 0
, f = 0
, d = 0
, _ = 0
, g = 0
, m = 0
, v = 0
, y = 0
, b = 0
, T = 0
, C = 0
, A = 0
, S = 0
, P = 0
, R = !1
, M = !1
, x = !1
, I = !1
, w = 1
, O = 0
, D = null;
if (n && (R = !!n.facetNormals,
M = !!n.facetPositions,
x = !!n.facetPartitioning,
w = n.useRightHandedSystem === !0 ? -1 : 1,
O = n.ratio || 0,
I = !!n.depthSort,
D = n.distanceTo,
I)) {
D === void 0 && (D = Vector3.Zero());
var F = n.depthSortedFacets
}
var V = 0
, N = 0
, L = 0
, k = 0;
if (x && n && n.bbSize) {
var U = 0
, z = 0
, H = 0
, G = 0
, W = 0
, j = 0
, B = 0
, X = 0
, $ = 0
, Y = 0
, K = 0
, Z = 0
, q = 0
, J = 0
, Q = 0
, te = 0
, re = n.bbSize.x > n.bbSize.y ? n.bbSize.x : n.bbSize.y;
re = re > n.bbSize.z ? re : n.bbSize.z,
V = n.subDiv.X * O / n.bbSize.x,
N = n.subDiv.Y * O / n.bbSize.y,
L = n.subDiv.Z * O / n.bbSize.z,
k = n.subDiv.max * n.subDiv.max,
n.facetPartitioning.length = 0
}
for (o = 0; o < e.length; o++)
r[o] = 0;
var ie = t.length / 3 | 0;
for (o = 0; o < ie; o++) {
if (m = t[o * 3] * 3,
v = m + 1,
y = m + 2,
b = t[o * 3 + 1] * 3,
T = b + 1,
C = b + 2,
A = t[o * 3 + 2] * 3,
S = A + 1,
P = A + 2,
a = e[m] - e[b],
s = e[v] - e[T],
l = e[y] - e[C],
u = e[A] - e[b],
c = e[S] - e[T],
h = e[P] - e[C],
f = w * (s * h - l * c),
d = w * (l * u - a * h),
_ = w * (a * c - s * u),
g = Math.sqrt(f * f + d * d + _ * _),
g = g === 0 ? 1 : g,
f /= g,
d /= g,
_ /= g,
R && n && (n.facetNormals[o].x = f,
n.facetNormals[o].y = d,
n.facetNormals[o].z = _),
M && n && (n.facetPositions[o].x = (e[m] + e[b] + e[A]) / 3,
n.facetPositions[o].y = (e[v] + e[T] + e[S]) / 3,
n.facetPositions[o].z = (e[y] + e[C] + e[P]) / 3),
x && n && (U = Math.floor((n.facetPositions[o].x - n.bInfo.minimum.x * O) * V),
z = Math.floor((n.facetPositions[o].y - n.bInfo.minimum.y * O) * N),
H = Math.floor((n.facetPositions[o].z - n.bInfo.minimum.z * O) * L),
G = Math.floor((e[m] - n.bInfo.minimum.x * O) * V),
W = Math.floor((e[v] - n.bInfo.minimum.y * O) * N),
j = Math.floor((e[y] - n.bInfo.minimum.z * O) * L),
B = Math.floor((e[b] - n.bInfo.minimum.x * O) * V),
X = Math.floor((e[T] - n.bInfo.minimum.y * O) * N),
$ = Math.floor((e[C] - n.bInfo.minimum.z * O) * L),
Y = Math.floor((e[A] - n.bInfo.minimum.x * O) * V),
K = Math.floor((e[S] - n.bInfo.minimum.y * O) * N),
Z = Math.floor((e[P] - n.bInfo.minimum.z * O) * L),
J = G + n.subDiv.max * W + k * j,
Q = B + n.subDiv.max * X + k * $,
te = Y + n.subDiv.max * K + k * Z,
q = U + n.subDiv.max * z + k * H,
n.facetPartitioning[q] = n.facetPartitioning[q] ? n.facetPartitioning[q] : new Array,
n.facetPartitioning[J] = n.facetPartitioning[J] ? n.facetPartitioning[J] : new Array,
n.facetPartitioning[Q] = n.facetPartitioning[Q] ? n.facetPartitioning[Q] : new Array,
n.facetPartitioning[te] = n.facetPartitioning[te] ? n.facetPartitioning[te] : new Array,
n.facetPartitioning[J].push(o),
Q != J && n.facetPartitioning[Q].push(o),
te == Q || te == J || n.facetPartitioning[te].push(o),
q == J || q == Q || q == te || n.facetPartitioning[q].push(o)),
I && n && n.facetPositions) {
var ee = F[o];
ee.ind = o * 3,
ee.sqDistance = Vector3.DistanceSquared(n.facetPositions[o], D)
}
r[m] += f,
r[v] += d,
r[y] += _,
r[b] += f,
r[T] += d,
r[C] += _,
r[A] += f,
r[S] += d,
r[P] += _
}
for (o = 0; o < r.length / 3; o++)
f = r[o * 3],
d = r[o * 3 + 1],
_ = r[o * 3 + 2],
g = Math.sqrt(f * f + d * d + _ * _),
g = g === 0 ? 1 : g,
f /= g,
d /= g,
_ /= g,
r[o * 3] = f,
r[o * 3 + 1] = d,
r[o * 3 + 2] = _
}
,
i._ComputeSides = function(e, t, r, n, o, a, s) {
var l = r.length, u = n.length, c, h;
switch (e = e || i.DEFAULTSIDE,
e) {
case i.FRONTSIDE:
break;
case i.BACKSIDE:
var f;
for (c = 0; c < l; c += 3)
f = r[c],
r[c] = r[c + 2],
r[c + 2] = f;
for (h = 0; h < u; h++)
n[h] = -n[h];
break;
case i.DOUBLESIDE:
for (var d = t.length, _ = d / 3, g = 0; g < d; g++)
t[d + g] = t[g];
for (c = 0; c < l; c += 3)
r[c + l] = r[c + 2] + _,
r[c + 1 + l] = r[c + 1] + _,
r[c + 2 + l] = r[c] + _;
for (h = 0; h < u; h++)
n[u + h] = -n[h];
var m = o.length
, v = 0;
for (v = 0; v < m; v++)
o[v + m] = o[v];
for (a = a || new Vector4(0,0,1,1),
s = s || new Vector4(0,0,1,1),
v = 0,
c = 0; c < m / 2; c++)
o[v] = a.x + (a.z - a.x) * o[v],
o[v + 1] = a.y + (a.w - a.y) * o[v + 1],
o[v + m] = s.x + (s.z - s.x) * o[v + m],
o[v + m + 1] = s.y + (s.w - s.y) * o[v + m + 1],
v += 2;
break
}
}
,
i.ImportVertexData = function(e, t) {
var r = new i
, n = e.positions;
n && r.set(n, VertexBuffer.PositionKind);
var o = e.normals;
o && r.set(o, VertexBuffer.NormalKind);
var a = e.tangents;
a && r.set(a, VertexBuffer.TangentKind);
var s = e.uvs;
s && r.set(s, VertexBuffer.UVKind);
var l = e.uv2s;
l && r.set(l, VertexBuffer.UV2Kind);
var u = e.uv3s;
u && r.set(u, VertexBuffer.UV3Kind);
var c = e.uv4s;
c && r.set(c, VertexBuffer.UV4Kind);
var h = e.uv5s;
h && r.set(h, VertexBuffer.UV5Kind);
var f = e.uv6s;
f && r.set(f, VertexBuffer.UV6Kind);
var d = e.colors;
d && r.set(Color4.CheckColors4(d, n.length / 3), VertexBuffer.ColorKind);
var _ = e.matricesIndices;
_ && r.set(_, VertexBuffer.MatricesIndicesKind);
var g = e.matricesWeights;
g && r.set(g, VertexBuffer.MatricesWeightsKind);
var m = e.indices;
m && (r.indices = m),
t.setAllVerticesData(r, e.updatable)
}
,
i.FRONTSIDE = 0,
i.BACKSIDE = 1,
i.DOUBLESIDE = 2,
i.DEFAULTSIDE = 0,
__decorate([nativeOverride.filter(function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
var r = e[0];
return !Array.isArray(r)
})], i, "_TransformVector3Coordinates", null),
__decorate([nativeOverride.filter(function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
var r = e[0];
return !Array.isArray(r)
})], i, "_TransformVector3Normals", null),
__decorate([nativeOverride.filter(function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
var r = e[0];
return !Array.isArray(r)
})], i, "_TransformVector4Normals", null),
__decorate([nativeOverride.filter(function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
var r = e[0];
return !Array.isArray(r)
})], i, "_FlipFaces", null),
i
}()
, IntersectionInfo = function() {
function i(e, t, r) {
this.bu = e,
this.bv = t,
this.distance = r,
this.faceId = 0,
this.subMeshId = 0
}
return i
}()
, BoundingBox = function() {
function i(e, t, r) {
this.vectors = ArrayTools.BuildArray(8, Vector3.Zero),
this.center = Vector3.Zero(),
this.centerWorld = Vector3.Zero(),
this.extendSize = Vector3.Zero(),
this.extendSizeWorld = Vector3.Zero(),
this.directions = ArrayTools.BuildArray(3, Vector3.Zero),
this.vectorsWorld = ArrayTools.BuildArray(8, Vector3.Zero),
this.minimumWorld = Vector3.Zero(),
this.maximumWorld = Vector3.Zero(),
this.minimum = Vector3.Zero(),
this.maximum = Vector3.Zero(),
this._drawWrapperFront = null,
this._drawWrapperBack = null,
this.reConstruct(e, t, r)
}
return i.prototype.reConstruct = function(e, t, r) {
var n = e.x
, o = e.y
, a = e.z
, s = t.x
, l = t.y
, u = t.z
, c = this.vectors;
this.minimum.copyFromFloats(n, o, a),
this.maximum.copyFromFloats(s, l, u),
c[0].copyFromFloats(n, o, a),
c[1].copyFromFloats(s, l, u),
c[2].copyFromFloats(s, o, a),
c[3].copyFromFloats(n, l, a),
c[4].copyFromFloats(n, o, u),
c[5].copyFromFloats(s, l, a),
c[6].copyFromFloats(n, l, u),
c[7].copyFromFloats(s, o, u),
t.addToRef(e, this.center).scaleInPlace(.5),
t.subtractToRef(e, this.extendSize).scaleInPlace(.5),
this._worldMatrix = r || Matrix.IdentityReadOnly,
this._update(this._worldMatrix)
}
,
i.prototype.scale = function(e) {
var t = i.TmpVector3
, r = this.maximum.subtractToRef(this.minimum, t[0])
, n = r.length();
r.normalizeFromLength(n);
var o = n * e
, a = r.scaleInPlace(o * .5)
, s = this.center.subtractToRef(a, t[1])
, l = this.center.addToRef(a, t[2]);
return this.reConstruct(s, l, this._worldMatrix),
this
}
,
i.prototype.getWorldMatrix = function() {
return this._worldMatrix
}
,
i.prototype._update = function(e) {
var t = this.minimumWorld
, r = this.maximumWorld
, n = this.directions
, o = this.vectorsWorld
, a = this.vectors;
if (e.isIdentity()) {
t.copyFrom(this.minimum),
r.copyFrom(this.maximum);
for (var s = 0; s < 8; ++s)
o[s].copyFrom(a[s]);
this.extendSizeWorld.copyFrom(this.extendSize),
this.centerWorld.copyFrom(this.center)
} else {
t.setAll(Number.MAX_VALUE),
r.setAll(-Number.MAX_VALUE);
for (var s = 0; s < 8; ++s) {
var l = o[s];
Vector3.TransformCoordinatesToRef(a[s], e, l),
t.minimizeInPlace(l),
r.maximizeInPlace(l)
}
r.subtractToRef(t, this.extendSizeWorld).scaleInPlace(.5),
r.addToRef(t, this.centerWorld).scaleInPlace(.5)
}
Vector3.FromArrayToRef(e.m, 0, n[0]),
Vector3.FromArrayToRef(e.m, 4, n[1]),
Vector3.FromArrayToRef(e.m, 8, n[2]),
this._worldMatrix = e
}
,
i.prototype.isInFrustum = function(e) {
return i.IsInFrustum(this.vectorsWorld, e)
}
,
i.prototype.isCompletelyInFrustum = function(e) {
return i.IsCompletelyInFrustum(this.vectorsWorld, e)
}
,
i.prototype.intersectsPoint = function(e) {
var t = this.minimumWorld
, r = this.maximumWorld
, n = t.x
, o = t.y
, a = t.z
, s = r.x
, l = r.y
, u = r.z
, c = e.x
, h = e.y
, f = e.z
, d = -Epsilon;
return !(s - c < d || d > c - n || l - h < d || d > h - o || u - f < d || d > f - a)
}
,
i.prototype.intersectsSphere = function(e) {
return i.IntersectsSphere(this.minimumWorld, this.maximumWorld, e.centerWorld, e.radiusWorld)
}
,
i.prototype.intersectsMinMax = function(e, t) {
var r = this.minimumWorld
, n = this.maximumWorld
, o = r.x
, a = r.y
, s = r.z
, l = n.x
, u = n.y
, c = n.z
, h = e.x
, f = e.y
, d = e.z
, _ = t.x
, g = t.y
, m = t.z;
return !(l < h || o > _ || u < f || a > g || c < d || s > m)
}
,
i.prototype.dispose = function() {
var e, t;
(e = this._drawWrapperFront) === null || e === void 0 || e.dispose(),
(t = this._drawWrapperBack) === null || t === void 0 || t.dispose()
}
,
i.Intersects = function(e, t) {
return e.intersectsMinMax(t.minimumWorld, t.maximumWorld)
}
,
i.IntersectsSphere = function(e, t, r, n) {
var o = i.TmpVector3[0];
Vector3.ClampToRef(r, e, t, o);
var a = Vector3.DistanceSquared(r, o);
return a <= n * n
}
,
i.IsCompletelyInFrustum = function(e, t) {
for (var r = 0; r < 6; ++r)
for (var n = t[r], o = 0; o < 8; ++o)
if (n.dotCoordinate(e[o]) < 0)
return !1;
return !0
}
,
i.IsInFrustum = function(e, t) {
for (var r = 0; r < 6; ++r) {
for (var n = !0, o = t[r], a = 0; a < 8; ++a)
if (o.dotCoordinate(e[a]) >= 0) {
n = !1;
break
}
if (n)
return !1
}
return !0
}
,
i.TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero),
i
}()
, BoundingSphere = function() {
function i(e, t, r) {
this.center = Vector3.Zero(),
this.centerWorld = Vector3.Zero(),
this.minimum = Vector3.Zero(),
this.maximum = Vector3.Zero(),
this.reConstruct(e, t, r)
}
return i.prototype.reConstruct = function(e, t, r) {
this.minimum.copyFrom(e),
this.maximum.copyFrom(t);
var n = Vector3.Distance(e, t);
t.addToRef(e, this.center).scaleInPlace(.5),
this.radius = n * .5,
this._update(r || Matrix.IdentityReadOnly)
}
,
i.prototype.scale = function(e) {
var t = this.radius * e
, r = i.TmpVector3
, n = r[0].setAll(t)
, o = this.center.subtractToRef(n, r[1])
, a = this.center.addToRef(n, r[2]);
return this.reConstruct(o, a, this._worldMatrix),
this
}
,
i.prototype.getWorldMatrix = function() {
return this._worldMatrix
}
,
i.prototype._update = function(e) {
if (e.isIdentity())
this.centerWorld.copyFrom(this.center),
this.radiusWorld = this.radius;
else {
Vector3.TransformCoordinatesToRef(this.center, e, this.centerWorld);
var t = i.TmpVector3[0];
Vector3.TransformNormalFromFloatsToRef(1, 1, 1, e, t),
this.radiusWorld = Math.max(Math.abs(t.x), Math.abs(t.y), Math.abs(t.z)) * this.radius
}
}
,
i.prototype.isInFrustum = function(e) {
for (var t = this.centerWorld, r = this.radiusWorld, n = 0; n < 6; n++)
if (e[n].dotCoordinate(t) <= -r)
return !1;
return !0
}
,
i.prototype.isCenterInFrustum = function(e) {
for (var t = this.centerWorld, r = 0; r < 6; r++)
if (e[r].dotCoordinate(t) < 0)
return !1;
return !0
}
,
i.prototype.intersectsPoint = function(e) {
var t = Vector3.DistanceSquared(this.centerWorld, e);
return !(this.radiusWorld * this.radiusWorld < t)
}
,
i.Intersects = function(e, t) {
var r = Vector3.DistanceSquared(e.centerWorld, t.centerWorld)
, n = e.radiusWorld + t.radiusWorld;
return !(n * n < r)
}
,
i.CreateFromCenterAndRadius = function(e, t, r) {
this.TmpVector3[0].copyFrom(e),
this.TmpVector3[1].copyFromFloats(0, 0, t),
this.TmpVector3[2].copyFrom(e),
this.TmpVector3[0].addInPlace(this.TmpVector3[1]),
this.TmpVector3[2].subtractInPlace(this.TmpVector3[1]);
var n = new i(this.TmpVector3[0],this.TmpVector3[2]);
return r ? n._worldMatrix = r : n._worldMatrix = Matrix.Identity(),
n
}
,
i.TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero),
i
}()
, _result0 = {
min: 0,
max: 0
}
, _result1 = {
min: 0,
max: 0
}
, computeBoxExtents = function(i, e, t) {
var r = Vector3.Dot(e.centerWorld, i)
, n = Math.abs(Vector3.Dot(e.directions[0], i)) * e.extendSize.x
, o = Math.abs(Vector3.Dot(e.directions[1], i)) * e.extendSize.y
, a = Math.abs(Vector3.Dot(e.directions[2], i)) * e.extendSize.z
, s = n + o + a;
t.min = r - s,
t.max = r + s
}
, axisOverlap = function(i, e, t) {
return computeBoxExtents(i, e, _result0),
computeBoxExtents(i, t, _result1),
!(_result0.min > _result1.max || _result1.min > _result0.max)
}
, BoundingInfo = function() {
function i(e, t, r) {
this._isLocked = !1,
this.boundingBox = new BoundingBox(e,t,r),
this.boundingSphere = new BoundingSphere(e,t,r)
}
return i.prototype.reConstruct = function(e, t, r) {
this.boundingBox.reConstruct(e, t, r),
this.boundingSphere.reConstruct(e, t, r)
}
,
Object.defineProperty(i.prototype, "minimum", {
get: function() {
return this.boundingBox.minimum
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "maximum", {
get: function() {
return this.boundingBox.maximum
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isLocked", {
get: function() {
return this._isLocked
},
set: function(e) {
this._isLocked = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.update = function(e) {
this._isLocked || (this.boundingBox._update(e),
this.boundingSphere._update(e))
}
,
i.prototype.centerOn = function(e, t) {
var r = i.TmpVector3[0].copyFrom(e).subtractInPlace(t)
, n = i.TmpVector3[1].copyFrom(e).addInPlace(t);
return this.boundingBox.reConstruct(r, n, this.boundingBox.getWorldMatrix()),
this.boundingSphere.reConstruct(r, n, this.boundingBox.getWorldMatrix()),
this
}
,
i.prototype.encapsulate = function(e) {
var t = Vector3.Minimize(this.minimum, e)
, r = Vector3.Maximize(this.maximum, e);
return this.reConstruct(t, r, this.boundingBox.getWorldMatrix()),
this
}
,
i.prototype.encapsulateBoundingInfo = function(e) {
return this.encapsulate(e.boundingBox.centerWorld.subtract(e.boundingBox.extendSizeWorld)),
this.encapsulate(e.boundingBox.centerWorld.add(e.boundingBox.extendSizeWorld)),
this
}
,
i.prototype.scale = function(e) {
return this.boundingBox.scale(e),
this.boundingSphere.scale(e),
this
}
,
i.prototype.isInFrustum = function(e, t) {
t === void 0 && (t = 0);
var r = t === 2 || t === 3;
if (r && this.boundingSphere.isCenterInFrustum(e))
return !0;
if (!this.boundingSphere.isInFrustum(e))
return !1;
var n = t === 1 || t === 3;
return n ? !0 : this.boundingBox.isInFrustum(e)
}
,
Object.defineProperty(i.prototype, "diagonalLength", {
get: function() {
var e = this.boundingBox
, t = e.maximumWorld.subtractToRef(e.minimumWorld, i.TmpVector3[0]);
return t.length()
},
enumerable: !1,
configurable: !0
}),
i.prototype.isCompletelyInFrustum = function(e) {
return this.boundingBox.isCompletelyInFrustum(e)
}
,
i.prototype._checkCollision = function(e) {
return e._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld)
}
,
i.prototype.intersectsPoint = function(e) {
return !(!this.boundingSphere.centerWorld || !this.boundingSphere.intersectsPoint(e) || !this.boundingBox.intersectsPoint(e))
}
,
i.prototype.intersects = function(e, t) {
if (!BoundingSphere.Intersects(this.boundingSphere, e.boundingSphere) || !BoundingBox.Intersects(this.boundingBox, e.boundingBox))
return !1;
if (!t)
return !0;
var r = this.boundingBox
, n = e.boundingBox;
return !(!axisOverlap(r.directions[0], r, n) || !axisOverlap(r.directions[1], r, n) || !axisOverlap(r.directions[2], r, n) || !axisOverlap(n.directions[0], r, n) || !axisOverlap(n.directions[1], r, n) || !axisOverlap(n.directions[2], r, n) || !axisOverlap(Vector3.Cross(r.directions[0], n.directions[0]), r, n) || !axisOverlap(Vector3.Cross(r.directions[0], n.directions[1]), r, n) || !axisOverlap(Vector3.Cross(r.directions[0], n.directions[2]), r, n) || !axisOverlap(Vector3.Cross(r.directions[1], n.directions[0]), r, n) || !axisOverlap(Vector3.Cross(r.directions[1], n.directions[1]), r, n) || !axisOverlap(Vector3.Cross(r.directions[1], n.directions[2]), r, n) || !axisOverlap(Vector3.Cross(r.directions[2], n.directions[0]), r, n) || !axisOverlap(Vector3.Cross(r.directions[2], n.directions[1]), r, n) || !axisOverlap(Vector3.Cross(r.directions[2], n.directions[2]), r, n))
}
,
i.TmpVector3 = ArrayTools.BuildArray(2, Vector3.Zero),
i
}()
, MathHelpers = function() {
function i() {}
return i.extractMinAndMaxIndexed = function(e, t, r, n, o, a) {
for (var s = r; s < r + n; s++) {
var l = t[s] * 3
, u = e[l]
, c = e[l + 1]
, h = e[l + 2];
o.minimizeInPlaceFromFloats(u, c, h),
a.maximizeInPlaceFromFloats(u, c, h)
}
}
,
i.extractMinAndMax = function(e, t, r, n, o, a) {
for (var s = t, l = t * n; s < t + r; s++,
l += n) {
var u = e[l]
, c = e[l + 1]
, h = e[l + 2];
o.minimizeInPlaceFromFloats(u, c, h),
a.maximizeInPlaceFromFloats(u, c, h)
}
}
,
__decorate([nativeOverride.filter(function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
var r = e[0]
, n = e[1];
return !Array.isArray(r) && !Array.isArray(n)
})], i, "extractMinAndMaxIndexed", null),
__decorate([nativeOverride.filter(function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
var r = e[0];
return !Array.isArray(r)
})], i, "extractMinAndMax", null),
i
}();
function extractMinAndMaxIndexed(i, e, t, r, n) {
n === void 0 && (n = null);
var o = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
, a = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
return MathHelpers.extractMinAndMaxIndexed(i, e, t, r, o, a),
n && (o.x -= o.x * n.x + n.y,
o.y -= o.y * n.x + n.y,
o.z -= o.z * n.x + n.y,
a.x += a.x * n.x + n.y,
a.y += a.y * n.x + n.y,
a.z += a.z * n.x + n.y),
{
minimum: o,
maximum: a
}
}
function extractMinAndMax(i, e, t, r, n) {
r === void 0 && (r = null);
var o = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
, a = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
return n || (n = 3),
MathHelpers.extractMinAndMax(i, e, t, n, o, a),
r && (o.x -= o.x * r.x + r.y,
o.y -= o.y * r.x + r.y,
o.z -= o.z * r.x + r.y,
a.x += a.x * r.x + r.y,
a.y += a.y * r.x + r.y,
a.z += a.z * r.x + r.y),
{
minimum: o,
maximum: a
}
}
var SubMesh = function() {
function i(e, t, r, n, o, a, s, l, u) {
l === void 0 && (l = !0),
u === void 0 && (u = !0),
this.materialIndex = e,
this.verticesStart = t,
this.verticesCount = r,
this.indexStart = n,
this.indexCount = o,
this._mainDrawWrapperOverride = 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 = a,
this._renderingMesh = s || a,
u && a.subMeshes.push(this),
this._engine = this._mesh.getScene().getEngine(),
this.resetDrawCache(),
this._trianglePlanes = [],
this._id = a.subMeshes.length - 1,
l && (this.refreshBoundingInfo(),
a.computeWorldMatrix(!0))
}
return Object.defineProperty(i.prototype, "materialDefines", {
get: function() {
var e;
return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.defines : (e = this._getDrawWrapper()) === null || e === void 0 ? void 0 : e.defines
},
set: function(e) {
var t, r = (t = this._mainDrawWrapperOverride) !== null && t !== void 0 ? t : this._getDrawWrapper(void 0, !0);
r.defines = e
},
enumerable: !1,
configurable: !0
}),
i.prototype._getDrawWrapper = function(e, t) {
t === void 0 && (t = !1),
e = e != null ? e : this._engine.currentRenderPassId;
var r = this._drawWrappers[e];
return !r && t && (this._drawWrappers[e] = r = new DrawWrapper(this._mesh.getScene().getEngine())),
r
}
,
i.prototype._removeDrawWrapper = function(e, t) {
var r;
t === void 0 && (t = !0),
t && ((r = this._drawWrappers[e]) === null || r === void 0 || r.dispose()),
this._drawWrappers[e] = void 0
}
,
Object.defineProperty(i.prototype, "effect", {
get: function() {
var e, t;
return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : (t = (e = this._getDrawWrapper()) === null || e === void 0 ? void 0 : e.effect) !== null && t !== void 0 ? t : null
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "_drawWrapper", {
get: function() {
var e;
return (e = this._mainDrawWrapperOverride) !== null && e !== void 0 ? e : this._getDrawWrapper(void 0, !0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "_drawWrapperOverride", {
get: function() {
return this._mainDrawWrapperOverride
},
enumerable: !1,
configurable: !0
}),
i.prototype._setMainDrawWrapperOverride = function(e) {
this._mainDrawWrapperOverride = e
}
,
i.prototype.setEffect = function(e, t, r, n) {
t === void 0 && (t = null),
n === void 0 && (n = !0);
var o = this._drawWrapper;
o.setEffect(e, t, n),
r !== void 0 && (o.materialContext = r),
e || (o.defines = null,
o.materialContext = void 0)
}
,
i.prototype.resetDrawCache = function() {
if (this._drawWrappers)
for (var e = 0, t = this._drawWrappers; e < t.length; e++) {
var r = t[e];
r == null || r.dispose()
}
this._drawWrappers = []
}
,
i.AddToMesh = function(e, t, r, n, o, a, s, l) {
return l === void 0 && (l = !0),
new i(e,t,r,n,o,a,s,l)
}
,
Object.defineProperty(i.prototype, "IsGlobal", {
get: function() {
return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices()
},
enumerable: !1,
configurable: !0
}),
i.prototype.getBoundingInfo = function() {
return this.IsGlobal ? this._mesh.getBoundingInfo() : this._boundingInfo
}
,
i.prototype.setBoundingInfo = function(e) {
return this._boundingInfo = e,
this
}
,
i.prototype.getMesh = function() {
return this._mesh
}
,
i.prototype.getRenderingMesh = function() {
return this._renderingMesh
}
,
i.prototype.getReplacementMesh = function() {
return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null
}
,
i.prototype.getEffectiveMesh = function() {
var e = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;
return e || this._renderingMesh
}
,
i.prototype.getMaterial = function() {
var e, t = (e = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)) !== null && e !== void 0 ? e : this._renderingMesh.material;
if (t == null)
return this._mesh.getScene().defaultMaterial;
if (this._IsMultiMaterial(t)) {
var r = t.getSubMaterial(this.materialIndex);
return this._currentMaterial !== r && (this._currentMaterial = r,
this.resetDrawCache()),
r
}
return t
}
,
i.prototype._IsMultiMaterial = function(e) {
return e.getSubMaterial !== void 0
}
,
i.prototype.refreshBoundingInfo = function(e) {
if (e === void 0 && (e = null),
this._lastColliderWorldVertices = null,
this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry)
return this;
if (e || (e = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind)),
!e)
return this._boundingInfo = this._mesh.getBoundingInfo(),
this;
var t = this._renderingMesh.getIndices(), r;
if (this.indexStart === 0 && this.indexCount === t.length) {
var n = this._renderingMesh.getBoundingInfo();
r = {
minimum: n.minimum.clone(),
maximum: n.maximum.clone()
}
} else
r = extractMinAndMaxIndexed(e, t, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
return this._boundingInfo ? this._boundingInfo.reConstruct(r.minimum, r.maximum) : this._boundingInfo = new BoundingInfo(r.minimum,r.maximum),
this
}
,
i.prototype._checkCollision = function(e) {
var t = this.getBoundingInfo();
return t._checkCollision(e)
}
,
i.prototype.updateBoundingInfo = function(e) {
var t = this.getBoundingInfo();
return t || (this.refreshBoundingInfo(),
t = this.getBoundingInfo()),
t && t.update(e),
this
}
,
i.prototype.isInFrustum = function(e) {
var t = this.getBoundingInfo();
return t ? t.isInFrustum(e, this._mesh.cullingStrategy) : !1
}
,
i.prototype.isCompletelyInFrustum = function(e) {
var t = this.getBoundingInfo();
return t ? t.isCompletelyInFrustum(e) : !1
}
,
i.prototype.render = function(e) {
return this._renderingMesh.render(this, e, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : void 0),
this
}
,
i.prototype._getLinesIndexBuffer = function(e, t) {
if (!this._linesIndexBuffer) {
for (var r = [], n = this.indexStart; n < this.indexStart + this.indexCount; n += 3)
r.push(e[n], e[n + 1], e[n + 1], e[n + 2], e[n + 2], e[n]);
this._linesIndexBuffer = t.createIndexBuffer(r),
this._linesIndexCount = r.length
}
return this._linesIndexBuffer
}
,
i.prototype.canIntersects = function(e) {
var t = this.getBoundingInfo();
return t ? e.intersectsBox(t.boundingBox) : !1
}
,
i.prototype.intersects = function(e, t, r, n, o) {
var a = this.getMaterial();
if (!a)
return null;
var s = 3
, l = !1;
switch (a.fillMode) {
case 3:
case 4:
case 5:
case 6:
case 8:
return null;
case 7:
s = 1,
l = !0;
break
}
return this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh" ? r.length ? this._intersectLines(e, t, r, this._mesh.intersectionThreshold, n) : this._intersectUnIndexedLines(e, t, r, this._mesh.intersectionThreshold, n) : !r.length && this._mesh._unIndexed ? this._intersectUnIndexedTriangles(e, t, r, n, o) : this._intersectTriangles(e, t, r, s, l, n, o)
}
,
i.prototype._intersectLines = function(e, t, r, n, o) {
for (var a = null, s = this.indexStart; s < this.indexStart + this.indexCount; s += 2) {
var l = t[r[s]]
, u = t[r[s + 1]]
, c = e.intersectionSegment(l, u, n);
if (!(c < 0) && (o || !a || c < a.distance) && (a = new IntersectionInfo(null,null,c),
a.faceId = s / 2,
o))
break
}
return a
}
,
i.prototype._intersectUnIndexedLines = function(e, t, r, n, o) {
for (var a = null, s = this.verticesStart; s < this.verticesStart + this.verticesCount; s += 2) {
var l = t[s]
, u = t[s + 1]
, c = e.intersectionSegment(l, u, n);
if (!(c < 0) && (o || !a || c < a.distance) && (a = new IntersectionInfo(null,null,c),
a.faceId = s / 2,
o))
break
}
return a
}
,
i.prototype._intersectTriangles = function(e, t, r, n, o, a, s) {
for (var l = null, u = -1, c = this.indexStart; c < this.indexStart + this.indexCount - (3 - n); c += n) {
u++;
var h = r[c]
, f = r[c + 1]
, d = r[c + 2];
if (o && d === 4294967295) {
c += 2;
continue
}
var _ = t[h]
, g = t[f]
, m = t[d];
if (!(!_ || !g || !m) && !(s && !s(_, g, m, e))) {
var v = e.intersectsTriangle(_, g, m);
if (v) {
if (v.distance < 0)
continue;
if ((a || !l || v.distance < l.distance) && (l = v,
l.faceId = u,
a))
break
}
}
}
return l
}
,
i.prototype._intersectUnIndexedTriangles = function(e, t, r, n, o) {
for (var a = null, s = this.verticesStart; s < this.verticesStart + this.verticesCount; s += 3) {
var l = t[s]
, u = t[s + 1]
, c = t[s + 2];
if (!(o && !o(l, u, c, e))) {
var h = e.intersectsTriangle(l, u, c);
if (h) {
if (h.distance < 0)
continue;
if ((n || !a || h.distance < a.distance) && (a = h,
a.faceId = s / 3,
n))
break
}
}
}
return a
}
,
i.prototype._rebuild = function() {
this._linesIndexBuffer && (this._linesIndexBuffer = null)
}
,
i.prototype.clone = function(e, t) {
var r = new i(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,e,t,!1);
if (!this.IsGlobal) {
var n = this.getBoundingInfo();
if (!n)
return r;
r._boundingInfo = new BoundingInfo(n.minimum,n.maximum)
}
return r
}
,
i.prototype.dispose = function() {
this._linesIndexBuffer && (this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),
this._linesIndexBuffer = null);
var e = this._mesh.subMeshes.indexOf(this);
this._mesh.subMeshes.splice(e, 1),
this.resetDrawCache()
}
,
i.prototype.getClassName = function() {
return "SubMesh"
}
,
i.CreateFromIndices = function(e, t, r, n, o, a) {
a === void 0 && (a = !0);
for (var s = Number.MAX_VALUE, l = -Number.MAX_VALUE, u = o || n, c = u.getIndices(), h = t; h < t + r; h++) {
var f = c[h];
f < s && (s = f),
f > l && (l = f)
}
return new i(e,s,l - s + 1,t,r,n,o,a)
}
,
i
}()
, Geometry = function() {
function i(e, t, r, n, o) {
n === void 0 && (n = !1),
o === void 0 && (o = null),
this.delayLoadState = 0,
this._totalVertices = 0,
this._isDisposed = !1,
this._indexBufferIsUpdatable = !1,
this._positionsCache = [],
this._parentContainer = null,
this.useBoundingInfoFromGeometry = !1,
this.id = e,
this.uniqueId = t.getUniqueId(),
this._engine = t.getEngine(),
this._meshes = [],
this._scene = t,
this._vertexBuffers = {},
this._indices = [],
this._updatable = n,
r ? this.setAllVerticesData(r, n) : (this._totalVertices = 0,
this._indices = []),
this._engine.getCaps().vertexArrayObject && (this._vertexArrayObjects = {}),
o && (this.applyToMesh(o),
o.computeWorldMatrix(!0))
}
return Object.defineProperty(i.prototype, "boundingBias", {
get: function() {
return this._boundingBias
},
set: function(e) {
this._boundingBias ? this._boundingBias.copyFrom(e) : this._boundingBias = e.clone(),
this._updateBoundingInfo(!0, null)
},
enumerable: !1,
configurable: !0
}),
i.CreateGeometryForMesh = function(e) {
var t = new i(i.RandomId(),e.getScene());
return t.applyToMesh(e),
t
}
,
Object.defineProperty(i.prototype, "meshes", {
get: function() {
return this._meshes
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "extend", {
get: function() {
return this._extend
},
enumerable: !1,
configurable: !0
}),
i.prototype.getScene = function() {
return this._scene
}
,
i.prototype.getEngine = function() {
return this._engine
}
,
i.prototype.isReady = function() {
return this.delayLoadState === 1 || this.delayLoadState === 0
}
,
Object.defineProperty(i.prototype, "doNotSerialize", {
get: function() {
for (var e = 0; e < this._meshes.length; e++)
if (!this._meshes[e].doNotSerialize)
return !1;
return !0
},
enumerable: !1,
configurable: !0
}),
i.prototype._rebuild = function() {
this._vertexArrayObjects && (this._vertexArrayObjects = {}),
this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable));
for (var e in this._vertexBuffers) {
var t = this._vertexBuffers[e];
t._rebuild()
}
}
,
i.prototype.setAllVerticesData = function(e, t) {
e.applyToGeometry(this, t),
this.notifyUpdate()
}
,
i.prototype.setVerticesData = function(e, t, r, n) {
r === void 0 && (r = !1),
r && Array.isArray(t) && (t = new Float32Array(t));
var o = new VertexBuffer(this._engine,t,e,r,this._meshes.length === 0,n);
this.setVerticesBuffer(o)
}
,
i.prototype.removeVerticesData = function(e) {
this._vertexBuffers[e] && (this._vertexBuffers[e].dispose(),
delete this._vertexBuffers[e]),
this._vertexArrayObjects && this._disposeVertexArrayObjects()
}
,
i.prototype.setVerticesBuffer = function(e, t, r) {
t === void 0 && (t = null),
r === void 0 && (r = !0);
var n = e.getKind();
this._vertexBuffers[n] && r && this._vertexBuffers[n].dispose(),
e._buffer && e._buffer._increaseReferences(),
this._vertexBuffers[n] = e;
var o = this._meshes
, a = o.length;
if (n === VertexBuffer.PositionKind) {
var s = e.getData();
t != null ? this._totalVertices = t : s != null && (this._totalVertices = s.length / (e.type === VertexBuffer.BYTE ? e.byteStride : e.byteStride / 4)),
this._updateExtend(s),
this._resetPointsArrayCache();
for (var l = 0; l < a; l++) {
var u = o[l];
u.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
u._createGlobalSubMesh(!1),
u.computeWorldMatrix(!0),
u.synchronizeInstances()
}
}
this.notifyUpdate(n)
}
,
i.prototype.updateVerticesDataDirectly = function(e, t, r, n) {
n === void 0 && (n = !1);
var o = this.getVertexBuffer(e);
!o || (o.updateDirectly(t, r, n),
this.notifyUpdate(e))
}
,
i.prototype.updateVerticesData = function(e, t, r) {
r === void 0 && (r = !1);
var n = this.getVertexBuffer(e);
!n || (n.update(t),
e === VertexBuffer.PositionKind && this._updateBoundingInfo(r, t),
this.notifyUpdate(e))
}
,
i.prototype._updateBoundingInfo = function(e, t) {
if (e && this._updateExtend(t),
this._resetPointsArrayCache(),
e)
for (var r = this._meshes, n = 0, o = r; n < o.length; n++) {
var a = o[n];
a.hasBoundingInfo ? a.getBoundingInfo().reConstruct(this._extend.minimum, this._extend.maximum) : a.buildBoundingInfo(this._extend.minimum, this._extend.maximum);
for (var s = a.subMeshes, l = 0, u = s; l < u.length; l++) {
var c = u[l];
c.refreshBoundingInfo()
}
}
}
,
i.prototype._bind = function(e, t, r, n) {
if (!!e) {
t === void 0 && (t = this._indexBuffer);
var o = this.getVertexBuffers();
if (!!o) {
if (t != this._indexBuffer || !this._vertexArrayObjects && !n) {
this._engine.bindBuffers(o, t, e, r);
return
}
var a = n || this._vertexArrayObjects;
a[e.key] || (a[e.key] = this._engine.recordVertexArrayObject(o, t, e, r)),
this._engine.bindVertexArrayObject(a[e.key], t)
}
}
}
,
i.prototype.getTotalVertices = function() {
return this.isReady() ? this._totalVertices : 0
}
,
i.prototype.getVerticesData = function(e, t, r) {
var n = this.getVertexBuffer(e);
return n ? n.getFloatData(this._totalVertices, r || t && this._meshes.length !== 1) : null
}
,
i.prototype.isVertexBufferUpdatable = function(e) {
var t = this._vertexBuffers[e];
return t ? t.isUpdatable() : !1
}
,
i.prototype.getVertexBuffer = function(e) {
return this.isReady() ? this._vertexBuffers[e] : null
}
,
i.prototype.getVertexBuffers = function() {
return this.isReady() ? this._vertexBuffers : null
}
,
i.prototype.isVerticesDataPresent = function(e) {
return this._vertexBuffers ? this._vertexBuffers[e] !== void 0 : this._delayInfo ? this._delayInfo.indexOf(e) !== -1 : !1
}
,
i.prototype.getVerticesDataKinds = function() {
var e = [], t;
if (!this._vertexBuffers && this._delayInfo)
for (t in this._delayInfo)
e.push(t);
else
for (t in this._vertexBuffers)
e.push(t);
return e
}
,
i.prototype.updateIndices = function(e, t, r) {
if (r === void 0 && (r = !1),
!!this._indexBuffer)
if (!this._indexBufferIsUpdatable)
this.setIndices(e, null, !0);
else {
var n = e.length !== this._indices.length;
if (r || (this._indices = e.slice()),
this._engine.updateDynamicIndexBuffer(this._indexBuffer, e, t),
n)
for (var o = 0, a = this._meshes; o < a.length; o++) {
var s = a[o];
s._createGlobalSubMesh(!0)
}
}
}
,
i.prototype.setIndices = function(e, t, r) {
t === void 0 && (t = null),
r === void 0 && (r = !1),
this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
this._indices = e,
this._indexBufferIsUpdatable = r,
this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, r)),
t != null && (this._totalVertices = t);
for (var n = 0, o = this._meshes; n < o.length; n++) {
var a = o[n];
a._createGlobalSubMesh(!0),
a.synchronizeInstances()
}
this.notifyUpdate()
}
,
i.prototype.getTotalIndices = function() {
return this.isReady() ? this._indices.length : 0
}
,
i.prototype.getIndices = function(e, t) {
if (!this.isReady())
return null;
var r = this._indices;
return !t && (!e || this._meshes.length === 1) ? r : Tools.Slice(r)
}
,
i.prototype.getIndexBuffer = function() {
return this.isReady() ? this._indexBuffer : null
}
,
i.prototype._releaseVertexArrayObject = function(e) {
e === void 0 && (e = null),
!(!e || !this._vertexArrayObjects) && this._vertexArrayObjects[e.key] && (this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),
delete this._vertexArrayObjects[e.key])
}
,
i.prototype.releaseForMesh = function(e, t) {
var r = this._meshes
, n = r.indexOf(e);
n !== -1 && (r.splice(n, 1),
this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject(),
e._geometry = null,
r.length === 0 && t && this.dispose())
}
,
i.prototype.applyToMesh = function(e) {
if (e._geometry !== this) {
var t = e._geometry;
t && t.releaseForMesh(e),
this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject();
var r = this._meshes;
e._geometry = this,
e._internalAbstractMeshDataInfo._positions = null,
this._scene.pushGeometry(this),
r.push(e),
this.isReady() ? this._applyToMesh(e) : this._boundingInfo && e.setBoundingInfo(this._boundingInfo)
}
}
,
i.prototype._updateExtend = function(e) {
e === void 0 && (e = null),
this.useBoundingInfoFromGeometry && this._boundingInfo ? this._extend = {
minimum: this._boundingInfo.minimum.clone(),
maximum: this._boundingInfo.maximum.clone()
} : (e || (e = this.getVerticesData(VertexBuffer.PositionKind)),
this._extend = extractMinAndMax(e, 0, this._totalVertices, this.boundingBias, 3))
}
,
i.prototype._applyToMesh = function(e) {
var t = this._meshes.length;
for (var r in this._vertexBuffers)
t === 1 && this._vertexBuffers[r].create(),
r === VertexBuffer.PositionKind && (this._extend || this._updateExtend(),
e.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
e._createGlobalSubMesh(!1),
e._updateBoundingInfo());
t === 1 && this._indices && this._indices.length > 0 && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)),
e._syncGeometryWithMorphTargetManager(),
e.synchronizeInstances()
}
,
i.prototype.notifyUpdate = function(e) {
this.onGeometryUpdated && this.onGeometryUpdated(this, e),
this._vertexArrayObjects && this._disposeVertexArrayObjects();
for (var t = 0, r = this._meshes; t < r.length; t++) {
var n = r[t];
n._markSubMeshesAsAttributesDirty()
}
}
,
i.prototype.load = function(e, t) {
if (this.delayLoadState !== 2) {
if (this.isReady()) {
t && t();
return
}
this.delayLoadState = 2,
this._queueLoad(e, t)
}
}
,
i.prototype._queueLoad = function(e, t) {
var r = this;
!this.delayLoadingFile || (e._addPendingData(this),
e._loadFile(this.delayLoadingFile, function(n) {
if (!!r._delayLoadingFunction) {
r._delayLoadingFunction(JSON.parse(n), r),
r.delayLoadState = 1,
r._delayInfo = [],
e._removePendingData(r);
for (var o = r._meshes, a = o.length, s = 0; s < a; s++)
r._applyToMesh(o[s]);
t && t()
}
}, void 0, !0))
}
,
i.prototype.toLeftHanded = function() {
var e = this.getIndices(!1);
if (e != null && e.length > 0) {
for (var t = 0; t < e.length; t += 3) {
var r = e[t + 0];
e[t + 0] = e[t + 2],
e[t + 2] = r
}
this.setIndices(e)
}
var n = this.getVerticesData(VertexBuffer.PositionKind, !1);
if (n != null && n.length > 0) {
for (var t = 0; t < n.length; t += 3)
n[t + 2] = -n[t + 2];
this.setVerticesData(VertexBuffer.PositionKind, n, !1)
}
var o = this.getVerticesData(VertexBuffer.NormalKind, !1);
if (o != null && o.length > 0) {
for (var t = 0; t < o.length; t += 3)
o[t + 2] = -o[t + 2];
this.setVerticesData(VertexBuffer.NormalKind, o, !1)
}
}
,
i.prototype._resetPointsArrayCache = function() {
this._positions = null
}
,
i.prototype._generatePointsArray = function() {
if (this._positions)
return !0;
var e = this.getVerticesData(VertexBuffer.PositionKind);
if (!e || e.length === 0)
return !1;
for (var t = this._positionsCache.length * 3, r = this._positionsCache.length; t < e.length; t += 3,
++r)
this._positionsCache[r] = Vector3.FromArray(e, t);
for (var t = 0, r = 0; t < e.length; t += 3,
++r)
this._positionsCache[r].set(e[0 + t], e[1 + t], e[2 + t]);
return this._positionsCache.length = e.length / 3,
this._positions = this._positionsCache,
!0
}
,
i.prototype.isDisposed = function() {
return this._isDisposed
}
,
i.prototype._disposeVertexArrayObjects = function() {
if (this._vertexArrayObjects) {
for (var e in this._vertexArrayObjects)
this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);
this._vertexArrayObjects = {};
for (var t = this._meshes, r = t.length, n = 0; n < r; n++)
t[n]._invalidateInstanceVertexArrayObject()
}
}
,
i.prototype.dispose = function() {
var e = this._meshes, t = e.length, r;
for (r = 0; r < t; r++)
this.releaseForMesh(e[r]);
this._meshes = [],
this._disposeVertexArrayObjects();
for (var n in this._vertexBuffers)
this._vertexBuffers[n].dispose();
if (this._vertexBuffers = {},
this._totalVertices = 0,
this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
this._indexBuffer = null,
this._indices = [],
this.delayLoadState = 0,
this.delayLoadingFile = null,
this._delayLoadingFunction = null,
this._delayInfo = [],
this._boundingInfo = null,
this._scene.removeGeometry(this),
this._parentContainer) {
var o = this._parentContainer.geometries.indexOf(this);
o > -1 && this._parentContainer.geometries.splice(o, 1),
this._parentContainer = null
}
this._isDisposed = !0
}
,
i.prototype.copy = function(e) {
var t = new VertexData;
t.indices = [];
var r = this.getIndices();
if (r)
for (var n = 0; n < r.length; n++)
t.indices.push(r[n]);
var o = !1, a = !1, s;
for (s in this._vertexBuffers) {
var l = this.getVerticesData(s);
if (l && (l instanceof Float32Array ? t.set(new Float32Array(l), s) : t.set(l.slice(0), s),
!a)) {
var u = this.getVertexBuffer(s);
u && (o = u.isUpdatable(),
a = !o)
}
}
var c = new i(e,this._scene,t,o);
c.delayLoadState = this.delayLoadState,
c.delayLoadingFile = this.delayLoadingFile,
c._delayLoadingFunction = this._delayLoadingFunction;
for (s in this._delayInfo)
c._delayInfo = c._delayInfo || [],
c._delayInfo.push(s);
return c._boundingInfo = new BoundingInfo(this._extend.minimum,this._extend.maximum),
c
}
,
i.prototype.serialize = function() {
var e = {};
return e.id = this.id,
e.uniqueId = this.uniqueId,
e.updatable = this._updatable,
Tags && Tags.HasTags(this) && (e.tags = Tags.GetTags(this)),
e
}
,
i.prototype.toNumberArray = function(e) {
return Array.isArray(e) ? e : Array.prototype.slice.call(e)
}
,
i.prototype.clearCachedData = function() {
this._indices = [],
this._resetPointsArrayCache();
for (var e in this._vertexBuffers)
!this._vertexBuffers.hasOwnProperty(e) || (this._vertexBuffers[e]._buffer._data = null)
}
,
i.prototype.serializeVerticeData = function() {
var e = this.serialize();
return this.isVerticesDataPresent(VertexBuffer.PositionKind) && (e.positions = this.toNumberArray(this.getVerticesData(VertexBuffer.PositionKind)),
this.isVertexBufferUpdatable(VertexBuffer.PositionKind) && (e.positions._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.NormalKind) && (e.normals = this.toNumberArray(this.getVerticesData(VertexBuffer.NormalKind)),
this.isVertexBufferUpdatable(VertexBuffer.NormalKind) && (e.normals._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.TangentKind) && (e.tangents = this.toNumberArray(this.getVerticesData(VertexBuffer.TangentKind)),
this.isVertexBufferUpdatable(VertexBuffer.TangentKind) && (e.tangents._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.UVKind) && (e.uvs = this.toNumberArray(this.getVerticesData(VertexBuffer.UVKind)),
this.isVertexBufferUpdatable(VertexBuffer.UVKind) && (e.uvs._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.UV2Kind) && (e.uv2s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV2Kind)),
this.isVertexBufferUpdatable(VertexBuffer.UV2Kind) && (e.uv2s._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.UV3Kind) && (e.uv3s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV3Kind)),
this.isVertexBufferUpdatable(VertexBuffer.UV3Kind) && (e.uv3s._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.UV4Kind) && (e.uv4s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV4Kind)),
this.isVertexBufferUpdatable(VertexBuffer.UV4Kind) && (e.uv4s._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.UV5Kind) && (e.uv5s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV5Kind)),
this.isVertexBufferUpdatable(VertexBuffer.UV5Kind) && (e.uv5s._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.UV6Kind) && (e.uv6s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV6Kind)),
this.isVertexBufferUpdatable(VertexBuffer.UV6Kind) && (e.uv6s._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.ColorKind) && (e.colors = this.toNumberArray(this.getVerticesData(VertexBuffer.ColorKind)),
this.isVertexBufferUpdatable(VertexBuffer.ColorKind) && (e.colors._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && (e.matricesIndices = this.toNumberArray(this.getVerticesData(VertexBuffer.MatricesIndicesKind)),
e.matricesIndices._isExpanded = !0,
this.isVertexBufferUpdatable(VertexBuffer.MatricesIndicesKind) && (e.matricesIndices._updatable = !0)),
this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) && (e.matricesWeights = this.toNumberArray(this.getVerticesData(VertexBuffer.MatricesWeightsKind)),
this.isVertexBufferUpdatable(VertexBuffer.MatricesWeightsKind) && (e.matricesWeights._updatable = !0)),
e.indices = this.toNumberArray(this.getIndices()),
e
}
,
i.ExtractFromMesh = function(e, t) {
var r = e._geometry;
return r ? r.copy(t) : null
}
,
i.RandomId = function() {
return Tools.RandomId()
}
,
i._GetGeometryByLoadedUniqueId = function(e, t) {
for (var r = 0; r < t.geometries.length; r++)
if (t.geometries[r]._loadedUniqueId === e)
return t.geometries[r];
return null
}
,
i._ImportGeometry = function(e, t) {
var r = t.getScene()
, n = e.geometryUniqueId
, o = e.geometryId;
if (n || o) {
var a = n ? this._GetGeometryByLoadedUniqueId(n, r) : r.getGeometryById(o);
a && a.applyToMesh(t)
} else if (e instanceof ArrayBuffer) {
var s = t._binaryInfo;
if (s.positionsAttrDesc && s.positionsAttrDesc.count > 0) {
var l = new Float32Array(e,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);
t.setVerticesData(VertexBuffer.PositionKind, l, !1)
}
if (s.normalsAttrDesc && s.normalsAttrDesc.count > 0) {
var u = new Float32Array(e,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);
t.setVerticesData(VertexBuffer.NormalKind, u, !1)
}
if (s.tangetsAttrDesc && s.tangetsAttrDesc.count > 0) {
var c = new Float32Array(e,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);
t.setVerticesData(VertexBuffer.TangentKind, c, !1)
}
if (s.uvsAttrDesc && s.uvsAttrDesc.count > 0) {
var h = new Float32Array(e,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);
t.setVerticesData(VertexBuffer.UVKind, h, !1)
}
if (s.uvs2AttrDesc && s.uvs2AttrDesc.count > 0) {
var f = new Float32Array(e,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);
t.setVerticesData(VertexBuffer.UV2Kind, f, !1)
}
if (s.uvs3AttrDesc && s.uvs3AttrDesc.count > 0) {
var d = new Float32Array(e,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);
t.setVerticesData(VertexBuffer.UV3Kind, d, !1)
}
if (s.uvs4AttrDesc && s.uvs4AttrDesc.count > 0) {
var _ = new Float32Array(e,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);
t.setVerticesData(VertexBuffer.UV4Kind, _, !1)
}
if (s.uvs5AttrDesc && s.uvs5AttrDesc.count > 0) {
var g = new Float32Array(e,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);
t.setVerticesData(VertexBuffer.UV5Kind, g, !1)
}
if (s.uvs6AttrDesc && s.uvs6AttrDesc.count > 0) {
var m = new Float32Array(e,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);
t.setVerticesData(VertexBuffer.UV6Kind, m, !1)
}
if (s.colorsAttrDesc && s.colorsAttrDesc.count > 0) {
var v = new Float32Array(e,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);
t.setVerticesData(VertexBuffer.ColorKind, v, !1, s.colorsAttrDesc.stride)
}
if (s.matricesIndicesAttrDesc && s.matricesIndicesAttrDesc.count > 0) {
for (var y = new Int32Array(e,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count), b = [], T = 0; T < y.length; T++) {
var C = y[T];
b.push(C & 255),
b.push((C & 65280) >> 8),
b.push((C & 16711680) >> 16),
b.push(C >> 24 & 255)
}
t.setVerticesData(VertexBuffer.MatricesIndicesKind, b, !1)
}
if (s.matricesIndicesExtraAttrDesc && s.matricesIndicesExtraAttrDesc.count > 0) {
for (var y = new Int32Array(e,s.matricesIndicesExtraAttrDesc.offset,s.matricesIndicesExtraAttrDesc.count), b = [], T = 0; T < y.length; T++) {
var C = y[T];
b.push(C & 255),
b.push((C & 65280) >> 8),
b.push((C & 16711680) >> 16),
b.push(C >> 24 & 255)
}
t.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, b, !1)
}
if (s.matricesWeightsAttrDesc && s.matricesWeightsAttrDesc.count > 0) {
var A = new Float32Array(e,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);
t.setVerticesData(VertexBuffer.MatricesWeightsKind, A, !1)
}
if (s.indicesAttrDesc && s.indicesAttrDesc.count > 0) {
var S = new Int32Array(e,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);
t.setIndices(S, null)
}
if (s.subMeshesAttrDesc && s.subMeshesAttrDesc.count > 0) {
var P = new Int32Array(e,s.subMeshesAttrDesc.offset,s.subMeshesAttrDesc.count * 5);
t.subMeshes = [];
for (var T = 0; T < s.subMeshesAttrDesc.count; T++) {
var R = P[T * 5 + 0]
, M = P[T * 5 + 1]
, x = P[T * 5 + 2]
, I = P[T * 5 + 3]
, w = P[T * 5 + 4];
SubMesh.AddToMesh(R, M, x, I, w, t)
}
}
} else if (e.positions && e.normals && e.indices) {
if (t.setVerticesData(VertexBuffer.PositionKind, e.positions, e.positions._updatable),
t.setVerticesData(VertexBuffer.NormalKind, e.normals, e.normals._updatable),
e.tangents && t.setVerticesData(VertexBuffer.TangentKind, e.tangents, e.tangents._updatable),
e.uvs && t.setVerticesData(VertexBuffer.UVKind, e.uvs, e.uvs._updatable),
e.uvs2 && t.setVerticesData(VertexBuffer.UV2Kind, e.uvs2, e.uvs2._updatable),
e.uvs3 && t.setVerticesData(VertexBuffer.UV3Kind, e.uvs3, e.uvs3._updatable),
e.uvs4 && t.setVerticesData(VertexBuffer.UV4Kind, e.uvs4, e.uvs4._updatable),
e.uvs5 && t.setVerticesData(VertexBuffer.UV5Kind, e.uvs5, e.uvs5._updatable),
e.uvs6 && t.setVerticesData(VertexBuffer.UV6Kind, e.uvs6, e.uvs6._updatable),
e.colors && t.setVerticesData(VertexBuffer.ColorKind, Color4.CheckColors4(e.colors, e.positions.length / 3), e.colors._updatable),
e.matricesIndices)
if (e.matricesIndices._isExpanded)
delete e.matricesIndices._isExpanded,
t.setVerticesData(VertexBuffer.MatricesIndicesKind, e.matricesIndices, e.matricesIndices._updatable);
else {
for (var b = [], T = 0; T < e.matricesIndices.length; T++) {
var O = e.matricesIndices[T];
b.push(O & 255),
b.push((O & 65280) >> 8),
b.push((O & 16711680) >> 16),
b.push(O >> 24 & 255)
}
t.setVerticesData(VertexBuffer.MatricesIndicesKind, b, e.matricesIndices._updatable)
}
if (e.matricesIndicesExtra)
if (e.matricesIndicesExtra._isExpanded)
delete e.matricesIndices._isExpanded,
t.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, e.matricesIndicesExtra, e.matricesIndicesExtra._updatable);
else {
for (var b = [], T = 0; T < e.matricesIndicesExtra.length; T++) {
var O = e.matricesIndicesExtra[T];
b.push(O & 255),
b.push((O & 65280) >> 8),
b.push((O & 16711680) >> 16),
b.push(O >> 24 & 255)
}
t.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, b, e.matricesIndicesExtra._updatable)
}
e.matricesWeights && (i._CleanMatricesWeights(e, t),
t.setVerticesData(VertexBuffer.MatricesWeightsKind, e.matricesWeights, e.matricesWeights._updatable)),
e.matricesWeightsExtra && t.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, e.matricesWeightsExtra, e.matricesWeights._updatable),
t.setIndices(e.indices, null)
}
if (e.subMeshes) {
t.subMeshes = [];
for (var D = 0; D < e.subMeshes.length; D++) {
var F = e.subMeshes[D];
SubMesh.AddToMesh(F.materialIndex, F.verticesStart, F.verticesCount, F.indexStart, F.indexCount, t)
}
}
t._shouldGenerateFlatShading && (t.convertToFlatShadedMesh(),
t._shouldGenerateFlatShading = !1),
t.computeWorldMatrix(!0),
r.onMeshImportedObservable.notifyObservers(t)
}
,
i._CleanMatricesWeights = function(e, t) {
var r = .001;
if (!!SceneLoaderFlags.CleanBoneMatrixWeights) {
var n = 0;
if (e.skeletonId > -1) {
var o = t.getScene().getLastSkeletonById(e.skeletonId);
if (!o)
return;
n = o.bones.length
} else
return;
for (var a = t.getVerticesData(VertexBuffer.MatricesIndicesKind), s = t.getVerticesData(VertexBuffer.MatricesIndicesExtraKind), l = e.matricesWeights, u = e.matricesWeightsExtra, c = e.numBoneInfluencer, h = l.length, f = 0; f < h; f += 4) {
for (var d = 0, _ = -1, g = 0; g < 4; g++) {
var m = l[f + g];
d += m,
m < r && _ < 0 && (_ = g)
}
if (u)
for (var g = 0; g < 4; g++) {
var m = u[f + g];
d += m,
m < r && _ < 0 && (_ = g + 4)
}
if ((_ < 0 || _ > c - 1) && (_ = c - 1),
d > r) {
for (var v = 1 / d, g = 0; g < 4; g++)
l[f + g] *= v;
if (u)
for (var g = 0; g < 4; g++)
u[f + g] *= v
} else
_ >= 4 ? (u[f + _ - 4] = 1 - d,
s[f + _ - 4] = n) : (l[f + _] = 1 - d,
a[f + _] = n)
}
t.setVerticesData(VertexBuffer.MatricesIndicesKind, a),
e.matricesWeightsExtra && t.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, s)
}
}
,
i.Parse = function(e, t, r) {
var n = new i(e.id,t,void 0,e.updatable);
return n._loadedUniqueId = e.uniqueId,
Tags && Tags.AddTagsTo(n, e.tags),
e.delayLoadingFile ? (n.delayLoadState = 4,
n.delayLoadingFile = r + e.delayLoadingFile,
n._boundingInfo = new BoundingInfo(Vector3.FromArray(e.boundingBoxMinimum),Vector3.FromArray(e.boundingBoxMaximum)),
n._delayInfo = [],
e.hasUVs && n._delayInfo.push(VertexBuffer.UVKind),
e.hasUVs2 && n._delayInfo.push(VertexBuffer.UV2Kind),
e.hasUVs3 && n._delayInfo.push(VertexBuffer.UV3Kind),
e.hasUVs4 && n._delayInfo.push(VertexBuffer.UV4Kind),
e.hasUVs5 && n._delayInfo.push(VertexBuffer.UV5Kind),
e.hasUVs6 && n._delayInfo.push(VertexBuffer.UV6Kind),
e.hasColors && n._delayInfo.push(VertexBuffer.ColorKind),
e.hasMatricesIndices && n._delayInfo.push(VertexBuffer.MatricesIndicesKind),
e.hasMatricesWeights && n._delayInfo.push(VertexBuffer.MatricesWeightsKind),
n._delayLoadingFunction = VertexData.ImportVertexData) : VertexData.ImportVertexData(e, n),
t.pushGeometry(n, !0),
n
}
,
i
}()
, TransformNode = function(i) {
__extends(e, i);
function e(t, r, n) {
r === void 0 && (r = null),
n === void 0 && (n = !0);
var o = i.call(this, t, r) || this;
return o._forward = new Vector3(0,0,1),
o._forwardInverted = new Vector3(0,0,-1),
o._up = new Vector3(0,1,0),
o._right = new Vector3(1,0,0),
o._rightInverted = new Vector3(-1,0,0),
o._position = Vector3.Zero(),
o._rotation = Vector3.Zero(),
o._rotationQuaternion = null,
o._scaling = Vector3.One(),
o._transformToBoneReferal = null,
o._isAbsoluteSynced = !1,
o._billboardMode = e.BILLBOARDMODE_NONE,
o._preserveParentRotationForBillboard = !1,
o.scalingDeterminant = 1,
o._infiniteDistance = !1,
o.ignoreNonUniformScaling = !1,
o.reIntegrateRotationIntoRotationQuaternion = !1,
o._poseMatrix = null,
o._localMatrix = Matrix.Zero(),
o._usePivotMatrix = !1,
o._absolutePosition = Vector3.Zero(),
o._absoluteScaling = Vector3.Zero(),
o._absoluteRotationQuaternion = Quaternion.Identity(),
o._pivotMatrix = Matrix.Identity(),
o._postMultiplyPivotMatrix = !1,
o._isWorldMatrixFrozen = !1,
o._indexInSceneTransformNodesArray = -1,
o.onAfterWorldMatrixUpdateObservable = new Observable,
o._nonUniformScaling = !1,
n && o.getScene().addTransformNode(o),
o
}
return Object.defineProperty(e.prototype, "billboardMode", {
get: function() {
return this._billboardMode
},
set: function(t) {
this._billboardMode !== t && (this._billboardMode = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "preserveParentRotationForBillboard", {
get: function() {
return this._preserveParentRotationForBillboard
},
set: function(t) {
t !== this._preserveParentRotationForBillboard && (this._preserveParentRotationForBillboard = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "infiniteDistance", {
get: function() {
return this._infiniteDistance
},
set: function(t) {
this._infiniteDistance !== t && (this._infiniteDistance = t)
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "TransformNode"
}
,
Object.defineProperty(e.prototype, "position", {
get: function() {
return this._position
},
set: function(t) {
this._position = t,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
e.prototype.isUsingPivotMatrix = function() {
return this._usePivotMatrix
}
,
Object.defineProperty(e.prototype, "rotation", {
get: function() {
return this._rotation
},
set: function(t) {
this._rotation = t,
this._rotationQuaternion = null,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "scaling", {
get: function() {
return this._scaling
},
set: function(t) {
this._scaling = t,
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rotationQuaternion", {
get: function() {
return this._rotationQuaternion
},
set: function(t) {
this._rotationQuaternion = t,
t && this._rotation.setAll(0),
this._isDirty = !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "forward", {
get: function() {
return Vector3.Normalize(Vector3.TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "up", {
get: function() {
return Vector3.Normalize(Vector3.TransformNormal(this._up, this.getWorldMatrix()))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return Vector3.Normalize(Vector3.TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()))
},
enumerable: !1,
configurable: !0
}),
e.prototype.updatePoseMatrix = function(t) {
return this._poseMatrix ? (this._poseMatrix.copyFrom(t),
this) : (this._poseMatrix = t.clone(),
this)
}
,
e.prototype.getPoseMatrix = function() {
return this._poseMatrix || (this._poseMatrix = Matrix.Identity()),
this._poseMatrix
}
,
e.prototype._isSynchronized = function() {
var t = this._cache;
return !(this.billboardMode !== t.billboardMode || this.billboardMode !== e.BILLBOARDMODE_NONE || t.pivotMatrixUpdated || this.infiniteDistance || this.position._isDirty || this.scaling._isDirty || this._rotationQuaternion && this._rotationQuaternion._isDirty || this.rotation._isDirty)
}
,
e.prototype._initCache = function() {
i.prototype._initCache.call(this);
var t = this._cache;
t.localMatrixUpdated = !1,
t.billboardMode = -1,
t.infiniteDistance = !1
}
,
Object.defineProperty(e.prototype, "absolutePosition", {
get: function() {
return this.getAbsolutePosition()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "absoluteScaling", {
get: function() {
return this._syncAbsoluteScalingAndRotation(),
this._absoluteScaling
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "absoluteRotationQuaternion", {
get: function() {
return this._syncAbsoluteScalingAndRotation(),
this._absoluteRotationQuaternion
},
enumerable: !1,
configurable: !0
}),
e.prototype.setPreTransformMatrix = function(t) {
return this.setPivotMatrix(t, !1)
}
,
e.prototype.setPivotMatrix = function(t, r) {
return r === void 0 && (r = !0),
this._pivotMatrix.copyFrom(t),
this._usePivotMatrix = !this._pivotMatrix.isIdentity(),
this._cache.pivotMatrixUpdated = !0,
this._postMultiplyPivotMatrix = r,
this._postMultiplyPivotMatrix && (this._pivotMatrixInverse ? this._pivotMatrix.invertToRef(this._pivotMatrixInverse) : this._pivotMatrixInverse = Matrix.Invert(this._pivotMatrix)),
this
}
,
e.prototype.getPivotMatrix = function() {
return this._pivotMatrix
}
,
e.prototype.instantiateHierarchy = function(t, r, n) {
t === void 0 && (t = null);
var o = this.clone("Clone of " + (this.name || this.id), t || this.parent, !0);
o && n && n(this, o);
for (var a = 0, s = this.getChildTransformNodes(!0); a < s.length; a++) {
var l = s[a];
l.instantiateHierarchy(o, r, n)
}
return o
}
,
e.prototype.freezeWorldMatrix = function(t, r) {
return t === void 0 && (t = null),
r === void 0 && (r = !1),
t ? r ? (this._rotation.setAll(0),
this._rotationQuaternion = this._rotationQuaternion || Quaternion.Identity(),
t.decompose(this._scaling, this._rotationQuaternion, this._position),
this.computeWorldMatrix(!0)) : (this._worldMatrix = t,
this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]),
this._afterComputeWorldMatrix()) : (this._isWorldMatrixFrozen = !1,
this.computeWorldMatrix(!0)),
this._isDirty = !1,
this._isWorldMatrixFrozen = !0,
this
}
,
e.prototype.unfreezeWorldMatrix = function() {
return this._isWorldMatrixFrozen = !1,
this.computeWorldMatrix(!0),
this
}
,
Object.defineProperty(e.prototype, "isWorldMatrixFrozen", {
get: function() {
return this._isWorldMatrixFrozen
},
enumerable: !1,
configurable: !0
}),
e.prototype.getAbsolutePosition = function() {
return this.computeWorldMatrix(),
this._absolutePosition
}
,
e.prototype.setAbsolutePosition = function(t) {
if (!t)
return this;
var r, n, o;
if (t.x === void 0) {
if (arguments.length < 3)
return this;
r = arguments[0],
n = arguments[1],
o = arguments[2]
} else
r = t.x,
n = t.y,
o = t.z;
if (this.parent) {
var a = TmpVectors.Matrix[0];
this.parent.getWorldMatrix().invertToRef(a),
Vector3.TransformCoordinatesFromFloatsToRef(r, n, o, a, this.position)
} else
this.position.x = r,
this.position.y = n,
this.position.z = o;
return this._absolutePosition.copyFrom(t),
this
}
,
e.prototype.setPositionWithLocalVector = function(t) {
return this.computeWorldMatrix(),
this.position = Vector3.TransformNormal(t, this._localMatrix),
this
}
,
e.prototype.getPositionExpressedInLocalSpace = function() {
this.computeWorldMatrix();
var t = TmpVectors.Matrix[0];
return this._localMatrix.invertToRef(t),
Vector3.TransformNormal(this.position, t)
}
,
e.prototype.locallyTranslate = function(t) {
return this.computeWorldMatrix(!0),
this.position = Vector3.TransformCoordinates(t, this._localMatrix),
this
}
,
e.prototype.lookAt = function(t, r, n, o, a) {
r === void 0 && (r = 0),
n === void 0 && (n = 0),
o === void 0 && (o = 0),
a === void 0 && (a = Space.LOCAL);
var s = e._lookAtVectorCache
, l = a === Space.LOCAL ? this.position : this.getAbsolutePosition();
if (t.subtractToRef(l, s),
this.setDirection(s, r, n, o),
a === Space.WORLD && this.parent)
if (this.rotationQuaternion) {
var u = TmpVectors.Matrix[0];
this.rotationQuaternion.toRotationMatrix(u);
var c = TmpVectors.Matrix[1];
this.parent.getWorldMatrix().getRotationMatrixToRef(c),
c.invert(),
u.multiplyToRef(c, u),
this.rotationQuaternion.fromRotationMatrix(u)
} else {
var h = TmpVectors.Quaternion[0];
Quaternion.FromEulerVectorToRef(this.rotation, h);
var u = TmpVectors.Matrix[0];
h.toRotationMatrix(u);
var c = TmpVectors.Matrix[1];
this.parent.getWorldMatrix().getRotationMatrixToRef(c),
c.invert(),
u.multiplyToRef(c, u),
h.fromRotationMatrix(u),
h.toEulerAnglesToRef(this.rotation)
}
return this
}
,
e.prototype.getDirection = function(t) {
var r = Vector3.Zero();
return this.getDirectionToRef(t, r),
r
}
,
e.prototype.getDirectionToRef = function(t, r) {
return Vector3.TransformNormalToRef(t, this.getWorldMatrix(), r),
this
}
,
e.prototype.setDirection = function(t, r, n, o) {
r === void 0 && (r = 0),
n === void 0 && (n = 0),
o === void 0 && (o = 0);
var a = -Math.atan2(t.z, t.x) + Math.PI / 2
, s = Math.sqrt(t.x * t.x + t.z * t.z)
, l = -Math.atan2(t.y, s);
return this.rotationQuaternion ? Quaternion.RotationYawPitchRollToRef(a + r, l + n, o, this.rotationQuaternion) : (this.rotation.x = l + n,
this.rotation.y = a + r,
this.rotation.z = o),
this
}
,
e.prototype.setPivotPoint = function(t, r) {
r === void 0 && (r = Space.LOCAL),
this.getScene().getRenderId() == 0 && this.computeWorldMatrix(!0);
var n = this.getWorldMatrix();
if (r == Space.WORLD) {
var o = TmpVectors.Matrix[0];
n.invertToRef(o),
t = Vector3.TransformCoordinates(t, o)
}
return this.setPivotMatrix(Matrix.Translation(-t.x, -t.y, -t.z), !0)
}
,
e.prototype.getPivotPoint = function() {
var t = Vector3.Zero();
return this.getPivotPointToRef(t),
t
}
,
e.prototype.getPivotPointToRef = function(t) {
return t.x = -this._pivotMatrix.m[12],
t.y = -this._pivotMatrix.m[13],
t.z = -this._pivotMatrix.m[14],
this
}
,
e.prototype.getAbsolutePivotPoint = function() {
var t = Vector3.Zero();
return this.getAbsolutePivotPointToRef(t),
t
}
,
e.prototype.getAbsolutePivotPointToRef = function(t) {
return this.getPivotPointToRef(t),
Vector3.TransformCoordinatesToRef(t, this.getWorldMatrix(), t),
this
}
,
e.prototype.markAsDirty = function(t) {
if (this._children)
for (var r = 0, n = this._children; r < n.length; r++) {
var o = n[r];
o.markAsDirty(t)
}
return i.prototype.markAsDirty.call(this, t)
}
,
e.prototype.setParent = function(t, r) {
if (r === void 0 && (r = !1),
!t && !this.parent)
return this;
var n = TmpVectors.Quaternion[0]
, o = TmpVectors.Vector3[0]
, a = TmpVectors.Vector3[1]
, s = TmpVectors.Matrix[1];
Matrix.IdentityToRef(s);
var l = TmpVectors.Matrix[0];
this.computeWorldMatrix(!0);
var u = this.rotationQuaternion;
return u || (u = e._TmpRotation,
Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, u)),
Matrix.ComposeToRef(this.scaling, u, this.position, l),
this.parent && l.multiplyToRef(this.parent.computeWorldMatrix(!0), l),
t && (t.computeWorldMatrix(!0).invertToRef(s),
l.multiplyToRef(s, l)),
l.decompose(a, n, o, r ? this : void 0),
this.rotationQuaternion ? this.rotationQuaternion.copyFrom(n) : n.toEulerAnglesToRef(this.rotation),
this.scaling.copyFrom(a),
this.position.copyFrom(o),
this.parent = t,
this
}
,
Object.defineProperty(e.prototype, "nonUniformScaling", {
get: function() {
return this._nonUniformScaling
},
enumerable: !1,
configurable: !0
}),
e.prototype._updateNonUniformScalingState = function(t) {
return this._nonUniformScaling === t ? !1 : (this._nonUniformScaling = t,
!0)
}
,
e.prototype.attachToBone = function(t, r) {
return this._currentParentWhenAttachingToBone = this.parent,
this._transformToBoneReferal = r,
this.parent = t,
t.getSkeleton().prepare(),
t.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
this
}
,
e.prototype.detachFromBone = function(t) {
return t === void 0 && (t = !1),
this.parent ? (this.parent.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
this._transformToBoneReferal = null,
t ? this.parent = this._currentParentWhenAttachingToBone : this.parent = null,
this) : (t && (this.parent = this._currentParentWhenAttachingToBone),
this)
}
,
e.prototype.rotate = function(t, r, n) {
t.normalize(),
this.rotationQuaternion || (this.rotationQuaternion = this.rotation.toQuaternion(),
this.rotation.setAll(0));
var o;
if (!n || n === Space.LOCAL)
o = Quaternion.RotationAxisToRef(t, r, e._rotationAxisCache),
this.rotationQuaternion.multiplyToRef(o, this.rotationQuaternion);
else {
if (this.parent) {
var a = TmpVectors.Matrix[0];
this.parent.getWorldMatrix().invertToRef(a),
t = Vector3.TransformNormal(t, a)
}
o = Quaternion.RotationAxisToRef(t, r, e._rotationAxisCache),
o.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
}
return this
}
,
e.prototype.rotateAround = function(t, r, n) {
r.normalize(),
this.rotationQuaternion || (this.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z),
this.rotation.setAll(0));
var o = TmpVectors.Vector3[0]
, a = TmpVectors.Vector3[1]
, s = TmpVectors.Vector3[2]
, l = TmpVectors.Quaternion[0]
, u = TmpVectors.Matrix[0]
, c = TmpVectors.Matrix[1]
, h = TmpVectors.Matrix[2]
, f = TmpVectors.Matrix[3];
return t.subtractToRef(this.position, o),
Matrix.TranslationToRef(o.x, o.y, o.z, u),
Matrix.TranslationToRef(-o.x, -o.y, -o.z, c),
Matrix.RotationAxisToRef(r, n, h),
c.multiplyToRef(h, f),
f.multiplyToRef(u, f),
f.decompose(a, l, s),
this.position.addInPlace(s),
l.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion),
this
}
,
e.prototype.translate = function(t, r, n) {
var o = t.scale(r);
if (!n || n === Space.LOCAL) {
var a = this.getPositionExpressedInLocalSpace().add(o);
this.setPositionWithLocalVector(a)
} else
this.setAbsolutePosition(this.getAbsolutePosition().add(o));
return this
}
,
e.prototype.addRotation = function(t, r, n) {
var o;
this.rotationQuaternion ? o = this.rotationQuaternion : (o = TmpVectors.Quaternion[1],
Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, o));
var a = TmpVectors.Quaternion[0];
return Quaternion.RotationYawPitchRollToRef(r, t, n, a),
o.multiplyInPlace(a),
this.rotationQuaternion || o.toEulerAnglesToRef(this.rotation),
this
}
,
e.prototype._getEffectiveParent = function() {
return this.parent
}
,
e.prototype.computeWorldMatrix = function(t) {
if (this._isWorldMatrixFrozen && !this._isDirty)
return this._worldMatrix;
var r = this.getScene().getRenderId();
if (!this._isDirty && !t && this.isSynchronized())
return this._currentRenderId = r,
this._worldMatrix;
var n = this.getScene().activeCamera
, o = (this._billboardMode & e.BILLBOARDMODE_USE_POSITION) !== 0
, a = this._billboardMode !== e.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
a && n && o && (this.lookAt(n.position),
(this.billboardMode & e.BILLBOARDMODE_X) !== e.BILLBOARDMODE_X && (this.rotation.x = 0),
(this.billboardMode & e.BILLBOARDMODE_Y) !== e.BILLBOARDMODE_Y && (this.rotation.y = 0),
(this.billboardMode & e.BILLBOARDMODE_Z) !== e.BILLBOARDMODE_Z && (this.rotation.z = 0)),
this._updateCache();
var s = this._cache;
s.pivotMatrixUpdated = !1,
s.billboardMode = this.billboardMode,
s.infiniteDistance = this.infiniteDistance,
this._currentRenderId = r,
this._childUpdateId += 1,
this._isDirty = !1,
this._position._isDirty = !1,
this._rotation._isDirty = !1,
this._scaling._isDirty = !1;
var l = this._getEffectiveParent()
, u = e._TmpScaling
, c = this._position;
if (this._infiniteDistance && !this.parent && n) {
var h = n.getWorldMatrix()
, f = new Vector3(h.m[12],h.m[13],h.m[14]);
c = e._TmpTranslation,
c.copyFromFloats(this._position.x + f.x, this._position.y + f.y, this._position.z + f.z)
}
u.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
var d;
if (this._rotationQuaternion) {
if (this._rotationQuaternion._isDirty = !1,
d = this._rotationQuaternion,
this.reIntegrateRotationIntoRotationQuaternion) {
var _ = this.rotation.lengthSquared();
_ && (this._rotationQuaternion.multiplyInPlace(Quaternion.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z)),
this._rotation.copyFromFloats(0, 0, 0))
}
} else
d = e._TmpRotation,
Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, d);
if (this._usePivotMatrix) {
var g = TmpVectors.Matrix[1];
Matrix.ScalingToRef(u.x, u.y, u.z, g);
var m = TmpVectors.Matrix[0];
d.toRotationMatrix(m),
this._pivotMatrix.multiplyToRef(g, TmpVectors.Matrix[4]),
TmpVectors.Matrix[4].multiplyToRef(m, this._localMatrix),
this._postMultiplyPivotMatrix && this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix),
this._localMatrix.addTranslationFromFloats(c.x, c.y, c.z)
} else
Matrix.ComposeToRef(u, d, c, this._localMatrix);
if (l && l.getWorldMatrix) {
if (t && l.computeWorldMatrix(t),
a) {
this._transformToBoneReferal ? l.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), TmpVectors.Matrix[7]) : TmpVectors.Matrix[7].copyFrom(l.getWorldMatrix());
var v = TmpVectors.Vector3[5]
, y = TmpVectors.Vector3[6];
TmpVectors.Matrix[7].decompose(y, void 0, v),
Matrix.ScalingToRef(y.x, y.y, y.z, TmpVectors.Matrix[7]),
TmpVectors.Matrix[7].setTranslation(v),
this._localMatrix.multiplyToRef(TmpVectors.Matrix[7], this._worldMatrix)
} else
this._transformToBoneReferal ? (this._localMatrix.multiplyToRef(l.getWorldMatrix(), TmpVectors.Matrix[6]),
TmpVectors.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix)) : this._localMatrix.multiplyToRef(l.getWorldMatrix(), this._worldMatrix);
this._markSyncedWithParent()
} else
this._worldMatrix.copyFrom(this._localMatrix);
if (a && n && this.billboardMode && !o) {
var b = TmpVectors.Vector3[0];
if (this._worldMatrix.getTranslationToRef(b),
TmpVectors.Matrix[1].copyFrom(n.getViewMatrix()),
TmpVectors.Matrix[1].setTranslationFromFloats(0, 0, 0),
TmpVectors.Matrix[1].invertToRef(TmpVectors.Matrix[0]),
(this.billboardMode & e.BILLBOARDMODE_ALL) !== e.BILLBOARDMODE_ALL) {
TmpVectors.Matrix[0].decompose(void 0, TmpVectors.Quaternion[0], void 0);
var T = TmpVectors.Vector3[1];
TmpVectors.Quaternion[0].toEulerAnglesToRef(T),
(this.billboardMode & e.BILLBOARDMODE_X) !== e.BILLBOARDMODE_X && (T.x = 0),
(this.billboardMode & e.BILLBOARDMODE_Y) !== e.BILLBOARDMODE_Y && (T.y = 0),
(this.billboardMode & e.BILLBOARDMODE_Z) !== e.BILLBOARDMODE_Z && (T.z = 0),
Matrix.RotationYawPitchRollToRef(T.y, T.x, T.z, TmpVectors.Matrix[0])
}
this._worldMatrix.setTranslationFromFloats(0, 0, 0),
this._worldMatrix.multiplyToRef(TmpVectors.Matrix[0], this._worldMatrix),
this._worldMatrix.setTranslation(TmpVectors.Vector3[0])
}
return this.ignoreNonUniformScaling ? this._updateNonUniformScalingState(!1) : this._scaling.isNonUniformWithinEpsilon(1e-6) ? this._updateNonUniformScalingState(!0) : l && l._nonUniformScaling ? this._updateNonUniformScalingState(l._nonUniformScaling) : this._updateNonUniformScalingState(!1),
this._afterComputeWorldMatrix(),
this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]),
this._isAbsoluteSynced = !1,
this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),
this._poseMatrix || (this._poseMatrix = Matrix.Invert(this._worldMatrix)),
this._worldMatrixDeterminantIsDirty = !0,
this._worldMatrix
}
,
e.prototype.resetLocalMatrix = function(t) {
if (t === void 0 && (t = !0),
this.computeWorldMatrix(),
t)
for (var r = this.getChildren(), n = 0; n < r.length; ++n) {
var o = r[n];
if (o) {
o.computeWorldMatrix();
var a = TmpVectors.Matrix[0];
o._localMatrix.multiplyToRef(this._localMatrix, a);
var s = TmpVectors.Quaternion[0];
a.decompose(o.scaling, s, o.position),
o.rotationQuaternion ? o.rotationQuaternion.copyFrom(s) : s.toEulerAnglesToRef(o.rotation)
}
}
this.scaling.copyFromFloats(1, 1, 1),
this.position.copyFromFloats(0, 0, 0),
this.rotation.copyFromFloats(0, 0, 0),
this.rotationQuaternion && (this.rotationQuaternion = Quaternion.Identity()),
this._worldMatrix = Matrix.Identity()
}
,
e.prototype._afterComputeWorldMatrix = function() {}
,
e.prototype.registerAfterWorldMatrixUpdate = function(t) {
return this.onAfterWorldMatrixUpdateObservable.add(t),
this
}
,
e.prototype.unregisterAfterWorldMatrixUpdate = function(t) {
return this.onAfterWorldMatrixUpdateObservable.removeCallback(t),
this
}
,
e.prototype.getPositionInCameraSpace = function(t) {
return t === void 0 && (t = null),
t || (t = this.getScene().activeCamera),
Vector3.TransformCoordinates(this.getAbsolutePosition(), t.getViewMatrix())
}
,
e.prototype.getDistanceToCamera = function(t) {
return t === void 0 && (t = null),
t || (t = this.getScene().activeCamera),
this.getAbsolutePosition().subtract(t.globalPosition).length()
}
,
e.prototype.clone = function(t, r, n) {
var o = this
, a = SerializationHelper.Clone(function() {
return new e(t,o.getScene())
}, this);
if (a.name = t,
a.id = t,
r && (a.parent = r),
!n)
for (var s = this.getDescendants(!0), l = 0; l < s.length; l++) {
var u = s[l];
u.clone && u.clone(t + "." + u.name, a)
}
return a
}
,
e.prototype.serialize = function(t) {
var r = SerializationHelper.Serialize(this, t);
return r.type = this.getClassName(),
r.uniqueId = this.uniqueId,
this.parent && (r.parentId = this.parent.uniqueId),
r.localMatrix = this.getPivotMatrix().asArray(),
r.isEnabled = this.isEnabled(),
this.parent && (r.parentId = this.parent.uniqueId),
r
}
,
e.Parse = function(t, r, n) {
var o = SerializationHelper.Parse(function() {
return new e(t.name,r)
}, t, r, n);
return t.localMatrix ? o.setPreTransformMatrix(Matrix.FromArray(t.localMatrix)) : t.pivotMatrix && o.setPivotMatrix(Matrix.FromArray(t.pivotMatrix)),
o.setEnabled(t.isEnabled),
t.parentId && (o._waitingParentId = t.parentId),
o
}
,
e.prototype.getChildTransformNodes = function(t, r) {
var n = [];
return this._getDescendants(n, t, function(o) {
return (!r || r(o)) && o instanceof e
}),
n
}
,
e.prototype.dispose = function(t, r) {
if (r === void 0 && (r = !1),
this.getScene().stopAnimation(this),
this.getScene().removeTransformNode(this),
this._parentContainer) {
var n = this._parentContainer.transformNodes.indexOf(this);
n > -1 && this._parentContainer.transformNodes.splice(n, 1),
this._parentContainer = null
}
if (this.onAfterWorldMatrixUpdateObservable.clear(),
t)
for (var o = this.getChildTransformNodes(!0), a = 0, s = o; a < s.length; a++) {
var l = s[a];
l.parent = null,
l.computeWorldMatrix(!0)
}
i.prototype.dispose.call(this, t, r)
}
,
e.prototype.normalizeToUnitCube = function(t, r, n) {
t === void 0 && (t = !0),
r === void 0 && (r = !1);
var o = null
, a = null;
r && (this.rotationQuaternion ? (a = this.rotationQuaternion.clone(),
this.rotationQuaternion.copyFromFloats(0, 0, 0, 1)) : this.rotation && (o = this.rotation.clone(),
this.rotation.copyFromFloats(0, 0, 0)));
var s = this.getHierarchyBoundingVectors(t, n)
, l = s.max.subtract(s.min)
, u = Math.max(l.x, l.y, l.z);
if (u === 0)
return this;
var c = 1 / u;
return this.scaling.scaleInPlace(c),
r && (this.rotationQuaternion && a ? this.rotationQuaternion.copyFrom(a) : this.rotation && o && this.rotation.copyFrom(o)),
this
}
,
e.prototype._syncAbsoluteScalingAndRotation = function() {
this._isAbsoluteSynced || (this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion),
this._isAbsoluteSynced = !0)
}
,
e.BILLBOARDMODE_NONE = 0,
e.BILLBOARDMODE_X = 1,
e.BILLBOARDMODE_Y = 2,
e.BILLBOARDMODE_Z = 4,
e.BILLBOARDMODE_ALL = 7,
e.BILLBOARDMODE_USE_POSITION = 128,
e._TmpRotation = Quaternion.Zero(),
e._TmpScaling = Vector3.Zero(),
e._TmpTranslation = Vector3.Zero(),
e._lookAtVectorCache = new Vector3(0,0,0),
e._rotationAxisCache = new Quaternion,
__decorate([serializeAsVector3("position")], e.prototype, "_position", void 0),
__decorate([serializeAsVector3("rotation")], e.prototype, "_rotation", void 0),
__decorate([serializeAsQuaternion("rotationQuaternion")], e.prototype, "_rotationQuaternion", void 0),
__decorate([serializeAsVector3("scaling")], e.prototype, "_scaling", void 0),
__decorate([serialize("billboardMode")], e.prototype, "_billboardMode", void 0),
__decorate([serialize()], e.prototype, "scalingDeterminant", void 0),
__decorate([serialize("infiniteDistance")], e.prototype, "_infiniteDistance", void 0),
__decorate([serialize()], e.prototype, "ignoreNonUniformScaling", void 0),
__decorate([serialize()], e.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0),
e
}(Node$2)
, _MeshCollisionData = function() {
function i() {
this._checkCollisions = !1,
this._collisionMask = -1,
this._collisionGroup = -1,
this._surroundingMeshes = null,
this._collider = null,
this._oldPositionForCollisions = new Vector3(0,0,0),
this._diffPositionForCollisions = new Vector3(0,0,0),
this._collisionResponse = !0
}
return i
}()
, _FacetDataStorage = function() {
function i() {
this.facetNb = 0,
this.partitioningSubdivisions = 10,
this.partitioningBBoxRatio = 1.01,
this.facetDataEnabled = !1,
this.facetParameters = {},
this.bbSize = Vector3.Zero(),
this.subDiv = {
max: 1,
X: 1,
Y: 1,
Z: 1
},
this.facetDepthSort = !1,
this.facetDepthSortEnabled = !1
}
return i
}()
, _InternalAbstractMeshDataInfo = function() {
function i() {
this._hasVertexAlpha = !1,
this._useVertexColors = !0,
this._numBoneInfluencers = 4,
this._applyFog = !0,
this._receiveShadows = !1,
this._facetData = new _FacetDataStorage,
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,
this._collisionRetryCount = 3,
this._morphTargetManager = null,
this._renderingGroupId = 0,
this._bakedVertexAnimationManager = null,
this._material = null,
this._positions = null,
this._meshCollisionData = new _MeshCollisionData
}
return i
}()
, AbstractMesh = function(i) {
__extends(e, i);
function e(t, r) {
r === void 0 && (r = null);
var n = i.call(this, t, r, !1) || this;
return n._internalAbstractMeshDataInfo = new _InternalAbstractMeshDataInfo,
n.cullingStrategy = e.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
n.onCollideObservable = new Observable,
n.onCollisionPositionChangeObservable = new Observable,
n.onMaterialChangedObservable = new Observable,
n.definedFacingForward = !0,
n._occlusionQuery = null,
n._renderingGroup = null,
n.alphaIndex = Number.MAX_VALUE,
n.isVisible = !0,
n.isPickable = !0,
n.isNearPickable = !1,
n.isNearGrabbable = !1,
n.showSubMeshesBoundingBox = !1,
n.isBlocker = !1,
n.enablePointerMoveEvents = !1,
n.outlineColor = Color3.Red(),
n.outlineWidth = .02,
n.overlayColor = Color3.Red(),
n.overlayAlpha = .5,
n.useOctreeForRenderingSelection = !0,
n.useOctreeForPicking = !0,
n.useOctreeForCollisions = !0,
n.alwaysSelectAsActiveMesh = !1,
n.doNotSyncBoundingInfo = !1,
n.actionManager = null,
n.ellipsoid = new Vector3(.5,1,.5),
n.ellipsoidOffset = new Vector3(0,0,0),
n.edgesWidth = 1,
n.edgesColor = new Color4(1,0,0,1),
n._edgesRenderer = null,
n._masterMesh = null,
n._boundingInfo = null,
n._boundingInfoIsDirty = !0,
n._renderId = 0,
n._intersectionsInProgress = new Array,
n._unIndexed = !1,
n._lightSources = new Array,
n._waitingData = {
lods: null,
actions: null,
freezeWorldMatrix: null
},
n._bonesTransformMatrices = null,
n._transformMatrixTexture = null,
n.onRebuildObservable = new Observable,
n._onCollisionPositionChange = function(o, a, s) {
s === void 0 && (s = null),
a.subtractToRef(n._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, n._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
n._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > Engine.CollisionsEpsilon && n.position.addInPlace(n._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
s && n.onCollideObservable.notifyObservers(s),
n.onCollisionPositionChangeObservable.notifyObservers(n.position)
}
,
n.getScene().addMesh(n),
n._resyncLightSources(),
n._uniformBuffer = new UniformBuffer(n.getScene().getEngine(),void 0,void 0,t),
n._buildUniformLayout(),
n
}
return Object.defineProperty(e, "BILLBOARDMODE_NONE", {
get: function() {
return TransformNode.BILLBOARDMODE_NONE
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "BILLBOARDMODE_X", {
get: function() {
return TransformNode.BILLBOARDMODE_X
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "BILLBOARDMODE_Y", {
get: function() {
return TransformNode.BILLBOARDMODE_Y
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "BILLBOARDMODE_Z", {
get: function() {
return TransformNode.BILLBOARDMODE_Z
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "BILLBOARDMODE_ALL", {
get: function() {
return TransformNode.BILLBOARDMODE_ALL
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "BILLBOARDMODE_USE_POSITION", {
get: function() {
return TransformNode.BILLBOARDMODE_USE_POSITION
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "facetNb", {
get: function() {
return this._internalAbstractMeshDataInfo._facetData.facetNb
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "partitioningSubdivisions", {
get: function() {
return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions
},
set: function(t) {
this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "partitioningBBoxRatio", {
get: function() {
return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio
},
set: function(t) {
this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "mustDepthSortFacets", {
get: function() {
return this._internalAbstractMeshDataInfo._facetData.facetDepthSort
},
set: function(t) {
this._internalAbstractMeshDataInfo._facetData.facetDepthSort = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "facetDepthSortFrom", {
get: function() {
return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom
},
set: function(t) {
this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "collisionRetryCount", {
get: function() {
return this._internalAbstractMeshDataInfo._collisionRetryCount
},
set: function(t) {
this._internalAbstractMeshDataInfo._collisionRetryCount = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isFacetDataEnabled", {
get: function() {
return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "morphTargetManager", {
get: function() {
return this._internalAbstractMeshDataInfo._morphTargetManager
},
set: function(t) {
this._internalAbstractMeshDataInfo._morphTargetManager !== t && (this._internalAbstractMeshDataInfo._morphTargetManager = t,
this._syncGeometryWithMorphTargetManager())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "bakedVertexAnimationManager", {
get: function() {
return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager
},
set: function(t) {
this._internalAbstractMeshDataInfo._bakedVertexAnimationManager !== t && (this._internalAbstractMeshDataInfo._bakedVertexAnimationManager = t,
this._markSubMeshesAsAttributesDirty())
},
enumerable: !1,
configurable: !0
}),
e.prototype._syncGeometryWithMorphTargetManager = function() {}
,
e.prototype._updateNonUniformScalingState = function(t) {
return i.prototype._updateNonUniformScalingState.call(this, t) ? (this._markSubMeshesAsMiscDirty(),
!0) : !1
}
,
Object.defineProperty(e.prototype, "onCollide", {
set: function(t) {
this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver && this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),
this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver = this.onCollideObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onCollisionPositionChange", {
set: function(t) {
this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver && this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),
this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "visibility", {
get: function() {
return this._internalAbstractMeshDataInfo._visibility
},
set: function(t) {
if (this._internalAbstractMeshDataInfo._visibility !== t) {
var r = this._internalAbstractMeshDataInfo._visibility;
this._internalAbstractMeshDataInfo._visibility = t,
(r === 1 && t !== 1 || r !== 1 && t === 1) && this._markSubMeshesAsMiscDirty()
}
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "renderingGroupId", {
get: function() {
return this._internalAbstractMeshDataInfo._renderingGroupId
},
set: function(t) {
this._internalAbstractMeshDataInfo._renderingGroupId = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "material", {
get: function() {
return this._internalAbstractMeshDataInfo._material
},
set: function(t) {
this._internalAbstractMeshDataInfo._material !== t && (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
this._internalAbstractMeshDataInfo._material = t,
t && t.meshMap && (t.meshMap[this.uniqueId] = this),
this.onMaterialChangedObservable.hasObservers() && this.onMaterialChangedObservable.notifyObservers(this),
this.subMeshes && (this.resetDrawCache(),
this._unBindEffect()))
},
enumerable: !1,
configurable: !0
}),
e.prototype.getMaterialForRenderPass = function(t) {
var r;
return (r = this._internalAbstractMeshDataInfo._materialForRenderPass) === null || r === void 0 ? void 0 : r[t]
}
,
e.prototype.setMaterialForRenderPass = function(t, r) {
this._internalAbstractMeshDataInfo._materialForRenderPass || (this._internalAbstractMeshDataInfo._materialForRenderPass = []),
this._internalAbstractMeshDataInfo._materialForRenderPass[t] = r
}
,
Object.defineProperty(e.prototype, "receiveShadows", {
get: function() {
return this._internalAbstractMeshDataInfo._receiveShadows
},
set: function(t) {
this._internalAbstractMeshDataInfo._receiveShadows !== t && (this._internalAbstractMeshDataInfo._receiveShadows = t,
this._markSubMeshesAsLightDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "hasVertexAlpha", {
get: function() {
return this._internalAbstractMeshDataInfo._hasVertexAlpha
},
set: function(t) {
this._internalAbstractMeshDataInfo._hasVertexAlpha !== t && (this._internalAbstractMeshDataInfo._hasVertexAlpha = t,
this._markSubMeshesAsAttributesDirty(),
this._markSubMeshesAsMiscDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "useVertexColors", {
get: function() {
return this._internalAbstractMeshDataInfo._useVertexColors
},
set: function(t) {
this._internalAbstractMeshDataInfo._useVertexColors !== t && (this._internalAbstractMeshDataInfo._useVertexColors = t,
this._markSubMeshesAsAttributesDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "computeBonesUsingShaders", {
get: function() {
return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
},
set: function(t) {
this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== t && (this._internalAbstractMeshDataInfo._computeBonesUsingShaders = t,
this._markSubMeshesAsAttributesDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "numBoneInfluencers", {
get: function() {
return this._internalAbstractMeshDataInfo._numBoneInfluencers
},
set: function(t) {
this._internalAbstractMeshDataInfo._numBoneInfluencers !== t && (this._internalAbstractMeshDataInfo._numBoneInfluencers = t,
this._markSubMeshesAsAttributesDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "applyFog", {
get: function() {
return this._internalAbstractMeshDataInfo._applyFog
},
set: function(t) {
this._internalAbstractMeshDataInfo._applyFog !== t && (this._internalAbstractMeshDataInfo._applyFog = t,
this._markSubMeshesAsMiscDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "layerMask", {
get: function() {
return this._internalAbstractMeshDataInfo._layerMask
},
set: function(t) {
t !== this._internalAbstractMeshDataInfo._layerMask && (this._internalAbstractMeshDataInfo._layerMask = t,
this._resyncLightSources())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "collisionMask", {
get: function() {
return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask
},
set: function(t) {
this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask = isNaN(t) ? -1 : t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "collisionResponse", {
get: function() {
return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse
},
set: function(t) {
this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "collisionGroup", {
get: function() {
return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup
},
set: function(t) {
this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup = isNaN(t) ? -1 : t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "surroundingMeshes", {
get: function() {
return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes
},
set: function(t) {
this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "lightSources", {
get: function() {
return this._lightSources
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "_positions", {
get: function() {
return null
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "skeleton", {
get: function() {
return this._internalAbstractMeshDataInfo._skeleton
},
set: function(t) {
var r = this._internalAbstractMeshDataInfo._skeleton;
r && r.needInitialSkinMatrix && r._unregisterMeshWithPoseMatrix(this),
t && t.needInitialSkinMatrix && t._registerMeshWithPoseMatrix(this),
this._internalAbstractMeshDataInfo._skeleton = t,
this._internalAbstractMeshDataInfo._skeleton || (this._bonesTransformMatrices = null),
this._markSubMeshesAsAttributesDirty()
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildUniformLayout = function() {
this._uniformBuffer.addUniform("world", 16),
this._uniformBuffer.addUniform("visibility", 1),
this._uniformBuffer.create()
}
,
e.prototype.transferToEffect = function(t) {
var r = this._uniformBuffer;
r.updateMatrix("world", t),
r.updateFloat("visibility", this._internalAbstractMeshDataInfo._visibility),
r.update()
}
,
e.prototype.getMeshUniformBuffer = function() {
return this._uniformBuffer
}
,
e.prototype.getClassName = function() {
return "AbstractMesh"
}
,
e.prototype.toString = function(t) {
var r = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
r += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
var n = this._internalAbstractMeshDataInfo._skeleton;
return n && (r += ", skeleton: " + n.name),
t && (r += ", billboard mode: " + ["NONE", "X", "Y", null, "Z", null, null, "ALL"][this.billboardMode],
r += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO")),
r
}
,
e.prototype._getEffectiveParent = function() {
return this._masterMesh && this.billboardMode !== TransformNode.BILLBOARDMODE_NONE ? this._masterMesh : i.prototype._getEffectiveParent.call(this)
}
,
e.prototype._getActionManagerForTrigger = function(t, r) {
if (r === void 0 && (r = !0),
this.actionManager && (r || this.actionManager.isRecursive))
if (t) {
if (this.actionManager.hasSpecificTrigger(t))
return this.actionManager
} else
return this.actionManager;
return this.parent ? this.parent._getActionManagerForTrigger(t, !1) : null
}
,
e.prototype._rebuild = function(t) {
if (this.onRebuildObservable.notifyObservers(this),
this._occlusionQuery !== null && (this._occlusionQuery = null),
!!this.subMeshes)
for (var r = 0, n = this.subMeshes; r < n.length; r++) {
var o = n[r];
o._rebuild()
}
}
,
e.prototype._resyncLightSources = function() {
this._lightSources.length = 0;
for (var t = 0, r = this.getScene().lights; t < r.length; t++) {
var n = r[t];
!n.isEnabled() || n.canAffectMesh(this) && this._lightSources.push(n)
}
this._markSubMeshesAsLightDirty()
}
,
e.prototype._resyncLightSource = function(t) {
var r = t.isEnabled() && t.canAffectMesh(this)
, n = this._lightSources.indexOf(t)
, o = !1;
if (n === -1) {
if (!r)
return;
this._lightSources.push(t)
} else {
if (r)
return;
o = !0,
this._lightSources.splice(n, 1)
}
this._markSubMeshesAsLightDirty(o)
}
,
e.prototype._unBindEffect = function() {
for (var t = 0, r = this.subMeshes; t < r.length; t++) {
var n = r[t];
n.setEffect(null)
}
}
,
e.prototype._removeLightSource = function(t, r) {
var n = this._lightSources.indexOf(t);
n !== -1 && (this._lightSources.splice(n, 1),
this._markSubMeshesAsLightDirty(r))
}
,
e.prototype._markSubMeshesAsDirty = function(t) {
if (!!this.subMeshes)
for (var r = 0, n = this.subMeshes; r < n.length; r++)
for (var o = n[r], a = 0; a < o._drawWrappers.length; ++a) {
var s = o._drawWrappers[a];
!s || !s.defines || !s.defines.markAllAsDirty || t(s.defines)
}
}
,
e.prototype._markSubMeshesAsLightDirty = function(t) {
t === void 0 && (t = !1),
this._markSubMeshesAsDirty(function(r) {
return r.markAsLightDirty(t)
})
}
,
e.prototype._markSubMeshesAsAttributesDirty = function() {
this._markSubMeshesAsDirty(function(t) {
return t.markAsAttributesDirty()
})
}
,
e.prototype._markSubMeshesAsMiscDirty = function() {
this._markSubMeshesAsDirty(function(t) {
return t.markAsMiscDirty()
})
}
,
e.prototype.markAsDirty = function(t) {
return this._currentRenderId = Number.MAX_VALUE,
this._isDirty = !0,
this
}
,
e.prototype.resetDrawCache = function() {
if (!!this.subMeshes)
for (var t = 0, r = this.subMeshes; t < r.length; t++) {
var n = r[t];
n.resetDrawCache()
}
}
,
Object.defineProperty(e.prototype, "scaling", {
get: function() {
return this._scaling
},
set: function(t) {
this._scaling = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isBlocked", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
e.prototype.getLOD = function(t) {
return this
}
,
e.prototype.getTotalVertices = function() {
return 0
}
,
e.prototype.getTotalIndices = function() {
return 0
}
,
e.prototype.getIndices = function() {
return null
}
,
e.prototype.getVerticesData = function(t) {
return null
}
,
e.prototype.setVerticesData = function(t, r, n, o) {
return this
}
,
e.prototype.updateVerticesData = function(t, r, n, o) {
return this
}
,
e.prototype.setIndices = function(t, r) {
return this
}
,
e.prototype.isVerticesDataPresent = function(t) {
return !1
}
,
e.prototype.getBoundingInfo = function() {
return this._masterMesh ? this._masterMesh.getBoundingInfo() : (this._boundingInfoIsDirty && (this._boundingInfoIsDirty = !1,
this._updateBoundingInfo()),
this._boundingInfo)
}
,
e.prototype.setBoundingInfo = function(t) {
return this._boundingInfo = t,
this
}
,
Object.defineProperty(e.prototype, "hasBoundingInfo", {
get: function() {
return this._boundingInfo !== null
},
enumerable: !1,
configurable: !0
}),
e.prototype.buildBoundingInfo = function(t, r, n) {
return this._boundingInfo = new BoundingInfo(t,r,n),
this._boundingInfo
}
,
e.prototype.normalizeToUnitCube = function(t, r, n) {
return t === void 0 && (t = !0),
r === void 0 && (r = !1),
i.prototype.normalizeToUnitCube.call(this, t, r, n)
}
,
Object.defineProperty(e.prototype, "useBones", {
get: function() {
return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)
},
enumerable: !1,
configurable: !0
}),
e.prototype._preActivate = function() {}
,
e.prototype._preActivateForIntermediateRendering = function(t) {}
,
e.prototype._activate = function(t, r) {
return this._renderId = t,
!0
}
,
e.prototype._postActivate = function() {}
,
e.prototype._freeze = function() {}
,
e.prototype._unFreeze = function() {}
,
e.prototype.getWorldMatrix = function() {
return this._masterMesh && this.billboardMode === TransformNode.BILLBOARDMODE_NONE ? this._masterMesh.getWorldMatrix() : i.prototype.getWorldMatrix.call(this)
}
,
e.prototype._getWorldMatrixDeterminant = function() {
return this._masterMesh ? this._masterMesh._getWorldMatrixDeterminant() : i.prototype._getWorldMatrixDeterminant.call(this)
}
,
Object.defineProperty(e.prototype, "isAnInstance", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "hasInstances", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "hasThinInstances", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
e.prototype.movePOV = function(t, r, n) {
return this.position.addInPlace(this.calcMovePOV(t, r, n)),
this
}
,
e.prototype.calcMovePOV = function(t, r, n) {
var o = new Matrix
, a = this.rotationQuaternion ? this.rotationQuaternion : Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
a.toRotationMatrix(o);
var s = Vector3.Zero()
, l = this.definedFacingForward ? -1 : 1;
return Vector3.TransformCoordinatesFromFloatsToRef(t * l, r, n * l, o, s),
s
}
,
e.prototype.rotatePOV = function(t, r, n) {
return this.rotation.addInPlace(this.calcRotatePOV(t, r, n)),
this
}
,
e.prototype.calcRotatePOV = function(t, r, n) {
var o = this.definedFacingForward ? 1 : -1;
return new Vector3(t * o,r,n * o)
}
,
e.prototype.refreshBoundingInfo = function(t, r) {
return t === void 0 && (t = !1),
r === void 0 && (r = !1),
this._boundingInfo && this._boundingInfo.isLocked ? this : (this._refreshBoundingInfo(this._getPositionData(t, r), null),
this)
}
,
e.prototype._refreshBoundingInfo = function(t, r) {
if (t) {
var n = extractMinAndMax(t, 0, this.getTotalVertices(), r);
this._boundingInfo ? this._boundingInfo.reConstruct(n.minimum, n.maximum) : this._boundingInfo = new BoundingInfo(n.minimum,n.maximum)
}
if (this.subMeshes)
for (var o = 0; o < this.subMeshes.length; o++)
this.subMeshes[o].refreshBoundingInfo(t);
this._updateBoundingInfo()
}
,
e.prototype._getPositionData = function(t, r) {
var n, o = this.getVerticesData(VertexBuffer.PositionKind);
if (this._internalAbstractMeshDataInfo._positions && (this._internalAbstractMeshDataInfo._positions = null),
o && (t && this.skeleton || r && this.morphTargetManager) && (o = Tools.Slice(o),
this._generatePointsArray(),
this._positions)) {
var a = this._positions;
this._internalAbstractMeshDataInfo._positions = new Array(a.length);
for (var s = 0; s < a.length; s++)
this._internalAbstractMeshDataInfo._positions[s] = ((n = a[s]) === null || n === void 0 ? void 0 : n.clone()) || new Vector3
}
if (o && r && this.morphTargetManager)
for (var l = 0, u = 0, c = 0; c < o.length; c++) {
for (var h = 0; h < this.morphTargetManager.numTargets; h++) {
var f = this.morphTargetManager.getTarget(h)
, d = f.influence;
if (d > 0) {
var _ = f.getPositions();
_ && (o[c] += (_[c] - o[c]) * d)
}
}
if (l++,
this._positions && l === 3) {
l = 0;
var g = u * 3;
this._positions[u++].copyFromFloats(o[g], o[g + 1], o[g + 2])
}
}
if (o && t && this.skeleton) {
var m = this.getVerticesData(VertexBuffer.MatricesIndicesKind)
, v = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
if (v && m) {
var y = this.numBoneInfluencers > 4
, b = y ? this.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null
, T = y ? this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;
this.skeleton.prepare();
for (var C = this.skeleton.getTransformMatrices(this), A = TmpVectors.Vector3[0], S = TmpVectors.Matrix[0], P = TmpVectors.Matrix[1], R = 0, M = 0; M < o.length; M += 3,
R += 4) {
S.reset();
var x, I;
for (x = 0; x < 4; x++)
I = v[R + x],
I > 0 && (Matrix.FromFloat32ArrayToRefScaled(C, Math.floor(m[R + x] * 16), I, P),
S.addToSelf(P));
if (y)
for (x = 0; x < 4; x++)
I = T[R + x],
I > 0 && (Matrix.FromFloat32ArrayToRefScaled(C, Math.floor(b[R + x] * 16), I, P),
S.addToSelf(P));
Vector3.TransformCoordinatesFromFloatsToRef(o[M], o[M + 1], o[M + 2], S, A),
A.toArray(o, M),
this._positions && this._positions[M / 3].copyFrom(A)
}
}
}
return o
}
,
e.prototype._updateBoundingInfo = function() {
var t = this._effectiveMesh;
return this._boundingInfo ? this._boundingInfo.update(t.worldMatrixFromCache) : this._boundingInfo = new BoundingInfo(this.position,this.position,t.worldMatrixFromCache),
this._updateSubMeshesBoundingInfo(t.worldMatrixFromCache),
this
}
,
e.prototype._updateSubMeshesBoundingInfo = function(t) {
if (!this.subMeshes)
return this;
for (var r = this.subMeshes.length, n = 0; n < r; n++) {
var o = this.subMeshes[n];
(r > 1 || !o.IsGlobal) && o.updateBoundingInfo(t)
}
return this
}
,
e.prototype._afterComputeWorldMatrix = function() {
this.doNotSyncBoundingInfo || (this._boundingInfoIsDirty = !0)
}
,
Object.defineProperty(e.prototype, "_effectiveMesh", {
get: function() {
return this.skeleton && this.skeleton.overrideMesh || this
},
enumerable: !1,
configurable: !0
}),
e.prototype.isInFrustum = function(t) {
return this.getBoundingInfo().isInFrustum(t, this.cullingStrategy)
}
,
e.prototype.isCompletelyInFrustum = function(t) {
return this.getBoundingInfo().isCompletelyInFrustum(t)
}
,
e.prototype.intersectsMesh = function(t, r, n) {
r === void 0 && (r = !1);
var o = this.getBoundingInfo()
, a = t.getBoundingInfo();
if (o.intersects(a, r))
return !0;
if (n)
for (var s = 0, l = this.getChildMeshes(); s < l.length; s++) {
var u = l[s];
if (u.intersectsMesh(t, r, !0))
return !0
}
return !1
}
,
e.prototype.intersectsPoint = function(t) {
return this.getBoundingInfo().intersectsPoint(t)
}
,
Object.defineProperty(e.prototype, "checkCollisions", {
get: function() {
return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions
},
set: function(t) {
this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "collider", {
get: function() {
return this._internalAbstractMeshDataInfo._meshCollisionData._collider
},
enumerable: !1,
configurable: !0
}),
e.prototype.moveWithCollisions = function(t) {
var r = this.getAbsolutePosition();
r.addToRef(this.ellipsoidOffset, this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);
var n = this.getScene().collisionCoordinator;
return this._internalAbstractMeshDataInfo._meshCollisionData._collider || (this._internalAbstractMeshDataInfo._meshCollisionData._collider = n.createCollider()),
this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius = this.ellipsoid,
n.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, t, this._internalAbstractMeshDataInfo._meshCollisionData._collider, this.collisionRetryCount, this, this._onCollisionPositionChange, this.uniqueId),
this
}
,
e.prototype._collideForSubMesh = function(t, r, n) {
if (this._generatePointsArray(),
!this._positions)
return this;
if (!t._lastColliderWorldVertices || !t._lastColliderTransformMatrix.equals(r)) {
t._lastColliderTransformMatrix = r.clone(),
t._lastColliderWorldVertices = [],
t._trianglePlanes = [];
for (var o = t.verticesStart, a = t.verticesStart + t.verticesCount, s = o; s < a; s++)
t._lastColliderWorldVertices.push(Vector3.TransformCoordinates(this._positions[s], r))
}
return n._collide(t._trianglePlanes, t._lastColliderWorldVertices, this.getIndices(), t.indexStart, t.indexStart + t.indexCount, t.verticesStart, !!t.getMaterial(), this),
this
}
,
e.prototype._processCollisionsForSubMeshes = function(t, r) {
for (var n = this._scene.getCollidingSubMeshCandidates(this, t), o = n.length, a = 0; a < o; a++) {
var s = n.data[a];
o > 1 && !s._checkCollision(t) || this._collideForSubMesh(s, r, t)
}
return this
}
,
e.prototype._checkCollision = function(t) {
if (!this.getBoundingInfo()._checkCollision(t))
return this;
var r = TmpVectors.Matrix[0]
, n = TmpVectors.Matrix[1];
return Matrix.ScalingToRef(1 / t._radius.x, 1 / t._radius.y, 1 / t._radius.z, r),
this.worldMatrixFromCache.multiplyToRef(r, n),
this._processCollisionsForSubMeshes(t, n),
this
}
,
e.prototype._generatePointsArray = function() {
return !1
}
,
e.prototype.intersects = function(t, r, n, o, a, s) {
o === void 0 && (o = !1),
s === void 0 && (s = !1);
var l = new PickingInfo
, u = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0
, c = this.getBoundingInfo();
if (!this.subMeshes || !s && (!t.intersectsSphere(c.boundingSphere, u) || !t.intersectsBox(c.boundingBox, u)))
return l;
if (o)
return l.hit = !s,
l.pickedMesh = s ? null : this,
l.distance = s ? 0 : Vector3.Distance(t.origin, c.boundingSphere.center),
l.subMeshId = 0,
l;
if (!this._generatePointsArray())
return l;
for (var h = null, f = this._scene.getIntersectingSubMeshCandidates(this, t), d = f.length, _ = !1, g = 0; g < d; g++) {
var m = f.data[g]
, v = m.getMaterial();
if (!!v && (v.fillMode == 7 || v.fillMode == 0 || v.fillMode == 1 || v.fillMode == 2)) {
_ = !0;
break
}
}
if (!_)
return l.hit = !0,
l.pickedMesh = this,
l.distance = Vector3.Distance(t.origin, c.boundingSphere.center),
l.subMeshId = -1,
l;
for (var g = 0; g < d; g++) {
var m = f.data[g];
if (!(d > 1 && !m.canIntersects(t))) {
var y = m.intersects(t, this._positions, this.getIndices(), r, n);
if (y && (r || !h || y.distance < h.distance) && (h = y,
h.subMeshId = g,
r))
break
}
}
if (h) {
var b = a != null ? a : this.skeleton && this.skeleton.overrideMesh ? this.skeleton.overrideMesh.getWorldMatrix() : this.getWorldMatrix()
, T = TmpVectors.Vector3[0]
, C = TmpVectors.Vector3[1];
Vector3.TransformCoordinatesToRef(t.origin, b, T),
t.direction.scaleToRef(h.distance, C);
var A = Vector3.TransformNormal(C, b)
, S = A.addInPlace(T);
return l.hit = !0,
l.distance = Vector3.Distance(T, S),
l.pickedPoint = S,
l.pickedMesh = this,
l.bu = h.bu || 0,
l.bv = h.bv || 0,
l.subMeshFaceId = h.faceId,
l.faceId = h.faceId + f.data[h.subMeshId].indexStart / (this.getClassName().indexOf("LinesMesh") !== -1 ? 2 : 3),
l.subMeshId = h.subMeshId,
l
}
return l
}
,
e.prototype.clone = function(t, r, n) {
return null
}
,
e.prototype.releaseSubMeshes = function() {
if (this.subMeshes)
for (; this.subMeshes.length; )
this.subMeshes[0].dispose();
else
this.subMeshes = new Array;
return this
}
,
e.prototype.dispose = function(t, r) {
var n = this;
r === void 0 && (r = !1);
var o;
for (this._scene.useMaterialMeshMap && this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
this.getScene().freeActiveMeshes(),
this.getScene().freeRenderingGroups(),
this.actionManager !== void 0 && this.actionManager !== null && (this.actionManager.dispose(),
this.actionManager = null),
this._internalAbstractMeshDataInfo._skeleton = null,
this._transformMatrixTexture && (this._transformMatrixTexture.dispose(),
this._transformMatrixTexture = null),
o = 0; o < this._intersectionsInProgress.length; o++) {
var a = this._intersectionsInProgress[o]
, s = a._intersectionsInProgress.indexOf(this);
a._intersectionsInProgress.splice(s, 1)
}
this._intersectionsInProgress = [];
var l = this.getScene().lights;
l.forEach(function(h) {
var f = h.includedOnlyMeshes.indexOf(n);
f !== -1 && h.includedOnlyMeshes.splice(f, 1),
f = h.excludedMeshes.indexOf(n),
f !== -1 && h.excludedMeshes.splice(f, 1);
var d = h.getShadowGenerator();
if (d) {
var _ = d.getShadowMap();
_ && _.renderList && (f = _.renderList.indexOf(n),
f !== -1 && _.renderList.splice(f, 1))
}
}),
(this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") && this.releaseSubMeshes();
var u = this.getScene().getEngine();
if (this._occlusionQuery !== null && (this.isOcclusionQueryInProgress = !1,
u.deleteQuery(this._occlusionQuery),
this._occlusionQuery = null),
u.wipeCaches(),
this.getScene().removeMesh(this),
this._parentContainer) {
var c = this._parentContainer.meshes.indexOf(this);
c > -1 && this._parentContainer.meshes.splice(c, 1),
this._parentContainer = null
}
if (r && this.material && (this.material.getClassName() === "MultiMaterial" ? this.material.dispose(!1, !0, !0) : this.material.dispose(!1, !0)),
!t)
for (o = 0; o < this.getScene().particleSystems.length; o++)
this.getScene().particleSystems[o].emitter === this && (this.getScene().particleSystems[o].dispose(),
o--);
this._internalAbstractMeshDataInfo._facetData.facetDataEnabled && this.disableFacetData(),
this._uniformBuffer.dispose(),
this.onAfterWorldMatrixUpdateObservable.clear(),
this.onCollideObservable.clear(),
this.onCollisionPositionChangeObservable.clear(),
this.onRebuildObservable.clear(),
i.prototype.dispose.call(this, t, r)
}
,
e.prototype.addChild = function(t, r) {
return r === void 0 && (r = !1),
t.setParent(this, r),
this
}
,
e.prototype.removeChild = function(t, r) {
return r === void 0 && (r = !1),
t.setParent(null, r),
this
}
,
e.prototype._initFacetData = function() {
var t = this._internalAbstractMeshDataInfo._facetData;
t.facetNormals || (t.facetNormals = new Array),
t.facetPositions || (t.facetPositions = new Array),
t.facetPartitioning || (t.facetPartitioning = new Array),
t.facetNb = this.getIndices().length / 3 | 0,
t.partitioningSubdivisions = t.partitioningSubdivisions ? t.partitioningSubdivisions : 10,
t.partitioningBBoxRatio = t.partitioningBBoxRatio ? t.partitioningBBoxRatio : 1.01;
for (var r = 0; r < t.facetNb; r++)
t.facetNormals[r] = Vector3.Zero(),
t.facetPositions[r] = Vector3.Zero();
return t.facetDataEnabled = !0,
this
}
,
e.prototype.updateFacetData = function() {
var t = this._internalAbstractMeshDataInfo._facetData;
t.facetDataEnabled || this._initFacetData();
var r = this.getVerticesData(VertexBuffer.PositionKind)
, n = this.getIndices()
, o = this.getVerticesData(VertexBuffer.NormalKind)
, a = this.getBoundingInfo();
if (t.facetDepthSort && !t.facetDepthSortEnabled) {
if (t.facetDepthSortEnabled = !0,
n instanceof Uint16Array)
t.depthSortedIndices = new Uint16Array(n);
else if (n instanceof Uint32Array)
t.depthSortedIndices = new Uint32Array(n);
else {
for (var s = !1, l = 0; l < n.length; l++)
if (n[l] > 65535) {
s = !0;
break
}
s ? t.depthSortedIndices = new Uint32Array(n) : t.depthSortedIndices = new Uint16Array(n)
}
if (t.facetDepthSortFunction = function(g, m) {
return m.sqDistance - g.sqDistance
}
,
!t.facetDepthSortFrom) {
var u = this.getScene().activeCamera;
t.facetDepthSortFrom = u ? u.position : Vector3.Zero()
}
t.depthSortedFacets = [];
for (var c = 0; c < t.facetNb; c++) {
var h = {
ind: c * 3,
sqDistance: 0
};
t.depthSortedFacets.push(h)
}
t.invertedMatrix = Matrix.Identity(),
t.facetDepthSortOrigin = Vector3.Zero()
}
t.bbSize.x = a.maximum.x - a.minimum.x > Epsilon ? a.maximum.x - a.minimum.x : Epsilon,
t.bbSize.y = a.maximum.y - a.minimum.y > Epsilon ? a.maximum.y - a.minimum.y : Epsilon,
t.bbSize.z = a.maximum.z - a.minimum.z > Epsilon ? a.maximum.z - a.minimum.z : Epsilon;
var f = t.bbSize.x > t.bbSize.y ? t.bbSize.x : t.bbSize.y;
if (f = f > t.bbSize.z ? f : t.bbSize.z,
t.subDiv.max = t.partitioningSubdivisions,
t.subDiv.X = Math.floor(t.subDiv.max * t.bbSize.x / f),
t.subDiv.Y = Math.floor(t.subDiv.max * t.bbSize.y / f),
t.subDiv.Z = Math.floor(t.subDiv.max * t.bbSize.z / f),
t.subDiv.X = t.subDiv.X < 1 ? 1 : t.subDiv.X,
t.subDiv.Y = t.subDiv.Y < 1 ? 1 : t.subDiv.Y,
t.subDiv.Z = t.subDiv.Z < 1 ? 1 : t.subDiv.Z,
t.facetParameters.facetNormals = this.getFacetLocalNormals(),
t.facetParameters.facetPositions = this.getFacetLocalPositions(),
t.facetParameters.facetPartitioning = this.getFacetLocalPartitioning(),
t.facetParameters.bInfo = a,
t.facetParameters.bbSize = t.bbSize,
t.facetParameters.subDiv = t.subDiv,
t.facetParameters.ratio = this.partitioningBBoxRatio,
t.facetParameters.depthSort = t.facetDepthSort,
t.facetDepthSort && t.facetDepthSortEnabled && (this.computeWorldMatrix(!0),
this._worldMatrix.invertToRef(t.invertedMatrix),
Vector3.TransformCoordinatesToRef(t.facetDepthSortFrom, t.invertedMatrix, t.facetDepthSortOrigin),
t.facetParameters.distanceTo = t.facetDepthSortOrigin),
t.facetParameters.depthSortedFacets = t.depthSortedFacets,
o && VertexData.ComputeNormals(r, n, o, t.facetParameters),
t.facetDepthSort && t.facetDepthSortEnabled) {
t.depthSortedFacets.sort(t.facetDepthSortFunction);
for (var d = t.depthSortedIndices.length / 3 | 0, c = 0; c < d; c++) {
var _ = t.depthSortedFacets[c].ind;
t.depthSortedIndices[c * 3] = n[_],
t.depthSortedIndices[c * 3 + 1] = n[_ + 1],
t.depthSortedIndices[c * 3 + 2] = n[_ + 2]
}
this.updateIndices(t.depthSortedIndices, void 0, !0)
}
return this
}
,
e.prototype.getFacetLocalNormals = function() {
var t = this._internalAbstractMeshDataInfo._facetData;
return t.facetNormals || this.updateFacetData(),
t.facetNormals
}
,
e.prototype.getFacetLocalPositions = function() {
var t = this._internalAbstractMeshDataInfo._facetData;
return t.facetPositions || this.updateFacetData(),
t.facetPositions
}
,
e.prototype.getFacetLocalPartitioning = function() {
var t = this._internalAbstractMeshDataInfo._facetData;
return t.facetPartitioning || this.updateFacetData(),
t.facetPartitioning
}
,
e.prototype.getFacetPosition = function(t) {
var r = Vector3.Zero();
return this.getFacetPositionToRef(t, r),
r
}
,
e.prototype.getFacetPositionToRef = function(t, r) {
var n = this.getFacetLocalPositions()[t]
, o = this.getWorldMatrix();
return Vector3.TransformCoordinatesToRef(n, o, r),
this
}
,
e.prototype.getFacetNormal = function(t) {
var r = Vector3.Zero();
return this.getFacetNormalToRef(t, r),
r
}
,
e.prototype.getFacetNormalToRef = function(t, r) {
var n = this.getFacetLocalNormals()[t];
return Vector3.TransformNormalToRef(n, this.getWorldMatrix(), r),
this
}
,
e.prototype.getFacetsAtLocalCoordinates = function(t, r, n) {
var o = this.getBoundingInfo()
, a = this._internalAbstractMeshDataInfo._facetData
, s = Math.floor((t - o.minimum.x * a.partitioningBBoxRatio) * a.subDiv.X * a.partitioningBBoxRatio / a.bbSize.x)
, l = Math.floor((r - o.minimum.y * a.partitioningBBoxRatio) * a.subDiv.Y * a.partitioningBBoxRatio / a.bbSize.y)
, u = Math.floor((n - o.minimum.z * a.partitioningBBoxRatio) * a.subDiv.Z * a.partitioningBBoxRatio / a.bbSize.z);
return s < 0 || s > a.subDiv.max || l < 0 || l > a.subDiv.max || u < 0 || u > a.subDiv.max ? null : a.facetPartitioning[s + a.subDiv.max * l + a.subDiv.max * a.subDiv.max * u]
}
,
e.prototype.getClosestFacetAtCoordinates = function(t, r, n, o, a, s) {
a === void 0 && (a = !1),
s === void 0 && (s = !0);
var l = this.getWorldMatrix()
, u = TmpVectors.Matrix[5];
l.invertToRef(u);
var c = TmpVectors.Vector3[8];
Vector3.TransformCoordinatesFromFloatsToRef(t, r, n, u, c);
var h = this.getClosestFacetAtLocalCoordinates(c.x, c.y, c.z, o, a, s);
return o && Vector3.TransformCoordinatesFromFloatsToRef(o.x, o.y, o.z, l, o),
h
}
,
e.prototype.getClosestFacetAtLocalCoordinates = function(t, r, n, o, a, s) {
a === void 0 && (a = !1),
s === void 0 && (s = !0);
var l = null
, u = 0
, c = 0
, h = 0
, f = 0
, d = 0
, _ = 0
, g = 0
, m = 0
, v = this.getFacetLocalPositions()
, y = this.getFacetLocalNormals()
, b = this.getFacetsAtLocalCoordinates(t, r, n);
if (!b)
return null;
for (var T = Number.MAX_VALUE, C = T, A, S, P, R = 0; R < b.length; R++)
A = b[R],
S = y[A],
P = v[A],
f = (t - P.x) * S.x + (r - P.y) * S.y + (n - P.z) * S.z,
(!a || a && s && f >= 0 || a && !s && f <= 0) && (f = S.x * P.x + S.y * P.y + S.z * P.z,
d = -(S.x * t + S.y * r + S.z * n - f) / (S.x * S.x + S.y * S.y + S.z * S.z),
_ = t + S.x * d,
g = r + S.y * d,
m = n + S.z * d,
u = _ - t,
c = g - r,
h = m - n,
C = u * u + c * c + h * h,
C < T && (T = C,
l = A,
o && (o.x = _,
o.y = g,
o.z = m)));
return l
}
,
e.prototype.getFacetDataParameters = function() {
return this._internalAbstractMeshDataInfo._facetData.facetParameters
}
,
e.prototype.disableFacetData = function() {
var t = this._internalAbstractMeshDataInfo._facetData;
return t.facetDataEnabled && (t.facetDataEnabled = !1,
t.facetPositions = new Array,
t.facetNormals = new Array,
t.facetPartitioning = new Array,
t.facetParameters = null,
t.depthSortedIndices = new Uint32Array(0)),
this
}
,
e.prototype.updateIndices = function(t, r, n) {
return this
}
,
e.prototype.createNormals = function(t) {
var r = this.getVerticesData(VertexBuffer.PositionKind), n = this.getIndices(), o;
return this.isVerticesDataPresent(VertexBuffer.NormalKind) ? o = this.getVerticesData(VertexBuffer.NormalKind) : o = [],
VertexData.ComputeNormals(r, n, o, {
useRightHandedSystem: this.getScene().useRightHandedSystem
}),
this.setVerticesData(VertexBuffer.NormalKind, o, t),
this
}
,
e.prototype.alignWithNormal = function(t, r) {
r || (r = Axis.Y);
var n = TmpVectors.Vector3[0]
, o = TmpVectors.Vector3[1];
return Vector3.CrossToRef(r, t, o),
Vector3.CrossToRef(t, o, n),
this.rotationQuaternion ? Quaternion.RotationQuaternionFromAxisToRef(n, t, o, this.rotationQuaternion) : Vector3.RotationFromAxisToRef(n, t, o, this.rotation),
this
}
,
e.prototype._checkOcclusionQuery = function() {
return !1
}
,
e.prototype.disableEdgesRendering = function() {
throw _WarnImport("EdgesRenderer")
}
,
e.prototype.enableEdgesRendering = function(t, r, n) {
throw _WarnImport("EdgesRenderer")
}
,
e.prototype.getConnectedParticleSystems = function() {
var t = this;
return this._scene.particleSystems.filter(function(r) {
return r.emitter === t
})
}
,
e.OCCLUSION_TYPE_NONE = 0,
e.OCCLUSION_TYPE_OPTIMISTIC = 1,
e.OCCLUSION_TYPE_STRICT = 2,
e.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0,
e.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1,
e.CULLINGSTRATEGY_STANDARD = 0,
e.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1,
e.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2,
e.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3,
e
}(TransformNode);
RegisterClass("BABYLON.AbstractMesh", AbstractMesh);
var Viewport = function() {
function i(e, t, r, n) {
this.x = e,
this.y = t,
this.width = r,
this.height = n
}
return i.prototype.toGlobal = function(e, t) {
return new i(this.x * e,this.y * t,this.width * e,this.height * t)
}
,
i.prototype.toGlobalToRef = function(e, t, r) {
return r.x = this.x * e,
r.y = this.y * t,
r.width = this.width * e,
r.height = this.height * t,
this
}
,
i.prototype.clone = function() {
return new i(this.x,this.y,this.width,this.height)
}
,
i
}()
, Camera$1 = function(i) {
__extends(e, i);
function e(t, r, n, o) {
o === void 0 && (o = !0);
var a = i.call(this, t, n) || this;
return a._position = Vector3.Zero(),
a._upVector = Vector3.Up(),
a.orthoLeft = null,
a.orthoRight = null,
a.orthoBottom = null,
a.orthoTop = null,
a.fov = .8,
a.projectionPlaneTilt = 0,
a.minZ = 1,
a.maxZ = 1e4,
a.inertia = .9,
a.mode = e.PERSPECTIVE_CAMERA,
a.isIntermediate = !1,
a.viewport = new Viewport(0,0,1,1),
a.layerMask = 268435455,
a.fovMode = e.FOVMODE_VERTICAL_FIXED,
a.cameraRigMode = e.RIG_MODE_NONE,
a.customRenderTargets = new Array,
a.outputRenderTarget = null,
a.onViewMatrixChangedObservable = new Observable,
a.onProjectionMatrixChangedObservable = new Observable,
a.onAfterCheckInputsObservable = new Observable,
a.onRestoreStateObservable = new Observable,
a.isRigCamera = !1,
a._rigCameras = new Array,
a._webvrViewMatrix = Matrix.Identity(),
a._skipRendering = !1,
a._projectionMatrix = new Matrix,
a._postProcesses = new Array,
a._activeMeshes = new SmartArray(256),
a._globalPosition = Vector3.Zero(),
a._computedViewMatrix = Matrix.Identity(),
a._doNotComputeProjectionMatrix = !1,
a._transformMatrix = Matrix.Zero(),
a._refreshFrustumPlanes = !0,
a._absoluteRotation = Quaternion.Identity(),
a._isCamera = !0,
a._isLeftCamera = !1,
a._isRightCamera = !1,
a.getScene().addCamera(a),
o && !a.getScene().activeCamera && (a.getScene().activeCamera = a),
a.position = r,
a.renderPassId = a.getScene().getEngine().createRenderPassId("Camera " + t),
a
}
return Object.defineProperty(e.prototype, "position", {
get: function() {
return this._position
},
set: function(t) {
this._position = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "upVector", {
get: function() {
return this._upVector
},
set: function(t) {
this._upVector = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "screenArea", {
get: function() {
var t, r, n, o, a = 0, s = 0;
if (this.mode === e.PERSPECTIVE_CAMERA)
this.fovMode === e.FOVMODE_VERTICAL_FIXED ? (s = this.minZ * 2 * Math.tan(this.fov / 2),
a = this.getEngine().getAspectRatio(this) * s) : (a = this.minZ * 2 * Math.tan(this.fov / 2),
s = a / this.getEngine().getAspectRatio(this));
else {
var l = this.getEngine().getRenderWidth() / 2
, u = this.getEngine().getRenderHeight() / 2;
a = ((t = this.orthoRight) !== null && t !== void 0 ? t : l) - ((r = this.orthoLeft) !== null && r !== void 0 ? r : -l),
s = ((n = this.orthoTop) !== null && n !== void 0 ? n : u) - ((o = this.orthoBottom) !== null && o !== void 0 ? o : -u)
}
return a * s
},
enumerable: !1,
configurable: !0
}),
e.prototype.storeState = function() {
return this._stateStored = !0,
this._storedFov = this.fov,
this
}
,
e.prototype._restoreStateValues = function() {
return this._stateStored ? (this.fov = this._storedFov,
!0) : !1
}
,
e.prototype.restoreState = function() {
return this._restoreStateValues() ? (this.onRestoreStateObservable.notifyObservers(this),
!0) : !1
}
,
e.prototype.getClassName = function() {
return "Camera"
}
,
e.prototype.toString = function(t) {
var r = "Name: " + this.name;
if (r += ", type: " + this.getClassName(),
this.animations)
for (var n = 0; n < this.animations.length; n++)
r += ", animation[0]: " + this.animations[n].toString(t);
return r
}
,
e.prototype.applyVerticalCorrection = function() {
var t = this.absoluteRotation.toEulerAngles();
this.projectionPlaneTilt = this._scene.useRightHandedSystem ? -t.x : t.x
}
,
Object.defineProperty(e.prototype, "globalPosition", {
get: function() {
return this._globalPosition
},
enumerable: !1,
configurable: !0
}),
e.prototype.getActiveMeshes = function() {
return this._activeMeshes
}
,
e.prototype.isActiveMesh = function(t) {
return this._activeMeshes.indexOf(t) !== -1
}
,
e.prototype.isReady = function(t) {
if (t === void 0 && (t = !1),
t)
for (var r = 0, n = this._postProcesses; r < n.length; r++) {
var o = n[r];
if (o && !o.isReady())
return !1
}
return i.prototype.isReady.call(this, t)
}
,
e.prototype._initCache = function() {
i.prototype._initCache.call(this),
this._cache.position = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._cache.upVector = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._cache.mode = void 0,
this._cache.minZ = void 0,
this._cache.maxZ = void 0,
this._cache.fov = void 0,
this._cache.fovMode = void 0,
this._cache.aspectRatio = void 0,
this._cache.orthoLeft = void 0,
this._cache.orthoRight = void 0,
this._cache.orthoBottom = void 0,
this._cache.orthoTop = void 0,
this._cache.renderWidth = void 0,
this._cache.renderHeight = void 0
}
,
e.prototype._updateCache = function(t) {
t || i.prototype._updateCache.call(this),
this._cache.position.copyFrom(this.position),
this._cache.upVector.copyFrom(this.upVector)
}
,
e.prototype._isSynchronized = function() {
return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix()
}
,
e.prototype._isSynchronizedViewMatrix = function() {
return i.prototype._isSynchronized.call(this) ? this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent() : !1
}
,
e.prototype._isSynchronizedProjectionMatrix = function() {
var t = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
if (!t)
return !1;
var r = this.getEngine();
return this.mode === e.PERSPECTIVE_CAMERA ? t = this._cache.fov === this.fov && this._cache.fovMode === this.fovMode && this._cache.aspectRatio === r.getAspectRatio(this) && this._cache.projectionPlaneTilt === this.projectionPlaneTilt : t = this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === r.getRenderWidth() && this._cache.renderHeight === r.getRenderHeight(),
t
}
,
e.prototype.attachControl = function(t, r) {}
,
e.prototype.detachControl = function(t) {}
,
e.prototype.update = function() {
this._checkInputs(),
this.cameraRigMode !== e.RIG_MODE_NONE && this._updateRigCameras()
}
,
e.prototype._checkInputs = function() {
this.onAfterCheckInputsObservable.notifyObservers(this)
}
,
Object.defineProperty(e.prototype, "rigCameras", {
get: function() {
return this._rigCameras
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rigPostProcess", {
get: function() {
return this._rigPostProcess
},
enumerable: !1,
configurable: !0
}),
e.prototype._getFirstPostProcess = function() {
for (var t = 0; t < this._postProcesses.length; t++)
if (this._postProcesses[t] !== null)
return this._postProcesses[t];
return null
}
,
e.prototype._cascadePostProcessesToRigCams = function() {
var t = this._getFirstPostProcess();
t && t.markTextureDirty();
for (var r = 0, n = this._rigCameras.length; r < n; r++) {
var o = this._rigCameras[r]
, a = o._rigPostProcess;
if (a) {
var s = a.getEffectName() === "pass";
s && (o.isIntermediate = this._postProcesses.length === 0),
o._postProcesses = this._postProcesses.slice(0).concat(a),
a.markTextureDirty()
} else
o._postProcesses = this._postProcesses.slice(0)
}
}
,
e.prototype.attachPostProcess = function(t, r) {
return r === void 0 && (r = null),
!t.isReusable() && this._postProcesses.indexOf(t) > -1 ? (Logger$2.Error("You're trying to reuse a post process not defined as reusable."),
0) : (r == null || r < 0 ? this._postProcesses.push(t) : this._postProcesses[r] === null ? this._postProcesses[r] = t : this._postProcesses.splice(r, 0, t),
this._cascadePostProcessesToRigCams(),
this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
this._postProcesses.indexOf(t))
}
,
e.prototype.detachPostProcess = function(t) {
var r = this._postProcesses.indexOf(t);
r !== -1 && (this._postProcesses[r] = null),
this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
this._cascadePostProcessesToRigCams()
}
,
e.prototype.getWorldMatrix = function() {
return this._isSynchronizedViewMatrix() ? this._worldMatrix : (this.getViewMatrix(),
this._worldMatrix)
}
,
e.prototype._getViewMatrix = function() {
return Matrix.Identity()
}
,
e.prototype.getViewMatrix = function(t) {
return !t && this._isSynchronizedViewMatrix() ? this._computedViewMatrix : (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)
}
,
e.prototype.freezeProjectionMatrix = function(t) {
this._doNotComputeProjectionMatrix = !0,
t !== void 0 && (this._projectionMatrix = t)
}
,
e.prototype.unfreezeProjectionMatrix = function() {
this._doNotComputeProjectionMatrix = !1
}
,
e.prototype.getProjectionMatrix = function(t) {
var r, n, o, a, s, l, u, c;
if (this._doNotComputeProjectionMatrix || !t && 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()
, f = this.getScene();
if (this.mode === e.PERSPECTIVE_CAMERA) {
this._cache.fov = this.fov,
this._cache.fovMode = this.fovMode,
this._cache.aspectRatio = h.getAspectRatio(this),
this._cache.projectionPlaneTilt = this.projectionPlaneTilt,
this.minZ <= 0 && (this.minZ = .1);
var d = h.useReverseDepthBuffer
, _ = void 0;
f.useRightHandedSystem ? _ = Matrix.PerspectiveFovRHToRef : _ = Matrix.PerspectiveFovLHToRef,
_(this.fov, h.getAspectRatio(this), d ? this.maxZ : this.minZ, d ? this.minZ : this.maxZ, this._projectionMatrix, this.fovMode === e.FOVMODE_VERTICAL_FIXED, h.isNDCHalfZRange, this.projectionPlaneTilt, h.useReverseDepthBuffer)
} else {
var g = h.getRenderWidth() / 2
, m = h.getRenderHeight() / 2;
f.useRightHandedSystem ? Matrix.OrthoOffCenterRHToRef((r = this.orthoLeft) !== null && r !== void 0 ? r : -g, (n = this.orthoRight) !== null && n !== void 0 ? n : g, (o = this.orthoBottom) !== null && o !== void 0 ? o : -m, (a = this.orthoTop) !== null && a !== void 0 ? a : m, this.minZ, this.maxZ, this._projectionMatrix, h.isNDCHalfZRange) : Matrix.OrthoOffCenterLHToRef((s = this.orthoLeft) !== null && s !== void 0 ? s : -g, (l = this.orthoRight) !== null && l !== void 0 ? l : g, (u = this.orthoBottom) !== null && u !== void 0 ? u : -m, (c = this.orthoTop) !== null && c !== void 0 ? c : m, this.minZ, this.maxZ, this._projectionMatrix, h.isNDCHalfZRange),
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
}
,
e.prototype.getTransformationMatrix = function() {
return this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
this._transformMatrix
}
,
e.prototype._updateFrustumPlanes = function() {
!this._refreshFrustumPlanes || (this.getTransformationMatrix(),
this._frustumPlanes ? Frustum.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = Frustum.GetPlanes(this._transformMatrix),
this._refreshFrustumPlanes = !1)
}
,
e.prototype.isInFrustum = function(t, r) {
if (r === void 0 && (r = !1),
this._updateFrustumPlanes(),
r && this.rigCameras.length > 0) {
var n = !1;
return this.rigCameras.forEach(function(o) {
o._updateFrustumPlanes(),
n = n || t.isInFrustum(o._frustumPlanes)
}),
n
} else
return t.isInFrustum(this._frustumPlanes)
}
,
e.prototype.isCompletelyInFrustum = function(t) {
return this._updateFrustumPlanes(),
t.isCompletelyInFrustum(this._frustumPlanes)
}
,
e.prototype.getForwardRay = function(t, r, n) {
throw _WarnImport("Ray")
}
,
e.prototype.getForwardRayToRef = function(t, r, n, o) {
throw _WarnImport("Ray")
}
,
e.prototype.dispose = function(t, r) {
for (r === void 0 && (r = !1),
this.onViewMatrixChangedObservable.clear(),
this.onProjectionMatrixChangedObservable.clear(),
this.onAfterCheckInputsObservable.clear(),
this.onRestoreStateObservable.clear(),
this.inputs && this.inputs.clear(),
this.getScene().stopAnimation(this),
this.getScene().removeCamera(this); this._rigCameras.length > 0; ) {
var n = this._rigCameras.pop();
n && n.dispose()
}
if (this._parentContainer) {
var o = this._parentContainer.cameras.indexOf(this);
o > -1 && this._parentContainer.cameras.splice(o, 1),
this._parentContainer = null
}
if (this._rigPostProcess)
this._rigPostProcess.dispose(this),
this._rigPostProcess = null,
this._postProcesses = [];
else if (this.cameraRigMode !== e.RIG_MODE_NONE)
this._rigPostProcess = null,
this._postProcesses = [];
else
for (var s = this._postProcesses.length; --s >= 0; ) {
var a = this._postProcesses[s];
a && a.dispose(this)
}
for (var s = this.customRenderTargets.length; --s >= 0; )
this.customRenderTargets[s].dispose();
this.customRenderTargets = [],
this._activeMeshes.dispose(),
this.getScene().getEngine().releaseRenderPassId(this.renderPassId),
i.prototype.dispose.call(this, t, r)
}
,
Object.defineProperty(e.prototype, "isLeftCamera", {
get: function() {
return this._isLeftCamera
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isRightCamera", {
get: function() {
return this._isRightCamera
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "leftCamera", {
get: function() {
return this._rigCameras.length < 1 ? null : this._rigCameras[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rightCamera", {
get: function() {
return this._rigCameras.length < 2 ? null : this._rigCameras[1]
},
enumerable: !1,
configurable: !0
}),
e.prototype.getLeftTarget = function() {
return this._rigCameras.length < 1 ? null : this._rigCameras[0].getTarget()
}
,
e.prototype.getRightTarget = function() {
return this._rigCameras.length < 2 ? null : this._rigCameras[1].getTarget()
}
,
e.prototype.setCameraRigMode = function(t, r) {
if (this.cameraRigMode !== t) {
for (; this._rigCameras.length > 0; ) {
var n = this._rigCameras.pop();
n && n.dispose()
}
if (this.cameraRigMode = t,
this._cameraRigParams = {},
this._cameraRigParams.interaxialDistance = r.interaxialDistance || .0637,
this._cameraRigParams.stereoHalfAngle = Tools.ToRadians(this._cameraRigParams.interaxialDistance / .0637),
this.cameraRigMode !== e.RIG_MODE_NONE) {
var o = this.createRigCamera(this.name + "_L", 0);
o && (o._isLeftCamera = !0);
var a = this.createRigCamera(this.name + "_R", 1);
a && (a._isRightCamera = !0),
o && a && (this._rigCameras.push(o),
this._rigCameras.push(a))
}
this._setRigMode(r),
this._cascadePostProcessesToRigCams(),
this.update()
}
}
,
e.prototype._setRigMode = function(t) {}
,
e.prototype._getVRProjectionMatrix = function() {
return Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix, !0, this.getEngine().isNDCHalfZRange),
this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix),
this._projectionMatrix
}
,
e.prototype._updateCameraRotationMatrix = function() {}
,
e.prototype._updateWebVRCameraRotationMatrix = function() {}
,
e.prototype._getWebVRProjectionMatrix = function() {
return Matrix.Identity()
}
,
e.prototype._getWebVRViewMatrix = function() {
return Matrix.Identity()
}
,
e.prototype.setCameraRigParameter = function(t, r) {
this._cameraRigParams || (this._cameraRigParams = {}),
this._cameraRigParams[t] = r,
t === "interaxialDistance" && (this._cameraRigParams.stereoHalfAngle = Tools.ToRadians(r / .0637))
}
,
e.prototype.createRigCamera = function(t, r) {
return null
}
,
e.prototype._updateRigCameras = function() {
for (var t = 0; t < this._rigCameras.length; t++)
this._rigCameras[t].minZ = this.minZ,
this._rigCameras[t].maxZ = this.maxZ,
this._rigCameras[t].fov = this.fov,
this._rigCameras[t].upVector.copyFrom(this.upVector);
this.cameraRigMode === e.RIG_MODE_STEREOSCOPIC_ANAGLYPH && (this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport)
}
,
e.prototype._setupInputs = function() {}
,
e.prototype.serialize = function() {
var t = SerializationHelper.Serialize(this);
return t.uniqueId = this.uniqueId,
t.type = this.getClassName(),
this.parent && (t.parentId = this.parent.uniqueId),
this.inputs && this.inputs.serialize(t),
SerializationHelper.AppendSerializedAnimations(this, t),
t.ranges = this.serializeAnimationRanges(),
t.isEnabled = this.isEnabled(),
t
}
,
e.prototype.clone = function(t) {
var r = SerializationHelper.Clone(e.GetConstructorFromName(this.getClassName(), t, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
return r.name = t,
this.onClonedObservable.notifyObservers(r),
r
}
,
e.prototype.getDirection = function(t) {
var r = Vector3.Zero();
return this.getDirectionToRef(t, r),
r
}
,
Object.defineProperty(e.prototype, "absoluteRotation", {
get: function() {
return this.getWorldMatrix().decompose(void 0, this._absoluteRotation),
this._absoluteRotation
},
enumerable: !1,
configurable: !0
}),
e.prototype.getDirectionToRef = function(t, r) {
Vector3.TransformNormalToRef(t, this.getWorldMatrix(), r)
}
,
e.GetConstructorFromName = function(t, r, n, o, a) {
o === void 0 && (o = 0),
a === void 0 && (a = !0);
var s = Node$2.Construct(t, r, n, {
interaxial_distance: o,
isStereoscopicSideBySide: a
});
return s || function() {
return e._createDefaultParsedCamera(r, n)
}
}
,
e.prototype.computeWorldMatrix = function() {
return this.getWorldMatrix()
}
,
e.Parse = function(t, r) {
var n = t.type
, o = e.GetConstructorFromName(n, t.name, r, t.interaxial_distance, t.isStereoscopicSideBySide)
, a = SerializationHelper.Parse(o, t, r);
if (t.parentId && (a._waitingParentId = t.parentId),
a.inputs && (a.inputs.parse(t),
a._setupInputs()),
t.upVector && (a.upVector = Vector3.FromArray(t.upVector)),
a.setPosition && (a.position.copyFromFloats(0, 0, 0),
a.setPosition(Vector3.FromArray(t.position))),
t.target && a.setTarget && a.setTarget(Vector3.FromArray(t.target)),
t.cameraRigMode) {
var s = t.interaxial_distance ? {
interaxialDistance: t.interaxial_distance
} : {};
a.setCameraRigMode(t.cameraRigMode, s)
}
if (t.animations) {
for (var l = 0; l < t.animations.length; l++) {
var u = t.animations[l]
, c = GetClass("BABYLON.Animation");
c && a.animations.push(c.Parse(u))
}
Node$2.ParseAnimationRanges(a, t, r)
}
return t.autoAnimate && r.beginAnimation(a, t.autoAnimateFrom, t.autoAnimateTo, t.autoAnimateLoop, t.autoAnimateSpeed || 1),
t.isEnabled !== void 0 && a.setEnabled(t.isEnabled),
a
}
,
e._createDefaultParsedCamera = function(t, r) {
throw _WarnImport("UniversalCamera")
}
,
e.PERSPECTIVE_CAMERA = 0,
e.ORTHOGRAPHIC_CAMERA = 1,
e.FOVMODE_VERTICAL_FIXED = 0,
e.FOVMODE_HORIZONTAL_FIXED = 1,
e.RIG_MODE_NONE = 0,
e.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10,
e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11,
e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12,
e.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13,
e.RIG_MODE_STEREOSCOPIC_INTERLACED = 14,
e.RIG_MODE_VR = 20,
e.RIG_MODE_WEBVR = 21,
e.RIG_MODE_CUSTOM = 22,
e.ForceAttachControlToAlwaysPreventDefault = !1,
__decorate([serializeAsVector3("position")], e.prototype, "_position", void 0),
__decorate([serializeAsVector3("upVector")], e.prototype, "_upVector", void 0),
__decorate([serialize()], e.prototype, "orthoLeft", void 0),
__decorate([serialize()], e.prototype, "orthoRight", void 0),
__decorate([serialize()], e.prototype, "orthoBottom", void 0),
__decorate([serialize()], e.prototype, "orthoTop", void 0),
__decorate([serialize()], e.prototype, "fov", void 0),
__decorate([serialize()], e.prototype, "projectionPlaneTilt", void 0),
__decorate([serialize()], e.prototype, "minZ", void 0),
__decorate([serialize()], e.prototype, "maxZ", void 0),
__decorate([serialize()], e.prototype, "inertia", void 0),
__decorate([serialize()], e.prototype, "mode", void 0),
__decorate([serialize()], e.prototype, "layerMask", void 0),
__decorate([serialize()], e.prototype, "fovMode", void 0),
__decorate([serialize()], e.prototype, "cameraRigMode", void 0),
__decorate([serialize()], e.prototype, "interaxialDistance", void 0),
__decorate([serialize()], e.prototype, "isStereoscopicSideBySide", void 0),
e
}(Node$2)
, Light = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t, r) || this;
return n.diffuse = new Color3(1,1,1),
n.specular = new Color3(1,1,1),
n.falloffType = e.FALLOFF_DEFAULT,
n.intensity = 1,
n._range = Number.MAX_VALUE,
n._inverseSquaredRange = 0,
n._photometricScale = 1,
n._intensityMode = e.INTENSITYMODE_AUTOMATIC,
n._radius = 1e-5,
n.renderPriority = 0,
n._shadowEnabled = !0,
n._excludeWithLayerMask = 0,
n._includeOnlyWithLayerMask = 0,
n._lightmapMode = 0,
n._excludedMeshesIds = new Array,
n._includedOnlyMeshesIds = new Array,
n._isLight = !0,
n.getScene().addLight(n),
n._uniformBuffer = new UniformBuffer(n.getScene().getEngine(),void 0,void 0,t),
n._buildUniformLayout(),
n.includedOnlyMeshes = new Array,
n.excludedMeshes = new Array,
n._resyncMeshes(),
n
}
return Object.defineProperty(e.prototype, "range", {
get: function() {
return this._range
},
set: function(t) {
this._range = t,
this._inverseSquaredRange = 1 / (this.range * this.range)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "intensityMode", {
get: function() {
return this._intensityMode
},
set: function(t) {
this._intensityMode = t,
this._computePhotometricScale()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "radius", {
get: function() {
return this._radius
},
set: function(t) {
this._radius = t,
this._computePhotometricScale()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "shadowEnabled", {
get: function() {
return this._shadowEnabled
},
set: function(t) {
this._shadowEnabled !== t && (this._shadowEnabled = t,
this._markMeshesAsLightDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "includedOnlyMeshes", {
get: function() {
return this._includedOnlyMeshes
},
set: function(t) {
this._includedOnlyMeshes = t,
this._hookArrayForIncludedOnly(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "excludedMeshes", {
get: function() {
return this._excludedMeshes
},
set: function(t) {
this._excludedMeshes = t,
this._hookArrayForExcluded(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "excludeWithLayerMask", {
get: function() {
return this._excludeWithLayerMask
},
set: function(t) {
this._excludeWithLayerMask = t,
this._resyncMeshes()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "includeOnlyWithLayerMask", {
get: function() {
return this._includeOnlyWithLayerMask
},
set: function(t) {
this._includeOnlyWithLayerMask = t,
this._resyncMeshes()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "lightmapMode", {
get: function() {
return this._lightmapMode
},
set: function(t) {
this._lightmapMode !== t && (this._lightmapMode = t,
this._markMeshesAsLightDirty())
},
enumerable: !1,
configurable: !0
}),
e.prototype.transferTexturesToEffect = function(t, r) {
return this
}
,
e.prototype._bindLight = function(t, r, n, o, a) {
a === void 0 && (a = !0);
var s = t.toString()
, l = !1;
if (this._uniformBuffer.bindToEffect(n, "Light" + s),
this._renderId !== r.getRenderId() || !this._uniformBuffer.useUbo) {
this._renderId = r.getRenderId();
var u = this.getScaledIntensity();
this.transferToEffect(n, s),
this.diffuse.scaleToRef(u, TmpColors.Color3[0]),
this._uniformBuffer.updateColor4("vLightDiffuse", TmpColors.Color3[0], this.range, s),
o && (this.specular.scaleToRef(u, TmpColors.Color3[1]),
this._uniformBuffer.updateColor4("vLightSpecular", TmpColors.Color3[1], this.radius, s)),
l = !0
}
if (this.transferTexturesToEffect(n, s),
r.shadowsEnabled && this.shadowEnabled && a) {
var c = this.getShadowGenerator();
c && (c.bindShadowLight(s, n),
l = !0)
}
l ? this._uniformBuffer.update() : this._uniformBuffer.bindUniformBuffer()
}
,
e.prototype.getClassName = function() {
return "Light"
}
,
e.prototype.toString = function(t) {
var r = "Name: " + this.name;
if (r += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()],
this.animations)
for (var n = 0; n < this.animations.length; n++)
r += ", animation[0]: " + this.animations[n].toString(t);
return r
}
,
e.prototype._syncParentEnabledState = function() {
i.prototype._syncParentEnabledState.call(this),
this.isDisposed() || this._resyncMeshes()
}
,
e.prototype.setEnabled = function(t) {
i.prototype.setEnabled.call(this, t),
this._resyncMeshes()
}
,
e.prototype.getShadowGenerator = function() {
return this._shadowGenerator
}
,
e.prototype.getAbsolutePosition = function() {
return Vector3.Zero()
}
,
e.prototype.canAffectMesh = function(t) {
return t ? !(this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(t) === -1 || this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(t) !== -1 || this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & t.layerMask) === 0 || this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & t.layerMask) : !0
}
,
e.prototype.dispose = function(t, r) {
if (r === void 0 && (r = !1),
this._shadowGenerator && (this._shadowGenerator.dispose(),
this._shadowGenerator = null),
this.getScene().stopAnimation(this),
this._parentContainer) {
var n = this._parentContainer.lights.indexOf(this);
n > -1 && this._parentContainer.lights.splice(n, 1),
this._parentContainer = null
}
for (var o = 0, a = this.getScene().meshes; o < a.length; o++) {
var s = a[o];
s._removeLightSource(this, !0)
}
this._uniformBuffer.dispose(),
this.getScene().removeLight(this),
i.prototype.dispose.call(this, t, r)
}
,
e.prototype.getTypeID = function() {
return 0
}
,
e.prototype.getScaledIntensity = function() {
return this._photometricScale * this.intensity
}
,
e.prototype.clone = function(t, r) {
r === void 0 && (r = null);
var n = e.GetConstructorFromName(this.getTypeID(), t, this.getScene());
if (!n)
return null;
var o = SerializationHelper.Clone(n, this);
return t && (o.name = t),
r && (o.parent = r),
o.setEnabled(this.isEnabled()),
this.onClonedObservable.notifyObservers(o),
o
}
,
e.prototype.serialize = function() {
var t = SerializationHelper.Serialize(this);
return t.uniqueId = this.uniqueId,
t.type = this.getTypeID(),
this.parent && (t.parentId = this.parent.uniqueId),
this.excludedMeshes.length > 0 && (t.excludedMeshesIds = [],
this.excludedMeshes.forEach(function(r) {
t.excludedMeshesIds.push(r.id)
})),
this.includedOnlyMeshes.length > 0 && (t.includedOnlyMeshesIds = [],
this.includedOnlyMeshes.forEach(function(r) {
t.includedOnlyMeshesIds.push(r.id)
})),
SerializationHelper.AppendSerializedAnimations(this, t),
t.ranges = this.serializeAnimationRanges(),
t.isEnabled = this.isEnabled(),
t
}
,
e.GetConstructorFromName = function(t, r, n) {
var o = Node$2.Construct("Light_Type_" + t, r, n);
return o || null
}
,
e.Parse = function(t, r) {
var n = e.GetConstructorFromName(t.type, t.name, r);
if (!n)
return null;
var o = SerializationHelper.Parse(n, t, r);
if (t.excludedMeshesIds && (o._excludedMeshesIds = t.excludedMeshesIds),
t.includedOnlyMeshesIds && (o._includedOnlyMeshesIds = t.includedOnlyMeshesIds),
t.parentId && (o._waitingParentId = t.parentId),
t.falloffType !== void 0 && (o.falloffType = t.falloffType),
t.lightmapMode !== void 0 && (o.lightmapMode = t.lightmapMode),
t.animations) {
for (var a = 0; a < t.animations.length; a++) {
var s = t.animations[a]
, l = GetClass("BABYLON.Animation");
l && o.animations.push(l.Parse(s))
}
Node$2.ParseAnimationRanges(o, t, r)
}
return t.autoAnimate && r.beginAnimation(o, t.autoAnimateFrom, t.autoAnimateTo, t.autoAnimateLoop, t.autoAnimateSpeed || 1),
t.isEnabled !== void 0 && o.setEnabled(t.isEnabled),
o
}
,
e.prototype._hookArrayForExcluded = function(t) {
var r = this
, n = t.push;
t.push = function() {
for (var u = [], c = 0; c < arguments.length; c++)
u[c] = arguments[c];
for (var h = n.apply(t, u), f = 0, d = u; f < d.length; f++) {
var _ = d[f];
_._resyncLightSource(r)
}
return h
}
;
var o = t.splice;
t.splice = function(u, c) {
for (var h = o.apply(t, [u, c]), f = 0, d = h; f < d.length; f++) {
var _ = d[f];
_._resyncLightSource(r)
}
return h
}
;
for (var a = 0, s = t; a < s.length; a++) {
var l = s[a];
l._resyncLightSource(this)
}
}
,
e.prototype._hookArrayForIncludedOnly = function(t) {
var r = this
, n = t.push;
t.push = function() {
for (var a = [], s = 0; s < arguments.length; s++)
a[s] = arguments[s];
var l = n.apply(t, a);
return r._resyncMeshes(),
l
}
;
var o = t.splice;
t.splice = function(a, s) {
var l = o.apply(t, [a, s]);
return r._resyncMeshes(),
l
}
,
this._resyncMeshes()
}
,
e.prototype._resyncMeshes = function() {
for (var t = 0, r = this.getScene().meshes; t < r.length; t++) {
var n = r[t];
n._resyncLightSource(this)
}
}
,
e.prototype._markMeshesAsLightDirty = function() {
for (var t = 0, r = this.getScene().meshes; t < r.length; t++) {
var n = r[t];
n.lightSources.indexOf(this) !== -1 && n._markSubMeshesAsLightDirty()
}
}
,
e.prototype._computePhotometricScale = function() {
this._photometricScale = this._getPhotometricScale(),
this.getScene().resetCachedMaterial()
}
,
e.prototype._getPhotometricScale = function() {
var t = 0
, r = this.getTypeID()
, n = this.intensityMode;
switch (n === e.INTENSITYMODE_AUTOMATIC && (r === e.LIGHTTYPEID_DIRECTIONALLIGHT ? n = e.INTENSITYMODE_ILLUMINANCE : n = e.INTENSITYMODE_LUMINOUSINTENSITY),
r) {
case e.LIGHTTYPEID_POINTLIGHT:
case e.LIGHTTYPEID_SPOTLIGHT:
switch (n) {
case e.INTENSITYMODE_LUMINOUSPOWER:
t = 1 / (4 * Math.PI);
break;
case e.INTENSITYMODE_LUMINOUSINTENSITY:
t = 1;
break;
case e.INTENSITYMODE_LUMINANCE:
t = this.radius * this.radius;
break
}
break;
case e.LIGHTTYPEID_DIRECTIONALLIGHT:
switch (n) {
case e.INTENSITYMODE_ILLUMINANCE:
t = 1;
break;
case e.INTENSITYMODE_LUMINANCE:
var o = this.radius;
o = Math.max(o, .001);
var a = 2 * Math.PI * (1 - Math.cos(o));
t = a;
break
}
break;
case e.LIGHTTYPEID_HEMISPHERICLIGHT:
t = 1;
break
}
return t
}
,
e.prototype._reorderLightsInScene = function() {
var t = this.getScene();
this._renderPriority != 0 && (t.requireLightSorting = !0),
this.getScene().sortLightsByPriority()
}
,
e.FALLOFF_DEFAULT = LightConstants.FALLOFF_DEFAULT,
e.FALLOFF_PHYSICAL = LightConstants.FALLOFF_PHYSICAL,
e.FALLOFF_GLTF = LightConstants.FALLOFF_GLTF,
e.FALLOFF_STANDARD = LightConstants.FALLOFF_STANDARD,
e.LIGHTMAP_DEFAULT = LightConstants.LIGHTMAP_DEFAULT,
e.LIGHTMAP_SPECULAR = LightConstants.LIGHTMAP_SPECULAR,
e.LIGHTMAP_SHADOWSONLY = LightConstants.LIGHTMAP_SHADOWSONLY,
e.INTENSITYMODE_AUTOMATIC = LightConstants.INTENSITYMODE_AUTOMATIC,
e.INTENSITYMODE_LUMINOUSPOWER = LightConstants.INTENSITYMODE_LUMINOUSPOWER,
e.INTENSITYMODE_LUMINOUSINTENSITY = LightConstants.INTENSITYMODE_LUMINOUSINTENSITY,
e.INTENSITYMODE_ILLUMINANCE = LightConstants.INTENSITYMODE_ILLUMINANCE,
e.INTENSITYMODE_LUMINANCE = LightConstants.INTENSITYMODE_LUMINANCE,
e.LIGHTTYPEID_POINTLIGHT = LightConstants.LIGHTTYPEID_POINTLIGHT,
e.LIGHTTYPEID_DIRECTIONALLIGHT = LightConstants.LIGHTTYPEID_DIRECTIONALLIGHT,
e.LIGHTTYPEID_SPOTLIGHT = LightConstants.LIGHTTYPEID_SPOTLIGHT,
e.LIGHTTYPEID_HEMISPHERICLIGHT = LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT,
__decorate([serializeAsColor3()], e.prototype, "diffuse", void 0),
__decorate([serializeAsColor3()], e.prototype, "specular", void 0),
__decorate([serialize()], e.prototype, "falloffType", void 0),
__decorate([serialize()], e.prototype, "intensity", void 0),
__decorate([serialize()], e.prototype, "range", null),
__decorate([serialize()], e.prototype, "intensityMode", null),
__decorate([serialize()], e.prototype, "radius", null),
__decorate([serialize()], e.prototype, "_renderPriority", void 0),
__decorate([expandToProperty("_reorderLightsInScene")], e.prototype, "renderPriority", void 0),
__decorate([serialize("shadowEnabled")], e.prototype, "_shadowEnabled", void 0),
__decorate([serialize("excludeWithLayerMask")], e.prototype, "_excludeWithLayerMask", void 0),
__decorate([serialize("includeOnlyWithLayerMask")], e.prototype, "_includeOnlyWithLayerMask", void 0),
__decorate([serialize("lightmapMode")], e.prototype, "_lightmapMode", void 0),
e
}(Node$2)
, ThinMaterialHelper = function() {
function i() {}
return i.BindClipPlane = function(e, t) {
if (t.clipPlane) {
var r = t.clipPlane;
e.setFloat4("vClipPlane", r.normal.x, r.normal.y, r.normal.z, r.d)
}
if (t.clipPlane2) {
var r = t.clipPlane2;
e.setFloat4("vClipPlane2", r.normal.x, r.normal.y, r.normal.z, r.d)
}
if (t.clipPlane3) {
var r = t.clipPlane3;
e.setFloat4("vClipPlane3", r.normal.x, r.normal.y, r.normal.z, r.d)
}
if (t.clipPlane4) {
var r = t.clipPlane4;
e.setFloat4("vClipPlane4", r.normal.x, r.normal.y, r.normal.z, r.d)
}
if (t.clipPlane5) {
var r = t.clipPlane5;
e.setFloat4("vClipPlane5", r.normal.x, r.normal.y, r.normal.z, r.d)
}
if (t.clipPlane6) {
var r = t.clipPlane6;
e.setFloat4("vClipPlane6", r.normal.x, r.normal.y, r.normal.z, r.d)
}
}
,
i
}()
, MaterialHelper = function() {
function i() {}
return i.BindSceneUniformBuffer = function(e, t) {
t.bindToEffect(e, "Scene")
}
,
i.PrepareDefinesForMergedUV = function(e, t, r) {
t._needUVs = !0,
t[r] = !0,
e.getTextureMatrix().isIdentityAs3x2() ? (t[r + "DIRECTUV"] = e.coordinatesIndex + 1,
t["MAINUV" + (e.coordinatesIndex + 1)] = !0) : t[r + "DIRECTUV"] = 0
}
,
i.BindTextureMatrix = function(e, t, r) {
var n = e.getTextureMatrix();
t.updateMatrix(r + "Matrix", n)
}
,
i.GetFogState = function(e, t) {
return t.fogEnabled && e.applyFog && t.fogMode !== Scene.FOGMODE_NONE
}
,
i.PrepareDefinesForMisc = function(e, t, r, n, o, a, s) {
s._areMiscDirty && (s.LOGARITHMICDEPTH = r,
s.POINTSIZE = n,
s.FOG = o && this.GetFogState(e, t),
s.NONUNIFORMSCALING = e.nonUniformScaling,
s.ALPHATEST = a)
}
,
i.PrepareDefinesForFrameBoundValues = function(e, t, r, n, o, a) {
o === void 0 && (o = null),
a === void 0 && (a = !1);
var s = !1
, l = !1
, u = !1
, c = !1
, h = !1
, f = !1
, d = !1;
l = o == null ? e.clipPlane !== void 0 && e.clipPlane !== null : o,
u = o == null ? e.clipPlane2 !== void 0 && e.clipPlane2 !== null : o,
c = o == null ? e.clipPlane3 !== void 0 && e.clipPlane3 !== null : o,
h = o == null ? e.clipPlane4 !== void 0 && e.clipPlane4 !== null : o,
f = o == null ? e.clipPlane5 !== void 0 && e.clipPlane5 !== null : o,
d = o == null ? e.clipPlane6 !== void 0 && e.clipPlane6 !== null : o,
r.CLIPPLANE !== l && (r.CLIPPLANE = l,
s = !0),
r.CLIPPLANE2 !== u && (r.CLIPPLANE2 = u,
s = !0),
r.CLIPPLANE3 !== c && (r.CLIPPLANE3 = c,
s = !0),
r.CLIPPLANE4 !== h && (r.CLIPPLANE4 = h,
s = !0),
r.CLIPPLANE5 !== f && (r.CLIPPLANE5 = f,
s = !0),
r.CLIPPLANE6 !== d && (r.CLIPPLANE6 = d,
s = !0),
r.DEPTHPREPASS !== !t.getColorWrite() && (r.DEPTHPREPASS = !r.DEPTHPREPASS,
s = !0),
r.INSTANCES !== n && (r.INSTANCES = n,
s = !0),
r.THIN_INSTANCES !== a && (r.THIN_INSTANCES = a,
s = !0),
s && r.markAsUnprocessed()
}
,
i.PrepareDefinesForBones = function(e, t) {
if (e.useBones && e.computeBonesUsingShaders && e.skeleton) {
t.NUM_BONE_INFLUENCERS = e.numBoneInfluencers;
var r = t.BONETEXTURE !== void 0;
if (e.skeleton.isUsingTextureForMatrices && r)
t.BONETEXTURE = !0;
else {
t.BonesPerMesh = e.skeleton.bones.length + 1,
t.BONETEXTURE = r ? !1 : void 0;
var n = e.getScene().prePassRenderer;
if (n && n.enabled) {
var o = n.excludedSkinnedMesh.indexOf(e) === -1;
t.BONES_VELOCITY_ENABLED = o
}
}
} else
t.NUM_BONE_INFLUENCERS = 0,
t.BonesPerMesh = 0
}
,
i.PrepareDefinesForMorphTargets = function(e, t) {
var r = e.morphTargetManager;
r ? (t.MORPHTARGETS_UV = r.supportsUVs && t.UV1,
t.MORPHTARGETS_TANGENT = r.supportsTangents && t.TANGENT,
t.MORPHTARGETS_NORMAL = r.supportsNormals && t.NORMAL,
t.MORPHTARGETS = r.numInfluencers > 0,
t.NUM_MORPH_INFLUENCERS = r.numInfluencers,
t.MORPHTARGETS_TEXTURE = r.isUsingTextureForTargets) : (t.MORPHTARGETS_UV = !1,
t.MORPHTARGETS_TANGENT = !1,
t.MORPHTARGETS_NORMAL = !1,
t.MORPHTARGETS = !1,
t.NUM_MORPH_INFLUENCERS = 0)
}
,
i.PrepareDefinesForBakedVertexAnimation = function(e, t) {
var r = e.bakedVertexAnimationManager;
t.BAKED_VERTEX_ANIMATION_TEXTURE = !!(r && r.isEnabled)
}
,
i.PrepareDefinesForAttributes = function(e, t, r, n, o, a, s) {
if (o === void 0 && (o = !1),
a === void 0 && (a = !0),
s === void 0 && (s = !0),
!t._areAttributesDirty && t._needNormals === t._normals && t._needUVs === t._uvs)
return !1;
t._normals = t._needNormals,
t._uvs = t._needUVs,
t.NORMAL = t._needNormals && e.isVerticesDataPresent(VertexBuffer.NormalKind),
t._needNormals && e.isVerticesDataPresent(VertexBuffer.TangentKind) && (t.TANGENT = !0);
for (var l = 1; l <= 6; ++l)
t["UV" + l] = t._needUVs ? e.isVerticesDataPresent("uv" + (l === 1 ? "" : l)) : !1;
if (r) {
var u = e.useVertexColors && e.isVerticesDataPresent(VertexBuffer.ColorKind);
t.VERTEXCOLOR = u,
t.VERTEXALPHA = e.hasVertexAlpha && u && a
}
return n && this.PrepareDefinesForBones(e, t),
o && this.PrepareDefinesForMorphTargets(e, t),
s && this.PrepareDefinesForBakedVertexAnimation(e, t),
!0
}
,
i.PrepareDefinesForMultiview = function(e, t) {
if (e.activeCamera) {
var r = t.MULTIVIEW;
t.MULTIVIEW = e.activeCamera.outputRenderTarget !== null && e.activeCamera.outputRenderTarget.getViewCount() > 1,
t.MULTIVIEW != r && t.markAsUnprocessed()
}
}
,
i.PrepareDefinesForOIT = function(e, t, r) {
var n = t.ORDER_INDEPENDENT_TRANSPARENCY
, o = t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;
t.ORDER_INDEPENDENT_TRANSPARENCY = e.useOrderIndependentTransparency && r,
t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !e.getEngine().getCaps().textureFloatLinearFiltering,
(n !== t.ORDER_INDEPENDENT_TRANSPARENCY || o !== t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS) && t.markAsUnprocessed()
}
,
i.PrepareDefinesForPrePass = function(e, t, r) {
var n = t.PREPASS;
if (!!t._arePrePassDirty) {
var o = [{
type: 1,
define: "PREPASS_POSITION",
index: "PREPASS_POSITION_INDEX"
}, {
type: 2,
define: "PREPASS_VELOCITY",
index: "PREPASS_VELOCITY_INDEX"
}, {
type: 3,
define: "PREPASS_REFLECTIVITY",
index: "PREPASS_REFLECTIVITY_INDEX"
}, {
type: 0,
define: "PREPASS_IRRADIANCE",
index: "PREPASS_IRRADIANCE_INDEX"
}, {
type: 7,
define: "PREPASS_ALBEDO_SQRT",
index: "PREPASS_ALBEDO_SQRT_INDEX"
}, {
type: 5,
define: "PREPASS_DEPTH",
index: "PREPASS_DEPTH_INDEX"
}, {
type: 6,
define: "PREPASS_NORMAL",
index: "PREPASS_NORMAL_INDEX"
}];
if (e.prePassRenderer && e.prePassRenderer.enabled && r) {
t.PREPASS = !0,
t.SCENE_MRT_COUNT = e.prePassRenderer.mrtCount;
for (var a = 0; a < o.length; a++) {
var s = e.prePassRenderer.getIndex(o[a].type);
s !== -1 ? (t[o[a].define] = !0,
t[o[a].index] = s) : t[o[a].define] = !1
}
} else {
t.PREPASS = !1;
for (var a = 0; a < o.length; a++)
t[o[a].define] = !1
}
t.PREPASS != n && (t.markAsUnprocessed(),
t.markAsImageProcessingDirty())
}
}
,
i.PrepareDefinesForLight = function(e, t, r, n, o, a, s) {
switch (s.needNormals = !0,
o["LIGHT" + n] === void 0 && (s.needRebuild = !0),
o["LIGHT" + n] = !0,
o["SPOTLIGHT" + n] = !1,
o["HEMILIGHT" + n] = !1,
o["POINTLIGHT" + n] = !1,
o["DIRLIGHT" + n] = !1,
r.prepareLightSpecificDefines(o, n),
o["LIGHT_FALLOFF_PHYSICAL" + n] = !1,
o["LIGHT_FALLOFF_GLTF" + n] = !1,
o["LIGHT_FALLOFF_STANDARD" + n] = !1,
r.falloffType) {
case Light.FALLOFF_GLTF:
o["LIGHT_FALLOFF_GLTF" + n] = !0;
break;
case Light.FALLOFF_PHYSICAL:
o["LIGHT_FALLOFF_PHYSICAL" + n] = !0;
break;
case Light.FALLOFF_STANDARD:
o["LIGHT_FALLOFF_STANDARD" + n] = !0;
break
}
if (a && !r.specular.equalsFloats(0, 0, 0) && (s.specularEnabled = !0),
o["SHADOW" + n] = !1,
o["SHADOWCSM" + n] = !1,
o["SHADOWCSMDEBUG" + n] = !1,
o["SHADOWCSMNUM_CASCADES" + n] = !1,
o["SHADOWCSMUSESHADOWMAXZ" + n] = !1,
o["SHADOWCSMNOBLEND" + n] = !1,
o["SHADOWCSM_RIGHTHANDED" + n] = !1,
o["SHADOWPCF" + n] = !1,
o["SHADOWPCSS" + n] = !1,
o["SHADOWPOISSON" + n] = !1,
o["SHADOWESM" + n] = !1,
o["SHADOWCLOSEESM" + n] = !1,
o["SHADOWCUBE" + n] = !1,
o["SHADOWLOWQUALITY" + n] = !1,
o["SHADOWMEDIUMQUALITY" + n] = !1,
t && t.receiveShadows && e.shadowsEnabled && r.shadowEnabled) {
var l = r.getShadowGenerator();
if (l) {
var u = l.getShadowMap();
u && u.renderList && u.renderList.length > 0 && (s.shadowEnabled = !0,
l.prepareDefines(o, n))
}
}
r.lightmapMode != Light.LIGHTMAP_DEFAULT ? (s.lightmapMode = !0,
o["LIGHTMAPEXCLUDED" + n] = !0,
o["LIGHTMAPNOSPECULAR" + n] = r.lightmapMode == Light.LIGHTMAP_SHADOWSONLY) : (o["LIGHTMAPEXCLUDED" + n] = !1,
o["LIGHTMAPNOSPECULAR" + n] = !1)
}
,
i.PrepareDefinesForLights = function(e, t, r, n, o, a) {
if (o === void 0 && (o = 4),
a === void 0 && (a = !1),
!r._areLightsDirty)
return r._needNormals;
var s = 0
, l = {
needNormals: !1,
needRebuild: !1,
lightmapMode: !1,
shadowEnabled: !1,
specularEnabled: !1
};
if (e.lightsEnabled && !a)
for (var u = 0, c = t.lightSources; u < c.length; u++) {
var h = c[u];
if (this.PrepareDefinesForLight(e, t, h, s, r, n, l),
s++,
s === o)
break
}
r.SPECULARTERM = l.specularEnabled,
r.SHADOWS = l.shadowEnabled;
for (var f = s; f < o; f++)
r["LIGHT" + f] !== void 0 && (r["LIGHT" + f] = !1,
r["HEMILIGHT" + f] = !1,
r["POINTLIGHT" + f] = !1,
r["DIRLIGHT" + f] = !1,
r["SPOTLIGHT" + f] = !1,
r["SHADOW" + f] = !1,
r["SHADOWCSM" + f] = !1,
r["SHADOWCSMDEBUG" + f] = !1,
r["SHADOWCSMNUM_CASCADES" + f] = !1,
r["SHADOWCSMUSESHADOWMAXZ" + f] = !1,
r["SHADOWCSMNOBLEND" + f] = !1,
r["SHADOWCSM_RIGHTHANDED" + f] = !1,
r["SHADOWPCF" + f] = !1,
r["SHADOWPCSS" + f] = !1,
r["SHADOWPOISSON" + f] = !1,
r["SHADOWESM" + f] = !1,
r["SHADOWCLOSEESM" + f] = !1,
r["SHADOWCUBE" + f] = !1,
r["SHADOWLOWQUALITY" + f] = !1,
r["SHADOWMEDIUMQUALITY" + f] = !1);
var d = e.getEngine().getCaps();
return r.SHADOWFLOAT === void 0 && (l.needRebuild = !0),
r.SHADOWFLOAT = l.shadowEnabled && (d.textureFloatRender && d.textureFloatLinearFiltering || d.textureHalfFloatRender && d.textureHalfFloatLinearFiltering),
r.LIGHTMAPEXCLUDED = l.lightmapMode,
l.needRebuild && r.rebuild(),
l.needNormals
}
,
i.PrepareUniformsAndSamplersForLight = function(e, t, r, n, o, a) {
o === void 0 && (o = null),
a === void 0 && (a = !1),
o && o.push("Light" + e),
!a && (t.push("vLightData" + e, "vLightDiffuse" + e, "vLightSpecular" + e, "vLightDirection" + e, "vLightFalloff" + e, "vLightGround" + e, "lightMatrix" + e, "shadowsInfo" + e, "depthValues" + e),
r.push("shadowSampler" + e),
r.push("depthSampler" + e),
t.push("viewFrustumZ" + e, "cascadeBlendFactor" + e, "lightSizeUVCorrection" + e, "depthCorrection" + e, "penumbraDarkness" + e, "frustumLengths" + e),
n && (r.push("projectionLightSampler" + e),
t.push("textureProjectionMatrix" + e)))
}
,
i.PrepareUniformsAndSamplersList = function(e, t, r, n) {
n === void 0 && (n = 4);
var o, a = null;
if (e.uniformsNames) {
var s = e;
o = s.uniformsNames,
a = s.uniformBuffersNames,
t = s.samplers,
r = s.defines,
n = s.maxSimultaneousLights || 0
} else
o = e,
t || (t = []);
for (var l = 0; l < n && r["LIGHT" + l]; l++)
this.PrepareUniformsAndSamplersForLight(l, o, t, r["PROJECTEDLIGHTTEXTURE" + l], a);
r.NUM_MORPH_INFLUENCERS && o.push("morphTargetInfluences"),
r.BAKED_VERTEX_ANIMATION_TEXTURE && (o.push("bakedVertexAnimationSettings"),
o.push("bakedVertexAnimationTextureSizeInverted"),
o.push("bakedVertexAnimationTime"),
t.push("bakedVertexAnimationTexture"))
}
,
i.HandleFallbacksForShadows = function(e, t, r, n) {
r === void 0 && (r = 4),
n === void 0 && (n = 0);
for (var o = 0, a = 0; a < r && e["LIGHT" + a]; a++)
a > 0 && (o = n + a,
t.addFallback(o, "LIGHT" + a)),
e.SHADOWS || (e["SHADOW" + a] && t.addFallback(n, "SHADOW" + a),
e["SHADOWPCF" + a] && t.addFallback(n, "SHADOWPCF" + a),
e["SHADOWPCSS" + a] && t.addFallback(n, "SHADOWPCSS" + a),
e["SHADOWPOISSON" + a] && t.addFallback(n, "SHADOWPOISSON" + a),
e["SHADOWESM" + a] && t.addFallback(n, "SHADOWESM" + a),
e["SHADOWCLOSEESM" + a] && t.addFallback(n, "SHADOWCLOSEESM" + a));
return o++
}
,
i.PrepareAttributesForMorphTargetsInfluencers = function(e, t, r) {
this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS = r,
this.PrepareAttributesForMorphTargets(e, t, this._TmpMorphInfluencers)
}
,
i.PrepareAttributesForMorphTargets = function(e, t, r) {
var n = r.NUM_MORPH_INFLUENCERS;
if (n > 0 && EngineStore.LastCreatedEngine) {
var o = EngineStore.LastCreatedEngine.getCaps().maxVertexAttribs
, a = t.morphTargetManager;
if (a != null && a.isUsingTextureForTargets)
return;
for (var s = a && a.supportsNormals && r.NORMAL, l = a && a.supportsTangents && r.TANGENT, u = a && a.supportsUVs && r.UV1, c = 0; c < n; c++)
e.push(VertexBuffer.PositionKind + c),
s && e.push(VertexBuffer.NormalKind + c),
l && e.push(VertexBuffer.TangentKind + c),
u && e.push(VertexBuffer.UVKind + "_" + c),
e.length > o && Logger$2.Error("Cannot add more vertex attributes for mesh " + t.name)
}
}
,
i.PrepareAttributesForBakedVertexAnimation = function(e, t, r) {
var n = r.BAKED_VERTEX_ANIMATION_TEXTURE && r.INSTANCES;
n && (e.push("bakedVertexAnimationSettingsInstanced"),
e.push("bakedVertexAnimationTimeInstanced"))
}
,
i.PrepareAttributesForBones = function(e, t, r, n) {
r.NUM_BONE_INFLUENCERS > 0 && (n.addCPUSkinningFallback(0, t),
e.push(VertexBuffer.MatricesIndicesKind),
e.push(VertexBuffer.MatricesWeightsKind),
r.NUM_BONE_INFLUENCERS > 4 && (e.push(VertexBuffer.MatricesIndicesExtraKind),
e.push(VertexBuffer.MatricesWeightsExtraKind)))
}
,
i.PrepareAttributesForInstances = function(e, t) {
(t.INSTANCES || t.THIN_INSTANCES) && this.PushAttributesForInstances(e, !!t.PREPASS_VELOCITY)
}
,
i.PushAttributesForInstances = function(e, t) {
t === void 0 && (t = !1),
e.push("world0"),
e.push("world1"),
e.push("world2"),
e.push("world3"),
t && (e.push("previousWorld0"),
e.push("previousWorld1"),
e.push("previousWorld2"),
e.push("previousWorld3"))
}
,
i.BindLightProperties = function(e, t, r) {
e.transferToEffect(t, r + "")
}
,
i.BindLight = function(e, t, r, n, o, a) {
a === void 0 && (a = !0),
e._bindLight(t, r, n, o, a)
}
,
i.BindLights = function(e, t, r, n, o) {
o === void 0 && (o = 4);
for (var a = Math.min(t.lightSources.length, o), s = 0; s < a; s++) {
var l = t.lightSources[s];
this.BindLight(l, s, e, r, typeof n == "boolean" ? n : n.SPECULARTERM, t.receiveShadows)
}
}
,
i.BindFogParameters = function(e, t, r, n) {
n === void 0 && (n = !1),
e.fogEnabled && t.applyFog && e.fogMode !== Scene.FOGMODE_NONE && (r.setFloat4("vFogInfos", e.fogMode, e.fogStart, e.fogEnd, e.fogDensity),
n ? (e.fogColor.toLinearSpaceToRef(this._tempFogColor),
r.setColor3("vFogColor", this._tempFogColor)) : r.setColor3("vFogColor", e.fogColor))
}
,
i.BindBonesParameters = function(e, t, r) {
if (!(!t || !e) && (e.computeBonesUsingShaders && t._bonesComputationForcedToCPU && (e.computeBonesUsingShaders = !1),
e.useBones && e.computeBonesUsingShaders && e.skeleton)) {
var n = e.skeleton;
if (n.isUsingTextureForMatrices && t.getUniformIndex("boneTextureWidth") > -1) {
var o = n.getTransformMatrixTexture(e);
t.setTexture("boneSampler", o),
t.setFloat("boneTextureWidth", 4 * (n.bones.length + 1))
} else {
var a = n.getTransformMatrices(e);
a && (t.setMatrices("mBones", a),
r && e.getScene().prePassRenderer && e.getScene().prePassRenderer.getIndex(2) && (r.previousBones[e.uniqueId] || (r.previousBones[e.uniqueId] = a.slice()),
t.setMatrices("mPreviousBones", r.previousBones[e.uniqueId]),
i._CopyBonesTransformationMatrices(a, r.previousBones[e.uniqueId])))
}
}
}
,
i._CopyBonesTransformationMatrices = function(e, t) {
return t.set(e),
t
}
,
i.BindMorphTargetParameters = function(e, t) {
var r = e.morphTargetManager;
!e || !r || t.setFloatArray("morphTargetInfluences", r.influences)
}
,
i.BindLogDepth = function(e, t, r) {
if (!e || e.LOGARITHMICDEPTH) {
var n = r.activeCamera;
n.mode === Camera$1.ORTHOGRAPHIC_CAMERA && Logger$2.Error("Logarithmic depth is not compatible with orthographic cameras!", 20),
t.setFloat("logarithmicDepthConstant", 2 / (Math.log(n.maxZ + 1) / Math.LN2))
}
}
,
i.BindClipPlane = function(e, t) {
ThinMaterialHelper.BindClipPlane(e, t)
}
,
i._TmpMorphInfluencers = {
NUM_MORPH_INFLUENCERS: 0
},
i._tempFogColor = Color3.Black(),
i
}()
, MaterialStencilState = function() {
function i() {
this.reset()
}
return i.prototype.reset = function() {
this.enabled = !1,
this.mask = 255,
this.func = 519,
this.funcRef = 1,
this.funcMask = 255,
this.opStencilFail = 7680,
this.opDepthFail = 7680,
this.opStencilDepthPass = 7681
}
,
Object.defineProperty(i.prototype, "func", {
get: function() {
return this._func
},
set: function(e) {
this._func = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "funcRef", {
get: function() {
return this._funcRef
},
set: function(e) {
this._funcRef = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "funcMask", {
get: function() {
return this._funcMask
},
set: function(e) {
this._funcMask = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "opStencilFail", {
get: function() {
return this._opStencilFail
},
set: function(e) {
this._opStencilFail = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "opDepthFail", {
get: function() {
return this._opDepthFail
},
set: function(e) {
this._opDepthFail = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "opStencilDepthPass", {
get: function() {
return this._opStencilDepthPass
},
set: function(e) {
this._opStencilDepthPass = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "mask", {
get: function() {
return this._mask
},
set: function(e) {
this._mask = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "enabled", {
get: function() {
return this._enabled
},
set: function(e) {
this._enabled = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.getClassName = function() {
return "MaterialStencilState"
}
,
i.prototype.copyTo = function(e) {
SerializationHelper.Clone(function() {
return e
}, this)
}
,
i.prototype.serialize = function() {
return SerializationHelper.Serialize(this)
}
,
i.prototype.parse = function(e, t, r) {
var n = this;
SerializationHelper.Parse(function() {
return n
}, e, t, r)
}
,
__decorate([serialize()], i.prototype, "func", null),
__decorate([serialize()], i.prototype, "funcRef", null),
__decorate([serialize()], i.prototype, "funcMask", null),
__decorate([serialize()], i.prototype, "opStencilFail", null),
__decorate([serialize()], i.prototype, "opDepthFail", null),
__decorate([serialize()], i.prototype, "opStencilDepthPass", null),
__decorate([serialize()], i.prototype, "mask", null),
__decorate([serialize()], i.prototype, "enabled", null),
i
}()
, Material = function() {
function i(e, t, r) {
this.shadowDepthWrapper = null,
this.allowShaderHotSwapping = !0,
this.metadata = null,
this.reservedDataStore = null,
this.checkReadyOnEveryCall = !1,
this.checkReadyOnlyOnce = !1,
this.state = "",
this._alpha = 1,
this._backFaceCulling = !0,
this._cullBackFaces = !0,
this.onCompiled = null,
this.onError = null,
this.getRenderTargetTextures = null,
this.doNotSerialize = !1,
this._storeEffectOnSubMeshes = !1,
this.animations = null,
this.onDisposeObservable = new Observable,
this._onDisposeObserver = null,
this._onUnBindObservable = null,
this._onBindObserver = null,
this._alphaMode = 2,
this._needDepthPrePass = !1,
this.disableDepthWrite = !1,
this.disableColorWrite = !1,
this.forceDepthWrite = !1,
this.depthFunction = 0,
this.separateCullingPass = !1,
this._fogEnabled = !0,
this.pointSize = 1,
this.zOffset = 0,
this.zOffsetUnits = 0,
this.stencil = new MaterialStencilState,
this._useUBO = !1,
this._fillMode = i.TriangleFillMode,
this._cachedDepthWriteState = !1,
this._cachedColorWriteState = !1,
this._cachedDepthFunctionState = 0,
this._indexInSceneMaterialArray = -1,
this.meshMap = null,
this._parentContainer = null,
this._forceAlphaTest = !1,
this._transparencyMode = null,
this.name = e,
this._scene = t || EngineStore.LastCreatedScene,
this.id = e || Tools.RandomId(),
this.uniqueId = this._scene.getUniqueId(),
this._materialContext = this._scene.getEngine().createMaterialContext(),
this._drawWrapper = new DrawWrapper(this._scene.getEngine(),!1),
this._drawWrapper.materialContext = this._materialContext,
this._scene.useRightHandedSystem ? this.sideOrientation = i.ClockWiseSideOrientation : this.sideOrientation = i.CounterClockWiseSideOrientation,
this._uniformBuffer = new UniformBuffer(this._scene.getEngine(),void 0,void 0,e),
this._useUBO = this.getScene().getEngine().supportsUniformBuffers,
r || this._scene.addMaterial(this),
this._scene.useMaterialMeshMap && (this.meshMap = {})
}
return Object.defineProperty(i.prototype, "canRenderToMRT", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "alpha", {
get: function() {
return this._alpha
},
set: function(e) {
this._alpha !== e && (this._alpha = e,
this.markAsDirty(i.MiscDirtyFlag))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "backFaceCulling", {
get: function() {
return this._backFaceCulling
},
set: function(e) {
this._backFaceCulling !== e && (this._backFaceCulling = e,
this.markAsDirty(i.TextureDirtyFlag))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "cullBackFaces", {
get: function() {
return this._cullBackFaces
},
set: function(e) {
this._cullBackFaces !== e && (this._cullBackFaces = e,
this.markAsDirty(i.TextureDirtyFlag))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "hasRenderTargetTextures", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onDispose", {
set: function(e) {
this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
this._onDisposeObserver = this.onDisposeObservable.add(e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onBindObservable", {
get: function() {
return this._onBindObservable || (this._onBindObservable = new Observable),
this._onBindObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onBind", {
set: function(e) {
this._onBindObserver && this.onBindObservable.remove(this._onBindObserver),
this._onBindObserver = this.onBindObservable.add(e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onUnBindObservable", {
get: function() {
return this._onUnBindObservable || (this._onUnBindObservable = new Observable),
this._onUnBindObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onEffectCreatedObservable", {
get: function() {
return this._onEffectCreatedObservable || (this._onEffectCreatedObservable = new Observable),
this._onEffectCreatedObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "alphaMode", {
get: function() {
return this._alphaMode
},
set: function(e) {
this._alphaMode !== e && (this._alphaMode = e,
this.markAsDirty(i.TextureDirtyFlag))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "needDepthPrePass", {
get: function() {
return this._needDepthPrePass
},
set: function(e) {
this._needDepthPrePass !== e && (this._needDepthPrePass = e,
this._needDepthPrePass && (this.checkReadyOnEveryCall = !0))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isPrePassCapable", {
get: function() {
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "fogEnabled", {
get: function() {
return this._fogEnabled
},
set: function(e) {
this._fogEnabled !== e && (this._fogEnabled = e,
this.markAsDirty(i.MiscDirtyFlag))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "wireframe", {
get: function() {
switch (this._fillMode) {
case i.WireFrameFillMode:
case i.LineListDrawMode:
case i.LineLoopDrawMode:
case i.LineStripDrawMode:
return !0
}
return this._scene.forceWireframe
},
set: function(e) {
this.fillMode = e ? i.WireFrameFillMode : i.TriangleFillMode
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "pointsCloud", {
get: function() {
switch (this._fillMode) {
case i.PointFillMode:
case i.PointListDrawMode:
return !0
}
return this._scene.forcePointsCloud
},
set: function(e) {
this.fillMode = e ? i.PointFillMode : i.TriangleFillMode
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "fillMode", {
get: function() {
return this._fillMode
},
set: function(e) {
this._fillMode !== e && (this._fillMode = e,
this.markAsDirty(i.MiscDirtyFlag))
},
enumerable: !1,
configurable: !0
}),
i.prototype._getDrawWrapper = function() {
return this._drawWrapper
}
,
i.prototype._setDrawWrapper = function(e) {
this._drawWrapper = e
}
,
i.prototype.toString = function(e) {
var t = "Name: " + this.name;
return t
}
,
i.prototype.getClassName = function() {
return "Material"
}
,
Object.defineProperty(i.prototype, "isFrozen", {
get: function() {
return this.checkReadyOnlyOnce
},
enumerable: !1,
configurable: !0
}),
i.prototype.freeze = function() {
this.markDirty(),
this.checkReadyOnlyOnce = !0
}
,
i.prototype.unfreeze = function() {
this.markDirty(),
this.checkReadyOnlyOnce = !1
}
,
i.prototype.isReady = function(e, t) {
return !0
}
,
i.prototype.isReadyForSubMesh = function(e, t, r) {
return !1
}
,
i.prototype.getEffect = function() {
return this._drawWrapper.effect
}
,
i.prototype.getScene = function() {
return this._scene
}
,
Object.defineProperty(i.prototype, "transparencyMode", {
get: function() {
return this._transparencyMode
},
set: function(e) {
this._transparencyMode !== e && (this._transparencyMode = e,
this._forceAlphaTest = e === i.MATERIAL_ALPHATESTANDBLEND,
this._markAllSubMeshesAsTexturesAndMiscDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "_disableAlphaBlending", {
get: function() {
return this._transparencyMode === i.MATERIAL_OPAQUE || this._transparencyMode === i.MATERIAL_ALPHATEST
},
enumerable: !1,
configurable: !0
}),
i.prototype.needAlphaBlending = function() {
return this._disableAlphaBlending ? !1 : this.alpha < 1
}
,
i.prototype.needAlphaBlendingForMesh = function(e) {
return this._disableAlphaBlending && e.visibility >= 1 ? !1 : this.needAlphaBlending() || e.visibility < 1 || e.hasVertexAlpha
}
,
i.prototype.needAlphaTesting = function() {
return !!this._forceAlphaTest
}
,
i.prototype._shouldTurnAlphaTestOn = function(e) {
return !this.needAlphaBlendingForMesh(e) && this.needAlphaTesting()
}
,
i.prototype.getAlphaTestTexture = function() {
return null
}
,
i.prototype.markDirty = function() {
for (var e = this.getScene().meshes, t = 0, r = e; t < r.length; t++) {
var n = r[t];
if (!!n.subMeshes)
for (var o = 0, a = n.subMeshes; o < a.length; o++) {
var s = a[o];
s.getMaterial() === this && (!s.effect || (s.effect._wasPreviouslyReady = !1))
}
}
}
,
i.prototype._preBind = function(e, t) {
t === void 0 && (t = null);
var r = this._scene.getEngine()
, n = t == null ? this.sideOrientation : t
, o = n === i.ClockWiseSideOrientation;
return r.enableEffect(e || this._getDrawWrapper()),
r.setState(this.backFaceCulling, this.zOffset, !1, o, this.cullBackFaces, this.stencil, this.zOffsetUnits),
o
}
,
i.prototype.bind = function(e, t) {}
,
i.prototype.bindForSubMesh = function(e, t, r) {}
,
i.prototype.bindOnlyWorldMatrix = function(e) {}
,
i.prototype.bindView = function(e) {
this._useUBO ? this._needToBindSceneUbo = !0 : e.setMatrix("view", this.getScene().getViewMatrix())
}
,
i.prototype.bindViewProjection = function(e) {
this._useUBO ? this._needToBindSceneUbo = !0 : (e.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
e.setMatrix("projection", this.getScene().getProjectionMatrix()))
}
,
i.prototype.bindEyePosition = function(e, t) {
this._useUBO ? this._needToBindSceneUbo = !0 : this._scene.bindEyePosition(e, t)
}
,
i.prototype._afterBind = function(e, t) {
if (t === void 0 && (t = null),
this._scene._cachedMaterial = this,
this._needToBindSceneUbo && t && (this._needToBindSceneUbo = !1,
MaterialHelper.BindSceneUniformBuffer(t, this.getScene().getSceneUniformBuffer()),
this._scene.finalizeSceneUbo()),
e ? this._scene._cachedVisibility = e.visibility : this._scene._cachedVisibility = 1,
this._onBindObservable && e && this._onBindObservable.notifyObservers(e),
this.disableDepthWrite) {
var r = this._scene.getEngine();
this._cachedDepthWriteState = r.getDepthWrite(),
r.setDepthWrite(!1)
}
if (this.disableColorWrite) {
var r = this._scene.getEngine();
this._cachedColorWriteState = r.getColorWrite(),
r.setColorWrite(!1)
}
if (this.depthFunction !== 0) {
var r = this._scene.getEngine();
this._cachedDepthFunctionState = r.getDepthFunction() || 0,
r.setDepthFunction(this.depthFunction)
}
}
,
i.prototype.unbind = function() {
if (this._onUnBindObservable && this._onUnBindObservable.notifyObservers(this),
this.depthFunction !== 0) {
var e = this._scene.getEngine();
e.setDepthFunction(this._cachedDepthFunctionState)
}
if (this.disableDepthWrite) {
var e = this._scene.getEngine();
e.setDepthWrite(this._cachedDepthWriteState)
}
if (this.disableColorWrite) {
var e = this._scene.getEngine();
e.setColorWrite(this._cachedColorWriteState)
}
}
,
i.prototype.getActiveTextures = function() {
return []
}
,
i.prototype.hasTexture = function(e) {
return !1
}
,
i.prototype.clone = function(e) {
return null
}
,
i.prototype.getBindedMeshes = function() {
var e = this;
if (this.meshMap) {
var t = new Array;
for (var r in this.meshMap) {
var n = this.meshMap[r];
n && t.push(n)
}
return t
} else {
var o = this._scene.meshes;
return o.filter(function(a) {
return a.material === e
})
}
}
,
i.prototype.forceCompilation = function(e, t, r, n) {
var o = this
, a = __assign({
clipPlane: !1,
useInstances: !1
}, r)
, s = this.getScene()
, l = this.allowShaderHotSwapping;
this.allowShaderHotSwapping = !1;
var u = function() {
if (!(!o._scene || !o._scene.getEngine())) {
var c = s.clipPlane;
if (a.clipPlane && (s.clipPlane = new Plane(0,0,0,1)),
o._storeEffectOnSubMeshes) {
var h = !0
, f = null;
if (e.subMeshes) {
var d = new SubMesh(0,0,0,0,0,e,void 0,!1,!1);
d.materialDefines && (d.materialDefines._renderId = -1),
o.isReadyForSubMesh(e, d, a.useInstances) || (d.effect && d.effect.getCompilationError() && d.effect.allFallbacksProcessed() ? f = d.effect.getCompilationError() : (h = !1,
setTimeout(u, 16)))
}
h && (o.allowShaderHotSwapping = l,
f && n && n(f),
t && t(o))
} else
o.isReady() ? (o.allowShaderHotSwapping = l,
t && t(o)) : setTimeout(u, 16);
a.clipPlane && (s.clipPlane = c)
}
};
u()
}
,
i.prototype.forceCompilationAsync = function(e, t) {
var r = this;
return new Promise(function(n, o) {
r.forceCompilation(e, function() {
n()
}, t, function(a) {
o(a)
})
}
)
}
,
i.prototype.markAsDirty = function(e) {
this.getScene().blockMaterialDirtyMechanism || (i._DirtyCallbackArray.length = 0,
e & i.TextureDirtyFlag && i._DirtyCallbackArray.push(i._TextureDirtyCallBack),
e & i.LightDirtyFlag && i._DirtyCallbackArray.push(i._LightsDirtyCallBack),
e & i.FresnelDirtyFlag && i._DirtyCallbackArray.push(i._FresnelDirtyCallBack),
e & i.AttributesDirtyFlag && i._DirtyCallbackArray.push(i._AttributeDirtyCallBack),
e & i.MiscDirtyFlag && i._DirtyCallbackArray.push(i._MiscDirtyCallBack),
e & i.PrePassDirtyFlag && i._DirtyCallbackArray.push(i._PrePassDirtyCallBack),
i._DirtyCallbackArray.length && this._markAllSubMeshesAsDirty(i._RunDirtyCallBacks),
this.getScene().resetCachedMaterial())
}
,
i.prototype._markAllSubMeshesAsDirty = function(e) {
if (!this.getScene().blockMaterialDirtyMechanism)
for (var t = this.getScene().meshes, r = 0, n = t; r < n.length; r++) {
var o = n[r];
if (!!o.subMeshes)
for (var a = 0, s = o.subMeshes; a < s.length; a++) {
var l = s[a];
if (l.getMaterial() === this)
for (var u = 0, c = l._drawWrappers; u < c.length; u++) {
var h = c[u];
!h || !h.defines || !h.defines.markAllAsDirty || this._materialContext === h.materialContext && e(h.defines)
}
}
}
}
,
i.prototype._markScenePrePassDirty = function() {
if (!this.getScene().blockMaterialDirtyMechanism) {
var e = this.getScene().enablePrePassRenderer();
e && e.markAsDirty()
}
}
,
i.prototype._markAllSubMeshesAsAllDirty = function() {
this._markAllSubMeshesAsDirty(i._AllDirtyCallBack)
}
,
i.prototype._markAllSubMeshesAsImageProcessingDirty = function() {
this._markAllSubMeshesAsDirty(i._ImageProcessingDirtyCallBack)
}
,
i.prototype._markAllSubMeshesAsTexturesDirty = function() {
this._markAllSubMeshesAsDirty(i._TextureDirtyCallBack)
}
,
i.prototype._markAllSubMeshesAsFresnelDirty = function() {
this._markAllSubMeshesAsDirty(i._FresnelDirtyCallBack)
}
,
i.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function() {
this._markAllSubMeshesAsDirty(i._FresnelAndMiscDirtyCallBack)
}
,
i.prototype._markAllSubMeshesAsLightsDirty = function() {
this._markAllSubMeshesAsDirty(i._LightsDirtyCallBack)
}
,
i.prototype._markAllSubMeshesAsAttributesDirty = function() {
this._markAllSubMeshesAsDirty(i._AttributeDirtyCallBack)
}
,
i.prototype._markAllSubMeshesAsMiscDirty = function() {
this._markAllSubMeshesAsDirty(i._MiscDirtyCallBack)
}
,
i.prototype._markAllSubMeshesAsPrePassDirty = function() {
this._markAllSubMeshesAsDirty(i._MiscDirtyCallBack)
}
,
i.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function() {
this._markAllSubMeshesAsDirty(i._TextureAndMiscDirtyCallBack)
}
,
i.prototype.setPrePassRenderer = function(e) {
return !1
}
,
i.prototype.dispose = function(e, t, r) {
var n = this.getScene();
if (n.stopAnimation(this),
n.freeProcessedMaterials(),
n.removeMaterial(this),
this._parentContainer) {
var o = this._parentContainer.materials.indexOf(this);
o > -1 && this._parentContainer.materials.splice(o, 1),
this._parentContainer = null
}
if (r !== !0)
if (this.meshMap)
for (var a in this.meshMap) {
var s = this.meshMap[a];
s && (s.material = null,
this.releaseVertexArrayObject(s, e))
}
else
for (var l = n.meshes, u = 0, c = l; u < c.length; u++) {
var s = c[u];
s.material === this && !s.sourceMesh && (s.material = null,
this.releaseVertexArrayObject(s, e))
}
this._uniformBuffer.dispose(),
e && this._drawWrapper.effect && (this._storeEffectOnSubMeshes || this._drawWrapper.effect.dispose(),
this._drawWrapper.effect = null),
this.metadata = null,
this.onDisposeObservable.notifyObservers(this),
this.onDisposeObservable.clear(),
this._onBindObservable && this._onBindObservable.clear(),
this._onUnBindObservable && this._onUnBindObservable.clear(),
this._onEffectCreatedObservable && this._onEffectCreatedObservable.clear()
}
,
i.prototype.releaseVertexArrayObject = function(e, t) {
if (e.geometry) {
var r = e.geometry;
if (this._storeEffectOnSubMeshes)
for (var n = 0, o = e.subMeshes; n < o.length; n++) {
var a = o[n];
r._releaseVertexArrayObject(a.effect),
t && a.effect && a.effect.dispose()
}
else
r._releaseVertexArrayObject(this._drawWrapper.effect)
}
}
,
i.prototype.serialize = function() {
var e = SerializationHelper.Serialize(this);
return e.stencil = this.stencil.serialize(),
e
}
,
i.Parse = function(e, t, r) {
if (!e.customType)
e.customType = "BABYLON.StandardMaterial";
else if (e.customType === "BABYLON.PBRMaterial" && e.overloadedAlbedo && (e.customType = "BABYLON.LegacyPBRMaterial",
!BABYLON.LegacyPBRMaterial))
return Logger$2.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),
null;
var n = Tools.Instantiate(e.customType);
return n.Parse(e, t, r)
}
,
i.TriangleFillMode = 0,
i.WireFrameFillMode = 1,
i.PointFillMode = 2,
i.PointListDrawMode = 3,
i.LineListDrawMode = 4,
i.LineLoopDrawMode = 5,
i.LineStripDrawMode = 6,
i.TriangleStripDrawMode = 7,
i.TriangleFanDrawMode = 8,
i.ClockWiseSideOrientation = 0,
i.CounterClockWiseSideOrientation = 1,
i.TextureDirtyFlag = 1,
i.LightDirtyFlag = 2,
i.FresnelDirtyFlag = 4,
i.AttributesDirtyFlag = 8,
i.MiscDirtyFlag = 16,
i.PrePassDirtyFlag = 32,
i.AllDirtyFlag = 63,
i.MATERIAL_OPAQUE = 0,
i.MATERIAL_ALPHATEST = 1,
i.MATERIAL_ALPHABLEND = 2,
i.MATERIAL_ALPHATESTANDBLEND = 3,
i.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0,
i.MATERIAL_NORMALBLENDMETHOD_RNM = 1,
i._AllDirtyCallBack = function(e) {
return e.markAllAsDirty()
}
,
i._ImageProcessingDirtyCallBack = function(e) {
return e.markAsImageProcessingDirty()
}
,
i._TextureDirtyCallBack = function(e) {
return e.markAsTexturesDirty()
}
,
i._FresnelDirtyCallBack = function(e) {
return e.markAsFresnelDirty()
}
,
i._MiscDirtyCallBack = function(e) {
return e.markAsMiscDirty()
}
,
i._PrePassDirtyCallBack = function(e) {
return e.markAsPrePassDirty()
}
,
i._LightsDirtyCallBack = function(e) {
return e.markAsLightDirty()
}
,
i._AttributeDirtyCallBack = function(e) {
return e.markAsAttributesDirty()
}
,
i._FresnelAndMiscDirtyCallBack = function(e) {
i._FresnelDirtyCallBack(e),
i._MiscDirtyCallBack(e)
}
,
i._TextureAndMiscDirtyCallBack = function(e) {
i._TextureDirtyCallBack(e),
i._MiscDirtyCallBack(e)
}
,
i._DirtyCallbackArray = [],
i._RunDirtyCallBacks = function(e) {
for (var t = 0, r = i._DirtyCallbackArray; t < r.length; t++) {
var n = r[t];
n(e)
}
}
,
__decorate([serialize()], i.prototype, "id", void 0),
__decorate([serialize()], i.prototype, "uniqueId", void 0),
__decorate([serialize()], i.prototype, "name", void 0),
__decorate([serialize()], i.prototype, "metadata", void 0),
__decorate([serialize()], i.prototype, "checkReadyOnEveryCall", void 0),
__decorate([serialize()], i.prototype, "checkReadyOnlyOnce", void 0),
__decorate([serialize()], i.prototype, "state", void 0),
__decorate([serialize("alpha")], i.prototype, "_alpha", void 0),
__decorate([serialize("backFaceCulling")], i.prototype, "_backFaceCulling", void 0),
__decorate([serialize("cullBackFaces")], i.prototype, "_cullBackFaces", void 0),
__decorate([serialize()], i.prototype, "sideOrientation", void 0),
__decorate([serialize("alphaMode")], i.prototype, "_alphaMode", void 0),
__decorate([serialize()], i.prototype, "_needDepthPrePass", void 0),
__decorate([serialize()], i.prototype, "disableDepthWrite", void 0),
__decorate([serialize()], i.prototype, "disableColorWrite", void 0),
__decorate([serialize()], i.prototype, "forceDepthWrite", void 0),
__decorate([serialize()], i.prototype, "depthFunction", void 0),
__decorate([serialize()], i.prototype, "separateCullingPass", void 0),
__decorate([serialize("fogEnabled")], i.prototype, "_fogEnabled", void 0),
__decorate([serialize()], i.prototype, "pointSize", void 0),
__decorate([serialize()], i.prototype, "zOffset", void 0),
__decorate([serialize()], i.prototype, "zOffsetUnits", void 0),
__decorate([serialize()], i.prototype, "pointsCloud", null),
__decorate([serialize()], i.prototype, "fillMode", null),
__decorate([serialize()], i.prototype, "transparencyMode", null),
i
}()
, MultiMaterial = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t, r, !0) || this;
return r.multiMaterials.push(n),
n.subMaterials = new Array,
n._storeEffectOnSubMeshes = !0,
n
}
return Object.defineProperty(e.prototype, "subMaterials", {
get: function() {
return this._subMaterials
},
set: function(t) {
this._subMaterials = t,
this._hookArray(t)
},
enumerable: !1,
configurable: !0
}),
e.prototype.getChildren = function() {
return this.subMaterials
}
,
e.prototype._hookArray = function(t) {
var r = this
, n = t.push;
t.push = function() {
for (var a = [], s = 0; s < arguments.length; s++)
a[s] = arguments[s];
var l = n.apply(t, a);
return r._markAllSubMeshesAsTexturesDirty(),
l
}
;
var o = t.splice;
t.splice = function(a, s) {
var l = o.apply(t, [a, s]);
return r._markAllSubMeshesAsTexturesDirty(),
l
}
}
,
e.prototype.getSubMaterial = function(t) {
return t < 0 || t >= this.subMaterials.length ? this.getScene().defaultMaterial : this.subMaterials[t]
}
,
e.prototype.getActiveTextures = function() {
var t;
return (t = i.prototype.getActiveTextures.call(this)).concat.apply(t, this.subMaterials.map(function(r) {
return r ? r.getActiveTextures() : []
}))
}
,
e.prototype.hasTexture = function(t) {
var r;
if (i.prototype.hasTexture.call(this, t))
return !0;
for (var n = 0; n < this.subMaterials.length; n++)
if (!((r = this.subMaterials[n]) === null || r === void 0) && r.hasTexture(t))
return !0;
return !1
}
,
e.prototype.getClassName = function() {
return "MultiMaterial"
}
,
e.prototype.isReadyForSubMesh = function(t, r, n) {
for (var o = 0; o < this.subMaterials.length; o++) {
var a = this.subMaterials[o];
if (a) {
if (a._storeEffectOnSubMeshes) {
if (!a.isReadyForSubMesh(t, r, n))
return !1;
continue
}
if (!a.isReady(t))
return !1
}
}
return !0
}
,
e.prototype.clone = function(t, r) {
for (var n = new e(t,this.getScene()), o = 0; o < this.subMaterials.length; o++) {
var a = null
, s = this.subMaterials[o];
r && s ? a = s.clone(t + "-" + s.name) : a = this.subMaterials[o],
n.subMaterials.push(a)
}
return n
}
,
e.prototype.serialize = function() {
var t = {};
t.name = this.name,
t.id = this.id,
Tags && (t.tags = Tags.GetTags(this)),
t.materials = [];
for (var r = 0; r < this.subMaterials.length; r++) {
var n = this.subMaterials[r];
n ? t.materials.push(n.id) : t.materials.push(null)
}
return t
}
,
e.prototype.dispose = function(t, r, n) {
var o = this.getScene();
if (!!o) {
if (n)
for (var s = 0; s < this.subMaterials.length; s++) {
var a = this.subMaterials[s];
a && a.dispose(t, r)
}
var s = o.multiMaterials.indexOf(this);
s >= 0 && o.multiMaterials.splice(s, 1),
i.prototype.dispose.call(this, t, r)
}
}
,
e.ParseMultiMaterial = function(t, r) {
var n = new e(t.name,r);
n.id = t.id,
Tags && Tags.AddTagsTo(n, t.tags);
for (var o = 0; o < t.materials.length; o++) {
var a = t.materials[o];
a ? n.subMaterials.push(r.getLastMaterialById(a)) : n.subMaterials.push(null)
}
return n
}
,
e
}(Material);
RegisterClass("BABYLON.MultiMaterial", MultiMaterial);
var MeshLODLevel = function() {
function i(e, t) {
this.distanceOrScreenCoverage = e,
this.mesh = t
}
return i
}()
, _injectLTSMesh = function(i) {
i.prototype.setMaterialByID = function(e) {
return this.setMaterialById(e)
}
,
i.CreateDisc = i.CreateDisc || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateBox = i.CreateBox || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateSphere = i.CreateSphere || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateCylinder = i.CreateCylinder || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateTorusKnot = i.CreateTorusKnot || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateTorus = i.CreateTorus || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreatePlane = i.CreatePlane || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateGround = i.CreateGround || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateTiledGround = i.CreateTiledGround || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateGroundFromHeightMap = i.CreateGroundFromHeightMap || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateTube = i.CreateTube || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreatePolyhedron = i.CreatePolyhedron || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateIcoSphere = i.CreateIcoSphere || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateDecal = i.CreateDecal || function() {
throw _WarnImport("MeshBuilder")
}
,
i.CreateCapsule = i.CreateCapsule || function() {
throw _WarnImport("MeshBuilder")
}
,
i.ExtendToGoldberg = i.ExtendToGoldberg || function() {
throw _WarnImport("MeshBuilder")
}
}
, _CreationDataStorage = function() {
function i() {}
return i
}()
, _InstanceDataStorage = function() {
function i() {
this.visibleInstances = {},
this.batchCache = new _InstancesBatch,
this.batchCacheReplacementModeInFrozenMode = new _InstancesBatch,
this.instancesBufferSize = 32 * 16 * 4
}
return i
}()
, _InstancesBatch = function() {
function i() {
this.mustReturn = !1,
this.visibleInstances = new Array,
this.renderSelf = new Array,
this.hardwareInstancedRendering = new Array
}
return i
}()
, _ThinInstanceDataStorage = function() {
function i() {
this.instancesCount = 0,
this.matrixBuffer = null,
this.previousMatrixBuffer = null,
this.matrixBufferSize = 32 * 16,
this.matrixData = null,
this.boundingVectors = [],
this.worldMatrices = null
}
return i
}()
, _InternalMeshDataInfo = function() {
function i() {
this._areNormalsFrozen = !1,
this._source = null,
this.meshMap = null,
this._preActivateId = -1,
this._LODLevels = new Array,
this._useLODScreenCoverage = !1,
this._effectiveMaterial = null,
this._forcedInstanceCount = 0
}
return i
}()
, Mesh = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s) {
r === void 0 && (r = null),
n === void 0 && (n = null),
o === void 0 && (o = null),
s === void 0 && (s = !0);
var l = i.call(this, t, r) || this;
if (l._internalMeshDataInfo = new _InternalMeshDataInfo,
l.delayLoadState = 0,
l.instances = new Array,
l._creationDataStorage = null,
l._geometry = null,
l._instanceDataStorage = new _InstanceDataStorage,
l._thinInstanceDataStorage = new _ThinInstanceDataStorage,
l._shouldGenerateFlatShading = !1,
l._originalBuilderSideOrientation = e.DEFAULTSIDE,
l.overrideMaterialSideOrientation = null,
l.ignoreCameraMaxZ = !1,
r = l.getScene(),
o) {
if (o._geometry && o._geometry.applyToMesh(l),
DeepCopier.DeepCopy(o, l, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata", "morphTargetManager", "hasInstances", "source", "worldMatrixInstancedBuffer", "previousWorldMatrixInstancedBuffer", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen", "facetNb", "isFacetDataEnabled", "lightSources", "useBones", "isAnInstance", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances", "cloneMeshMap", "hasBoundingInfo"], ["_poseMatrix"]),
l._internalMeshDataInfo._source = o,
r.useClonedMeshMap && (o._internalMeshDataInfo.meshMap || (o._internalMeshDataInfo.meshMap = {}),
o._internalMeshDataInfo.meshMap[l.uniqueId] = l),
l._originalBuilderSideOrientation = o._originalBuilderSideOrientation,
l._creationDataStorage = o._creationDataStorage,
o._ranges) {
var u = o._ranges;
for (var t in u)
!u.hasOwnProperty(t) || !u[t] || l.createAnimationRange(t, u[t].from, u[t].to)
}
o.metadata && o.metadata.clone ? l.metadata = o.metadata.clone() : l.metadata = o.metadata,
Tags && Tags.HasTags(o) && Tags.AddTagsTo(l, Tags.GetTags(o, !0)),
l.setEnabled(o.isEnabled()),
l.parent = o.parent,
l.setPivotMatrix(o.getPivotMatrix()),
l.id = t + "." + o.id,
l.material = o.material;
var c;
if (!a)
for (var h = o.getDescendants(!0), f = 0; f < h.length; f++) {
var d = h[f];
d.clone && d.clone(t + "." + d.name, l)
}
if (o.morphTargetManager && (l.morphTargetManager = o.morphTargetManager),
r.getPhysicsEngine) {
var _ = r.getPhysicsEngine();
if (s && _) {
var g = _.getImpostorForPhysicsObject(o);
g && (l.physicsImpostor = g.clone(l))
}
}
for (c = 0; c < r.particleSystems.length; c++) {
var m = r.particleSystems[c];
m.emitter === o && m.clone(m.name, l)
}
l.refreshBoundingInfo(),
l.computeWorldMatrix(!0)
}
return n !== null && (l.parent = n),
l._instanceDataStorage.hardwareInstancedRendering = l.getEngine().getCaps().instancedArrays,
l._internalMeshDataInfo._onMeshReadyObserverAdded = function(v) {
v.unregisterOnNextCall = !0,
l.isReady(!0) ? l.onMeshReadyObservable.notifyObservers(l) : l._internalMeshDataInfo._checkReadinessObserver || (l._internalMeshDataInfo._checkReadinessObserver = l._scene.onBeforeRenderObservable.add(function() {
l.isReady(!0) && (l._scene.onBeforeRenderObservable.remove(l._internalMeshDataInfo._checkReadinessObserver),
l._internalMeshDataInfo._checkReadinessObserver = null,
l.onMeshReadyObservable.notifyObservers(l))
}))
}
,
l.onMeshReadyObservable = new Observable(l._internalMeshDataInfo._onMeshReadyObserverAdded),
o && o.onClonedObservable.notifyObservers(l),
l
}
return e._GetDefaultSideOrientation = function(t) {
return t || e.FRONTSIDE
}
,
Object.defineProperty(e.prototype, "useLODScreenCoverage", {
get: function() {
return this._internalMeshDataInfo._useLODScreenCoverage
},
set: function(t) {
this._internalMeshDataInfo._useLODScreenCoverage = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "computeBonesUsingShaders", {
get: function() {
return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
},
set: function(t) {
this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== t && (t && this._internalMeshDataInfo._sourcePositions && (this.setVerticesData(VertexBuffer.PositionKind, this._internalMeshDataInfo._sourcePositions.slice(), !0),
this._internalMeshDataInfo._sourceNormals && this.setVerticesData(VertexBuffer.NormalKind, this._internalMeshDataInfo._sourceNormals.slice(), !0)),
this._internalAbstractMeshDataInfo._computeBonesUsingShaders = t,
this._markSubMeshesAsAttributesDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onBeforeRenderObservable", {
get: function() {
return this._internalMeshDataInfo._onBeforeRenderObservable || (this._internalMeshDataInfo._onBeforeRenderObservable = new Observable),
this._internalMeshDataInfo._onBeforeRenderObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onBeforeBindObservable", {
get: function() {
return this._internalMeshDataInfo._onBeforeBindObservable || (this._internalMeshDataInfo._onBeforeBindObservable = new Observable),
this._internalMeshDataInfo._onBeforeBindObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onAfterRenderObservable", {
get: function() {
return this._internalMeshDataInfo._onAfterRenderObservable || (this._internalMeshDataInfo._onAfterRenderObservable = new Observable),
this._internalMeshDataInfo._onAfterRenderObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onBetweenPassObservable", {
get: function() {
return this._internalMeshDataInfo._onBetweenPassObservable || (this._internalMeshDataInfo._onBetweenPassObservable = new Observable),
this._internalMeshDataInfo._onBetweenPassObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onBeforeDrawObservable", {
get: function() {
return this._internalMeshDataInfo._onBeforeDrawObservable || (this._internalMeshDataInfo._onBeforeDrawObservable = new Observable),
this._internalMeshDataInfo._onBeforeDrawObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onBeforeDraw", {
set: function(t) {
this._onBeforeDrawObserver && this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),
this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "hasInstances", {
get: function() {
return this.instances.length > 0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "hasThinInstances", {
get: function() {
var t;
return ((t = this._thinInstanceDataStorage.instancesCount) !== null && t !== void 0 ? t : 0) > 0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "forcedInstanceCount", {
get: function() {
return this._internalMeshDataInfo._forcedInstanceCount
},
set: function(t) {
this._internalMeshDataInfo._forcedInstanceCount = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "source", {
get: function() {
return this._internalMeshDataInfo._source
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cloneMeshMap", {
get: function() {
return this._internalMeshDataInfo.meshMap
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isUnIndexed", {
get: function() {
return this._unIndexed
},
set: function(t) {
this._unIndexed !== t && (this._unIndexed = t,
this._markSubMeshesAsAttributesDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "worldMatrixInstancedBuffer", {
get: function() {
return this._instanceDataStorage.instancesData
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "previousWorldMatrixInstancedBuffer", {
get: function() {
return this._instanceDataStorage.instancesPreviousData
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "manualUpdateOfWorldMatrixInstancedBuffer", {
get: function() {
return this._instanceDataStorage.manualUpdate
},
set: function(t) {
this._instanceDataStorage.manualUpdate = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "manualUpdateOfPreviousWorldMatrixInstancedBuffer", {
get: function() {
return this._instanceDataStorage.previousManualUpdate
},
set: function(t) {
this._instanceDataStorage.previousManualUpdate = t
},
enumerable: !1,
configurable: !0
}),
e.prototype.instantiateHierarchy = function(t, r, n) {
t === void 0 && (t = null);
var o = this.getTotalVertices() > 0 && (!r || !r.doNotInstantiate) ? this.createInstance("instance of " + (this.name || this.id)) : this.clone("Clone of " + (this.name || this.id), t || this.parent, !0);
o && (o.parent = t || this.parent,
o.position = this.position.clone(),
o.scaling = this.scaling.clone(),
this.rotationQuaternion ? o.rotationQuaternion = this.rotationQuaternion.clone() : o.rotation = this.rotation.clone(),
n && n(this, o));
for (var a = 0, s = this.getChildTransformNodes(!0); a < s.length; a++) {
var l = s[a];
l.instantiateHierarchy(o, r, n)
}
return o
}
,
e.prototype.getClassName = function() {
return "Mesh"
}
,
Object.defineProperty(e.prototype, "_isMesh", {
get: function() {
return !0
},
enumerable: !1,
configurable: !0
}),
e.prototype.toString = function(t) {
var r = i.prototype.toString.call(this, t);
if (r += ", n vertices: " + this.getTotalVertices(),
r += ", parent: " + (this._waitingParentId ? this._waitingParentId : this.parent ? this.parent.name : "NONE"),
this.animations)
for (var n = 0; n < this.animations.length; n++)
r += ", animation[0]: " + this.animations[n].toString(t);
if (t)
if (this._geometry) {
var o = this.getIndices()
, a = this.getVerticesData(VertexBuffer.PositionKind);
a && o && (r += ", flat shading: " + (a.length / 3 === o.length ? "YES" : "NO"))
} else
r += ", flat shading: UNKNOWN";
return r
}
,
e.prototype._unBindEffect = function() {
i.prototype._unBindEffect.call(this);
for (var t = 0, r = this.instances; t < r.length; t++) {
var n = r[t];
n._unBindEffect()
}
}
,
Object.defineProperty(e.prototype, "hasLODLevels", {
get: function() {
return this._internalMeshDataInfo._LODLevels.length > 0
},
enumerable: !1,
configurable: !0
}),
e.prototype.getLODLevels = function() {
return this._internalMeshDataInfo._LODLevels
}
,
e.prototype._sortLODLevels = function() {
var t = this._internalMeshDataInfo._useLODScreenCoverage ? -1 : 1;
this._internalMeshDataInfo._LODLevels.sort(function(r, n) {
return r.distanceOrScreenCoverage < n.distanceOrScreenCoverage ? t : r.distanceOrScreenCoverage > n.distanceOrScreenCoverage ? -t : 0
})
}
,
e.prototype.addLODLevel = function(t, r) {
if (r && r._masterMesh)
return Logger$2.Warn("You cannot use a mesh as LOD level twice"),
this;
var n = new MeshLODLevel(t,r);
return this._internalMeshDataInfo._LODLevels.push(n),
r && (r._masterMesh = this),
this._sortLODLevels(),
this
}
,
e.prototype.getLODLevelAtDistance = function(t) {
for (var r = this._internalMeshDataInfo, n = 0; n < r._LODLevels.length; n++) {
var o = r._LODLevels[n];
if (o.distanceOrScreenCoverage === t)
return o.mesh
}
return null
}
,
e.prototype.removeLODLevel = function(t) {
for (var r = this._internalMeshDataInfo, n = 0; n < r._LODLevels.length; n++)
r._LODLevels[n].mesh === t && (r._LODLevels.splice(n, 1),
t && (t._masterMesh = null));
return this._sortLODLevels(),
this
}
,
e.prototype.getLOD = function(t, r) {
var n = this._internalMeshDataInfo;
if (!n._LODLevels || n._LODLevels.length === 0)
return this;
var o;
if (r)
o = r;
else {
var a = this.getBoundingInfo();
o = a.boundingSphere
}
var s = o.centerWorld.subtract(t.globalPosition).length()
, l = n._useLODScreenCoverage
, u = s
, c = 1;
if (l) {
var h = t.screenArea
, f = o.radiusWorld * t.minZ / s;
f = f * f * Math.PI,
u = f / h,
c = -1
}
if (c * n._LODLevels[n._LODLevels.length - 1].distanceOrScreenCoverage > c * u)
return this.onLODLevelSelection && this.onLODLevelSelection(u, this, this),
this;
for (var d = 0; d < n._LODLevels.length; d++) {
var _ = n._LODLevels[d];
if (c * _.distanceOrScreenCoverage < c * u) {
if (_.mesh) {
if (_.mesh.delayLoadState === 4)
return _.mesh._checkDelayState(),
this;
if (_.mesh.delayLoadState === 2)
return this;
_.mesh._preActivate(),
_.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)
}
return this.onLODLevelSelection && this.onLODLevelSelection(u, this, _.mesh),
_.mesh
}
}
return this.onLODLevelSelection && this.onLODLevelSelection(u, this, this),
this
}
,
Object.defineProperty(e.prototype, "geometry", {
get: function() {
return this._geometry
},
enumerable: !1,
configurable: !0
}),
e.prototype.getTotalVertices = function() {
return this._geometry === null || this._geometry === void 0 ? 0 : this._geometry.getTotalVertices()
}
,
e.prototype.getVerticesData = function(t, r, n) {
var o, a;
if (!this._geometry)
return null;
var s = (a = (o = this._userInstancedBuffersStorage) === null || o === void 0 ? void 0 : o.vertexBuffers[t]) === null || a === void 0 ? void 0 : a.getFloatData(this._geometry.getTotalVertices(), n || r && this._geometry.meshes.length !== 1);
return s || (s = this._geometry.getVerticesData(t, r, n)),
s
}
,
e.prototype.getVertexBuffer = function(t) {
var r, n;
return this._geometry ? (n = (r = this._userInstancedBuffersStorage) === null || r === void 0 ? void 0 : r.vertexBuffers[t]) !== null && n !== void 0 ? n : this._geometry.getVertexBuffer(t) : null
}
,
e.prototype.isVerticesDataPresent = function(t) {
var r;
return this._geometry ? ((r = this._userInstancedBuffersStorage) === null || r === void 0 ? void 0 : r.vertexBuffers[t]) !== void 0 || this._geometry.isVerticesDataPresent(t) : this._delayInfo ? this._delayInfo.indexOf(t) !== -1 : !1
}
,
e.prototype.isVertexBufferUpdatable = function(t) {
var r, n;
return this._geometry ? ((n = (r = this._userInstancedBuffersStorage) === null || r === void 0 ? void 0 : r.vertexBuffers[t]) === null || n === void 0 ? void 0 : n.isUpdatable()) || this._geometry.isVertexBufferUpdatable(t) : this._delayInfo ? this._delayInfo.indexOf(t) !== -1 : !1
}
,
e.prototype.getVerticesDataKinds = function() {
if (!this._geometry) {
var t = new Array;
return this._delayInfo && this._delayInfo.forEach(function(o) {
t.push(o)
}),
t
}
var r = this._geometry.getVerticesDataKinds();
if (this._userInstancedBuffersStorage)
for (var n in this._userInstancedBuffersStorage.vertexBuffers)
r.push(n);
return r
}
,
e.prototype.getTotalIndices = function() {
return this._geometry ? this._geometry.getTotalIndices() : 0
}
,
e.prototype.getIndices = function(t, r) {
return this._geometry ? this._geometry.getIndices(t, r) : []
}
,
Object.defineProperty(e.prototype, "isBlocked", {
get: function() {
return this._masterMesh !== null && this._masterMesh !== void 0
},
enumerable: !1,
configurable: !0
}),
e.prototype.isReady = function(t, r) {
var n, o, a, s, l, u;
if (t === void 0 && (t = !1),
r === void 0 && (r = !1),
this.delayLoadState === 2 || !i.prototype.isReady.call(this, t))
return !1;
if (!this.subMeshes || this.subMeshes.length === 0 || !t)
return !0;
var c = this.getEngine()
, h = this.getScene()
, f = r || c.getCaps().instancedArrays && (this.instances.length > 0 || this.hasThinInstances);
this.computeWorldMatrix();
var d = this.material || h.defaultMaterial;
if (d) {
if (d._storeEffectOnSubMeshes)
for (var _ = 0, g = this.subMeshes; _ < g.length; _++) {
var m = g[_]
, v = m.getMaterial();
if (v) {
if (v._storeEffectOnSubMeshes) {
if (!v.isReadyForSubMesh(this, m, f))
return !1
} else if (!v.isReady(this, f))
return !1
}
}
else if (!d.isReady(this, f))
return !1
}
for (var y = c.currentRenderPassId, b = 0, T = this.lightSources; b < T.length; b++) {
var C = T[b]
, A = C.getShadowGenerator();
if (A && (!(!((n = A.getShadowMap()) === null || n === void 0) && n.renderList) || ((o = A.getShadowMap()) === null || o === void 0 ? void 0 : o.renderList) && ((s = (a = A.getShadowMap()) === null || a === void 0 ? void 0 : a.renderList) === null || s === void 0 ? void 0 : s.indexOf(this)) !== -1)) {
A.getShadowMap() && (c.currentRenderPassId = A.getShadowMap().renderPassId);
for (var S = 0, P = this.subMeshes; S < P.length; S++) {
var m = P[S];
if (!A.isReady(m, f, (u = (l = m.getMaterial()) === null || l === void 0 ? void 0 : l.needAlphaBlendingForMesh(this)) !== null && u !== void 0 ? u : !1))
return c.currentRenderPassId = y,
!1
}
c.currentRenderPassId = y
}
}
for (var R = 0, M = this._internalMeshDataInfo._LODLevels; R < M.length; R++) {
var x = M[R];
if (x.mesh && !x.mesh.isReady(f))
return !1
}
return !0
}
,
Object.defineProperty(e.prototype, "areNormalsFrozen", {
get: function() {
return this._internalMeshDataInfo._areNormalsFrozen
},
enumerable: !1,
configurable: !0
}),
e.prototype.freezeNormals = function() {
return this._internalMeshDataInfo._areNormalsFrozen = !0,
this
}
,
e.prototype.unfreezeNormals = function() {
return this._internalMeshDataInfo._areNormalsFrozen = !1,
this
}
,
Object.defineProperty(e.prototype, "overridenInstanceCount", {
set: function(t) {
this._instanceDataStorage.overridenInstanceCount = t
},
enumerable: !1,
configurable: !0
}),
e.prototype._preActivate = function() {
var t = this._internalMeshDataInfo
, r = this.getScene().getRenderId();
return t._preActivateId === r ? this : (t._preActivateId = r,
this._instanceDataStorage.visibleInstances = null,
this)
}
,
e.prototype._preActivateForIntermediateRendering = function(t) {
return this._instanceDataStorage.visibleInstances && (this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = t),
this
}
,
e.prototype._registerInstanceForRenderId = function(t, r) {
return this._instanceDataStorage.visibleInstances || (this._instanceDataStorage.visibleInstances = {
defaultRenderId: r,
selfDefaultRenderId: this._renderId
}),
this._instanceDataStorage.visibleInstances[r] || (this._instanceDataStorage.previousRenderId !== void 0 && this._instanceDataStorage.isFrozen && (this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId] = null),
this._instanceDataStorage.previousRenderId = r,
this._instanceDataStorage.visibleInstances[r] = new Array),
this._instanceDataStorage.visibleInstances[r].push(t),
this
}
,
e.prototype._afterComputeWorldMatrix = function() {
i.prototype._afterComputeWorldMatrix.call(this),
this.hasThinInstances && (this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1))
}
,
e.prototype._postActivate = function() {
this.edgesShareWithInstances && this.edgesRenderer && this.edgesRenderer.isEnabled && this._renderingGroup && (this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),
this.edgesRenderer.customInstances.push(this.getWorldMatrix()))
}
,
e.prototype.refreshBoundingInfo = function(t, r) {
if (t === void 0 && (t = !1),
r === void 0 && (r = !0),
this.hasBoundingInfo && this.getBoundingInfo().isLocked)
return this;
var n = this.geometry ? this.geometry.boundingBias : null;
return this._refreshBoundingInfo(this._getPositionData(t, r), n),
this
}
,
e.prototype._createGlobalSubMesh = function(t) {
var r = this.getTotalVertices();
if (!r || !this.getIndices())
return null;
if (this.subMeshes && this.subMeshes.length > 0) {
var n = this.getIndices();
if (!n)
return null;
var o = n.length
, a = !1;
if (t)
a = !0;
else
for (var s = 0, l = this.subMeshes; s < l.length; s++) {
var u = l[s];
if (u.indexStart + u.indexCount > o) {
a = !0;
break
}
if (u.verticesStart + u.verticesCount > r) {
a = !0;
break
}
}
if (!a)
return this.subMeshes[0]
}
return this.releaseSubMeshes(),
new SubMesh(0,0,r,0,this.getTotalIndices(),this)
}
,
e.prototype.subdivide = function(t) {
if (!(t < 1)) {
for (var r = this.getTotalIndices(), n = r / t | 0, o = 0; n % 3 !== 0; )
n++;
this.releaseSubMeshes();
for (var a = 0; a < t && !(o >= r); a++)
SubMesh.CreateFromIndices(0, o, a === t - 1 ? r - o : n, this),
o += n;
this.synchronizeInstances()
}
}
,
e.prototype.setVerticesData = function(t, r, n, o) {
if (n === void 0 && (n = !1),
this._geometry)
this._geometry.setVerticesData(t, r, n, o);
else {
var a = new VertexData;
a.set(r, t);
var s = this.getScene();
new Geometry(Geometry.RandomId(),s,a,n,this)
}
return this
}
,
e.prototype.removeVerticesData = function(t) {
!this._geometry || this._geometry.removeVerticesData(t)
}
,
e.prototype.markVerticesDataAsUpdatable = function(t, r) {
r === void 0 && (r = !0);
var n = this.getVertexBuffer(t);
!n || n.isUpdatable() === r || this.setVerticesData(t, this.getVerticesData(t), r)
}
,
e.prototype.setVerticesBuffer = function(t, r) {
return r === void 0 && (r = !0),
this._geometry || (this._geometry = Geometry.CreateGeometryForMesh(this)),
this._geometry.setVerticesBuffer(t, null, r),
this
}
,
e.prototype.updateVerticesData = function(t, r, n, o) {
return this._geometry ? (o ? (this.makeGeometryUnique(),
this.updateVerticesData(t, r, n, !1)) : this._geometry.updateVerticesData(t, r, n),
this) : this
}
,
e.prototype.updateMeshPositions = function(t, r) {
r === void 0 && (r = !0);
var n = this.getVerticesData(VertexBuffer.PositionKind);
if (!n)
return this;
if (t(n),
this.updateVerticesData(VertexBuffer.PositionKind, n, !1, !1),
r) {
var o = this.getIndices()
, a = this.getVerticesData(VertexBuffer.NormalKind);
if (!a)
return this;
VertexData.ComputeNormals(n, o, a),
this.updateVerticesData(VertexBuffer.NormalKind, a, !1, !1)
}
return this
}
,
e.prototype.makeGeometryUnique = function() {
if (!this._geometry)
return this;
if (this._geometry.meshes.length === 1)
return this;
var t = this._geometry
, r = this._geometry.copy(Geometry.RandomId());
return t.releaseForMesh(this, !0),
r.applyToMesh(this),
this
}
,
e.prototype.setIndices = function(t, r, n) {
if (r === void 0 && (r = null),
n === void 0 && (n = !1),
this._geometry)
this._geometry.setIndices(t, r, n);
else {
var o = new VertexData;
o.indices = t;
var a = this.getScene();
new Geometry(Geometry.RandomId(),a,o,n,this)
}
return this
}
,
e.prototype.updateIndices = function(t, r, n) {
return n === void 0 && (n = !1),
this._geometry ? (this._geometry.updateIndices(t, r, n),
this) : this
}
,
e.prototype.toLeftHanded = function() {
return this._geometry ? (this._geometry.toLeftHanded(),
this) : this
}
,
e.prototype._bind = function(t, r, n) {
if (!this._geometry)
return this;
var o = this.getScene().getEngine();
this.morphTargetManager && this.morphTargetManager.isUsingTextureForTargets && this.morphTargetManager._bind(r);
var a;
if (this._unIndexed)
a = null;
else
switch (n) {
case Material.PointFillMode:
a = null;
break;
case Material.WireFrameFillMode:
a = t._getLinesIndexBuffer(this.getIndices(), o);
break;
default:
case Material.TriangleFillMode:
a = this._geometry.getIndexBuffer();
break
}
return !this._userInstancedBuffersStorage || this.hasThinInstances ? this._geometry._bind(r, a) : this._geometry._bind(r, a, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects),
this
}
,
e.prototype._draw = function(t, r, n) {
if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
return this;
this._internalMeshDataInfo._onBeforeDrawObservable && this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);
var o = this.getScene()
, a = o.getEngine();
return this._unIndexed || r == Material.PointFillMode ? a.drawArraysType(r, t.verticesStart, t.verticesCount, this.forcedInstanceCount || n) : r == Material.WireFrameFillMode ? a.drawElementsType(r, 0, t._linesIndexCount, this.forcedInstanceCount || n) : a.drawElementsType(r, t.indexStart, t.indexCount, this.forcedInstanceCount || n),
this
}
,
e.prototype.registerBeforeRender = function(t) {
return this.onBeforeRenderObservable.add(t),
this
}
,
e.prototype.unregisterBeforeRender = function(t) {
return this.onBeforeRenderObservable.removeCallback(t),
this
}
,
e.prototype.registerAfterRender = function(t) {
return this.onAfterRenderObservable.add(t),
this
}
,
e.prototype.unregisterAfterRender = function(t) {
return this.onAfterRenderObservable.removeCallback(t),
this
}
,
e.prototype._getInstancesRenderList = function(t, r) {
if (r === void 0 && (r = !1),
this._instanceDataStorage.isFrozen) {
if (r)
return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[t] = !1,
this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[t] = !0,
this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;
if (this._instanceDataStorage.previousBatch)
return this._instanceDataStorage.previousBatch
}
var n = this.getScene()
, o = n._isInIntermediateRendering()
, a = o ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances
, s = this._instanceDataStorage.batchCache;
if (s.mustReturn = !1,
s.renderSelf[t] = r || !a && this.isEnabled() && this.isVisible,
s.visibleInstances[t] = null,
this._instanceDataStorage.visibleInstances && !r) {
var l = this._instanceDataStorage.visibleInstances
, u = n.getRenderId()
, c = o ? l.intermediateDefaultRenderId : l.defaultRenderId;
s.visibleInstances[t] = l[u],
!s.visibleInstances[t] && c && (s.visibleInstances[t] = l[c])
}
return s.hardwareInstancedRendering[t] = !r && this._instanceDataStorage.hardwareInstancedRendering && s.visibleInstances[t] !== null && s.visibleInstances[t] !== void 0,
this._instanceDataStorage.previousBatch = s,
s
}
,
e.prototype._renderWithInstances = function(t, r, n, o, a) {
var s, l = n.visibleInstances[t._id];
if (!l)
return this;
for (var u = this._instanceDataStorage, c = u.instancesBufferSize, h = u.instancesBuffer, f = u.instancesPreviousBuffer, d = l.length + 1, _ = d * 16 * 4; u.instancesBufferSize < _; )
u.instancesBufferSize *= 2;
(!u.instancesData || c != u.instancesBufferSize) && (u.instancesData = new Float32Array(u.instancesBufferSize / 4)),
(this._scene.needsPreviousWorldMatrices && !u.instancesPreviousData || c != u.instancesBufferSize) && (u.instancesPreviousData = new Float32Array(u.instancesBufferSize / 4));
var g = 0
, m = 0
, v = n.renderSelf[t._id]
, y = !h || c !== u.instancesBufferSize || this._scene.needsPreviousWorldMatrices && !u.instancesPreviousBuffer;
if (!this._instanceDataStorage.manualUpdate && (!u.isFrozen || y)) {
var b = this._effectiveMesh.getWorldMatrix();
if (v && (this._scene.needsPreviousWorldMatrices && (u.masterMeshPreviousWorldMatrix ? (u.masterMeshPreviousWorldMatrix.copyToArray(u.instancesPreviousData, g),
u.masterMeshPreviousWorldMatrix.copyFrom(b)) : (u.masterMeshPreviousWorldMatrix = b.clone(),
u.masterMeshPreviousWorldMatrix.copyToArray(u.instancesPreviousData, g))),
b.copyToArray(u.instancesData, g),
g += 16,
m++),
l) {
if (e.INSTANCEDMESH_SORT_TRANSPARENT && this._scene.activeCamera && ((s = t.getMaterial()) === null || s === void 0 ? void 0 : s.needAlphaBlendingForMesh(t.getRenderingMesh()))) {
for (var T = this._scene.activeCamera.globalPosition, C = 0; C < l.length; C++) {
var A = l[C];
A._distanceToCamera = Vector3.Distance(A.getBoundingInfo().boundingSphere.centerWorld, T)
}
l.sort(function(M, x) {
return M._distanceToCamera > x._distanceToCamera ? -1 : M._distanceToCamera < x._distanceToCamera ? 1 : 0
})
}
for (var S = 0; S < l.length; S++) {
var P = l[S]
, R = P.getWorldMatrix();
R.copyToArray(u.instancesData, g),
this._scene.needsPreviousWorldMatrices && (P._previousWorldMatrix ? (P._previousWorldMatrix.copyToArray(u.instancesPreviousData, g),
P._previousWorldMatrix.copyFrom(R)) : (P._previousWorldMatrix = R.clone(),
P._previousWorldMatrix.copyToArray(u.instancesPreviousData, g))),
g += 16,
m++
}
}
} else
m = (v ? 1 : 0) + l.length;
return y ? (h && h.dispose(),
f && f.dispose(),
h = new Buffer(a,u.instancesData,!0,16,!1,!0),
u.instancesBuffer = h,
this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = {
data: {},
vertexBuffers: {},
strides: {},
sizes: {},
vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
}),
this._userInstancedBuffersStorage.vertexBuffers.world0 = h.createVertexBuffer("world0", 0, 4),
this._userInstancedBuffersStorage.vertexBuffers.world1 = h.createVertexBuffer("world1", 4, 4),
this._userInstancedBuffersStorage.vertexBuffers.world2 = h.createVertexBuffer("world2", 8, 4),
this._userInstancedBuffersStorage.vertexBuffers.world3 = h.createVertexBuffer("world3", 12, 4),
this._scene.needsPreviousWorldMatrices && (f = new Buffer(a,u.instancesPreviousData,!0,16,!1,!0),
u.instancesPreviousBuffer = f,
this._userInstancedBuffersStorage.vertexBuffers.previousWorld0 = f.createVertexBuffer("previousWorld0", 0, 4),
this._userInstancedBuffersStorage.vertexBuffers.previousWorld1 = f.createVertexBuffer("previousWorld1", 4, 4),
this._userInstancedBuffersStorage.vertexBuffers.previousWorld2 = f.createVertexBuffer("previousWorld2", 8, 4),
this._userInstancedBuffersStorage.vertexBuffers.previousWorld3 = f.createVertexBuffer("previousWorld3", 12, 4)),
this._invalidateInstanceVertexArrayObject()) : this._instanceDataStorage.isFrozen || (h.updateDirectly(u.instancesData, 0, m),
this._scene.needsPreviousWorldMatrices && (!this._instanceDataStorage.manualUpdate || this._instanceDataStorage.previousManualUpdate) && f.updateDirectly(u.instancesPreviousData, 0, m)),
this._processInstancedBuffers(l, v),
this.getScene()._activeIndices.addCount(t.indexCount * m, !1),
a._currentDrawContext && (a._currentDrawContext.useInstancing = !0),
this._bind(t, o, r),
this._draw(t, r, m),
this._scene.needsPreviousWorldMatrices && !y && this._instanceDataStorage.manualUpdate && !this._instanceDataStorage.isFrozen && !this._instanceDataStorage.previousManualUpdate && f.updateDirectly(u.instancesData, 0, m),
a.unbindInstanceAttributes(),
this
}
,
e.prototype._renderWithThinInstances = function(t, r, n, o) {
var a, s, l = (s = (a = this._thinInstanceDataStorage) === null || a === void 0 ? void 0 : a.instancesCount) !== null && s !== void 0 ? s : 0;
this.getScene()._activeIndices.addCount(t.indexCount * l, !1),
o._currentDrawContext && (o._currentDrawContext.useInstancing = !0),
this._bind(t, n, r),
this._draw(t, r, l),
this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && this._thinInstanceDataStorage.matrixData && (this._thinInstanceDataStorage.previousMatrixBuffer ? this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, l) : this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", this._thinInstanceDataStorage.matrixData, !1)),
o.unbindInstanceAttributes()
}
,
e.prototype._processInstancedBuffers = function(t, r) {}
,
e.prototype._processRendering = function(t, r, n, o, a, s, l, u) {
var c = this.getScene()
, h = c.getEngine();
if (s && r.getRenderingMesh().hasThinInstances)
return this._renderWithThinInstances(r, o, n, h),
this;
if (s)
this._renderWithInstances(r, o, a, n, h);
else {
h._currentDrawContext && (h._currentDrawContext.useInstancing = !1);
var f = 0;
a.renderSelf[r._id] && (l && l(!1, t._effectiveMesh.getWorldMatrix(), u, t._effectiveMesh),
f++,
this._draw(r, o, this._instanceDataStorage.overridenInstanceCount));
var d = a.visibleInstances[r._id];
if (d) {
var _ = d.length;
f += _;
for (var g = 0; g < _; g++) {
var m = d[g]
, v = m.getWorldMatrix();
l && l(!0, v, u),
this._draw(r, o)
}
}
c._activeIndices.addCount(r.indexCount * f, !1)
}
return this
}
,
e.prototype._rebuild = function(t) {
if (t === void 0 && (t = !1),
this._instanceDataStorage.instancesBuffer && (t && this._instanceDataStorage.instancesBuffer.dispose(),
this._instanceDataStorage.instancesBuffer = null),
this._userInstancedBuffersStorage) {
for (var r in this._userInstancedBuffersStorage.vertexBuffers) {
var n = this._userInstancedBuffersStorage.vertexBuffers[r];
n && (t && n.dispose(),
this._userInstancedBuffersStorage.vertexBuffers[r] = null)
}
this._userInstancedBuffersStorage.vertexArrayObjects && (this._userInstancedBuffersStorage.vertexArrayObjects = {})
}
this._internalMeshDataInfo._effectiveMaterial = null,
i.prototype._rebuild.call(this, t)
}
,
e.prototype._freeze = function() {
if (!!this.subMeshes) {
for (var t = 0; t < this.subMeshes.length; t++)
this._getInstancesRenderList(t);
this._internalMeshDataInfo._effectiveMaterial = null,
this._instanceDataStorage.isFrozen = !0
}
}
,
e.prototype._unFreeze = function() {
this._instanceDataStorage.isFrozen = !1,
this._instanceDataStorage.previousBatch = null
}
,
e.prototype.render = function(t, r, n) {
var o, a, s, l = this.getScene();
if (this._internalAbstractMeshDataInfo._isActiveIntermediate ? this._internalAbstractMeshDataInfo._isActiveIntermediate = !1 : this._internalAbstractMeshDataInfo._isActive = !1,
this._checkOcclusionQuery())
return this;
var u = this._getInstancesRenderList(t._id, !!n);
if (u.mustReturn)
return this;
if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
return this;
var c = l.getEngine()
, h = 0
, f = null;
this.ignoreCameraMaxZ && l.activeCamera && !l._isInIntermediateRendering() && (h = l.activeCamera.maxZ,
f = l.activeCamera,
l.activeCamera.maxZ = 0,
l.updateTransformMatrix(!0)),
this._internalMeshDataInfo._onBeforeRenderObservable && this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);
var d = u.hardwareInstancedRendering[t._id] || t.getRenderingMesh().hasThinInstances
, _ = this._instanceDataStorage
, g = t.getMaterial();
if (!g)
return f && (f.maxZ = h,
l.updateTransformMatrix(!0)),
this;
if (!_.isFrozen || !this._internalMeshDataInfo._effectiveMaterial || this._internalMeshDataInfo._effectiveMaterial !== g) {
if (g._storeEffectOnSubMeshes) {
if (!g.isReadyForSubMesh(this, t, d))
return f && (f.maxZ = h,
l.updateTransformMatrix(!0)),
this
} else if (!g.isReady(this, d))
return f && (f.maxZ = h,
l.updateTransformMatrix(!0)),
this;
this._internalMeshDataInfo._effectiveMaterial = g
} else if (g._storeEffectOnSubMeshes && !(!((o = t.effect) === null || o === void 0) && o._wasPreviouslyReady) || !g._storeEffectOnSubMeshes && !(!((a = g.getEffect()) === null || a === void 0) && a._wasPreviouslyReady))
return f && (f.maxZ = h,
l.updateTransformMatrix(!0)),
this;
r && c.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);
var m;
this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes ? m = t._drawWrapper : m = this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();
for (var v = (s = m == null ? void 0 : m.effect) !== null && s !== void 0 ? s : null, y = 0, b = l._beforeRenderingMeshStage; y < b.length; y++) {
var T = b[y];
T.action(this, t, u, v)
}
if (!m || !v)
return f && (f.maxZ = h,
l.updateTransformMatrix(!0)),
this;
var C = n || this._effectiveMesh, A;
if (!_.isFrozen && (this._internalMeshDataInfo._effectiveMaterial.backFaceCulling || this.overrideMaterialSideOrientation !== null)) {
var S = C._getWorldMatrixDeterminant();
A = this.overrideMaterialSideOrientation,
A == null && (A = this._internalMeshDataInfo._effectiveMaterial.sideOrientation),
S < 0 && (A = A === Material.ClockWiseSideOrientation ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation),
_.sideOrientation = A
} else
A = _.sideOrientation;
var P = this._internalMeshDataInfo._effectiveMaterial._preBind(m, A);
this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite && c.setDepthWrite(!0);
var R = l.forcePointsCloud ? Material.PointFillMode : l.forceWireframe ? Material.WireFrameFillMode : this._internalMeshDataInfo._effectiveMaterial.fillMode;
this._internalMeshDataInfo._onBeforeBindObservable && this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),
d || this._bind(t, v, R);
var M = this._internalMeshDataInfo._effectiveMaterial
, x = C.getWorldMatrix();
M._storeEffectOnSubMeshes ? M.bindForSubMesh(x, this, t) : M.bind(x, this),
!M.backFaceCulling && M.separateCullingPass && (c.setState(!0, M.zOffset, !1, !P, M.cullBackFaces, M.stencil, M.zOffsetUnits),
this._processRendering(this, t, v, R, u, d, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
c.setState(!0, M.zOffset, !1, P, M.cullBackFaces, M.stencil, M.zOffsetUnits),
this._internalMeshDataInfo._onBetweenPassObservable && this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(t)),
this._processRendering(this, t, v, R, u, d, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
this._internalMeshDataInfo._effectiveMaterial.unbind();
for (var I = 0, w = l._afterRenderingMeshStage; I < w.length; I++) {
var T = w[I];
T.action(this, t, u, v)
}
return this._internalMeshDataInfo._onAfterRenderObservable && this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),
f && (f.maxZ = h,
l.updateTransformMatrix(!0)),
this
}
,
e.prototype._onBeforeDraw = function(t, r, n) {
t && n && n.bindOnlyWorldMatrix(r)
}
,
e.prototype.cleanMatrixWeights = function() {
this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) && (this.isVerticesDataPresent(VertexBuffer.MatricesWeightsExtraKind) ? this.normalizeSkinWeightsAndExtra() : this.normalizeSkinFourWeights())
}
,
e.prototype.normalizeSkinFourWeights = function() {
for (var t = this.getVerticesData(VertexBuffer.MatricesWeightsKind), r = t.length, n = 0; n < r; n += 4) {
var o = t[n] + t[n + 1] + t[n + 2] + t[n + 3];
if (o === 0)
t[n] = 1;
else {
var a = 1 / o;
t[n] *= a,
t[n + 1] *= a,
t[n + 2] *= a,
t[n + 3] *= a
}
}
this.setVerticesData(VertexBuffer.MatricesWeightsKind, t)
}
,
e.prototype.normalizeSkinWeightsAndExtra = function() {
for (var t = this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind), r = this.getVerticesData(VertexBuffer.MatricesWeightsKind), n = r.length, o = 0; o < n; o += 4) {
var a = r[o] + r[o + 1] + r[o + 2] + r[o + 3];
if (a += t[o] + t[o + 1] + t[o + 2] + t[o + 3],
a === 0)
r[o] = 1;
else {
var s = 1 / a;
r[o] *= s,
r[o + 1] *= s,
r[o + 2] *= s,
r[o + 3] *= s,
t[o] *= s,
t[o + 1] *= s,
t[o + 2] *= s,
t[o + 3] *= s
}
}
this.setVerticesData(VertexBuffer.MatricesWeightsKind, r),
this.setVerticesData(VertexBuffer.MatricesWeightsKind, t)
}
,
e.prototype.validateSkinning = function() {
var t = this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind)
, r = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
if (r === null || this.skeleton == null)
return {
skinned: !1,
valid: !0,
report: "not skinned"
};
for (var n = r.length, o = 0, a = 0, s = 0, l = 0, u = t === null ? 4 : 8, c = new Array, h = 0; h <= u; h++)
c[h] = 0;
for (var f = .001, h = 0; h < n; h += 4) {
for (var d = r[h], _ = d, g = _ === 0 ? 0 : 1, m = 1; m < u; m++) {
var v = m < 4 ? r[h + m] : t[h + m - 4];
v > d && o++,
v !== 0 && g++,
_ += v,
d = v
}
if (c[g]++,
g > s && (s = g),
_ === 0)
a++;
else {
var y = 1 / _
, b = 0;
for (m = 0; m < u; m++)
m < 4 ? b += Math.abs(r[h + m] - r[h + m] * y) : b += Math.abs(t[h + m - 4] - t[h + m - 4] * y);
b > f && l++
}
}
for (var T = this.skeleton.bones.length, C = this.getVerticesData(VertexBuffer.MatricesIndicesKind), A = this.getVerticesData(VertexBuffer.MatricesIndicesExtraKind), S = 0, h = 0; h < n; h += 4)
for (var m = 0; m < u; m++) {
var P = m < 4 ? C[h + m] : A[h + m - 4];
(P >= T || P < 0) && S++
}
var R = "Number of Weights = " + n / 4 + `
Maximum influences = ` + s + `
Missing Weights = ` + a + `
Not Sorted = ` + o + `
Not Normalized = ` + l + `
WeightCounts = [` + c + `]
Number of bones = ` + T + `
Bad Bone Indices = ` + S;
return {
skinned: !0,
valid: a === 0 && l === 0 && S === 0,
report: R
}
}
,
e.prototype._checkDelayState = function() {
var t = this.getScene();
return this._geometry ? this._geometry.load(t) : this.delayLoadState === 4 && (this.delayLoadState = 2,
this._queueLoad(t)),
this
}
,
e.prototype._queueLoad = function(t) {
var r = this;
t._addPendingData(this);
var n = this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1;
return Tools.LoadFile(this.delayLoadingFile, function(o) {
o instanceof ArrayBuffer ? r._delayLoadingFunction(o, r) : r._delayLoadingFunction(JSON.parse(o), r),
r.instances.forEach(function(a) {
a.refreshBoundingInfo(),
a._syncSubMeshes()
}),
r.delayLoadState = 1,
t._removePendingData(r)
}, function() {}, t.offlineProvider, n),
this
}
,
e.prototype.isInFrustum = function(t) {
return this.delayLoadState === 2 || !i.prototype.isInFrustum.call(this, t) ? !1 : (this._checkDelayState(),
!0)
}
,
e.prototype.setMaterialById = function(t) {
var r = this.getScene().materials, n;
for (n = r.length - 1; n > -1; n--)
if (r[n].id === t)
return this.material = r[n],
this;
var o = this.getScene().multiMaterials;
for (n = o.length - 1; n > -1; n--)
if (o[n].id === t)
return this.material = o[n],
this;
return this
}
,
e.prototype.getAnimatables = function() {
var t = new Array;
return this.material && t.push(this.material),
this.skeleton && t.push(this.skeleton),
t
}
,
e.prototype.bakeTransformIntoVertices = function(t) {
if (!this.isVerticesDataPresent(VertexBuffer.PositionKind))
return this;
var r = this.subMeshes.splice(0);
this._resetPointsArrayCache();
var n = this.getVerticesData(VertexBuffer.PositionKind), o = new Array, a;
for (a = 0; a < n.length; a += 3)
Vector3.TransformCoordinates(Vector3.FromArray(n, a), t).toArray(o, a);
if (this.setVerticesData(VertexBuffer.PositionKind, o, this.getVertexBuffer(VertexBuffer.PositionKind).isUpdatable()),
this.isVerticesDataPresent(VertexBuffer.NormalKind)) {
for (n = this.getVerticesData(VertexBuffer.NormalKind),
o = [],
a = 0; a < n.length; a += 3)
Vector3.TransformNormal(Vector3.FromArray(n, a), t).normalize().toArray(o, a);
this.setVerticesData(VertexBuffer.NormalKind, o, this.getVertexBuffer(VertexBuffer.NormalKind).isUpdatable())
}
return t.determinant() < 0 && this.flipFaces(),
this.releaseSubMeshes(),
this.subMeshes = r,
this
}
,
e.prototype.bakeCurrentTransformIntoVertices = function(t) {
return t === void 0 && (t = !0),
this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),
this.resetLocalMatrix(t),
this
}
,
Object.defineProperty(e.prototype, "_positions", {
get: function() {
return this._internalAbstractMeshDataInfo._positions ? this._internalAbstractMeshDataInfo._positions : this._geometry ? this._geometry._positions : null
},
enumerable: !1,
configurable: !0
}),
e.prototype._resetPointsArrayCache = function() {
return this._geometry && this._geometry._resetPointsArrayCache(),
this
}
,
e.prototype._generatePointsArray = function() {
return this._geometry ? this._geometry._generatePointsArray() : !1
}
,
e.prototype.clone = function(t, r, n, o) {
return t === void 0 && (t = ""),
r === void 0 && (r = null),
o === void 0 && (o = !0),
new e(t,this.getScene(),r,this,n,o)
}
,
e.prototype.dispose = function(t, r) {
r === void 0 && (r = !1),
this.morphTargetManager = null,
this._geometry && this._geometry.releaseForMesh(this, !0);
var n = this._internalMeshDataInfo;
if (n._onBeforeDrawObservable && n._onBeforeDrawObservable.clear(),
n._onBeforeBindObservable && n._onBeforeBindObservable.clear(),
n._onBeforeRenderObservable && n._onBeforeRenderObservable.clear(),
n._onAfterRenderObservable && n._onAfterRenderObservable.clear(),
n._onBetweenPassObservable && n._onBetweenPassObservable.clear(),
this._scene.useClonedMeshMap) {
if (n.meshMap)
for (var o in n.meshMap) {
var a = n.meshMap[o];
a && (a._internalMeshDataInfo._source = null,
n.meshMap[o] = void 0)
}
n._source && n._source._internalMeshDataInfo.meshMap && (n._source._internalMeshDataInfo.meshMap[this.uniqueId] = void 0)
} else
for (var s = this.getScene().meshes, l = 0, u = s; l < u.length; l++) {
var c = u[l]
, a = c;
a._internalMeshDataInfo && a._internalMeshDataInfo._source && a._internalMeshDataInfo._source === this && (a._internalMeshDataInfo._source = null)
}
n._source = null,
this._disposeInstanceSpecificData(),
this._disposeThinInstanceSpecificData(),
this._internalMeshDataInfo._checkReadinessObserver && this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),
i.prototype.dispose.call(this, t, r)
}
,
e.prototype._disposeInstanceSpecificData = function() {}
,
e.prototype._disposeThinInstanceSpecificData = function() {}
,
e.prototype._invalidateInstanceVertexArrayObject = function() {}
,
e.prototype.applyDisplacementMap = function(t, r, n, o, a, s, l) {
var u = this;
l === void 0 && (l = !1);
var c = this.getScene()
, h = function(f) {
var d = f.width
, _ = f.height
, g = u.getEngine().createCanvas(d, _)
, m = g.getContext("2d");
m.drawImage(f, 0, 0);
var v = m.getImageData(0, 0, d, _).data;
u.applyDisplacementMapFromBuffer(v, d, _, r, n, a, s, l),
o && o(u)
};
return Tools.LoadImage(t, h, function() {}, c.offlineProvider),
this
}
,
e.prototype.applyDisplacementMapFromBuffer = function(t, r, n, o, a, s, l, u) {
if (u === void 0 && (u = !1),
!this.isVerticesDataPresent(VertexBuffer.PositionKind) || !this.isVerticesDataPresent(VertexBuffer.NormalKind) || !this.isVerticesDataPresent(VertexBuffer.UVKind))
return Logger$2.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),
this;
var c = this.getVerticesData(VertexBuffer.PositionKind, !0, !0)
, h = this.getVerticesData(VertexBuffer.NormalKind)
, f = this.getVerticesData(VertexBuffer.UVKind)
, d = Vector3.Zero()
, _ = Vector3.Zero()
, g = Vector2.Zero();
s = s || Vector2.Zero(),
l = l || new Vector2(1,1);
for (var m = 0; m < c.length; m += 3) {
Vector3.FromArrayToRef(c, m, d),
Vector3.FromArrayToRef(h, m, _),
Vector2.FromArrayToRef(f, m / 3 * 2, g);
var v = Math.abs(g.x * l.x + s.x % 1) * (r - 1) % r | 0
, y = Math.abs(g.y * l.y + s.y % 1) * (n - 1) % n | 0
, b = (v + y * r) * 4
, T = t[b] / 255
, C = t[b + 1] / 255
, A = t[b + 2] / 255
, S = T * .3 + C * .59 + A * .11;
_.normalize(),
_.scaleInPlace(o + (a - o) * S),
d = d.add(_),
d.toArray(c, m)
}
return VertexData.ComputeNormals(c, this.getIndices(), h),
u ? (this.setVerticesData(VertexBuffer.PositionKind, c),
this.setVerticesData(VertexBuffer.NormalKind, h),
this.setVerticesData(VertexBuffer.UVKind, f)) : (this.updateVerticesData(VertexBuffer.PositionKind, c),
this.updateVerticesData(VertexBuffer.NormalKind, h)),
this
}
,
e.prototype.convertToFlatShadedMesh = function() {
var t = this.getVerticesDataKinds(), r = {}, n = {}, o = {}, a = !1, s, l;
for (s = 0; s < t.length; s++) {
l = t[s];
var u = this.getVertexBuffer(l);
if (l === VertexBuffer.NormalKind) {
a = u.isUpdatable(),
t.splice(s, 1),
s--;
continue
}
r[l] = u,
n[l] = this.getVerticesData(l),
o[l] = []
}
var c = this.subMeshes.slice(0), h = this.getIndices(), f = this.getTotalIndices(), d;
for (d = 0; d < f; d++) {
var _ = h[d];
for (s = 0; s < t.length; s++) {
l = t[s];
for (var g = r[l].getStrideSize(), m = 0; m < g; m++)
o[l].push(n[l][_ * g + m])
}
}
var v = [], y = o[VertexBuffer.PositionKind], b = this.getScene().useRightHandedSystem, T;
for (b ? T = this.overrideMaterialSideOrientation === 1 : T = this.overrideMaterialSideOrientation === 0,
d = 0; d < f; d += 3) {
h[d] = d,
h[d + 1] = d + 1,
h[d + 2] = d + 2;
var C = Vector3.FromArray(y, d * 3)
, A = Vector3.FromArray(y, (d + 1) * 3)
, S = Vector3.FromArray(y, (d + 2) * 3)
, P = C.subtract(A)
, R = S.subtract(A)
, M = Vector3.Normalize(Vector3.Cross(P, R));
T && M.scaleInPlace(-1);
for (var x = 0; x < 3; x++)
v.push(M.x),
v.push(M.y),
v.push(M.z)
}
for (this.setIndices(h),
this.setVerticesData(VertexBuffer.NormalKind, v, a),
s = 0; s < t.length; s++)
l = t[s],
this.setVerticesData(l, o[l], r[l].isUpdatable());
this.releaseSubMeshes();
for (var I = 0; I < c.length; I++) {
var w = c[I];
SubMesh.AddToMesh(w.materialIndex, w.indexStart, w.indexCount, w.indexStart, w.indexCount, this)
}
return this.synchronizeInstances(),
this
}
,
e.prototype.convertToUnIndexedMesh = function() {
var t = this.getVerticesDataKinds(), r = {}, n = {}, o = {}, a, s;
for (a = 0; a < t.length; a++) {
s = t[a];
var l = this.getVertexBuffer(s);
r[s] = l,
n[s] = r[s].getData(),
o[s] = []
}
var u = this.subMeshes.slice(0), c = this.getIndices(), h = this.getTotalIndices(), f;
for (f = 0; f < h; f++) {
var d = c[f];
for (a = 0; a < t.length; a++) {
s = t[a];
for (var _ = r[s].getStrideSize(), g = 0; g < _; g++)
o[s].push(n[s][d * _ + g])
}
}
for (f = 0; f < h; f += 3)
c[f] = f,
c[f + 1] = f + 1,
c[f + 2] = f + 2;
for (this.setIndices(c),
a = 0; a < t.length; a++)
s = t[a],
this.setVerticesData(s, o[s], r[s].isUpdatable());
this.releaseSubMeshes();
for (var m = 0; m < u.length; m++) {
var v = u[m];
SubMesh.AddToMesh(v.materialIndex, v.indexStart, v.indexCount, v.indexStart, v.indexCount, this)
}
return this._unIndexed = !0,
this.synchronizeInstances(),
this
}
,
e.prototype.flipFaces = function(t) {
t === void 0 && (t = !1);
var r = VertexData.ExtractFromMesh(this), n;
if (t && this.isVerticesDataPresent(VertexBuffer.NormalKind) && r.normals)
for (n = 0; n < r.normals.length; n++)
r.normals[n] *= -1;
if (r.indices) {
var o;
for (n = 0; n < r.indices.length; n += 3)
o = r.indices[n + 1],
r.indices[n + 1] = r.indices[n + 2],
r.indices[n + 2] = o
}
return r.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind)),
this
}
,
e.prototype.increaseVertices = function(t) {
var r = VertexData.ExtractFromMesh(this)
, n = r.uvs && !Array.isArray(r.uvs) && Array.from ? Array.from(r.uvs) : r.uvs
, o = r.indices && !Array.isArray(r.indices) && Array.from ? Array.from(r.indices) : r.indices
, a = r.positions && !Array.isArray(r.positions) && Array.from ? Array.from(r.positions) : r.positions
, s = r.normals && !Array.isArray(r.normals) && Array.from ? Array.from(r.normals) : r.normals;
if (!o || !a || !s || !n)
Logger$2.Warn("VertexData contains null entries");
else {
r.indices = o,
r.positions = a,
r.normals = s,
r.uvs = n;
for (var l = t + 1, u = new Array, c = 0; c < l + 1; c++)
u[c] = new Array;
for (var h, f, d = new Vector3(0,0,0), _ = new Vector3(0,0,0), g = new Vector2(0,0), m = new Array, v = new Array, y = new Array, b, T = a.length, C = n.length, c = 0; c < o.length; c += 3) {
v[0] = o[c],
v[1] = o[c + 1],
v[2] = o[c + 2];
for (var A = 0; A < 3; A++)
if (h = v[A],
f = v[(A + 1) % 3],
y[h] === void 0 && y[f] === void 0 ? (y[h] = new Array,
y[f] = new Array) : (y[h] === void 0 && (y[h] = new Array),
y[f] === void 0 && (y[f] = new Array)),
y[h][f] === void 0 && y[f][h] === void 0) {
y[h][f] = [],
d.x = (a[3 * f] - a[3 * h]) / l,
d.y = (a[3 * f + 1] - a[3 * h + 1]) / l,
d.z = (a[3 * f + 2] - a[3 * h + 2]) / l,
_.x = (s[3 * f] - s[3 * h]) / l,
_.y = (s[3 * f + 1] - s[3 * h + 1]) / l,
_.z = (s[3 * f + 2] - s[3 * h + 2]) / l,
g.x = (n[2 * f] - n[2 * h]) / l,
g.y = (n[2 * f + 1] - n[2 * h + 1]) / l,
y[h][f].push(h);
for (var S = 1; S < l; S++)
y[h][f].push(a.length / 3),
a[T] = a[3 * h] + S * d.x,
s[T++] = s[3 * h] + S * _.x,
a[T] = a[3 * h + 1] + S * d.y,
s[T++] = s[3 * h + 1] + S * _.y,
a[T] = a[3 * h + 2] + S * d.z,
s[T++] = s[3 * h + 2] + S * _.z,
n[C++] = n[2 * h] + S * g.x,
n[C++] = n[2 * h + 1] + S * g.y;
y[h][f].push(f),
y[f][h] = new Array,
b = y[h][f].length;
for (var P = 0; P < b; P++)
y[f][h][P] = y[h][f][b - 1 - P]
}
u[0][0] = o[c],
u[1][0] = y[o[c]][o[c + 1]][1],
u[1][1] = y[o[c]][o[c + 2]][1];
for (var S = 2; S < l; S++) {
u[S][0] = y[o[c]][o[c + 1]][S],
u[S][S] = y[o[c]][o[c + 2]][S],
d.x = (a[3 * u[S][S]] - a[3 * u[S][0]]) / S,
d.y = (a[3 * u[S][S] + 1] - a[3 * u[S][0] + 1]) / S,
d.z = (a[3 * u[S][S] + 2] - a[3 * u[S][0] + 2]) / S,
_.x = (s[3 * u[S][S]] - s[3 * u[S][0]]) / S,
_.y = (s[3 * u[S][S] + 1] - s[3 * u[S][0] + 1]) / S,
_.z = (s[3 * u[S][S] + 2] - s[3 * u[S][0] + 2]) / S,
g.x = (n[2 * u[S][S]] - n[2 * u[S][0]]) / S,
g.y = (n[2 * u[S][S] + 1] - n[2 * u[S][0] + 1]) / S;
for (var A = 1; A < S; A++)
u[S][A] = a.length / 3,
a[T] = a[3 * u[S][0]] + A * d.x,
s[T++] = s[3 * u[S][0]] + A * _.x,
a[T] = a[3 * u[S][0] + 1] + A * d.y,
s[T++] = s[3 * u[S][0] + 1] + A * _.y,
a[T] = a[3 * u[S][0] + 2] + A * d.z,
s[T++] = s[3 * u[S][0] + 2] + A * _.z,
n[C++] = n[2 * u[S][0]] + A * g.x,
n[C++] = n[2 * u[S][0] + 1] + A * g.y
}
u[l] = y[o[c + 1]][o[c + 2]],
m.push(u[0][0], u[1][0], u[1][1]);
for (var S = 1; S < l; S++) {
for (var A = 0; A < S; A++)
m.push(u[S][A], u[S + 1][A], u[S + 1][A + 1]),
m.push(u[S][A], u[S + 1][A + 1], u[S][A + 1]);
m.push(u[S][A], u[S + 1][A], u[S + 1][A + 1])
}
}
r.indices = m,
r.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind))
}
}
,
e.prototype.forceSharedVertices = function() {
var t = VertexData.ExtractFromMesh(this)
, r = t.uvs
, n = t.indices
, o = t.positions
, a = t.colors;
if (n === void 0 || o === void 0 || n === null || o === null)
Logger$2.Warn("VertexData contains empty entries");
else {
for (var s = new Array, l = new Array, u = new Array, c = new Array, h = new Array, f = 0, d = {}, _, g, m = 0; m < n.length; m += 3) {
g = [n[m], n[m + 1], n[m + 2]],
h = new Array;
for (var v = 0; v < 3; v++) {
h[v] = "";
for (var y = 0; y < 3; y++)
Math.abs(o[3 * g[v] + y]) < 1e-8 && (o[3 * g[v] + y] = 0),
h[v] += o[3 * g[v] + y] + "|"
}
if (!(h[0] == h[1] || h[0] == h[2] || h[1] == h[2]))
for (var v = 0; v < 3; v++) {
if (_ = d[h[v]],
_ === void 0) {
d[h[v]] = f,
_ = f++;
for (var y = 0; y < 3; y++)
s.push(o[3 * g[v] + y]);
if (a != null)
for (var y = 0; y < 4; y++)
c.push(a[4 * g[v] + y]);
if (r != null)
for (var y = 0; y < 2; y++)
u.push(r[2 * g[v] + y])
}
l.push(_)
}
}
var b = new Array;
VertexData.ComputeNormals(s, l, b),
t.positions = s,
t.indices = l,
t.normals = b,
r != null && (t.uvs = u),
a != null && (t.colors = c),
t.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind))
}
}
,
e._instancedMeshFactory = function(t, r) {
throw _WarnImport("InstancedMesh")
}
,
e._PhysicsImpostorParser = function(t, r, n) {
throw _WarnImport("PhysicsImpostor")
}
,
e.prototype.createInstance = function(t) {
return e._instancedMeshFactory(t, this)
}
,
e.prototype.synchronizeInstances = function() {
for (var t = 0; t < this.instances.length; t++) {
var r = this.instances[t];
r._syncSubMeshes()
}
return this
}
,
e.prototype.optimizeIndices = function(t) {
var r = this
, n = this.getIndices()
, o = this.getVerticesData(VertexBuffer.PositionKind);
if (!o || !n)
return this;
for (var a = new Array, s = 0; s < o.length; s = s + 3)
a.push(Vector3.FromArray(o, s));
var l = new Array;
return AsyncLoop.SyncAsyncForLoop(a.length, 40, function(u) {
for (var c = a.length - 1 - u, h = a[c], f = 0; f < c; ++f) {
var d = a[f];
if (h.equals(d)) {
l[c] = f;
break
}
}
}, function() {
for (var u = 0; u < n.length; ++u)
n[u] = l[n[u]] || n[u];
var c = r.subMeshes.slice(0);
r.setIndices(n),
r.subMeshes = c,
t && t(r)
}),
this
}
,
e.prototype.serialize = function(t) {
t.name = this.name,
t.id = this.id,
t.uniqueId = this.uniqueId,
t.type = this.getClassName(),
Tags && Tags.HasTags(this) && (t.tags = Tags.GetTags(this)),
t.position = this.position.asArray(),
this.rotationQuaternion ? t.rotationQuaternion = this.rotationQuaternion.asArray() : this.rotation && (t.rotation = this.rotation.asArray()),
t.scaling = this.scaling.asArray(),
this._postMultiplyPivotMatrix ? t.pivotMatrix = this.getPivotMatrix().asArray() : t.localMatrix = this.getPivotMatrix().asArray(),
t.isEnabled = this.isEnabled(!1),
t.isVisible = this.isVisible,
t.infiniteDistance = this.infiniteDistance,
t.pickable = this.isPickable,
t.receiveShadows = this.receiveShadows,
t.billboardMode = this.billboardMode,
t.visibility = this.visibility,
t.checkCollisions = this.checkCollisions,
t.isBlocker = this.isBlocker,
t.overrideMaterialSideOrientation = this.overrideMaterialSideOrientation,
this.parent && (t.parentId = this.parent.uniqueId),
t.isUnIndexed = this.isUnIndexed;
var r = this._geometry;
if (r && this.subMeshes) {
t.geometryUniqueId = r.uniqueId,
t.geometryId = r.id,
t.subMeshes = [];
for (var n = 0; n < this.subMeshes.length; n++) {
var o = this.subMeshes[n];
t.subMeshes.push({
materialIndex: o.materialIndex,
verticesStart: o.verticesStart,
verticesCount: o.verticesCount,
indexStart: o.indexStart,
indexCount: o.indexCount
})
}
}
if (this.material ? this.material.doNotSerialize || (t.materialId = this.material.id) : (this.material = null,
t.materialId = this._scene.defaultMaterial.id),
this.morphTargetManager && (t.morphTargetManagerId = this.morphTargetManager.uniqueId),
this.skeleton && (t.skeletonId = this.skeleton.id,
t.numBoneInfluencers = this.numBoneInfluencers),
this.getScene()._getComponent(SceneComponentConstants.NAME_PHYSICSENGINE)) {
var a = this.getPhysicsImpostor();
a && (t.physicsMass = a.getParam("mass"),
t.physicsFriction = a.getParam("friction"),
t.physicsRestitution = a.getParam("mass"),
t.physicsImpostor = a.type)
}
this.metadata && (t.metadata = this.metadata),
t.instances = [];
for (var s = 0; s < this.instances.length; s++) {
var l = this.instances[s];
if (!l.doNotSerialize) {
var u = {
name: l.name,
id: l.id,
isEnabled: l.isEnabled(!1),
isVisible: l.isVisible,
isPickable: l.isPickable,
checkCollisions: l.checkCollisions,
position: l.position.asArray(),
scaling: l.scaling.asArray()
};
if (l.parent && (u.parentId = l.parent.uniqueId),
l.rotationQuaternion ? u.rotationQuaternion = l.rotationQuaternion.asArray() : l.rotation && (u.rotation = l.rotation.asArray()),
this.getScene()._getComponent(SceneComponentConstants.NAME_PHYSICSENGINE)) {
var a = l.getPhysicsImpostor();
a && (u.physicsMass = a.getParam("mass"),
u.physicsFriction = a.getParam("friction"),
u.physicsRestitution = a.getParam("mass"),
u.physicsImpostor = a.type)
}
l.metadata && (u.metadata = l.metadata),
t.instances.push(u),
SerializationHelper.AppendSerializedAnimations(l, u),
u.ranges = l.serializeAnimationRanges()
}
}
if (this._thinInstanceDataStorage.instancesCount && this._thinInstanceDataStorage.matrixData && (t.thinInstances = {
instancesCount: this._thinInstanceDataStorage.instancesCount,
matrixData: Tools.SliceToArray(this._thinInstanceDataStorage.matrixData),
matrixBufferSize: this._thinInstanceDataStorage.matrixBufferSize,
enablePicking: this.thinInstanceEnablePicking
},
this._userThinInstanceBuffersStorage)) {
var c = {
data: {},
sizes: {},
strides: {}
};
for (var h in this._userThinInstanceBuffersStorage.data)
c.data[h] = Tools.SliceToArray(this._userThinInstanceBuffersStorage.data[h]),
c.sizes[h] = this._userThinInstanceBuffersStorage.sizes[h],
c.strides[h] = this._userThinInstanceBuffersStorage.strides[h];
t.thinInstances.userThinInstance = c
}
SerializationHelper.AppendSerializedAnimations(this, t),
t.ranges = this.serializeAnimationRanges(),
t.layerMask = this.layerMask,
t.alphaIndex = this.alphaIndex,
t.hasVertexAlpha = this.hasVertexAlpha,
t.overlayAlpha = this.overlayAlpha,
t.overlayColor = this.overlayColor.asArray(),
t.renderOverlay = this.renderOverlay,
t.applyFog = this.applyFog,
this.actionManager && (t.actions = this.actionManager.serialize(this.name))
}
,
e.prototype._syncGeometryWithMorphTargetManager = function() {
if (!!this.geometry) {
this._markSubMeshesAsAttributesDirty();
var t = this._internalAbstractMeshDataInfo._morphTargetManager;
if (t && t.vertexCount) {
if (t.vertexCount !== this.getTotalVertices()) {
Logger$2.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),
this.morphTargetManager = null;
return
}
if (t.isUsingTextureForTargets)
return;
for (var r = 0; r < t.numInfluencers; r++) {
var n = t.getActiveTarget(r)
, o = n.getPositions();
if (!o) {
Logger$2.Error("Invalid morph target. Target must have positions.");
return
}
this.geometry.setVerticesData(VertexBuffer.PositionKind + r, o, !1, 3);
var a = n.getNormals();
a && this.geometry.setVerticesData(VertexBuffer.NormalKind + r, a, !1, 3);
var s = n.getTangents();
s && this.geometry.setVerticesData(VertexBuffer.TangentKind + r, s, !1, 3);
var l = n.getUVs();
l && this.geometry.setVerticesData(VertexBuffer.UVKind + "_" + r, l, !1, 2)
}
} else
for (var r = 0; this.geometry.isVerticesDataPresent(VertexBuffer.PositionKind + r); )
this.geometry.removeVerticesData(VertexBuffer.PositionKind + r),
this.geometry.isVerticesDataPresent(VertexBuffer.NormalKind + r) && this.geometry.removeVerticesData(VertexBuffer.NormalKind + r),
this.geometry.isVerticesDataPresent(VertexBuffer.TangentKind + r) && this.geometry.removeVerticesData(VertexBuffer.TangentKind + r),
this.geometry.isVerticesDataPresent(VertexBuffer.UVKind + r) && this.geometry.removeVerticesData(VertexBuffer.UVKind + "_" + r),
r++
}
}
,
e.Parse = function(t, r, n) {
var o;
if (t.type && t.type === "LinesMesh" ? o = e._LinesMeshParser(t, r) : t.type && t.type === "GroundMesh" ? o = e._GroundMeshParser(t, r) : o = new e(t.name,r),
o.id = t.id,
Tags && Tags.AddTagsTo(o, t.tags),
o.position = Vector3.FromArray(t.position),
t.metadata !== void 0 && (o.metadata = t.metadata),
t.rotationQuaternion ? o.rotationQuaternion = Quaternion.FromArray(t.rotationQuaternion) : t.rotation && (o.rotation = Vector3.FromArray(t.rotation)),
o.scaling = Vector3.FromArray(t.scaling),
t.localMatrix ? o.setPreTransformMatrix(Matrix.FromArray(t.localMatrix)) : t.pivotMatrix && o.setPivotMatrix(Matrix.FromArray(t.pivotMatrix)),
o.setEnabled(t.isEnabled),
o.isVisible = t.isVisible,
o.infiniteDistance = t.infiniteDistance,
o.showBoundingBox = t.showBoundingBox,
o.showSubMeshesBoundingBox = t.showSubMeshesBoundingBox,
t.applyFog !== void 0 && (o.applyFog = t.applyFog),
t.pickable !== void 0 && (o.isPickable = t.pickable),
t.alphaIndex !== void 0 && (o.alphaIndex = t.alphaIndex),
o.receiveShadows = t.receiveShadows,
o.billboardMode = t.billboardMode,
t.visibility !== void 0 && (o.visibility = t.visibility),
o.checkCollisions = t.checkCollisions,
o.overrideMaterialSideOrientation = t.overrideMaterialSideOrientation,
t.isBlocker !== void 0 && (o.isBlocker = t.isBlocker),
o._shouldGenerateFlatShading = t.useFlatShading,
t.freezeWorldMatrix && (o._waitingData.freezeWorldMatrix = t.freezeWorldMatrix),
t.parentId && (o._waitingParentId = t.parentId),
t.actions !== void 0 && (o._waitingData.actions = t.actions),
t.overlayAlpha !== void 0 && (o.overlayAlpha = t.overlayAlpha),
t.overlayColor !== void 0 && (o.overlayColor = Color3.FromArray(t.overlayColor)),
t.renderOverlay !== void 0 && (o.renderOverlay = t.renderOverlay),
o.isUnIndexed = !!t.isUnIndexed,
o.hasVertexAlpha = t.hasVertexAlpha,
t.delayLoadingFile ? (o.delayLoadState = 4,
o.delayLoadingFile = n + t.delayLoadingFile,
o.buildBoundingInfo(Vector3.FromArray(t.boundingBoxMinimum), Vector3.FromArray(t.boundingBoxMaximum)),
t._binaryInfo && (o._binaryInfo = t._binaryInfo),
o._delayInfo = [],
t.hasUVs && o._delayInfo.push(VertexBuffer.UVKind),
t.hasUVs2 && o._delayInfo.push(VertexBuffer.UV2Kind),
t.hasUVs3 && o._delayInfo.push(VertexBuffer.UV3Kind),
t.hasUVs4 && o._delayInfo.push(VertexBuffer.UV4Kind),
t.hasUVs5 && o._delayInfo.push(VertexBuffer.UV5Kind),
t.hasUVs6 && o._delayInfo.push(VertexBuffer.UV6Kind),
t.hasColors && o._delayInfo.push(VertexBuffer.ColorKind),
t.hasMatricesIndices && o._delayInfo.push(VertexBuffer.MatricesIndicesKind),
t.hasMatricesWeights && o._delayInfo.push(VertexBuffer.MatricesWeightsKind),
o._delayLoadingFunction = Geometry._ImportGeometry,
SceneLoaderFlags.ForceFullSceneLoadingForIncremental && o._checkDelayState()) : Geometry._ImportGeometry(t, o),
t.materialId ? o.setMaterialById(t.materialId) : o.material = null,
t.morphTargetManagerId > -1 && (o.morphTargetManager = r.getMorphTargetManagerById(t.morphTargetManagerId)),
t.skeletonId !== void 0 && t.skeletonId !== null && (o.skeleton = r.getLastSkeletonById(t.skeletonId),
t.numBoneInfluencers && (o.numBoneInfluencers = t.numBoneInfluencers)),
t.animations) {
for (var a = 0; a < t.animations.length; a++) {
var s = t.animations[a]
, l = GetClass("BABYLON.Animation");
l && o.animations.push(l.Parse(s))
}
Node$2.ParseAnimationRanges(o, t, r)
}
if (t.autoAnimate && r.beginAnimation(o, t.autoAnimateFrom, t.autoAnimateTo, t.autoAnimateLoop, t.autoAnimateSpeed || 1),
t.layerMask && !isNaN(t.layerMask) ? o.layerMask = Math.abs(parseInt(t.layerMask)) : o.layerMask = 268435455,
t.physicsImpostor && e._PhysicsImpostorParser(r, o, t),
t.lodMeshIds && (o._waitingData.lods = {
ids: t.lodMeshIds,
distances: t.lodDistances ? t.lodDistances : null,
coverages: t.lodCoverages ? t.lodCoverages : null
}),
t.instances)
for (var u = 0; u < t.instances.length; u++) {
var c = t.instances[u]
, h = o.createInstance(c.name);
if (c.id && (h.id = c.id),
Tags && (c.tags ? Tags.AddTagsTo(h, c.tags) : Tags.AddTagsTo(h, t.tags)),
h.position = Vector3.FromArray(c.position),
c.metadata !== void 0 && (h.metadata = c.metadata),
c.parentId && (h._waitingParentId = c.parentId),
c.isEnabled !== void 0 && c.isEnabled !== null && h.setEnabled(c.isEnabled),
c.isVisible !== void 0 && c.isVisible !== null && (h.isVisible = c.isVisible),
c.isPickable !== void 0 && c.isPickable !== null && (h.isPickable = c.isPickable),
c.rotationQuaternion ? h.rotationQuaternion = Quaternion.FromArray(c.rotationQuaternion) : c.rotation && (h.rotation = Vector3.FromArray(c.rotation)),
h.scaling = Vector3.FromArray(c.scaling),
c.checkCollisions != null && c.checkCollisions != null && (h.checkCollisions = c.checkCollisions),
c.pickable != null && c.pickable != null && (h.isPickable = c.pickable),
c.showBoundingBox != null && c.showBoundingBox != null && (h.showBoundingBox = c.showBoundingBox),
c.showSubMeshesBoundingBox != null && c.showSubMeshesBoundingBox != null && (h.showSubMeshesBoundingBox = c.showSubMeshesBoundingBox),
c.alphaIndex != null && c.showSubMeshesBoundingBox != null && (h.alphaIndex = c.alphaIndex),
c.physicsImpostor && e._PhysicsImpostorParser(r, h, c),
c.animations) {
for (a = 0; a < c.animations.length; a++) {
s = c.animations[a];
var l = GetClass("BABYLON.Animation");
l && h.animations.push(l.Parse(s))
}
Node$2.ParseAnimationRanges(h, c, r),
c.autoAnimate && r.beginAnimation(h, c.autoAnimateFrom, c.autoAnimateTo, c.autoAnimateLoop, c.autoAnimateSpeed || 1)
}
}
if (t.thinInstances) {
var f = t.thinInstances;
if (o.thinInstanceEnablePicking = !!f.enablePicking,
f.matrixData ? (o.thinInstanceSetBuffer("matrix", new Float32Array(f.matrixData), 16, !1),
o._thinInstanceDataStorage.matrixBufferSize = f.matrixBufferSize,
o._thinInstanceDataStorage.instancesCount = f.instancesCount) : o._thinInstanceDataStorage.matrixBufferSize = f.matrixBufferSize,
t.thinInstances.userThinInstance) {
var d = t.thinInstances.userThinInstance;
for (var _ in d.data)
o.thinInstanceSetBuffer(_, new Float32Array(d.data[_]), d.strides[_], !1),
o._userThinInstanceBuffersStorage.sizes[_] = d.sizes[_]
}
}
return o
}
,
e.prototype.setPositionsForCPUSkinning = function() {
var t = this._internalMeshDataInfo;
if (!t._sourcePositions) {
var r = this.getVerticesData(VertexBuffer.PositionKind);
if (!r)
return t._sourcePositions;
t._sourcePositions = new Float32Array(r),
this.isVertexBufferUpdatable(VertexBuffer.PositionKind) || this.setVerticesData(VertexBuffer.PositionKind, r, !0)
}
return t._sourcePositions
}
,
e.prototype.setNormalsForCPUSkinning = function() {
var t = this._internalMeshDataInfo;
if (!t._sourceNormals) {
var r = this.getVerticesData(VertexBuffer.NormalKind);
if (!r)
return t._sourceNormals;
t._sourceNormals = new Float32Array(r),
this.isVertexBufferUpdatable(VertexBuffer.NormalKind) || this.setVerticesData(VertexBuffer.NormalKind, r, !0)
}
return t._sourceNormals
}
,
e.prototype.applySkeleton = function(t) {
if (!this.geometry)
return this;
if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId())
return this;
if (this.geometry._softwareSkinningFrameId = this.getScene().getFrameId(),
!this.isVerticesDataPresent(VertexBuffer.PositionKind))
return this;
if (!this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind))
return this;
if (!this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind))
return this;
var r = this.isVerticesDataPresent(VertexBuffer.NormalKind)
, n = this._internalMeshDataInfo;
if (!n._sourcePositions) {
var o = this.subMeshes.slice();
this.setPositionsForCPUSkinning(),
this.subMeshes = o
}
r && !n._sourceNormals && this.setNormalsForCPUSkinning();
var a = this.getVerticesData(VertexBuffer.PositionKind);
if (!a)
return this;
a instanceof Float32Array || (a = new Float32Array(a));
var s = this.getVerticesData(VertexBuffer.NormalKind);
if (r) {
if (!s)
return this;
s instanceof Float32Array || (s = new Float32Array(s))
}
var l = this.getVerticesData(VertexBuffer.MatricesIndicesKind)
, u = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
if (!u || !l)
return this;
for (var c = this.numBoneInfluencers > 4, h = c ? this.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null, f = c ? this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null, d = t.getTransformMatrices(this), _ = Vector3.Zero(), g = new Matrix, m = new Matrix, v = 0, y, b = 0; b < a.length; b += 3,
v += 4) {
var T;
for (y = 0; y < 4; y++)
T = u[v + y],
T > 0 && (Matrix.FromFloat32ArrayToRefScaled(d, Math.floor(l[v + y] * 16), T, m),
g.addToSelf(m));
if (c)
for (y = 0; y < 4; y++)
T = f[v + y],
T > 0 && (Matrix.FromFloat32ArrayToRefScaled(d, Math.floor(h[v + y] * 16), T, m),
g.addToSelf(m));
Vector3.TransformCoordinatesFromFloatsToRef(n._sourcePositions[b], n._sourcePositions[b + 1], n._sourcePositions[b + 2], g, _),
_.toArray(a, b),
r && (Vector3.TransformNormalFromFloatsToRef(n._sourceNormals[b], n._sourceNormals[b + 1], n._sourceNormals[b + 2], g, _),
_.toArray(s, b)),
g.reset()
}
return this.updateVerticesData(VertexBuffer.PositionKind, a),
r && this.updateVerticesData(VertexBuffer.NormalKind, s),
this
}
,
e.MinMax = function(t) {
var r = null
, n = null;
return t.forEach(function(o) {
var a = o.getBoundingInfo()
, s = a.boundingBox;
!r || !n ? (r = s.minimumWorld,
n = s.maximumWorld) : (r.minimizeInPlace(s.minimumWorld),
n.maximizeInPlace(s.maximumWorld))
}),
!r || !n ? {
min: Vector3.Zero(),
max: Vector3.Zero()
} : {
min: r,
max: n
}
}
,
e.Center = function(t) {
var r = t instanceof Array ? e.MinMax(t) : t;
return Vector3.Center(r.min, r.max)
}
,
e.MergeMeshes = function(t, r, n, o, a, s) {
return r === void 0 && (r = !0),
runCoroutineSync(e._MergeMeshesCoroutine(t, r, n, o, a, s, !1))
}
,
e.MergeMeshesAsync = function(t, r, n, o, a, s) {
return r === void 0 && (r = !0),
runCoroutineAsync(e._MergeMeshesCoroutine(t, r, n, o, a, s, !0), createYieldingScheduler())
}
,
e._MergeMeshesCoroutine = function(t, r, n, o, a, s, l) {
var u, c, h, f, d, _, g, m, v, y, b, T, C, A, S, P, R, M, x, I, w, O, D, F;
return r === void 0 && (r = !0),
__generator(this, function(V) {
switch (V.label) {
case 0:
if (t = t.filter(Boolean),
t.length === 0)
return [2, null];
if (!n) {
for (c = 0,
u = 0; u < t.length; u++)
if (c += t[u].getTotalVertices(),
c >= 65536)
return Logger$2.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),
[2, null]
}
for (s && (h = null,
a = !1),
_ = new Array,
g = new Array,
m = new Array,
u = 0; u < t.length; u++) {
if (v = t[u],
v.isAnInstance)
return Logger$2.Warn("Cannot merge instance meshes."),
[2, null];
if (a && m.push(v.getTotalIndices()),
s)
if (v.material)
if (y = v.material,
y instanceof MultiMaterial) {
for (d = 0; d < y.subMaterials.length; d++)
_.indexOf(y.subMaterials[d]) < 0 && _.push(y.subMaterials[d]);
for (f = 0; f < v.subMeshes.length; f++)
g.push(_.indexOf(y.subMaterials[v.subMeshes[f].materialIndex])),
m.push(v.subMeshes[f].indexCount)
} else
for (_.indexOf(y) < 0 && _.push(y),
f = 0; f < v.subMeshes.length; f++)
g.push(_.indexOf(y)),
m.push(v.subMeshes[f].indexCount);
else
for (f = 0; f < v.subMeshes.length; f++)
g.push(0),
m.push(v.subMeshes[f].indexCount)
}
return b = t[0],
T = function(N) {
var L = N.computeWorldMatrix(!0)
, k = VertexData.ExtractFromMesh(N, !0, !0);
return k.transform(L),
k
}
,
C = T(b),
l ? [4] : [3, 2];
case 1:
V.sent(),
V.label = 2;
case 2:
A = new Array(t.length - 1),
S = 1,
V.label = 3;
case 3:
return S < t.length ? (A[S - 1] = T(t[S]),
l ? [4] : [3, 5]) : [3, 6];
case 4:
V.sent(),
V.label = 5;
case 5:
return S++,
[3, 3];
case 6:
P = C._mergeCoroutine(A, n, l),
R = P.next(),
V.label = 7;
case 7:
return R.done ? [3, 10] : l ? [4] : [3, 9];
case 8:
V.sent(),
V.label = 9;
case 9:
return R = P.next(),
[3, 7];
case 10:
M = R.value,
o || (o = new e(b.name + "_merged",b.getScene())),
x = M._applyToCoroutine(o, void 0, l),
I = x.next(),
V.label = 11;
case 11:
return I.done ? [3, 14] : l ? [4] : [3, 13];
case 12:
V.sent(),
V.label = 13;
case 13:
return I = x.next(),
[3, 11];
case 14:
if (o.checkCollisions = b.checkCollisions,
o.overrideMaterialSideOrientation = b.overrideMaterialSideOrientation,
r)
for (u = 0; u < t.length; u++)
t[u].dispose();
if (a || s) {
for (o.releaseSubMeshes(),
u = 0,
w = 0; u < m.length; )
SubMesh.CreateFromIndices(0, w, m[u], o, void 0, !1),
w += m[u],
u++;
for (O = 0,
D = o.subMeshes; O < D.length; O++)
F = D[O],
F.refreshBoundingInfo();
o.computeWorldMatrix(!0)
}
if (s) {
for (h = new MultiMaterial(b.name + "_merged",b.getScene()),
h.subMaterials = _,
f = 0; f < o.subMeshes.length; f++)
o.subMeshes[f].materialIndex = g[f];
o.material = h
} else
o.material = b.material;
return [2, o]
}
})
}
,
e.prototype.addInstance = function(t) {
t._indexInSourceMeshInstanceArray = this.instances.length,
this.instances.push(t)
}
,
e.prototype.removeInstance = function(t) {
var r = t._indexInSourceMeshInstanceArray;
if (r != -1) {
if (r !== this.instances.length - 1) {
var n = this.instances[this.instances.length - 1];
this.instances[r] = n,
n._indexInSourceMeshInstanceArray = r
}
t._indexInSourceMeshInstanceArray = -1,
this.instances.pop()
}
}
,
e.FRONTSIDE = VertexData.FRONTSIDE,
e.BACKSIDE = VertexData.BACKSIDE,
e.DOUBLESIDE = VertexData.DOUBLESIDE,
e.DEFAULTSIDE = VertexData.DEFAULTSIDE,
e.NO_CAP = 0,
e.CAP_START = 1,
e.CAP_END = 2,
e.CAP_ALL = 3,
e.NO_FLIP = 0,
e.FLIP_TILE = 1,
e.ROTATE_TILE = 2,
e.FLIP_ROW = 3,
e.ROTATE_ROW = 4,
e.FLIP_N_ROTATE_TILE = 5,
e.FLIP_N_ROTATE_ROW = 6,
e.CENTER = 0,
e.LEFT = 1,
e.RIGHT = 2,
e.TOP = 3,
e.BOTTOM = 4,
e.INSTANCEDMESH_SORT_TRANSPARENT = !1,
e._GroundMeshParser = function(t, r) {
throw _WarnImport("GroundMesh")
}
,
e._LinesMeshParser = function(t, r) {
throw _WarnImport("LinesMesh")
}
,
e
}(AbstractMesh);
RegisterClass("BABYLON.Mesh", Mesh);
_injectLTSMesh(Mesh);
var AutoRotationBehavior = function() {
function i() {
this._zoomStopsAnimation = !1,
this._idleRotationSpeed = .05,
this._idleRotationWaitTime = 2e3,
this._idleRotationSpinupTime = 2e3,
this._isPointerDown = !1,
this._lastFrameTime = null,
this._lastInteractionTime = -1 / 0,
this._cameraRotationSpeed = 0,
this._lastFrameRadius = 0
}
return Object.defineProperty(i.prototype, "name", {
get: function() {
return "AutoRotation"
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "zoomStopsAnimation", {
get: function() {
return this._zoomStopsAnimation
},
set: function(e) {
this._zoomStopsAnimation = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "idleRotationSpeed", {
get: function() {
return this._idleRotationSpeed
},
set: function(e) {
this._idleRotationSpeed = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "idleRotationWaitTime", {
get: function() {
return this._idleRotationWaitTime
},
set: function(e) {
this._idleRotationWaitTime = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "idleRotationSpinupTime", {
get: function() {
return this._idleRotationSpinupTime
},
set: function(e) {
this._idleRotationSpinupTime = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "rotationInProgress", {
get: function() {
return Math.abs(this._cameraRotationSpeed) > 0
},
enumerable: !1,
configurable: !0
}),
i.prototype.init = function() {}
,
i.prototype.attach = function(e) {
var t = this;
this._attachedCamera = e;
var r = this._attachedCamera.getScene();
this._onPrePointerObservableObserver = r.onPrePointerObservable.add(function(n) {
if (n.type === PointerEventTypes.POINTERDOWN) {
t._isPointerDown = !0;
return
}
n.type === PointerEventTypes.POINTERUP && (t._isPointerDown = !1)
}),
this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add(function() {
var n = PrecisionDate.Now
, o = 0;
t._lastFrameTime != null && (o = n - t._lastFrameTime),
t._lastFrameTime = n,
t._applyUserInteraction();
var a = n - t._lastInteractionTime - t._idleRotationWaitTime
, s = Math.max(Math.min(a / t._idleRotationSpinupTime, 1), 0);
t._cameraRotationSpeed = t._idleRotationSpeed * s,
t._attachedCamera && (t._attachedCamera.alpha -= t._cameraRotationSpeed * (o / 1e3))
})
}
,
i.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
}
}
,
i.prototype.resetLastInteractionTime = function(e) {
this._lastInteractionTime = e != null ? e : PrecisionDate.Now
}
,
i.prototype._userIsZooming = function() {
return this._attachedCamera ? this._attachedCamera.inertialRadiusOffset !== 0 : !1
}
,
i.prototype._shouldAnimationStopForInteraction = function() {
if (!this._attachedCamera)
return !1;
var e = !1;
return this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0 && (e = !0),
this._lastFrameRadius = this._attachedCamera.radius,
this._zoomStopsAnimation ? e : this._userIsZooming()
}
,
i.prototype._applyUserInteraction = function() {
this._userIsMoving() && !this._shouldAnimationStopForInteraction() && (this._lastInteractionTime = PrecisionDate.Now)
}
,
i.prototype._userIsMoving = function() {
return this._attachedCamera ? this._attachedCamera.inertialAlphaOffset !== 0 || this._attachedCamera.inertialBetaOffset !== 0 || this._attachedCamera.inertialRadiusOffset !== 0 || this._attachedCamera.inertialPanningX !== 0 || this._attachedCamera.inertialPanningY !== 0 || this._isPointerDown : !1
}
,
i
}(), Orientation;
(function(i) {
i[i.CW = 0] = "CW",
i[i.CCW = 1] = "CCW"
}
)(Orientation || (Orientation = {}));
var BezierCurve = function() {
function i() {}
return i.Interpolate = function(e, t, r, n, o) {
for (var a = 1 - 3 * n + 3 * t, s = 3 * n - 6 * t, l = 3 * t, u = e, c = 0; c < 5; c++) {
var h = u * u
, f = h * u
, d = a * f + s * h + l * u
, _ = 1 / (3 * a * h + 2 * s * u + l);
u -= (d - e) * _,
u = Math.min(1, Math.max(0, u))
}
return 3 * Math.pow(1 - u, 2) * u * r + 3 * (1 - u) * Math.pow(u, 2) * o + Math.pow(u, 3)
}
,
i
}()
, Angle = function() {
function i(e) {
this._radians = e,
this._radians < 0 && (this._radians += 2 * Math.PI)
}
return i.prototype.degrees = function() {
return this._radians * 180 / Math.PI
}
,
i.prototype.radians = function() {
return this._radians
}
,
i.BetweenTwoPoints = function(e, t) {
var r = t.subtract(e)
, n = Math.atan2(r.y, r.x);
return new i(n)
}
,
i.FromRadians = function(e) {
return new i(e)
}
,
i.FromDegrees = function(e) {
return new i(e * Math.PI / 180)
}
,
i
}()
, Arc2 = function() {
function i(e, t, r) {
this.startPoint = e,
this.midPoint = t,
this.endPoint = r;
var n = Math.pow(t.x, 2) + Math.pow(t.y, 2)
, o = (Math.pow(e.x, 2) + Math.pow(e.y, 2) - n) / 2
, a = (n - Math.pow(r.x, 2) - Math.pow(r.y, 2)) / 2
, s = (e.x - t.x) * (t.y - r.y) - (t.x - r.x) * (e.y - t.y);
this.centerPoint = new Vector2((o * (t.y - r.y) - a * (e.y - t.y)) / s,((e.x - t.x) * a - (t.x - r.x) * o) / s),
this.radius = this.centerPoint.subtract(this.startPoint).length(),
this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
var l = this.startAngle.degrees()
, u = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees()
, c = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
u - l > 180 && (u -= 360),
u - l < -180 && (u += 360),
c - u > 180 && (c -= 360),
c - u < -180 && (c += 360),
this.orientation = u - l < 0 ? Orientation.CW : Orientation.CCW,
this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? l - c : c - l)
}
return i
}()
, Path2 = function() {
function i(e, t) {
this._points = new Array,
this._length = 0,
this.closed = !1,
this._points.push(new Vector2(e,t))
}
return i.prototype.addLineTo = function(e, t) {
if (this.closed)
return this;
var r = new Vector2(e,t)
, n = this._points[this._points.length - 1];
return this._points.push(r),
this._length += r.subtract(n).length(),
this
}
,
i.prototype.addArcTo = function(e, t, r, n, o) {
if (o === void 0 && (o = 36),
this.closed)
return this;
var a = this._points[this._points.length - 1]
, s = new Vector2(e,t)
, l = new Vector2(r,n)
, u = new Arc2(a,s,l)
, c = u.angle.radians() / o;
u.orientation === Orientation.CW && (c *= -1);
for (var h = u.startAngle.radians() + c, f = 0; f < o; f++) {
var d = Math.cos(h) * u.radius + u.centerPoint.x
, _ = Math.sin(h) * u.radius + u.centerPoint.y;
this.addLineTo(d, _),
h += c
}
return this
}
,
i.prototype.close = function() {
return this.closed = !0,
this
}
,
i.prototype.length = function() {
var e = this._length;
if (this.closed) {
var t = this._points[this._points.length - 1]
, r = this._points[0];
e += r.subtract(t).length()
}
return e
}
,
i.prototype.getPoints = function() {
return this._points
}
,
i.prototype.getPointAtLengthPosition = function(e) {
if (e < 0 || e > 1)
return Vector2.Zero();
for (var t = e * this.length(), r = 0, n = 0; n < this._points.length; n++) {
var o = (n + 1) % this._points.length
, a = this._points[n]
, s = this._points[o]
, l = s.subtract(a)
, u = l.length() + r;
if (t >= r && t <= u) {
var c = l.normalize()
, h = t - r;
return new Vector2(a.x + c.x * h,a.y + c.y * h)
}
r = u
}
return Vector2.Zero()
}
,
i.StartingAt = function(e, t) {
return new i(e,t)
}
,
i
}()
, Path3D = function() {
function i(e, t, r, n) {
t === void 0 && (t = null),
n === void 0 && (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: Vector3.Zero(),
previousPointArrayIndex: 0,
position: 0,
subPosition: 0,
interpolateReady: !1,
interpolationMatrix: Matrix.Identity()
};
for (var o = 0; o < e.length; o++)
this._curve[o] = e[o].clone();
this._raw = r || !1,
this._alignTangentsWithPath = n,
this._compute(t, n)
}
return i.prototype.getCurve = function() {
return this._curve
}
,
i.prototype.getPoints = function() {
return this._curve
}
,
i.prototype.length = function() {
return this._distances[this._distances.length - 1]
}
,
i.prototype.getTangents = function() {
return this._tangents
}
,
i.prototype.getNormals = function() {
return this._normals
}
,
i.prototype.getBinormals = function() {
return this._binormals
}
,
i.prototype.getDistances = function() {
return this._distances
}
,
i.prototype.getPointAt = function(e) {
return this._updatePointAtData(e).point
}
,
i.prototype.getTangentAt = function(e, t) {
return t === void 0 && (t = !1),
this._updatePointAtData(e, t),
t ? Vector3.TransformCoordinates(Vector3.Forward(), this._pointAtData.interpolationMatrix) : this._tangents[this._pointAtData.previousPointArrayIndex]
}
,
i.prototype.getNormalAt = function(e, t) {
return t === void 0 && (t = !1),
this._updatePointAtData(e, t),
t ? Vector3.TransformCoordinates(Vector3.Right(), this._pointAtData.interpolationMatrix) : this._normals[this._pointAtData.previousPointArrayIndex]
}
,
i.prototype.getBinormalAt = function(e, t) {
return t === void 0 && (t = !1),
this._updatePointAtData(e, t),
t ? Vector3.TransformCoordinates(Vector3.UpReadOnly, this._pointAtData.interpolationMatrix) : this._binormals[this._pointAtData.previousPointArrayIndex]
}
,
i.prototype.getDistanceAt = function(e) {
return this.length() * e
}
,
i.prototype.getPreviousPointIndexAt = function(e) {
return this._updatePointAtData(e),
this._pointAtData.previousPointArrayIndex
}
,
i.prototype.getSubPositionAt = function(e) {
return this._updatePointAtData(e),
this._pointAtData.subPosition
}
,
i.prototype.getClosestPositionTo = function(e) {
for (var t = Number.MAX_VALUE, r = 0, n = 0; n < this._curve.length - 1; n++) {
var o = this._curve[n + 0]
, a = this._curve[n + 1].subtract(o).normalize()
, s = this._distances[n + 1] - this._distances[n + 0]
, l = Math.min(Math.max(Vector3.Dot(a, e.subtract(o).normalize()), 0) * Vector3.Distance(o, e) / s, 1)
, u = Vector3.Distance(o.add(a.scale(l * s)), e);
u < t && (t = u,
r = (this._distances[n + 0] + s * l) / this.length())
}
return r
}
,
i.prototype.slice = function(e, t) {
if (e === void 0 && (e = 0),
t === void 0 && (t = 1),
e < 0 && (e = 1 - e * -1 % 1),
t < 0 && (t = 1 - t * -1 % 1),
e > t) {
var r = e;
e = t,
t = r
}
var n = this.getCurve()
, o = this.getPointAt(e)
, a = this.getPreviousPointIndexAt(e)
, s = this.getPointAt(t)
, l = this.getPreviousPointIndexAt(t) + 1
, u = [];
return e !== 0 && (a++,
u.push(o)),
u.push.apply(u, n.slice(a, l)),
(t !== 1 || e === 1) && u.push(s),
new i(u,this.getNormalAt(e),this._raw,this._alignTangentsWithPath)
}
,
i.prototype.update = function(e, t, r) {
t === void 0 && (t = null),
r === void 0 && (r = !1);
for (var n = 0; n < e.length; n++)
this._curve[n].x = e[n].x,
this._curve[n].y = e[n].y,
this._curve[n].z = e[n].z;
return this._compute(t, r),
this
}
,
i.prototype._compute = function(e, t) {
t === void 0 && (t = !1);
var r = this._curve.length;
if (!(r < 2)) {
this._tangents[0] = this._getFirstNonNullVector(0),
this._raw || this._tangents[0].normalize(),
this._tangents[r - 1] = this._curve[r - 1].subtract(this._curve[r - 2]),
this._raw || this._tangents[r - 1].normalize();
var n = this._tangents[0]
, o = this._normalVector(n, e);
this._normals[0] = o,
this._raw || this._normals[0].normalize(),
this._binormals[0] = Vector3.Cross(n, this._normals[0]),
this._raw || this._binormals[0].normalize(),
this._distances[0] = 0;
for (var a, s, l, u, c, h = 1; h < r; h++)
a = this._getLastNonNullVector(h),
h < r - 1 && (s = this._getFirstNonNullVector(h),
this._tangents[h] = t ? s : a.add(s),
this._tangents[h].normalize()),
this._distances[h] = this._distances[h - 1] + this._curve[h].subtract(this._curve[h - 1]).length(),
l = this._tangents[h],
c = this._binormals[h - 1],
this._normals[h] = Vector3.Cross(c, l),
this._raw || (this._normals[h].length() === 0 ? (u = this._normals[h - 1],
this._normals[h] = u.clone()) : this._normals[h].normalize()),
this._binormals[h] = Vector3.Cross(l, this._normals[h]),
this._raw || this._binormals[h].normalize();
this._pointAtData.id = NaN
}
}
,
i.prototype._getFirstNonNullVector = function(e) {
for (var t = 1, r = this._curve[e + t].subtract(this._curve[e]); r.length() === 0 && e + t + 1 < this._curve.length; )
t++,
r = this._curve[e + t].subtract(this._curve[e]);
return r
}
,
i.prototype._getLastNonNullVector = function(e) {
for (var t = 1, r = this._curve[e].subtract(this._curve[e - t]); r.length() === 0 && e > t + 1; )
t++,
r = this._curve[e].subtract(this._curve[e - t]);
return r
}
,
i.prototype._normalVector = function(e, t) {
var r, n = e.length();
if (n === 0 && (n = 1),
t == null) {
var o;
Scalar.WithinEpsilon(Math.abs(e.y) / n, 1, Epsilon) ? Scalar.WithinEpsilon(Math.abs(e.x) / n, 1, Epsilon) ? Scalar.WithinEpsilon(Math.abs(e.z) / n, 1, Epsilon) ? o = Vector3.Zero() : o = new Vector3(0,0,1) : o = new Vector3(1,0,0) : o = new Vector3(0,-1,0),
r = Vector3.Cross(e, o)
} else
r = Vector3.Cross(e, t),
Vector3.CrossToRef(r, e, r);
return r.normalize(),
r
}
,
i.prototype._updatePointAtData = function(e, t) {
if (t === void 0 && (t = !1),
this._pointAtData.id === e)
return this._pointAtData.interpolateReady || this._updateInterpolationMatrix(),
this._pointAtData;
this._pointAtData.id = e;
var r = this.getPoints();
if (e <= 0)
return this._setPointAtData(0, 0, r[0], 0, t);
if (e >= 1)
return this._setPointAtData(1, 1, r[r.length - 1], r.length - 1, t);
for (var n = r[0], o, a = 0, s = e * this.length(), l = 1; l < r.length; l++) {
o = r[l];
var u = Vector3.Distance(n, o);
if (a += u,
a === s)
return this._setPointAtData(e, 1, o, l, t);
if (a > s) {
var c = a - s
, h = c / u
, f = n.subtract(o)
, d = o.add(f.scaleInPlace(h));
return this._setPointAtData(e, 1 - h, d, l - 1, t)
}
n = o
}
return this._pointAtData
}
,
i.prototype._setPointAtData = function(e, t, r, n, o) {
return this._pointAtData.point = r,
this._pointAtData.position = e,
this._pointAtData.subPosition = t,
this._pointAtData.previousPointArrayIndex = n,
this._pointAtData.interpolateReady = o,
o && this._updateInterpolationMatrix(),
this._pointAtData
}
,
i.prototype._updateInterpolationMatrix = function() {
this._pointAtData.interpolationMatrix = Matrix.Identity();
var e = this._pointAtData.previousPointArrayIndex;
if (e !== this._tangents.length - 1) {
var t = e + 1
, r = this._tangents[e].clone()
, n = this._normals[e].clone()
, o = this._binormals[e].clone()
, a = this._tangents[t].clone()
, s = this._normals[t].clone()
, l = this._binormals[t].clone()
, u = Quaternion.RotationQuaternionFromAxis(n, o, r)
, c = Quaternion.RotationQuaternionFromAxis(s, l, a)
, h = Quaternion.Slerp(u, c, this._pointAtData.subPosition);
h.toRotationMatrix(this._pointAtData.interpolationMatrix)
}
}
,
i
}()
, Curve3 = function() {
function i(e) {
this._length = 0,
this._points = e,
this._length = this._computeLength(e)
}
return i.CreateQuadraticBezier = function(e, t, r, n) {
n = n > 2 ? n : 3;
for (var o = new Array, a = function(l, u, c, h) {
var f = (1 - l) * (1 - l) * u + 2 * l * (1 - l) * c + l * l * h;
return f
}, s = 0; s <= n; s++)
o.push(new Vector3(a(s / n, e.x, t.x, r.x),a(s / n, e.y, t.y, r.y),a(s / n, e.z, t.z, r.z)));
return new i(o)
}
,
i.CreateCubicBezier = function(e, t, r, n, o) {
o = o > 3 ? o : 4;
for (var a = new Array, s = function(u, c, h, f, d) {
var _ = (1 - u) * (1 - u) * (1 - u) * c + 3 * u * (1 - u) * (1 - u) * h + 3 * u * u * (1 - u) * f + u * u * u * d;
return _
}, l = 0; l <= o; l++)
a.push(new Vector3(s(l / o, e.x, t.x, r.x, n.x),s(l / o, e.y, t.y, r.y, n.y),s(l / o, e.z, t.z, r.z, n.z)));
return new i(a)
}
,
i.CreateHermiteSpline = function(e, t, r, n, o) {
for (var a = new Array, s = 1 / o, l = 0; l <= o; l++)
a.push(Vector3.Hermite(e, t, r, n, l * s));
return new i(a)
}
,
i.CreateCatmullRomSpline = function(e, t, r) {
var n = new Array
, o = 1 / t
, a = 0;
if (r) {
for (var s = e.length, l = 0; l < s; l++) {
a = 0;
for (var u = 0; u < t; u++)
n.push(Vector3.CatmullRom(e[l % s], e[(l + 1) % s], e[(l + 2) % s], e[(l + 3) % s], a)),
a += o
}
n.push(n[0])
} else {
var c = new Array;
c.push(e[0].clone()),
Array.prototype.push.apply(c, e),
c.push(e[e.length - 1].clone());
for (var l = 0; l < c.length - 3; l++) {
a = 0;
for (var u = 0; u < t; u++)
n.push(Vector3.CatmullRom(c[l], c[l + 1], c[l + 2], c[l + 3], a)),
a += o
}
l--,
n.push(Vector3.CatmullRom(c[l], c[l + 1], c[l + 2], c[l + 3], a))
}
return new i(n)
}
,
i.prototype.getPoints = function() {
return this._points
}
,
i.prototype.length = function() {
return this._length
}
,
i.prototype.continue = function(e) {
for (var t = this._points[this._points.length - 1], r = this._points.slice(), n = e.getPoints(), o = 1; o < n.length; o++)
r.push(n[o].subtract(n[0]).add(t));
var a = new i(r);
return a
}
,
i.prototype._computeLength = function(e) {
for (var t = 0, r = 1; r < e.length; r++)
t += e[r].subtract(e[r - 1]).length();
return t
}
,
i
}()
, EasingFunction = function() {
function i() {
this._easingMode = i.EASINGMODE_EASEIN
}
return i.prototype.setEasingMode = function(e) {
var t = Math.min(Math.max(e, 0), 2);
this._easingMode = t
}
,
i.prototype.getEasingMode = function() {
return this._easingMode
}
,
i.prototype.easeInCore = function(e) {
throw new Error("You must implement this method")
}
,
i.prototype.ease = function(e) {
switch (this._easingMode) {
case i.EASINGMODE_EASEIN:
return this.easeInCore(e);
case i.EASINGMODE_EASEOUT:
return 1 - this.easeInCore(1 - e)
}
return e >= .5 ? (1 - this.easeInCore((1 - e) * 2)) * .5 + .5 : this.easeInCore(e * 2) * .5
}
,
i.EASINGMODE_EASEIN = 0,
i.EASINGMODE_EASEOUT = 1,
i.EASINGMODE_EASEINOUT = 2,
i
}()
, CircleEase = function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.easeInCore = function(t) {
return t = Math.max(0, Math.min(1, t)),
1 - Math.sqrt(1 - t * t)
}
,
e
}(EasingFunction)
, BackEase = function(i) {
__extends(e, i);
function e(t) {
t === void 0 && (t = 1);
var r = i.call(this) || this;
return r.amplitude = t,
r
}
return e.prototype.easeInCore = function(t) {
var r = Math.max(0, this.amplitude);
return Math.pow(t, 3) - t * r * Math.sin(3.141592653589793 * t)
}
,
e
}(EasingFunction);
(function(i) {
__extends(e, i);
function e(t, r) {
t === void 0 && (t = 3),
r === void 0 && (r = 2);
var n = i.call(this) || this;
return n.bounces = t,
n.bounciness = r,
n
}
return e.prototype.easeInCore = function(t) {
var r = Math.max(0, this.bounces)
, n = this.bounciness;
n <= 1 && (n = 1.001);
var o = Math.pow(n, r)
, a = 1 - n
, s = (1 - o) / a + o * .5
, l = t * s
, u = Math.log(-l * (1 - n) + 1) / Math.log(n)
, c = Math.floor(u)
, h = c + 1
, f = (1 - Math.pow(n, c)) / (a * s)
, d = (1 - Math.pow(n, h)) / (a * s)
, _ = (f + d) * .5
, g = t - _
, m = _ - f;
return -Math.pow(1 / n, r - c) / (m * m) * (g - m) * (g + m)
}
,
e
}
)(EasingFunction);
(function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.easeInCore = function(t) {
return t * t * t
}
,
e
}
)(EasingFunction);
(function(i) {
__extends(e, i);
function e(t, r) {
t === void 0 && (t = 3),
r === void 0 && (r = 3);
var n = i.call(this) || this;
return n.oscillations = t,
n.springiness = r,
n
}
return e.prototype.easeInCore = function(t) {
var r, n = Math.max(0, this.oscillations), o = Math.max(0, this.springiness);
return o == 0 ? r = t : r = (Math.exp(o * t) - 1) / (Math.exp(o) - 1),
r * Math.sin((6.283185307179586 * n + 1.5707963267948966) * t)
}
,
e
}
)(EasingFunction);
var ExponentialEase = function(i) {
__extends(e, i);
function e(t) {
t === void 0 && (t = 2);
var r = i.call(this) || this;
return r.exponent = t,
r
}
return e.prototype.easeInCore = function(t) {
return this.exponent <= 0 ? t : (Math.exp(this.exponent * t) - 1) / (Math.exp(this.exponent) - 1)
}
,
e
}(EasingFunction);
(function(i) {
__extends(e, i);
function e(t) {
t === void 0 && (t = 2);
var r = i.call(this) || this;
return r.power = t,
r
}
return e.prototype.easeInCore = function(t) {
var r = Math.max(0, this.power);
return Math.pow(t, r)
}
,
e
}
)(EasingFunction);
(function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.easeInCore = function(t) {
return t * t
}
,
e
}
)(EasingFunction);
(function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.easeInCore = function(t) {
return t * t * t * t
}
,
e
}
)(EasingFunction);
(function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.easeInCore = function(t) {
return t * t * t * t * t
}
,
e
}
)(EasingFunction);
var SineEase = function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.easeInCore = function(t) {
return 1 - Math.sin(1.5707963267948966 * (1 - t))
}
,
e
}(EasingFunction);
(function(i) {
__extends(e, i);
function e(t, r, n, o) {
t === void 0 && (t = 0),
r === void 0 && (r = 0),
n === void 0 && (n = 1),
o === void 0 && (o = 1);
var a = i.call(this) || this;
return a.x1 = t,
a.y1 = r,
a.x2 = n,
a.y2 = o,
a
}
return e.prototype.easeInCore = function(t) {
return BezierCurve.Interpolate(t, this.x1, this.y1, this.x2, this.y2)
}
,
e
}
)(EasingFunction);
var BouncingBehavior = function() {
function i() {
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(i.prototype, "name", {
get: function() {
return "Bouncing"
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "autoTransitionRange", {
get: function() {
return this._autoTransitionRange
},
set: function(e) {
var t = this;
if (this._autoTransitionRange !== e) {
this._autoTransitionRange = e;
var r = this._attachedCamera;
!r || (e ? this._onMeshTargetChangedObserver = r.onMeshTargetChangedObservable.add(function(n) {
if (!!n) {
n.computeWorldMatrix(!0);
var o = n.getBoundingInfo().diagonalLength;
t.lowerRadiusTransitionRange = o * .05,
t.upperRadiusTransitionRange = o * .05
}
}) : this._onMeshTargetChangedObserver && r.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))
}
},
enumerable: !1,
configurable: !0
}),
i.prototype.init = function() {}
,
i.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))
})
}
,
i.prototype.detach = function() {
!this._attachedCamera || (this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),
this._attachedCamera = null)
}
,
i.prototype._isRadiusAtLimit = function(e) {
return this._attachedCamera ? this._attachedCamera.radius === e && !this._radiusIsAnimating : !1
}
,
i.prototype._applyBoundRadiusAnimation = function(e) {
var t = this;
if (!!this._attachedCamera) {
this._radiusBounceTransition || (i.EasingFunction.setEasingMode(i.EasingMode),
this._radiusBounceTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, i.EasingFunction)),
this._cachedWheelPrecision = this._attachedCamera.wheelPrecision,
this._attachedCamera.wheelPrecision = 1 / 0,
this._attachedCamera.inertialRadiusOffset = 0,
this.stopAllAnimations(),
this._radiusIsAnimating = !0;
var r = Animation.TransitionTo("radius", this._attachedCamera.radius + e, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, function() {
return t._clearAnimationLocks()
});
r && this._animatables.push(r)
}
}
,
i.prototype._clearAnimationLocks = function() {
this._radiusIsAnimating = !1,
this._attachedCamera && (this._attachedCamera.wheelPrecision = this._cachedWheelPrecision)
}
,
i.prototype.stopAllAnimations = function() {
for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
this._animatables[0].onAnimationEnd = null,
this._animatables[0].stop(),
this._animatables.shift()
}
,
i.EasingFunction = new BackEase(.3),
i.EasingMode = EasingFunction.EASINGMODE_EASEOUT,
i
}()
, FramingBehavior = function() {
function i() {
this.onTargetFramingAnimationEndObservable = new Observable,
this._mode = i.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(i.prototype, "name", {
get: function() {
return "Framing"
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "mode", {
get: function() {
return this._mode
},
set: function(e) {
this._mode = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "radiusScale", {
get: function() {
return this._radiusScale
},
set: function(e) {
this._radiusScale = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "positionScale", {
get: function() {
return this._positionScale
},
set: function(e) {
this._positionScale = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "defaultElevation", {
get: function() {
return this._defaultElevation
},
set: function(e) {
this._defaultElevation = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "elevationReturnTime", {
get: function() {
return this._elevationReturnTime
},
set: function(e) {
this._elevationReturnTime = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "elevationReturnWaitTime", {
get: function() {
return this._elevationReturnWaitTime
},
set: function(e) {
this._elevationReturnWaitTime = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "zoomStopsAnimation", {
get: function() {
return this._zoomStopsAnimation
},
set: function(e) {
this._zoomStopsAnimation = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "framingTime", {
get: function() {
return this._framingTime
},
set: function(e) {
this._framingTime = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.init = function() {}
,
i.prototype.attach = function(e) {
var t = this;
this._attachedCamera = e;
var r = this._attachedCamera.getScene();
i.EasingFunction.setEasingMode(i.EasingMode),
this._onPrePointerObservableObserver = r.onPrePointerObservable.add(function(n) {
if (n.type === PointerEventTypes.POINTERDOWN) {
t._isPointerDown = !0;
return
}
n.type === PointerEventTypes.POINTERUP && (t._isPointerDown = !1)
}),
this._onMeshTargetChangedObserver = e.onMeshTargetChangedObservable.add(function(n) {
n && t.zoomOnMesh(n, void 0, function() {
t.onTargetFramingAnimationEndObservable.notifyObservers()
})
}),
this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add(function() {
t._applyUserInteraction(),
t._maintainCameraAboveGround()
})
}
,
i.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
}
}
,
i.prototype.zoomOnMesh = function(e, t, r) {
t === void 0 && (t = !1),
r === void 0 && (r = null),
e.computeWorldMatrix(!0);
var n = e.getBoundingInfo().boundingBox;
this.zoomOnBoundingInfo(n.minimumWorld, n.maximumWorld, t, r)
}
,
i.prototype.zoomOnMeshHierarchy = function(e, t, r) {
t === void 0 && (t = !1),
r === void 0 && (r = null),
e.computeWorldMatrix(!0);
var n = e.getHierarchyBoundingVectors(!0);
this.zoomOnBoundingInfo(n.min, n.max, t, r)
}
,
i.prototype.zoomOnMeshesHierarchy = function(e, t, r) {
t === void 0 && (t = !1),
r === void 0 && (r = null);
for (var n = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE), o = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE), a = 0; a < e.length; a++) {
var s = e[a].getHierarchyBoundingVectors(!0);
Vector3.CheckExtends(s.min, n, o),
Vector3.CheckExtends(s.max, n, o)
}
this.zoomOnBoundingInfo(n, o, t, r)
}
,
i.prototype.zoomOnBoundingInfo = function(e, t, r, n) {
var o = this;
r === void 0 && (r = !1),
n === void 0 && (n = null);
var a;
if (!!this._attachedCamera) {
var s = e.y
, l = t.y
, u = s + (l - s) * this._positionScale
, c = t.subtract(e).scale(.5);
if (r)
a = new Vector3(0,u,0);
else {
var h = e.add(c);
a = new Vector3(h.x,u,h.z)
}
this._vectorTransition || (this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, i.EasingFunction)),
this._betaIsAnimating = !0;
var f = Animation.TransitionTo("target", a, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
f && this._animatables.push(f);
var d = 0;
if (this._mode === i.FitFrustumSidesMode) {
var _ = this._calculateLowerRadiusFromModelBoundingSphere(e, t);
this.autoCorrectCameraLimitsAndSensibility && (this._attachedCamera.lowerRadiusLimit = c.length() + this._attachedCamera.minZ),
d = _
} else
this._mode === i.IgnoreBoundsSizeMode && (d = this._calculateLowerRadiusFromModelBoundingSphere(e, t),
this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null && (this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ));
if (this.autoCorrectCameraLimitsAndSensibility) {
var g = t.subtract(e).length();
this._attachedCamera.panningSensibility = 5e3 / g,
this._attachedCamera.wheelPrecision = 100 / d
}
this._radiusTransition || (this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, i.EasingFunction)),
f = Animation.TransitionTo("radius", d, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function() {
o.stopAllAnimations(),
n && n(),
o._attachedCamera && o._attachedCamera.useInputToRestoreState && o._attachedCamera.storeState()
}),
f && this._animatables.push(f)
}
}
,
i.prototype._calculateLowerRadiusFromModelBoundingSphere = function(e, t) {
var r = t.subtract(e)
, n = r.length()
, o = this._getFrustumSlope()
, a = n * .5
, s = a * this._radiusScale
, l = s * Math.sqrt(1 + 1 / (o.x * o.x))
, u = s * Math.sqrt(1 + 1 / (o.y * o.y))
, c = Math.max(l, u)
, h = this._attachedCamera;
return h ? (h.lowerRadiusLimit && this._mode === i.IgnoreBoundsSizeMode && (c = c < h.lowerRadiusLimit ? h.lowerRadiusLimit : c),
h.upperRadiusLimit && (c = c > h.upperRadiusLimit ? h.upperRadiusLimit : c),
c) : 0
}
,
i.prototype._maintainCameraAboveGround = function() {
var e = this;
if (!(this._elevationReturnTime < 0)) {
var t = PrecisionDate.Now - this._lastInteractionTime
, r = Math.PI * .5 - this._defaultElevation
, n = Math.PI * .5;
if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > n && t >= this._elevationReturnWaitTime) {
this._betaIsAnimating = !0,
this.stopAllAnimations(),
this._betaTransition || (this._betaTransition = Animation.CreateAnimation("beta", Animation.ANIMATIONTYPE_FLOAT, 60, i.EasingFunction));
var o = Animation.TransitionTo("beta", r, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function() {
e._clearAnimationLocks(),
e.stopAllAnimations()
});
o && this._animatables.push(o)
}
}
}
,
i.prototype._getFrustumSlope = function() {
var e = this._attachedCamera;
if (!e)
return Vector2.Zero();
var t = e.getScene().getEngine()
, r = t.getAspectRatio(e)
, n = Math.tan(e.fov / 2)
, o = n * r;
return new Vector2(o,n)
}
,
i.prototype._clearAnimationLocks = function() {
this._betaIsAnimating = !1
}
,
i.prototype._applyUserInteraction = function() {
this.isUserIsMoving && (this._lastInteractionTime = PrecisionDate.Now,
this.stopAllAnimations(),
this._clearAnimationLocks())
}
,
i.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(i.prototype, "isUserIsMoving", {
get: function() {
return this._attachedCamera ? this._attachedCamera.inertialAlphaOffset !== 0 || this._attachedCamera.inertialBetaOffset !== 0 || this._attachedCamera.inertialRadiusOffset !== 0 || this._attachedCamera.inertialPanningX !== 0 || this._attachedCamera.inertialPanningY !== 0 || this._isPointerDown : !1
},
enumerable: !1,
configurable: !0
}),
i.EasingFunction = new ExponentialEase,
i.EasingMode = EasingFunction.EASINGMODE_EASEINOUT,
i.IgnoreBoundsSizeMode = 0,
i.FitFrustumSidesMode = 1,
i
}()
, TargetCamera = function(i) {
__extends(e, i);
function e(t, r, n, o) {
o === void 0 && (o = !0);
var a = i.call(this, t, r, n, o) || this;
return a._tmpUpVector = Vector3.Zero(),
a._tmpTargetVector = Vector3.Zero(),
a.cameraDirection = new Vector3(0,0,0),
a.cameraRotation = new Vector2(0,0),
a.ignoreParentScaling = !1,
a.updateUpVectorFromRotation = !1,
a._tmpQuaternion = new Quaternion,
a.rotation = new Vector3(0,0,0),
a.speed = 2,
a.noRotationConstraint = !1,
a.invertRotation = !1,
a.inverseRotationSpeed = .2,
a.lockedTarget = null,
a._currentTarget = Vector3.Zero(),
a._initialFocalDistance = 1,
a._viewMatrix = Matrix.Zero(),
a._camMatrix = Matrix.Zero(),
a._cameraTransformMatrix = Matrix.Zero(),
a._cameraRotationMatrix = Matrix.Zero(),
a._referencePoint = new Vector3(0,0,1),
a._transformedReferencePoint = Vector3.Zero(),
a._defaultUp = Vector3.Up(),
a._cachedRotationZ = 0,
a._cachedQuaternionRotationZ = 0,
a
}
return e.prototype.getFrontPosition = function(t) {
this.getWorldMatrix();
var r = this.getTarget().subtract(this.position);
return r.normalize(),
r.scaleInPlace(t),
this.globalPosition.add(r)
}
,
e.prototype._getLockedTargetPosition = function() {
return this.lockedTarget ? (this.lockedTarget.absolutePosition && this.lockedTarget.computeWorldMatrix(),
this.lockedTarget.absolutePosition || this.lockedTarget) : null
}
,
e.prototype.storeState = function() {
return this._storedPosition = this.position.clone(),
this._storedRotation = this.rotation.clone(),
this.rotationQuaternion && (this._storedRotationQuaternion = this.rotationQuaternion.clone()),
i.prototype.storeState.call(this)
}
,
e.prototype._restoreStateValues = function() {
return i.prototype._restoreStateValues.call(this) ? (this.position = this._storedPosition.clone(),
this.rotation = this._storedRotation.clone(),
this.rotationQuaternion && (this.rotationQuaternion = this._storedRotationQuaternion.clone()),
this.cameraDirection.copyFromFloats(0, 0, 0),
this.cameraRotation.copyFromFloats(0, 0),
!0) : !1
}
,
e.prototype._initCache = function() {
i.prototype._initCache.call(this),
this._cache.lockedTarget = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._cache.rotation = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._cache.rotationQuaternion = new Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
}
,
e.prototype._updateCache = function(t) {
t || i.prototype._updateCache.call(this);
var r = this._getLockedTargetPosition();
r ? this._cache.lockedTarget ? this._cache.lockedTarget.copyFrom(r) : this._cache.lockedTarget = r.clone() : this._cache.lockedTarget = null,
this._cache.rotation.copyFrom(this.rotation),
this.rotationQuaternion && this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)
}
,
e.prototype._isSynchronizedViewMatrix = function() {
if (!i.prototype._isSynchronizedViewMatrix.call(this))
return !1;
var t = this._getLockedTargetPosition();
return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(t) : !t) && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation))
}
,
e.prototype._computeLocalCameraSpeed = function() {
var t = this.getEngine();
return this.speed * Math.sqrt(t.getDeltaTime() / (t.getFps() * 100))
}
,
e.prototype.setTarget = function(t) {
this.upVector.normalize(),
this._initialFocalDistance = t.subtract(this.position).length(),
this.position.z === t.z && (this.position.z += Epsilon),
this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),
Matrix.LookAtLHToRef(this.position, t, this._defaultUp, this._camMatrix),
this._camMatrix.invert(),
this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
var r = t.subtract(this.position);
r.x >= 0 ? this.rotation.y = -Math.atan(r.z / r.x) + Math.PI / 2 : this.rotation.y = -Math.atan(r.z / r.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 && Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
}
,
Object.defineProperty(e.prototype, "target", {
get: function() {
return this.getTarget()
},
set: function(t) {
this.setTarget(t)
},
enumerable: !1,
configurable: !0
}),
e.prototype.getTarget = function() {
return this._currentTarget
}
,
e.prototype._decideIfNeedsToMove = function() {
return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
}
,
e.prototype._updatePosition = function() {
if (this.parent) {
this.parent.getWorldMatrix().invertToRef(TmpVectors.Matrix[0]),
Vector3.TransformNormalToRef(this.cameraDirection, TmpVectors.Matrix[0], TmpVectors.Vector3[0]),
this.position.addInPlace(TmpVectors.Vector3[0]);
return
}
this.position.addInPlace(this.cameraDirection)
}
,
e.prototype._checkInputs = function() {
var t = this.invertRotation ? -this.inverseRotationSpeed : 1
, r = this._decideIfNeedsToMove()
, n = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
if (r && 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) {
var o = 1.570796;
this.rotation.x > o && (this.rotation.x = o),
this.rotation.x < -o && (this.rotation.x = -o)
}
if (this.rotationQuaternion) {
var a = this.rotation.lengthSquared();
a && Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
}
}
r && (Math.abs(this.cameraDirection.x) < this.speed * Epsilon && (this.cameraDirection.x = 0),
Math.abs(this.cameraDirection.y) < this.speed * Epsilon && (this.cameraDirection.y = 0),
Math.abs(this.cameraDirection.z) < this.speed * Epsilon && (this.cameraDirection.z = 0),
this.cameraDirection.scaleInPlace(this.inertia)),
n && (Math.abs(this.cameraRotation.x) < this.speed * Epsilon && (this.cameraRotation.x = 0),
Math.abs(this.cameraRotation.y) < this.speed * Epsilon && (this.cameraRotation.y = 0),
this.cameraRotation.scaleInPlace(this.inertia)),
i.prototype._checkInputs.call(this)
}
,
e.prototype._updateCameraRotationMatrix = function() {
this.rotationQuaternion ? this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix) : Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix)
}
,
e.prototype._rotateUpVectorWithCameraRotationMatrix = function() {
return Vector3.TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector),
this
}
,
e.prototype._getViewMatrix = function() {
return this.lockedTarget && this.setTarget(this._getLockedTargetPosition()),
this._updateCameraRotationMatrix(),
this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z ? (this._rotateUpVectorWithCameraRotationMatrix(),
this._cachedQuaternionRotationZ = this.rotationQuaternion.z) : this._cachedRotationZ !== this.rotation.z && (this._rotateUpVectorWithCameraRotationMatrix(),
this._cachedRotationZ = this.rotation.z),
Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
this.updateUpVectorFromRotation && (this.rotationQuaternion ? Axis.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector) : (Quaternion.FromEulerVectorToRef(this.rotation, this._tmpQuaternion),
Axis.Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector))),
this._computeViewMatrix(this.position, this._currentTarget, this.upVector),
this._viewMatrix
}
,
e.prototype._computeViewMatrix = function(t, r, n) {
if (this.ignoreParentScaling) {
if (this.parent) {
var o = this.parent.getWorldMatrix();
Vector3.TransformCoordinatesToRef(t, o, this._globalPosition),
Vector3.TransformCoordinatesToRef(r, o, this._tmpTargetVector),
Vector3.TransformNormalToRef(n, o, this._tmpUpVector),
this._markSyncedWithParent()
} else
this._globalPosition.copyFrom(t),
this._tmpTargetVector.copyFrom(r),
this._tmpUpVector.copyFrom(n);
this.getScene().useRightHandedSystem ? Matrix.LookAtRHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) : Matrix.LookAtLHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix);
return
}
if (this.getScene().useRightHandedSystem ? Matrix.LookAtRHToRef(t, r, n, this._viewMatrix) : Matrix.LookAtLHToRef(t, r, n, this._viewMatrix),
this.parent) {
var o = this.parent.getWorldMatrix();
this._viewMatrix.invert(),
this._viewMatrix.multiplyToRef(o, this._viewMatrix),
this._viewMatrix.getTranslationToRef(this._globalPosition),
this._viewMatrix.invert(),
this._markSyncedWithParent()
} else
this._globalPosition.copyFrom(t)
}
,
e.prototype.createRigCamera = function(t, r) {
if (this.cameraRigMode !== Camera$1.RIG_MODE_NONE) {
var n = new e(t,this.position.clone(),this.getScene());
return n.isRigCamera = !0,
n.rigParent = this,
(this.cameraRigMode === Camera$1.RIG_MODE_VR || this.cameraRigMode === Camera$1.RIG_MODE_WEBVR) && (this.rotationQuaternion || (this.rotationQuaternion = new Quaternion),
n._cameraRigParams = {},
n.rotationQuaternion = new Quaternion),
n
}
return null
}
,
e.prototype._updateRigCameras = function() {
var t = this._rigCameras[0]
, r = this._rigCameras[1];
switch (this.computeWorldMatrix(),
this.cameraRigMode) {
case Camera$1.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
case Camera$1.RIG_MODE_STEREOSCOPIC_OVERUNDER:
case Camera$1.RIG_MODE_STEREOSCOPIC_INTERLACED:
var n = this.cameraRigMode === Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? 1 : -1
, o = this.cameraRigMode === Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? -1 : 1;
this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * n, t),
this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * o, r);
break;
case Camera$1.RIG_MODE_VR:
t.rotationQuaternion ? (t.rotationQuaternion.copyFrom(this.rotationQuaternion),
r.rotationQuaternion.copyFrom(this.rotationQuaternion)) : (t.rotation.copyFrom(this.rotation),
r.rotation.copyFrom(this.rotation)),
t.position.copyFrom(this.position),
r.position.copyFrom(this.position);
break
}
i.prototype._updateRigCameras.call(this)
}
,
e.prototype._getRigCamPositionAndTarget = function(t, r) {
var n = this.getTarget();
n.subtractToRef(this.position, e._TargetFocalPoint),
e._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
var o = e._TargetFocalPoint.addInPlace(this.position);
Matrix.TranslationToRef(-o.x, -o.y, -o.z, e._TargetTransformMatrix),
e._TargetTransformMatrix.multiplyToRef(Matrix.RotationAxis(r.upVector, t), e._RigCamTransformMatrix),
Matrix.TranslationToRef(o.x, o.y, o.z, e._TargetTransformMatrix),
e._RigCamTransformMatrix.multiplyToRef(e._TargetTransformMatrix, e._RigCamTransformMatrix),
Vector3.TransformCoordinatesToRef(this.position, e._RigCamTransformMatrix, r.position),
r.setTarget(o)
}
,
e.prototype.getClassName = function() {
return "TargetCamera"
}
,
e._RigCamTransformMatrix = new Matrix,
e._TargetTransformMatrix = new Matrix,
e._TargetFocalPoint = new Vector3,
__decorate([serializeAsVector3()], e.prototype, "rotation", void 0),
__decorate([serialize()], e.prototype, "speed", void 0),
__decorate([serializeAsMeshReference("lockedTargetId")], e.prototype, "lockedTarget", void 0),
e
}(Camera$1)
, CameraInputTypes = {}
, CameraInputsManager = function() {
function i(e) {
this.attachedToElement = !1,
this.attached = {},
this.camera = e,
this.checkInputs = function() {}
}
return i.prototype.add = function(e) {
var t = e.getSimpleName();
if (this.attached[t]) {
Logger$2.Warn("camera input of type " + t + " already exists on camera");
return
}
this.attached[t] = e,
e.camera = this.camera,
e.checkInputs && (this.checkInputs = this._addCheckInputs(e.checkInputs.bind(e))),
this.attachedToElement && e.attachControl()
}
,
i.prototype.remove = function(e) {
for (var t in this.attached) {
var r = this.attached[t];
r === e && (r.detachControl(),
r.camera = null,
delete this.attached[t],
this.rebuildInputCheck())
}
}
,
i.prototype.removeByType = function(e) {
for (var t in this.attached) {
var r = this.attached[t];
r.getClassName() === e && (r.detachControl(),
r.camera = null,
delete this.attached[t],
this.rebuildInputCheck())
}
}
,
i.prototype._addCheckInputs = function(e) {
var t = this.checkInputs;
return function() {
t(),
e()
}
}
,
i.prototype.attachInput = function(e) {
this.attachedToElement && e.attachControl(this.noPreventDefault)
}
,
i.prototype.attachElement = function(e) {
if (e === void 0 && (e = !1),
!this.attachedToElement) {
e = Camera$1.ForceAttachControlToAlwaysPreventDefault ? !1 : e,
this.attachedToElement = !0,
this.noPreventDefault = e;
for (var t in this.attached)
this.attached[t].attachControl(e)
}
}
,
i.prototype.detachElement = function(e) {
e === void 0 && (e = !1);
for (var t in this.attached)
this.attached[t].detachControl(),
e && (this.attached[t].camera = null);
this.attachedToElement = !1
}
,
i.prototype.rebuildInputCheck = function() {
this.checkInputs = function() {}
;
for (var e in this.attached) {
var t = this.attached[e];
t.checkInputs && (this.checkInputs = this._addCheckInputs(t.checkInputs.bind(t)))
}
}
,
i.prototype.clear = function() {
this.attachedToElement && this.detachElement(!0),
this.attached = {},
this.attachedToElement = !1,
this.checkInputs = function() {}
}
,
i.prototype.serialize = function(e) {
var t = {};
for (var r in this.attached) {
var n = this.attached[r]
, o = SerializationHelper.Serialize(n);
t[n.getClassName()] = o
}
e.inputsmgr = t
}
,
i.prototype.parse = function(e) {
var t = e.inputsmgr;
if (t) {
this.clear();
for (var r in t) {
var n = CameraInputTypes[r];
if (n) {
var o = t[r]
, a = SerializationHelper.Parse(function() {
return new n
}, o, null);
this.add(a)
}
}
} else
for (var r in this.attached) {
var n = CameraInputTypes[this.attached[r].getClassName()];
if (n) {
var a = SerializationHelper.Parse(function() {
return new n
}, e, null);
this.remove(this.attached[r]),
this.add(a)
}
}
}
,
i
}()
, BaseCameraPointersInput = function() {
function i() {
this._currentActiveButton = -1,
this.buttons = [0, 1, 2]
}
return i.prototype.attachControl = function(e) {
var t = this;
e = Tools.BackCompatCameraNoPreventDefault(arguments);
var r = this.camera.getEngine()
, n = r.getInputElement()
, o = 0
, a = null;
this.pointA = null,
this.pointB = null,
this._altKey = !1,
this._ctrlKey = !1,
this._metaKey = !1,
this._shiftKey = !1,
this._buttonsPressed = 0,
this._pointerInput = function(l, u) {
var c = l.event
, h = c.pointerType === "touch";
if (!r.isInVRExclusivePointerMode && !(l.type !== PointerEventTypes.POINTERMOVE && t.buttons.indexOf(c.button) === -1)) {
var f = 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,
r.isPointerLock) {
var d = c.movementX || c.mozMovementX || c.webkitMovementX || c.msMovementX || 0
, _ = c.movementY || c.mozMovementY || c.webkitMovementY || c.msMovementY || 0;
t.onTouch(null, d, _),
t.pointA = null,
t.pointB = null
} else if (l.type === PointerEventTypes.POINTERDOWN && (t._currentActiveButton === -1 || h)) {
try {
f == null || f.setPointerCapture(c.pointerId)
} catch {}
t.pointA === null ? t.pointA = {
x: c.clientX,
y: c.clientY,
pointerId: c.pointerId,
type: c.pointerType
} : t.pointB === null && (t.pointB = {
x: c.clientX,
y: c.clientY,
pointerId: c.pointerId,
type: c.pointerType
}),
t._currentActiveButton === -1 && !h && (t._currentActiveButton = c.button),
t.onButtonDown(c),
e || (c.preventDefault(),
n && n.focus())
} else if (l.type === PointerEventTypes.POINTERDOUBLETAP)
t.onDoubleTap(c.pointerType);
else if (l.type === PointerEventTypes.POINTERUP && (t._currentActiveButton === c.button || h)) {
try {
f == null || f.releasePointerCapture(c.pointerId)
} catch {}
h || (t.pointB = null),
r._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,
(o !== 0 || a) && (t.onMultiTouch(t.pointA, t.pointB, o, 0, a, null),
o = 0,
a = null),
t._currentActiveButton = -1,
t.onButtonUp(c),
e || c.preventDefault()
} else if (l.type === PointerEventTypes.POINTERMOVE) {
if (e || c.preventDefault(),
t.pointA && t.pointB === null) {
var d = c.clientX - t.pointA.x
, _ = c.clientY - t.pointA.y;
t.onTouch(t.pointA, d, _),
t.pointA.x = c.clientX,
t.pointA.y = c.clientY
} else if (t.pointA && t.pointB) {
var g = t.pointA.pointerId === c.pointerId ? t.pointA : t.pointB;
g.x = c.clientX,
g.y = c.clientY;
var m = t.pointA.x - t.pointB.x
, v = t.pointA.y - t.pointB.y
, y = m * m + v * v
, b = {
x: (t.pointA.x + t.pointB.x) / 2,
y: (t.pointA.y + t.pointB.y) / 2,
pointerId: c.pointerId,
type: l.type
};
t.onMultiTouch(t.pointA, t.pointB, o, y, a, b),
a = b,
o = y
}
}
}
}
,
this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE | PointerEventTypes.POINTERDOUBLETAP),
this._onLostFocus = function() {
t.pointA = t.pointB = null,
o = 0,
a = null,
t.onLostFocus()
}
,
n && n.addEventListener("contextmenu", this.onContextMenu.bind(this), !1);
var s = this.camera.getScene().getEngine().getHostWindow();
s && Tools.RegisterTopRootEvents(s, [{
name: "blur",
handler: this._onLostFocus
}])
}
,
i.prototype.detachControl = function(e) {
if (this._onLostFocus) {
var t = this.camera.getScene().getEngine().getHostWindow();
t && Tools.UnregisterTopRootEvents(t, [{
name: "blur",
handler: this._onLostFocus
}])
}
if (this._observer) {
if (this.camera.getScene().onPointerObservable.remove(this._observer),
this._observer = null,
this.onContextMenu) {
var r = this.camera.getScene().getEngine().getInputElement();
r && r.removeEventListener("contextmenu", this.onContextMenu)
}
this._onLostFocus = null
}
this._altKey = !1,
this._ctrlKey = !1,
this._metaKey = !1,
this._shiftKey = !1,
this._buttonsPressed = 0
}
,
i.prototype.getClassName = function() {
return "BaseCameraPointersInput"
}
,
i.prototype.getSimpleName = function() {
return "pointers"
}
,
i.prototype.onDoubleTap = function(e) {}
,
i.prototype.onTouch = function(e, t, r) {}
,
i.prototype.onMultiTouch = function(e, t, r, n, o, a) {}
,
i.prototype.onContextMenu = function(e) {
e.preventDefault()
}
,
i.prototype.onButtonDown = function(e) {}
,
i.prototype.onButtonUp = function(e) {}
,
i.prototype.onLostFocus = function() {}
,
__decorate([serialize()], i.prototype, "buttons", void 0),
i
}()
, ArcRotateCameraPointersInput = function(i) {
__extends(e, i);
function e() {
var t = i !== null && i.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.pinchZoom = !0,
t.panningSensibility = 1e3,
t.multiTouchPanning = !0,
t.multiTouchPanAndZoom = !0,
t.pinchInwards = !0,
t._isPanClick = !1,
t._twoFingerActivityCount = 0,
t._isPinching = !1,
t
}
return e.prototype.getClassName = function() {
return "ArcRotateCameraPointersInput"
}
,
e.prototype._computeMultiTouchPanning = function(t, r) {
if (this.panningSensibility !== 0 && t && r) {
var n = r.x - t.x
, o = r.y - t.y;
this.camera.inertialPanningX += -n / this.panningSensibility,
this.camera.inertialPanningY += o / this.panningSensibility
}
}
,
e.prototype._computePinchZoom = function(t, r) {
var n = this.camera.radius || e.MinimumRadiusForPinch;
this.useNaturalPinchZoom ? this.camera.radius = n * Math.sqrt(t) / Math.sqrt(r) : this.pinchDeltaPercentage ? this.camera.inertialRadiusOffset += (r - t) * .001 * n * this.pinchDeltaPercentage : this.camera.inertialRadiusOffset += (r - t) / (this.pinchPrecision * (this.pinchInwards ? 1 : -1) * (this.angularSensibilityX + this.angularSensibilityY) / 2)
}
,
e.prototype.onTouch = function(t, r, n) {
this.panningSensibility !== 0 && (this._ctrlKey && this.camera._useCtrlForPanning || this._isPanClick) ? (this.camera.inertialPanningX += -r / this.panningSensibility,
this.camera.inertialPanningY += n / this.panningSensibility) : (this.camera.inertialAlphaOffset -= r / this.angularSensibilityX,
this.camera.inertialBetaOffset -= n / this.angularSensibilityY)
}
,
e.prototype.onDoubleTap = function(t) {
this.camera.useInputToRestoreState && this.camera.restoreState()
}
,
e.prototype.onMultiTouch = function(t, r, n, o, a, s) {
n === 0 && a === null || o === 0 && s === null || (this.multiTouchPanAndZoom ? (this._computePinchZoom(n, o),
this._computeMultiTouchPanning(a, s)) : this.multiTouchPanning && this.pinchZoom ? (this._twoFingerActivityCount++,
this._isPinching || this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(o) - Math.sqrt(n)) > this.camera.pinchToPanMaxDistance ? (this._computePinchZoom(n, o),
this._isPinching = !0) : this._computeMultiTouchPanning(a, s)) : this.multiTouchPanning ? this._computeMultiTouchPanning(a, s) : this.pinchZoom && this._computePinchZoom(n, o))
}
,
e.prototype.onButtonDown = function(t) {
this._isPanClick = t.button === this.camera._panningMouseButton
}
,
e.prototype.onButtonUp = function(t) {
this._twoFingerActivityCount = 0,
this._isPinching = !1
}
,
e.prototype.onLostFocus = function() {
this._isPanClick = !1,
this._twoFingerActivityCount = 0,
this._isPinching = !1
}
,
e.MinimumRadiusForPinch = .001,
__decorate([serialize()], e.prototype, "buttons", void 0),
__decorate([serialize()], e.prototype, "angularSensibilityX", void 0),
__decorate([serialize()], e.prototype, "angularSensibilityY", void 0),
__decorate([serialize()], e.prototype, "pinchPrecision", void 0),
__decorate([serialize()], e.prototype, "pinchDeltaPercentage", void 0),
__decorate([serialize()], e.prototype, "useNaturalPinchZoom", void 0),
__decorate([serialize()], e.prototype, "pinchZoom", void 0),
__decorate([serialize()], e.prototype, "panningSensibility", void 0),
__decorate([serialize()], e.prototype, "multiTouchPanning", void 0),
__decorate([serialize()], e.prototype, "multiTouchPanAndZoom", void 0),
e
}(BaseCameraPointersInput);
CameraInputTypes.ArcRotateCameraPointersInput = ArcRotateCameraPointersInput;
var ArcRotateCameraKeyboardMoveInput = function() {
function i() {
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 i.prototype.attachControl = function(e) {
var t = this;
e = Tools.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(r) {
var n = r.event;
if (!n.metaKey) {
if (r.type === KeyboardEventTypes.KEYDOWN) {
if (t._ctrlPressed = n.ctrlKey,
t._altPressed = n.altKey,
t.keysUp.indexOf(n.keyCode) !== -1 || t.keysDown.indexOf(n.keyCode) !== -1 || t.keysLeft.indexOf(n.keyCode) !== -1 || t.keysRight.indexOf(n.keyCode) !== -1 || t.keysReset.indexOf(n.keyCode) !== -1) {
var o = t._keys.indexOf(n.keyCode);
o === -1 && t._keys.push(n.keyCode),
n.preventDefault && (e || n.preventDefault())
}
} else if (t.keysUp.indexOf(n.keyCode) !== -1 || t.keysDown.indexOf(n.keyCode) !== -1 || t.keysLeft.indexOf(n.keyCode) !== -1 || t.keysRight.indexOf(n.keyCode) !== -1 || t.keysReset.indexOf(n.keyCode) !== -1) {
var o = t._keys.indexOf(n.keyCode);
o >= 0 && t._keys.splice(o, 1),
n.preventDefault && (e || n.preventDefault())
}
}
}))
}
,
i.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 = []
}
,
i.prototype.checkInputs = function() {
if (this._onKeyboardObserver)
for (var e = this.camera, t = 0; t < this._keys.length; t++) {
var r = this._keys[t];
this.keysLeft.indexOf(r) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX -= 1 / this.panningSensibility : e.inertialAlphaOffset -= this.angularSpeed : this.keysUp.indexOf(r) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY += 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset += 1 / this.zoomingSensibility : e.inertialBetaOffset -= this.angularSpeed : this.keysRight.indexOf(r) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX += 1 / this.panningSensibility : e.inertialAlphaOffset += this.angularSpeed : this.keysDown.indexOf(r) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY -= 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset -= 1 / this.zoomingSensibility : e.inertialBetaOffset += this.angularSpeed : this.keysReset.indexOf(r) !== -1 && e.useInputToRestoreState && e.restoreState()
}
}
,
i.prototype.getClassName = function() {
return "ArcRotateCameraKeyboardMoveInput"
}
,
i.prototype.getSimpleName = function() {
return "keyboard"
}
,
__decorate([serialize()], i.prototype, "keysUp", void 0),
__decorate([serialize()], i.prototype, "keysDown", void 0),
__decorate([serialize()], i.prototype, "keysLeft", void 0),
__decorate([serialize()], i.prototype, "keysRight", void 0),
__decorate([serialize()], i.prototype, "keysReset", void 0),
__decorate([serialize()], i.prototype, "panningSensibility", void 0),
__decorate([serialize()], i.prototype, "zoomingSensibility", void 0),
__decorate([serialize()], i.prototype, "useAltToZoom", void 0),
__decorate([serialize()], i.prototype, "angularSpeed", void 0),
i
}();
CameraInputTypes.ArcRotateCameraKeyboardMoveInput = ArcRotateCameraKeyboardMoveInput;
var ffMultiplier = 40
, ArcRotateCameraMouseWheelInput = function() {
function i() {
this.wheelPrecision = 3,
this.zoomToMouseLocation = !1,
this.wheelDeltaPercentage = 0,
this.customComputeDeltaFromMouseWheel = null,
this._inertialPanning = Vector3.Zero()
}
return i.prototype.computeDeltaFromMouseWheelLegacyEvent = function(e, t) {
var r = 0
, n = e * .01 * this.wheelDeltaPercentage * t;
return e > 0 ? r = n / (1 + this.wheelDeltaPercentage) : r = n * (1 + this.wheelDeltaPercentage),
r
}
,
i.prototype.attachControl = function(e) {
var t = this;
e = Tools.BackCompatCameraNoPreventDefault(arguments),
this._wheel = function(r, n) {
if (r.type === PointerEventTypes.POINTERWHEEL) {
var o = r.event
, a = 0
, s = o
, l = 0
, u = o.deltaMode === EventConstants.DOM_DELTA_LINE ? ffMultiplier : 1;
if (o.deltaY !== void 0 ? l = -(o.deltaY * u) : o.wheelDeltaY !== void 0 ? l = -(o.wheelDeltaY * u) : l = s.wheelDelta,
t.customComputeDeltaFromMouseWheel)
a = t.customComputeDeltaFromMouseWheel(l, t, o);
else if (t.wheelDeltaPercentage) {
if (a = t.computeDeltaFromMouseWheelLegacyEvent(l, t.camera.radius),
a > 0) {
for (var c = t.camera.radius, h = t.camera.inertialRadiusOffset + a, f = 0; f < 20 && Math.abs(h) > .001; f++)
c -= h,
h *= t.camera.inertia;
c = Scalar.Clamp(c, 0, Number.MAX_VALUE),
a = t.computeDeltaFromMouseWheelLegacyEvent(l, c)
}
} else
a = l / (t.wheelPrecision * 40);
a && (t.zoomToMouseLocation && t._hitPlane ? t._zoomToMouse(a) : t.camera.inertialRadiusOffset += a),
o.preventDefault && (e || o.preventDefault())
}
}
,
this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, PointerEventTypes.POINTERWHEEL),
this.zoomToMouseLocation && this._inertialPanning.setAll(0)
}
,
i.prototype.detachControl = function(e) {
this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
this._observer = null,
this._wheel = null)
}
,
i.prototype.checkInputs = function() {
if (!!this.zoomToMouseLocation) {
var e = this.camera
, t = 0 + e.inertialAlphaOffset + e.inertialBetaOffset + e.inertialRadiusOffset;
t && (this._updateHitPlane(),
e.target.addInPlace(this._inertialPanning),
this._inertialPanning.scaleInPlace(e.inertia),
this._zeroIfClose(this._inertialPanning))
}
}
,
i.prototype.getClassName = function() {
return "ArcRotateCameraMouseWheelInput"
}
,
i.prototype.getSimpleName = function() {
return "mousewheel"
}
,
i.prototype._updateHitPlane = function() {
var e = this.camera
, t = e.target.subtract(e.position);
this._hitPlane = Plane.FromPositionAndNormal(Vector3.Zero(), t)
}
,
i.prototype._getPosition = function() {
var e, t = this.camera, r = t.getScene(), n = r.createPickingRay(r.pointerX, r.pointerY, Matrix.Identity(), t, !1), o = 0;
return this._hitPlane && (o = (e = n.intersectsPlane(this._hitPlane)) !== null && e !== void 0 ? e : 0),
n.origin.addInPlace(n.direction.scaleInPlace(o))
}
,
i.prototype._zoomToMouse = function(e) {
var t, r, n = this.camera, o = 1 - n.inertia;
if (n.lowerRadiusLimit) {
var a = (t = n.lowerRadiusLimit) !== null && t !== void 0 ? t : 0;
n.radius - (n.inertialRadiusOffset + e) / o < a && (e = (n.radius - a) * o - n.inertialRadiusOffset)
}
if (n.upperRadiusLimit) {
var s = (r = n.upperRadiusLimit) !== null && r !== void 0 ? r : 0;
n.radius - (n.inertialRadiusOffset + e) / o > s && (e = (n.radius - s) * o - n.inertialRadiusOffset)
}
var l = e / o
, u = l / n.radius
, c = this._getPosition()
, h = c.subtract(n.target)
, f = h.scale(u);
f.scaleInPlace(o),
this._inertialPanning.addInPlace(f),
n.inertialRadiusOffset += e
}
,
i.prototype._zeroIfClose = function(e) {
Math.abs(e.x) < Epsilon && (e.x = 0),
Math.abs(e.y) < Epsilon && (e.y = 0),
Math.abs(e.z) < Epsilon && (e.z = 0)
}
,
__decorate([serialize()], i.prototype, "wheelPrecision", void 0),
__decorate([serialize()], i.prototype, "zoomToMouseLocation", void 0),
__decorate([serialize()], i.prototype, "wheelDeltaPercentage", void 0),
i
}();
CameraInputTypes.ArcRotateCameraMouseWheelInput = ArcRotateCameraMouseWheelInput;
var ArcRotateCameraInputsManager = function(i) {
__extends(e, i);
function e(t) {
return i.call(this, t) || this
}
return e.prototype.addMouseWheel = function() {
return this.add(new ArcRotateCameraMouseWheelInput),
this
}
,
e.prototype.addPointers = function() {
return this.add(new ArcRotateCameraPointersInput),
this
}
,
e.prototype.addKeyboard = function() {
return this.add(new ArcRotateCameraKeyboardMoveInput),
this
}
,
e
}(CameraInputsManager);
Node$2.AddNodeConstructor("ArcRotateCamera", function(i, e) {
return function() {
return new ArcRotateCamera(i,0,0,1,Vector3.Zero(),e)
}
});
var ArcRotateCamera = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l) {
l === void 0 && (l = !0);
var u = i.call(this, t, Vector3.Zero(), s, 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 = Vector3.Zero(),
u.panningInertia = .9,
u.zoomOnFactor = 1,
u.targetScreenOffset = Vector2.Zero(),
u.allowUpsideDown = !0,
u.useInputToRestoreState = !0,
u._viewMatrix = new Matrix,
u.panningAxis = new Vector3(1,1,0),
u._transformedDirection = new Vector3,
u.mapPanning = !1,
u.onMeshTargetChangedObservable = new Observable,
u.checkCollisions = !1,
u.collisionRadius = new Vector3(.5,.5,.5),
u._previousPosition = Vector3.Zero(),
u._collisionVelocity = Vector3.Zero(),
u._newPosition = Vector3.Zero(),
u._computationVector = Vector3.Zero(),
u._onCollisionPositionChange = function(c, h, f) {
f === void 0 && (f = null),
f ? (u.setPosition(h),
u.onCollide && u.onCollide(f)) : u._previousPosition.copyFrom(u._position);
var d = Math.cos(u.alpha)
, _ = Math.sin(u.alpha)
, g = Math.cos(u.beta)
, m = Math.sin(u.beta);
m === 0 && (m = 1e-4);
var v = u._getTargetPosition();
u._computationVector.copyFromFloats(u.radius * d * m, u.radius * g, u.radius * _ * m),
v.addToRef(u._computationVector, u._newPosition),
u._position.copyFrom(u._newPosition);
var y = u.upVector;
u.allowUpsideDown && u.beta < 0 && (y = y.clone(),
y = y.negate()),
u._computeViewMatrix(u._position, v, y),
u._viewMatrix.addAtIndex(12, u.targetScreenOffset.x),
u._viewMatrix.addAtIndex(13, u.targetScreenOffset.y),
u._collisionTriggered = !1
}
,
u._target = Vector3.Zero(),
a && u.setTarget(a),
u.alpha = r,
u.beta = n,
u.radius = o,
u.getViewMatrix(),
u.inputs = new ArcRotateCameraInputsManager(u),
u.inputs.addKeyboard().addMouseWheel().addPointers(),
u
}
return Object.defineProperty(e.prototype, "target", {
get: function() {
return this._target
},
set: function(t) {
this.setTarget(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "targetHost", {
get: function() {
return this._targetHost
},
set: function(t) {
t && this.setTarget(t)
},
enumerable: !1,
configurable: !0
}),
e.prototype.getTarget = function() {
return this.target
}
,
Object.defineProperty(e.prototype, "position", {
get: function() {
return this._position
},
set: function(t) {
this.setPosition(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "upVector", {
get: function() {
return this._upVector
},
set: function(t) {
this._upToYMatrix || (this._YToUpMatrix = new Matrix,
this._upToYMatrix = new Matrix,
this._upVector = Vector3.Zero()),
t.normalize(),
this._upVector.copyFrom(t),
this.setMatUp()
},
enumerable: !1,
configurable: !0
}),
e.prototype.setMatUp = function() {
Matrix.RotationAlignToRef(Vector3.UpReadOnly, this._upVector, this._YToUpMatrix),
Matrix.RotationAlignToRef(this._upVector, Vector3.UpReadOnly, this._upToYMatrix)
}
,
Object.defineProperty(e.prototype, "angularSensibilityX", {
get: function() {
var t = this.inputs.attached.pointers;
return t ? t.angularSensibilityX : 0
},
set: function(t) {
var r = this.inputs.attached.pointers;
r && (r.angularSensibilityX = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "angularSensibilityY", {
get: function() {
var t = this.inputs.attached.pointers;
return t ? t.angularSensibilityY : 0
},
set: function(t) {
var r = this.inputs.attached.pointers;
r && (r.angularSensibilityY = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "pinchPrecision", {
get: function() {
var t = this.inputs.attached.pointers;
return t ? t.pinchPrecision : 0
},
set: function(t) {
var r = this.inputs.attached.pointers;
r && (r.pinchPrecision = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "pinchDeltaPercentage", {
get: function() {
var t = this.inputs.attached.pointers;
return t ? t.pinchDeltaPercentage : 0
},
set: function(t) {
var r = this.inputs.attached.pointers;
r && (r.pinchDeltaPercentage = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "useNaturalPinchZoom", {
get: function() {
var t = this.inputs.attached.pointers;
return t ? t.useNaturalPinchZoom : !1
},
set: function(t) {
var r = this.inputs.attached.pointers;
r && (r.useNaturalPinchZoom = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "panningSensibility", {
get: function() {
var t = this.inputs.attached.pointers;
return t ? t.panningSensibility : 0
},
set: function(t) {
var r = this.inputs.attached.pointers;
r && (r.panningSensibility = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysUp", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysUp : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysUp = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysDown", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysDown : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysDown = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysLeft", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysLeft : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysLeft = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysRight", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysRight : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysRight = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelPrecision", {
get: function() {
var t = this.inputs.attached.mousewheel;
return t ? t.wheelPrecision : 0
},
set: function(t) {
var r = this.inputs.attached.mousewheel;
r && (r.wheelPrecision = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "zoomToMouseLocation", {
get: function() {
var t = this.inputs.attached.mousewheel;
return t ? t.zoomToMouseLocation : !1
},
set: function(t) {
var r = this.inputs.attached.mousewheel;
r && (r.zoomToMouseLocation = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelDeltaPercentage", {
get: function() {
var t = this.inputs.attached.mousewheel;
return t ? t.wheelDeltaPercentage : 0
},
set: function(t) {
var r = this.inputs.attached.mousewheel;
r && (r.wheelDeltaPercentage = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "bouncingBehavior", {
get: function() {
return this._bouncingBehavior
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "useBouncingBehavior", {
get: function() {
return this._bouncingBehavior != null
},
set: function(t) {
t !== this.useBouncingBehavior && (t ? (this._bouncingBehavior = new BouncingBehavior,
this.addBehavior(this._bouncingBehavior)) : this._bouncingBehavior && (this.removeBehavior(this._bouncingBehavior),
this._bouncingBehavior = null))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "framingBehavior", {
get: function() {
return this._framingBehavior
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "useFramingBehavior", {
get: function() {
return this._framingBehavior != null
},
set: function(t) {
t !== this.useFramingBehavior && (t ? (this._framingBehavior = new FramingBehavior,
this.addBehavior(this._framingBehavior)) : this._framingBehavior && (this.removeBehavior(this._framingBehavior),
this._framingBehavior = null))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "autoRotationBehavior", {
get: function() {
return this._autoRotationBehavior
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "useAutoRotationBehavior", {
get: function() {
return this._autoRotationBehavior != null
},
set: function(t) {
t !== this.useAutoRotationBehavior && (t ? (this._autoRotationBehavior = new AutoRotationBehavior,
this.addBehavior(this._autoRotationBehavior)) : this._autoRotationBehavior && (this.removeBehavior(this._autoRotationBehavior),
this._autoRotationBehavior = null))
},
enumerable: !1,
configurable: !0
}),
e.prototype._initCache = function() {
i.prototype._initCache.call(this),
this._cache._target = new Vector3(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 = Vector2.Zero()
}
,
e.prototype._updateCache = function(t) {
t || i.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)
}
,
e.prototype._getTargetPosition = function() {
if (this._targetHost && this._targetHost.getAbsolutePosition) {
var t = this._targetHost.getAbsolutePosition();
this._targetBoundingCenter ? t.addToRef(this._targetBoundingCenter, this._target) : this._target.copyFrom(t)
}
var r = this._getLockedTargetPosition();
return r || this._target
}
,
e.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(),
i.prototype.storeState.call(this)
}
,
e.prototype._restoreStateValues = function() {
return i.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) : !1
}
,
e.prototype._isSynchronizedViewMatrix = function() {
return i.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) : !1
}
,
e.prototype.attachControl = function(t, r, n, o) {
var a = this;
n === void 0 && (n = !0),
o === void 0 && (o = 2),
r = Tools.BackCompatCameraNoPreventDefault(arguments),
this._useCtrlForPanning = n,
this._panningMouseButton = o,
typeof arguments[0] == "boolean" && (arguments.length > 1 && (this._useCtrlForPanning = arguments[1]),
arguments.length > 2 && (this._panningMouseButton = arguments[2])),
this.inputs.attachElement(r),
this._reset = function() {
a.inertialAlphaOffset = 0,
a.inertialBetaOffset = 0,
a.inertialRadiusOffset = 0,
a.inertialPanningX = 0,
a.inertialPanningY = 0
}
}
,
e.prototype.detachControl = function(t) {
this.inputs.detachElement(),
this._reset && this._reset()
}
,
e.prototype._checkInputs = function() {
if (!this._collisionTriggered) {
if (this.inputs.checkInputs(),
this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
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) < Epsilon && (this.inertialAlphaOffset = 0),
Math.abs(this.inertialBetaOffset) < Epsilon && (this.inertialBetaOffset = 0),
Math.abs(this.inertialRadiusOffset) < this.speed * Epsilon && (this.inertialRadiusOffset = 0)
}
if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
var r = new Vector3(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);
if (this._viewMatrix.invertToRef(this._cameraTransformMatrix),
r.multiplyInPlace(this.panningAxis),
Vector3.TransformNormalToRef(r, this._cameraTransformMatrix, this._transformedDirection),
this.mapPanning && (this._transformedDirection.y = 0),
!this._targetHost)
if (this.panningDistanceLimit) {
this._transformedDirection.addInPlace(this._target);
var n = Vector3.DistanceSquared(this._transformedDirection, this.panningOriginTarget);
n <= this.panningDistanceLimit * this.panningDistanceLimit && this._target.copyFrom(this._transformedDirection)
} else
this._target.addInPlace(this._transformedDirection);
this.inertialPanningX *= this.panningInertia,
this.inertialPanningY *= this.panningInertia,
Math.abs(this.inertialPanningX) < this.speed * Epsilon && (this.inertialPanningX = 0),
Math.abs(this.inertialPanningY) < this.speed * Epsilon && (this.inertialPanningY = 0)
}
this._checkLimits(),
i.prototype._checkInputs.call(this)
}
}
,
e.prototype._checkLimits = function() {
this.lowerBetaLimit === null || this.lowerBetaLimit === void 0 ? this.allowUpsideDown && this.beta > Math.PI && (this.beta = this.beta - 2 * Math.PI) : this.beta < this.lowerBetaLimit && (this.beta = this.lowerBetaLimit),
this.upperBetaLimit === null || this.upperBetaLimit === void 0 ? this.allowUpsideDown && this.beta < -Math.PI && (this.beta = this.beta + 2 * Math.PI) : this.beta > this.upperBetaLimit && (this.beta = this.upperBetaLimit),
this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit && (this.alpha = this.lowerAlphaLimit),
this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit && (this.alpha = this.upperAlphaLimit),
this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit,
this.inertialRadiusOffset = 0),
this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit,
this.inertialRadiusOffset = 0)
}
,
e.prototype.rebuildAnglesAndRadius = function() {
this._position.subtractToRef(this._getTargetPosition(), this._computationVector),
(this._upVector.x !== 0 || this._upVector.y !== 1 || this._upVector.z !== 0) && Vector3.TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector),
this.radius = this._computationVector.length(),
this.radius === 0 && (this.radius = 1e-4);
var t = this.alpha;
this._computationVector.x === 0 && this._computationVector.z === 0 ? this.alpha = Math.PI / 2 : this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2))),
this._computationVector.z < 0 && (this.alpha = 2 * Math.PI - this.alpha);
var r = Math.round((t - this.alpha) / (2 * Math.PI));
this.alpha += r * 2 * Math.PI,
this.beta = Math.acos(this._computationVector.y / this.radius),
this._checkLimits()
}
,
e.prototype.setPosition = function(t) {
this._position.equals(t) || (this._position.copyFrom(t),
this.rebuildAnglesAndRadius())
}
,
e.prototype.setTarget = function(t, r, n) {
if (r === void 0 && (r = !1),
n === void 0 && (n = !1),
t.getBoundingInfo)
r ? this._targetBoundingCenter = t.getBoundingInfo().boundingBox.centerWorld.clone() : this._targetBoundingCenter = null,
t.computeWorldMatrix(),
this._targetHost = t,
this._target = this._getTargetPosition(),
this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
else {
var o = t
, a = this._getTargetPosition();
if (a && !n && a.equals(o))
return;
this._targetHost = null,
this._target = o,
this._targetBoundingCenter = null,
this.onMeshTargetChangedObservable.notifyObservers(null)
}
this.rebuildAnglesAndRadius()
}
,
e.prototype._getViewMatrix = function() {
var t = Math.cos(this.alpha)
, r = Math.sin(this.alpha)
, n = Math.cos(this.beta)
, o = Math.sin(this.beta);
o === 0 && (o = 1e-4),
this.radius === 0 && (this.radius = 1e-4);
var a = this._getTargetPosition();
if (this._computationVector.copyFromFloats(this.radius * t * o, this.radius * n, this.radius * r * o),
(this._upVector.x !== 0 || this._upVector.y !== 1 || this._upVector.z !== 0) && Vector3.TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector),
a.addToRef(this._computationVector, this._newPosition),
this.getScene().collisionsEnabled && this.checkCollisions) {
var s = this.getScene().collisionCoordinator;
this._collider || (this._collider = s.createCollider()),
this._collider._radius = this.collisionRadius,
this._newPosition.subtractToRef(this._position, this._collisionVelocity),
this._collisionTriggered = !0,
s.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
} else {
this._position.copyFrom(this._newPosition);
var l = this.upVector;
this.allowUpsideDown && o < 0 && (l = l.negate()),
this._computeViewMatrix(this._position, a, l),
this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x),
this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y)
}
return this._currentTarget = a,
this._viewMatrix
}
,
e.prototype.zoomOn = function(t, r) {
r === void 0 && (r = !1),
t = t || this.getScene().meshes;
var n = Mesh.MinMax(t)
, o = Vector3.Distance(n.min, n.max);
this.radius = o * this.zoomOnFactor,
this.focusOn({
min: n.min,
max: n.max,
distance: o
}, r)
}
,
e.prototype.focusOn = function(t, r) {
r === void 0 && (r = !1);
var n, o;
if (t.min === void 0) {
var a = t || this.getScene().meshes;
n = Mesh.MinMax(a),
o = Vector3.Distance(n.min, n.max)
} else {
var s = t;
n = s,
o = s.distance
}
this._target = Mesh.Center(n),
r || (this.maxZ = o * 2)
}
,
e.prototype.createRigCamera = function(t, r) {
var n = 0;
switch (this.cameraRigMode) {
case Camera$1.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
case Camera$1.RIG_MODE_STEREOSCOPIC_OVERUNDER:
case Camera$1.RIG_MODE_STEREOSCOPIC_INTERLACED:
case Camera$1.RIG_MODE_VR:
n = this._cameraRigParams.stereoHalfAngle * (r === 0 ? 1 : -1);
break;
case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
n = this._cameraRigParams.stereoHalfAngle * (r === 0 ? -1 : 1);
break
}
var o = new e(t,this.alpha + n,this.beta,this.radius,this._target,this.getScene());
return o._cameraRigParams = {},
o.isRigCamera = !0,
o.rigParent = this,
o.upVector = this.upVector,
o
}
,
e.prototype._updateRigCameras = function() {
var t = this._rigCameras[0]
, r = this._rigCameras[1];
switch (t.beta = r.beta = this.beta,
this.cameraRigMode) {
case Camera$1.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
case Camera$1.RIG_MODE_STEREOSCOPIC_OVERUNDER:
case Camera$1.RIG_MODE_STEREOSCOPIC_INTERLACED:
case Camera$1.RIG_MODE_VR:
t.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle,
r.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
break;
case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
t.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle,
r.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
break
}
i.prototype._updateRigCameras.call(this)
}
,
e.prototype.dispose = function() {
this.inputs.clear(),
i.prototype.dispose.call(this)
}
,
e.prototype.getClassName = function() {
return "ArcRotateCamera"
}
,
__decorate([serialize()], e.prototype, "alpha", void 0),
__decorate([serialize()], e.prototype, "beta", void 0),
__decorate([serialize()], e.prototype, "radius", void 0),
__decorate([serializeAsVector3("target")], e.prototype, "_target", void 0),
__decorate([serializeAsMeshReference("targetHost")], e.prototype, "_targetHost", void 0),
__decorate([serialize()], e.prototype, "inertialAlphaOffset", void 0),
__decorate([serialize()], e.prototype, "inertialBetaOffset", void 0),
__decorate([serialize()], e.prototype, "inertialRadiusOffset", void 0),
__decorate([serialize()], e.prototype, "lowerAlphaLimit", void 0),
__decorate([serialize()], e.prototype, "upperAlphaLimit", void 0),
__decorate([serialize()], e.prototype, "lowerBetaLimit", void 0),
__decorate([serialize()], e.prototype, "upperBetaLimit", void 0),
__decorate([serialize()], e.prototype, "lowerRadiusLimit", void 0),
__decorate([serialize()], e.prototype, "upperRadiusLimit", void 0),
__decorate([serialize()], e.prototype, "inertialPanningX", void 0),
__decorate([serialize()], e.prototype, "inertialPanningY", void 0),
__decorate([serialize()], e.prototype, "pinchToPanMaxDistance", void 0),
__decorate([serialize()], e.prototype, "panningDistanceLimit", void 0),
__decorate([serializeAsVector3()], e.prototype, "panningOriginTarget", void 0),
__decorate([serialize()], e.prototype, "panningInertia", void 0),
__decorate([serialize()], e.prototype, "zoomToMouseLocation", null),
__decorate([serialize()], e.prototype, "zoomOnFactor", void 0),
__decorate([serialize()], e.prototype, "targetScreenOffset", void 0),
__decorate([serialize()], e.prototype, "allowUpsideDown", void 0),
__decorate([serialize()], e.prototype, "useInputToRestoreState", void 0),
e
}(TargetCamera)
, FreeCameraKeyboardMoveInput = function() {
function i() {
this.keysUp = [38],
this.keysUpward = [33],
this.keysDown = [40],
this.keysDownward = [34],
this.keysLeft = [37],
this.keysRight = [39],
this.rotationSpeed = .5,
this.keysRotateLeft = [],
this.keysRotateRight = [],
this._keys = new Array
}
return i.prototype.attachControl = function(e) {
var t = this;
e = Tools.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(r) {
var n = r.event;
if (!n.metaKey) {
if (r.type === KeyboardEventTypes.KEYDOWN) {
if (t.keysUp.indexOf(n.keyCode) !== -1 || t.keysDown.indexOf(n.keyCode) !== -1 || t.keysLeft.indexOf(n.keyCode) !== -1 || t.keysRight.indexOf(n.keyCode) !== -1 || t.keysUpward.indexOf(n.keyCode) !== -1 || t.keysDownward.indexOf(n.keyCode) !== -1 || t.keysRotateLeft.indexOf(n.keyCode) !== -1 || t.keysRotateRight.indexOf(n.keyCode) !== -1) {
var o = t._keys.indexOf(n.keyCode);
o === -1 && t._keys.push(n.keyCode),
e || n.preventDefault()
}
} else if (t.keysUp.indexOf(n.keyCode) !== -1 || t.keysDown.indexOf(n.keyCode) !== -1 || t.keysLeft.indexOf(n.keyCode) !== -1 || t.keysRight.indexOf(n.keyCode) !== -1 || t.keysUpward.indexOf(n.keyCode) !== -1 || t.keysDownward.indexOf(n.keyCode) !== -1 || t.keysRotateLeft.indexOf(n.keyCode) !== -1 || t.keysRotateRight.indexOf(n.keyCode) !== -1) {
var o = t._keys.indexOf(n.keyCode);
o >= 0 && t._keys.splice(o, 1),
e || n.preventDefault()
}
}
}))
}
,
i.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 = []
}
,
i.prototype.checkInputs = function() {
if (this._onKeyboardObserver)
for (var e = this.camera, t = 0; t < this._keys.length; t++) {
var r = this._keys[t]
, n = e._computeLocalCameraSpeed();
this.keysLeft.indexOf(r) !== -1 ? e._localDirection.copyFromFloats(-n, 0, 0) : this.keysUp.indexOf(r) !== -1 ? e._localDirection.copyFromFloats(0, 0, n) : this.keysRight.indexOf(r) !== -1 ? e._localDirection.copyFromFloats(n, 0, 0) : this.keysDown.indexOf(r) !== -1 ? e._localDirection.copyFromFloats(0, 0, -n) : this.keysUpward.indexOf(r) !== -1 ? e._localDirection.copyFromFloats(0, n, 0) : this.keysDownward.indexOf(r) !== -1 ? e._localDirection.copyFromFloats(0, -n, 0) : this.keysRotateLeft.indexOf(r) !== -1 ? (e._localDirection.copyFromFloats(0, 0, 0),
e.cameraRotation.y -= this._getLocalRotation()) : this.keysRotateRight.indexOf(r) !== -1 && (e._localDirection.copyFromFloats(0, 0, 0),
e.cameraRotation.y += this._getLocalRotation()),
e.getScene().useRightHandedSystem && (e._localDirection.z *= -1),
e.getViewMatrix().invertToRef(e._cameraTransformMatrix),
Vector3.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection),
e.cameraDirection.addInPlace(e._transformedDirection)
}
}
,
i.prototype.getClassName = function() {
return "FreeCameraKeyboardMoveInput"
}
,
i.prototype._onLostFocus = function() {
this._keys = []
}
,
i.prototype.getSimpleName = function() {
return "keyboard"
}
,
i.prototype._getLocalRotation = function() {
var e = this.rotationSpeed * this._engine.getDeltaTime() / 1e3;
return this.camera.getScene().useRightHandedSystem && (e *= -1),
this.camera.parent && this.camera.parent._getWorldMatrixDeterminant() < 0 && (e *= -1),
e
}
,
__decorate([serialize()], i.prototype, "keysUp", void 0),
__decorate([serialize()], i.prototype, "keysUpward", void 0),
__decorate([serialize()], i.prototype, "keysDown", void 0),
__decorate([serialize()], i.prototype, "keysDownward", void 0),
__decorate([serialize()], i.prototype, "keysLeft", void 0),
__decorate([serialize()], i.prototype, "keysRight", void 0),
__decorate([serialize()], i.prototype, "rotationSpeed", void 0),
__decorate([serialize()], i.prototype, "keysRotateLeft", void 0),
__decorate([serialize()], i.prototype, "keysRotateRight", void 0),
i
}();
CameraInputTypes.FreeCameraKeyboardMoveInput = FreeCameraKeyboardMoveInput;
var FreeCameraMouseInput = function() {
function i(e) {
e === void 0 && (e = !0),
this.touchEnabled = e,
this.buttons = [0, 1, 2],
this.angularSensibility = 2e3,
this.previousPosition = null,
this.onPointerMovedObservable = new Observable,
this._allowCameraRotation = !0,
this._currentActiveButton = -1
}
return i.prototype.attachControl = function(e) {
var t = this;
e = Tools.BackCompatCameraNoPreventDefault(arguments);
var r = this.camera.getEngine()
, n = r.getInputElement();
this._pointerInput || (this._pointerInput = function(o) {
var a = o.event
, s = a.pointerType === "touch";
if (!r.isInVRExclusivePointerMode && !(!t.touchEnabled && s) && !(o.type !== PointerEventTypes.POINTERMOVE && t.buttons.indexOf(a.button) === -1)) {
var l = a.srcElement || a.target;
if (o.type === PointerEventTypes.POINTERDOWN && (t._currentActiveButton === -1 || s)) {
try {
l == null || l.setPointerCapture(a.pointerId)
} catch {}
t._currentActiveButton === -1 && (t._currentActiveButton = a.button),
t.previousPosition = {
x: a.clientX,
y: a.clientY
},
e || (a.preventDefault(),
n && n.focus()),
r.isPointerLock && t._onMouseMove && t._onMouseMove(o.event)
} else if (o.type === PointerEventTypes.POINTERUP && (t._currentActiveButton === a.button || s)) {
try {
l == null || l.releasePointerCapture(a.pointerId)
} catch {}
t._currentActiveButton = -1,
t.previousPosition = null,
e || a.preventDefault()
} else if (o.type === PointerEventTypes.POINTERMOVE) {
if (r.isPointerLock && t._onMouseMove)
t._onMouseMove(o.event);
else if (t.previousPosition) {
var u = a.clientX - t.previousPosition.x
, c = a.clientY - t.previousPosition.y;
t.camera.getScene().useRightHandedSystem && (u *= -1),
t.camera.parent && t.camera.parent._getWorldMatrixDeterminant() < 0 && (u *= -1),
t._allowCameraRotation && (t.camera.cameraRotation.y += u / t.angularSensibility,
t.camera.cameraRotation.x += c / t.angularSensibility),
t.onPointerMovedObservable.notifyObservers({
offsetX: u,
offsetY: c
}),
t.previousPosition = {
x: a.clientX,
y: a.clientY
},
e || a.preventDefault()
}
}
}
}
),
this._onMouseMove = function(o) {
if (!!r.isPointerLock && !r.isInVRExclusivePointerMode) {
var a = o.movementX || o.mozMovementX || o.webkitMovementX || o.msMovementX || 0;
t.camera.getScene().useRightHandedSystem && (a *= -1),
t.camera.parent && t.camera.parent._getWorldMatrixDeterminant() < 0 && (a *= -1),
t.camera.cameraRotation.y += a / t.angularSensibility;
var s = o.movementY || o.mozMovementY || o.webkitMovementY || o.msMovementY || 0;
t.camera.cameraRotation.x += s / t.angularSensibility,
t.previousPosition = null,
e || o.preventDefault()
}
}
,
this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE),
n && n.addEventListener("contextmenu", this.onContextMenu.bind(this), !1)
}
,
i.prototype.onContextMenu = function(e) {
e.preventDefault()
}
,
i.prototype.detachControl = function(e) {
if (this._observer) {
if (this.camera.getScene().onPointerObservable.remove(this._observer),
this.onContextMenu) {
var t = this.camera.getEngine()
, r = t.getInputElement();
r && r.removeEventListener("contextmenu", this.onContextMenu)
}
this.onPointerMovedObservable && this.onPointerMovedObservable.clear(),
this._observer = null,
this._onMouseMove = null,
this.previousPosition = null
}
}
,
i.prototype.getClassName = function() {
return "FreeCameraMouseInput"
}
,
i.prototype.getSimpleName = function() {
return "mouse"
}
,
__decorate([serialize()], i.prototype, "buttons", void 0),
__decorate([serialize()], i.prototype, "angularSensibility", void 0),
i
}();
CameraInputTypes.FreeCameraMouseInput = FreeCameraMouseInput;
var BaseCameraMouseWheelInput = function() {
function i() {
this.wheelPrecisionX = 3,
this.wheelPrecisionY = 3,
this.wheelPrecisionZ = 3,
this.onChangedObservable = new Observable,
this._wheelDeltaX = 0,
this._wheelDeltaY = 0,
this._wheelDeltaZ = 0,
this._ffMultiplier = 12,
this._normalize = 120
}
return i.prototype.attachControl = function(e) {
var t = this;
e = Tools.BackCompatCameraNoPreventDefault(arguments),
this._wheel = function(r) {
if (r.type === PointerEventTypes.POINTERWHEEL) {
var n = r.event
, o = n.deltaMode === EventConstants.DOM_DELTA_LINE ? t._ffMultiplier : 1;
n.deltaY !== void 0 ? (t._wheelDeltaX += t.wheelPrecisionX * o * n.deltaX / t._normalize,
t._wheelDeltaY -= t.wheelPrecisionY * o * n.deltaY / t._normalize,
t._wheelDeltaZ += t.wheelPrecisionZ * o * n.deltaZ / t._normalize) : n.wheelDeltaY !== void 0 ? (t._wheelDeltaX += t.wheelPrecisionX * o * n.wheelDeltaX / t._normalize,
t._wheelDeltaY -= t.wheelPrecisionY * o * n.wheelDeltaY / t._normalize,
t._wheelDeltaZ += t.wheelPrecisionZ * o * n.wheelDeltaZ / t._normalize) : n.wheelDelta && (t._wheelDeltaY -= t.wheelPrecisionY * n.wheelDelta / t._normalize),
n.preventDefault && (e || n.preventDefault())
}
}
,
this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, PointerEventTypes.POINTERWHEEL)
}
,
i.prototype.detachControl = function(e) {
this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
this._observer = null,
this._wheel = null),
this.onChangedObservable && this.onChangedObservable.clear()
}
,
i.prototype.checkInputs = function() {
this.onChangedObservable.notifyObservers({
wheelDeltaX: this._wheelDeltaX,
wheelDeltaY: this._wheelDeltaY,
wheelDeltaZ: this._wheelDeltaZ
}),
this._wheelDeltaX = 0,
this._wheelDeltaY = 0,
this._wheelDeltaZ = 0
}
,
i.prototype.getClassName = function() {
return "BaseCameraMouseWheelInput"
}
,
i.prototype.getSimpleName = function() {
return "mousewheel"
}
,
__decorate([serialize()], i.prototype, "wheelPrecisionX", void 0),
__decorate([serialize()], i.prototype, "wheelPrecisionY", void 0),
__decorate([serialize()], i.prototype, "wheelPrecisionZ", void 0),
i
}(), _CameraProperty;
(function(i) {
i[i.MoveRelative = 0] = "MoveRelative",
i[i.RotateRelative = 1] = "RotateRelative",
i[i.MoveScene = 2] = "MoveScene"
}
)(_CameraProperty || (_CameraProperty = {}));
var FreeCameraMouseWheelInput = function(i) {
__extends(e, i);
function e() {
var t = i !== null && i.apply(this, arguments) || this;
return t._moveRelative = Vector3.Zero(),
t._rotateRelative = Vector3.Zero(),
t._moveScene = Vector3.Zero(),
t._wheelXAction = _CameraProperty.MoveRelative,
t._wheelXActionCoordinate = Coordinate.X,
t._wheelYAction = _CameraProperty.MoveRelative,
t._wheelYActionCoordinate = Coordinate.Z,
t._wheelZAction = null,
t._wheelZActionCoordinate = null,
t
}
return e.prototype.getClassName = function() {
return "FreeCameraMouseWheelInput"
}
,
Object.defineProperty(e.prototype, "wheelXMoveRelative", {
get: function() {
return this._wheelXAction !== _CameraProperty.MoveRelative ? null : this._wheelXActionCoordinate
},
set: function(t) {
t === null && this._wheelXAction !== _CameraProperty.MoveRelative || (this._wheelXAction = _CameraProperty.MoveRelative,
this._wheelXActionCoordinate = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelYMoveRelative", {
get: function() {
return this._wheelYAction !== _CameraProperty.MoveRelative ? null : this._wheelYActionCoordinate
},
set: function(t) {
t === null && this._wheelYAction !== _CameraProperty.MoveRelative || (this._wheelYAction = _CameraProperty.MoveRelative,
this._wheelYActionCoordinate = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelZMoveRelative", {
get: function() {
return this._wheelZAction !== _CameraProperty.MoveRelative ? null : this._wheelZActionCoordinate
},
set: function(t) {
t === null && this._wheelZAction !== _CameraProperty.MoveRelative || (this._wheelZAction = _CameraProperty.MoveRelative,
this._wheelZActionCoordinate = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelXRotateRelative", {
get: function() {
return this._wheelXAction !== _CameraProperty.RotateRelative ? null : this._wheelXActionCoordinate
},
set: function(t) {
t === null && this._wheelXAction !== _CameraProperty.RotateRelative || (this._wheelXAction = _CameraProperty.RotateRelative,
this._wheelXActionCoordinate = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelYRotateRelative", {
get: function() {
return this._wheelYAction !== _CameraProperty.RotateRelative ? null : this._wheelYActionCoordinate
},
set: function(t) {
t === null && this._wheelYAction !== _CameraProperty.RotateRelative || (this._wheelYAction = _CameraProperty.RotateRelative,
this._wheelYActionCoordinate = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelZRotateRelative", {
get: function() {
return this._wheelZAction !== _CameraProperty.RotateRelative ? null : this._wheelZActionCoordinate
},
set: function(t) {
t === null && this._wheelZAction !== _CameraProperty.RotateRelative || (this._wheelZAction = _CameraProperty.RotateRelative,
this._wheelZActionCoordinate = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelXMoveScene", {
get: function() {
return this._wheelXAction !== _CameraProperty.MoveScene ? null : this._wheelXActionCoordinate
},
set: function(t) {
t === null && this._wheelXAction !== _CameraProperty.MoveScene || (this._wheelXAction = _CameraProperty.MoveScene,
this._wheelXActionCoordinate = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelYMoveScene", {
get: function() {
return this._wheelYAction !== _CameraProperty.MoveScene ? null : this._wheelYActionCoordinate
},
set: function(t) {
t === null && this._wheelYAction !== _CameraProperty.MoveScene || (this._wheelYAction = _CameraProperty.MoveScene,
this._wheelYActionCoordinate = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "wheelZMoveScene", {
get: function() {
return this._wheelZAction !== _CameraProperty.MoveScene ? null : this._wheelZActionCoordinate
},
set: function(t) {
t === null && this._wheelZAction !== _CameraProperty.MoveScene || (this._wheelZAction = _CameraProperty.MoveScene,
this._wheelZActionCoordinate = t)
},
enumerable: !1,
configurable: !0
}),
e.prototype.checkInputs = function() {
if (!(this._wheelDeltaX === 0 && this._wheelDeltaY === 0 && this._wheelDeltaZ == 0)) {
this._moveRelative.setAll(0),
this._rotateRelative.setAll(0),
this._moveScene.setAll(0),
this._updateCamera(),
this.camera.getScene().useRightHandedSystem && (this._moveRelative.z *= -1);
var t = Matrix.Zero();
this.camera.getViewMatrix().invertToRef(t);
var r = Vector3.Zero();
Vector3.TransformNormalToRef(this._moveRelative, t, r),
this.camera.cameraRotation.x += this._rotateRelative.x / 200,
this.camera.cameraRotation.y += this._rotateRelative.y / 200,
this.camera.cameraDirection.addInPlace(r),
this.camera.cameraDirection.addInPlace(this._moveScene),
i.prototype.checkInputs.call(this)
}
}
,
e.prototype._updateCamera = function() {
this._updateCameraProperty(this._wheelDeltaX, this._wheelXAction, this._wheelXActionCoordinate),
this._updateCameraProperty(this._wheelDeltaY, this._wheelYAction, this._wheelYActionCoordinate),
this._updateCameraProperty(this._wheelDeltaZ, this._wheelZAction, this._wheelZActionCoordinate)
}
,
e.prototype._updateCameraProperty = function(t, r, n) {
if (t !== 0 && !(r === null || n === null)) {
var o = null;
switch (r) {
case _CameraProperty.MoveRelative:
o = this._moveRelative;
break;
case _CameraProperty.RotateRelative:
o = this._rotateRelative;
break;
case _CameraProperty.MoveScene:
o = this._moveScene;
break
}
switch (n) {
case Coordinate.X:
o.set(t, 0, 0);
break;
case Coordinate.Y:
o.set(0, t, 0);
break;
case Coordinate.Z:
o.set(0, 0, t);
break
}
}
}
,
__decorate([serialize()], e.prototype, "wheelXMoveRelative", null),
__decorate([serialize()], e.prototype, "wheelYMoveRelative", null),
__decorate([serialize()], e.prototype, "wheelZMoveRelative", null),
__decorate([serialize()], e.prototype, "wheelXRotateRelative", null),
__decorate([serialize()], e.prototype, "wheelYRotateRelative", null),
__decorate([serialize()], e.prototype, "wheelZRotateRelative", null),
__decorate([serialize()], e.prototype, "wheelXMoveScene", null),
__decorate([serialize()], e.prototype, "wheelYMoveScene", null),
__decorate([serialize()], e.prototype, "wheelZMoveScene", null),
e
}(BaseCameraMouseWheelInput);
CameraInputTypes.FreeCameraMouseWheelInput = FreeCameraMouseWheelInput;
var FreeCameraTouchInput = function() {
function i(e) {
e === void 0 && (e = !1),
this.allowMouse = e,
this.touchAngularSensibility = 2e5,
this.touchMoveSensibility = 250,
this.singleFingerRotate = !1,
this._offsetX = null,
this._offsetY = null,
this._pointerPressed = new Array
}
return i.prototype.attachControl = function(e) {
var t = this;
e = Tools.BackCompatCameraNoPreventDefault(arguments);
var r = null;
if (this._pointerInput === void 0 && (this._onLostFocus = function() {
t._offsetX = null,
t._offsetY = null
}
,
this._pointerInput = function(a) {
var s = a.event
, l = !t.camera.getEngine().hostInformation.isMobile && s instanceof MouseEvent;
if (!(!t.allowMouse && (s.pointerType === "mouse" || l))) {
if (a.type === PointerEventTypes.POINTERDOWN) {
if (e || s.preventDefault(),
t._pointerPressed.push(s.pointerId),
t._pointerPressed.length !== 1)
return;
r = {
x: s.clientX,
y: s.clientY
}
} else if (a.type === PointerEventTypes.POINTERUP) {
e || s.preventDefault();
var u = t._pointerPressed.indexOf(s.pointerId);
if (u === -1 || (t._pointerPressed.splice(u, 1),
u != 0))
return;
r = null,
t._offsetX = null,
t._offsetY = null
} else if (a.type === PointerEventTypes.POINTERMOVE) {
if (e || s.preventDefault(),
!r)
return;
var u = t._pointerPressed.indexOf(s.pointerId);
if (u != 0)
return;
t._offsetX = s.clientX - r.x,
t._offsetY = -(s.clientY - r.y)
}
}
}
),
this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE),
this._onLostFocus) {
var n = this.camera.getEngine()
, o = n.getInputElement();
o && o.addEventListener("blur", this._onLostFocus)
}
}
,
i.prototype.detachControl = function(e) {
if (this._pointerInput) {
if (this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
this._observer = null),
this._onLostFocus) {
var t = this.camera.getEngine()
, r = t.getInputElement();
r && r.removeEventListener("blur", this._onLostFocus),
this._onLostFocus = null
}
this._pointerPressed = [],
this._offsetX = null,
this._offsetY = null
}
}
,
i.prototype.checkInputs = function() {
if (!(this._offsetX === null || this._offsetY === null) && !(this._offsetX === 0 && this._offsetY === 0)) {
var e = this.camera;
e.cameraRotation.y = this._offsetX / this.touchAngularSensibility;
var t = this.singleFingerRotate && this._pointerPressed.length === 1 || !this.singleFingerRotate && this._pointerPressed.length > 1;
if (t)
e.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;
else {
var r = e._computeLocalCameraSpeed()
, n = new Vector3(0,0,r * this._offsetY / this.touchMoveSensibility);
Matrix.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, e._cameraRotationMatrix),
e.cameraDirection.addInPlace(Vector3.TransformCoordinates(n, e._cameraRotationMatrix))
}
}
}
,
i.prototype.getClassName = function() {
return "FreeCameraTouchInput"
}
,
i.prototype.getSimpleName = function() {
return "touch"
}
,
__decorate([serialize()], i.prototype, "touchAngularSensibility", void 0),
__decorate([serialize()], i.prototype, "touchMoveSensibility", void 0),
i
}();
CameraInputTypes.FreeCameraTouchInput = FreeCameraTouchInput;
var FreeCameraInputsManager = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t) || this;
return r._mouseInput = null,
r._mouseWheelInput = null,
r
}
return e.prototype.addKeyboard = function() {
return this.add(new FreeCameraKeyboardMoveInput),
this
}
,
e.prototype.addMouse = function(t) {
return t === void 0 && (t = !0),
this._mouseInput || (this._mouseInput = new FreeCameraMouseInput(t),
this.add(this._mouseInput)),
this
}
,
e.prototype.removeMouse = function() {
return this._mouseInput && this.remove(this._mouseInput),
this
}
,
e.prototype.addMouseWheel = function() {
return this._mouseWheelInput || (this._mouseWheelInput = new FreeCameraMouseWheelInput,
this.add(this._mouseWheelInput)),
this
}
,
e.prototype.removeMouseWheel = function() {
return this._mouseWheelInput && this.remove(this._mouseWheelInput),
this
}
,
e.prototype.addTouch = function() {
return this.add(new FreeCameraTouchInput),
this
}
,
e.prototype.clear = function() {
i.prototype.clear.call(this),
this._mouseInput = null
}
,
e
}(CameraInputsManager)
, FreeCamera = function(i) {
__extends(e, i);
function e(t, r, n, o) {
o === void 0 && (o = !0);
var a = i.call(this, t, r, n, o) || this;
return a.ellipsoid = new Vector3(.5,1,.5),
a.ellipsoidOffset = new Vector3(0,0,0),
a.checkCollisions = !1,
a.applyGravity = !1,
a._needMoveForGravity = !1,
a._oldPosition = Vector3.Zero(),
a._diffPosition = Vector3.Zero(),
a._newPosition = Vector3.Zero(),
a._collisionMask = -1,
a._onCollisionPositionChange = function(s, l, u) {
u === void 0 && (u = null);
var c = function(h) {
a._newPosition.copyFrom(h),
a._newPosition.subtractToRef(a._oldPosition, a._diffPosition),
a._diffPosition.length() > Engine.CollisionsEpsilon && (a.position.addInPlace(a._diffPosition),
a.onCollide && u && a.onCollide(u))
};
c(l)
}
,
a.inputs = new FreeCameraInputsManager(a),
a.inputs.addKeyboard().addMouse(),
a
}
return Object.defineProperty(e.prototype, "angularSensibility", {
get: function() {
var t = this.inputs.attached.mouse;
return t ? t.angularSensibility : 0
},
set: function(t) {
var r = this.inputs.attached.mouse;
r && (r.angularSensibility = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysUp", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysUp : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysUp = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysUpward", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysUpward : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysUpward = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysDown", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysDown : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysDown = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysDownward", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysDownward : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysDownward = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysLeft", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysLeft : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysLeft = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysRight", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysRight : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysRight = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysRotateLeft", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysRotateLeft : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysRotateLeft = t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "keysRotateRight", {
get: function() {
var t = this.inputs.attached.keyboard;
return t ? t.keysRotateRight : []
},
set: function(t) {
var r = this.inputs.attached.keyboard;
r && (r.keysRotateRight = t)
},
enumerable: !1,
configurable: !0
}),
e.prototype.attachControl = function(t, r) {
r = Tools.BackCompatCameraNoPreventDefault(arguments),
this.inputs.attachElement(r)
}
,
e.prototype.detachControl = function(t) {
this.inputs.detachElement(),
this.cameraDirection = new Vector3(0,0,0),
this.cameraRotation = new Vector2(0,0)
}
,
Object.defineProperty(e.prototype, "collisionMask", {
get: function() {
return this._collisionMask
},
set: function(t) {
this._collisionMask = isNaN(t) ? -1 : t
},
enumerable: !1,
configurable: !0
}),
e.prototype._collideWithWorld = function(t) {
var r;
this.parent ? r = Vector3.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : r = this.position,
r.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition),
this._oldPosition.addInPlace(this.ellipsoidOffset);
var n = this.getScene().collisionCoordinator;
this._collider || (this._collider = n.createCollider()),
this._collider._radius = this.ellipsoid,
this._collider.collisionMask = this._collisionMask;
var o = t;
this.applyGravity && (o = t.add(this.getScene().gravity)),
n.getNewPosition(this._oldPosition, o, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
}
,
e.prototype._checkInputs = function() {
this._localDirection || (this._localDirection = Vector3.Zero(),
this._transformedDirection = Vector3.Zero()),
this.inputs.checkInputs(),
i.prototype._checkInputs.call(this)
}
,
e.prototype._decideIfNeedsToMove = function() {
return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
}
,
e.prototype._updatePosition = function() {
this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : i.prototype._updatePosition.call(this)
}
,
e.prototype.dispose = function() {
this.inputs.clear(),
i.prototype.dispose.call(this)
}
,
e.prototype.getClassName = function() {
return "FreeCamera"
}
,
__decorate([serializeAsVector3()], e.prototype, "ellipsoid", void 0),
__decorate([serializeAsVector3()], e.prototype, "ellipsoidOffset", void 0),
__decorate([serialize()], e.prototype, "checkCollisions", void 0),
__decorate([serialize()], e.prototype, "applyGravity", void 0),
e
}(TargetCamera)
, ShadowLight = function(i) {
__extends(e, i);
function e() {
var t = i !== null && i.apply(this, arguments) || this;
return t._needProjectionMatrixCompute = !0,
t
}
return e.prototype._setPosition = function(t) {
this._position = t
}
,
Object.defineProperty(e.prototype, "position", {
get: function() {
return this._position
},
set: function(t) {
this._setPosition(t)
},
enumerable: !1,
configurable: !0
}),
e.prototype._setDirection = function(t) {
this._direction = t
}
,
Object.defineProperty(e.prototype, "direction", {
get: function() {
return this._direction
},
set: function(t) {
this._setDirection(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "shadowMinZ", {
get: function() {
return this._shadowMinZ
},
set: function(t) {
this._shadowMinZ = t,
this.forceProjectionMatrixCompute()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "shadowMaxZ", {
get: function() {
return this._shadowMaxZ
},
set: function(t) {
this._shadowMaxZ = t,
this.forceProjectionMatrixCompute()
},
enumerable: !1,
configurable: !0
}),
e.prototype.computeTransformedInformation = function() {
return this.parent && this.parent.getWorldMatrix ? (this.transformedPosition || (this.transformedPosition = Vector3.Zero()),
Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition),
this.direction && (this.transformedDirection || (this.transformedDirection = Vector3.Zero()),
Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection)),
!0) : !1
}
,
e.prototype.getDepthScale = function() {
return 50
}
,
e.prototype.getShadowDirection = function(t) {
return this.transformedDirection ? this.transformedDirection : this.direction
}
,
e.prototype.getAbsolutePosition = function() {
return this.transformedPosition ? this.transformedPosition : this.position
}
,
e.prototype.setDirectionToTarget = function(t) {
return this.direction = Vector3.Normalize(t.subtract(this.position)),
this.direction
}
,
e.prototype.getRotation = function() {
this.direction.normalize();
var t = Vector3.Cross(this.direction, Axis.Y)
, r = Vector3.Cross(t, this.direction);
return Vector3.RotationFromAxis(t, r, this.direction)
}
,
e.prototype.needCube = function() {
return !1
}
,
e.prototype.needProjectionMatrixCompute = function() {
return this._needProjectionMatrixCompute
}
,
e.prototype.forceProjectionMatrixCompute = function() {
this._needProjectionMatrixCompute = !0
}
,
e.prototype._initCache = function() {
i.prototype._initCache.call(this),
this._cache.position = Vector3.Zero()
}
,
e.prototype._isSynchronized = function() {
return !!this._cache.position.equals(this.position)
}
,
e.prototype.computeWorldMatrix = function(t) {
return !t && this.isSynchronized() ? (this._currentRenderId = this.getScene().getRenderId(),
this._worldMatrix) : (this._updateCache(),
this._cache.position.copyFrom(this.position),
this._worldMatrix || (this._worldMatrix = Matrix.Identity()),
Matrix.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)
}
,
e.prototype.getDepthMinZ = function(t) {
return this.shadowMinZ !== void 0 ? this.shadowMinZ : t.minZ
}
,
e.prototype.getDepthMaxZ = function(t) {
return this.shadowMaxZ !== void 0 ? this.shadowMaxZ : t.maxZ
}
,
e.prototype.setShadowProjectionMatrix = function(t, r, n) {
return this.customProjectionMatrixBuilder ? this.customProjectionMatrixBuilder(r, n, t) : this._setDefaultShadowProjectionMatrix(t, r, n),
this
}
,
__decorate([serializeAsVector3()], e.prototype, "position", null),
__decorate([serializeAsVector3()], e.prototype, "direction", null),
__decorate([serialize()], e.prototype, "shadowMinZ", null),
__decorate([serialize()], e.prototype, "shadowMaxZ", null),
e
}(Light);
Node$2.AddNodeConstructor("Light_Type_1", function(i, e) {
return function() {
return new DirectionalLight(i,Vector3.Zero(),e)
}
});
var DirectionalLight = function(i) {
__extends(e, i);
function e(t, r, n) {
var o = i.call(this, t, n) || this;
return o._shadowFrustumSize = 0,
o._shadowOrthoScale = .1,
o.autoUpdateExtends = !0,
o.autoCalcShadowZBounds = !1,
o._orthoLeft = Number.MAX_VALUE,
o._orthoRight = Number.MIN_VALUE,
o._orthoTop = Number.MIN_VALUE,
o._orthoBottom = Number.MAX_VALUE,
o.position = r.scale(-1),
o.direction = r,
o
}
return Object.defineProperty(e.prototype, "shadowFrustumSize", {
get: function() {
return this._shadowFrustumSize
},
set: function(t) {
this._shadowFrustumSize = t,
this.forceProjectionMatrixCompute()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "shadowOrthoScale", {
get: function() {
return this._shadowOrthoScale
},
set: function(t) {
this._shadowOrthoScale = t,
this.forceProjectionMatrixCompute()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "orthoLeft", {
get: function() {
return this._orthoLeft
},
set: function(t) {
this._orthoLeft = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "orthoRight", {
get: function() {
return this._orthoRight
},
set: function(t) {
this._orthoRight = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "orthoTop", {
get: function() {
return this._orthoTop
},
set: function(t) {
this._orthoTop = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "orthoBottom", {
get: function() {
return this._orthoBottom
},
set: function(t) {
this._orthoBottom = t
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "DirectionalLight"
}
,
e.prototype.getTypeID = function() {
return Light.LIGHTTYPEID_DIRECTIONALLIGHT
}
,
e.prototype._setDefaultShadowProjectionMatrix = function(t, r, n) {
this.shadowFrustumSize > 0 ? this._setDefaultFixedFrustumShadowProjectionMatrix(t) : this._setDefaultAutoExtendShadowProjectionMatrix(t, r, n)
}
,
e.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function(t) {
var r = this.getScene().activeCamera;
!r || Matrix.OrthoLHToRef(this.shadowFrustumSize, this.shadowFrustumSize, this.shadowMinZ !== void 0 ? this.shadowMinZ : r.minZ, this.shadowMaxZ !== void 0 ? this.shadowMaxZ : r.maxZ, t, this.getScene().getEngine().isNDCHalfZRange)
}
,
e.prototype._setDefaultAutoExtendShadowProjectionMatrix = function(t, r, n) {
var o = this.getScene().activeCamera;
if (!!o) {
if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
var a = Vector3.Zero();
this._orthoLeft = Number.MAX_VALUE,
this._orthoRight = Number.MIN_VALUE,
this._orthoTop = Number.MIN_VALUE,
this._orthoBottom = Number.MAX_VALUE;
for (var s = Number.MAX_VALUE, l = Number.MIN_VALUE, u = 0; u < n.length; u++) {
var c = n[u];
if (!!c)
for (var h = c.getBoundingInfo(), f = h.boundingBox, d = 0; d < f.vectorsWorld.length; d++)
Vector3.TransformCoordinatesToRef(f.vectorsWorld[d], r, a),
a.x < this._orthoLeft && (this._orthoLeft = a.x),
a.y < this._orthoBottom && (this._orthoBottom = a.y),
a.x > this._orthoRight && (this._orthoRight = a.x),
a.y > this._orthoTop && (this._orthoTop = a.y),
this.autoCalcShadowZBounds && (a.z < s && (s = a.z),
a.z > l && (l = a.z))
}
this.autoCalcShadowZBounds && (this._shadowMinZ = s,
this._shadowMaxZ = l)
}
var _ = this._orthoRight - this._orthoLeft
, g = this._orthoTop - this._orthoBottom
, m = this.shadowMinZ !== void 0 ? this.shadowMinZ : o.minZ
, v = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : o.maxZ
, y = this.getScene().getEngine().useReverseDepthBuffer;
Matrix.OrthoOffCenterLHToRef(this._orthoLeft - _ * this.shadowOrthoScale, this._orthoRight + _ * this.shadowOrthoScale, this._orthoBottom - g * this.shadowOrthoScale, this._orthoTop + g * this.shadowOrthoScale, y ? v : m, y ? m : v, t, this.getScene().getEngine().isNDCHalfZRange)
}
}
,
e.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()
}
,
e.prototype.transferToEffect = function(t, r) {
return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, r),
this) : (this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, r),
this)
}
,
e.prototype.transferToNodeMaterialEffect = function(t, r) {
return this.computeTransformedInformation() ? (t.setFloat3(r, this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z),
this) : (t.setFloat3(r, this.direction.x, this.direction.y, this.direction.z),
this)
}
,
e.prototype.getDepthMinZ = function(t) {
var r = this._scene.getEngine();
return !r.useReverseDepthBuffer && r.isNDCHalfZRange ? 0 : 1
}
,
e.prototype.getDepthMaxZ = function(t) {
var r = this._scene.getEngine();
return r.useReverseDepthBuffer && r.isNDCHalfZRange ? 0 : 1
}
,
e.prototype.prepareLightSpecificDefines = function(t, r) {
t["DIRLIGHT" + r] = !0
}
,
__decorate([serialize()], e.prototype, "shadowFrustumSize", null),
__decorate([serialize()], e.prototype, "shadowOrthoScale", null),
__decorate([serialize()], e.prototype, "autoUpdateExtends", void 0),
__decorate([serialize()], e.prototype, "autoCalcShadowZBounds", void 0),
__decorate([serialize("orthoLeft")], e.prototype, "_orthoLeft", void 0),
__decorate([serialize("orthoRight")], e.prototype, "_orthoRight", void 0),
__decorate([serialize("orthoTop")], e.prototype, "_orthoTop", void 0),
__decorate([serialize("orthoBottom")], e.prototype, "_orthoBottom", void 0),
e
}(ShadowLight);
Node$2.AddNodeConstructor("Light_Type_3", function(i, e) {
return function() {
return new HemisphericLight(i,Vector3.Zero(),e)
}
});
var HemisphericLight = function(i) {
__extends(e, i);
function e(t, r, n) {
var o = i.call(this, t, n) || this;
return o.groundColor = new Color3(0,0,0),
o.direction = r || Vector3.Up(),
o
}
return e.prototype._buildUniformLayout = function() {
this._uniformBuffer.addUniform("vLightData", 4),
this._uniformBuffer.addUniform("vLightDiffuse", 4),
this._uniformBuffer.addUniform("vLightSpecular", 4),
this._uniformBuffer.addUniform("vLightGround", 3),
this._uniformBuffer.addUniform("shadowsInfo", 3),
this._uniformBuffer.addUniform("depthValues", 2),
this._uniformBuffer.create()
}
,
e.prototype.getClassName = function() {
return "HemisphericLight"
}
,
e.prototype.setDirectionToTarget = function(t) {
return this.direction = Vector3.Normalize(t.subtract(Vector3.Zero())),
this.direction
}
,
e.prototype.getShadowGenerator = function() {
return null
}
,
e.prototype.transferToEffect = function(t, r) {
var n = Vector3.Normalize(this.direction);
return this._uniformBuffer.updateFloat4("vLightData", n.x, n.y, n.z, 0, r),
this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), r),
this
}
,
e.prototype.transferToNodeMaterialEffect = function(t, r) {
var n = Vector3.Normalize(this.direction);
return t.setFloat3(r, n.x, n.y, n.z),
this
}
,
e.prototype.computeWorldMatrix = function() {
return this._worldMatrix || (this._worldMatrix = Matrix.Identity()),
this._worldMatrix
}
,
e.prototype.getTypeID = function() {
return Light.LIGHTTYPEID_HEMISPHERICLIGHT
}
,
e.prototype.prepareLightSpecificDefines = function(t, r) {
t["HEMILIGHT" + r] = !0
}
,
__decorate([serializeAsColor3()], e.prototype, "groundColor", void 0),
__decorate([serializeAsVector3()], e.prototype, "direction", void 0),
e
}(Light)
, RenderTargetWrapper = function() {
function i(e, t, r, n) {
this._textures = null,
this._attachments = null,
this._generateStencilBuffer = !1,
this._generateDepthBuffer = !1,
this._depthStencilTextureWithStencil = !1,
this._isMulti = e,
this._isCube = t,
this._size = r,
this._engine = n,
this._depthStencilTexture = null
}
return Object.defineProperty(i.prototype, "isCube", {
get: function() {
return this._isCube
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isMulti", {
get: function() {
return this._isMulti
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "is2DArray", {
get: function() {
return this.layers > 0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "size", {
get: function() {
return this.width
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "width", {
get: function() {
return this._size.width || this._size
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "height", {
get: function() {
return this._size.height || this._size
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "layers", {
get: function() {
return this._size.layers || 0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "texture", {
get: function() {
var e, t;
return (t = (e = this._textures) === null || e === void 0 ? void 0 : e[0]) !== null && t !== void 0 ? t : null
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "textures", {
get: function() {
return this._textures
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "samples", {
get: function() {
var e, t;
return (t = (e = this.texture) === null || e === void 0 ? void 0 : e.samples) !== null && t !== void 0 ? t : 1
},
enumerable: !1,
configurable: !0
}),
i.prototype.setSamples = function(e, t, r) {
return t === void 0 && (t = !0),
r === void 0 && (r = !1),
this.samples === e && !r ? e : this._isMulti ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, e, t) : this._engine.updateRenderTargetTextureSampleCount(this, e)
}
,
i.prototype.setTextures = function(e) {
Array.isArray(e) ? this._textures = e : e ? this._textures = [e] : this._textures = null
}
,
i.prototype.setTexture = function(e, t, r) {
t === void 0 && (t = 0),
r === void 0 && (r = !0),
this._textures || (this._textures = []),
this._textures[t] && r && this._textures[t].dispose(),
this._textures[t] = e
}
,
i.prototype.createDepthStencilTexture = function(e, t, r, n, o) {
var a;
return e === void 0 && (e = 0),
t === void 0 && (t = !0),
r === void 0 && (r = !1),
n === void 0 && (n = 1),
o === void 0 && (o = 15),
(a = this._depthStencilTexture) === null || a === void 0 || a.dispose(),
this._depthStencilTextureWithStencil = r,
this._depthStencilTexture = this._engine.createDepthStencilTexture(this._size, {
bilinearFiltering: t,
comparisonFunction: e,
generateStencil: r,
isCube: this._isCube,
samples: n,
depthTextureFormat: o
}, this),
this._depthStencilTexture
}
,
i.prototype._shareDepth = function(e) {
this._depthStencilTexture && (e._depthStencilTexture && e._depthStencilTexture.dispose(),
e._depthStencilTexture = this._depthStencilTexture,
this._depthStencilTexture.incrementReferences())
}
,
i.prototype._swapAndDie = function(e) {
this.texture && this.texture._swapAndDie(e),
this._textures = null,
this.dispose(!0)
}
,
i.prototype._cloneRenderTargetWrapper = function() {
var e, t, r, n, o, a, s = null;
if (this._isMulti) {
var l = this.textures;
if (l && l.length > 0) {
var u = !1
, c = l.length
, h = l[l.length - 1]._source;
(h === InternalTextureSource.Depth || h === InternalTextureSource.DepthStencil) && (u = !0,
c--);
for (var f = [], d = [], _ = 0; _ < c; ++_) {
var g = l[_];
f.push(g.samplingMode),
d.push(g.type)
}
var m = {
samplingModes: f,
generateMipMaps: l[0].generateMipMaps,
generateDepthBuffer: this._generateDepthBuffer,
generateStencilBuffer: this._generateStencilBuffer,
generateDepthTexture: u,
types: d,
textureCount: c
}
, v = {
width: this.width,
height: this.height
};
s = this._engine.createMultipleRenderTarget(v, m)
}
} else {
var y = {};
if (y.generateDepthBuffer = this._generateDepthBuffer,
y.generateMipMaps = (t = (e = this.texture) === null || e === void 0 ? void 0 : e.generateMipMaps) !== null && t !== void 0 ? t : !1,
y.generateStencilBuffer = this._generateStencilBuffer,
y.samplingMode = (r = this.texture) === null || r === void 0 ? void 0 : r.samplingMode,
y.type = (n = this.texture) === null || n === void 0 ? void 0 : n.type,
y.format = (o = this.texture) === null || o === void 0 ? void 0 : o.format,
this.isCube)
s = this._engine.createRenderTargetCubeTexture(this.width, y);
else {
var v = {
width: this.width,
height: this.height,
layers: this.is2DArray ? (a = this.texture) === null || a === void 0 ? void 0 : a.depth : void 0
};
s = this._engine.createRenderTargetTexture(v, y)
}
s.texture.isReady = !0
}
return s
}
,
i.prototype._swapRenderTargetWrapper = function(e) {
if (this._textures && e._textures)
for (var t = 0; t < this._textures.length; ++t)
this._textures[t]._swapAndDie(e._textures[t], !1),
e._textures[t].isReady = !0;
this._depthStencilTexture && e._depthStencilTexture && (this._depthStencilTexture._swapAndDie(e._depthStencilTexture),
e._depthStencilTexture.isReady = !0),
this._textures = null,
this._depthStencilTexture = null
}
,
i.prototype._rebuild = function() {
var e = this._cloneRenderTargetWrapper();
if (!!e) {
if (this._depthStencilTexture) {
var t = this._depthStencilTexture.samplingMode
, r = t === 2 || t === 3 || t === 11;
e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, r, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples)
}
this.samples > 1 && e.setSamples(this.samples),
e._swapRenderTargetWrapper(this),
e.dispose()
}
}
,
i.prototype.releaseTextures = function() {
var e, t;
if (this._textures)
for (var r = 0; (t = r < ((e = this._textures) === null || e === void 0 ? void 0 : e.length)) !== null && t !== void 0 && t; ++r)
this._textures[r].dispose();
this._textures = null
}
,
i.prototype.dispose = function(e) {
var t;
e === void 0 && (e = !1),
e || ((t = this._depthStencilTexture) === null || t === void 0 || t.dispose(),
this._depthStencilTexture = null,
this.releaseTextures()),
this._engine._releaseRenderTargetWrapper(this)
}
,
i
}()
, WebGLRenderTargetWrapper = function(i) {
__extends(e, i);
function e(t, r, n, o, a) {
var s = i.call(this, t, r, n, o) || this;
return s._framebuffer = null,
s._depthStencilBuffer = null,
s._MSAAFramebuffer = null,
s._colorTextureArray = null,
s._depthStencilTextureArray = null,
s._context = a,
s
}
return e.prototype._cloneRenderTargetWrapper = function() {
var t = null;
return this._colorTextureArray && this._depthStencilTextureArray ? (t = this._engine.createMultiviewRenderTargetTexture(this.width, this.height),
t.texture.isReady = !0) : t = i.prototype._cloneRenderTargetWrapper.call(this),
t
}
,
e.prototype._swapRenderTargetWrapper = function(t) {
i.prototype._swapRenderTargetWrapper.call(this, t),
t._framebuffer = this._framebuffer,
t._depthStencilBuffer = this._depthStencilBuffer,
t._MSAAFramebuffer = this._MSAAFramebuffer,
t._colorTextureArray = this._colorTextureArray,
t._depthStencilTextureArray = this._depthStencilTextureArray,
this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null
}
,
e.prototype._shareDepth = function(t) {
i.prototype._shareDepth.call(this, t);
var r = this._context
, n = this._depthStencilBuffer
, o = t._framebuffer;
t._depthStencilBuffer && r.deleteRenderbuffer(t._depthStencilBuffer),
t._depthStencilBuffer = this._depthStencilBuffer,
this._engine._bindUnboundFramebuffer(o),
r.framebufferRenderbuffer(r.FRAMEBUFFER, r.DEPTH_ATTACHMENT, r.RENDERBUFFER, n),
this._engine._bindUnboundFramebuffer(null)
}
,
e.prototype._bindTextureRenderTarget = function(t, r, n, o) {
if (r === void 0 && (r = 0),
n === void 0 && (n = -1),
o === void 0 && (o = 0),
!!t._hardwareTexture) {
var a = this._context
, s = this._framebuffer
, l = this._engine._currentFramebuffer;
this._engine._bindUnboundFramebuffer(s);
var u = a[this._engine.webGLVersion > 1 ? "COLOR_ATTACHMENT" + r : "COLOR_ATTACHMENT" + r + "_WEBGL"]
, c = n !== -1 ? a.TEXTURE_CUBE_MAP_POSITIVE_X + n : a.TEXTURE_2D;
a.framebufferTexture2D(a.FRAMEBUFFER, u, c, t._hardwareTexture.underlyingResource, o),
this._engine._bindUnboundFramebuffer(l)
}
}
,
e.prototype.setTexture = function(t, r, n) {
r === void 0 && (r = 0),
n === void 0 && (n = !0),
i.prototype.setTexture.call(this, t, r, n),
this._bindTextureRenderTarget(t, r)
}
,
e.prototype.dispose = function(t) {
t === void 0 && (t = !1);
var r = this._context;
t || (this._colorTextureArray && (this._context.deleteTexture(this._colorTextureArray),
this._colorTextureArray = null),
this._depthStencilTextureArray && (this._context.deleteTexture(this._depthStencilTextureArray),
this._depthStencilTextureArray = null)),
this._framebuffer && (r.deleteFramebuffer(this._framebuffer),
this._framebuffer = null),
this._depthStencilBuffer && (r.deleteRenderbuffer(this._depthStencilBuffer),
this._depthStencilBuffer = null),
this._MSAAFramebuffer && (r.deleteFramebuffer(this._MSAAFramebuffer),
this._MSAAFramebuffer = null),
i.prototype.dispose.call(this, t)
}
,
e
}(RenderTargetWrapper);
ThinEngine.prototype._createHardwareRenderTargetWrapper = function(i, e, t) {
var r = new WebGLRenderTargetWrapper(i,e,t,this,this._gl);
return this._renderTargetWrapperCache.push(r),
r
}
;
ThinEngine.prototype.createRenderTargetTexture = function(i, e) {
var t = this._createHardwareRenderTargetWrapper(!1, !1, i)
, r = {};
e !== void 0 && typeof e == "object" ? (r.generateDepthBuffer = !!e.generateDepthBuffer,
r.generateStencilBuffer = !!e.generateStencilBuffer) : (r.generateDepthBuffer = !0,
r.generateStencilBuffer = !1);
var n = this._createInternalTexture(i, e, !0, InternalTextureSource.RenderTarget)
, o = i.width || i
, a = i.height || i
, s = this._currentFramebuffer
, l = this._gl
, u = l.createFramebuffer();
return this._bindUnboundFramebuffer(u),
t._depthStencilBuffer = this._setupFramebufferDepthAttachments(!!r.generateStencilBuffer, r.generateDepthBuffer, o, a),
n.is2DArray || l.framebufferTexture2D(l.FRAMEBUFFER, l.COLOR_ATTACHMENT0, l.TEXTURE_2D, n._hardwareTexture.underlyingResource, 0),
this._bindUnboundFramebuffer(s),
t._framebuffer = u,
t._generateDepthBuffer = r.generateDepthBuffer,
t._generateStencilBuffer = !!r.generateStencilBuffer,
t.setTextures(n),
t
}
;
ThinEngine.prototype.createDepthStencilTexture = function(i, e, t) {
if (e.isCube) {
var r = i.width || i;
return this._createDepthStencilCubeTexture(r, e, t)
} else
return this._createDepthStencilTexture(i, e, t)
}
;
ThinEngine.prototype._createDepthStencilTexture = function(i, e, t) {
var r = this._gl
, n = i.layers || 0
, o = n !== 0 ? r.TEXTURE_2D_ARRAY : r.TEXTURE_2D
, a = new InternalTexture(this,InternalTextureSource.DepthStencil);
if (!this._caps.depthTextureExtension)
return Logger$2.Error("Depth texture is not supported by your browser or hardware."),
a;
var s = __assign({
bilinearFiltering: !1,
comparisonFunction: 0,
generateStencil: !1
}, e);
this._bindTextureDirectly(o, a, !0),
this._setupDepthStencilTexture(a, i, s.generateStencil, s.comparisonFunction === 0 ? !1 : s.bilinearFiltering, s.comparisonFunction),
t._depthStencilTexture = a,
t._depthStencilTextureWithStencil = s.generateStencil;
var l = s.generateStencil ? r.UNSIGNED_INT_24_8 : r.UNSIGNED_INT
, u = s.generateStencil ? r.DEPTH_STENCIL : r.DEPTH_COMPONENT
, c = u;
return this.webGLVersion > 1 && (c = s.generateStencil ? r.DEPTH24_STENCIL8 : r.DEPTH_COMPONENT24),
a.is2DArray ? r.texImage3D(o, 0, c, a.width, a.height, n, 0, u, l, null) : r.texImage2D(o, 0, c, a.width, a.height, 0, u, l, null),
this._bindTextureDirectly(o, null),
this._internalTexturesCache.push(a),
a
}
;
ThinEngine.prototype.updateRenderTargetTextureSampleCount = function(i, e) {
if (this.webGLVersion < 2 || !i || !i.texture)
return 1;
if (i.samples === e)
return e;
var t = this._gl;
e = Math.min(e, this.getCaps().maxMSAASamples),
i._depthStencilBuffer && (t.deleteRenderbuffer(i._depthStencilBuffer),
i._depthStencilBuffer = null),
i._MSAAFramebuffer && (t.deleteFramebuffer(i._MSAAFramebuffer),
i._MSAAFramebuffer = null);
var r = i.texture._hardwareTexture;
if (r._MSAARenderBuffer && (t.deleteRenderbuffer(r._MSAARenderBuffer),
r._MSAARenderBuffer = null),
e > 1 && t.renderbufferStorageMultisample) {
var n = t.createFramebuffer();
if (!n)
throw new Error("Unable to create multi sampled framebuffer");
i._MSAAFramebuffer = n,
this._bindUnboundFramebuffer(i._MSAAFramebuffer);
var o = this._createRenderBuffer(i.texture.width, i.texture.height, e, -1, this._getRGBAMultiSampleBufferFormat(i.texture.type), t.COLOR_ATTACHMENT0, !1);
if (!o)
throw new Error("Unable to create multi sampled framebuffer");
r._MSAARenderBuffer = o
} else
this._bindUnboundFramebuffer(i._framebuffer);
return i.texture.samples = e,
i._depthStencilBuffer = this._setupFramebufferDepthAttachments(i._generateStencilBuffer, i._generateDepthBuffer, i.texture.width, i.texture.height, e),
this._bindUnboundFramebuffer(null),
e
}
;
ThinEngine.prototype.createRenderTargetCubeTexture = function(i, e) {
var t = this._createHardwareRenderTargetWrapper(!1, !0, i)
, r = __assign({
generateMipMaps: !0,
generateDepthBuffer: !0,
generateStencilBuffer: !1,
type: 0,
samplingMode: 3,
format: 5
}, e);
r.generateStencilBuffer = r.generateDepthBuffer && r.generateStencilBuffer,
(r.type === 1 && !this._caps.textureFloatLinearFiltering || r.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (r.samplingMode = 1);
var n = this._gl
, o = new InternalTexture(this,InternalTextureSource.RenderTarget);
this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, o, !0);
var a = this._getSamplingParameters(r.samplingMode, r.generateMipMaps);
r.type === 1 && !this._caps.textureFloat && (r.type = 0,
Logger$2.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, a.mag),
n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MIN_FILTER, a.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 s = 0; s < 6; s++)
n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + s, 0, this._getRGBABufferInternalSizedFormat(r.type, r.format), i, i, 0, this._getInternalFormat(r.format), this._getWebGLTextureType(r.type), null);
var l = n.createFramebuffer();
return this._bindUnboundFramebuffer(l),
t._depthStencilBuffer = this._setupFramebufferDepthAttachments(r.generateStencilBuffer, r.generateDepthBuffer, i, i),
r.generateMipMaps && n.generateMipmap(n.TEXTURE_CUBE_MAP),
this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, null),
this._bindUnboundFramebuffer(null),
t._framebuffer = l,
t._generateDepthBuffer = r.generateDepthBuffer,
t._generateStencilBuffer = r.generateStencilBuffer,
o.width = i,
o.height = i,
o.isReady = !0,
o.isCube = !0,
o.samples = 1,
o.generateMipMaps = r.generateMipMaps,
o.samplingMode = r.samplingMode,
o.type = r.type,
o.format = r.format,
this._internalTexturesCache.push(o),
t.setTextures(o),
t
}
;
var RenderTargetTexture = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u, c, h, f, d, _, g, m) {
a === void 0 && (a = !0),
s === void 0 && (s = 0),
l === void 0 && (l = !1),
u === void 0 && (u = Texture.TRILINEAR_SAMPLINGMODE),
c === void 0 && (c = !0),
h === void 0 && (h = !1),
f === void 0 && (f = !1),
d === void 0 && (d = 5),
_ === void 0 && (_ = !1);
var v, y = i.call(this, null, n, !o, void 0, u, void 0, void 0, void 0, void 0, d) || this;
if (y.renderParticles = !0,
y.renderSprites = !1,
y.ignoreCameraViewport = !1,
y.onBeforeBindObservable = new Observable,
y.onAfterUnbindObservable = new Observable,
y.onBeforeRenderObservable = new Observable,
y.onAfterRenderObservable = new Observable,
y.onClearObservable = new Observable,
y.onResizeObservable = new Observable,
y._cleared = !1,
y.skipInitialClear = !1,
y._currentRefreshId = -1,
y._refreshRate = 1,
y._samples = 1,
y._canRescale = !0,
y._renderTarget = null,
y.boundingBoxPosition = Vector3.Zero(),
n = y.getScene(),
!n)
return y;
var b = y.getScene().getEngine();
return y._coordinatesMode = Texture.PROJECTION_MODE,
y.renderList = new Array,
y.name = t,
y.isRenderTarget = !0,
y._initialSizeParameter = r,
y._renderPassIds = [],
y.__isCube = l,
y._processSizeParameter(r),
y.renderPassId = y._renderPassIds[0],
y._resizeObserver = b.onResizeObservable.add(function() {}),
y._generateMipMaps = !!o,
y._doNotChangeAspectRatio = a,
y._renderingManager = new RenderingManager(n),
y._renderingManager._useSceneAutoClearSetup = !0,
f || (y._renderTargetOptions = {
generateMipMaps: o,
type: s,
format: (v = y._format) !== null && v !== void 0 ? v : void 0,
samplingMode: y.samplingMode,
generateDepthBuffer: c,
generateStencilBuffer: h,
samples: g,
creationFlags: m
},
y.samplingMode === Texture.NEAREST_SAMPLINGMODE && (y.wrapU = Texture.CLAMP_ADDRESSMODE,
y.wrapV = Texture.CLAMP_ADDRESSMODE),
_ || (l ? (y._renderTarget = n.getEngine().createRenderTargetCubeTexture(y.getRenderSize(), y._renderTargetOptions),
y.coordinatesMode = Texture.INVCUBIC_MODE,
y._textureMatrix = Matrix.Identity()) : y._renderTarget = n.getEngine().createRenderTargetTexture(y._size, y._renderTargetOptions),
y._texture = y._renderTarget.texture,
g !== void 0 && (y.samples = g))),
y
}
return Object.defineProperty(e.prototype, "renderList", {
get: function() {
return this._renderList
},
set: function(t) {
this._renderList = t,
this._renderList && this._hookArray(this._renderList)
},
enumerable: !1,
configurable: !0
}),
e.prototype._hookArray = function(t) {
var r = this
, n = t.push;
t.push = function() {
for (var a, s = [], l = 0; l < arguments.length; l++)
s[l] = arguments[l];
var u = t.length === 0
, c = n.apply(t, s);
return u && ((a = r.getScene()) === null || a === void 0 || a.meshes.forEach(function(h) {
h._markSubMeshesAsLightDirty()
})),
c
}
;
var o = t.splice;
t.splice = function(a, s) {
var l, u = o.apply(t, [a, s]);
return t.length === 0 && ((l = r.getScene()) === null || l === void 0 || l.meshes.forEach(function(c) {
c._markSubMeshesAsLightDirty()
})),
u
}
}
,
Object.defineProperty(e.prototype, "postProcesses", {
get: function() {
return this._postProcesses
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "_prePassEnabled", {
get: function() {
return !!this._prePassRenderTarget && this._prePassRenderTarget.enabled
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onAfterUnbind", {
set: function(t) {
this._onAfterUnbindObserver && this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),
this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onBeforeRender", {
set: function(t) {
this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onAfterRender", {
set: function(t) {
this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
this._onAfterRenderObserver = this.onAfterRenderObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onClear", {
set: function(t) {
this._onClearObserver && this.onClearObservable.remove(this._onClearObserver),
this._onClearObserver = this.onClearObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "renderPassIds", {
get: function() {
return this._renderPassIds
},
enumerable: !1,
configurable: !0
}),
e.prototype.setMaterialForRendering = function(t, r) {
var n;
Array.isArray(t) ? n = t : n = [t];
for (var o = 0; o < n.length; ++o)
for (var a = 0; a < this._renderPassIds.length; ++a)
n[o].setMaterialForRenderPass(this._renderPassIds[a], r !== void 0 ? Array.isArray(r) ? r[a] : r : void 0)
}
,
Object.defineProperty(e.prototype, "renderTargetOptions", {
get: function() {
return this._renderTargetOptions
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "renderTarget", {
get: function() {
return this._renderTarget
},
enumerable: !1,
configurable: !0
}),
e.prototype._onRatioRescale = function() {
this._sizeRatio && this.resize(this._initialSizeParameter)
}
,
Object.defineProperty(e.prototype, "boundingBoxSize", {
get: function() {
return this._boundingBoxSize
},
set: function(t) {
if (!(this._boundingBoxSize && this._boundingBoxSize.equals(t))) {
this._boundingBoxSize = t;
var r = this.getScene();
r && r.markAllMaterialsAsDirty(1)
}
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "depthStencilTexture", {
get: function() {
var t, r;
return (r = (t = this._renderTarget) === null || t === void 0 ? void 0 : t._depthStencilTexture) !== null && r !== void 0 ? r : null
},
enumerable: !1,
configurable: !0
}),
e.prototype.createDepthStencilTexture = function(t, r, n, o) {
var a;
t === void 0 && (t = 0),
r === void 0 && (r = !0),
n === void 0 && (n = !1),
o === void 0 && (o = 1),
(a = this._renderTarget) === null || a === void 0 || a.createDepthStencilTexture(t, r, n, o)
}
,
e.prototype._releaseRenderPassId = function() {
if (this._scene)
for (var t = this._scene.getEngine(), r = 0; r < this._renderPassIds.length; ++r)
t.releaseRenderPassId(this._renderPassIds[r]);
this._renderPassIds = []
}
,
e.prototype._createRenderPassId = function() {
this._releaseRenderPassId();
for (var t = this._scene.getEngine(), r = this.__isCube ? 6 : this.getRenderLayers() || 1, n = 0; n < r; ++n)
this._renderPassIds[n] = t.createRenderPassId("RenderTargetTexture - " + this.name + "#" + n)
}
,
e.prototype._processSizeParameter = function(t) {
if (t.ratio) {
this._sizeRatio = t.ratio;
var r = this._getEngine();
this._size = {
width: this._bestReflectionRenderTargetDimension(r.getRenderWidth(), this._sizeRatio),
height: this._bestReflectionRenderTargetDimension(r.getRenderHeight(), this._sizeRatio)
}
} else
this._size = t;
this._createRenderPassId()
}
,
Object.defineProperty(e.prototype, "samples", {
get: function() {
var t, r;
return (r = (t = this._renderTarget) === null || t === void 0 ? void 0 : t.samples) !== null && r !== void 0 ? r : this._samples
},
set: function(t) {
this._renderTarget && (this._samples = this._renderTarget.setSamples(t))
},
enumerable: !1,
configurable: !0
}),
e.prototype.resetRefreshCounter = function() {
this._currentRefreshId = -1
}
,
Object.defineProperty(e.prototype, "refreshRate", {
get: function() {
return this._refreshRate
},
set: function(t) {
this._refreshRate = t,
this.resetRefreshCounter()
},
enumerable: !1,
configurable: !0
}),
e.prototype.addPostProcess = function(t) {
if (!this._postProcessManager) {
var r = this.getScene();
if (!r)
return;
this._postProcessManager = new PostProcessManager(r),
this._postProcesses = new Array
}
this._postProcesses.push(t),
this._postProcesses[0].autoClear = !1
}
,
e.prototype.clearPostProcesses = function(t) {
if (t === void 0 && (t = !1),
!!this._postProcesses) {
if (t)
for (var r = 0, n = this._postProcesses; r < n.length; r++) {
var o = n[r];
o.dispose()
}
this._postProcesses = []
}
}
,
e.prototype.removePostProcess = function(t) {
if (!!this._postProcesses) {
var r = this._postProcesses.indexOf(t);
r !== -1 && (this._postProcesses.splice(r, 1),
this._postProcesses.length > 0 && (this._postProcesses[0].autoClear = !1))
}
}
,
e.prototype._shouldRender = function() {
return this._currentRefreshId === -1 ? (this._currentRefreshId = 1,
!0) : this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
!0) : (this._currentRefreshId++,
!1)
}
,
e.prototype.getRenderSize = function() {
return this.getRenderWidth()
}
,
e.prototype.getRenderWidth = function() {
return this._size.width ? this._size.width : this._size
}
,
e.prototype.getRenderHeight = function() {
return this._size.width ? this._size.height : this._size
}
,
e.prototype.getRenderLayers = function() {
var t = this._size.layers;
return t || 0
}
,
e.prototype.disableRescaling = function() {
this._canRescale = !1
}
,
Object.defineProperty(e.prototype, "canRescale", {
get: function() {
return this._canRescale
},
enumerable: !1,
configurable: !0
}),
e.prototype.scale = function(t) {
var r = Math.max(1, this.getRenderSize() * t);
this.resize(r)
}
,
e.prototype.getReflectionTextureMatrix = function() {
return this.isCube ? this._textureMatrix : i.prototype.getReflectionTextureMatrix.call(this)
}
,
e.prototype.resize = function(t) {
var r, n = this.isCube;
(r = this._renderTarget) === null || r === void 0 || r.dispose(),
this._renderTarget = null;
var o = this.getScene();
!o || (this._processSizeParameter(t),
n ? this._renderTarget = o.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions) : this._renderTarget = o.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions),
this._texture = this._renderTarget.texture,
this._renderTargetOptions.samples !== void 0 && (this.samples = this._renderTargetOptions.samples),
this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this))
}
,
e.prototype.render = function(t, r) {
t === void 0 && (t = !1),
r === void 0 && (r = !1),
this._render(t, r)
}
,
e.prototype.isReadyForRendering = function() {
return this._render(!1, !1, !0)
}
,
e.prototype._render = function(t, r, n) {
var o;
t === void 0 && (t = !1),
r === void 0 && (r = !1),
n === void 0 && (n = !1);
var a = this.getScene();
if (!a)
return n;
var s = a.getEngine();
if (this.useCameraPostProcesses !== void 0 && (t = this.useCameraPostProcesses),
this._waitingRenderList) {
this.renderList = [];
for (var l = 0; l < this._waitingRenderList.length; l++) {
var u = this._waitingRenderList[l]
, c = a.getMeshById(u);
c && this.renderList.push(c)
}
this._waitingRenderList = void 0
}
if (this.renderListPredicate) {
this.renderList ? this.renderList.length = 0 : this.renderList = [];
var a = this.getScene();
if (!a)
return n;
for (var h = a.meshes, l = 0; l < h.length; l++) {
var f = h[l];
this.renderListPredicate(f) && this.renderList.push(f)
}
}
var d = s.currentRenderPassId;
this.onBeforeBindObservable.notifyObservers(this);
var _ = (o = this.activeCamera) !== null && o !== void 0 ? o : a.activeCamera;
_ && (_ !== a.activeCamera && a.setTransformMatrix(_.getViewMatrix(), _.getProjectionMatrix(!0)),
s.setViewport(_.viewport, this.getRenderWidth(), this.getRenderHeight())),
this._defaultRenderListPrepared = !1;
var g = n;
if (n) {
a.getViewMatrix() || a.updateTransformMatrix();
for (var y = this.is2DArray ? this.getRenderLayers() : this.isCube ? 6 : 1, m = 0; m < y && g; m++) {
var b = null
, T = this.renderList ? this.renderList : a.getActiveMeshes().data
, C = this.renderList ? this.renderList.length : a.getActiveMeshes().length;
s.currentRenderPassId = this._renderPassIds[m],
this.onBeforeRenderObservable.notifyObservers(m),
this.getCustomRenderList && (b = this.getCustomRenderList(m, T, C)),
b || (b = T),
this._doNotChangeAspectRatio || a.updateTransformMatrix(!0);
for (var A = 0; A < b.length && g; ++A) {
var S = b[A];
if (!(!S.isEnabled() || S.isBlocked || !S.isVisible || !S.subMeshes)) {
if (this.customIsReadyFunction) {
if (!this.customIsReadyFunction(S, this.refreshRate)) {
g = !1;
break
}
} else if (!S.isReady(!0)) {
g = !1;
break
}
}
}
this.onAfterRenderObservable.notifyObservers(m)
}
} else if (this.is2DArray)
for (var m = 0; m < this.getRenderLayers(); m++)
this.renderToTarget(0, t, r, m, _),
a.incrementRenderId(),
a.resetCachedMaterial();
else if (this.isCube)
for (var v = 0; v < 6; v++)
this.renderToTarget(v, t, r, void 0, _),
a.incrementRenderId(),
a.resetCachedMaterial();
else
this.renderToTarget(0, t, r, void 0, _);
return this.onAfterUnbindObservable.notifyObservers(this),
s.currentRenderPassId = d,
a.activeCamera && ((a.getEngine().scenes.length > 1 || this.activeCamera && this.activeCamera !== a.activeCamera) && a.setTransformMatrix(a.activeCamera.getViewMatrix(), a.activeCamera.getProjectionMatrix(!0)),
s.setViewport(a.activeCamera.viewport)),
a.resetCachedMaterial(),
g
}
,
e.prototype._bestReflectionRenderTargetDimension = function(t, r) {
var n = 128
, o = t * r
, a = Engine.NearestPOT(o + n * n / (n + o));
return Math.min(Engine.FloorPOT(t), a)
}
,
e.prototype._prepareRenderingManager = function(t, r, n, o) {
var a = this.getScene();
if (!!a) {
this._renderingManager.reset();
for (var s = a.getRenderId(), l = 0; l < r; l++) {
var u = t[l];
if (u && !u.isBlocked) {
if (this.customIsReadyFunction) {
if (!this.customIsReadyFunction(u, this.refreshRate)) {
this.resetRefreshCounter();
continue
}
} else if (!u.isReady(this.refreshRate === 0)) {
this.resetRefreshCounter();
continue
}
if (!u._internalAbstractMeshDataInfo._currentLODIsUpToDate && a.activeCamera && (u._internalAbstractMeshDataInfo._currentLOD = a.customLODSelector ? a.customLODSelector(u, this.activeCamera || a.activeCamera) : u.getLOD(this.activeCamera || a.activeCamera),
u._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0),
!u._internalAbstractMeshDataInfo._currentLOD)
continue;
var c = u._internalAbstractMeshDataInfo._currentLOD;
c._preActivateForIntermediateRendering(s);
var h = void 0;
if (o && n ? h = (u.layerMask & n.layerMask) === 0 : h = !1,
u.isEnabled() && u.isVisible && u.subMeshes && !h && (c !== u && c._activate(s, !0),
u._activate(s, !0) && u.subMeshes.length)) {
u.isAnInstance ? u._internalAbstractMeshDataInfo._actAsRegularMesh && (c = u) : c._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !1,
c._internalAbstractMeshDataInfo._isActiveIntermediate = !0;
for (var f = 0; f < c.subMeshes.length; f++) {
var d = c.subMeshes[f];
this._renderingManager.dispatch(d, c)
}
}
}
}
for (var _ = 0; _ < a.particleSystems.length; _++) {
var g = a.particleSystems[_]
, m = g.emitter;
!g.isStarted() || !m || !m.position || !m.isEnabled() || t.indexOf(m) >= 0 && this._renderingManager.dispatchParticles(g)
}
}
}
,
e.prototype._bindFrameBuffer = function(t, r) {
t === void 0 && (t = 0),
r === void 0 && (r = 0);
var n = this.getScene();
if (!!n) {
var o = n.getEngine();
this._renderTarget && o.bindFramebuffer(this._renderTarget, this.isCube ? t : void 0, void 0, void 0, this.ignoreCameraViewport, 0, r)
}
}
,
e.prototype.unbindFrameBuffer = function(t, r) {
var n = this;
!this._renderTarget || t.unBindFramebuffer(this._renderTarget, this.isCube, function() {
n.onAfterRenderObservable.notifyObservers(r)
})
}
,
e.prototype._prepareFrame = function(t, r, n, o) {
this._postProcessManager ? this._prePassEnabled || this._postProcessManager._prepareFrame(this._texture, this._postProcesses) : (!o || !t.postProcessManager._prepareFrame(this._texture)) && this._bindFrameBuffer(r, n)
}
,
e.prototype.renderToTarget = function(t, r, n, o, a) {
var s, l, u, c;
o === void 0 && (o = 0),
a === void 0 && (a = null);
var h = this.getScene();
if (!!h) {
var f = h.getEngine();
if (!!this._texture) {
(s = f._debugPushGroup) === null || s === void 0 || s.call(f, "render to face #" + t + " layer #" + o, 1),
this._prepareFrame(h, t, o, r),
this.is2DArray ? (f.currentRenderPassId = this._renderPassIds[o],
this.onBeforeRenderObservable.notifyObservers(o)) : (f.currentRenderPassId = this._renderPassIds[t],
this.onBeforeRenderObservable.notifyObservers(t));
var d = f.snapshotRendering && f.snapshotRenderingMode === 1;
if (d)
this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(f) : this.skipInitialClear || f.clear(this.clearColor || h.clearColor, !0, !0, !0);
else {
var _ = null
, g = this.renderList ? this.renderList : h.getActiveMeshes().data
, m = this.renderList ? this.renderList.length : h.getActiveMeshes().length;
this.getCustomRenderList && (_ = this.getCustomRenderList(this.is2DArray ? o : t, g, m)),
_ ? this._prepareRenderingManager(_, _.length, a, !1) : (this._defaultRenderListPrepared || (this._prepareRenderingManager(g, m, a, !this.renderList),
this._defaultRenderListPrepared = !0),
_ = g);
for (var v = 0, y = h._beforeRenderTargetClearStage; v < y.length; v++) {
var b = y[v];
b.action(this, t, o)
}
this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(f) : this.skipInitialClear || f.clear(this.clearColor || h.clearColor, !0, !0, !0),
this._doNotChangeAspectRatio || h.updateTransformMatrix(!0);
for (var T = 0, C = h._beforeRenderTargetDrawStage; T < C.length; T++) {
var b = C[T];
b.action(this, t, o)
}
this._renderingManager.render(this.customRenderFunction, _, this.renderParticles, this.renderSprites);
for (var A = 0, S = h._afterRenderTargetDrawStage; A < S.length; A++) {
var b = S[A];
b.action(this, t, o)
}
var P = this._texture.generateMipMaps;
this._texture.generateMipMaps = !1,
this._postProcessManager ? this._postProcessManager._finalizeFrame(!1, (l = this._renderTarget) !== null && l !== void 0 ? l : void 0, t, this._postProcesses, this.ignoreCameraViewport) : r && h.postProcessManager._finalizeFrame(!1, (u = this._renderTarget) !== null && u !== void 0 ? u : void 0, t),
this._texture.generateMipMaps = P,
this._doNotChangeAspectRatio || h.updateTransformMatrix(!0),
n && Tools.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), f)
}
this.unbindFrameBuffer(f, t),
this.isCube && t === 5 && f.generateMipMapsForCubemap(this._texture),
(c = f._debugPopGroup) === null || c === void 0 || c.call(f, 1)
}
}
}
,
e.prototype.setRenderingOrder = function(t, r, n, o) {
r === void 0 && (r = null),
n === void 0 && (n = null),
o === void 0 && (o = null),
this._renderingManager.setRenderingOrder(t, r, n, o)
}
,
e.prototype.setRenderingAutoClearDepthStencil = function(t, r) {
this._renderingManager.setRenderingAutoClearDepthStencil(t, r),
this._renderingManager._useSceneAutoClearSetup = !1
}
,
e.prototype.clone = function() {
var t = this.getSize()
, r = new e(this.name,t,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer,void 0,this._renderTargetOptions.format,void 0,this._renderTargetOptions.samples);
return r.hasAlpha = this.hasAlpha,
r.level = this.level,
r.coordinatesMode = this.coordinatesMode,
this.renderList && (r.renderList = this.renderList.slice(0)),
r
}
,
e.prototype.serialize = function() {
if (!this.name)
return null;
var t = i.prototype.serialize.call(this);
if (t.renderTargetSize = this.getRenderSize(),
t.renderList = [],
this.renderList)
for (var r = 0; r < this.renderList.length; r++)
t.renderList.push(this.renderList[r].id);
return t
}
,
e.prototype.disposeFramebufferObjects = function() {
var t;
(t = this._renderTarget) === null || t === void 0 || t.dispose(!0)
}
,
e.prototype.releaseInternalTexture = function() {
var t;
(t = this._renderTarget) === null || t === void 0 || t.releaseTextures(),
this._texture = null
}
,
e.prototype.dispose = function() {
var t;
this.onResizeObservable.clear(),
this.onClearObservable.clear(),
this.onAfterRenderObservable.clear(),
this.onAfterUnbindObservable.clear(),
this.onBeforeBindObservable.clear(),
this.onBeforeRenderObservable.clear(),
this._postProcessManager && (this._postProcessManager.dispose(),
this._postProcessManager = null),
this._prePassRenderTarget && this._prePassRenderTarget.dispose(),
this._releaseRenderPassId(),
this.clearPostProcesses(!0),
this._resizeObserver && (this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),
this._resizeObserver = null),
this.renderList = null;
var r = this.getScene();
if (!!r) {
var n = r.customRenderTargets.indexOf(this);
n >= 0 && r.customRenderTargets.splice(n, 1);
for (var o = 0, a = r.cameras; o < a.length; o++) {
var s = a[o];
n = s.customRenderTargets.indexOf(this),
n >= 0 && s.customRenderTargets.splice(n, 1)
}
(t = this._renderTarget) === null || t === void 0 || t.dispose(),
this._renderTarget = null,
this._texture = null,
i.prototype.dispose.call(this)
}
}
,
e.prototype._rebuild = function() {
this.refreshRate === e.REFRESHRATE_RENDER_ONCE && (this.refreshRate = e.REFRESHRATE_RENDER_ONCE),
this._postProcessManager && this._postProcessManager._rebuild()
}
,
e.prototype.freeRenderingGroups = function() {
this._renderingManager && this._renderingManager.freeRenderingGroups()
}
,
e.prototype.getViewCount = function() {
return 1
}
,
e.REFRESHRATE_RENDER_ONCE = 0,
e.REFRESHRATE_RENDER_ONEVERYFRAME = 1,
e.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2,
e
}(Texture);
Texture._CreateRenderTargetTexture = function(i, e, t, r, n) {
return new RenderTargetTexture(i,e,t,r)
}
;
var name$2_ = "postprocessVertexShader"
, shader$2_ = `
attribute vec2 position;
uniform vec2 scale;
varying vec2 vUV;
const vec2 madd=vec2(0.5,0.5);
void main(void) {
vUV=(position*madd+madd)*scale;
gl_Position=vec4(position,0.0,1.0);
}`;
ShaderStore.ShadersStore[name$2_] = shader$2_;
var PostProcess = function() {
function i(e, t, r, n, o, a, s, l, u, c, h, f, d, _, g) {
s === void 0 && (s = 1),
c === void 0 && (c = null),
h === void 0 && (h = 0),
f === void 0 && (f = "postprocess"),
_ === void 0 && (_ = !1),
g === void 0 && (g = 5),
this._parentContainer = null,
this.width = -1,
this.height = -1,
this.nodeMaterialSource = null,
this._outputTexture = null,
this.autoClear = !0,
this.alphaMode = 0,
this.animations = new Array,
this.enablePixelPerfectMode = !1,
this.forceFullscreenViewport = !0,
this.scaleMode = 1,
this.alwaysForcePOT = !1,
this._samples = 1,
this.adaptScaleToCurrentViewport = !1,
this._reusable = !1,
this._renderId = 0,
this.externalTextureSamplerBinding = !1,
this._textures = new SmartArray(2),
this._textureCache = [],
this._currentRenderTextureInd = 0,
this._scaleRatio = new Vector2(1,1),
this._texelSize = Vector2.Zero(),
this.onActivateObservable = new Observable,
this.onSizeChangedObservable = new Observable,
this.onApplyObservable = new Observable,
this.onBeforeRenderObservable = new Observable,
this.onAfterRenderObservable = new Observable,
this.name = e,
a != null ? (this._camera = a,
this._scene = a.getScene(),
a.attachPostProcess(this),
this._engine = this._scene.getEngine(),
this._scene.postProcesses.push(this),
this.uniqueId = this._scene.getUniqueId()) : l && (this._engine = l,
this._engine.postProcesses.push(this)),
this._options = o,
this.renderTargetSamplingMode = s || 1,
this._reusable = u || !1,
this._textureType = h,
this._textureFormat = g,
this._samplers = n || [],
this._samplers.push("textureSampler"),
this._fragmentUrl = t,
this._vertexUrl = f,
this._parameters = r || [],
this._parameters.push("scale"),
this._indexParameters = d,
this._drawWrapper = new DrawWrapper(this._engine),
_ || this.updateEffect(c)
}
return Object.defineProperty(i.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(r) {
r.samples !== t._samples && t._engine.updateRenderTargetTextureSampleCount(r, t._samples)
})
},
enumerable: !1,
configurable: !0
}),
i.prototype.getEffectName = function() {
return this._fragmentUrl
}
,
Object.defineProperty(i.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(i.prototype, "onSizeChanged", {
set: function(e) {
this._onSizeChangedObserver && this.onSizeChangedObservable.remove(this._onSizeChangedObserver),
this._onSizeChangedObserver = this.onSizeChangedObservable.add(e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onApply", {
set: function(e) {
this._onApplyObserver && this.onApplyObservable.remove(this._onApplyObserver),
this._onApplyObserver = this.onApplyObservable.add(e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onBeforeRender", {
set: function(e) {
this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "onAfterRender", {
set: function(e) {
this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "inputTexture", {
get: function() {
return this._textures.data[this._currentRenderTextureInd]
},
set: function(e) {
this._forcedOutputTexture = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.restoreDefaultInputTexture = function() {
this._forcedOutputTexture && (this._forcedOutputTexture = null,
this.markTextureDirty())
}
,
i.prototype.getCamera = function() {
return this._camera
}
,
Object.defineProperty(i.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
}),
i.prototype.getClassName = function() {
return "PostProcess"
}
,
i.prototype.getEngine = function() {
return this._engine
}
,
i.prototype.getEffect = function() {
return this._drawWrapper.effect
}
,
i.prototype.shareOutputWith = function(e) {
return this._disposeTextures(),
this._shareOutputWithPostProcess = e,
this
}
,
i.prototype.useOwnOutput = function() {
this._textures.length == 0 && (this._textures = new SmartArray(2)),
this._shareOutputWithPostProcess = null
}
,
i.prototype.updateEffect = function(e, t, r, n, o, a, s, l) {
e === void 0 && (e = null),
t === void 0 && (t = null),
r === void 0 && (r = null),
this._postProcessDefines = e,
this._drawWrapper.effect = this._engine.createEffect({
vertex: s != null ? s : this._vertexUrl,
fragment: l != null ? l : this._fragmentUrl
}, ["position"], t || this._parameters, r || this._samplers, e !== null ? e : "", void 0, o, a, n || this._indexParameters)
}
,
i.prototype.isReusable = function() {
return this._reusable
}
,
i.prototype.markTextureDirty = function() {
this.width = -1
}
,
i.prototype._createRenderTargetTexture = function(e, t, r) {
r === void 0 && (r = 0);
for (var n = 0; n < this._textureCache.length; n++)
if (this._textureCache[n].texture.width === e.width && this._textureCache[n].texture.height === e.height && this._textureCache[n].postProcessChannel === r && this._textureCache[n].texture._generateDepthBuffer === t.generateDepthBuffer)
return this._textureCache[n].texture;
var o = this._engine.createRenderTargetTexture(e, t);
return this._textureCache.push({
texture: o,
postProcessChannel: r,
lastUsedRenderId: -1
}),
o
}
,
i.prototype._flushTextureCache = function() {
for (var e = this._renderId, t = this._textureCache.length - 1; t >= 0; t--)
if (e - this._textureCache[t].lastUsedRenderId > 100) {
for (var r = !1, n = 0; n < this._textures.length; n++)
if (this._textures.data[n] === this._textureCache[t].texture) {
r = !0;
break
}
r || (this._textureCache[t].texture.dispose(),
this._textureCache.splice(t, 1))
}
}
,
i.prototype._resize = function(e, t, r, n, o) {
this._textures.length > 0 && this._textures.reset(),
this.width = e,
this.height = t;
for (var a = null, s = 0; s < r._postProcesses.length; s++)
if (r._postProcesses[s] !== null) {
a = r._postProcesses[s];
break
}
var l = {
width: this.width,
height: this.height
}
, u = {
generateMipMaps: n,
generateDepthBuffer: o || a === this,
generateStencilBuffer: (o || a === this) && this._engine.isStencilEnable,
samplingMode: this.renderTargetSamplingMode,
type: this._textureType,
format: this._textureFormat
};
this._textures.push(this._createRenderTargetTexture(l, u, 0)),
this._reusable && this._textures.push(this._createRenderTargetTexture(l, u, 1)),
this._texelSize.copyFromFloats(1 / this.width, 1 / this.height),
this.onSizeChangedObservable.notifyObservers(this)
}
,
i.prototype.activate = function(e, t, r) {
var n = this, o, a;
t === void 0 && (t = null),
e = e || this._camera;
var s = e.getScene()
, l = s.getEngine()
, u = l.getCaps().maxTextureSize
, c = (t ? t.width : this._engine.getRenderWidth(!0)) * this._options | 0
, h = (t ? t.height : this._engine.getRenderHeight(!0)) * this._options | 0
, f = e.parent;
f && (f.leftCamera == e || f.rightCamera == e) && (c /= 2);
var d = this._options.width || c
, _ = this._options.height || h
, g = this.renderTargetSamplingMode !== 7 && this.renderTargetSamplingMode !== 1 && this.renderTargetSamplingMode !== 2;
if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
if (this.adaptScaleToCurrentViewport) {
var m = l.currentViewport;
m && (d *= m.width,
_ *= m.height)
}
(g || this.alwaysForcePOT) && (this._options.width || (d = l.needPOTTextures ? Engine.GetExponentOfTwo(d, u, this.scaleMode) : d),
this._options.height || (_ = l.needPOTTextures ? Engine.GetExponentOfTwo(_, u, this.scaleMode) : _)),
(this.width !== d || this.height !== _) && this._resize(d, _, e, g, r),
this._textures.forEach(function(T) {
T.samples !== n.samples && n._engine.updateRenderTargetTextureSampleCount(T, n.samples)
}),
this._flushTextureCache(),
this._renderId++
}
var v;
if (this._shareOutputWithPostProcess)
v = this._shareOutputWithPostProcess.inputTexture;
else if (this._forcedOutputTexture)
v = this._forcedOutputTexture,
this.width = this._forcedOutputTexture.width,
this.height = this._forcedOutputTexture.height;
else {
v = this.inputTexture;
for (var y = void 0, b = 0; b < this._textureCache.length; b++)
if (this._textureCache[b].texture === v) {
y = this._textureCache[b];
break
}
y && (y.lastUsedRenderId = this._renderId)
}
return this.enablePixelPerfectMode ? (this._scaleRatio.copyFromFloats(c / d, h / _),
this._engine.bindFramebuffer(v, 0, c, h, this.forceFullscreenViewport)) : (this._scaleRatio.copyFromFloats(1, 1),
this._engine.bindFramebuffer(v, 0, void 0, void 0, this.forceFullscreenViewport)),
(a = (o = this._engine)._debugInsertMarker) === null || a === void 0 || a.call(o, "post process " + this.name + " input"),
this.onActivateObservable.notifyObservers(e),
this.autoClear && this.alphaMode === 0 && this._engine.clear(this.clearColor ? this.clearColor : s.clearColor, s._allowPostProcessClearColor, !0, !0),
this._reusable && (this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2),
v
}
,
Object.defineProperty(i.prototype, "isSupported", {
get: function() {
return this._drawWrapper.effect.isSupported
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "aspectRatio", {
get: function() {
return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.aspectRatio : this._forcedOutputTexture ? this._forcedOutputTexture.width / this._forcedOutputTexture.height : this.width / this.height
},
enumerable: !1,
configurable: !0
}),
i.prototype.isReady = function() {
var e, t;
return (t = (e = this._drawWrapper.effect) === null || e === void 0 ? void 0 : e.isReady()) !== null && t !== void 0 ? t : !1
}
,
i.prototype.apply = function() {
var e;
if (!(!((e = this._drawWrapper.effect) === null || e === void 0) && e.isReady()))
return null;
this._engine.enableEffect(this._drawWrapper),
this._engine.setState(!1),
this._engine.setDepthBuffer(!1),
this._engine.setDepthWrite(!1),
this._engine.setAlphaMode(this.alphaMode),
this.alphaConstants && this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
var t;
return this._shareOutputWithPostProcess ? t = this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? t = this._forcedOutputTexture : t = this.inputTexture,
this.externalTextureSamplerBinding || this._drawWrapper.effect._bindTexture("textureSampler", t == null ? void 0 : t.texture),
this._drawWrapper.effect.setVector2("scale", this._scaleRatio),
this.onApplyObservable.notifyObservers(this._drawWrapper.effect),
this._drawWrapper.effect
}
,
i.prototype._disposeTextures = function() {
if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
this._disposeTextureCache();
return
}
this._disposeTextureCache(),
this._textures.dispose()
}
,
i.prototype._disposeTextureCache = function() {
for (var e = this._textureCache.length - 1; e >= 0; e--)
this._textureCache[e].texture.dispose();
this._textureCache.length = 0
}
,
i.prototype.setPrePassRenderer = function(e) {
return this._prePassEffectConfiguration ? (this._prePassEffectConfiguration = e.addEffectConfiguration(this._prePassEffectConfiguration),
this._prePassEffectConfiguration.enabled = !0,
!0) : !1
}
,
i.prototype.dispose = function(e) {
e = e || this._camera,
this._disposeTextures();
var t;
if (this._scene && (t = this._scene.postProcesses.indexOf(this),
t !== -1 && this._scene.postProcesses.splice(t, 1)),
this._parentContainer) {
var r = this._parentContainer.postProcesses.indexOf(this);
r > -1 && this._parentContainer.postProcesses.splice(r, 1),
this._parentContainer = null
}
if (t = this._engine.postProcesses.indexOf(this),
t !== -1 && this._engine.postProcesses.splice(t, 1),
!!e) {
if (e.detachPostProcess(this),
t = e._postProcesses.indexOf(this),
t === 0 && e._postProcesses.length > 0) {
var n = this._camera._getFirstPostProcess();
n && n.markTextureDirty()
}
this.onActivateObservable.clear(),
this.onAfterRenderObservable.clear(),
this.onApplyObservable.clear(),
this.onBeforeRenderObservable.clear(),
this.onSizeChangedObservable.clear()
}
}
,
i.prototype.serialize = function() {
var e = SerializationHelper.Serialize(this)
, t = this.getCamera() || this._scene && this._scene.activeCamera;
return e.customType = "BABYLON." + this.getClassName(),
e.cameraId = t ? t.id : null,
e.reusable = this._reusable,
e.textureType = this._textureType,
e.fragmentUrl = this._fragmentUrl,
e.parameters = this._parameters,
e.samplers = this._samplers,
e.options = this._options,
e.defines = this._postProcessDefines,
e.textureFormat = this._textureFormat,
e.vertexUrl = this._vertexUrl,
e.indexParameters = this._indexParameters,
e
}
,
i.prototype.clone = function() {
var e = this.serialize();
e._engine = this._engine,
e.cameraId = null;
var t = i.Parse(e, this._scene, "");
return t ? (t.onActivateObservable = this.onActivateObservable.clone(),
t.onSizeChangedObservable = this.onSizeChangedObservable.clone(),
t.onApplyObservable = this.onApplyObservable.clone(),
t.onBeforeRenderObservable = this.onBeforeRenderObservable.clone(),
t.onAfterRenderObservable = this.onAfterRenderObservable.clone(),
t._prePassEffectConfiguration = this._prePassEffectConfiguration,
t) : null
}
,
i.Parse = function(e, t, r) {
var n = GetClass(e.customType);
if (!n || !n._Parse)
return null;
var o = t ? t.getCameraById(e.cameraId) : null;
return n._Parse(e, o, t, r)
}
,
i._Parse = function(e, t, r, n) {
return SerializationHelper.Parse(function() {
return new i(e.name,e.fragmentUrl,e.parameters,e.samplers,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable,e.defines,e.textureType,e.vertexUrl,e.indexParameters,!1,e.textureFormat)
}, e, r, n)
}
,
__decorate([serialize()], i.prototype, "uniqueId", void 0),
__decorate([serialize()], i.prototype, "name", void 0),
__decorate([serialize()], i.prototype, "width", void 0),
__decorate([serialize()], i.prototype, "height", void 0),
__decorate([serialize()], i.prototype, "renderTargetSamplingMode", void 0),
__decorate([serializeAsColor4()], i.prototype, "clearColor", void 0),
__decorate([serialize()], i.prototype, "autoClear", void 0),
__decorate([serialize()], i.prototype, "alphaMode", void 0),
__decorate([serialize()], i.prototype, "alphaConstants", void 0),
__decorate([serialize()], i.prototype, "enablePixelPerfectMode", void 0),
__decorate([serialize()], i.prototype, "forceFullscreenViewport", void 0),
__decorate([serialize()], i.prototype, "scaleMode", void 0),
__decorate([serialize()], i.prototype, "alwaysForcePOT", void 0),
__decorate([serialize("samples")], i.prototype, "_samples", void 0),
__decorate([serialize()], i.prototype, "adaptScaleToCurrentViewport", void 0),
i
}();
RegisterClass("BABYLON.PostProcess", PostProcess);
var name$2Z = "kernelBlurVaryingDeclaration"
, shader$2Z = "varying vec2 sampleCoord{X};";
ShaderStore.IncludesShadersStore[name$2Z] = shader$2Z;
var name$2Y = "packingFunctions"
, shader$2Y = `vec4 pack(float depth)
{
const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);
const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);
vec4 res=fract(depth*bit_shift);
res-=res.xxyz*bit_mask;
return res;
}
float unpack(vec4 color)
{
const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);
return dot(color,bit_shift);
}`;
ShaderStore.IncludesShadersStore[name$2Y] = shader$2Y;
var name$2X = "kernelBlurFragment"
, shader$2X = `#ifdef DOF
factor=sampleCoC(sampleCoord{X});
computedWeight=KERNEL_WEIGHT{X}*factor;
sumOfWeights+=computedWeight;
#else
computedWeight=KERNEL_WEIGHT{X};
#endif
#ifdef PACKEDFLOAT
blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;
#else
blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;
#endif`;
ShaderStore.IncludesShadersStore[name$2X] = shader$2X;
var name$2W = "kernelBlurFragment2"
, shader$2W = `#ifdef DOF
factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});
computedWeight=KERNEL_DEP_WEIGHT{X}*factor;
sumOfWeights+=computedWeight;
#else
computedWeight=KERNEL_DEP_WEIGHT{X};
#endif
#ifdef PACKEDFLOAT
blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;
#else
blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;
#endif`;
ShaderStore.IncludesShadersStore[name$2W] = shader$2W;
var name$2V = "kernelBlurPixelShader"
, shader$2V = `
uniform sampler2D textureSampler;
uniform vec2 delta;
varying vec2 sampleCenter;
#ifdef DOF
uniform sampler2D circleOfConfusionSampler;
uniform vec2 cameraMinMaxZ;
float sampleDistance(in vec2 offset) {
float depth=texture2D(circleOfConfusionSampler,offset).g;
return cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;
}
float sampleCoC(in vec2 offset) {
float coc=texture2D(circleOfConfusionSampler,offset).r;
return coc;
}
#endif
#include[0..varyingCount]
#ifdef PACKEDFLOAT
#include
#endif
void main(void)
{
float computedWeight=0.0;
#ifdef PACKEDFLOAT
float blend=0.;
#else
vec4 blend=vec4(0.);
#endif
#ifdef DOF
float sumOfWeights=CENTER_WEIGHT;
float factor=0.0;
#ifdef PACKEDFLOAT
blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;
#else
blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;
#endif
#endif
#include[0..varyingCount]
#include[0..depCount]
#ifdef PACKEDFLOAT
gl_FragColor=pack(blend);
#else
gl_FragColor=blend;
#endif
#ifdef DOF
gl_FragColor/=sumOfWeights;
#endif
}`;
ShaderStore.ShadersStore[name$2V] = shader$2V;
var name$2U = "kernelBlurVertex"
, shader$2U = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
ShaderStore.IncludesShadersStore[name$2U] = shader$2U;
var name$2T = "kernelBlurVertexShader"
, shader$2T = `
attribute vec2 position;
uniform vec2 delta;
varying vec2 sampleCenter;
#include[0..varyingCount]
const vec2 madd=vec2(0.5,0.5);
void main(void) {
sampleCenter=(position*madd+madd);
#include[0..varyingCount]
gl_Position=vec4(position,0.0,1.0);
}`;
ShaderStore.ShadersStore[name$2T] = shader$2T;
var BlurPostProcess = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u, c, h, f) {
s === void 0 && (s = Texture.BILINEAR_SAMPLINGMODE),
c === void 0 && (c = 0),
h === void 0 && (h = ""),
f === void 0 && (f = !1);
var d = i.call(this, t, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["circleOfConfusionSampler"], o, a, s, l, u, null, c, "kernelBlur", {
varyingCount: 0,
depCount: 0
}, !0) || this;
return d.blockCompilation = f,
d._packedFloat = !1,
d._staticDefines = "",
d._staticDefines = h,
d.direction = r,
d.onApplyObservable.add(function(_) {
d._outputTexture ? _.setFloat2("delta", 1 / d._outputTexture.width * d.direction.x, 1 / d._outputTexture.height * d.direction.y) : _.setFloat2("delta", 1 / d.width * d.direction.x, 1 / d.height * d.direction.y)
}),
d.kernel = n,
d
}
return Object.defineProperty(e.prototype, "kernel", {
get: function() {
return this._idealKernel
},
set: function(t) {
this._idealKernel !== t && (t = Math.max(t, 1),
this._idealKernel = t,
this._kernel = this._nearestBestKernel(t),
this.blockCompilation || this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "packedFloat", {
get: function() {
return this._packedFloat
},
set: function(t) {
this._packedFloat !== t && (this._packedFloat = t,
this.blockCompilation || this._updateParameters())
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "BlurPostProcess"
}
,
e.prototype.updateEffect = function(t, r, n, o, a, s) {
this._updateParameters(a, s)
}
,
e.prototype._updateParameters = function(t, r) {
for (var n = this._kernel, o = (n - 1) / 2, a = [], s = [], l = 0, u = 0; u < n; u++) {
var c = u / (n - 1)
, h = this._gaussianWeight(c * 2 - 1);
a[u] = u - o,
s[u] = h,
l += h
}
for (var u = 0; u < s.length; u++)
s[u] /= l;
for (var f = [], d = [], _ = [], u = 0; u <= o; u += 2) {
var g = Math.min(u + 1, Math.floor(o))
, m = u === g;
if (m)
_.push({
o: a[u],
w: s[u]
});
else {
var v = g === o
, y = s[u] + s[g] * (v ? .5 : 1)
, b = a[u] + 1 / (1 + s[u] / s[g]);
b === 0 ? (_.push({
o: a[u],
w: s[u]
}),
_.push({
o: a[u + 1],
w: s[u + 1]
})) : (_.push({
o: b,
w: y
}),
_.push({
o: -b,
w: y
}))
}
}
for (var u = 0; u < _.length; u++)
d[u] = _[u].o,
f[u] = _[u].w;
a = d,
s = f;
var T = this.getEngine().getCaps().maxVaryingVectors
, C = Math.max(T, 0) - 1
, A = Math.min(a.length, C)
, S = "";
S += this._staticDefines,
this._staticDefines.indexOf("DOF") != -1 && (S += "#define CENTER_WEIGHT " + this._glslFloat(s[A - 1]) + `\r
`,
A--);
for (var u = 0; u < A; u++)
S += "#define KERNEL_OFFSET" + u + " " + this._glslFloat(a[u]) + `\r
`,
S += "#define KERNEL_WEIGHT" + u + " " + this._glslFloat(s[u]) + `\r
`;
for (var P = 0, u = C; u < a.length; u++)
S += "#define KERNEL_DEP_OFFSET" + P + " " + this._glslFloat(a[u]) + `\r
`,
S += "#define KERNEL_DEP_WEIGHT" + P + " " + this._glslFloat(s[u]) + `\r
`,
P++;
this.packedFloat && (S += "#define PACKEDFLOAT 1"),
this.blockCompilation = !1,
i.prototype.updateEffect.call(this, S, null, null, {
varyingCount: A,
depCount: P
}, t, r)
}
,
e.prototype._nearestBestKernel = function(t) {
for (var r = Math.round(t), n = 0, o = [r, r - 1, r + 1, r - 2, r + 2]; n < o.length; n++) {
var a = o[n];
if (a % 2 !== 0 && Math.floor(a / 2) % 2 === 0 && a > 0)
return Math.max(a, 3)
}
return Math.max(r, 3)
}
,
e.prototype._gaussianWeight = function(t) {
var r = .3333333333333333
, n = Math.sqrt(2 * Math.PI) * r
, o = -(t * t / (2 * r * r))
, a = 1 / n * Math.exp(o);
return a
}
,
e.prototype._glslFloat = function(t, r) {
return r === void 0 && (r = 8),
t.toFixed(r).replace(/0+$/, "")
}
,
e._Parse = function(t, r, n, o) {
return SerializationHelper.Parse(function() {
return new e(t.name,t.direction,t.kernel,t.options,r,t.renderTargetSamplingMode,n.getEngine(),t.reusable,t.textureType,void 0,!1)
}, t, n, o)
}
,
__decorate([serialize("kernel")], e.prototype, "_kernel", void 0),
__decorate([serialize("packedFloat")], e.prototype, "_packedFloat", void 0),
__decorate([serializeAsVector2()], e.prototype, "direction", void 0),
e
}(PostProcess);
RegisterClass("BABYLON.BlurPostProcess", BlurPostProcess);
var EffectFallbacks = function() {
function i() {
this._defines = {},
this._currentRank = 32,
this._maxRank = -1,
this._mesh = null
}
return i.prototype.unBindMesh = function() {
this._mesh = null
}
,
i.prototype.addFallback = function(e, t) {
this._defines[e] || (e < this._currentRank && (this._currentRank = e),
e > this._maxRank && (this._maxRank = e),
this._defines[e] = new Array),
this._defines[e].push(t)
}
,
i.prototype.addCPUSkinningFallback = function(e, t) {
this._mesh = t,
e < this._currentRank && (this._currentRank = e),
e > this._maxRank && (this._maxRank = e)
}
,
Object.defineProperty(i.prototype, "hasMoreFallbacks", {
get: function() {
return this._currentRank <= this._maxRank
},
enumerable: !1,
configurable: !0
}),
i.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 r = this._mesh.getScene(), n = 0; n < r.meshes.length; n++) {
var o = r.meshes[n];
if (!o.material) {
!this._mesh.material && o.computeBonesUsingShaders && o.numBoneInfluencers > 0 && (o.computeBonesUsingShaders = !1);
continue
}
if (!(!o.computeBonesUsingShaders || o.numBoneInfluencers === 0)) {
if (o.material.getEffect() === t)
o.computeBonesUsingShaders = !1;
else if (o.subMeshes)
for (var a = 0, s = o.subMeshes; a < s.length; a++) {
var l = s[a]
, u = l.effect;
if (u === t) {
o.computeBonesUsingShaders = !1;
break
}
}
}
}
} else {
var c = this._defines[this._currentRank];
if (c)
for (var n = 0; n < c.length; n++)
e = e.replace("#define " + c[n], "");
this._currentRank++
}
return e
}
,
i
}()
, name$2S = "bayerDitherFunctions"
, shader$2S = `
float bayerDither2(vec2 _P) {
return mod(2.0*_P.y+_P.x+1.0,4.0);
}
float bayerDither4(vec2 _P) {
vec2 P1=mod(_P,2.0);
vec2 P2=floor(0.5*mod(_P,4.0));
return 4.0*bayerDither2(P1)+bayerDither2(P2);
}
float bayerDither8(vec2 _P) {
vec2 P1=mod(_P,2.0);
vec2 P2=floor(0.5*mod(_P,4.0));
vec2 P4=floor(0.25*mod(_P,8.0));
return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);
}
`;
ShaderStore.IncludesShadersStore[name$2S] = shader$2S;
var name$2R = "shadowMapFragmentExtraDeclaration"
, shader$2R = `#if SM_FLOAT == 0
#include
#endif
#if SM_SOFTTRANSPARENTSHADOW == 1
#include
uniform float softTransparentShadowSM;
#endif
varying float vDepthMetricSM;
#if SM_USEDISTANCE == 1
uniform vec3 lightDataSM;
varying vec3 vPositionWSM;
#endif
uniform vec3 biasAndScaleSM;
uniform vec2 depthValuesSM;
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
varying float zSM;
#endif
`;
ShaderStore.IncludesShadersStore[name$2R] = shader$2R;
var name$2Q = "clipPlaneFragmentDeclaration"
, shader$2Q = `#ifdef CLIPPLANE
varying float fClipDistance;
#endif
#ifdef CLIPPLANE2
varying float fClipDistance2;
#endif
#ifdef CLIPPLANE3
varying float fClipDistance3;
#endif
#ifdef CLIPPLANE4
varying float fClipDistance4;
#endif
#ifdef CLIPPLANE5
varying float fClipDistance5;
#endif
#ifdef CLIPPLANE6
varying float fClipDistance6;
#endif`;
ShaderStore.IncludesShadersStore[name$2Q] = shader$2Q;
var name$2P = "clipPlaneFragment"
, shader$2P = `#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
if (false) {}
#endif
#ifdef CLIPPLANE
else if (fClipDistance>0.0)
{
discard;
}
#endif
#ifdef CLIPPLANE2
else if (fClipDistance2>0.0)
{
discard;
}
#endif
#ifdef CLIPPLANE3
else if (fClipDistance3>0.0)
{
discard;
}
#endif
#ifdef CLIPPLANE4
else if (fClipDistance4>0.0)
{
discard;
}
#endif
#ifdef CLIPPLANE5
else if (fClipDistance5>0.0)
{
discard;
}
#endif
#ifdef CLIPPLANE6
else if (fClipDistance6>0.0)
{
discard;
}
#endif`;
ShaderStore.IncludesShadersStore[name$2P] = shader$2P;
var name$2O = "shadowMapFragment"
, shader$2O = ` float depthSM=vDepthMetricSM;
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
#if SM_USEDISTANCE == 1
depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#else
#ifdef USE_REVERSE_DEPTHBUFFER
depthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#else
depthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#endif
#endif
#ifdef USE_REVERSE_DEPTHBUFFER
gl_FragDepth=clamp(1.0-depthSM,0.0,1.0);
#else
gl_FragDepth=clamp(depthSM,0.0,1.0);
#endif
#elif SM_USEDISTANCE == 1
depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#endif
#if SM_ESM == 1
depthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);
#endif
#if SM_FLOAT == 1
gl_FragColor=vec4(depthSM,1.0,1.0,1.0);
#else
gl_FragColor=pack(depthSM);
#endif
return;`;
ShaderStore.IncludesShadersStore[name$2O] = shader$2O;
var name$2N = "shadowMapPixelShader"
, shader$2N = `#include
#ifdef ALPHATEST
varying vec2 vUV;
uniform sampler2D diffuseSampler;
#endif
#include
void main(void)
{
#include
#ifdef ALPHATEST
float alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;
if (alphaFromAlphaTexture<0.4)
discard;
#endif
#if SM_SOFTTRANSPARENTSHADOW == 1
#ifdef ALPHATEST
if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;
#else
if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;
#endif
#endif
#include
}`;
ShaderStore.ShadersStore[name$2N] = shader$2N;
var name$2M = "bonesDeclaration"
, shader$2M = `#if NUM_BONE_INFLUENCERS>0
attribute vec4 matricesIndices;
attribute vec4 matricesWeights;
#if NUM_BONE_INFLUENCERS>4
attribute vec4 matricesIndicesExtra;
attribute vec4 matricesWeightsExtra;
#endif
#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
#ifdef BONETEXTURE
uniform sampler2D boneSampler;
uniform float boneTextureWidth;
#else
uniform mat4 mBones[BonesPerMesh];
#ifdef BONES_VELOCITY_ENABLED
uniform mat4 mPreviousBones[BonesPerMesh];
#endif
#endif
#ifdef BONETEXTURE
#define inline
mat4 readMatrixFromRawSampler(sampler2D smp,float index)
{
float offset=index*4.0;
float dx=1.0/boneTextureWidth;
vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));
vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));
vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));
vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));
return mat4(m0,m1,m2,m3);
}
#endif
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$2M] = shader$2M;
var name$2L = "bakedVertexAnimationDeclaration"
, shader$2L = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
uniform float bakedVertexAnimationTime;
uniform vec2 bakedVertexAnimationTextureSizeInverted;
uniform vec4 bakedVertexAnimationSettings;
uniform sampler2D bakedVertexAnimationTexture;
#ifdef INSTANCES
attribute vec4 bakedVertexAnimationSettingsInstanced;
attribute float bakedVertexAnimationTimeInstanced;
#endif
#define inline
mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)
{
float offset=index*4.0;
float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;
float dx=bakedVertexAnimationTextureSizeInverted.x;
vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));
vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));
vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));
vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));
return mat4(m0,m1,m2,m3);
}
#endif`;
ShaderStore.IncludesShadersStore[name$2L] = shader$2L;
var name$2K = "morphTargetsVertexGlobalDeclaration"
, shader$2K = `#ifdef MORPHTARGETS
uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
#ifdef MORPHTARGETS_TEXTURE
precision mediump sampler2DArray;
uniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];
uniform vec3 morphTargetTextureInfo;
uniform sampler2DArray morphTargets;
vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)
{
float y=floor(vertexIndex/morphTargetTextureInfo.y);
float x=vertexIndex-y*morphTargetTextureInfo.y;
vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);
return texture(morphTargets,textureUV).xyz;
}
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$2K] = shader$2K;
var name$2J = "morphTargetsVertexDeclaration"
, shader$2J = `#ifdef MORPHTARGETS
#ifndef MORPHTARGETS_TEXTURE
attribute vec3 position{X};
#ifdef MORPHTARGETS_NORMAL
attribute vec3 normal{X};
#endif
#ifdef MORPHTARGETS_TANGENT
attribute vec3 tangent{X};
#endif
#ifdef MORPHTARGETS_UV
attribute vec2 uv_{X};
#endif
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$2J] = shader$2J;
var name$2I = "helperFunctions"
, shader$2I = `const float PI=3.1415926535897932384626433832795;
const float HALF_MIN=5.96046448e-08;
const float LinearEncodePowerApprox=2.2;
const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;
const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);
const float Epsilon=0.0000001;
#define saturate(x) clamp(x,0.0,1.0)
#define absEps(x) abs(x)+Epsilon
#define maxEps(x) max(x,Epsilon)
#define saturateEps(x) clamp(x,Epsilon,1.0)
mat3 transposeMat3(mat3 inMatrix) {
vec3 i0=inMatrix[0];
vec3 i1=inMatrix[1];
vec3 i2=inMatrix[2];
mat3 outMatrix=mat3(
vec3(i0.x,i1.x,i2.x),
vec3(i0.y,i1.y,i2.y),
vec3(i0.z,i1.z,i2.z)
);
return outMatrix;
}
mat3 inverseMat3(mat3 inMatrix) {
float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];
float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];
float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];
float b01=a22*a11-a12*a21;
float b11=-a22*a10+a12*a20;
float b21=a21*a10-a11*a20;
float det=a00*b01+a01*b11+a02*b21;
return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),
b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;
}
float toLinearSpace(float color)
{
return pow(color,LinearEncodePowerApprox);
}
vec3 toLinearSpace(vec3 color)
{
return pow(color,vec3(LinearEncodePowerApprox));
}
vec4 toLinearSpace(vec4 color)
{
return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);
}
vec3 toGammaSpace(vec3 color)
{
return pow(color,vec3(GammaEncodePowerApprox));
}
vec4 toGammaSpace(vec4 color)
{
return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);
}
float toGammaSpace(float color)
{
return pow(color,GammaEncodePowerApprox);
}
float square(float value)
{
return value*value;
}
float pow5(float value) {
float sq=value*value;
return sq*sq*value;
}
float getLuminance(vec3 color)
{
return clamp(dot(color,LuminanceEncodeApprox),0.,1.);
}
float getRand(vec2 seed) {
return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);
}
float dither(vec2 seed,float varianceAmount) {
float rand=getRand(seed);
float dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);
return dither;
}
const float rgbdMaxRange=255.0;
vec4 toRGBD(vec3 color) {
float maxRGB=maxEps(max(color.r,max(color.g,color.b)));
float D=max(rgbdMaxRange/maxRGB,1.);
D=clamp(floor(D)/255.0,0.,1.);
vec3 rgb=color.rgb*D;
rgb=toGammaSpace(rgb);
return vec4(clamp(rgb,0.,1.),D);
}
vec3 fromRGBD(vec4 rgbd) {
rgbd.rgb=toLinearSpace(rgbd.rgb);
return rgbd.rgb/rgbd.a;
}
vec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {
vec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;
vec3 halfSize=cubeSize*0.5;
vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;
vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;
vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);
float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);
vec3 intersectPositionWS=vertexPos+origVec*distance;
return intersectPositionWS-cubePos;
}
`;
ShaderStore.IncludesShadersStore[name$2I] = shader$2I;
var name$2H = "sceneVertexDeclaration"
, shader$2H = `uniform mat4 viewProjection;
#ifdef MULTIVIEW
uniform mat4 viewProjectionR;
#endif
uniform mat4 view;
uniform mat4 projection;
uniform vec4 vEyePosition;
`;
ShaderStore.IncludesShadersStore[name$2H] = shader$2H;
var name$2G = "meshVertexDeclaration"
, shader$2G = `uniform mat4 world;
uniform float visibility;
`;
ShaderStore.IncludesShadersStore[name$2G] = shader$2G;
var name$2F = "shadowMapVertexDeclaration"
, shader$2F = `#include
#include
`;
ShaderStore.IncludesShadersStore[name$2F] = shader$2F;
var name$2E = "sceneUboDeclaration"
, shader$2E = `layout(std140,column_major) uniform;
uniform Scene {
mat4 viewProjection;
#ifdef MULTIVIEW
mat4 viewProjectionR;
#endif
mat4 view;
mat4 projection;
vec4 vEyePosition;
};
`;
ShaderStore.IncludesShadersStore[name$2E] = shader$2E;
var name$2D = "meshUboDeclaration"
, shader$2D = `layout(std140,column_major) uniform;
uniform Mesh
{
mat4 world;
float visibility;
};
#define WORLD_UBO`;
ShaderStore.IncludesShadersStore[name$2D] = shader$2D;
var name$2C = "shadowMapUboDeclaration"
, shader$2C = `layout(std140,column_major) uniform;
#include
#include
`;
ShaderStore.IncludesShadersStore[name$2C] = shader$2C;
var name$2B = "shadowMapVertexExtraDeclaration"
, shader$2B = `#if SM_NORMALBIAS == 1
uniform vec3 lightDataSM;
#endif
uniform vec3 biasAndScaleSM;
uniform vec2 depthValuesSM;
varying float vDepthMetricSM;
#if SM_USEDISTANCE == 1
varying vec3 vPositionWSM;
#endif
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
varying float zSM;
#endif
`;
ShaderStore.IncludesShadersStore[name$2B] = shader$2B;
var name$2A = "clipPlaneVertexDeclaration"
, shader$2A = `#ifdef CLIPPLANE
uniform vec4 vClipPlane;
varying float fClipDistance;
#endif
#ifdef CLIPPLANE2
uniform vec4 vClipPlane2;
varying float fClipDistance2;
#endif
#ifdef CLIPPLANE3
uniform vec4 vClipPlane3;
varying float fClipDistance3;
#endif
#ifdef CLIPPLANE4
uniform vec4 vClipPlane4;
varying float fClipDistance4;
#endif
#ifdef CLIPPLANE5
uniform vec4 vClipPlane5;
varying float fClipDistance5;
#endif
#ifdef CLIPPLANE6
uniform vec4 vClipPlane6;
varying float fClipDistance6;
#endif`;
ShaderStore.IncludesShadersStore[name$2A] = shader$2A;
var name$2z = "morphTargetsVertexGlobal"
, shader$2z = `#ifdef MORPHTARGETS
#ifdef MORPHTARGETS_TEXTURE
float vertexID;
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$2z] = shader$2z;
var name$2y = "morphTargetsVertex"
, shader$2y = `#ifdef MORPHTARGETS
#ifdef MORPHTARGETS_TEXTURE
vertexID=float(gl_VertexID)*morphTargetTextureInfo.x;
positionUpdated+=(readVector3FromRawSampler({X},vertexID)-position)*morphTargetInfluences[{X}];
vertexID+=1.0;
#ifdef MORPHTARGETS_NORMAL
normalUpdated+=(readVector3FromRawSampler({X},vertexID)-normal)*morphTargetInfluences[{X}];
vertexID+=1.0;
#endif
#ifdef MORPHTARGETS_UV
uvUpdated+=(readVector3FromRawSampler({X},vertexID).xy-uv)*morphTargetInfluences[{X}];
vertexID+=1.0;
#endif
#ifdef MORPHTARGETS_TANGENT
tangentUpdated.xyz+=(readVector3FromRawSampler({X},vertexID)-tangent.xyz)*morphTargetInfluences[{X}];
#endif
#else
positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];
#ifdef MORPHTARGETS_NORMAL
normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];
#endif
#ifdef MORPHTARGETS_TANGENT
tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];
#endif
#ifdef MORPHTARGETS_UV
uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];
#endif
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$2y] = shader$2y;
var name$2x = "instancesVertex"
, shader$2x = `#ifdef INSTANCES
mat4 finalWorld=mat4(world0,world1,world2,world3);
#if defined(PREPASS_VELOCITY) || defined(VELOCITY)
mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,previousWorld2,previousWorld3);
#endif
#ifdef THIN_INSTANCES
finalWorld=world*finalWorld;
#if defined(PREPASS_VELOCITY) || defined(VELOCITY)
finalPreviousWorld=previousWorld*finalPreviousWorld;
#endif
#endif
#else
mat4 finalWorld=world;
#if defined(PREPASS_VELOCITY) || defined(VELOCITY)
mat4 finalPreviousWorld=previousWorld;
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$2x] = shader$2x;
var name$2w = "bonesVertex"
, shader$2w = `#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
#if NUM_BONE_INFLUENCERS>0
mat4 influence;
#ifdef BONETEXTURE
influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
#endif
#if NUM_BONE_INFLUENCERS>2
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
#endif
#if NUM_BONE_INFLUENCERS>3
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
#endif
#if NUM_BONE_INFLUENCERS>5
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
#endif
#if NUM_BONE_INFLUENCERS>6
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
#endif
#if NUM_BONE_INFLUENCERS>7
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
#endif
#else
influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
#endif
#if NUM_BONE_INFLUENCERS>2
influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
#endif
#if NUM_BONE_INFLUENCERS>3
influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
#endif
#if NUM_BONE_INFLUENCERS>5
influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
#endif
#if NUM_BONE_INFLUENCERS>6
influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
#endif
#if NUM_BONE_INFLUENCERS>7
influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
#endif
#endif
finalWorld=finalWorld*influence;
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$2w] = shader$2w;
var name$2v = "bakedVertexAnimation"
, shader$2v = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
{
#ifdef INSTANCES
#define BVASNAME bakedVertexAnimationSettingsInstanced
#else
#define BVASNAME bakedVertexAnimationSettings
#endif
float VATStartFrame=BVASNAME.x;
float VATEndFrame=BVASNAME.y;
float VATOffsetFrame=BVASNAME.z;
float VATSpeed=BVASNAME.w;
float totalFrames=VATEndFrame-VATStartFrame+1.0;
#ifdef INSTANCES
float time=bakedVertexAnimationTimeInstanced*VATSpeed/totalFrames;
#else
float time=bakedVertexAnimationTime*VATSpeed/totalFrames;
#endif
float frameCorrection=time<1.0 ? 0.0 : 1.0;
float numOfFrames=totalFrames-frameCorrection;
float VATFrameNum=fract(time)*numOfFrames;
VATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);
VATFrameNum=floor(VATFrameNum);
VATFrameNum+=VATStartFrame+frameCorrection;
mat4 VATInfluence;
VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
#endif
#if NUM_BONE_INFLUENCERS>2
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
#endif
#if NUM_BONE_INFLUENCERS>3
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
#endif
#if NUM_BONE_INFLUENCERS>5
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
#endif
#if NUM_BONE_INFLUENCERS>6
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
#endif
#if NUM_BONE_INFLUENCERS>7
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
#endif
finalWorld=finalWorld*VATInfluence;
}
#endif`;
ShaderStore.IncludesShadersStore[name$2v] = shader$2v;
var name$2u = "shadowMapVertexNormalBias"
, shader$2u = `
#if SM_NORMALBIAS == 1
#if SM_DIRECTIONINLIGHTDATA == 1
vec3 worldLightDirSM=normalize(-lightDataSM.xyz);
#else
vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;
vec3 worldLightDirSM=normalize(directionToLightSM);
#endif
float ndlSM=dot(vNormalW,worldLightDirSM);
float sinNLSM=sqrt(1.0-ndlSM*ndlSM);
float normalBiasSM=biasAndScaleSM.y*sinNLSM;
worldPos.xyz-=vNormalW*normalBiasSM;
#endif
`;
ShaderStore.IncludesShadersStore[name$2u] = shader$2u;
var name$2t = "shadowMapVertexMetric"
, shader$2t = `#if SM_USEDISTANCE == 1
vPositionWSM=worldPos.xyz;
#endif
#if SM_DEPTHTEXTURE == 1
#ifdef IS_NDC_HALF_ZRANGE
#define BIASFACTOR 0.5
#else
#define BIASFACTOR 1.0
#endif
#ifdef USE_REVERSE_DEPTHBUFFER
gl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
#else
gl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
#endif
#endif
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
zSM=gl_Position.z;
gl_Position.z=0.0;
#elif SM_USEDISTANCE == 0
#ifdef USE_REVERSE_DEPTHBUFFER
vDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#else
vDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
#endif
#endif
`;
ShaderStore.IncludesShadersStore[name$2t] = shader$2t;
var name$2s = "clipPlaneVertex"
, shader$2s = `#ifdef CLIPPLANE
fClipDistance=dot(worldPos,vClipPlane);
#endif
#ifdef CLIPPLANE2
fClipDistance2=dot(worldPos,vClipPlane2);
#endif
#ifdef CLIPPLANE3
fClipDistance3=dot(worldPos,vClipPlane3);
#endif
#ifdef CLIPPLANE4
fClipDistance4=dot(worldPos,vClipPlane4);
#endif
#ifdef CLIPPLANE5
fClipDistance5=dot(worldPos,vClipPlane5);
#endif
#ifdef CLIPPLANE6
fClipDistance6=dot(worldPos,vClipPlane6);
#endif`;
ShaderStore.IncludesShadersStore[name$2s] = shader$2s;
var name$2r = "shadowMapVertexShader"
, shader$2r = `
attribute vec3 position;
#ifdef NORMAL
attribute vec3 normal;
#endif
#include
#include
#include
#include[0..maxSimultaneousMorphTargets]
#ifdef INSTANCES
attribute vec4 world0;
attribute vec4 world1;
attribute vec4 world2;
attribute vec4 world3;
#endif
#include
#include<__decl__shadowMapVertex>
#ifdef ALPHATEST
varying vec2 vUV;
uniform mat4 diffuseMatrix;
#ifdef UV1
attribute vec2 uv;
#endif
#ifdef UV2
attribute vec2 uv2;
#endif
#endif
#include
#include
void main(void)
{
vec3 positionUpdated=position;
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#ifdef NORMAL
vec3 normalUpdated=normal;
#endif
#include
#include[0..maxSimultaneousMorphTargets]
#include
#include
#include
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
#ifdef NORMAL
mat3 normWorldSM=mat3(finalWorld);
#if defined(INSTANCES) && defined(THIN_INSTANCES)
vec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));
vNormalW=normalize(normWorldSM*vNormalW);
#else
#ifdef NONUNIFORMSCALING
normWorldSM=transposeMat3(inverseMat3(normWorldSM));
#endif
vec3 vNormalW=normalize(normWorldSM*normalUpdated);
#endif
#endif
#include
gl_Position=viewProjection*worldPos;
#include
#ifdef ALPHATEST
#ifdef UV1
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
#endif
#ifdef UV2
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
#endif
#endif
#include
}`;
ShaderStore.ShadersStore[name$2r] = shader$2r;
var name$2q = "depthBoxBlurPixelShader"
, shader$2q = `
varying vec2 vUV;
uniform sampler2D textureSampler;
uniform vec2 screenSize;
void main(void)
{
vec4 colorDepth=vec4(0.0);
for (int x=-OFFSET; x<=OFFSET; x++)
for (int y=-OFFSET; y<=OFFSET; y++)
colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);
gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));
}`;
ShaderStore.ShadersStore[name$2q] = shader$2q;
var name$2p = "shadowMapFragmentSoftTransparentShadow"
, shader$2p = `#if SM_SOFTTRANSPARENTSHADOW == 1
if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;
#endif
`;
ShaderStore.IncludesShadersStore[name$2p] = shader$2p;
var ShadowGenerator = function() {
function i(e, t, r) {
this.onBeforeShadowMapRenderObservable = new Observable,
this.onAfterShadowMapRenderObservable = new Observable,
this.onBeforeShadowMapRenderMeshObservable = new Observable,
this.onAfterShadowMapRenderMeshObservable = new Observable,
this._bias = 5e-5,
this._normalBias = 0,
this._blurBoxOffset = 1,
this._blurScale = 2,
this._blurKernel = 1,
this._useKernelBlur = !1,
this._filter = i.FILTER_NONE,
this._filteringQuality = i.QUALITY_HIGH,
this._contactHardeningLightSizeUVRatio = .1,
this._darkness = 0,
this._transparencyShadow = !1,
this.enableSoftTransparentShadow = !1,
this.frustumEdgeFalloff = 0,
this.forceBackFacesOnly = !1,
this._lightDirection = Vector3.Zero(),
this._viewMatrix = Matrix.Zero(),
this._projectionMatrix = Matrix.Zero(),
this._transformMatrix = Matrix.Zero(),
this._cachedPosition = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._cachedDirection = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._currentFaceIndex = 0,
this._currentFaceIndexCache = 0,
this._defaultTextureMatrix = Matrix.Identity(),
this._mapSize = e,
this._light = t,
this._scene = t.getScene(),
t._shadowGenerator = this,
this.id = t.id,
this._useUBO = this._scene.getEngine().supportsUniformBuffers,
this._useUBO && (this._sceneUBOs = [],
this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for Shadow Generator (light "' + this._light.name + '")'))),
i._SceneComponentInitialization(this._scene);
var n = this._scene.getEngine().getCaps();
r ? n.textureFloatRender && n.textureFloatLinearFiltering ? this._textureType = 1 : n.textureHalfFloatRender && n.textureHalfFloatLinearFiltering ? this._textureType = 2 : this._textureType = 0 : n.textureHalfFloatRender && n.textureHalfFloatLinearFiltering ? this._textureType = 2 : n.textureFloatRender && n.textureFloatLinearFiltering ? this._textureType = 1 : this._textureType = 0,
this._initializeGenerator(),
this._applyFilterValues()
}
return Object.defineProperty(i.prototype, "bias", {
get: function() {
return this._bias
},
set: function(e) {
this._bias = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "normalBias", {
get: function() {
return this._normalBias
},
set: function(e) {
this._normalBias = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "blurBoxOffset", {
get: function() {
return this._blurBoxOffset
},
set: function(e) {
this._blurBoxOffset !== e && (this._blurBoxOffset = e,
this._disposeBlurPostProcesses())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "blurScale", {
get: function() {
return this._blurScale
},
set: function(e) {
this._blurScale !== e && (this._blurScale = e,
this._disposeBlurPostProcesses())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "blurKernel", {
get: function() {
return this._blurKernel
},
set: function(e) {
this._blurKernel !== e && (this._blurKernel = e,
this._disposeBlurPostProcesses())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "useKernelBlur", {
get: function() {
return this._useKernelBlur
},
set: function(e) {
this._useKernelBlur !== e && (this._useKernelBlur = e,
this._disposeBlurPostProcesses())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "depthScale", {
get: function() {
return this._depthScale !== void 0 ? this._depthScale : this._light.getDepthScale()
},
set: function(e) {
this._depthScale = e
},
enumerable: !1,
configurable: !0
}),
i.prototype._validateFilter = function(e) {
return e
}
,
Object.defineProperty(i.prototype, "filter", {
get: function() {
return this._filter
},
set: function(e) {
if (e = this._validateFilter(e),
this._light.needCube()) {
if (e === i.FILTER_BLUREXPONENTIALSHADOWMAP) {
this.useExponentialShadowMap = !0;
return
} else if (e === i.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
this.useCloseExponentialShadowMap = !0;
return
} else if (e === i.FILTER_PCF || e === i.FILTER_PCSS) {
this.usePoissonSampling = !0;
return
}
}
if ((e === i.FILTER_PCF || e === i.FILTER_PCSS) && !this._scene.getEngine()._features.supportShadowSamplers) {
this.usePoissonSampling = !0;
return
}
this._filter !== e && (this._filter = e,
this._disposeBlurPostProcesses(),
this._applyFilterValues(),
this._light._markMeshesAsLightDirty())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "usePoissonSampling", {
get: function() {
return this.filter === i.FILTER_POISSONSAMPLING
},
set: function(e) {
var t = this._validateFilter(i.FILTER_POISSONSAMPLING);
!e && this.filter !== i.FILTER_POISSONSAMPLING || (this.filter = e ? t : i.FILTER_NONE)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "useExponentialShadowMap", {
get: function() {
return this.filter === i.FILTER_EXPONENTIALSHADOWMAP
},
set: function(e) {
var t = this._validateFilter(i.FILTER_EXPONENTIALSHADOWMAP);
!e && this.filter !== i.FILTER_EXPONENTIALSHADOWMAP || (this.filter = e ? t : i.FILTER_NONE)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "useBlurExponentialShadowMap", {
get: function() {
return this.filter === i.FILTER_BLUREXPONENTIALSHADOWMAP
},
set: function(e) {
var t = this._validateFilter(i.FILTER_BLUREXPONENTIALSHADOWMAP);
!e && this.filter !== i.FILTER_BLUREXPONENTIALSHADOWMAP || (this.filter = e ? t : i.FILTER_NONE)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "useCloseExponentialShadowMap", {
get: function() {
return this.filter === i.FILTER_CLOSEEXPONENTIALSHADOWMAP
},
set: function(e) {
var t = this._validateFilter(i.FILTER_CLOSEEXPONENTIALSHADOWMAP);
!e && this.filter !== i.FILTER_CLOSEEXPONENTIALSHADOWMAP || (this.filter = e ? t : i.FILTER_NONE)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "useBlurCloseExponentialShadowMap", {
get: function() {
return this.filter === i.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP
},
set: function(e) {
var t = this._validateFilter(i.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);
!e && this.filter !== i.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP || (this.filter = e ? t : i.FILTER_NONE)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "usePercentageCloserFiltering", {
get: function() {
return this.filter === i.FILTER_PCF
},
set: function(e) {
var t = this._validateFilter(i.FILTER_PCF);
!e && this.filter !== i.FILTER_PCF || (this.filter = e ? t : i.FILTER_NONE)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.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(i.prototype, "useContactHardeningShadow", {
get: function() {
return this.filter === i.FILTER_PCSS
},
set: function(e) {
var t = this._validateFilter(i.FILTER_PCSS);
!e && this.filter !== i.FILTER_PCSS || (this.filter = e ? t : i.FILTER_NONE)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "contactHardeningLightSizeUVRatio", {
get: function() {
return this._contactHardeningLightSizeUVRatio
},
set: function(e) {
this._contactHardeningLightSizeUVRatio = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "darkness", {
get: function() {
return this._darkness
},
set: function(e) {
this.setDarkness(e)
},
enumerable: !1,
configurable: !0
}),
i.prototype.getDarkness = function() {
return this._darkness
}
,
i.prototype.setDarkness = function(e) {
return e >= 1 ? this._darkness = 1 : e <= 0 ? this._darkness = 0 : this._darkness = e,
this
}
,
Object.defineProperty(i.prototype, "transparencyShadow", {
get: function() {
return this._transparencyShadow
},
set: function(e) {
this.setTransparencyShadow(e)
},
enumerable: !1,
configurable: !0
}),
i.prototype.setTransparencyShadow = function(e) {
return this._transparencyShadow = e,
this
}
,
i.prototype.getShadowMap = function() {
return this._shadowMap
}
,
i.prototype.getShadowMapForRendering = function() {
return this._shadowMap2 ? this._shadowMap2 : this._shadowMap
}
,
i.prototype.getClassName = function() {
return i.CLASSNAME
}
,
i.prototype.addShadowCaster = function(e, t) {
if (t === void 0 && (t = !0),
!this._shadowMap)
return this;
if (this._shadowMap.renderList || (this._shadowMap.renderList = []),
this._shadowMap.renderList.indexOf(e) === -1 && this._shadowMap.renderList.push(e),
t)
for (var r = 0, n = e.getChildMeshes(); r < n.length; r++) {
var o = n[r];
this._shadowMap.renderList.indexOf(o) === -1 && this._shadowMap.renderList.push(o)
}
return this
}
,
i.prototype.removeShadowCaster = function(e, t) {
if (t === void 0 && (t = !0),
!this._shadowMap || !this._shadowMap.renderList)
return this;
var r = this._shadowMap.renderList.indexOf(e);
if (r !== -1 && this._shadowMap.renderList.splice(r, 1),
t)
for (var n = 0, o = e.getChildren(); n < o.length; n++) {
var a = o[n];
this.removeShadowCaster(a)
}
return this
}
,
i.prototype.getLight = function() {
return this._light
}
,
Object.defineProperty(i.prototype, "mapSize", {
get: function() {
return this._mapSize
},
set: function(e) {
this._mapSize = e,
this._light._markMeshesAsLightDirty(),
this.recreateShadowMap()
},
enumerable: !1,
configurable: !0
}),
i.prototype._initializeGenerator = function() {
this._light._markMeshesAsLightDirty(),
this._initializeShadowMap()
}
,
i.prototype._createTargetRenderTexture = function() {
var e = this._scene.getEngine();
e._features.supportDepthStencilTexture ? (this._shadowMap = new RenderTargetTexture(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),
this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? 516 : 513, !0)) : this._shadowMap = new RenderTargetTexture(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())
}
,
i.prototype._initializeShadowMap = function() {
var e = this;
if (this._createTargetRenderTexture(),
this._shadowMap !== null) {
this._shadowMap.wrapU = Texture.CLAMP_ADDRESSMODE,
this._shadowMap.wrapV = Texture.CLAMP_ADDRESSMODE,
this._shadowMap.anisotropicFilteringLevel = 1,
this._shadowMap.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE),
this._shadowMap.renderParticles = !1,
this._shadowMap.ignoreCameraViewport = !0,
this._storedUniqueId && (this._shadowMap.uniqueId = this._storedUniqueId),
this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this),
this._shadowMap.customIsReadyFunction = function(a, s) {
return !0
}
;
var t = this._scene.getEngine();
this._shadowMap.onBeforeBindObservable.add(function() {
var a;
e._currentSceneUBO = e._scene.getSceneUniformBuffer(),
(a = t._debugPushGroup) === null || a === void 0 || a.call(t, "shadow map generation for pass id " + t.currentRenderPassId, 1)
}),
this._shadowMap.onBeforeRenderObservable.add(function(a) {
e._sceneUBOs && e._scene.setSceneUniformBuffer(e._sceneUBOs[0]),
e._currentFaceIndex = a,
e._filter === i.FILTER_PCF && t.setColorWrite(!1),
e.getTransformMatrix(),
e._scene.setTransformMatrix(e._viewMatrix, e._projectionMatrix),
e._useUBO && (e._scene.getSceneUniformBuffer().unbindEffect(),
e._scene.finalizeSceneUbo())
}),
this._shadowMap.onAfterUnbindObservable.add(function() {
var a, s;
if (e._sceneUBOs && e._scene.setSceneUniformBuffer(e._currentSceneUBO),
e._scene.updateTransformMatrix(),
e._filter === i.FILTER_PCF && t.setColorWrite(!0),
!e.useBlurExponentialShadowMap && !e.useBlurCloseExponentialShadowMap) {
(a = t._debugPopGroup) === null || a === void 0 || a.call(t, 1);
return
}
var l = e.getShadowMapForRendering();
l && (e._scene.postProcessManager.directRender(e._blurPostProcesses, l.renderTarget, !0),
t.unBindFramebuffer(l.renderTarget, !0),
(s = t._debugPopGroup) === null || s === void 0 || s.call(t, 1))
});
var r = new Color4(0,0,0,0)
, n = new Color4(1,1,1,1);
this._shadowMap.onClearObservable.add(function(a) {
e._filter === i.FILTER_PCF ? a.clear(n, !1, !0, !1) : e.useExponentialShadowMap || e.useBlurExponentialShadowMap ? a.clear(r, !0, !0, !1) : a.clear(n, !0, !0, !1)
}),
this._shadowMap.onResizeObservable.add(function(a) {
e._storedUniqueId = e._shadowMap.uniqueId,
e._mapSize = a.getRenderSize(),
e._light._markMeshesAsLightDirty(),
e.recreateShadowMap()
});
for (var o = RenderingManager.MIN_RENDERINGGROUPS; o < RenderingManager.MAX_RENDERINGGROUPS; o++)
this._shadowMap.setRenderingAutoClearDepthStencil(o, !1)
}
}
,
i.prototype._initializeBlurRTTAndPostProcesses = function() {
var e = this
, t = this._scene.getEngine()
, r = this._mapSize / this.blurScale;
(!this.useKernelBlur || this.blurScale !== 1) && (this._shadowMap2 = new RenderTargetTexture(this._light.name + "_shadowMap2",r,this._scene,!1,!0,this._textureType,void 0,void 0,!1),
this._shadowMap2.wrapU = Texture.CLAMP_ADDRESSMODE,
this._shadowMap2.wrapV = Texture.CLAMP_ADDRESSMODE,
this._shadowMap2.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE)),
this.useKernelBlur ? (this._kernelBlurXPostprocess = new BlurPostProcess(this._light.name + "KernelBlurX",new Vector2(1,0),this.blurKernel,1,null,Texture.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),
this._kernelBlurXPostprocess.width = r,
this._kernelBlurXPostprocess.height = r,
this._kernelBlurXPostprocess.externalTextureSamplerBinding = !0,
this._kernelBlurXPostprocess.onApplyObservable.add(function(n) {
n.setTexture("textureSampler", e._shadowMap)
}),
this._kernelBlurYPostprocess = new BlurPostProcess(this._light.name + "KernelBlurY",new Vector2(0,1),this.blurKernel,1,null,Texture.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),
this._kernelBlurXPostprocess.autoClear = !1,
this._kernelBlurYPostprocess.autoClear = !1,
this._textureType === 0 && (this._kernelBlurXPostprocess.packedFloat = !0,
this._kernelBlurYPostprocess.packedFloat = !0),
this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess]) : (this._boxBlurPostprocess = new PostProcess(this._light.name + "DepthBoxBlur","depthBoxBlur",["screenSize", "boxOffset"],[],1,null,Texture.BILINEAR_SAMPLINGMODE,t,!1,"#define OFFSET " + this._blurBoxOffset,this._textureType),
this._boxBlurPostprocess.externalTextureSamplerBinding = !0,
this._boxBlurPostprocess.onApplyObservable.add(function(n) {
n.setFloat2("screenSize", r, r),
n.setTexture("textureSampler", e._shadowMap)
}),
this._boxBlurPostprocess.autoClear = !1,
this._blurPostProcesses = [this._boxBlurPostprocess])
}
,
i.prototype._renderForShadowMap = function(e, t, r, n) {
var o;
if (n.length)
for (o = 0; o < n.length; o++)
this._renderSubMeshForShadowMap(n.data[o]);
for (o = 0; o < e.length; o++)
this._renderSubMeshForShadowMap(e.data[o]);
for (o = 0; o < t.length; o++)
this._renderSubMeshForShadowMap(t.data[o]);
if (this._transparencyShadow)
for (o = 0; o < r.length; o++)
this._renderSubMeshForShadowMap(r.data[o], !0);
else
for (o = 0; o < r.length; o++)
r.data[o].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
}
,
i.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, t, r) {
t.setMatrix("viewProjection", this.getTransformMatrix())
}
,
i.prototype._renderSubMeshForShadowMap = function(e, t) {
var r, n;
t === void 0 && (t = !1);
var o = e.getRenderingMesh()
, a = e.getEffectiveMesh()
, s = this._scene
, l = s.getEngine()
, u = e.getMaterial();
if (a._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
!(!u || e.verticesCount === 0 || e._renderId === s.getRenderId())) {
var c = a._getWorldMatrixDeterminant() < 0
, h = (r = o.overrideMaterialSideOrientation) !== null && r !== void 0 ? r : u.sideOrientation;
(s.useRightHandedSystem && !c || !s.useRightHandedSystem && c) && (h = h === 0 ? 1 : 0);
var f = h === 0;
l.setState(u.backFaceCulling, void 0, void 0, f, u.cullBackFaces);
var d = o._getInstancesRenderList(e._id, !!e.getReplacementMesh());
if (!d.mustReturn) {
var _ = l.getCaps().instancedArrays && (d.visibleInstances[e._id] !== null && d.visibleInstances[e._id] !== void 0 || o.hasThinInstances);
if (!(this.customAllowRendering && !this.customAllowRendering(e)))
if (this.isReady(e, _, t)) {
e._renderId = s.getRenderId();
var g = u.shadowDepthWrapper
, m = (n = g == null ? void 0 : g.getEffect(e, this, l.currentRenderPassId)) !== null && n !== void 0 ? n : e._getDrawWrapper()
, v = DrawWrapper.GetEffect(m);
if (l.enableEffect(m),
_ || o._bind(e, v, u.fillMode),
this.getTransformMatrix(),
v.setFloat3("biasAndScaleSM", this.bias, this.normalBias, this.depthScale),
this.getLight().getTypeID() === Light.LIGHTTYPEID_DIRECTIONALLIGHT ? v.setVector3("lightDataSM", this._cachedDirection) : v.setVector3("lightDataSM", this._cachedPosition),
s.activeCamera && v.setFloat2("depthValuesSM", this.getLight().getDepthMinZ(s.activeCamera), this.getLight().getDepthMinZ(s.activeCamera) + this.getLight().getDepthMaxZ(s.activeCamera)),
t && this.enableSoftTransparentShadow && v.setFloat("softTransparentShadowSM", a.visibility * u.alpha),
g)
e._setMainDrawWrapperOverride(m),
g.standalone ? g.baseMaterial.bindForSubMesh(a.getWorldMatrix(), o, e) : u.bindForSubMesh(a.getWorldMatrix(), o, e),
e._setMainDrawWrapperOverride(null);
else {
if (u && u.needAlphaTesting()) {
var y = u.getAlphaTestTexture();
y && (v.setTexture("diffuseSampler", y),
v.setMatrix("diffuseMatrix", y.getTextureMatrix() || this._defaultTextureMatrix))
}
if (o.useBones && o.computeBonesUsingShaders && o.skeleton) {
var b = o.skeleton;
if (b.isUsingTextureForMatrices) {
var T = b.getTransformMatrixTexture(o);
if (!T)
return;
v.setTexture("boneSampler", T),
v.setFloat("boneTextureWidth", 4 * (b.bones.length + 1))
} else
v.setMatrices("mBones", b.getTransformMatrices(o))
}
MaterialHelper.BindMorphTargetParameters(o, v),
o.morphTargetManager && o.morphTargetManager.isUsingTextureForTargets && o.morphTargetManager._bind(v),
MaterialHelper.BindClipPlane(v, s)
}
!this._useUBO && !g && this._bindCustomEffectForRenderSubMeshForShadowMap(e, v, a),
MaterialHelper.BindSceneUniformBuffer(v, this._scene.getSceneUniformBuffer()),
this._scene.getSceneUniformBuffer().bindUniformBuffer();
var C = a.getWorldMatrix();
_ && (a.getMeshUniformBuffer().bindToEffect(v, "Mesh"),
a.transferToEffect(C)),
this.forceBackFacesOnly && l.setState(!0, 0, !1, !0, u.cullBackFaces),
this.onBeforeShadowMapRenderMeshObservable.notifyObservers(o),
this.onBeforeShadowMapRenderObservable.notifyObservers(v),
o._processRendering(a, e, v, u.fillMode, d, _, function(A, S, P, R) {
R && a !== R ? (R.getMeshUniformBuffer().bindToEffect(v, "Mesh"),
R.transferToEffect(S)) : (a.getMeshUniformBuffer().bindToEffect(v, "Mesh"),
a.transferToEffect(C))
}),
this.forceBackFacesOnly && l.setState(!0, 0, !1, !1, u.cullBackFaces),
this.onAfterShadowMapRenderObservable.notifyObservers(v),
this.onAfterShadowMapRenderMeshObservable.notifyObservers(o)
} else
this._shadowMap && this._shadowMap.resetRefreshCounter()
}
}
}
,
i.prototype._applyFilterValues = function() {
!this._shadowMap || (this.filter === i.FILTER_NONE || this.filter === i.FILTER_PCSS ? this._shadowMap.updateSamplingMode(Texture.NEAREST_SAMPLINGMODE) : this._shadowMap.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE))
}
,
i.prototype.forceCompilation = function(e, t) {
var r = this
, n = __assign({
useInstances: !1
}, t)
, o = this.getShadowMap();
if (!o) {
e && e(this);
return
}
var a = o.renderList;
if (!a) {
e && e(this);
return
}
for (var s = new Array, l = 0, u = a; l < u.length; l++) {
var c = u[l];
s.push.apply(s, c.subMeshes)
}
if (s.length === 0) {
e && e(this);
return
}
var h = 0
, f = function() {
var d, _;
if (!(!r._scene || !r._scene.getEngine())) {
for (; r.isReady(s[h], n.useInstances, (_ = (d = s[h].getMaterial()) === null || d === void 0 ? void 0 : d.needAlphaBlendingForMesh(s[h].getMesh())) !== null && _ !== void 0 ? _ : !1); )
if (h++,
h >= s.length) {
e && e(r);
return
}
setTimeout(f, 16)
}
};
f()
}
,
i.prototype.forceCompilationAsync = function(e) {
var t = this;
return new Promise(function(r) {
t.forceCompilation(function() {
r()
}, e)
}
)
}
,
i.prototype._isReadyCustomDefines = function(e, t, r) {}
,
i.prototype._prepareShadowDefines = function(e, t, r, n) {
r.push("#define SM_FLOAT " + (this._textureType !== 0 ? "1" : "0")),
r.push("#define SM_ESM " + (this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? "1" : "0")),
r.push("#define SM_DEPTHTEXTURE " + (this.usePercentageCloserFiltering || this.useContactHardeningShadow ? "1" : "0"));
var o = e.getMesh();
return r.push("#define SM_NORMALBIAS " + (this.normalBias && o.isVerticesDataPresent(VertexBuffer.NormalKind) ? "1" : "0")),
r.push("#define SM_DIRECTIONINLIGHTDATA " + (this.getLight().getTypeID() === Light.LIGHTTYPEID_DIRECTIONALLIGHT ? "1" : "0")),
r.push("#define SM_USEDISTANCE " + (this._light.needCube() ? "1" : "0")),
r.push("#define SM_SOFTTRANSPARENTSHADOW " + (this.enableSoftTransparentShadow && n ? "1" : "0")),
this._isReadyCustomDefines(r, e, t),
r
}
,
i.prototype.isReady = function(e, t, r) {
var n = e.getMaterial()
, o = n == null ? void 0 : n.shadowDepthWrapper
, a = [];
if (this._prepareShadowDefines(e, t, a, r),
o) {
if (!o.isReadyForSubMesh(e, a, this, t, this._scene.getEngine().currentRenderPassId))
return !1
} else {
var s = e._getDrawWrapper(void 0, !0)
, l = s.effect
, u = s.defines
, c = [VertexBuffer.PositionKind]
, h = e.getMesh();
if (this.normalBias && h.isVerticesDataPresent(VertexBuffer.NormalKind) && (c.push(VertexBuffer.NormalKind),
a.push("#define NORMAL"),
h.nonUniformScaling && a.push("#define NONUNIFORMSCALING")),
n && n.needAlphaTesting()) {
var f = n.getAlphaTestTexture();
if (f) {
if (!f.isReady())
return !1;
a.push("#define ALPHATEST"),
h.isVerticesDataPresent(VertexBuffer.UVKind) && (c.push(VertexBuffer.UVKind),
a.push("#define UV1")),
h.isVerticesDataPresent(VertexBuffer.UV2Kind) && f.coordinatesIndex === 1 && (c.push(VertexBuffer.UV2Kind),
a.push("#define UV2"))
}
}
var d = new EffectFallbacks;
if (h.useBones && h.computeBonesUsingShaders && h.skeleton) {
c.push(VertexBuffer.MatricesIndicesKind),
c.push(VertexBuffer.MatricesWeightsKind),
h.numBoneInfluencers > 4 && (c.push(VertexBuffer.MatricesIndicesExtraKind),
c.push(VertexBuffer.MatricesWeightsExtraKind));
var _ = h.skeleton;
a.push("#define NUM_BONE_INFLUENCERS " + h.numBoneInfluencers),
h.numBoneInfluencers > 0 && d.addCPUSkinningFallback(0, h),
_.isUsingTextureForMatrices ? a.push("#define BONETEXTURE") : a.push("#define BonesPerMesh " + (_.bones.length + 1))
} else
a.push("#define NUM_BONE_INFLUENCERS 0");
var g = h.morphTargetManager
, m = 0;
g && g.numInfluencers > 0 && (a.push("#define MORPHTARGETS"),
m = g.numInfluencers,
a.push("#define NUM_MORPH_INFLUENCERS " + m),
g.isUsingTextureForTargets && a.push("#define MORPHTARGETS_TEXTURE"),
MaterialHelper.PrepareAttributesForMorphTargetsInfluencers(c, h, m));
var v = this._scene;
if (v.clipPlane && a.push("#define CLIPPLANE"),
v.clipPlane2 && a.push("#define CLIPPLANE2"),
v.clipPlane3 && a.push("#define CLIPPLANE3"),
v.clipPlane4 && a.push("#define CLIPPLANE4"),
v.clipPlane5 && a.push("#define CLIPPLANE5"),
v.clipPlane6 && a.push("#define CLIPPLANE6"),
t && (a.push("#define INSTANCES"),
MaterialHelper.PushAttributesForInstances(c),
e.getRenderingMesh().hasThinInstances && a.push("#define THIN_INSTANCES")),
this.customShaderOptions && this.customShaderOptions.defines)
for (var y = 0, b = this.customShaderOptions.defines; y < b.length; y++) {
var T = b[y];
a.indexOf(T) === -1 && a.push(T)
}
var C = a.join(`
`);
if (u !== C) {
u = C;
var A = "shadowMap"
, S = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightDataSM", "depthValuesSM", "biasAndScaleSM", "morphTargetInfluences", "boneTextureWidth", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "softTransparentShadowSM", "morphTargetTextureInfo", "morphTargetTextureIndices"]
, P = ["diffuseSampler", "boneSampler", "morphTargets"]
, R = ["Scene", "Mesh"];
if (this.customShaderOptions) {
if (A = this.customShaderOptions.shaderName,
this.customShaderOptions.attributes)
for (var M = 0, x = this.customShaderOptions.attributes; M < x.length; M++) {
var I = x[M];
c.indexOf(I) === -1 && c.push(I)
}
if (this.customShaderOptions.uniforms)
for (var w = 0, O = this.customShaderOptions.uniforms; w < O.length; w++) {
var D = O[w];
S.indexOf(D) === -1 && S.push(D)
}
if (this.customShaderOptions.samplers)
for (var F = 0, V = this.customShaderOptions.samplers; F < V.length; F++) {
var N = V[F];
P.indexOf(N) === -1 && P.push(N)
}
}
var L = this._scene.getEngine();
l = L.createEffect(A, {
attributes: c,
uniformsNames: S,
uniformBuffersNames: R,
samplers: P,
defines: C,
fallbacks: d,
onCompiled: null,
onError: null,
indexParameters: {
maxSimultaneousMorphTargets: m
}
}, L),
s.setEffect(l, u)
}
if (!l.isReady())
return !1
}
return (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (!this._blurPostProcesses || !this._blurPostProcesses.length) && this._initializeBlurRTTAndPostProcesses(),
!(this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady() || this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady() || this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady())
}
,
i.prototype.prepareDefines = function(e, t) {
var r = this._scene
, n = this._light;
!r.shadowsEnabled || !n.shadowEnabled || (e["SHADOW" + t] = !0,
this.useContactHardeningShadow ? (e["SHADOWPCSS" + t] = !0,
this._filteringQuality === i.QUALITY_LOW ? e["SHADOWLOWQUALITY" + t] = !0 : this._filteringQuality === i.QUALITY_MEDIUM && (e["SHADOWMEDIUMQUALITY" + t] = !0)) : this.usePercentageCloserFiltering ? (e["SHADOWPCF" + t] = !0,
this._filteringQuality === i.QUALITY_LOW ? e["SHADOWLOWQUALITY" + t] = !0 : this._filteringQuality === i.QUALITY_MEDIUM && (e["SHADOWMEDIUMQUALITY" + t] = !0)) : this.usePoissonSampling ? e["SHADOWPOISSON" + t] = !0 : this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? e["SHADOWESM" + t] = !0 : (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (e["SHADOWCLOSEESM" + t] = !0),
n.needCube() && (e["SHADOWCUBE" + t] = !0))
}
,
i.prototype.bindShadowLight = function(e, t) {
var r = this._light
, n = this._scene;
if (!(!n.shadowsEnabled || !r.shadowEnabled)) {
var o = n.activeCamera;
if (!!o) {
var a = this.getShadowMap();
!a || (r.needCube() || t.setMatrix("lightMatrix" + e, this.getTransformMatrix()),
this._filter === i.FILTER_PCF ? (t.setDepthStencilTexture("shadowSampler" + e, this.getShadowMapForRendering()),
r._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a.getSize().width, 1 / a.getSize().width, this.frustumEdgeFalloff, e)) : this._filter === i.FILTER_PCSS ? (t.setDepthStencilTexture("shadowSampler" + e, this.getShadowMapForRendering()),
t.setTexture("depthSampler" + e, this.getShadowMapForRendering()),
r._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / a.getSize().width, this._contactHardeningLightSizeUVRatio * a.getSize().width, this.frustumEdgeFalloff, e)) : (t.setTexture("shadowSampler" + e, this.getShadowMapForRendering()),
r._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / a.getSize().width, this.depthScale, this.frustumEdgeFalloff, e)),
r._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(o), this.getLight().getDepthMinZ(o) + this.getLight().getDepthMaxZ(o), e))
}
}
}
,
i.prototype.getTransformMatrix = function() {
var e = this._scene;
if (this._currentRenderId === e.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex)
return this._transformMatrix;
this._currentRenderId = e.getRenderId(),
this._currentFaceIndexCache = this._currentFaceIndex;
var t = this._light.position;
if (this._light.computeTransformedInformation() && (t = this._light.transformedPosition),
Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection),
Math.abs(Vector3.Dot(this._lightDirection, Vector3.Up())) === 1 && (this._lightDirection.z = 1e-13),
this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !t.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
this._cachedPosition.copyFrom(t),
this._cachedDirection.copyFrom(this._lightDirection),
Matrix.LookAtLHToRef(t, t.add(this._lightDirection), Vector3.Up(), this._viewMatrix);
var r = this.getShadowMap();
if (r) {
var n = r.renderList;
n && this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, n)
}
this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix)
}
return this._transformMatrix
}
,
i.prototype.recreateShadowMap = function() {
var e = this._shadowMap;
if (!!e) {
var t = e.renderList;
if (this._disposeRTTandPostProcesses(),
this._initializeGenerator(),
this.filter = this.filter,
this._applyFilterValues(),
t) {
this._shadowMap.renderList || (this._shadowMap.renderList = []);
for (var r = 0, n = t; r < n.length; r++) {
var o = n[r];
this._shadowMap.renderList.push(o)
}
} else
this._shadowMap.renderList = null
}
}
,
i.prototype._disposeBlurPostProcesses = function() {
this._shadowMap2 && (this._shadowMap2.dispose(),
this._shadowMap2 = null),
this._boxBlurPostprocess && (this._boxBlurPostprocess.dispose(),
this._boxBlurPostprocess = null),
this._kernelBlurXPostprocess && (this._kernelBlurXPostprocess.dispose(),
this._kernelBlurXPostprocess = null),
this._kernelBlurYPostprocess && (this._kernelBlurYPostprocess.dispose(),
this._kernelBlurYPostprocess = null),
this._blurPostProcesses = []
}
,
i.prototype._disposeRTTandPostProcesses = function() {
this._shadowMap && (this._shadowMap.dispose(),
this._shadowMap = null),
this._disposeBlurPostProcesses()
}
,
i.prototype._disposeSceneUBOs = function() {
if (this._sceneUBOs) {
for (var e = 0, t = this._sceneUBOs; e < t.length; e++) {
var r = t[e];
r.dispose()
}
this._sceneUBOs = []
}
}
,
i.prototype.dispose = function() {
this._disposeRTTandPostProcesses(),
this._disposeSceneUBOs(),
this._light && (this._light._shadowGenerator = null,
this._light._markMeshesAsLightDirty()),
this.onBeforeShadowMapRenderMeshObservable.clear(),
this.onBeforeShadowMapRenderObservable.clear(),
this.onAfterShadowMapRenderMeshObservable.clear(),
this.onAfterShadowMapRenderObservable.clear()
}
,
i.prototype.serialize = function() {
var e = {}
, t = this.getShadowMap();
if (!t)
return e;
if (e.className = this.getClassName(),
e.lightId = this._light.id,
e.id = this.id,
e.mapSize = t.getRenderSize(),
e.forceBackFacesOnly = this.forceBackFacesOnly,
e.darkness = this.getDarkness(),
e.transparencyShadow = this._transparencyShadow,
e.frustumEdgeFalloff = this.frustumEdgeFalloff,
e.bias = this.bias,
e.normalBias = this.normalBias,
e.usePercentageCloserFiltering = this.usePercentageCloserFiltering,
e.useContactHardeningShadow = this.useContactHardeningShadow,
e.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio,
e.filteringQuality = this.filteringQuality,
e.useExponentialShadowMap = this.useExponentialShadowMap,
e.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap,
e.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
e.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
e.usePoissonSampling = this.usePoissonSampling,
e.depthScale = this.depthScale,
e.blurBoxOffset = this.blurBoxOffset,
e.blurKernel = this.blurKernel,
e.blurScale = this.blurScale,
e.useKernelBlur = this.useKernelBlur,
e.renderList = [],
t.renderList)
for (var r = 0; r < t.renderList.length; r++) {
var n = t.renderList[r];
e.renderList.push(n.id)
}
return e
}
,
i.Parse = function(e, t, r) {
for (var n = t.getLightById(e.lightId), o = r ? r(e.mapSize, n) : new i(e.mapSize,n), a = o.getShadowMap(), s = 0; s < e.renderList.length; s++) {
var l = t.getMeshesById(e.renderList[s]);
l.forEach(function(u) {
!a || (a.renderList || (a.renderList = []),
a.renderList.push(u))
})
}
return e.id !== void 0 && (o.id = e.id),
o.forceBackFacesOnly = !!e.forceBackFacesOnly,
e.darkness !== void 0 && o.setDarkness(e.darkness),
e.transparencyShadow && o.setTransparencyShadow(!0),
e.frustumEdgeFalloff !== void 0 && (o.frustumEdgeFalloff = e.frustumEdgeFalloff),
e.bias !== void 0 && (o.bias = e.bias),
e.normalBias !== void 0 && (o.normalBias = e.normalBias),
e.usePercentageCloserFiltering ? o.usePercentageCloserFiltering = !0 : e.useContactHardeningShadow ? o.useContactHardeningShadow = !0 : e.usePoissonSampling ? o.usePoissonSampling = !0 : e.useExponentialShadowMap ? o.useExponentialShadowMap = !0 : e.useBlurExponentialShadowMap ? o.useBlurExponentialShadowMap = !0 : e.useCloseExponentialShadowMap ? o.useCloseExponentialShadowMap = !0 : e.useBlurCloseExponentialShadowMap ? o.useBlurCloseExponentialShadowMap = !0 : e.useVarianceShadowMap ? o.useExponentialShadowMap = !0 : e.useBlurVarianceShadowMap && (o.useBlurExponentialShadowMap = !0),
e.contactHardeningLightSizeUVRatio !== void 0 && (o.contactHardeningLightSizeUVRatio = e.contactHardeningLightSizeUVRatio),
e.filteringQuality !== void 0 && (o.filteringQuality = e.filteringQuality),
e.depthScale && (o.depthScale = e.depthScale),
e.blurScale && (o.blurScale = e.blurScale),
e.blurBoxOffset && (o.blurBoxOffset = e.blurBoxOffset),
e.useKernelBlur && (o.useKernelBlur = e.useKernelBlur),
e.blurKernel && (o.blurKernel = e.blurKernel),
o
}
,
i.CLASSNAME = "ShadowGenerator",
i.FILTER_NONE = 0,
i.FILTER_EXPONENTIALSHADOWMAP = 1,
i.FILTER_POISSONSAMPLING = 2,
i.FILTER_BLUREXPONENTIALSHADOWMAP = 3,
i.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4,
i.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5,
i.FILTER_PCF = 6,
i.FILTER_PCSS = 7,
i.QUALITY_HIGH = 0,
i.QUALITY_MEDIUM = 1,
i.QUALITY_LOW = 2,
i._SceneComponentInitialization = function(e) {
throw _WarnImport("ShadowGeneratorSceneComponent")
}
,
i
}()
, PushMaterial = function(i) {
__extends(e, i);
function e(t, r, n) {
n === void 0 && (n = !0);
var o = i.call(this, t, r) || this;
return o._normalMatrix = new Matrix,
o._storeEffectOnSubMeshes = n,
o
}
return e.prototype.getEffect = function() {
return this._storeEffectOnSubMeshes ? this._activeEffect : i.prototype.getEffect.call(this)
}
,
e.prototype.isReady = function(t, r) {
return t ? !this._storeEffectOnSubMeshes || !t.subMeshes || t.subMeshes.length === 0 ? !0 : this.isReadyForSubMesh(t, t.subMeshes[0], r) : !1
}
,
e.prototype._isReadyForSubMesh = function(t) {
var r = t.materialDefines;
return !!(!this.checkReadyOnEveryCall && t.effect && r && r._renderId === this.getScene().getRenderId())
}
,
e.prototype.bindOnlyWorldMatrix = function(t) {
this._activeEffect.setMatrix("world", t)
}
,
e.prototype.bindOnlyNormalMatrix = function(t) {
this._activeEffect.setMatrix("normalMatrix", t)
}
,
e.prototype.bind = function(t, r) {
!r || this.bindForSubMesh(t, r, r.subMeshes[0])
}
,
e.prototype._afterBind = function(t, r) {
r === void 0 && (r = null),
i.prototype._afterBind.call(this, t, r),
this.getScene()._cachedEffect = r
}
,
e.prototype._mustRebind = function(t, r, n) {
return n === void 0 && (n = 1),
t.isCachedMaterialInvalid(this, r, n)
}
,
e
}(Material)
, onCreatedEffectParameters$3 = {
effect: null,
subMesh: null
}
, ShaderMaterial = function(i) {
__extends(e, i);
function e(t, r, n, o, a) {
o === void 0 && (o = {}),
a === void 0 && (a = !0);
var s = i.call(this, t, r, a) || this;
return s._textures = {},
s._textureArrays = {},
s._externalTextures = {},
s._floats = {},
s._ints = {},
s._floatsArrays = {},
s._colors3 = {},
s._colors3Arrays = {},
s._colors4 = {},
s._colors4Arrays = {},
s._vectors2 = {},
s._vectors3 = {},
s._vectors4 = {},
s._matrices = {},
s._matrixArrays = {},
s._matrices3x3 = {},
s._matrices2x2 = {},
s._vectors2Arrays = {},
s._vectors3Arrays = {},
s._vectors4Arrays = {},
s._uniformBuffers = {},
s._textureSamplers = {},
s._storageBuffers = {},
s._cachedWorldViewMatrix = new Matrix,
s._cachedWorldViewProjectionMatrix = new Matrix,
s._multiview = !1,
s._shaderPath = n,
s._options = __assign({
needAlphaBlending: !1,
needAlphaTesting: !1,
attributes: ["position", "normal", "uv"],
uniforms: ["worldViewProjection"],
uniformBuffers: [],
samplers: [],
externalTextures: [],
samplerObjects: [],
storageBuffers: [],
defines: [],
useClipPlane: !1
}, o),
s
}
return Object.defineProperty(e.prototype, "shaderPath", {
get: function() {
return this._shaderPath
},
set: function(t) {
this._shaderPath = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "options", {
get: function() {
return this._options
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "ShaderMaterial"
}
,
e.prototype.needAlphaBlending = function() {
return this.alpha < 1 || this._options.needAlphaBlending
}
,
e.prototype.needAlphaTesting = function() {
return this._options.needAlphaTesting
}
,
e.prototype._checkUniform = function(t) {
this._options.uniforms.indexOf(t) === -1 && this._options.uniforms.push(t)
}
,
e.prototype.setTexture = function(t, r) {
return this._options.samplers.indexOf(t) === -1 && this._options.samplers.push(t),
this._textures[t] = r,
this
}
,
e.prototype.setTextureArray = function(t, r) {
return this._options.samplers.indexOf(t) === -1 && this._options.samplers.push(t),
this._checkUniform(t),
this._textureArrays[t] = r,
this
}
,
e.prototype.setExternalTexture = function(t, r) {
return this._options.externalTextures.indexOf(t) === -1 && this._options.externalTextures.push(t),
this._externalTextures[t] = r,
this
}
,
e.prototype.setFloat = function(t, r) {
return this._checkUniform(t),
this._floats[t] = r,
this
}
,
e.prototype.setInt = function(t, r) {
return this._checkUniform(t),
this._ints[t] = r,
this
}
,
e.prototype.setFloats = function(t, r) {
return this._checkUniform(t),
this._floatsArrays[t] = r,
this
}
,
e.prototype.setColor3 = function(t, r) {
return this._checkUniform(t),
this._colors3[t] = r,
this
}
,
e.prototype.setColor3Array = function(t, r) {
return this._checkUniform(t),
this._colors3Arrays[t] = r.reduce(function(n, o) {
return o.toArray(n, n.length),
n
}, []),
this
}
,
e.prototype.setColor4 = function(t, r) {
return this._checkUniform(t),
this._colors4[t] = r,
this
}
,
e.prototype.setColor4Array = function(t, r) {
return this._checkUniform(t),
this._colors4Arrays[t] = r.reduce(function(n, o) {
return o.toArray(n, n.length),
n
}, []),
this
}
,
e.prototype.setVector2 = function(t, r) {
return this._checkUniform(t),
this._vectors2[t] = r,
this
}
,
e.prototype.setVector3 = function(t, r) {
return this._checkUniform(t),
this._vectors3[t] = r,
this
}
,
e.prototype.setVector4 = function(t, r) {
return this._checkUniform(t),
this._vectors4[t] = r,
this
}
,
e.prototype.setMatrix = function(t, r) {
return this._checkUniform(t),
this._matrices[t] = r,
this
}
,
e.prototype.setMatrices = function(t, r) {
this._checkUniform(t);
for (var n = new Float32Array(r.length * 16), o = 0; o < r.length; o++) {
var a = r[o];
a.copyToArray(n, o * 16)
}
return this._matrixArrays[t] = n,
this
}
,
e.prototype.setMatrix3x3 = function(t, r) {
return this._checkUniform(t),
this._matrices3x3[t] = r,
this
}
,
e.prototype.setMatrix2x2 = function(t, r) {
return this._checkUniform(t),
this._matrices2x2[t] = r,
this
}
,
e.prototype.setArray2 = function(t, r) {
return this._checkUniform(t),
this._vectors2Arrays[t] = r,
this
}
,
e.prototype.setArray3 = function(t, r) {
return this._checkUniform(t),
this._vectors3Arrays[t] = r,
this
}
,
e.prototype.setArray4 = function(t, r) {
return this._checkUniform(t),
this._vectors4Arrays[t] = r,
this
}
,
e.prototype.setUniformBuffer = function(t, r) {
return this._options.uniformBuffers.indexOf(t) === -1 && this._options.uniformBuffers.push(t),
this._uniformBuffers[t] = r,
this
}
,
e.prototype.setTextureSampler = function(t, r) {
return this._options.samplerObjects.indexOf(t) === -1 && this._options.samplerObjects.push(t),
this._textureSamplers[t] = r,
this
}
,
e.prototype.setStorageBuffer = function(t, r) {
return this._options.storageBuffers.indexOf(t) === -1 && this._options.storageBuffers.push(t),
this._storageBuffers[t] = r,
this
}
,
e.prototype.isReadyForSubMesh = function(t, r, n) {
return this.isReady(t, n, r)
}
,
e.prototype.isReady = function(t, r, n) {
var o, a, s, l, u = n && this._storeEffectOnSubMeshes;
if (this.isFrozen)
if (u) {
if (n.effect && n.effect._wasPreviouslyReady)
return !0
} else {
var c = this._drawWrapper.effect;
if (c && c._wasPreviouslyReady && this._effectUsesInstances === r)
return !0
}
var h = this.getScene()
, f = h.getEngine()
, d = []
, _ = []
, g = new EffectFallbacks
, m = this._shaderPath
, v = this._options.uniforms
, y = this._options.uniformBuffers
, b = this._options.samplers;
f.getCaps().multiview && h.activeCamera && h.activeCamera.outputRenderTarget && h.activeCamera.outputRenderTarget.getViewCount() > 1 && (this._multiview = !0,
d.push("#define MULTIVIEW"),
this._options.uniforms.indexOf("viewProjection") !== -1 && this._options.uniforms.indexOf("viewProjectionR") === -1 && this._options.uniforms.push("viewProjectionR"));
for (var T = 0; T < this._options.defines.length; T++) {
var C = this._options.defines[T].indexOf("#define") === 0 ? this._options.defines[T] : "#define " + this._options.defines[T];
d.push(C)
}
for (var T = 0; T < this._options.attributes.length; T++)
_.push(this._options.attributes[T]);
if (t && t.isVerticesDataPresent(VertexBuffer.ColorKind) && (_.push(VertexBuffer.ColorKind),
d.push("#define VERTEXCOLOR")),
r && (d.push("#define INSTANCES"),
MaterialHelper.PushAttributesForInstances(_),
t != null && t.hasThinInstances && d.push("#define THIN_INSTANCES")),
t && t.useBones && t.computeBonesUsingShaders && t.skeleton) {
_.push(VertexBuffer.MatricesIndicesKind),
_.push(VertexBuffer.MatricesWeightsKind),
t.numBoneInfluencers > 4 && (_.push(VertexBuffer.MatricesIndicesExtraKind),
_.push(VertexBuffer.MatricesWeightsExtraKind));
var A = t.skeleton;
d.push("#define NUM_BONE_INFLUENCERS " + t.numBoneInfluencers),
g.addCPUSkinningFallback(0, t),
A.isUsingTextureForMatrices ? (d.push("#define BONETEXTURE"),
this._options.uniforms.indexOf("boneTextureWidth") === -1 && this._options.uniforms.push("boneTextureWidth"),
this._options.samplers.indexOf("boneSampler") === -1 && this._options.samplers.push("boneSampler")) : (d.push("#define BonesPerMesh " + (A.bones.length + 1)),
this._options.uniforms.indexOf("mBones") === -1 && this._options.uniforms.push("mBones"))
} else
d.push("#define NUM_BONE_INFLUENCERS 0");
var S = 0
, P = t ? t.morphTargetManager : null;
if (P) {
var R = P.supportsUVs && d.indexOf("#define UV1") !== -1
, M = P.supportsTangents && d.indexOf("#define TANGENT") !== -1
, x = P.supportsNormals && d.indexOf("#define NORMAL") !== -1;
S = P.numInfluencers,
R && d.push("#define MORPHTARGETS_UV"),
M && d.push("#define MORPHTARGETS_TANGENT"),
x && d.push("#define MORPHTARGETS_NORMAL"),
S > 0 && d.push("#define MORPHTARGETS"),
P.isUsingTextureForTargets && (d.push("#define MORPHTARGETS_TEXTURE"),
this._options.uniforms.indexOf("morphTargetTextureIndices") === -1 && this._options.uniforms.push("morphTargetTextureIndices"),
this._options.samplers.indexOf("morphTargets") === -1 && this._options.samplers.push("morphTargets")),
d.push("#define NUM_MORPH_INFLUENCERS " + S);
for (var T = 0; T < S; T++)
_.push(VertexBuffer.PositionKind + T),
x && _.push(VertexBuffer.NormalKind + T),
M && _.push(VertexBuffer.TangentKind + T),
R && _.push(VertexBuffer.UVKind + "_" + T);
S > 0 && (v = v.slice(),
v.push("morphTargetInfluences"),
v.push("morphTargetTextureInfo"),
v.push("morphTargetTextureIndices"))
} else
d.push("#define NUM_MORPH_INFLUENCERS 0");
if (t) {
var I = t.bakedVertexAnimationManager;
I && I.isEnabled && (d.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),
this._options.uniforms.indexOf("bakedVertexAnimationSettings") === -1 && this._options.uniforms.push("bakedVertexAnimationSettings"),
this._options.uniforms.indexOf("bakedVertexAnimationTextureSizeInverted") === -1 && this._options.uniforms.push("bakedVertexAnimationTextureSizeInverted"),
this._options.uniforms.indexOf("bakedVertexAnimationTime") === -1 && this._options.uniforms.push("bakedVertexAnimationTime"),
this._options.samplers.indexOf("bakedVertexAnimationTexture") === -1 && this._options.samplers.push("bakedVertexAnimationTexture")),
MaterialHelper.PrepareAttributesForBakedVertexAnimation(_, t, d)
}
for (var w in this._textures)
if (!this._textures[w].isReady())
return !1;
t && this._shouldTurnAlphaTestOn(t) && d.push("#define ALPHATEST"),
(this._options.useClipPlane === null && !!h.clipPlane || this._options.useClipPlane) && (d.push("#define CLIPPLANE"),
v.indexOf("vClipPlane") === -1 && v.push("vClipPlane")),
(this._options.useClipPlane === null && !!h.clipPlane2 || this._options.useClipPlane) && (d.push("#define CLIPPLANE2"),
v.indexOf("vClipPlane2") === -1 && v.push("vClipPlane2")),
(this._options.useClipPlane === null && !!h.clipPlane3 || this._options.useClipPlane) && (d.push("#define CLIPPLANE3"),
v.indexOf("vClipPlane3") === -1 && v.push("vClipPlane3")),
(this._options.useClipPlane === null && !!h.clipPlane4 || this._options.useClipPlane) && (d.push("#define CLIPPLANE4"),
v.indexOf("vClipPlane4") === -1 && v.push("vClipPlane4")),
(this._options.useClipPlane === null && !!h.clipPlane5 || this._options.useClipPlane) && (d.push("#define CLIPPLANE5"),
v.indexOf("vClipPlane5") === -1 && v.push("vClipPlane5")),
(this._options.useClipPlane === null && !!h.clipPlane6 || this._options.useClipPlane) && (d.push("#define CLIPPLANE6"),
v.indexOf("vClipPlane6") === -1 && v.push("vClipPlane6")),
this.customShaderNameResolve && (v = v.slice(),
y = y.slice(),
b = b.slice(),
m = this.customShaderNameResolve(m, v, y, b, d, _));
var O = u ? n._getDrawWrapper() : this._drawWrapper
, D = (o = O == null ? void 0 : O.effect) !== null && o !== void 0 ? o : null
, F = (a = O == null ? void 0 : O.defines) !== null && a !== void 0 ? a : null
, V = d.join(`
`)
, N = D;
return F !== V && (N = f.createEffect(m, {
attributes: _,
uniformsNames: v,
uniformBuffersNames: y,
samplers: b,
defines: V,
fallbacks: g,
onCompiled: this.onCompiled,
onError: this.onError,
indexParameters: {
maxSimultaneousMorphTargets: S
},
shaderLanguage: this._options.shaderLanguage
}, f),
u ? n.setEffect(N, V, this._materialContext) : O && O.setEffect(N, V),
this._onEffectCreatedObservable && (onCreatedEffectParameters$3.effect = N,
onCreatedEffectParameters$3.subMesh = (s = n != null ? n : t == null ? void 0 : t.subMeshes[0]) !== null && s !== void 0 ? s : null,
this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters$3))),
this._effectUsesInstances = !!r,
!((l = !(N != null && N.isReady())) !== null && l !== void 0) || l ? !1 : (D !== N && h.resetCachedMaterial(),
N._wasPreviouslyReady = !0,
!0)
}
,
e.prototype.bindOnlyWorldMatrix = function(t, r) {
var n = this.getScene()
, o = r != null ? r : this.getEffect();
!o || (this._options.uniforms.indexOf("world") !== -1 && o.setMatrix("world", t),
this._options.uniforms.indexOf("worldView") !== -1 && (t.multiplyToRef(n.getViewMatrix(), this._cachedWorldViewMatrix),
o.setMatrix("worldView", this._cachedWorldViewMatrix)),
this._options.uniforms.indexOf("worldViewProjection") !== -1 && (t.multiplyToRef(n.getTransformMatrix(), this._cachedWorldViewProjectionMatrix),
o.setMatrix("worldViewProjection", this._cachedWorldViewProjectionMatrix)))
}
,
e.prototype.bindForSubMesh = function(t, r, n) {
var o;
this.bind(t, r, (o = n._drawWrapperOverride) === null || o === void 0 ? void 0 : o.effect, n)
}
,
e.prototype.bind = function(t, r, n, o) {
var a, s = o && this._storeEffectOnSubMeshes, l = n != null ? n : s ? o.effect : this.getEffect();
if (!!l) {
this._activeEffect = l,
this.bindOnlyWorldMatrix(t, n);
var u = this._options.uniformBuffers
, c = !1;
if (l && u && u.length > 0 && this.getScene().getEngine().supportsUniformBuffers)
for (var h = 0; h < u.length; ++h) {
var f = u[h];
switch (f) {
case "Mesh":
r && (r.getMeshUniformBuffer().bindToEffect(l, "Mesh"),
r.transferToEffect(t));
break;
case "Scene":
MaterialHelper.BindSceneUniformBuffer(l, this.getScene().getSceneUniformBuffer()),
this.getScene().finalizeSceneUbo(),
c = !0;
break
}
}
var d = r && s ? this._mustRebind(this.getScene(), l, r.visibility) : this.getScene().getCachedMaterial() !== this;
if (l && d) {
!c && this._options.uniforms.indexOf("view") !== -1 && l.setMatrix("view", this.getScene().getViewMatrix()),
!c && this._options.uniforms.indexOf("projection") !== -1 && l.setMatrix("projection", this.getScene().getProjectionMatrix()),
!c && this._options.uniforms.indexOf("viewProjection") !== -1 && (l.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
this._multiview && l.setMatrix("viewProjectionR", this.getScene()._transformMatrixR)),
this.getScene().activeCamera && this._options.uniforms.indexOf("cameraPosition") !== -1 && l.setVector3("cameraPosition", this.getScene().activeCamera.globalPosition),
MaterialHelper.BindBonesParameters(r, l),
MaterialHelper.BindClipPlane(l, this.getScene());
var _;
for (_ in this._textures)
l.setTexture(_, this._textures[_]);
for (_ in this._textureArrays)
l.setTextureArray(_, this._textureArrays[_]);
for (_ in this._externalTextures)
l.setExternalTexture(_, this._externalTextures[_]);
for (_ in this._ints)
l.setInt(_, this._ints[_]);
for (_ in this._floats)
l.setFloat(_, this._floats[_]);
for (_ in this._floatsArrays)
l.setArray(_, this._floatsArrays[_]);
for (_ in this._colors3)
l.setColor3(_, this._colors3[_]);
for (_ in this._colors3Arrays)
l.setArray3(_, this._colors3Arrays[_]);
for (_ in this._colors4) {
var g = this._colors4[_];
l.setFloat4(_, g.r, g.g, g.b, g.a)
}
for (_ in this._colors4Arrays)
l.setArray4(_, this._colors4Arrays[_]);
for (_ in this._vectors2)
l.setVector2(_, this._vectors2[_]);
for (_ in this._vectors3)
l.setVector3(_, this._vectors3[_]);
for (_ in this._vectors4)
l.setVector4(_, this._vectors4[_]);
for (_ in this._matrices)
l.setMatrix(_, this._matrices[_]);
for (_ in this._matrixArrays)
l.setMatrices(_, this._matrixArrays[_]);
for (_ in this._matrices3x3)
l.setMatrix3x3(_, this._matrices3x3[_]);
for (_ in this._matrices2x2)
l.setMatrix2x2(_, this._matrices2x2[_]);
for (_ in this._vectors2Arrays)
l.setArray2(_, this._vectors2Arrays[_]);
for (_ in this._vectors3Arrays)
l.setArray3(_, this._vectors3Arrays[_]);
for (_ in this._vectors4Arrays)
l.setArray4(_, this._vectors4Arrays[_]);
for (_ in this._uniformBuffers) {
var m = this._uniformBuffers[_].getBuffer();
m && l.bindUniformBuffer(m, _)
}
for (_ in this._textureSamplers)
l.setTextureSampler(_, this._textureSamplers[_]);
for (_ in this._storageBuffers)
l.setStorageBuffer(_, this._storageBuffers[_])
}
if (l && r && (d || !this.isFrozen)) {
var v = r.morphTargetManager;
v && v.numInfluencers > 0 && MaterialHelper.BindMorphTargetParameters(r, l);
var y = r.bakedVertexAnimationManager;
y && y.isEnabled && ((a = r.bakedVertexAnimationManager) === null || a === void 0 || a.bind(l, this._effectUsesInstances))
}
this._afterBind(r, l)
}
}
,
e.prototype.getActiveTextures = function() {
var t = i.prototype.getActiveTextures.call(this);
for (var r in this._textures)
t.push(this._textures[r]);
for (var r in this._textureArrays)
for (var n = this._textureArrays[r], o = 0; o < n.length; o++)
t.push(n[o]);
return t
}
,
e.prototype.hasTexture = function(t) {
if (i.prototype.hasTexture.call(this, t))
return !0;
for (var r in this._textures)
if (this._textures[r] === t)
return !0;
for (var r in this._textureArrays)
for (var n = this._textureArrays[r], o = 0; o < n.length; o++)
if (n[o] === t)
return !0;
return !1
}
,
e.prototype.clone = function(t) {
var r = this
, n = SerializationHelper.Clone(function() {
return new e(t,r.getScene(),r._shaderPath,r._options,r._storeEffectOnSubMeshes)
}, this);
n.name = t,
n.id = t,
typeof n._shaderPath == "object" && (n._shaderPath = __assign({}, n._shaderPath)),
this._options = __assign({}, this._options),
Object.keys(this._options).forEach(function(a) {
var s = r._options[a];
Array.isArray(s) && (r._options[a] = s.slice(0))
}),
this.stencil.copyTo(n.stencil);
for (var o in this._textures)
n.setTexture(o, this._textures[o]);
for (var o in this._textureArrays)
n.setTextureArray(o, this._textureArrays[o]);
for (var o in this._externalTextures)
n.setExternalTexture(o, this._externalTextures[o]);
for (var o in this._ints)
n.setInt(o, this._ints[o]);
for (var o in this._floats)
n.setFloat(o, this._floats[o]);
for (var o in this._floatsArrays)
n.setFloats(o, this._floatsArrays[o]);
for (var o in this._colors3)
n.setColor3(o, this._colors3[o]);
for (var o in this._colors3Arrays)
n._colors3Arrays[o] = this._colors3Arrays[o];
for (var o in this._colors4)
n.setColor4(o, this._colors4[o]);
for (var o in this._colors4Arrays)
n._colors4Arrays[o] = this._colors4Arrays[o];
for (var o in this._vectors2)
n.setVector2(o, this._vectors2[o]);
for (var o in this._vectors3)
n.setVector3(o, this._vectors3[o]);
for (var o in this._vectors4)
n.setVector4(o, this._vectors4[o]);
for (var o in this._matrices)
n.setMatrix(o, this._matrices[o]);
for (var o in this._matrixArrays)
n._matrixArrays[o] = this._matrixArrays[o].slice();
for (var o in this._matrices3x3)
n.setMatrix3x3(o, this._matrices3x3[o]);
for (var o in this._matrices2x2)
n.setMatrix2x2(o, this._matrices2x2[o]);
for (var o in this._vectors2Arrays)
n.setArray2(o, this._vectors2Arrays[o]);
for (var o in this._vectors3Arrays)
n.setArray3(o, this._vectors3Arrays[o]);
for (var o in this._vectors4Arrays)
n.setArray4(o, this._vectors4Arrays[o]);
for (var o in this._uniformBuffers)
n.setUniformBuffer(o, this._uniformBuffers[o]);
for (var o in this._textureSamplers)
n.setTextureSampler(o, this._textureSamplers[o]);
for (var o in this._storageBuffers)
n.setStorageBuffer(o, this._storageBuffers[o]);
return n
}
,
e.prototype.dispose = function(t, r, n) {
if (r) {
var o;
for (o in this._textures)
this._textures[o].dispose();
for (o in this._textureArrays)
for (var a = this._textureArrays[o], s = 0; s < a.length; s++)
a[s].dispose()
}
this._textures = {},
i.prototype.dispose.call(this, t, r, n)
}
,
e.prototype.serialize = function() {
var t = SerializationHelper.Serialize(this);
t.customType = "BABYLON.ShaderMaterial",
t.options = this._options,
t.shaderPath = this._shaderPath,
t.storeEffectOnSubMeshes = this._storeEffectOnSubMeshes;
var r;
t.stencil = this.stencil.serialize(),
t.textures = {};
for (r in this._textures)
t.textures[r] = this._textures[r].serialize();
t.textureArrays = {};
for (r in this._textureArrays) {
t.textureArrays[r] = [];
for (var n = this._textureArrays[r], o = 0; o < n.length; o++)
t.textureArrays[r].push(n[o].serialize())
}
t.ints = {};
for (r in this._ints)
t.ints[r] = this._ints[r];
t.floats = {};
for (r in this._floats)
t.floats[r] = this._floats[r];
t.FloatArrays = {};
for (r in this._floatsArrays)
t.FloatArrays[r] = this._floatsArrays[r];
t.colors3 = {};
for (r in this._colors3)
t.colors3[r] = this._colors3[r].asArray();
t.colors3Arrays = {};
for (r in this._colors3Arrays)
t.colors3Arrays[r] = this._colors3Arrays[r];
t.colors4 = {};
for (r in this._colors4)
t.colors4[r] = this._colors4[r].asArray();
t.colors4Arrays = {};
for (r in this._colors4Arrays)
t.colors4Arrays[r] = this._colors4Arrays[r];
t.vectors2 = {};
for (r in this._vectors2)
t.vectors2[r] = this._vectors2[r].asArray();
t.vectors3 = {};
for (r in this._vectors3)
t.vectors3[r] = this._vectors3[r].asArray();
t.vectors4 = {};
for (r in this._vectors4)
t.vectors4[r] = this._vectors4[r].asArray();
t.matrices = {};
for (r in this._matrices)
t.matrices[r] = this._matrices[r].asArray();
t.matrixArray = {};
for (r in this._matrixArrays)
t.matrixArray[r] = this._matrixArrays[r];
t.matrices3x3 = {};
for (r in this._matrices3x3)
t.matrices3x3[r] = this._matrices3x3[r];
t.matrices2x2 = {};
for (r in this._matrices2x2)
t.matrices2x2[r] = this._matrices2x2[r];
t.vectors2Arrays = {};
for (r in this._vectors2Arrays)
t.vectors2Arrays[r] = this._vectors2Arrays[r];
t.vectors3Arrays = {};
for (r in this._vectors3Arrays)
t.vectors3Arrays[r] = this._vectors3Arrays[r];
t.vectors4Arrays = {};
for (r in this._vectors4Arrays)
t.vectors4Arrays[r] = this._vectors4Arrays[r];
return t
}
,
e.Parse = function(t, r, n) {
var o = SerializationHelper.Parse(function() {
return new e(t.name,r,t.shaderPath,t.options,t.storeEffectOnSubMeshes)
}, t, r, n), a;
t.stencil && o.stencil.parse(t.stencil, r, n);
for (a in t.textures)
o.setTexture(a, Texture.Parse(t.textures[a], r, n));
for (a in t.textureArrays) {
for (var s = t.textureArrays[a], l = new Array, u = 0; u < s.length; u++)
l.push(Texture.Parse(s[u], r, n));
o.setTextureArray(a, l)
}
for (a in t.ints)
o.setInt(a, t.ints[a]);
for (a in t.floats)
o.setFloat(a, t.floats[a]);
for (a in t.floatsArrays)
o.setFloats(a, t.floatsArrays[a]);
for (a in t.colors3)
o.setColor3(a, Color3.FromArray(t.colors3[a]));
for (a in t.colors3Arrays) {
var c = t.colors3Arrays[a].reduce(function(h, f, d) {
return d % 3 === 0 ? h.push([f]) : h[h.length - 1].push(f),
h
}, []).map(function(h) {
return Color3.FromArray(h)
});
o.setColor3Array(a, c)
}
for (a in t.colors4)
o.setColor4(a, Color4.FromArray(t.colors4[a]));
for (a in t.colors4Arrays) {
var c = t.colors4Arrays[a].reduce(function(f, d, _) {
return _ % 4 === 0 ? f.push([d]) : f[f.length - 1].push(d),
f
}, []).map(function(f) {
return Color4.FromArray(f)
});
o.setColor4Array(a, c)
}
for (a in t.vectors2)
o.setVector2(a, Vector2.FromArray(t.vectors2[a]));
for (a in t.vectors3)
o.setVector3(a, Vector3.FromArray(t.vectors3[a]));
for (a in t.vectors4)
o.setVector4(a, Vector4.FromArray(t.vectors4[a]));
for (a in t.matrices)
o.setMatrix(a, Matrix.FromArray(t.matrices[a]));
for (a in t.matrixArray)
o._matrixArrays[a] = new Float32Array(t.matrixArray[a]);
for (a in t.matrices3x3)
o.setMatrix3x3(a, t.matrices3x3[a]);
for (a in t.matrices2x2)
o.setMatrix2x2(a, t.matrices2x2[a]);
for (a in t.vectors2Arrays)
o.setArray2(a, t.vectors2Arrays[a]);
for (a in t.vectors3Arrays)
o.setArray3(a, t.vectors3Arrays[a]);
for (a in t.vectors4Arrays)
o.setArray4(a, t.vectors4Arrays[a]);
return o
}
,
e.ParseFromFileAsync = function(t, r, n, o) {
var a = this;
return o === void 0 && (o = ""),
new Promise(function(s, l) {
var u = new WebRequest;
u.addEventListener("readystatechange", function() {
if (u.readyState == 4)
if (u.status == 200) {
var c = JSON.parse(u.responseText)
, h = a.Parse(c, n || Engine.LastCreatedScene, o);
t && (h.name = t),
s(h)
} else
l("Unable to load the ShaderMaterial")
}),
u.open("GET", r),
u.send()
}
)
}
,
e.CreateFromSnippetAsync = function(t, r, n) {
var o = this;
return n === void 0 && (n = ""),
new Promise(function(a, s) {
var l = new WebRequest;
l.addEventListener("readystatechange", function() {
if (l.readyState == 4)
if (l.status == 200) {
var u = JSON.parse(JSON.parse(l.responseText).jsonPayload)
, c = JSON.parse(u.shaderMaterial)
, h = o.Parse(c, r || Engine.LastCreatedScene, n);
h.snippetId = t,
a(h)
} else
s("Unable to load the snippet " + t)
}),
l.open("GET", o.SnippetUrl + "/" + t.replace(/#/g, "/")),
l.send()
}
)
}
,
e.SnippetUrl = "https://snippet.babylonjs.com",
e
}(PushMaterial);
RegisterClass("BABYLON.ShaderMaterial", ShaderMaterial);
var PrePassConfiguration = function() {
function i() {
this.previousWorldMatrices = {},
this.previousBones = {}
}
return i.AddUniforms = function(e) {
e.push("previousWorld", "previousViewProjection", "mPreviousBones")
}
,
i.AddSamplers = function(e) {}
,
i.prototype.bindForSubMesh = function(e, t, r, n, o) {
if (t.prePassRenderer && t.prePassRenderer.enabled && t.prePassRenderer.currentRTisSceneRT && t.prePassRenderer.getIndex(2) !== -1) {
this.previousWorldMatrices[r.uniqueId] || (this.previousWorldMatrices[r.uniqueId] = n.clone()),
this.previousViewProjection || (this.previousViewProjection = t.getTransformMatrix().clone(),
this.currentViewProjection = t.getTransformMatrix().clone());
var a = t.getEngine();
this.currentViewProjection.updateFlag !== t.getTransformMatrix().updateFlag ? (this._lastUpdateFrameId = a.frameId,
this.previousViewProjection.copyFrom(this.currentViewProjection),
this.currentViewProjection.copyFrom(t.getTransformMatrix())) : this._lastUpdateFrameId !== a.frameId && (this._lastUpdateFrameId = a.frameId,
this.previousViewProjection.copyFrom(this.currentViewProjection)),
e.setMatrix("previousWorld", this.previousWorldMatrices[r.uniqueId]),
e.setMatrix("previousViewProjection", this.previousViewProjection),
this.previousWorldMatrices[r.uniqueId] = n.clone()
}
}
,
i
}()
, MaterialFlags = function() {
function i() {}
return Object.defineProperty(i, "DiffuseTextureEnabled", {
get: function() {
return this._DiffuseTextureEnabled
},
set: function(e) {
this._DiffuseTextureEnabled !== e && (this._DiffuseTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "DetailTextureEnabled", {
get: function() {
return this._DetailTextureEnabled
},
set: function(e) {
this._DetailTextureEnabled !== e && (this._DetailTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "AmbientTextureEnabled", {
get: function() {
return this._AmbientTextureEnabled
},
set: function(e) {
this._AmbientTextureEnabled !== e && (this._AmbientTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "OpacityTextureEnabled", {
get: function() {
return this._OpacityTextureEnabled
},
set: function(e) {
this._OpacityTextureEnabled !== e && (this._OpacityTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ReflectionTextureEnabled", {
get: function() {
return this._ReflectionTextureEnabled
},
set: function(e) {
this._ReflectionTextureEnabled !== e && (this._ReflectionTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "EmissiveTextureEnabled", {
get: function() {
return this._EmissiveTextureEnabled
},
set: function(e) {
this._EmissiveTextureEnabled !== e && (this._EmissiveTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "SpecularTextureEnabled", {
get: function() {
return this._SpecularTextureEnabled
},
set: function(e) {
this._SpecularTextureEnabled !== e && (this._SpecularTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "BumpTextureEnabled", {
get: function() {
return this._BumpTextureEnabled
},
set: function(e) {
this._BumpTextureEnabled !== e && (this._BumpTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "LightmapTextureEnabled", {
get: function() {
return this._LightmapTextureEnabled
},
set: function(e) {
this._LightmapTextureEnabled !== e && (this._LightmapTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "RefractionTextureEnabled", {
get: function() {
return this._RefractionTextureEnabled
},
set: function(e) {
this._RefractionTextureEnabled !== e && (this._RefractionTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ColorGradingTextureEnabled", {
get: function() {
return this._ColorGradingTextureEnabled
},
set: function(e) {
this._ColorGradingTextureEnabled !== e && (this._ColorGradingTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "FresnelEnabled", {
get: function() {
return this._FresnelEnabled
},
set: function(e) {
this._FresnelEnabled !== e && (this._FresnelEnabled = e,
Engine.MarkAllMaterialsAsDirty(4))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ClearCoatTextureEnabled", {
get: function() {
return this._ClearCoatTextureEnabled
},
set: function(e) {
this._ClearCoatTextureEnabled !== e && (this._ClearCoatTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ClearCoatBumpTextureEnabled", {
get: function() {
return this._ClearCoatBumpTextureEnabled
},
set: function(e) {
this._ClearCoatBumpTextureEnabled !== e && (this._ClearCoatBumpTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ClearCoatTintTextureEnabled", {
get: function() {
return this._ClearCoatTintTextureEnabled
},
set: function(e) {
this._ClearCoatTintTextureEnabled !== e && (this._ClearCoatTintTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "SheenTextureEnabled", {
get: function() {
return this._SheenTextureEnabled
},
set: function(e) {
this._SheenTextureEnabled !== e && (this._SheenTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "AnisotropicTextureEnabled", {
get: function() {
return this._AnisotropicTextureEnabled
},
set: function(e) {
this._AnisotropicTextureEnabled !== e && (this._AnisotropicTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "ThicknessTextureEnabled", {
get: function() {
return this._ThicknessTextureEnabled
},
set: function(e) {
this._ThicknessTextureEnabled !== e && (this._ThicknessTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "RefractionIntensityTextureEnabled", {
get: function() {
return this._ThicknessTextureEnabled
},
set: function(e) {
this._RefractionIntensityTextureEnabled !== e && (this._RefractionIntensityTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i, "TranslucencyIntensityTextureEnabled", {
get: function() {
return this._ThicknessTextureEnabled
},
set: function(e) {
this._TranslucencyIntensityTextureEnabled !== e && (this._TranslucencyIntensityTextureEnabled = e,
Engine.MarkAllMaterialsAsDirty(1))
},
enumerable: !1,
configurable: !0
}),
i._DiffuseTextureEnabled = !0,
i._DetailTextureEnabled = !0,
i._AmbientTextureEnabled = !0,
i._OpacityTextureEnabled = !0,
i._ReflectionTextureEnabled = !0,
i._EmissiveTextureEnabled = !0,
i._SpecularTextureEnabled = !0,
i._BumpTextureEnabled = !0,
i._LightmapTextureEnabled = !0,
i._RefractionTextureEnabled = !0,
i._ColorGradingTextureEnabled = !0,
i._FresnelEnabled = !0,
i._ClearCoatTextureEnabled = !0,
i._ClearCoatBumpTextureEnabled = !0,
i._ClearCoatTintTextureEnabled = !0,
i._SheenTextureEnabled = !0,
i._AnisotropicTextureEnabled = !0,
i._ThicknessTextureEnabled = !0,
i._RefractionIntensityTextureEnabled = !0,
i._TranslucencyIntensityTextureEnabled = !0,
i
}()
, name$2o = "defaultFragmentDeclaration"
, shader$2o = `uniform vec4 vEyePosition;
uniform vec4 vDiffuseColor;
#ifdef SPECULARTERM
uniform vec4 vSpecularColor;
#endif
uniform vec3 vEmissiveColor;
uniform vec3 vAmbientColor;
uniform float visibility;
#ifdef DIFFUSE
uniform vec2 vDiffuseInfos;
#endif
#ifdef AMBIENT
uniform vec2 vAmbientInfos;
#endif
#ifdef OPACITY
uniform vec2 vOpacityInfos;
#endif
#ifdef EMISSIVE
uniform vec2 vEmissiveInfos;
#endif
#ifdef LIGHTMAP
uniform vec2 vLightmapInfos;
#endif
#ifdef BUMP
uniform vec3 vBumpInfos;
uniform vec2 vTangentSpaceParams;
#endif
#ifdef ALPHATEST
uniform float alphaCutOff;
#endif
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
uniform mat4 view;
#endif
#ifdef REFRACTION
uniform vec4 vRefractionInfos;
#ifndef REFRACTIONMAP_3D
uniform mat4 refractionMatrix;
#endif
#ifdef REFRACTIONFRESNEL
uniform vec4 refractionLeftColor;
uniform vec4 refractionRightColor;
#endif
#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)
uniform vec3 vRefractionPosition;
uniform vec3 vRefractionSize;
#endif
#endif
#if defined(SPECULAR) && defined(SPECULARTERM)
uniform vec2 vSpecularInfos;
#endif
#ifdef DIFFUSEFRESNEL
uniform vec4 diffuseLeftColor;
uniform vec4 diffuseRightColor;
#endif
#ifdef OPACITYFRESNEL
uniform vec4 opacityParts;
#endif
#ifdef EMISSIVEFRESNEL
uniform vec4 emissiveLeftColor;
uniform vec4 emissiveRightColor;
#endif
#ifdef REFLECTION
uniform vec2 vReflectionInfos;
#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)
uniform mat4 reflectionMatrix;
#endif
#ifndef REFLECTIONMAP_SKYBOX
#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
uniform vec3 vReflectionPosition;
uniform vec3 vReflectionSize;
#endif
#endif
#ifdef REFLECTIONFRESNEL
uniform vec4 reflectionLeftColor;
uniform vec4 reflectionRightColor;
#endif
#endif
#ifdef DETAIL
uniform vec4 vDetailInfos;
#endif`;
ShaderStore.IncludesShadersStore[name$2o] = shader$2o;
var name$2n = "defaultUboDeclaration"
, shader$2n = `layout(std140,column_major) uniform;
uniform Material
{
vec4 diffuseLeftColor;
vec4 diffuseRightColor;
vec4 opacityParts;
vec4 reflectionLeftColor;
vec4 reflectionRightColor;
vec4 refractionLeftColor;
vec4 refractionRightColor;
vec4 emissiveLeftColor;
vec4 emissiveRightColor;
vec2 vDiffuseInfos;
vec2 vAmbientInfos;
vec2 vOpacityInfos;
vec2 vReflectionInfos;
vec3 vReflectionPosition;
vec3 vReflectionSize;
vec2 vEmissiveInfos;
vec2 vLightmapInfos;
vec2 vSpecularInfos;
vec3 vBumpInfos;
mat4 diffuseMatrix;
mat4 ambientMatrix;
mat4 opacityMatrix;
mat4 reflectionMatrix;
mat4 emissiveMatrix;
mat4 lightmapMatrix;
mat4 specularMatrix;
mat4 bumpMatrix;
vec2 vTangentSpaceParams;
float pointSize;
float alphaCutOff;
mat4 refractionMatrix;
vec4 vRefractionInfos;
vec3 vRefractionPosition;
vec3 vRefractionSize;
vec4 vSpecularColor;
vec3 vEmissiveColor;
vec4 vDiffuseColor;
vec3 vAmbientColor;
vec4 vDetailInfos;
mat4 detailMatrix;
};
#include
#include
`;
ShaderStore.IncludesShadersStore[name$2n] = shader$2n;
var name$2m = "prePassDeclaration"
, shader$2m = `#ifdef PREPASS
#extension GL_EXT_draw_buffers : require
layout(location=0) out highp vec4 glFragData[{X}];
highp vec4 gl_FragColor;
#ifdef PREPASS_DEPTH
varying highp vec3 vViewPos;
#endif
#ifdef PREPASS_VELOCITY
varying highp vec4 vCurrentPosition;
varying highp vec4 vPreviousPosition;
#endif
#endif
`;
ShaderStore.IncludesShadersStore[name$2m] = shader$2m;
var name$2l = "oitDeclaration"
, shader$2l = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
#extension GL_EXT_draw_buffers : require
layout(location=0) out vec2 depth;
layout(location=1) out vec4 frontColor;
layout(location=2) out vec4 backColor;
#define MAX_DEPTH 99999.0
highp vec4 gl_FragColor;
uniform sampler2D oitDepthSampler;
uniform sampler2D oitFrontColorSampler;
#endif
`;
ShaderStore.IncludesShadersStore[name$2l] = shader$2l;
var name$2k = "mainUVVaryingDeclaration"
, shader$2k = `#ifdef MAINUV{X}
varying vec2 vMainUV{X};
#endif
`;
ShaderStore.IncludesShadersStore[name$2k] = shader$2k;
var name$2j = "lightFragmentDeclaration"
, shader$2j = `#ifdef LIGHT{X}
uniform vec4 vLightData{X};
uniform vec4 vLightDiffuse{X};
#ifdef SPECULARTERM
uniform vec4 vLightSpecular{X};
#else
vec4 vLightSpecular{X}=vec4(0.);
#endif
#ifdef SHADOW{X}
#ifdef SHADOWCSM{X}
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float cascadeBlendFactor{X};
varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
varying vec4 vPositionFromCamera{X};
#if defined(SHADOWPCSS{X})
uniform highp sampler2DArrayShadow shadowSampler{X};
uniform highp sampler2DArray depthSampler{X};
uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float penumbraDarkness{X};
#elif defined(SHADOWPCF{X})
uniform highp sampler2DArrayShadow shadowSampler{X};
#else
uniform highp sampler2DArray shadowSampler{X};
#endif
#ifdef SHADOWCSMDEBUG{X}
const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
(
vec3 ( 1.5,0.0,0.0 ),
vec3 ( 0.0,1.5,0.0 ),
vec3 ( 0.0,0.0,5.5 ),
vec3 ( 1.5,0.0,5.5 ),
vec3 ( 1.5,1.5,0.0 ),
vec3 ( 1.0,1.0,1.0 ),
vec3 ( 0.0,1.0,5.5 ),
vec3 ( 0.5,3.5,0.75 )
);
vec3 shadowDebug{X};
#endif
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
int index{X}=-1;
#else
int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
#endif
float diff{X}=0.;
#elif defined(SHADOWCUBE{X})
uniform samplerCube shadowSampler{X};
#else
varying vec4 vPositionFromLight{X};
varying float vDepthMetric{X};
#if defined(SHADOWPCSS{X})
uniform highp sampler2DShadow shadowSampler{X};
uniform highp sampler2D depthSampler{X};
#elif defined(SHADOWPCF{X})
uniform highp sampler2DShadow shadowSampler{X};
#else
uniform sampler2D shadowSampler{X};
#endif
uniform mat4 lightMatrix{X};
#endif
uniform vec4 shadowsInfo{X};
uniform vec2 depthValues{X};
#endif
#ifdef SPOTLIGHT{X}
uniform vec4 vLightDirection{X};
uniform vec4 vLightFalloff{X};
#elif defined(POINTLIGHT{X})
uniform vec4 vLightFalloff{X};
#elif defined(HEMILIGHT{X})
uniform vec3 vLightGround{X};
#endif
#ifdef PROJECTEDLIGHTTEXTURE{X}
uniform mat4 textureProjectionMatrix{X};
uniform sampler2D projectionLightSampler{X};
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$2j] = shader$2j;
var name$2i = "lightUboDeclaration"
, shader$2i = `#ifdef LIGHT{X}
uniform Light{X}
{
vec4 vLightData;
vec4 vLightDiffuse;
vec4 vLightSpecular;
#ifdef SPOTLIGHT{X}
vec4 vLightDirection;
vec4 vLightFalloff;
#elif defined(POINTLIGHT{X})
vec4 vLightFalloff;
#elif defined(HEMILIGHT{X})
vec3 vLightGround;
#endif
vec4 shadowsInfo;
vec2 depthValues;
} light{X};
#ifdef PROJECTEDLIGHTTEXTURE{X}
uniform mat4 textureProjectionMatrix{X};
uniform sampler2D projectionLightSampler{X};
#endif
#ifdef SHADOW{X}
#ifdef SHADOWCSM{X}
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float cascadeBlendFactor{X};
varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
varying vec4 vPositionFromCamera{X};
#if defined(SHADOWPCSS{X})
uniform highp sampler2DArrayShadow shadowSampler{X};
uniform highp sampler2DArray depthSampler{X};
uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
uniform float penumbraDarkness{X};
#elif defined(SHADOWPCF{X})
uniform highp sampler2DArrayShadow shadowSampler{X};
#else
uniform highp sampler2DArray shadowSampler{X};
#endif
#ifdef SHADOWCSMDEBUG{X}
const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
(
vec3 ( 1.5,0.0,0.0 ),
vec3 ( 0.0,1.5,0.0 ),
vec3 ( 0.0,0.0,5.5 ),
vec3 ( 1.5,0.0,5.5 ),
vec3 ( 1.5,1.5,0.0 ),
vec3 ( 1.0,1.0,1.0 ),
vec3 ( 0.0,1.0,5.5 ),
vec3 ( 0.5,3.5,0.75 )
);
vec3 shadowDebug{X};
#endif
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
int index{X}=-1;
#else
int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
#endif
float diff{X}=0.;
#elif defined(SHADOWCUBE{X})
uniform samplerCube shadowSampler{X};
#else
varying vec4 vPositionFromLight{X};
varying float vDepthMetric{X};
#if defined(SHADOWPCSS{X})
uniform highp sampler2DShadow shadowSampler{X};
uniform highp sampler2D depthSampler{X};
#elif defined(SHADOWPCF{X})
uniform highp sampler2DShadow shadowSampler{X};
#else
uniform sampler2D shadowSampler{X};
#endif
uniform mat4 lightMatrix{X};
#endif
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$2i] = shader$2i;
var name$2h = "lightsFragmentFunctions"
, shader$2h = `
struct lightingInfo
{
vec3 diffuse;
#ifdef SPECULARTERM
vec3 specular;
#endif
#ifdef NDOTL
float ndl;
#endif
};
lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {
lightingInfo result;
vec3 lightVectorW;
float attenuation=1.0;
if (lightData.w == 0.)
{
vec3 direction=lightData.xyz-vPositionW;
attenuation=max(0.,1.0-length(direction)/range);
lightVectorW=normalize(direction);
}
else
{
lightVectorW=normalize(-lightData.xyz);
}
float ndl=max(0.,dot(vNormal,lightVectorW));
#ifdef NDOTL
result.ndl=ndl;
#endif
result.diffuse=ndl*diffuseColor*attenuation;
#ifdef SPECULARTERM
vec3 angleW=normalize(viewDirectionW+lightVectorW);
float specComp=max(0.,dot(vNormal,angleW));
specComp=pow(specComp,max(1.,glossiness));
result.specular=specComp*specularColor*attenuation;
#endif
return result;
}
lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {
lightingInfo result;
vec3 direction=lightData.xyz-vPositionW;
vec3 lightVectorW=normalize(direction);
float attenuation=max(0.,1.0-length(direction)/range);
float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));
if (cosAngle>=lightDirection.w)
{
cosAngle=max(0.,pow(cosAngle,lightData.w));
attenuation*=cosAngle;
float ndl=max(0.,dot(vNormal,lightVectorW));
#ifdef NDOTL
result.ndl=ndl;
#endif
result.diffuse=ndl*diffuseColor*attenuation;
#ifdef SPECULARTERM
vec3 angleW=normalize(viewDirectionW+lightVectorW);
float specComp=max(0.,dot(vNormal,angleW));
specComp=pow(specComp,max(1.,glossiness));
result.specular=specComp*specularColor*attenuation;
#endif
return result;
}
result.diffuse=vec3(0.);
#ifdef SPECULARTERM
result.specular=vec3(0.);
#endif
#ifdef NDOTL
result.ndl=0.;
#endif
return result;
}
lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {
lightingInfo result;
float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;
#ifdef NDOTL
result.ndl=ndl;
#endif
result.diffuse=mix(groundColor,diffuseColor,ndl);
#ifdef SPECULARTERM
vec3 angleW=normalize(viewDirectionW+lightData.xyz);
float specComp=max(0.,dot(vNormal,angleW));
specComp=pow(specComp,max(1.,glossiness));
result.specular=specComp*specularColor;
#endif
return result;
}
#define inline
vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){
vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);
strq/=strq.w;
vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;
return textureColor;
}`;
ShaderStore.IncludesShadersStore[name$2h] = shader$2h;
var name$2g = "shadowsFragmentFunctions"
, shader$2g = `#ifdef SHADOWS
#ifndef SHADOWFLOAT
float unpack(vec4 color)
{
const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);
return dot(color,bit_shift);
}
#endif
float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
{
float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));
return mix(value,1.0,mask);
}
#define inline
float computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)
{
vec3 directionToLight=vPositionW-lightPosition;
float depth=length(directionToLight);
depth=(depth+depthValues.x)/(depthValues.y);
depth=clamp(depth,0.,1.0);
directionToLight=normalize(directionToLight);
directionToLight.y=-directionToLight.y;
#ifndef SHADOWFLOAT
float shadow=unpack(textureCube(shadowSampler,directionToLight));
#else
float shadow=textureCube(shadowSampler,directionToLight).x;
#endif
return depth>shadow ? darkness : 1.0;
}
#define inline
float computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)
{
vec3 directionToLight=vPositionW-lightPosition;
float depth=length(directionToLight);
depth=(depth+depthValues.x)/(depthValues.y);
depth=clamp(depth,0.,1.0);
directionToLight=normalize(directionToLight);
directionToLight.y=-directionToLight.y;
float visibility=1.;
vec3 poissonDisk[4];
poissonDisk[0]=vec3(-1.0,1.0,-1.0);
poissonDisk[1]=vec3(1.0,-1.0,-1.0);
poissonDisk[2]=vec3(-1.0,-1.0,-1.0);
poissonDisk[3]=vec3(1.0,-1.0,1.0);
#ifndef SHADOWFLOAT
if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
}
#endif
#define inline
float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec2 uv=0.5*clipSpace.xy+vec2(0.5);
if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
{
return 1.0;
}
else
{
float shadowPixelDepth=clamp(depthMetric,0.,1.0);
#ifndef SHADOWFLOAT
float shadow=unpack(texture2D(shadowSampler,uv));
#else
float shadow=texture2D(shadowSampler,uv).x;
#endif
return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
}
}
#define inline
float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec2 uv=0.5*clipSpace.xy+vec2(0.5);
if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
{
return 1.0;
}
else
{
float shadowPixelDepth=clamp(depthMetric,0.,1.0);
float visibility=1.;
vec2 poissonDisk[4];
poissonDisk[0]=vec2(-0.94201624,-0.39906216);
poissonDisk[1]=vec2(0.94558609,-0.76890725);
poissonDisk[2]=vec2(-0.094184101,-0.92938870);
poissonDisk[3]=vec2(0.34495938,0.29387760);
#ifndef SHADOWFLOAT
if (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)
{
return 1.0;
}
else
{
float shadowPixelDepth=clamp(depthMetric,0.,1.0);
#ifndef SHADOWFLOAT
float shadowMapSample=unpack(texture2D(shadowSampler,uv));
#else
float shadowMapSample=texture2D(shadowSampler,uv).x;
#endif
float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);
return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);
}
}
#define inline
float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec2 uv=0.5*clipSpace.xy+vec2(0.5);
if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
{
return 1.0;
}
else
{
float shadowPixelDepth=clamp(depthMetric,0.,1.0);
#ifndef SHADOWFLOAT
float shadowMapSample=unpack(texture2D(shadowSampler,uv));
#else
float shadowMapSample=texture2D(shadowSampler,uv).x;
#endif
float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);
}
}
#ifdef IS_NDC_HALF_ZRANGE
#define ZINCLIP clipSpace.z
#else
#define ZINCLIP uvDepth.z
#endif
#if defined(WEBGL2) || defined(WEBGPU)
#define GREATEST_LESS_THAN_ONE 0.99999994
#define inline
float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);
float shadow=texture2D(shadowSampler,uvDepthLayer);
shadow=mix(darkness,1.,shadow);
return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
}
#define inline
float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
uv+=0.5;
vec2 st=fract(uv);
vec2 base_uv=floor(uv)-0.5;
base_uv*=shadowMapSizeAndInverse.y;
vec2 uvw0=3.-2.*st;
vec2 uvw1=1.+2.*st;
vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;
vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;
float shadow=0.;
shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));
shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));
shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));
shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));
shadow=shadow/16.;
shadow=mix(darkness,1.,shadow);
return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
}
#define inline
float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
uv+=0.5;
vec2 st=fract(uv);
vec2 base_uv=floor(uv)-0.5;
base_uv*=shadowMapSizeAndInverse.y;
vec2 uvw0=4.-3.*st;
vec2 uvw1=vec2(7.);
vec2 uvw2=1.+3.*st;
vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;
vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;
float shadow=0.;
shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));
shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));
shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));
shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));
shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));
shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));
shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));
shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));
shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));
shadow=shadow/144.;
shadow=mix(darkness,1.,shadow);
return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
}
#define inline
float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
{
if (depthMetric>1.0 || depthMetric<0.0) {
return 1.0;
}
else
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
uvDepth.z=ZINCLIP;
float shadow=texture2D(shadowSampler,uvDepth);
shadow=mix(darkness,1.,shadow);
return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
}
}
#define inline
float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
{
if (depthMetric>1.0 || depthMetric<0.0) {
return 1.0;
}
else
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
uvDepth.z=ZINCLIP;
vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
uv+=0.5;
vec2 st=fract(uv);
vec2 base_uv=floor(uv)-0.5;
base_uv*=shadowMapSizeAndInverse.y;
vec2 uvw0=3.-2.*st;
vec2 uvw1=1.+2.*st;
vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;
vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;
float shadow=0.;
shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));
shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));
shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));
shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));
shadow=shadow/16.;
shadow=mix(darkness,1.,shadow);
return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
}
}
#define inline
float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
{
if (depthMetric>1.0 || depthMetric<0.0) {
return 1.0;
}
else
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
uvDepth.z=ZINCLIP;
vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
uv+=0.5;
vec2 st=fract(uv);
vec2 base_uv=floor(uv)-0.5;
base_uv*=shadowMapSizeAndInverse.y;
vec2 uvw0=4.-3.*st;
vec2 uvw1=vec2(7.);
vec2 uvw2=1.+3.*st;
vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;
vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;
float shadow=0.;
shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));
shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));
shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));
shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));
shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));
shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));
shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));
shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));
shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));
shadow=shadow/144.;
shadow=mix(darkness,1.,shadow);
return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
}
}
const vec3 PoissonSamplers32[64]=vec3[64](
vec3(0.06407013,0.05409927,0.),
vec3(0.7366577,0.5789394,0.),
vec3(-0.6270542,-0.5320278,0.),
vec3(-0.4096107,0.8411095,0.),
vec3(0.6849564,-0.4990818,0.),
vec3(-0.874181,-0.04579735,0.),
vec3(0.9989998,0.0009880066,0.),
vec3(-0.004920578,-0.9151649,0.),
vec3(0.1805763,0.9747483,0.),
vec3(-0.2138451,0.2635818,0.),
vec3(0.109845,0.3884785,0.),
vec3(0.06876755,-0.3581074,0.),
vec3(0.374073,-0.7661266,0.),
vec3(0.3079132,-0.1216763,0.),
vec3(-0.3794335,-0.8271583,0.),
vec3(-0.203878,-0.07715034,0.),
vec3(0.5912697,0.1469799,0.),
vec3(-0.88069,0.3031784,0.),
vec3(0.5040108,0.8283722,0.),
vec3(-0.5844124,0.5494877,0.),
vec3(0.6017799,-0.1726654,0.),
vec3(-0.5554981,0.1559997,0.),
vec3(-0.3016369,-0.3900928,0.),
vec3(-0.5550632,-0.1723762,0.),
vec3(0.925029,0.2995041,0.),
vec3(-0.2473137,0.5538505,0.),
vec3(0.9183037,-0.2862392,0.),
vec3(0.2469421,0.6718712,0.),
vec3(0.3916397,-0.4328209,0.),
vec3(-0.03576927,-0.6220032,0.),
vec3(-0.04661255,0.7995201,0.),
vec3(0.4402924,0.3640312,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.),
vec3(0.,0.,0.)
);
const vec3 PoissonSamplers64[64]=vec3[64](
vec3(-0.613392,0.617481,0.),
vec3(0.170019,-0.040254,0.),
vec3(-0.299417,0.791925,0.),
vec3(0.645680,0.493210,0.),
vec3(-0.651784,0.717887,0.),
vec3(0.421003,0.027070,0.),
vec3(-0.817194,-0.271096,0.),
vec3(-0.705374,-0.668203,0.),
vec3(0.977050,-0.108615,0.),
vec3(0.063326,0.142369,0.),
vec3(0.203528,0.214331,0.),
vec3(-0.667531,0.326090,0.),
vec3(-0.098422,-0.295755,0.),
vec3(-0.885922,0.215369,0.),
vec3(0.566637,0.605213,0.),
vec3(0.039766,-0.396100,0.),
vec3(0.751946,0.453352,0.),
vec3(0.078707,-0.715323,0.),
vec3(-0.075838,-0.529344,0.),
vec3(0.724479,-0.580798,0.),
vec3(0.222999,-0.215125,0.),
vec3(-0.467574,-0.405438,0.),
vec3(-0.248268,-0.814753,0.),
vec3(0.354411,-0.887570,0.),
vec3(0.175817,0.382366,0.),
vec3(0.487472,-0.063082,0.),
vec3(-0.084078,0.898312,0.),
vec3(0.488876,-0.783441,0.),
vec3(0.470016,0.217933,0.),
vec3(-0.696890,-0.549791,0.),
vec3(-0.149693,0.605762,0.),
vec3(0.034211,0.979980,0.),
vec3(0.503098,-0.308878,0.),
vec3(-0.016205,-0.872921,0.),
vec3(0.385784,-0.393902,0.),
vec3(-0.146886,-0.859249,0.),
vec3(0.643361,0.164098,0.),
vec3(0.634388,-0.049471,0.),
vec3(-0.688894,0.007843,0.),
vec3(0.464034,-0.188818,0.),
vec3(-0.440840,0.137486,0.),
vec3(0.364483,0.511704,0.),
vec3(0.034028,0.325968,0.),
vec3(0.099094,-0.308023,0.),
vec3(0.693960,-0.366253,0.),
vec3(0.678884,-0.204688,0.),
vec3(0.001801,0.780328,0.),
vec3(0.145177,-0.898984,0.),
vec3(0.062655,-0.611866,0.),
vec3(0.315226,-0.604297,0.),
vec3(-0.780145,0.486251,0.),
vec3(-0.371868,0.882138,0.),
vec3(0.200476,0.494430,0.),
vec3(-0.494552,-0.711051,0.),
vec3(0.612476,0.705252,0.),
vec3(-0.578845,-0.768792,0.),
vec3(-0.772454,-0.090976,0.),
vec3(0.504440,0.372295,0.),
vec3(0.155736,0.065157,0.),
vec3(0.391522,0.849605,0.),
vec3(-0.620106,-0.328104,0.),
vec3(0.789239,-0.419965,0.),
vec3(-0.545396,0.538133,0.),
vec3(-0.178564,-0.596057,0.)
);
#define inline
float 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)
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);
float blockerDepth=0.0;
float sumBlockerDepth=0.0;
float numBlocker=0.0;
for (int i=0; i1.0 || depthMetric<0.0) {
return 1.0;
}
else
{
vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
uvDepth.z=ZINCLIP;
float blockerDepth=0.0;
float sumBlockerDepth=0.0;
float numBlocker=0.0;
for (int i=0; i(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
#endif
#if defined(DETAIL)
#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
#endif
#if defined(BUMP) && defined(PARALLAX)
const float minSamples=4.;
const float maxSamples=15.;
const int iMaxSamples=15;
vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {
float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;
parallaxLimit*=parallaxScale;
vec2 vOffsetDir=normalize(vViewDirCoT.xy);
vec2 vMaxOffset=vOffsetDir*parallaxLimit;
float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));
float stepSize=1.0/numSamples;
float currRayHeight=1.0;
vec2 vCurrOffset=vec2(0,0);
vec2 vLastOffset=vec2(0,0);
float lastSampledHeight=1.0;
float currSampledHeight=1.0;
for (int i=0; icurrRayHeight)
{
float delta1=currSampledHeight-currRayHeight;
float delta2=(currRayHeight+stepSize)-lastSampledHeight;
float ratio=delta1/(delta1+delta2);
vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;
break;
}
else
{
currRayHeight-=stepSize;
vLastOffset=vCurrOffset;
vCurrOffset+=stepSize*vMaxOffset;
lastSampledHeight=currSampledHeight;
}
}
return vCurrOffset;
}
vec2 parallaxOffset(vec3 viewDir,float heightScale)
{
float height=texture2D(bumpSampler,vBumpUV).w;
vec2 texCoordOffset=heightScale*viewDir.xy*height;
return -texCoordOffset;
}
#endif
`;
ShaderStore.IncludesShadersStore[name$29] = shader$29;
var name$28 = "logDepthDeclaration"
, shader$28 = `#ifdef LOGARITHMICDEPTH
uniform float logarithmicDepthConstant;
varying float vFragmentDepth;
#endif`;
ShaderStore.IncludesShadersStore[name$28] = shader$28;
var name$27 = "fogFragmentDeclaration"
, shader$27 = `#ifdef FOG
#define FOGMODE_NONE 0.
#define FOGMODE_EXP 1.
#define FOGMODE_EXP2 2.
#define FOGMODE_LINEAR 3.
#define E 2.71828
uniform vec4 vFogInfos;
uniform vec3 vFogColor;
varying vec3 vFogDistance;
float CalcFogFactor()
{
float fogCoeff=1.0;
float fogStart=vFogInfos.y;
float fogEnd=vFogInfos.z;
float fogDensity=vFogInfos.w;
float fogDistance=length(vFogDistance);
if (FOGMODE_LINEAR == vFogInfos.x)
{
fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);
}
else if (FOGMODE_EXP == vFogInfos.x)
{
fogCoeff=1.0/pow(E,fogDistance*fogDensity);
}
else if (FOGMODE_EXP2 == vFogInfos.x)
{
fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);
}
return clamp(fogCoeff,0.0,1.0);
}
#endif`;
ShaderStore.IncludesShadersStore[name$27] = shader$27;
var name$26 = "oitFragment"
, shader$26 = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
float fragDepth=gl_FragCoord.z;
#ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
uint halfFloat=packHalf2x16(vec2(fragDepth));
vec2 full=unpackHalf2x16(halfFloat);
fragDepth=full.x;
#endif
ivec2 fragCoord=ivec2(gl_FragCoord.xy);
vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;
vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);
depth.rg=vec2(-MAX_DEPTH);
frontColor=lastFrontColor;
backColor=vec4(0.0);
#ifdef USE_REVERSE_DEPTHBUFFER
float furthestDepth=-lastDepth.x;
float nearestDepth=lastDepth.y;
#else
float nearestDepth=-lastDepth.x;
float furthestDepth=lastDepth.y;
#endif
float alphaMultiplier=1.0-lastFrontColor.a;
#ifdef USE_REVERSE_DEPTHBUFFER
if (fragDepth>nearestDepth || fragDepthfurthestDepth) {
#endif
return;
}
#ifdef USE_REVERSE_DEPTHBUFFER
if (fragDepthfurthestDepth) {
#else
if (fragDepth>nearestDepth && fragDepth=0.) {
index{X}=i;
break;
}
}
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
if (index{X}>=0)
#endif
{
#if defined(SHADOWPCF{X})
#if defined(SHADOWLOWQUALITY{X})
shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#elif defined(SHADOWMEDIUMQUALITY{X})
shadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#else
shadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPCSS{X})
#if defined(SHADOWLOWQUALITY{X})
shadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#elif defined(SHADOWMEDIUMQUALITY{X})
shadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#else
shadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#endif
#else
shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#ifdef SHADOWCSMDEBUG{X}
shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];
#endif
#ifndef SHADOWCSMNOBLEND{X}
float frustumLength=frustumLengths{X}[index{X}];
float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};
if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
{
index{X}+=1;
float nextShadow=0.;
#if defined(SHADOWPCF{X})
#if defined(SHADOWLOWQUALITY{X})
nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#elif defined(SHADOWMEDIUMQUALITY{X})
nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#else
nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPCSS{X})
#if defined(SHADOWLOWQUALITY{X})
nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#elif defined(SHADOWMEDIUMQUALITY{X})
nextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#else
nextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
#endif
#else
nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
shadow=mix(nextShadow,shadow,diffRatio);
#ifdef SHADOWCSMDEBUG{X}
shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
#endif
}
#endif
}
#elif defined(SHADOWCLOSEESM{X})
#if defined(SHADOWCUBE{X})
shadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
#else
shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWESM{X})
#if defined(SHADOWCUBE{X})
shadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
#else
shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPOISSON{X})
#if defined(SHADOWCUBE{X})
shadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
#else
shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPCF{X})
#if defined(SHADOWLOWQUALITY{X})
shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#elif defined(SHADOWMEDIUMQUALITY{X})
shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#else
shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#elif defined(SHADOWPCSS{X})
#if defined(SHADOWLOWQUALITY{X})
shadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#elif defined(SHADOWMEDIUMQUALITY{X})
shadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#else
shadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#else
#if defined(SHADOWCUBE{X})
shadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);
#else
shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
#endif
#endif
#ifdef SHADOWONLY
#ifndef SHADOWINUSE
#define SHADOWINUSE
#endif
globalShadow+=shadow;
shadowLightCount+=1.0;
#endif
#else
shadow=1.;
#endif
#ifndef SHADOWONLY
#ifdef CUSTOMUSERLIGHTING
diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
#ifdef SPECULARTERM
specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
#endif
#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
diffuseBase+=lightmapColor.rgb*shadow;
#ifdef SPECULARTERM
#ifndef LIGHTMAPNOSPECULAR{X}
specularBase+=info.specular*shadow*lightmapColor.rgb;
#endif
#endif
#ifdef CLEARCOAT
#ifndef LIGHTMAPNOSPECULAR{X}
clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
#endif
#endif
#ifdef SHEEN
#ifndef LIGHTMAPNOSPECULAR{X}
sheenBase+=info.sheen.rgb*shadow;
#endif
#endif
#else
#ifdef SHADOWCSMDEBUG{X}
diffuseBase+=info.diffuse*shadowDebug{X};
#else
diffuseBase+=info.diffuse*shadow;
#endif
#ifdef SPECULARTERM
specularBase+=info.specular*shadow;
#endif
#ifdef CLEARCOAT
clearCoatBase+=info.clearCoat.rgb*shadow;
#endif
#ifdef SHEEN
sheenBase+=info.sheen.rgb*shadow;
#endif
#endif
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$23] = shader$23;
var name$22 = "logDepthFragment"
, shader$22 = `#ifdef LOGARITHMICDEPTH
gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;
#endif`;
ShaderStore.IncludesShadersStore[name$22] = shader$22;
var name$21 = "fogFragment"
, shader$21 = `#ifdef FOG
float fog=CalcFogFactor();
#ifdef PBR
fog=toLinearSpace(fog);
#endif
color.rgb=mix(vFogColor,color.rgb,fog);
#endif`;
ShaderStore.IncludesShadersStore[name$21] = shader$21;
var name$20 = "defaultPixelShader"
, shader$20 = `#include<__decl__defaultFragment>
#if defined(BUMP) || !defined(NORMAL)
#extension GL_OES_standard_derivatives : enable
#endif
#include[SCENE_MRT_COUNT]
#include
#define CUSTOM_FRAGMENT_BEGIN
#ifdef LOGARITHMICDEPTH
#extension GL_EXT_frag_depth : enable
#endif
#define RECIPROCAL_PI2 0.15915494
varying vec3 vPositionW;
#ifdef NORMAL
varying vec3 vNormalW;
#endif
#ifdef VERTEXCOLOR
varying vec4 vColor;
#endif
#include[1..7]
#include
#include<__decl__lightFragment>[0..maxSimultaneousLights]
#include
#include
#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
#ifdef REFRACTION
#ifdef REFRACTIONMAP_3D
uniform samplerCube refractionCubeSampler;
#else
uniform sampler2D refraction2DSampler;
#endif
#endif
#if defined(SPECULARTERM)
#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
#endif
#include
#ifdef REFLECTION
#ifdef REFLECTIONMAP_3D
uniform samplerCube reflectionCubeSampler;
#else
uniform sampler2D reflection2DSampler;
#endif
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#else
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#endif
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#define CUSTOM_FRAGMENT_DEFINITIONS
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#include
#include
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
vec4 baseColor=vec4(1.,1.,1.,1.);
vec3 diffuseColor=vDiffuseColor.rgb;
float alpha=vDiffuseColor.a;
#ifdef NORMAL
vec3 normalW=normalize(vNormalW);
#else
vec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));
#endif
#include
#ifdef TWOSIDEDLIGHTING
normalW=gl_FrontFacing ? normalW : -normalW;
#endif
#ifdef DIFFUSE
baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);
#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
if (baseColor.a
#ifdef VERTEXCOLOR
baseColor.rgb*=vColor.rgb;
#endif
#ifdef DETAIL
baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);
#endif
#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
vec3 baseAmbientColor=vec3(1.,1.,1.);
#ifdef AMBIENT
baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;
#endif
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
#ifdef SPECULARTERM
float glossiness=vSpecularColor.a;
vec3 specularColor=vSpecularColor.rgb;
#ifdef SPECULAR
vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);
specularColor=specularMapColor.rgb;
#ifdef GLOSSINESS
glossiness=glossiness*specularMapColor.a;
#endif
#endif
#else
float glossiness=0.;
#endif
vec3 diffuseBase=vec3(0.,0.,0.);
lightingInfo info;
#ifdef SPECULARTERM
vec3 specularBase=vec3(0.,0.,0.);
#endif
float shadow=1.;
#ifdef LIGHTMAP
vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
#ifdef RGBDLIGHTMAP
lightmapColor.rgb=fromRGBD(lightmapColor);
#endif
lightmapColor.rgb*=vLightmapInfos.y;
#endif
#include[0..maxSimultaneousLights]
vec4 refractionColor=vec4(0.,0.,0.,1.);
#ifdef REFRACTION
vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));
#ifdef REFRACTIONMAP_3D
#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);
#endif
refractionVector.y=refractionVector.y*vRefractionInfos.w;
if (dot(refractionVector,viewDirectionW)<1.0) {
refractionColor=textureCube(refractionCubeSampler,refractionVector);
}
#else
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
refractionCoords.y=1.0-refractionCoords.y;
refractionColor=texture2D(refraction2DSampler,refractionCoords);
#endif
#ifdef RGBDREFRACTION
refractionColor.rgb=fromRGBD(refractionColor);
#endif
#ifdef IS_REFRACTION_LINEAR
refractionColor.rgb=toGammaSpace(refractionColor.rgb);
#endif
refractionColor.rgb*=vRefractionInfos.x;
#endif
vec4 reflectionColor=vec4(0.,0.,0.,1.);
#ifdef REFLECTION
vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
#ifdef REFLECTIONMAP_OPPOSITEZ
vReflectionUVW.z*=-1.0;
#endif
#ifdef REFLECTIONMAP_3D
#ifdef ROUGHNESS
float bias=vReflectionInfos.y;
#ifdef SPECULARTERM
#ifdef SPECULAR
#ifdef GLOSSINESS
bias*=(1.0-specularMapColor.a);
#endif
#endif
#endif
reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);
#else
reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);
#endif
#else
vec2 coords=vReflectionUVW.xy;
#ifdef REFLECTIONMAP_PROJECTION
coords/=vReflectionUVW.z;
#endif
coords.y=1.0-coords.y;
reflectionColor=texture2D(reflection2DSampler,coords);
#endif
#ifdef RGBDREFLECTION
reflectionColor.rgb=fromRGBD(reflectionColor);
#endif
#ifdef IS_REFLECTION_LINEAR
reflectionColor.rgb=toGammaSpace(reflectionColor.rgb);
#endif
reflectionColor.rgb*=vReflectionInfos.x;
#ifdef REFLECTIONFRESNEL
float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);
#ifdef REFLECTIONFRESNELFROMSPECULAR
#ifdef SPECULARTERM
reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
#else
reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
#endif
#else
reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
#endif
#endif
#endif
#ifdef REFRACTIONFRESNEL
float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);
refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;
#endif
#ifdef OPACITY
vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
#ifdef OPACITYRGB
opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);
alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;
#else
alpha*=opacityMap.a*vOpacityInfos.y;
#endif
#endif
#ifdef VERTEXALPHA
alpha*=vColor.a;
#endif
#ifdef OPACITYFRESNEL
float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);
alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;
#endif
#ifdef ALPHATEST
#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
if (alpha
#include
#ifdef IMAGEPROCESSINGPOSTPROCESS
color.rgb=toLinearSpace(color.rgb);
#else
#ifdef IMAGEPROCESSING
color.rgb=toLinearSpace(color.rgb);
color=applyImageProcessing(color);
#endif
#endif
color.a*=visibility;
#ifdef PREMULTIPLYALPHA
color.rgb*=color.a;
#endif
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
#ifdef PREPASS
float writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;
gl_FragData[0]=color;
#ifdef PREPASS_POSITION
gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
#endif
#ifdef PREPASS_VELOCITY
vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
vec2 velocity=abs(a-b);
velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
#endif
#ifdef PREPASS_IRRADIANCE
gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
#endif
#ifdef PREPASS_DEPTH
gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
#endif
#ifdef PREPASS_NORMAL
gl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo);
#endif
#ifdef PREPASS_ALBEDO_SQRT
gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
#endif
#ifdef PREPASS_REFLECTIVITY
#if defined(SPECULAR)
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularMapColor.rgb,specularMapColor.a*writeGeometryInfo);
#else
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
#endif
#endif
#endif
#if !defined(PREPASS) || defined(WEBGL2)
gl_FragColor=color;
#endif
#if ORDER_INDEPENDENT_TRANSPARENCY
if (fragDepth == nearestDepth) {
frontColor.rgb+=color.rgb*color.a*alphaMultiplier;
frontColor.a=1.0-alphaMultiplier*(1.0-color.a);
} else {
backColor+=color;
}
#endif
}
`;
ShaderStore.ShadersStore[name$20] = shader$20;
var name$1$ = "defaultVertexDeclaration"
, shader$1$ = `
uniform mat4 viewProjection;
uniform mat4 view;
#ifdef DIFFUSE
uniform mat4 diffuseMatrix;
uniform vec2 vDiffuseInfos;
#endif
#ifdef AMBIENT
uniform mat4 ambientMatrix;
uniform vec2 vAmbientInfos;
#endif
#ifdef OPACITY
uniform mat4 opacityMatrix;
uniform vec2 vOpacityInfos;
#endif
#ifdef EMISSIVE
uniform vec2 vEmissiveInfos;
uniform mat4 emissiveMatrix;
#endif
#ifdef LIGHTMAP
uniform vec2 vLightmapInfos;
uniform mat4 lightmapMatrix;
#endif
#if defined(SPECULAR) && defined(SPECULARTERM)
uniform vec2 vSpecularInfos;
uniform mat4 specularMatrix;
#endif
#ifdef BUMP
uniform vec3 vBumpInfos;
uniform mat4 bumpMatrix;
#endif
#ifdef REFLECTION
uniform mat4 reflectionMatrix;
#endif
#ifdef POINTSIZE
uniform float pointSize;
#endif
#ifdef DETAIL
uniform vec4 vDetailInfos;
uniform mat4 detailMatrix;
#endif`;
ShaderStore.IncludesShadersStore[name$1$] = shader$1$;
var name$1_ = "uvAttributeDeclaration"
, shader$1_ = `#ifdef UV{X}
attribute vec2 uv{X};
#endif
`;
ShaderStore.IncludesShadersStore[name$1_] = shader$1_;
var name$1Z = "instancesDeclaration"
, shader$1Z = `#ifdef INSTANCES
attribute vec4 world0;
attribute vec4 world1;
attribute vec4 world2;
attribute vec4 world3;
#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
uniform mat4 world;
#endif
#if defined(VELOCITY) || defined(PREPASS_VELOCITY)
attribute vec4 previousWorld0;
attribute vec4 previousWorld1;
attribute vec4 previousWorld2;
attribute vec4 previousWorld3;
#ifdef THIN_INSTANCES
uniform mat4 previousWorld;
#endif
#endif
#else
#if !defined(WORLD_UBO)
uniform mat4 world;
#endif
#if defined(VELOCITY) || defined(PREPASS_VELOCITY)
uniform mat4 previousWorld;
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$1Z] = shader$1Z;
var name$1Y = "prePassVertexDeclaration"
, shader$1Y = `#ifdef PREPASS
#ifdef PREPASS_DEPTH
varying vec3 vViewPos;
#endif
#ifdef PREPASS_VELOCITY
uniform mat4 previousViewProjection;
varying vec4 vCurrentPosition;
varying vec4 vPreviousPosition;
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$1Y] = shader$1Y;
var name$1X = "samplerVertexDeclaration"
, shader$1X = `#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV == 0
varying vec2 v_VARYINGNAME_UV;
#endif
`;
ShaderStore.IncludesShadersStore[name$1X] = shader$1X;
var name$1W = "bumpVertexDeclaration"
, shader$1W = `#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
#if defined(TANGENT) && defined(NORMAL)
varying mat3 vTBN;
#endif
#endif
`;
ShaderStore.IncludesShadersStore[name$1W] = shader$1W;
var name$1V = "fogVertexDeclaration"
, shader$1V = `#ifdef FOG
varying vec3 vFogDistance;
#endif`;
ShaderStore.IncludesShadersStore[name$1V] = shader$1V;
var name$1U = "lightVxFragmentDeclaration"
, shader$1U = `#ifdef LIGHT{X}
uniform vec4 vLightData{X};
uniform vec4 vLightDiffuse{X};
#ifdef SPECULARTERM
uniform vec4 vLightSpecular{X};
#else
vec4 vLightSpecular{X}=vec4(0.);
#endif
#ifdef SHADOW{X}
#ifdef SHADOWCSM{X}
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
varying vec4 vPositionFromCamera{X};
#elif defined(SHADOWCUBE{X})
#else
varying vec4 vPositionFromLight{X};
varying float vDepthMetric{X};
uniform mat4 lightMatrix{X};
#endif
uniform vec4 shadowsInfo{X};
uniform vec2 depthValues{X};
#endif
#ifdef SPOTLIGHT{X}
uniform vec4 vLightDirection{X};
uniform vec4 vLightFalloff{X};
#elif defined(POINTLIGHT{X})
uniform vec4 vLightFalloff{X};
#elif defined(HEMILIGHT{X})
uniform vec3 vLightGround{X};
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$1U] = shader$1U;
var name$1T = "lightVxUboDeclaration"
, shader$1T = `#ifdef LIGHT{X}
uniform Light{X}
{
vec4 vLightData;
vec4 vLightDiffuse;
vec4 vLightSpecular;
#ifdef SPOTLIGHT{X}
vec4 vLightDirection;
vec4 vLightFalloff;
#elif defined(POINTLIGHT{X})
vec4 vLightFalloff;
#elif defined(HEMILIGHT{X})
vec3 vLightGround;
#endif
vec4 shadowsInfo;
vec2 depthValues;
} light{X};
#ifdef SHADOW{X}
#ifdef SHADOWCSM{X}
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
varying vec4 vPositionFromCamera{X};
#elif defined(SHADOWCUBE{X})
#else
varying vec4 vPositionFromLight{X};
varying float vDepthMetric{X};
uniform mat4 lightMatrix{X};
#endif
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$1T] = shader$1T;
var name$1S = "prePassVertex"
, shader$1S = `#ifdef PREPASS_DEPTH
vViewPos=(view*worldPos).rgb;
#endif
#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)
vCurrentPosition=viewProjection*worldPos;
#if NUM_BONE_INFLUENCERS>0
mat4 previousInfluence;
previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
#if NUM_BONE_INFLUENCERS>1
previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
#endif
#if NUM_BONE_INFLUENCERS>2
previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
#endif
#if NUM_BONE_INFLUENCERS>3
previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
#endif
#if NUM_BONE_INFLUENCERS>4
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
#endif
#if NUM_BONE_INFLUENCERS>5
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
#endif
#if NUM_BONE_INFLUENCERS>6
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
#endif
#if NUM_BONE_INFLUENCERS>7
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
#endif
vPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);
#else
vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$1S] = shader$1S;
var name$1R = "uvVariableDeclaration"
, shader$1R = `#if !defined(UV{X}) && defined(MAINUV{X})
vec2 uv{X}=vec2(0.,0.);
#endif
#ifdef MAINUV{X}
vMainUV{X}=uv{X};
#endif
`;
ShaderStore.IncludesShadersStore[name$1R] = shader$1R;
var name$1Q = "samplerVertexImplementation"
, shader$1Q = `#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV == 0
if (v_INFONAME_ == 0.)
{
v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));
}
#ifdef UV2
else if (v_INFONAME_ == 1.)
{
v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2,1.0,0.0));
}
#endif
#ifdef UV3
else if (v_INFONAME_ == 2.)
{
v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));
}
#endif
#ifdef UV4
else if (v_INFONAME_ == 3.)
{
v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));
}
#endif
#ifdef UV5
else if (v_INFONAME_ == 4.)
{
v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));
}
#endif
#ifdef UV6
else if (v_INFONAME_ == 5.)
{
v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));
}
#endif
#endif
`;
ShaderStore.IncludesShadersStore[name$1Q] = shader$1Q;
var name$1P = "bumpVertex"
, shader$1P = `#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
#if defined(TANGENT) && defined(NORMAL)
vec3 tbnNormal=normalize(normalUpdated);
vec3 tbnTangent=normalize(tangentUpdated.xyz);
vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;
vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$1P] = shader$1P;
var name$1O = "fogVertex"
, shader$1O = `#ifdef FOG
vFogDistance=(view*worldPos).xyz;
#endif`;
ShaderStore.IncludesShadersStore[name$1O] = shader$1O;
var name$1N = "shadowsVertex"
, shader$1N = `#ifdef SHADOWS
#if defined(SHADOWCSM{X})
vPositionFromCamera{X}=view*worldPos;
for (int i=0; i
#define CUSTOM_VERTEX_BEGIN
attribute vec3 position;
#ifdef NORMAL
attribute vec3 normal;
#endif
#ifdef TANGENT
attribute vec4 tangent;
#endif
#ifdef UV1
attribute vec2 uv;
#endif
#include[2..7]
#ifdef VERTEXCOLOR
attribute vec4 color;
#endif
#include
#include
#include
#include
#include
#include[1..7]
#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)
#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
#if defined(SPECULARTERM)
#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)
#endif
#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
varying vec3 vPositionW;
#ifdef NORMAL
varying vec3 vNormalW;
#endif
#ifdef VERTEXCOLOR
varying vec4 vColor;
#endif
#include
#include
#include
#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
#include
#include[0..maxSimultaneousMorphTargets]
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#endif
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#include
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vec3 positionUpdated=position;
#ifdef NORMAL
vec3 normalUpdated=normal;
#endif
#ifdef TANGENT
vec4 tangentUpdated=tangent;
#endif
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#include
#include[0..maxSimultaneousMorphTargets]
#ifdef REFLECTIONMAP_SKYBOX
vPositionUVW=positionUpdated;
#endif
#define CUSTOM_VERTEX_UPDATE_POSITION
#define CUSTOM_VERTEX_UPDATE_NORMAL
#include
#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
#endif
#include
#include
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
#ifdef NORMAL
mat3 normalWorld=mat3(finalWorld);
#if defined(INSTANCES) && defined(THIN_INSTANCES)
vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));
vNormalW=normalize(normalWorld*vNormalW);
#else
#ifdef NONUNIFORMSCALING
normalWorld=transposeMat3(inverseMat3(normalWorld));
#endif
vNormalW=normalize(normalWorld*normalUpdated);
#endif
#endif
#define CUSTOM_VERTEX_UPDATE_WORLDPOS
#ifdef MULTIVIEW
if (gl_ViewID_OVR == 0u) {
gl_Position=viewProjection*worldPos;
} else {
gl_Position=viewProjectionR*worldPos;
}
#else
gl_Position=viewProjection*worldPos;
#endif
vPositionW=vec3(worldPos);
#include
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
#endif
#ifndef UV1
vec2 uvUpdated=vec2(0.,0.);
#endif
#ifdef MAINUV1
vMainUV1=uvUpdated;
#endif
#include[2..7]
#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)
#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
#if defined(SPECULARTERM)
#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)
#endif
#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
#include
#include
#include
#include[0..maxSimultaneousLights]
#ifdef VERTEXCOLOR
vColor=color;
#endif
#include
#include
#define CUSTOM_VERTEX_MAIN_END
}
`;
ShaderStore.ShadersStore[name$1K] = shader$1K;
var DetailMapConfiguration = function() {
function i(e) {
this._texture = null,
this.diffuseBlendLevel = 1,
this.roughnessBlendLevel = 1,
this.bumpLevel = 1,
this._normalBlendMethod = Material.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,
this._isEnabled = !1,
this.isEnabled = !1,
this._internalMarkAllSubMeshesAsTexturesDirty = e
}
return i.prototype._markAllSubMeshesAsTexturesDirty = function() {
this._internalMarkAllSubMeshesAsTexturesDirty()
}
,
i.prototype.isReadyForSubMesh = function(e, t) {
if (!this._isEnabled)
return !0;
var r = t.getEngine();
return !(e._areTexturesDirty && t.texturesEnabled && r.getCaps().standardDerivatives && this._texture && MaterialFlags.DetailTextureEnabled && !this._texture.isReady())
}
,
i.prototype.prepareDefines = function(e, t) {
if (this._isEnabled) {
e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod;
var r = t.getEngine();
e._areTexturesDirty && (r.getCaps().standardDerivatives && this._texture && MaterialFlags.DetailTextureEnabled && this._isEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "DETAIL"),
e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod) : e.DETAIL = !1)
} else
e.DETAIL = !1
}
,
i.prototype.bindForSubMesh = function(e, t, r) {
!this._isEnabled || ((!e.useUbo || !r || !e.isSync) && this._texture && MaterialFlags.DetailTextureEnabled && (e.updateFloat4("vDetailInfos", this._texture.coordinatesIndex, this.diffuseBlendLevel, this.bumpLevel, this.roughnessBlendLevel),
MaterialHelper.BindTextureMatrix(this._texture, e, "detail")),
t.texturesEnabled && this._texture && MaterialFlags.DetailTextureEnabled && e.setTexture("detailSampler", this._texture))
}
,
i.prototype.hasTexture = function(e) {
return this._texture === e
}
,
i.prototype.getActiveTextures = function(e) {
this._texture && e.push(this._texture)
}
,
i.prototype.getAnimatables = function(e) {
this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
}
,
i.prototype.dispose = function(e) {
var t;
e && ((t = this._texture) === null || t === void 0 || t.dispose())
}
,
i.prototype.getClassName = function() {
return "DetailMapConfiguration"
}
,
i.AddUniforms = function(e) {
e.push("vDetailInfos"),
e.push("detailMatrix")
}
,
i.AddSamplers = function(e) {
e.push("detailSampler")
}
,
i.PrepareUniformBuffer = function(e) {
e.addUniform("vDetailInfos", 4),
e.addUniform("detailMatrix", 16)
}
,
i.prototype.copyTo = function(e) {
SerializationHelper.Clone(function() {
return e
}, this)
}
,
i.prototype.serialize = function() {
return SerializationHelper.Serialize(this)
}
,
i.prototype.parse = function(e, t, r) {
var n = this;
SerializationHelper.Parse(function() {
return n
}, e, t, r)
}
,
__decorate([serializeAsTexture("detailTexture"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "texture", void 0),
__decorate([serialize()], i.prototype, "diffuseBlendLevel", void 0),
__decorate([serialize()], i.prototype, "roughnessBlendLevel", void 0),
__decorate([serialize()], i.prototype, "bumpLevel", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "normalBlendMethod", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "isEnabled", void 0),
i
}()
, onCreatedEffectParameters$2 = {
effect: null,
subMesh: null
}
, StandardMaterialDefines = function(i) {
__extends(e, i);
function e() {
var t = i.call(this) || this;
return t.MAINUV1 = !1,
t.MAINUV2 = !1,
t.MAINUV3 = !1,
t.MAINUV4 = !1,
t.MAINUV5 = !1,
t.MAINUV6 = !1,
t.DIFFUSE = !1,
t.DIFFUSEDIRECTUV = 0,
t.DETAIL = !1,
t.DETAILDIRECTUV = 0,
t.DETAIL_NORMALBLENDMETHOD = 0,
t.BAKED_VERTEX_ANIMATION_TEXTURE = !1,
t.AMBIENT = !1,
t.AMBIENTDIRECTUV = 0,
t.OPACITY = !1,
t.OPACITYDIRECTUV = 0,
t.OPACITYRGB = !1,
t.REFLECTION = !1,
t.EMISSIVE = !1,
t.EMISSIVEDIRECTUV = 0,
t.SPECULAR = !1,
t.SPECULARDIRECTUV = 0,
t.BUMP = !1,
t.BUMPDIRECTUV = 0,
t.PARALLAX = !1,
t.PARALLAXOCCLUSION = !1,
t.SPECULAROVERALPHA = !1,
t.CLIPPLANE = !1,
t.CLIPPLANE2 = !1,
t.CLIPPLANE3 = !1,
t.CLIPPLANE4 = !1,
t.CLIPPLANE5 = !1,
t.CLIPPLANE6 = !1,
t.ALPHATEST = !1,
t.DEPTHPREPASS = !1,
t.ALPHAFROMDIFFUSE = !1,
t.POINTSIZE = !1,
t.FOG = !1,
t.SPECULARTERM = !1,
t.DIFFUSEFRESNEL = !1,
t.OPACITYFRESNEL = !1,
t.REFLECTIONFRESNEL = !1,
t.REFRACTIONFRESNEL = !1,
t.EMISSIVEFRESNEL = !1,
t.FRESNEL = !1,
t.NORMAL = !1,
t.TANGENT = !1,
t.UV1 = !1,
t.UV2 = !1,
t.UV3 = !1,
t.UV4 = !1,
t.UV5 = !1,
t.UV6 = !1,
t.VERTEXCOLOR = !1,
t.VERTEXALPHA = !1,
t.NUM_BONE_INFLUENCERS = 0,
t.BonesPerMesh = 0,
t.BONETEXTURE = !1,
t.BONES_VELOCITY_ENABLED = !1,
t.INSTANCES = !1,
t.THIN_INSTANCES = !1,
t.GLOSSINESS = !1,
t.ROUGHNESS = !1,
t.EMISSIVEASILLUMINATION = !1,
t.LINKEMISSIVEWITHDIFFUSE = !1,
t.REFLECTIONFRESNELFROMSPECULAR = !1,
t.LIGHTMAP = !1,
t.LIGHTMAPDIRECTUV = 0,
t.OBJECTSPACE_NORMALMAP = !1,
t.USELIGHTMAPASSHADOWMAP = !1,
t.REFLECTIONMAP_3D = !1,
t.REFLECTIONMAP_SPHERICAL = !1,
t.REFLECTIONMAP_PLANAR = !1,
t.REFLECTIONMAP_CUBIC = !1,
t.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
t.USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
t.REFLECTIONMAP_PROJECTION = !1,
t.REFLECTIONMAP_SKYBOX = !1,
t.REFLECTIONMAP_EXPLICIT = !1,
t.REFLECTIONMAP_EQUIRECTANGULAR = !1,
t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
t.REFLECTIONMAP_OPPOSITEZ = !1,
t.INVERTCUBICMAP = !1,
t.LOGARITHMICDEPTH = !1,
t.REFRACTION = !1,
t.REFRACTIONMAP_3D = !1,
t.REFLECTIONOVERALPHA = !1,
t.TWOSIDEDLIGHTING = !1,
t.SHADOWFLOAT = !1,
t.MORPHTARGETS = !1,
t.MORPHTARGETS_NORMAL = !1,
t.MORPHTARGETS_TANGENT = !1,
t.MORPHTARGETS_UV = !1,
t.NUM_MORPH_INFLUENCERS = 0,
t.MORPHTARGETS_TEXTURE = !1,
t.NONUNIFORMSCALING = !1,
t.PREMULTIPLYALPHA = !1,
t.ALPHATEST_AFTERALLALPHACOMPUTATIONS = !1,
t.ALPHABLEND = !0,
t.PREPASS = !1,
t.PREPASS_IRRADIANCE = !1,
t.PREPASS_IRRADIANCE_INDEX = -1,
t.PREPASS_ALBEDO_SQRT = !1,
t.PREPASS_ALBEDO_SQRT_INDEX = -1,
t.PREPASS_DEPTH = !1,
t.PREPASS_DEPTH_INDEX = -1,
t.PREPASS_NORMAL = !1,
t.PREPASS_NORMAL_INDEX = -1,
t.PREPASS_POSITION = !1,
t.PREPASS_POSITION_INDEX = -1,
t.PREPASS_VELOCITY = !1,
t.PREPASS_VELOCITY_INDEX = -1,
t.PREPASS_REFLECTIVITY = !1,
t.PREPASS_REFLECTIVITY_INDEX = -1,
t.SCENE_MRT_COUNT = 0,
t.RGBDLIGHTMAP = !1,
t.RGBDREFLECTION = !1,
t.RGBDREFRACTION = !1,
t.IMAGEPROCESSING = !1,
t.VIGNETTE = !1,
t.VIGNETTEBLENDMODEMULTIPLY = !1,
t.VIGNETTEBLENDMODEOPAQUE = !1,
t.TONEMAPPING = !1,
t.TONEMAPPING_ACES = !1,
t.CONTRAST = !1,
t.COLORCURVES = !1,
t.COLORGRADING = !1,
t.COLORGRADING3D = !1,
t.SAMPLER3DGREENDEPTH = !1,
t.SAMPLER3DBGRMAP = !1,
t.IMAGEPROCESSINGPOSTPROCESS = !1,
t.SKIPFINALCOLORCLAMP = !1,
t.MULTIVIEW = !1,
t.ORDER_INDEPENDENT_TRANSPARENCY = !1,
t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1,
t.IS_REFLECTION_LINEAR = !1,
t.IS_REFRACTION_LINEAR = !1,
t.EXPOSURE = !1,
t.rebuild(),
t
}
return e.prototype.setReflectionMode = function(t) {
for (var r = ["REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX", "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED", "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"], n = 0, o = r; n < o.length; n++) {
var a = o[n];
this[a] = a === t
}
}
,
e
}(MaterialDefines)
, StandardMaterial = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t, r) || this;
return n._diffuseTexture = null,
n._ambientTexture = null,
n._opacityTexture = null,
n._reflectionTexture = null,
n._emissiveTexture = null,
n._specularTexture = null,
n._bumpTexture = null,
n._lightmapTexture = null,
n._refractionTexture = null,
n.ambientColor = new Color3(0,0,0),
n.diffuseColor = new Color3(1,1,1),
n.specularColor = new Color3(1,1,1),
n.emissiveColor = new Color3(0,0,0),
n.specularPower = 64,
n._useAlphaFromDiffuseTexture = !1,
n._useEmissiveAsIllumination = !1,
n._linkEmissiveWithDiffuse = !1,
n._useSpecularOverAlpha = !1,
n._useReflectionOverAlpha = !1,
n._disableLighting = !1,
n._useObjectSpaceNormalMap = !1,
n._useParallax = !1,
n._useParallaxOcclusion = !1,
n.parallaxScaleBias = .05,
n._roughness = 0,
n.indexOfRefraction = .98,
n.invertRefractionY = !0,
n.alphaCutOff = .4,
n._useLightmapAsShadowmap = !1,
n._useReflectionFresnelFromSpecular = !1,
n._useGlossinessFromSpecularMapAlpha = !1,
n._maxSimultaneousLights = 4,
n._invertNormalMapX = !1,
n._invertNormalMapY = !1,
n._twoSidedLighting = !1,
n.detailMap = new DetailMapConfiguration(n._markAllSubMeshesAsTexturesDirty.bind(n)),
n._renderTargets = new SmartArray(16),
n._worldViewProjectionMatrix = Matrix.Zero(),
n._globalAmbientColor = new Color3(0,0,0),
n.buildUniformLayout(),
n._attachImageProcessingConfiguration(null),
n.prePassConfiguration = new PrePassConfiguration,
n.getRenderTargetTextures = function() {
return n._renderTargets.reset(),
e.ReflectionTextureEnabled && n._reflectionTexture && n._reflectionTexture.isRenderTarget && n._renderTargets.push(n._reflectionTexture),
e.RefractionTextureEnabled && n._refractionTexture && n._refractionTexture.isRenderTarget && n._renderTargets.push(n._refractionTexture),
n._renderTargets
}
,
n
}
return Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
get: function() {
return this._imageProcessingConfiguration
},
set: function(t) {
this._attachImageProcessingConfiguration(t),
this._markAllSubMeshesAsTexturesDirty()
},
enumerable: !1,
configurable: !0
}),
e.prototype._attachImageProcessingConfiguration = function(t) {
var r = this;
t !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
t ? this._imageProcessingConfiguration = t : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
r._markAllSubMeshesAsImageProcessingDirty()
})))
}
,
Object.defineProperty(e.prototype, "isPrePassCapable", {
get: function() {
return !this.disableDepthWrite
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraColorCurvesEnabled", {
get: function() {
return this.imageProcessingConfiguration.colorCurvesEnabled
},
set: function(t) {
this.imageProcessingConfiguration.colorCurvesEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraColorGradingEnabled", {
get: function() {
return this.imageProcessingConfiguration.colorGradingEnabled
},
set: function(t) {
this.imageProcessingConfiguration.colorGradingEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraToneMappingEnabled", {
get: function() {
return this._imageProcessingConfiguration.toneMappingEnabled
},
set: function(t) {
this._imageProcessingConfiguration.toneMappingEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraExposure", {
get: function() {
return this._imageProcessingConfiguration.exposure
},
set: function(t) {
this._imageProcessingConfiguration.exposure = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraContrast", {
get: function() {
return this._imageProcessingConfiguration.contrast
},
set: function(t) {
this._imageProcessingConfiguration.contrast = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraColorGradingTexture", {
get: function() {
return this._imageProcessingConfiguration.colorGradingTexture
},
set: function(t) {
this._imageProcessingConfiguration.colorGradingTexture = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraColorCurves", {
get: function() {
return this._imageProcessingConfiguration.colorCurves
},
set: function(t) {
this._imageProcessingConfiguration.colorCurves = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "canRenderToMRT", {
get: function() {
return !0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "hasRenderTargetTextures", {
get: function() {
return !!(e.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget || e.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget)
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "StandardMaterial"
}
,
Object.defineProperty(e.prototype, "useLogarithmicDepth", {
get: function() {
return this._useLogarithmicDepth
},
set: function(t) {
this._useLogarithmicDepth = t && this.getScene().getEngine().getCaps().fragmentDepthSupported,
this._markAllSubMeshesAsMiscDirty()
},
enumerable: !1,
configurable: !0
}),
e.prototype.needAlphaBlending = function() {
return this._disableAlphaBlending ? !1 : this.alpha < 1 || this._opacityTexture != null || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled
}
,
e.prototype.needAlphaTesting = function() {
return this._forceAlphaTest ? !0 : this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === Material.MATERIAL_ALPHATEST)
}
,
e.prototype._shouldUseAlphaFromDiffuseTexture = function() {
return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== Material.MATERIAL_OPAQUE
}
,
e.prototype._hasAlphaChannel = function() {
return this._diffuseTexture != null && this._diffuseTexture.hasAlpha || this._opacityTexture != null
}
,
e.prototype.getAlphaTestTexture = function() {
return this._diffuseTexture
}
,
e.prototype.isReadyForSubMesh = function(t, r, n) {
if (n === void 0 && (n = !1),
r.effect && this.isFrozen && r.effect._wasPreviouslyReady)
return !0;
r.materialDefines || (r.materialDefines = new StandardMaterialDefines);
var o = this.getScene()
, a = r.materialDefines;
if (this._isReadyForSubMesh(r))
return !0;
var s = o.getEngine();
a._needNormals = MaterialHelper.PrepareDefinesForLights(o, t, a, !0, this._maxSimultaneousLights, this._disableLighting),
MaterialHelper.PrepareDefinesForMultiview(o, a);
var l = this.needAlphaBlendingForMesh(t) && this.getScene().useOrderIndependentTransparency;
if (MaterialHelper.PrepareDefinesForPrePass(o, a, this.canRenderToMRT && !l),
MaterialHelper.PrepareDefinesForOIT(o, a, l),
a._areTexturesDirty) {
a._needUVs = !1;
for (var u = 1; u <= 6; ++u)
a["MAINUV" + u] = !1;
if (o.texturesEnabled) {
if (this._diffuseTexture && e.DiffuseTextureEnabled)
if (this._diffuseTexture.isReadyOrNotBlocking())
MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture, a, "DIFFUSE");
else
return !1;
else
a.DIFFUSE = !1;
if (this._ambientTexture && e.AmbientTextureEnabled)
if (this._ambientTexture.isReadyOrNotBlocking())
MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture, a, "AMBIENT");
else
return !1;
else
a.AMBIENT = !1;
if (this._opacityTexture && e.OpacityTextureEnabled)
if (this._opacityTexture.isReadyOrNotBlocking())
MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture, a, "OPACITY"),
a.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
else
return !1;
else
a.OPACITY = !1;
if (this._reflectionTexture && e.ReflectionTextureEnabled)
if (this._reflectionTexture.isReadyOrNotBlocking()) {
switch (a._needNormals = !0,
a.REFLECTION = !0,
a.ROUGHNESS = this._roughness > 0,
a.REFLECTIONOVERALPHA = this._useReflectionOverAlpha,
a.INVERTCUBICMAP = this._reflectionTexture.coordinatesMode === Texture.INVCUBIC_MODE,
a.REFLECTIONMAP_3D = this._reflectionTexture.isCube,
a.RGBDREFLECTION = this._reflectionTexture.isRGBD,
a.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !this._reflectionTexture.invertZ : this._reflectionTexture.invertZ,
this._reflectionTexture.coordinatesMode) {
case Texture.EXPLICIT_MODE:
a.setReflectionMode("REFLECTIONMAP_EXPLICIT");
break;
case Texture.PLANAR_MODE:
a.setReflectionMode("REFLECTIONMAP_PLANAR");
break;
case Texture.PROJECTION_MODE:
a.setReflectionMode("REFLECTIONMAP_PROJECTION");
break;
case Texture.SKYBOX_MODE:
a.setReflectionMode("REFLECTIONMAP_SKYBOX");
break;
case Texture.SPHERICAL_MODE:
a.setReflectionMode("REFLECTIONMAP_SPHERICAL");
break;
case Texture.EQUIRECTANGULAR_MODE:
a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
break;
case Texture.FIXED_EQUIRECTANGULAR_MODE:
a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
break;
case Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
break;
case Texture.CUBIC_MODE:
case Texture.INVCUBIC_MODE:
default:
a.setReflectionMode("REFLECTIONMAP_CUBIC");
break
}
a.USE_LOCAL_REFLECTIONMAP_CUBIC = !!this._reflectionTexture.boundingBoxSize
} else
return !1;
else
a.REFLECTION = !1,
a.REFLECTIONMAP_OPPOSITEZ = !1;
if (this._emissiveTexture && e.EmissiveTextureEnabled)
if (this._emissiveTexture.isReadyOrNotBlocking())
MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture, a, "EMISSIVE");
else
return !1;
else
a.EMISSIVE = !1;
if (this._lightmapTexture && e.LightmapTextureEnabled)
if (this._lightmapTexture.isReadyOrNotBlocking())
MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture, a, "LIGHTMAP"),
a.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
a.RGBDLIGHTMAP = this._lightmapTexture.isRGBD;
else
return !1;
else
a.LIGHTMAP = !1;
if (this._specularTexture && e.SpecularTextureEnabled)
if (this._specularTexture.isReadyOrNotBlocking())
MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture, a, "SPECULAR"),
a.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
else
return !1;
else
a.SPECULAR = !1;
if (o.getEngine().getCaps().standardDerivatives && this._bumpTexture && e.BumpTextureEnabled) {
if (this._bumpTexture.isReady())
MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture, a, "BUMP"),
a.PARALLAX = this._useParallax,
a.PARALLAXOCCLUSION = this._useParallaxOcclusion;
else
return !1;
a.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap
} else
a.BUMP = !1;
if (this._refractionTexture && e.RefractionTextureEnabled)
if (this._refractionTexture.isReadyOrNotBlocking())
a._needUVs = !0,
a.REFRACTION = !0,
a.REFRACTIONMAP_3D = this._refractionTexture.isCube,
a.RGBDREFRACTION = this._refractionTexture.isRGBD,
a.USE_LOCAL_REFRACTIONMAP_CUBIC = !!this._refractionTexture.boundingBoxSize;
else
return !1;
else
a.REFRACTION = !1;
a.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting
} else
a.DIFFUSE = !1,
a.AMBIENT = !1,
a.OPACITY = !1,
a.REFLECTION = !1,
a.EMISSIVE = !1,
a.LIGHTMAP = !1,
a.BUMP = !1,
a.REFRACTION = !1;
a.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture(),
a.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination,
a.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse,
a.SPECULAROVERALPHA = this._useSpecularOverAlpha,
a.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8,
a.ALPHATEST_AFTERALLALPHACOMPUTATIONS = this.transparencyMode !== null,
a.ALPHABLEND = this.transparencyMode === null || this.needAlphaBlendingForMesh(t)
}
if (!this.detailMap.isReadyForSubMesh(a, o))
return !1;
if (a._areImageProcessingDirty && this._imageProcessingConfiguration) {
if (!this._imageProcessingConfiguration.isReady())
return !1;
this._imageProcessingConfiguration.prepareDefines(a),
a.IS_REFLECTION_LINEAR = this.reflectionTexture != null && !this.reflectionTexture.gammaSpace,
a.IS_REFRACTION_LINEAR = this.refractionTexture != null && !this.refractionTexture.gammaSpace
}
if (a._areFresnelDirty && (e.FresnelEnabled ? (this._diffuseFresnelParameters || this._opacityFresnelParameters || this._emissiveFresnelParameters || this._refractionFresnelParameters || this._reflectionFresnelParameters) && (a.DIFFUSEFRESNEL = this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled,
a.OPACITYFRESNEL = this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled,
a.REFLECTIONFRESNEL = this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled,
a.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular,
a.REFRACTIONFRESNEL = this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled,
a.EMISSIVEFRESNEL = this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled,
a._needNormals = !0,
a.FRESNEL = !0) : a.FRESNEL = !1),
MaterialHelper.PrepareDefinesForMisc(t, o, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(t) || this._forceAlphaTest, a),
MaterialHelper.PrepareDefinesForAttributes(t, a, !0, !0, !0),
MaterialHelper.PrepareDefinesForFrameBoundValues(o, s, a, n, null, r.getRenderingMesh().hasThinInstances),
this.detailMap.prepareDefines(a, o),
a.isDirty) {
var c = a._areLightsDisposed;
a.markAsProcessed();
var h = new EffectFallbacks;
a.REFLECTION && h.addFallback(0, "REFLECTION"),
a.SPECULAR && h.addFallback(0, "SPECULAR"),
a.BUMP && h.addFallback(0, "BUMP"),
a.PARALLAX && h.addFallback(1, "PARALLAX"),
a.PARALLAXOCCLUSION && h.addFallback(0, "PARALLAXOCCLUSION"),
a.SPECULAROVERALPHA && h.addFallback(0, "SPECULAROVERALPHA"),
a.FOG && h.addFallback(1, "FOG"),
a.POINTSIZE && h.addFallback(0, "POINTSIZE"),
a.LOGARITHMICDEPTH && h.addFallback(0, "LOGARITHMICDEPTH"),
MaterialHelper.HandleFallbacksForShadows(a, h, this._maxSimultaneousLights),
a.SPECULARTERM && h.addFallback(0, "SPECULARTERM"),
a.DIFFUSEFRESNEL && h.addFallback(1, "DIFFUSEFRESNEL"),
a.OPACITYFRESNEL && h.addFallback(2, "OPACITYFRESNEL"),
a.REFLECTIONFRESNEL && h.addFallback(3, "REFLECTIONFRESNEL"),
a.EMISSIVEFRESNEL && h.addFallback(4, "EMISSIVEFRESNEL"),
a.FRESNEL && h.addFallback(4, "FRESNEL"),
a.MULTIVIEW && h.addFallback(0, "MULTIVIEW");
var f = [VertexBuffer.PositionKind];
a.NORMAL && f.push(VertexBuffer.NormalKind),
a.TANGENT && f.push(VertexBuffer.TangentKind);
for (var u = 1; u <= 6; ++u)
a["UV" + u] && f.push("uv" + (u === 1 ? "" : u));
a.VERTEXCOLOR && f.push(VertexBuffer.ColorKind),
MaterialHelper.PrepareAttributesForBones(f, t, a, h),
MaterialHelper.PrepareAttributesForInstances(f, a),
MaterialHelper.PrepareAttributesForMorphTargets(f, t, a),
MaterialHelper.PrepareAttributesForBakedVertexAnimation(f, t, a);
var d = "default"
, _ = ["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", "vRefractionPosition", "vRefractionSize", "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth", "morphTargetTextureInfo", "morphTargetTextureIndices"]
, g = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler", "boneSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
, m = ["Material", "Scene", "Mesh"];
DetailMapConfiguration.AddUniforms(_),
DetailMapConfiguration.AddSamplers(g),
PrePassConfiguration.AddUniforms(_),
PrePassConfiguration.AddSamplers(g),
ImageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(_, a),
ImageProcessingConfiguration.PrepareSamplers(g, a)),
MaterialHelper.PrepareUniformsAndSamplersList({
uniformsNames: _,
uniformBuffersNames: m,
samplers: g,
defines: a,
maxSimultaneousLights: this._maxSimultaneousLights
});
var v = {};
this.customShaderNameResolve && (d = this.customShaderNameResolve(d, _, m, g, a, f, v));
var y = a.toString()
, b = r.effect
, T = o.getEngine().createEffect(d, {
attributes: f,
uniformsNames: _,
uniformBuffersNames: m,
samplers: g,
defines: y,
fallbacks: h,
onCompiled: this.onCompiled,
onError: this.onError,
indexParameters: {
maxSimultaneousLights: this._maxSimultaneousLights,
maxSimultaneousMorphTargets: a.NUM_MORPH_INFLUENCERS
},
processFinalCode: v.processFinalCode,
multiTarget: a.PREPASS
}, s);
if (T)
if (this._onEffectCreatedObservable && (onCreatedEffectParameters$2.effect = T,
onCreatedEffectParameters$2.subMesh = r,
this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters$2)),
this.allowShaderHotSwapping && b && !T.isReady()) {
if (T = b,
a.markAsUnprocessed(),
c)
return a._areLightsDisposed = !0,
!1
} else
o.resetCachedMaterial(),
r.setEffect(T, a, this._materialContext)
}
return !r.effect || !r.effect.isReady() ? !1 : (a._renderId = o.getRenderId(),
r.effect._wasPreviouslyReady = !0,
!0)
}
,
e.prototype.buildUniformLayout = function() {
var t = this._uniformBuffer;
t.addUniform("diffuseLeftColor", 4),
t.addUniform("diffuseRightColor", 4),
t.addUniform("opacityParts", 4),
t.addUniform("reflectionLeftColor", 4),
t.addUniform("reflectionRightColor", 4),
t.addUniform("refractionLeftColor", 4),
t.addUniform("refractionRightColor", 4),
t.addUniform("emissiveLeftColor", 4),
t.addUniform("emissiveRightColor", 4),
t.addUniform("vDiffuseInfos", 2),
t.addUniform("vAmbientInfos", 2),
t.addUniform("vOpacityInfos", 2),
t.addUniform("vReflectionInfos", 2),
t.addUniform("vReflectionPosition", 3),
t.addUniform("vReflectionSize", 3),
t.addUniform("vEmissiveInfos", 2),
t.addUniform("vLightmapInfos", 2),
t.addUniform("vSpecularInfos", 2),
t.addUniform("vBumpInfos", 3),
t.addUniform("diffuseMatrix", 16),
t.addUniform("ambientMatrix", 16),
t.addUniform("opacityMatrix", 16),
t.addUniform("reflectionMatrix", 16),
t.addUniform("emissiveMatrix", 16),
t.addUniform("lightmapMatrix", 16),
t.addUniform("specularMatrix", 16),
t.addUniform("bumpMatrix", 16),
t.addUniform("vTangentSpaceParams", 2),
t.addUniform("pointSize", 1),
t.addUniform("alphaCutOff", 1),
t.addUniform("refractionMatrix", 16),
t.addUniform("vRefractionInfos", 4),
t.addUniform("vRefractionPosition", 3),
t.addUniform("vRefractionSize", 3),
t.addUniform("vSpecularColor", 4),
t.addUniform("vEmissiveColor", 3),
t.addUniform("vDiffuseColor", 4),
t.addUniform("vAmbientColor", 3),
DetailMapConfiguration.PrepareUniformBuffer(t),
t.create()
}
,
e.prototype.unbind = function() {
if (this._activeEffect && !this.getScene().getEngine()._features.needToAlwaysBindUniformBuffers) {
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()
}
i.prototype.unbind.call(this)
}
,
e.prototype.bindForSubMesh = function(t, r, n) {
var o, a = this.getScene(), s = n.materialDefines;
if (!!s) {
var l = n.effect;
if (!!l) {
this._activeEffect = l,
r.getMeshUniformBuffer().bindToEffect(l, "Mesh"),
r.transferToEffect(t),
this.prePassConfiguration.bindForSubMesh(this._activeEffect, a, r, t, this.isFrozen),
s.OBJECTSPACE_NORMALMAP && (t.toNormalMatrix(this._normalMatrix),
this.bindOnlyNormalMatrix(this._normalMatrix));
var u = this._mustRebind(a, l, r.visibility);
MaterialHelper.BindBonesParameters(r, l);
var c = this._uniformBuffer;
if (u) {
if (c.bindToEffect(l, "Material"),
this.bindViewProjection(l),
!c.useUbo || !this.isFrozen || !c.isSync) {
if (e.FresnelEnabled && s.FRESNEL && (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled && (c.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power),
c.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias)),
this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled && c.updateColor4("opacityParts", new Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power),
this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled && (c.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power),
c.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias)),
this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled && (c.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power),
c.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias)),
this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled && (c.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power),
c.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias))),
a.texturesEnabled) {
if (this._diffuseTexture && e.DiffuseTextureEnabled && (c.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
MaterialHelper.BindTextureMatrix(this._diffuseTexture, c, "diffuse")),
this._ambientTexture && e.AmbientTextureEnabled && (c.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level),
MaterialHelper.BindTextureMatrix(this._ambientTexture, c, "ambient")),
this._opacityTexture && e.OpacityTextureEnabled && (c.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
MaterialHelper.BindTextureMatrix(this._opacityTexture, c, "opacity")),
this._hasAlphaChannel() && c.updateFloat("alphaCutOff", this.alphaCutOff),
this._reflectionTexture && e.ReflectionTextureEnabled && (c.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness),
c.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix()),
this._reflectionTexture.boundingBoxSize)) {
var h = this._reflectionTexture;
c.updateVector3("vReflectionPosition", h.boundingBoxPosition),
c.updateVector3("vReflectionSize", h.boundingBoxSize)
}
if (this._emissiveTexture && e.EmissiveTextureEnabled && (c.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
MaterialHelper.BindTextureMatrix(this._emissiveTexture, c, "emissive")),
this._lightmapTexture && e.LightmapTextureEnabled && (c.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
MaterialHelper.BindTextureMatrix(this._lightmapTexture, c, "lightmap")),
this._specularTexture && e.SpecularTextureEnabled && (c.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level),
MaterialHelper.BindTextureMatrix(this._specularTexture, c, "specular")),
this._bumpTexture && a.getEngine().getCaps().standardDerivatives && e.BumpTextureEnabled && (c.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1 / this._bumpTexture.level, this.parallaxScaleBias),
MaterialHelper.BindTextureMatrix(this._bumpTexture, c, "bump"),
a._mirroredCameraPosition ? c.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : c.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1)),
this._refractionTexture && e.RefractionTextureEnabled) {
var f = 1;
if (this._refractionTexture.isCube || (c.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix()),
this._refractionTexture.depth && (f = this._refractionTexture.depth)),
c.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, f, this.invertRefractionY ? -1 : 1),
this._refractionTexture.boundingBoxSize) {
var h = this._refractionTexture;
c.updateVector3("vRefractionPosition", h.boundingBoxPosition),
c.updateVector3("vRefractionSize", h.boundingBoxSize)
}
}
}
this.pointsCloud && c.updateFloat("pointSize", this.pointSize),
s.SPECULARTERM && c.updateColor4("vSpecularColor", this.specularColor, this.specularPower),
c.updateColor3("vEmissiveColor", e.EmissiveTextureEnabled ? this.emissiveColor : Color3.BlackReadOnly),
c.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha),
a.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor),
c.updateColor3("vAmbientColor", this._globalAmbientColor)
}
if (a.texturesEnabled && (this._diffuseTexture && e.DiffuseTextureEnabled && l.setTexture("diffuseSampler", this._diffuseTexture),
this._ambientTexture && e.AmbientTextureEnabled && l.setTexture("ambientSampler", this._ambientTexture),
this._opacityTexture && e.OpacityTextureEnabled && l.setTexture("opacitySampler", this._opacityTexture),
this._reflectionTexture && e.ReflectionTextureEnabled && (this._reflectionTexture.isCube ? l.setTexture("reflectionCubeSampler", this._reflectionTexture) : l.setTexture("reflection2DSampler", this._reflectionTexture)),
this._emissiveTexture && e.EmissiveTextureEnabled && l.setTexture("emissiveSampler", this._emissiveTexture),
this._lightmapTexture && e.LightmapTextureEnabled && l.setTexture("lightmapSampler", this._lightmapTexture),
this._specularTexture && e.SpecularTextureEnabled && l.setTexture("specularSampler", this._specularTexture),
this._bumpTexture && a.getEngine().getCaps().standardDerivatives && e.BumpTextureEnabled && l.setTexture("bumpSampler", this._bumpTexture),
this._refractionTexture && e.RefractionTextureEnabled)) {
var f = 1;
this._refractionTexture.isCube ? l.setTexture("refractionCubeSampler", this._refractionTexture) : l.setTexture("refraction2DSampler", this._refractionTexture)
}
this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(r) && this.getScene().depthPeelingRenderer.bind(l),
this.detailMap.bindForSubMesh(c, a, this.isFrozen),
MaterialHelper.BindClipPlane(l, a),
this.bindEyePosition(l)
} else
a.getEngine()._features.needToAlwaysBindUniformBuffers && (c.bindToEffect(l, "Material"),
this._needToBindSceneUbo = !0);
(u || !this.isFrozen) && (a.lightsEnabled && !this._disableLighting && MaterialHelper.BindLights(a, r, l, s, this._maxSimultaneousLights),
(a.fogEnabled && r.applyFog && a.fogMode !== Scene.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture || r.receiveShadows) && this.bindView(l),
MaterialHelper.BindFogParameters(a, r, l),
s.NUM_MORPH_INFLUENCERS && MaterialHelper.BindMorphTargetParameters(r, l),
s.BAKED_VERTEX_ANIMATION_TEXTURE && ((o = r.bakedVertexAnimationManager) === null || o === void 0 || o.bind(l, s.INSTANCES)),
this.useLogarithmicDepth && MaterialHelper.BindLogDepth(s, l, a),
this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(this._activeEffect)),
this._afterBind(r, this._activeEffect),
c.update()
}
}
}
,
e.prototype.getAnimatables = function() {
var t = [];
return this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0 && t.push(this._diffuseTexture),
this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && t.push(this._ambientTexture),
this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && t.push(this._opacityTexture),
this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && t.push(this._reflectionTexture),
this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && t.push(this._emissiveTexture),
this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0 && t.push(this._specularTexture),
this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && t.push(this._bumpTexture),
this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && t.push(this._lightmapTexture),
this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && t.push(this._refractionTexture),
this.detailMap.getAnimatables(t),
t
}
,
e.prototype.getActiveTextures = function() {
var t = i.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
}
,
e.prototype.hasTexture = function(t) {
return !!(i.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))
}
,
e.prototype.dispose = function(t, r) {
var n, o, a, s, l, u, c, h, f;
r && ((n = this._diffuseTexture) === null || n === void 0 || n.dispose(),
(o = this._ambientTexture) === null || o === void 0 || o.dispose(),
(a = this._opacityTexture) === null || a === void 0 || a.dispose(),
(s = this._reflectionTexture) === null || s === void 0 || s.dispose(),
(l = this._emissiveTexture) === null || l === void 0 || l.dispose(),
(u = this._specularTexture) === null || u === void 0 || u.dispose(),
(c = this._bumpTexture) === null || c === void 0 || c.dispose(),
(h = this._lightmapTexture) === null || h === void 0 || h.dispose(),
(f = this._refractionTexture) === null || f === void 0 || f.dispose()),
this.detailMap.dispose(r),
this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
i.prototype.dispose.call(this, t, r)
}
,
e.prototype.clone = function(t) {
var r = this
, n = SerializationHelper.Clone(function() {
return new e(t,r.getScene())
}, this);
return n.name = t,
n.id = t,
this.stencil.copyTo(n.stencil),
n
}
,
e.prototype.serialize = function() {
var t = SerializationHelper.Serialize(this);
return t.stencil = this.stencil.serialize(),
t
}
,
e.Parse = function(t, r, n) {
var o = SerializationHelper.Parse(function() {
return new e(t.name,r)
}, t, r, n);
return t.stencil && o.stencil.parse(t.stencil, r, n),
o
}
,
Object.defineProperty(e, "DiffuseTextureEnabled", {
get: function() {
return MaterialFlags.DiffuseTextureEnabled
},
set: function(t) {
MaterialFlags.DiffuseTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "DetailTextureEnabled", {
get: function() {
return MaterialFlags.DetailTextureEnabled
},
set: function(t) {
MaterialFlags.DetailTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "AmbientTextureEnabled", {
get: function() {
return MaterialFlags.AmbientTextureEnabled
},
set: function(t) {
MaterialFlags.AmbientTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "OpacityTextureEnabled", {
get: function() {
return MaterialFlags.OpacityTextureEnabled
},
set: function(t) {
MaterialFlags.OpacityTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "ReflectionTextureEnabled", {
get: function() {
return MaterialFlags.ReflectionTextureEnabled
},
set: function(t) {
MaterialFlags.ReflectionTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "EmissiveTextureEnabled", {
get: function() {
return MaterialFlags.EmissiveTextureEnabled
},
set: function(t) {
MaterialFlags.EmissiveTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "SpecularTextureEnabled", {
get: function() {
return MaterialFlags.SpecularTextureEnabled
},
set: function(t) {
MaterialFlags.SpecularTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "BumpTextureEnabled", {
get: function() {
return MaterialFlags.BumpTextureEnabled
},
set: function(t) {
MaterialFlags.BumpTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "LightmapTextureEnabled", {
get: function() {
return MaterialFlags.LightmapTextureEnabled
},
set: function(t) {
MaterialFlags.LightmapTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "RefractionTextureEnabled", {
get: function() {
return MaterialFlags.RefractionTextureEnabled
},
set: function(t) {
MaterialFlags.RefractionTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "ColorGradingTextureEnabled", {
get: function() {
return MaterialFlags.ColorGradingTextureEnabled
},
set: function(t) {
MaterialFlags.ColorGradingTextureEnabled = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "FresnelEnabled", {
get: function() {
return MaterialFlags.FresnelEnabled
},
set: function(t) {
MaterialFlags.FresnelEnabled = t
},
enumerable: !1,
configurable: !0
}),
__decorate([serializeAsTexture("diffuseTexture")], e.prototype, "_diffuseTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "diffuseTexture", void 0),
__decorate([serializeAsTexture("ambientTexture")], e.prototype, "_ambientTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientTexture", void 0),
__decorate([serializeAsTexture("opacityTexture")], e.prototype, "_opacityTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "opacityTexture", void 0),
__decorate([serializeAsTexture("reflectionTexture")], e.prototype, "_reflectionTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionTexture", void 0),
__decorate([serializeAsTexture("emissiveTexture")], e.prototype, "_emissiveTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "emissiveTexture", void 0),
__decorate([serializeAsTexture("specularTexture")], e.prototype, "_specularTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "specularTexture", void 0),
__decorate([serializeAsTexture("bumpTexture")], e.prototype, "_bumpTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "bumpTexture", void 0),
__decorate([serializeAsTexture("lightmapTexture")], e.prototype, "_lightmapTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "lightmapTexture", void 0),
__decorate([serializeAsTexture("refractionTexture")], e.prototype, "_refractionTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "refractionTexture", void 0),
__decorate([serializeAsColor3("ambient")], e.prototype, "ambientColor", void 0),
__decorate([serializeAsColor3("diffuse")], e.prototype, "diffuseColor", void 0),
__decorate([serializeAsColor3("specular")], e.prototype, "specularColor", void 0),
__decorate([serializeAsColor3("emissive")], e.prototype, "emissiveColor", void 0),
__decorate([serialize()], e.prototype, "specularPower", void 0),
__decorate([serialize("useAlphaFromDiffuseTexture")], e.prototype, "_useAlphaFromDiffuseTexture", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "useAlphaFromDiffuseTexture", void 0),
__decorate([serialize("useEmissiveAsIllumination")], e.prototype, "_useEmissiveAsIllumination", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useEmissiveAsIllumination", void 0),
__decorate([serialize("linkEmissiveWithDiffuse")], e.prototype, "_linkEmissiveWithDiffuse", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "linkEmissiveWithDiffuse", void 0),
__decorate([serialize("useSpecularOverAlpha")], e.prototype, "_useSpecularOverAlpha", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useSpecularOverAlpha", void 0),
__decorate([serialize("useReflectionOverAlpha")], e.prototype, "_useReflectionOverAlpha", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useReflectionOverAlpha", void 0),
__decorate([serialize("disableLighting")], e.prototype, "_disableLighting", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "disableLighting", void 0),
__decorate([serialize("useObjectSpaceNormalMap")], e.prototype, "_useObjectSpaceNormalMap", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useObjectSpaceNormalMap", void 0),
__decorate([serialize("useParallax")], e.prototype, "_useParallax", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallax", void 0),
__decorate([serialize("useParallaxOcclusion")], e.prototype, "_useParallaxOcclusion", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallaxOcclusion", void 0),
__decorate([serialize()], e.prototype, "parallaxScaleBias", void 0),
__decorate([serialize("roughness")], e.prototype, "_roughness", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "roughness", void 0),
__decorate([serialize()], e.prototype, "indexOfRefraction", void 0),
__decorate([serialize()], e.prototype, "invertRefractionY", void 0),
__decorate([serialize()], e.prototype, "alphaCutOff", void 0),
__decorate([serialize("useLightmapAsShadowmap")], e.prototype, "_useLightmapAsShadowmap", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useLightmapAsShadowmap", void 0),
__decorate([serializeAsFresnelParameters("diffuseFresnelParameters")], e.prototype, "_diffuseFresnelParameters", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "diffuseFresnelParameters", void 0),
__decorate([serializeAsFresnelParameters("opacityFresnelParameters")], e.prototype, "_opacityFresnelParameters", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")], e.prototype, "opacityFresnelParameters", void 0),
__decorate([serializeAsFresnelParameters("reflectionFresnelParameters")], e.prototype, "_reflectionFresnelParameters", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "reflectionFresnelParameters", void 0),
__decorate([serializeAsFresnelParameters("refractionFresnelParameters")], e.prototype, "_refractionFresnelParameters", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "refractionFresnelParameters", void 0),
__decorate([serializeAsFresnelParameters("emissiveFresnelParameters")], e.prototype, "_emissiveFresnelParameters", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "emissiveFresnelParameters", void 0),
__decorate([serialize("useReflectionFresnelFromSpecular")], e.prototype, "_useReflectionFresnelFromSpecular", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "useReflectionFresnelFromSpecular", void 0),
__decorate([serialize("useGlossinessFromSpecularMapAlpha")], e.prototype, "_useGlossinessFromSpecularMapAlpha", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useGlossinessFromSpecularMapAlpha", void 0),
__decorate([serialize("maxSimultaneousLights")], e.prototype, "_maxSimultaneousLights", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "maxSimultaneousLights", void 0),
__decorate([serialize("invertNormalMapX")], e.prototype, "_invertNormalMapX", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapX", void 0),
__decorate([serialize("invertNormalMapY")], e.prototype, "_invertNormalMapY", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapY", void 0),
__decorate([serialize("twoSidedLighting")], e.prototype, "_twoSidedLighting", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "twoSidedLighting", void 0),
__decorate([serialize()], e.prototype, "useLogarithmicDepth", null),
e
}(PushMaterial);
RegisterClass("BABYLON.StandardMaterial", StandardMaterial);
Scene.DefaultMaterialFactory = function(i) {
return new StandardMaterial("default material",i)
}
;
ThinEngine.prototype._createDepthStencilCubeTexture = function(i, e, t) {
var r = new InternalTexture(this,InternalTextureSource.DepthStencil);
if (r.isCube = !0,
this.webGLVersion === 1)
return Logger$2.Error("Depth cube texture is not supported by WebGL 1."),
r;
var n = __assign({
bilinearFiltering: !1,
comparisonFunction: 0,
generateStencil: !1
}, e)
, o = this._gl;
this._bindTextureDirectly(o.TEXTURE_CUBE_MAP, r, !0),
this._setupDepthStencilTexture(r, i, n.generateStencil, n.bilinearFiltering, n.comparisonFunction),
t._depthStencilTexture = r,
t._depthStencilTextureWithStencil = n.generateStencil;
for (var a = 0; a < 6; a++)
n.generateStencil ? o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X + a, 0, o.DEPTH24_STENCIL8, i, i, 0, o.DEPTH_STENCIL, o.UNSIGNED_INT_24_8, null) : o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X + a, 0, o.DEPTH_COMPONENT24, i, i, 0, o.DEPTH_COMPONENT, o.UNSIGNED_INT, null);
return this._bindTextureDirectly(o.TEXTURE_CUBE_MAP, null),
this._internalTexturesCache.push(r),
r
}
;
ThinEngine.prototype._partialLoadFile = function(i, e, t, r, n) {
n === void 0 && (n = null);
var o = function(s) {
t[e] = s,
t._internalCount++,
t._internalCount === 6 && r(t)
}
, a = function(s, l) {
n && s && n(s.status + " " + s.statusText, l)
};
this._loadFile(i, o, void 0, void 0, !0, a)
}
;
ThinEngine.prototype._cascadeLoadFiles = function(i, e, t, r) {
r === void 0 && (r = null);
var n = [];
n._internalCount = 0;
for (var o = 0; o < 6; o++)
this._partialLoadFile(t[o], o, n, e, r)
}
;
ThinEngine.prototype._cascadeLoadImgs = function(i, e, t, r, n, o) {
n === void 0 && (n = null);
var a = [];
a._internalCount = 0;
for (var s = 0; s < 6; s++)
this._partialLoadImg(r[s], s, a, i, e, t, n, o)
}
;
ThinEngine.prototype._partialLoadImg = function(i, e, t, r, n, o, a, s) {
a === void 0 && (a = null);
var l = RandomGUID()
, u = function(h) {
t[e] = h,
t._internalCount++,
r && r._removePendingData(l),
t._internalCount === 6 && o && o(n, t)
}
, c = function(h, f) {
r && r._removePendingData(l),
a && a(h, f)
};
LoadImage(i, u, c, r ? r.offlineProvider : null, s),
r && r._addPendingData(l)
}
;
ThinEngine.prototype._setCubeMapTextureParams = function(i, e) {
var t = this._gl;
t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_MAG_FILTER, t.LINEAR),
t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_MIN_FILTER, e ? t.LINEAR_MIPMAP_LINEAR : t.LINEAR),
t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE),
t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE),
i.samplingMode = e ? 3 : 2,
this._bindTextureDirectly(t.TEXTURE_CUBE_MAP, null)
}
;
ThinEngine.prototype.createCubeTextureBase = function(i, e, t, r, n, o, a, s, l, u, c, h, f, d, _) {
var g = this;
n === void 0 && (n = null),
o === void 0 && (o = null),
s === void 0 && (s = null),
l === void 0 && (l = !1),
u === void 0 && (u = 0),
c === void 0 && (c = 0),
h === void 0 && (h = null),
f === void 0 && (f = null),
d === void 0 && (d = null),
_ === void 0 && (_ = !1);
var m = h || new InternalTexture(this,InternalTextureSource.Cube);
m.isCube = !0,
m.url = i,
m.generateMipMaps = !r,
m._lodGenerationScale = u,
m._lodGenerationOffset = c,
m._useSRGBBuffer = !!_ && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || !!r),
this._doNotHandleContextLost || (m._extension = s,
m._files = t);
var v = i;
this._transformTextureUrl && !h && (i = this._transformTextureUrl(i));
for (var y = i.lastIndexOf("."), b = s || (y > -1 ? i.substring(y).toLowerCase() : ""), T = null, C = 0, A = ThinEngine._TextureLoaders; C < A.length; C++) {
var S = A[C];
if (S.canLoad(b)) {
T = S;
break
}
}
var P = function(M, x) {
i === v ? o && M && o(M.status + " " + M.statusText, x) : (Logger$2.Warn("Failed to load " + i + ", falling back to the " + v),
g.createCubeTextureBase(v, e, t, !!r, n, o, a, s, l, u, c, m, f, d, _))
};
if (T) {
var R = function(M) {
f && f(m, M),
T.loadCubeData(M, m, l, n, o)
};
t && t.length === 6 ? T.supportCascades ? this._cascadeLoadFiles(e, function(M) {
return R(M.map(function(x) {
return new Uint8Array(x)
}))
}, t, o) : o ? o("Textures type does not support cascades.") : Logger$2.Warn("Texture loader does not support cascades.") : this._loadFile(i, function(M) {
return R(new Uint8Array(M))
}, void 0, void 0, !0, P)
} else {
if (!t)
throw new Error("Cannot load cubemap because files were not defined");
this._cascadeLoadImgs(e, m, function(M, x) {
d && d(M, x)
}, t, o)
}
return this._internalTexturesCache.push(m),
m
}
;
ThinEngine.prototype.createCubeTexture = function(i, e, t, r, n, o, a, s, l, u, c, h, f, d) {
var _ = this;
n === void 0 && (n = null),
o === void 0 && (o = null),
s === void 0 && (s = null),
l === void 0 && (l = !1),
u === void 0 && (u = 0),
c === void 0 && (c = 0),
h === void 0 && (h = null),
d === void 0 && (d = !1);
var g = this._gl;
return this.createCubeTextureBase(i, e, t, !!r, n, o, a, s, l, u, c, h, function(m, v) {
return _._bindTextureDirectly(g.TEXTURE_CUBE_MAP, m, !0)
}, function(m, v) {
var y = _.needPOTTextures ? ThinEngine.GetExponentOfTwo(v[0].width, _._caps.maxCubemapTextureSize) : v[0].width
, b = y
, T = [g.TEXTURE_CUBE_MAP_POSITIVE_X, g.TEXTURE_CUBE_MAP_POSITIVE_Y, g.TEXTURE_CUBE_MAP_POSITIVE_Z, g.TEXTURE_CUBE_MAP_NEGATIVE_X, g.TEXTURE_CUBE_MAP_NEGATIVE_Y, g.TEXTURE_CUBE_MAP_NEGATIVE_Z];
_._bindTextureDirectly(g.TEXTURE_CUBE_MAP, m, !0),
_._unpackFlipY(!1);
var C = a ? _._getInternalFormat(a, m._useSRGBBuffer) : m._useSRGBBuffer ? g.SRGB8_ALPHA8 : g.RGBA
, A = a ? _._getInternalFormat(a) : g.RGBA;
m._useSRGBBuffer && _.webGLVersion === 1 && (A = C);
for (var S = 0; S < T.length; S++)
if (v[S].width !== y || v[S].height !== b) {
if (_._prepareWorkingCanvas(),
!_._workingCanvas || !_._workingContext) {
Logger$2.Warn("Cannot create canvas to resize texture.");
return
}
_._workingCanvas.width = y,
_._workingCanvas.height = b,
_._workingContext.drawImage(v[S], 0, 0, v[S].width, v[S].height, 0, 0, y, b),
g.texImage2D(T[S], 0, C, A, g.UNSIGNED_BYTE, _._workingCanvas)
} else
g.texImage2D(T[S], 0, C, A, g.UNSIGNED_BYTE, v[S]);
r || g.generateMipmap(g.TEXTURE_CUBE_MAP),
_._setCubeMapTextureParams(m, !r),
m.width = y,
m.height = b,
m.isReady = !0,
a && (m.format = a),
m.onLoadedObservable.notifyObservers(m),
m.onLoadedObservable.clear(),
n && n()
}, !!d)
}
;
var CubeTexture = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u, c, h, f, d, _, g, m) {
n === void 0 && (n = null),
o === void 0 && (o = !1),
a === void 0 && (a = null),
s === void 0 && (s = null),
l === void 0 && (l = null),
u === void 0 && (u = 5),
c === void 0 && (c = !1),
h === void 0 && (h = null),
f === void 0 && (f = !1),
d === void 0 && (d = .8),
_ === void 0 && (_ = 0);
var v, y = i.call(this, r) || this;
return y._lodScale = .8,
y._lodOffset = 0,
y.onLoadObservable = new Observable,
y.boundingBoxPosition = Vector3.Zero(),
y._rotationY = 0,
y._files = null,
y._forcedExtension = null,
y._extensions = null,
y.name = t,
y.url = t,
y._noMipmap = o,
y.hasAlpha = !1,
y._format = u,
y.isCube = !0,
y._textureMatrix = Matrix.Identity(),
y._createPolynomials = f,
y.coordinatesMode = Texture.CUBIC_MODE,
y._extensions = n,
y._files = a,
y._forcedExtension = h,
y._loaderOptions = g,
y._useSRGBBuffer = m,
y._lodScale = d,
y._lodOffset = _,
!t && !a || y.updateURL(t, h, s, c, l, n, (v = y.getScene()) === null || v === void 0 ? void 0 : v.useDelayedTextureLoading, a),
y
}
return Object.defineProperty(e.prototype, "boundingBoxSize", {
get: function() {
return this._boundingBoxSize
},
set: function(t) {
if (!(this._boundingBoxSize && this._boundingBoxSize.equals(t))) {
this._boundingBoxSize = t;
var r = this.getScene();
r && r.markAllMaterialsAsDirty(1)
}
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rotationY", {
get: function() {
return this._rotationY
},
set: function(t) {
this._rotationY = t,
this.setReflectionTextureMatrix(Matrix.RotationY(this._rotationY))
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "noMipmap", {
get: function() {
return this._noMipmap
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "forcedExtension", {
get: function() {
return this._forcedExtension
},
enumerable: !1,
configurable: !0
}),
e.CreateFromImages = function(t, r, n) {
var o = "";
return t.forEach(function(a) {
return o += a
}),
new e(o,r,null,n,t)
}
,
e.CreateFromPrefilteredData = function(t, r, n, o) {
n === void 0 && (n = null),
o === void 0 && (o = !0);
var a = r.useDelayedTextureLoading;
r.useDelayedTextureLoading = !1;
var s = new e(t,r,null,!1,null,null,null,void 0,!0,n,o);
return r.useDelayedTextureLoading = a,
s
}
,
e.prototype.getClassName = function() {
return "CubeTexture"
}
,
e.prototype.updateURL = function(t, r, n, o, a, s, l, u) {
n === void 0 && (n = null),
o === void 0 && (o = !1),
a === void 0 && (a = null),
s === void 0 && (s = null),
l === void 0 && (l = !1),
u === void 0 && (u = null),
(!this.name || StartsWith(this.name, "data:")) && (this.name = t),
this.url = t;
var c = t.lastIndexOf(".")
, h = r || (c > -1 ? t.substring(c).toLowerCase() : "")
, f = h.indexOf(".dds") === 0
, d = h.indexOf(".env") === 0;
if (d ? (this.gammaSpace = !1,
this._prefiltered = !1,
this.anisotropicFilteringLevel = 1) : (this._prefiltered = o,
o && (this.gammaSpace = !1,
this.anisotropicFilteringLevel = 1)),
u)
this._files = u;
else if (!d && !f && !s && (s = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"]),
this._files = this._files || [],
this._files.length = 0,
s) {
for (var _ = 0; _ < s.length; _++)
this._files.push(t + s[_]);
this._extensions = s
}
l ? (this.delayLoadState = 4,
this._delayedOnLoad = n,
this._delayedOnError = a) : this._loadTexture(n, a)
}
,
e.prototype.delayLoad = function(t) {
this.delayLoadState === 4 && (t && (this._forcedExtension = t),
this.delayLoadState = 1,
this._loadTexture(this._delayedOnLoad, this._delayedOnError))
}
,
e.prototype.getReflectionTextureMatrix = function() {
return this._textureMatrix
}
,
e.prototype.setReflectionTextureMatrix = function(t) {
var r = this, n;
t.updateFlag !== this._textureMatrix.updateFlag && (t.isIdentity() !== this._textureMatrix.isIdentity() && ((n = this.getScene()) === null || n === void 0 || n.markAllMaterialsAsDirty(1, function(o) {
return o.getActiveTextures().indexOf(r) !== -1
})),
this._textureMatrix = t)
}
,
e.prototype._loadTexture = function(t, r) {
var n = this, o;
t === void 0 && (t = null),
r === void 0 && (r = null);
var a = this.getScene()
, s = this._texture;
this._texture = this._getFromCache(this.url, this._noMipmap, void 0, void 0, this._useSRGBBuffer);
var l = function() {
var c;
n.onLoadObservable.notifyObservers(n),
s && (s.dispose(),
(c = n.getScene()) === null || c === void 0 || c.markAllMaterialsAsDirty(1)),
t && t()
}
, u = function(c, h) {
n._loadingError = !0,
n._errorObject = {
message: c,
exception: h
},
r && r(c, h),
Texture.OnTextureLoadErrorObservable.notifyObservers(n)
};
this._texture ? this._texture.isReady ? Tools.SetImmediate(function() {
return l()
}) : this._texture.onLoadedObservable.add(function() {
return l()
}) : (this._prefiltered ? this._texture = this._getEngine().createPrefilteredCubeTexture(this.url, a, this._lodScale, this._lodOffset, t, u, this._format, this._forcedExtension, this._createPolynomials) : this._texture = this._getEngine().createCubeTexture(this.url, a, this._files, this._noMipmap, t, u, this._format, this._forcedExtension, !1, this._lodScale, this._lodOffset, null, this._loaderOptions, !!this._useSRGBBuffer),
(o = this._texture) === null || o === void 0 || o.onLoadedObservable.add(function() {
return n.onLoadObservable.notifyObservers(n)
}))
}
,
e.Parse = function(t, r, n) {
var o = SerializationHelper.Parse(function() {
var u = !1;
return t.prefiltered && (u = t.prefiltered),
new e(n + t.name,r,t.extensions,!1,t.files || null,null,null,void 0,u,t.forcedExtension)
}, t, r);
if (t.boundingBoxPosition && (o.boundingBoxPosition = Vector3.FromArray(t.boundingBoxPosition)),
t.boundingBoxSize && (o.boundingBoxSize = Vector3.FromArray(t.boundingBoxSize)),
t.animations)
for (var a = 0; a < t.animations.length; a++) {
var s = t.animations[a]
, l = GetClass("BABYLON.Animation");
l && o.animations.push(l.Parse(s))
}
return o
}
,
e.prototype.clone = function() {
var t = this
, r = 0
, n = SerializationHelper.Clone(function() {
var o = new e(t.url,t.getScene() || t._getEngine(),t._extensions,t._noMipmap,t._files);
return r = o.uniqueId,
o
}, this);
return n.uniqueId = r,
n
}
,
__decorate([serialize()], e.prototype, "url", void 0),
__decorate([serialize("rotationY")], e.prototype, "rotationY", null),
__decorate([serialize("files")], e.prototype, "_files", void 0),
__decorate([serialize("forcedExtension")], e.prototype, "_forcedExtension", void 0),
__decorate([serialize("extensions")], e.prototype, "_extensions", void 0),
__decorate([serializeAsMatrix("textureMatrix")], e.prototype, "_textureMatrix", void 0),
e
}(BaseTexture);
Texture._CubeTextureParser = CubeTexture.Parse;
RegisterClass("BABYLON.CubeTexture", CubeTexture);
ThinEngine.prototype.createDynamicTexture = function(i, e, t, r) {
var n = new InternalTexture(this,InternalTextureSource.Dynamic);
return n.baseWidth = i,
n.baseHeight = e,
t && (i = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(i, this._caps.maxTextureSize) : i,
e = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(e, this._caps.maxTextureSize) : e),
n.width = i,
n.height = e,
n.isReady = !1,
n.generateMipMaps = t,
n.samplingMode = r,
this.updateTextureSamplingMode(r, n),
this._internalTexturesCache.push(n),
n
}
;
ThinEngine.prototype.updateDynamicTexture = function(i, e, t, r, n, o, a) {
if (r === void 0 && (r = !1),
o === void 0 && (o = !1),
!!i) {
var s = this._gl
, l = s.TEXTURE_2D
, u = this._bindTextureDirectly(l, i, !0, o);
this._unpackFlipY(t === void 0 ? i.invertY : t),
r && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
var c = this._getWebGLTextureType(i.type)
, h = this._getInternalFormat(n || i.format)
, f = this._getRGBABufferInternalSizedFormat(i.type, h);
s.texImage2D(l, 0, f, h, c, e),
i.generateMipMaps && s.generateMipmap(l),
u || this._bindTextureDirectly(l, null),
r && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
i.isReady = !0
}
}
;
var DynamicTexture = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l) {
n === void 0 && (n = null),
o === void 0 && (o = !1),
a === void 0 && (a = 3),
s === void 0 && (s = 5);
var u = i.call(this, null, n, !o, l, a, void 0, void 0, void 0, void 0, s) || this;
u.name = t,
u.wrapU = Texture.CLAMP_ADDRESSMODE,
u.wrapV = Texture.CLAMP_ADDRESSMODE,
u._generateMipMaps = o;
var c = u._getEngine();
if (!c)
return u;
r.getContext ? (u._canvas = r,
u._texture = c.createDynamicTexture(r.width, r.height, o, a)) : (u._canvas = c.createCanvas(1, 1),
r.width || r.width === 0 ? u._texture = c.createDynamicTexture(r.width, r.height, o, a) : u._texture = c.createDynamicTexture(r, r, o, a));
var h = u.getSize();
return u._canvas.width !== h.width && (u._canvas.width = h.width),
u._canvas.height !== h.height && (u._canvas.height = h.height),
u._context = u._canvas.getContext("2d"),
u
}
return e.prototype.getClassName = function() {
return "DynamicTexture"
}
,
Object.defineProperty(e.prototype, "canRescale", {
get: function() {
return !0
},
enumerable: !1,
configurable: !0
}),
e.prototype._recreate = function(t) {
this._canvas.width = t.width,
this._canvas.height = t.height,
this.releaseInternalTexture(),
this._texture = this._getEngine().createDynamicTexture(t.width, t.height, this._generateMipMaps, this.samplingMode)
}
,
e.prototype.scale = function(t) {
var r = this.getSize();
r.width *= t,
r.height *= t,
this._recreate(r)
}
,
e.prototype.scaleTo = function(t, r) {
var n = this.getSize();
n.width = t,
n.height = r,
this._recreate(n)
}
,
e.prototype.getContext = function() {
return this._context
}
,
e.prototype.clear = function() {
var t = this.getSize();
this._context.fillRect(0, 0, t.width, t.height)
}
,
e.prototype.update = function(t, r, n) {
r === void 0 && (r = !1),
n === void 0 && (n = !1),
this._getEngine().updateDynamicTexture(this._texture, this._canvas, t === void 0 ? !0 : t, r, this._format || void 0, void 0, n)
}
,
e.prototype.drawText = function(t, r, n, o, a, s, l, u) {
u === void 0 && (u = !0);
var c = this.getSize();
if (s && (this._context.fillStyle = s,
this._context.fillRect(0, 0, c.width, c.height)),
this._context.font = o,
r == null) {
var h = this._context.measureText(t);
r = (c.width - h.width) / 2
}
if (n == null) {
var f = parseInt(o.replace(/\D/g, ""));
n = c.height / 2 + f / 3.65
}
this._context.fillStyle = a || "",
this._context.fillText(t, r, n),
u && this.update(l)
}
,
e.prototype.clone = function() {
var t = this.getScene();
if (!t)
return this;
var r = this.getSize()
, n = new e(this.name,r,t,this._generateMipMaps);
return n.hasAlpha = this.hasAlpha,
n.level = this.level,
n.wrapU = this.wrapU,
n.wrapV = this.wrapV,
n
}
,
e.prototype.serialize = function() {
var t = this.getScene();
t && !t.isReady() && Logger$2.Warn("The scene must be ready before serializing the dynamic texture");
var r = i.prototype.serialize.call(this);
return this._IsCanvasElement(this._canvas) && (r.base64String = this._canvas.toDataURL()),
r.invertY = this._invertY,
r.samplingMode = this.samplingMode,
r
}
,
e.prototype._IsCanvasElement = function(t) {
return t.toDataURL !== void 0
}
,
e.prototype._rebuild = function() {
this.update()
}
,
e
}(Texture);
ThinEngine.prototype.updateVideoTexture = function(i, e, t) {
if (!(!i || i._isDisabled)) {
var r = this._bindTextureDirectly(this._gl.TEXTURE_2D, i, !0);
this._unpackFlipY(!t);
try {
if (this._videoTextureSupported === void 0 && (this._gl.getError(),
this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, e),
this._gl.getError() !== 0 ? this._videoTextureSupported = !1 : this._videoTextureSupported = !0),
this._videoTextureSupported)
this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, e);
else {
if (!i._workingCanvas) {
i._workingCanvas = this.createCanvas(i.width, i.height);
var n = i._workingCanvas.getContext("2d");
if (!n)
throw new Error("Unable to get 2d context");
i._workingContext = n,
i._workingCanvas.width = i.width,
i._workingCanvas.height = i.height
}
i._workingContext.clearRect(0, 0, i.width, i.height),
i._workingContext.drawImage(e, 0, 0, e.videoWidth, e.videoHeight, 0, 0, i.width, i.height),
this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, i._workingCanvas)
}
i.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
r || this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
i.isReady = !0
} catch {
i._isDisabled = !0
}
}
}
;
var VideoTexture = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u) {
o === void 0 && (o = !1),
a === void 0 && (a = !1),
s === void 0 && (s = Texture.TRILINEAR_SAMPLINGMODE);
var c = i.call(this, null, n, !o, a) || this;
c._onUserActionRequestedObservable = null,
c._stillImageCaptured = !1,
c._displayingPosterTexture = !1,
c._frameId = -1,
c._currentSrc = null,
c._errorFound = !1,
c._createInternalTexture = function() {
if (c._texture != null)
if (c._displayingPosterTexture)
c._texture.dispose(),
c._displayingPosterTexture = !1;
else
return;
if (!c._getEngine().needPOTTextures || Tools.IsExponentOfTwo(c.video.videoWidth) && Tools.IsExponentOfTwo(c.video.videoHeight) ? (c.wrapU = Texture.WRAP_ADDRESSMODE,
c.wrapV = Texture.WRAP_ADDRESSMODE) : (c.wrapU = Texture.CLAMP_ADDRESSMODE,
c.wrapV = Texture.CLAMP_ADDRESSMODE,
c._generateMipMaps = !1),
c._texture = c._getEngine().createDynamicTexture(c.video.videoWidth, c.video.videoHeight, c._generateMipMaps, c.samplingMode),
!c.video.autoplay && !c._settings.poster) {
var f = c.video.onplaying
, d = c.video.muted;
c.video.muted = !0,
c.video.onplaying = function() {
c.video.muted = d,
c.video.onplaying = f,
c._updateInternalTexture(),
c._errorFound || c.video.pause(),
c.onLoadObservable.hasObservers() && c.onLoadObservable.notifyObservers(c)
}
,
c._handlePlay()
} else
c._updateInternalTexture(),
c.onLoadObservable.hasObservers() && c.onLoadObservable.notifyObservers(c)
}
,
c.reset = function() {
c._texture != null && (c._displayingPosterTexture || (c._texture.dispose(),
c._texture = null))
}
,
c._updateInternalTexture = function() {
if (c._texture != null && !(c.video.readyState < c.video.HAVE_CURRENT_DATA) && !c._displayingPosterTexture) {
var f = c.getScene().getFrameId();
c._frameId !== f && (c._frameId = f,
c._getEngine().updateVideoTexture(c._texture, c.video, c._invertY))
}
}
,
l || (l = {
autoPlay: !0,
loop: !0,
autoUpdateTexture: !0
}),
c._onError = u,
c._generateMipMaps = o,
c._initialSamplingMode = s,
c.autoUpdateTexture = l.autoUpdateTexture,
c._currentSrc = r,
c.name = t || c._getName(r),
c.video = c._getVideo(r),
c._settings = l,
l.poster && (c.video.poster = l.poster),
l.autoPlay !== void 0 && (c.video.autoplay = l.autoPlay),
l.loop !== void 0 && (c.video.loop = l.loop),
l.muted !== void 0 && (c.video.muted = l.muted),
c.video.setAttribute("playsinline", ""),
c.video.addEventListener("paused", c._updateInternalTexture),
c.video.addEventListener("seeked", c._updateInternalTexture),
c.video.addEventListener("emptied", c.reset),
c._createInternalTextureOnEvent = l.poster && !l.autoPlay ? "play" : "canplay",
c.video.addEventListener(c._createInternalTextureOnEvent, c._createInternalTexture),
l.autoPlay && c._handlePlay();
var h = c.video.readyState >= c.video.HAVE_CURRENT_DATA;
return l.poster && (!l.autoPlay || !h) ? (c._texture = c._getEngine().createTexture(l.poster, !1, !c.invertY, n),
c._displayingPosterTexture = !0) : h && c._createInternalTexture(),
c
}
return Object.defineProperty(e.prototype, "onUserActionRequestedObservable", {
get: function() {
return this._onUserActionRequestedObservable || (this._onUserActionRequestedObservable = new Observable),
this._onUserActionRequestedObservable
},
enumerable: !1,
configurable: !0
}),
e.prototype._processError = function(t) {
this._errorFound = !0,
this._onError ? this._onError(t == null ? void 0 : t.message) : Logger$2.Error(t == null ? void 0 : t.message)
}
,
e.prototype._handlePlay = function() {
var t = this;
this._errorFound = !1,
this.video.play().catch(function(r) {
if ((r == null ? void 0 : r.name) === "NotAllowedError") {
if (t._onUserActionRequestedObservable && t._onUserActionRequestedObservable.hasObservers()) {
t._onUserActionRequestedObservable.notifyObservers(t);
return
} else if (!t.video.muted) {
Logger$2.Warn("Unable to autoplay a video with sound. Trying again with muted turned true"),
t.video.muted = !0,
t._errorFound = !1,
t.video.play().catch(function(n) {
t._processError(n)
});
return
}
}
t._processError(r)
})
}
,
e.prototype.getClassName = function() {
return "VideoTexture"
}
,
e.prototype._getName = function(t) {
return t instanceof HTMLVideoElement ? t.currentSrc : typeof t == "object" ? t.toString() : t
}
,
e.prototype._getVideo = function(t) {
if (t.isNative)
return t;
if (t instanceof HTMLVideoElement)
return Tools.SetCorsBehavior(t.currentSrc, t),
t;
var r = document.createElement("video");
return typeof t == "string" ? (Tools.SetCorsBehavior(t, r),
r.src = t) : (Tools.SetCorsBehavior(t[0], r),
t.forEach(function(n) {
var o = document.createElement("source");
o.src = n,
r.appendChild(o)
})),
r
}
,
e.prototype._rebuild = function() {
this.update()
}
,
e.prototype.update = function() {
!this.autoUpdateTexture || this.updateTexture(!0)
}
,
e.prototype.updateTexture = function(t) {
!t || this.video.paused && this._stillImageCaptured || (this._stillImageCaptured = !0,
this._updateInternalTexture())
}
,
e.prototype.updateURL = function(t) {
this.video.src = t,
this._currentSrc = t
}
,
e.prototype.clone = function() {
return new e(this.name,this._currentSrc,this.getScene(),this._generateMipMaps,this.invertY,this.samplingMode,this._settings)
}
,
e.prototype.dispose = function() {
i.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()
}
,
e.CreateFromStreamAsync = function(t, r, n, o) {
o === void 0 && (o = !0);
var a = t.getEngine().createVideoElement(n);
return t.getEngine()._badOS && (document.body.appendChild(a),
a.style.transform = "scale(0.0001, 0.0001)",
a.style.opacity = "0",
a.style.position = "fixed",
a.style.bottom = "0px",
a.style.right = "0px"),
a.setAttribute("autoplay", ""),
a.setAttribute("muted", "true"),
a.setAttribute("playsinline", ""),
a.muted = !0,
a.mozSrcObject !== void 0 ? a.mozSrcObject = r : typeof a.srcObject == "object" ? a.srcObject = r : (window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL,
a.src = window.URL && window.URL.createObjectURL(r)),
new Promise(function(s) {
var l = function() {
s(new e("video",a,t,!0,o)),
a.removeEventListener("playing", l)
};
a.addEventListener("playing", l),
a.play()
}
)
}
,
e.CreateFromWebCamAsync = function(t, r, n, o) {
var a = this;
n === void 0 && (n = !1),
o === void 0 && (o = !0);
var s;
if (r && r.deviceId && (s = {
exact: r.deviceId
}),
navigator.mediaDevices)
return navigator.mediaDevices.getUserMedia({
video: r,
audio: n
}).then(function(u) {
return a.CreateFromStreamAsync(t, u, r, o)
});
var l = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
return l && l({
video: {
deviceId: s,
width: {
min: r && r.minWidth || 256,
max: r && r.maxWidth || 640
},
height: {
min: r && r.minHeight || 256,
max: r && r.maxHeight || 480
}
},
audio: n
}, function(u) {
return a.CreateFromStreamAsync(t, u, r, o)
}, function(u) {
Logger$2.Error(u.name)
}),
Promise.reject("No support for userMedia on this device")
}
,
e.CreateFromWebCam = function(t, r, n, o, a) {
o === void 0 && (o = !1),
a === void 0 && (a = !0),
this.CreateFromWebCamAsync(t, n, o, a).then(function(s) {
r && r(s)
}).catch(function(s) {
Logger$2.Error(s.name)
})
}
,
e
}(Texture)
, Action = function() {
function i(e, t) {
this.triggerOptions = e,
this.onBeforeExecuteObservable = new Observable,
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 i.prototype._prepare = function() {}
,
i.prototype.getTriggerParameter = function() {
return this._triggerParameter
}
,
i.prototype.setTriggerParameter = function(e) {
this._triggerParameter = e
}
,
i.prototype._evaluateConditionForCurrentFrame = function() {
var e = this._condition;
if (!e)
return !0;
var t = this._actionManager.getScene().getRenderId();
return e._evaluationId !== t && (e._evaluationId = t,
e._currentResult = e.isValid()),
e._currentResult
}
,
i.prototype._executeCurrent = function(e) {
var t = this._evaluateConditionForCurrentFrame();
!t || (this.onBeforeExecuteObservable.notifyObservers(this),
this._nextActiveAction.execute(e),
this.skipToNextActiveAction())
}
,
i.prototype.execute = function(e) {}
,
i.prototype.skipToNextActiveAction = function() {
this._nextActiveAction._child ? (this._nextActiveAction._child._actionManager || (this._nextActiveAction._child._actionManager = this._actionManager),
this._nextActiveAction = this._nextActiveAction._child) : this._nextActiveAction = this
}
,
i.prototype.then = function(e) {
return this._child = e,
e._actionManager = this._actionManager,
e._prepare(),
e
}
,
i.prototype._getProperty = function(e) {
return this._actionManager._getProperty(e)
}
,
i.prototype._getEffectiveTarget = function(e, t) {
return this._actionManager._getEffectiveTarget(e, t)
}
,
i.prototype.serialize = function(e) {}
,
i.prototype._serialize = function(e, t) {
var r = {
type: 1,
children: [],
name: e.name,
properties: e.properties || []
};
if (this._child && this._child.serialize(r),
this._condition) {
var n = this._condition.serialize();
return n.children.push(r),
t && t.children.push(n),
n
}
return t && t.children.push(r),
r
}
,
i._SerializeValueAsString = function(e) {
return typeof e == "number" ? e.toString() : typeof e == "boolean" ? e ? "true" : "false" : e instanceof Vector2 ? e.x + ", " + e.y : e instanceof Vector3 ? e.x + ", " + e.y + ", " + e.z : e instanceof Color3 ? e.r + ", " + e.g + ", " + e.b : e instanceof Color4 ? e.r + ", " + e.g + ", " + e.b + ", " + e.a : e
}
,
i._GetTargetProperty = function(e) {
return {
name: "target",
targetType: e._isMesh ? "MeshProperties" : e._isLight ? "LightProperties" : e._isCamera ? "CameraProperties" : "SceneProperties",
value: e._isScene ? "Scene" : e.name
}
}
,
i
}();
RegisterClass("BABYLON.Action", Action);
var Condition = function() {
function i(e) {
this._actionManager = e
}
return i.prototype.isValid = function() {
return !0
}
,
i.prototype._getProperty = function(e) {
return this._actionManager._getProperty(e)
}
,
i.prototype._getEffectiveTarget = function(e, t) {
return this._actionManager._getEffectiveTarget(e, t)
}
,
i.prototype.serialize = function() {}
,
i.prototype._serialize = function(e) {
return {
type: 2,
children: [],
name: e.name,
properties: e.properties
}
}
,
i
}()
, ValueCondition = function(i) {
__extends(e, i);
function e(t, r, n, o, a) {
a === void 0 && (a = e.IsEqual);
var s = i.call(this, t) || this;
return s.propertyPath = n,
s.value = o,
s.operator = a,
s._target = r,
s._effectiveTarget = s._getEffectiveTarget(r, s.propertyPath),
s._property = s._getProperty(s.propertyPath),
s
}
return Object.defineProperty(e, "IsEqual", {
get: function() {
return e._IsEqual
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "IsDifferent", {
get: function() {
return e._IsDifferent
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "IsGreater", {
get: function() {
return e._IsGreater
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "IsLesser", {
get: function() {
return e._IsLesser
},
enumerable: !1,
configurable: !0
}),
e.prototype.isValid = function() {
switch (this.operator) {
case e.IsGreater:
return this._effectiveTarget[this._property] > this.value;
case e.IsLesser:
return this._effectiveTarget[this._property] < this.value;
case e.IsEqual:
case e.IsDifferent:
var t;
return this.value.equals ? t = this.value.equals(this._effectiveTarget[this._property]) : t = this.value === this._effectiveTarget[this._property],
this.operator === e.IsEqual ? t : !t
}
return !1
}
,
e.prototype.serialize = function() {
return this._serialize({
name: "ValueCondition",
properties: [Action._GetTargetProperty(this._target), {
name: "propertyPath",
value: this.propertyPath
}, {
name: "value",
value: Action._SerializeValueAsString(this.value)
}, {
name: "operator",
value: e.GetOperatorName(this.operator)
}]
})
}
,
e.GetOperatorName = function(t) {
switch (t) {
case e._IsEqual:
return "IsEqual";
case e._IsDifferent:
return "IsDifferent";
case e._IsGreater:
return "IsGreater";
case e._IsLesser:
return "IsLesser";
default:
return ""
}
}
,
e._IsEqual = 0,
e._IsDifferent = 1,
e._IsGreater = 2,
e._IsLesser = 3,
e
}(Condition)
, PredicateCondition = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t) || this;
return n.predicate = r,
n
}
return e.prototype.isValid = function() {
return this.predicate()
}
,
e
}(Condition)
, StateCondition = function(i) {
__extends(e, i);
function e(t, r, n) {
var o = i.call(this, t) || this;
return o.value = n,
o._target = r,
o
}
return e.prototype.isValid = function() {
return this._target.state === this.value
}
,
e.prototype.serialize = function() {
return this._serialize({
name: "StateCondition",
properties: [Action._GetTargetProperty(this._target), {
name: "value",
value: this.value
}]
})
}
,
e
}(Condition);
RegisterClass("BABYLON.ValueCondition", ValueCondition);
RegisterClass("BABYLON.PredicateCondition", PredicateCondition);
RegisterClass("BABYLON.StateCondition", StateCondition);
(function(i) {
__extends(e, i);
function e(t, r, n, o) {
var a = i.call(this, t, o) || this;
return a.propertyPath = n,
a._target = a._effectiveTarget = r,
a
}
return e.prototype._prepare = function() {
this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
this._property = this._getProperty(this.propertyPath)
}
,
e.prototype.execute = function() {
this._effectiveTarget[this._property] = !this._effectiveTarget[this._property]
}
,
e.prototype.serialize = function(t) {
return i.prototype._serialize.call(this, {
name: "SwitchBooleanAction",
properties: [Action._GetTargetProperty(this._target), {
name: "propertyPath",
value: this.propertyPath
}]
}, t)
}
,
e
}
)(Action);
var SetStateAction = function(i) {
__extends(e, i);
function e(t, r, n, o) {
var a = i.call(this, t, o) || this;
return a.value = n,
a._target = r,
a
}
return e.prototype.execute = function() {
this._target.state = this.value
}
,
e.prototype.serialize = function(t) {
return i.prototype._serialize.call(this, {
name: "SetStateAction",
properties: [Action._GetTargetProperty(this._target), {
name: "value",
value: this.value
}]
}, t)
}
,
e
}(Action)
, SetValueAction = function(i) {
__extends(e, i);
function e(t, r, n, o, a) {
var s = i.call(this, t, a) || this;
return s.propertyPath = n,
s.value = o,
s._target = s._effectiveTarget = r,
s
}
return e.prototype._prepare = function() {
this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
this._property = this._getProperty(this.propertyPath)
}
,
e.prototype.execute = function() {
this._effectiveTarget[this._property] = this.value,
this._target.markAsDirty && this._target.markAsDirty(this._property)
}
,
e.prototype.serialize = function(t) {
return i.prototype._serialize.call(this, {
name: "SetValueAction",
properties: [Action._GetTargetProperty(this._target), {
name: "propertyPath",
value: this.propertyPath
}, {
name: "value",
value: Action._SerializeValueAsString(this.value)
}]
}, t)
}
,
e
}(Action)
, IncrementValueAction = function(i) {
__extends(e, i);
function e(t, r, n, o, a) {
var s = i.call(this, t, a) || this;
return s.propertyPath = n,
s.value = o,
s._target = s._effectiveTarget = r,
s
}
return e.prototype._prepare = function() {
this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
this._property = this._getProperty(this.propertyPath),
typeof this._effectiveTarget[this._property] != "number" && Logger$2.Warn("Warning: IncrementValueAction can only be used with number values")
}
,
e.prototype.execute = function() {
this._effectiveTarget[this._property] += this.value,
this._target.markAsDirty && this._target.markAsDirty(this._property)
}
,
e.prototype.serialize = function(t) {
return i.prototype._serialize.call(this, {
name: "IncrementValueAction",
properties: [Action._GetTargetProperty(this._target), {
name: "propertyPath",
value: this.propertyPath
}, {
name: "value",
value: Action._SerializeValueAsString(this.value)
}]
}, t)
}
,
e
}(Action)
, PlayAnimationAction = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s) {
var l = i.call(this, t, s) || this;
return l.from = n,
l.to = o,
l.loop = a,
l._target = r,
l
}
return e.prototype._prepare = function() {}
,
e.prototype.execute = function() {
var t = this._actionManager.getScene();
t.beginAnimation(this._target, this.from, this.to, this.loop)
}
,
e.prototype.serialize = function(t) {
return i.prototype._serialize.call(this, {
name: "PlayAnimationAction",
properties: [Action._GetTargetProperty(this._target), {
name: "from",
value: String(this.from)
}, {
name: "to",
value: String(this.to)
}, {
name: "loop",
value: Action._SerializeValueAsString(this.loop) || !1
}]
}, t)
}
,
e
}(Action)
, StopAnimationAction = function(i) {
__extends(e, i);
function e(t, r, n) {
var o = i.call(this, t, n) || this;
return o._target = r,
o
}
return e.prototype._prepare = function() {}
,
e.prototype.execute = function() {
var t = this._actionManager.getScene();
t.stopAnimation(this._target)
}
,
e.prototype.serialize = function(t) {
return i.prototype._serialize.call(this, {
name: "StopAnimationAction",
properties: [Action._GetTargetProperty(this._target)]
}, t)
}
,
e
}(Action)
, DoNothingAction = function(i) {
__extends(e, i);
function e(t, r) {
return t === void 0 && (t = 0),
i.call(this, t, r) || this
}
return e.prototype.execute = function() {}
,
e.prototype.serialize = function(t) {
return i.prototype._serialize.call(this, {
name: "DoNothingAction",
properties: []
}, t)
}
,
e
}(Action);
(function(i) {
__extends(e, i);
function e(t, r, n, o) {
o === void 0 && (o = !0);
var a = i.call(this, t, n) || this;
return a.children = r,
a.enableChildrenConditions = o,
a
}
return e.prototype._prepare = function() {
for (var t = 0; t < this.children.length; t++)
this.children[t]._actionManager = this._actionManager,
this.children[t]._prepare()
}
,
e.prototype.execute = function(t) {
for (var r = 0, n = this.children; r < n.length; r++) {
var o = n[r];
(!this.enableChildrenConditions || o._evaluateConditionForCurrentFrame()) && o.execute(t)
}
}
,
e.prototype.serialize = function(t) {
for (var r = i.prototype._serialize.call(this, {
name: "CombineAction",
properties: [],
combine: []
}, t), n = 0; n < this.children.length; n++)
r.combine.push(this.children[n].serialize(null));
return r
}
,
e
}
)(Action);
var ExecuteCodeAction = function(i) {
__extends(e, i);
function e(t, r, n) {
var o = i.call(this, t, n) || this;
return o.func = r,
o
}
return e.prototype.execute = function(t) {
this.func(t)
}
,
e
}(Action)
, SetParentAction = function(i) {
__extends(e, i);
function e(t, r, n, o) {
var a = i.call(this, t, o) || this;
return a._target = r,
a._parent = n,
a
}
return e.prototype._prepare = function() {}
,
e.prototype.execute = function() {
if (this._target.parent !== this._parent) {
var t = this._parent.getWorldMatrix().clone();
t.invert(),
this._target.position = Vector3.TransformCoordinates(this._target.position, t),
this._target.parent = this._parent
}
}
,
e.prototype.serialize = function(t) {
return i.prototype._serialize.call(this, {
name: "SetParentAction",
properties: [Action._GetTargetProperty(this._target), Action._GetTargetProperty(this._parent)]
}, t)
}
,
e
}(Action);
RegisterClass("BABYLON.SetParentAction", SetParentAction);
RegisterClass("BABYLON.ExecuteCodeAction", ExecuteCodeAction);
RegisterClass("BABYLON.DoNothingAction", DoNothingAction);
RegisterClass("BABYLON.StopAnimationAction", StopAnimationAction);
RegisterClass("BABYLON.PlayAnimationAction", PlayAnimationAction);
RegisterClass("BABYLON.IncrementValueAction", IncrementValueAction);
RegisterClass("BABYLON.SetValueAction", SetValueAction);
RegisterClass("BABYLON.SetStateAction", SetStateAction);
RegisterClass("BABYLON.SetParentAction", SetParentAction);
var ActionManager = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this) || this;
return r._scene = t || EngineStore.LastCreatedScene,
t.actionManagers.push(r),
r
}
return e.prototype.dispose = function() {
for (var t = this._scene.actionManagers.indexOf(this), r = 0; r < this.actions.length; r++) {
var n = this.actions[r];
e.Triggers[n.trigger]--,
e.Triggers[n.trigger] === 0 && delete e.Triggers[n.trigger]
}
t > -1 && this._scene.actionManagers.splice(t, 1)
}
,
e.prototype.getScene = function() {
return this._scene
}
,
e.prototype.hasSpecificTriggers = function(t) {
for (var r = 0; r < this.actions.length; r++) {
var n = this.actions[r];
if (t.indexOf(n.trigger) > -1)
return !0
}
return !1
}
,
e.prototype.hasSpecificTriggers2 = function(t, r) {
for (var n = 0; n < this.actions.length; n++) {
var o = this.actions[n];
if (t == o.trigger || r == o.trigger)
return !0
}
return !1
}
,
e.prototype.hasSpecificTrigger = function(t, r) {
for (var n = 0; n < this.actions.length; n++) {
var o = this.actions[n];
if (o.trigger === t)
if (r) {
if (r(o.getTriggerParameter()))
return !0
} else
return !0
}
return !1
}
,
Object.defineProperty(e.prototype, "hasPointerTriggers", {
get: function() {
for (var t = 0; t < this.actions.length; t++) {
var r = this.actions[t];
if (r.trigger >= e.OnPickTrigger && r.trigger <= e.OnPointerOutTrigger)
return !0
}
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "hasPickTriggers", {
get: function() {
for (var t = 0; t < this.actions.length; t++) {
var r = this.actions[t];
if (r.trigger >= e.OnPickTrigger && r.trigger <= e.OnPickUpTrigger)
return !0
}
return !1
},
enumerable: !1,
configurable: !0
}),
e.prototype.registerAction = function(t) {
return t.trigger === e.OnEveryFrameTrigger && this.getScene().actionManager !== this ? (Logger$2.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),
null) : (this.actions.push(t),
e.Triggers[t.trigger] ? e.Triggers[t.trigger]++ : e.Triggers[t.trigger] = 1,
t._actionManager = this,
t._prepare(),
t)
}
,
e.prototype.unregisterAction = function(t) {
var r = this.actions.indexOf(t);
return r !== -1 ? (this.actions.splice(r, 1),
e.Triggers[t.trigger] -= 1,
e.Triggers[t.trigger] === 0 && delete e.Triggers[t.trigger],
t._actionManager = null,
!0) : !1
}
,
e.prototype.processTrigger = function(t, r) {
for (var n = 0; n < this.actions.length; n++) {
var o = this.actions[n];
if (o.trigger === t) {
if (r && (t === e.OnKeyUpTrigger || t === e.OnKeyDownTrigger)) {
var a = o.getTriggerParameter();
if (a && a !== r.sourceEvent.keyCode) {
if (!a.toLowerCase)
continue;
var s = a.toLowerCase();
if (s !== r.sourceEvent.key) {
var l = r.sourceEvent.charCode ? r.sourceEvent.charCode : r.sourceEvent.keyCode
, u = String.fromCharCode(l).toLowerCase();
if (u !== s)
continue
}
}
}
o._executeCurrent(r)
}
}
}
,
e.prototype._getEffectiveTarget = function(t, r) {
for (var n = r.split("."), o = 0; o < n.length - 1; o++)
t = t[n[o]];
return t
}
,
e.prototype._getProperty = function(t) {
var r = t.split(".");
return r[r.length - 1]
}
,
e.prototype.serialize = function(t) {
for (var r = {
children: new Array,
name: t,
type: 3,
properties: new Array
}, n = 0; n < this.actions.length; n++) {
var o = {
type: 0,
children: new Array,
name: e.GetTriggerName(this.actions[n].trigger),
properties: new Array
}
, a = this.actions[n].triggerOptions;
if (a && typeof a != "number")
if (a.parameter instanceof Node)
o.properties.push(Action._GetTargetProperty(a.parameter));
else {
var s = {};
DeepCopier.DeepCopy(a.parameter, s, ["mesh"]),
a.parameter && a.parameter.mesh && (s._meshId = a.parameter.mesh.id),
o.properties.push({
name: "parameter",
targetType: null,
value: s
})
}
this.actions[n].serialize(o),
r.children.push(o)
}
return r
}
,
e.Parse = function(t, r, n) {
var o = new e(n);
r === null ? n.actionManager = o : r.actionManager = o;
for (var a = function(g, m) {
var v = GetClass("BABYLON." + g);
if (v) {
var y = Object.create(v.prototype);
return y.constructor.apply(y, m),
y
}
}, s = function(g, m, v, y) {
if (y === null) {
var b = parseFloat(m);
return m === "true" || m === "false" ? m === "true" : isNaN(b) ? m : b
}
for (var T = y.split("."), C = m.split(","), A = 0; A < T.length; A++)
v = v[T[A]];
if (typeof v == "boolean")
return C[0] === "true";
if (typeof v == "string")
return C[0];
for (var S = new Array, A = 0; A < C.length; A++)
S.push(parseFloat(C[A]));
return v instanceof Vector3 ? Vector3.FromArray(S) : v instanceof Vector4 ? Vector4.FromArray(S) : v instanceof Color3 ? Color3.FromArray(S) : v instanceof Color4 ? Color4.FromArray(S) : parseFloat(C[0])
}, l = function(g, m, v, y, b) {
if (b === void 0 && (b = null),
!g.detached) {
var T = new Array
, C = null
, A = null
, S = g.combine && g.combine.length > 0;
if (g.type === 2 ? T.push(o) : T.push(m),
S) {
for (var P = new Array, R = 0; R < g.combine.length; R++)
l(g.combine[R], e.NothingTrigger, v, y, P);
T.push(P)
} else
for (var M = 0; M < g.properties.length; M++) {
var x = g.properties[M].value
, I = g.properties[M].name
, w = g.properties[M].targetType;
I === "target" ? w !== null && w === "SceneProperties" ? x = C = n : x = C = n.getNodeByName(x) : I === "parent" ? x = n.getNodeByName(x) : I === "sound" ? n.getSoundByName && (x = n.getSoundByName(x)) : I !== "propertyPath" ? g.type === 2 && I === "operator" ? x = ValueCondition[x] : x = s(I, x, C, I === "value" ? A : null) : A = x,
T.push(x)
}
if (b === null ? T.push(v) : T.push(null),
g.name === "InterpolateValueAction") {
var O = T[T.length - 2];
T[T.length - 1] = O,
T[T.length - 2] = v
}
var D = a(g.name, T);
if (D instanceof Condition && v !== null) {
var F = new DoNothingAction(m,v);
y ? y.then(F) : o.registerAction(F),
y = F
}
b === null ? D instanceof Condition ? (v = D,
D = y) : (v = null,
y ? y.then(D) : o.registerAction(D)) : b.push(D);
for (var M = 0; M < g.children.length; M++)
l(g.children[M], m, v, D, null)
}
}, u = 0; u < t.children.length; u++) {
var c, h = t.children[u];
if (h.properties.length > 0) {
var f = h.properties[0].value
, d = h.properties[0].targetType === null ? f : n.getMeshByName(f);
d._meshId && (d.mesh = n.getMeshById(d._meshId)),
c = {
trigger: e[h.name],
parameter: d
}
} else
c = e[h.name];
for (var _ = 0; _ < h.children.length; _++)
h.detached || l(h.children[_], c, null, null)
}
}
,
e.GetTriggerName = function(t) {
switch (t) {
case 0:
return "NothingTrigger";
case 1:
return "OnPickTrigger";
case 2:
return "OnLeftPickTrigger";
case 3:
return "OnRightPickTrigger";
case 4:
return "OnCenterPickTrigger";
case 5:
return "OnPickDownTrigger";
case 6:
return "OnPickUpTrigger";
case 7:
return "OnLongPressTrigger";
case 8:
return "OnPointerOverTrigger";
case 9:
return "OnPointerOutTrigger";
case 10:
return "OnEveryFrameTrigger";
case 11:
return "OnIntersectionEnterTrigger";
case 12:
return "OnIntersectionExitTrigger";
case 13:
return "OnKeyDownTrigger";
case 14:
return "OnKeyUpTrigger";
case 15:
return "OnPickOutTrigger";
default:
return ""
}
}
,
e.NothingTrigger = 0,
e.OnPickTrigger = 1,
e.OnLeftPickTrigger = 2,
e.OnRightPickTrigger = 3,
e.OnCenterPickTrigger = 4,
e.OnPickDownTrigger = 5,
e.OnDoublePickTrigger = 6,
e.OnPickUpTrigger = 7,
e.OnPickOutTrigger = 16,
e.OnLongPressTrigger = 8,
e.OnPointerOverTrigger = 9,
e.OnPointerOutTrigger = 10,
e.OnEveryFrameTrigger = 11,
e.OnIntersectionEnterTrigger = 12,
e.OnIntersectionExitTrigger = 13,
e.OnKeyDownTrigger = 14,
e.OnKeyUpTrigger = 15,
e
}(AbstractActionManager);
Node$2.AddNodeConstructor("Light_Type_0", function(i, e) {
return function() {
return new PointLight(i,Vector3.Zero(),e)
}
});
var PointLight = function(i) {
__extends(e, i);
function e(t, r, n) {
var o = i.call(this, t, n) || this;
return o._shadowAngle = Math.PI / 2,
o.position = r,
o
}
return Object.defineProperty(e.prototype, "shadowAngle", {
get: function() {
return this._shadowAngle
},
set: function(t) {
this._shadowAngle = t,
this.forceProjectionMatrixCompute()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "direction", {
get: function() {
return this._direction
},
set: function(t) {
var r = this.needCube();
this._direction = t,
this.needCube() !== r && this._shadowGenerator && this._shadowGenerator.recreateShadowMap()
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "PointLight"
}
,
e.prototype.getTypeID = function() {
return Light.LIGHTTYPEID_POINTLIGHT
}
,
e.prototype.needCube = function() {
return !this.direction
}
,
e.prototype.getShadowDirection = function(t) {
if (this.direction)
return i.prototype.getShadowDirection.call(this, t);
switch (t) {
case 0:
return new Vector3(1,0,0);
case 1:
return new Vector3(-1,0,0);
case 2:
return new Vector3(0,-1,0);
case 3:
return new Vector3(0,1,0);
case 4:
return new Vector3(0,0,1);
case 5:
return new Vector3(0,0,-1)
}
return Vector3.Zero()
}
,
e.prototype._setDefaultShadowProjectionMatrix = function(t, r, n) {
var o = this.getScene().activeCamera;
if (!!o) {
var a = this.shadowMinZ !== void 0 ? this.shadowMinZ : o.minZ
, s = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : o.maxZ
, l = this.getScene().getEngine().useReverseDepthBuffer;
Matrix.PerspectiveFovLHToRef(this.shadowAngle, 1, l ? s : a, l ? a : s, t, !0, this._scene.getEngine().isNDCHalfZRange, void 0, l)
}
}
,
e.prototype._buildUniformLayout = function() {
this._uniformBuffer.addUniform("vLightData", 4),
this._uniformBuffer.addUniform("vLightDiffuse", 4),
this._uniformBuffer.addUniform("vLightSpecular", 4),
this._uniformBuffer.addUniform("vLightFalloff", 4),
this._uniformBuffer.addUniform("shadowsInfo", 3),
this._uniformBuffer.addUniform("depthValues", 2),
this._uniformBuffer.create()
}
,
e.prototype.transferToEffect = function(t, r) {
return this.computeTransformedInformation() ? this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0, r) : this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, r),
this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, r),
this
}
,
e.prototype.transferToNodeMaterialEffect = function(t, r) {
return this.computeTransformedInformation() ? t.setFloat3(r, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z) : t.setFloat3(r, this.position.x, this.position.y, this.position.z),
this
}
,
e.prototype.prepareLightSpecificDefines = function(t, r) {
t["POINTLIGHT" + r] = !0
}
,
__decorate([serialize()], e.prototype, "shadowAngle", null),
e
}(ShadowLight);
function CreateRibbonVertexData(i) {
var e = i.pathArray
, t = i.closeArray || !1
, r = i.closePath || !1
, n = i.invertUV || !1
, o = Math.floor(e[0].length / 2)
, a = i.offset || o;
a = a > o ? o : Math.floor(a);
var s = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE, l = i.uvs, u = i.colors, c = [], h = [], f = [], d = [], _ = [], g = [], m = [], v = [], y, b = [], T = [], C, A, S;
if (e.length < 2) {
var P = []
, R = [];
for (A = 0; A < e[0].length - a; A++)
P.push(e[0][A]),
R.push(e[0][A + a]);
e = [P, R]
}
var M = 0, x = r ? 1 : 0, I, w;
y = e[0].length;
var O, D;
for (C = 0; C < e.length; C++) {
for (m[C] = 0,
_[C] = [0],
I = e[C],
w = I.length,
y = y < w ? y : w,
S = 0; S < w; )
c.push(I[S].x, I[S].y, I[S].z),
S > 0 && (O = I[S].subtract(I[S - 1]).length(),
D = O + m[C],
_[C].push(D),
m[C] = D),
S++;
r && (S--,
c.push(I[0].x, I[0].y, I[0].z),
O = I[S].subtract(I[0]).length(),
D = O + m[C],
_[C].push(D),
m[C] = D),
b[C] = w + x,
T[C] = M,
M += w + x
}
var F, V, N = null, L = null;
for (A = 0; A < y + x; A++) {
for (v[A] = 0,
g[A] = [0],
C = 0; C < e.length - 1; C++)
F = e[C],
V = e[C + 1],
A === y ? (N = F[0],
L = V[0]) : (N = F[A],
L = V[A]),
O = L.subtract(N).length(),
D = O + v[A],
g[A].push(D),
v[A] = D;
t && L && N && (F = e[C],
V = e[0],
A === y && (L = V[0]),
O = L.subtract(N).length(),
D = O + v[A],
v[A] = D)
}
var k, U;
if (l)
for (C = 0; C < l.length; C++)
d.push(l[C].x, l[C].y);
else
for (C = 0; C < e.length; C++)
for (A = 0; A < y + x; A++)
k = m[C] != 0 ? _[C][A] / m[C] : 0,
U = v[A] != 0 ? g[A][C] / v[A] : 0,
n ? d.push(U, k) : d.push(k, U);
C = 0;
for (var z = 0, H = b[C] - 1, G = b[C + 1] - 1, W = H < G ? H : G, j = T[1] - T[0], B = t ? b.length : b.length - 1; z <= W && C < B; )
h.push(z, z + j, z + 1),
h.push(z + j + 1, z + 1, z + j),
z += 1,
z === W && (C++,
C === b.length - 1 ? (j = T[0] - T[C],
H = b[C] - 1,
G = b[0] - 1) : (j = T[C + 1] - T[C],
H = b[C] - 1,
G = b[C + 1] - 1),
z = T[C],
W = H < G ? H + z : G + z);
if (VertexData.ComputeNormals(c, h, f),
r) {
var X = 0
, $ = 0;
for (C = 0; C < e.length; C++)
X = T[C] * 3,
C + 1 < e.length ? $ = (T[C + 1] - 1) * 3 : $ = f.length - 3,
f[X] = (f[X] + f[$]) * .5,
f[X + 1] = (f[X + 1] + f[$ + 1]) * .5,
f[X + 2] = (f[X + 2] + f[$ + 2]) * .5,
f[$] = f[X],
f[$ + 1] = f[X + 1],
f[$ + 2] = f[X + 2]
}
VertexData._ComputeSides(s, c, h, f, d, i.frontUVs, i.backUVs);
var Y = null;
if (u) {
Y = new Float32Array(u.length * 4);
for (var K = 0; K < u.length; K++)
Y[K * 4] = u[K].r,
Y[K * 4 + 1] = u[K].g,
Y[K * 4 + 2] = u[K].b,
Y[K * 4 + 3] = u[K].a
}
var Z = new VertexData
, q = new Float32Array(c)
, J = new Float32Array(f)
, Q = new Float32Array(d);
return Z.indices = h,
Z.positions = q,
Z.normals = J,
Z.uvs = Q,
Y && Z.set(Y, VertexBuffer.ColorKind),
r && (Z._idx = T),
Z
}
function CreateRibbon(i, e, t) {
t === void 0 && (t = null);
var r = e.pathArray
, n = e.closeArray
, o = e.closePath
, a = Mesh._GetDefaultSideOrientation(e.sideOrientation)
, s = e.instance
, l = e.updatable;
if (s) {
var u = TmpVectors.Vector3[0].setAll(Number.MAX_VALUE)
, c = TmpVectors.Vector3[1].setAll(-Number.MAX_VALUE)
, h = function(x) {
for (var I = r[0].length, w = s, O = 0, D = w._originalBuilderSideOrientation === Mesh.DOUBLESIDE ? 2 : 1, F = 1; F <= D; ++F)
for (var V = 0; V < r.length; ++V) {
var N = r[V]
, L = N.length;
I = I < L ? I : L;
for (var k = 0; k < I; ++k) {
var U = N[k];
x[O] = U.x,
x[O + 1] = U.y,
x[O + 2] = U.z,
u.minimizeInPlaceFromFloats(U.x, U.y, U.z),
c.maximizeInPlaceFromFloats(U.x, U.y, U.z),
O += 3
}
if (w._creationDataStorage && w._creationDataStorage.closePath) {
var U = N[0];
x[O] = U.x,
x[O + 1] = U.y,
x[O + 2] = U.z,
O += 3
}
}
}
, f = s.getVerticesData(VertexBuffer.PositionKind);
if (h(f),
s.hasBoundingInfo ? s.getBoundingInfo().reConstruct(u, c, s._worldMatrix) : s.buildBoundingInfo(u, c, s._worldMatrix),
s.updateVerticesData(VertexBuffer.PositionKind, f, !1, !1),
e.colors) {
for (var d = s.getVerticesData(VertexBuffer.ColorKind), _ = 0, g = 0; _ < e.colors.length; _++,
g += 4) {
var m = e.colors[_];
d[g] = m.r,
d[g + 1] = m.g,
d[g + 2] = m.b,
d[g + 3] = m.a
}
s.updateVerticesData(VertexBuffer.ColorKind, d, !1, !1)
}
if (e.uvs) {
for (var v = s.getVerticesData(VertexBuffer.UVKind), y = 0; y < e.uvs.length; y++)
v[y * 2] = e.uvs[y].x,
v[y * 2 + 1] = e.uvs[y].y;
s.updateVerticesData(VertexBuffer.UVKind, v, !1, !1)
}
if (!s.areNormalsFrozen || s.isFacetDataEnabled) {
var b = s.getIndices()
, T = s.getVerticesData(VertexBuffer.NormalKind)
, C = s.isFacetDataEnabled ? s.getFacetDataParameters() : null;
if (VertexData.ComputeNormals(f, b, T, C),
s._creationDataStorage && s._creationDataStorage.closePath)
for (var A = 0, S = 0, P = 0; P < r.length; P++)
A = s._creationDataStorage.idx[P] * 3,
P + 1 < r.length ? S = (s._creationDataStorage.idx[P + 1] - 1) * 3 : S = T.length - 3,
T[A] = (T[A] + T[S]) * .5,
T[A + 1] = (T[A + 1] + T[S + 1]) * .5,
T[A + 2] = (T[A + 2] + T[S + 2]) * .5,
T[S] = T[A],
T[S + 1] = T[A + 1],
T[S + 2] = T[A + 2];
s.areNormalsFrozen || s.updateVerticesData(VertexBuffer.NormalKind, T, !1, !1)
}
return s
} else {
var R = new Mesh(i,t);
R._originalBuilderSideOrientation = a,
R._creationDataStorage = new _CreationDataStorage;
var M = CreateRibbonVertexData(e);
return o && (R._creationDataStorage.idx = M._idx),
R._creationDataStorage.closePath = o,
R._creationDataStorage.closeArray = n,
M.applyToMesh(R, l),
R
}
}
VertexData.CreateRibbon = CreateRibbonVertexData;
Mesh.CreateRibbon = function(i, e, t, r, n, o, a, s, l) {
return t === void 0 && (t = !1),
a === void 0 && (a = !1),
CreateRibbon(i, {
pathArray: e,
closeArray: t,
closePath: r,
offset: n,
updatable: a,
sideOrientation: s,
instance: l
}, o)
}
;
function CreateDiscVertexData(i) {
var e = new Array
, t = new Array
, r = new Array
, n = new Array
, o = i.radius || .5
, a = i.tessellation || 64
, s = i.arc && (i.arc <= 0 || i.arc > 1) ? 1 : i.arc || 1
, l = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE;
e.push(0, 0, 0),
n.push(.5, .5);
for (var u = Math.PI * 2 * s, c = s === 1 ? u / a : u / (a - 1), h = 0, f = 0; f < a; f++) {
var d = Math.cos(h)
, _ = Math.sin(h)
, g = (d + 1) / 2
, m = (1 - _) / 2;
e.push(o * d, o * _, 0),
n.push(g, m),
h += c
}
s === 1 && (e.push(e[3], e[4], e[5]),
n.push(n[2], n[3]));
for (var v = e.length / 3, y = 1; y < v - 1; y++)
t.push(y + 1, 0, y);
VertexData.ComputeNormals(e, t, r),
VertexData._ComputeSides(l, e, t, r, n, i.frontUVs, i.backUVs);
var b = new VertexData;
return b.indices = t,
b.positions = e,
b.normals = r,
b.uvs = n,
b
}
function CreateDisc(i, e, t) {
e === void 0 && (e = {}),
t === void 0 && (t = null);
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreateDiscVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreateDisc = CreateDiscVertexData;
Mesh.CreateDisc = function(i, e, t, r, n, o) {
r === void 0 && (r = null);
var a = {
radius: e,
tessellation: t,
sideOrientation: o,
updatable: n
};
return CreateDisc(i, a, r)
}
;
function CreateBoxVertexData(i) {
var e = 6
, t = [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]
, r = [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]
, n = []
, o = []
, a = i.width || i.size || 1
, s = i.height || i.size || 1
, l = i.depth || i.size || 1
, u = i.wrap || !1
, c = i.topBaseAt === void 0 ? 1 : i.topBaseAt
, h = i.bottomBaseAt === void 0 ? 0 : i.bottomBaseAt;
c = (c + 4) % 4,
h = (h + 4) % 4;
var f = [2, 0, 3, 1]
, d = [2, 0, 1, 3]
, _ = f[c]
, g = d[h]
, 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 (u) {
t = [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 v = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]], y = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]], b = [17, 18, 19, 16], T = [22, 23, 20, 21]; _ > 0; )
v.unshift(v.pop()),
b.unshift(b.pop()),
_--;
for (; g > 0; )
y.unshift(y.pop()),
T.unshift(T.pop()),
g--;
v = v.flat(),
y = y.flat(),
m = m.concat(v).concat(y),
t.push(b[0], b[2], b[3], b[0], b[1], b[2]),
t.push(T[0], T[2], T[3], T[0], T[1], T[2])
}
var C = [a / 2, s / 2, l / 2];
o = m.reduce(function(D, F, V) {
return D.concat(F * C[V % 3])
}, []);
for (var A = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE, S = i.faceUV || new Array(6), P = i.faceColors, R = [], M = 0; M < 6; M++)
S[M] === void 0 && (S[M] = new Vector4(0,0,1,1)),
P && P[M] === void 0 && (P[M] = new Color4(1,1,1,1));
for (var x = 0; x < e; x++)
if (n.push(S[x].z, S[x].w),
n.push(S[x].x, S[x].w),
n.push(S[x].x, S[x].y),
n.push(S[x].z, S[x].y),
P)
for (var I = 0; I < 4; I++)
R.push(P[x].r, P[x].g, P[x].b, P[x].a);
VertexData._ComputeSides(A, o, t, r, n, i.frontUVs, i.backUVs);
var w = new VertexData;
if (w.indices = t,
w.positions = o,
w.normals = r,
w.uvs = n,
P) {
var O = A === VertexData.DOUBLESIDE ? R.concat(R) : R;
w.colors = O
}
return w
}
function CreateBox(i, e, t) {
e === void 0 && (e = {}),
t === void 0 && (t = null);
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreateBoxVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreateBox = CreateBoxVertexData;
Mesh.CreateBox = function(i, e, t, r, n) {
t === void 0 && (t = null);
var o = {
size: e,
sideOrientation: n,
updatable: r
};
return CreateBox(i, o, t)
}
;
function CreateTiledPlaneVertexData(i) {
var e = i.pattern || Mesh.NO_FLIP
, t = i.tileWidth || i.tileSize || 1
, r = i.tileHeight || i.tileSize || 1
, n = i.alignHorizontal || 0
, o = i.alignVertical || 0
, a = i.width || i.size || 1
, s = Math.floor(a / t)
, l = a - s * t
, u = i.height || i.size || 1
, c = Math.floor(u / r)
, h = u - c * r
, f = t * s / 2
, d = r * c / 2
, _ = 0
, g = 0
, m = 0
, v = 0
, y = 0
, b = 0;
if (l > 0 || h > 0) {
m = -f,
v = -d;
var y = f
, b = d;
switch (n) {
case Mesh.CENTER:
l /= 2,
m -= l,
y += l;
break;
case Mesh.LEFT:
y += l,
_ = -l / 2;
break;
case Mesh.RIGHT:
m -= l,
_ = l / 2;
break
}
switch (o) {
case Mesh.CENTER:
h /= 2,
v -= h,
b += h;
break;
case Mesh.BOTTOM:
b += h,
g = -h / 2;
break;
case Mesh.TOP:
v -= h,
g = h / 2;
break
}
}
var T = []
, C = []
, A = [];
A[0] = [0, 0, 1, 0, 1, 1, 0, 1],
A[1] = [0, 0, 1, 0, 1, 1, 0, 1],
(e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (A[1] = [1, 1, 0, 1, 0, 0, 1, 0]),
(e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (A[1] = [1, 0, 0, 0, 0, 1, 1, 1]),
(e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (A[1] = [0, 1, 1, 1, 1, 0, 0, 0]);
for (var S = [], P = [], R = [], M = 0, x = 0; x < c; x++)
for (var I = 0; I < s; I++)
T.push(-f + I * t + _, -d + x * r + g, 0),
T.push(-f + (I + 1) * t + _, -d + x * r + g, 0),
T.push(-f + (I + 1) * t + _, -d + (x + 1) * r + g, 0),
T.push(-f + I * t + _, -d + (x + 1) * r + g, 0),
R.push(M, M + 1, M + 3, M + 1, M + 2, M + 3),
e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? S = S.concat(A[(I % 2 + x % 2) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? S = S.concat(A[x % 2]) : S = S.concat(A[0]),
P.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
C.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1),
M += 4;
if (l > 0 || h > 0) {
var w = h > 0 && (o === Mesh.CENTER || o === Mesh.TOP), O = h > 0 && (o === Mesh.CENTER || o === Mesh.BOTTOM), D = l > 0 && (n === Mesh.CENTER || n === Mesh.RIGHT), F = l > 0 && (n === Mesh.CENTER || n === Mesh.LEFT), V = [], N, L, k, U;
if (w && D && (T.push(m + _, v + g, 0),
T.push(-f + _, v + g, 0),
T.push(-f + _, v + h + g, 0),
T.push(m + _, v + h + g, 0),
R.push(M, M + 1, M + 3, M + 1, M + 2, M + 3),
M += 4,
N = 1 - l / t,
L = 1 - h / r,
k = 1,
U = 1,
V = [N, L, k, L, k, U, N, U],
e === Mesh.ROTATE_ROW && (V = [1 - N, 1 - L, 1 - k, 1 - L, 1 - k, 1 - U, 1 - N, 1 - U]),
e === Mesh.FLIP_ROW && (V = [1 - N, L, 1 - k, L, 1 - k, U, 1 - N, U]),
e === Mesh.FLIP_N_ROTATE_ROW && (V = [N, 1 - L, k, 1 - L, k, 1 - U, N, 1 - U]),
S = S.concat(V),
P.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
C.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
w && F && (T.push(f + _, v + g, 0),
T.push(y + _, v + g, 0),
T.push(y + _, v + h + g, 0),
T.push(f + _, v + h + g, 0),
R.push(M, M + 1, M + 3, M + 1, M + 2, M + 3),
M += 4,
N = 0,
L = 1 - h / r,
k = l / t,
U = 1,
V = [N, L, k, L, k, U, N, U],
(e === Mesh.ROTATE_ROW || e === Mesh.ROTATE_TILE && s % 2 === 0) && (V = [1 - N, 1 - L, 1 - k, 1 - L, 1 - k, 1 - U, 1 - N, 1 - U]),
(e === Mesh.FLIP_ROW || e === Mesh.FLIP_TILE && s % 2 === 0) && (V = [1 - N, L, 1 - k, L, 1 - k, U, 1 - N, U]),
(e === Mesh.FLIP_N_ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_TILE && s % 2 === 0) && (V = [N, 1 - L, k, 1 - L, k, 1 - U, N, 1 - U]),
S = S.concat(V),
P.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
C.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
O && D && (T.push(m + _, d + g, 0),
T.push(-f + _, d + g, 0),
T.push(-f + _, b + g, 0),
T.push(m + _, b + g, 0),
R.push(M, M + 1, M + 3, M + 1, M + 2, M + 3),
M += 4,
N = 1 - l / t,
L = 0,
k = 1,
U = h / r,
V = [N, L, k, L, k, U, N, U],
(e === Mesh.ROTATE_ROW && c % 2 === 1 || e === Mesh.ROTATE_TILE && c % 1 === 0) && (V = [1 - N, 1 - L, 1 - k, 1 - L, 1 - k, 1 - U, 1 - N, 1 - U]),
(e === Mesh.FLIP_ROW && c % 2 === 1 || e === Mesh.FLIP_TILE && c % 2 === 0) && (V = [1 - N, L, 1 - k, L, 1 - k, U, 1 - N, U]),
(e === Mesh.FLIP_N_ROTATE_ROW && c % 2 === 1 || e === Mesh.FLIP_N_ROTATE_TILE && c % 2 === 0) && (V = [N, 1 - L, k, 1 - L, k, 1 - U, N, 1 - U]),
S = S.concat(V),
P.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
C.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
O && F && (T.push(f + _, d + g, 0),
T.push(y + _, d + g, 0),
T.push(y + _, b + g, 0),
T.push(f + _, b + g, 0),
R.push(M, M + 1, M + 3, M + 1, M + 2, M + 3),
M += 4,
N = 0,
L = 0,
k = l / t,
U = h / r,
V = [N, L, k, L, k, U, N, U],
(e === Mesh.ROTATE_ROW && c % 2 === 1 || e === Mesh.ROTATE_TILE && (c + s) % 2 === 1) && (V = [1 - N, 1 - L, 1 - k, 1 - L, 1 - k, 1 - U, 1 - N, 1 - U]),
(e === Mesh.FLIP_ROW && c % 2 === 1 || e === Mesh.FLIP_TILE && (c + s) % 2 === 1) && (V = [1 - N, L, 1 - k, L, 1 - k, U, 1 - N, U]),
(e === Mesh.FLIP_N_ROTATE_ROW && c % 2 === 1 || e === Mesh.FLIP_N_ROTATE_TILE && (c + s) % 2 === 1) && (V = [N, 1 - L, k, 1 - L, k, 1 - U, N, 1 - U]),
S = S.concat(V),
P.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
C.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
w) {
var z = [];
N = 0,
L = 1 - h / r,
k = 1,
U = 1,
z[0] = [N, L, k, L, k, U, N, U],
z[1] = [N, L, k, L, k, U, N, U],
(e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (z[1] = [1 - N, 1 - L, 1 - k, 1 - L, 1 - k, 1 - U, 1 - N, 1 - U]),
(e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (z[1] = [1 - N, L, 1 - k, L, 1 - k, U, 1 - N, U]),
(e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (z[1] = [N, 1 - L, k, 1 - L, k, 1 - U, N, 1 - U]);
for (var I = 0; I < s; I++)
T.push(-f + I * t + _, v + g, 0),
T.push(-f + (I + 1) * t + _, v + g, 0),
T.push(-f + (I + 1) * t + _, v + h + g, 0),
T.push(-f + I * t + _, v + h + g, 0),
R.push(M, M + 1, M + 3, M + 1, M + 2, M + 3),
M += 4,
e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? S = S.concat(z[(I + 1) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? S = S.concat(z[1]) : S = S.concat(z[0]),
P.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
C.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
}
if (O) {
var H = [];
N = 0,
L = 0,
k = 1,
U = h / r,
H[0] = [N, L, k, L, k, U, N, U],
H[1] = [N, L, k, L, k, U, N, U],
(e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (H[1] = [1 - N, 1 - L, 1 - k, 1 - L, 1 - k, 1 - U, 1 - N, 1 - U]),
(e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (H[1] = [1 - N, L, 1 - k, L, 1 - k, U, 1 - N, U]),
(e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (H[1] = [N, 1 - L, k, 1 - L, k, 1 - U, N, 1 - U]);
for (var I = 0; I < s; I++)
T.push(-f + I * t + _, b - h + g, 0),
T.push(-f + (I + 1) * t + _, b - h + g, 0),
T.push(-f + (I + 1) * t + _, b + g, 0),
T.push(-f + I * t + _, b + g, 0),
R.push(M, M + 1, M + 3, M + 1, M + 2, M + 3),
M += 4,
e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? S = S.concat(H[(I + c) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? S = S.concat(H[c % 2]) : S = S.concat(H[0]),
P.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
C.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
}
if (D) {
var G = [];
N = 1 - l / t,
L = 0,
k = 1,
U = 1,
G[0] = [N, L, k, L, k, U, N, U],
G[1] = [N, L, k, L, k, U, N, U],
(e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (G[1] = [1 - N, 1 - L, 1 - k, 1 - L, 1 - k, 1 - U, 1 - N, 1 - U]),
(e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (G[1] = [1 - N, L, 1 - k, L, 1 - k, U, 1 - N, U]),
(e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (G[1] = [N, 1 - L, k, 1 - L, k, 1 - U, N, 1 - U]);
for (var x = 0; x < c; x++)
T.push(m + _, -d + x * r + g, 0),
T.push(m + l + _, -d + x * r + g, 0),
T.push(m + l + _, -d + (x + 1) * r + g, 0),
T.push(m + _, -d + (x + 1) * r + g, 0),
R.push(M, M + 1, M + 3, M + 1, M + 2, M + 3),
M += 4,
e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? S = S.concat(G[(x + 1) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? S = S.concat(G[x % 2]) : S = S.concat(G[0]),
P.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
C.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
}
if (F) {
var W = [];
N = 0,
L = 0,
k = l / r,
U = 1,
W[0] = [N, L, k, L, k, U, N, U],
W[1] = [N, L, k, L, k, U, N, U],
(e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (W[1] = [1 - N, 1 - L, 1 - k, 1 - L, 1 - k, 1 - U, 1 - N, 1 - U]),
(e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (W[1] = [1 - N, L, 1 - k, L, 1 - k, U, 1 - N, U]),
(e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (W[1] = [N, 1 - L, k, 1 - L, k, 1 - U, N, 1 - U]);
for (var x = 0; x < c; x++)
T.push(y - l + _, -d + x * r + g, 0),
T.push(y + _, -d + x * r + g, 0),
T.push(y + _, -d + (x + 1) * r + g, 0),
T.push(y - l + _, -d + (x + 1) * r + g, 0),
R.push(M, M + 1, M + 3, M + 1, M + 2, M + 3),
M += 4,
e === Mesh.FLIP_TILE || e === Mesh.ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_TILE ? S = S.concat(W[(x + s) % 2]) : e === Mesh.FLIP_ROW || e === Mesh.ROTATE_ROW || e === Mesh.FLIP_N_ROTATE_ROW ? S = S.concat(W[x % 2]) : S = S.concat(W[0]),
P.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
C.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
}
}
var j = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE;
VertexData._ComputeSides(j, T, R, C, S, i.frontUVs, i.backUVs);
var B = new VertexData;
B.indices = R,
B.positions = T,
B.normals = C,
B.uvs = S;
var X = j === VertexData.DOUBLESIDE ? P.concat(P) : P;
return B.colors = X,
B
}
function CreateTiledPlane(i, e, t) {
t === void 0 && (t = null);
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreateTiledPlaneVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreateTiledPlane = CreateTiledPlaneVertexData;
function CreateTiledBoxVertexData(i) {
for (var e = 6, t = i.faceUV || new Array(6), r = i.faceColors, n = i.pattern || Mesh.NO_FLIP, o = i.width || i.size || 1, a = i.height || i.size || 1, s = i.depth || i.size || 1, l = i.tileWidth || i.tileSize || 1, u = i.tileHeight || i.tileSize || 1, c = i.alignHorizontal || 0, h = i.alignVertical || 0, f = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE, d = 0; d < e; d++)
t[d] === void 0 && (t[d] = new Vector4(0,0,1,1)),
r && r[d] === void 0 && (r[d] = new Color4(1,1,1,1));
for (var _ = o / 2, g = a / 2, m = s / 2, v = [], d = 0; d < 2; d++)
v[d] = CreateTiledPlaneVertexData({
pattern: n,
tileWidth: l,
tileHeight: u,
width: o,
height: a,
alignVertical: h,
alignHorizontal: c,
sideOrientation: f
});
for (var d = 2; d < 4; d++)
v[d] = CreateTiledPlaneVertexData({
pattern: n,
tileWidth: l,
tileHeight: u,
width: s,
height: a,
alignVertical: h,
alignHorizontal: c,
sideOrientation: f
});
var y = h;
h === Mesh.BOTTOM ? y = Mesh.TOP : h === Mesh.TOP && (y = Mesh.BOTTOM);
for (var d = 4; d < 6; d++)
v[d] = CreateTiledPlaneVertexData({
pattern: n,
tileWidth: l,
tileHeight: u,
width: o,
height: s,
alignVertical: y,
alignHorizontal: c,
sideOrientation: f
});
for (var b = [], T = [], C = [], A = [], S = [], P = [], R = [], M = [], x = 0, I = 0, w = 0, d = 0; d < e; d++) {
var x = v[d].positions.length;
P[d] = [],
R[d] = [];
for (var O = 0; O < x / 3; O++)
P[d].push(new Vector3(v[d].positions[3 * O],v[d].positions[3 * O + 1],v[d].positions[3 * O + 2])),
R[d].push(new Vector3(v[d].normals[3 * O],v[d].normals[3 * O + 1],v[d].normals[3 * O + 2]));
I = v[d].uvs.length,
M[d] = [];
for (var D = 0; D < I; D += 2)
M[d][D] = t[d].x + (t[d].z - t[d].x) * v[d].uvs[D],
M[d][D + 1] = t[d].y + (t[d].w - t[d].y) * v[d].uvs[D + 1];
if (C = C.concat(M[d]),
A = A.concat(v[d].indices.map(function($) {
return $ + w
})),
w += P[d].length,
r)
for (var F = 0; F < 4; F++)
S.push(r[d].r, r[d].g, r[d].b, r[d].a)
}
var V = new Vector3(0,0,m)
, N = Matrix.RotationY(Math.PI);
b = P[0].map(function(B) {
return Vector3.TransformNormal(B, N).add(V)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, []),
T = R[0].map(function(B) {
return Vector3.TransformNormal(B, N)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, []),
b = b.concat(P[1].map(function(B) {
return B.subtract(V)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, [])),
T = T.concat(R[1].map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, []));
var L = new Vector3(_,0,0)
, k = Matrix.RotationY(-Math.PI / 2);
b = b.concat(P[2].map(function(B) {
return Vector3.TransformNormal(B, k).add(L)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, [])),
T = T.concat(R[2].map(function(B) {
return Vector3.TransformNormal(B, k)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, []));
var U = Matrix.RotationY(Math.PI / 2);
b = b.concat(P[3].map(function(B) {
return Vector3.TransformNormal(B, U).subtract(L)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, [])),
T = T.concat(R[3].map(function(B) {
return Vector3.TransformNormal(B, U)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, []));
var z = new Vector3(0,g,0)
, H = Matrix.RotationX(Math.PI / 2);
b = b.concat(P[4].map(function(B) {
return Vector3.TransformNormal(B, H).add(z)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, [])),
T = T.concat(R[4].map(function(B) {
return Vector3.TransformNormal(B, H)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, []));
var G = Matrix.RotationX(-Math.PI / 2);
b = b.concat(P[5].map(function(B) {
return Vector3.TransformNormal(B, G).subtract(z)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, [])),
T = T.concat(R[5].map(function(B) {
return Vector3.TransformNormal(B, G)
}).map(function(B) {
return [B.x, B.y, B.z]
}).reduce(function(B, X) {
return B.concat(X)
}, [])),
VertexData._ComputeSides(f, b, A, T, C);
var W = new VertexData;
if (W.indices = A,
W.positions = b,
W.normals = T,
W.uvs = C,
r) {
var j = f === VertexData.DOUBLESIDE ? S.concat(S) : S;
W.colors = j
}
return W
}
function CreateTiledBox(i, e, t) {
t === void 0 && (t = null);
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreateTiledBoxVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreateTiledBox = CreateTiledBoxVertexData;
function CreateSphereVertexData(i) {
for (var e = i.segments || 32, t = i.diameterX || i.diameter || 1, r = i.diameterY || i.diameter || 1, n = i.diameterZ || i.diameter || 1, o = i.arc && (i.arc <= 0 || i.arc > 1) ? 1 : i.arc || 1, a = i.slice && i.slice <= 0 ? 1 : i.slice || 1, s = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE, l = !!i.dedupTopBottomIndices, u = new Vector3(t / 2,r / 2,n / 2), c = 2 + e, h = 2 * c, f = [], d = [], _ = [], g = [], m = 0; m <= c; m++) {
for (var v = m / c, y = v * Math.PI * a, b = 0; b <= h; b++) {
var T = b / h
, C = T * Math.PI * 2 * o
, A = Matrix.RotationZ(-y)
, S = Matrix.RotationY(C)
, P = Vector3.TransformCoordinates(Vector3.Up(), A)
, R = Vector3.TransformCoordinates(P, S)
, M = R.multiply(u)
, x = R.divide(u).normalize();
d.push(M.x, M.y, M.z),
_.push(x.x, x.y, x.z),
g.push(T, v)
}
if (m > 0)
for (var I = d.length / 3, w = I - 2 * (h + 1); w + h + 2 < I; w++)
l ? (m > 1 && (f.push(w),
f.push(w + 1),
f.push(w + h + 1)),
(m < c || a < 1) && (f.push(w + h + 1),
f.push(w + 1),
f.push(w + h + 2))) : (f.push(w),
f.push(w + 1),
f.push(w + h + 1),
f.push(w + h + 1),
f.push(w + 1),
f.push(w + h + 2))
}
VertexData._ComputeSides(s, d, f, _, g, i.frontUVs, i.backUVs);
var O = new VertexData;
return O.indices = f,
O.positions = d,
O.normals = _,
O.uvs = g,
O
}
function CreateSphere(i, e, t) {
e === void 0 && (e = {}),
t === void 0 && (t = null);
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreateSphereVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreateSphere = CreateSphereVertexData;
Mesh.CreateSphere = function(i, e, t, r, n, o) {
var a = {
segments: e,
diameterX: t,
diameterY: t,
diameterZ: t,
sideOrientation: o,
updatable: n
};
return CreateSphere(i, a, r)
}
;
function CreateCylinderVertexData(i) {
var e = i.height || 2
, t = i.diameterTop === 0 ? 0 : i.diameterTop || i.diameter || 1
, r = i.diameterBottom === 0 ? 0 : i.diameterBottom || i.diameter || 1;
t = t || 1e-5,
r = r || 1e-5;
var n = i.tessellation || 24, o = i.subdivisions || 1, a = !!i.hasRings, s = !!i.enclose, l = i.cap === 0 ? 0 : i.cap || Mesh.CAP_ALL, u = i.arc && (i.arc <= 0 || i.arc > 1) ? 1 : i.arc || 1, c = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE, h = i.faceUV || new Array(3), f = i.faceColors, d = u !== 1 && s ? 2 : 0, _ = a ? o : 1, g = 2 + (1 + d) * _, m;
for (m = 0; m < g; m++)
f && f[m] === void 0 && (f[m] = new Color4(1,1,1,1));
for (m = 0; m < g; m++)
h && h[m] === void 0 && (h[m] = new Vector4(0,0,1,1));
var v = new Array, y = new Array, b = new Array, T = new Array, C = new Array, A = Math.PI * 2 * u / n, S, P, R, M = (r - t) / 2 / e, x = Vector3.Zero(), I = Vector3.Zero(), w = Vector3.Zero(), O = Vector3.Zero(), D = Vector3.Zero(), F = Axis.Y, V, N, L, k = 1, G = 1, U = 0, z = 0;
for (V = 0; V <= o; V++)
for (P = V / o,
R = (P * (t - r) + r) / 2,
k = a && V !== 0 && V !== o ? 2 : 1,
L = 0; L < k; L++) {
for (a && (G += L),
s && (G += 2 * L),
N = 0; N <= n; N++)
S = N * A,
x.x = Math.cos(-S) * R,
x.y = -e / 2 + P * e,
x.z = Math.sin(-S) * R,
t === 0 && V === o ? (I.x = b[b.length - (n + 1) * 3],
I.y = b[b.length - (n + 1) * 3 + 1],
I.z = b[b.length - (n + 1) * 3 + 2]) : (I.x = x.x,
I.z = x.z,
I.y = Math.sqrt(I.x * I.x + I.z * I.z) * M,
I.normalize()),
N === 0 && (w.copyFrom(x),
O.copyFrom(I)),
y.push(x.x, x.y, x.z),
b.push(I.x, I.y, I.z),
a ? z = U !== G ? h[G].y : h[G].w : z = h[G].y + (h[G].w - h[G].y) * P,
T.push(h[G].x + (h[G].z - h[G].x) * N / n, z),
f && C.push(f[G].r, f[G].g, f[G].b, f[G].a);
u !== 1 && s && (y.push(x.x, x.y, x.z),
y.push(0, x.y, 0),
y.push(0, x.y, 0),
y.push(w.x, w.y, w.z),
Vector3.CrossToRef(F, I, D),
D.normalize(),
b.push(D.x, D.y, D.z, D.x, D.y, D.z),
Vector3.CrossToRef(O, F, D),
D.normalize(),
b.push(D.x, D.y, D.z, D.x, D.y, D.z),
a ? z = U !== G ? h[G + 1].y : h[G + 1].w : z = h[G + 1].y + (h[G + 1].w - h[G + 1].y) * P,
T.push(h[G + 1].x, z),
T.push(h[G + 1].z, z),
a ? z = U !== G ? h[G + 2].y : h[G + 2].w : z = h[G + 2].y + (h[G + 2].w - h[G + 2].y) * P,
T.push(h[G + 2].x, z),
T.push(h[G + 2].z, z),
f && (C.push(f[G + 1].r, f[G + 1].g, f[G + 1].b, f[G + 1].a),
C.push(f[G + 1].r, f[G + 1].g, f[G + 1].b, f[G + 1].a),
C.push(f[G + 2].r, f[G + 2].g, f[G + 2].b, f[G + 2].a),
C.push(f[G + 2].r, f[G + 2].g, f[G + 2].b, f[G + 2].a))),
U !== G && (U = G)
}
var H = u !== 1 && s ? n + 4 : n, G;
for (V = 0,
G = 0; G < o; G++) {
var W = 0
, j = 0
, B = 0
, X = 0;
for (N = 0; N < n; N++)
W = V * (H + 1) + N,
j = (V + 1) * (H + 1) + N,
B = V * (H + 1) + (N + 1),
X = (V + 1) * (H + 1) + (N + 1),
v.push(W, j, B),
v.push(X, B, j);
u !== 1 && s && (v.push(W + 2, j + 2, B + 2),
v.push(X + 2, B + 2, j + 2),
v.push(W + 4, j + 4, B + 4),
v.push(X + 4, B + 4, j + 4)),
V = a ? V + 2 : V + 1
}
var $ = function(K) {
var Z = K ? t / 2 : r / 2;
if (Z !== 0) {
var q, J, Q, te = K ? h[g - 1] : h[0], re = null;
f && (re = K ? f[g - 1] : f[0]);
var ie = y.length / 3
, ee = K ? e / 2 : -e / 2
, ne = new Vector3(0,ee,0);
y.push(ne.x, ne.y, ne.z),
b.push(0, K ? 1 : -1, 0),
T.push(te.x + (te.z - te.x) * .5, te.y + (te.w - te.y) * .5),
re && C.push(re.r, re.g, re.b, re.a);
var ce = new Vector2(.5,.5);
for (Q = 0; Q <= n; Q++) {
q = Math.PI * 2 * Q * u / n;
var he = Math.cos(-q)
, fe = Math.sin(-q);
J = new Vector3(he * Z,ee,fe * Z);
var ue = new Vector2(he * ce.x + .5,fe * ce.y + .5);
y.push(J.x, J.y, J.z),
b.push(0, K ? 1 : -1, 0),
T.push(te.x + (te.z - te.x) * ue.x, te.y + (te.w - te.y) * ue.y),
re && C.push(re.r, re.g, re.b, re.a)
}
for (Q = 0; Q < n; Q++)
K ? (v.push(ie),
v.push(ie + (Q + 2)),
v.push(ie + (Q + 1))) : (v.push(ie),
v.push(ie + (Q + 1)),
v.push(ie + (Q + 2)))
}
};
(l === Mesh.CAP_START || l === Mesh.CAP_ALL) && $(!1),
(l === Mesh.CAP_END || l === Mesh.CAP_ALL) && $(!0),
VertexData._ComputeSides(c, y, v, b, T, i.frontUVs, i.backUVs);
var Y = new VertexData;
return Y.indices = v,
Y.positions = y,
Y.normals = b,
Y.uvs = T,
f && (Y.colors = C),
Y
}
function CreateCylinder(i, e, t) {
e === void 0 && (e = {});
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreateCylinderVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreateCylinder = CreateCylinderVertexData;
Mesh.CreateCylinder = function(i, e, t, r, n, o, a, s, l) {
(a === void 0 || !(a instanceof Scene)) && (a !== void 0 && (l = s || Mesh.DEFAULTSIDE,
s = a),
a = o,
o = 1);
var u = {
height: e,
diameterTop: t,
diameterBottom: r,
tessellation: n,
subdivisions: o,
sideOrientation: l,
updatable: s
};
return CreateCylinder(i, u, a)
}
;
function CreateTorusVertexData(i) {
for (var e = [], t = [], r = [], n = [], o = i.diameter || 1, a = i.thickness || .5, s = i.tessellation || 16, l = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE, u = s + 1, c = 0; c <= s; c++)
for (var h = c / s, f = c * Math.PI * 2 / s - Math.PI / 2, d = Matrix.Translation(o / 2, 0, 0).multiply(Matrix.RotationY(f)), _ = 0; _ <= s; _++) {
var g = 1 - _ / s
, m = _ * Math.PI * 2 / s + Math.PI
, v = Math.cos(m)
, y = Math.sin(m)
, b = new Vector3(v,y,0)
, T = b.scale(a / 2)
, C = new Vector2(h,g);
T = Vector3.TransformCoordinates(T, d),
b = Vector3.TransformNormal(b, d),
t.push(T.x, T.y, T.z),
r.push(b.x, b.y, b.z),
n.push(C.x, C.y);
var A = (c + 1) % u
, S = (_ + 1) % u;
e.push(c * u + _),
e.push(c * u + S),
e.push(A * u + _),
e.push(c * u + S),
e.push(A * u + S),
e.push(A * u + _)
}
VertexData._ComputeSides(l, t, e, r, n, i.frontUVs, i.backUVs);
var P = new VertexData;
return P.indices = e,
P.positions = t,
P.normals = r,
P.uvs = n,
P
}
function CreateTorus(i, e, t) {
e === void 0 && (e = {});
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreateTorusVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreateTorus = CreateTorusVertexData;
Mesh.CreateTorus = function(i, e, t, r, n, o, a) {
var s = {
diameter: e,
thickness: t,
tessellation: r,
sideOrientation: a,
updatable: o
};
return CreateTorus(i, s, n)
}
;
function CreateTorusKnotVertexData(i) {
var e = new Array, t = new Array, r = new Array, n = new Array, o = i.radius || 2, a = i.tube || .5, s = i.radialSegments || 32, l = i.tubularSegments || 32, u = i.p || 2, c = i.q || 3, h = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE, f = function(F) {
var V = Math.cos(F)
, N = Math.sin(F)
, L = c / u * F
, k = Math.cos(L)
, U = o * (2 + k) * .5 * V
, z = o * (2 + k) * N * .5
, H = o * Math.sin(L) * .5;
return new Vector3(U,z,H)
}, d, _;
for (d = 0; d <= s; d++) {
var g = d % s
, m = g / s * 2 * u * Math.PI
, v = f(m)
, y = f(m + .01)
, b = y.subtract(v)
, T = y.add(v)
, C = Vector3.Cross(b, T);
for (T = Vector3.Cross(C, b),
C.normalize(),
T.normalize(),
_ = 0; _ < l; _++) {
var A = _ % l
, S = A / l * 2 * Math.PI
, P = -a * Math.cos(S)
, R = a * Math.sin(S);
t.push(v.x + P * T.x + R * C.x),
t.push(v.y + P * T.y + R * C.y),
t.push(v.z + P * T.z + R * C.z),
n.push(d / s),
n.push(_ / l)
}
}
for (d = 0; d < s; d++)
for (_ = 0; _ < l; _++) {
var M = (_ + 1) % l
, x = d * l + _
, I = (d + 1) * l + _
, w = (d + 1) * l + M
, O = d * l + M;
e.push(O),
e.push(I),
e.push(x),
e.push(O),
e.push(w),
e.push(I)
}
VertexData.ComputeNormals(t, e, r),
VertexData._ComputeSides(h, t, e, r, n, i.frontUVs, i.backUVs);
var D = new VertexData;
return D.indices = e,
D.positions = t,
D.normals = r,
D.uvs = n,
D
}
function CreateTorusKnot(i, e, t) {
e === void 0 && (e = {});
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreateTorusKnotVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreateTorusKnot = CreateTorusKnotVertexData;
Mesh.CreateTorusKnot = function(i, e, t, r, n, o, a, s, l, u) {
var c = {
radius: e,
tube: t,
radialSegments: r,
tubularSegments: n,
p: o,
q: a,
sideOrientation: u,
updatable: l
};
return CreateTorusKnot(i, c, s)
}
;
Mesh._instancedMeshFactory = function(i, e) {
var t = new InstancedMesh(i,e);
if (e.instancedBuffers) {
t.instancedBuffers = {};
for (var r in e.instancedBuffers)
t.instancedBuffers[r] = e.instancedBuffers[r]
}
return t
}
;
var InstancedMesh = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t, r.getScene()) || this;
n._indexInSourceMeshInstanceArray = -1,
n._distanceToCamera = 0,
r.addInstance(n),
n._sourceMesh = r,
n._unIndexed = r._unIndexed,
n.position.copyFrom(r.position),
n.rotation.copyFrom(r.rotation),
n.scaling.copyFrom(r.scaling),
r.rotationQuaternion && (n.rotationQuaternion = r.rotationQuaternion.clone()),
n.animations = Tools.Slice(r.animations);
for (var o = 0, a = r.getAnimationRanges(); o < a.length; o++) {
var s = a[o];
s != null && n.createAnimationRange(s.name, s.from, s.to)
}
return n.infiniteDistance = r.infiniteDistance,
n.setPivotMatrix(r.getPivotMatrix()),
n.refreshBoundingInfo(),
n._syncSubMeshes(),
n
}
return e.prototype.getClassName = function() {
return "InstancedMesh"
}
,
Object.defineProperty(e.prototype, "lightSources", {
get: function() {
return this._sourceMesh._lightSources
},
enumerable: !1,
configurable: !0
}),
e.prototype._resyncLightSources = function() {}
,
e.prototype._resyncLightSource = function(t) {}
,
e.prototype._removeLightSource = function(t, r) {}
,
Object.defineProperty(e.prototype, "receiveShadows", {
get: function() {
return this._sourceMesh.receiveShadows
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "material", {
get: function() {
return this._sourceMesh.material
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "visibility", {
get: function() {
return this._sourceMesh.visibility
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "skeleton", {
get: function() {
return this._sourceMesh.skeleton
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "renderingGroupId", {
get: function() {
return this._sourceMesh.renderingGroupId
},
set: function(t) {
!this._sourceMesh || t === this._sourceMesh.renderingGroupId || Logger$2.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")
},
enumerable: !1,
configurable: !0
}),
e.prototype.getTotalVertices = function() {
return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0
}
,
e.prototype.getTotalIndices = function() {
return this._sourceMesh.getTotalIndices()
}
,
Object.defineProperty(e.prototype, "sourceMesh", {
get: function() {
return this._sourceMesh
},
enumerable: !1,
configurable: !0
}),
e.prototype.createInstance = function(t) {
return this._sourceMesh.createInstance(t)
}
,
e.prototype.isReady = function(t) {
return t === void 0 && (t = !1),
this._sourceMesh.isReady(t, !0)
}
,
e.prototype.getVerticesData = function(t, r) {
return this._sourceMesh.getVerticesData(t, r)
}
,
e.prototype.setVerticesData = function(t, r, n, o) {
return this.sourceMesh && this.sourceMesh.setVerticesData(t, r, n, o),
this.sourceMesh
}
,
e.prototype.updateVerticesData = function(t, r, n, o) {
return this.sourceMesh && this.sourceMesh.updateVerticesData(t, r, n, o),
this.sourceMesh
}
,
e.prototype.setIndices = function(t, r) {
return r === void 0 && (r = null),
this.sourceMesh && this.sourceMesh.setIndices(t, r),
this.sourceMesh
}
,
e.prototype.isVerticesDataPresent = function(t) {
return this._sourceMesh.isVerticesDataPresent(t)
}
,
e.prototype.getIndices = function() {
return this._sourceMesh.getIndices()
}
,
Object.defineProperty(e.prototype, "_positions", {
get: function() {
return this._sourceMesh._positions
},
enumerable: !1,
configurable: !0
}),
e.prototype.refreshBoundingInfo = function(t, r) {
if (t === void 0 && (t = !1),
r === void 0 && (r = !1),
this.hasBoundingInfo && this.getBoundingInfo().isLocked)
return this;
var n = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
return this._refreshBoundingInfo(this._sourceMesh._getPositionData(t, r), n),
this
}
,
e.prototype._preActivate = function() {
return this._currentLOD && this._currentLOD._preActivate(),
this
}
,
e.prototype._activate = function(t, r) {
if (this._sourceMesh.subMeshes || Logger$2.Warn("Instances should only be created for meshes with geometry."),
this._currentLOD) {
var n = this._currentLOD._getWorldMatrixDeterminant() > 0 != this._getWorldMatrixDeterminant() > 0;
if (n)
return this._internalAbstractMeshDataInfo._actAsRegularMesh = !0,
!0;
if (this._internalAbstractMeshDataInfo._actAsRegularMesh = !1,
this._currentLOD._registerInstanceForRenderId(this, t),
r) {
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
}
,
e.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)
}
,
e.prototype.getWorldMatrix = function() {
if (this._currentLOD && this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {
this._billboardWorldMatrix || (this._billboardWorldMatrix = new Matrix);
var t = this._currentLOD._masterMesh;
return this._currentLOD._masterMesh = this,
TmpVectors.Vector3[7].copyFrom(this._currentLOD.position),
this._currentLOD.position.set(0, 0, 0),
this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),
this._currentLOD.position.copyFrom(TmpVectors.Vector3[7]),
this._currentLOD._masterMesh = t,
this._billboardWorldMatrix
}
return i.prototype.getWorldMatrix.call(this)
}
,
Object.defineProperty(e.prototype, "isAnInstance", {
get: function() {
return !0
},
enumerable: !1,
configurable: !0
}),
e.prototype.getLOD = function(t) {
if (!t)
return this;
var r = this.getBoundingInfo();
return this._currentLOD = this.sourceMesh.getLOD(t, r.boundingSphere),
this._currentLOD === this.sourceMesh ? this.sourceMesh : this._currentLOD
}
,
e.prototype._preActivateForIntermediateRendering = function(t) {
return this.sourceMesh._preActivateForIntermediateRendering(t)
}
,
e.prototype._syncSubMeshes = function() {
if (this.releaseSubMeshes(),
this._sourceMesh.subMeshes)
for (var t = 0; t < this._sourceMesh.subMeshes.length; t++)
this._sourceMesh.subMeshes[t].clone(this, this._sourceMesh);
return this
}
,
e.prototype._generatePointsArray = function() {
return this._sourceMesh._generatePointsArray()
}
,
e.prototype._updateBoundingInfo = function() {
var t = this;
return this.hasBoundingInfo ? this.getBoundingInfo().update(t.worldMatrixFromCache) : this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, t.worldMatrixFromCache),
this._updateSubMeshesBoundingInfo(t.worldMatrixFromCache),
this
}
,
e.prototype.clone = function(t, r, n) {
r === void 0 && (r = null);
var o = this._sourceMesh.createInstance(t);
if (DeepCopier.DeepCopy(this, o, ["name", "subMeshes", "uniqueId", "parent", "lightSources", "receiveShadows", "material", "visibility", "skeleton", "sourceMesh", "isAnInstance", "facetNb", "isFacetDataEnabled", "isBlocked", "useBones", "hasInstances", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances"], []),
this.refreshBoundingInfo(),
r && (o.parent = r),
!n)
for (var a = 0; a < this.getScene().meshes.length; a++) {
var s = this.getScene().meshes[a];
s.parent === this && s.clone(s.name, o)
}
return o.computeWorldMatrix(!0),
this.onClonedObservable.notifyObservers(o),
o
}
,
e.prototype.dispose = function(t, r) {
r === void 0 && (r = !1),
this._sourceMesh.removeInstance(this),
i.prototype.dispose.call(this, t, r)
}
,
e
}(AbstractMesh);
Mesh.prototype.edgesShareWithInstances = !1;
Mesh.prototype.registerInstancedBuffer = function(i, e) {
var t, r;
if ((r = (t = this._userInstancedBuffersStorage) === null || t === void 0 ? void 0 : t.vertexBuffers[i]) === null || r === void 0 || r.dispose(),
!this.instancedBuffers) {
this.instancedBuffers = {};
for (var n = 0, o = this.instances; n < o.length; n++) {
var a = o[n];
a.instancedBuffers = {}
}
this._userInstancedBuffersStorage = {
data: {},
vertexBuffers: {},
strides: {},
sizes: {},
vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
}
}
this.instancedBuffers[i] = null,
this._userInstancedBuffersStorage.strides[i] = e,
this._userInstancedBuffersStorage.sizes[i] = e * 32,
this._userInstancedBuffersStorage.data[i] = new Float32Array(this._userInstancedBuffersStorage.sizes[i]),
this._userInstancedBuffersStorage.vertexBuffers[i] = new VertexBuffer(this.getEngine(),this._userInstancedBuffersStorage.data[i],i,!0,!1,e,!0);
for (var s = 0, l = this.instances; s < l.length; s++) {
var a = l[s];
a.instancedBuffers[i] = null
}
this._invalidateInstanceVertexArrayObject()
}
;
Mesh.prototype._processInstancedBuffers = function(i, e) {
var t = i.length;
for (var r in this.instancedBuffers) {
for (var n = this._userInstancedBuffersStorage.sizes[r], o = this._userInstancedBuffersStorage.strides[r], a = (t + 1) * o; n < a; )
n *= 2;
this._userInstancedBuffersStorage.data[r].length != n && (this._userInstancedBuffersStorage.data[r] = new Float32Array(n),
this._userInstancedBuffersStorage.sizes[r] = n,
this._userInstancedBuffersStorage.vertexBuffers[r] && (this._userInstancedBuffersStorage.vertexBuffers[r].dispose(),
this._userInstancedBuffersStorage.vertexBuffers[r] = null));
var s = this._userInstancedBuffersStorage.data[r]
, l = 0;
if (e) {
var u = this.instancedBuffers[r];
u.toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u,
l += o
}
for (var c = 0; c < t; c++) {
var h = i[c]
, u = h.instancedBuffers[r];
u.toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u,
l += o
}
this._userInstancedBuffersStorage.vertexBuffers[r] ? this._userInstancedBuffersStorage.vertexBuffers[r].updateDirectly(s, 0) : (this._userInstancedBuffersStorage.vertexBuffers[r] = new VertexBuffer(this.getEngine(),this._userInstancedBuffersStorage.data[r],r,!0,!1,o,!0),
this._invalidateInstanceVertexArrayObject())
}
}
;
Mesh.prototype._invalidateInstanceVertexArrayObject = function() {
if (!(!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === void 0)) {
for (var i in this._userInstancedBuffersStorage.vertexArrayObjects)
this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[i]);
this._userInstancedBuffersStorage.vertexArrayObjects = {}
}
}
;
Mesh.prototype._disposeInstanceSpecificData = function() {
for (this._instanceDataStorage.instancesBuffer && (this._instanceDataStorage.instancesBuffer.dispose(),
this._instanceDataStorage.instancesBuffer = null); this.instances.length; )
this.instances[0].dispose();
for (var i in this.instancedBuffers)
this._userInstancedBuffersStorage.vertexBuffers[i] && this._userInstancedBuffersStorage.vertexBuffers[i].dispose();
this._invalidateInstanceVertexArrayObject(),
this.instancedBuffers = {}
}
;
var name$1J = "colorPixelShader"
, shader$1J = `#ifdef VERTEXCOLOR
varying vec4 vColor;
#else
uniform vec4 color;
#endif
#include
void main(void) {
#include
#ifdef VERTEXCOLOR
gl_FragColor=vColor;
#else
gl_FragColor=color;
#endif
}`;
ShaderStore.ShadersStore[name$1J] = shader$1J;
var name$1I = "colorVertexShader"
, shader$1I = `
attribute vec3 position;
#ifdef VERTEXCOLOR
attribute vec4 color;
#endif
#include
#include
#include
#include
uniform mat4 viewProjection;
#ifdef MULTIVIEW
uniform mat4 viewProjectionR;
#endif
#ifdef VERTEXCOLOR
varying vec4 vColor;
#endif
void main(void) {
#include
#include
#include
vec4 worldPos=finalWorld*vec4(position,1.0);
#ifdef MULTIVIEW
if (gl_ViewID_OVR == 0u) {
gl_Position=viewProjection*worldPos;
} else {
gl_Position=viewProjectionR*worldPos;
}
#else
gl_Position=viewProjection*worldPos;
#endif
#include
#ifdef VERTEXCOLOR
vColor=color;
#endif
}`;
ShaderStore.ShadersStore[name$1I] = shader$1I;
Mesh._LinesMeshParser = function(i, e) {
return LinesMesh.Parse(i, e)
}
;
var LinesMesh = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u) {
r === void 0 && (r = null),
n === void 0 && (n = null),
o === void 0 && (o = null);
var c = i.call(this, t, r, n, o, a) || this;
c.useVertexColor = s,
c.useVertexAlpha = l,
c.color = new Color3(1,1,1),
c.alpha = 1,
o && (c.color = o.color.clone(),
c.alpha = o.alpha,
c.useVertexColor = o.useVertexColor,
c.useVertexAlpha = o.useVertexAlpha),
c.intersectionThreshold = .1;
var h = []
, f = {
attributes: [VertexBuffer.PositionKind],
uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "world", "viewProjection"],
needAlphaBlending: !0,
defines: h,
useClipPlane: null
};
return l === !1 && (f.needAlphaBlending = !1),
s ? (f.defines.push("#define VERTEXCOLOR"),
f.attributes.push(VertexBuffer.ColorKind)) : (f.uniforms.push("color"),
c.color4 = new Color4),
u ? c.material = u : c._lineMaterial = new ShaderMaterial("colorShader",c.getScene(),"color",f,!1),
c
}
return e.prototype._isShaderMaterial = function(t) {
return t.getClassName() === "ShaderMaterial"
}
,
e.prototype.isReady = function() {
return this._lineMaterial.isReady(this, !!this._userInstancedBuffersStorage) ? i.prototype.isReady.call(this) : !1
}
,
e.prototype.getClassName = function() {
return "LinesMesh"
}
,
Object.defineProperty(e.prototype, "material", {
get: function() {
return this._lineMaterial
},
set: function(t) {
this._lineMaterial = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "checkCollisions", {
get: function() {
return !1
},
set: function(t) {},
enumerable: !1,
configurable: !0
}),
e.prototype._bind = function(t, r, n) {
if (!this._geometry)
return this;
var o = this._lineMaterial.getEffect()
, a = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
if (this._userInstancedBuffersStorage ? this._geometry._bind(o, a, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects) : this._geometry._bind(o, a),
!this.useVertexColor && this._isShaderMaterial(this._lineMaterial)) {
var s = this.color
, l = s.r
, u = s.g
, c = s.b;
this.color4.set(l, u, c, this.alpha),
this._lineMaterial.setColor4("color", this.color4)
}
return this
}
,
e.prototype._draw = function(t, r, n) {
if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
return this;
var o = this.getScene().getEngine();
return this._unIndexed ? o.drawArraysType(Material.LineListDrawMode, t.verticesStart, t.verticesCount, n) : o.drawElementsType(Material.LineListDrawMode, t.indexStart, t.indexCount, n),
this
}
,
e.prototype.dispose = function(t) {
this._lineMaterial.dispose(!1, !1, !0),
i.prototype.dispose.call(this, t)
}
,
e.prototype.clone = function(t, r, n) {
return r === void 0 && (r = null),
new e(t,this.getScene(),r,this,n)
}
,
e.prototype.createInstance = function(t) {
var r = new InstancedLinesMesh(t,this);
if (this.instancedBuffers) {
r.instancedBuffers = {};
for (var n in this.instancedBuffers)
r.instancedBuffers[n] = this.instancedBuffers[n]
}
return r
}
,
e.prototype.serialize = function(t) {
i.prototype.serialize.call(this, t),
t.color = this.color.asArray(),
t.alpha = this.alpha
}
,
e.Parse = function(t, r) {
var n = new e(t.name,r);
return n.color = Color3.FromArray(t.color),
n.alpha = t.alpha,
n
}
,
e
}(Mesh)
, InstancedLinesMesh = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t, r) || this;
return n.intersectionThreshold = r.intersectionThreshold,
n
}
return e.prototype.getClassName = function() {
return "InstancedLinesMesh"
}
,
e
}(InstancedMesh);
function CreateLineSystemVertexData(i) {
for (var e = [], t = [], r = i.lines, n = i.colors, o = [], a = 0, s = 0; s < r.length; s++)
for (var l = r[s], u = 0; u < l.length; u++) {
if (t.push(l[u].x, l[u].y, l[u].z),
n) {
var c = n[s];
o.push(c[u].r, c[u].g, c[u].b, c[u].a)
}
u > 0 && (e.push(a - 1),
e.push(a)),
a++
}
var h = new VertexData;
return h.indices = e,
h.positions = t,
n && (h.colors = o),
h
}
function CreateDashedLinesVertexData(i) {
var e = i.dashSize || 3
, t = i.gapSize || 1
, r = i.dashNb || 200
, n = i.points
, o = new Array
, a = new Array
, s = Vector3.Zero()
, l = 0
, u = 0
, c = 0
, h = 0
, f = 0
, d = 0
, _ = 0;
for (_ = 0; _ < n.length - 1; _++)
n[_ + 1].subtractToRef(n[_], s),
l += s.length();
for (c = l / r,
h = e * c / (e + t),
_ = 0; _ < n.length - 1; _++) {
n[_ + 1].subtractToRef(n[_], s),
u = Math.floor(s.length() / c),
s.normalize();
for (var g = 0; g < u; g++)
f = c * g,
o.push(n[_].x + f * s.x, n[_].y + f * s.y, n[_].z + f * s.z),
o.push(n[_].x + (f + h) * s.x, n[_].y + (f + h) * s.y, n[_].z + (f + h) * s.z),
a.push(d, d + 1),
d += 2
}
var m = new VertexData;
return m.positions = o,
m.indices = a,
m
}
function CreateLineSystem(i, e, t) {
var r = e.instance
, n = e.lines
, o = e.colors;
if (r) {
var a = r.getVerticesData(VertexBuffer.PositionKind), s, l;
o && (s = r.getVerticesData(VertexBuffer.ColorKind));
for (var u = 0, c = 0, h = 0; h < n.length; h++)
for (var f = n[h], d = 0; d < f.length; d++)
a[u] = f[d].x,
a[u + 1] = f[d].y,
a[u + 2] = f[d].z,
o && s && (l = o[h],
s[c] = l[d].r,
s[c + 1] = l[d].g,
s[c + 2] = l[d].b,
s[c + 3] = l[d].a,
c += 4),
u += 3;
return r.updateVerticesData(VertexBuffer.PositionKind, a, !1, !1),
o && s && r.updateVerticesData(VertexBuffer.ColorKind, s, !1, !1),
r
}
var _ = !!o
, g = new LinesMesh(i,t,null,void 0,void 0,_,e.useVertexAlpha,e.material)
, m = CreateLineSystemVertexData(e);
return m.applyToMesh(g, e.updatable),
g
}
function CreateLines(i, e, t) {
t === void 0 && (t = null);
var r = e.colors ? [e.colors] : null
, n = CreateLineSystem(i, {
lines: [e.points],
updatable: e.updatable,
instance: e.instance,
colors: r,
useVertexAlpha: e.useVertexAlpha,
material: e.material
}, t);
return n
}
function CreateDashedLines(i, e, t) {
t === void 0 && (t = null);
var r = e.points
, n = e.instance
, o = e.gapSize || 1
, a = e.dashSize || 3;
if (n) {
var s = function(c) {
var h = Vector3.Zero()
, f = c.length / 6
, d = 0
, _ = 0
, g = 0
, m = 0
, v = 0
, y = 0
, b = 0
, T = 0;
for (b = 0; b < r.length - 1; b++)
r[b + 1].subtractToRef(r[b], h),
d += h.length();
g = d / f;
var C = n._creationDataStorage.dashSize
, A = n._creationDataStorage.gapSize;
for (m = C * g / (C + A),
b = 0; b < r.length - 1; b++)
for (r[b + 1].subtractToRef(r[b], h),
_ = Math.floor(h.length() / g),
h.normalize(),
T = 0; T < _ && y < c.length; )
v = g * T,
c[y] = r[b].x + v * h.x,
c[y + 1] = r[b].y + v * h.y,
c[y + 2] = r[b].z + v * h.z,
c[y + 3] = r[b].x + (v + m) * h.x,
c[y + 4] = r[b].y + (v + m) * h.y,
c[y + 5] = r[b].z + (v + m) * h.z,
y += 6,
T++;
for (; y < c.length; )
c[y] = r[b].x,
c[y + 1] = r[b].y,
c[y + 2] = r[b].z,
y += 3
};
return n.updateMeshPositions(s, !1),
n
}
var l = new LinesMesh(i,t,null,void 0,void 0,void 0,e.useVertexAlpha,e.material)
, u = CreateDashedLinesVertexData(e);
return u.applyToMesh(l, e.updatable),
l._creationDataStorage = new _CreationDataStorage,
l._creationDataStorage.dashSize = a,
l._creationDataStorage.gapSize = o,
l
}
VertexData.CreateLineSystem = CreateLineSystemVertexData;
VertexData.CreateDashedLines = CreateDashedLinesVertexData;
Mesh.CreateLines = function(i, e, t, r, n) {
t === void 0 && (t = null),
r === void 0 && (r = !1),
n === void 0 && (n = null);
var o = {
points: e,
updatable: r,
instance: n
};
return CreateLines(i, o, t)
}
;
Mesh.CreateDashedLines = function(i, e, t, r, n, o, a, s) {
o === void 0 && (o = null);
var l = {
points: e,
dashSize: t,
gapSize: r,
dashNb: n,
updatable: a,
instance: s
};
return CreateDashedLines(i, l, o)
}
;
var IndexedVector2 = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t.x, t.y) || this;
return n.index = r,
n
}
return e
}(Vector2)
, PolygonPoints = function() {
function i() {
this.elements = new Array
}
return i.prototype.add = function(e) {
var t = this
, r = new Array;
return e.forEach(function(n) {
var o = new IndexedVector2(n,t.elements.length);
r.push(o),
t.elements.push(o)
}),
r
}
,
i.prototype.computeBounds = function() {
var e = new Vector2(this.elements[0].x,this.elements[0].y)
, t = new Vector2(this.elements[0].x,this.elements[0].y);
return this.elements.forEach(function(r) {
r.x < e.x ? e.x = r.x : r.x > t.x && (t.x = r.x),
r.y < e.y ? e.y = r.y : r.y > t.y && (t.y = r.y)
}),
{
min: e,
max: t,
width: t.x - e.x,
height: t.y - e.y
}
}
,
i
}()
, PolygonMeshBuilder = function() {
function i(e, t, r, n) {
n === void 0 && (n = earcut),
this._points = new PolygonPoints,
this._outlinepoints = new PolygonPoints,
this._holes = new Array,
this._epoints = new Array,
this._eholes = new Array,
this.bjsEarcut = n,
this._name = e,
this._scene = r || Engine.LastCreatedScene;
var o;
t instanceof Path2 ? o = t.getPoints() : o = t,
this._addToepoint(o),
this._points.add(o),
this._outlinepoints.add(o),
typeof this.bjsEarcut == "undefined" && Logger$2.Warn("Earcut was not found, the polygon will not be built.")
}
return i.prototype._addToepoint = function(e) {
for (var t = 0, r = e; t < r.length; t++) {
var n = r[t];
this._epoints.push(n.x, n.y)
}
}
,
i.prototype.addHole = function(e) {
this._points.add(e);
var t = new PolygonPoints;
return t.add(e),
this._holes.push(t),
this._eholes.push(this._epoints.length / 2),
this._addToepoint(e),
this
}
,
i.prototype.build = function(e, t, r) {
e === void 0 && (e = !1),
t === void 0 && (t = 0),
r === void 0 && (r = 2);
var n = new Mesh(this._name,this._scene)
, o = this.buildVertexData(t, r);
return n.setVerticesData(VertexBuffer.PositionKind, o.positions, e),
n.setVerticesData(VertexBuffer.NormalKind, o.normals, e),
n.setVerticesData(VertexBuffer.UVKind, o.uvs, e),
n.setIndices(o.indices),
n
}
,
i.prototype.buildVertexData = function(e, t) {
var r = this;
e === void 0 && (e = 0),
t === void 0 && (t = 2);
var n = new VertexData
, o = new Array
, a = new Array
, s = new Array
, l = this._points.computeBounds();
this._points.elements.forEach(function(v) {
o.push(0, 1, 0),
a.push(v.x, 0, v.y),
s.push((v.x - l.min.x) / l.width, (v.y - l.min.y) / l.height)
});
for (var u = new Array, c = this.bjsEarcut(this._epoints, this._eholes, 2), h = 0; h < c.length; h++)
u.push(c[h]);
if (e > 0) {
var f = a.length / 3;
this._points.elements.forEach(function(v) {
o.push(0, -1, 0),
a.push(v.x, -e, v.y),
s.push(1 - (v.x - l.min.x) / l.width, 1 - (v.y - l.min.y) / l.height)
});
for (var d = u.length, h = 0; h < d; h += 3) {
var _ = u[h + 0]
, g = u[h + 1]
, m = u[h + 2];
u.push(m + f),
u.push(g + f),
u.push(_ + f)
}
this.addSide(a, o, s, u, l, this._outlinepoints, e, !1, t),
this._holes.forEach(function(v) {
r.addSide(a, o, s, u, l, v, e, !0, t)
})
}
return n.indices = u,
n.positions = a,
n.normals = o,
n.uvs = s,
n
}
,
i.prototype.addSide = function(e, t, r, n, o, a, s, l, u) {
for (var c = e.length / 3, h = 0, f = 0; f < a.elements.length; f++) {
var d = a.elements[f]
, _ = a.elements[(f + 1) % a.elements.length];
e.push(d.x, 0, d.y),
e.push(d.x, -s, d.y),
e.push(_.x, 0, _.y),
e.push(_.x, -s, _.y);
var g = a.elements[(f + a.elements.length - 1) % a.elements.length]
, m = a.elements[(f + 2) % a.elements.length]
, v = new Vector3(-(_.y - d.y),0,_.x - d.x)
, y = new Vector3(-(d.y - g.y),0,d.x - g.x)
, b = new Vector3(-(m.y - _.y),0,m.x - _.x);
l || (v = v.scale(-1),
y = y.scale(-1),
b = b.scale(-1));
var T = v.normalizeToNew()
, C = y.normalizeToNew()
, A = b.normalizeToNew()
, S = Vector3.Dot(C, T);
S > u ? S < Epsilon - 1 ? C = new Vector3(d.x,0,d.y).subtract(new Vector3(_.x,0,_.y)).normalize() : C = y.add(v).normalize() : C = T;
var P = Vector3.Dot(b, v);
P > u ? P < Epsilon - 1 ? A = new Vector3(_.x,0,_.y).subtract(new Vector3(d.x,0,d.y)).normalize() : A = b.add(v).normalize() : A = T,
r.push(h / o.width, 0),
r.push(h / o.width, 1),
h += v.length(),
r.push(h / o.width, 0),
r.push(h / o.width, 1),
t.push(C.x, C.y, C.z),
t.push(C.x, C.y, C.z),
t.push(A.x, A.y, A.z),
t.push(A.x, A.y, A.z),
l ? (n.push(c),
n.push(c + 2),
n.push(c + 1),
n.push(c + 1),
n.push(c + 2),
n.push(c + 3)) : (n.push(c),
n.push(c + 1),
n.push(c + 2),
n.push(c + 1),
n.push(c + 3),
n.push(c + 2)),
c += 4
}
}
,
i
}();
function CreatePolygonVertexData(i, e, t, r, n, o, a) {
for (var s = t || new Array(3), l = r, u = [], c = a || !1, h = 0; h < 3; h++)
s[h] === void 0 && (s[h] = new Vector4(0,0,1,1)),
l && l[h] === void 0 && (l[h] = new Color4(1,1,1,1));
var f = i.getVerticesData(VertexBuffer.PositionKind)
, d = i.getVerticesData(VertexBuffer.NormalKind)
, _ = i.getVerticesData(VertexBuffer.UVKind)
, g = i.getIndices()
, m = f.length / 9
, v = 0
, y = 0
, b = 0
, T = 0
, C = 0
, A = [0];
if (c)
for (var S = m; S < f.length / 3; S += 4)
y = f[3 * (S + 2)] - f[3 * S],
b = f[3 * (S + 2) + 2] - f[3 * S + 2],
T = Math.sqrt(y * y + b * b),
C += T,
A.push(C);
for (var S = 0, P = 0, R = 0; R < d.length; R += 3)
Math.abs(d[R + 1]) < .001 && (P = 1),
Math.abs(d[R + 1] - 1) < .001 && (P = 0),
Math.abs(d[R + 1] + 1) < .001 && (P = 2),
S = R / 3,
P === 1 ? (v = S - m,
v % 4 < 1.5 ? c ? _[2 * S] = s[P].x + (s[P].z - s[P].x) * A[Math.floor(v / 4)] / C : _[2 * S] = s[P].x : c ? _[2 * S] = s[P].x + (s[P].z - s[P].x) * A[Math.floor(v / 4) + 1] / C : _[2 * S] = s[P].z,
v % 2 === 0 ? _[2 * S + 1] = s[P].w : _[2 * S + 1] = s[P].y) : (_[2 * S] = (1 - _[2 * S]) * s[P].x + _[2 * S] * s[P].z,
_[2 * S + 1] = (1 - _[2 * S + 1]) * s[P].y + _[2 * S + 1] * s[P].w),
l && u.push(l[P].r, l[P].g, l[P].b, l[P].a);
VertexData._ComputeSides(e, f, g, d, _, n, o);
var M = new VertexData;
if (M.indices = g,
M.positions = f,
M.normals = d,
M.uvs = _,
l) {
var x = e === VertexData.DOUBLESIDE ? u.concat(u) : u;
M.colors = x
}
return M
}
function CreatePolygon(i, e, t, r) {
t === void 0 && (t = null),
r === void 0 && (r = earcut),
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation);
for (var n = e.shape, o = e.holes || [], a = e.depth || 0, s = e.smoothingThreshold || 2, l = [], u = [], c = 0; c < n.length; c++)
l[c] = new Vector2(n[c].x,n[c].z);
var h = 1e-8;
l[0].equalsWithEpsilon(l[l.length - 1], h) && l.pop();
for (var f = new PolygonMeshBuilder(i,l,t || EngineStore.LastCreatedScene,r), d = 0; d < o.length; d++) {
u = [];
for (var _ = 0; _ < o[d].length; _++)
u.push(new Vector2(o[d][_].x,o[d][_].z));
f.addHole(u)
}
var g = f.build(e.updatable, a, s);
g._originalBuilderSideOrientation = e.sideOrientation;
var m = CreatePolygonVertexData(g, e.sideOrientation, e.faceUV, e.faceColors, e.frontUVs, e.backUVs, e.wrap);
return m.applyToMesh(g, e.updatable),
g
}
function ExtrudePolygon(i, e, t, r) {
return t === void 0 && (t = null),
r === void 0 && (r = earcut),
CreatePolygon(i, e, t, r)
}
VertexData.CreatePolygon = CreatePolygonVertexData;
Mesh.CreatePolygon = function(i, e, t, r, n, o, a) {
a === void 0 && (a = earcut);
var s = {
shape: e,
holes: r,
updatable: n,
sideOrientation: o
};
return CreatePolygon(i, s, t, a)
}
;
Mesh.ExtrudePolygon = function(i, e, t, r, n, o, a, s) {
s === void 0 && (s = earcut);
var l = {
shape: e,
holes: n,
depth: t,
updatable: o,
sideOrientation: a
};
return ExtrudePolygon(i, l, r, s)
}
;
function ExtrudeShape(i, e, t) {
t === void 0 && (t = null);
var r = e.path
, n = e.shape
, o = e.scale || 1
, a = e.rotation || 0
, s = e.cap === 0 ? 0 : e.cap || Mesh.NO_CAP
, l = e.updatable
, u = Mesh._GetDefaultSideOrientation(e.sideOrientation)
, c = e.instance || null
, h = e.invertUV || !1;
return _ExtrudeShapeGeneric(i, n, r, o, a, null, null, !1, !1, s, !1, t, !!l, u, c, h, e.frontUVs || null, e.backUVs || null)
}
function ExtrudeShapeCustom(i, e, t) {
t === void 0 && (t = null);
var r = e.path
, n = e.shape
, o = e.scaleFunction || function() {
return 1
}
, a = e.rotationFunction || function() {
return 0
}
, s = e.ribbonCloseArray || !1
, l = e.ribbonClosePath || !1
, u = e.cap === 0 ? 0 : e.cap || Mesh.NO_CAP
, c = e.updatable
, h = Mesh._GetDefaultSideOrientation(e.sideOrientation)
, f = e.instance
, d = e.invertUV || !1;
return _ExtrudeShapeGeneric(i, n, r, null, null, o, a, s, l, u, !0, t, !!c, h, f || null, d, e.frontUVs || null, e.backUVs || null)
}
function _ExtrudeShapeGeneric(i, e, t, r, n, o, a, s, l, u, c, h, f, d, _, g, m, v) {
var y = function(P, R, M, x, I, w, O, D, F, V) {
for (var N = M.getTangents(), L = M.getNormals(), k = M.getBinormals(), U = M.getDistances(), z = 0, H = function() {
return I !== null ? I : 1
}, G = function() {
return w !== null ? w : 0
}, W = V && D ? D : G, j = V && O ? O : H, B = F === Mesh.NO_CAP || F === Mesh.CAP_END ? 0 : 2, X = TmpVectors.Matrix[0], $ = 0; $ < R.length; $++) {
for (var Y = new Array, K = W($, U[$]), Z = j($, U[$]), q = 0; q < P.length; q++) {
Matrix.RotationAxisToRef(N[$], z, X);
var J = N[$].scale(P[q].z).add(L[$].scale(P[q].x)).add(k[$].scale(P[q].y))
, Q = Y[q] ? Y[q] : Vector3.Zero();
Vector3.TransformCoordinatesToRef(J, X, Q),
Q.scaleInPlace(Z).addInPlace(R[$]),
Y[q] = Q
}
x[B] = Y,
z += K,
B++
}
var te = function(re) {
var ie = Array(), ee = Vector3.Zero(), ne;
for (ne = 0; ne < re.length; ne++)
ee.addInPlace(re[ne]);
for (ee.scaleInPlace(1 / re.length),
ne = 0; ne < re.length; ne++)
ie.push(ee);
return ie
};
switch (F) {
case Mesh.NO_CAP:
break;
case Mesh.CAP_START:
x[0] = te(x[2]),
x[1] = x[2];
break;
case Mesh.CAP_END:
x[B] = x[B - 1],
x[B + 1] = te(x[B - 1]);
break;
case Mesh.CAP_ALL:
x[0] = te(x[2]),
x[1] = x[2],
x[B] = x[B - 1],
x[B + 1] = te(x[B - 1]);
break
}
return x
}, b, T;
if (_) {
var C = _._creationDataStorage;
return b = C.path3D.update(t),
T = y(e, t, C.path3D, C.pathArray, r, n, o, a, C.cap, c),
_ = CreateRibbon("", {
pathArray: T,
closeArray: !1,
closePath: !1,
offset: 0,
updatable: !1,
sideOrientation: 0,
instance: _
}, h || void 0),
_
}
b = new Path3D(t);
var A = new Array;
u = u < 0 || u > 3 ? 0 : u,
T = y(e, t, b, A, r, n, o, a, u, c);
var S = CreateRibbon(i, {
pathArray: T,
closeArray: s,
closePath: l,
updatable: f,
sideOrientation: d,
invertUV: g,
frontUVs: m || void 0,
backUVs: v || void 0
}, h);
return S._creationDataStorage.pathArray = T,
S._creationDataStorage.path3D = b,
S._creationDataStorage.cap = u,
S
}
Mesh.ExtrudeShape = function(i, e, t, r, n, o, a, s, l, u) {
a === void 0 && (a = null);
var c = {
shape: e,
path: t,
scale: r,
rotation: n,
cap: o === 0 ? 0 : o || Mesh.NO_CAP,
sideOrientation: l,
instance: u,
updatable: s
};
return ExtrudeShape(i, c, a)
}
;
Mesh.ExtrudeShapeCustom = function(i, e, t, r, n, o, a, s, l, u, c, h) {
var f = {
shape: e,
path: t,
scaleFunction: r,
rotationFunction: n,
ribbonCloseArray: o,
ribbonClosePath: a,
cap: s === 0 ? 0 : s || Mesh.NO_CAP,
sideOrientation: c,
instance: h,
updatable: u
};
return ExtrudeShapeCustom(i, f, l)
}
;
function CreateLathe(i, e, t) {
t === void 0 && (t = null);
var r = e.arc ? e.arc <= 0 || e.arc > 1 ? 1 : e.arc : 1, n = e.closed === void 0 ? !0 : e.closed, o = e.shape, a = e.radius || 1, s = e.tessellation || 64, l = e.clip || 0, u = e.updatable, c = Mesh._GetDefaultSideOrientation(e.sideOrientation), h = e.cap || Mesh.NO_CAP, f = Math.PI * 2, d = new Array, _ = e.invertUV || !1, g = 0, m = 0, v = f / s * r, y, b = new Array;
for (g = 0; g <= s - l; g++) {
var b = [];
for ((h == Mesh.CAP_START || h == Mesh.CAP_ALL) && (b.push(new Vector3(0,o[0].y,0)),
b.push(new Vector3(Math.cos(g * v) * o[0].x * a,o[0].y,Math.sin(g * v) * o[0].x * a))),
m = 0; m < o.length; m++)
y = new Vector3(Math.cos(g * v) * o[m].x * a,o[m].y,Math.sin(g * v) * o[m].x * a),
b.push(y);
(h == Mesh.CAP_END || h == Mesh.CAP_ALL) && (b.push(new Vector3(Math.cos(g * v) * o[o.length - 1].x * a,o[o.length - 1].y,Math.sin(g * v) * o[o.length - 1].x * a)),
b.push(new Vector3(0,o[o.length - 1].y,0))),
d.push(b)
}
var T = CreateRibbon(i, {
pathArray: d,
closeArray: n,
sideOrientation: c,
updatable: u,
invertUV: _,
frontUVs: e.frontUVs,
backUVs: e.backUVs
}, t);
return T
}
Mesh.CreateLathe = function(i, e, t, r, n, o, a) {
var s = {
shape: e,
radius: t,
tessellation: r,
sideOrientation: a,
updatable: o
};
return CreateLathe(i, s, n)
}
;
function CreatePlaneVertexData(i) {
var e = []
, t = []
, r = []
, n = []
, o = i.width || i.size || 1
, a = i.height || i.size || 1
, s = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE
, l = o / 2
, u = a / 2;
t.push(-l, -u, 0),
r.push(0, 0, -1),
n.push(0, 0),
t.push(l, -u, 0),
r.push(0, 0, -1),
n.push(1, 0),
t.push(l, u, 0),
r.push(0, 0, -1),
n.push(1, 1),
t.push(-l, u, 0),
r.push(0, 0, -1),
n.push(0, 1),
e.push(0),
e.push(1),
e.push(2),
e.push(0),
e.push(2),
e.push(3),
VertexData._ComputeSides(s, t, e, r, n, i.frontUVs, i.backUVs);
var c = new VertexData;
return c.indices = e,
c.positions = t,
c.normals = r,
c.uvs = n,
c
}
function CreatePlane(i, e, t) {
e === void 0 && (e = {}),
t === void 0 && (t = null);
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreatePlaneVertexData(e);
return n.applyToMesh(r, e.updatable),
e.sourcePlane && (r.translate(e.sourcePlane.normal, -e.sourcePlane.d),
r.setDirection(e.sourcePlane.normal.scale(-1))),
r
}
VertexData.CreatePlane = CreatePlaneVertexData;
Mesh.CreatePlane = function(i, e, t, r, n) {
var o = {
size: e,
width: e,
height: e,
sideOrientation: n,
updatable: r
};
return CreatePlane(i, o, t)
}
;
Mesh._GroundMeshParser = function(i, e) {
return GroundMesh.Parse(i, e)
}
;
var GroundMesh = function(i) {
__extends(e, i);
function e(t, r) {
var n = i.call(this, t, r) || this;
return n.generateOctree = !1,
n
}
return e.prototype.getClassName = function() {
return "GroundMesh"
}
,
Object.defineProperty(e.prototype, "subdivisions", {
get: function() {
return Math.min(this._subdivisionsX, this._subdivisionsY)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "subdivisionsX", {
get: function() {
return this._subdivisionsX
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "subdivisionsY", {
get: function() {
return this._subdivisionsY
},
enumerable: !1,
configurable: !0
}),
e.prototype.optimize = function(t, r) {
r === void 0 && (r = 32),
this._subdivisionsX = t,
this._subdivisionsY = t,
this.subdivide(t);
var n = this;
n.createOrUpdateSubmeshesOctree && n.createOrUpdateSubmeshesOctree(r)
}
,
e.prototype.getHeightAtCoordinates = function(t, r) {
var n = this.getWorldMatrix()
, o = TmpVectors.Matrix[5];
n.invertToRef(o);
var a = TmpVectors.Vector3[8];
if (Vector3.TransformCoordinatesFromFloatsToRef(t, 0, r, o, a),
t = a.x,
r = a.z,
t < this._minX || t > this._maxX || r < this._minZ || r > this._maxZ)
return this.position.y;
(!this._heightQuads || this._heightQuads.length == 0) && (this._initHeightQuads(),
this._computeHeightQuads());
var s = this._getFacetAt(t, r)
, l = -(s.x * t + s.z * r + s.w) / s.y;
return Vector3.TransformCoordinatesFromFloatsToRef(0, l, 0, n, a),
a.y
}
,
e.prototype.getNormalAtCoordinates = function(t, r) {
var n = new Vector3(0,1,0);
return this.getNormalAtCoordinatesToRef(t, r, n),
n
}
,
e.prototype.getNormalAtCoordinatesToRef = function(t, r, n) {
var o = this.getWorldMatrix()
, a = TmpVectors.Matrix[5];
o.invertToRef(a);
var s = TmpVectors.Vector3[8];
if (Vector3.TransformCoordinatesFromFloatsToRef(t, 0, r, a, s),
t = s.x,
r = s.z,
t < this._minX || t > this._maxX || r < this._minZ || r > this._maxZ)
return this;
(!this._heightQuads || this._heightQuads.length == 0) && (this._initHeightQuads(),
this._computeHeightQuads());
var l = this._getFacetAt(t, r);
return Vector3.TransformNormalFromFloatsToRef(l.x, l.y, l.z, o, n),
this
}
,
e.prototype.updateCoordinateHeights = function() {
return (!this._heightQuads || this._heightQuads.length == 0) && this._initHeightQuads(),
this._computeHeightQuads(),
this
}
,
e.prototype._getFacetAt = function(t, r) {
var n = Math.floor((t + this._maxX) * this._subdivisionsX / this._width), o = Math.floor(-(r + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY), a = this._heightQuads[o * this._subdivisionsX + n], s;
return r < a.slope.x * t + a.slope.y ? s = a.facet1 : s = a.facet2,
s
}
,
e.prototype._initHeightQuads = function() {
var t = this._subdivisionsX
, r = this._subdivisionsY;
this._heightQuads = new Array;
for (var n = 0; n < r; n++)
for (var o = 0; o < t; o++) {
var a = {
slope: Vector2.Zero(),
facet1: new Vector4(0,0,0,0),
facet2: new Vector4(0,0,0,0)
};
this._heightQuads[n * t + o] = a
}
return this
}
,
e.prototype._computeHeightQuads = function() {
var t = this.getVerticesData(VertexBuffer.PositionKind);
if (!t)
return this;
for (var r = TmpVectors.Vector3[3], n = TmpVectors.Vector3[2], o = TmpVectors.Vector3[1], a = TmpVectors.Vector3[0], s = TmpVectors.Vector3[4], l = TmpVectors.Vector3[5], u = TmpVectors.Vector3[6], c = TmpVectors.Vector3[7], h = TmpVectors.Vector3[8], f = 0, d = 0, _ = 0, g = 0, m = 0, v = 0, y = 0, b = this._subdivisionsX, T = this._subdivisionsY, C = 0; C < T; C++)
for (var A = 0; A < b; A++) {
f = A * 3,
d = C * (b + 1) * 3,
_ = (C + 1) * (b + 1) * 3,
r.x = t[d + f],
r.y = t[d + f + 1],
r.z = t[d + f + 2],
n.x = t[d + f + 3],
n.y = t[d + f + 4],
n.z = t[d + f + 5],
o.x = t[_ + f],
o.y = t[_ + f + 1],
o.z = t[_ + f + 2],
a.x = t[_ + f + 3],
a.y = t[_ + f + 4],
a.z = t[_ + f + 5],
g = (a.z - r.z) / (a.x - r.x),
m = r.z - g * r.x,
n.subtractToRef(r, s),
o.subtractToRef(r, l),
a.subtractToRef(r, u),
Vector3.CrossToRef(u, l, c),
Vector3.CrossToRef(s, u, h),
c.normalize(),
h.normalize(),
v = -(c.x * r.x + c.y * r.y + c.z * r.z),
y = -(h.x * n.x + h.y * n.y + h.z * n.z);
var S = this._heightQuads[C * b + A];
S.slope.copyFromFloats(g, m),
S.facet1.copyFromFloats(c.x, c.y, c.z, v),
S.facet2.copyFromFloats(h.x, h.y, h.z, y)
}
return this
}
,
e.prototype.serialize = function(t) {
i.prototype.serialize.call(this, t),
t.subdivisionsX = this._subdivisionsX,
t.subdivisionsY = this._subdivisionsY,
t.minX = this._minX,
t.maxX = this._maxX,
t.minZ = this._minZ,
t.maxZ = this._maxZ,
t.width = this._width,
t.height = this._height
}
,
e.Parse = function(t, r) {
var n = new e(t.name,r);
return n._subdivisionsX = t.subdivisionsX || 1,
n._subdivisionsY = t.subdivisionsY || 1,
n._minX = t.minX,
n._maxX = t.maxX,
n._minZ = t.minZ,
n._maxZ = t.maxZ,
n._width = t.width,
n._height = t.height,
n
}
,
e
}(Mesh);
function CreateGroundVertexData(i) {
var e = [], t = [], r = [], n = [], o, a, s = i.width || 1, l = i.height || 1, u = i.subdivisionsX || i.subdivisions || 1, c = i.subdivisionsY || i.subdivisions || 1;
for (o = 0; o <= c; o++)
for (a = 0; a <= u; a++) {
var h = new Vector3(a * s / u - s / 2,0,(c - o) * l / c - l / 2)
, f = new Vector3(0,1,0);
t.push(h.x, h.y, h.z),
r.push(f.x, f.y, f.z),
n.push(a / u, 1 - o / c)
}
for (o = 0; o < c; o++)
for (a = 0; a < u; a++)
e.push(a + 1 + (o + 1) * (u + 1)),
e.push(a + 1 + o * (u + 1)),
e.push(a + o * (u + 1)),
e.push(a + (o + 1) * (u + 1)),
e.push(a + 1 + (o + 1) * (u + 1)),
e.push(a + o * (u + 1));
var d = new VertexData;
return d.indices = e,
d.positions = t,
d.normals = r,
d.uvs = n,
d
}
function CreateTiledGroundVertexData(i) {
var e = i.xmin !== void 0 && i.xmin !== null ? i.xmin : -1, t = i.zmin !== void 0 && i.zmin !== null ? i.zmin : -1, r = i.xmax !== void 0 && i.xmax !== null ? i.xmax : 1, n = i.zmax !== void 0 && i.zmax !== null ? i.zmax : 1, o = i.subdivisions || {
w: 1,
h: 1
}, a = i.precision || {
w: 1,
h: 1
}, s = new Array, l = new Array, u = new Array, c = new Array, h, f, d, _;
o.h = o.h < 1 ? 1 : o.h,
o.w = o.w < 1 ? 1 : o.w,
a.w = a.w < 1 ? 1 : a.w,
a.h = a.h < 1 ? 1 : a.h;
var g = {
w: (r - e) / o.w,
h: (n - t) / o.h
};
function m(y, b, T, C) {
var A = l.length / 3
, S = a.w + 1;
for (h = 0; h < a.h; h++)
for (f = 0; f < a.w; f++) {
var P = [A + f + h * S, A + (f + 1) + h * S, A + (f + 1) + (h + 1) * S, A + f + (h + 1) * S];
s.push(P[1]),
s.push(P[2]),
s.push(P[3]),
s.push(P[0]),
s.push(P[1]),
s.push(P[3])
}
var R = Vector3.Zero()
, M = new Vector3(0,1,0);
for (h = 0; h <= a.h; h++)
for (R.z = h * (C - b) / a.h + b,
f = 0; f <= a.w; f++)
R.x = f * (T - y) / a.w + y,
R.y = 0,
l.push(R.x, R.y, R.z),
u.push(M.x, M.y, M.z),
c.push(f / a.w, h / a.h)
}
for (d = 0; d < o.h; d++)
for (_ = 0; _ < o.w; _++)
m(e + _ * g.w, t + d * g.h, e + (_ + 1) * g.w, t + (d + 1) * g.h);
var v = new VertexData;
return v.indices = s,
v.positions = l,
v.normals = u,
v.uvs = c,
v
}
function CreateGroundFromHeightMapVertexData(i) {
var e = [], t = [], r = [], n = [], o, a, s = i.colorFilter || new Color3(.3,.59,.11), l = i.alphaFilter || 0, u = !1;
if (i.minHeight > i.maxHeight) {
u = !0;
var c = i.maxHeight;
i.maxHeight = i.minHeight,
i.minHeight = c
}
for (o = 0; o <= i.subdivisions; o++)
for (a = 0; a <= i.subdivisions; a++) {
var h = new Vector3(a * i.width / i.subdivisions - i.width / 2,0,(i.subdivisions - o) * i.height / i.subdivisions - i.height / 2)
, f = (h.x + i.width / 2) / i.width * (i.bufferWidth - 1) | 0
, d = (1 - (h.z + i.height / 2) / i.height) * (i.bufferHeight - 1) | 0
, _ = (f + d * i.bufferWidth) * 4
, g = i.buffer[_] / 255
, m = i.buffer[_ + 1] / 255
, v = i.buffer[_ + 2] / 255
, y = i.buffer[_ + 3] / 255;
u && (g = 1 - g,
m = 1 - m,
v = 1 - v);
var b = g * s.r + m * s.g + v * s.b;
y >= l ? h.y = i.minHeight + (i.maxHeight - i.minHeight) * b : h.y = i.minHeight - Epsilon,
t.push(h.x, h.y, h.z),
r.push(0, 0, 0),
n.push(a / i.subdivisions, 1 - o / i.subdivisions)
}
for (o = 0; o < i.subdivisions; o++)
for (a = 0; a < i.subdivisions; a++) {
var T = a + 1 + (o + 1) * (i.subdivisions + 1)
, C = a + 1 + o * (i.subdivisions + 1)
, A = a + o * (i.subdivisions + 1)
, S = a + (o + 1) * (i.subdivisions + 1)
, P = t[T * 3 + 1] >= i.minHeight
, R = t[C * 3 + 1] >= i.minHeight
, M = t[A * 3 + 1] >= i.minHeight;
P && R && M && (e.push(T),
e.push(C),
e.push(A));
var x = t[S * 3 + 1] >= i.minHeight;
x && P && M && (e.push(S),
e.push(T),
e.push(A))
}
VertexData.ComputeNormals(t, e, r);
var I = new VertexData;
return I.indices = e,
I.positions = t,
I.normals = r,
I.uvs = n,
I
}
function CreateGround(i, e, t) {
e === void 0 && (e = {});
var r = new GroundMesh(i,t);
r._setReady(!1),
r._subdivisionsX = e.subdivisionsX || e.subdivisions || 1,
r._subdivisionsY = e.subdivisionsY || e.subdivisions || 1,
r._width = e.width || 1,
r._height = e.height || 1,
r._maxX = r._width / 2,
r._maxZ = r._height / 2,
r._minX = -r._maxX,
r._minZ = -r._maxZ;
var n = CreateGroundVertexData(e);
return n.applyToMesh(r, e.updatable),
r._setReady(!0),
r
}
function CreateTiledGround(i, e, t) {
t === void 0 && (t = null);
var r = new Mesh(i,t)
, n = CreateTiledGroundVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
function CreateGroundFromHeightMap(i, e, t, r) {
t === void 0 && (t = {}),
r === void 0 && (r = null);
var n = t.width || 10
, o = t.height || 10
, a = t.subdivisions || 1
, s = t.minHeight || 0
, l = t.maxHeight || 1
, u = t.colorFilter || new Color3(.3,.59,.11)
, c = t.alphaFilter || 0
, h = t.updatable
, f = t.onReady;
r = r || EngineStore.LastCreatedScene;
var d = new GroundMesh(i,r);
d._subdivisionsX = a,
d._subdivisionsY = a,
d._width = n,
d._height = o,
d._maxX = d._width / 2,
d._maxZ = d._height / 2,
d._minX = -d._maxX,
d._minZ = -d._maxZ,
d._setReady(!1);
var _ = function(g) {
var m = g.width
, v = g.height;
if (!r.isDisposed) {
var y = r == null ? void 0 : r.getEngine().resizeImageBitmap(g, m, v)
, b = CreateGroundFromHeightMapVertexData({
width: n,
height: o,
subdivisions: a,
minHeight: s,
maxHeight: l,
colorFilter: u,
buffer: y,
bufferWidth: m,
bufferHeight: v,
alphaFilter: c
});
b.applyToMesh(d, h),
f && f(d),
d._setReady(!0)
}
};
return Tools.LoadImage(e, _, function() {}, r.offlineProvider),
d
}
VertexData.CreateGround = CreateGroundVertexData;
VertexData.CreateTiledGround = CreateTiledGroundVertexData;
VertexData.CreateGroundFromHeightMap = CreateGroundFromHeightMapVertexData;
Mesh.CreateGround = function(i, e, t, r, n, o) {
var a = {
width: e,
height: t,
subdivisions: r,
updatable: o
};
return CreateGround(i, a, n)
}
;
Mesh.CreateTiledGround = function(i, e, t, r, n, o, a, s, l) {
var u = {
xmin: e,
zmin: t,
xmax: r,
zmax: n,
subdivisions: o,
precision: a,
updatable: l
};
return CreateTiledGround(i, u, s)
}
;
Mesh.CreateGroundFromHeightMap = function(i, e, t, r, n, o, a, s, l, u, c) {
var h = {
width: t,
height: r,
subdivisions: n,
minHeight: o,
maxHeight: a,
updatable: l,
onReady: u,
alphaFilter: c
};
return CreateGroundFromHeightMap(i, e, h, s)
}
;
function CreateTube(i, e, t) {
t === void 0 && (t = null);
var r = e.path
, n = e.instance
, o = 1;
e.radius !== void 0 ? o = e.radius : n && (o = n._creationDataStorage.radius);
var a = e.tessellation || 64
, s = e.radiusFunction || null
, l = e.cap || Mesh.NO_CAP
, u = e.invertUV || !1
, c = e.updatable
, h = Mesh._GetDefaultSideOrientation(e.sideOrientation);
e.arc = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1;
var f = function(b, T, C, A, S, P, R, M) {
for (var x = T.getTangents(), I = T.getNormals(), w = T.getDistances(), O = Math.PI * 2, D = O / S * M, F = function() {
return A
}, V = P || F, N, L, k, U, z = TmpVectors.Matrix[0], H = R === Mesh.NO_CAP || R === Mesh.CAP_END ? 0 : 2, G = 0; G < b.length; G++) {
L = V(G, w[G]),
N = Array(),
k = I[G];
for (var W = 0; W < S; W++)
Matrix.RotationAxisToRef(x[G], D * W, z),
U = N[W] ? N[W] : Vector3.Zero(),
Vector3.TransformCoordinatesToRef(k, z, U),
U.scaleInPlace(L).addInPlace(b[G]),
N[W] = U;
C[H] = N,
H++
}
var j = function(B, X) {
for (var $ = Array(), Y = 0; Y < B; Y++)
$.push(b[X]);
return $
};
switch (R) {
case Mesh.NO_CAP:
break;
case Mesh.CAP_START:
C[0] = j(S, 0),
C[1] = C[2].slice(0);
break;
case Mesh.CAP_END:
C[H] = C[H - 1].slice(0),
C[H + 1] = j(S, b.length - 1);
break;
case Mesh.CAP_ALL:
C[0] = j(S, 0),
C[1] = C[2].slice(0),
C[H] = C[H - 1].slice(0),
C[H + 1] = j(S, b.length - 1);
break
}
return C
}, d, _;
if (n) {
var g = n._creationDataStorage
, m = e.arc || g.arc;
return d = g.path3D.update(r),
_ = f(r, d, g.pathArray, o, g.tessellation, s, g.cap, m),
n = CreateRibbon("", {
pathArray: _,
instance: n
}),
g.path3D = d,
g.pathArray = _,
g.arc = m,
g.radius = o,
n
}
d = new Path3D(r);
var v = new Array;
l = l < 0 || l > 3 ? 0 : l,
_ = f(r, d, v, o, a, s, l, e.arc);
var y = CreateRibbon(i, {
pathArray: _,
closePath: !0,
closeArray: !1,
updatable: c,
sideOrientation: h,
invertUV: u,
frontUVs: e.frontUVs,
backUVs: e.backUVs
}, t);
return y._creationDataStorage.pathArray = _,
y._creationDataStorage.path3D = d,
y._creationDataStorage.tessellation = a,
y._creationDataStorage.cap = l,
y._creationDataStorage.arc = e.arc,
y._creationDataStorage.radius = o,
y
}
Mesh.CreateTube = function(i, e, t, r, n, o, a, s, l, u) {
var c = {
path: e,
radius: t,
tessellation: r,
radiusFunction: n,
arc: 1,
cap: o,
updatable: s,
sideOrientation: l,
instance: u
};
return CreateTube(i, c, a)
}
;
function CreatePolyhedronVertexData(i) {
var e = [];
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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]]
},
e[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 t = i.type && (i.type < 0 || i.type >= e.length) ? 0 : i.type || 0, r = i.size, n = i.sizeX || r || 1, o = i.sizeY || r || 1, a = i.sizeZ || r || 1, s = i.custom || e[t], l = s.face.length, u = i.faceUV || new Array(l), c = i.faceColors, h = i.flat === void 0 ? !0 : i.flat, f = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE, d = new Array, _ = new Array, g = new Array, m = new Array, v = new Array, y = 0, b = 0, T = new Array, C = 0, A = 0, S, P, R, M, x, I;
if (h)
for (A = 0; A < l; A++)
c && c[A] === void 0 && (c[A] = new Color4(1,1,1,1)),
u && u[A] === void 0 && (u[A] = new Vector4(0,0,1,1));
if (h)
for (A = 0; A < l; A++) {
var w = s.face[A].length;
for (R = 2 * Math.PI / w,
M = .5 * Math.tan(R / 2),
x = .5,
C = 0; C < w; C++)
d.push(s.vertex[s.face[A][C]][0] * n, s.vertex[s.face[A][C]][1] * o, s.vertex[s.face[A][C]][2] * a),
T.push(y),
y++,
S = u[A].x + (u[A].z - u[A].x) * (.5 + M),
P = u[A].y + (u[A].w - u[A].y) * (x - .5),
m.push(S, P),
I = M * Math.cos(R) - x * Math.sin(R),
x = M * Math.sin(R) + x * Math.cos(R),
M = I,
c && v.push(c[A].r, c[A].g, c[A].b, c[A].a);
for (C = 0; C < w - 2; C++)
_.push(T[0 + b], T[C + 2 + b], T[C + 1 + b]);
b += w
}
else {
for (C = 0; C < s.vertex.length; C++)
d.push(s.vertex[C][0] * n, s.vertex[C][1] * o, s.vertex[C][2] * a),
m.push(0, 0);
for (A = 0; A < l; A++)
for (C = 0; C < s.face[A].length - 2; C++)
_.push(s.face[A][0], s.face[A][C + 2], s.face[A][C + 1])
}
VertexData.ComputeNormals(d, _, g),
VertexData._ComputeSides(f, d, _, g, m, i.frontUVs, i.backUVs);
var O = new VertexData;
return O.positions = d,
O.indices = _,
O.normals = g,
O.uvs = m,
c && h && (O.colors = v),
O
}
function CreatePolyhedron(i, e, t) {
e === void 0 && (e = {}),
t === void 0 && (t = null);
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreatePolyhedronVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreatePolyhedron = CreatePolyhedronVertexData;
Mesh.CreatePolyhedron = function(i, e, t) {
return CreatePolyhedron(i, e, t)
}
;
function CreateIcoSphereVertexData(i) {
var e = i.sideOrientation || VertexData.DEFAULTSIDE, t = i.radius || 1, r = i.flat === void 0 ? !0 : i.flat, n = i.subdivisions || 4, o = i.radiusX || t, a = i.radiusY || t, s = i.radiusZ || t, l = (1 + Math.sqrt(5)) / 2, u = [-1, l, -0, 1, l, 0, -1, -l, 0, 1, -l, 0, 0, -1, -l, 0, 1, -l, 0, -1, l, 0, 1, l, l, 0, 1, l, 0, -1, -l, 0, 1, -l, 0, -1], c = [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23, 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8, 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9, 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1], h = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 2, 3, 3, 3, 4, 7, 8, 9, 9, 10, 11], f = [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], d = 138 / 1024, _ = 239 / 1024, g = 60 / 1024, m = 26 / 1024, v = -40 / 1024, y = 20 / 1024, b = [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0], T = new Array, C = new Array, A = new Array, S = new Array, P = 0, R = new Array(3), M = new Array(3), x;
for (x = 0; x < 3; x++)
R[x] = Vector3.Zero(),
M[x] = Vector2.Zero();
for (var I = 0; I < 20; I++) {
for (x = 0; x < 3; x++) {
var w = c[3 * I + x];
R[x].copyFromFloats(u[3 * h[w]], u[3 * h[w] + 1], u[3 * h[w] + 2]),
R[x].normalize().scaleInPlace(t),
M[x].copyFromFloats(f[2 * w] * d + g + b[I] * v, f[2 * w + 1] * _ + m + b[I] * y)
}
for (var O = function(N, L, k, U) {
var z = Vector3.Lerp(R[0], R[2], L / n)
, H = Vector3.Lerp(R[1], R[2], L / n)
, G = n === L ? R[2] : Vector3.Lerp(z, H, N / (n - L));
G.normalize();
var W;
if (r) {
var j = Vector3.Lerp(R[0], R[2], U / n)
, B = Vector3.Lerp(R[1], R[2], U / n);
W = Vector3.Lerp(j, B, k / (n - U))
} else
W = new Vector3(G.x,G.y,G.z);
W.x /= o,
W.y /= a,
W.z /= s,
W.normalize();
var X = Vector2.Lerp(M[0], M[2], L / n)
, $ = Vector2.Lerp(M[1], M[2], L / n)
, Y = n === L ? M[2] : Vector2.Lerp(X, $, N / (n - L));
C.push(G.x * o, G.y * a, G.z * s),
A.push(W.x, W.y, W.z),
S.push(Y.x, Y.y),
T.push(P),
P++
}, D = 0; D < n; D++)
for (var F = 0; F + D < n; F++)
O(F, D, F + 1 / 3, D + 1 / 3),
O(F + 1, D, F + 1 / 3, D + 1 / 3),
O(F, D + 1, F + 1 / 3, D + 1 / 3),
F + D + 1 < n && (O(F + 1, D, F + 2 / 3, D + 2 / 3),
O(F + 1, D + 1, F + 2 / 3, D + 2 / 3),
O(F, D + 1, F + 2 / 3, D + 2 / 3))
}
VertexData._ComputeSides(e, C, T, A, S, i.frontUVs, i.backUVs);
var V = new VertexData;
return V.indices = T,
V.positions = C,
V.normals = A,
V.uvs = S,
V
}
function CreateIcoSphere(i, e, t) {
e === void 0 && (e = {}),
t === void 0 && (t = null);
var r = new Mesh(i,t);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
r._originalBuilderSideOrientation = e.sideOrientation;
var n = CreateIcoSphereVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
VertexData.CreateIcoSphere = CreateIcoSphereVertexData;
Mesh.CreateIcoSphere = function(i, e, t) {
return CreateIcoSphere(i, e, t)
}
;
var PositionNormalTextureVertex = function() {
function i(e, t, r) {
e === void 0 && (e = Vector3.Zero()),
t === void 0 && (t = Vector3.Up()),
r === void 0 && (r = Vector2.Zero()),
this.position = e,
this.normal = t,
this.uv = r
}
return i.prototype.clone = function() {
return new i(this.position.clone(),this.normal.clone(),this.uv.clone())
}
,
i
}();
function CreateDecal(i, e, t) {
var r = e.getIndices()
, n = e.getVerticesData(VertexBuffer.PositionKind)
, o = e.getVerticesData(VertexBuffer.NormalKind)
, a = e.getVerticesData(VertexBuffer.UVKind)
, s = t.position || Vector3.Zero()
, l = t.normal || Vector3.Up()
, u = t.size || Vector3.One()
, c = t.angle || 0;
if (!l) {
var h = new Vector3(0,0,1)
, f = e.getScene().activeCamera
, d = Vector3.TransformCoordinates(h, f.getWorldMatrix());
l = f.globalPosition.subtract(d)
}
var _ = -Math.atan2(l.z, l.x) - Math.PI / 2
, g = Math.sqrt(l.x * l.x + l.z * l.z)
, m = Math.atan2(l.y, g)
, v = Matrix.RotationYawPitchRoll(_, m, c).multiply(Matrix.Translation(s.x, s.y, s.z))
, y = Matrix.Invert(v)
, b = e.getWorldMatrix()
, T = b.multiply(y)
, C = new VertexData;
C.indices = [],
C.positions = [],
C.normals = [],
C.uvs = [];
for (var A = 0, S = function(O) {
var D = new PositionNormalTextureVertex;
if (!r || !n || !o)
return D;
var F = r[O];
return D.position = new Vector3(n[F * 3],n[F * 3 + 1],n[F * 3 + 2]),
D.position = Vector3.TransformCoordinates(D.position, T),
D.normal = new Vector3(o[F * 3],o[F * 3 + 1],o[F * 3 + 2]),
D.normal = Vector3.TransformNormal(D.normal, T),
t.captureUVS && a && (D.uv = new Vector2(a[F * 2],a[F * 2 + 1])),
D
}, P = function(O, D) {
if (O.length === 0)
return O;
for (var F = .5 * Math.abs(Vector3.Dot(u, D)), V = function(K, Z) {
var q = Vector3.GetClipFactor(K.position, Z.position, D, F);
return new PositionNormalTextureVertex(Vector3.Lerp(K.position, Z.position, q),Vector3.Lerp(K.normal, Z.normal, q))
}, N = new Array, L = 0; L < O.length; L += 3) {
var k, U, z, H = 0, G = null, W = null, j = null, B = null, X = Vector3.Dot(O[L].position, D) - F, $ = Vector3.Dot(O[L + 1].position, D) - F, Y = Vector3.Dot(O[L + 2].position, D) - F;
switch (k = X > 0,
U = $ > 0,
z = Y > 0,
H = (k ? 1 : 0) + (U ? 1 : 0) + (z ? 1 : 0),
H) {
case 0:
N.push(O[L]),
N.push(O[L + 1]),
N.push(O[L + 2]);
break;
case 1:
if (k && (G = O[L + 1],
W = O[L + 2],
j = V(O[L], G),
B = V(O[L], W)),
U) {
G = O[L],
W = O[L + 2],
j = V(O[L + 1], G),
B = V(O[L + 1], W),
N.push(j),
N.push(W.clone()),
N.push(G.clone()),
N.push(W.clone()),
N.push(j.clone()),
N.push(B);
break
}
z && (G = O[L],
W = O[L + 1],
j = V(O[L + 2], G),
B = V(O[L + 2], W)),
G && W && j && B && (N.push(G.clone()),
N.push(W.clone()),
N.push(j),
N.push(B),
N.push(j.clone()),
N.push(W.clone()));
break;
case 2:
k || (G = O[L].clone(),
W = V(G, O[L + 1]),
j = V(G, O[L + 2]),
N.push(G),
N.push(W),
N.push(j)),
U || (G = O[L + 1].clone(),
W = V(G, O[L + 2]),
j = V(G, O[L]),
N.push(G),
N.push(W),
N.push(j)),
z || (G = O[L + 2].clone(),
W = V(G, O[L]),
j = V(G, O[L + 1]),
N.push(G),
N.push(W),
N.push(j));
break
}
}
return N
}, R = 0; R < r.length; R += 3) {
var M = new Array;
if (M.push(S(R)),
M.push(S(R + 1)),
M.push(S(R + 2)),
M = P(M, new Vector3(1,0,0)),
M = P(M, new Vector3(-1,0,0)),
M = P(M, new Vector3(0,1,0)),
M = P(M, new Vector3(0,-1,0)),
M = P(M, new Vector3(0,0,1)),
M = P(M, new Vector3(0,0,-1)),
M.length !== 0)
for (var x = 0; x < M.length; x++) {
var I = M[x];
C.indices.push(A),
I.position.toArray(C.positions, A * 3),
I.normal.toArray(C.normals, A * 3),
t.captureUVS ? I.uv.toArray(C.uvs, A * 2) : (C.uvs.push(.5 + I.position.x / u.x),
C.uvs.push(.5 + I.position.y / u.y)),
A++
}
}
var w = new Mesh(i,e.getScene());
return C.applyToMesh(w),
w.position = s.clone(),
w.rotation = new Vector3(m,_,c),
w
}
Mesh.CreateDecal = function(i, e, t, r, n, o) {
var a = {
position: t,
normal: r,
size: n,
angle: o
};
return CreateDecal(i, e, a)
}
;
function CreateCapsuleVertexData(i) {
i === void 0 && (i = {
subdivisions: 2,
tessellation: 16,
height: 1,
radius: .25,
capSubdivisions: 6
});
var e = Math.max(i.subdivisions ? i.subdivisions : 2, 1), t = Math.max(i.tessellation ? i.tessellation : 16, 3), r = Math.max(i.height ? i.height : 1, 0), n = Math.max(i.radius ? i.radius : .25, 0), o = Math.max(i.capSubdivisions ? i.capSubdivisions : 6, 1), a = t, s = e, l = Math.max(i.radiusTop ? i.radiusTop : n, 0), u = Math.max(i.radiusBottom ? i.radiusBottom : n, 0), c = r - (l + u), h = 0, f = 2 * Math.PI, d = Math.max(i.topCapSubdivisions ? i.topCapSubdivisions : o, 1), _ = Math.max(i.bottomCapSubdivisions ? i.bottomCapSubdivisions : o, 1), g = Math.acos((u - l) / r), m = [], v = [], y = [], b = [], T = 0, C = [], A = c * .5, S = Math.PI * .5, P, R, M = Vector3.Zero(), x = Vector3.Zero(), I = Math.cos(g), w = Math.sin(g), O = new Vector2(l * w,A + l * I).subtract(new Vector2(u * w,-A + u * I)).length(), D = l * g + O + u * (S - g), F = 0;
for (R = 0; R <= d; R++) {
var V = []
, N = S - g * (R / d);
F += l * g / d;
var L = Math.cos(N)
, k = Math.sin(N)
, U = L * l;
for (P = 0; P <= a; P++) {
var z = P / a
, H = z * f + h
, G = Math.sin(H)
, W = Math.cos(H);
x.x = U * G,
x.y = A + k * l,
x.z = U * W,
v.push(x.x, x.y, x.z),
M.set(L * G, k, L * W),
y.push(M.x, M.y, M.z),
b.push(z, 1 - F / D),
V.push(T),
T++
}
C.push(V)
}
var j = r - l - u + I * l - I * u
, B = w * (u - l) / j;
for (R = 1; R <= s; R++) {
var V = [];
F += O / s;
var U = w * (R * (u - l) / s + l);
for (P = 0; P <= a; P++) {
var z = P / a
, H = z * f + h
, G = Math.sin(H)
, W = Math.cos(H);
x.x = U * G,
x.y = A + I * l - R * j / s,
x.z = U * W,
v.push(x.x, x.y, x.z),
M.set(G, B, W).normalize(),
y.push(M.x, M.y, M.z),
b.push(z, 1 - F / D),
V.push(T),
T++
}
C.push(V)
}
for (R = 1; R <= _; R++) {
var V = []
, N = S - g - (Math.PI - g) * (R / _);
F += u * g / _;
var L = Math.cos(N)
, k = Math.sin(N)
, U = L * u;
for (P = 0; P <= a; P++) {
var z = P / a
, H = z * f + h
, G = Math.sin(H)
, W = Math.cos(H);
x.x = U * G,
x.y = -A + k * u,
x.z = U * W,
v.push(x.x, x.y, x.z),
M.set(L * G, k, L * W),
y.push(M.x, M.y, M.z),
b.push(z, 1 - F / D),
V.push(T),
T++
}
C.push(V)
}
for (P = 0; P < a; P++)
for (R = 0; R < d + s + _; R++) {
var X = C[R][P]
, $ = C[R + 1][P]
, Y = C[R + 1][P + 1]
, K = C[R][P + 1];
m.push(X),
m.push($),
m.push(K),
m.push($),
m.push(Y),
m.push(K)
}
if (m = m.reverse(),
i.orientation && !i.orientation.equals(Vector3.Up())) {
var Z = new Matrix;
i.orientation.clone().scale(Math.PI * .5).cross(Vector3.Up()).toQuaternion().toRotationMatrix(Z);
for (var q = Vector3.Zero(), J = 0; J < v.length; J += 3)
q.set(v[J], v[J + 1], v[J + 2]),
Vector3.TransformCoordinatesToRef(q.clone(), Z, q),
v[J] = q.x,
v[J + 1] = q.y,
v[J + 2] = q.z
}
var Q = new VertexData;
return Q.positions = v,
Q.normals = y,
Q.uvs = b,
Q.indices = m,
Q
}
function CreateCapsule(i, e, t) {
e === void 0 && (e = {
orientation: Vector3.Up(),
subdivisions: 2,
tessellation: 16,
height: 1,
radius: .25,
capSubdivisions: 6,
updatable: !1
}),
t === void 0 && (t = null);
var r = new Mesh(i,t)
, n = CreateCapsuleVertexData(e);
return n.applyToMesh(r, e.updatable),
r
}
Mesh.CreateCapsule = function(i, e, t) {
return CreateCapsule(i, e, t)
}
;
VertexData.CreateCapsule = CreateCapsuleVertexData;
var _IsoVector = function() {
function i(e, t) {
e === void 0 && (e = 0),
t === void 0 && (t = 0),
this.x = e,
this.y = t,
e !== Math.floor(e) && Logger$2.Warn("x is not an integer, floor(x) used"),
t !== Math.floor(t) && Logger$2.Warn("y is not an integer, floor(y) used")
}
return i.prototype.clone = function() {
return new i(this.x,this.y)
}
,
i.prototype.rotate60About = function(e) {
var t = this.x;
return this.x = e.x + e.y - this.y,
this.y = t + this.y - e.x,
this
}
,
i.prototype.rotateNeg60About = function(e) {
var t = this.x;
return this.x = t + this.y - e.y,
this.y = e.x + e.y - t,
this
}
,
i.prototype.rotate120 = function(e, t) {
e !== Math.floor(e) && Logger$2.Warn("m not an integer only floor(m) used"),
t !== Math.floor(t) && Logger$2.Warn("n not an integer only floor(n) used");
var r = this.x;
return this.x = e - r - this.y,
this.y = t + r,
this
}
,
i.prototype.rotateNeg120 = function(e, t) {
e !== Math.floor(e) && Logger$2.Warn("m is not an integer, floor(m) used"),
t !== Math.floor(t) && Logger$2.Warn("n is not an integer, floor(n) used");
var r = this.x;
return this.x = this.y - t,
this.y = e + t - r - this.y,
this
}
,
i.prototype.toCartesianOrigin = function(e, t) {
var r = Vector3.Zero();
return r.x = e.x + 2 * this.x * t + this.y * t,
r.y = e.y + Math.sqrt(3) * this.y * t,
r
}
,
i.Zero = function() {
return new i(0,0)
}
,
i
}()
, _PrimaryIsoTriangle = function() {
function i() {
this.cartesian = [],
this.vertices = [],
this.max = [],
this.min = [],
this.closestTo = [],
this.innerFacets = [],
this.isoVecsABOB = [],
this.isoVecsOBOA = [],
this.isoVecsBAOA = [],
this.vertexTypes = [],
this.IDATA = new PolyhedronData("icosahedron","Regular",[[0, PHI, -1], [-PHI, 1, 0], [-1, 0, -PHI], [1, 0, -PHI], [PHI, 1, 0], [0, PHI, 1], [-1, 0, PHI], [-PHI, -1, 0], [0, -PHI, -1], [PHI, -1, 0], [1, 0, PHI], [0, -PHI, 1]],[[0, 2, 1], [0, 3, 2], [0, 4, 3], [0, 5, 4], [0, 1, 5], [7, 6, 1], [8, 7, 2], [9, 8, 3], [10, 9, 4], [6, 10, 5], [2, 7, 1], [3, 8, 2], [4, 9, 3], [5, 10, 4], [1, 6, 5], [11, 6, 7], [11, 7, 8], [11, 8, 9], [11, 9, 10], [11, 10, 6]])
}
return i.prototype.setIndices = function() {
var e = 12
, t = {}
, r = this.m
, n = this.n
, o = r
, a = 1
, s = 0;
n !== 0 && (o = Scalar.HCF(r, n)),
a = r / o,
s = n / o;
var l, u, c, h, f, d = _IsoVector.Zero(), _ = new _IsoVector(r,n), g = new _IsoVector(-n,r + n), m = _IsoVector.Zero(), v = _IsoVector.Zero(), y = _IsoVector.Zero(), b = [], T, C, A, S, P = [], R = this.vertByDist;
this.IDATA.edgematch = [[1, "B"], [2, "B"], [3, "B"], [4, "B"], [0, "B"], [10, "O", 14, "A"], [11, "O", 10, "A"], [12, "O", 11, "A"], [13, "O", 12, "A"], [14, "O", 13, "A"], [0, "O"], [1, "O"], [2, "O"], [3, "O"], [4, "O"], [19, "B", 5, "A"], [15, "B", 6, "A"], [16, "B", 7, "A"], [17, "B", 8, "A"], [18, "B", 9, "A"]];
for (var M = 0; M < 20; M++) {
if (b = this.IDATA.face[M],
c = b[2],
h = b[1],
f = b[0],
A = d.x + "|" + d.y,
T = M + "|" + A,
T in t || (t[T] = c,
P[c] = [b[R[A][0]], R[A][1]]),
A = _.x + "|" + _.y,
T = M + "|" + A,
T in t || (t[T] = h,
P[h] = [b[R[A][0]], R[A][1]]),
A = g.x + "|" + g.y,
T = M + "|" + A,
T in t || (t[T] = f,
P[f] = [b[R[A][0]], R[A][1]]),
l = this.IDATA.edgematch[M][0],
u = this.IDATA.edgematch[M][1],
u === "B")
for (var x = 1; x < o; x++)
v.x = r - x * (a + s),
v.y = n + x * a,
y.x = -x * s,
y.y = x * (a + s),
A = v.x + "|" + v.y,
S = y.x + "|" + y.y,
I(M, l, A, S);
if (u === "O")
for (var x = 1; x < o; x++)
y.x = -x * s,
y.y = x * (a + s),
m.x = x * a,
m.y = x * s,
A = y.x + "|" + y.y,
S = m.x + "|" + m.y,
I(M, l, A, S);
if (l = this.IDATA.edgematch[M][2],
u = this.IDATA.edgematch[M][3],
u && u === "A")
for (var x = 1; x < o; x++)
m.x = x * a,
m.y = x * s,
v.x = r - (o - x) * (a + s),
v.y = n + (o - x) * a,
A = m.x + "|" + m.y,
S = v.x + "|" + v.y,
I(M, l, A, S);
for (var x = 0; x < this.vertices.length; x++)
A = this.vertices[x].x + "|" + this.vertices[x].y,
T = M + "|" + A,
T in t || (t[T] = e++,
R[A][0] > 2 ? P[t[T]] = [-R[A][0], R[A][1], t[T]] : P[t[T]] = [b[R[A][0]], R[A][1], t[T]])
}
function I(w, O, D, F) {
T = w + "|" + D,
C = O + "|" + F,
T in t || C in t ? T in t && !(C in t) ? t[C] = t[T] : C in t && !(T in t) && (t[T] = t[C]) : (t[T] = e,
t[C] = e,
e++),
R[D][0] > 2 ? P[t[T]] = [-R[D][0], R[D][1], t[T]] : P[t[T]] = [b[R[D][0]], R[D][1], t[T]]
}
this.closestTo = P,
this.vecToIdx = t
}
,
i.prototype.calcCoeffs = function() {
var e = this.m
, t = this.n
, r = Math.sqrt(3) / 3
, n = e * e + t * t + e * t;
this.coau = (e + t) / n,
this.cobu = -t / n,
this.coav = -r * (e - t) / n,
this.cobv = r * (2 * e + t) / n
}
,
i.prototype.createInnerFacets = function() {
for (var e = this.m, t = this.n, r = 0; r < t + e + 1; r++)
for (var n = this.min[r]; n < this.max[r] + 1; n++)
n < this.max[r] && n < this.max[r + 1] + 1 && this.innerFacets.push(["|" + n + "|" + r, "|" + n + "|" + (r + 1), "|" + (n + 1) + "|" + r]),
r > 0 && n < this.max[r - 1] && n + 1 < this.max[r] + 1 && this.innerFacets.push(["|" + n + "|" + r, "|" + (n + 1) + "|" + r, "|" + (n + 1) + "|" + (r - 1)])
}
,
i.prototype.edgeVecsABOB = function() {
for (var e = this.m, t = this.n, r = new _IsoVector(-t,e + t), n = 1; n < e + t; n++) {
var o = new _IsoVector(this.min[n],n)
, a = new _IsoVector(this.min[n - 1],n - 1)
, s = new _IsoVector(this.min[n + 1],n + 1)
, l = o.clone()
, u = a.clone()
, c = s.clone();
l.rotate60About(r),
u.rotate60About(r),
c.rotate60About(r);
var h = new _IsoVector(this.max[l.y],l.y)
, f = new _IsoVector(this.max[l.y - 1],l.y - 1)
, d = new _IsoVector(this.max[l.y - 1] - 1,l.y - 1);
(l.x !== h.x || l.y !== h.y) && (l.x !== f.x ? (this.vertexTypes.push([1, 0, 0]),
this.isoVecsABOB.push([o, f, d]),
this.vertexTypes.push([1, 0, 0]),
this.isoVecsABOB.push([o, d, h])) : l.y === c.y ? (this.vertexTypes.push([1, 1, 0]),
this.isoVecsABOB.push([o, a, f]),
this.vertexTypes.push([1, 0, 1]),
this.isoVecsABOB.push([o, f, s])) : (this.vertexTypes.push([1, 1, 0]),
this.isoVecsABOB.push([o, a, f]),
this.vertexTypes.push([1, 0, 0]),
this.isoVecsABOB.push([o, f, h])))
}
}
,
i.prototype.mapABOBtoOBOA = function() {
for (var e = new _IsoVector(0,0), t = 0; t < this.isoVecsABOB.length; t++) {
for (var r = [], n = 0; n < 3; n++)
e.x = this.isoVecsABOB[t][n].x,
e.y = this.isoVecsABOB[t][n].y,
this.vertexTypes[t][n] === 0 && e.rotateNeg120(this.m, this.n),
r.push(e.clone());
this.isoVecsOBOA.push(r)
}
}
,
i.prototype.mapABOBtoBAOA = function() {
for (var e = new _IsoVector(0,0), t = 0; t < this.isoVecsABOB.length; t++) {
for (var r = [], n = 0; n < 3; n++)
e.x = this.isoVecsABOB[t][n].x,
e.y = this.isoVecsABOB[t][n].y,
this.vertexTypes[t][n] === 1 && e.rotate120(this.m, this.n),
r.push(e.clone());
this.isoVecsBAOA.push(r)
}
}
,
i.prototype.MapToFace = function(e, t) {
for (var r = this.IDATA.face[e], n = r[2], o = r[1], a = r[0], s = Vector3.FromArray(this.IDATA.vertex[n]), l = Vector3.FromArray(this.IDATA.vertex[o]), u = Vector3.FromArray(this.IDATA.vertex[a]), c = l.subtract(s), h = u.subtract(s), f = c.scale(this.coau).add(h.scale(this.cobu)), d = c.scale(this.coav).add(h.scale(this.cobv)), _ = [], g, m = TmpVectors.Vector3[0], v = 0; v < this.cartesian.length; v++)
m = f.scale(this.cartesian[v].x).add(d.scale(this.cartesian[v].y)).add(s),
_[v] = [m.x, m.y, m.z],
g = e + "|" + this.vertices[v].x + "|" + this.vertices[v].y,
t.vertex[this.vecToIdx[g]] = [m.x, m.y, m.z]
}
,
i.prototype.build = function(e, t) {
var r = new Array
, n = _IsoVector.Zero()
, o = new _IsoVector(e,t)
, a = new _IsoVector(-t,e + t);
r.push(n, o, a);
for (var s = t; s < e + 1; s++)
for (var l = 0; l < e + 1 - s; l++)
r.push(new _IsoVector(l,s));
if (t > 0) {
for (var u = Scalar.HCF(e, t), c = e / u, h = t / u, f = 1; f < u; f++)
r.push(new _IsoVector(f * c,f * h)),
r.push(new _IsoVector(-f * h,f * (c + h))),
r.push(new _IsoVector(e - f * (c + h),t + f * c));
for (var d = e / t, _ = 1; _ < t; _++)
for (var g = 0; g < _ * d; g++)
r.push(new _IsoVector(g,_)),
r.push(new _IsoVector(g,_).rotate120(e, t)),
r.push(new _IsoVector(g,_).rotateNeg120(e, t))
}
r.sort(function(D, F) {
return D.x - F.x
}),
r.sort(function(D, F) {
return D.y - F.y
});
for (var m = new Array(e + t + 1), v = new Array(e + t + 1), f = 0; f < m.length; f++)
m[f] = 1 / 0,
v[f] = -1 / 0;
for (var y = 0, b = 0, T = r.length, f = 0; f < T; f++)
b = r[f].x,
y = r[f].y,
m[y] = Math.min(b, m[y]),
v[y] = Math.max(b, v[y]);
for (var C = function(D, F) {
var V = D.clone();
return F === "A" && V.rotateNeg120(e, t),
F === "B" && V.rotate120(e, t),
V.x < 0 ? V.y : V.x + V.y
}, A = [], S = [], P = [], R = [], M = {}, x = [], I = -1, w = -1, f = 0; f < T; f++)
A[f] = r[f].toCartesianOrigin(new _IsoVector(0,0), .5),
S[f] = C(r[f], "O"),
P[f] = C(r[f], "A"),
R[f] = C(r[f], "B"),
S[f] === P[f] && P[f] === R[f] ? (I = 3,
w = S[f]) : S[f] === P[f] ? (I = 4,
w = S[f]) : P[f] === R[f] ? (I = 5,
w = P[f]) : R[f] === S[f] && (I = 6,
w = S[f]),
S[f] < P[f] && S[f] < R[f] && (I = 2,
w = S[f]),
P[f] < S[f] && P[f] < R[f] && (I = 1,
w = P[f]),
R[f] < P[f] && R[f] < S[f] && (I = 0,
w = R[f]),
x.push([I, w, r[f].x, r[f].y]);
x.sort(function(D, F) {
return D[2] - F[2]
}),
x.sort(function(D, F) {
return D[3] - F[3]
}),
x.sort(function(D, F) {
return D[1] - F[1]
}),
x.sort(function(D, F) {
return D[0] - F[0]
});
for (var O = 0; O < x.length; O++)
M[x[O][2] + "|" + x[O][3]] = [x[O][0], x[O][1], O];
return this.m = e,
this.n = t,
this.vertices = r,
this.vertByDist = M,
this.cartesian = A,
this.min = m,
this.max = v,
this
}
,
i
}()
, PolyhedronData = function() {
function i(e, t, r, n) {
this.name = e,
this.category = t,
this.vertex = r,
this.face = n
}
return i
}()
, GeodesicData = function(i) {
__extends(e, i);
function e() {
return i !== null && i.apply(this, arguments) || this
}
return e.prototype.innerToData = function(t, r) {
for (var n = 0; n < r.innerFacets.length; n++)
this.face.push(r.innerFacets[n].map(function(o) {
return r.vecToIdx[t + o]
}))
}
,
e.prototype.mapABOBtoDATA = function(t, r) {
for (var n = r.IDATA.edgematch[t][0], o = 0; o < r.isoVecsABOB.length; o++) {
for (var a = [], s = 0; s < 3; s++)
r.vertexTypes[o][s] === 0 ? a.push(t + "|" + r.isoVecsABOB[o][s].x + "|" + r.isoVecsABOB[o][s].y) : a.push(n + "|" + r.isoVecsABOB[o][s].x + "|" + r.isoVecsABOB[o][s].y);
this.face.push([r.vecToIdx[a[0]], r.vecToIdx[a[1]], r.vecToIdx[a[2]]])
}
}
,
e.prototype.mapOBOAtoDATA = function(t, r) {
for (var n = r.IDATA.edgematch[t][0], o = 0; o < r.isoVecsOBOA.length; o++) {
for (var a = [], s = 0; s < 3; s++)
r.vertexTypes[o][s] === 1 ? a.push(t + "|" + r.isoVecsOBOA[o][s].x + "|" + r.isoVecsOBOA[o][s].y) : a.push(n + "|" + r.isoVecsOBOA[o][s].x + "|" + r.isoVecsOBOA[o][s].y);
this.face.push([r.vecToIdx[a[0]], r.vecToIdx[a[1]], r.vecToIdx[a[2]]])
}
}
,
e.prototype.mapBAOAtoDATA = function(t, r) {
for (var n = r.IDATA.edgematch[t][2], o = 0; o < r.isoVecsBAOA.length; o++) {
for (var a = [], s = 0; s < 3; s++)
r.vertexTypes[o][s] === 1 ? a.push(t + "|" + r.isoVecsBAOA[o][s].x + "|" + r.isoVecsBAOA[o][s].y) : a.push(n + "|" + r.isoVecsBAOA[o][s].x + "|" + r.isoVecsBAOA[o][s].y);
this.face.push([r.vecToIdx[a[0]], r.vecToIdx[a[1]], r.vecToIdx[a[2]]])
}
}
,
e.prototype.orderData = function(t) {
for (var r = [], n = 0; n < 13; n++)
r[n] = [];
for (var o = t.closestTo, n = 0; n < o.length; n++)
o[n][0] > -1 ? o[n][1] > 0 && r[o[n][0]].push([n, o[n][1]]) : r[12].push([n, o[n][0]]);
for (var a = [], n = 0; n < 12; n++)
a[n] = n;
for (var s = 12, n = 0; n < 12; n++) {
r[n].sort(function(c, h) {
return c[1] - h[1]
});
for (var l = 0; l < r[n].length; l++)
a[r[n][l][0]] = s++
}
for (var l = 0; l < r[12].length; l++)
a[r[12][l][0]] = s++;
for (var n = 0; n < this.vertex.length; n++)
this.vertex[n].push(a[n]);
this.vertex.sort(function(u, c) {
return u[3] - c[3]
});
for (var n = 0; n < this.vertex.length; n++)
this.vertex[n].pop();
for (var n = 0; n < this.face.length; n++)
for (var l = 0; l < this.face[n].length; l++)
this.face[n][l] = a[this.face[n][l]];
this.sharedNodes = r[12].length,
this.poleNodes = this.vertex.length - this.sharedNodes
}
,
e.prototype.setOrder = function(t, r) {
var n = []
, o = []
, a = r.pop();
o.push(a);
var s = this.face[a].indexOf(t);
s = (s + 2) % 3;
var l = this.face[a][s];
n.push(l);
for (var u = 0; r.length > 0; )
a = r[u],
this.face[a].indexOf(l) > -1 ? (s = (this.face[a].indexOf(l) + 1) % 3,
l = this.face[a][s],
n.push(l),
o.push(a),
r.splice(u, 1),
u = 0) : u++;
return this.adjacentFaces.push(n),
o
}
,
e.prototype.toGoldbergData = function() {
var t = this
, r = new PolyhedronData("GeoDual","Goldberg",[],[]);
r.name = "GD dual";
for (var n = this.vertex.length, o = new Array(n), a = 0; a < n; a++)
o[a] = [];
for (var s = 0; s < this.face.length; s++)
for (var l = 0; l < 3; l++)
o[this.face[s][l]].push(s);
var u = 0
, c = 0
, h = 0
, f = []
, d = [];
this.adjacentFaces = [];
for (var _ = 0; _ < o.length; _++)
r.face[_] = this.setOrder(_, o[_].concat([])),
o[_].forEach(function(g) {
u = 0,
c = 0,
h = 0,
f = t.face[g];
for (var m = 0; m < 3; m++)
d = t.vertex[f[m]],
u += d[0],
c += d[1],
h += d[2];
r.vertex[g] = [u / 3, c / 3, h / 3]
});
return r
}
,
e.BuildGeodesicData = function(t) {
var r = new e("Geodesic-m-n","Geodesic",[[0, PHI, -1], [-PHI, 1, 0], [-1, 0, -PHI], [1, 0, -PHI], [PHI, 1, 0], [0, PHI, 1], [-1, 0, PHI], [-PHI, -1, 0], [0, -PHI, -1], [PHI, -1, 0], [1, 0, PHI], [0, -PHI, 1]],[]);
t.setIndices(),
t.calcCoeffs(),
t.createInnerFacets(),
t.edgeVecsABOB(),
t.mapABOBtoOBOA(),
t.mapABOBtoBAOA();
for (var n = 0; n < t.IDATA.face.length; n++)
t.MapToFace(n, r),
r.innerToData(n, t),
t.IDATA.edgematch[n][1] === "B" && r.mapABOBtoDATA(n, t),
t.IDATA.edgematch[n][1] === "O" && r.mapOBOAtoDATA(n, t),
t.IDATA.edgematch[n][3] === "A" && r.mapBAOAtoDATA(n, t);
r.orderData(t);
var o = 1;
return r.vertex = r.vertex.map(function(a) {
var s = a[0]
, l = a[1]
, u = a[2]
, c = Math.sqrt(s * s + l * l + u * u);
return a[0] *= o / c,
a[1] *= o / c,
a[2] *= o / c,
a
}),
r
}
,
e
}(PolyhedronData);
function CreateGeodesic(i, e, t) {
t === void 0 && (t = null);
var r = e.m || 1;
r !== Math.floor(r) && Logger$2.Warn("m not an integer only floor(m) used");
var n = e.n || 0;
if (n !== Math.floor(n) && Logger$2.Warn("n not an integer only floor(n) used"),
n > r) {
var o = n;
n = r,
r = o,
Logger$2.Warn("n > m therefore m and n swapped")
}
var a = new _PrimaryIsoTriangle;
a.build(r, n);
var s = GeodesicData.BuildGeodesicData(a)
, l = {
custom: s,
size: e.size,
sizeX: e.sizeX,
sizeY: e.sizeY,
sizeZ: e.sizeZ,
faceUV: e.faceUV,
faceColors: e.faceColors,
flat: e.flat,
updatable: e.updatable,
sideOrientation: e.sideOrientation,
frontUVs: e.frontUVs,
backUVs: e.backUVs
}
, u = CreatePolyhedron(i, l, t);
return u
}
function CreateGoldbergVertexData(i, e) {
for (var t = i.size, r = i.sizeX || t || 1, n = i.sizeY || t || 1, o = i.sizeZ || t || 1, a = i.sideOrientation === 0 ? 0 : i.sideOrientation || VertexData.DEFAULTSIDE, s = new Array, l = new Array, u = new Array, c = new Array, h = 1 / 0, f = -1 / 0, d = 1 / 0, _ = -1 / 0, g = 0; g < e.vertex.length; g++)
h = Math.min(h, e.vertex[g][0] * r),
f = Math.max(f, e.vertex[g][0] * r),
d = Math.min(d, e.vertex[g][1] * n),
_ = Math.max(_, e.vertex[g][1] * n);
for (var m = 0, v = 0; v < e.face.length; v++) {
for (var y = e.face[v], b = Vector3.FromArray(e.vertex[y[0]]), T = Vector3.FromArray(e.vertex[y[2]]), C = Vector3.FromArray(e.vertex[y[1]]), A = T.subtract(b), S = C.subtract(b), P = Vector3.Cross(S, A).normalize(), g = 0; g < y.length; g++) {
u.push(P.x, P.y, P.z);
var R = e.vertex[y[g]];
s.push(R[0] * r, R[1] * n, R[2] * o),
c.push((R[0] * r - h) / (f - h), (R[1] * n - d) / (_ - d))
}
for (var g = 0; g < y.length - 2; g++)
l.push(m, m + g + 2, m + g + 1);
m += y.length
}
VertexData._ComputeSides(a, s, l, u, c);
var M = new VertexData;
return M.positions = s,
M.indices = l,
M.normals = u,
M.uvs = c,
M
}
function CreateGoldberg(i, e, t) {
var r = e.m || 1;
r !== Math.floor(r) && Logger$2.Warn("m not an integer only floor(m) used");
var n = e.n || 0;
if (n !== Math.floor(n) && Logger$2.Warn("n not an integer only floor(n) used"),
n > r) {
var o = n;
n = r,
r = o,
Logger$2.Warn("n > m therefore m and n swapped")
}
var a = new _PrimaryIsoTriangle;
a.build(r, n);
var s = GeodesicData.BuildGeodesicData(a)
, l = s.toGoldbergData()
, u = new GoldbergMesh(i);
e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
u._originalBuilderSideOrientation = e.sideOrientation;
var c = CreateGoldbergVertexData(e, l);
c.applyToMesh(u, e.updatable),
u.nbSharedFaces = s.sharedNodes,
u.nbUnsharedFaces = s.poleNodes,
u.adjacentFaces = s.adjacentFaces,
u.nbFaces = u.nbSharedFaces + u.nbUnsharedFaces,
u.nbFacesAtPole = (u.nbUnsharedFaces - 12) / 12;
for (var h = 0; h < s.vertex.length; h++)
u.faceCenters.push(Vector3.FromArray(s.vertex[h])),
u.faceColors.push(new Color4(1,1,1,1));
for (var h = 0; h < l.face.length; h++) {
var f = l.face[h]
, d = Vector3.FromArray(l.vertex[f[0]])
, _ = Vector3.FromArray(l.vertex[f[2]])
, g = Vector3.FromArray(l.vertex[f[1]])
, m = _.subtract(d)
, v = g.subtract(d)
, y = Vector3.Cross(v, m).normalize()
, b = Vector3.Cross(v, y).normalize();
u.faceXaxis.push(v.normalize()),
u.faceYaxis.push(y),
u.faceZaxis.push(b)
}
return u.setMetadata(),
u
}
function GoldbergCreate(i) {
return function(e) {
__extends(t, e);
function t() {
var r = e !== null && e.apply(this, arguments) || this;
return r.faceColors = [],
r.faceCenters = [],
r.faceZaxis = [],
r.faceXaxis = [],
r.faceYaxis = [],
r
}
return t.prototype.setMetadata = function() {
this.metadata = {
nbSharedFaces: this.nbSharedFaces,
nbUnsharedFaces: this.nbUnsharedFaces,
nbFacesAtPole: this.nbFacesAtPole,
nbFaces: this.nbFaces,
faceCenters: this.faceCenters,
faceXaxis: this.faceXaxis,
faceYaxis: this.faceYaxis,
faceZaxis: this.faceZaxis,
adjacentFaces: this.adjacentFaces
}
}
,
t.prototype.relFace = function(r, n) {
return n === void 0 ? (r > this.nbUnsharedFaces - 1 && (Logger$2.Warn("Maximum number of unshared faces used"),
r = this.nbUnsharedFaces - 1),
this.nbUnsharedFaces + r) : (r > 11 && (Logger$2.Warn("Last pole used"),
r = 11),
n > this.nbFacesAtPole - 1 && (Logger$2.Warn("Maximum number of faces at a pole used"),
n = this.nbFacesAtPole - 1),
12 + r * this.nbFacesAtPole + n)
}
,
t.prototype.refreshFaceData = function() {
this.nbSharedFaces = this.metadata.nbSharedFaces,
this.nbUnsharedFaces = this.metadata.nbUnsharedFaces,
this.nbFacesAtPole = this.metadata.nbFacesAtPole,
this.adjacentFaces = this.metadata.adjacentFaces,
this.nbFaces = this.metadata.nbFaces,
this.faceCenters = this.metadata.faceCenters,
this.faceXaxis = this.metadata.faceXaxis,
this.faceYaxis = this.metadata.faceYaxis,
this.faceZaxis = this.metadata.faceZaxis
}
,
t.prototype.changeFaceColors = function(r) {
for (var n = 0; n < r.length; n++)
for (var o = r[n][0], a = r[n][1], s = r[n][2], l = o; l < a + 1; l++)
this.faceColors[l] = s;
for (var u = [], l = 0; l < 12; l++)
for (var n = 0; n < 5; n++)
u.push(this.faceColors[l].r, this.faceColors[l].g, this.faceColors[l].b, this.faceColors[l].a);
for (var l = 12; l < this.faceColors.length; l++)
for (var n = 0; n < 6; n++)
u.push(this.faceColors[l].r, this.faceColors[l].g, this.faceColors[l].b, this.faceColors[l].a);
return u
}
,
t.prototype.setFaceColors = function(r) {
var n = this.changeFaceColors(r);
this.setVerticesData(VertexBuffer.ColorKind, n)
}
,
t.prototype.updateFaceColors = function(r) {
var n = this.changeFaceColors(r);
this.updateVerticesData(VertexBuffer.ColorKind, n)
}
,
t.prototype.changeFaceUVs = function(r) {
for (var n = this.getVerticesData(VertexBuffer.UVKind), o = 0; o < r.length; o++) {
for (var a = r[o][0], s = r[o][1], l = r[o][2], u = r[o][3], c = r[o][4], h = [], f = [], d = void 0, _ = void 0, g = 0; g < 5; g++)
d = l.x + u * Math.cos(c + g * Math.PI / 2.5),
_ = l.y + u * Math.sin(c + g * Math.PI / 2.5),
d < 0 && (d = 0),
d > 1 && (d = 1),
h.push(d, _);
for (var g = 0; g < 6; g++)
d = l.x + u * Math.cos(c + g * Math.PI / 3),
_ = l.y + u * Math.sin(c + g * Math.PI / 3),
d < 0 && (d = 0),
d > 1 && (d = 1),
f.push(d, _);
for (var m = a; m < Math.min(12, s + 1); m++)
for (var g = 0; g < 5; g++)
n[10 * m + 2 * g] = h[2 * g],
n[10 * m + 2 * g + 1] = h[2 * g + 1];
for (var m = Math.max(12, a); m < s + 1; m++)
for (var g = 0; g < 6; g++)
n[12 * m - 24 + 2 * g] = f[2 * g],
n[12 * m - 23 + 2 * g] = f[2 * g + 1]
}
return n
}
,
t.prototype.setFaceUVs = function(r) {
var n = this.changeFaceUVs(r);
this.setVerticesData(VertexBuffer.UVKind, n)
}
,
t.prototype.updateFaceUVs = function(r) {
var n = this.changeFaceUVs(r);
this.updateVerticesData(VertexBuffer.UVKind, n)
}
,
t.prototype.placeOnFaceAt = function(r, n, o) {
var a = Vector3.RotationFromAxis(this.faceXaxis[n], this.faceYaxis[n], this.faceZaxis[n]);
r.rotation = a,
r.position = this.faceCenters[n].add(this.faceXaxis[n].scale(o.x)).add(this.faceYaxis[n].scale(o.y)).add(this.faceZaxis[n].scale(o.z))
}
,
t
}(i)
}
var GoldbergMesh = GoldbergCreate(Mesh)
, MeshBuilder = {
CreateBox,
CreateTiledBox,
CreateSphere,
CreateDisc,
CreateIcoSphere,
CreateRibbon,
CreateCylinder,
CreateTorus,
CreateTorusKnot,
CreateLineSystem,
CreateLines,
CreateDashedLines,
ExtrudeShape,
ExtrudeShapeCustom,
CreateLathe,
CreateTiledPlane,
CreatePlane,
CreateGround,
CreateTiledGround,
CreateGroundFromHeightMap,
CreatePolygon,
ExtrudePolygon,
CreateTube,
CreatePolyhedron,
CreateGeodesic,
CreateGoldberg,
CreateDecal,
CreateCapsule
}
, Ray = function() {
function i(e, t, r) {
r === void 0 && (r = Number.MAX_VALUE),
this.origin = e,
this.direction = t,
this.length = r
}
return i.prototype.clone = function() {
return new i(this.origin.clone(),this.direction.clone(),this.length)
}
,
i.prototype.intersectsBoxMinMax = function(e, t, r) {
r === void 0 && (r = 0);
var n = i._TmpVector3[0].copyFromFloats(e.x - r, e.y - r, e.z - r), o = i._TmpVector3[1].copyFromFloats(t.x + r, t.y + r, t.z + r), a = 0, s = Number.MAX_VALUE, l, u, c, h;
if (Math.abs(this.direction.x) < 1e-7) {
if (this.origin.x < n.x || this.origin.x > o.x)
return !1
} else if (l = 1 / this.direction.x,
u = (n.x - this.origin.x) * l,
c = (o.x - this.origin.x) * l,
c === -1 / 0 && (c = 1 / 0),
u > c && (h = u,
u = c,
c = h),
a = Math.max(u, a),
s = Math.min(c, s),
a > s)
return !1;
if (Math.abs(this.direction.y) < 1e-7) {
if (this.origin.y < n.y || this.origin.y > o.y)
return !1
} else if (l = 1 / this.direction.y,
u = (n.y - this.origin.y) * l,
c = (o.y - this.origin.y) * l,
c === -1 / 0 && (c = 1 / 0),
u > c && (h = u,
u = c,
c = h),
a = Math.max(u, a),
s = Math.min(c, s),
a > s)
return !1;
if (Math.abs(this.direction.z) < 1e-7) {
if (this.origin.z < n.z || this.origin.z > o.z)
return !1
} else if (l = 1 / this.direction.z,
u = (n.z - this.origin.z) * l,
c = (o.z - this.origin.z) * l,
c === -1 / 0 && (c = 1 / 0),
u > c && (h = u,
u = c,
c = h),
a = Math.max(u, a),
s = Math.min(c, s),
a > s)
return !1;
return !0
}
,
i.prototype.intersectsBox = function(e, t) {
return t === void 0 && (t = 0),
this.intersectsBoxMinMax(e.minimum, e.maximum, t)
}
,
i.prototype.intersectsSphere = function(e, t) {
t === void 0 && (t = 0);
var r = e.center.x - this.origin.x
, n = e.center.y - this.origin.y
, o = e.center.z - this.origin.z
, a = r * r + n * n + o * o
, s = e.radius + t
, l = s * s;
if (a <= l)
return !0;
var u = r * this.direction.x + n * this.direction.y + o * this.direction.z;
if (u < 0)
return !1;
var c = a - u * u;
return c <= l
}
,
i.prototype.intersectsTriangle = function(e, t, r) {
var n = i._TmpVector3[0]
, o = i._TmpVector3[1]
, a = i._TmpVector3[2]
, s = i._TmpVector3[3]
, l = i._TmpVector3[4];
t.subtractToRef(e, n),
r.subtractToRef(e, o),
Vector3.CrossToRef(this.direction, o, a);
var u = Vector3.Dot(n, a);
if (u === 0)
return null;
var c = 1 / u;
this.origin.subtractToRef(e, s);
var h = Vector3.Dot(s, a) * c;
if (h < 0 || h > 1)
return null;
Vector3.CrossToRef(s, n, l);
var f = Vector3.Dot(this.direction, l) * c;
if (f < 0 || h + f > 1)
return null;
var d = Vector3.Dot(o, l) * c;
return d > this.length ? null : new IntersectionInfo(1 - h - f,h,d)
}
,
i.prototype.intersectsPlane = function(e) {
var t, r = Vector3.Dot(e.normal, this.direction);
if (Math.abs(r) < 999999997475243e-21)
return null;
var n = Vector3.Dot(e.normal, this.origin);
return t = (-e.d - n) / r,
t < 0 ? t < -999999997475243e-21 ? null : 0 : t
}
,
i.prototype.intersectsAxis = function(e, t) {
switch (t === void 0 && (t = 0),
e) {
case "y":
var r = (this.origin.y - t) / this.direction.y;
return r > 0 ? null : new Vector3(this.origin.x + this.direction.x * -r,t,this.origin.z + this.direction.z * -r);
case "x":
var r = (this.origin.x - t) / this.direction.x;
return r > 0 ? null : new Vector3(t,this.origin.y + this.direction.y * -r,this.origin.z + this.direction.z * -r);
case "z":
var r = (this.origin.z - t) / this.direction.z;
return r > 0 ? null : new Vector3(this.origin.x + this.direction.x * -r,this.origin.y + this.direction.y * -r,t);
default:
return null
}
}
,
i.prototype.intersectsMesh = function(e, t) {
var r = TmpVectors.Matrix[0];
return e.getWorldMatrix().invertToRef(r),
this._tmpRay ? i.TransformToRef(this, r, this._tmpRay) : this._tmpRay = i.Transform(this, r),
e.intersects(this._tmpRay, t)
}
,
i.prototype.intersectsMeshes = function(e, t, r) {
r ? r.length = 0 : r = [];
for (var n = 0; n < e.length; n++) {
var o = this.intersectsMesh(e[n], t);
o.hit && r.push(o)
}
return r.sort(this._comparePickingInfo),
r
}
,
i.prototype._comparePickingInfo = function(e, t) {
return e.distance < t.distance ? -1 : e.distance > t.distance ? 1 : 0
}
,
i.prototype.intersectionSegment = function(e, t, r) {
var n = this.origin
, o = TmpVectors.Vector3[0]
, a = TmpVectors.Vector3[1]
, s = TmpVectors.Vector3[2]
, l = TmpVectors.Vector3[3];
t.subtractToRef(e, o),
this.direction.scaleToRef(i.rayl, s),
n.addToRef(s, a),
e.subtractToRef(n, l);
var u = Vector3.Dot(o, o), c = Vector3.Dot(o, s), h = Vector3.Dot(s, s), f = Vector3.Dot(o, l), d = Vector3.Dot(s, l), _ = u * h - c * c, g, m, v = _, y, b, T = _;
_ < i.smallnum ? (m = 0,
v = 1,
b = d,
T = h) : (m = c * d - h * f,
b = u * d - c * f,
m < 0 ? (m = 0,
b = d,
T = h) : m > v && (m = v,
b = d + c,
T = h)),
b < 0 ? (b = 0,
-f < 0 ? m = 0 : -f > u ? m = v : (m = -f,
v = u)) : b > T && (b = T,
-f + c < 0 ? m = 0 : -f + c > u ? m = v : (m = -f + c,
v = u)),
g = Math.abs(m) < i.smallnum ? 0 : m / v,
y = Math.abs(b) < i.smallnum ? 0 : b / T;
var C = TmpVectors.Vector3[4];
s.scaleToRef(y, C);
var A = TmpVectors.Vector3[5];
o.scaleToRef(g, A),
A.addInPlace(l);
var S = TmpVectors.Vector3[6];
A.subtractToRef(C, S);
var P = y > 0 && y <= this.length && S.lengthSquared() < r * r;
return P ? A.length() : -1
}
,
i.prototype.update = function(e, t, r, n, o, a, s) {
return this.unprojectRayToRef(e, t, r, n, o, a, s),
this
}
,
i.Zero = function() {
return new i(Vector3.Zero(),Vector3.Zero())
}
,
i.CreateNew = function(e, t, r, n, o, a, s) {
var l = i.Zero();
return l.update(e, t, r, n, o, a, s)
}
,
i.CreateNewFromTo = function(e, t, r) {
r === void 0 && (r = Matrix.IdentityReadOnly);
var n = t.subtract(e)
, o = Math.sqrt(n.x * n.x + n.y * n.y + n.z * n.z);
return n.normalize(),
i.Transform(new i(e,n,o), r)
}
,
i.Transform = function(e, t) {
var r = new i(new Vector3(0,0,0),new Vector3(0,0,0));
return i.TransformToRef(e, t, r),
r
}
,
i.TransformToRef = function(e, t, r) {
Vector3.TransformCoordinatesToRef(e.origin, t, r.origin),
Vector3.TransformNormalToRef(e.direction, t, r.direction),
r.length = e.length;
var n = r.direction
, o = n.length();
if (!(o === 0 || o === 1)) {
var a = 1 / o;
n.x *= a,
n.y *= a,
n.z *= a,
r.length *= o
}
}
,
i.prototype.unprojectRayToRef = function(e, t, r, n, o, a, s) {
var l = TmpVectors.Matrix[0];
o.multiplyToRef(a, l),
l.multiplyToRef(s, l),
l.invert();
var u = TmpVectors.Vector3[0];
u.x = e / r * 2 - 1,
u.y = -(t / n * 2 - 1),
u.z = -1;
var c = TmpVectors.Vector3[1].copyFromFloats(u.x, u.y, 1)
, h = TmpVectors.Vector3[2]
, f = TmpVectors.Vector3[3];
Vector3._UnprojectFromInvertedMatrixToRef(u, l, h),
Vector3._UnprojectFromInvertedMatrixToRef(c, l, f),
this.origin.copyFrom(h),
f.subtractToRef(h, this.direction),
this.direction.normalize()
}
,
i._TmpVector3 = ArrayTools.BuildArray(6, Vector3.Zero),
i.smallnum = 1e-8,
i.rayl = 1e9,
i
}();
Scene.prototype.createPickingRay = function(i, e, t, r, n) {
n === void 0 && (n = !1);
var o = Ray.Zero();
return this.createPickingRayToRef(i, e, t, o, r, n),
o
}
;
Scene.prototype.createPickingRayToRef = function(i, e, t, r, n, o) {
o === void 0 && (o = !1);
var a = this.getEngine();
if (!n) {
if (!this.activeCamera)
return this;
n = this.activeCamera
}
var s = n.viewport
, l = s.toGlobal(a.getRenderWidth(), a.getRenderHeight());
return i = i / a.getHardwareScalingLevel() - l.x,
e = e / a.getHardwareScalingLevel() - (a.getRenderHeight() - l.y - l.height),
r.update(i, e, l.width, l.height, t || Matrix.IdentityReadOnly, o ? Matrix.IdentityReadOnly : n.getViewMatrix(), n.getProjectionMatrix()),
this
}
;
Scene.prototype.createPickingRayInCameraSpace = function(i, e, t) {
var r = Ray.Zero();
return this.createPickingRayInCameraSpaceToRef(i, e, r, t),
r
}
;
Scene.prototype.createPickingRayInCameraSpaceToRef = function(i, e, t, r) {
if (!PickingInfo)
return this;
var n = this.getEngine();
if (!r) {
if (!this.activeCamera)
throw new Error("Active camera not set");
r = this.activeCamera
}
var o = r.viewport
, a = o.toGlobal(n.getRenderWidth(), n.getRenderHeight())
, s = Matrix.Identity();
return i = i / n.getHardwareScalingLevel() - a.x,
e = e / n.getHardwareScalingLevel() - (n.getRenderHeight() - a.y - a.height),
t.update(i, e, a.width, a.height, s, s, r.getProjectionMatrix()),
this
}
;
Scene.prototype._internalPickForMesh = function(i, e, t, r, n, o, a, s) {
var l = e(r)
, u = t.intersects(l, n, a, o, r, s);
return !u || !u.hit || !n && i != null && u.distance >= i.distance ? null : u
}
;
Scene.prototype._internalPick = function(i, e, t, r, n) {
if (!PickingInfo)
return null;
for (var o = null, a = 0; a < this.meshes.length; a++) {
var s = this.meshes[a];
if (e) {
if (!e(s))
continue
} else if (!s.isEnabled() || !s.isVisible || !s.isPickable)
continue;
var l = s.skeleton && s.skeleton.overrideMesh ? s.skeleton.overrideMesh.getWorldMatrix() : s.getWorldMatrix();
if (s.hasThinInstances && s.thinInstanceEnablePicking) {
var u = this._internalPickForMesh(o, i, s, l, !0, !0, n);
if (u) {
if (r)
return o;
for (var c = TmpVectors.Matrix[1], h = s.thinInstanceGetWorldMatrices(), f = 0; f < h.length; f++) {
var d = h[f];
d.multiplyToRef(l, c);
var _ = this._internalPickForMesh(o, i, s, c, t, r, n, !0);
if (_ && (o = _,
o.thinInstanceIndex = f,
t))
return o
}
}
} else {
var u = this._internalPickForMesh(o, i, s, l, t, r, n);
if (u && (o = u,
t))
return o
}
}
return o || new PickingInfo
}
;
Scene.prototype._internalMultiPick = function(i, e, t) {
if (!PickingInfo)
return null;
for (var r = new Array, n = 0; n < this.meshes.length; n++) {
var o = this.meshes[n];
if (e) {
if (!e(o))
continue
} else if (!o.isEnabled() || !o.isVisible || !o.isPickable)
continue;
var a = o.skeleton && o.skeleton.overrideMesh ? o.skeleton.overrideMesh.getWorldMatrix() : o.getWorldMatrix();
if (o.hasThinInstances && o.thinInstanceEnablePicking) {
var s = this._internalPickForMesh(null, i, o, a, !0, !0, t);
if (s)
for (var l = TmpVectors.Matrix[1], u = o.thinInstanceGetWorldMatrices(), c = 0; c < u.length; c++) {
var h = u[c];
h.multiplyToRef(a, l);
var f = this._internalPickForMesh(null, i, o, l, !1, !1, t, !0);
f && (f.thinInstanceIndex = c,
r.push(f))
}
} else {
var s = this._internalPickForMesh(null, i, o, a, !1, !1, t);
s && r.push(s)
}
}
return r
}
;
Scene.prototype.pickWithBoundingInfo = function(i, e, t, r, n) {
var o = this;
if (!PickingInfo)
return null;
var a = this._internalPick(function(s) {
return o._tempPickingRay || (o._tempPickingRay = Ray.Zero()),
o.createPickingRayToRef(i, e, s, o._tempPickingRay, n || null),
o._tempPickingRay
}, t, r, !0);
return a && (a.ray = this.createPickingRay(i, e, Matrix.Identity(), n || null)),
a
}
;
Scene.prototype.pick = function(i, e, t, r, n, o) {
var a = this;
if (!PickingInfo)
return null;
var s = this._internalPick(function(l) {
return a._tempPickingRay || (a._tempPickingRay = Ray.Zero()),
a.createPickingRayToRef(i, e, l, a._tempPickingRay, n || null),
a._tempPickingRay
}, t, r, !1, o);
return s && (s.ray = this.createPickingRay(i, e, Matrix.Identity(), n || null)),
s
}
;
Scene.prototype.pickWithRay = function(i, e, t, r) {
var n = this
, o = this._internalPick(function(a) {
return n._pickWithRayInverseMatrix || (n._pickWithRayInverseMatrix = Matrix.Identity()),
a.invertToRef(n._pickWithRayInverseMatrix),
n._cachedRayForTransform || (n._cachedRayForTransform = Ray.Zero()),
Ray.TransformToRef(i, n._pickWithRayInverseMatrix, n._cachedRayForTransform),
n._cachedRayForTransform
}, e, t, !1, r);
return o && (o.ray = i),
o
}
;
Scene.prototype.multiPick = function(i, e, t, r, n) {
var o = this;
return this._internalMultiPick(function(a) {
return o.createPickingRay(i, e, a, r || null)
}, t, n)
}
;
Scene.prototype.multiPickWithRay = function(i, e, t) {
var r = this;
return this._internalMultiPick(function(n) {
return r._pickWithRayInverseMatrix || (r._pickWithRayInverseMatrix = Matrix.Identity()),
n.invertToRef(r._pickWithRayInverseMatrix),
r._cachedRayForTransform || (r._cachedRayForTransform = Ray.Zero()),
Ray.TransformToRef(i, r._pickWithRayInverseMatrix, r._cachedRayForTransform),
r._cachedRayForTransform
}, e, t)
}
;
Camera$1.prototype.getForwardRay = function(i, e, t) {
return i === void 0 && (i = 100),
this.getForwardRayToRef(new Ray(Vector3.Zero(),Vector3.Zero(),i), i, e, t)
}
;
Camera$1.prototype.getForwardRayToRef = function(i, e, t, r) {
return e === void 0 && (e = 100),
t || (t = this.getWorldMatrix()),
i.length = e,
r ? i.origin.copyFrom(r) : i.origin.copyFrom(this.position),
TmpVectors.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
Vector3.TransformNormalToRef(TmpVectors.Vector3[2], t, TmpVectors.Vector3[3]),
Vector3.NormalizeToRef(TmpVectors.Vector3[3], i.direction),
i
}
;
var ColorGradient = function() {
function i(e, t, r) {
this.gradient = e,
this.color1 = t,
this.color2 = r
}
return i.prototype.getColorToRef = function(e) {
if (!this.color2) {
e.copyFrom(this.color1);
return
}
Color4.LerpToRef(this.color1, this.color2, Math.random(), e)
}
,
i
}(), Color3Gradient = function() {
function i(e, t) {
this.gradient = e,
this.color = t
}
return i
}(), FactorGradient = function() {
function i(e, t, r) {
this.gradient = e,
this.factor1 = t,
this.factor2 = r
}
return i.prototype.getFactor = function() {
return this.factor2 === void 0 || this.factor2 === this.factor1 ? this.factor1 : this.factor1 + (this.factor2 - this.factor1) * Math.random()
}
,
i
}(), GradientHelper = function() {
function i() {}
return i.GetCurrentGradient = function(e, t, r) {
if (t[0].gradient > e) {
r(t[0], t[0], 1);
return
}
for (var n = 0; n < t.length - 1; n++) {
var o = t[n]
, a = t[n + 1];
if (e >= o.gradient && e <= a.gradient) {
var s = (e - o.gradient) / (a.gradient - o.gradient);
r(o, a, s);
return
}
}
var l = t.length - 1;
r(t[l], t[l], 1)
}
,
i
}(), BoxParticleEmitter = function() {
function i() {
this.direction1 = new Vector3(0,1,0),
this.direction2 = new Vector3(0,1,0),
this.minEmitBox = new Vector3(-.5,-.5,-.5),
this.maxEmitBox = new Vector3(.5,.5,.5)
}
return i.prototype.startDirectionFunction = function(e, t, r, n) {
var o = Scalar.RandomRange(this.direction1.x, this.direction2.x)
, a = Scalar.RandomRange(this.direction1.y, this.direction2.y)
, s = Scalar.RandomRange(this.direction1.z, this.direction2.z);
if (n) {
t.x = o,
t.y = a,
t.z = s;
return
}
Vector3.TransformNormalFromFloatsToRef(o, a, s, e, t)
}
,
i.prototype.startPositionFunction = function(e, t, r, n) {
var o = Scalar.RandomRange(this.minEmitBox.x, this.maxEmitBox.x)
, a = Scalar.RandomRange(this.minEmitBox.y, this.maxEmitBox.y)
, s = Scalar.RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
if (n) {
t.x = o,
t.y = a,
t.z = s;
return
}
Vector3.TransformCoordinatesFromFloatsToRef(o, a, s, e, t)
}
,
i.prototype.clone = function() {
var e = new i;
return DeepCopier.DeepCopy(this, e),
e
}
,
i.prototype.applyToShader = function(e) {
e.setVector3("direction1", this.direction1),
e.setVector3("direction2", this.direction2),
e.setVector3("minEmitBox", this.minEmitBox),
e.setVector3("maxEmitBox", this.maxEmitBox)
}
,
i.prototype.buildUniformLayout = function(e) {
e.addUniform("direction1", 3),
e.addUniform("direction2", 3),
e.addUniform("minEmitBox", 3),
e.addUniform("maxEmitBox", 3)
}
,
i.prototype.getEffectDefines = function() {
return "#define BOXEMITTER"
}
,
i.prototype.getClassName = function() {
return "BoxParticleEmitter"
}
,
i.prototype.serialize = function() {
var e = {};
return e.type = this.getClassName(),
e.direction1 = this.direction1.asArray(),
e.direction2 = this.direction2.asArray(),
e.minEmitBox = this.minEmitBox.asArray(),
e.maxEmitBox = this.maxEmitBox.asArray(),
e
}
,
i.prototype.parse = function(e) {
Vector3.FromArrayToRef(e.direction1, 0, this.direction1),
Vector3.FromArrayToRef(e.direction2, 0, this.direction2),
Vector3.FromArrayToRef(e.minEmitBox, 0, this.minEmitBox),
Vector3.FromArrayToRef(e.maxEmitBox, 0, this.maxEmitBox)
}
,
i
}(), ConeParticleEmitter = function() {
function i(e, t, r) {
e === void 0 && (e = 1),
t === void 0 && (t = Math.PI),
r === void 0 && (r = 0),
this.directionRandomizer = r,
this.radiusRange = 1,
this.heightRange = 1,
this.emitFromSpawnPointOnly = !1,
this.angle = t,
this.radius = e
}
return Object.defineProperty(i.prototype, "radius", {
get: function() {
return this._radius
},
set: function(e) {
this._radius = e,
this._buildHeight()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "angle", {
get: function() {
return this._angle
},
set: function(e) {
this._angle = e,
this._buildHeight()
},
enumerable: !1,
configurable: !0
}),
i.prototype._buildHeight = function() {
this._angle !== 0 ? this._height = this._radius / Math.tan(this._angle / 2) : this._height = 1
}
,
i.prototype.startDirectionFunction = function(e, t, r, n) {
n ? TmpVectors.Vector3[0].copyFrom(r._localPosition).normalize() : r.position.subtractToRef(e.getTranslation(), TmpVectors.Vector3[0]).normalize();
var o = Scalar.RandomRange(0, this.directionRandomizer)
, a = Scalar.RandomRange(0, this.directionRandomizer)
, s = Scalar.RandomRange(0, this.directionRandomizer);
t.x = TmpVectors.Vector3[0].x + o,
t.y = TmpVectors.Vector3[0].y + a,
t.z = TmpVectors.Vector3[0].z + s,
t.normalize()
}
,
i.prototype.startPositionFunction = function(e, t, r, n) {
var o = Scalar.RandomRange(0, Math.PI * 2), a;
this.emitFromSpawnPointOnly ? a = 1e-4 : (a = Scalar.RandomRange(0, this.heightRange),
a = 1 - a * a);
var s = this._radius - Scalar.RandomRange(0, this._radius * this.radiusRange);
s = s * a;
var l = s * Math.sin(o)
, u = s * Math.cos(o)
, c = a * this._height;
if (n) {
t.x = l,
t.y = c,
t.z = u;
return
}
Vector3.TransformCoordinatesFromFloatsToRef(l, c, u, e, t)
}
,
i.prototype.clone = function() {
var e = new i(this._radius,this._angle,this.directionRandomizer);
return DeepCopier.DeepCopy(this, e),
e
}
,
i.prototype.applyToShader = function(e) {
e.setFloat2("radius", this._radius, this.radiusRange),
e.setFloat("coneAngle", this._angle),
e.setFloat2("height", this._height, this.heightRange),
e.setFloat("directionRandomizer", this.directionRandomizer)
}
,
i.prototype.buildUniformLayout = function(e) {
e.addUniform("radius", 2),
e.addUniform("coneAngle", 1),
e.addUniform("height", 2),
e.addUniform("directionRandomizer", 1)
}
,
i.prototype.getEffectDefines = function() {
var e = "#define CONEEMITTER";
return this.emitFromSpawnPointOnly && (e += `
#define CONEEMITTERSPAWNPOINT`),
e
}
,
i.prototype.getClassName = function() {
return "ConeParticleEmitter"
}
,
i.prototype.serialize = function() {
var e = {};
return e.type = this.getClassName(),
e.radius = this._radius,
e.angle = this._angle,
e.directionRandomizer = this.directionRandomizer,
e.radiusRange = this.radiusRange,
e.heightRange = this.heightRange,
e.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly,
e
}
,
i.prototype.parse = function(e) {
this.radius = e.radius,
this.angle = e.angle,
this.directionRandomizer = e.directionRandomizer,
this.radiusRange = e.radiusRange !== void 0 ? e.radiusRange : 1,
this.heightRange = e.radiusRange !== void 0 ? e.heightRange : 1,
this.emitFromSpawnPointOnly = e.emitFromSpawnPointOnly !== void 0 ? e.emitFromSpawnPointOnly : !1
}
,
i
}(), CylinderParticleEmitter = function() {
function i(e, t, r, n) {
e === void 0 && (e = 1),
t === void 0 && (t = 1),
r === void 0 && (r = 1),
n === void 0 && (n = 0),
this.radius = e,
this.height = t,
this.radiusRange = r,
this.directionRandomizer = n,
this._tempVector = Vector3.Zero()
}
return i.prototype.startDirectionFunction = function(e, t, r, n, o) {
r.position.subtractToRef(e.getTranslation(), this._tempVector),
this._tempVector.normalize(),
Vector3.TransformNormalToRef(this._tempVector, o, this._tempVector);
var a = Scalar.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2)
, s = Math.atan2(this._tempVector.x, this._tempVector.z);
if (s += Scalar.RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer,
this._tempVector.y = a,
this._tempVector.x = Math.sin(s),
this._tempVector.z = Math.cos(s),
this._tempVector.normalize(),
n) {
t.copyFrom(this._tempVector);
return
}
Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, e, t)
}
,
i.prototype.startPositionFunction = function(e, t, r, n) {
var o = Scalar.RandomRange(-this.height / 2, this.height / 2)
, a = Scalar.RandomRange(0, 2 * Math.PI)
, s = Scalar.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1)
, l = Math.sqrt(s) * this.radius
, u = l * Math.cos(a)
, c = l * Math.sin(a);
if (n) {
t.copyFromFloats(u, o, c);
return
}
Vector3.TransformCoordinatesFromFloatsToRef(u, o, c, e, t)
}
,
i.prototype.clone = function() {
var e = new i(this.radius,this.directionRandomizer);
return DeepCopier.DeepCopy(this, e),
e
}
,
i.prototype.applyToShader = function(e) {
e.setFloat("radius", this.radius),
e.setFloat("height", this.height),
e.setFloat("radiusRange", this.radiusRange),
e.setFloat("directionRandomizer", this.directionRandomizer)
}
,
i.prototype.buildUniformLayout = function(e) {
e.addUniform("radius", 1),
e.addUniform("height", 1),
e.addUniform("radiusRange", 1),
e.addUniform("directionRandomizer", 1)
}
,
i.prototype.getEffectDefines = function() {
return "#define CYLINDEREMITTER"
}
,
i.prototype.getClassName = function() {
return "CylinderParticleEmitter"
}
,
i.prototype.serialize = function() {
var e = {};
return e.type = this.getClassName(),
e.radius = this.radius,
e.height = this.height,
e.radiusRange = this.radiusRange,
e.directionRandomizer = this.directionRandomizer,
e
}
,
i.prototype.parse = function(e) {
this.radius = e.radius,
this.height = e.height,
this.radiusRange = e.radiusRange,
this.directionRandomizer = e.directionRandomizer
}
,
i
}(), CylinderDirectedParticleEmitter = function(i) {
__extends(e, i);
function e(t, r, n, o, a) {
t === void 0 && (t = 1),
r === void 0 && (r = 1),
n === void 0 && (n = 1),
o === void 0 && (o = new Vector3(0,1,0)),
a === void 0 && (a = new Vector3(0,1,0));
var s = i.call(this, t, r, n) || this;
return s.direction1 = o,
s.direction2 = a,
s
}
return e.prototype.startDirectionFunction = function(t, r, n) {
var o = Scalar.RandomRange(this.direction1.x, this.direction2.x)
, a = Scalar.RandomRange(this.direction1.y, this.direction2.y)
, s = Scalar.RandomRange(this.direction1.z, this.direction2.z);
Vector3.TransformNormalFromFloatsToRef(o, a, s, t, r)
}
,
e.prototype.clone = function() {
var t = new e(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);
return DeepCopier.DeepCopy(this, t),
t
}
,
e.prototype.applyToShader = function(t) {
t.setFloat("radius", this.radius),
t.setFloat("height", this.height),
t.setFloat("radiusRange", this.radiusRange),
t.setVector3("direction1", this.direction1),
t.setVector3("direction2", this.direction2)
}
,
e.prototype.buildUniformLayout = function(t) {
t.addUniform("radius", 1),
t.addUniform("height", 1),
t.addUniform("radiusRange", 1),
t.addUniform("direction1", 3),
t.addUniform("direction2", 3)
}
,
e.prototype.getEffectDefines = function() {
return `#define CYLINDEREMITTER
#define DIRECTEDCYLINDEREMITTER`
}
,
e.prototype.getClassName = function() {
return "CylinderDirectedParticleEmitter"
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.direction1 = this.direction1.asArray(),
t.direction2 = this.direction2.asArray(),
t
}
,
e.prototype.parse = function(t) {
i.prototype.parse.call(this, t),
this.direction1.copyFrom(t.direction1),
this.direction2.copyFrom(t.direction2)
}
,
e
}(CylinderParticleEmitter), HemisphericParticleEmitter = function() {
function i(e, t, r) {
e === void 0 && (e = 1),
t === void 0 && (t = 1),
r === void 0 && (r = 0),
this.radius = e,
this.radiusRange = t,
this.directionRandomizer = r
}
return i.prototype.startDirectionFunction = function(e, t, r, n) {
var o = r.position.subtract(e.getTranslation()).normalize()
, a = Scalar.RandomRange(0, this.directionRandomizer)
, s = Scalar.RandomRange(0, this.directionRandomizer)
, l = Scalar.RandomRange(0, this.directionRandomizer);
if (o.x += a,
o.y += s,
o.z += l,
o.normalize(),
n) {
t.copyFrom(o);
return
}
Vector3.TransformNormalFromFloatsToRef(o.x, o.y, o.z, e, t)
}
,
i.prototype.startPositionFunction = function(e, t, r, n) {
var o = this.radius - Scalar.RandomRange(0, this.radius * this.radiusRange)
, a = Scalar.RandomRange(0, 1)
, s = Scalar.RandomRange(0, 2 * Math.PI)
, l = Math.acos(2 * a - 1)
, u = o * Math.cos(s) * Math.sin(l)
, c = o * Math.cos(l)
, h = o * Math.sin(s) * Math.sin(l);
if (n) {
t.copyFromFloats(u, Math.abs(c), h);
return
}
Vector3.TransformCoordinatesFromFloatsToRef(u, Math.abs(c), h, e, t)
}
,
i.prototype.clone = function() {
var e = new i(this.radius,this.directionRandomizer);
return DeepCopier.DeepCopy(this, e),
e
}
,
i.prototype.applyToShader = function(e) {
e.setFloat("radius", this.radius),
e.setFloat("radiusRange", this.radiusRange),
e.setFloat("directionRandomizer", this.directionRandomizer)
}
,
i.prototype.buildUniformLayout = function(e) {
e.addUniform("radius", 1),
e.addUniform("radiusRange", 1),
e.addUniform("directionRandomizer", 1)
}
,
i.prototype.getEffectDefines = function() {
return "#define HEMISPHERICEMITTER"
}
,
i.prototype.getClassName = function() {
return "HemisphericParticleEmitter"
}
,
i.prototype.serialize = function() {
var e = {};
return e.type = this.getClassName(),
e.radius = this.radius,
e.radiusRange = this.radiusRange,
e.directionRandomizer = this.directionRandomizer,
e
}
,
i.prototype.parse = function(e) {
this.radius = e.radius,
this.radiusRange = e.radiusRange,
this.directionRandomizer = e.directionRandomizer
}
,
i
}(), PointParticleEmitter = function() {
function i() {
this.direction1 = new Vector3(0,1,0),
this.direction2 = new Vector3(0,1,0)
}
return i.prototype.startDirectionFunction = function(e, t, r, n) {
var o = Scalar.RandomRange(this.direction1.x, this.direction2.x)
, a = Scalar.RandomRange(this.direction1.y, this.direction2.y)
, s = Scalar.RandomRange(this.direction1.z, this.direction2.z);
if (n) {
t.copyFromFloats(o, a, s);
return
}
Vector3.TransformNormalFromFloatsToRef(o, a, s, e, t)
}
,
i.prototype.startPositionFunction = function(e, t, r, n) {
if (n) {
t.copyFromFloats(0, 0, 0);
return
}
Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, e, t)
}
,
i.prototype.clone = function() {
var e = new i;
return DeepCopier.DeepCopy(this, e),
e
}
,
i.prototype.applyToShader = function(e) {
e.setVector3("direction1", this.direction1),
e.setVector3("direction2", this.direction2)
}
,
i.prototype.buildUniformLayout = function(e) {
e.addUniform("direction1", 3),
e.addUniform("direction2", 3)
}
,
i.prototype.getEffectDefines = function() {
return "#define POINTEMITTER"
}
,
i.prototype.getClassName = function() {
return "PointParticleEmitter"
}
,
i.prototype.serialize = function() {
var e = {};
return e.type = this.getClassName(),
e.direction1 = this.direction1.asArray(),
e.direction2 = this.direction2.asArray(),
e
}
,
i.prototype.parse = function(e) {
Vector3.FromArrayToRef(e.direction1, 0, this.direction1),
Vector3.FromArrayToRef(e.direction2, 0, this.direction2)
}
,
i
}(), SphereParticleEmitter = function() {
function i(e, t, r) {
e === void 0 && (e = 1),
t === void 0 && (t = 1),
r === void 0 && (r = 0),
this.radius = e,
this.radiusRange = t,
this.directionRandomizer = r
}
return i.prototype.startDirectionFunction = function(e, t, r, n) {
var o = r.position.subtract(e.getTranslation()).normalize()
, a = Scalar.RandomRange(0, this.directionRandomizer)
, s = Scalar.RandomRange(0, this.directionRandomizer)
, l = Scalar.RandomRange(0, this.directionRandomizer);
if (o.x += a,
o.y += s,
o.z += l,
o.normalize(),
n) {
t.copyFrom(o);
return
}
Vector3.TransformNormalFromFloatsToRef(o.x, o.y, o.z, e, t)
}
,
i.prototype.startPositionFunction = function(e, t, r, n) {
var o = this.radius - Scalar.RandomRange(0, this.radius * this.radiusRange)
, a = Scalar.RandomRange(0, 1)
, s = Scalar.RandomRange(0, 2 * Math.PI)
, l = Math.acos(2 * a - 1)
, u = o * Math.cos(s) * Math.sin(l)
, c = o * Math.cos(l)
, h = o * Math.sin(s) * Math.sin(l);
if (n) {
t.copyFromFloats(u, c, h);
return
}
Vector3.TransformCoordinatesFromFloatsToRef(u, c, h, e, t)
}
,
i.prototype.clone = function() {
var e = new i(this.radius,this.directionRandomizer);
return DeepCopier.DeepCopy(this, e),
e
}
,
i.prototype.applyToShader = function(e) {
e.setFloat("radius", this.radius),
e.setFloat("radiusRange", this.radiusRange),
e.setFloat("directionRandomizer", this.directionRandomizer)
}
,
i.prototype.buildUniformLayout = function(e) {
e.addUniform("radius", 1),
e.addUniform("radiusRange", 1),
e.addUniform("directionRandomizer", 1)
}
,
i.prototype.getEffectDefines = function() {
return "#define SPHEREEMITTER"
}
,
i.prototype.getClassName = function() {
return "SphereParticleEmitter"
}
,
i.prototype.serialize = function() {
var e = {};
return e.type = this.getClassName(),
e.radius = this.radius,
e.radiusRange = this.radiusRange,
e.directionRandomizer = this.directionRandomizer,
e
}
,
i.prototype.parse = function(e) {
this.radius = e.radius,
this.radiusRange = e.radiusRange,
this.directionRandomizer = e.directionRandomizer
}
,
i
}(), SphereDirectedParticleEmitter = function(i) {
__extends(e, i);
function e(t, r, n) {
t === void 0 && (t = 1),
r === void 0 && (r = new Vector3(0,1,0)),
n === void 0 && (n = new Vector3(0,1,0));
var o = i.call(this, t) || this;
return o.direction1 = r,
o.direction2 = n,
o
}
return e.prototype.startDirectionFunction = function(t, r, n) {
var o = Scalar.RandomRange(this.direction1.x, this.direction2.x)
, a = Scalar.RandomRange(this.direction1.y, this.direction2.y)
, s = Scalar.RandomRange(this.direction1.z, this.direction2.z);
Vector3.TransformNormalFromFloatsToRef(o, a, s, t, r)
}
,
e.prototype.clone = function() {
var t = new e(this.radius,this.direction1,this.direction2);
return DeepCopier.DeepCopy(this, t),
t
}
,
e.prototype.applyToShader = function(t) {
t.setFloat("radius", this.radius),
t.setFloat("radiusRange", this.radiusRange),
t.setVector3("direction1", this.direction1),
t.setVector3("direction2", this.direction2)
}
,
e.prototype.buildUniformLayout = function(t) {
t.addUniform("radius", 1),
t.addUniform("radiusRange", 1),
t.addUniform("direction1", 3),
t.addUniform("direction2", 3)
}
,
e.prototype.getEffectDefines = function() {
return `#define SPHEREEMITTER
#define DIRECTEDSPHEREEMITTER`
}
,
e.prototype.getClassName = function() {
return "SphereDirectedParticleEmitter"
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.direction1 = this.direction1.asArray(),
t.direction2 = this.direction2.asArray(),
t
}
,
e.prototype.parse = function(t) {
i.prototype.parse.call(this, t),
this.direction1.copyFrom(t.direction1),
this.direction2.copyFrom(t.direction2)
}
,
e
}(SphereParticleEmitter), CustomParticleEmitter = function() {
function i() {
this.particlePositionGenerator = function() {}
,
this.particleDestinationGenerator = function() {}
}
return i.prototype.startDirectionFunction = function(e, t, r, n) {
var o = TmpVectors.Vector3[0];
if (this.particleDestinationGenerator) {
this.particleDestinationGenerator(-1, r, o);
var a = TmpVectors.Vector3[1];
o.subtractToRef(r.position, a),
a.scaleToRef(1 / r.lifeTime, o)
} else
o.set(0, 0, 0);
if (n) {
t.copyFrom(o);
return
}
Vector3.TransformNormalToRef(o, e, t)
}
,
i.prototype.startPositionFunction = function(e, t, r, n) {
var o = TmpVectors.Vector3[0];
if (this.particlePositionGenerator ? this.particlePositionGenerator(-1, r, o) : o.set(0, 0, 0),
n) {
t.copyFrom(o);
return
}
Vector3.TransformCoordinatesToRef(o, e, t)
}
,
i.prototype.clone = function() {
var e = new i;
return DeepCopier.DeepCopy(this, e),
e
}
,
i.prototype.applyToShader = function(e) {}
,
i.prototype.buildUniformLayout = function(e) {}
,
i.prototype.getEffectDefines = function() {
return "#define CUSTOMEMITTER"
}
,
i.prototype.getClassName = function() {
return "CustomParticleEmitter"
}
,
i.prototype.serialize = function() {
var e = {};
return e.type = this.getClassName(),
e
}
,
i.prototype.parse = function(e) {}
,
i
}(), MeshParticleEmitter = function() {
function i(e) {
e === void 0 && (e = null),
this._indices = null,
this._positions = null,
this._normals = null,
this._storedNormal = Vector3.Zero(),
this._mesh = null,
this.direction1 = new Vector3(0,1,0),
this.direction2 = new Vector3(0,1,0),
this.useMeshNormalsForDirection = !0,
this.mesh = e
}
return Object.defineProperty(i.prototype, "mesh", {
get: function() {
return this._mesh
},
set: function(e) {
this._mesh !== e && (this._mesh = e,
e ? (this._indices = e.getIndices(),
this._positions = e.getVerticesData(VertexBuffer.PositionKind),
this._normals = e.getVerticesData(VertexBuffer.NormalKind)) : (this._indices = null,
this._positions = null,
this._normals = null))
},
enumerable: !1,
configurable: !0
}),
i.prototype.startDirectionFunction = function(e, t, r, n) {
if (this.useMeshNormalsForDirection && this._normals) {
Vector3.TransformNormalToRef(this._storedNormal, e, t);
return
}
var o = Scalar.RandomRange(this.direction1.x, this.direction2.x)
, a = Scalar.RandomRange(this.direction1.y, this.direction2.y)
, s = Scalar.RandomRange(this.direction1.z, this.direction2.z);
if (n) {
t.copyFromFloats(o, a, s);
return
}
Vector3.TransformNormalFromFloatsToRef(o, a, s, e, t)
}
,
i.prototype.startPositionFunction = function(e, t, r, n) {
if (!(!this._indices || !this._positions)) {
var o = 3 * Math.random() * (this._indices.length / 3) | 0
, a = Math.random()
, s = Math.random() * (1 - a)
, l = 1 - a - s
, u = this._indices[o]
, c = this._indices[o + 1]
, h = this._indices[o + 2]
, f = TmpVectors.Vector3[0]
, d = TmpVectors.Vector3[1]
, _ = TmpVectors.Vector3[2]
, g = TmpVectors.Vector3[3];
Vector3.FromArrayToRef(this._positions, u * 3, f),
Vector3.FromArrayToRef(this._positions, c * 3, d),
Vector3.FromArrayToRef(this._positions, h * 3, _),
g.x = a * f.x + s * d.x + l * _.x,
g.y = a * f.y + s * d.y + l * _.y,
g.z = a * f.z + s * d.z + l * _.z,
n ? t.copyFromFloats(g.x, g.y, g.z) : Vector3.TransformCoordinatesFromFloatsToRef(g.x, g.y, g.z, e, t),
this.useMeshNormalsForDirection && this._normals && (Vector3.FromArrayToRef(this._normals, u * 3, f),
Vector3.FromArrayToRef(this._normals, c * 3, d),
Vector3.FromArrayToRef(this._normals, h * 3, _),
this._storedNormal.x = a * f.x + s * d.x + l * _.x,
this._storedNormal.y = a * f.y + s * d.y + l * _.y,
this._storedNormal.z = a * f.z + s * d.z + l * _.z)
}
}
,
i.prototype.clone = function() {
var e = new i(this.mesh);
return DeepCopier.DeepCopy(this, e),
e
}
,
i.prototype.applyToShader = function(e) {
e.setVector3("direction1", this.direction1),
e.setVector3("direction2", this.direction2)
}
,
i.prototype.buildUniformLayout = function(e) {
e.addUniform("direction1", 3),
e.addUniform("direction2", 3)
}
,
i.prototype.getEffectDefines = function() {
return ""
}
,
i.prototype.getClassName = function() {
return "MeshParticleEmitter"
}
,
i.prototype.serialize = function() {
var e, t = {};
return t.type = this.getClassName(),
t.direction1 = this.direction1.asArray(),
t.direction2 = this.direction2.asArray(),
t.meshId = (e = this.mesh) === null || e === void 0 ? void 0 : e.id,
t.useMeshNormalsForDirection = this.useMeshNormalsForDirection,
t
}
,
i.prototype.parse = function(e, t) {
Vector3.FromArrayToRef(e.direction1, 0, this.direction1),
Vector3.FromArrayToRef(e.direction2, 0, this.direction2),
e.meshId && t && (this.mesh = t.getLastMeshById(e.meshId)),
this.useMeshNormalsForDirection = e.useMeshNormalsForDirection
}
,
i
}(), BaseParticleSystem = function() {
function i(e) {
this.animations = [],
this.renderingGroupId = 0,
this.emitter = Vector3.Zero(),
this.emitRate = 10,
this.manualEmitCount = -1,
this.updateSpeed = .01,
this.targetStopDuration = 0,
this.disposeOnStop = !1,
this.minEmitPower = 1,
this.maxEmitPower = 1,
this.minLifeTime = 1,
this.maxLifeTime = 1,
this.minSize = 1,
this.maxSize = 1,
this.minScaleX = 1,
this.maxScaleX = 1,
this.minScaleY = 1,
this.maxScaleY = 1,
this.minInitialRotation = 0,
this.maxInitialRotation = 0,
this.minAngularSpeed = 0,
this.maxAngularSpeed = 0,
this.layerMask = 268435455,
this.customShader = null,
this.preventAutoStart = !1,
this._rootUrl = "",
this.noiseStrength = new Vector3(10,10,10),
this.onAnimationEnd = null,
this.blendMode = i.BLENDMODE_ONEONE,
this.forceDepthWrite = !1,
this.preWarmCycles = 0,
this.preWarmStepOffset = 1,
this.spriteCellChangeSpeed = 1,
this.startSpriteCellID = 0,
this.endSpriteCellID = 0,
this.spriteCellWidth = 0,
this.spriteCellHeight = 0,
this.spriteCellLoop = !0,
this.spriteRandomStartCell = !1,
this.translationPivot = new Vector2(0,0),
this.beginAnimationOnStart = !1,
this.beginAnimationFrom = 0,
this.beginAnimationTo = 60,
this.beginAnimationLoop = !1,
this.worldOffset = new Vector3(0,0,0),
this.gravity = Vector3.Zero(),
this._colorGradients = null,
this._sizeGradients = null,
this._lifeTimeGradients = null,
this._angularSpeedGradients = null,
this._velocityGradients = null,
this._limitVelocityGradients = null,
this._dragGradients = null,
this._emitRateGradients = null,
this._startSizeGradients = null,
this._rampGradients = null,
this._colorRemapGradients = null,
this._alphaRemapGradients = null,
this.startDelay = 0,
this.limitVelocityDamping = .4,
this.color1 = new Color4(1,1,1,1),
this.color2 = new Color4(1,1,1,1),
this.colorDead = new Color4(0,0,0,1),
this.textureMask = new Color4(1,1,1,1),
this._isSubEmitter = !1,
this.billboardMode = 7,
this._isBillboardBased = !0,
this._imageProcessingConfigurationDefines = new ImageProcessingConfigurationDefines,
this.id = e,
this.name = e
}
return Object.defineProperty(i.prototype, "noiseTexture", {
get: function() {
return this._noiseTexture
},
set: function(e) {
this._noiseTexture !== e && (this._noiseTexture = e,
this._reset())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isAnimationSheetEnabled", {
get: function() {
return this._isAnimationSheetEnabled
},
set: function(e) {
this._isAnimationSheetEnabled != e && (this._isAnimationSheetEnabled = e,
this._reset())
},
enumerable: !1,
configurable: !0
}),
i.prototype.getScene = function() {
return this._scene
}
,
i.prototype._hasTargetStopDurationDependantGradient = function() {
return this._startSizeGradients && this._startSizeGradients.length > 0 || this._emitRateGradients && this._emitRateGradients.length > 0 || this._lifeTimeGradients && this._lifeTimeGradients.length > 0
}
,
i.prototype.getDragGradients = function() {
return this._dragGradients
}
,
i.prototype.getLimitVelocityGradients = function() {
return this._limitVelocityGradients
}
,
i.prototype.getColorGradients = function() {
return this._colorGradients
}
,
i.prototype.getSizeGradients = function() {
return this._sizeGradients
}
,
i.prototype.getColorRemapGradients = function() {
return this._colorRemapGradients
}
,
i.prototype.getAlphaRemapGradients = function() {
return this._alphaRemapGradients
}
,
i.prototype.getLifeTimeGradients = function() {
return this._lifeTimeGradients
}
,
i.prototype.getAngularSpeedGradients = function() {
return this._angularSpeedGradients
}
,
i.prototype.getVelocityGradients = function() {
return this._velocityGradients
}
,
i.prototype.getStartSizeGradients = function() {
return this._startSizeGradients
}
,
i.prototype.getEmitRateGradients = function() {
return this._emitRateGradients
}
,
Object.defineProperty(i.prototype, "direction1", {
get: function() {
return this.particleEmitterType.direction1 ? this.particleEmitterType.direction1 : Vector3.Zero()
},
set: function(e) {
this.particleEmitterType.direction1 && (this.particleEmitterType.direction1 = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "direction2", {
get: function() {
return this.particleEmitterType.direction2 ? this.particleEmitterType.direction2 : Vector3.Zero()
},
set: function(e) {
this.particleEmitterType.direction2 && (this.particleEmitterType.direction2 = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "minEmitBox", {
get: function() {
return this.particleEmitterType.minEmitBox ? this.particleEmitterType.minEmitBox : Vector3.Zero()
},
set: function(e) {
this.particleEmitterType.minEmitBox && (this.particleEmitterType.minEmitBox = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "maxEmitBox", {
get: function() {
return this.particleEmitterType.maxEmitBox ? this.particleEmitterType.maxEmitBox : Vector3.Zero()
},
set: function(e) {
this.particleEmitterType.maxEmitBox && (this.particleEmitterType.maxEmitBox = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isBillboardBased", {
get: function() {
return this._isBillboardBased
},
set: function(e) {
this._isBillboardBased !== e && (this._isBillboardBased = e,
this._reset())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "imageProcessingConfiguration", {
get: function() {
return this._imageProcessingConfiguration
},
set: function(e) {
this._attachImageProcessingConfiguration(e)
},
enumerable: !1,
configurable: !0
}),
i.prototype._attachImageProcessingConfiguration = function(e) {
e !== this._imageProcessingConfiguration && (!e && this._scene ? this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration : this._imageProcessingConfiguration = e)
}
,
i.prototype._reset = function() {}
,
i.prototype._removeGradientAndTexture = function(e, t, r) {
if (!t)
return this;
for (var n = 0, o = 0, a = t; o < a.length; o++) {
var s = a[o];
if (s.gradient === e) {
t.splice(n, 1);
break
}
n++
}
return r && r.dispose(),
this
}
,
i.prototype.createPointEmitter = function(e, t) {
var r = new PointParticleEmitter;
return r.direction1 = e,
r.direction2 = t,
this.particleEmitterType = r,
r
}
,
i.prototype.createHemisphericEmitter = function(e, t) {
e === void 0 && (e = 1),
t === void 0 && (t = 1);
var r = new HemisphericParticleEmitter(e,t);
return this.particleEmitterType = r,
r
}
,
i.prototype.createSphereEmitter = function(e, t) {
e === void 0 && (e = 1),
t === void 0 && (t = 1);
var r = new SphereParticleEmitter(e,t);
return this.particleEmitterType = r,
r
}
,
i.prototype.createDirectedSphereEmitter = function(e, t, r) {
e === void 0 && (e = 1),
t === void 0 && (t = new Vector3(0,1,0)),
r === void 0 && (r = new Vector3(0,1,0));
var n = new SphereDirectedParticleEmitter(e,t,r);
return this.particleEmitterType = n,
n
}
,
i.prototype.createCylinderEmitter = function(e, t, r, n) {
e === void 0 && (e = 1),
t === void 0 && (t = 1),
r === void 0 && (r = 1),
n === void 0 && (n = 0);
var o = new CylinderParticleEmitter(e,t,r,n);
return this.particleEmitterType = o,
o
}
,
i.prototype.createDirectedCylinderEmitter = function(e, t, r, n, o) {
e === void 0 && (e = 1),
t === void 0 && (t = 1),
r === void 0 && (r = 1),
n === void 0 && (n = new Vector3(0,1,0)),
o === void 0 && (o = new Vector3(0,1,0));
var a = new CylinderDirectedParticleEmitter(e,t,r,n,o);
return this.particleEmitterType = a,
a
}
,
i.prototype.createConeEmitter = function(e, t) {
e === void 0 && (e = 1),
t === void 0 && (t = Math.PI / 4);
var r = new ConeParticleEmitter(e,t);
return this.particleEmitterType = r,
r
}
,
i.prototype.createBoxEmitter = function(e, t, r, n) {
var o = new BoxParticleEmitter;
return this.particleEmitterType = o,
this.direction1 = e,
this.direction2 = t,
this.minEmitBox = r,
this.maxEmitBox = n,
o
}
,
i.BLENDMODE_ONEONE = 0,
i.BLENDMODE_STANDARD = 1,
i.BLENDMODE_ADD = 2,
i.BLENDMODE_MULTIPLY = 3,
i.BLENDMODE_MULTIPLYADD = 4,
i
}(), Particle = function() {
function i(e) {
this.particleSystem = e,
this.position = Vector3.Zero(),
this.direction = Vector3.Zero(),
this.color = new Color4(0,0,0,0),
this.colorStep = new Color4(0,0,0,0),
this.lifeTime = 1,
this.age = 0,
this.size = 0,
this.scale = new Vector2(1,1),
this.angle = 0,
this.angularSpeed = 0,
this.cellIndex = 0,
this._attachedSubEmitters = null,
this._currentColor1 = new Color4(0,0,0,0),
this._currentColor2 = new Color4(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 = i._Count++,
this.particleSystem.isAnimationSheetEnabled && this.updateCellInfoFromSystem()
}
return i.prototype.updateCellInfoFromSystem = function() {
this.cellIndex = this.particleSystem.startSpriteCellID
}
,
i.prototype.updateCellIndex = function() {
var e = this.age
, t = this.particleSystem.spriteCellChangeSpeed;
this.particleSystem.spriteRandomStartCell && (this._randomCellOffset === void 0 && (this._randomCellOffset = Math.random() * this.lifeTime),
t === 0 ? (t = 1,
e = this._randomCellOffset) : e += this._randomCellOffset);
var r = this._initialEndSpriteCellID - this._initialStartSpriteCellID, n;
this._initialSpriteCellLoop ? n = Scalar.Clamp(e * t % this.lifeTime / this.lifeTime) : n = Scalar.Clamp(e * t / this.lifeTime),
this.cellIndex = this._initialStartSpriteCellID + n * r | 0
}
,
i.prototype._inheritParticleInfoToSubEmitter = function(e) {
if (e.particleSystem.emitter.position) {
var t = e.particleSystem.emitter;
if (t.position.copyFrom(this.position),
e.inheritDirection) {
var r = TmpVectors.Vector3[0];
this.direction.normalizeToRef(r),
t.setDirection(r, 0, Math.PI / 2)
}
} else {
var n = e.particleSystem.emitter;
n.copyFrom(this.position)
}
this.direction.scaleToRef(e.inheritedVelocityAmount / 2, TmpVectors.Vector3[0]),
e.particleSystem._inheritedVelocityOffset.copyFrom(TmpVectors.Vector3[0])
}
,
i.prototype._inheritParticleInfoToSubEmitters = function() {
var e = this;
this._attachedSubEmitters && this._attachedSubEmitters.length > 0 && this._attachedSubEmitters.forEach(function(t) {
e._inheritParticleInfoToSubEmitter(t)
})
}
,
i.prototype._reset = function() {
this.age = 0,
this.id = i._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
}
,
i.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,
e._initialSpriteCellLoop = this._initialSpriteCellLoop),
this.particleSystem.useRampGradients && (e.remapData && this.remapData ? e.remapData.copyFrom(this.remapData) : e.remapData = new Vector4(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()))
}
,
i._Count = 0,
i
}(), SubEmitterType;
(function(i) {
i[i.ATTACHED = 0] = "ATTACHED",
i[i.END = 1] = "END"
}
)(SubEmitterType || (SubEmitterType = {}));
var SubEmitter = function() {
function i(e) {
if (this.particleSystem = e,
this.type = SubEmitterType.END,
this.inheritDirection = !1,
this.inheritedVelocityAmount = 0,
!e.emitter || !e.emitter.dispose) {
var t = GetClass("BABYLON.AbstractMesh");
e.emitter = new t("SubemitterSystemEmitter",e.getScene()),
e._disposeEmitterOnDispose = !0
}
}
return i.prototype.clone = function() {
var e = this.particleSystem.emitter;
if (!e)
e = new Vector3;
else if (e instanceof Vector3)
e = e.clone();
else if (e.getClassName().indexOf("Mesh") !== -1) {
var t = GetClass("BABYLON.Mesh");
e = new t("",e.getScene()),
e.isVisible = !1
}
var r = new i(this.particleSystem.clone(this.particleSystem.name, e));
return r.particleSystem.name += "Clone",
r.type = this.type,
r.inheritDirection = this.inheritDirection,
r.inheritedVelocityAmount = this.inheritedVelocityAmount,
r.particleSystem._disposeEmitterOnDispose = !0,
r.particleSystem.disposeOnStop = !0,
r
}
,
i.prototype.serialize = function(e) {
e === void 0 && (e = !1);
var t = {};
return t.type = this.type,
t.inheritDirection = this.inheritDirection,
t.inheritedVelocityAmount = this.inheritedVelocityAmount,
t.particleSystem = this.particleSystem.serialize(e),
t
}
,
i._ParseParticleSystem = function(e, t, r, n) {
throw _WarnImport("ParseParticle")
}
,
i.Parse = function(e, t, r) {
var n = e.particleSystem
, o = new i(i._ParseParticleSystem(n, t, r, !0));
return o.type = e.type,
o.inheritDirection = e.inheritDirection,
o.inheritedVelocityAmount = e.inheritedVelocityAmount,
o.particleSystem._isSubEmitter = !0,
o
}
,
i.prototype.dispose = function() {
this.particleSystem.dispose()
}
,
i
}()
, name$1H = "particlesPixelShader"
, shader$1H = `
varying vec2 vUV;
varying vec4 vColor;
uniform vec4 textureMask;
uniform sampler2D diffuseSampler;
#include
#include
#include
#include
#ifdef RAMPGRADIENT
varying vec4 remapRanges;
uniform sampler2D rampSampler;
#endif
void main(void) {
#include
vec4 textureColor=texture2D(diffuseSampler,vUV);
vec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;
#ifdef RAMPGRADIENT
float alpha=baseColor.a;
float remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);
vec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));
baseColor.rgb*=rampColor.rgb;
float finalAlpha=baseColor.a;
baseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);
#endif
#ifdef BLENDMULTIPLYMODE
float sourceAlpha=vColor.a*textureColor.a;
baseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);
#endif
#ifdef IMAGEPROCESSINGPOSTPROCESS
baseColor.rgb=toLinearSpace(baseColor.rgb);
#else
#ifdef IMAGEPROCESSING
baseColor.rgb=toLinearSpace(baseColor.rgb);
baseColor=applyImageProcessing(baseColor);
#endif
#endif
gl_FragColor=baseColor;
}`;
ShaderStore.ShadersStore[name$1H] = shader$1H;
var name$1G = "particlesVertexShader"
, shader$1G = `
attribute vec3 position;
attribute vec4 color;
attribute float angle;
attribute vec2 size;
#ifdef ANIMATESHEET
attribute float cellIndex;
#endif
#ifndef BILLBOARD
attribute vec3 direction;
#endif
#ifdef BILLBOARDSTRETCHED
attribute vec3 direction;
#endif
#ifdef RAMPGRADIENT
attribute vec4 remapData;
#endif
attribute vec2 offset;
uniform mat4 view;
uniform mat4 projection;
uniform vec2 translationPivot;
#ifdef ANIMATESHEET
uniform vec3 particlesInfos;
#endif
varying vec2 vUV;
varying vec4 vColor;
varying vec3 vPositionW;
#ifdef RAMPGRADIENT
varying vec4 remapRanges;
#endif
#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
uniform mat4 invView;
#endif
#include
#ifdef BILLBOARD
uniform vec3 eyePosition;
#endif
vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
vec3 zaxis=normalize(cross(yaxis,xaxis));
vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
mat3 rotMatrix=mat3(row0,row1,row2);
vec3 alignedCorner=rotMatrix*rotatedCorner;
return position+alignedCorner;
}
#ifdef BILLBOARDSTRETCHED
vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
vec3 normalizedToCamera=normalize(toCamera);
vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
mat3 rotMatrix=mat3(row0,row1,row2);
vec3 alignedCorner=rotMatrix*rotatedCorner;
return position+alignedCorner;
}
#endif
void main(void) {
vec2 cornerPos;
cornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;
#ifdef BILLBOARD
vec3 rotatedCorner;
#ifdef BILLBOARDY
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
rotatedCorner.y=0.;
vec3 yaxis=position-eyePosition;
yaxis.y=0.;
vPositionW=rotate(normalize(yaxis),rotatedCorner);
vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
#elif defined(BILLBOARDSTRETCHED)
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
rotatedCorner.z=0.;
vec3 toCamera=position-eyePosition;
vPositionW=rotateAlign(toCamera,rotatedCorner);
vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
#else
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
rotatedCorner.z=0.;
vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;
vPositionW=(invView*vec4(viewPos,1)).xyz;
#endif
#ifdef RAMPGRADIENT
remapRanges=remapData;
#endif
gl_Position=projection*vec4(viewPos,1.0);
#else
vec3 rotatedCorner;
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
rotatedCorner.y=0.;
vec3 yaxis=normalize(direction);
vPositionW=rotate(yaxis,rotatedCorner);
gl_Position=projection*view*vec4(vPositionW,1.0);
#endif
vColor=color;
#ifdef ANIMATESHEET
float rowOffset=floor(cellIndex*particlesInfos.z);
float columnOffset=cellIndex-rowOffset/particlesInfos.z;
vec2 uvScale=particlesInfos.xy;
vec2 uvOffset=vec2(offset.x ,1.0-offset.y);
vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
#else
vUV=offset;
#endif
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
vec4 worldPos=vec4(vPositionW,1.0);
#endif
#include
}`;
ShaderStore.ShadersStore[name$1G] = shader$1G;
var ParticleSystem = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s) {
o === void 0 && (o = null),
a === void 0 && (a = !1),
s === void 0 && (s = .01);
var l = i.call(this, t) || this;
l._emitterInverseWorldMatrix = Matrix.Identity(),
l._inheritedVelocityOffset = new Vector3,
l.onDisposeObservable = new Observable,
l.onStoppedObservable = new Observable,
l._particles = new Array,
l._stockParticles = new Array,
l._newPartsExcess = 0,
l._vertexBuffers = {},
l._scaledColorStep = new Color4(0,0,0,0),
l._colorDiff = new Color4(0,0,0,0),
l._scaledDirection = Vector3.Zero(),
l._scaledGravity = Vector3.Zero(),
l._currentRenderId = -1,
l._useInstancing = !1,
l._started = !1,
l._stopped = !1,
l._actualFrame = 0,
l._currentEmitRate1 = 0,
l._currentEmitRate2 = 0,
l._currentStartSize1 = 0,
l._currentStartSize2 = 0,
l._rawTextureWidth = 256,
l._useRampGradients = !1,
l._disposeEmitterOnDispose = !1,
l.isLocal = !1,
l._onBeforeDrawParticlesObservable = null,
l.recycleParticle = function(c) {
var h = l._particles.pop();
h !== c && h.copyTo(c),
l._stockParticles.push(h)
}
,
l._createParticle = function() {
var c;
if (l._stockParticles.length !== 0 ? (c = l._stockParticles.pop(),
c._reset()) : c = new Particle(l),
l._subEmitters && l._subEmitters.length > 0) {
var h = l._subEmitters[Math.floor(Math.random() * l._subEmitters.length)];
c._attachedSubEmitters = [],
h.forEach(function(f) {
if (f.type === SubEmitterType.ATTACHED) {
var d = f.clone();
c._attachedSubEmitters.push(d),
d.particleSystem.start()
}
})
}
return c
}
,
l._emitFromParticle = function(c) {
if (!(!l._subEmitters || l._subEmitters.length === 0)) {
var h = Math.floor(Math.random() * l._subEmitters.length);
l._subEmitters[h].forEach(function(f) {
if (f.type === SubEmitterType.END) {
var d = f.clone();
c._inheritParticleInfoToSubEmitter(d),
d.particleSystem._rootParticleSystem = l,
l.activeSubSystems.push(d.particleSystem),
d.particleSystem.start()
}
})
}
}
,
l._capacity = r,
l._epsilon = s,
l._isAnimationSheetEnabled = a,
!n || n.getClassName() === "Scene" ? (l._scene = n || EngineStore.LastCreatedScene,
l._engine = l._scene.getEngine(),
l.uniqueId = l._scene.getUniqueId(),
l._scene.particleSystems.push(l)) : (l._engine = n,
l.defaultProjectionMatrix = Matrix.PerspectiveFovLH(.8, 1, .1, 100, l._engine.isNDCHalfZRange)),
l._engine.getCaps().vertexArrayObject && (l._vertexArrayObject = null),
l._attachImageProcessingConfiguration(null),
l._customWrappers = {
0: new DrawWrapper(l._engine)
},
l._customWrappers[0].effect = o,
l._drawWrappers = [],
l._useInstancing = l._engine.getCaps().instancedArrays,
l._createIndexBuffer(),
l._createVertexBuffers(),
l.particleEmitterType = new BoxParticleEmitter;
var u = null;
return l.updateFunction = function(c) {
var h, f = null;
l.noiseTexture && (f = l.noiseTexture.getSize(),
(h = l.noiseTexture.getContent()) === null || h === void 0 || h.then(function(m) {
u = m
}));
for (var d = function() {
_ = c[g];
var m = l._scaledUpdateSpeed
, v = _.age;
if (_.age += m,
_.age > _.lifeTime) {
var y = _.age - v
, b = _.lifeTime - v;
m = b * m / y,
_.age = _.lifeTime
}
var T = _.age / _.lifeTime;
l._colorGradients && l._colorGradients.length > 0 ? GradientHelper.GetCurrentGradient(T, l._colorGradients, function(x, I, w) {
x !== _._currentColorGradient && (_._currentColor1.copyFrom(_._currentColor2),
I.getColorToRef(_._currentColor2),
_._currentColorGradient = x),
Color4.LerpToRef(_._currentColor1, _._currentColor2, w, _.color)
}) : (_.colorStep.scaleToRef(m, l._scaledColorStep),
_.color.addInPlace(l._scaledColorStep),
_.color.a < 0 && (_.color.a = 0)),
l._angularSpeedGradients && l._angularSpeedGradients.length > 0 && GradientHelper.GetCurrentGradient(T, l._angularSpeedGradients, function(x, I, w) {
x !== _._currentAngularSpeedGradient && (_._currentAngularSpeed1 = _._currentAngularSpeed2,
_._currentAngularSpeed2 = I.getFactor(),
_._currentAngularSpeedGradient = x),
_.angularSpeed = Scalar.Lerp(_._currentAngularSpeed1, _._currentAngularSpeed2, w)
}),
_.angle += _.angularSpeed * m;
var C = m;
if (l._velocityGradients && l._velocityGradients.length > 0 && GradientHelper.GetCurrentGradient(T, l._velocityGradients, function(x, I, w) {
x !== _._currentVelocityGradient && (_._currentVelocity1 = _._currentVelocity2,
_._currentVelocity2 = I.getFactor(),
_._currentVelocityGradient = x),
C *= Scalar.Lerp(_._currentVelocity1, _._currentVelocity2, w)
}),
_.direction.scaleToRef(C, l._scaledDirection),
l._limitVelocityGradients && l._limitVelocityGradients.length > 0 && GradientHelper.GetCurrentGradient(T, l._limitVelocityGradients, function(x, I, w) {
x !== _._currentLimitVelocityGradient && (_._currentLimitVelocity1 = _._currentLimitVelocity2,
_._currentLimitVelocity2 = I.getFactor(),
_._currentLimitVelocityGradient = x);
var O = Scalar.Lerp(_._currentLimitVelocity1, _._currentLimitVelocity2, w)
, D = _.direction.length();
D > O && _.direction.scaleInPlace(l.limitVelocityDamping)
}),
l._dragGradients && l._dragGradients.length > 0 && GradientHelper.GetCurrentGradient(T, l._dragGradients, function(x, I, w) {
x !== _._currentDragGradient && (_._currentDrag1 = _._currentDrag2,
_._currentDrag2 = I.getFactor(),
_._currentDragGradient = x);
var O = Scalar.Lerp(_._currentDrag1, _._currentDrag2, w);
l._scaledDirection.scaleInPlace(1 - O)
}),
l.isLocal && _._localPosition ? (_._localPosition.addInPlace(l._scaledDirection),
Vector3.TransformCoordinatesToRef(_._localPosition, l._emitterWorldMatrix, _.position)) : _.position.addInPlace(l._scaledDirection),
u && f && _._randomNoiseCoordinates1) {
var A = l._fetchR(_._randomNoiseCoordinates1.x, _._randomNoiseCoordinates1.y, f.width, f.height, u)
, S = l._fetchR(_._randomNoiseCoordinates1.z, _._randomNoiseCoordinates2.x, f.width, f.height, u)
, P = l._fetchR(_._randomNoiseCoordinates2.y, _._randomNoiseCoordinates2.z, f.width, f.height, u)
, R = TmpVectors.Vector3[0]
, M = TmpVectors.Vector3[1];
R.copyFromFloats((2 * A - 1) * l.noiseStrength.x, (2 * S - 1) * l.noiseStrength.y, (2 * P - 1) * l.noiseStrength.z),
R.scaleToRef(m, M),
_.direction.addInPlace(M)
}
if (l.gravity.scaleToRef(m, l._scaledGravity),
_.direction.addInPlace(l._scaledGravity),
l._sizeGradients && l._sizeGradients.length > 0 && GradientHelper.GetCurrentGradient(T, l._sizeGradients, function(x, I, w) {
x !== _._currentSizeGradient && (_._currentSize1 = _._currentSize2,
_._currentSize2 = I.getFactor(),
_._currentSizeGradient = x),
_.size = Scalar.Lerp(_._currentSize1, _._currentSize2, w)
}),
l._useRampGradients && (l._colorRemapGradients && l._colorRemapGradients.length > 0 && GradientHelper.GetCurrentGradient(T, l._colorRemapGradients, function(x, I, w) {
var O = Scalar.Lerp(x.factor1, I.factor1, w)
, D = Scalar.Lerp(x.factor2, I.factor2, w);
_.remapData.x = O,
_.remapData.y = D - O
}),
l._alphaRemapGradients && l._alphaRemapGradients.length > 0 && GradientHelper.GetCurrentGradient(T, l._alphaRemapGradients, function(x, I, w) {
var O = Scalar.Lerp(x.factor1, I.factor1, w)
, D = Scalar.Lerp(x.factor2, I.factor2, w);
_.remapData.z = O,
_.remapData.w = D - O
})),
l._isAnimationSheetEnabled && _.updateCellIndex(),
_._inheritParticleInfoToSubEmitters(),
_.age >= _.lifeTime)
return l._emitFromParticle(_),
_._attachedSubEmitters && (_._attachedSubEmitters.forEach(function(x) {
x.particleSystem.disposeOnStop = !0,
x.particleSystem.stop()
}),
_._attachedSubEmitters = null),
l.recycleParticle(_),
g--,
"continue"
}, _, g = 0; g < c.length; g++)
d()
}
,
l
}
return Object.defineProperty(e.prototype, "onDispose", {
set: function(t) {
this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
this._onDisposeObserver = this.onDisposeObservable.add(t)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "useRampGradients", {
get: function() {
return this._useRampGradients
},
set: function(t) {
this._useRampGradients !== t && (this._useRampGradients = t,
this._resetEffect())
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "particles", {
get: function() {
return this._particles
},
enumerable: !1,
configurable: !0
}),
e.prototype.getActiveCount = function() {
return this._particles.length
}
,
e.prototype.getClassName = function() {
return "ParticleSystem"
}
,
e.prototype.isStopping = function() {
return this._stopped && this.isAlive()
}
,
e.prototype.getCustomEffect = function(t) {
var r, n;
return t === void 0 && (t = 0),
(n = (r = this._customWrappers[t]) === null || r === void 0 ? void 0 : r.effect) !== null && n !== void 0 ? n : this._customWrappers[0].effect
}
,
e.prototype._getCustomDrawWrapper = function(t) {
var r;
return t === void 0 && (t = 0),
(r = this._customWrappers[t]) !== null && r !== void 0 ? r : this._customWrappers[0]
}
,
e.prototype.setCustomEffect = function(t, r) {
r === void 0 && (r = 0),
this._customWrappers[r] = new DrawWrapper(this._engine),
this._customWrappers[r].effect = t,
this._customWrappers[r].drawContext && (this._customWrappers[r].drawContext.useInstancing = this._useInstancing)
}
,
Object.defineProperty(e.prototype, "onBeforeDrawParticlesObservable", {
get: function() {
return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new Observable),
this._onBeforeDrawParticlesObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "vertexShaderName", {
get: function() {
return "particles"
},
enumerable: !1,
configurable: !0
}),
e.prototype._addFactorGradient = function(t, r, n, o) {
var a = new FactorGradient(r,n,o);
t.push(a),
t.sort(function(s, l) {
return s.gradient < l.gradient ? -1 : s.gradient > l.gradient ? 1 : 0
})
}
,
e.prototype._removeFactorGradient = function(t, r) {
if (!!t)
for (var n = 0, o = 0, a = t; o < a.length; o++) {
var s = a[o];
if (s.gradient === r) {
t.splice(n, 1);
break
}
n++
}
}
,
e.prototype.addLifeTimeGradient = function(t, r, n) {
return this._lifeTimeGradients || (this._lifeTimeGradients = []),
this._addFactorGradient(this._lifeTimeGradients, t, r, n),
this
}
,
e.prototype.removeLifeTimeGradient = function(t) {
return this._removeFactorGradient(this._lifeTimeGradients, t),
this
}
,
e.prototype.addSizeGradient = function(t, r, n) {
return this._sizeGradients || (this._sizeGradients = []),
this._addFactorGradient(this._sizeGradients, t, r, n),
this
}
,
e.prototype.removeSizeGradient = function(t) {
return this._removeFactorGradient(this._sizeGradients, t),
this
}
,
e.prototype.addColorRemapGradient = function(t, r, n) {
return this._colorRemapGradients || (this._colorRemapGradients = []),
this._addFactorGradient(this._colorRemapGradients, t, r, n),
this
}
,
e.prototype.removeColorRemapGradient = function(t) {
return this._removeFactorGradient(this._colorRemapGradients, t),
this
}
,
e.prototype.addAlphaRemapGradient = function(t, r, n) {
return this._alphaRemapGradients || (this._alphaRemapGradients = []),
this._addFactorGradient(this._alphaRemapGradients, t, r, n),
this
}
,
e.prototype.removeAlphaRemapGradient = function(t) {
return this._removeFactorGradient(this._alphaRemapGradients, t),
this
}
,
e.prototype.addAngularSpeedGradient = function(t, r, n) {
return this._angularSpeedGradients || (this._angularSpeedGradients = []),
this._addFactorGradient(this._angularSpeedGradients, t, r, n),
this
}
,
e.prototype.removeAngularSpeedGradient = function(t) {
return this._removeFactorGradient(this._angularSpeedGradients, t),
this
}
,
e.prototype.addVelocityGradient = function(t, r, n) {
return this._velocityGradients || (this._velocityGradients = []),
this._addFactorGradient(this._velocityGradients, t, r, n),
this
}
,
e.prototype.removeVelocityGradient = function(t) {
return this._removeFactorGradient(this._velocityGradients, t),
this
}
,
e.prototype.addLimitVelocityGradient = function(t, r, n) {
return this._limitVelocityGradients || (this._limitVelocityGradients = []),
this._addFactorGradient(this._limitVelocityGradients, t, r, n),
this
}
,
e.prototype.removeLimitVelocityGradient = function(t) {
return this._removeFactorGradient(this._limitVelocityGradients, t),
this
}
,
e.prototype.addDragGradient = function(t, r, n) {
return this._dragGradients || (this._dragGradients = []),
this._addFactorGradient(this._dragGradients, t, r, n),
this
}
,
e.prototype.removeDragGradient = function(t) {
return this._removeFactorGradient(this._dragGradients, t),
this
}
,
e.prototype.addEmitRateGradient = function(t, r, n) {
return this._emitRateGradients || (this._emitRateGradients = []),
this._addFactorGradient(this._emitRateGradients, t, r, n),
this
}
,
e.prototype.removeEmitRateGradient = function(t) {
return this._removeFactorGradient(this._emitRateGradients, t),
this
}
,
e.prototype.addStartSizeGradient = function(t, r, n) {
return this._startSizeGradients || (this._startSizeGradients = []),
this._addFactorGradient(this._startSizeGradients, t, r, n),
this
}
,
e.prototype.removeStartSizeGradient = function(t) {
return this._removeFactorGradient(this._startSizeGradients, t),
this
}
,
e.prototype._createRampGradientTexture = function() {
if (!(!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture || !this._scene)) {
for (var t = new Uint8Array(this._rawTextureWidth * 4), r = TmpColors.Color3[0], n = 0; n < this._rawTextureWidth; n++) {
var o = n / this._rawTextureWidth;
GradientHelper.GetCurrentGradient(o, this._rampGradients, function(a, s, l) {
Color3.LerpToRef(a.color, s.color, l, r),
t[n * 4] = r.r * 255,
t[n * 4 + 1] = r.g * 255,
t[n * 4 + 2] = r.b * 255,
t[n * 4 + 3] = 255
})
}
this._rampGradientsTexture = RawTexture.CreateRGBATexture(t, this._rawTextureWidth, 1, this._scene, !1, !1, 1)
}
}
,
e.prototype.getRampGradients = function() {
return this._rampGradients
}
,
e.prototype.forceRefreshGradients = function() {
this._syncRampGradientTexture()
}
,
e.prototype._syncRampGradientTexture = function() {
!this._rampGradients || (this._rampGradients.sort(function(t, r) {
return t.gradient < r.gradient ? -1 : t.gradient > r.gradient ? 1 : 0
}),
this._rampGradientsTexture && (this._rampGradientsTexture.dispose(),
this._rampGradientsTexture = null),
this._createRampGradientTexture())
}
,
e.prototype.addRampGradient = function(t, r) {
this._rampGradients || (this._rampGradients = []);
var n = new Color3Gradient(t,r);
return this._rampGradients.push(n),
this._syncRampGradientTexture(),
this
}
,
e.prototype.removeRampGradient = function(t) {
return this._removeGradientAndTexture(t, this._rampGradients, this._rampGradientsTexture),
this._rampGradientsTexture = null,
this._rampGradients && this._rampGradients.length > 0 && this._createRampGradientTexture(),
this
}
,
e.prototype.addColorGradient = function(t, r, n) {
this._colorGradients || (this._colorGradients = []);
var o = new ColorGradient(t,r,n);
return this._colorGradients.push(o),
this._colorGradients.sort(function(a, s) {
return a.gradient < s.gradient ? -1 : a.gradient > s.gradient ? 1 : 0
}),
this
}
,
e.prototype.removeColorGradient = function(t) {
if (!this._colorGradients)
return this;
for (var r = 0, n = 0, o = this._colorGradients; n < o.length; n++) {
var a = o[n];
if (a.gradient === t) {
this._colorGradients.splice(r, 1);
break
}
r++
}
return this
}
,
e.prototype.resetDrawCache = function() {
for (var t = 0, r = this._drawWrappers; t < r.length; t++) {
var n = r[t];
if (n)
for (var o = 0, a = n; o < a.length; o++) {
var s = a[o];
s == null || s.dispose()
}
}
this._drawWrappers = []
}
,
e.prototype._fetchR = function(t, r, n, o, a) {
t = Math.abs(t) * .5 + .5,
r = Math.abs(r) * .5 + .5;
var s = t * n % n | 0
, l = r * o % o | 0
, u = (s + l * n) * 4;
return a[u] / 255
}
,
e.prototype._reset = function() {
this._resetEffect()
}
,
e.prototype._resetEffect = function() {
this._vertexBuffer && (this._vertexBuffer.dispose(),
this._vertexBuffer = null),
this._spriteBuffer && (this._spriteBuffer.dispose(),
this._spriteBuffer = null),
this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
this._vertexArrayObject = null),
this._createVertexBuffers()
}
,
e.prototype._createVertexBuffers = function() {
this._vertexBufferSize = this._useInstancing ? 10 : 12,
this._isAnimationSheetEnabled && (this._vertexBufferSize += 1),
(!this._isBillboardBased || this.billboardMode === e.BILLBOARDMODE_STRETCHED) && (this._vertexBufferSize += 3),
this._useRampGradients && (this._vertexBufferSize += 4);
var t = this._engine;
this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4)),
this._vertexBuffer = new Buffer(t,this._vertexData,!0,this._vertexBufferSize);
var r = 0
, n = this._vertexBuffer.createVertexBuffer(VertexBuffer.PositionKind, r, 3, this._vertexBufferSize, this._useInstancing);
this._vertexBuffers[VertexBuffer.PositionKind] = n,
r += 3;
var o = this._vertexBuffer.createVertexBuffer(VertexBuffer.ColorKind, r, 4, this._vertexBufferSize, this._useInstancing);
this._vertexBuffers[VertexBuffer.ColorKind] = o,
r += 4;
var a = this._vertexBuffer.createVertexBuffer("angle", r, 1, this._vertexBufferSize, this._useInstancing);
this._vertexBuffers.angle = a,
r += 1;
var s = this._vertexBuffer.createVertexBuffer("size", r, 2, this._vertexBufferSize, this._useInstancing);
if (this._vertexBuffers.size = s,
r += 2,
this._isAnimationSheetEnabled) {
var l = this._vertexBuffer.createVertexBuffer("cellIndex", r, 1, this._vertexBufferSize, this._useInstancing);
this._vertexBuffers.cellIndex = l,
r += 1
}
if (!this._isBillboardBased || this.billboardMode === e.BILLBOARDMODE_STRETCHED) {
var u = this._vertexBuffer.createVertexBuffer("direction", r, 3, this._vertexBufferSize, this._useInstancing);
this._vertexBuffers.direction = u,
r += 3
}
if (this._useRampGradients) {
var c = this._vertexBuffer.createVertexBuffer("remapData", r, 4, this._vertexBufferSize, this._useInstancing);
this._vertexBuffers.remapData = c,
r += 4
}
var h;
if (this._useInstancing) {
var f = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
this._spriteBuffer = new Buffer(t,f,!1,2),
h = this._spriteBuffer.createVertexBuffer("offset", 0, 2)
} else
h = this._vertexBuffer.createVertexBuffer("offset", r, 2, this._vertexBufferSize, this._useInstancing),
r += 2;
this._vertexBuffers.offset = h,
this.resetDrawCache()
}
,
e.prototype._createIndexBuffer = function() {
if (!this._useInstancing) {
for (var t = [], r = 0, n = 0; n < this._capacity; n++)
t.push(r),
t.push(r + 1),
t.push(r + 2),
t.push(r),
t.push(r + 2),
t.push(r + 3),
r += 4;
this._indexBuffer = this._engine.createIndexBuffer(t)
}
}
,
e.prototype.getCapacity = function() {
return this._capacity
}
,
e.prototype.isAlive = function() {
return this._alive
}
,
e.prototype.isStarted = function() {
return this._started
}
,
e.prototype._prepareSubEmitterInternalArray = function() {
var t = this;
this._subEmitters = new Array,
this.subEmitters && this.subEmitters.forEach(function(r) {
r instanceof e ? t._subEmitters.push([new SubEmitter(r)]) : r instanceof SubEmitter ? t._subEmitters.push([r]) : r instanceof Array && t._subEmitters.push(r)
})
}
,
e.prototype.start = function(t) {
var r = this, n;
if (t === void 0 && (t = this.startDelay),
!this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
if (t) {
setTimeout(function() {
r.start(0)
}, t);
return
}
if (this._prepareSubEmitterInternalArray(),
this._started = !0,
this._stopped = !1,
this._actualFrame = 0,
this._subEmitters && this._subEmitters.length != 0 && (this.activeSubSystems = new Array),
this._emitRateGradients && (this._emitRateGradients.length > 0 && (this._currentEmitRateGradient = this._emitRateGradients[0],
this._currentEmitRate1 = this._currentEmitRateGradient.getFactor(),
this._currentEmitRate2 = this._currentEmitRate1),
this._emitRateGradients.length > 1 && (this._currentEmitRate2 = this._emitRateGradients[1].getFactor())),
this._startSizeGradients && (this._startSizeGradients.length > 0 && (this._currentStartSizeGradient = this._startSizeGradients[0],
this._currentStartSize1 = this._currentStartSizeGradient.getFactor(),
this._currentStartSize2 = this._currentStartSize1),
this._startSizeGradients.length > 1 && (this._currentStartSize2 = this._startSizeGradients[1].getFactor())),
this.preWarmCycles) {
((n = this.emitter) === null || n === void 0 ? void 0 : n.getClassName().indexOf("Mesh")) !== -1 && this.emitter.computeWorldMatrix(!0);
var o = this.noiseTexture;
if (o && o.onGeneratedObservable)
o.onGeneratedObservable.addOnce(function() {
setTimeout(function() {
for (var s = 0; s < r.preWarmCycles; s++)
r.animate(!0),
o.render()
})
});
else
for (var a = 0; a < this.preWarmCycles; a++)
this.animate(!0)
}
this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop)
}
,
e.prototype.stop = function(t) {
t === void 0 && (t = !0),
!this._stopped && (this.onStoppedObservable.notifyObservers(this),
this._stopped = !0,
t && this._stopSubEmitters())
}
,
e.prototype.reset = function() {
this._stockParticles = [],
this._particles = []
}
,
e.prototype._appendParticleVertex = function(t, r, n, o) {
var a = t * this._vertexBufferSize;
if (this._vertexData[a++] = r.position.x + this.worldOffset.x,
this._vertexData[a++] = r.position.y + this.worldOffset.y,
this._vertexData[a++] = r.position.z + this.worldOffset.z,
this._vertexData[a++] = r.color.r,
this._vertexData[a++] = r.color.g,
this._vertexData[a++] = r.color.b,
this._vertexData[a++] = r.color.a,
this._vertexData[a++] = r.angle,
this._vertexData[a++] = r.scale.x * r.size,
this._vertexData[a++] = r.scale.y * r.size,
this._isAnimationSheetEnabled && (this._vertexData[a++] = r.cellIndex),
this._isBillboardBased)
this.billboardMode === e.BILLBOARDMODE_STRETCHED && (this._vertexData[a++] = r.direction.x,
this._vertexData[a++] = r.direction.y,
this._vertexData[a++] = r.direction.z);
else if (r._initialDirection) {
var s = r._initialDirection;
this.isLocal && (Vector3.TransformNormalToRef(s, this._emitterWorldMatrix, TmpVectors.Vector3[0]),
s = TmpVectors.Vector3[0]),
s.x === 0 && s.z === 0 && (s.x = .001),
this._vertexData[a++] = s.x,
this._vertexData[a++] = s.y,
this._vertexData[a++] = s.z
} else {
var l = r.direction;
this.isLocal && (Vector3.TransformNormalToRef(l, this._emitterWorldMatrix, TmpVectors.Vector3[0]),
l = TmpVectors.Vector3[0]),
l.x === 0 && l.z === 0 && (l.x = .001),
this._vertexData[a++] = l.x,
this._vertexData[a++] = l.y,
this._vertexData[a++] = l.z
}
this._useRampGradients && r.remapData && (this._vertexData[a++] = r.remapData.x,
this._vertexData[a++] = r.remapData.y,
this._vertexData[a++] = r.remapData.z,
this._vertexData[a++] = r.remapData.w),
this._useInstancing || (this._isAnimationSheetEnabled && (n === 0 ? n = this._epsilon : n === 1 && (n = 1 - this._epsilon),
o === 0 ? o = this._epsilon : o === 1 && (o = 1 - this._epsilon)),
this._vertexData[a++] = n,
this._vertexData[a++] = o)
}
,
e.prototype._stopSubEmitters = function() {
!this.activeSubSystems || (this.activeSubSystems.forEach(function(t) {
t.stop(!0)
}),
this.activeSubSystems = new Array)
}
,
e.prototype._removeFromRoot = function() {
if (!!this._rootParticleSystem) {
var t = this._rootParticleSystem.activeSubSystems.indexOf(this);
t !== -1 && this._rootParticleSystem.activeSubSystems.splice(t, 1),
this._rootParticleSystem = null
}
}
,
e.prototype._update = function(t) {
var r = this;
if (this._alive = this._particles.length > 0,
this.emitter.position) {
var n = this.emitter;
this._emitterWorldMatrix = n.getWorldMatrix()
} else {
var o = this.emitter;
this._emitterWorldMatrix = Matrix.Translation(o.x, o.y, o.z)
}
this._emitterWorldMatrix.invertToRef(this._emitterInverseWorldMatrix),
this.updateFunction(this._particles);
for (var a, s = function() {
if (l._particles.length === l._capacity)
return "break";
if (a = l._createParticle(),
l._particles.push(a),
l.targetStopDuration && l._lifeTimeGradients && l._lifeTimeGradients.length > 0) {
var f = Scalar.Clamp(l._actualFrame / l.targetStopDuration);
GradientHelper.GetCurrentGradient(f, l._lifeTimeGradients, function(g, m) {
var v = g
, y = m
, b = v.getFactor()
, T = y.getFactor()
, C = (f - v.gradient) / (y.gradient - v.gradient);
a.lifeTime = Scalar.Lerp(b, T, C)
})
} else
a.lifeTime = Scalar.RandomRange(l.minLifeTime, l.maxLifeTime);
var d = Scalar.RandomRange(l.minEmitPower, l.maxEmitPower);
if (l.startPositionFunction ? l.startPositionFunction(l._emitterWorldMatrix, a.position, a, l.isLocal) : l.particleEmitterType.startPositionFunction(l._emitterWorldMatrix, a.position, a, l.isLocal),
l.isLocal && (a._localPosition ? a._localPosition.copyFrom(a.position) : a._localPosition = a.position.clone(),
Vector3.TransformCoordinatesToRef(a._localPosition, l._emitterWorldMatrix, a.position)),
l.startDirectionFunction ? l.startDirectionFunction(l._emitterWorldMatrix, a.direction, a, l.isLocal) : l.particleEmitterType.startDirectionFunction(l._emitterWorldMatrix, a.direction, a, l.isLocal, l._emitterInverseWorldMatrix),
d === 0 ? a._initialDirection ? a._initialDirection.copyFrom(a.direction) : a._initialDirection = a.direction.clone() : a._initialDirection = null,
a.direction.scaleInPlace(d),
!l._sizeGradients || l._sizeGradients.length === 0 ? a.size = Scalar.RandomRange(l.minSize, l.maxSize) : (a._currentSizeGradient = l._sizeGradients[0],
a._currentSize1 = a._currentSizeGradient.getFactor(),
a.size = a._currentSize1,
l._sizeGradients.length > 1 ? a._currentSize2 = l._sizeGradients[1].getFactor() : a._currentSize2 = a._currentSize1),
a.scale.copyFromFloats(Scalar.RandomRange(l.minScaleX, l.maxScaleX), Scalar.RandomRange(l.minScaleY, l.maxScaleY)),
l._startSizeGradients && l._startSizeGradients[0] && l.targetStopDuration) {
var _ = l._actualFrame / l.targetStopDuration;
GradientHelper.GetCurrentGradient(_, l._startSizeGradients, function(g, m, v) {
g !== r._currentStartSizeGradient && (r._currentStartSize1 = r._currentStartSize2,
r._currentStartSize2 = m.getFactor(),
r._currentStartSizeGradient = g);
var y = Scalar.Lerp(r._currentStartSize1, r._currentStartSize2, v);
a.scale.scaleInPlace(y)
})
}
!l._angularSpeedGradients || l._angularSpeedGradients.length === 0 ? a.angularSpeed = Scalar.RandomRange(l.minAngularSpeed, l.maxAngularSpeed) : (a._currentAngularSpeedGradient = l._angularSpeedGradients[0],
a.angularSpeed = a._currentAngularSpeedGradient.getFactor(),
a._currentAngularSpeed1 = a.angularSpeed,
l._angularSpeedGradients.length > 1 ? a._currentAngularSpeed2 = l._angularSpeedGradients[1].getFactor() : a._currentAngularSpeed2 = a._currentAngularSpeed1),
a.angle = Scalar.RandomRange(l.minInitialRotation, l.maxInitialRotation),
l._velocityGradients && l._velocityGradients.length > 0 && (a._currentVelocityGradient = l._velocityGradients[0],
a._currentVelocity1 = a._currentVelocityGradient.getFactor(),
l._velocityGradients.length > 1 ? a._currentVelocity2 = l._velocityGradients[1].getFactor() : a._currentVelocity2 = a._currentVelocity1),
l._limitVelocityGradients && l._limitVelocityGradients.length > 0 && (a._currentLimitVelocityGradient = l._limitVelocityGradients[0],
a._currentLimitVelocity1 = a._currentLimitVelocityGradient.getFactor(),
l._limitVelocityGradients.length > 1 ? a._currentLimitVelocity2 = l._limitVelocityGradients[1].getFactor() : a._currentLimitVelocity2 = a._currentLimitVelocity1),
l._dragGradients && l._dragGradients.length > 0 && (a._currentDragGradient = l._dragGradients[0],
a._currentDrag1 = a._currentDragGradient.getFactor(),
l._dragGradients.length > 1 ? a._currentDrag2 = l._dragGradients[1].getFactor() : a._currentDrag2 = a._currentDrag1),
!l._colorGradients || l._colorGradients.length === 0 ? (u = Scalar.RandomRange(0, 1),
Color4.LerpToRef(l.color1, l.color2, u, a.color),
l.colorDead.subtractToRef(a.color, l._colorDiff),
l._colorDiff.scaleToRef(1 / a.lifeTime, a.colorStep)) : (a._currentColorGradient = l._colorGradients[0],
a._currentColorGradient.getColorToRef(a.color),
a._currentColor1.copyFrom(a.color),
l._colorGradients.length > 1 ? l._colorGradients[1].getColorToRef(a._currentColor2) : a._currentColor2.copyFrom(a.color)),
l._isAnimationSheetEnabled && (a._initialStartSpriteCellID = l.startSpriteCellID,
a._initialEndSpriteCellID = l.endSpriteCellID,
a._initialSpriteCellLoop = l.spriteCellLoop),
a.direction.addInPlace(l._inheritedVelocityOffset),
l._useRampGradients && (a.remapData = new Vector4(0,1,0,1)),
l.noiseTexture && (a._randomNoiseCoordinates1 ? (a._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random()),
a._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random())) : (a._randomNoiseCoordinates1 = new Vector3(Math.random(),Math.random(),Math.random()),
a._randomNoiseCoordinates2 = new Vector3(Math.random(),Math.random(),Math.random()))),
a._inheritParticleInfoToSubEmitters()
}, l = this, u, c = 0; c < t; c++) {
var h = s();
if (h === "break")
break
}
}
,
e._GetAttributeNamesOrOptions = function(t, r, n) {
t === void 0 && (t = !1),
r === void 0 && (r = !1),
n === void 0 && (n = !1);
var o = [VertexBuffer.PositionKind, VertexBuffer.ColorKind, "angle", "offset", "size"];
return t && o.push("cellIndex"),
r || o.push("direction"),
n && o.push("remapData"),
o
}
,
e._GetEffectCreationOptions = function(t) {
t === void 0 && (t = !1);
var r = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMask", "translationPivot", "eyePosition"];
return t && r.push("particlesInfos"),
r
}
,
e.prototype.fillDefines = function(t, r) {
if (this._scene && (this._scene.clipPlane && t.push("#define CLIPPLANE"),
this._scene.clipPlane2 && t.push("#define CLIPPLANE2"),
this._scene.clipPlane3 && t.push("#define CLIPPLANE3"),
this._scene.clipPlane4 && t.push("#define CLIPPLANE4"),
this._scene.clipPlane5 && t.push("#define CLIPPLANE5"),
this._scene.clipPlane6 && t.push("#define CLIPPLANE6")),
this._isAnimationSheetEnabled && t.push("#define ANIMATESHEET"),
r === e.BLENDMODE_MULTIPLY && t.push("#define BLENDMULTIPLYMODE"),
this._useRampGradients && t.push("#define RAMPGRADIENT"),
this._isBillboardBased)
switch (t.push("#define BILLBOARD"),
this.billboardMode) {
case e.BILLBOARDMODE_Y:
t.push("#define BILLBOARDY");
break;
case e.BILLBOARDMODE_STRETCHED:
t.push("#define BILLBOARDSTRETCHED");
break;
case e.BILLBOARDMODE_ALL:
t.push("#define BILLBOARDMODE_ALL");
break
}
this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
t.push(this._imageProcessingConfigurationDefines.toString()))
}
,
e.prototype.fillUniformsAttributesAndSamplerNames = function(t, r, n) {
r.push.apply(r, e._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== e.BILLBOARDMODE_STRETCHED, this._useRampGradients)),
t.push.apply(t, e._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
n.push("diffuseSampler", "rampSampler"),
this._imageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(t, this._imageProcessingConfigurationDefines),
ImageProcessingConfiguration.PrepareSamplers(n, this._imageProcessingConfigurationDefines))
}
,
e.prototype._getWrapper = function(t) {
var r = this._getCustomDrawWrapper(t);
if (r != null && r.effect)
return r;
var n = [];
this.fillDefines(n, t);
var o = this._engine._features.supportRenderPasses ? this._engine.currentRenderPassId : 0
, a = this._drawWrappers[o];
a || (a = this._drawWrappers[o] = []);
var s = a[t];
s || (s = new DrawWrapper(this._engine),
s.drawContext && (s.drawContext.useInstancing = this._useInstancing),
a[t] = s);
var l = n.join(`
`);
if (s.defines !== l) {
var u = []
, c = []
, h = [];
this.fillUniformsAttributesAndSamplerNames(c, u, h),
s.setEffect(this._engine.createEffect("particles", u, c, h, l), l)
}
return s
}
,
e.prototype.animate = function(t) {
var r = this, n;
if (t === void 0 && (t = !1),
!!this._started) {
if (!t && this._scene) {
if (!this.isReady() || this._currentRenderId === this._scene.getFrameId())
return;
this._currentRenderId = this._scene.getFrameId()
}
this._scaledUpdateSpeed = this.updateSpeed * (t ? this.preWarmStepOffset : ((n = this._scene) === null || n === void 0 ? void 0 : n.getAnimationRatio()) || 1);
var o;
if (this.manualEmitCount > -1)
o = this.manualEmitCount,
this._newPartsExcess = 0,
this.manualEmitCount = 0;
else {
var a = this.emitRate;
if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
var s = this._actualFrame / this.targetStopDuration;
GradientHelper.GetCurrentGradient(s, this._emitRateGradients, function(h, f, d) {
h !== r._currentEmitRateGradient && (r._currentEmitRate1 = r._currentEmitRate2,
r._currentEmitRate2 = f.getFactor(),
r._currentEmitRateGradient = h),
a = Scalar.Lerp(r._currentEmitRate1, r._currentEmitRate2, d)
})
}
o = a * this._scaledUpdateSpeed >> 0,
this._newPartsExcess += a * this._scaledUpdateSpeed - o
}
if (this._newPartsExcess > 1 && (o += this._newPartsExcess >> 0,
this._newPartsExcess -= this._newPartsExcess >> 0),
this._alive = !1,
this._stopped ? o = 0 : (this._actualFrame += this._scaledUpdateSpeed,
this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()),
this._update(o),
this._stopped && (this._alive || (this._started = !1,
this.onAnimationEnd && this.onAnimationEnd(),
this.disposeOnStop && this._scene && this._scene._toBeDisposed.push(this))),
!t) {
for (var l = 0, u = 0; u < this._particles.length; u++) {
var c = this._particles[u];
this._appendParticleVertices(l, c),
l += this._useInstancing ? 1 : 4
}
this._vertexBuffer && this._vertexBuffer.updateDirectly(this._vertexData, 0, this._particles.length)
}
this.manualEmitCount === 0 && this.disposeOnStop && this.stop()
}
}
,
e.prototype._appendParticleVertices = function(t, r) {
this._appendParticleVertex(t++, r, 0, 0),
this._useInstancing || (this._appendParticleVertex(t++, r, 1, 0),
this._appendParticleVertex(t++, r, 1, 1),
this._appendParticleVertex(t++, r, 0, 1))
}
,
e.prototype.rebuild = function() {
var t, r;
this._engine.getCaps().vertexArrayObject && (this._vertexArrayObject = null),
this._createIndexBuffer(),
(t = this._spriteBuffer) === null || t === void 0 || t._rebuild(),
(r = this._vertexBuffer) === null || r === void 0 || r._rebuild();
for (var n in this._vertexBuffers)
this._vertexBuffers[n]._rebuild();
this.resetDrawCache()
}
,
e.prototype.isReady = function() {
if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
return !1;
if (this.blendMode !== e.BLENDMODE_MULTIPLYADD) {
if (!this._getWrapper(this.blendMode).effect.isReady())
return !1
} else if (!this._getWrapper(e.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(e.BLENDMODE_ADD).effect.isReady())
return !1;
return !0
}
,
e.prototype._render = function(t) {
var r, n, o = this._getWrapper(t), a = o.effect, s = this._engine;
s.enableEffect(o);
var l = (r = this.defaultViewMatrix) !== null && r !== void 0 ? r : this._scene.getViewMatrix();
if (a.setTexture("diffuseSampler", this.particleTexture),
a.setMatrix("view", l),
a.setMatrix("projection", (n = this.defaultProjectionMatrix) !== null && n !== void 0 ? n : this._scene.getProjectionMatrix()),
this._isAnimationSheetEnabled && this.particleTexture) {
var u = this.particleTexture.getBaseSize();
a.setFloat3("particlesInfos", this.spriteCellWidth / u.width, this.spriteCellHeight / u.height, this.spriteCellWidth / u.width)
}
if (a.setVector2("translationPivot", this.translationPivot),
a.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a),
this._isBillboardBased && this._scene) {
var c = this._scene.activeCamera;
a.setVector3("eyePosition", c.globalPosition)
}
this._rampGradientsTexture && ((!this._rampGradients || !this._rampGradients.length) && (this._rampGradientsTexture.dispose(),
this._rampGradientsTexture = null),
a.setTexture("rampSampler", this._rampGradientsTexture));
var h = a.defines;
switch (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && ThinMaterialHelper.BindClipPlane(a, this._scene),
h.indexOf("#define BILLBOARDMODE_ALL") >= 0 && (l.invertToRef(TmpVectors.Matrix[0]),
a.setMatrix("invView", TmpVectors.Matrix[0])),
this._vertexArrayObject !== void 0 ? (this._vertexArrayObject || (this._vertexArrayObject = this._engine.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, a)),
this._engine.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : s.bindBuffers(this._vertexBuffers, this._indexBuffer, a),
this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(a),
t) {
case e.BLENDMODE_ADD:
s.setAlphaMode(1);
break;
case e.BLENDMODE_ONEONE:
s.setAlphaMode(6);
break;
case e.BLENDMODE_STANDARD:
s.setAlphaMode(2);
break;
case e.BLENDMODE_MULTIPLY:
s.setAlphaMode(4);
break
}
return this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(a),
this._useInstancing ? s.drawArraysType(7, 0, 4, this._particles.length) : s.drawElementsType(0, 0, this._particles.length * 6),
this._particles.length
}
,
e.prototype.render = function() {
if (!this.isReady() || !this._particles.length)
return 0;
var t = this._engine;
t.setState && (t.setState(!1),
this.forceDepthWrite && t.setDepthWrite(!0));
var r = 0;
return this.blendMode === e.BLENDMODE_MULTIPLYADD ? r = this._render(e.BLENDMODE_MULTIPLY) + this._render(e.BLENDMODE_ADD) : r = this._render(this.blendMode),
this._engine.unbindInstanceAttributes(),
this._engine.setAlphaMode(0),
r
}
,
e.prototype.dispose = function(t) {
if (t === void 0 && (t = !0),
this.resetDrawCache(),
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),
t && this.particleTexture && (this.particleTexture.dispose(),
this.particleTexture = null),
t && 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 r = 0; r < this._subEmitters.length; r++)
for (var n = 0, o = this._subEmitters[r]; n < o.length; n++) {
var a = o[n];
a.dispose()
}
this._subEmitters = [],
this.subEmitters = []
}
if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose && this.emitter.dispose(!0),
this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.clear(),
this._scene) {
var r = this._scene.particleSystems.indexOf(this);
r > -1 && this._scene.particleSystems.splice(r, 1),
this._scene._activeParticleSystems.dispose()
}
this.onDisposeObservable.notifyObservers(this),
this.onDisposeObservable.clear(),
this.onStoppedObservable.clear(),
this.reset()
}
,
e.prototype.clone = function(t, r) {
var n = __assign({}, this._customWrappers)
, o = null
, a = this._engine;
if (a.createEffectForParticles && this.customShader != null) {
o = this.customShader;
var s = o.shaderOptions.defines.length > 0 ? o.shaderOptions.defines.join(`
`) : "";
n[0] = a.createEffectForParticles(o.shaderPath.fragmentElement, o.shaderOptions.uniforms, o.shaderOptions.samplers, s)
}
var l = this.serialize()
, u = e.Parse(l, this._scene || this._engine, this._rootUrl);
return u.name = t,
u.customShader = o,
u._customWrappers = n,
r === void 0 && (r = this.emitter),
this.noiseTexture && (u.noiseTexture = this.noiseTexture.clone()),
u.emitter = r,
this.preventAutoStart || u.start(),
u
}
,
e.prototype.serialize = function(t) {
t === void 0 && (t = !1);
var r = {};
if (e._Serialize(r, this, t),
r.textureMask = this.textureMask.asArray(),
r.customShader = this.customShader,
r.preventAutoStart = this.preventAutoStart,
this.subEmitters) {
r.subEmitters = [],
this._subEmitters || this._prepareSubEmitterInternalArray();
for (var n = 0, o = this._subEmitters; n < o.length; n++) {
for (var a = o[n], s = [], l = 0, u = a; l < u.length; l++) {
var c = u[l];
s.push(c.serialize(t))
}
r.subEmitters.push(s)
}
}
return r
}
,
e._Serialize = function(t, r, n) {
if (t.name = r.name,
t.id = r.id,
t.capacity = r.getCapacity(),
t.disposeOnStop = r.disposeOnStop,
t.manualEmitCount = r.manualEmitCount,
r.emitter.position) {
var o = r.emitter;
t.emitterId = o.id
} else {
var a = r.emitter;
t.emitter = a.asArray()
}
r.particleEmitterType && (t.particleEmitterType = r.particleEmitterType.serialize()),
r.particleTexture && (n ? t.texture = r.particleTexture.serialize() : (t.textureName = r.particleTexture.name,
t.invertY = !!r.particleTexture._invertY)),
t.isLocal = r.isLocal,
SerializationHelper.AppendSerializedAnimations(r, t),
t.beginAnimationOnStart = r.beginAnimationOnStart,
t.beginAnimationFrom = r.beginAnimationFrom,
t.beginAnimationTo = r.beginAnimationTo,
t.beginAnimationLoop = r.beginAnimationLoop,
t.startDelay = r.startDelay,
t.renderingGroupId = r.renderingGroupId,
t.isBillboardBased = r.isBillboardBased,
t.billboardMode = r.billboardMode,
t.minAngularSpeed = r.minAngularSpeed,
t.maxAngularSpeed = r.maxAngularSpeed,
t.minSize = r.minSize,
t.maxSize = r.maxSize,
t.minScaleX = r.minScaleX,
t.maxScaleX = r.maxScaleX,
t.minScaleY = r.minScaleY,
t.maxScaleY = r.maxScaleY,
t.minEmitPower = r.minEmitPower,
t.maxEmitPower = r.maxEmitPower,
t.minLifeTime = r.minLifeTime,
t.maxLifeTime = r.maxLifeTime,
t.emitRate = r.emitRate,
t.gravity = r.gravity.asArray(),
t.noiseStrength = r.noiseStrength.asArray(),
t.color1 = r.color1.asArray(),
t.color2 = r.color2.asArray(),
t.colorDead = r.colorDead.asArray(),
t.updateSpeed = r.updateSpeed,
t.targetStopDuration = r.targetStopDuration,
t.blendMode = r.blendMode,
t.preWarmCycles = r.preWarmCycles,
t.preWarmStepOffset = r.preWarmStepOffset,
t.minInitialRotation = r.minInitialRotation,
t.maxInitialRotation = r.maxInitialRotation,
t.startSpriteCellID = r.startSpriteCellID,
t.spriteCellLoop = r.spriteCellLoop,
t.endSpriteCellID = r.endSpriteCellID,
t.spriteCellChangeSpeed = r.spriteCellChangeSpeed,
t.spriteCellWidth = r.spriteCellWidth,
t.spriteCellHeight = r.spriteCellHeight,
t.spriteRandomStartCell = r.spriteRandomStartCell,
t.isAnimationSheetEnabled = r.isAnimationSheetEnabled;
var s = r.getColorGradients();
if (s) {
t.colorGradients = [];
for (var l = 0, u = s; l < u.length; l++) {
var c = u[l]
, h = {
gradient: c.gradient,
color1: c.color1.asArray()
};
c.color2 ? h.color2 = c.color2.asArray() : h.color2 = c.color1.asArray(),
t.colorGradients.push(h)
}
}
var f = r.getRampGradients();
if (f) {
t.rampGradients = [];
for (var d = 0, _ = f; d < _.length; d++) {
var g = _[d]
, h = {
gradient: g.gradient,
color: g.color.asArray()
};
t.rampGradients.push(h)
}
t.useRampGradients = r.useRampGradients
}
var m = r.getColorRemapGradients();
if (m) {
t.colorRemapGradients = [];
for (var v = 0, y = m; v < y.length; v++) {
var b = y[v]
, h = {
gradient: b.gradient,
factor1: b.factor1
};
b.factor2 !== void 0 ? h.factor2 = b.factor2 : h.factor2 = b.factor1,
t.colorRemapGradients.push(h)
}
}
var T = r.getAlphaRemapGradients();
if (T) {
t.alphaRemapGradients = [];
for (var C = 0, A = T; C < A.length; C++) {
var S = A[C]
, h = {
gradient: S.gradient,
factor1: S.factor1
};
S.factor2 !== void 0 ? h.factor2 = S.factor2 : h.factor2 = S.factor1,
t.alphaRemapGradients.push(h)
}
}
var P = r.getSizeGradients();
if (P) {
t.sizeGradients = [];
for (var R = 0, M = P; R < M.length; R++) {
var x = M[R]
, h = {
gradient: x.gradient,
factor1: x.factor1
};
x.factor2 !== void 0 ? h.factor2 = x.factor2 : h.factor2 = x.factor1,
t.sizeGradients.push(h)
}
}
var I = r.getAngularSpeedGradients();
if (I) {
t.angularSpeedGradients = [];
for (var w = 0, O = I; w < O.length; w++) {
var D = O[w]
, h = {
gradient: D.gradient,
factor1: D.factor1
};
D.factor2 !== void 0 ? h.factor2 = D.factor2 : h.factor2 = D.factor1,
t.angularSpeedGradients.push(h)
}
}
var F = r.getVelocityGradients();
if (F) {
t.velocityGradients = [];
for (var V = 0, N = F; V < N.length; V++) {
var L = N[V]
, h = {
gradient: L.gradient,
factor1: L.factor1
};
L.factor2 !== void 0 ? h.factor2 = L.factor2 : h.factor2 = L.factor1,
t.velocityGradients.push(h)
}
}
var k = r.getDragGradients();
if (k) {
t.dragGradients = [];
for (var U = 0, z = k; U < z.length; U++) {
var H = z[U]
, h = {
gradient: H.gradient,
factor1: H.factor1
};
H.factor2 !== void 0 ? h.factor2 = H.factor2 : h.factor2 = H.factor1,
t.dragGradients.push(h)
}
}
var G = r.getEmitRateGradients();
if (G) {
t.emitRateGradients = [];
for (var W = 0, j = G; W < j.length; W++) {
var B = j[W]
, h = {
gradient: B.gradient,
factor1: B.factor1
};
B.factor2 !== void 0 ? h.factor2 = B.factor2 : h.factor2 = B.factor1,
t.emitRateGradients.push(h)
}
}
var X = r.getStartSizeGradients();
if (X) {
t.startSizeGradients = [];
for (var $ = 0, Y = X; $ < Y.length; $++) {
var K = Y[$]
, h = {
gradient: K.gradient,
factor1: K.factor1
};
K.factor2 !== void 0 ? h.factor2 = K.factor2 : h.factor2 = K.factor1,
t.startSizeGradients.push(h)
}
}
var Z = r.getLifeTimeGradients();
if (Z) {
t.lifeTimeGradients = [];
for (var q = 0, J = Z; q < J.length; q++) {
var Q = J[q]
, h = {
gradient: Q.gradient,
factor1: Q.factor1
};
Q.factor2 !== void 0 ? h.factor2 = Q.factor2 : h.factor2 = Q.factor1,
t.lifeTimeGradients.push(h)
}
}
var te = r.getLimitVelocityGradients();
if (te) {
t.limitVelocityGradients = [];
for (var re = 0, ie = te; re < ie.length; re++) {
var ee = ie[re]
, h = {
gradient: ee.gradient,
factor1: ee.factor1
};
ee.factor2 !== void 0 ? h.factor2 = ee.factor2 : h.factor2 = ee.factor1,
t.limitVelocityGradients.push(h)
}
t.limitVelocityDamping = r.limitVelocityDamping
}
r.noiseTexture && (t.noiseTexture = r.noiseTexture.serialize())
}
,
e._Parse = function(t, r, n, o) {
var a, s, l, u;
n instanceof ThinEngine ? u = null : u = n;
var c = GetClass("BABYLON.Texture");
if (c && u && (t.texture ? r.particleTexture = c.Parse(t.texture, u, o) : t.textureName && (r.particleTexture = new c(o + t.textureName,u,!1,t.invertY !== void 0 ? t.invertY : !0),
r.particleTexture.name = t.textureName)),
!t.emitterId && t.emitterId !== 0 && t.emitter === void 0 ? r.emitter = Vector3.Zero() : t.emitterId && u ? r.emitter = u.getLastMeshById(t.emitterId) : r.emitter = Vector3.FromArray(t.emitter),
r.isLocal = !!t.isLocal,
t.renderingGroupId !== void 0 && (r.renderingGroupId = t.renderingGroupId),
t.isBillboardBased !== void 0 && (r.isBillboardBased = t.isBillboardBased),
t.billboardMode !== void 0 && (r.billboardMode = t.billboardMode),
t.animations) {
for (var h = 0; h < t.animations.length; h++) {
var f = t.animations[h]
, d = GetClass("BABYLON.Animation");
d && r.animations.push(d.Parse(f))
}
r.beginAnimationOnStart = t.beginAnimationOnStart,
r.beginAnimationFrom = t.beginAnimationFrom,
r.beginAnimationTo = t.beginAnimationTo,
r.beginAnimationLoop = t.beginAnimationLoop
}
if (t.autoAnimate && u && u.beginAnimation(r, t.autoAnimateFrom, t.autoAnimateTo, t.autoAnimateLoop, t.autoAnimateSpeed || 1),
r.startDelay = t.startDelay | 0,
r.minAngularSpeed = t.minAngularSpeed,
r.maxAngularSpeed = t.maxAngularSpeed,
r.minSize = t.minSize,
r.maxSize = t.maxSize,
t.minScaleX && (r.minScaleX = t.minScaleX,
r.maxScaleX = t.maxScaleX,
r.minScaleY = t.minScaleY,
r.maxScaleY = t.maxScaleY),
t.preWarmCycles !== void 0 && (r.preWarmCycles = t.preWarmCycles,
r.preWarmStepOffset = t.preWarmStepOffset),
t.minInitialRotation !== void 0 && (r.minInitialRotation = t.minInitialRotation,
r.maxInitialRotation = t.maxInitialRotation),
r.minLifeTime = t.minLifeTime,
r.maxLifeTime = t.maxLifeTime,
r.minEmitPower = t.minEmitPower,
r.maxEmitPower = t.maxEmitPower,
r.emitRate = t.emitRate,
r.gravity = Vector3.FromArray(t.gravity),
t.noiseStrength && (r.noiseStrength = Vector3.FromArray(t.noiseStrength)),
r.color1 = Color4.FromArray(t.color1),
r.color2 = Color4.FromArray(t.color2),
r.colorDead = Color4.FromArray(t.colorDead),
r.updateSpeed = t.updateSpeed,
r.targetStopDuration = t.targetStopDuration,
r.blendMode = t.blendMode,
t.colorGradients)
for (var _ = 0, g = t.colorGradients; _ < g.length; _++) {
var m = g[_];
r.addColorGradient(m.gradient, Color4.FromArray(m.color1), m.color2 ? Color4.FromArray(m.color2) : void 0)
}
if (t.rampGradients) {
for (var v = 0, y = t.rampGradients; v < y.length; v++) {
var b = y[v];
r.addRampGradient(b.gradient, Color3.FromArray(b.color))
}
r.useRampGradients = t.useRampGradients
}
if (t.colorRemapGradients)
for (var T = 0, C = t.colorRemapGradients; T < C.length; T++) {
var A = C[T];
r.addColorRemapGradient(A.gradient, A.factor1 !== void 0 ? A.factor1 : A.factor, A.factor2)
}
if (t.alphaRemapGradients)
for (var S = 0, P = t.alphaRemapGradients; S < P.length; S++) {
var R = P[S];
r.addAlphaRemapGradient(R.gradient, R.factor1 !== void 0 ? R.factor1 : R.factor, R.factor2)
}
if (t.sizeGradients)
for (var M = 0, x = t.sizeGradients; M < x.length; M++) {
var I = x[M];
r.addSizeGradient(I.gradient, I.factor1 !== void 0 ? I.factor1 : I.factor, I.factor2)
}
if (t.angularSpeedGradients)
for (var w = 0, O = t.angularSpeedGradients; w < O.length; w++) {
var D = O[w];
r.addAngularSpeedGradient(D.gradient, D.factor1 !== void 0 ? D.factor1 : D.factor, D.factor2)
}
if (t.velocityGradients)
for (var F = 0, V = t.velocityGradients; F < V.length; F++) {
var N = V[F];
r.addVelocityGradient(N.gradient, N.factor1 !== void 0 ? N.factor1 : N.factor, N.factor2)
}
if (t.dragGradients)
for (var L = 0, k = t.dragGradients; L < k.length; L++) {
var U = k[L];
r.addDragGradient(U.gradient, U.factor1 !== void 0 ? U.factor1 : U.factor, U.factor2)
}
if (t.emitRateGradients)
for (var z = 0, H = t.emitRateGradients; z < H.length; z++) {
var G = H[z];
r.addEmitRateGradient(G.gradient, G.factor1 !== void 0 ? G.factor1 : G.factor, G.factor2)
}
if (t.startSizeGradients)
for (var W = 0, j = t.startSizeGradients; W < j.length; W++) {
var B = j[W];
r.addStartSizeGradient(B.gradient, B.factor1 !== void 0 ? B.factor1 : B.factor, B.factor2)
}
if (t.lifeTimeGradients)
for (var X = 0, $ = t.lifeTimeGradients; X < $.length; X++) {
var Y = $[X];
r.addLifeTimeGradient(Y.gradient, Y.factor1 !== void 0 ? Y.factor1 : Y.factor, Y.factor2)
}
if (t.limitVelocityGradients) {
for (var K = 0, Z = t.limitVelocityGradients; K < Z.length; K++) {
var q = Z[K];
r.addLimitVelocityGradient(q.gradient, q.factor1 !== void 0 ? q.factor1 : q.factor, q.factor2)
}
r.limitVelocityDamping = t.limitVelocityDamping
}
if (t.noiseTexture && u) {
var J = GetClass("BABYLON.ProceduralTexture");
r.noiseTexture = J.Parse(t.noiseTexture, u, o)
}
var Q;
if (t.particleEmitterType) {
switch (t.particleEmitterType.type) {
case "SphereParticleEmitter":
Q = new SphereParticleEmitter;
break;
case "SphereDirectedParticleEmitter":
Q = new SphereDirectedParticleEmitter;
break;
case "ConeEmitter":
case "ConeParticleEmitter":
Q = new ConeParticleEmitter;
break;
case "CylinderParticleEmitter":
Q = new CylinderParticleEmitter;
break;
case "CylinderDirectedParticleEmitter":
Q = new CylinderDirectedParticleEmitter;
break;
case "HemisphericParticleEmitter":
Q = new HemisphericParticleEmitter;
break;
case "PointParticleEmitter":
Q = new PointParticleEmitter;
break;
case "MeshParticleEmitter":
Q = new MeshParticleEmitter;
break;
case "BoxEmitter":
case "BoxParticleEmitter":
default:
Q = new BoxParticleEmitter;
break
}
Q.parse(t.particleEmitterType, u)
} else
Q = new BoxParticleEmitter,
Q.parse(t, u);
r.particleEmitterType = Q,
r.startSpriteCellID = t.startSpriteCellID,
r.endSpriteCellID = t.endSpriteCellID,
r.spriteCellLoop = (a = t.spriteCellLoop) !== null && a !== void 0 ? a : !0,
r.spriteCellWidth = t.spriteCellWidth,
r.spriteCellHeight = t.spriteCellHeight,
r.spriteCellChangeSpeed = t.spriteCellChangeSpeed,
r.spriteRandomStartCell = t.spriteRandomStartCell,
r.disposeOnStop = (s = t.disposeOnStop) !== null && s !== void 0 ? s : !1,
r.manualEmitCount = (l = t.manualEmitCount) !== null && l !== void 0 ? l : -1
}
,
e.Parse = function(t, r, n, o, a) {
o === void 0 && (o = !1);
var s = t.name, l = null, u = null, c, h;
if (r instanceof ThinEngine ? c = r : (h = r,
c = h.getEngine()),
t.customShader && c.createEffectForParticles) {
u = t.customShader;
var f = u.shaderOptions.defines.length > 0 ? u.shaderOptions.defines.join(`
`) : "";
l = c.createEffectForParticles(u.shaderPath.fragmentElement, u.shaderOptions.uniforms, u.shaderOptions.samplers, f)
}
var d = new e(s,a || t.capacity,r,l,t.isAnimationSheetEnabled);
if (d.customShader = u,
d._rootUrl = n,
t.id && (d.id = t.id),
t.subEmitters) {
d.subEmitters = [];
for (var _ = 0, g = t.subEmitters; _ < g.length; _++) {
for (var m = g[_], v = [], y = 0, b = m; y < b.length; y++) {
var T = b[y];
v.push(SubEmitter.Parse(T, r, n))
}
d.subEmitters.push(v)
}
}
return e._Parse(t, d, r, n),
t.textureMask && (d.textureMask = Color4.FromArray(t.textureMask)),
t.preventAutoStart && (d.preventAutoStart = t.preventAutoStart),
!o && !d.preventAutoStart && d.start(),
d
}
,
e.BILLBOARDMODE_Y = 2,
e.BILLBOARDMODE_ALL = 7,
e.BILLBOARDMODE_STRETCHED = 8,
e
}(BaseParticleSystem);
SubEmitter._ParseParticleSystem = ParticleSystem.Parse;
var name$1F = "clipPlaneFragmentDeclaration2"
, shader$1F = `#ifdef CLIPPLANE
in float fClipDistance;
#endif
#ifdef CLIPPLANE2
in float fClipDistance2;
#endif
#ifdef CLIPPLANE3
in float fClipDistance3;
#endif
#ifdef CLIPPLANE4
in float fClipDistance4;
#endif
#ifdef CLIPPLANE5
in float fClipDistance5;
#endif
#ifdef CLIPPLANE6
in float fClipDistance6;
#endif`;
ShaderStore.IncludesShadersStore[name$1F] = shader$1F;
var name$1E = "gpuRenderParticlesPixelShader"
, shader$1E = `precision highp float;
uniform sampler2D diffuseSampler;
varying vec2 vUV;
varying vec4 vColor;
#include
#include
#include
#include
void main() {
#include
vec4 textureColor=texture2D(diffuseSampler,vUV);
gl_FragColor=textureColor*vColor;
#ifdef BLENDMULTIPLYMODE
float alpha=vColor.a*textureColor.a;
gl_FragColor.rgb=gl_FragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);
#endif
#ifdef IMAGEPROCESSINGPOSTPROCESS
gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);
#else
#ifdef IMAGEPROCESSING
gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);
gl_FragColor=applyImageProcessing(gl_FragColor);
#endif
#endif
}
`;
ShaderStore.ShadersStore[name$1E] = shader$1E;
var name$1D = "clipPlaneVertexDeclaration2"
, shader$1D = `#ifdef CLIPPLANE
uniform vec4 vClipPlane;
out float fClipDistance;
#endif
#ifdef CLIPPLANE2
uniform vec4 vClipPlane2;
out float fClipDistance2;
#endif
#ifdef CLIPPLANE3
uniform vec4 vClipPlane3;
out float fClipDistance3;
#endif
#ifdef CLIPPLANE4
uniform vec4 vClipPlane4;
out float fClipDistance4;
#endif
#ifdef CLIPPLANE5
uniform vec4 vClipPlane5;
out float fClipDistance5;
#endif
#ifdef CLIPPLANE6
uniform vec4 vClipPlane6;
out float fClipDistance6;
#endif`;
ShaderStore.IncludesShadersStore[name$1D] = shader$1D;
var name$1C = "gpuRenderParticlesVertexShader"
, shader$1C = `precision highp float;
uniform mat4 view;
uniform mat4 projection;
uniform vec2 translationPivot;
uniform vec3 worldOffset;
#ifdef LOCAL
uniform mat4 emitterWM;
#endif
attribute vec3 position;
attribute float age;
attribute float life;
attribute vec3 size;
#ifndef BILLBOARD
attribute vec3 initialDirection;
#endif
#ifdef BILLBOARDSTRETCHED
attribute vec3 direction;
#endif
attribute float angle;
#ifdef ANIMATESHEET
attribute float cellIndex;
#endif
attribute vec2 offset;
attribute vec2 uv;
varying vec2 vUV;
varying vec4 vColor;
varying vec3 vPositionW;
#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
uniform mat4 invView;
#endif
#include
#ifdef COLORGRADIENTS
uniform sampler2D colorGradientSampler;
#else
uniform vec4 colorDead;
attribute vec4 color;
#endif
#ifdef ANIMATESHEET
uniform vec3 sheetInfos;
#endif
#ifdef BILLBOARD
uniform vec3 eyePosition;
#endif
vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
vec3 zaxis=normalize(cross(yaxis,xaxis));
vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
mat3 rotMatrix=mat3(row0,row1,row2);
vec3 alignedCorner=rotMatrix*rotatedCorner;
#ifdef LOCAL
return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
#else
return (position+worldOffset)+alignedCorner;
#endif
}
#ifdef BILLBOARDSTRETCHED
vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
vec3 normalizedToCamera=normalize(toCamera);
vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
mat3 rotMatrix=mat3(row0,row1,row2);
vec3 alignedCorner=rotMatrix*rotatedCorner;
#ifdef LOCAL
return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
#else
return (position+worldOffset)+alignedCorner;
#endif
}
#endif
void main() {
#ifdef ANIMATESHEET
float rowOffset=floor(cellIndex/sheetInfos.z);
float columnOffset=cellIndex-rowOffset*sheetInfos.z;
vec2 uvScale=sheetInfos.xy;
vec2 uvOffset=vec2(uv.x ,1.0-uv.y);
vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
#else
vUV=uv;
#endif
float ratio=age/life;
#ifdef COLORGRADIENTS
vColor=texture2D(colorGradientSampler,vec2(ratio,0));
#else
vColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);
#endif
vec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;
#ifdef BILLBOARD
vec4 rotatedCorner;
rotatedCorner.w=0.;
#ifdef BILLBOARDY
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
rotatedCorner.y=0.;
vec3 yaxis=(position+worldOffset)-eyePosition;
yaxis.y=0.;
vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);
vec4 viewPosition=(view*vec4(vPositionW,1.0));
#elif defined(BILLBOARDSTRETCHED)
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
rotatedCorner.z=0.;
vec3 toCamera=(position+worldOffset)-eyePosition;
vPositionW=rotateAlign(toCamera,rotatedCorner.xyz);
vec4 viewPosition=(view*vec4(vPositionW,1.0));
#else
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
rotatedCorner.z=0.;
#ifdef LOCAL
vec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;
#else
vec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;
#endif
vPositionW=(invView*viewPosition).xyz;
#endif
#else
vec3 rotatedCorner;
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
rotatedCorner.y=0.;
rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
vec3 yaxis=normalize(initialDirection);
vPositionW=rotate(yaxis,rotatedCorner);
vec4 viewPosition=view*vec4(vPositionW,1.0);
#endif
gl_Position=projection*viewPosition;
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
vec4 worldPos=vec4(vPositionW,1.0);
#endif
#include
}`;
ShaderStore.ShadersStore[name$1C] = shader$1C;
var GPUParticleSystem = function(i) {
__extends(e, i);
function e(t, r, n, o, a) {
o === void 0 && (o = null),
a === void 0 && (a = !1);
var s = i.call(this, t) || this;
if (s.layerMask = 268435455,
s._accumulatedCount = 0,
s._targetIndex = 0,
s._currentRenderId = -1,
s._currentRenderingCameraUniqueId = -1,
s._started = !1,
s._stopped = !1,
s._timeDelta = 0,
s._actualFrame = 0,
s._rawTextureWidth = 256,
s.onDisposeObservable = new Observable,
s.onStoppedObservable = new Observable,
s.forceDepthWrite = !1,
s._preWarmDone = !1,
s.isLocal = !1,
s._onBeforeDrawParticlesObservable = null,
!n || n.getClassName() === "Scene" ? (s._scene = n || EngineStore.LastCreatedScene,
s._engine = s._scene.getEngine(),
s.uniqueId = s._scene.getUniqueId(),
s._scene.particleSystems.push(s)) : (s._engine = n,
s.defaultProjectionMatrix = Matrix.PerspectiveFovLH(.8, 1, .1, 100, s._engine.isNDCHalfZRange)),
s._engine.getCaps().supportComputeShaders) {
if (!GetClass("BABYLON.ComputeShaderParticleSystem"))
throw new Error("The ComputeShaderParticleSystem class is not available! Make sure you have imported it.");
s._platform = new (GetClass("BABYLON.ComputeShaderParticleSystem"))(s,s._engine)
} else {
if (!GetClass("BABYLON.WebGL2ParticleSystem"))
throw new Error("The WebGL2ParticleSystem class is not available! Make sure you have imported it.");
s._platform = new (GetClass("BABYLON.WebGL2ParticleSystem"))(s,s._engine)
}
s._customWrappers = {
0: new DrawWrapper(s._engine)
},
s._customWrappers[0].effect = o,
s._drawWrappers = {
0: new DrawWrapper(s._engine)
},
s._drawWrappers[0].drawContext && (s._drawWrappers[0].drawContext.useInstancing = !0),
s._attachImageProcessingConfiguration(null),
r = r != null ? r : {},
r.randomTextureSize || delete r.randomTextureSize;
var l = __assign({
capacity: 5e4,
randomTextureSize: s._engine.getCaps().maxTextureSize
}, r)
, u = r;
isFinite(u) && (l.capacity = u),
s._capacity = l.capacity,
s._activeCount = l.capacity,
s._currentActiveCount = 0,
s._isAnimationSheetEnabled = a,
s.particleEmitterType = new BoxParticleEmitter;
for (var c = Math.min(s._engine.getCaps().maxTextureSize, l.randomTextureSize), h = [], f = 0; f < c; ++f)
h.push(Math.random()),
h.push(Math.random()),
h.push(Math.random()),
h.push(Math.random());
s._randomTexture = new RawTexture(new Float32Array(h),c,1,5,n,!1,!1,1,1),
s._randomTexture.name = "GPUParticleSystem_random1",
s._randomTexture.wrapU = 1,
s._randomTexture.wrapV = 1,
h = [];
for (var f = 0; f < c; ++f)
h.push(Math.random()),
h.push(Math.random()),
h.push(Math.random()),
h.push(Math.random());
return s._randomTexture2 = new RawTexture(new Float32Array(h),c,1,5,n,!1,!1,1,1),
s._randomTexture2.name = "GPUParticleSystem_random2",
s._randomTexture2.wrapU = 1,
s._randomTexture2.wrapV = 1,
s._randomTextureSize = c,
s
}
return Object.defineProperty(e, "IsSupported", {
get: function() {
return EngineStore.LastCreatedEngine ? EngineStore.LastCreatedEngine.name === "WebGL" && EngineStore.LastCreatedEngine.version > 1 || EngineStore.LastCreatedEngine.getCaps().supportComputeShaders : !1
},
enumerable: !1,
configurable: !0
}),
e.prototype.getCapacity = function() {
return this._capacity
}
,
Object.defineProperty(e.prototype, "activeParticleCount", {
get: function() {
return this._activeCount
},
set: function(t) {
this._activeCount = Math.min(t, this._capacity)
},
enumerable: !1,
configurable: !0
}),
e.prototype.isReady = function() {
if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
return !1;
if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
if (!this._getWrapper(this.blendMode).effect.isReady())
return !1
} else if (!this._getWrapper(ParticleSystem.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(ParticleSystem.BLENDMODE_ADD).effect.isReady())
return !1;
return this._platform.isUpdateBufferCreated() ? this._platform.isUpdateBufferReady() : (this._recreateUpdateEffect(),
!1)
}
,
e.prototype.isStarted = function() {
return this._started
}
,
e.prototype.isStopped = function() {
return this._stopped
}
,
e.prototype.isStopping = function() {
return !1
}
,
e.prototype.getActiveCount = function() {
return this._currentActiveCount
}
,
e.prototype.start = function(t) {
var r = this;
if (t === void 0 && (t = this.startDelay),
!this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
if (t) {
setTimeout(function() {
r.start(0)
}, t);
return
}
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)
}
,
e.prototype.stop = function() {
this._stopped || (this._stopped = !0)
}
,
e.prototype.reset = function() {
this._releaseBuffers(),
this._platform.releaseVertexBuffers(),
this._currentActiveCount = 0,
this._targetIndex = 0
}
,
e.prototype.getClassName = function() {
return "GPUParticleSystem"
}
,
e.prototype.getCustomEffect = function(t) {
var r, n;
return t === void 0 && (t = 0),
(n = (r = this._customWrappers[t]) === null || r === void 0 ? void 0 : r.effect) !== null && n !== void 0 ? n : this._customWrappers[0].effect
}
,
e.prototype._getCustomDrawWrapper = function(t) {
var r;
return t === void 0 && (t = 0),
(r = this._customWrappers[t]) !== null && r !== void 0 ? r : this._customWrappers[0]
}
,
e.prototype.setCustomEffect = function(t, r) {
r === void 0 && (r = 0),
this._customWrappers[r] = new DrawWrapper(this._engine),
this._customWrappers[r].effect = t
}
,
Object.defineProperty(e.prototype, "onBeforeDrawParticlesObservable", {
get: function() {
return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new Observable),
this._onBeforeDrawParticlesObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "vertexShaderName", {
get: function() {
return "gpuRenderParticles"
},
enumerable: !1,
configurable: !0
}),
e.prototype._removeGradientAndTexture = function(t, r, n) {
return i.prototype._removeGradientAndTexture.call(this, t, r, n),
this._releaseBuffers(),
this
}
,
e.prototype.addColorGradient = function(t, r, n) {
this._colorGradients || (this._colorGradients = []);
var o = new ColorGradient(t,r);
return this._colorGradients.push(o),
this._refreshColorGradient(!0),
this._releaseBuffers(),
this
}
,
e.prototype._refreshColorGradient = function(t) {
t === void 0 && (t = !1),
this._colorGradients && (t && this._colorGradients.sort(function(r, n) {
return r.gradient < n.gradient ? -1 : r.gradient > n.gradient ? 1 : 0
}),
this._colorGradientsTexture && (this._colorGradientsTexture.dispose(),
this._colorGradientsTexture = null))
}
,
e.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()
}
,
e.prototype.removeColorGradient = function(t) {
return this._removeGradientAndTexture(t, this._colorGradients, this._colorGradientsTexture),
this._colorGradientsTexture = null,
this
}
,
e.prototype.resetDrawCache = function() {
var t;
for (var r in this._drawWrappers) {
var n = this._drawWrappers[r];
(t = n.drawContext) === null || t === void 0 || t.reset()
}
}
,
e.prototype._addFactorGradient = function(t, r, n) {
var o = new FactorGradient(r,n);
t.push(o),
this._releaseBuffers()
}
,
e.prototype.addSizeGradient = function(t, r) {
return this._sizeGradients || (this._sizeGradients = []),
this._addFactorGradient(this._sizeGradients, t, r),
this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture", !0),
this._releaseBuffers(),
this
}
,
e.prototype.removeSizeGradient = function(t) {
return this._removeGradientAndTexture(t, this._sizeGradients, this._sizeGradientsTexture),
this._sizeGradientsTexture = null,
this
}
,
e.prototype._refreshFactorGradient = function(t, r, n) {
if (n === void 0 && (n = !1),
!!t) {
n && t.sort(function(a, s) {
return a.gradient < s.gradient ? -1 : a.gradient > s.gradient ? 1 : 0
});
var o = this;
o[r] && (o[r].dispose(),
o[r] = null)
}
}
,
e.prototype.addAngularSpeedGradient = function(t, r) {
return this._angularSpeedGradients || (this._angularSpeedGradients = []),
this._addFactorGradient(this._angularSpeedGradients, t, r),
this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture", !0),
this._releaseBuffers(),
this
}
,
e.prototype.removeAngularSpeedGradient = function(t) {
return this._removeGradientAndTexture(t, this._angularSpeedGradients, this._angularSpeedGradientsTexture),
this._angularSpeedGradientsTexture = null,
this
}
,
e.prototype.addVelocityGradient = function(t, r) {
return this._velocityGradients || (this._velocityGradients = []),
this._addFactorGradient(this._velocityGradients, t, r),
this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture", !0),
this._releaseBuffers(),
this
}
,
e.prototype.removeVelocityGradient = function(t) {
return this._removeGradientAndTexture(t, this._velocityGradients, this._velocityGradientsTexture),
this._velocityGradientsTexture = null,
this
}
,
e.prototype.addLimitVelocityGradient = function(t, r) {
return this._limitVelocityGradients || (this._limitVelocityGradients = []),
this._addFactorGradient(this._limitVelocityGradients, t, r),
this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture", !0),
this._releaseBuffers(),
this
}
,
e.prototype.removeLimitVelocityGradient = function(t) {
return this._removeGradientAndTexture(t, this._limitVelocityGradients, this._limitVelocityGradientsTexture),
this._limitVelocityGradientsTexture = null,
this
}
,
e.prototype.addDragGradient = function(t, r) {
return this._dragGradients || (this._dragGradients = []),
this._addFactorGradient(this._dragGradients, t, r),
this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture", !0),
this._releaseBuffers(),
this
}
,
e.prototype.removeDragGradient = function(t) {
return this._removeGradientAndTexture(t, this._dragGradients, this._dragGradientsTexture),
this._dragGradientsTexture = null,
this
}
,
e.prototype.addEmitRateGradient = function(t, r, n) {
return this
}
,
e.prototype.removeEmitRateGradient = function(t) {
return this
}
,
e.prototype.addStartSizeGradient = function(t, r, n) {
return this
}
,
e.prototype.removeStartSizeGradient = function(t) {
return this
}
,
e.prototype.addColorRemapGradient = function(t, r, n) {
return this
}
,
e.prototype.removeColorRemapGradient = function() {
return this
}
,
e.prototype.addAlphaRemapGradient = function(t, r, n) {
return this
}
,
e.prototype.removeAlphaRemapGradient = function() {
return this
}
,
e.prototype.addRampGradient = function(t, r) {
return this
}
,
e.prototype.removeRampGradient = function() {
return this
}
,
e.prototype.getRampGradients = function() {
return null
}
,
Object.defineProperty(e.prototype, "useRampGradients", {
get: function() {
return !1
},
set: function(t) {},
enumerable: !1,
configurable: !0
}),
e.prototype.addLifeTimeGradient = function(t, r, n) {
return this
}
,
e.prototype.removeLifeTimeGradient = function(t) {
return this
}
,
e.prototype._reset = function() {
this._releaseBuffers()
}
,
e.prototype._createVertexBuffers = function(t, r, n) {
var o = {};
o.position = r.createVertexBuffer("position", 0, 3, this._attributesStrideSize, !0);
var a = 3;
o.age = r.createVertexBuffer("age", a, 1, this._attributesStrideSize, !0),
a += 1,
o.size = r.createVertexBuffer("size", a, 3, this._attributesStrideSize, !0),
a += 3,
o.life = r.createVertexBuffer("life", a, 1, this._attributesStrideSize, !0),
a += 1,
a += 4,
this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED && (o.direction = r.createVertexBuffer("direction", a, 3, this._attributesStrideSize, !0)),
a += 3,
this._platform.alignDataInBuffer && (a += 1),
this.particleEmitterType instanceof CustomParticleEmitter && (a += 3,
this._platform.alignDataInBuffer && (a += 1)),
this._colorGradientsTexture || (o.color = r.createVertexBuffer("color", a, 4, this._attributesStrideSize, !0),
a += 4),
this._isBillboardBased || (o.initialDirection = r.createVertexBuffer("initialDirection", a, 3, this._attributesStrideSize, !0),
a += 3,
this._platform.alignDataInBuffer && (a += 1)),
this.noiseTexture && (o.noiseCoordinates1 = r.createVertexBuffer("noiseCoordinates1", a, 3, this._attributesStrideSize, !0),
a += 3,
this._platform.alignDataInBuffer && (a += 1),
o.noiseCoordinates2 = r.createVertexBuffer("noiseCoordinates2", a, 3, this._attributesStrideSize, !0),
a += 3,
this._platform.alignDataInBuffer && (a += 1)),
o.angle = r.createVertexBuffer("angle", a, 1, this._attributesStrideSize, !0),
this._angularSpeedGradientsTexture ? a++ : a += 2,
this._isAnimationSheetEnabled && (o.cellIndex = r.createVertexBuffer("cellIndex", a, 1, this._attributesStrideSize, !0),
a += 1,
this.spriteRandomStartCell && (o.cellStartOffset = r.createVertexBuffer("cellStartOffset", a, 1, this._attributesStrideSize, !0),
a += 1)),
o.offset = n.createVertexBuffer("offset", 0, 2),
o.uv = n.createVertexBuffer("uv", 2, 2),
this._platform.createVertexBuffers(t, o),
this.resetDrawCache()
}
,
e.prototype._initialize = function(t) {
if (t === void 0 && (t = !1),
!(this._buffer0 && !t)) {
var r = this._engine
, n = new Array;
this._attributesStrideSize = 21,
this._targetIndex = 0,
this._platform.alignDataInBuffer && (this._attributesStrideSize += 1),
this.particleEmitterType instanceof CustomParticleEmitter && (this._attributesStrideSize += 3,
this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)),
this.isBillboardBased || (this._attributesStrideSize += 3,
this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)),
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,
this._platform.alignDataInBuffer && (this._attributesStrideSize += 2)),
this._platform.alignDataInBuffer && (this._attributesStrideSize += 3 - (this._attributesStrideSize + 3 & 3));
for (var o = this.particleEmitterType instanceof CustomParticleEmitter, a = TmpVectors.Vector3[0], s = 0, l = 0; l < this._capacity; l++)
if (n.push(0),
n.push(0),
n.push(0),
n.push(0),
n.push(0),
n.push(0),
n.push(0),
n.push(0),
n.push(Math.random()),
n.push(Math.random()),
n.push(Math.random()),
n.push(Math.random()),
o ? (this.particleEmitterType.particleDestinationGenerator(l, null, a),
n.push(a.x),
n.push(a.y),
n.push(a.z)) : (n.push(0),
n.push(0),
n.push(0)),
this._platform.alignDataInBuffer && n.push(0),
s += 16,
o && (this.particleEmitterType.particlePositionGenerator(l, null, a),
n.push(a.x),
n.push(a.y),
n.push(a.z),
this._platform.alignDataInBuffer && n.push(0),
s += 4),
this._colorGradientsTexture || (n.push(0),
n.push(0),
n.push(0),
n.push(0),
s += 4),
this.isBillboardBased || (n.push(0),
n.push(0),
n.push(0),
this._platform.alignDataInBuffer && n.push(0),
s += 4),
this.noiseTexture && (n.push(Math.random()),
n.push(Math.random()),
n.push(Math.random()),
this._platform.alignDataInBuffer && n.push(0),
n.push(Math.random()),
n.push(Math.random()),
n.push(Math.random()),
this._platform.alignDataInBuffer && n.push(0),
s += 8),
n.push(0),
s += 1,
this._angularSpeedGradientsTexture || (n.push(0),
s += 1),
this._isAnimationSheetEnabled && (n.push(0),
s += 1,
this.spriteRandomStartCell && (n.push(0),
s += 1)),
this._platform.alignDataInBuffer) {
var u = 3 - (s + 3 & 3);
for (s += u; u-- > 0; )
n.push(0)
}
var c = new Float32Array([.5, .5, 1, 1, -.5, .5, 0, 1, .5, -.5, 1, 0, -.5, -.5, 0, 0])
, h = this._platform.createParticleBuffer(n)
, f = this._platform.createParticleBuffer(n);
this._buffer0 = new Buffer(r,h,!1,this._attributesStrideSize),
this._buffer1 = new Buffer(r,f,!1,this._attributesStrideSize),
this._spriteBuffer = new Buffer(r,c,!1,4),
this._createVertexBuffers(this._buffer0, this._buffer1, this._spriteBuffer),
this._createVertexBuffers(this._buffer1, this._buffer0, this._spriteBuffer),
this._sourceBuffer = this._buffer0,
this._targetBuffer = this._buffer1
}
}
,
e.prototype._recreateUpdateEffect = function() {
var t = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
this._isBillboardBased && (t += `
#define BILLBOARD`),
this._colorGradientsTexture && (t += `
#define COLORGRADIENTS`),
this._sizeGradientsTexture && (t += `
#define SIZEGRADIENTS`),
this._angularSpeedGradientsTexture && (t += `
#define ANGULARSPEEDGRADIENTS`),
this._velocityGradientsTexture && (t += `
#define VELOCITYGRADIENTS`),
this._limitVelocityGradientsTexture && (t += `
#define LIMITVELOCITYGRADIENTS`),
this._dragGradientsTexture && (t += `
#define DRAGGRADIENTS`),
this.isAnimationSheetEnabled && (t += `
#define ANIMATESHEET`,
this.spriteRandomStartCell && (t += `
#define ANIMATESHEETRANDOMSTART`)),
this.noiseTexture && (t += `
#define NOISE`),
this.isLocal && (t += `
#define LOCAL`),
!(this._platform.isUpdateBufferCreated() && this._cachedUpdateDefines === t) && (this._cachedUpdateDefines = t,
this._updateBuffer = this._platform.createUpdateBuffer(t))
}
,
e.prototype._getWrapper = function(t) {
var r = this._getCustomDrawWrapper(t);
if (r != null && r.effect)
return r;
var n = [];
this.fillDefines(n, t);
var o = this._drawWrappers[t];
o || (o = new DrawWrapper(this._engine),
o.drawContext && (o.drawContext.useInstancing = !0),
this._drawWrappers[t] = o);
var a = n.join(`
`);
if (o.defines !== a) {
var s = []
, l = []
, u = [];
this.fillUniformsAttributesAndSamplerNames(l, s, u),
o.setEffect(this._engine.createEffect("gpuRenderParticles", s, l, u, a), a)
}
return o
}
,
e._GetAttributeNamesOrOptions = function(t, r, n, o) {
t === void 0 && (t = !1),
r === void 0 && (r = !1),
n === void 0 && (n = !1),
o === void 0 && (o = !1);
var a = [VertexBuffer.PositionKind, "age", "life", "size", "angle"];
return t || a.push(VertexBuffer.ColorKind),
r && a.push("cellIndex"),
n || a.push("initialDirection"),
o || a.push("direction"),
a.push("offset", VertexBuffer.UVKind),
a
}
,
e._GetEffectCreationOptions = function(t) {
t === void 0 && (t = !1);
var r = ["emitterWM", "worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "translationPivot", "eyePosition"];
return t && r.push("sheetInfos"),
r
}
,
e.prototype.fillDefines = function(t, r) {
if (r === void 0 && (r = 0),
this._scene && (this._scene.clipPlane && t.push("#define CLIPPLANE"),
this._scene.clipPlane2 && t.push("#define CLIPPLANE2"),
this._scene.clipPlane3 && t.push("#define CLIPPLANE3"),
this._scene.clipPlane4 && t.push("#define CLIPPLANE4"),
this._scene.clipPlane5 && t.push("#define CLIPPLANE5"),
this._scene.clipPlane6 && t.push("#define CLIPPLANE6")),
r === ParticleSystem.BLENDMODE_MULTIPLY && t.push("#define BLENDMULTIPLYMODE"),
this.isLocal && t.push("#define LOCAL"),
this._isBillboardBased)
switch (t.push("#define BILLBOARD"),
this.billboardMode) {
case ParticleSystem.BILLBOARDMODE_Y:
t.push("#define BILLBOARDY");
break;
case ParticleSystem.BILLBOARDMODE_STRETCHED:
t.push("#define BILLBOARDSTRETCHED");
break;
case ParticleSystem.BILLBOARDMODE_ALL:
t.push("#define BILLBOARDMODE_ALL");
break
}
this._colorGradientsTexture && t.push("#define COLORGRADIENTS"),
this.isAnimationSheetEnabled && t.push("#define ANIMATESHEET"),
this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
t.push("" + this._imageProcessingConfigurationDefines.toString()))
}
,
e.prototype.fillUniformsAttributesAndSamplerNames = function(t, r, n) {
r.push.apply(r, e._GetAttributeNamesOrOptions(!!this._colorGradientsTexture, this._isAnimationSheetEnabled, this._isBillboardBased, this._isBillboardBased && this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED)),
t.push.apply(t, e._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
n.push("diffuseSampler", "colorGradientSampler"),
this._imageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(t, this._imageProcessingConfigurationDefines),
ImageProcessingConfiguration.PrepareSamplers(n, this._imageProcessingConfigurationDefines))
}
,
e.prototype.animate = function(t) {
var r;
t === void 0 && (t = !1),
this._timeDelta = this.updateSpeed * (t ? this.preWarmStepOffset : ((r = this._scene) === null || r === void 0 ? void 0 : r.getAnimationRatio()) || 1),
this._actualFrame += this._timeDelta,
this._stopped || this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()
}
,
e.prototype._createFactorGradientTexture = function(t, r) {
var n = this[r];
if (!(!t || !t.length || n)) {
for (var o = new Float32Array(this._rawTextureWidth), a = 0; a < this._rawTextureWidth; a++) {
var s = a / this._rawTextureWidth;
GradientHelper.GetCurrentGradient(s, t, function(l, u, c) {
o[a] = Scalar.Lerp(l.factor1, u.factor1, c)
})
}
this[r] = RawTexture.CreateRTexture(o, this._rawTextureWidth, 1, this._scene || this._engine, !1, !1, 1)
}
}
,
e.prototype._createSizeGradientTexture = function() {
this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture")
}
,
e.prototype._createAngularSpeedGradientTexture = function() {
this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture")
}
,
e.prototype._createVelocityGradientTexture = function() {
this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture")
}
,
e.prototype._createLimitVelocityGradientTexture = function() {
this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture")
}
,
e.prototype._createDragGradientTexture = function() {
this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture")
}
,
e.prototype._createColorGradientTexture = function() {
if (!(!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture)) {
for (var t = new Uint8Array(this._rawTextureWidth * 4), r = TmpColors.Color4[0], n = 0; n < this._rawTextureWidth; n++) {
var o = n / this._rawTextureWidth;
GradientHelper.GetCurrentGradient(o, this._colorGradients, function(a, s, l) {
Color4.LerpToRef(a.color1, s.color1, l, r),
t[n * 4] = r.r * 255,
t[n * 4 + 1] = r.g * 255,
t[n * 4 + 2] = r.b * 255,
t[n * 4 + 3] = r.a * 255
})
}
this._colorGradientsTexture = RawTexture.CreateRGBATexture(t, this._rawTextureWidth, 1, this._scene, !1, !1, 1)
}
}
,
e.prototype._render = function(t, r) {
var n, o, a = this._getWrapper(t), s = a.effect;
this._engine.enableEffect(a);
var l = ((n = this._scene) === null || n === void 0 ? void 0 : n.getViewMatrix()) || Matrix.IdentityReadOnly;
if (s.setMatrix("view", l),
s.setMatrix("projection", (o = this.defaultProjectionMatrix) !== null && o !== void 0 ? o : this._scene.getProjectionMatrix()),
s.setTexture("diffuseSampler", this.particleTexture),
s.setVector2("translationPivot", this.translationPivot),
s.setVector3("worldOffset", this.worldOffset),
this.isLocal && s.setMatrix("emitterWM", r),
this._colorGradientsTexture ? s.setTexture("colorGradientSampler", this._colorGradientsTexture) : s.setDirectColor4("colorDead", this.colorDead),
this._isAnimationSheetEnabled && this.particleTexture) {
var u = this.particleTexture.getBaseSize();
s.setFloat3("sheetInfos", this.spriteCellWidth / u.width, this.spriteCellHeight / u.height, u.width / this.spriteCellWidth)
}
if (this._isBillboardBased && this._scene) {
var c = this._scene.activeCamera;
s.setVector3("eyePosition", c.globalPosition)
}
var h = s.defines;
if (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && MaterialHelper.BindClipPlane(s, this._scene),
h.indexOf("#define BILLBOARDMODE_ALL") >= 0) {
var f = l.clone();
f.invert(),
s.setMatrix("invView", f)
}
switch (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(s),
t) {
case ParticleSystem.BLENDMODE_ADD:
this._engine.setAlphaMode(1);
break;
case ParticleSystem.BLENDMODE_ONEONE:
this._engine.setAlphaMode(6);
break;
case ParticleSystem.BLENDMODE_STANDARD:
this._engine.setAlphaMode(2);
break;
case ParticleSystem.BLENDMODE_MULTIPLY:
this._engine.setAlphaMode(4);
break
}
return this._platform.bindDrawBuffers(this._targetIndex, s),
this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(s),
this._engine.drawArraysType(7, 0, 4, this._currentActiveCount),
this._engine.setAlphaMode(0),
this._currentActiveCount
}
,
e.prototype.render = function(t, r) {
if (t === void 0 && (t = !1),
r === void 0 && (r = !1),
!this._started || (this._createColorGradientTexture(),
this._createSizeGradientTexture(),
this._createAngularSpeedGradientTexture(),
this._createVelocityGradientTexture(),
this._createLimitVelocityGradientTexture(),
this._createDragGradientTexture(),
this._recreateUpdateEffect(),
!this.isReady()))
return 0;
if (!t && this._scene) {
if (!this._preWarmDone && this.preWarmCycles) {
for (var n = 0; n < this.preWarmCycles; n++)
this.animate(!0),
this.render(!0, !0);
this._preWarmDone = !0
}
if (this._currentRenderId === this._scene.getFrameId() && (!this._scene.activeCamera || this._scene.activeCamera && this._currentRenderingCameraUniqueId === this._scene.activeCamera.uniqueId))
return 0;
this._currentRenderId = this._scene.getFrameId(),
this._scene.activeCamera && (this._currentRenderingCameraUniqueId = this._scene.activeCamera.uniqueId)
}
if (this._initialize(),
this._accumulatedCount += this.emitRate * this._timeDelta,
this._accumulatedCount > 1) {
var o = this._accumulatedCount | 0;
this._accumulatedCount -= o,
this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + o)
}
if (!this._currentActiveCount)
return 0;
var a;
if (this.emitter.position) {
var s = this.emitter;
a = s.getWorldMatrix()
} else {
var l = this.emitter;
a = Matrix.Translation(l.x, l.y, l.z)
}
var u = this._engine;
this._platform.preUpdateParticleBuffer(),
this._updateBuffer.setFloat("currentCount", this._currentActiveCount),
this._updateBuffer.setFloat("timeDelta", this._timeDelta),
this._updateBuffer.setFloat("stopFactor", this._stopped ? 0 : 1),
this._updateBuffer.setInt("randomTextureSize", this._randomTextureSize),
this._updateBuffer.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime),
this._updateBuffer.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower),
this._colorGradientsTexture || (this._updateBuffer.setDirectColor4("color1", this.color1),
this._updateBuffer.setDirectColor4("color2", this.color2)),
this._updateBuffer.setFloat2("sizeRange", this.minSize, this.maxSize),
this._updateBuffer.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY),
this._updateBuffer.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation),
this._updateBuffer.setVector3("gravity", this.gravity),
this._limitVelocityGradientsTexture && this._updateBuffer.setFloat("limitVelocityDamping", this.limitVelocityDamping),
this.particleEmitterType && this.particleEmitterType.applyToShader(this._updateBuffer),
this._isAnimationSheetEnabled && this._updateBuffer.setFloat4("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed, this.spriteCellLoop ? 1 : 0),
this.noiseTexture && this._updateBuffer.setVector3("noiseStrength", this.noiseStrength),
this.isLocal || this._updateBuffer.setMatrix("emitterWM", a),
this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
var c = 0;
!t && !r && (u.setState(!1),
this.forceDepthWrite && u.setDepthWrite(!0),
this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD ? c = this._render(ParticleSystem.BLENDMODE_MULTIPLY, a) + this._render(ParticleSystem.BLENDMODE_ADD, a) : c = this._render(this.blendMode, a),
this._engine.setAlphaMode(0)),
this._targetIndex++,
this._targetIndex === 2 && (this._targetIndex = 0);
var h = this._sourceBuffer;
return this._sourceBuffer = this._targetBuffer,
this._targetBuffer = h,
c
}
,
e.prototype.rebuild = function() {
this._initialize(!0)
}
,
e.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),
this._platform.releaseBuffers()
}
,
e.prototype.dispose = function(t) {
t === void 0 && (t = !0);
for (var r in this._drawWrappers) {
var n = this._drawWrappers[r];
n.dispose()
}
if (this._drawWrappers = {},
this._scene) {
var o = this._scene.particleSystems.indexOf(this);
o > -1 && this._scene.particleSystems.splice(o, 1)
}
this._releaseBuffers(),
this._platform.releaseVertexBuffers(),
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),
t && this.particleTexture && (this.particleTexture.dispose(),
this.particleTexture = null),
t && this.noiseTexture && (this.noiseTexture.dispose(),
this.noiseTexture = null),
this.onStoppedObservable.clear(),
this.onDisposeObservable.notifyObservers(this),
this.onDisposeObservable.clear()
}
,
e.prototype.clone = function(t, r) {
var n = __assign({}, this._customWrappers)
, o = null
, a = this._engine;
if (a.createEffectForParticles && this.customShader != null) {
o = this.customShader;
var s = o.shaderOptions.defines.length > 0 ? o.shaderOptions.defines.join(`
`) : "";
n[0] = a.createEffectForParticles(o.shaderPath.fragmentElement, o.shaderOptions.uniforms, o.shaderOptions.samplers, s, void 0, void 0, void 0, this)
}
var l = this.serialize()
, u = e.Parse(l, this._scene || this._engine, this._rootUrl);
return u.name = t,
u.customShader = o,
u._customWrappers = n,
r === void 0 && (r = this.emitter),
this.noiseTexture && (u.noiseTexture = this.noiseTexture.clone()),
u.emitter = r,
u
}
,
e.prototype.serialize = function(t) {
t === void 0 && (t = !1);
var r = {};
return ParticleSystem._Serialize(r, this, t),
r.activeParticleCount = this.activeParticleCount,
r.randomTextureSize = this._randomTextureSize,
r.customShader = this.customShader,
r
}
,
e.Parse = function(t, r, n, o, a) {
o === void 0 && (o = !1);
var s = t.name, l, u;
r instanceof ThinEngine ? l = r : (u = r,
l = u.getEngine());
var c = new e(s,{
capacity: a || t.capacity,
randomTextureSize: t.randomTextureSize
},r,null,t.isAnimationSheetEnabled);
if (c._rootUrl = n,
t.customShader && l.createEffectForParticles) {
var h = t.customShader
, f = h.shaderOptions.defines.length > 0 ? h.shaderOptions.defines.join(`
`) : ""
, d = l.createEffectForParticles(h.shaderPath.fragmentElement, h.shaderOptions.uniforms, h.shaderOptions.samplers, f, void 0, void 0, void 0, c);
c.setCustomEffect(d, 0),
c.customShader = h
}
return t.id && (c.id = t.id),
t.activeParticleCount && (c.activeParticleCount = t.activeParticleCount),
ParticleSystem._Parse(t, c, r, n),
t.preventAutoStart && (c.preventAutoStart = t.preventAutoStart),
!o && !c.preventAutoStart && c.start(),
c
}
,
e
}(BaseParticleSystem)
, ParticleSystemSet = function() {
function i() {
this._emitterNodeIsOwned = !0,
this.systems = new Array
}
return Object.defineProperty(i.prototype, "emitterNode", {
get: function() {
return this._emitterNode
},
set: function(e) {
this._emitterNodeIsOwned && this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(),
this._emitterNodeIsOwned = !1);
for (var t = 0, r = this.systems; t < r.length; t++) {
var n = r[t];
n.emitter = e
}
this._emitterNode = e
},
enumerable: !1,
configurable: !0
}),
i.prototype.setEmitterAsSphere = function(e, t, r) {
this._emitterNodeIsOwned && this._emitterNode && this._emitterNode.dispose && this._emitterNode.dispose(),
this._emitterNodeIsOwned = !0,
this._emitterCreationOptions = {
kind: "Sphere",
options: e,
renderingGroupId: t
};
var n = CreateSphere("emitterSphere", {
diameter: e.diameter,
segments: e.segments
}, r);
n.renderingGroupId = t;
var o = new StandardMaterial("emitterSphereMaterial",r);
o.emissiveColor = e.color,
n.material = o;
for (var a = 0, s = this.systems; a < s.length; a++) {
var l = s[a];
l.emitter = n
}
this._emitterNode = n
}
,
i.prototype.start = function(e) {
for (var t = 0, r = this.systems; t < r.length; t++) {
var n = r[t];
e && (n.emitter = e),
n.start()
}
}
,
i.prototype.dispose = function() {
for (var e = 0, t = this.systems; e < t.length; e++) {
var r = t[e];
r.dispose()
}
this.systems = [],
this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(),
this._emitterNode = null)
}
,
i.prototype.serialize = function(e) {
e === void 0 && (e = !1);
var t = {};
t.systems = [];
for (var r = 0, n = this.systems; r < n.length; r++) {
var o = n[r];
t.systems.push(o.serialize(e))
}
return this._emitterNode && (t.emitter = this._emitterCreationOptions),
t
}
,
i.Parse = function(e, t, r, n) {
r === void 0 && (r = !1);
var o = new i
, a = this.BaseAssetsUrl + "/textures/";
t = t || EngineStore.LastCreatedScene;
for (var s = 0, l = e.systems; s < l.length; s++) {
var u = l[s];
o.systems.push(r ? GPUParticleSystem.Parse(u, t, a, !0, n) : ParticleSystem.Parse(u, t, a, !0, n))
}
if (e.emitter) {
var c = e.emitter.options;
switch (e.emitter.kind) {
case "Sphere":
o.setEmitterAsSphere({
diameter: c.diameter,
segments: c.segments,
color: Color3.FromArray(c.color)
}, e.emitter.renderingGroupId, t);
break
}
}
return o
}
,
i.BaseAssetsUrl = "https://assets.babylonjs.com/particles",
i
}()
, ProceduralTextureSceneComponent = function() {
function i(e) {
this.name = SceneComponentConstants.NAME_PROCEDURALTEXTURE,
this.scene = e,
this.scene.proceduralTextures = new Array
}
return i.prototype.register = function() {
this.scene._beforeClearStage.registerStep(SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear)
}
,
i.prototype.rebuild = function() {}
,
i.prototype.dispose = function() {}
,
i.prototype._beforeClear = function() {
if (this.scene.proceduralTexturesEnabled) {
Tools.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
for (var e = 0; e < this.scene.proceduralTextures.length; e++) {
var t = this.scene.proceduralTextures[e];
t._shouldRender() && t.render()
}
Tools.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0)
}
}
,
i
}()
, name$1B = "proceduralVertexShader"
, shader$1B = `
attribute vec2 position;
varying vec2 vPosition;
varying vec2 vUV;
const vec2 madd=vec2(0.5,0.5);
void main(void) {
vPosition=position;
vUV=position*madd+madd;
gl_Position=vec4(position,0.0,1.0);
}`;
ShaderStore.ShadersStore[name$1B] = shader$1B;
var ProceduralTexture = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u) {
a === void 0 && (a = null),
s === void 0 && (s = !0),
l === void 0 && (l = !1),
u === void 0 && (u = 0);
var c = i.call(this, null, o, !s) || this;
c.isEnabled = !0,
c.autoClear = !0,
c.onGeneratedObservable = new Observable,
c.onBeforeGenerationObservable = new Observable,
c.nodeMaterialSource = null,
c._textures = {},
c._currentRefreshId = -1,
c._frameId = -1,
c._refreshRate = 1,
c._vertexBuffers = {},
c._uniforms = new Array,
c._samplers = new Array,
c._floats = {},
c._ints = {},
c._floatsArrays = {},
c._colors3 = {},
c._colors4 = {},
c._vectors2 = {},
c._vectors3 = {},
c._matrices = {},
c._fallbackTextureUsed = !1,
c._cachedDefines = null,
c._contentUpdateId = -1,
c._rtWrapper = null,
o = c.getScene() || EngineStore.LastCreatedScene;
var h = o._getComponent(SceneComponentConstants.NAME_PROCEDURALTEXTURE);
h || (h = new ProceduralTextureSceneComponent(o),
o._addComponent(h)),
o.proceduralTextures.push(c),
c._fullEngine = o.getEngine(),
c.name = t,
c.isRenderTarget = !0,
c._size = r,
c._textureType = u,
c._generateMipMaps = s,
c._drawWrapper = new DrawWrapper(c._fullEngine),
c.setFragment(n),
c._fallbackTexture = a,
l ? (c._rtWrapper = c._fullEngine.createRenderTargetCubeTexture(r, {
generateMipMaps: s,
generateDepthBuffer: !1,
generateStencilBuffer: !1,
type: u
}),
c.setFloat("face", 0)) : c._rtWrapper = c._fullEngine.createRenderTargetTexture(r, {
generateMipMaps: s,
generateDepthBuffer: !1,
generateStencilBuffer: !1,
type: u
}),
c._texture = c._rtWrapper.texture;
var f = [];
return f.push(1, 1),
f.push(-1, 1),
f.push(-1, -1),
f.push(1, -1),
c._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(c._fullEngine,f,VertexBuffer.PositionKind,!1,!1,2),
c._createIndexBuffer(),
c
}
return e.prototype.getEffect = function() {
return this._drawWrapper.effect
}
,
e.prototype._setEffect = function(t) {
this._drawWrapper.effect = t
}
,
e.prototype.getContent = function() {
var t = this;
return this._contentData && this._frameId === this._contentUpdateId ? this._contentData : (this._contentData ? this._contentData.then(function(r) {
t._contentData = t.readPixels(0, 0, r),
t._contentUpdateId = t._frameId
}) : (this._contentData = this.readPixels(0, 0),
this._contentUpdateId = this._frameId),
this._contentData)
}
,
e.prototype._createIndexBuffer = function() {
var t = this._fullEngine
, r = [];
r.push(0),
r.push(1),
r.push(2),
r.push(0),
r.push(2),
r.push(3),
this._indexBuffer = t.createIndexBuffer(r)
}
,
e.prototype._rebuild = function() {
var t = this._vertexBuffers[VertexBuffer.PositionKind];
t && t._rebuild(),
this._createIndexBuffer(),
this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE && (this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE)
}
,
e.prototype.reset = function() {
var t;
(t = this._drawWrapper.effect) === null || t === void 0 || t.dispose()
}
,
e.prototype._getDefines = function() {
return ""
}
,
e.prototype.isReady = function() {
var t = this, r = this._fullEngine, n;
if (this.nodeMaterialSource)
return this._drawWrapper.effect.isReady();
if (!this._fragment)
return !1;
if (this._fallbackTextureUsed)
return !0;
var o = this._getDefines();
return this._drawWrapper.effect && o === this._cachedDefines && this._drawWrapper.effect.isReady() ? !0 : (this._fragment.fragmentElement !== void 0 ? n = {
vertex: "procedural",
fragmentElement: this._fragment.fragmentElement
} : n = {
vertex: "procedural",
fragment: this._fragment
},
this._cachedDefines !== o && (this._cachedDefines = o,
this._drawWrapper.effect = r.createEffect(n, [VertexBuffer.PositionKind], this._uniforms, this._samplers, o, void 0, void 0, function() {
var a;
(a = t._rtWrapper) === null || a === void 0 || a.dispose(),
t._rtWrapper = t._texture = null,
t._fallbackTexture && (t._texture = t._fallbackTexture._texture,
t._texture && t._texture.incrementReferences()),
t._fallbackTextureUsed = !0
})),
this._drawWrapper.effect.isReady())
}
,
e.prototype.resetRefreshCounter = function() {
this._currentRefreshId = -1
}
,
e.prototype.setFragment = function(t) {
this._fragment = t
}
,
Object.defineProperty(e.prototype, "refreshRate", {
get: function() {
return this._refreshRate
},
set: function(t) {
this._refreshRate = t,
this.resetRefreshCounter()
},
enumerable: !1,
configurable: !0
}),
e.prototype._shouldRender = function() {
return !this.isEnabled || !this.isReady() || !this._texture ? (this._texture && (this._texture.isReady = !1),
!1) : this._fallbackTextureUsed ? !1 : this._currentRefreshId === -1 ? (this._currentRefreshId = 1,
this._frameId++,
!0) : this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
this._frameId++,
!0) : (this._currentRefreshId++,
!1)
}
,
e.prototype.getRenderSize = function() {
return this._size
}
,
e.prototype.resize = function(t, r) {
var n;
this._fallbackTextureUsed || ((n = this._rtWrapper) === null || n === void 0 || n.dispose(),
this._rtWrapper = this._fullEngine.createRenderTargetTexture(t, {
generateMipMaps: r,
generateDepthBuffer: !1,
generateStencilBuffer: !1,
type: this._textureType
}),
this._texture = this._rtWrapper.texture,
this._size = t,
this._generateMipMaps = r)
}
,
e.prototype._checkUniform = function(t) {
this._uniforms.indexOf(t) === -1 && this._uniforms.push(t)
}
,
e.prototype.setTexture = function(t, r) {
return this._samplers.indexOf(t) === -1 && this._samplers.push(t),
this._textures[t] = r,
this
}
,
e.prototype.setFloat = function(t, r) {
return this._checkUniform(t),
this._floats[t] = r,
this
}
,
e.prototype.setInt = function(t, r) {
return this._checkUniform(t),
this._ints[t] = r,
this
}
,
e.prototype.setFloats = function(t, r) {
return this._checkUniform(t),
this._floatsArrays[t] = r,
this
}
,
e.prototype.setColor3 = function(t, r) {
return this._checkUniform(t),
this._colors3[t] = r,
this
}
,
e.prototype.setColor4 = function(t, r) {
return this._checkUniform(t),
this._colors4[t] = r,
this
}
,
e.prototype.setVector2 = function(t, r) {
return this._checkUniform(t),
this._vectors2[t] = r,
this
}
,
e.prototype.setVector3 = function(t, r) {
return this._checkUniform(t),
this._vectors3[t] = r,
this
}
,
e.prototype.setMatrix = function(t, r) {
return this._checkUniform(t),
this._matrices[t] = r,
this
}
,
e.prototype.render = function(t) {
var r, n, o = this.getScene();
if (!!o) {
var a = this._fullEngine;
if (a.enableEffect(this._drawWrapper),
this.onBeforeGenerationObservable.notifyObservers(this),
a.setState(!1),
!this.nodeMaterialSource) {
for (var s in this._textures)
this._drawWrapper.effect.setTexture(s, this._textures[s]);
for (s in this._ints)
this._drawWrapper.effect.setInt(s, this._ints[s]);
for (s in this._floats)
this._drawWrapper.effect.setFloat(s, this._floats[s]);
for (s in this._floatsArrays)
this._drawWrapper.effect.setArray(s, this._floatsArrays[s]);
for (s in this._colors3)
this._drawWrapper.effect.setColor3(s, this._colors3[s]);
for (s in this._colors4) {
var l = this._colors4[s];
this._drawWrapper.effect.setFloat4(s, l.r, l.g, l.b, l.a)
}
for (s in this._vectors2)
this._drawWrapper.effect.setVector2(s, this._vectors2[s]);
for (s in this._vectors3)
this._drawWrapper.effect.setVector3(s, this._vectors3[s]);
for (s in this._matrices)
this._drawWrapper.effect.setMatrix(s, this._matrices[s])
}
if (!(!this._texture || !this._rtWrapper)) {
if ((r = a._debugPushGroup) === null || r === void 0 || r.call(a, "procedural texture generation for " + this.name, 1),
this.isCube)
for (var u = 0; u < 6; u++)
a.bindFramebuffer(this._rtWrapper, u, void 0, void 0, !0),
a.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
this._drawWrapper.effect.setFloat("face", u),
this.autoClear && a.clear(o.clearColor, !0, !1, !1),
a.drawElementsType(Material.TriangleFillMode, 0, 6);
else
a.bindFramebuffer(this._rtWrapper, 0, void 0, void 0, !0),
a.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
this.autoClear && a.clear(o.clearColor, !0, !1, !1),
a.drawElementsType(Material.TriangleFillMode, 0, 6);
a.unBindFramebuffer(this._rtWrapper, this.isCube),
this.isCube && a.generateMipMapsForCubemap(this._texture),
(n = a._debugPopGroup) === null || n === void 0 || n.call(a, 1),
this.onGenerated && this.onGenerated(),
this.onGeneratedObservable.notifyObservers(this)
}
}
}
,
e.prototype.clone = function() {
var t = this.getSize()
, r = new e(this.name,t.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);
return r.hasAlpha = this.hasAlpha,
r.level = this.level,
r.coordinatesMode = this.coordinatesMode,
r
}
,
e.prototype.dispose = function() {
var t = this.getScene();
if (!!t) {
var r = t.proceduralTextures.indexOf(this);
r >= 0 && t.proceduralTextures.splice(r, 1);
var n = this._vertexBuffers[VertexBuffer.PositionKind];
n && (n.dispose(),
this._vertexBuffers[VertexBuffer.PositionKind] = null),
this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer) && (this._indexBuffer = null),
this.onGeneratedObservable.clear(),
this.onBeforeGenerationObservable.clear(),
i.prototype.dispose.call(this)
}
}
,
__decorate([serialize()], e.prototype, "isEnabled", void 0),
__decorate([serialize()], e.prototype, "autoClear", void 0),
__decorate([serialize()], e.prototype, "_generateMipMaps", void 0),
__decorate([serialize()], e.prototype, "_size", void 0),
__decorate([serialize()], e.prototype, "refreshRate", null),
e
}(Texture);
RegisterClass("BABYLON.ProceduralTexture", ProceduralTexture);
var name$1A = "noisePixelShader"
, shader$1A = `
uniform float brightness;
uniform float persistence;
uniform float timeScale;
varying vec2 vUV;
vec2 hash22(vec2 p)
{
p=p*mat2(127.1,311.7,269.5,183.3);
p=-1.0+2.0*fract(sin(p)*43758.5453123);
return sin(p*6.283+timeScale);
}
float interpolationNoise(vec2 p)
{
vec2 pi=floor(p);
vec2 pf=p-pi;
vec2 w=pf*pf*(3.-2.*pf);
float f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));
float f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));
float f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));
float f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));
float xm1=mix(f00,f10,w.x);
float xm2=mix(f01,f11,w.x);
float ym=mix(xm1,xm2,w.y);
return ym;
}
float perlinNoise2D(float x,float y)
{
float sum=0.0;
float frequency=0.0;
float amplitude=0.0;
for(int i=0; i 0
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isDirectlyConnectedToVertexOutput", {
get: function() {
if (!this.hasEndpoints)
return !1;
for (var e = 0, t = this._endpoints; e < t.length; e++) {
var r = t[e];
if (r.ownerBlock.target === NodeMaterialBlockTargets.Vertex || (r.ownerBlock.target === NodeMaterialBlockTargets.Neutral || r.ownerBlock.target === NodeMaterialBlockTargets.VertexAndFragment) && r.ownerBlock.outputs.some(function(n) {
return n.isDirectlyConnectedToVertexOutput
}))
return !0
}
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isConnectedInVertexShader", {
get: function() {
if (this.target === NodeMaterialBlockTargets.Vertex)
return !0;
if (!this.hasEndpoints)
return !1;
for (var e = 0, t = this._endpoints; e < t.length; e++) {
var r = t[e];
if (r.ownerBlock.target === NodeMaterialBlockTargets.Vertex || r.target === NodeMaterialBlockTargets.Vertex || (r.ownerBlock.target === NodeMaterialBlockTargets.Neutral || r.ownerBlock.target === NodeMaterialBlockTargets.VertexAndFragment) && r.ownerBlock.outputs.some(function(n) {
return n.isConnectedInVertexShader
}))
return !0
}
return !1
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isConnectedInFragmentShader", {
get: function() {
if (this.target === NodeMaterialBlockTargets.Fragment)
return !0;
if (!this.hasEndpoints)
return !1;
for (var e = 0, t = this._endpoints; e < t.length; e++) {
var r = t[e];
if (r.ownerBlock.target === NodeMaterialBlockTargets.Fragment || (r.ownerBlock.target === NodeMaterialBlockTargets.Neutral || r.ownerBlock.target === NodeMaterialBlockTargets.VertexAndFragment) && r.ownerBlock.outputs.some(function(n) {
return n.isConnectedInFragmentShader
}))
return !0
}
return !1
},
enumerable: !1,
configurable: !0
}),
i.prototype.createCustomInputBlock = function() {
return null
}
,
i.prototype.getClassName = function() {
return "NodeMaterialConnectionPoint"
}
,
i.prototype.canConnectTo = function(e) {
return this.checkCompatibilityState(e) === NodeMaterialConnectionPointCompatibilityStates.Compatible
}
,
i.prototype.checkCompatibilityState = function(e) {
var t = this._ownerBlock
, r = e.ownerBlock;
if (t.target === NodeMaterialBlockTargets.Fragment) {
if (r.target === NodeMaterialBlockTargets.Vertex)
return NodeMaterialConnectionPointCompatibilityStates.TargetIncompatible;
for (var n = 0, o = r.outputs; n < o.length; n++) {
var a = o[n];
if (a.ownerBlock.target != NodeMaterialBlockTargets.Neutral && a.isConnectedInVertexShader)
return NodeMaterialConnectionPointCompatibilityStates.TargetIncompatible
}
}
if (this.type !== e.type && e.innerType !== NodeMaterialBlockConnectionPointTypes.AutoDetect)
return i.AreEquivalentTypes(this.type, e.type) || e.acceptedConnectionPointTypes && e.acceptedConnectionPointTypes.indexOf(this.type) !== -1 || e._acceptedConnectionPointType && i.AreEquivalentTypes(e._acceptedConnectionPointType.type, this.type) ? NodeMaterialConnectionPointCompatibilityStates.Compatible : NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible;
if (e.excludedConnectionPointTypes && e.excludedConnectionPointTypes.indexOf(this.type) !== -1)
return NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible;
var s = r
, l = t;
return this.direction === NodeMaterialConnectionPointDirection.Input && (s = t,
l = r),
s.isAnAncestorOf(l) ? NodeMaterialConnectionPointCompatibilityStates.HierarchyIssue : NodeMaterialConnectionPointCompatibilityStates.Compatible
}
,
i.prototype.connectTo = function(e, t) {
if (t === void 0 && (t = !1),
!t && !this.canConnectTo(e))
throw "Cannot connect these two connectors.";
return this._endpoints.push(e),
e._connectedPoint = this,
this._enforceAssociatedVariableName = !1,
this.onConnectionObservable.notifyObservers(e),
e.onConnectionObservable.notifyObservers(this),
this
}
,
i.prototype.disconnectFrom = function(e) {
var t = this._endpoints.indexOf(e);
return t === -1 ? this : (this._endpoints.splice(t, 1),
e._connectedPoint = null,
this._enforceAssociatedVariableName = !1,
e._enforceAssociatedVariableName = !1,
this)
}
,
i.prototype.serialize = function(e) {
e === void 0 && (e = !0);
var t = {};
return t.name = this.name,
t.displayName = this.displayName,
e && this.connectedPoint && (t.inputName = this.name,
t.targetBlockId = this.connectedPoint.ownerBlock.uniqueId,
t.targetConnectionName = this.connectedPoint.name,
t.isExposedOnFrame = !0,
t.exposedPortPosition = this.exposedPortPosition),
(this.isExposedOnFrame || this.exposedPortPosition >= 0) && (t.isExposedOnFrame = !0,
t.exposedPortPosition = this.exposedPortPosition),
t
}
,
i.prototype.dispose = function() {
this.onConnectionObservable.clear()
}
,
i
}()
, NodeMaterialBlock = function() {
function i(e, t, r, n) {
t === void 0 && (t = NodeMaterialBlockTargets.Vertex),
r === void 0 && (r = !1),
n === void 0 && (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.visibleOnFrame = !1,
this._target = t,
this._originalTargetIsNeutral = t === NodeMaterialBlockTargets.Neutral,
this._isFinalMerger = r,
this._isInput = n,
this._name = e,
this.uniqueId = UniqueIdGenerator.UniqueId
}
return Object.defineProperty(i.prototype, "name", {
get: function() {
return this._name
},
set: function(e) {
!this.validateBlockName(e) || (this._name = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isUnique", {
get: function() {
return this._isUnique
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isFinalMerger", {
get: function() {
return this._isFinalMerger
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "isInput", {
get: function() {
return this._isInput
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "buildId", {
get: function() {
return this._buildId
},
set: function(e) {
this._buildId = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "target", {
get: function() {
return this._target
},
set: function(e) {
(this._target & e) === 0 && (this._target = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "inputs", {
get: function() {
return this._inputs
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "outputs", {
get: function() {
return this._outputs
},
enumerable: !1,
configurable: !0
}),
i.prototype.getInputByName = function(e) {
var t = this._inputs.filter(function(r) {
return r.name === e
});
return t.length ? t[0] : null
}
,
i.prototype.getOutputByName = function(e) {
var t = this._outputs.filter(function(r) {
return r.name === e
});
return t.length ? t[0] : null
}
,
i.prototype.initialize = function(e) {}
,
i.prototype.bind = function(e, t, r, n) {}
,
i.prototype._declareOutput = function(e, t) {
return t._getGLType(e.type) + " " + e.associatedVariableName
}
,
i.prototype._writeVariable = function(e) {
var t = e.connectedPoint;
return t ? "" + e.associatedVariableName : "0."
}
,
i.prototype._writeFloat = function(e) {
var t = e.toString();
return t.indexOf(".") === -1 && (t += ".0"),
"" + t
}
,
i.prototype.getClassName = function() {
return "NodeMaterialBlock"
}
,
i.prototype.registerInput = function(e, t, r, n, o) {
return r === void 0 && (r = !1),
o = o != null ? o : new NodeMaterialConnectionPoint(e,this,NodeMaterialConnectionPointDirection.Input),
o.type = t,
o.isOptional = r,
n && (o.target = n),
this._inputs.push(o),
this
}
,
i.prototype.registerOutput = function(e, t, r, n) {
return n = n != null ? n : new NodeMaterialConnectionPoint(e,this,NodeMaterialConnectionPointDirection.Output),
n.type = t,
r && (n.target = r),
this._outputs.push(n),
this
}
,
i.prototype.getFirstAvailableInput = function(e) {
e === void 0 && (e = null);
for (var t = 0, r = this._inputs; t < r.length; t++) {
var n = r[t];
if (!n.connectedPoint && (!e || e.type === n.type || n.type === NodeMaterialBlockConnectionPointTypes.AutoDetect))
return n
}
return null
}
,
i.prototype.getFirstAvailableOutput = function(e) {
e === void 0 && (e = null);
for (var t = 0, r = this._outputs; t < r.length; t++) {
var n = r[t];
if (!e || !e.target || e.target === NodeMaterialBlockTargets.Neutral || (e.target & n.target) !== 0)
return n
}
return null
}
,
i.prototype.getSiblingOutput = function(e) {
var t = this._outputs.indexOf(e);
return t === -1 || t >= this._outputs.length ? null : this._outputs[t + 1]
}
,
i.prototype.isAnAncestorOf = function(e) {
for (var t = 0, r = this._outputs; t < r.length; t++) {
var n = r[t];
if (!!n.hasEndpoints)
for (var o = 0, a = n.endpoints; o < a.length; o++) {
var s = a[o];
if (s.ownerBlock === e || s.ownerBlock.isAnAncestorOf(e))
return !0
}
}
return !1
}
,
i.prototype.connectTo = function(e, t) {
if (this._outputs.length !== 0) {
for (var r = t && t.output ? this.getOutputByName(t.output) : this.getFirstAvailableOutput(e), n = !0; n; ) {
var o = t && t.input ? e.getInputByName(t.input) : e.getFirstAvailableInput(r);
if (r && o && r.canConnectTo(o))
r.connectTo(o),
n = !1;
else if (r)
r = this.getSiblingOutput(r);
else
throw "Unable to find a compatible match"
}
return this
}
}
,
i.prototype._buildBlock = function(e) {}
,
i.prototype.updateUniformsAndSamples = function(e, t, r, n) {}
,
i.prototype.provideFallbacks = function(e, t) {}
,
i.prototype.initializeDefines = function(e, t, r, n) {}
,
i.prototype.prepareDefines = function(e, t, r, n, o) {}
,
i.prototype.autoConfigure = function(e) {}
,
i.prototype.replaceRepeatableContent = function(e, t, r, n) {}
,
Object.defineProperty(i.prototype, "willBeGeneratedIntoVertexShaderFromFragmentShader", {
get: function() {
return this.isInput || this.isFinalMerger || this._outputs.some(function(e) {
return e.isDirectlyConnectedToVertexOutput
}) ? !1 : !!(this.target === NodeMaterialBlockTargets.Vertex || (this.target === NodeMaterialBlockTargets.VertexAndFragment || this.target === NodeMaterialBlockTargets.Neutral) && this._outputs.some(function(e) {
return e.isConnectedInVertexShader
}))
},
enumerable: !1,
configurable: !0
}),
i.prototype.isReady = function(e, t, r, n) {
return !0
}
,
i.prototype._linkConnectionTypes = function(e, t, r) {
r === void 0 && (r = !1),
r ? this._inputs[t]._acceptedConnectionPointType = this._inputs[e] : this._inputs[e]._linkedConnectionSource = this._inputs[t],
this._inputs[t]._linkedConnectionSource = this._inputs[e]
}
,
i.prototype._processBuild = function(e, t, r, n) {
e.build(t, n);
var o = t._vertexState != null
, a = e._buildTarget === NodeMaterialBlockTargets.Vertex && e.target !== NodeMaterialBlockTargets.VertexAndFragment;
if (o && ((e.target & e._buildTarget) === 0 || (e.target & r.target) === 0 || this.target !== NodeMaterialBlockTargets.VertexAndFragment && a) && (!e.isInput && t.target !== e._buildTarget || e.isInput && e.isAttribute && !e._noContextSwitch)) {
var s = r.connectedPoint;
t._vertexState._emitVaryingFromString("v_" + s.associatedVariableName, t._getGLType(s.type)) && (t._vertexState.compilationString += "v_" + s.associatedVariableName + " = " + s.associatedVariableName + `;\r
`),
r.associatedVariableName = "v_" + s.associatedVariableName,
r._enforceAssociatedVariableName = !0
}
}
,
i.prototype.validateBlockName = function(e) {
for (var t = ["position", "normal", "tangent", "particle_positionw", "uv", "uv2", "uv3", "uv4", "uv5", "uv6", "position2d", "particle_uv", "matricesIndices", "matricesWeights", "world0", "world1", "world2", "world3", "particle_color", "particle_texturemask"], r = 0, n = t; r < n.length; r++) {
var o = n[r];
if (e === o)
return !1
}
return !0
}
,
i.prototype.build = function(e, t) {
if (this._buildId === e.sharedData.buildId)
return !0;
if (!this.isInput)
for (var r = 0, n = this._outputs; r < n.length; r++) {
var o = n[r];
o.associatedVariableName || (o.associatedVariableName = e._getFreeVariableName(o.name))
}
for (var a = 0, s = this._inputs; a < s.length; a++) {
var l = s[a];
if (!l.connectedPoint) {
l.isOptional || e.sharedData.checks.notConnectedNonOptionalInputs.push(l);
continue
}
if (!(this.target !== NodeMaterialBlockTargets.Neutral && ((l.target & this.target) === 0 || (l.target & e.target) === 0))) {
var u = l.connectedPoint.ownerBlock;
u && u !== this && this._processBuild(u, e, l, t)
}
}
if (this._buildId === e.sharedData.buildId)
return !0;
if (e.sharedData.verbose && console.log((e.target === NodeMaterialBlockTargets.Vertex ? "Vertex shader" : "Fragment shader") + ": Building " + this.name + " [" + this.getClassName() + "]"),
this.isFinalMerger)
switch (e.target) {
case NodeMaterialBlockTargets.Vertex:
e.sharedData.checks.emitVertex = !0;
break;
case NodeMaterialBlockTargets.Fragment:
e.sharedData.checks.emitFragment = !0;
break
}
!this.isInput && e.sharedData.emitComments && (e.compilationString += `\r
//` + this.name + `\r
`),
this._buildBlock(e),
this._buildId = e.sharedData.buildId,
this._buildTarget = e.target;
for (var c = 0, h = this._outputs; c < h.length; c++) {
var o = h[c];
if ((o.target & e.target) !== 0)
for (var f = 0, d = o.endpoints; f < d.length; f++) {
var _ = d[f]
, u = _.ownerBlock;
u && (u.target & e.target) !== 0 && t.indexOf(u) !== -1 && this._processBuild(u, e, _, t)
}
}
return !1
}
,
i.prototype._inputRename = function(e) {
return e
}
,
i.prototype._outputRename = function(e) {
return e
}
,
i.prototype._dumpPropertiesCode = function() {
var e = this._codeVariableName;
return e + ".visibleInInspector = " + this.visibleInInspector + `;\r
` + e + ".visibleOnFrame = " + this.visibleOnFrame + `;\r
` + e + ".target = " + this.target + `;\r
`
}
,
i.prototype._dumpCode = function(e, t) {
t.push(this);
var r, n = this.name.replace(/[^A-Za-z_]+/g, "");
if (this._codeVariableName = n || this.getClassName() + "_" + this.uniqueId,
e.indexOf(this._codeVariableName) !== -1) {
var o = 0;
do
o++,
this._codeVariableName = n + o;
while (e.indexOf(this._codeVariableName) !== -1)
}
e.push(this._codeVariableName),
r = `\r
// ` + this.getClassName() + `\r
`,
this.comments && (r += "// " + this.comments + `\r
`),
r += "var " + this._codeVariableName + " = new BABYLON." + this.getClassName() + '("' + this.name + `");\r
`,
r += this._dumpPropertiesCode();
for (var a = 0, s = this.inputs; a < s.length; a++) {
var l = s[a];
if (!!l.isConnected) {
var u = l.connectedPoint
, c = u.ownerBlock;
t.indexOf(c) === -1 && (r += c._dumpCode(e, t))
}
}
for (var h = 0, f = this.outputs; h < f.length; h++) {
var d = f[h];
if (!!d.hasEndpoints)
for (var _ = 0, g = d.endpoints; _ < g.length; _++) {
var m = g[_]
, c = m.ownerBlock;
c && t.indexOf(c) === -1 && (r += c._dumpCode(e, t))
}
}
return r
}
,
i.prototype._dumpCodeForOutputConnections = function(e) {
var t = "";
if (e.indexOf(this) !== -1)
return t;
e.push(this);
for (var r = 0, n = this.inputs; r < n.length; r++) {
var o = n[r];
if (!!o.isConnected) {
var a = o.connectedPoint
, s = a.ownerBlock;
t += s._dumpCodeForOutputConnections(e),
t += s._codeVariableName + "." + s._outputRename(a.name) + ".connectTo(" + this._codeVariableName + "." + this._inputRename(o.name) + `);\r
`
}
}
return t
}
,
i.prototype.clone = function(e, t) {
t === void 0 && (t = "");
var r = this.serialize()
, n = GetClass(r.customType);
if (n) {
var o = new n;
return o._deserialize(r, e, t),
o
}
return null
}
,
i.prototype.serialize = function() {
var e = {};
e.customType = "BABYLON." + this.getClassName(),
e.id = this.uniqueId,
e.name = this.name,
e.comments = this.comments,
e.visibleInInspector = this.visibleInInspector,
e.visibleOnFrame = this.visibleOnFrame,
e.target = this.target,
e.inputs = [],
e.outputs = [];
for (var t = 0, r = this.inputs; t < r.length; t++) {
var n = r[t];
e.inputs.push(n.serialize())
}
for (var o = 0, a = this.outputs; o < a.length; o++) {
var s = a[o];
e.outputs.push(s.serialize(!1))
}
return e
}
,
i.prototype._deserialize = function(e, t, r) {
var n;
this.name = e.name,
this.comments = e.comments,
this.visibleInInspector = !!e.visibleInInspector,
this.visibleOnFrame = !!e.visibleOnFrame,
this._target = (n = e.target) !== null && n !== void 0 ? n : this.target,
this._deserializePortDisplayNamesAndExposedOnFrame(e)
}
,
i.prototype._deserializePortDisplayNamesAndExposedOnFrame = function(e) {
var t = this
, r = e.inputs
, n = e.outputs;
r && r.forEach(function(o, a) {
o.displayName && (t.inputs[a].displayName = o.displayName),
o.isExposedOnFrame && (t.inputs[a].isExposedOnFrame = o.isExposedOnFrame,
t.inputs[a].exposedPortPosition = o.exposedPortPosition)
}),
n && n.forEach(function(o, a) {
o.displayName && (t.outputs[a].displayName = o.displayName),
o.isExposedOnFrame && (t.outputs[a].isExposedOnFrame = o.isExposedOnFrame,
t.outputs[a].exposedPortPosition = o.exposedPortPosition)
})
}
,
i.prototype.dispose = function() {
for (var e = 0, t = this.inputs; e < t.length; e++) {
var r = t[e];
r.dispose()
}
for (var n = 0, o = this.outputs; n < o.length; n++) {
var a = o[n];
a.dispose()
}
}
,
i
}()
, NodeMaterialBuildState = function() {
function i() {
this.supportUniformBuffers = !1,
this.attributes = new Array,
this.uniforms = new Array,
this.constants = new Array,
this.samplers = new Array,
this.functions = {},
this.extensions = {},
this.counters = {},
this._attributeDeclaration = "",
this._uniformDeclaration = "",
this._constantDeclaration = "",
this._samplerDeclaration = "",
this._varyingTransfer = "",
this._injectAtEnd = "",
this._repeatableContentAnchorIndex = 0,
this._builtCompilationString = "",
this.compilationString = ""
}
return i.prototype.finalize = function(e) {
var t = e.sharedData.emitComments
, r = this.target === NodeMaterialBlockTargets.Fragment;
this.compilationString = `\r
` + (t ? `//Entry point\r
` : "") + `void main(void) {\r
` + this.compilationString,
this._constantDeclaration && (this.compilationString = `\r
` + (t ? `//Constants\r
` : "") + this._constantDeclaration + `\r
` + this.compilationString);
var n = "";
for (var o in this.functions)
n += this.functions[o] + `\r
`;
this.compilationString = `\r
` + n + `\r
` + this.compilationString,
!r && this._varyingTransfer && (this.compilationString = this.compilationString + `\r
` + this._varyingTransfer),
this._injectAtEnd && (this.compilationString = this.compilationString + `\r
` + this._injectAtEnd),
this.compilationString = this.compilationString + `\r
}`,
this.sharedData.varyingDeclaration && (this.compilationString = `\r
` + (t ? `//Varyings\r
` : "") + this.sharedData.varyingDeclaration + `\r
` + this.compilationString),
this._samplerDeclaration && (this.compilationString = `\r
` + (t ? `//Samplers\r
` : "") + this._samplerDeclaration + `\r
` + this.compilationString),
this._uniformDeclaration && (this.compilationString = `\r
` + (t ? `//Uniforms\r
` : "") + this._uniformDeclaration + `\r
` + this.compilationString),
this._attributeDeclaration && !r && (this.compilationString = `\r
` + (t ? `//Attributes\r
` : "") + this._attributeDeclaration + `\r
` + this.compilationString),
this.compilationString = `precision highp float;\r
` + this.compilationString;
for (var a in this.extensions) {
var s = this.extensions[a];
this.compilationString = `\r
` + s + `\r
` + this.compilationString
}
this._builtCompilationString = this.compilationString
}
,
Object.defineProperty(i.prototype, "_repeatableContentAnchor", {
get: function() {
return "###___ANCHOR" + this._repeatableContentAnchorIndex++ + "___###"
},
enumerable: !1,
configurable: !0
}),
i.prototype._getFreeVariableName = function(e) {
return e = e.replace(/[^a-zA-Z_]+/g, ""),
this.sharedData.variableNames[e] === void 0 ? (this.sharedData.variableNames[e] = 0,
e === "output" || e === "texture" ? e + this.sharedData.variableNames[e] : e) : (this.sharedData.variableNames[e]++,
e + this.sharedData.variableNames[e])
}
,
i.prototype._getFreeDefineName = function(e) {
return this.sharedData.defineNames[e] === void 0 ? this.sharedData.defineNames[e] = 0 : this.sharedData.defineNames[e]++,
e + this.sharedData.defineNames[e]
}
,
i.prototype._excludeVariableName = function(e) {
this.sharedData.variableNames[e] = 0
}
,
i.prototype._emit2DSampler = function(e) {
this.samplers.indexOf(e) < 0 && (this._samplerDeclaration += "uniform sampler2D " + e + `;\r
`,
this.samplers.push(e))
}
,
i.prototype._getGLType = function(e) {
switch (e) {
case NodeMaterialBlockConnectionPointTypes.Float:
return "float";
case NodeMaterialBlockConnectionPointTypes.Int:
return "int";
case NodeMaterialBlockConnectionPointTypes.Vector2:
return "vec2";
case NodeMaterialBlockConnectionPointTypes.Color3:
case NodeMaterialBlockConnectionPointTypes.Vector3:
return "vec3";
case NodeMaterialBlockConnectionPointTypes.Color4:
case NodeMaterialBlockConnectionPointTypes.Vector4:
return "vec4";
case NodeMaterialBlockConnectionPointTypes.Matrix:
return "mat4"
}
return ""
}
,
i.prototype._emitExtension = function(e, t, r) {
r === void 0 && (r = ""),
!this.extensions[e] && (r && (t = "#if " + r + `\r
` + t + `\r
#endif`),
this.extensions[e] = t)
}
,
i.prototype._emitFunction = function(e, t, r) {
this.functions[e] || (this.sharedData.emitComments && (t = r + `\r
` + t),
this.functions[e] = t)
}
,
i.prototype._emitCodeFromInclude = function(e, t, r) {
if (r && r.repeatKey)
return "#include<" + e + ">[0.." + r.repeatKey + `]\r
`;
var n = Effect.IncludesShadersStore[e] + `\r
`;
if (this.sharedData.emitComments && (n = t + `\r
` + n),
!r)
return n;
if (r.replaceStrings)
for (var o = 0; o < r.replaceStrings.length; o++) {
var a = r.replaceStrings[o];
n = n.replace(a.search, a.replace)
}
return n
}
,
i.prototype._emitFunctionFromInclude = function(e, t, r, n) {
n === void 0 && (n = "");
var o = e + n;
if (!this.functions[o]) {
if (!r || !r.removeAttributes && !r.removeUniforms && !r.removeVaryings && !r.removeIfDef && !r.replaceStrings) {
r && r.repeatKey ? this.functions[o] = "#include<" + e + ">[0.." + r.repeatKey + `]\r
` : this.functions[o] = "#include<" + e + `>\r
`,
this.sharedData.emitComments && (this.functions[o] = t + `\r
` + this.functions[o]);
return
}
if (this.functions[o] = Effect.IncludesShadersStore[e],
this.sharedData.emitComments && (this.functions[o] = t + `\r
` + this.functions[o]),
r.removeIfDef && (this.functions[o] = this.functions[o].replace(/^\s*?#ifdef.+$/gm, ""),
this.functions[o] = this.functions[o].replace(/^\s*?#endif.*$/gm, ""),
this.functions[o] = this.functions[o].replace(/^\s*?#else.*$/gm, ""),
this.functions[o] = this.functions[o].replace(/^\s*?#elif.*$/gm, "")),
r.removeAttributes && (this.functions[o] = this.functions[o].replace(/^\s*?attribute.+$/gm, "")),
r.removeUniforms && (this.functions[o] = this.functions[o].replace(/^\s*?uniform.+$/gm, "")),
r.removeVaryings && (this.functions[o] = this.functions[o].replace(/^\s*?varying.+$/gm, "")),
r.replaceStrings)
for (var a = 0; a < r.replaceStrings.length; a++) {
var s = r.replaceStrings[a];
this.functions[o] = this.functions[o].replace(s.search, s.replace)
}
}
}
,
i.prototype._registerTempVariable = function(e) {
return this.sharedData.temps.indexOf(e) !== -1 ? !1 : (this.sharedData.temps.push(e),
!0)
}
,
i.prototype._emitVaryingFromString = function(e, t, r, n) {
return r === void 0 && (r = ""),
n === void 0 && (n = !1),
this.sharedData.varyings.indexOf(e) !== -1 ? !1 : (this.sharedData.varyings.push(e),
r && (StartsWith(r, "defined(") ? this.sharedData.varyingDeclaration += "#if " + r + `\r
` : this.sharedData.varyingDeclaration += (n ? "#ifndef" : "#ifdef") + " " + r + `\r
`),
this.sharedData.varyingDeclaration += "varying " + t + " " + e + `;\r
`,
r && (this.sharedData.varyingDeclaration += `#endif\r
`),
!0)
}
,
i.prototype._emitUniformFromString = function(e, t, r, n) {
r === void 0 && (r = ""),
n === void 0 && (n = !1),
this.uniforms.indexOf(e) === -1 && (this.uniforms.push(e),
r && (StartsWith(r, "defined(") ? this._uniformDeclaration += "#if " + r + `\r
` : this._uniformDeclaration += (n ? "#ifndef" : "#ifdef") + " " + r + `\r
`),
this._uniformDeclaration += "uniform " + t + " " + e + `;\r
`,
r && (this._uniformDeclaration += `#endif\r
`))
}
,
i.prototype._emitFloat = function(e) {
return e.toString() === e.toFixed(0) ? e + ".0" : e.toString()
}
,
i
}()
, NodeMaterialBuildStateSharedData = function() {
function i() {
this.temps = new Array,
this.varyings = new Array,
this.varyingDeclaration = "",
this.inputBlocks = new Array,
this.textureBlocks = new Array,
this.bindableBlocks = new Array,
this.forcedBindableBlocks = new Array,
this.blocksWithFallbacks = new Array,
this.blocksWithDefines = new Array,
this.repeatableContentBlocks = new Array,
this.dynamicUniformBlocks = new Array,
this.blockingBlocks = new Array,
this.animatedInputs = new Array,
this.variableNames = {},
this.defineNames = {},
this.hints = {
needWorldViewMatrix: !1,
needWorldViewProjectionMatrix: !1,
needAlphaBlending: !1,
needAlphaTesting: !1
},
this.checks = {
emitVertex: !1,
emitFragment: !1,
notConnectedNonOptionalInputs: new Array
},
this.allowEmptyVertexProgram = !1,
this.variableNames.position = 0,
this.variableNames.normal = 0,
this.variableNames.tangent = 0,
this.variableNames.uv = 0,
this.variableNames.uv2 = 0,
this.variableNames.uv3 = 0,
this.variableNames.uv4 = 0,
this.variableNames.uv5 = 0,
this.variableNames.uv6 = 0,
this.variableNames.color = 0,
this.variableNames.matricesIndices = 0,
this.variableNames.matricesWeights = 0,
this.variableNames.matricesIndicesExtra = 0,
this.variableNames.matricesWeightsExtra = 0,
this.variableNames.diffuseBase = 0,
this.variableNames.specularBase = 0,
this.variableNames.worldPos = 0,
this.variableNames.shadow = 0,
this.variableNames.view = 0,
this.variableNames.vTBN = 0,
this.defineNames.MAINUV0 = 0,
this.defineNames.MAINUV1 = 0,
this.defineNames.MAINUV2 = 0,
this.defineNames.MAINUV3 = 0,
this.defineNames.MAINUV4 = 0,
this.defineNames.MAINUV5 = 0,
this.defineNames.MAINUV6 = 0,
this.defineNames.MAINUV7 = 0
}
return i.prototype.emitErrors = function() {
var e = "";
!this.checks.emitVertex && !this.allowEmptyVertexProgram && (e += `NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.\r
`),
this.checks.emitFragment || (e += `NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.\r
`);
for (var t = 0, r = this.checks.notConnectedNonOptionalInputs; t < r.length; t++) {
var n = r[t];
e += "input " + n.name + " from block " + n.ownerBlock.name + "[" + n.ownerBlock.getClassName() + `] is not connected and is not optional.\r
`
}
if (e)
throw `Build of NodeMaterial failed:\r
` + e
}
,
i
}()
, TransformBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.complementW = 1,
r.complementZ = 0,
r.target = NodeMaterialBlockTargets.Vertex,
r.registerInput("vector", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("transform", NodeMaterialBlockConnectionPointTypes.Matrix),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3),
r._inputs[0].onConnectionObservable.add(function(n) {
if (n.ownerBlock.isInput) {
var o = n.ownerBlock;
(o.name === "normal" || o.name === "tangent") && (r.complementW = 0)
}
}),
r
}
return e.prototype.getClassName = function() {
return "TransformBlock"
}
,
Object.defineProperty(e.prototype, "vector", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyz", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "transform", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this.vector
, n = this.transform;
if (r.connectedPoint) {
if (this.complementW === 0) {
var o = "//" + this.name;
t._emitFunctionFromInclude("helperFunctions", o),
t.sharedData.blocksWithDefines.push(this);
var a = t._getFreeVariableName(n.associatedVariableName + "_NUS");
switch (t.compilationString += "mat3 " + a + " = mat3(" + n.associatedVariableName + `);\r
`,
t.compilationString += `#ifdef NONUNIFORMSCALING\r
`,
t.compilationString += a + " = transposeMat3(inverseMat3(" + a + `));\r
`,
t.compilationString += `#endif\r
`,
r.connectedPoint.type) {
case NodeMaterialBlockConnectionPointTypes.Vector2:
t.compilationString += this._declareOutput(this.output, t) + (" = vec4(" + a + " * vec3(" + r.associatedVariableName + ", " + this._writeFloat(this.complementZ) + "), " + this._writeFloat(this.complementW) + `);\r
`);
break;
case NodeMaterialBlockConnectionPointTypes.Vector3:
case NodeMaterialBlockConnectionPointTypes.Color3:
t.compilationString += this._declareOutput(this.output, t) + (" = vec4(" + a + " * " + r.associatedVariableName + ", " + this._writeFloat(this.complementW) + `);\r
`);
break;
default:
t.compilationString += this._declareOutput(this.output, t) + (" = vec4(" + a + " * " + r.associatedVariableName + ".xyz, " + this._writeFloat(this.complementW) + `);\r
`);
break
}
} else {
var a = n.associatedVariableName;
switch (r.connectedPoint.type) {
case NodeMaterialBlockConnectionPointTypes.Vector2:
t.compilationString += this._declareOutput(this.output, t) + (" = " + a + " * vec4(" + r.associatedVariableName + ", " + this._writeFloat(this.complementZ) + ", " + this._writeFloat(this.complementW) + `);\r
`);
break;
case NodeMaterialBlockConnectionPointTypes.Vector3:
case NodeMaterialBlockConnectionPointTypes.Color3:
t.compilationString += this._declareOutput(this.output, t) + (" = " + a + " * vec4(" + r.associatedVariableName + ", " + this._writeFloat(this.complementW) + `);\r
`);
break;
default:
t.compilationString += this._declareOutput(this.output, t) + (" = " + a + " * " + r.associatedVariableName + `;\r
`);
break
}
}
this.xyz.hasEndpoints && (t.compilationString += this._declareOutput(this.xyz, t) + (" = " + this.output.associatedVariableName + `.xyz;\r
`))
}
return this
}
,
e.prototype.prepareDefines = function(t, r, n, o, a) {
t.nonUniformScaling && n.setValue("NONUNIFORMSCALING", !0)
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.complementZ = this.complementZ,
t.complementW = this.complementW,
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.complementZ = t.complementZ !== void 0 ? t.complementZ : 0,
this.complementW = t.complementW !== void 0 ? t.complementW : 1
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".complementZ = " + this.complementZ + `;\r
`);
return t += this._codeVariableName + ".complementW = " + this.complementW + `;\r
`,
t
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.TransformBlock", TransformBlock);
var VertexOutputBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Vertex, !0) || this;
return r.registerInput("vector", NodeMaterialBlockConnectionPointTypes.Vector4),
r
}
return e.prototype.getClassName = function() {
return "VertexOutputBlock"
}
,
Object.defineProperty(e.prototype, "vector", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._isLogarithmicDepthEnabled = function(t) {
for (var r = 0, n = t; r < n.length; r++) {
var o = n[r];
if (o.useLogarithmicDepth)
return !0
}
return !1
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this.vector;
return t.compilationString += "gl_Position = " + r.associatedVariableName + `;\r
`,
this._isLogarithmicDepthEnabled(t.sharedData.fragmentOutputNodes) && (t._emitUniformFromString("logarithmicDepthConstant", "float"),
t._emitVaryingFromString("vFragmentDepth", "float"),
t.compilationString += `vFragmentDepth = 1.0 + gl_Position.w;\r
`,
t.compilationString += `gl_Position.z = log2(max(0.000001, vFragmentDepth)) * logarithmicDepthConstant;\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.VertexOutputBlock", VertexOutputBlock);
var PropertyTypeForEdition;
(function(i) {
i[i.Boolean = 0] = "Boolean",
i[i.Float = 1] = "Float",
i[i.Int = 2] = "Int",
i[i.Vector2 = 3] = "Vector2",
i[i.List = 4] = "List"
}
)(PropertyTypeForEdition || (PropertyTypeForEdition = {}));
function editableInPropertyPage(i, e, t, r) {
return e === void 0 && (e = PropertyTypeForEdition.Boolean),
t === void 0 && (t = "PROPERTIES"),
function(n, o) {
var a = n._propStore;
a || (a = [],
n._propStore = a),
a.push({
propertyName: o,
displayName: i,
type: e,
groupName: t,
options: r != null ? r : {}
})
}
}
var FragmentOutputBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment, !0) || this;
return r.convertToGammaSpace = !1,
r.convertToLinearSpace = !1,
r.useLogarithmicDepth = !1,
r.registerInput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, !0),
r.registerInput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, !0),
r.registerInput("a", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.rgb.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "FragmentOutputBlock"
}
,
e.prototype.initialize = function(t) {
t._excludeVariableName("logarithmicDepthConstant"),
t._excludeVariableName("vFragmentDepth")
}
,
Object.defineProperty(e.prototype, "rgba", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgb", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "a", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
e.prototype.prepareDefines = function(t, r, n) {
n.setValue(this._linearDefineName, this.convertToLinearSpace, !0),
n.setValue(this._gammaDefineName, this.convertToGammaSpace, !0)
}
,
e.prototype.bind = function(t, r, n) {
this.useLogarithmicDepth && n && MaterialHelper.BindLogDepth(void 0, t, n.getScene())
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this.rgba
, n = this.rgb
, o = this.a;
t.sharedData.hints.needAlphaBlending = r.isConnected || o.isConnected,
t.sharedData.blocksWithDefines.push(this),
this.useLogarithmicDepth && (t._emitUniformFromString("logarithmicDepthConstant", "float"),
t._emitVaryingFromString("vFragmentDepth", "float"),
t.sharedData.bindableBlocks.push(this)),
this._linearDefineName = t._getFreeDefineName("CONVERTTOLINEAR"),
this._gammaDefineName = t._getFreeDefineName("CONVERTTOGAMMA");
var a = "//" + this.name;
if (t._emitFunctionFromInclude("helperFunctions", a),
r.connectedPoint)
o.isConnected ? t.compilationString += "gl_FragColor = vec4(" + r.associatedVariableName + ".rgb, " + o.associatedVariableName + `);\r
` : t.compilationString += "gl_FragColor = " + r.associatedVariableName + `;\r
`;
else if (n.connectedPoint) {
var s = "1.0";
o.connectedPoint && (s = o.associatedVariableName),
n.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Float ? t.compilationString += "gl_FragColor = vec4(" + n.associatedVariableName + ", " + n.associatedVariableName + ", " + n.associatedVariableName + ", " + s + `);\r
` : t.compilationString += "gl_FragColor = vec4(" + n.associatedVariableName + ", " + s + `);\r
`
} else
t.sharedData.checks.notConnectedNonOptionalInputs.push(r);
return t.compilationString += "#ifdef " + this._linearDefineName + `\r
`,
t.compilationString += `gl_FragColor = toLinearSpace(gl_FragColor);\r
`,
t.compilationString += `#endif\r
`,
t.compilationString += "#ifdef " + this._gammaDefineName + `\r
`,
t.compilationString += `gl_FragColor = toGammaSpace(gl_FragColor);\r
`,
t.compilationString += `#endif\r
`,
this.useLogarithmicDepth && (t.compilationString += `gl_FragDepthEXT = log2(vFragmentDepth) * logarithmicDepthConstant * 0.5;\r
`),
this
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this);
return t += this._codeVariableName + ".convertToGammaSpace = " + this.convertToGammaSpace + `;\r
`,
t += this._codeVariableName + ".convertToLinearSpace = " + this.convertToLinearSpace + `;\r
`,
t += this._codeVariableName + ".useLogarithmicDepth = " + this.useLogarithmicDepth + `;\r
`,
t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.convertToGammaSpace = this.convertToGammaSpace,
t.convertToLinearSpace = this.convertToLinearSpace,
t.useLogarithmicDepth = this.useLogarithmicDepth,
t
}
,
e.prototype._deserialize = function(t, r, n) {
var o;
i.prototype._deserialize.call(this, t, r, n),
this.convertToGammaSpace = t.convertToGammaSpace,
this.convertToLinearSpace = t.convertToLinearSpace,
this.useLogarithmicDepth = (o = t.useLogarithmicDepth) !== null && o !== void 0 ? o : !1
}
,
__decorate([editableInPropertyPage("Convert to gamma space", PropertyTypeForEdition.Boolean, "PROPERTIES", {
notifiers: {
update: !0
}
})], e.prototype, "convertToGammaSpace", void 0),
__decorate([editableInPropertyPage("Convert to linear space", PropertyTypeForEdition.Boolean, "PROPERTIES", {
notifiers: {
update: !0
}
})], e.prototype, "convertToLinearSpace", void 0),
__decorate([editableInPropertyPage("Use logarithmic depth", PropertyTypeForEdition.Boolean, "PROPERTIES")], e.prototype, "useLogarithmicDepth", void 0),
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.FragmentOutputBlock", FragmentOutputBlock);
var AnimatedInputBlockTypes;
(function(i) {
i[i.None = 0] = "None",
i[i.Time = 1] = "Time"
}
)(AnimatedInputBlockTypes || (AnimatedInputBlockTypes = {}));
var remapAttributeName = {
position2d: "position",
particle_uv: "vUV",
particle_color: "vColor",
particle_texturemask: "textureMask",
particle_positionw: "vPositionW"
}
, attributeInFragmentOnly = {
particle_uv: !0,
particle_color: !0,
particle_texturemask: !0,
particle_positionw: !0
}
, attributeAsUniform = {
particle_texturemask: !0
}
, InputBlock = function(i) {
__extends(e, i);
function e(t, r, n) {
r === void 0 && (r = NodeMaterialBlockTargets.Vertex),
n === void 0 && (n = NodeMaterialBlockConnectionPointTypes.AutoDetect);
var o = i.call(this, t, r, !1, !0) || this;
return o._mode = NodeMaterialBlockConnectionPointMode.Undefined,
o._animationType = AnimatedInputBlockTypes.None,
o.min = 0,
o.max = 0,
o.isBoolean = !1,
o.matrixMode = 0,
o._systemValue = null,
o.isConstant = !1,
o.groupInInspector = "",
o.onValueChangedObservable = new Observable,
o.convertToGammaSpace = !1,
o.convertToLinearSpace = !1,
o._type = n,
o.setDefaultValue(),
o.registerOutput("output", n),
o
}
return Object.defineProperty(e.prototype, "type", {
get: function() {
if (this._type === NodeMaterialBlockConnectionPointTypes.AutoDetect) {
if (this.isUniform && this.value != null) {
if (!isNaN(this.value))
return this._type = NodeMaterialBlockConnectionPointTypes.Float,
this._type;
switch (this.value.getClassName()) {
case "Vector2":
return this._type = NodeMaterialBlockConnectionPointTypes.Vector2,
this._type;
case "Vector3":
return this._type = NodeMaterialBlockConnectionPointTypes.Vector3,
this._type;
case "Vector4":
return this._type = NodeMaterialBlockConnectionPointTypes.Vector4,
this._type;
case "Color3":
return this._type = NodeMaterialBlockConnectionPointTypes.Color3,
this._type;
case "Color4":
return this._type = NodeMaterialBlockConnectionPointTypes.Color4,
this._type;
case "Matrix":
return this._type = NodeMaterialBlockConnectionPointTypes.Matrix,
this._type
}
}
if (this.isAttribute)
switch (this.name) {
case "position":
case "normal":
case "tangent":
case "particle_positionw":
return this._type = NodeMaterialBlockConnectionPointTypes.Vector3,
this._type;
case "uv":
case "uv2":
case "uv3":
case "uv4":
case "uv5":
case "uv6":
case "position2d":
case "particle_uv":
return this._type = NodeMaterialBlockConnectionPointTypes.Vector2,
this._type;
case "matricesIndices":
case "matricesWeights":
case "world0":
case "world1":
case "world2":
case "world3":
return this._type = NodeMaterialBlockConnectionPointTypes.Vector4,
this._type;
case "color":
case "particle_color":
case "particle_texturemask":
return this._type = NodeMaterialBlockConnectionPointTypes.Color4,
this._type
}
if (this.isSystemValue)
switch (this._systemValue) {
case NodeMaterialSystemValues.World:
case NodeMaterialSystemValues.WorldView:
case NodeMaterialSystemValues.WorldViewProjection:
case NodeMaterialSystemValues.View:
case NodeMaterialSystemValues.ViewProjection:
case NodeMaterialSystemValues.Projection:
return this._type = NodeMaterialBlockConnectionPointTypes.Matrix,
this._type;
case NodeMaterialSystemValues.CameraPosition:
return this._type = NodeMaterialBlockConnectionPointTypes.Vector3,
this._type;
case NodeMaterialSystemValues.FogColor:
return this._type = NodeMaterialBlockConnectionPointTypes.Color3,
this._type;
case NodeMaterialSystemValues.DeltaTime:
return this._type = NodeMaterialBlockConnectionPointTypes.Float,
this._type;
case NodeMaterialSystemValues.CameraParameters:
return this._type = NodeMaterialBlockConnectionPointTypes.Vector4,
this._type
}
}
return this._type
},
enumerable: !1,
configurable: !0
}),
e.prototype.validateBlockName = function(t) {
return this.isAttribute ? !0 : i.prototype.validateBlockName.call(this, t)
}
,
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.setAsAttribute = function(t) {
return this._mode = NodeMaterialBlockConnectionPointMode.Attribute,
t && (this.name = t),
this
}
,
e.prototype.setAsSystemValue = function(t) {
return this.systemValue = t,
this
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._storedValue
},
set: function(t) {
this.type === NodeMaterialBlockConnectionPointTypes.Float && (this.isBoolean ? t = t ? 1 : 0 : this.min !== this.max && (t = Math.max(this.min, t),
t = Math.min(this.max, t))),
this._storedValue = t,
this._mode = NodeMaterialBlockConnectionPointMode.Uniform,
this.onValueChangedObservable.notifyObservers(this)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "valueCallback", {
get: function() {
return this._valueCallback
},
set: function(t) {
this._valueCallback = t,
this._mode = NodeMaterialBlockConnectionPointMode.Uniform
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "associatedVariableName", {
get: function() {
return this._associatedVariableName
},
set: function(t) {
this._associatedVariableName = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "animationType", {
get: function() {
return this._animationType
},
set: function(t) {
this._animationType = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isUndefined", {
get: function() {
return this._mode === NodeMaterialBlockConnectionPointMode.Undefined
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isUniform", {
get: function() {
return this._mode === NodeMaterialBlockConnectionPointMode.Uniform
},
set: function(t) {
this._mode = t ? NodeMaterialBlockConnectionPointMode.Uniform : NodeMaterialBlockConnectionPointMode.Undefined,
this.associatedVariableName = ""
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isAttribute", {
get: function() {
return this._mode === NodeMaterialBlockConnectionPointMode.Attribute
},
set: function(t) {
this._mode = t ? NodeMaterialBlockConnectionPointMode.Attribute : NodeMaterialBlockConnectionPointMode.Undefined,
this.associatedVariableName = ""
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isVarying", {
get: function() {
return this._mode === NodeMaterialBlockConnectionPointMode.Varying
},
set: function(t) {
this._mode = t ? NodeMaterialBlockConnectionPointMode.Varying : NodeMaterialBlockConnectionPointMode.Undefined,
this.associatedVariableName = ""
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "isSystemValue", {
get: function() {
return this._systemValue != null
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "systemValue", {
get: function() {
return this._systemValue
},
set: function(t) {
this._mode = NodeMaterialBlockConnectionPointMode.Uniform,
this.associatedVariableName = "",
this._systemValue = t
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "InputBlock"
}
,
e.prototype.animate = function(t) {
switch (this._animationType) {
case AnimatedInputBlockTypes.Time:
{
this.type === NodeMaterialBlockConnectionPointTypes.Float && (this.value += t.getAnimationRatio() * .01);
break
}
}
}
,
e.prototype._emitDefine = function(t) {
return t[0] === "!" ? "#ifndef " + t.substring(1) + `\r
` : "#ifdef " + t + `\r
`
}
,
e.prototype.initialize = function(t) {
this.associatedVariableName = ""
}
,
e.prototype.setDefaultValue = function() {
switch (this.type) {
case NodeMaterialBlockConnectionPointTypes.Float:
this.value = 0;
break;
case NodeMaterialBlockConnectionPointTypes.Vector2:
this.value = Vector2.Zero();
break;
case NodeMaterialBlockConnectionPointTypes.Vector3:
this.value = Vector3.Zero();
break;
case NodeMaterialBlockConnectionPointTypes.Vector4:
this.value = Vector4.Zero();
break;
case NodeMaterialBlockConnectionPointTypes.Color3:
this.value = Color3.White();
break;
case NodeMaterialBlockConnectionPointTypes.Color4:
this.value = new Color4(1,1,1,1);
break;
case NodeMaterialBlockConnectionPointTypes.Matrix:
this.value = Matrix.Identity();
break
}
}
,
e.prototype._emitConstant = function(t) {
switch (this.type) {
case NodeMaterialBlockConnectionPointTypes.Float:
return "" + t._emitFloat(this.value);
case NodeMaterialBlockConnectionPointTypes.Vector2:
return "vec2(" + this.value.x + ", " + this.value.y + ")";
case NodeMaterialBlockConnectionPointTypes.Vector3:
return "vec3(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ")";
case NodeMaterialBlockConnectionPointTypes.Vector4:
return "vec4(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ", " + this.value.w + ")";
case NodeMaterialBlockConnectionPointTypes.Color3:
return TmpColors.Color3[0].set(this.value.r, this.value.g, this.value.b),
this.convertToGammaSpace && TmpColors.Color3[0].toGammaSpaceToRef(TmpColors.Color3[0]),
this.convertToLinearSpace && TmpColors.Color3[0].toLinearSpaceToRef(TmpColors.Color3[0]),
"vec3(" + TmpColors.Color3[0].r + ", " + TmpColors.Color3[0].g + ", " + TmpColors.Color3[0].b + ")";
case NodeMaterialBlockConnectionPointTypes.Color4:
return TmpColors.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
this.convertToGammaSpace && TmpColors.Color4[0].toGammaSpaceToRef(TmpColors.Color4[0]),
this.convertToLinearSpace && TmpColors.Color4[0].toLinearSpaceToRef(TmpColors.Color4[0]),
"vec4(" + TmpColors.Color4[0].r + ", " + TmpColors.Color4[0].g + ", " + TmpColors.Color4[0].b + ", " + TmpColors.Color4[0].a + ")"
}
return ""
}
,
Object.defineProperty(e.prototype, "_noContextSwitch", {
get: function() {
return attributeInFragmentOnly[this.name]
},
enumerable: !1,
configurable: !0
}),
e.prototype._emit = function(t, r) {
var n;
if (this.isUniform) {
if (this.associatedVariableName || (this.associatedVariableName = t._getFreeVariableName("u_" + this.name)),
this.isConstant) {
if (t.constants.indexOf(this.associatedVariableName) !== -1)
return;
t.constants.push(this.associatedVariableName),
t._constantDeclaration += this._declareOutput(this.output, t) + (" = " + this._emitConstant(t) + `;\r
`);
return
}
if (t.uniforms.indexOf(this.associatedVariableName) !== -1)
return;
t.uniforms.push(this.associatedVariableName),
r && (t._uniformDeclaration += this._emitDefine(r)),
t._uniformDeclaration += "uniform " + t._getGLType(this.type) + " " + this.associatedVariableName + `;\r
`,
r && (t._uniformDeclaration += `#endif\r
`);
var o = t.sharedData.hints;
if (this._systemValue !== null && this._systemValue !== void 0)
switch (this._systemValue) {
case NodeMaterialSystemValues.WorldView:
o.needWorldViewMatrix = !0;
break;
case NodeMaterialSystemValues.WorldViewProjection:
o.needWorldViewProjectionMatrix = !0;
break
}
else
this._animationType !== AnimatedInputBlockTypes.None && t.sharedData.animatedInputs.push(this);
return
}
if (this.isAttribute) {
if (this.associatedVariableName = (n = remapAttributeName[this.name]) !== null && n !== void 0 ? n : this.name,
this.target === NodeMaterialBlockTargets.Vertex && t._vertexState) {
attributeInFragmentOnly[this.name] ? attributeAsUniform[this.name] ? t._emitUniformFromString(this.associatedVariableName, t._getGLType(this.type), r) : t._emitVaryingFromString(this.associatedVariableName, t._getGLType(this.type), r) : this._emit(t._vertexState, r);
return
}
if (t.attributes.indexOf(this.associatedVariableName) !== -1)
return;
t.attributes.push(this.associatedVariableName),
attributeInFragmentOnly[this.name] ? attributeAsUniform[this.name] ? t._emitUniformFromString(this.associatedVariableName, t._getGLType(this.type), r) : t._emitVaryingFromString(this.associatedVariableName, t._getGLType(this.type), r) : (r && (t._attributeDeclaration += this._emitDefine(r)),
t._attributeDeclaration += "attribute " + t._getGLType(this.type) + " " + this.associatedVariableName + `;\r
`,
r && (t._attributeDeclaration += `#endif\r
`))
}
}
,
e.prototype._transmitWorld = function(t, r, n, o) {
if (!!this._systemValue) {
var a = this.associatedVariableName;
switch (this._systemValue) {
case NodeMaterialSystemValues.World:
t.setMatrix(a, r);
break;
case NodeMaterialSystemValues.WorldView:
t.setMatrix(a, n);
break;
case NodeMaterialSystemValues.WorldViewProjection:
t.setMatrix(a, o);
break
}
}
}
,
e.prototype._transmit = function(t, r) {
if (!this.isAttribute) {
var n = this.associatedVariableName;
if (this._systemValue) {
switch (this._systemValue) {
case NodeMaterialSystemValues.World:
case NodeMaterialSystemValues.WorldView:
case NodeMaterialSystemValues.WorldViewProjection:
return;
case NodeMaterialSystemValues.View:
t.setMatrix(n, r.getViewMatrix());
break;
case NodeMaterialSystemValues.Projection:
t.setMatrix(n, r.getProjectionMatrix());
break;
case NodeMaterialSystemValues.ViewProjection:
t.setMatrix(n, r.getTransformMatrix());
break;
case NodeMaterialSystemValues.CameraPosition:
r.bindEyePosition(t, n, !0);
break;
case NodeMaterialSystemValues.FogColor:
t.setColor3(n, r.fogColor);
break;
case NodeMaterialSystemValues.DeltaTime:
t.setFloat(n, r.deltaTime / 1e3);
case NodeMaterialSystemValues.CameraParameters:
r.activeCamera && t.setFloat4(n, r.getEngine().hasOriginBottomLeft ? -1 : 1, r.activeCamera.minZ, r.activeCamera.maxZ, 1 / r.activeCamera.maxZ);
break
}
return
}
var o = this._valueCallback ? this._valueCallback() : this._storedValue;
if (o !== null)
switch (this.type) {
case NodeMaterialBlockConnectionPointTypes.Float:
t.setFloat(n, o);
break;
case NodeMaterialBlockConnectionPointTypes.Int:
t.setInt(n, o);
break;
case NodeMaterialBlockConnectionPointTypes.Color3:
TmpColors.Color3[0].set(this.value.r, this.value.g, this.value.b),
this.convertToGammaSpace && TmpColors.Color3[0].toGammaSpaceToRef(TmpColors.Color3[0]),
this.convertToLinearSpace && TmpColors.Color3[0].toLinearSpaceToRef(TmpColors.Color3[0]),
t.setColor3(n, TmpColors.Color3[0]);
break;
case NodeMaterialBlockConnectionPointTypes.Color4:
TmpColors.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
this.convertToGammaSpace && TmpColors.Color4[0].toGammaSpaceToRef(TmpColors.Color4[0]),
this.convertToLinearSpace && TmpColors.Color4[0].toLinearSpaceToRef(TmpColors.Color4[0]),
t.setDirectColor4(n, TmpColors.Color4[0]);
break;
case NodeMaterialBlockConnectionPointTypes.Vector2:
t.setVector2(n, o);
break;
case NodeMaterialBlockConnectionPointTypes.Vector3:
t.setVector3(n, o);
break;
case NodeMaterialBlockConnectionPointTypes.Vector4:
t.setVector4(n, o);
break;
case NodeMaterialBlockConnectionPointTypes.Matrix:
t.setMatrix(n, o);
break
}
}
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t),
(this.isUniform || this.isSystemValue) && t.sharedData.inputBlocks.push(this),
this._emit(t)
}
,
e.prototype._dumpPropertiesCode = function() {
var t = this._codeVariableName;
if (this.isAttribute)
return i.prototype._dumpPropertiesCode.call(this) + (t + '.setAsAttribute("' + this.name + `");\r
`);
if (this.isSystemValue)
return i.prototype._dumpPropertiesCode.call(this) + (t + ".setAsSystemValue(BABYLON.NodeMaterialSystemValues." + NodeMaterialSystemValues[this._systemValue] + `);\r
`);
if (this.isUniform) {
var r = []
, n = "";
switch (this.type) {
case NodeMaterialBlockConnectionPointTypes.Float:
n = "" + this.value;
break;
case NodeMaterialBlockConnectionPointTypes.Vector2:
n = "new BABYLON.Vector2(" + this.value.x + ", " + this.value.y + ")";
break;
case NodeMaterialBlockConnectionPointTypes.Vector3:
n = "new BABYLON.Vector3(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ")";
break;
case NodeMaterialBlockConnectionPointTypes.Vector4:
n = "new BABYLON.Vector4(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ", " + this.value.w + ")";
break;
case NodeMaterialBlockConnectionPointTypes.Color3:
n = "new BABYLON.Color3(" + this.value.r + ", " + this.value.g + ", " + this.value.b + ")",
this.convertToGammaSpace && (n += ".toGammaSpace()"),
this.convertToLinearSpace && (n += ".toLinearSpace()");
break;
case NodeMaterialBlockConnectionPointTypes.Color4:
n = "new BABYLON.Color4(" + this.value.r + ", " + this.value.g + ", " + this.value.b + ", " + this.value.a + ")",
this.convertToGammaSpace && (n += ".toGammaSpace()"),
this.convertToLinearSpace && (n += ".toLinearSpace()");
break;
case NodeMaterialBlockConnectionPointTypes.Matrix:
n = "BABYLON.Matrix.FromArray([" + this.value.m + "])";
break
}
return r.push(t + ".value = " + n),
this.type === NodeMaterialBlockConnectionPointTypes.Float && r.push(t + ".min = " + this.min, t + ".max = " + this.max, t + ".isBoolean = " + this.isBoolean, t + ".matrixMode = " + this.matrixMode, t + ".animationType = BABYLON.AnimatedInputBlockTypes." + AnimatedInputBlockTypes[this.animationType]),
r.push(t + ".isConstant = " + this.isConstant),
r.push(""),
i.prototype._dumpPropertiesCode.call(this) + r.join(`;\r
`)
}
return i.prototype._dumpPropertiesCode.call(this)
}
,
e.prototype.dispose = function() {
this.onValueChangedObservable.clear(),
i.prototype.dispose.call(this)
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.type = this.type,
t.mode = this._mode,
t.systemValue = this._systemValue,
t.animationType = this._animationType,
t.min = this.min,
t.max = this.max,
t.isBoolean = this.isBoolean,
t.matrixMode = this.matrixMode,
t.isConstant = this.isConstant,
t.groupInInspector = this.groupInInspector,
t.convertToGammaSpace = this.convertToGammaSpace,
t.convertToLinearSpace = this.convertToLinearSpace,
this._storedValue != null && this._mode === NodeMaterialBlockConnectionPointMode.Uniform && (this._storedValue.asArray ? (t.valueType = "BABYLON." + this._storedValue.getClassName(),
t.value = this._storedValue.asArray()) : (t.valueType = "number",
t.value = this._storedValue)),
t
}
,
e.prototype._deserialize = function(t, r, n) {
if (this._mode = t.mode,
i.prototype._deserialize.call(this, t, r, n),
this._type = t.type,
this._systemValue = t.systemValue || t.wellKnownValue,
this._animationType = t.animationType,
this.min = t.min || 0,
this.max = t.max || 0,
this.isBoolean = !!t.isBoolean,
this.matrixMode = t.matrixMode || 0,
this.isConstant = !!t.isConstant,
this.groupInInspector = t.groupInInspector || "",
this.convertToGammaSpace = !!t.convertToGammaSpace,
this.convertToLinearSpace = !!t.convertToLinearSpace,
!!t.valueType)
if (t.valueType === "number")
this._storedValue = t.value;
else {
var o = GetClass(t.valueType);
o && (this._storedValue = o.FromArray(t.value))
}
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.InputBlock", InputBlock);
var CurrentScreenBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.VertexAndFragment) || this;
return r._samplerName = "textureSampler",
r.convertToGammaSpace = !1,
r.convertToLinearSpace = !1,
r._isUnique = !1,
r.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
r.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral),
r.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral),
r.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
r.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
r.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
r.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r._inputs[0]._prioritizeVertex = !1,
r
}
return e.prototype.getClassName = function() {
return "CurrentScreenBlock"
}
,
Object.defineProperty(e.prototype, "uv", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgba", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgb", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "r", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "g", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "b", {
get: function() {
return this._outputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "a", {
get: function() {
return this._outputs[5]
},
enumerable: !1,
configurable: !0
}),
e.prototype.initialize = function(t) {
t._excludeVariableName("textureSampler")
}
,
Object.defineProperty(e.prototype, "target", {
get: function() {
return !this.uv.isConnected || this.uv.sourceBlock.isInput ? NodeMaterialBlockTargets.VertexAndFragment : NodeMaterialBlockTargets.Fragment
},
enumerable: !1,
configurable: !0
}),
e.prototype.prepareDefines = function(t, r, n) {
n.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
n.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
}
,
e.prototype.isReady = function() {
return !(this.texture && !this.texture.isReadyOrNotBlocking())
}
,
e.prototype._injectVertexCode = function(t) {
var r = this.uv;
if (r.connectedPoint.ownerBlock.isInput) {
var n = r.connectedPoint.ownerBlock;
n.isAttribute || t._emitUniformFromString(r.associatedVariableName, "vec2")
}
if (this._mainUVName = "vMain" + r.associatedVariableName,
t._emitVaryingFromString(this._mainUVName, "vec2"),
t.compilationString += this._mainUVName + " = " + r.associatedVariableName + `.xy;\r
`,
!!this._outputs.some(function(l) {
return l.isConnectedInVertexShader
})) {
this._writeTextureRead(t, !0);
for (var o = 0, a = this._outputs; o < a.length; o++) {
var s = a[o];
s.hasEndpoints && this._writeOutput(t, s, s.name, !0)
}
}
}
,
e.prototype._writeTextureRead = function(t, r) {
r === void 0 && (r = !1);
var n = this.uv;
if (r) {
if (t.target === NodeMaterialBlockTargets.Fragment)
return;
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + n.associatedVariableName + `);\r
`;
return
}
if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + n.associatedVariableName + `);\r
`;
return
}
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this._mainUVName + `);\r
`
}
,
e.prototype._writeOutput = function(t, r, n, o) {
if (o === void 0 && (o = !1),
o) {
if (t.target === NodeMaterialBlockTargets.Fragment)
return;
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + `;\r
`;
return
}
if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + `;\r
`;
return
}
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + `;\r
`,
t.compilationString += "#ifdef " + this._linearDefineName + `\r
`,
t.compilationString += r.associatedVariableName + " = toGammaSpace(" + r.associatedVariableName + `);\r
`,
t.compilationString += `#endif\r
`,
t.compilationString += "#ifdef " + this._gammaDefineName + `\r
`,
t.compilationString += r.associatedVariableName + " = toLinearSpace(" + r.associatedVariableName + `);\r
`,
t.compilationString += `#endif\r
`
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
t.sharedData.blockingBlocks.indexOf(this) < 0 && t.sharedData.blockingBlocks.push(this),
t.sharedData.textureBlocks.indexOf(this) < 0 && t.sharedData.textureBlocks.push(this),
t.sharedData.blocksWithDefines.indexOf(this) < 0 && t.sharedData.blocksWithDefines.push(this),
t.target !== NodeMaterialBlockTargets.Fragment) {
t._emit2DSampler(this._samplerName),
this._injectVertexCode(t);
return
}
if (!!this._outputs.some(function(s) {
return s.isConnectedInFragmentShader
})) {
t._emit2DSampler(this._samplerName),
this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
this._gammaDefineName = t._getFreeDefineName("ISGAMMA");
var r = "//" + this.name;
t._emitFunctionFromInclude("helperFunctions", r),
this._writeTextureRead(t);
for (var n = 0, o = this._outputs; n < o.length; n++) {
var a = o[n];
a.hasEndpoints && this._writeOutput(t, a, a.name)
}
return this
}
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.convertToGammaSpace = this.convertToGammaSpace,
t.convertToLinearSpace = this.convertToLinearSpace,
this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.convertToGammaSpace = t.convertToGammaSpace,
this.convertToLinearSpace = !!t.convertToLinearSpace,
t.texture && (n = t.texture.url.indexOf("data:") === 0 ? "" : n,
this.texture = Texture.Parse(t.texture, r, n))
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.CurrentScreenBlock", CurrentScreenBlock);
var ParticleTextureBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r._samplerName = "diffuseSampler",
r.convertToGammaSpace = !1,
r.convertToLinearSpace = !1,
r._isUnique = !1,
r.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
r.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral),
r.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral),
r.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
r.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
r.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
r.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r
}
return e.prototype.getClassName = function() {
return "ParticleTextureBlock"
}
,
Object.defineProperty(e.prototype, "uv", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgba", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgb", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "r", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "g", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "b", {
get: function() {
return this._outputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "a", {
get: function() {
return this._outputs[5]
},
enumerable: !1,
configurable: !0
}),
e.prototype.initialize = function(t) {
t._excludeVariableName("diffuseSampler")
}
,
e.prototype.autoConfigure = function(t) {
if (!this.uv.isConnected) {
var r = t.getInputBlockByPredicate(function(n) {
return n.isAttribute && n.name === "particle_uv"
});
r || (r = new InputBlock("uv"),
r.setAsAttribute("particle_uv")),
r.output.connectTo(this.uv)
}
}
,
e.prototype.prepareDefines = function(t, r, n) {
n.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
n.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
}
,
e.prototype.isReady = function() {
return !(this.texture && !this.texture.isReadyOrNotBlocking())
}
,
e.prototype._writeOutput = function(t, r, n) {
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + `;\r
`,
t.compilationString += "#ifdef " + this._linearDefineName + `\r
`,
t.compilationString += r.associatedVariableName + " = toGammaSpace(" + r.associatedVariableName + `);\r
`,
t.compilationString += `#endif\r
`,
t.compilationString += "#ifdef " + this._gammaDefineName + `\r
`,
t.compilationString += r.associatedVariableName + " = toLinearSpace(" + r.associatedVariableName + `);\r
`,
t.compilationString += `#endif\r
`
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
t.target !== NodeMaterialBlockTargets.Vertex) {
this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
t._emit2DSampler(this._samplerName),
t.sharedData.blockingBlocks.push(this),
t.sharedData.textureBlocks.push(this),
t.sharedData.blocksWithDefines.push(this),
this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
this._gammaDefineName = t._getFreeDefineName("ISGAMMA");
var r = "//" + this.name;
t._emitFunctionFromInclude("helperFunctions", r),
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this.uv.associatedVariableName + `);\r
`;
for (var n = 0, o = this._outputs; n < o.length; n++) {
var a = o[n];
a.hasEndpoints && this._writeOutput(t, a, a.name)
}
return this
}
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.convertToGammaSpace = this.convertToGammaSpace,
t.convertToLinearSpace = this.convertToLinearSpace,
this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.convertToGammaSpace = t.convertToGammaSpace,
this.convertToLinearSpace = !!t.convertToLinearSpace,
t.texture && (n = t.texture.url.indexOf("data:") === 0 ? "" : n,
this.texture = Texture.Parse(t.texture, r, n))
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ParticleTextureBlock", ParticleTextureBlock);
var ParticleRampGradientBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r._isUnique = !0,
r.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color4, !1, NodeMaterialBlockTargets.Fragment),
r.registerOutput("rampColor", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment),
r
}
return e.prototype.getClassName = function() {
return "ParticleRampGradientBlock"
}
,
Object.defineProperty(e.prototype, "color", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rampColor", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.initialize = function(t) {
t._excludeVariableName("remapRanges"),
t._excludeVariableName("rampSampler"),
t._excludeVariableName("baseColor"),
t._excludeVariableName("alpha"),
t._excludeVariableName("remappedColorIndex"),
t._excludeVariableName("rampColor"),
t._excludeVariableName("finalAlpha")
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
t.target !== NodeMaterialBlockTargets.Vertex)
return t._emit2DSampler("rampSampler"),
t._emitVaryingFromString("remapRanges", "vec4", "RAMPGRADIENT"),
t.compilationString += `
#ifdef RAMPGRADIENT
vec4 baseColor = ` + this.color.associatedVariableName + `;
float alpha = ` + this.color.associatedVariableName + `.a;
float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);
vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));
baseColor.rgb *= rampColor.rgb;
// Remapped alpha
float finalAlpha = baseColor.a;
baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);
` + this._declareOutput(this.rampColor, t) + ` = baseColor;
#else
` + this._declareOutput(this.rampColor, t) + " = " + this.color.associatedVariableName + `;
#endif
`,
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ParticleRampGradientBlock", ParticleRampGradientBlock);
var ParticleBlendMultiplyBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r._isUnique = !0,
r.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color4, !1, NodeMaterialBlockTargets.Fragment),
r.registerInput("alphaTexture", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
r.registerInput("alphaColor", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
r.registerOutput("blendColor", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment),
r
}
return e.prototype.getClassName = function() {
return "ParticleBlendMultiplyBlock"
}
,
Object.defineProperty(e.prototype, "color", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "alphaTexture", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "alphaColor", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "blendColor", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.initialize = function(t) {
t._excludeVariableName("sourceAlpha")
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
t.target !== NodeMaterialBlockTargets.Vertex)
return t.compilationString += `
#ifdef BLENDMULTIPLYMODE
` + this._declareOutput(this.blendColor, t) + `;
float sourceAlpha = ` + this.alphaColor.associatedVariableName + " * " + this.alphaTexture.associatedVariableName + `;
` + this.blendColor.associatedVariableName + ".rgb = " + this.color.associatedVariableName + `.rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);
` + this.blendColor.associatedVariableName + ".a = " + this.color.associatedVariableName + `.a;
#else
` + this._declareOutput(this.blendColor, t) + " = " + this.color.associatedVariableName + `;
#endif
`,
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ParticleBlendMultiplyBlock", ParticleBlendMultiplyBlock);
var VectorMergerBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.xSwizzle = "x",
r.ySwizzle = "y",
r.zSwizzle = "z",
r.wSwizzle = "w",
r.registerInput("xyzw ", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
r.registerInput("xyz ", NodeMaterialBlockConnectionPointTypes.Vector3, !0),
r.registerInput("xy ", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
r.registerInput("zw ", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
r.registerInput("x", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("y", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("z", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("w", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerOutput("xyzw", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerOutput("zw", NodeMaterialBlockConnectionPointTypes.Vector2),
r
}
return e.prototype.getClassName = function() {
return "VectorMergerBlock"
}
,
Object.defineProperty(e.prototype, "xyzwIn", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyzIn", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyIn", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "zwIn", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "x", {
get: function() {
return this._inputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "y", {
get: function() {
return this._inputs[5]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "z", {
get: function() {
return this._inputs[6]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "w", {
get: function() {
return this._inputs[7]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyzw", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyzOut", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyOut", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "zwOut", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xy", {
get: function() {
return this.xyOut
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyz", {
get: function() {
return this.xyzOut
},
enumerable: !1,
configurable: !0
}),
e.prototype._inputRename = function(t) {
return t === "xyzw " ? "xyzwIn" : t === "xyz " ? "xyzIn" : t === "xy " ? "xyIn" : t === "zw " ? "zwIn" : t
}
,
e.prototype._buildSwizzle = function(t) {
var r = this.xSwizzle + this.ySwizzle + this.zSwizzle + this.wSwizzle;
return "." + r.substr(0, t)
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this.x
, n = this.y
, o = this.z
, a = this.w
, s = this.xyIn
, l = this.zwIn
, u = this.xyzIn
, c = this.xyzwIn
, h = this._outputs[0]
, f = this._outputs[1]
, d = this._outputs[2]
, _ = this._outputs[3];
return c.isConnected ? (h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + (" = " + c.associatedVariableName + this._buildSwizzle(4) + `;\r
`)),
f.hasEndpoints && (t.compilationString += this._declareOutput(f, t) + (" = " + c.associatedVariableName + this._buildSwizzle(3) + `;\r
`)),
d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + (" = " + c.associatedVariableName + this._buildSwizzle(2) + `;\r
`))) : u.isConnected ? (h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + (" = vec4(" + u.associatedVariableName + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
`)),
f.hasEndpoints && (t.compilationString += this._declareOutput(f, t) + (" = " + u.associatedVariableName + this._buildSwizzle(3) + `;\r
`)),
d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + (" = " + u.associatedVariableName + this._buildSwizzle(2) + `;\r
`))) : s.isConnected ? (h.hasEndpoints && (l.isConnected ? t.compilationString += this._declareOutput(h, t) + (" = vec4(" + s.associatedVariableName + ", " + l.associatedVariableName + ")" + this._buildSwizzle(4) + `;\r
`) : t.compilationString += this._declareOutput(h, t) + (" = vec4(" + s.associatedVariableName + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
`)),
f.hasEndpoints && (t.compilationString += this._declareOutput(f, t) + (" = vec3(" + s.associatedVariableName + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + ")" + this._buildSwizzle(3) + `;\r
`)),
d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + (" = " + s.associatedVariableName + this._buildSwizzle(2) + `;\r
`)),
_.hasEndpoints && (l.isConnected ? t.compilationString += this._declareOutput(_, t) + (" = " + l.associatedVariableName + this._buildSwizzle(2) + `;\r
`) : t.compilationString += this._declareOutput(_, t) + (" = vec2(" + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + ")" + this._buildSwizzle(2) + `;\r
`))) : (h.hasEndpoints && (l.isConnected ? t.compilationString += this._declareOutput(h, t) + (" = vec4(" + (r.isConnected ? this._writeVariable(r) : "0.0") + ", " + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + l.associatedVariableName + ")" + this._buildSwizzle(4) + `;\r
`) : t.compilationString += this._declareOutput(h, t) + (" = vec4(" + (r.isConnected ? this._writeVariable(r) : "0.0") + ", " + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
`)),
f.hasEndpoints && (t.compilationString += this._declareOutput(f, t) + (" = vec3(" + (r.isConnected ? this._writeVariable(r) : "0.0") + ", " + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + ")" + this._buildSwizzle(3) + `;\r
`)),
d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + (" = vec2(" + (r.isConnected ? this._writeVariable(r) : "0.0") + ", " + (n.isConnected ? this._writeVariable(n) : "0.0") + ")" + this._buildSwizzle(2) + `;\r
`)),
_.hasEndpoints && (l.isConnected ? t.compilationString += this._declareOutput(_, t) + (" = " + l.associatedVariableName + this._buildSwizzle(2) + `;\r
`) : t.compilationString += this._declareOutput(_, t) + (" = vec2(" + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + ")" + this._buildSwizzle(2) + `;\r
`))),
this
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.xSwizzle = this.xSwizzle,
t.ySwizzle = this.ySwizzle,
t.zSwizzle = this.zSwizzle,
t.wSwizzle = this.wSwizzle,
t
}
,
e.prototype._deserialize = function(t, r, n) {
var o, a, s, l;
i.prototype._deserialize.call(this, t, r, n),
this.xSwizzle = (o = t.xSwizzle) !== null && o !== void 0 ? o : "x",
this.ySwizzle = (a = t.ySwizzle) !== null && a !== void 0 ? a : "y",
this.zSwizzle = (s = t.zSwizzle) !== null && s !== void 0 ? s : "z",
this.wSwizzle = (l = t.wSwizzle) !== null && l !== void 0 ? l : "w"
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this);
return t += this._codeVariableName + '.xSwizzle = "' + this.xSwizzle + `";\r
`,
t += this._codeVariableName + '.ySwizzle = "' + this.ySwizzle + `";\r
`,
t += this._codeVariableName + '.zSwizzle = "' + this.zSwizzle + `";\r
`,
t += this._codeVariableName + '.wSwizzle = "' + this.wSwizzle + `";\r
`,
t
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.VectorMergerBlock", VectorMergerBlock);
var RemapBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.sourceRange = new Vector2(-1,1),
r.targetRange = new Vector2(0,1),
r.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("sourceMin", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("sourceMax", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("targetMin", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("targetMax", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r
}
return e.prototype.getClassName = function() {
return "RemapBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "sourceMin", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "sourceMax", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "targetMin", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "targetMax", {
get: function() {
return this._inputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0]
, n = this.sourceMin.isConnected ? this.sourceMin.associatedVariableName : this._writeFloat(this.sourceRange.x)
, o = this.sourceMax.isConnected ? this.sourceMax.associatedVariableName : this._writeFloat(this.sourceRange.y)
, a = this.targetMin.isConnected ? this.targetMin.associatedVariableName : this._writeFloat(this.targetRange.x)
, s = this.targetMax.isConnected ? this.targetMax.associatedVariableName : this._writeFloat(this.targetRange.y);
return t.compilationString += this._declareOutput(r, t) + (" = " + a + " + (" + this._inputs[0].associatedVariableName + " - " + n + ") * (" + s + " - " + a + ") / (" + o + " - " + n + `);\r
`),
this
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".sourceRange = new BABYLON.Vector2(" + this.sourceRange.x + ", " + this.sourceRange.y + `);\r
`);
return t += this._codeVariableName + ".targetRange = new BABYLON.Vector2(" + this.targetRange.x + ", " + this.targetRange.y + `);\r
`,
t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.sourceRange = this.sourceRange.asArray(),
t.targetRange = this.targetRange.asArray(),
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.sourceRange = Vector2.FromArray(t.sourceRange),
this.targetRange = Vector2.FromArray(t.targetRange)
}
,
__decorate([editableInPropertyPage("From", PropertyTypeForEdition.Vector2)], e.prototype, "sourceRange", void 0),
__decorate([editableInPropertyPage("To", PropertyTypeForEdition.Vector2)], e.prototype, "targetRange", void 0),
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.RemapBlock", RemapBlock);
var MultiplyBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r
}
return e.prototype.getClassName = function() {
return "MultiplyBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = " + this.left.associatedVariableName + " * " + this.right.associatedVariableName + `;\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.MultiplyBlock", MultiplyBlock);
var ColorSplitterBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, !0),
r.registerInput("rgb ", NodeMaterialBlockConnectionPointTypes.Color3, !0),
r.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3),
r.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float),
r.inputsAreExclusive = !0,
r
}
return e.prototype.getClassName = function() {
return "ColorSplitterBlock"
}
,
Object.defineProperty(e.prototype, "rgba", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgbIn", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgbOut", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "r", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "g", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "b", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "a", {
get: function() {
return this._outputs[4]
},
enumerable: !1,
configurable: !0
}),
e.prototype._inputRename = function(t) {
return t === "rgb " ? "rgbIn" : t
}
,
e.prototype._outputRename = function(t) {
return t === "rgb" ? "rgbOut" : t
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this.rgba.isConnected ? this.rgba : this.rgbIn;
if (!!r.isConnected) {
var n = this._outputs[0]
, o = this._outputs[1]
, a = this._outputs[2]
, s = this._outputs[3]
, l = this._outputs[4];
return n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + (" = " + r.associatedVariableName + `.rgb;\r
`)),
o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + (" = " + r.associatedVariableName + `.r;\r
`)),
a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + (" = " + r.associatedVariableName + `.g;\r
`)),
s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + (" = " + r.associatedVariableName + `.b;\r
`)),
l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + (" = " + r.associatedVariableName + `.a;\r
`)),
this
}
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ColorSplitterBlock", ColorSplitterBlock);
var TrigonometryBlockOperations;
(function(i) {
i[i.Cos = 0] = "Cos",
i[i.Sin = 1] = "Sin",
i[i.Abs = 2] = "Abs",
i[i.Exp = 3] = "Exp",
i[i.Exp2 = 4] = "Exp2",
i[i.Round = 5] = "Round",
i[i.Floor = 6] = "Floor",
i[i.Ceiling = 7] = "Ceiling",
i[i.Sqrt = 8] = "Sqrt",
i[i.Log = 9] = "Log",
i[i.Tan = 10] = "Tan",
i[i.ArcTan = 11] = "ArcTan",
i[i.ArcCos = 12] = "ArcCos",
i[i.ArcSin = 13] = "ArcSin",
i[i.Fract = 14] = "Fract",
i[i.Sign = 15] = "Sign",
i[i.Radians = 16] = "Radians",
i[i.Degrees = 17] = "Degrees"
}
)(TrigonometryBlockOperations || (TrigonometryBlockOperations = {}));
var TrigonometryBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.operation = TrigonometryBlockOperations.Cos,
r.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r
}
return e.prototype.getClassName = function() {
return "TrigonometryBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0]
, n = "";
switch (this.operation) {
case TrigonometryBlockOperations.Cos:
{
n = "cos";
break
}
case TrigonometryBlockOperations.Sin:
{
n = "sin";
break
}
case TrigonometryBlockOperations.Abs:
{
n = "abs";
break
}
case TrigonometryBlockOperations.Exp:
{
n = "exp";
break
}
case TrigonometryBlockOperations.Exp2:
{
n = "exp2";
break
}
case TrigonometryBlockOperations.Round:
{
n = "round";
break
}
case TrigonometryBlockOperations.Floor:
{
n = "floor";
break
}
case TrigonometryBlockOperations.Ceiling:
{
n = "ceil";
break
}
case TrigonometryBlockOperations.Sqrt:
{
n = "sqrt";
break
}
case TrigonometryBlockOperations.Log:
{
n = "log";
break
}
case TrigonometryBlockOperations.Tan:
{
n = "tan";
break
}
case TrigonometryBlockOperations.ArcTan:
{
n = "atan";
break
}
case TrigonometryBlockOperations.ArcCos:
{
n = "acos";
break
}
case TrigonometryBlockOperations.ArcSin:
{
n = "asin";
break
}
case TrigonometryBlockOperations.Fract:
{
n = "fract";
break
}
case TrigonometryBlockOperations.Sign:
{
n = "sign";
break
}
case TrigonometryBlockOperations.Radians:
{
n = "radians";
break
}
case TrigonometryBlockOperations.Degrees:
{
n = "degrees";
break
}
}
return t.compilationString += this._declareOutput(r, t) + (" = " + n + "(" + this.input.associatedVariableName + `);\r
`),
this
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.operation = this.operation,
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.operation = t.operation
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".operation = BABYLON.TrigonometryBlockOperations." + TrigonometryBlockOperations[this.operation] + `;\r
`);
return t
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.TrigonometryBlock", TrigonometryBlock);
var onCreatedEffectParameters$1 = {
effect: null,
subMesh: null
}
, NodeMaterialDefines = function(i) {
__extends(e, i);
function e() {
var t = i.call(this) || this;
return t.NORMAL = !1,
t.TANGENT = !1,
t.UV1 = !1,
t.UV2 = !1,
t.UV3 = !1,
t.UV4 = !1,
t.UV5 = !1,
t.UV6 = !1,
t.NUM_BONE_INFLUENCERS = 0,
t.BonesPerMesh = 0,
t.BONETEXTURE = !1,
t.MORPHTARGETS = !1,
t.MORPHTARGETS_NORMAL = !1,
t.MORPHTARGETS_TANGENT = !1,
t.MORPHTARGETS_UV = !1,
t.NUM_MORPH_INFLUENCERS = 0,
t.MORPHTARGETS_TEXTURE = !1,
t.IMAGEPROCESSING = !1,
t.VIGNETTE = !1,
t.VIGNETTEBLENDMODEMULTIPLY = !1,
t.VIGNETTEBLENDMODEOPAQUE = !1,
t.TONEMAPPING = !1,
t.TONEMAPPING_ACES = !1,
t.CONTRAST = !1,
t.EXPOSURE = !1,
t.COLORCURVES = !1,
t.COLORGRADING = !1,
t.COLORGRADING3D = !1,
t.SAMPLER3DGREENDEPTH = !1,
t.SAMPLER3DBGRMAP = !1,
t.IMAGEPROCESSINGPOSTPROCESS = !1,
t.SKIPFINALCOLORCLAMP = !1,
t.BUMPDIRECTUV = 0,
t.rebuild(),
t
}
return e.prototype.setValue = function(t, r, n) {
n === void 0 && (n = !1),
this[t] === void 0 && this._keys.push(t),
n && this[t] !== r && this.markAsUnprocessed(),
this[t] = r
}
,
e
}(MaterialDefines)
, NodeMaterial = function(i) {
__extends(e, i);
function e(t, r, n) {
n === void 0 && (n = {});
var o = i.call(this, t, r || Engine.LastCreatedScene) || this;
return o._buildId = e._BuildIdGenerator++,
o._buildWasSuccessful = !1,
o._cachedWorldViewMatrix = new Matrix,
o._cachedWorldViewProjectionMatrix = new Matrix,
o._optimizers = new Array,
o._animationFrame = -1,
o.BJSNODEMATERIALEDITOR = o._getGlobalNodeMaterialEditor(),
o.editorData = null,
o.ignoreAlpha = !1,
o.maxSimultaneousLights = 4,
o.onBuildObservable = new Observable,
o._vertexOutputNodes = new Array,
o._fragmentOutputNodes = new Array,
o.attachedBlocks = new Array,
o._mode = NodeMaterialModes.Material,
o._options = __assign({
emitComments: !1
}, n),
o._attachImageProcessingConfiguration(null),
o
}
return e.prototype._getGlobalNodeMaterialEditor = function() {
if (typeof NODEEDITOR != "undefined")
return NODEEDITOR;
if (typeof BABYLON != "undefined" && typeof BABYLON.NodeEditor != "undefined")
return BABYLON
}
,
Object.defineProperty(e.prototype, "options", {
get: function() {
return this._options
},
set: function(t) {
this._options = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
get: function() {
return this._imageProcessingConfiguration
},
set: function(t) {
this._attachImageProcessingConfiguration(t),
this._markAllSubMeshesAsTexturesDirty()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "mode", {
get: function() {
return this._mode
},
set: function(t) {
this._mode = t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "buildId", {
get: function() {
return this._buildId
},
set: function(t) {
this._buildId = t
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "NodeMaterial"
}
,
e.prototype._attachImageProcessingConfiguration = function(t) {
var r = this;
t !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
t ? this._imageProcessingConfiguration = t : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
r._markAllSubMeshesAsImageProcessingDirty()
})))
}
,
e.prototype.getBlockByName = function(t) {
for (var r = null, n = 0, o = this.attachedBlocks; n < o.length; n++) {
var a = o[n];
if (a.name === t)
if (!r)
r = a;
else
return Tools.Warn("More than one block was found with the name `" + t + "`"),
r
}
return r
}
,
e.prototype.getBlockByPredicate = function(t) {
for (var r = 0, n = this.attachedBlocks; r < n.length; r++) {
var o = n[r];
if (t(o))
return o
}
return null
}
,
e.prototype.getInputBlockByPredicate = function(t) {
for (var r = 0, n = this.attachedBlocks; r < n.length; r++) {
var o = n[r];
if (o.isInput && t(o))
return o
}
return null
}
,
e.prototype.getInputBlocks = function() {
for (var t = [], r = 0, n = this.attachedBlocks; r < n.length; r++) {
var o = n[r];
o.isInput && t.push(o)
}
return t
}
,
e.prototype.registerOptimizer = function(t) {
var r = this._optimizers.indexOf(t);
if (!(r > -1))
return this._optimizers.push(t),
this
}
,
e.prototype.unregisterOptimizer = function(t) {
var r = this._optimizers.indexOf(t);
if (r !== -1)
return this._optimizers.splice(r, 1),
this
}
,
e.prototype.addOutputNode = function(t) {
if (t.target === null)
throw "This node is not meant to be an output node. You may want to explicitly set its target value.";
return (t.target & NodeMaterialBlockTargets.Vertex) !== 0 && this._addVertexOutputNode(t),
(t.target & NodeMaterialBlockTargets.Fragment) !== 0 && this._addFragmentOutputNode(t),
this
}
,
e.prototype.removeOutputNode = function(t) {
return t.target === null ? this : ((t.target & NodeMaterialBlockTargets.Vertex) !== 0 && this._removeVertexOutputNode(t),
(t.target & NodeMaterialBlockTargets.Fragment) !== 0 && this._removeFragmentOutputNode(t),
this)
}
,
e.prototype._addVertexOutputNode = function(t) {
if (this._vertexOutputNodes.indexOf(t) === -1)
return t.target = NodeMaterialBlockTargets.Vertex,
this._vertexOutputNodes.push(t),
this
}
,
e.prototype._removeVertexOutputNode = function(t) {
var r = this._vertexOutputNodes.indexOf(t);
if (r !== -1)
return this._vertexOutputNodes.splice(r, 1),
this
}
,
e.prototype._addFragmentOutputNode = function(t) {
if (this._fragmentOutputNodes.indexOf(t) === -1)
return t.target = NodeMaterialBlockTargets.Fragment,
this._fragmentOutputNodes.push(t),
this
}
,
e.prototype._removeFragmentOutputNode = function(t) {
var r = this._fragmentOutputNodes.indexOf(t);
if (r !== -1)
return this._fragmentOutputNodes.splice(r, 1),
this
}
,
e.prototype.needAlphaBlending = function() {
return this.ignoreAlpha ? !1 : this.alpha < 1 || this._sharedData && this._sharedData.hints.needAlphaBlending
}
,
e.prototype.needAlphaTesting = function() {
return this._sharedData && this._sharedData.hints.needAlphaTesting
}
,
e.prototype._initializeBlock = function(t, r, n, o) {
if (o === void 0 && (o = !0),
t.initialize(r),
o && t.autoConfigure(this),
t._preparationId = this._buildId,
this.attachedBlocks.indexOf(t) === -1) {
if (t.isUnique)
for (var a = t.getClassName(), s = 0, l = this.attachedBlocks; s < l.length; s++) {
var u = l[s];
if (u.getClassName() === a)
throw "Cannot have multiple blocks of type " + a + " in the same NodeMaterial"
}
this.attachedBlocks.push(t)
}
for (var c = 0, h = t.inputs; c < h.length; c++) {
var f = h[c];
f.associatedVariableName = "";
var d = f.connectedPoint;
if (d) {
var _ = d.ownerBlock;
_ !== t && ((_.target === NodeMaterialBlockTargets.VertexAndFragment || r.target === NodeMaterialBlockTargets.Fragment && _.target === NodeMaterialBlockTargets.Vertex && _._preparationId !== this._buildId) && n.push(_),
this._initializeBlock(_, r, n, o))
}
}
for (var g = 0, m = t.outputs; g < m.length; g++) {
var v = m[g];
v.associatedVariableName = ""
}
}
,
e.prototype._resetDualBlocks = function(t, r) {
t.target === NodeMaterialBlockTargets.VertexAndFragment && (t.buildId = r);
for (var n = 0, o = t.inputs; n < o.length; n++) {
var a = o[n]
, s = a.connectedPoint;
if (s) {
var l = s.ownerBlock;
l !== t && this._resetDualBlocks(l, r)
}
}
}
,
e.prototype.removeBlock = function(t) {
var r = this.attachedBlocks.indexOf(t);
r > -1 && this.attachedBlocks.splice(r, 1),
t.isFinalMerger && this.removeOutputNode(t)
}
,
e.prototype.build = function(t, r, n) {
t === void 0 && (t = !1),
r === void 0 && (r = !0),
n === void 0 && (n = !0),
this._buildWasSuccessful = !1;
var o = this.getScene().getEngine()
, a = this._mode === NodeMaterialModes.Particle;
if (this._vertexOutputNodes.length === 0 && !a)
throw "You must define at least one vertexOutputNode";
if (this._fragmentOutputNodes.length === 0)
throw "You must define at least one fragmentOutputNode";
this._vertexCompilationState = new NodeMaterialBuildState,
this._vertexCompilationState.supportUniformBuffers = o.supportsUniformBuffers,
this._vertexCompilationState.target = NodeMaterialBlockTargets.Vertex,
this._fragmentCompilationState = new NodeMaterialBuildState,
this._fragmentCompilationState.supportUniformBuffers = o.supportsUniformBuffers,
this._fragmentCompilationState.target = NodeMaterialBlockTargets.Fragment,
this._sharedData = new NodeMaterialBuildStateSharedData,
this._sharedData.fragmentOutputNodes = this._fragmentOutputNodes,
this._vertexCompilationState.sharedData = this._sharedData,
this._fragmentCompilationState.sharedData = this._sharedData,
this._sharedData.buildId = this._buildId,
this._sharedData.emitComments = this._options.emitComments,
this._sharedData.verbose = t,
this._sharedData.scene = this.getScene(),
this._sharedData.allowEmptyVertexProgram = a;
for (var s = [], l = [], u = 0, c = this._vertexOutputNodes; u < c.length; u++) {
var h = c[u];
s.push(h),
this._initializeBlock(h, this._vertexCompilationState, l, n)
}
for (var f = 0, d = this._fragmentOutputNodes; f < d.length; f++) {
var _ = d[f];
l.push(_),
this._initializeBlock(_, this._fragmentCompilationState, s, n)
}
this.optimize();
for (var g = 0, m = s; g < m.length; g++) {
var h = m[g];
h.build(this._vertexCompilationState, s)
}
this._fragmentCompilationState.uniforms = this._vertexCompilationState.uniforms.slice(0),
this._fragmentCompilationState._uniformDeclaration = this._vertexCompilationState._uniformDeclaration,
this._fragmentCompilationState._constantDeclaration = this._vertexCompilationState._constantDeclaration,
this._fragmentCompilationState._vertexState = this._vertexCompilationState;
for (var v = 0, y = l; v < y.length; v++) {
var _ = y[v];
this._resetDualBlocks(_, this._buildId - 1)
}
for (var b = 0, T = l; b < T.length; b++) {
var _ = T[b];
_.build(this._fragmentCompilationState, l)
}
this._vertexCompilationState.finalize(this._vertexCompilationState),
this._fragmentCompilationState.finalize(this._fragmentCompilationState),
r && (this._buildId = e._BuildIdGenerator++),
this._sharedData.emitErrors(),
t && (console.log("Vertex shader:"),
console.log(this._vertexCompilationState.compilationString),
console.log("Fragment shader:"),
console.log(this._fragmentCompilationState.compilationString)),
this._buildWasSuccessful = !0,
this.onBuildObservable.notifyObservers(this);
for (var C = this.getScene().meshes, A = 0, S = C; A < S.length; A++) {
var P = S[A];
if (!!P.subMeshes)
for (var R = 0, M = P.subMeshes; R < M.length; R++) {
var x = M[R];
if (x.getMaterial() === this && !!x.materialDefines) {
var I = x.materialDefines;
I.markAllAsDirty(),
I.reset()
}
}
}
}
,
e.prototype.optimize = function() {
for (var t = 0, r = this._optimizers; t < r.length; t++) {
var n = r[t];
n.optimize(this._vertexOutputNodes, this._fragmentOutputNodes)
}
}
,
e.prototype._prepareDefinesForAttributes = function(t, r) {
var n = r.NORMAL
, o = r.TANGENT;
r.NORMAL = t.isVerticesDataPresent(VertexBuffer.NormalKind),
r.TANGENT = t.isVerticesDataPresent(VertexBuffer.TangentKind);
for (var a = !1, s = 1; s <= 6; ++s) {
var l = r["UV" + s];
r["UV" + s] = t.isVerticesDataPresent("uv" + (s === 1 ? "" : s)),
a = a || r["UV" + s] !== l
}
(n !== r.NORMAL || o !== r.TANGENT || a) && r.markAsAttributesDirty()
}
,
e.prototype.createPostProcess = function(t, r, n, o, a, s, l) {
return r === void 0 && (r = 1),
n === void 0 && (n = 1),
s === void 0 && (s = 0),
l === void 0 && (l = 5),
this.mode !== NodeMaterialModes.PostProcess ? (console.log("Incompatible material mode"),
null) : this._createEffectForPostProcess(null, t, r, n, o, a, s, l)
}
,
e.prototype.createEffectForPostProcess = function(t) {
this._createEffectForPostProcess(t)
}
,
e.prototype._createEffectForPostProcess = function(t, r, n, o, a, s, l, u) {
var c = this;
n === void 0 && (n = 1),
o === void 0 && (o = 1),
l === void 0 && (l = 0),
u === void 0 && (u = 5);
var h = this.name + this._buildId
, f = new NodeMaterialDefines
, d = new AbstractMesh(h + "PostProcess",this.getScene())
, _ = this._buildId;
return this._processDefines(d, f),
Effect.RegisterShader(h, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString),
t ? t.updateEffect(f.toString(), this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, {
maxSimultaneousLights: this.maxSimultaneousLights
}, void 0, void 0, h, h) : t = new PostProcess(this.name + "PostProcess",h,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,n,r,o,a,s,f.toString(),l,h,{
maxSimultaneousLights: this.maxSimultaneousLights
},!1,u),
t.nodeMaterialSource = this,
t.onApplyObservable.add(function(g) {
_ !== c._buildId && (delete Effect.ShadersStore[h + "VertexShader"],
delete Effect.ShadersStore[h + "PixelShader"],
h = c.name + c._buildId,
f.markAllAsDirty(),
_ = c._buildId);
var m = c._processDefines(d, f);
m && (Effect.RegisterShader(h, c._fragmentCompilationState._builtCompilationString, c._vertexCompilationState._builtCompilationString),
TimingTools.SetImmediate(function() {
return t.updateEffect(f.toString(), c._fragmentCompilationState.uniforms, c._fragmentCompilationState.samplers, {
maxSimultaneousLights: c.maxSimultaneousLights
}, void 0, void 0, h, h)
})),
c._checkInternals(g)
}),
t
}
,
e.prototype.createProceduralTexture = function(t, r) {
var n = this;
if (this.mode !== NodeMaterialModes.ProceduralTexture)
return console.log("Incompatible material mode"),
null;
var o = this.name + this._buildId
, a = new ProceduralTexture(o,t,null,r)
, s = new AbstractMesh(o + "Procedural",this.getScene());
s.reservedDataStore = {
hidden: !0
};
var l = new NodeMaterialDefines
, u = this._processDefines(s, l);
Effect.RegisterShader(o, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString);
var c = this.getScene().getEngine().createEffect({
vertexElement: o,
fragmentElement: o
}, [VertexBuffer.PositionKind], this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, l.toString(), u == null ? void 0 : u.fallbacks, void 0);
a.nodeMaterialSource = this,
a._setEffect(c);
var h = this._buildId;
return a.onBeforeGenerationObservable.add(function() {
h !== n._buildId && (delete Effect.ShadersStore[o + "VertexShader"],
delete Effect.ShadersStore[o + "PixelShader"],
o = n.name + n._buildId,
l.markAllAsDirty(),
h = n._buildId);
var f = n._processDefines(s, l);
f && (Effect.RegisterShader(o, n._fragmentCompilationState._builtCompilationString, n._vertexCompilationState._builtCompilationString),
TimingTools.SetImmediate(function() {
c = n.getScene().getEngine().createEffect({
vertexElement: o,
fragmentElement: o
}, [VertexBuffer.PositionKind], n._fragmentCompilationState.uniforms, n._fragmentCompilationState.samplers, l.toString(), f == null ? void 0 : f.fallbacks, void 0),
a._setEffect(c)
})),
n._checkInternals(c)
}),
a
}
,
e.prototype._createEffectForParticles = function(t, r, n, o, a, s, l, u) {
var c = this;
u === void 0 && (u = "");
var h = this.name + this._buildId + "_" + r;
s || (s = new NodeMaterialDefines),
l || (l = this.getScene().getMeshByName(this.name + "Particle"),
l || (l = new AbstractMesh(this.name + "Particle",this.getScene()),
l.reservedDataStore = {
hidden: !0
}));
var f = this._buildId
, d = []
, _ = u;
if (!a) {
var g = this._processDefines(l, s);
Effect.RegisterShader(h, this._fragmentCompilationState._builtCompilationString),
t.fillDefines(d, r),
_ = d.join(`
`),
a = this.getScene().getEngine().createEffectForParticles(h, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, s.toString() + `
` + _, g == null ? void 0 : g.fallbacks, n, o, t),
t.setCustomEffect(a, r)
}
a.onBindObservable.add(function(m) {
f !== c._buildId && (delete Effect.ShadersStore[h + "PixelShader"],
h = c.name + c._buildId + "_" + r,
s.markAllAsDirty(),
f = c._buildId),
d.length = 0,
t.fillDefines(d, r);
var v = d.join(`
`);
v !== _ && (s.markAllAsDirty(),
_ = v);
var y = c._processDefines(l, s);
if (y) {
Effect.RegisterShader(h, c._fragmentCompilationState._builtCompilationString),
m = c.getScene().getEngine().createEffectForParticles(h, c._fragmentCompilationState.uniforms, c._fragmentCompilationState.samplers, s.toString() + `
` + _, y == null ? void 0 : y.fallbacks, n, o, t),
t.setCustomEffect(m, r),
c._createEffectForParticles(t, r, n, o, m, s, l, _);
return
}
c._checkInternals(m)
})
}
,
e.prototype._checkInternals = function(t) {
if (this._sharedData.animatedInputs) {
var r = this.getScene()
, n = r.getFrameId();
if (this._animationFrame !== n) {
for (var o = 0, a = this._sharedData.animatedInputs; o < a.length; o++) {
var s = a[o];
s.animate(r)
}
this._animationFrame = n
}
}
for (var l = 0, u = this._sharedData.bindableBlocks; l < u.length; l++) {
var c = u[l];
c.bind(t, this)
}
for (var h = 0, f = this._sharedData.inputBlocks; h < f.length; h++) {
var d = f[h];
d._transmit(t, this.getScene())
}
}
,
e.prototype.createEffectForParticles = function(t, r, n) {
if (this.mode !== NodeMaterialModes.Particle) {
console.log("Incompatible material mode");
return
}
this._createEffectForParticles(t, BaseParticleSystem.BLENDMODE_ONEONE, r, n),
this._createEffectForParticles(t, BaseParticleSystem.BLENDMODE_MULTIPLY, r, n)
}
,
e.prototype._processDefines = function(t, r, n, o) {
var a = this;
n === void 0 && (n = !1);
var s = null;
if (this._sharedData.blocksWithDefines.forEach(function(d) {
d.initializeDefines(t, a, r, n)
}),
this._sharedData.blocksWithDefines.forEach(function(d) {
d.prepareDefines(t, a, r, n, o)
}),
r.isDirty) {
var l = r._areLightsDisposed;
r.markAsProcessed(),
this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString,
this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString,
this._sharedData.repeatableContentBlocks.forEach(function(d) {
d.replaceRepeatableContent(a._vertexCompilationState, a._fragmentCompilationState, t, r)
});
var u = [];
this._sharedData.dynamicUniformBlocks.forEach(function(d) {
d.updateUniformsAndSamples(a._vertexCompilationState, a, r, u)
});
var c = this._vertexCompilationState.uniforms;
this._fragmentCompilationState.uniforms.forEach(function(d) {
var _ = c.indexOf(d);
_ === -1 && c.push(d)
});
var h = this._vertexCompilationState.samplers;
this._fragmentCompilationState.samplers.forEach(function(d) {
var _ = h.indexOf(d);
_ === -1 && h.push(d)
});
var f = new EffectFallbacks;
this._sharedData.blocksWithFallbacks.forEach(function(d) {
d.provideFallbacks(t, f)
}),
s = {
lightDisposed: l,
uniformBuffers: u,
mergedUniforms: c,
mergedSamplers: h,
fallbacks: f
}
}
return s
}
,
e.prototype.isReadyForSubMesh = function(t, r, n) {
var o = this;
if (n === void 0 && (n = !1),
!this._buildWasSuccessful)
return !1;
var a = this.getScene();
if (this._sharedData.animatedInputs) {
var s = a.getFrameId();
if (this._animationFrame !== s) {
for (var l = 0, u = this._sharedData.animatedInputs; l < u.length; l++) {
var c = u[l];
c.animate(a)
}
this._animationFrame = s
}
}
if (r.effect && this.isFrozen && r.effect._wasPreviouslyReady)
return !0;
r.materialDefines || (r.materialDefines = new NodeMaterialDefines);
var h = r.materialDefines;
if (this._isReadyForSubMesh(r))
return !0;
var f = a.getEngine();
if (this._prepareDefinesForAttributes(t, h),
this._sharedData.blockingBlocks.some(function(v) {
return !v.isReady(t, o, h, n)
}))
return !1;
var d = this._processDefines(t, h, n, r);
if (d) {
var _ = r.effect
, g = h.toString()
, m = f.createEffect({
vertex: "nodeMaterial" + this._buildId,
fragment: "nodeMaterial" + this._buildId,
vertexSource: this._vertexCompilationState.compilationString,
fragmentSource: this._fragmentCompilationState.compilationString
}, {
attributes: this._vertexCompilationState.attributes,
uniformsNames: d.mergedUniforms,
uniformBuffersNames: d.uniformBuffers,
samplers: d.mergedSamplers,
defines: g,
fallbacks: d.fallbacks,
onCompiled: this.onCompiled,
onError: this.onError,
indexParameters: {
maxSimultaneousLights: this.maxSimultaneousLights,
maxSimultaneousMorphTargets: h.NUM_MORPH_INFLUENCERS
}
}, f);
if (m)
if (this._onEffectCreatedObservable && (onCreatedEffectParameters$1.effect = m,
onCreatedEffectParameters$1.subMesh = r,
this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters$1)),
this.allowShaderHotSwapping && _ && !m.isReady()) {
if (m = _,
h.markAsUnprocessed(),
d.lightDisposed)
return h._areLightsDisposed = !0,
!1
} else
a.resetCachedMaterial(),
r.setEffect(m, h, this._materialContext)
}
return !r.effect || !r.effect.isReady() ? !1 : (h._renderId = a.getRenderId(),
r.effect._wasPreviouslyReady = !0,
!0)
}
,
Object.defineProperty(e.prototype, "compiledShaders", {
get: function() {
return `// Vertex shader\r
` + this._vertexCompilationState.compilationString + `\r
\r
// Fragment shader\r
` + this._fragmentCompilationState.compilationString
},
enumerable: !1,
configurable: !0
}),
e.prototype.bindOnlyWorldMatrix = function(t) {
var r = this.getScene();
if (!!this._activeEffect) {
var n = this._sharedData.hints;
n.needWorldViewMatrix && t.multiplyToRef(r.getViewMatrix(), this._cachedWorldViewMatrix),
n.needWorldViewProjectionMatrix && t.multiplyToRef(r.getTransformMatrix(), this._cachedWorldViewProjectionMatrix);
for (var o = 0, a = this._sharedData.inputBlocks; o < a.length; o++) {
var s = a[o];
s._transmitWorld(this._activeEffect, t, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix)
}
}
}
,
e.prototype.bindForSubMesh = function(t, r, n) {
var o = this.getScene()
, a = n.effect;
if (!!a) {
this._activeEffect = a,
this.bindOnlyWorldMatrix(t);
var s = this._mustRebind(o, a, r.visibility)
, l = this._sharedData;
if (s) {
if (a) {
for (var u = 0, c = l.bindableBlocks; u < c.length; u++) {
var h = c[u];
h.bind(a, this, r, n)
}
for (var f = 0, d = l.forcedBindableBlocks; f < d.length; f++) {
var h = d[f];
h.bind(a, this, r, n)
}
for (var _ = 0, g = l.inputBlocks; _ < g.length; _++) {
var m = g[_];
m._transmit(a, o)
}
}
} else if (!this.isFrozen)
for (var v = 0, y = l.forcedBindableBlocks; v < y.length; v++) {
var h = y[v];
h.bind(a, this, r, n)
}
this._afterBind(r, this._activeEffect)
}
}
,
e.prototype.getActiveTextures = function() {
var t = i.prototype.getActiveTextures.call(this);
return this._sharedData && t.push.apply(t, this._sharedData.textureBlocks.filter(function(r) {
return r.texture
}).map(function(r) {
return r.texture
})),
t
}
,
e.prototype.getTextureBlocks = function() {
return this._sharedData ? this._sharedData.textureBlocks : []
}
,
e.prototype.hasTexture = function(t) {
if (i.prototype.hasTexture.call(this, t))
return !0;
if (!this._sharedData)
return !1;
for (var r = 0, n = this._sharedData.textureBlocks; r < n.length; r++) {
var o = n[r];
if (o.texture === t)
return !0
}
return !1
}
,
e.prototype.dispose = function(t, r, n) {
if (r && this._sharedData)
for (var o = 0, a = this._sharedData.textureBlocks.filter(function(h) {
return h.texture
}).map(function(h) {
return h.texture
}); o < a.length; o++) {
var s = a[o];
s.dispose()
}
for (var l = 0, u = this.attachedBlocks; l < u.length; l++) {
var c = u[l];
c.dispose()
}
this.attachedBlocks = [],
this._sharedData = null,
this._vertexCompilationState = null,
this._fragmentCompilationState = null,
this.attachedBlocks = [],
this._sharedData = null,
this._vertexCompilationState = null,
this._fragmentCompilationState = null,
this.onBuildObservable.clear(),
this._imageProcessingObserver && (this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
this._imageProcessingObserver = null),
i.prototype.dispose.call(this, t, r, n)
}
,
e.prototype._createNodeEditor = function() {
this.BJSNODEMATERIALEDITOR.NodeEditor.Show({
nodeMaterial: this
})
}
,
e.prototype.edit = function(t) {
var r = this;
return new Promise(function(n, o) {
if (r.BJSNODEMATERIALEDITOR = r.BJSNODEMATERIALEDITOR || r._getGlobalNodeMaterialEditor(),
typeof r.BJSNODEMATERIALEDITOR == "undefined") {
var a = t && t.editorURL ? t.editorURL : e.EditorURL;
Tools.LoadScript(a, function() {
r.BJSNODEMATERIALEDITOR = r.BJSNODEMATERIALEDITOR || r._getGlobalNodeMaterialEditor(),
r._createNodeEditor(),
n()
})
} else
r._createNodeEditor(),
n()
}
)
}
,
e.prototype.clear = function() {
this._vertexOutputNodes = [],
this._fragmentOutputNodes = [],
this.attachedBlocks = []
}
,
e.prototype.setToDefault = function() {
this.clear(),
this.editorData = null;
var t = new InputBlock("Position");
t.setAsAttribute("position");
var r = new InputBlock("World");
r.setAsSystemValue(NodeMaterialSystemValues.World);
var n = new TransformBlock("WorldPos");
t.connectTo(n),
r.connectTo(n);
var o = new InputBlock("ViewProjection");
o.setAsSystemValue(NodeMaterialSystemValues.ViewProjection);
var a = new TransformBlock("WorldPos * ViewProjectionTransform");
n.connectTo(a),
o.connectTo(a);
var s = new VertexOutputBlock("VertexOutput");
a.connectTo(s);
var l = new InputBlock("color");
l.value = new Color4(.8,.8,.8,1);
var u = new FragmentOutputBlock("FragmentOutput");
l.connectTo(u),
this.addOutputNode(s),
this.addOutputNode(u),
this._mode = NodeMaterialModes.Material
}
,
e.prototype.setToDefaultPostProcess = function() {
this.clear(),
this.editorData = null;
var t = new InputBlock("Position");
t.setAsAttribute("position2d");
var r = new InputBlock("Constant1");
r.isConstant = !0,
r.value = 1;
var n = new VectorMergerBlock("Position3D");
t.connectTo(n),
r.connectTo(n, {
input: "w"
});
var o = new VertexOutputBlock("VertexOutput");
n.connectTo(o);
var a = new InputBlock("Scale");
a.visibleInInspector = !0,
a.value = new Vector2(1,1);
var s = new RemapBlock("uv0");
t.connectTo(s);
var l = new MultiplyBlock("UV scale");
s.connectTo(l),
a.connectTo(l);
var u = new CurrentScreenBlock("CurrentScreen");
l.connectTo(u),
u.texture = new Texture("https://assets.babylonjs.com/nme/currentScreenPostProcess.png",this.getScene());
var c = new FragmentOutputBlock("FragmentOutput");
u.connectTo(c, {
output: "rgba"
}),
this.addOutputNode(o),
this.addOutputNode(c),
this._mode = NodeMaterialModes.PostProcess
}
,
e.prototype.setToDefaultProceduralTexture = function() {
this.clear(),
this.editorData = null;
var t = new InputBlock("Position");
t.setAsAttribute("position2d");
var r = new InputBlock("Constant1");
r.isConstant = !0,
r.value = 1;
var n = new VectorMergerBlock("Position3D");
t.connectTo(n),
r.connectTo(n, {
input: "w"
});
var o = new VertexOutputBlock("VertexOutput");
n.connectTo(o);
var a = new InputBlock("Time");
a.value = 0,
a.min = 0,
a.max = 0,
a.isBoolean = !1,
a.matrixMode = 0,
a.animationType = AnimatedInputBlockTypes.Time,
a.isConstant = !1;
var s = new InputBlock("Color3");
s.value = new Color3(1,1,1),
s.isConstant = !1;
var l = new FragmentOutputBlock("FragmentOutput")
, u = new VectorMergerBlock("VectorMerger");
u.visibleInInspector = !1;
var c = new TrigonometryBlock("Cos");
c.operation = TrigonometryBlockOperations.Cos,
t.connectTo(u),
a.output.connectTo(c.input),
c.output.connectTo(u.z),
u.xyzOut.connectTo(l.rgb),
this.addOutputNode(o),
this.addOutputNode(l),
this._mode = NodeMaterialModes.ProceduralTexture
}
,
e.prototype.setToDefaultParticle = function() {
this.clear(),
this.editorData = null;
var t = new InputBlock("uv");
t.setAsAttribute("particle_uv");
var r = new ParticleTextureBlock("ParticleTexture");
t.connectTo(r);
var n = new InputBlock("Color");
n.setAsAttribute("particle_color");
var o = new MultiplyBlock("Texture * Color");
r.connectTo(o),
n.connectTo(o);
var a = new ParticleRampGradientBlock("ParticleRampGradient");
o.connectTo(a);
var s = new ColorSplitterBlock("ColorSplitter");
n.connectTo(s);
var l = new ParticleBlendMultiplyBlock("ParticleBlendMultiply");
a.connectTo(l),
r.connectTo(l, {
output: "a"
}),
s.connectTo(l, {
output: "a"
});
var u = new FragmentOutputBlock("FragmentOutput");
l.connectTo(u),
this.addOutputNode(u),
this._mode = NodeMaterialModes.Particle
}
,
e.prototype.loadAsync = function(t) {
var r = this;
return this.getScene()._loadFileAsync(t).then(function(n) {
var o = JSON.parse(n);
r.loadFromSerialization(o, "")
})
}
,
e.prototype._gatherBlocks = function(t, r) {
if (r.indexOf(t) === -1) {
r.push(t);
for (var n = 0, o = t.inputs; n < o.length; n++) {
var a = o[n]
, s = a.connectedPoint;
if (s) {
var l = s.ownerBlock;
l !== t && this._gatherBlocks(l, r)
}
}
}
}
,
e.prototype.generateCode = function() {
for (var t = [], r = [], n = ["const", "var", "let"], o = 0, a = this._vertexOutputNodes; o < a.length; o++) {
var s = a[o];
this._gatherBlocks(s, r)
}
for (var l = [], u = 0, c = this._fragmentOutputNodes; u < c.length; u++) {
var s = c[u];
this._gatherBlocks(s, l)
}
for (var h = 'var nodeMaterial = new BABYLON.NodeMaterial("' + (this.name || "node material") + `");\r
`, f = 0, d = r; f < d.length; f++) {
var _ = d[f];
_.isInput && t.indexOf(_) === -1 && (h += _._dumpCode(n, t))
}
for (var g = 0, m = l; g < m.length; g++) {
var _ = m[g];
_.isInput && t.indexOf(_) === -1 && (h += _._dumpCode(n, t))
}
t = [],
h += `\r
// Connections\r
`;
for (var v = 0, y = this._vertexOutputNodes; v < y.length; v++) {
var _ = y[v];
h += _._dumpCodeForOutputConnections(t)
}
for (var b = 0, T = this._fragmentOutputNodes; b < T.length; b++) {
var _ = T[b];
h += _._dumpCodeForOutputConnections(t)
}
h += `\r
// Output nodes\r
`;
for (var C = 0, A = this._vertexOutputNodes; C < A.length; C++) {
var _ = A[C];
h += "nodeMaterial.addOutputNode(" + _._codeVariableName + `);\r
`
}
for (var S = 0, P = this._fragmentOutputNodes; S < P.length; S++) {
var _ = P[S];
h += "nodeMaterial.addOutputNode(" + _._codeVariableName + `);\r
`
}
return h += `nodeMaterial.build();\r
`,
h
}
,
e.prototype.serialize = function(t) {
var r = t ? {} : SerializationHelper.Serialize(this);
r.editorData = JSON.parse(JSON.stringify(this.editorData));
var n = [];
if (t)
n = t;
else {
r.customType = "BABYLON.NodeMaterial",
r.outputNodes = [];
for (var o = 0, a = this._vertexOutputNodes; o < a.length; o++) {
var s = a[o];
this._gatherBlocks(s, n),
r.outputNodes.push(s.uniqueId)
}
for (var l = 0, u = this._fragmentOutputNodes; l < u.length; l++) {
var s = u[l];
this._gatherBlocks(s, n),
r.outputNodes.indexOf(s.uniqueId) === -1 && r.outputNodes.push(s.uniqueId)
}
}
r.blocks = [];
for (var c = 0, h = n; c < h.length; c++) {
var f = h[c];
r.blocks.push(f.serialize())
}
if (!t)
for (var d = 0, _ = this.attachedBlocks; d < _.length; d++) {
var f = _[d];
n.indexOf(f) === -1 && r.blocks.push(f.serialize())
}
return r
}
,
e.prototype._restoreConnections = function(t, r, n) {
for (var o = 0, a = t.outputs; o < a.length; o++)
for (var s = a[o], l = 0, u = r.blocks; l < u.length; l++) {
var c = u[l]
, h = n[c.id];
if (!!h)
for (var f = 0, d = c.inputs; f < d.length; f++) {
var _ = d[f];
if (n[_.targetBlockId] === t && _.targetConnectionName === s.name) {
var g = h.getInputByName(_.inputName);
if (!g || g.isConnected)
continue;
s.connectTo(g, !0),
this._restoreConnections(h, r, n);
continue
}
}
}
}
,
e.prototype.loadFromSerialization = function(t, r, n) {
var o;
r === void 0 && (r = ""),
n === void 0 && (n = !1),
n || this.clear();
for (var a = {}, s = 0, l = t.blocks; s < l.length; s++) {
var u = l[s]
, c = GetClass(u.customType);
if (c) {
var h = new c;
h._deserialize(u, this.getScene(), r),
a[u.id] = h,
this.attachedBlocks.push(h)
}
}
for (var f = 0; f < t.blocks.length; f++) {
var d = t.blocks[f]
, h = a[d.id];
!h || h.inputs.length && !n || this._restoreConnections(h, t, a)
}
if (t.outputNodes)
for (var _ = 0, g = t.outputNodes; _ < g.length; _++) {
var m = g[_];
this.addOutputNode(a[m])
}
if (t.locations || t.editorData && t.editorData.locations) {
for (var v = t.locations || t.editorData.locations, y = 0, b = v; y < b.length; y++) {
var T = b[y];
a[T.blockId] && (T.blockId = a[T.blockId].uniqueId)
}
n && this.editorData && this.editorData.locations && v.concat(this.editorData.locations),
t.locations ? this.editorData = {
locations: v
} : (this.editorData = t.editorData,
this.editorData.locations = v);
var C = [];
for (var A in a)
C[A] = a[A].uniqueId;
this.editorData.map = C
}
this.comment = t.comment,
n || (this._mode = (o = t.mode) !== null && o !== void 0 ? o : NodeMaterialModes.Material)
}
,
e.prototype.clone = function(t, r) {
var n = this;
r === void 0 && (r = !1);
var o = this.serialize()
, a = SerializationHelper.Clone(function() {
return new e(t,n.getScene(),n.options)
}, this);
return a.id = t,
a.name = t,
a.loadFromSerialization(o),
a._buildId = this._buildId,
a.build(!1, !r),
a
}
,
e.Parse = function(t, r, n) {
n === void 0 && (n = "");
var o = SerializationHelper.Parse(function() {
return new e(t.name,r)
}, t, r, n);
return o.loadFromSerialization(t, n),
o.build(),
o
}
,
e.ParseFromFileAsync = function(t, r, n) {
var o = new e(t,n);
return new Promise(function(a, s) {
return o.loadAsync(r).then(function() {
o.build(),
a(o)
}).catch(s)
}
)
}
,
e.ParseFromSnippetAsync = function(t, r, n, o) {
var a = this;
return n === void 0 && (n = ""),
t === "_BLANK" ? Promise.resolve(this.CreateDefault("blank", r)) : new Promise(function(s, l) {
var u = new WebRequest;
u.addEventListener("readystatechange", function() {
if (u.readyState == 4)
if (u.status == 200) {
var c = JSON.parse(JSON.parse(u.responseText).jsonPayload)
, h = JSON.parse(c.nodeMaterial);
o || (o = SerializationHelper.Parse(function() {
return new e(t,r)
}, h, r, n),
o.uniqueId = r.getUniqueId()),
o.loadFromSerialization(h),
o.snippetId = t;
try {
o.build(),
s(o)
} catch (f) {
l(f)
}
} else
l("Unable to load the snippet " + t)
}),
u.open("GET", a.SnippetUrl + "/" + t.replace(/#/g, "/")),
u.send()
}
)
}
,
e.CreateDefault = function(t, r) {
var n = new e(t,r);
return n.setToDefault(),
n.build(),
n
}
,
e._BuildIdGenerator = 0,
e.EditorURL = "https://unpkg.com/babylonjs-node-editor@" + Engine.Version + "/babylon.nodeEditor.js",
e.SnippetUrl = "https://snippet.babylonjs.com",
e.IgnoreTexturesAtLoadTime = !1,
__decorate([serialize()], e.prototype, "ignoreAlpha", void 0),
__decorate([serialize()], e.prototype, "maxSimultaneousLights", void 0),
__decorate([serialize("mode")], e.prototype, "_mode", void 0),
__decorate([serialize("comment")], e.prototype, "comment", void 0),
e
}(PushMaterial);
RegisterClass("BABYLON.NodeMaterial", NodeMaterial);
var BonesBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Vertex) || this;
return r.registerInput("matricesIndices", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerInput("matricesWeights", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerInput("matricesIndicesExtra", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
r.registerInput("matricesWeightsExtra", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
r.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.initialize = function(t) {
t._excludeVariableName("boneSampler"),
t._excludeVariableName("boneTextureWidth"),
t._excludeVariableName("mBones"),
t._excludeVariableName("BonesPerMesh")
}
,
e.prototype.getClassName = function() {
return "BonesBlock"
}
,
Object.defineProperty(e.prototype, "matricesIndices", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "matricesWeights", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "matricesIndicesExtra", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "matricesWeightsExtra", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "world", {
get: function() {
return this._inputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.matricesIndices.isConnected) {
var r = t.getInputBlockByPredicate(function(a) {
return a.isAttribute && a.name === "matricesIndices"
});
r || (r = new InputBlock("matricesIndices"),
r.setAsAttribute("matricesIndices")),
r.output.connectTo(this.matricesIndices)
}
if (!this.matricesWeights.isConnected) {
var n = t.getInputBlockByPredicate(function(a) {
return a.isAttribute && a.name === "matricesWeights"
});
n || (n = new InputBlock("matricesWeights"),
n.setAsAttribute("matricesWeights")),
n.output.connectTo(this.matricesWeights)
}
if (!this.world.isConnected) {
var o = t.getInputBlockByPredicate(function(a) {
return a.systemValue === NodeMaterialSystemValues.World
});
o || (o = new InputBlock("world"),
o.setAsSystemValue(NodeMaterialSystemValues.World)),
o.output.connectTo(this.world)
}
}
,
e.prototype.provideFallbacks = function(t, r) {
t && t.useBones && t.computeBonesUsingShaders && t.skeleton && r.addCPUSkinningFallback(0, t)
}
,
e.prototype.bind = function(t, r, n) {
MaterialHelper.BindBonesParameters(n, t)
}
,
e.prototype.prepareDefines = function(t, r, n) {
!n._areAttributesDirty || MaterialHelper.PrepareDefinesForBones(t, n)
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t),
t.sharedData.blocksWithFallbacks.push(this),
t.sharedData.bindableBlocks.push(this),
t.sharedData.blocksWithDefines.push(this),
t.uniforms.push("boneTextureWidth"),
t.uniforms.push("mBones"),
t.samplers.push("boneSampler");
var r = "//" + this.name;
t._emitFunctionFromInclude("bonesDeclaration", r, {
removeAttributes: !0,
removeUniforms: !1,
removeVaryings: !0,
removeIfDef: !1
});
var n = t._getFreeVariableName("influence");
t.compilationString += t._emitCodeFromInclude("bonesVertex", r, {
replaceStrings: [{
search: /finalWorld=finalWorld\*influence;/,
replace: ""
}, {
search: /influence/gm,
replace: n
}]
});
var o = this._outputs[0]
, a = this.world;
return t.compilationString += `#if NUM_BONE_INFLUENCERS>0\r
`,
t.compilationString += this._declareOutput(o, t) + (" = " + a.associatedVariableName + " * " + n + `;\r
`),
t.compilationString += `#else\r
`,
t.compilationString += this._declareOutput(o, t) + (" = " + a.associatedVariableName + `;\r
`),
t.compilationString += `#endif\r
`,
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.BonesBlock", BonesBlock);
var InstancesBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Vertex) || this;
return r.registerInput("world0", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerInput("world1", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerInput("world2", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerInput("world3", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix, !0),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix),
r.registerOutput("instanceID", NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "InstancesBlock"
}
,
Object.defineProperty(e.prototype, "world0", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "world1", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "world2", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "world3", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "world", {
get: function() {
return this._inputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "instanceID", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.world0.connectedPoint) {
var r = t.getInputBlockByPredicate(function(l) {
return l.isAttribute && l.name === "world0"
});
r || (r = new InputBlock("world0"),
r.setAsAttribute("world0")),
r.output.connectTo(this.world0)
}
if (!this.world1.connectedPoint) {
var n = t.getInputBlockByPredicate(function(l) {
return l.isAttribute && l.name === "world1"
});
n || (n = new InputBlock("world1"),
n.setAsAttribute("world1")),
n.output.connectTo(this.world1)
}
if (!this.world2.connectedPoint) {
var o = t.getInputBlockByPredicate(function(l) {
return l.isAttribute && l.name === "world2"
});
o || (o = new InputBlock("world2"),
o.setAsAttribute("world2")),
o.output.connectTo(this.world2)
}
if (!this.world3.connectedPoint) {
var a = t.getInputBlockByPredicate(function(l) {
return l.isAttribute && l.name === "world3"
});
a || (a = new InputBlock("world3"),
a.setAsAttribute("world3")),
a.output.connectTo(this.world3)
}
if (!this.world.connectedPoint) {
var s = t.getInputBlockByPredicate(function(l) {
return l.isAttribute && l.name === "world"
});
s || (s = new InputBlock("world"),
s.setAsSystemValue(NodeMaterialSystemValues.World)),
s.output.connectTo(this.world)
}
this.world.define = "!INSTANCES || THIN_INSTANCES"
}
,
e.prototype.prepareDefines = function(t, r, n, o, a) {
o === void 0 && (o = !1);
var s = !1;
n.INSTANCES !== o && (n.setValue("INSTANCES", o),
s = !0),
a && n.THIN_INSTANCES !== !!(a != null && a.getRenderingMesh().hasThinInstances) && (n.setValue("THIN_INSTANCES", !!(a != null && a.getRenderingMesh().hasThinInstances)),
s = !0),
s && n.markAsUnprocessed()
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = t.sharedData.scene.getEngine();
t.sharedData.blocksWithDefines.push(this);
var n = this._outputs[0]
, o = this._outputs[1]
, a = this.world0
, s = this.world1
, l = this.world2
, u = this.world3;
return t.compilationString += `#ifdef INSTANCES\r
`,
t.compilationString += this._declareOutput(n, t) + (" = mat4(" + a.associatedVariableName + ", " + s.associatedVariableName + ", " + l.associatedVariableName + ", " + u.associatedVariableName + `);\r
`),
t.compilationString += `#ifdef THIN_INSTANCES\r
`,
t.compilationString += n.associatedVariableName + " = " + this.world.associatedVariableName + " * " + n.associatedVariableName + `;\r
`,
t.compilationString += `#endif\r
`,
r._caps.canUseGLInstanceID ? t.compilationString += this._declareOutput(o, t) + ` = float(gl_InstanceID);\r
` : t.compilationString += this._declareOutput(o, t) + ` = 0.0;\r
`,
t.compilationString += `#else\r
`,
t.compilationString += this._declareOutput(n, t) + (" = " + this.world.associatedVariableName + `;\r
`),
t.compilationString += this._declareOutput(o, t) + ` = 0.0;\r
`,
t.compilationString += `#endif\r
`,
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.InstancesBlock", InstancesBlock);
var MorphTargetsBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Vertex) || this;
return r.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("normal", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("tangent", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerOutput("positionOutput", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("normalOutput", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("tangentOutput", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("uvOutput", NodeMaterialBlockConnectionPointTypes.Vector2),
r
}
return e.prototype.getClassName = function() {
return "MorphTargetsBlock"
}
,
Object.defineProperty(e.prototype, "position", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "normal", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "tangent", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "uv", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "positionOutput", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "normalOutput", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "tangentOutput", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "uvOutput", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
e.prototype.initialize = function(t) {
t._excludeVariableName("morphTargetInfluences")
}
,
e.prototype.autoConfigure = function(t) {
if (!this.position.isConnected) {
var r = t.getInputBlockByPredicate(function(s) {
return s.isAttribute && s.name === "position"
});
r || (r = new InputBlock("position"),
r.setAsAttribute()),
r.output.connectTo(this.position)
}
if (!this.normal.isConnected) {
var n = t.getInputBlockByPredicate(function(s) {
return s.isAttribute && s.name === "normal"
});
n || (n = new InputBlock("normal"),
n.setAsAttribute("normal")),
n.output.connectTo(this.normal)
}
if (!this.tangent.isConnected) {
var o = t.getInputBlockByPredicate(function(s) {
return s.isAttribute && s.name === "tangent"
});
o || (o = new InputBlock("tangent"),
o.setAsAttribute("tangent")),
o.output.connectTo(this.tangent)
}
if (!this.uv.isConnected) {
var a = t.getInputBlockByPredicate(function(s) {
return s.isAttribute && s.name === "uv"
});
a || (a = new InputBlock("uv"),
a.setAsAttribute("uv")),
a.output.connectTo(this.uv)
}
}
,
e.prototype.prepareDefines = function(t, r, n) {
if (t.morphTargetManager) {
var o = t.morphTargetManager;
(o == null ? void 0 : o.isUsingTextureForTargets) && o.numInfluencers !== n.NUM_MORPH_INFLUENCERS && n.markAsAttributesDirty()
}
!n._areAttributesDirty || MaterialHelper.PrepareDefinesForMorphTargets(t, n)
}
,
e.prototype.bind = function(t, r, n) {
n && n.morphTargetManager && n.morphTargetManager.numInfluencers > 0 && (MaterialHelper.BindMorphTargetParameters(n, t),
n.morphTargetManager.isUsingTextureForTargets && n.morphTargetManager._bind(t))
}
,
e.prototype.replaceRepeatableContent = function(t, r, n, o) {
var a = this.position
, s = this.normal
, l = this.tangent
, u = this.uv
, c = this.positionOutput
, h = this.normalOutput
, f = this.tangentOutput
, d = this.uvOutput
, _ = t
, g = o.NUM_MORPH_INFLUENCERS
, m = n.morphTargetManager
, v = m && m.supportsNormals && o.NORMAL
, y = m && m.supportsTangents && o.TANGENT
, b = m && m.supportsUVs && o.UV1
, T = "";
(m == null ? void 0 : m.isUsingTextureForTargets) && g > 0 && (T += `float vertexID;\r
`);
for (var C = 0; C < g; C++)
T += `#ifdef MORPHTARGETS\r
`,
m != null && m.isUsingTextureForTargets ? (T += `vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;\r
`,
T += c.associatedVariableName + " += (readVector3FromRawSampler(" + C + ", vertexID) - " + a.associatedVariableName + ") * morphTargetInfluences[" + C + `];\r
`,
T += `vertexID += 1.0;\r
`) : T += c.associatedVariableName + " += (position" + C + " - " + a.associatedVariableName + ") * morphTargetInfluences[" + C + `];\r
`,
v && (T += `#ifdef MORPHTARGETS_NORMAL\r
`,
m != null && m.isUsingTextureForTargets ? (T += h.associatedVariableName + " += (readVector3FromRawSampler(" + C + ", vertexID) - " + s.associatedVariableName + ") * morphTargetInfluences[" + C + `];\r
`,
T += `vertexID += 1.0;\r
`) : T += h.associatedVariableName + " += (normal" + C + " - " + s.associatedVariableName + ") * morphTargetInfluences[" + C + `];\r
`,
T += `#endif\r
`),
b && (T += `#ifdef MORPHTARGETS_UV\r
`,
m != null && m.isUsingTextureForTargets ? (T += d.associatedVariableName + " += (readVector3FromRawSampler(" + C + ", vertexID).xy - " + u.associatedVariableName + ") * morphTargetInfluences[" + C + `];\r
`,
T += `vertexID += 1.0;\r
`) : T += d.associatedVariableName + ".xy += (uv_" + C + " - " + u.associatedVariableName + ".xy) * morphTargetInfluences[" + C + `];\r
`,
T += `#endif\r
`),
y && (T += `#ifdef MORPHTARGETS_TANGENT\r
`,
m != null && m.isUsingTextureForTargets ? T += f.associatedVariableName + " += (readVector3FromRawSampler(" + C + ", vertexID) - " + l.associatedVariableName + ") * morphTargetInfluences[" + C + `];\r
` : T += f.associatedVariableName + ".xyz += (tangent" + C + " - " + l.associatedVariableName + ".xyz) * morphTargetInfluences[" + C + `];\r
`,
T += `#endif\r
`),
T += `#endif\r
`;
if (_.compilationString = _.compilationString.replace(this._repeatableContentAnchor, T),
g > 0)
for (var C = 0; C < g; C++)
_.attributes.push(VertexBuffer.PositionKind + C),
v && _.attributes.push(VertexBuffer.NormalKind + C),
y && _.attributes.push(VertexBuffer.TangentKind + C),
b && _.attributes.push(VertexBuffer.UVKind + "_" + C)
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t),
t.sharedData.blocksWithDefines.push(this),
t.sharedData.bindableBlocks.push(this),
t.sharedData.repeatableContentBlocks.push(this);
var r = this.position
, n = this.normal
, o = this.tangent
, a = this.uv
, s = this.positionOutput
, l = this.normalOutput
, u = this.tangentOutput
, c = this.uvOutput
, h = "//" + this.name;
return t.uniforms.push("morphTargetInfluences"),
t.uniforms.push("morphTargetTextureInfo"),
t.uniforms.push("morphTargetTextureIndices"),
t.samplers.push("morphTargets"),
t._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration", h),
t._emitFunctionFromInclude("morphTargetsVertexDeclaration", h, {
repeatKey: "maxSimultaneousMorphTargets"
}),
t.compilationString += this._declareOutput(s, t) + " = " + r.associatedVariableName + `;\r
`,
t.compilationString += `#ifdef NORMAL\r
`,
t.compilationString += this._declareOutput(l, t) + " = " + n.associatedVariableName + `;\r
`,
t.compilationString += `#else\r
`,
t.compilationString += this._declareOutput(l, t) + ` = vec3(0., 0., 0.);\r
`,
t.compilationString += `#endif\r
`,
t.compilationString += `#ifdef TANGENT\r
`,
t.compilationString += this._declareOutput(u, t) + " = " + o.associatedVariableName + `;\r
`,
t.compilationString += `#else\r
`,
t.compilationString += this._declareOutput(u, t) + ` = vec3(0., 0., 0.);\r
`,
t.compilationString += `#endif\r
`,
t.compilationString += `#ifdef UV1\r
`,
t.compilationString += this._declareOutput(c, t) + " = " + a.associatedVariableName + `;\r
`,
t.compilationString += `#else\r
`,
t.compilationString += this._declareOutput(c, t) + ` = vec2(0., 0.);\r
`,
t.compilationString += `#endif\r
`,
this._repeatableContentAnchor = t._repeatableContentAnchor,
t.compilationString += this._repeatableContentAnchor,
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.MorphTargetsBlock", MorphTargetsBlock);
var LightInformationBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Vertex) || this;
return r.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
r.registerOutput("direction", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("color", NodeMaterialBlockConnectionPointTypes.Color3),
r.registerOutput("intensity", NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "LightInformationBlock"
}
,
Object.defineProperty(e.prototype, "worldPosition", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "direction", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "color", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "intensity", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
e.prototype.bind = function(t, r, n) {
if (!!n) {
this.light && this.light.isDisposed && (this.light = null);
var o = this.light
, a = r.getScene();
if (!o && a.lights.length && (o = this.light = a.lights[0],
this._forcePrepareDefines = !0),
!o || !o.isEnabled) {
t.setFloat3(this._lightDataUniformName, 0, 0, 0),
t.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);
return
}
o.transferToNodeMaterialEffect(t, this._lightDataUniformName),
t.setColor4(this._lightColorUniformName, o.diffuse, o.intensity)
}
}
,
e.prototype.prepareDefines = function(t, r, n) {
if (!(!n._areLightsDirty && !this._forcePrepareDefines)) {
this._forcePrepareDefines = !1;
var o = this.light;
n.setValue(this._lightTypeDefineName, !!(o && o instanceof PointLight), !0)
}
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t),
t.sharedData.bindableBlocks.push(this),
t.sharedData.blocksWithDefines.push(this);
var r = this.direction
, n = this.color
, o = this.intensity;
return this._lightDataUniformName = t._getFreeVariableName("lightData"),
this._lightColorUniformName = t._getFreeVariableName("lightColor"),
this._lightTypeDefineName = t._getFreeDefineName("LIGHTPOINTTYPE"),
t._emitUniformFromString(this._lightDataUniformName, "vec3"),
t._emitUniformFromString(this._lightColorUniformName, "vec4"),
t.compilationString += "#ifdef " + this._lightTypeDefineName + `\r
`,
t.compilationString += this._declareOutput(r, t) + (" = normalize(" + this.worldPosition.associatedVariableName + ".xyz - " + this._lightDataUniformName + `);\r
`),
t.compilationString += `#else\r
`,
t.compilationString += this._declareOutput(r, t) + (" = " + this._lightDataUniformName + `;\r
`),
t.compilationString += `#endif\r
`,
t.compilationString += this._declareOutput(n, t) + (" = " + this._lightColorUniformName + `.rgb;\r
`),
t.compilationString += this._declareOutput(o, t) + (" = " + this._lightColorUniformName + `.a;\r
`),
this
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return this.light && (t.lightId = this.light.id),
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
t.lightId && (this.light = r.getLightById(t.lightId))
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.LightInformationBlock", LightInformationBlock);
var ImageProcessingBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r.convertInputToLinearSpace = !0,
r.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color4),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color4),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
r
}
return e.prototype.getClassName = function() {
return "ImageProcessingBlock"
}
,
Object.defineProperty(e.prototype, "color", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.initialize = function(t) {
t._excludeVariableName("exposureLinear"),
t._excludeVariableName("contrast"),
t._excludeVariableName("vInverseScreenSize"),
t._excludeVariableName("vignetteSettings1"),
t._excludeVariableName("vignetteSettings2"),
t._excludeVariableName("vCameraColorCurveNegative"),
t._excludeVariableName("vCameraColorCurveNeutral"),
t._excludeVariableName("vCameraColorCurvePositive"),
t._excludeVariableName("txColorTransform"),
t._excludeVariableName("colorTransformSettings")
}
,
e.prototype.isReady = function(t, r, n) {
return !(n._areImageProcessingDirty && r.imageProcessingConfiguration && !r.imageProcessingConfiguration.isReady())
}
,
e.prototype.prepareDefines = function(t, r, n) {
n._areImageProcessingDirty && r.imageProcessingConfiguration && r.imageProcessingConfiguration.prepareDefines(n)
}
,
e.prototype.bind = function(t, r, n) {
!n || !r.imageProcessingConfiguration || r.imageProcessingConfiguration.bind(t)
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t),
t.sharedData.blocksWithDefines.push(this),
t.sharedData.blockingBlocks.push(this),
t.sharedData.bindableBlocks.push(this),
t.uniforms.push("exposureLinear"),
t.uniforms.push("contrast"),
t.uniforms.push("vInverseScreenSize"),
t.uniforms.push("vignetteSettings1"),
t.uniforms.push("vignetteSettings2"),
t.uniforms.push("vCameraColorCurveNegative"),
t.uniforms.push("vCameraColorCurveNeutral"),
t.uniforms.push("vCameraColorCurvePositive"),
t.uniforms.push("txColorTransform"),
t.uniforms.push("colorTransformSettings");
var r = this.color
, n = this._outputs[0]
, o = "//" + this.name;
return t._emitFunctionFromInclude("helperFunctions", o),
t._emitFunctionFromInclude("imageProcessingDeclaration", o),
t._emitFunctionFromInclude("imageProcessingFunctions", o),
r.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Color4 || r.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Vector4 ? t.compilationString += this._declareOutput(n, t) + " = " + r.associatedVariableName + `;\r
` : t.compilationString += this._declareOutput(n, t) + " = vec4(" + r.associatedVariableName + `, 1.0);\r
`,
t.compilationString += `#ifdef IMAGEPROCESSINGPOSTPROCESS\r
`,
this.convertInputToLinearSpace && (t.compilationString += n.associatedVariableName + ".rgb = toLinearSpace(" + r.associatedVariableName + `.rgb);\r
`),
t.compilationString += `#else\r
`,
t.compilationString += `#ifdef IMAGEPROCESSING\r
`,
this.convertInputToLinearSpace && (t.compilationString += n.associatedVariableName + ".rgb = toLinearSpace(" + r.associatedVariableName + `.rgb);\r
`),
t.compilationString += n.associatedVariableName + " = applyImageProcessing(" + n.associatedVariableName + `);\r
`,
t.compilationString += `#endif\r
`,
t.compilationString += `#endif\r
`,
this
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this);
return t += this._codeVariableName + ".convertInputToLinearSpace = " + this.convertInputToLinearSpace + `;\r
`,
t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.convertInputToLinearSpace = this.convertInputToLinearSpace,
t
}
,
e.prototype._deserialize = function(t, r, n) {
var o;
i.prototype._deserialize.call(this, t, r, n),
this.convertInputToLinearSpace = (o = t.convertInputToLinearSpace) !== null && o !== void 0 ? o : !0
}
,
__decorate([editableInPropertyPage("Convert input to linear space", PropertyTypeForEdition.Boolean, "ADVANCED")], e.prototype, "convertInputToLinearSpace", void 0),
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ImageProcessingBlock", ImageProcessingBlock);
var PerturbNormalBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r._tangentSpaceParameterName = "",
r.invertX = !1,
r.invertY = !1,
r.useParallaxOcclusion = !1,
r._isUnique = !0,
r.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1),
r.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1),
r.registerInput("worldTangent", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
r.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1),
r.registerInput("normalMapColor", NodeMaterialBlockConnectionPointTypes.Color3, !1),
r.registerInput("strength", NodeMaterialBlockConnectionPointTypes.Float, !1),
r.registerInput("viewDirection", NodeMaterialBlockConnectionPointTypes.Vector3, !0),
r.registerInput("parallaxScale", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("parallaxHeight", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerOutput("uvOffset", NodeMaterialBlockConnectionPointTypes.Vector2),
r
}
return e.prototype.getClassName = function() {
return "PerturbNormalBlock"
}
,
Object.defineProperty(e.prototype, "worldPosition", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "worldNormal", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "worldTangent", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "uv", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "normalMapColor", {
get: function() {
return this._inputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "strength", {
get: function() {
return this._inputs[5]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "viewDirection", {
get: function() {
return this._inputs[6]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "parallaxScale", {
get: function() {
return this._inputs[7]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "parallaxHeight", {
get: function() {
return this._inputs[8]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "uvOffset", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
e.prototype.prepareDefines = function(t, r, n) {
var o = this.normalMapColor.connectedPoint._ownerBlock.samplerName
, a = this.viewDirection.isConnected && (this.useParallaxOcclusion && o || !this.useParallaxOcclusion && this.parallaxHeight.isConnected);
n.setValue("BUMP", !0),
n.setValue("PARALLAX", a, !0),
n.setValue("PARALLAXOCCLUSION", this.useParallaxOcclusion, !0)
}
,
e.prototype.bind = function(t, r, n) {
r.getScene()._mirroredCameraPosition ? t.setFloat2(this._tangentSpaceParameterName, this.invertX ? 1 : -1, this.invertY ? 1 : -1) : t.setFloat2(this._tangentSpaceParameterName, this.invertX ? -1 : 1, this.invertY ? -1 : 1)
}
,
e.prototype.autoConfigure = function(t) {
if (!this.uv.isConnected) {
var r = t.getInputBlockByPredicate(function(o) {
return o.isAttribute && o.name === "uv"
});
r || (r = new InputBlock("uv"),
r.setAsAttribute()),
r.output.connectTo(this.uv)
}
if (!this.strength.isConnected) {
var n = new InputBlock("strength");
n.value = 1,
n.output.connectTo(this.strength)
}
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = "//" + this.name
, n = this.uv
, o = this.worldPosition
, a = this.worldNormal
, s = this.worldTangent;
t.sharedData.blocksWithDefines.push(this),
t.sharedData.bindableBlocks.push(this),
this._tangentSpaceParameterName = t._getFreeDefineName("tangentSpaceParameter"),
t._emitUniformFromString(this._tangentSpaceParameterName, "vec2");
var l = this.normalMapColor.connectedPoint._ownerBlock.samplerName
, u = this.viewDirection.isConnected && (this.useParallaxOcclusion && l || !this.useParallaxOcclusion && this.parallaxHeight.isConnected)
, c = this.parallaxScale.isConnectedToInputBlock ? this.parallaxScale.connectInputBlock.isConstant ? t._emitFloat(this.parallaxScale.connectInputBlock.value) : this.parallaxScale.associatedVariableName : "0.05"
, h = this.strength.isConnectedToInputBlock && this.strength.connectInputBlock.isConstant ? `\r
#if !defined(NORMALXYSCALE)\r
1.0/\r
#endif\r
` + t._emitFloat(this.strength.connectInputBlock.value) : `\r
#if !defined(NORMALXYSCALE)\r
1.0/\r
#endif\r
` + this.strength.associatedVariableName;
t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
var f = {
search: /defined\(TANGENT\)/g,
replace: s.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
};
s.isConnected && (t.compilationString += "vec3 tbnNormal = normalize(" + a.associatedVariableName + `.xyz);\r
`,
t.compilationString += "vec3 tbnTangent = normalize(" + s.associatedVariableName + `.xyz);\r
`,
t.compilationString += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
`,
t.compilationString += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
`),
t._emitFunctionFromInclude("bumpFragmentMainFunctions", r, {
replaceStrings: [f]
}),
t._emitFunctionFromInclude("bumpFragmentFunctions", r, {
replaceStrings: [{
search: /#include\(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump\)/g,
replace: ""
}, {
search: /uniform sampler2D bumpSampler;/g,
replace: ""
}, {
search: /vec2 parallaxOcclusion\(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale\)/g,
replace: `#define inline\r
vec2 parallaxOcclusion(vec3 vViewDirCoT, vec3 vNormalCoT, vec2 texCoord, float parallaxScale, sampler2D bumpSampler)`
}, {
search: /vec2 parallaxOffset\(vec3 viewDir,float heightScale\)/g,
replace: "vec2 parallaxOffset(vec3 viewDir, float heightScale, float height_)"
}, {
search: /texture2D\(bumpSampler,vBumpUV\)\.w/g,
replace: "height_"
}]
});
var d = !u || !l ? this.normalMapColor.associatedVariableName : "texture2D(" + l + ", " + n.associatedVariableName + " + uvOffset).xyz";
return t.compilationString += this._declareOutput(this.output, t) + ` = vec4(0.);\r
`,
t.compilationString += t._emitCodeFromInclude("bumpFragment", r, {
replaceStrings: [{
search: /perturbNormal\(TBN,texture2D\(bumpSampler,vBumpUV\+uvOffset\).xyz,vBumpInfos.y\)/g,
replace: "perturbNormal(TBN, " + d + ", vBumpInfos.y)"
}, {
search: /parallaxOcclusion\(invTBN\*-viewDirectionW,invTBN\*normalW,vBumpUV,vBumpInfos.z\)/g,
replace: "parallaxOcclusion((invTBN * -viewDirectionW), (invTBN * normalW), vBumpUV, vBumpInfos.z, " + (u && this.useParallaxOcclusion ? l : "bumpSampler") + ")"
}, {
search: /parallaxOffset\(invTBN\*viewDirectionW,vBumpInfos\.z\)/g,
replace: "parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z, " + (u ? this.parallaxHeight.associatedVariableName : "0.") + ")"
}, {
search: /vTangentSpaceParams/g,
replace: this._tangentSpaceParameterName
}, {
search: /vBumpInfos.y/g,
replace: h
}, {
search: /vBumpInfos.z/g,
replace: c
}, {
search: /vBumpUV/g,
replace: n.associatedVariableName
}, {
search: /vPositionW/g,
replace: o.associatedVariableName + ".xyz"
}, {
search: /normalW=/g,
replace: this.output.associatedVariableName + ".xyz = "
}, {
search: /mat3\(normalMatrix\)\*normalW/g,
replace: "mat3(normalMatrix) * " + this.output.associatedVariableName + ".xyz"
}, {
search: /normalW/g,
replace: a.associatedVariableName + ".xyz"
}, {
search: /viewDirectionW/g,
replace: u ? this.viewDirection.associatedVariableName : "vec3(0.)"
}, f]
}),
this
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".invertX = " + this.invertX + `;\r
`);
return t += this._codeVariableName + ".invertY = " + this.invertY + `;\r
`,
t += this._codeVariableName + ".useParallaxOcclusion = " + this.useParallaxOcclusion + `;\r
`,
t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.invertX = this.invertX,
t.invertY = this.invertY,
t.useParallaxOcclusion = this.useParallaxOcclusion,
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.invertX = t.invertX,
this.invertY = t.invertY,
this.useParallaxOcclusion = !!t.useParallaxOcclusion
}
,
__decorate([editableInPropertyPage("Invert X axis", PropertyTypeForEdition.Boolean, "PROPERTIES", {
notifiers: {
update: !1
}
})], e.prototype, "invertX", void 0),
__decorate([editableInPropertyPage("Invert Y axis", PropertyTypeForEdition.Boolean, "PROPERTIES", {
notifiers: {
update: !1
}
})], e.prototype, "invertY", void 0),
__decorate([editableInPropertyPage("Use parallax occlusion", PropertyTypeForEdition.Boolean)], e.prototype, "useParallaxOcclusion", void 0),
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.PerturbNormalBlock", PerturbNormalBlock);
var DiscardBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment, !0) || this;
return r.registerInput("value", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("cutoff", NodeMaterialBlockConnectionPointTypes.Float, !0),
r
}
return e.prototype.getClassName = function() {
return "DiscardBlock"
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cutoff", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
t.sharedData.hints.needAlphaTesting = !0,
!(!this.cutoff.isConnected || !this.value.isConnected))
return t.compilationString += "if (" + this.value.associatedVariableName + " < " + this.cutoff.associatedVariableName + `) discard;\r
`,
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.DiscardBlock", DiscardBlock);
var FrontFacingBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r
}
return e.prototype.getClassName = function() {
return "FrontFacingBlock"
}
,
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
t.target === NodeMaterialBlockTargets.Vertex)
throw "FrontFacingBlock must only be used in a fragment shader";
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + ` = gl_FrontFacing ? 1.0 : 0.0;\r
`,
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.FrontFacingBlock", FrontFacingBlock);
var DerivativeBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect, !1),
r.registerOutput("dx", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r.registerOutput("dy", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._outputs[1]._typeConnectionSource = r._inputs[0],
r
}
return e.prototype.getClassName = function() {
return "DerivativeBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "dx", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "dy", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0]
, n = this._outputs[1];
return t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"),
r.hasEndpoints && (t.compilationString += this._declareOutput(r, t) + (" = dFdx(" + this.input.associatedVariableName + `);\r
`)),
n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + (" = dFdy(" + this.input.associatedVariableName + `);\r
`)),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.DerivativeBlock", DerivativeBlock);
var FragCoordBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2, NodeMaterialBlockTargets.Fragment),
r.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3, NodeMaterialBlockTargets.Fragment),
r.registerOutput("xyzw", NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockTargets.Fragment),
r.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r.registerOutput("z", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r.registerOutput("w", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r
}
return e.prototype.getClassName = function() {
return "FragCoordBlock"
}
,
Object.defineProperty(e.prototype, "xy", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyz", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyzw", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "x", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "y", {
get: function() {
return this._outputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "z", {
get: function() {
return this._outputs[5]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[6]
},
enumerable: !1,
configurable: !0
}),
e.prototype.writeOutputs = function(t) {
for (var r = "", n = 0, o = this._outputs; n < o.length; n++) {
var a = o[n];
a.hasEndpoints && (r += this._declareOutput(a, t) + " = gl_FragCoord." + a.name + `;\r
`)
}
return r
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
t.target === NodeMaterialBlockTargets.Vertex)
throw "FragCoordBlock must only be used in a fragment shader";
return t.compilationString += this.writeOutputs(t),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.FragCoordBlock", FragCoordBlock);
var ScreenSizeBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2, NodeMaterialBlockTargets.Fragment),
r.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r
}
return e.prototype.getClassName = function() {
return "ScreenSizeBlock"
}
,
Object.defineProperty(e.prototype, "xy", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "x", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "y", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
e.prototype.bind = function(t, r, n) {
var o = this._scene.getEngine();
t.setFloat2(this._varName, o.getRenderWidth(), o.getRenderHeight())
}
,
e.prototype.writeOutputs = function(t, r) {
for (var n = "", o = 0, a = this._outputs; o < a.length; o++) {
var s = a[o];
s.hasEndpoints && (n += this._declareOutput(s, t) + " = " + r + "." + s.name + `;\r
`)
}
return n
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
this._scene = t.sharedData.scene,
t.target === NodeMaterialBlockTargets.Vertex)
throw "ScreenSizeBlock must only be used in a fragment shader";
return t.sharedData.bindableBlocks.push(this),
this._varName = t._getFreeVariableName("screenSize"),
t._emitUniformFromString(this._varName, "vec2"),
t.compilationString += this.writeOutputs(t, this._varName),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ScreenSizeBlock", ScreenSizeBlock);
var ScreenSpaceBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r.registerInput("vector", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("worldViewProjection", NodeMaterialBlockConnectionPointTypes.Matrix),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
r.inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r
}
return e.prototype.getClassName = function() {
return "ScreenSpaceBlock"
}
,
Object.defineProperty(e.prototype, "vector", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "worldViewProjection", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "x", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "y", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.worldViewProjection.isConnected) {
var r = t.getInputBlockByPredicate(function(n) {
return n.systemValue === NodeMaterialSystemValues.WorldViewProjection
});
r || (r = new InputBlock("worldViewProjection"),
r.setAsSystemValue(NodeMaterialSystemValues.WorldViewProjection)),
r.output.connectTo(this.worldViewProjection)
}
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this.vector
, n = this.worldViewProjection;
if (!!r.connectedPoint) {
var o = n.associatedVariableName
, a = t._getFreeVariableName("screenSpaceTemp");
switch (r.connectedPoint.type) {
case NodeMaterialBlockConnectionPointTypes.Vector3:
t.compilationString += "vec4 " + a + " = " + o + " * vec4(" + r.associatedVariableName + `, 1.0);\r
`;
break;
case NodeMaterialBlockConnectionPointTypes.Vector4:
t.compilationString += "vec4 " + a + " = " + o + " * " + r.associatedVariableName + `;\r
`;
break
}
return t.compilationString += a + ".xy /= " + a + ".w;",
t.compilationString += a + ".xy = " + a + ".xy * 0.5 + vec2(0.5, 0.5);",
this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + (" = " + a + `.xy;\r
`)),
this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + (" = " + a + `.x;\r
`)),
this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + (" = " + a + `.y;\r
`)),
this
}
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ScreenSpaceBlock", ScreenSpaceBlock);
var TwirlBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Fragment) || this;
return r.registerInput("input", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerInput("strength", NodeMaterialBlockConnectionPointTypes.Float),
r.registerInput("center", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerInput("offset", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "TwirlBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "strength", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "center", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "offset", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "x", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "y", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.center.isConnected) {
var r = new InputBlock("center");
r.value = new Vector2(.5,.5),
r.output.connectTo(this.center)
}
if (!this.strength.isConnected) {
var n = new InputBlock("strength");
n.value = 1,
n.output.connectTo(this.strength)
}
if (!this.offset.isConnected) {
var o = new InputBlock("offset");
o.value = new Vector2(0,0),
o.output.connectTo(this.offset)
}
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = t._getFreeVariableName("delta")
, n = t._getFreeVariableName("angle")
, o = t._getFreeVariableName("x")
, a = t._getFreeVariableName("y")
, s = t._getFreeVariableName("result");
return t.compilationString += `
vec2 ` + r + " = " + this.input.associatedVariableName + " - " + this.center.associatedVariableName + `;
float ` + n + " = " + this.strength.associatedVariableName + " * length(" + r + `);
float ` + o + " = cos(" + n + ") * " + r + ".x - sin(" + n + ") * " + r + `.y;
float ` + a + " = sin(" + n + ") * " + r + ".x + cos(" + n + ") * " + r + `.y;
vec2 ` + s + " = vec2(" + o + " + " + this.center.associatedVariableName + ".x + " + this.offset.associatedVariableName + ".x, " + a + " + " + this.center.associatedVariableName + ".y + " + this.offset.associatedVariableName + `.y);
`,
this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + (" = " + s + `;\r
`)),
this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + (" = " + s + `.x;\r
`)),
this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + (" = " + s + `.y;\r
`)),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.TwirlBlock", TwirlBlock);
var FogBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.VertexAndFragment, !1) || this;
return r.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
r.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Vertex),
r.registerInput("input", NodeMaterialBlockConnectionPointTypes.Color3, !1, NodeMaterialBlockTargets.Fragment),
r.registerInput("fogColor", NodeMaterialBlockConnectionPointTypes.Color3, !1, NodeMaterialBlockTargets.Fragment),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
r.input.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r.fogColor.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r
}
return e.prototype.getClassName = function() {
return "FogBlock"
}
,
Object.defineProperty(e.prototype, "worldPosition", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "view", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "fogColor", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.view.isConnected) {
var r = t.getInputBlockByPredicate(function(o) {
return o.systemValue === NodeMaterialSystemValues.View
});
r || (r = new InputBlock("view"),
r.setAsSystemValue(NodeMaterialSystemValues.View)),
r.output.connectTo(this.view)
}
if (!this.fogColor.isConnected) {
var n = t.getInputBlockByPredicate(function(o) {
return o.systemValue === NodeMaterialSystemValues.FogColor
});
n || (n = new InputBlock("fogColor",void 0,NodeMaterialBlockConnectionPointTypes.Color3),
n.setAsSystemValue(NodeMaterialSystemValues.FogColor)),
n.output.connectTo(this.fogColor)
}
}
,
e.prototype.prepareDefines = function(t, r, n) {
var o = t.getScene();
n.setValue("FOG", r.fogEnabled && MaterialHelper.GetFogState(t, o))
}
,
e.prototype.bind = function(t, r, n) {
if (!!n) {
var o = n.getScene();
t.setFloat4(this._fogParameters, o.fogMode, o.fogStart, o.fogEnd, o.fogDensity)
}
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
t.target === NodeMaterialBlockTargets.Fragment) {
t.sharedData.blocksWithDefines.push(this),
t.sharedData.bindableBlocks.push(this),
t._emitFunctionFromInclude("fogFragmentDeclaration", "//" + this.name, {
removeUniforms: !0,
removeVaryings: !0,
removeIfDef: !1,
replaceStrings: [{
search: /float CalcFogFactor\(\)/,
replace: "float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)"
}]
});
var r = t._getFreeVariableName("fog")
, n = this.input
, o = this.fogColor;
this._fogParameters = t._getFreeVariableName("fogParameters");
var a = this._outputs[0];
t._emitUniformFromString(this._fogParameters, "vec4"),
t.compilationString += `#ifdef FOG\r
`,
t.compilationString += "float " + r + " = CalcFogFactor(" + this._fogDistanceName + ", " + this._fogParameters + `);\r
`,
t.compilationString += this._declareOutput(a, t) + (" = " + r + " * " + n.associatedVariableName + ".rgb + (1.0 - " + r + ") * " + o.associatedVariableName + `.rgb;\r
`),
t.compilationString += `#else\r
` + this._declareOutput(a, t) + " = " + n.associatedVariableName + `.rgb;\r
`,
t.compilationString += `#endif\r
`
} else {
var s = this.worldPosition
, l = this.view;
this._fogDistanceName = t._getFreeVariableName("vFogDistance"),
t._emitVaryingFromString(this._fogDistanceName, "vec3"),
t.compilationString += this._fogDistanceName + " = (" + l.associatedVariableName + " * " + s.associatedVariableName + `).xyz;\r
`
}
return this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.FogBlock", FogBlock);
var LightBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.VertexAndFragment) || this;
return r._isUnique = !0,
r.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
r.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Fragment),
r.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Fragment),
r.registerInput("glossiness", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
r.registerInput("glossPower", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
r.registerInput("diffuseColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
r.registerInput("specularColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
r.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !0),
r.registerOutput("diffuseOutput", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
r.registerOutput("specularOutput", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
r.registerOutput("shadow", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r
}
return e.prototype.getClassName = function() {
return "LightBlock"
}
,
Object.defineProperty(e.prototype, "worldPosition", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "worldNormal", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraPosition", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "glossiness", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "glossPower", {
get: function() {
return this._inputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "diffuseColor", {
get: function() {
return this._inputs[5]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "specularColor", {
get: function() {
return this._inputs[6]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "view", {
get: function() {
return this._inputs[7]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "diffuseOutput", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "specularOutput", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "shadow", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.cameraPosition.isConnected) {
var r = t.getInputBlockByPredicate(function(n) {
return n.systemValue === NodeMaterialSystemValues.CameraPosition
});
r || (r = new InputBlock("cameraPosition"),
r.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
r.output.connectTo(this.cameraPosition)
}
}
,
e.prototype.prepareDefines = function(t, r, n) {
if (!!n._areLightsDirty) {
var o = t.getScene();
if (!this.light)
MaterialHelper.PrepareDefinesForLights(o, t, n, !0, r.maxSimultaneousLights);
else {
var a = {
needNormals: !1,
needRebuild: !1,
lightmapMode: !1,
shadowEnabled: !1,
specularEnabled: !1
};
MaterialHelper.PrepareDefinesForLight(o, t, this.light, this._lightId, n, !0, a),
a.needRebuild && n.rebuild()
}
}
}
,
e.prototype.updateUniformsAndSamples = function(t, r, n, o) {
for (var a = 0; a < r.maxSimultaneousLights && n["LIGHT" + a]; a++) {
var s = t.uniforms.indexOf("vLightData" + a) >= 0;
MaterialHelper.PrepareUniformsAndSamplersForLight(a, t.uniforms, t.samplers, n["PROJECTEDLIGHTTEXTURE" + a], o, s)
}
}
,
e.prototype.bind = function(t, r, n) {
if (!!n) {
var o = n.getScene();
this.light ? MaterialHelper.BindLight(this.light, this._lightId, o, t, !0) : MaterialHelper.BindLights(o, n, t, !0, r.maxSimultaneousLights)
}
}
,
e.prototype._injectVertexCode = function(t) {
var r = this.worldPosition
, n = "//" + this.name;
this.light ? (this._lightId = (t.counters.lightCounter !== void 0 ? t.counters.lightCounter : -1) + 1,
t.counters.lightCounter = this._lightId,
t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", n, {
replaceStrings: [{
search: /{X}/g,
replace: this._lightId.toString()
}]
}, this._lightId.toString())) : (t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", n, {
repeatKey: "maxSimultaneousLights"
}),
this._lightId = 0,
t.sharedData.dynamicUniformBlocks.push(this));
var o = "v_" + r.associatedVariableName;
t._emitVaryingFromString(o, "vec4") && (t.compilationString += o + " = " + r.associatedVariableName + `;\r
`),
this.light ? t.compilationString += t._emitCodeFromInclude("shadowsVertex", n, {
replaceStrings: [{
search: /{X}/g,
replace: this._lightId.toString()
}, {
search: /worldPos/g,
replace: r.associatedVariableName
}]
}) : (t.compilationString += "vec4 worldPos = " + r.associatedVariableName + `;\r
`,
this.view.isConnected && (t.compilationString += "mat4 view = " + this.view.associatedVariableName + `;\r
`),
t.compilationString += t._emitCodeFromInclude("shadowsVertex", n, {
repeatKey: "maxSimultaneousLights"
}))
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
t.target !== NodeMaterialBlockTargets.Fragment) {
this._injectVertexCode(t);
return
}
t.sharedData.forcedBindableBlocks.push(this),
t.sharedData.blocksWithDefines.push(this);
var r = "//" + this.name
, n = this.worldPosition;
t._emitFunctionFromInclude("helperFunctions", r),
t._emitFunctionFromInclude("lightsFragmentFunctions", r, {
replaceStrings: [{
search: /vPositionW/g,
replace: "v_" + n.associatedVariableName + ".xyz"
}]
}),
t._emitFunctionFromInclude("shadowsFragmentFunctions", r, {
replaceStrings: [{
search: /vPositionW/g,
replace: "v_" + n.associatedVariableName + ".xyz"
}]
}),
this.light ? t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", r, {
replaceStrings: [{
search: /{X}/g,
replace: this._lightId.toString()
}]
}, this._lightId.toString()) : t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", r, {
repeatKey: "maxSimultaneousLights"
}),
this._lightId === 0 && (t._registerTempVariable("viewDirectionW") && (t.compilationString += "vec3 viewDirectionW = normalize(" + this.cameraPosition.associatedVariableName + " - " + ("v_" + n.associatedVariableName) + `.xyz);\r
`),
t.compilationString += `lightingInfo info;\r
`,
t.compilationString += `float shadow = 1.;\r
`,
t.compilationString += "float glossiness = " + (this.glossiness.isConnected ? this.glossiness.associatedVariableName : "1.0") + " * " + (this.glossPower.isConnected ? this.glossPower.associatedVariableName : "1024.0") + `;\r
`,
t.compilationString += `vec3 diffuseBase = vec3(0., 0., 0.);\r
`,
t.compilationString += `vec3 specularBase = vec3(0., 0., 0.);\r
`,
t.compilationString += "vec3 normalW = " + this.worldNormal.associatedVariableName + `.xyz;\r
`),
this.light ? t.compilationString += t._emitCodeFromInclude("lightFragment", r, {
replaceStrings: [{
search: /{X}/g,
replace: this._lightId.toString()
}]
}) : t.compilationString += t._emitCodeFromInclude("lightFragment", r, {
repeatKey: "maxSimultaneousLights"
});
var o = this.diffuseOutput
, a = this.specularOutput;
return t.compilationString += this._declareOutput(o, t) + (" = diffuseBase" + (this.diffuseColor.isConnected ? " * " + this.diffuseColor.associatedVariableName : "") + `;\r
`),
a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + (" = specularBase" + (this.specularColor.isConnected ? " * " + this.specularColor.associatedVariableName : "") + `;\r
`)),
this.shadow.hasEndpoints && (t.compilationString += this._declareOutput(this.shadow, t) + ` = shadow;\r
`),
this
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return this.light && (t.lightId = this.light.id),
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
t.lightId && (this.light = r.getLightById(t.lightId))
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.LightBlock", LightBlock);
var NodeMaterialConnectionPointCustomObject = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s) {
var l = i.call(this, t, r, n) || this;
return l._blockType = o,
l._blockName = a,
l._nameForCheking = s,
l._nameForCheking || (l._nameForCheking = t),
l.needDualDirectionValidation = !0,
l
}
return e.prototype.checkCompatibilityState = function(t) {
return t instanceof e && t.name === this._nameForCheking ? NodeMaterialConnectionPointCompatibilityStates.Compatible : NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible
}
,
e.prototype.createCustomInputBlock = function() {
return [new this._blockType(this._blockName), this.name]
}
,
e
}(NodeMaterialConnectionPoint)
, ImageSourceBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.VertexAndFragment) || this;
return r.registerOutput("source", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("source",r,NodeMaterialConnectionPointDirection.Output,e,"ImageSourceBlock")),
r
}
return Object.defineProperty(e.prototype, "texture", {
get: function() {
return this._texture
},
set: function(t) {
var r = this, n;
if (this._texture !== t) {
var o = (n = t == null ? void 0 : t.getScene()) !== null && n !== void 0 ? n : Engine.LastCreatedScene;
!t && o && o.markAllMaterialsAsDirty(1, function(a) {
return a.hasTexture(r._texture)
}),
this._texture = t,
t && o && o.markAllMaterialsAsDirty(1, function(a) {
return a.hasTexture(t)
})
}
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "samplerName", {
get: function() {
return this._samplerName
},
enumerable: !1,
configurable: !0
}),
e.prototype.bind = function(t, r, n) {
!this.texture || t.setTexture(this._samplerName, this.texture)
}
,
e.prototype.isReady = function() {
return !(this.texture && !this.texture.isReadyOrNotBlocking())
}
,
e.prototype.getClassName = function() {
return "ImageSourceBlock"
}
,
Object.defineProperty(e.prototype, "source", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
return i.prototype._buildBlock.call(this, t),
t.target === NodeMaterialBlockTargets.Vertex && (this._samplerName = t._getFreeVariableName(this.name + "Sampler"),
t.sharedData.blockingBlocks.push(this),
t.sharedData.textureBlocks.push(this),
t.sharedData.bindableBlocks.push(this)),
t._emit2DSampler(this._samplerName),
this
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this);
return this.texture && (t += this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + '", null, ' + this.texture.noMipmap + ", " + this.texture.invertY + ", " + this.texture.samplingMode + `);\r
`,
t += this._codeVariableName + ".texture.wrapU = " + this.texture.wrapU + `;\r
`,
t += this._codeVariableName + ".texture.wrapV = " + this.texture.wrapV + `;\r
`,
t += this._codeVariableName + ".texture.uAng = " + this.texture.uAng + `;\r
`,
t += this._codeVariableName + ".texture.vAng = " + this.texture.vAng + `;\r
`,
t += this._codeVariableName + ".texture.wAng = " + this.texture.wAng + `;\r
`,
t += this._codeVariableName + ".texture.uOffset = " + this.texture.uOffset + `;\r
`,
t += this._codeVariableName + ".texture.vOffset = " + this.texture.vOffset + `;\r
`,
t += this._codeVariableName + ".texture.uScale = " + this.texture.uScale + `;\r
`,
t += this._codeVariableName + ".texture.vScale = " + this.texture.vScale + `;\r
`,
t += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
`),
t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return this.texture && !this.texture.isRenderTarget && this.texture.getClassName() !== "VideoTexture" && (t.texture = this.texture.serialize()),
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
t.texture && !NodeMaterial.IgnoreTexturesAtLoadTime && t.texture.url !== void 0 && (n = t.texture.url.indexOf("data:") === 0 ? "" : n,
this.texture = Texture.Parse(t.texture, r, n))
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ImageSourceBlock", ImageSourceBlock);
var TextureBlock = function(i) {
__extends(e, i);
function e(t, r) {
r === void 0 && (r = !1);
var n = i.call(this, t, r ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.VertexAndFragment) || this;
return n.convertToGammaSpace = !1,
n.convertToLinearSpace = !1,
n.disableLevelMultiplication = !1,
n._fragmentOnly = r,
n.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
n.registerInput("source", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("source",n,NodeMaterialConnectionPointDirection.Input,ImageSourceBlock,"ImageSourceBlock")),
n.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral),
n.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral),
n.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
n.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
n.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
n.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
n.registerOutput("level", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
n._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
n._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
n._inputs[0]._prioritizeVertex = !r,
n
}
return Object.defineProperty(e.prototype, "texture", {
get: function() {
var t;
return this.source.isConnected ? ((t = this.source.connectedPoint) === null || t === void 0 ? void 0 : t.ownerBlock).texture : this._texture
},
set: function(t) {
var r = this, n;
if (this._texture !== t) {
var o = (n = t == null ? void 0 : t.getScene()) !== null && n !== void 0 ? n : Engine.LastCreatedScene;
!t && o && o.markAllMaterialsAsDirty(1, function(a) {
return a.hasTexture(r._texture)
}),
this._texture = t,
t && o && o.markAllMaterialsAsDirty(1, function(a) {
return a.hasTexture(t)
})
}
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "samplerName", {
get: function() {
return this._imageSource ? this._imageSource.samplerName : this._samplerName
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "hasImageSource", {
get: function() {
return !!this._imageSource
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "TextureBlock"
}
,
Object.defineProperty(e.prototype, "uv", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "source", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgba", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgb", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "r", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "g", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "b", {
get: function() {
return this._outputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "a", {
get: function() {
return this._outputs[5]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "level", {
get: function() {
return this._outputs[6]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "target", {
get: function() {
if (this._fragmentOnly)
return NodeMaterialBlockTargets.Fragment;
if (!this.uv.isConnected || this.uv.sourceBlock.isInput)
return NodeMaterialBlockTargets.VertexAndFragment;
for (var t = this.uv.connectedPoint; t; ) {
if (t.target === NodeMaterialBlockTargets.Fragment)
return NodeMaterialBlockTargets.Fragment;
if (t.target === NodeMaterialBlockTargets.Vertex)
return NodeMaterialBlockTargets.VertexAndFragment;
if (t.target === NodeMaterialBlockTargets.Neutral || t.target === NodeMaterialBlockTargets.VertexAndFragment) {
var r = t.ownerBlock;
if (r.target === NodeMaterialBlockTargets.Fragment)
return NodeMaterialBlockTargets.Fragment;
t = null;
for (var n = 0, o = r.inputs; n < o.length; n++) {
var a = o[n];
if (a.connectedPoint) {
t = a.connectedPoint;
break
}
}
}
}
return NodeMaterialBlockTargets.VertexAndFragment
},
set: function(t) {},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.uv.isConnected)
if (t.mode === NodeMaterialModes.PostProcess) {
var r = t.getBlockByPredicate(function(o) {
return o.name === "uv"
});
r && r.connectTo(this)
} else {
var n = t.mode === NodeMaterialModes.Particle ? "particle_uv" : "uv"
, r = t.getInputBlockByPredicate(function(a) {
return a.isAttribute && a.name === n
});
r || (r = new InputBlock("uv"),
r.setAsAttribute(n)),
r.output.connectTo(this.uv)
}
}
,
e.prototype.initializeDefines = function(t, r, n, o) {
!n._areTexturesDirty || this._mainUVDefineName !== void 0 && n.setValue(this._mainUVDefineName, !1, !0)
}
,
e.prototype.prepareDefines = function(t, r, n) {
if (!!n._areTexturesDirty) {
if (!this.texture || !this.texture.getTextureMatrix) {
this._isMixed && (n.setValue(this._defineName, !1, !0),
n.setValue(this._mainUVDefineName, !0, !0));
return
}
n.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
n.setValue(this._gammaDefineName, this.convertToLinearSpace, !0),
this._isMixed && (this.texture.getTextureMatrix().isIdentityAs3x2() ? (n.setValue(this._defineName, !1, !0),
n.setValue(this._mainUVDefineName, !0, !0)) : (n.setValue(this._defineName, !0),
n[this._mainUVDefineName] == null && n.setValue(this._mainUVDefineName, !1, !0)))
}
}
,
e.prototype.isReady = function() {
return !(this.texture && !this.texture.isReadyOrNotBlocking())
}
,
e.prototype.bind = function(t, r, n) {
!this.texture || (this._isMixed && (t.setFloat(this._textureInfoName, this.texture.level),
t.setMatrix(this._textureTransformName, this.texture.getTextureMatrix())),
this._imageSource || t.setTexture(this._samplerName, this.texture))
}
,
Object.defineProperty(e.prototype, "_isMixed", {
get: function() {
return this.target !== NodeMaterialBlockTargets.Fragment
},
enumerable: !1,
configurable: !0
}),
e.prototype._injectVertexCode = function(t) {
var r = this.uv;
if (this._defineName = t._getFreeDefineName("UVTRANSFORM"),
this._mainUVDefineName = "VMAIN" + r.associatedVariableName.toUpperCase(),
this._mainUVName = "vMain" + r.associatedVariableName,
this._transformedUVName = t._getFreeVariableName("transformedUV"),
this._textureTransformName = t._getFreeVariableName("textureTransform"),
this._textureInfoName = t._getFreeVariableName("textureInfoName"),
this.level.associatedVariableName = this._textureInfoName,
t._emitVaryingFromString(this._transformedUVName, "vec2", this._defineName),
t._emitVaryingFromString(this._mainUVName, "vec2", this._mainUVDefineName),
t._emitUniformFromString(this._textureTransformName, "mat4", this._defineName),
t.compilationString += "#ifdef " + this._defineName + `\r
`,
t.compilationString += this._transformedUVName + " = vec2(" + this._textureTransformName + " * vec4(" + r.associatedVariableName + `.xy, 1.0, 0.0));\r
`,
t.compilationString += "#elif defined(" + this._mainUVDefineName + `)\r
`,
t.compilationString += this._mainUVName + " = " + r.associatedVariableName + `.xy;\r
`,
t.compilationString += `#endif\r
`,
!!this._outputs.some(function(s) {
return s.isConnectedInVertexShader
})) {
this._writeTextureRead(t, !0);
for (var n = 0, o = this._outputs; n < o.length; n++) {
var a = o[n];
a.hasEndpoints && a.name !== "level" && this._writeOutput(t, a, a.name, !0)
}
}
}
,
e.prototype._generateTextureLookup = function(t) {
var r = this.samplerName;
t.compilationString += "#ifdef " + this._defineName + `\r
`,
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + r + ", " + this._transformedUVName + `);\r
`,
t.compilationString += "#elif defined(" + this._mainUVDefineName + `)\r
`,
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + r + ", " + (this._mainUVName ? this._mainUVName : this.uv.associatedVariableName) + `);\r
`,
t.compilationString += `#endif\r
`
}
,
e.prototype._writeTextureRead = function(t, r) {
r === void 0 && (r = !1);
var n = this.uv;
if (r) {
if (t.target === NodeMaterialBlockTargets.Fragment)
return;
this._generateTextureLookup(t);
return
}
if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this.samplerName + ", " + n.associatedVariableName + `);\r
`;
return
}
this._generateTextureLookup(t)
}
,
e.prototype._generateConversionCode = function(t, r, n) {
n !== "a" && ((!this.texture || !this.texture.gammaSpace) && (t.compilationString += "#ifdef " + this._linearDefineName + `
` + r.associatedVariableName + " = toGammaSpace(" + r.associatedVariableName + `);
#endif
`),
(!this.texture || this.texture.gammaSpace) && (t.compilationString += "#ifdef " + this._gammaDefineName + `
` + r.associatedVariableName + " = toLinearSpace(" + r.associatedVariableName + `);
#endif
`))
}
,
e.prototype._writeOutput = function(t, r, n, o) {
if (o === void 0 && (o = !1),
o) {
if (t.target === NodeMaterialBlockTargets.Fragment)
return;
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + `;\r
`,
this._generateConversionCode(t, r, n);
return
}
if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + `;\r
`,
this._generateConversionCode(t, r, n);
return
}
var a = "";
this.disableLevelMultiplication || (a = " * " + this._textureInfoName),
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + a + `;\r
`,
this._generateConversionCode(t, r, n)
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
this.source.isConnected ? this._imageSource = this.source.connectedPoint.ownerBlock : this._imageSource = null,
(t.target === NodeMaterialBlockTargets.Vertex || this._fragmentOnly || t.target === NodeMaterialBlockTargets.Fragment && this._tempTextureRead === void 0) && (this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
this._gammaDefineName = t._getFreeDefineName("ISGAMMA")),
(!this._isMixed && t.target === NodeMaterialBlockTargets.Fragment || this._isMixed && t.target === NodeMaterialBlockTargets.Vertex) && (this._imageSource || (this._samplerName = t._getFreeVariableName(this.name + "Sampler"),
t._emit2DSampler(this._samplerName)),
t.sharedData.blockingBlocks.push(this),
t.sharedData.textureBlocks.push(this),
t.sharedData.blocksWithDefines.push(this),
t.sharedData.bindableBlocks.push(this)),
t.target !== NodeMaterialBlockTargets.Fragment) {
this._injectVertexCode(t);
return
}
if (!!this._outputs.some(function(s) {
return s.isConnectedInFragmentShader
})) {
this._isMixed && !this._imageSource && t._emit2DSampler(this._samplerName);
var r = "//" + this.name;
t._emitFunctionFromInclude("helperFunctions", r),
this._isMixed && t._emitUniformFromString(this._textureInfoName, "float"),
this._writeTextureRead(t);
for (var n = 0, o = this._outputs; n < o.length; n++) {
var a = o[n];
a.hasEndpoints && a.name !== "level" && this._writeOutput(t, a, a.name)
}
return this
}
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this);
return t += this._codeVariableName + ".convertToGammaSpace = " + this.convertToGammaSpace + `;\r
`,
t += this._codeVariableName + ".convertToLinearSpace = " + this.convertToLinearSpace + `;\r
`,
t += this._codeVariableName + ".disableLevelMultiplication = " + this.disableLevelMultiplication + `;\r
`,
this.texture && (t += this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + '", null, ' + this.texture.noMipmap + ", " + this.texture.invertY + ", " + this.texture.samplingMode + `);\r
`,
t += this._codeVariableName + ".texture.wrapU = " + this.texture.wrapU + `;\r
`,
t += this._codeVariableName + ".texture.wrapV = " + this.texture.wrapV + `;\r
`,
t += this._codeVariableName + ".texture.uAng = " + this.texture.uAng + `;\r
`,
t += this._codeVariableName + ".texture.vAng = " + this.texture.vAng + `;\r
`,
t += this._codeVariableName + ".texture.wAng = " + this.texture.wAng + `;\r
`,
t += this._codeVariableName + ".texture.uOffset = " + this.texture.uOffset + `;\r
`,
t += this._codeVariableName + ".texture.vOffset = " + this.texture.vOffset + `;\r
`,
t += this._codeVariableName + ".texture.uScale = " + this.texture.uScale + `;\r
`,
t += this._codeVariableName + ".texture.vScale = " + this.texture.vScale + `;\r
`,
t += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
`),
t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.convertToGammaSpace = this.convertToGammaSpace,
t.convertToLinearSpace = this.convertToLinearSpace,
t.fragmentOnly = this._fragmentOnly,
t.disableLevelMultiplication = this.disableLevelMultiplication,
!this.hasImageSource && this.texture && !this.texture.isRenderTarget && this.texture.getClassName() !== "VideoTexture" && (t.texture = this.texture.serialize()),
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.convertToGammaSpace = t.convertToGammaSpace,
this.convertToLinearSpace = !!t.convertToLinearSpace,
this._fragmentOnly = !!t.fragmentOnly,
this.disableLevelMultiplication = !!t.disableLevelMultiplication,
t.texture && !NodeMaterial.IgnoreTexturesAtLoadTime && t.texture.url !== void 0 && (n = t.texture.url.indexOf("data:") === 0 ? "" : n,
this.texture = Texture.Parse(t.texture, r, n))
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.TextureBlock", TextureBlock);
var ReflectionTextureBaseBlock = function(i) {
__extends(e, i);
function e(t) {
return i.call(this, t, NodeMaterialBlockTargets.VertexAndFragment) || this
}
return Object.defineProperty(e.prototype, "texture", {
get: function() {
return this._texture
},
set: function(t) {
var r = this, n;
if (this._texture !== t) {
var o = (n = t == null ? void 0 : t.getScene()) !== null && n !== void 0 ? n : Engine.LastCreatedScene;
!t && o && o.markAllMaterialsAsDirty(1, function(a) {
return a.hasTexture(r._texture)
}),
this._texture = t,
t && o && o.markAllMaterialsAsDirty(1, function(a) {
return a.hasTexture(t)
})
}
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "ReflectionTextureBaseBlock"
}
,
e.prototype._getTexture = function() {
return this.texture
}
,
e.prototype.autoConfigure = function(t) {
if (!this.position.isConnected) {
var r = t.getInputBlockByPredicate(function(a) {
return a.isAttribute && a.name === "position"
});
r || (r = new InputBlock("position"),
r.setAsAttribute()),
r.output.connectTo(this.position)
}
if (!this.world.isConnected) {
var n = t.getInputBlockByPredicate(function(a) {
return a.systemValue === NodeMaterialSystemValues.World
});
n || (n = new InputBlock("world"),
n.setAsSystemValue(NodeMaterialSystemValues.World)),
n.output.connectTo(this.world)
}
if (this.view && !this.view.isConnected) {
var o = t.getInputBlockByPredicate(function(a) {
return a.systemValue === NodeMaterialSystemValues.View
});
o || (o = new InputBlock("view"),
o.setAsSystemValue(NodeMaterialSystemValues.View)),
o.output.connectTo(this.view)
}
}
,
e.prototype.prepareDefines = function(t, r, n) {
if (!!n._areTexturesDirty) {
var o = this._getTexture();
!o || !o.getTextureMatrix || (n.setValue(this._define3DName, o.isCube, !0),
n.setValue(this._defineLocalCubicName, !!o.boundingBoxSize, !0),
n.setValue(this._defineExplicitName, o.coordinatesMode === 0, !0),
n.setValue(this._defineSkyboxName, o.coordinatesMode === 5, !0),
n.setValue(this._defineCubicName, o.coordinatesMode === 3 || o.coordinatesMode === 6, !0),
n.setValue("INVERTCUBICMAP", o.coordinatesMode === 6, !0),
n.setValue(this._defineSphericalName, o.coordinatesMode === 1, !0),
n.setValue(this._definePlanarName, o.coordinatesMode === 2, !0),
n.setValue(this._defineProjectionName, o.coordinatesMode === 4, !0),
n.setValue(this._defineEquirectangularName, o.coordinatesMode === 7, !0),
n.setValue(this._defineEquirectangularFixedName, o.coordinatesMode === 8, !0),
n.setValue(this._defineMirroredEquirectangularFixedName, o.coordinatesMode === 9, !0))
}
}
,
e.prototype.isReady = function() {
var t = this._getTexture();
return !(t && !t.isReadyOrNotBlocking())
}
,
e.prototype.bind = function(t, r, n) {
var o = this._getTexture();
if (!(!n || !o) && (t.setMatrix(this._reflectionMatrixName, o.getReflectionTextureMatrix()),
o.isCube ? t.setTexture(this._cubeSamplerName, o) : t.setTexture(this._2DSamplerName, o),
o.boundingBoxSize)) {
var a = o;
t.setVector3(this._reflectionPositionName, a.boundingBoxPosition),
t.setVector3(this._reflectionSizeName, a.boundingBoxSize)
}
}
,
e.prototype.handleVertexSide = function(t) {
this._define3DName = t._getFreeDefineName("REFLECTIONMAP_3D"),
this._defineCubicName = t._getFreeDefineName("REFLECTIONMAP_CUBIC"),
this._defineSphericalName = t._getFreeDefineName("REFLECTIONMAP_SPHERICAL"),
this._definePlanarName = t._getFreeDefineName("REFLECTIONMAP_PLANAR"),
this._defineProjectionName = t._getFreeDefineName("REFLECTIONMAP_PROJECTION"),
this._defineExplicitName = t._getFreeDefineName("REFLECTIONMAP_EXPLICIT"),
this._defineEquirectangularName = t._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"),
this._defineLocalCubicName = t._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"),
this._defineMirroredEquirectangularFixedName = t._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"),
this._defineEquirectangularFixedName = t._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"),
this._defineSkyboxName = t._getFreeDefineName("REFLECTIONMAP_SKYBOX"),
this._defineOppositeZ = t._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"),
this._reflectionMatrixName = t._getFreeVariableName("reflectionMatrix"),
t._emitUniformFromString(this._reflectionMatrixName, "mat4");
var r = ""
, n = "v_" + this.worldPosition.associatedVariableName;
return t._emitVaryingFromString(n, "vec4") && (r += n + " = " + this.worldPosition.associatedVariableName + `;\r
`),
this._positionUVWName = t._getFreeVariableName("positionUVW"),
this._directionWName = t._getFreeVariableName("directionW"),
t._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName) && (r += "#ifdef " + this._defineSkyboxName + `\r
`,
r += this._positionUVWName + " = " + this.position.associatedVariableName + `.xyz;\r
`,
r += `#endif\r
`),
t._emitVaryingFromString(this._directionWName, "vec3", "defined(" + this._defineEquirectangularFixedName + ") || defined(" + this._defineMirroredEquirectangularFixedName + ")") && (r += "#if defined(" + this._defineEquirectangularFixedName + ") || defined(" + this._defineMirroredEquirectangularFixedName + `)\r
`,
r += this._directionWName + " = normalize(vec3(" + this.world.associatedVariableName + " * vec4(" + this.position.associatedVariableName + `.xyz, 0.0)));\r
`,
r += `#endif\r
`),
r
}
,
e.prototype.handleFragmentSideInits = function(t) {
t.sharedData.blockingBlocks.push(this),
t.sharedData.textureBlocks.push(this),
this._cubeSamplerName = t._getFreeVariableName(this.name + "CubeSampler"),
t.samplers.push(this._cubeSamplerName),
this._2DSamplerName = t._getFreeVariableName(this.name + "2DSampler"),
t.samplers.push(this._2DSamplerName),
t._samplerDeclaration += "#ifdef " + this._define3DName + `\r
`,
t._samplerDeclaration += "uniform samplerCube " + this._cubeSamplerName + `;\r
`,
t._samplerDeclaration += `#else\r
`,
t._samplerDeclaration += "uniform sampler2D " + this._2DSamplerName + `;\r
`,
t._samplerDeclaration += `#endif\r
`,
t.sharedData.blocksWithDefines.push(this),
t.sharedData.bindableBlocks.push(this);
var r = "//" + this.name;
t._emitFunction("ReciprocalPI", "#define RECIPROCAL_PI2 0.15915494", ""),
t._emitFunctionFromInclude("helperFunctions", r),
t._emitFunctionFromInclude("reflectionFunction", r, {
replaceStrings: [{
search: /vec3 computeReflectionCoords/g,
replace: "void DUMMYFUNC"
}]
}),
this._reflectionColorName = t._getFreeVariableName("reflectionColor"),
this._reflectionVectorName = t._getFreeVariableName("reflectionUVW"),
this._reflectionCoordsName = t._getFreeVariableName("reflectionCoords"),
this._reflectionPositionName = t._getFreeVariableName("vReflectionPosition"),
t._emitUniformFromString(this._reflectionPositionName, "vec3"),
this._reflectionSizeName = t._getFreeVariableName("vReflectionPosition"),
t._emitUniformFromString(this._reflectionSizeName, "vec3")
}
,
e.prototype.handleFragmentSideCodeReflectionCoords = function(t, r, n) {
n === void 0 && (n = !1),
r || (r = "v_" + this.worldPosition.associatedVariableName);
var o = this._reflectionMatrixName
, a = "normalize(" + this._directionWName + ")"
, s = "" + this._positionUVWName
, l = "" + this.cameraPosition.associatedVariableName
, u = "" + this.view.associatedVariableName;
t += ".xyz";
var c = `
#ifdef ` + this._defineMirroredEquirectangularFixedName + `
vec3 ` + this._reflectionVectorName + " = computeMirroredFixedEquirectangularCoords(" + r + ", " + t + ", " + a + `);
#endif
#ifdef ` + this._defineEquirectangularFixedName + `
vec3 ` + this._reflectionVectorName + " = computeFixedEquirectangularCoords(" + r + ", " + t + ", " + a + `);
#endif
#ifdef ` + this._defineEquirectangularName + `
vec3 ` + this._reflectionVectorName + " = computeEquirectangularCoords(" + r + ", " + t + ", " + l + ".xyz, " + o + `);
#endif
#ifdef ` + this._defineSphericalName + `
vec3 ` + this._reflectionVectorName + " = computeSphericalCoords(" + r + ", " + t + ", " + u + ", " + o + `);
#endif
#ifdef ` + this._definePlanarName + `
vec3 ` + this._reflectionVectorName + " = computePlanarCoords(" + r + ", " + t + ", " + l + ".xyz, " + o + `);
#endif
#ifdef ` + this._defineCubicName + `
#ifdef ` + this._defineLocalCubicName + `
vec3 ` + this._reflectionVectorName + " = computeCubicLocalCoords(" + r + ", " + t + ", " + l + ".xyz, " + o + ", " + this._reflectionSizeName + ", " + this._reflectionPositionName + `);
#else
vec3 ` + this._reflectionVectorName + " = computeCubicCoords(" + r + ", " + t + ", " + l + ".xyz, " + o + `);
#endif
#endif
#ifdef ` + this._defineProjectionName + `
vec3 ` + this._reflectionVectorName + " = computeProjectionCoords(" + r + ", " + u + ", " + o + `);
#endif
#ifdef ` + this._defineSkyboxName + `
vec3 ` + this._reflectionVectorName + " = computeSkyBoxCoords(" + s + ", " + o + `);
#endif
#ifdef ` + this._defineExplicitName + `
vec3 ` + this._reflectionVectorName + ` = vec3(0, 0, 0);
#endif
#ifdef ` + this._defineOppositeZ + `
` + this._reflectionVectorName + `.z *= -1.0;
#endif\r
`;
return n || (c += `
#ifdef ` + this._define3DName + `
vec3 ` + this._reflectionCoordsName + " = " + this._reflectionVectorName + `;
#else
vec2 ` + this._reflectionCoordsName + " = " + this._reflectionVectorName + `.xy;
#ifdef ` + this._defineProjectionName + `
` + this._reflectionCoordsName + " /= " + this._reflectionVectorName + `.z;
#endif
` + this._reflectionCoordsName + ".y = 1.0 - " + this._reflectionCoordsName + `.y;
#endif\r
`),
c
}
,
e.prototype.handleFragmentSideCodeReflectionColor = function(t, r) {
r === void 0 && (r = ".rgb");
var n = "vec" + (r.length === 0 ? "4" : r.length - 1)
, o = n + " " + this._reflectionColorName + `;
#ifdef ` + this._define3DName + `\r
`;
return t ? o += this._reflectionColorName + " = textureCubeLodEXT(" + this._cubeSamplerName + ", " + this._reflectionVectorName + ", " + t + ")" + r + `;\r
` : o += this._reflectionColorName + " = textureCube(" + this._cubeSamplerName + ", " + this._reflectionVectorName + ")" + r + `;\r
`,
o += `
#else\r
`,
t ? o += this._reflectionColorName + " = texture2DLodEXT(" + this._2DSamplerName + ", " + this._reflectionCoordsName + ", " + t + ")" + r + `;\r
` : o += this._reflectionColorName + " = texture2D(" + this._2DSamplerName + ", " + this._reflectionCoordsName + ")" + r + `;\r
`,
o += `#endif\r
`,
o
}
,
e.prototype.writeOutputs = function(t, r) {
var n = "";
if (t.target === NodeMaterialBlockTargets.Fragment)
for (var o = 0, a = this._outputs; o < a.length; o++) {
var s = a[o];
s.hasEndpoints && (n += this._declareOutput(s, t) + " = " + r + "." + s.name + `;\r
`)
}
return n
}
,
e.prototype._buildBlock = function(t) {
return i.prototype._buildBlock.call(this, t),
this
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this);
if (!this.texture)
return t;
if (this.texture.isCube) {
var r = this.texture.forcedExtension;
t += this._codeVariableName + '.texture = new BABYLON.CubeTexture("' + this.texture.name + '", undefined, undefined, ' + this.texture.noMipmap + ", null, undefined, undefined, undefined, " + this.texture._prefiltered + ", " + (r ? '"' + r + '"' : "null") + `);\r
`
} else
t += this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + `", null);\r
`;
return t += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
`,
t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
t.texture && (n = t.texture.url.indexOf("data:") === 0 ? "" : n,
t.texture.isCube ? this.texture = CubeTexture.Parse(t.texture, r, n) : this.texture = Texture.Parse(t.texture, r, n))
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ReflectionTextureBaseBlock", ReflectionTextureBaseBlock);
var ReflectionTextureBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t) || this;
return r.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Vertex),
r.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
r.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Fragment),
r.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Vertex),
r.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Fragment),
r.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Fragment),
r.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
r.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment),
r.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r
}
return e.prototype.getClassName = function() {
return "ReflectionTextureBlock"
}
,
Object.defineProperty(e.prototype, "position", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "worldPosition", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "worldNormal", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "world", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraPosition", {
get: function() {
return this._inputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "view", {
get: function() {
return this._inputs[5]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgb", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgba", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "r", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "g", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "b", {
get: function() {
return this._outputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "a", {
get: function() {
return this._outputs[5]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (i.prototype.autoConfigure.call(this, t),
!this.cameraPosition.isConnected) {
var r = t.getInputBlockByPredicate(function(n) {
return n.systemValue === NodeMaterialSystemValues.CameraPosition
});
r || (r = new InputBlock("cameraPosition"),
r.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
r.output.connectTo(this.cameraPosition)
}
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
!this.texture)
return t.compilationString += this.writeOutputs(t, "vec3(0.)"),
this;
if (t.target !== NodeMaterialBlockTargets.Fragment)
return t.compilationString += this.handleVertexSide(t),
this;
this.handleFragmentSideInits(t);
var r = t._getFreeVariableName("normalWUnit");
return t.compilationString += "vec4 " + r + " = normalize(" + this.worldNormal.associatedVariableName + `);\r
`,
t.compilationString += this.handleFragmentSideCodeReflectionCoords(r),
t.compilationString += this.handleFragmentSideCodeReflectionColor(void 0, ""),
t.compilationString += this.writeOutputs(t, this._reflectionColorName),
this
}
,
e
}(ReflectionTextureBaseBlock);
RegisterClass("BABYLON.ReflectionTextureBlock", ReflectionTextureBlock);
var SceneDepthBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.VertexAndFragment) || this;
return r._samplerName = "textureSampler",
r.useNonLinearDepth = !1,
r.force32itsFloat = !1,
r._isUnique = !0,
r.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
r.registerOutput("depth", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r._inputs[0]._prioritizeVertex = !1,
r
}
return e.prototype.getClassName = function() {
return "SceneDepthBlock"
}
,
Object.defineProperty(e.prototype, "uv", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "depth", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.initialize = function(t) {
t._excludeVariableName("textureSampler")
}
,
Object.defineProperty(e.prototype, "target", {
get: function() {
return !this.uv.isConnected || this.uv.sourceBlock.isInput ? NodeMaterialBlockTargets.VertexAndFragment : NodeMaterialBlockTargets.Fragment
},
enumerable: !1,
configurable: !0
}),
e.prototype._getTexture = function(t) {
var r = t.enableDepthRenderer(void 0, this.useNonLinearDepth, this.force32itsFloat);
return r.getDepthMap()
}
,
e.prototype.bind = function(t, r, n) {
var o = this._getTexture(r.getScene());
t.setTexture(this._samplerName, o)
}
,
e.prototype._injectVertexCode = function(t) {
var r = this.uv;
if (r.connectedPoint.ownerBlock.isInput) {
var n = r.connectedPoint.ownerBlock;
n.isAttribute || t._emitUniformFromString(r.associatedVariableName, "vec" + (r.type === NodeMaterialBlockConnectionPointTypes.Vector3 ? "3" : r.type === NodeMaterialBlockConnectionPointTypes.Vector4 ? "4" : "2"))
}
if (this._mainUVName = "vMain" + r.associatedVariableName,
t._emitVaryingFromString(this._mainUVName, "vec2"),
t.compilationString += this._mainUVName + " = " + r.associatedVariableName + `.xy;\r
`,
!!this._outputs.some(function(l) {
return l.isConnectedInVertexShader
})) {
this._writeTextureRead(t, !0);
for (var o = 0, a = this._outputs; o < a.length; o++) {
var s = a[o];
s.hasEndpoints && this._writeOutput(t, s, "r", !0)
}
}
}
,
e.prototype._writeTextureRead = function(t, r) {
r === void 0 && (r = !1);
var n = this.uv;
if (r) {
if (t.target === NodeMaterialBlockTargets.Fragment)
return;
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + n.associatedVariableName + `.xy);\r
`;
return
}
if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + n.associatedVariableName + `.xy);\r
`;
return
}
t.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this._mainUVName + `);\r
`
}
,
e.prototype._writeOutput = function(t, r, n, o) {
if (o === void 0 && (o = !1),
o) {
if (t.target === NodeMaterialBlockTargets.Fragment)
return;
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + `;\r
`;
return
}
if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + `;\r
`;
return
}
t.compilationString += this._declareOutput(r, t) + " = " + this._tempTextureRead + "." + n + `;\r
`
}
,
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
t.sharedData.bindableBlocks.indexOf(this) < 0 && t.sharedData.bindableBlocks.push(this),
t.target !== NodeMaterialBlockTargets.Fragment) {
t._emit2DSampler(this._samplerName),
this._injectVertexCode(t);
return
}
if (!!this._outputs.some(function(a) {
return a.isConnectedInFragmentShader
})) {
t._emit2DSampler(this._samplerName),
this._writeTextureRead(t);
for (var r = 0, n = this._outputs; r < n.length; r++) {
var o = n[r];
o.hasEndpoints && this._writeOutput(t, o, "r")
}
return this
}
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.useNonLinearDepth = this.useNonLinearDepth,
t.force32itsFloat = this.force32itsFloat,
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.useNonLinearDepth = t.useNonLinearDepth,
this.force32itsFloat = t.force32itsFloat
}
,
__decorate([editableInPropertyPage("Use non linear depth", PropertyTypeForEdition.Boolean, "ADVANCED", {
notifiers: {
activatePreviewCommand: !0,
callback: function(t) {
return t.disableDepthRenderer()
}
}
})], e.prototype, "useNonLinearDepth", void 0),
__decorate([editableInPropertyPage("Force 32 bits float", PropertyTypeForEdition.Boolean, "ADVANCED", {
notifiers: {
activatePreviewCommand: !0,
callback: function(t) {
return t.disableDepthRenderer()
}
}
})], e.prototype, "force32itsFloat", void 0),
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.SceneDepthBlock", SceneDepthBlock);
var AddBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r
}
return e.prototype.getClassName = function() {
return "AddBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = " + this.left.associatedVariableName + " + " + this.right.associatedVariableName + `;\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.AddBlock", AddBlock);
var ScaleBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("factor", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r
}
return e.prototype.getClassName = function() {
return "ScaleBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "factor", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = " + this.input.associatedVariableName + " * " + this.factor.associatedVariableName + `;\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ScaleBlock", ScaleBlock);
var ClampBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.minimum = 0,
r.maximum = 1,
r.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r
}
return e.prototype.getClassName = function() {
return "ClampBlock"
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = clamp(" + this.value.associatedVariableName + ", " + this._writeFloat(this.minimum) + ", " + this._writeFloat(this.maximum) + `);\r
`),
this
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".minimum = " + this.minimum + `;\r
`);
return t += this._codeVariableName + ".maximum = " + this.maximum + `;\r
`,
t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.minimum = this.minimum,
t.maximum = this.maximum,
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.minimum = t.minimum,
this.maximum = t.maximum
}
,
__decorate([editableInPropertyPage("Minimum", PropertyTypeForEdition.Float)], e.prototype, "minimum", void 0),
__decorate([editableInPropertyPage("Maximum", PropertyTypeForEdition.Float)], e.prototype, "maximum", void 0),
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ClampBlock", ClampBlock);
var CrossBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
r._linkConnectionTypes(0, 1),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
r
}
return e.prototype.getClassName = function() {
return "CrossBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = cross(" + this.left.associatedVariableName + ".xyz, " + this.right.associatedVariableName + `.xyz);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.CrossBlock", CrossBlock);
var CustomBlock = function(i) {
__extends(e, i);
function e(t) {
return i.call(this, t) || this
}
return Object.defineProperty(e.prototype, "options", {
get: function() {
return this._options
},
set: function(t) {
this._deserializeOptions(t)
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "CustomBlock"
}
,
e.prototype._buildBlock = function(t) {
var r = this;
i.prototype._buildBlock.call(this, t);
var n = this._code
, o = this._options.functionName;
this._inputs.forEach(function(s) {
var l = new RegExp("\\{TYPE_" + s.name + "\\}","gm")
, u = t._getGLType(s.type);
n = n.replace(l, u),
o = o.replace(l, u)
}),
this._outputs.forEach(function(s) {
var l = new RegExp("\\{TYPE_" + s.name + "\\}","gm")
, u = t._getGLType(s.type);
n = n.replace(l, u),
o = o.replace(l, u)
}),
t._emitFunction(o, n, ""),
this._outputs.forEach(function(s) {
t.compilationString += r._declareOutput(s, t) + `;\r
`
}),
t.compilationString += o + "(";
var a = !1;
return this._inputs.forEach(function(s, l) {
l > 0 && (t.compilationString += ", "),
t.compilationString += s.associatedVariableName,
a = !0
}),
this._outputs.forEach(function(s, l) {
(l > 0 || a) && (t.compilationString += ", "),
t.compilationString += s.associatedVariableName
}),
t.compilationString += `);\r
`,
this
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this);
return t += this._codeVariableName + ".options = " + JSON.stringify(this._options) + `;\r
`,
t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.options = this._options,
t
}
,
e.prototype._deserialize = function(t, r, n) {
this._deserializeOptions(t.options),
i.prototype._deserialize.call(this, t, r, n)
}
,
e.prototype._deserializeOptions = function(t) {
var r = this, n, o, a;
this._options = t,
this._code = t.code.join(`\r
`) + `\r
`,
this.name = this.name || t.name,
this.target = NodeMaterialBlockTargets[t.target],
(n = t.inParameters) === null || n === void 0 || n.forEach(function(s, l) {
var u = NodeMaterialBlockConnectionPointTypes[s.type];
r.registerInput(s.name, u),
Object.defineProperty(r, s.name, {
get: function() {
return this._inputs[l]
},
enumerable: !0,
configurable: !0
})
}),
(o = t.outParameters) === null || o === void 0 || o.forEach(function(s, l) {
r.registerOutput(s.name, NodeMaterialBlockConnectionPointTypes[s.type]),
Object.defineProperty(r, s.name, {
get: function() {
return this._outputs[l]
},
enumerable: !0,
configurable: !0
}),
s.type === "BasedOnInput" && (r._outputs[l]._typeConnectionSource = r._findInputByName(s.typeFromInput)[0])
}),
(a = t.inLinkedConnectionTypes) === null || a === void 0 || a.forEach(function(s) {
r._linkConnectionTypes(r._findInputByName(s.input1)[1], r._findInputByName(s.input2)[1])
})
}
,
e.prototype._findInputByName = function(t) {
if (!t)
return null;
for (var r = 0; r < this._inputs.length; r++)
if (this._inputs[r].name === t)
return [this._inputs[r], r];
return null
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.CustomBlock", CustomBlock);
var DotBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
r._linkConnectionTypes(0, 1),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.getClassName = function() {
return "DotBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = dot(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.DotBlock", DotBlock);
var NormalizeBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.getClassName = function() {
return "NormalizeBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0]
, n = this._inputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = normalize(" + n.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.NormalizeBlock", NormalizeBlock);
var ColorMergerBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.rSwizzle = "r",
r.gSwizzle = "g",
r.bSwizzle = "b",
r.aSwizzle = "a",
r.registerInput("rgb ", NodeMaterialBlockConnectionPointTypes.Color3, !0),
r.registerInput("r", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("g", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("b", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerInput("a", NodeMaterialBlockConnectionPointTypes.Float, !0),
r.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4),
r.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3),
r
}
return e.prototype.getClassName = function() {
return "ColorMergerBlock"
}
,
Object.defineProperty(e.prototype, "rgbIn", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "r", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "g", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "b", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "a", {
get: function() {
return this._inputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgba", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgbOut", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rgb", {
get: function() {
return this.rgbOut
},
enumerable: !1,
configurable: !0
}),
e.prototype._inputRename = function(t) {
return t === "rgb " ? "rgbIn" : t
}
,
e.prototype._buildSwizzle = function(t) {
var r = this.rSwizzle + this.gSwizzle + this.bSwizzle + this.aSwizzle;
return "." + r.substr(0, t)
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this.r
, n = this.g
, o = this.b
, a = this.a
, s = this.rgbIn
, l = this._outputs[0]
, u = this._outputs[1];
return s.isConnected ? (l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + (" = vec4(" + s.associatedVariableName + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
`)),
u.hasEndpoints && (t.compilationString += this._declareOutput(u, t) + (" = " + s.associatedVariableName + this._buildSwizzle(3) + `;\r
`))) : (l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + (" = vec4(" + (r.isConnected ? this._writeVariable(r) : "0.0") + ", " + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
`)),
u.hasEndpoints && (t.compilationString += this._declareOutput(u, t) + (" = vec3(" + (r.isConnected ? this._writeVariable(r) : "0.0") + ", " + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + ")" + this._buildSwizzle(3) + `;\r
`))),
this
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.rSwizzle = this.rSwizzle,
t.gSwizzle = this.gSwizzle,
t.bSwizzle = this.bSwizzle,
t.aSwizzle = this.aSwizzle,
t
}
,
e.prototype._deserialize = function(t, r, n) {
var o, a, s, l;
i.prototype._deserialize.call(this, t, r, n),
this.rSwizzle = (o = t.rSwizzle) !== null && o !== void 0 ? o : "r",
this.gSwizzle = (a = t.gSwizzle) !== null && a !== void 0 ? a : "g",
this.bSwizzle = (s = t.bSwizzle) !== null && s !== void 0 ? s : "b",
this.aSwizzle = (l = t.aSwizzle) !== null && l !== void 0 ? l : "a"
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this);
return t += this._codeVariableName + ".rSwizzle = " + this.rSwizzle + `};\r
`,
t += this._codeVariableName + ".gSwizzle = " + this.gSwizzle + `};\r
`,
t += this._codeVariableName + ".bSwizzle = " + this.bSwizzle + `};\r
`,
t += this._codeVariableName + ".aSwizzle = " + this.aSwizzle + `};\r
`,
t
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ColorMergerBlock", ColorMergerBlock);
var VectorSplitterBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("xyzw", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
r.registerInput("xyz ", NodeMaterialBlockConnectionPointTypes.Vector3, !0),
r.registerInput("xy ", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
r.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerOutput("zw", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("z", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("w", NodeMaterialBlockConnectionPointTypes.Float),
r.inputsAreExclusive = !0,
r
}
return e.prototype.getClassName = function() {
return "VectorSplitterBlock"
}
,
Object.defineProperty(e.prototype, "xyzw", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyzIn", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyIn", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyzOut", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "xyOut", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "zw", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "x", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "y", {
get: function() {
return this._outputs[4]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "z", {
get: function() {
return this._outputs[5]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "w", {
get: function() {
return this._outputs[6]
},
enumerable: !1,
configurable: !0
}),
e.prototype._inputRename = function(t) {
switch (t) {
case "xy ":
return "xyIn";
case "xyz ":
return "xyzIn";
default:
return t
}
}
,
e.prototype._outputRename = function(t) {
switch (t) {
case "xy":
return "xyOut";
case "xyz":
return "xyzOut";
default:
return t
}
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this.xyzw.isConnected ? this.xyzw : this.xyzIn.isConnected ? this.xyzIn : this.xyIn
, n = this._outputs[0]
, o = this._outputs[1]
, a = this._outputs[2]
, s = this._outputs[3]
, l = this._outputs[4]
, u = this._outputs[5]
, c = this._outputs[6];
return n.hasEndpoints && (r === this.xyIn ? t.compilationString += this._declareOutput(n, t) + (" = vec3(" + r.associatedVariableName + `, 0.0);\r
`) : t.compilationString += this._declareOutput(n, t) + (" = " + r.associatedVariableName + `.xyz;\r
`)),
a.hasEndpoints && this.xyzw.isConnected && (t.compilationString += this._declareOutput(a, t) + (" = " + this.xyzw.associatedVariableName + `.zw;\r
`)),
o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + (" = " + r.associatedVariableName + `.xy;\r
`)),
s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + (" = " + r.associatedVariableName + `.x;\r
`)),
l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + (" = " + r.associatedVariableName + `.y;\r
`)),
u.hasEndpoints && (t.compilationString += this._declareOutput(u, t) + (" = " + r.associatedVariableName + `.z;\r
`)),
c.hasEndpoints && (t.compilationString += this._declareOutput(c, t) + (" = " + r.associatedVariableName + `.w;\r
`)),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.VectorSplitterBlock", VectorSplitterBlock);
var LerpBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r._linkConnectionTypes(1, 2, !0),
r._inputs[2].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "LerpBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "gradient", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = mix(" + this.left.associatedVariableName + " , " + this.right.associatedVariableName + ", " + this.gradient.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.LerpBlock", LerpBlock);
var DivideBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r
}
return e.prototype.getClassName = function() {
return "DivideBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = " + this.left.associatedVariableName + " / " + this.right.associatedVariableName + `;\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.DivideBlock", DivideBlock);
var SubtractBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r
}
return e.prototype.getClassName = function() {
return "SubtractBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = " + this.left.associatedVariableName + " - " + this.right.associatedVariableName + `;\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.SubtractBlock", SubtractBlock);
var StepBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("value", NodeMaterialBlockConnectionPointTypes.Float),
r.registerInput("edge", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "StepBlock"
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "edge", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = step(" + this.edge.associatedVariableName + ", " + this.value.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.StepBlock", StepBlock);
var OneMinusBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._outputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.getClassName = function() {
return "OneMinusBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = 1. - " + this.input.associatedVariableName + `;\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.OneMinusBlock", OneMinusBlock);
RegisterClass("BABYLON.OppositeBlock", OneMinusBlock);
var ViewDirectionBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
r
}
return e.prototype.getClassName = function() {
return "ViewDirectionBlock"
}
,
Object.defineProperty(e.prototype, "worldPosition", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "cameraPosition", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.cameraPosition.isConnected) {
var r = t.getInputBlockByPredicate(function(n) {
return n.systemValue === NodeMaterialSystemValues.CameraPosition
});
r || (r = new InputBlock("cameraPosition"),
r.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
r.output.connectTo(this.cameraPosition)
}
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = normalize(" + this.cameraPosition.associatedVariableName + " - " + this.worldPosition.associatedVariableName + `.xyz);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ViewDirectionBlock", ViewDirectionBlock);
var FresnelBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4),
r.registerInput("viewDirection", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("bias", NodeMaterialBlockConnectionPointTypes.Float),
r.registerInput("power", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("fresnel", NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "FresnelBlock"
}
,
Object.defineProperty(e.prototype, "worldNormal", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "viewDirection", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "bias", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "power", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "fresnel", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.viewDirection.isConnected) {
var r = new ViewDirectionBlock("View direction");
r.output.connectTo(this.viewDirection),
r.autoConfigure(t)
}
if (!this.bias.isConnected) {
var n = new InputBlock("bias");
n.value = 0,
n.output.connectTo(this.bias)
}
if (!this.power.isConnected) {
var o = new InputBlock("power");
o.value = 1,
o.output.connectTo(this.power)
}
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = "//" + this.name;
return t._emitFunctionFromInclude("fresnelFunction", r, {
removeIfDef: !0
}),
t.compilationString += this._declareOutput(this.fresnel, t) + (" = computeFresnelTerm(" + this.viewDirection.associatedVariableName + ".xyz, " + this.worldNormal.associatedVariableName + ".xyz, " + this.bias.associatedVariableName + ", " + this.power.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.FresnelBlock", FresnelBlock);
var MaxBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r
}
return e.prototype.getClassName = function() {
return "MaxBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = max(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.MaxBlock", MaxBlock);
var MinBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r
}
return e.prototype.getClassName = function() {
return "MinBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = min(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.MinBlock", MinBlock);
var DistanceBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
r._linkConnectionTypes(0, 1),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.getClassName = function() {
return "DistanceBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = length(" + this.left.associatedVariableName + " - " + this.right.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.DistanceBlock", DistanceBlock);
var LengthBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.getClassName = function() {
return "LengthBlock"
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = length(" + this.value.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.LengthBlock", LengthBlock);
var NegateBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r
}
return e.prototype.getClassName = function() {
return "NegateBlock"
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = -1.0 * " + this.value.associatedVariableName + `;\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.NegateBlock", NegateBlock);
var PowBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("power", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r
}
return e.prototype.getClassName = function() {
return "PowBlock"
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "power", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = pow(" + this.value.associatedVariableName + ", " + this.power.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.PowBlock", PowBlock);
var RandomNumberBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r
}
return e.prototype.getClassName = function() {
return "RandomNumberBlock"
}
,
Object.defineProperty(e.prototype, "seed", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0]
, n = "//" + this.name;
return t._emitFunctionFromInclude("helperFunctions", n),
t.compilationString += this._declareOutput(r, t) + (" = getRand(" + this.seed.associatedVariableName + `.xy);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.RandomNumberBlock", RandomNumberBlock);
var ArcTan2Block = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("x", NodeMaterialBlockConnectionPointTypes.Float),
r.registerInput("y", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "ArcTan2Block"
}
,
Object.defineProperty(e.prototype, "x", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "y", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = atan(" + this.x.associatedVariableName + ", " + this.y.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ArcTan2Block", ArcTan2Block);
var SmoothStepBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("edge0", NodeMaterialBlockConnectionPointTypes.Float),
r.registerInput("edge1", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r
}
return e.prototype.getClassName = function() {
return "SmoothStepBlock"
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "edge0", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "edge1", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = smoothstep(" + this.edge0.associatedVariableName + ", " + this.edge1.associatedVariableName + ", " + this.value.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.SmoothStepBlock", SmoothStepBlock);
var ReciprocalBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._outputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.getClassName = function() {
return "ReciprocalBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = 1. / " + this.input.associatedVariableName + `;\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ReciprocalBlock", ReciprocalBlock);
var ReplaceColorBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("reference", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("distance", NodeMaterialBlockConnectionPointTypes.Float),
r.registerInput("replacement", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r._linkConnectionTypes(0, 3),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r._inputs[3].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r._inputs[3].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.getClassName = function() {
return "ReplaceColorBlock"
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "reference", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "distance", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "replacement", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + `;\r
`,
t.compilationString += "if (length(" + this.value.associatedVariableName + " - " + this.reference.associatedVariableName + ") < " + this.distance.associatedVariableName + `) {\r
`,
t.compilationString += r.associatedVariableName + " = " + this.replacement.associatedVariableName + `;\r
`,
t.compilationString += `} else {\r
`,
t.compilationString += r.associatedVariableName + " = " + this.value.associatedVariableName + `;\r
`,
t.compilationString += `}\r
`,
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ReplaceColorBlock", ReplaceColorBlock);
var PosterizeBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("steps", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.getClassName = function() {
return "PosterizeBlock"
}
,
Object.defineProperty(e.prototype, "value", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "steps", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = floor(" + this.value.associatedVariableName + " / (1.0 / " + this.steps.associatedVariableName + ")) * (1.0 / " + this.steps.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.PosterizeBlock", PosterizeBlock);
var WaveBlockKind;
(function(i) {
i[i.SawTooth = 0] = "SawTooth",
i[i.Square = 1] = "Square",
i[i.Triangle = 2] = "Triangle"
}
)(WaveBlockKind || (WaveBlockKind = {}));
var WaveBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.kind = WaveBlockKind.SawTooth,
r.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
r
}
return e.prototype.getClassName = function() {
return "WaveBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
switch (this.kind) {
case WaveBlockKind.SawTooth:
{
t.compilationString += this._declareOutput(r, t) + (" = " + this.input.associatedVariableName + " - floor(0.5 + " + this.input.associatedVariableName + `);\r
`);
break
}
case WaveBlockKind.Square:
{
t.compilationString += this._declareOutput(r, t) + (" = 1.0 - 2.0 * round(fract(" + this.input.associatedVariableName + `));\r
`);
break
}
case WaveBlockKind.Triangle:
{
t.compilationString += this._declareOutput(r, t) + (" = 2.0 * abs(2.0 * (" + this.input.associatedVariableName + " - floor(0.5 + " + this.input.associatedVariableName + `))) - 1.0;\r
`);
break
}
}
return this
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.kind = this.kind,
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.kind = t.kind
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.WaveBlock", WaveBlock);
var GradientBlockColorStep = function() {
function i(e, t) {
this.step = e,
this.color = t
}
return Object.defineProperty(i.prototype, "step", {
get: function() {
return this._step
},
set: function(e) {
this._step = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(i.prototype, "color", {
get: function() {
return this._color
},
set: function(e) {
this._color = e
},
enumerable: !1,
configurable: !0
}),
i
}()
, GradientBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.colorSteps = [new GradientBlockColorStep(0,Color3.Black()), new GradientBlockColorStep(1,Color3.White())],
r.onValueChangedObservable = new Observable,
r.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r
}
return e.prototype.colorStepsUpdated = function() {
this.onValueChangedObservable.notifyObservers(this)
}
,
e.prototype.getClassName = function() {
return "GradientBlock"
}
,
Object.defineProperty(e.prototype, "gradient", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._writeColorConstant = function(t) {
var r = this.colorSteps[t];
return "vec3(" + r.color.r + ", " + r.color.g + ", " + r.color.b + ")"
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
if (!this.colorSteps.length || !this.gradient.connectedPoint) {
t.compilationString += this._declareOutput(r, t) + ` = vec3(0., 0., 0.);\r
`;
return
}
var n = t._getFreeVariableName("gradientTempColor")
, o = t._getFreeVariableName("gradientTempPosition");
t.compilationString += "vec3 " + n + " = " + this._writeColorConstant(0) + `;\r
`,
t.compilationString += "float " + o + `;\r
`;
var a = this.gradient.associatedVariableName;
this.gradient.connectedPoint.type !== NodeMaterialBlockConnectionPointTypes.Float && (a += ".x");
for (var s = 1; s < this.colorSteps.length; s++) {
var l = this.colorSteps[s]
, u = this.colorSteps[s - 1];
t.compilationString += o + " = clamp((" + a + " - " + t._emitFloat(u.step) + ") / (" + t._emitFloat(l.step) + " - " + t._emitFloat(u.step) + "), 0.0, 1.0) * step(" + t._emitFloat(s) + ", " + t._emitFloat(this.colorSteps.length - 1) + `);\r
`,
t.compilationString += n + " = mix(" + n + ", " + this._writeColorConstant(s) + ", " + o + `);\r
`
}
return t.compilationString += this._declareOutput(r, t) + (" = " + n + `;\r
`),
this
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
t.colorSteps = [];
for (var r = 0, n = this.colorSteps; r < n.length; r++) {
var o = n[r];
t.colorSteps.push({
step: o.step,
color: {
r: o.color.r,
g: o.color.g,
b: o.color.b
}
})
}
return t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.colorSteps = [];
for (var o = 0, a = t.colorSteps; o < a.length; o++) {
var s = a[o];
this.colorSteps.push(new GradientBlockColorStep(s.step,new Color3(s.color.r,s.color.g,s.color.b)))
}
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this);
t += this._codeVariableName + `.colorSteps = [];\r
`;
for (var r = 0, n = this.colorSteps; r < n.length; r++) {
var o = n[r];
t += this._codeVariableName + ".colorSteps.push(new BABYLON.GradientBlockColorStep(" + o.step + ", new BABYLON.Color3(" + o.color.r + ", " + o.color.g + ", " + o.color.b + `)));\r
`
}
return t
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.GradientBlock", GradientBlock);
var NLerpBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.AutoDetect),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
r._outputs[0]._typeConnectionSource = r._inputs[0],
r._linkConnectionTypes(0, 1),
r._linkConnectionTypes(1, 2, !0),
r._inputs[2].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "NLerpBlock"
}
,
Object.defineProperty(e.prototype, "left", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "right", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "gradient", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = normalize(mix(" + this.left.associatedVariableName + " , " + this.right.associatedVariableName + ", " + this.gradient.associatedVariableName + `));\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.NLerpBlock", NLerpBlock);
var WorleyNoise3DBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.manhattanDistance = !1,
r.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("jitter", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "WorleyNoise3DBlock"
}
,
Object.defineProperty(e.prototype, "seed", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "jitter", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "x", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "y", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
!!this.seed.isConnected && !(!this.output.hasEndpoints && !this.x.hasEndpoints && !this.y.hasEndpoints)) {
var r = `vec3 permute(vec3 x){\r
`;
r += ` return mod((34.0 * x + 1.0) * x, 289.0);\r
`,
r += `}\r
\r
`,
r += `vec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\r
`,
r += ` return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\r
`,
r += `}\r
\r
`,
r += `vec2 worley(vec3 P, float jitter, bool manhattanDistance){\r
`,
r += ` float K = 0.142857142857; // 1/7\r
`,
r += ` float Ko = 0.428571428571; // 1/2-K/2\r
`,
r += ` float K2 = 0.020408163265306; // 1/(7*7)\r
`,
r += ` float Kz = 0.166666666667; // 1/6\r
`,
r += ` float Kzo = 0.416666666667; // 1/2-1/6*2\r
`,
r += `\r
`,
r += ` vec3 Pi = mod(floor(P), 289.0);\r
`,
r += ` vec3 Pf = fract(P) - 0.5;\r
`,
r += `\r
`,
r += ` vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r
`,
r += ` vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r
`,
r += ` vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r
`,
r += `\r
`,
r += ` vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r
`,
r += ` vec3 p1 = permute(p + Pi.y - 1.0);\r
`,
r += ` vec3 p2 = permute(p + Pi.y);\r
`,
r += ` vec3 p3 = permute(p + Pi.y + 1.0);\r
`,
r += `\r
`,
r += ` vec3 p11 = permute(p1 + Pi.z - 1.0);\r
`,
r += ` vec3 p12 = permute(p1 + Pi.z);\r
`,
r += ` vec3 p13 = permute(p1 + Pi.z + 1.0);\r
`,
r += `\r
`,
r += ` vec3 p21 = permute(p2 + Pi.z - 1.0);\r
`,
r += ` vec3 p22 = permute(p2 + Pi.z);\r
`,
r += ` vec3 p23 = permute(p2 + Pi.z + 1.0);\r
`,
r += `\r
`,
r += ` vec3 p31 = permute(p3 + Pi.z - 1.0);\r
`,
r += ` vec3 p32 = permute(p3 + Pi.z);\r
`,
r += ` vec3 p33 = permute(p3 + Pi.z + 1.0);\r
`,
r += `\r
`,
r += ` vec3 ox11 = fract(p11*K) - Ko;\r
`,
r += ` vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r
`,
r += ` vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r
`,
r += `\r
`,
r += ` vec3 ox12 = fract(p12*K) - Ko;\r
`,
r += ` vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r
`,
r += ` vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r
`,
r += `\r
`,
r += ` vec3 ox13 = fract(p13*K) - Ko;\r
`,
r += ` vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r
`,
r += ` vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r
`,
r += `\r
`,
r += ` vec3 ox21 = fract(p21*K) - Ko;\r
`,
r += ` vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r
`,
r += ` vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r
`,
r += `\r
`,
r += ` vec3 ox22 = fract(p22*K) - Ko;\r
`,
r += ` vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r
`,
r += ` vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r
`,
r += `\r
`,
r += ` vec3 ox23 = fract(p23*K) - Ko;\r
`,
r += ` vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r
`,
r += ` vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r
`,
r += `\r
`,
r += ` vec3 ox31 = fract(p31*K) - Ko;\r
`,
r += ` vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r
`,
r += ` vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r
`,
r += `\r
`,
r += ` vec3 ox32 = fract(p32*K) - Ko;\r
`,
r += ` vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r
`,
r += ` vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r
`,
r += `\r
`,
r += ` vec3 ox33 = fract(p33*K) - Ko;\r
`,
r += ` vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r
`,
r += ` vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r
`,
r += `\r
`,
r += ` vec3 dx11 = Pfx + jitter*ox11;\r
`,
r += ` vec3 dy11 = Pfy.x + jitter*oy11;\r
`,
r += ` vec3 dz11 = Pfz.x + jitter*oz11;\r
`,
r += `\r
`,
r += ` vec3 dx12 = Pfx + jitter*ox12;\r
`,
r += ` vec3 dy12 = Pfy.x + jitter*oy12;\r
`,
r += ` vec3 dz12 = Pfz.y + jitter*oz12;\r
`,
r += `\r
`,
r += ` vec3 dx13 = Pfx + jitter*ox13;\r
`,
r += ` vec3 dy13 = Pfy.x + jitter*oy13;\r
`,
r += ` vec3 dz13 = Pfz.z + jitter*oz13;\r
`,
r += `\r
`,
r += ` vec3 dx21 = Pfx + jitter*ox21;\r
`,
r += ` vec3 dy21 = Pfy.y + jitter*oy21;\r
`,
r += ` vec3 dz21 = Pfz.x + jitter*oz21;\r
`,
r += `\r
`,
r += ` vec3 dx22 = Pfx + jitter*ox22;\r
`,
r += ` vec3 dy22 = Pfy.y + jitter*oy22;\r
`,
r += ` vec3 dz22 = Pfz.y + jitter*oz22;\r
`,
r += `\r
`,
r += ` vec3 dx23 = Pfx + jitter*ox23;\r
`,
r += ` vec3 dy23 = Pfy.y + jitter*oy23;\r
`,
r += ` vec3 dz23 = Pfz.z + jitter*oz23;\r
`,
r += `\r
`,
r += ` vec3 dx31 = Pfx + jitter*ox31;\r
`,
r += ` vec3 dy31 = Pfy.z + jitter*oy31;\r
`,
r += ` vec3 dz31 = Pfz.x + jitter*oz31;\r
`,
r += `\r
`,
r += ` vec3 dx32 = Pfx + jitter*ox32;\r
`,
r += ` vec3 dy32 = Pfy.z + jitter*oy32;\r
`,
r += ` vec3 dz32 = Pfz.y + jitter*oz32;\r
`,
r += `\r
`,
r += ` vec3 dx33 = Pfx + jitter*ox33;\r
`,
r += ` vec3 dy33 = Pfy.z + jitter*oy33;\r
`,
r += ` vec3 dz33 = Pfz.z + jitter*oz33;\r
`,
r += `\r
`,
r += ` vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r
`,
r += ` vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r
`,
r += ` vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r
`,
r += ` vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r
`,
r += ` vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r
`,
r += ` vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r
`,
r += ` vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r
`,
r += ` vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r
`,
r += ` vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r
`,
r += `\r
`,
r += ` vec3 d1a = min(d11, d12);\r
`,
r += ` d12 = max(d11, d12);\r
`,
r += ` d11 = min(d1a, d13); // Smallest now not in d12 or d13\r
`,
r += ` d13 = max(d1a, d13);\r
`,
r += ` d12 = min(d12, d13); // 2nd smallest now not in d13\r
`,
r += ` vec3 d2a = min(d21, d22);\r
`,
r += ` d22 = max(d21, d22);\r
`,
r += ` d21 = min(d2a, d23); // Smallest now not in d22 or d23\r
`,
r += ` d23 = max(d2a, d23);\r
`,
r += ` d22 = min(d22, d23); // 2nd smallest now not in d23\r
`,
r += ` vec3 d3a = min(d31, d32);\r
`,
r += ` d32 = max(d31, d32);\r
`,
r += ` d31 = min(d3a, d33); // Smallest now not in d32 or d33\r
`,
r += ` d33 = max(d3a, d33);\r
`,
r += ` d32 = min(d32, d33); // 2nd smallest now not in d33\r
`,
r += ` vec3 da = min(d11, d21);\r
`,
r += ` d21 = max(d11, d21);\r
`,
r += ` d11 = min(da, d31); // Smallest now in d11\r
`,
r += ` d31 = max(da, d31); // 2nd smallest now not in d31\r
`,
r += ` d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r
`,
r += ` d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r
`,
r += ` d12 = min(d12, d21); // 2nd smallest now not in d21\r
`,
r += ` d12 = min(d12, d22); // nor in d22\r
`,
r += ` d12 = min(d12, d31); // nor in d31\r
`,
r += ` d12 = min(d12, d32); // nor in d32\r
`,
r += ` d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r
`,
r += ` d11.y = min(d11.y,d12.z); // Only two more to go\r
`,
r += ` d11.y = min(d11.y,d11.z); // Done! (Phew!)\r
`,
r += ` return sqrt(d11.xy); // F1, F2\r
`,
r += `}\r
\r
`,
t._emitFunction("worley3D", r, "// Worley3D");
var n = t._getFreeVariableName("worleyTemp");
return t.compilationString += "vec2 " + n + " = worley(" + this.seed.associatedVariableName + ", " + this.jitter.associatedVariableName + ", " + this.manhattanDistance + `);\r
`,
this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + (" = " + n + `;\r
`)),
this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + (" = " + n + `.x;\r
`)),
this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + (" = " + n + `.y;\r
`)),
this
}
}
,
e.prototype._dumpPropertiesCode = function() {
var t = i.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".manhattanDistance = " + this.manhattanDistance + `;\r
`);
return t
}
,
e.prototype.serialize = function() {
var t = i.prototype.serialize.call(this);
return t.manhattanDistance = this.manhattanDistance,
t
}
,
e.prototype._deserialize = function(t, r, n) {
i.prototype._deserialize.call(this, t, r, n),
this.manhattanDistance = t.manhattanDistance
}
,
__decorate([editableInPropertyPage("Use Manhattan Distance", PropertyTypeForEdition.Boolean, "PROPERTIES", {
notifiers: {
update: !1
}
})], e.prototype, "manhattanDistance", void 0),
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.WorleyNoise3DBlock", WorleyNoise3DBlock);
var SimplexPerlin3DBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
r
}
return e.prototype.getClassName = function() {
return "SimplexPerlin3DBlock"
}
,
Object.defineProperty(e.prototype, "seed", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
if (i.prototype._buildBlock.call(this, t),
!!this.seed.isConnected && !!this._outputs[0].hasEndpoints) {
var r = `const float SKEWFACTOR = 1.0/3.0;\r
`;
return r += `const float UNSKEWFACTOR = 1.0/6.0;\r
`,
r += `const float SIMPLEX_CORNER_POS = 0.5;\r
`,
r += `const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r
`,
r += `float SimplexPerlin3D( vec3 P ){\r
`,
r += ` P *= SIMPLEX_TETRAHADRON_HEIGHT;\r
`,
r += " vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );",
r += ` vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r
`,
r += ` vec3 g = step(x0.yzx, x0.xyz);\r
`,
r += ` vec3 l = 1.0 - g;\r
`,
r += ` vec3 Pi_1 = min( g.xyz, l.zxy );\r
`,
r += ` vec3 Pi_2 = max( g.xyz, l.zxy );\r
`,
r += ` vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r
`,
r += ` vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r
`,
r += ` vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r
`,
r += ` vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r
`,
r += ` vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r
`,
r += ` vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r
`,
r += ` Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r
`,
r += ` vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r
`,
r += ` vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r
`,
r += ` Pt *= Pt;\r
`,
r += ` vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r
`,
r += ` Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r
`,
r += ` const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r
`,
r += ` const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r
`,
r += ` vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r
`,
r += ` vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r
`,
r += ` Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r
`,
r += ` Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r
`,
r += ` vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r
`,
r += ` vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r
`,
r += ` vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r
`,
r += ` vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\r
`,
r += ` const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r
`,
r += ` vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r
`,
r += ` kernel_weights = max(0.5 - kernel_weights, 0.0);\r
`,
r += ` kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r
`,
r += ` return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r
`,
r += `}\r
`,
t._emitFunction("SimplexPerlin3D", r, "// SimplexPerlin3D"),
t.compilationString += this._declareOutput(this._outputs[0], t) + (" = SimplexPerlin3D(" + this.seed.associatedVariableName + `);\r
`),
this
}
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.SimplexPerlin3DBlock", SimplexPerlin3DBlock);
var NormalBlendBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("normalMap0", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("normalMap1", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
r._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r
}
return e.prototype.getClassName = function() {
return "NormalBlendBlock"
}
,
Object.defineProperty(e.prototype, "normalMap0", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "normalMap1", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0]
, n = this._inputs[0]
, o = this._inputs[1]
, a = t._getFreeVariableName("stepR")
, s = t._getFreeVariableName("stepG");
return t.compilationString += "float " + a + " = step(0.5, " + n.associatedVariableName + `.r);\r
`,
t.compilationString += "float " + s + " = step(0.5, " + n.associatedVariableName + `.g);\r
`,
t.compilationString += this._declareOutput(r, t) + `;\r
`,
t.compilationString += r.associatedVariableName + ".r = (1.0 - " + a + ") * " + n.associatedVariableName + ".r * " + o.associatedVariableName + ".r * 2.0 + " + a + " * (1.0 - (1.0 - " + n.associatedVariableName + ".r) * (1.0 - " + o.associatedVariableName + `.r) * 2.0);\r
`,
t.compilationString += r.associatedVariableName + ".g = (1.0 - " + s + ") * " + n.associatedVariableName + ".g * " + o.associatedVariableName + ".g * 2.0 + " + s + " * (1.0 - (1.0 - " + n.associatedVariableName + ".g) * (1.0 - " + o.associatedVariableName + `.g) * 2.0);\r
`,
t.compilationString += r.associatedVariableName + ".b = " + n.associatedVariableName + ".b * " + o.associatedVariableName + `.b;\r
`,
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.NormalBlendBlock", NormalBlendBlock);
var Rotate2dBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("input", NodeMaterialBlockConnectionPointTypes.Vector2),
r.registerInput("angle", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
r
}
return e.prototype.getClassName = function() {
return "Rotate2dBlock"
}
,
Object.defineProperty(e.prototype, "input", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "angle", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype.autoConfigure = function(t) {
if (!this.angle.isConnected) {
var r = new InputBlock("angle");
r.value = 0,
r.output.connectTo(this.angle)
}
}
,
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0]
, n = this.angle
, o = this.input;
return t.compilationString += this._declareOutput(r, t) + (" = vec2(cos(" + n.associatedVariableName + ") * " + o.associatedVariableName + ".x - sin(" + n.associatedVariableName + ") * " + o.associatedVariableName + ".y, sin(" + n.associatedVariableName + ") * " + o.associatedVariableName + ".x + cos(" + n.associatedVariableName + ") * " + o.associatedVariableName + `.y);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.Rotate2dBlock", Rotate2dBlock);
var ReflectBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("incident", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("normal", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
r._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r
}
return e.prototype.getClassName = function() {
return "ReflectBlock"
}
,
Object.defineProperty(e.prototype, "incident", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "normal", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = reflect(" + this.incident.associatedVariableName + ".xyz, " + this.normal.associatedVariableName + `.xyz);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.ReflectBlock", ReflectBlock);
var RefractBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("incident", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("normal", NodeMaterialBlockConnectionPointTypes.Vector3),
r.registerInput("ior", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
r._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
r._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
r._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
r
}
return e.prototype.getClassName = function() {
return "RefractBlock"
}
,
Object.defineProperty(e.prototype, "incident", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "normal", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "ior", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0];
return t.compilationString += this._declareOutput(r, t) + (" = refract(" + this.incident.associatedVariableName + ".xyz, " + this.normal.associatedVariableName + ".xyz, " + this.ior.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.RefractBlock", RefractBlock);
var DesaturateBlock = function(i) {
__extends(e, i);
function e(t) {
var r = i.call(this, t, NodeMaterialBlockTargets.Neutral) || this;
return r.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color3),
r.registerInput("level", NodeMaterialBlockConnectionPointTypes.Float),
r.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3),
r
}
return e.prototype.getClassName = function() {
return "DesaturateBlock"
}
,
Object.defineProperty(e.prototype, "color", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "level", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "output", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
e.prototype._buildBlock = function(t) {
i.prototype._buildBlock.call(this, t);
var r = this._outputs[0]
, n = this.color
, o = n.associatedVariableName
, a = t._getFreeVariableName("colorMin")
, s = t._getFreeVariableName("colorMax")
, l = t._getFreeVariableName("colorMerge");
return t.compilationString += "float " + a + " = min(min(" + o + ".x, " + o + ".y), " + o + `.z);\r
`,
t.compilationString += "float " + s + " = max(max(" + o + ".x, " + o + ".y), " + o + `.z);\r
`,
t.compilationString += "float " + l + " = 0.5 * (" + a + " + " + s + `);\r
`,
t.compilationString += this._declareOutput(r, t) + (" = mix(" + o + ", vec3(" + l + ", " + l + ", " + l + "), " + this.level.associatedVariableName + `);\r
`),
this
}
,
e
}(NodeMaterialBlock);
RegisterClass("BABYLON.DesaturateBlock", DesaturateBlock);
var name$1z = "rgbdDecodePixelShader"
, shader$1z = `
varying vec2 vUV;
uniform sampler2D textureSampler;
#include
void main(void)
{
gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);
}`;
ShaderStore.ShadersStore[name$1z] = shader$1z;
var name$1y = "passPixelShader"
, shader$1y = `
varying vec2 vUV;
uniform sampler2D textureSampler;
void main(void)
{
gl_FragColor=texture2D(textureSampler,vUV);
}`;
ShaderStore.ShadersStore[name$1y] = shader$1y;
var name$1x = "passCubePixelShader"
, shader$1x = `
varying vec2 vUV;
uniform samplerCube textureSampler;
void main(void)
{
vec2 uv=vUV*2.0-1.0;
#ifdef POSITIVEX
gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));
#endif
#ifdef NEGATIVEX
gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));
#endif
#ifdef POSITIVEY
gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));
#endif
#ifdef NEGATIVEY
gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));
#endif
#ifdef POSITIVEZ
gl_FragColor=textureCube(textureSampler,vec3(uv,1.001));
#endif
#ifdef NEGATIVEZ
gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));
#endif
}`;
ShaderStore.ShadersStore[name$1x] = shader$1x;
var PassPostProcess = function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u) {
return n === void 0 && (n = null),
l === void 0 && (l = 0),
u === void 0 && (u = !1),
i.call(this, t, "pass", null, null, r, n, o, a, s, void 0, l, void 0, null, u) || this
}
return e.prototype.getClassName = function() {
return "PassPostProcess"
}
,
e._Parse = function(t, r, n, o) {
return SerializationHelper.Parse(function() {
return new e(t.name,t.options,r,t.renderTargetSamplingMode,t._engine,t.reusable)
}, t, n, o)
}
,
e
}(PostProcess);
RegisterClass("BABYLON.PassPostProcess", PassPostProcess);
(function(i) {
__extends(e, i);
function e(t, r, n, o, a, s, l, u) {
n === void 0 && (n = null),
l === void 0 && (l = 0),
u === void 0 && (u = !1);
var c = i.call(this, t, "passCube", null, null, r, n, o, a, s, "#define POSITIVEX", l, void 0, null, u) || this;
return c._face = 0,
c
}
return Object.defineProperty(e.prototype, "face", {
get: function() {
return this._face
},
set: function(t) {
if (!(t < 0 || t > 5))
switch (this._face = t,
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");
break
}
},
enumerable: !1,
configurable: !0
}),
e.prototype.getClassName = function() {
return "PassCubePostProcess"
}
,
e._Parse = function(t, r, n, o) {
return SerializationHelper.Parse(function() {
return new e(t.name,t.options,r,t.renderTargetSamplingMode,t._engine,t.reusable)
}, t, n, o)
}
,
e
}
)(PostProcess);
Engine._RescalePostProcessFactory = function(i) {
return new PassPostProcess("rescale",1,null,2,i,!1,0)
}
;
function ApplyPostProcess(i, e, t, r, n, o) {
var a = e.getEngine();
return e.isReady = !1,
n = n != null ? n : e.samplingMode,
r = r != null ? r : e.type,
o = o != null ? o : e.format,
r === -1 && (r = 0),
new Promise(function(s) {
var l = new PostProcess("postprocess",i,null,null,1,null,n,a,!1,void 0,r,void 0,null,!1,o);
l.externalTextureSamplerBinding = !0;
var u = a.createRenderTargetTexture({
width: e.width,
height: e.height
}, {
generateDepthBuffer: !1,
generateMipMaps: !1,
generateStencilBuffer: !1,
samplingMode: n,
type: r,
format: o
});
l.getEffect().executeWhenCompiled(function() {
l.onApply = function(c) {
c._bindTexture("textureSampler", e),
c.setFloat2("scale", 1, 1)
}
,
t.postProcessManager.directRender([l], u, !0),
a.restoreDefaultFramebuffer(),
a._releaseTexture(e),
l && l.dispose(),
u._swapAndDie(e),
e.type = r,
e.format = 5,
e.isReady = !0,
s(e)
})
}
)
}
var _FloatView, _Int32View;
function ToHalfFloat(i) {
_FloatView || (_FloatView = new Float32Array(1),
_Int32View = new Int32Array(_FloatView.buffer)),
_FloatView[0] = i;
var e = _Int32View[0]
, t = e >> 16 & 32768
, r = e >> 12 & 2047
, n = e >> 23 & 255;
return n < 103 ? t : n > 142 ? (t |= 31744,
t |= (n == 255 ? 0 : 1) && e & 8388607,
t) : n < 113 ? (r |= 2048,
t |= (r >> 114 - n) + (r >> 113 - n & 1),
t) : (t |= n - 112 << 10 | r >> 1,
t += r & 1,
t)
}
function FromHalfFloat(i) {
var e = (i & 32768) >> 15
, t = (i & 31744) >> 10
, r = i & 1023;
return t === 0 ? (e ? -1 : 1) * Math.pow(2, -14) * (r / Math.pow(2, 10)) : t == 31 ? r ? NaN : (e ? -1 : 1) * (1 / 0) : (e ? -1 : 1) * Math.pow(2, t - 15) * (1 + r / Math.pow(2, 10))
}
var RGBDTextureTools = function() {
function i() {}
return i.ExpandRGBDTexture = function(e) {
var t = e._texture;
if (!(!t || !e.isRGBD)) {
var r = t.getEngine()
, n = r.getCaps()
, o = t.isReady
, a = !1;
n.textureHalfFloatRender && n.textureHalfFloatLinearFiltering ? (a = !0,
t.type = 2) : n.textureFloatRender && n.textureFloatLinearFiltering && (a = !0,
t.type = 1),
a && (t.isReady = !1,
t._isRGBD = !1,
t.invertY = !1);
var s = function() {
if (a) {
var l = new PostProcess("rgbdDecode","rgbdDecode",null,null,1,null,3,r,!1,void 0,t.type,void 0,null,!1);
l.externalTextureSamplerBinding = !0;
var u = r.createRenderTargetTexture(t.width, {
generateDepthBuffer: !1,
generateMipMaps: !1,
generateStencilBuffer: !1,
samplingMode: t.samplingMode,
type: t.type,
format: 5
});
l.getEffect().executeWhenCompiled(function() {
l.onApply = function(c) {
c._bindTexture("textureSampler", t),
c.setFloat2("scale", 1, 1)
}
,
e.getScene().postProcessManager.directRender([l], u, !0),
r.restoreDefaultFramebuffer(),
r._releaseTexture(t),
l && l.dispose(),
u._swapAndDie(t),
t.isReady = !0
})
}
};
o ? s() : e.onLoadObservable.addOnce(s)
}
}
,
i.EncodeTextureToRGBD = function(e, t, r) {
return r === void 0 && (r = 0),
ApplyPostProcess("rgbdEncode", e, t, r, 1, 5)
}
,
i
}()
, _environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg=="
, _instanceNumber = 0
, GetEnvironmentBRDFTexture = function(i) {
if (!i.environmentBRDFTexture) {
var e = i.useDelayedTextureLoading;
i.useDelayedTextureLoading = !1;
var t = i._blockEntityCollection;
i._blockEntityCollection = !1;
var r = Texture.CreateFromBase64String(_environmentBRDFBase64Texture, "EnvironmentBRDFTexture" + _instanceNumber++, i, !0, !1, Texture.BILINEAR_SAMPLINGMODE);
i._blockEntityCollection = t;
var n = i.getEngine().getLoadedTexturesCache()
, o = n.indexOf(r.getInternalTexture());
o !== -1 && n.splice(o, 1),
r.isRGBD = !0,
r.wrapU = Texture.CLAMP_ADDRESSMODE,
r.wrapV = Texture.CLAMP_ADDRESSMODE,
i.environmentBRDFTexture = r,
i.useDelayedTextureLoading = e,
RGBDTextureTools.ExpandRGBDTexture(r),
i.getEngine().onContextRestoredObservable.add(function() {
r.isRGBD = !0;
var a = function() {
r.isReady() ? RGBDTextureTools.ExpandRGBDTexture(r) : Tools.SetImmediate(a)
};
a()
})
}
return i.environmentBRDFTexture
}
, PBRClearCoatConfiguration = function() {
function i(e) {
this._isEnabled = !1,
this.isEnabled = !1,
this.intensity = 1,
this.roughness = 0,
this._indexOfRefraction = i._DefaultIndexOfRefraction,
this.indexOfRefraction = i._DefaultIndexOfRefraction,
this._texture = null,
this.texture = null,
this._useRoughnessFromMainTexture = !0,
this.useRoughnessFromMainTexture = !0,
this._textureRoughness = null,
this.textureRoughness = null,
this._remapF0OnInterfaceChange = !0,
this.remapF0OnInterfaceChange = !0,
this._bumpTexture = null,
this.bumpTexture = null,
this._isTintEnabled = !1,
this.isTintEnabled = !1,
this.tintColor = Color3.White(),
this.tintColorAtDistance = 1,
this.tintThickness = 1,
this._tintTexture = null,
this.tintTexture = null,
this._internalMarkAllSubMeshesAsTexturesDirty = e
}
return i.prototype._markAllSubMeshesAsTexturesDirty = function() {
this._internalMarkAllSubMeshesAsTexturesDirty()
}
,
i.prototype.isReadyForSubMesh = function(e, t, r, n) {
return this._isEnabled ? !(e._areTexturesDirty && t.texturesEnabled && (this._texture && MaterialFlags.ClearCoatTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._textureRoughness && MaterialFlags.ClearCoatTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking() || r.getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.ClearCoatBumpTextureEnabled && !n && !this._bumpTexture.isReady() || this._isTintEnabled && this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled && !this._tintTexture.isReadyOrNotBlocking())) : !0
}
,
i.prototype.prepareDefines = function(e, t) {
var r;
this._isEnabled ? (e.CLEARCOAT = !0,
e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = this._texture !== null && this._texture._texture === ((r = this._textureRoughness) === null || r === void 0 ? void 0 : r._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness),
e.CLEARCOAT_REMAP_F0 = this._remapF0OnInterfaceChange,
e._areTexturesDirty && t.texturesEnabled && (this._texture && MaterialFlags.ClearCoatTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "CLEARCOAT_TEXTURE") : e.CLEARCOAT_TEXTURE = !1,
this._textureRoughness && MaterialFlags.ClearCoatTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._textureRoughness, e, "CLEARCOAT_TEXTURE_ROUGHNESS") : e.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
this._bumpTexture && MaterialFlags.ClearCoatBumpTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture, e, "CLEARCOAT_BUMP") : e.CLEARCOAT_BUMP = !1,
e.CLEARCOAT_DEFAULTIOR = this._indexOfRefraction === i._DefaultIndexOfRefraction,
this._isTintEnabled ? (e.CLEARCOAT_TINT = !0,
this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._tintTexture, e, "CLEARCOAT_TINT_TEXTURE"),
e.CLEARCOAT_TINT_GAMMATEXTURE = this._tintTexture.gammaSpace) : e.CLEARCOAT_TINT_TEXTURE = !1) : (e.CLEARCOAT_TINT = !1,
e.CLEARCOAT_TINT_TEXTURE = !1))) : (e.CLEARCOAT = !1,
e.CLEARCOAT_TEXTURE = !1,
e.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
e.CLEARCOAT_BUMP = !1,
e.CLEARCOAT_TINT = !1,
e.CLEARCOAT_TINT_TEXTURE = !1,
e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1)
}
,
i.prototype.bindForSubMesh = function(e, t, r, n, o, a, s, l) {
var u, c, h, f, d, _, g, m;
if (!!this._isEnabled) {
var v = l.materialDefines
, y = v.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL;
if (!e.useUbo || !o || !e.isSync) {
y && MaterialFlags.ClearCoatTextureEnabled ? (e.updateFloat4("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
MaterialHelper.BindTextureMatrix(this._texture, e, "clearCoat")) : (this._texture || this._textureRoughness) && MaterialFlags.ClearCoatTextureEnabled && (e.updateFloat4("vClearCoatInfos", (c = (u = this._texture) === null || u === void 0 ? void 0 : u.coordinatesIndex) !== null && c !== void 0 ? c : 0, (f = (h = this._texture) === null || h === void 0 ? void 0 : h.level) !== null && f !== void 0 ? f : 0, (_ = (d = this._textureRoughness) === null || d === void 0 ? void 0 : d.coordinatesIndex) !== null && _ !== void 0 ? _ : 0, (m = (g = this._textureRoughness) === null || g === void 0 ? void 0 : g.level) !== null && m !== void 0 ? m : 0),
this._texture && MaterialHelper.BindTextureMatrix(this._texture, e, "clearCoat"),
this._textureRoughness && !y && !v.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialHelper.BindTextureMatrix(this._textureRoughness, e, "clearCoatRoughness")),
this._bumpTexture && r.getCaps().standardDerivatives && MaterialFlags.ClearCoatTextureEnabled && !n && (e.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level),
MaterialHelper.BindTextureMatrix(this._bumpTexture, e, "clearCoatBump"),
t._mirroredCameraPosition ? e.updateFloat2("vClearCoatTangentSpaceParams", a ? 1 : -1, s ? 1 : -1) : e.updateFloat2("vClearCoatTangentSpaceParams", a ? -1 : 1, s ? -1 : 1)),
this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled && (e.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level),
MaterialHelper.BindTextureMatrix(this._tintTexture, e, "clearCoatTint")),
e.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
var b = 1 - this._indexOfRefraction
, T = 1 + this._indexOfRefraction
, C = Math.pow(-b / T, 2)
, A = 1 / this._indexOfRefraction;
e.updateFloat4("vClearCoatRefractionParams", C, A, b, T),
this._isTintEnabled && (e.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintThickness)),
e.updateFloat("clearCoatColorAtDistance", Math.max(1e-5, this.tintColorAtDistance)))
}
t.texturesEnabled && (this._texture && MaterialFlags.ClearCoatTextureEnabled && e.setTexture("clearCoatSampler", this._texture),
this._textureRoughness && !y && !v.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialFlags.ClearCoatTextureEnabled && e.setTexture("clearCoatRoughnessSampler", this._textureRoughness),
this._bumpTexture && r.getCaps().standardDerivatives && MaterialFlags.ClearCoatBumpTextureEnabled && !n && e.setTexture("clearCoatBumpSampler", this._bumpTexture),
this._isTintEnabled && this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled && e.setTexture("clearCoatTintSampler", this._tintTexture))
}
}
,
i.prototype.hasTexture = function(e) {
return this._texture === e || this._textureRoughness === e || this._bumpTexture === e || this._tintTexture === e
}
,
i.prototype.getActiveTextures = function(e) {
this._texture && e.push(this._texture),
this._textureRoughness && e.push(this._textureRoughness),
this._bumpTexture && e.push(this._bumpTexture),
this._tintTexture && e.push(this._tintTexture)
}
,
i.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),
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)
}
,
i.prototype.dispose = function(e) {
var t, r, n, o;
e && ((t = this._texture) === null || t === void 0 || t.dispose(),
(r = this._textureRoughness) === null || r === void 0 || r.dispose(),
(n = this._bumpTexture) === null || n === void 0 || n.dispose(),
(o = this._tintTexture) === null || o === void 0 || o.dispose())
}
,
i.prototype.getClassName = function() {
return "PBRClearCoatConfiguration"
}
,
i.AddFallbacks = function(e, t, r) {
return e.CLEARCOAT_BUMP && t.addFallback(r++, "CLEARCOAT_BUMP"),
e.CLEARCOAT_TINT && t.addFallback(r++, "CLEARCOAT_TINT"),
e.CLEARCOAT && t.addFallback(r++, "CLEARCOAT"),
r
}
,
i.AddUniforms = function(e) {
e.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatRoughnessMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos")
}
,
i.AddSamplers = function(e) {
e.push("clearCoatSampler", "clearCoatRoughnessSampler", "clearCoatBumpSampler", "clearCoatTintSampler")
}
,
i.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)
}
,
i.prototype.copyTo = function(e) {
SerializationHelper.Clone(function() {
return e
}, this)
}
,
i.prototype.serialize = function() {
return SerializationHelper.Serialize(this)
}
,
i.prototype.parse = function(e, t, r) {
var n = this;
SerializationHelper.Parse(function() {
return n
}, e, t, r)
}
,
i._DefaultIndexOfRefraction = 1.5,
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "isEnabled", void 0),
__decorate([serialize()], i.prototype, "intensity", void 0),
__decorate([serialize()], i.prototype, "roughness", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "indexOfRefraction", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "texture", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "useRoughnessFromMainTexture", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "textureRoughness", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "remapF0OnInterfaceChange", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "bumpTexture", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "isTintEnabled", void 0),
__decorate([serializeAsColor3()], i.prototype, "tintColor", void 0),
__decorate([serialize()], i.prototype, "tintColorAtDistance", void 0),
__decorate([serialize()], i.prototype, "tintThickness", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "tintTexture", void 0),
i
}()
, PBRAnisotropicConfiguration = function() {
function i(e) {
this._isEnabled = !1,
this.isEnabled = !1,
this.intensity = 1,
this.direction = new Vector2(1,0),
this._texture = null,
this.texture = null,
this._internalMarkAllSubMeshesAsTexturesDirty = e
}
return i.prototype._markAllSubMeshesAsTexturesDirty = function() {
this._internalMarkAllSubMeshesAsTexturesDirty()
}
,
i.prototype.isReadyForSubMesh = function(e, t) {
return this._isEnabled ? !(e._areTexturesDirty && t.texturesEnabled && this._texture && MaterialFlags.AnisotropicTextureEnabled && !this._texture.isReadyOrNotBlocking()) : !0
}
,
i.prototype.prepareDefines = function(e, t, r) {
this._isEnabled ? (e.ANISOTROPIC = this._isEnabled,
this._isEnabled && !t.isVerticesDataPresent(VertexBuffer.TangentKind) && (e._needUVs = !0,
e.MAINUV1 = !0),
e._areTexturesDirty && r.texturesEnabled && (this._texture && MaterialFlags.AnisotropicTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "ANISOTROPIC_TEXTURE") : e.ANISOTROPIC_TEXTURE = !1)) : (e.ANISOTROPIC = !1,
e.ANISOTROPIC_TEXTURE = !1)
}
,
i.prototype.bindForSubMesh = function(e, t, r) {
!this._isEnabled || ((!e.useUbo || !r || !e.isSync) && (this._texture && MaterialFlags.AnisotropicTextureEnabled && (e.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level),
MaterialHelper.BindTextureMatrix(this._texture, e, "anisotropy")),
e.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity)),
t.texturesEnabled && this._texture && MaterialFlags.AnisotropicTextureEnabled && e.setTexture("anisotropySampler", this._texture))
}
,
i.prototype.hasTexture = function(e) {
return this._texture === e
}
,
i.prototype.getActiveTextures = function(e) {
this._texture && e.push(this._texture)
}
,
i.prototype.getAnimatables = function(e) {
this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
}
,
i.prototype.dispose = function(e) {
e && this._texture && this._texture.dispose()
}
,
i.prototype.getClassName = function() {
return "PBRAnisotropicConfiguration"
}
,
i.AddFallbacks = function(e, t, r) {
return e.ANISOTROPIC && t.addFallback(r++, "ANISOTROPIC"),
r
}
,
i.AddUniforms = function(e) {
e.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix")
}
,
i.PrepareUniformBuffer = function(e) {
e.addUniform("vAnisotropy", 3),
e.addUniform("vAnisotropyInfos", 2),
e.addUniform("anisotropyMatrix", 16)
}
,
i.AddSamplers = function(e) {
e.push("anisotropySampler")
}
,
i.prototype.copyTo = function(e) {
SerializationHelper.Clone(function() {
return e
}, this)
}
,
i.prototype.serialize = function() {
return SerializationHelper.Serialize(this)
}
,
i.prototype.parse = function(e, t, r) {
var n = this;
SerializationHelper.Parse(function() {
return n
}, e, t, r)
}
,
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "isEnabled", void 0),
__decorate([serialize()], i.prototype, "intensity", void 0),
__decorate([serializeAsVector2()], i.prototype, "direction", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "texture", void 0),
i
}()
, PBRBRDFConfiguration = function() {
function i(e) {
this._useEnergyConservation = i.DEFAULT_USE_ENERGY_CONSERVATION,
this.useEnergyConservation = i.DEFAULT_USE_ENERGY_CONSERVATION,
this._useSmithVisibilityHeightCorrelated = i.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
this.useSmithVisibilityHeightCorrelated = i.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
this._useSphericalHarmonics = i.DEFAULT_USE_SPHERICAL_HARMONICS,
this.useSphericalHarmonics = i.DEFAULT_USE_SPHERICAL_HARMONICS,
this._useSpecularGlossinessInputEnergyConservation = i.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
this.useSpecularGlossinessInputEnergyConservation = i.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
this._internalMarkAllSubMeshesAsMiscDirty = e
}
return i.prototype._markAllSubMeshesAsMiscDirty = function() {
this._internalMarkAllSubMeshesAsMiscDirty()
}
,
i.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
}
,
i.prototype.getClassName = function() {
return "PBRBRDFConfiguration"
}
,
i.prototype.copyTo = function(e) {
SerializationHelper.Clone(function() {
return e
}, this)
}
,
i.prototype.serialize = function() {
return SerializationHelper.Serialize(this)
}
,
i.prototype.parse = function(e, t, r) {
var n = this;
SerializationHelper.Parse(function() {
return n
}, e, t, r)
}
,
i.DEFAULT_USE_ENERGY_CONSERVATION = !0,
i.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = !0,
i.DEFAULT_USE_SPHERICAL_HARMONICS = !0,
i.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = !0,
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], i.prototype, "useEnergyConservation", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], i.prototype, "useSmithVisibilityHeightCorrelated", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], i.prototype, "useSphericalHarmonics", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], i.prototype, "useSpecularGlossinessInputEnergyConservation", void 0),
i
}()
, PBRSheenConfiguration = function() {
function i(e) {
this._isEnabled = !1,
this.isEnabled = !1,
this._linkSheenWithAlbedo = !1,
this.linkSheenWithAlbedo = !1,
this.intensity = 1,
this.color = Color3.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 i.prototype._markAllSubMeshesAsTexturesDirty = function() {
this._internalMarkAllSubMeshesAsTexturesDirty()
}
,
i.prototype.isReadyForSubMesh = function(e, t) {
return this._isEnabled ? !(e._areTexturesDirty && t.texturesEnabled && (this._texture && MaterialFlags.SheenTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._textureRoughness && MaterialFlags.SheenTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking())) : !0
}
,
i.prototype.prepareDefines = function(e, t) {
var r;
this._isEnabled ? (e.SHEEN = this._isEnabled,
e.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo,
e.SHEEN_ROUGHNESS = this._roughness !== null,
e.SHEEN_ALBEDOSCALING = this._albedoScaling,
e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = this._texture !== null && this._texture._texture === ((r = this._textureRoughness) === null || r === void 0 ? void 0 : r._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness),
e._areTexturesDirty && t.texturesEnabled && (this._texture && MaterialFlags.SheenTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "SHEEN_TEXTURE"),
e.SHEEN_GAMMATEXTURE = this._texture.gammaSpace) : e.SHEEN_TEXTURE = !1,
this._textureRoughness && MaterialFlags.SheenTextureEnabled ? MaterialHelper.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)
}
,
i.prototype.bindForSubMesh = function(e, t, r, n) {
var o, a, s, l, u, c, h, f;
if (!!this._isEnabled) {
var d = n.materialDefines
, _ = d.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;
(!e.useUbo || !r || !e.isSync) && (_ && MaterialFlags.SheenTextureEnabled ? (e.updateFloat4("vSheenInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
MaterialHelper.BindTextureMatrix(this._texture, e, "sheen")) : (this._texture || this._textureRoughness) && MaterialFlags.SheenTextureEnabled && (e.updateFloat4("vSheenInfos", (a = (o = this._texture) === null || o === void 0 ? void 0 : o.coordinatesIndex) !== null && a !== void 0 ? a : 0, (l = (s = this._texture) === null || s === void 0 ? void 0 : s.level) !== null && l !== void 0 ? l : 0, (c = (u = this._textureRoughness) === null || u === void 0 ? void 0 : u.coordinatesIndex) !== null && c !== void 0 ? c : 0, (f = (h = this._textureRoughness) === null || h === void 0 ? void 0 : h.level) !== null && f !== void 0 ? f : 0),
this._texture && MaterialHelper.BindTextureMatrix(this._texture, e, "sheen"),
this._textureRoughness && !_ && !d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialHelper.BindTextureMatrix(this._textureRoughness, e, "sheenRoughness")),
e.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity),
this._roughness !== null && e.updateFloat("vSheenRoughness", this._roughness)),
t.texturesEnabled && (this._texture && MaterialFlags.SheenTextureEnabled && e.setTexture("sheenSampler", this._texture),
this._textureRoughness && !_ && !d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialFlags.SheenTextureEnabled && e.setTexture("sheenRoughnessSampler", this._textureRoughness))
}
}
,
i.prototype.hasTexture = function(e) {
return this._texture === e || this._textureRoughness === e
}
,
i.prototype.getActiveTextures = function(e) {
this._texture && e.push(this._texture),
this._textureRoughness && e.push(this._textureRoughness)
}
,
i.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)
}
,
i.prototype.dispose = function(e) {
var t, r;
e && ((t = this._texture) === null || t === void 0 || t.dispose(),
(r = this._textureRoughness) === null || r === void 0 || r.dispose())
}
,
i.prototype.getClassName = function() {
return "PBRSheenConfiguration"
}
,
i.AddFallbacks = function(e, t, r) {
return e.SHEEN && t.addFallback(r++, "SHEEN"),
r
}
,
i.AddUniforms = function(e) {
e.push("vSheenColor", "vSheenRoughness", "vSheenInfos", "sheenMatrix", "sheenRoughnessMatrix")
}
,
i.PrepareUniformBuffer = function(e) {
e.addUniform("vSheenColor", 4),
e.addUniform("vSheenRoughness", 1),
e.addUniform("vSheenInfos", 4),
e.addUniform("sheenMatrix", 16),
e.addUniform("sheenRoughnessMatrix", 16)
}
,
i.AddSamplers = function(e) {
e.push("sheenSampler"),
e.push("sheenRoughnessSampler")
}
,
i.prototype.copyTo = function(e) {
SerializationHelper.Clone(function() {
return e
}, this)
}
,
i.prototype.serialize = function() {
return SerializationHelper.Serialize(this)
}
,
i.prototype.parse = function(e, t, r) {
var n = this;
SerializationHelper.Parse(function() {
return n
}, e, t, r)
}
,
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "isEnabled", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "linkSheenWithAlbedo", void 0),
__decorate([serialize()], i.prototype, "intensity", void 0),
__decorate([serializeAsColor3()], i.prototype, "color", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "texture", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "useRoughnessFromMainTexture", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "roughness", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "textureRoughness", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "albedoScaling", void 0),
i
}()
, PBRSubSurfaceConfiguration = function() {
function i(e, t, r) {
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.useAlbedoToTintTranslucency = !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.useThicknessAsDepth = !1,
this.tintColor = Color3.White(),
this.tintColorAtDistance = 1,
this.diffusionDistance = Color3.White(),
this._useMaskFromThicknessTexture = !1,
this.useMaskFromThicknessTexture = !1,
this._refractionIntensityTexture = null,
this.refractionIntensityTexture = null,
this._translucencyIntensityTexture = null,
this.translucencyIntensityTexture = null,
this._useGltfStyleTextures = !1,
this.useGltfStyleTextures = !1,
this._internalMarkAllSubMeshesAsTexturesDirty = e,
this._internalMarkScenePrePassDirty = t,
this._scene = r
}
return Object.defineProperty(i.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(i.prototype, "volumeIndexOfRefraction", {
get: function() {
return this._volumeIndexOfRefraction >= 1 ? this._volumeIndexOfRefraction : this._indexOfRefraction
},
set: function(e) {
e >= 1 ? this._volumeIndexOfRefraction = e : this._volumeIndexOfRefraction = -1
},
enumerable: !1,
configurable: !0
}),
i.prototype._markAllSubMeshesAsTexturesDirty = function() {
this._internalMarkAllSubMeshesAsTexturesDirty()
}
,
i.prototype._markScenePrePassDirty = function() {
this._internalMarkAllSubMeshesAsTexturesDirty(),
this._internalMarkScenePrePassDirty()
}
,
i.prototype.isReadyForSubMesh = function(e, t) {
if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
return !0;
if (e._areTexturesDirty && t.texturesEnabled) {
if (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking())
return !1;
var r = this._getRefractionTexture(t);
if (r && MaterialFlags.RefractionTextureEnabled && !r.isReadyOrNotBlocking())
return !1
}
return !0
}
,
i.prototype.prepareDefines = function(e, t) {
if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled) {
e.SUBSURFACE = !1,
e.SS_TRANSLUCENCY = !1,
e.SS_SCATTERING = !1,
e.SS_REFRACTION = !1;
return
}
if (e._areTexturesDirty) {
if (e.SUBSURFACE = !1,
e.SS_TRANSLUCENCY = this._isTranslucencyEnabled,
e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1,
e.SS_SCATTERING = this._isScatteringEnabled,
e.SS_THICKNESSANDMASK_TEXTURE = !1,
e.SS_REFRACTIONINTENSITY_TEXTURE = !1,
e.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1,
e.SS_HAS_THICKNESS = !1,
e.SS_MASK_FROM_THICKNESS_TEXTURE = !1,
e.SS_USE_GLTF_TEXTURES = !1,
e.SS_REFRACTION = !1,
e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !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,
e.SS_ALBEDOFORTRANSLUCENCYTINT = !1,
e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
e.SS_USE_THICKNESS_AS_DEPTH = !1,
this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
e.SUBSURFACE = !0;
var r = !!this._thicknessTexture && !!this._refractionIntensityTexture && this._refractionIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._refractionIntensityTexture._texture === this._thicknessTexture._texture
, n = !!this._thicknessTexture && !!this._translucencyIntensityTexture && this._translucencyIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._translucencyIntensityTexture._texture === this._thicknessTexture._texture
, o = (r || !this._refractionIntensityTexture) && (n || !this._translucencyIntensityTexture);
e._areTexturesDirty && t.texturesEnabled && (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && MaterialHelper.PrepareDefinesForMergedUV(this._thicknessTexture, e, "SS_THICKNESSANDMASK_TEXTURE"),
this._refractionIntensityTexture && MaterialFlags.RefractionIntensityTextureEnabled && !o && MaterialHelper.PrepareDefinesForMergedUV(this._refractionIntensityTexture, e, "SS_REFRACTIONINTENSITY_TEXTURE"),
this._translucencyIntensityTexture && MaterialFlags.TranslucencyIntensityTextureEnabled && !o && MaterialHelper.PrepareDefinesForMergedUV(this._translucencyIntensityTexture, e, "SS_TRANSLUCENCYINTENSITY_TEXTURE")),
e.SS_HAS_THICKNESS = this.maximumThickness - this.minimumThickness !== 0,
e.SS_MASK_FROM_THICKNESS_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture || !!this._translucencyIntensityTexture) && o,
e.SS_USE_GLTF_TEXTURES = this._useGltfStyleTextures,
e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture) && o,
e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._translucencyIntensityTexture) && o
}
if (this._isRefractionEnabled && t.texturesEnabled) {
var a = this._getRefractionTexture(t);
a && MaterialFlags.RefractionTextureEnabled && (e.SS_REFRACTION = !0,
e.SS_REFRACTIONMAP_3D = a.isCube,
e.SS_GAMMAREFRACTION = a.gammaSpace,
e.SS_RGBDREFRACTION = a.isRGBD,
e.SS_LINEARSPECULARREFRACTION = a.linearSpecularLOD,
e.SS_REFRACTIONMAP_OPPOSITEZ = a.invertZ,
e.SS_LODINREFRACTIONALPHA = a.lodLevelInAlpha,
e.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency,
e.SS_ALBEDOFORREFRACTIONTINT = this.useAlbedoToTintRefraction,
e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = a.isCube && a.boundingBoxSize,
e.SS_USE_THICKNESS_AS_DEPTH = this.useThicknessAsDepth)
}
this._isTranslucencyEnabled && (e.SS_ALBEDOFORTRANSLUCENCYTINT = this.useAlbedoToTintTranslucency)
}
}
,
i.prototype.hardBindForSubMesh = function(e, t, r, n, o, a, s) {
if (!(!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)) {
s.getRenderingMesh().getWorldMatrix().decompose(TmpVectors.Vector3[0]);
var l = Math.max(Math.abs(TmpVectors.Vector3[0].x), Math.abs(TmpVectors.Vector3[0].y), Math.abs(TmpVectors.Vector3[0].z));
e.updateFloat2("vThicknessParam", this.minimumThickness * l, (this.maximumThickness - this.minimumThickness) * l)
}
}
,
i.prototype.bindForSubMesh = function(e, t, r, n, o, a, s) {
if (!(!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)) {
var l = s.materialDefines
, u = this._getRefractionTexture(t);
if (!e.useUbo || !n || !e.isSync) {
if (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && (e.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level),
MaterialHelper.BindTextureMatrix(this._thicknessTexture, e, "thickness")),
this._refractionIntensityTexture && MaterialFlags.RefractionIntensityTextureEnabled && l.SS_REFRACTIONINTENSITY_TEXTURE && (e.updateFloat2("vRefractionIntensityInfos", this._refractionIntensityTexture.coordinatesIndex, this._refractionIntensityTexture.level),
MaterialHelper.BindTextureMatrix(this._refractionIntensityTexture, e, "refractionIntensity")),
this._translucencyIntensityTexture && MaterialFlags.TranslucencyIntensityTextureEnabled && l.SS_TRANSLUCENCYINTENSITY_TEXTURE && (e.updateFloat2("vTranslucencyIntensityInfos", this._translucencyIntensityTexture.coordinatesIndex, this._translucencyIntensityTexture.level),
MaterialHelper.BindTextureMatrix(this._translucencyIntensityTexture, e, "translucencyIntensity")),
u && MaterialFlags.RefractionTextureEnabled) {
e.updateMatrix("refractionMatrix", u.getReflectionTextureMatrix());
var c = 1;
u.isCube || u.depth && (c = u.depth);
var h = u.getSize().width
, f = this.volumeIndexOfRefraction;
if (e.updateFloat4("vRefractionInfos", u.level, 1 / f, c, this._invertRefractionY ? -1 : 1),
e.updateFloat4("vRefractionMicrosurfaceInfos", h, u.lodGenerationScale, u.lodGenerationOffset, 1 / this.indexOfRefraction),
a && e.updateFloat2("vRefractionFilteringInfo", h, Scalar.Log2(h)),
u.boundingBoxSize) {
var d = u;
e.updateVector3("vRefractionPosition", d.boundingBoxPosition),
e.updateVector3("vRefractionSize", d.boundingBoxSize)
}
}
this.isScatteringEnabled && e.updateFloat("scatteringDiffusionProfile", this._scatteringDiffusionProfileIndex),
e.updateColor3("vDiffusionDistance", this.diffusionDistance),
e.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintColorAtDistance)),
e.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, 0)
}
t.texturesEnabled && (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && e.setTexture("thicknessSampler", this._thicknessTexture),
this._refractionIntensityTexture && MaterialFlags.RefractionIntensityTextureEnabled && l.SS_REFRACTIONINTENSITY_TEXTURE && e.setTexture("refractionIntensitySampler", this._refractionIntensityTexture),
this._translucencyIntensityTexture && MaterialFlags.TranslucencyIntensityTextureEnabled && l.SS_TRANSLUCENCYINTENSITY_TEXTURE && e.setTexture("translucencyIntensitySampler", this._translucencyIntensityTexture),
u && MaterialFlags.RefractionTextureEnabled && (o ? e.setTexture("refractionSampler", u) : (e.setTexture("refractionSampler", u._lodTextureMid || u),
e.setTexture("refractionSamplerLow", u._lodTextureLow || u),
e.setTexture("refractionSamplerHigh", u._lodTextureHigh || u))))
}
}
,
i.prototype.unbind = function(e) {
return this._refractionTexture && this._refractionTexture.isRenderTarget ? (e.setTexture("refractionSampler", null),
!0) : !1
}
,
i.prototype._getRefractionTexture = function(e) {
return this._refractionTexture ? this._refractionTexture : this._isRefractionEnabled ? e.environmentTexture : null
}
,
Object.defineProperty(i.prototype, "disableAlphaBlending", {
get: function() {
return this.isRefractionEnabled && this._linkRefractionWithTransparency
},
enumerable: !1,
configurable: !0
}),
i.prototype.fillRenderTargetTextures = function(e) {
MaterialFlags.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget && e.push(this._refractionTexture)
}
,
i.prototype.hasTexture = function(e) {
return this._thicknessTexture === e || this._refractionTexture === e
}
,
i.prototype.hasRenderTargetTextures = function() {
return !!(MaterialFlags.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget)
}
,
i.prototype.getActiveTextures = function(e) {
this._thicknessTexture && e.push(this._thicknessTexture),
this._refractionTexture && e.push(this._refractionTexture)
}
,
i.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)
}
,
i.prototype.dispose = function(e) {
e && (this._thicknessTexture && this._thicknessTexture.dispose(),
this._refractionTexture && this._refractionTexture.dispose())
}
,
i.prototype.getClassName = function() {
return "PBRSubSurfaceConfiguration"
}
,
i.AddFallbacks = function(e, t, r) {
return e.SS_SCATTERING && t.addFallback(r++, "SS_SCATTERING"),
e.SS_TRANSLUCENCY && t.addFallback(r++, "SS_TRANSLUCENCY"),
r
}
,
i.AddUniforms = function(e) {
e.push("vDiffusionDistance", "vTintColor", "vSubSurfaceIntensity", "vRefractionMicrosurfaceInfos", "vRefractionFilteringInfo", "vRefractionInfos", "vThicknessInfos", "vRefractionIntensityInfos", "vTranslucencyIntensityInfos", "vThicknessParam", "vRefractionPosition", "vRefractionSize", "refractionMatrix", "thicknessMatrix", "refractionIntensityMatrix", "translucencyIntensityMatrix", "scatteringDiffusionProfile")
}
,
i.AddSamplers = function(e) {
e.push("thicknessSampler", "refractionIntensitySampler", "translucencyIntensitySampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh")
}
,
i.PrepareUniformBuffer = function(e) {
e.addUniform("vRefractionMicrosurfaceInfos", 4),
e.addUniform("vRefractionFilteringInfo", 2),
e.addUniform("vTranslucencyIntensityInfos", 2),
e.addUniform("vRefractionInfos", 4),
e.addUniform("refractionMatrix", 16),
e.addUniform("vThicknessInfos", 2),
e.addUniform("vRefractionIntensityInfos", 2),
e.addUniform("thicknessMatrix", 16),
e.addUniform("refractionIntensityMatrix", 16),
e.addUniform("translucencyIntensityMatrix", 16),
e.addUniform("vThicknessParam", 2),
e.addUniform("vDiffusionDistance", 3),
e.addUniform("vTintColor", 4),
e.addUniform("vSubSurfaceIntensity", 3),
e.addUniform("vRefractionPosition", 3),
e.addUniform("vRefractionSize", 3),
e.addUniform("scatteringDiffusionProfile", 1)
}
,
i.prototype.copyTo = function(e) {
SerializationHelper.Clone(function() {
return e
}, this)
}
,
i.prototype.serialize = function() {
return SerializationHelper.Serialize(this)
}
,
i.prototype.parse = function(e, t, r) {
var n = this;
SerializationHelper.Parse(function() {
return n
}, e, t, r)
}
,
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "isRefractionEnabled", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "isTranslucencyEnabled", void 0),
__decorate([serialize(), expandToProperty("_markScenePrePassDirty")], i.prototype, "isScatteringEnabled", void 0),
__decorate([serialize()], i.prototype, "_scatteringDiffusionProfileIndex", void 0),
__decorate([serialize()], i.prototype, "refractionIntensity", void 0),
__decorate([serialize()], i.prototype, "translucencyIntensity", void 0),
__decorate([serialize()], i.prototype, "useAlbedoToTintRefraction", void 0),
__decorate([serialize()], i.prototype, "useAlbedoToTintTranslucency", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "thicknessTexture", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "refractionTexture", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "indexOfRefraction", void 0),
__decorate([serialize()], i.prototype, "_volumeIndexOfRefraction", void 0),
__decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "volumeIndexOfRefraction", null),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "invertRefractionY", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "linkRefractionWithTransparency", void 0),
__decorate([serialize()], i.prototype, "minimumThickness", void 0),
__decorate([serialize()], i.prototype, "maximumThickness", void 0),
__decorate([serialize()], i.prototype, "useThicknessAsDepth", void 0),
__decorate([serializeAsColor3()], i.prototype, "tintColor", void 0),
__decorate([serialize()], i.prototype, "tintColorAtDistance", void 0),
__decorate([serializeAsColor3()], i.prototype, "diffusionDistance", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "useMaskFromThicknessTexture", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "refractionIntensityTexture", void 0),
__decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "translucencyIntensityTexture", void 0),
__decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], i.prototype, "useGltfStyleTextures", void 0),
i
}()
, SH3ylmBasisConstants = [Math.sqrt(1 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(3 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(15 / (4 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(5 / (16 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(15 / (16 * Math.PI))]
, SH3ylmBasisTrigonometricTerms = [function(i) {
return 1
}
, function(i) {
return i.y
}
, function(i) {
return i.z
}
, function(i) {
return i.x
}
, function(i) {
return i.x * i.y
}
, function(i) {
return i.y * i.z
}
, function(i) {
return 3 * i.z * i.z - 1
}
, function(i) {
return i.x * i.z
}
, function(i) {
return i.x * i.x - i.y * i.y
}
]
, applySH3 = function(i, e) {
return SH3ylmBasisConstants[i] * SH3ylmBasisTrigonometricTerms[i](e)
}
, SHCosKernelConvolution = [Math.PI, 2 * Math.PI / 3, 2 * Math.PI / 3, 2 * Math.PI / 3, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4]
, SphericalHarmonics = function() {
function i() {
this.preScaled = !1,
this.l00 = Vector3.Zero(),
this.l1_1 = Vector3.Zero(),
this.l10 = Vector3.Zero(),
this.l11 = Vector3.Zero(),
this.l2_2 = Vector3.Zero(),
this.l2_1 = Vector3.Zero(),
this.l20 = Vector3.Zero(),
this.l21 = Vector3.Zero(),
this.l22 = Vector3.Zero()
}
return i.prototype.addLight = function(e, t, r) {
TmpVectors.Vector3[0].set(t.r, t.g, t.b);
var n = TmpVectors.Vector3[0]
, o = TmpVectors.Vector3[1];
n.scaleToRef(r, o),
o.scaleToRef(applySH3(0, e), TmpVectors.Vector3[2]),
this.l00.addInPlace(TmpVectors.Vector3[2]),
o.scaleToRef(applySH3(1, e), TmpVectors.Vector3[2]),
this.l1_1.addInPlace(TmpVectors.Vector3[2]),
o.scaleToRef(applySH3(2, e), TmpVectors.Vector3[2]),
this.l10.addInPlace(TmpVectors.Vector3[2]),
o.scaleToRef(applySH3(3, e), TmpVectors.Vector3[2]),
this.l11.addInPlace(TmpVectors.Vector3[2]),
o.scaleToRef(applySH3(4, e), TmpVectors.Vector3[2]),
this.l2_2.addInPlace(TmpVectors.Vector3[2]),
o.scaleToRef(applySH3(5, e), TmpVectors.Vector3[2]),
this.l2_1.addInPlace(TmpVectors.Vector3[2]),
o.scaleToRef(applySH3(6, e), TmpVectors.Vector3[2]),
this.l20.addInPlace(TmpVectors.Vector3[2]),
o.scaleToRef(applySH3(7, e), TmpVectors.Vector3[2]),
this.l21.addInPlace(TmpVectors.Vector3[2]),
o.scaleToRef(applySH3(8, e), TmpVectors.Vector3[2]),
this.l22.addInPlace(TmpVectors.Vector3[2])
}
,
i.prototype.scaleInPlace = function(e) {
this.l00.scaleInPlace(e),
this.l1_1.scaleInPlace(e),
this.l10.scaleInPlace(e),
this.l11.scaleInPlace(e),
this.l2_2.scaleInPlace(e),
this.l2_1.scaleInPlace(e),
this.l20.scaleInPlace(e),
this.l21.scaleInPlace(e),
this.l22.scaleInPlace(e)
}
,
i.prototype.convertIncidentRadianceToIrradiance = function() {
this.l00.scaleInPlace(SHCosKernelConvolution[0]),
this.l1_1.scaleInPlace(SHCosKernelConvolution[1]),
this.l10.scaleInPlace(SHCosKernelConvolution[2]),
this.l11.scaleInPlace(SHCosKernelConvolution[3]),
this.l2_2.scaleInPlace(SHCosKernelConvolution[4]),
this.l2_1.scaleInPlace(SHCosKernelConvolution[5]),
this.l20.scaleInPlace(SHCosKernelConvolution[6]),
this.l21.scaleInPlace(SHCosKernelConvolution[7]),
this.l22.scaleInPlace(SHCosKernelConvolution[8])
}
,
i.prototype.convertIrradianceToLambertianRadiance = function() {
this.scaleInPlace(1 / Math.PI)
}
,
i.prototype.preScaleForRendering = function() {
this.preScaled = !0,
this.l00.scaleInPlace(SH3ylmBasisConstants[0]),
this.l1_1.scaleInPlace(SH3ylmBasisConstants[1]),
this.l10.scaleInPlace(SH3ylmBasisConstants[2]),
this.l11.scaleInPlace(SH3ylmBasisConstants[3]),
this.l2_2.scaleInPlace(SH3ylmBasisConstants[4]),
this.l2_1.scaleInPlace(SH3ylmBasisConstants[5]),
this.l20.scaleInPlace(SH3ylmBasisConstants[6]),
this.l21.scaleInPlace(SH3ylmBasisConstants[7]),
this.l22.scaleInPlace(SH3ylmBasisConstants[8])
}
,
i.prototype.updateFromArray = function(e) {
return Vector3.FromArrayToRef(e[0], 0, this.l00),
Vector3.FromArrayToRef(e[1], 0, this.l1_1),
Vector3.FromArrayToRef(e[2], 0, this.l10),
Vector3.FromArrayToRef(e[3], 0, this.l11),
Vector3.FromArrayToRef(e[4], 0, this.l2_2),
Vector3.FromArrayToRef(e[5], 0, this.l2_1),
Vector3.FromArrayToRef(e[6], 0, this.l20),
Vector3.FromArrayToRef(e[7], 0, this.l21),
Vector3.FromArrayToRef(e[8], 0, this.l22),
this
}
,
i.prototype.updateFromFloatsArray = function(e) {
return Vector3.FromFloatsToRef(e[0], e[1], e[2], this.l00),
Vector3.FromFloatsToRef(e[3], e[4], e[5], this.l1_1),
Vector3.FromFloatsToRef(e[6], e[7], e[8], this.l10),
Vector3.FromFloatsToRef(e[9], e[10], e[11], this.l11),
Vector3.FromFloatsToRef(e[12], e[13], e[14], this.l2_2),
Vector3.FromFloatsToRef(e[15], e[16], e[17], this.l2_1),
Vector3.FromFloatsToRef(e[18], e[19], e[20], this.l20),
Vector3.FromFloatsToRef(e[21], e[22], e[23], this.l21),
Vector3.FromFloatsToRef(e[24], e[25], e[26], this.l22),
this
}
,
i.FromArray = function(e) {
var t = new i;
return t.updateFromArray(e)
}
,
i.FromPolynomial = function(e) {
var t = new i;
return t.l00 = e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),
t.l1_1 = e.y.scale(.977204),
t.l10 = e.z.scale(.977204),
t.l11 = e.x.scale(.977204),
t.l2_2 = e.xy.scale(1.16538),
t.l2_1 = e.yz.scale(1.16538),
t.l20 = e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),
t.l21 = e.zx.scale(1.16538),
t.l22 = e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),
t.l1_1.scaleInPlace(-1),
t.l11.scaleInPlace(-1),
t.l2_1.scaleInPlace(-1),
t.l21.scaleInPlace(-1),
t.scaleInPlace(Math.PI),
t
}
,
i
}()
, SphericalPolynomial = function() {
function i() {
this.x = Vector3.Zero(),
this.y = Vector3.Zero(),
this.z = Vector3.Zero(),
this.xx = Vector3.Zero(),
this.yy = Vector3.Zero(),
this.zz = Vector3.Zero(),
this.xy = Vector3.Zero(),
this.yz = Vector3.Zero(),
this.zx = Vector3.Zero()
}
return Object.defineProperty(i.prototype, "preScaledHarmonics", {
get: function() {
return this._harmonics || (this._harmonics = SphericalHarmonics.FromPolynomial(this)),
this._harmonics.preScaled || this._harmonics.preScaleForRendering(),
this._harmonics
},
enumerable: !1,
configurable: !0
}),
i.prototype.addAmbient = function(e) {
TmpVectors.Vector3[0].copyFromFloats(e.r, e.g, e.b);
var t = TmpVectors.Vector3[0];
this.xx.addInPlace(t),
this.yy.addInPlace(t),
this.zz.addInPlace(t)
}
,
i.prototype.scaleInPlace = function(e) {
this.x.scaleInPlace(e),
this.y.scaleInPlace(e),
this.z.scaleInPlace(e),
this.xx.scaleInPlace(e),
this.yy.scaleInPlace(e),
this.zz.scaleInPlace(e),
this.yz.scaleInPlace(e),
this.zx.scaleInPlace(e),
this.xy.scaleInPlace(e)
}
,
i.prototype.updateFromHarmonics = function(e) {
return this._harmonics = e,
this.x.copyFrom(e.l11),
this.x.scaleInPlace(1.02333).scaleInPlace(-1),
this.y.copyFrom(e.l1_1),
this.y.scaleInPlace(1.02333).scaleInPlace(-1),
this.z.copyFrom(e.l10),
this.z.scaleInPlace(1.02333),
this.xx.copyFrom(e.l00),
TmpVectors.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),
TmpVectors.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),
this.xx.scaleInPlace(.886277).subtractInPlace(TmpVectors.Vector3[0]).addInPlace(TmpVectors.Vector3[1]),
this.yy.copyFrom(e.l00),
this.yy.scaleInPlace(.886277).subtractInPlace(TmpVectors.Vector3[0]).subtractInPlace(TmpVectors.Vector3[1]),
this.zz.copyFrom(e.l00),
TmpVectors.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),
this.zz.scaleInPlace(.886277).addInPlace(TmpVectors.Vector3[0]),
this.yz.copyFrom(e.l2_1),
this.yz.scaleInPlace(.858086).scaleInPlace(-1),
this.zx.copyFrom(e.l21),
this.zx.scaleInPlace(.858086).scaleInPlace(-1),
this.xy.copyFrom(e.l2_2),
this.xy.scaleInPlace(.858086),
this.scaleInPlace(1 / Math.PI),
this
}
,
i.FromHarmonics = function(e) {
var t = new i;
return t.updateFromHarmonics(e)
}
,
i.FromArray = function(e) {
var t = new i;
return Vector3.FromArrayToRef(e[0], 0, t.x),
Vector3.FromArrayToRef(e[1], 0, t.y),
Vector3.FromArrayToRef(e[2], 0, t.z),
Vector3.FromArrayToRef(e[3], 0, t.xx),
Vector3.FromArrayToRef(e[4], 0, t.yy),
Vector3.FromArrayToRef(e[5], 0, t.zz),
Vector3.FromArrayToRef(e[6], 0, t.yz),
Vector3.FromArrayToRef(e[7], 0, t.zx),
Vector3.FromArrayToRef(e[8], 0, t.xy),
t
}
,
i
}()
, FileFaceOrientation = function() {
function i(e, t, r, n) {
this.name = e,
this.worldAxisForNormal = t,
this.worldAxisForFileX = r,
this.worldAxisForFileY = n
}
return i
}()
, CubeMapToSphericalPolynomialTools = function() {
function i() {}
return i.ConvertCubeMapTextureToSphericalPolynomial = function(e) {
var t = this, r;
if (!e.isCube)
return null;
(r = e.getScene()) === null || r === void 0 || r.getEngine().flushFramebuffer();
var n = e.getSize().width, o = e.readPixels(0, void 0, void 0, !1), a = e.readPixels(1, void 0, void 0, !1), s, l;
e.isRenderTarget ? (s = e.readPixels(3, void 0, void 0, !1),
l = e.readPixels(2, void 0, void 0, !1)) : (s = e.readPixels(2, void 0, void 0, !1),
l = e.readPixels(3, void 0, void 0, !1));
var u = e.readPixels(4, void 0, void 0, !1)
, c = e.readPixels(5, void 0, void 0, !1)
, h = e.gammaSpace
, f = 5
, d = 0;
return (e.textureType == 1 || e.textureType == 2) && (d = 1),
new Promise(function(_, g) {
Promise.all([a, o, s, l, u, c]).then(function(m) {
var v = m[0]
, y = m[1]
, b = m[2]
, T = m[3]
, C = m[4]
, A = m[5]
, S = {
size: n,
right: y,
left: v,
up: b,
down: T,
front: C,
back: A,
format: f,
type: d,
gammaSpace: h
};
_(t.ConvertCubeMapToSphericalPolynomial(S))
})
}
)
}
,
i.ConvertCubeMapToSphericalPolynomial = function(e) {
for (var t = new SphericalHarmonics, r = 0, n = 2 / e.size, o = n, a = n * .5 - 1, s = 0; s < 6; s++)
for (var l = this.FileFaces[s], u = e[l.name], c = a, h = e.format === 5 ? 4 : 3, f = 0; f < e.size; f++) {
for (var d = a, _ = 0; _ < e.size; _++) {
var g = l.worldAxisForFileX.scale(d).add(l.worldAxisForFileY.scale(c)).add(l.worldAxisForNormal);
g.normalize();
var m = Math.pow(1 + d * d + c * c, -3 / 2)
, v = u[f * e.size * h + _ * h + 0]
, y = u[f * e.size * h + _ * h + 1]
, b = u[f * e.size * h + _ * h + 2];
isNaN(v) && (v = 0),
isNaN(y) && (y = 0),
isNaN(b) && (b = 0),
e.type === 0 && (v /= 255,
y /= 255,
b /= 255),
e.gammaSpace && (v = Math.pow(Scalar.Clamp(v), ToLinearSpace),
y = Math.pow(Scalar.Clamp(y), ToLinearSpace),
b = Math.pow(Scalar.Clamp(b), ToLinearSpace));
var T = 4096;
v = Scalar.Clamp(v, 0, T),
y = Scalar.Clamp(y, 0, T),
b = Scalar.Clamp(b, 0, T);
var C = new Color3(v,y,b);
t.addLight(g, C, m),
r += m,
d += n
}
c += o
}
var A = 4 * Math.PI
, S = 6
, P = A * S / 6
, R = P / r;
return t.scaleInPlace(R),
t.convertIncidentRadianceToIrradiance(),
t.convertIrradianceToLambertianRadiance(),
SphericalPolynomial.FromHarmonics(t)
}
,
i.FileFaces = [new FileFaceOrientation("right",new Vector3(1,0,0),new Vector3(0,0,-1),new Vector3(0,-1,0)), new FileFaceOrientation("left",new Vector3(-1,0,0),new Vector3(0,0,1),new Vector3(0,-1,0)), new FileFaceOrientation("up",new Vector3(0,1,0),new Vector3(1,0,0),new Vector3(0,0,1)), new FileFaceOrientation("down",new Vector3(0,-1,0),new Vector3(1,0,0),new Vector3(0,0,-1)), new FileFaceOrientation("front",new Vector3(0,0,1),new Vector3(1,0,0),new Vector3(0,-1,0)), new FileFaceOrientation("back",new Vector3(0,0,-1),new Vector3(-1,0,0),new Vector3(0,-1,0))],
i
}();
BaseTexture.prototype.forceSphericalPolynomialsRecompute = function() {
this._texture && (this._texture._sphericalPolynomial = null,
this._texture._sphericalPolynomialPromise = null,
this._texture._sphericalPolynomialComputed = !1)
}
;
Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
get: function() {
var i = this;
if (this._texture) {
if (this._texture._sphericalPolynomial || this._texture._sphericalPolynomialComputed)
return this._texture._sphericalPolynomial;
if (this._texture.isReady)
return this._texture._sphericalPolynomialPromise || (this._texture._sphericalPolynomialPromise = CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial(this),
this._texture._sphericalPolynomialPromise === null ? this._texture._sphericalPolynomialComputed = !0 : this._texture._sphericalPolynomialPromise.then(function(e) {
i._texture._sphericalPolynomial = e,
i._texture._sphericalPolynomialComputed = !0
})),
null
}
return null
},
set: function(i) {
this._texture && (this._texture._sphericalPolynomial = i)
},
enumerable: !0,
configurable: !0
});
var name$1w = "pbrFragmentDeclaration"
, shader$1w = `uniform vec4 vEyePosition;
uniform vec3 vReflectionColor;
uniform vec4 vAlbedoColor;
uniform vec4 vLightingIntensity;
uniform vec4 vReflectivityColor;
uniform vec4 vMetallicReflectanceFactors;
uniform vec3 vEmissiveColor;
uniform float visibility;
uniform vec3 vAmbientColor;
#ifdef ALBEDO
uniform vec2 vAlbedoInfos;
#endif
#ifdef AMBIENT
uniform vec4 vAmbientInfos;
#endif
#ifdef BUMP
uniform vec3 vBumpInfos;
uniform vec2 vTangentSpaceParams;
#endif
#ifdef OPACITY
uniform vec2 vOpacityInfos;
#endif
#ifdef EMISSIVE
uniform vec2 vEmissiveInfos;
#endif
#ifdef LIGHTMAP
uniform vec2 vLightmapInfos;
#endif
#ifdef REFLECTIVITY
uniform vec3 vReflectivityInfos;
#endif
#ifdef MICROSURFACEMAP
uniform vec2 vMicroSurfaceSamplerInfos;
#endif
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)
uniform mat4 view;
#endif
#ifdef REFLECTION
uniform vec2 vReflectionInfos;
#ifdef REALTIME_FILTERING
uniform vec2 vReflectionFilteringInfo;
#endif
uniform mat4 reflectionMatrix;
uniform vec3 vReflectionMicrosurfaceInfos;
#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
uniform vec3 vReflectionPosition;
uniform vec3 vReflectionSize;
#endif
#endif
#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)
uniform vec3 vRefractionPosition;
uniform vec3 vRefractionSize;
#endif
#ifdef CLEARCOAT
uniform vec2 vClearCoatParams;
uniform vec4 vClearCoatRefractionParams;
#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
uniform vec4 vClearCoatInfos;
#endif
#ifdef CLEARCOAT_TEXTURE
uniform mat4 clearCoatMatrix;
#endif
#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
uniform mat4 clearCoatRoughnessMatrix;
#endif
#ifdef CLEARCOAT_BUMP
uniform vec2 vClearCoatBumpInfos;
uniform vec2 vClearCoatTangentSpaceParams;
uniform mat4 clearCoatBumpMatrix;
#endif
#ifdef CLEARCOAT_TINT
uniform vec4 vClearCoatTintParams;
uniform float clearCoatColorAtDistance;
#ifdef CLEARCOAT_TINT_TEXTURE
uniform vec2 vClearCoatTintInfos;
uniform mat4 clearCoatTintMatrix;
#endif
#endif
#endif
#ifdef ANISOTROPIC
uniform vec3 vAnisotropy;
#ifdef ANISOTROPIC_TEXTURE
uniform vec2 vAnisotropyInfos;
uniform mat4 anisotropyMatrix;
#endif
#endif
#ifdef SHEEN
uniform vec4 vSheenColor;
#ifdef SHEEN_ROUGHNESS
uniform float vSheenRoughness;
#endif
#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
uniform vec4 vSheenInfos;
#endif
#ifdef SHEEN_TEXTURE
uniform mat4 sheenMatrix;
#endif
#ifdef SHEEN_TEXTURE_ROUGHNESS
uniform mat4 sheenRoughnessMatrix;
#endif
#endif
#ifdef SUBSURFACE
#ifdef SS_REFRACTION
uniform vec4 vRefractionMicrosurfaceInfos;
uniform vec4 vRefractionInfos;
uniform mat4 refractionMatrix;
#ifdef REALTIME_FILTERING
uniform vec2 vRefractionFilteringInfo;
#endif
#endif
#ifdef SS_THICKNESSANDMASK_TEXTURE
uniform vec2 vThicknessInfos;
uniform mat4 thicknessMatrix;
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
uniform vec2 vRefractionIntensityInfos;
uniform mat4 refractionIntensityMatrix;
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
uniform vec2 vTranslucencyIntensityInfos;
uniform mat4 translucencyIntensityMatrix;
#endif
uniform vec2 vThicknessParam;
uniform vec3 vDiffusionDistance;
uniform vec4 vTintColor;
uniform vec3 vSubSurfaceIntensity;
#endif
#ifdef PREPASS
#ifdef SS_SCATTERING
uniform float scatteringDiffusionProfile;
#endif
#endif
#if DEBUGMODE>0
uniform vec2 vDebugMode;
#endif
#ifdef DETAIL
uniform vec4 vDetailInfos;
#endif
#ifdef USESPHERICALFROMREFLECTIONMAP
#ifdef SPHERICAL_HARMONICS
uniform vec3 vSphericalL00;
uniform vec3 vSphericalL1_1;
uniform vec3 vSphericalL10;
uniform vec3 vSphericalL11;
uniform vec3 vSphericalL2_2;
uniform vec3 vSphericalL2_1;
uniform vec3 vSphericalL20;
uniform vec3 vSphericalL21;
uniform vec3 vSphericalL22;
#else
uniform vec3 vSphericalX;
uniform vec3 vSphericalY;
uniform vec3 vSphericalZ;
uniform vec3 vSphericalXX_ZZ;
uniform vec3 vSphericalYY_ZZ;
uniform vec3 vSphericalZZ;
uniform vec3 vSphericalXY;
uniform vec3 vSphericalYZ;
uniform vec3 vSphericalZX;
#endif
#endif
`;
ShaderStore.IncludesShadersStore[name$1w] = shader$1w;
var name$1v = "pbrUboDeclaration"
, shader$1v = `layout(std140,column_major) uniform;
uniform Material {
vec2 vAlbedoInfos;
vec4 vAmbientInfos;
vec2 vOpacityInfos;
vec2 vEmissiveInfos;
vec2 vLightmapInfos;
vec3 vReflectivityInfos;
vec2 vMicroSurfaceSamplerInfos;
vec2 vReflectionInfos;
vec2 vReflectionFilteringInfo;
vec3 vReflectionPosition;
vec3 vReflectionSize;
vec3 vBumpInfos;
mat4 albedoMatrix;
mat4 ambientMatrix;
mat4 opacityMatrix;
mat4 emissiveMatrix;
mat4 lightmapMatrix;
mat4 reflectivityMatrix;
mat4 microSurfaceSamplerMatrix;
mat4 bumpMatrix;
vec2 vTangentSpaceParams;
mat4 reflectionMatrix;
vec3 vReflectionColor;
vec4 vAlbedoColor;
vec4 vLightingIntensity;
vec3 vReflectionMicrosurfaceInfos;
float pointSize;
vec4 vReflectivityColor;
vec3 vEmissiveColor;
vec3 vAmbientColor;
vec2 vDebugMode;
vec4 vMetallicReflectanceFactors;
vec2 vMetallicReflectanceInfos;
mat4 metallicReflectanceMatrix;
vec2 vReflectanceInfos;
mat4 reflectanceMatrix;
vec2 vClearCoatParams;
vec4 vClearCoatRefractionParams;
vec4 vClearCoatInfos;
mat4 clearCoatMatrix;
mat4 clearCoatRoughnessMatrix;
vec2 vClearCoatBumpInfos;
vec2 vClearCoatTangentSpaceParams;
mat4 clearCoatBumpMatrix;
vec4 vClearCoatTintParams;
float clearCoatColorAtDistance;
vec2 vClearCoatTintInfos;
mat4 clearCoatTintMatrix;
vec3 vAnisotropy;
vec2 vAnisotropyInfos;
mat4 anisotropyMatrix;
vec4 vSheenColor;
float vSheenRoughness;
vec4 vSheenInfos;
mat4 sheenMatrix;
mat4 sheenRoughnessMatrix;
vec4 vRefractionMicrosurfaceInfos;
vec2 vRefractionFilteringInfo;
vec2 vTranslucencyIntensityInfos;
vec4 vRefractionInfos;
mat4 refractionMatrix;
vec2 vThicknessInfos;
vec2 vRefractionIntensityInfos;
mat4 thicknessMatrix;
mat4 refractionIntensityMatrix;
mat4 translucencyIntensityMatrix;
vec2 vThicknessParam;
vec3 vDiffusionDistance;
vec4 vTintColor;
vec3 vSubSurfaceIntensity;
vec3 vRefractionPosition;
vec3 vRefractionSize;
float scatteringDiffusionProfile;
vec4 vDetailInfos;
mat4 detailMatrix;
vec3 vSphericalL00;
vec3 vSphericalL1_1;
vec3 vSphericalL10;
vec3 vSphericalL11;
vec3 vSphericalL2_2;
vec3 vSphericalL2_1;
vec3 vSphericalL20;
vec3 vSphericalL21;
vec3 vSphericalL22;
vec3 vSphericalX;
vec3 vSphericalY;
vec3 vSphericalZ;
vec3 vSphericalXX_ZZ;
vec3 vSphericalYY_ZZ;
vec3 vSphericalZZ;
vec3 vSphericalXY;
vec3 vSphericalYZ;
vec3 vSphericalZX;
};
#include
#include
`;
ShaderStore.IncludesShadersStore[name$1v] = shader$1v;
var name$1u = "pbrFragmentExtraDeclaration"
, shader$1u = `
varying vec3 vPositionW;
#if DEBUGMODE>0
varying vec4 vClipSpacePosition;
#endif
#include[1..7]
#ifdef NORMAL
varying vec3 vNormalW;
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
varying vec3 vEnvironmentIrradiance;
#endif
#endif
#ifdef VERTEXCOLOR
varying vec4 vColor;
#endif`;
ShaderStore.IncludesShadersStore[name$1u] = shader$1u;
var name$1t = "samplerFragmentAlternateDeclaration"
, shader$1t = `#ifdef _DEFINENAME_
#if _DEFINENAME_DIRECTUV == 1
#define v_VARYINGNAME_UV vMainUV1
#elif _DEFINENAME_DIRECTUV == 2
#define v_VARYINGNAME_UV vMainUV2
#elif _DEFINENAME_DIRECTUV == 3
#define v_VARYINGNAME_UV vMainUV3
#elif _DEFINENAME_DIRECTUV == 4
#define v_VARYINGNAME_UV vMainUV4
#elif _DEFINENAME_DIRECTUV == 5
#define v_VARYINGNAME_UV vMainUV5
#elif _DEFINENAME_DIRECTUV == 6
#define v_VARYINGNAME_UV vMainUV6
#else
varying vec2 v_VARYINGNAME_UV;
#endif
#endif
`;
ShaderStore.IncludesShadersStore[name$1t] = shader$1t;
var name$1s = "pbrFragmentSamplersDeclaration"
, shader$1s = `#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
#ifdef CLEARCOAT
#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)
uniform sampler2D clearCoatRoughnessSampler;
#endif
#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
#endif
#ifdef SHEEN
#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)
uniform sampler2D sheenRoughnessSampler;
#endif
#endif
#ifdef ANISOTROPIC
#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
#endif
#ifdef REFLECTION
#ifdef REFLECTIONMAP_3D
#define sampleReflection(s,c) textureCube(s,c)
uniform samplerCube reflectionSampler;
#ifdef LODBASEDMICROSFURACE
#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
#else
uniform samplerCube reflectionSamplerLow;
uniform samplerCube reflectionSamplerHigh;
#endif
#ifdef USEIRRADIANCEMAP
uniform samplerCube irradianceSampler;
#endif
#else
#define sampleReflection(s,c) texture2D(s,c)
uniform sampler2D reflectionSampler;
#ifdef LODBASEDMICROSFURACE
#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
#else
uniform sampler2D reflectionSamplerLow;
uniform sampler2D reflectionSamplerHigh;
#endif
#ifdef USEIRRADIANCEMAP
uniform sampler2D irradianceSampler;
#endif
#endif
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#else
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#endif
#endif
#ifdef ENVIRONMENTBRDF
uniform sampler2D environmentBrdfSampler;
#endif
#ifdef SUBSURFACE
#ifdef SS_REFRACTION
#ifdef SS_REFRACTIONMAP_3D
#define sampleRefraction(s,c) textureCube(s,c)
uniform samplerCube refractionSampler;
#ifdef LODBASEDMICROSFURACE
#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
#else
uniform samplerCube refractionSamplerLow;
uniform samplerCube refractionSamplerHigh;
#endif
#else
#define sampleRefraction(s,c) texture2D(s,c)
uniform sampler2D refractionSampler;
#ifdef LODBASEDMICROSFURACE
#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
#else
uniform sampler2D refractionSamplerLow;
uniform sampler2D refractionSamplerHigh;
#endif
#endif
#endif
#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
#endif`;
ShaderStore.IncludesShadersStore[name$1s] = shader$1s;
var name$1r = "subSurfaceScatteringFunctions"
, shader$1r = `bool testLightingForSSS(float diffusionProfile)
{
return diffusionProfile<1.;
}`;
ShaderStore.IncludesShadersStore[name$1r] = shader$1r;
var name$1q = "importanceSampling"
, shader$1q = `
vec3 hemisphereCosSample(vec2 u) {
float phi=2.*PI*u.x;
float cosTheta2=1.-u.y;
float cosTheta=sqrt(cosTheta2);
float sinTheta=sqrt(1.-cosTheta2);
return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
}
vec3 hemisphereImportanceSampleDggx(vec2 u,float a) {
float phi=2.*PI*u.x;
float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));
float cosTheta=sqrt(cosTheta2);
float sinTheta=sqrt(1.-cosTheta2);
return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
}
vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {
float phi=2.*PI*u.x;
float sinTheta=pow(u.y,a/(2.*a+1.));
float cosTheta=sqrt(1.-sinTheta*sinTheta);
return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
}`;
ShaderStore.IncludesShadersStore[name$1q] = shader$1q;
var name$1p = "pbrHelperFunctions"
, shader$1p = `
#define RECIPROCAL_PI2 0.15915494
#define RECIPROCAL_PI 0.31830988618
#define MINIMUMVARIANCE 0.0005
float convertRoughnessToAverageSlope(float roughness)
{
return square(roughness)+MINIMUMVARIANCE;
}
float fresnelGrazingReflectance(float reflectance0) {
float reflectance90=saturate(reflectance0*25.0);
return reflectance90;
}
vec2 getAARoughnessFactors(vec3 normalVector) {
#ifdef SPECULARAA
vec3 nDfdx=dFdx(normalVector.xyz);
vec3 nDfdy=dFdy(normalVector.xyz);
float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));
float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);
float geometricAlphaGFactor=sqrt(slopeSquare);
geometricAlphaGFactor*=0.75;
return vec2(geometricRoughnessFactor,geometricAlphaGFactor);
#else
return vec2(0.);
#endif
}
#ifdef ANISOTROPIC
vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {
float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);
float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);
return vec2(alphaT,alphaB);
}
vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {
vec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;
vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);
vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);
vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));
return anisotropicNormal;
}
#endif
#if defined(CLEARCOAT) || defined(SS_REFRACTION)
vec3 cocaLambert(vec3 alpha,float distance) {
return exp(-alpha*distance);
}
vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {
return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));
}
vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {
return -log(color)/distance;
}
vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
vec3 clearCoatAbsorption=mix(vec3(1.0),
cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
clearCoatIntensity);
return clearCoatAbsorption;
}
#endif
#ifdef MICROSURFACEAUTOMATIC
float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)
{
const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;
float reflectivityLuminance=getLuminance(reflectivityColor);
float reflectivityLuma=sqrt(reflectivityLuminance);
microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;
return microSurface;
}
#endif`;
ShaderStore.IncludesShadersStore[name$1p] = shader$1p;
var name$1o = "harmonicsFunctions"
, shader$1o = `#ifdef USESPHERICALFROMREFLECTIONMAP
#ifdef SPHERICAL_HARMONICS
vec3 computeEnvironmentIrradiance(vec3 normal) {
return vSphericalL00
+vSphericalL1_1*(normal.y)
+vSphericalL10*(normal.z)
+vSphericalL11*(normal.x)
+vSphericalL2_2*(normal.y*normal.x)
+vSphericalL2_1*(normal.y*normal.z)
+vSphericalL20*((3.0*normal.z*normal.z)-1.0)
+vSphericalL21*(normal.z*normal.x)
+vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));
}
#else
vec3 computeEnvironmentIrradiance(vec3 normal) {
float Nx=normal.x;
float Ny=normal.y;
float Nz=normal.z;
vec3 C1=vSphericalZZ.rgb;
vec3 Cx=vSphericalX.rgb;
vec3 Cy=vSphericalY.rgb;
vec3 Cz=vSphericalZ.rgb;
vec3 Cxx_zz=vSphericalXX_ZZ.rgb;
vec3 Cyy_zz=vSphericalYY_ZZ.rgb;
vec3 Cxy=vSphericalXY.rgb;
vec3 Cyz=vSphericalYZ.rgb;
vec3 Czx=vSphericalZX.rgb;
vec3 a1=Cyy_zz*Ny+Cy;
vec3 a2=Cyz*Nz+a1;
vec3 b1=Czx*Nz+Cx;
vec3 b2=Cxy*Ny+b1;
vec3 b3=Cxx_zz*Nx+b2;
vec3 t1=Cz*Nz+C1;
vec3 t2=a2*Ny+t1;
vec3 t3=b3*Nx+t2;
return t3;
}
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$1o] = shader$1o;
var name$1n = "pbrDirectLightingSetupFunctions"
, shader$1n = `
struct preLightingInfo
{
vec3 lightOffset;
float lightDistanceSquared;
float lightDistance;
float attenuation;
vec3 L;
vec3 H;
float NdotV;
float NdotLUnclamped;
float NdotL;
float VdotH;
float roughness;
};
preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
preLightingInfo result;
result.lightOffset=lightData.xyz-vPositionW;
result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);
result.lightDistance=sqrt(result.lightDistanceSquared);
result.L=normalize(result.lightOffset);
result.H=normalize(V+result.L);
result.VdotH=saturate(dot(V,result.H));
result.NdotLUnclamped=dot(N,result.L);
result.NdotL=saturateEps(result.NdotLUnclamped);
return result;
}
preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
preLightingInfo result;
result.lightDistance=length(-lightData.xyz);
result.L=normalize(-lightData.xyz);
result.H=normalize(V+result.L);
result.VdotH=saturate(dot(V,result.H));
result.NdotLUnclamped=dot(N,result.L);
result.NdotL=saturateEps(result.NdotLUnclamped);
return result;
}
preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
preLightingInfo result;
result.NdotL=dot(N,lightData.xyz)*0.5+0.5;
result.NdotL=saturateEps(result.NdotL);
result.NdotLUnclamped=result.NdotL;
#ifdef SPECULARTERM
result.L=normalize(lightData.xyz);
result.H=normalize(V+result.L);
result.VdotH=saturate(dot(V,result.H));
#endif
return result;
}`;
ShaderStore.IncludesShadersStore[name$1n] = shader$1n;
var name$1m = "pbrDirectLightingFalloffFunctions"
, shader$1m = `float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)
{
return max(0.,1.0-length(lightOffset)/range);
}
float computeDistanceLightFalloff_Physical(float lightDistanceSquared)
{
return 1.0/maxEps(lightDistanceSquared);
}
float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)
{
float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);
float factor=lightDistanceSquared*inverseSquaredRange;
float attenuation=saturate(1.0-factor*factor);
attenuation*=attenuation;
lightDistanceFalloff*=attenuation;
return lightDistanceFalloff;
}
float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)
{
#ifdef USEPHYSICALLIGHTFALLOFF
return computeDistanceLightFalloff_Physical(lightDistanceSquared);
#elif defined(USEGLTFLIGHTFALLOFF)
return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
#else
return computeDistanceLightFalloff_Standard(lightOffset,range);
#endif
}
float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)
{
float falloff=0.0;
float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));
if (cosAngle>=cosHalfAngle)
{
falloff=max(0.,pow(cosAngle,exponent));
}
return falloff;
}
float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)
{
const float kMinusLog2ConeAngleIntensityRatio=6.64385618977;
float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);
vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);
float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));
return falloff;
}
float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)
{
float cd=dot(-lightDirection,directionToLightCenterW);
float falloff=saturate(cd*lightAngleScale+lightAngleOffset);
falloff*=falloff;
return falloff;
}
float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)
{
#ifdef USEPHYSICALLIGHTFALLOFF
return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
#elif defined(USEGLTFLIGHTFALLOFF)
return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
#else
return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
#endif
}`;
ShaderStore.IncludesShadersStore[name$1m] = shader$1m;
var name$1l = "pbrBRDFFunctions"
, shader$1l = `
#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
#ifdef MS_BRDF_ENERGY_CONSERVATION
vec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);
}
#endif
#ifdef ENVIRONMENTBRDF
vec3 getBRDFLookup(float NdotV,float perceptualRoughness) {
vec2 UV=vec2(NdotV,perceptualRoughness);
vec4 brdfLookup=texture2D(environmentBrdfSampler,UV);
#ifdef ENVIRONMENTBRDF_RGBD
brdfLookup.rgb=fromRGBD(brdfLookup.rgba);
#endif
return brdfLookup.rgb;
}
vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {
#ifdef BRDF_V_HEIGHT_CORRELATED
vec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
#else
vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
#endif
return reflectance;
}
vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
#ifdef BRDF_V_HEIGHT_CORRELATED
vec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
#else
vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
#endif
return reflectance;
}
#endif
#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
vec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
{
float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);
return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));
}
#endif
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
vec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {
vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;
return sheenEnvironmentReflectance;
}
#endif
vec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)
{
return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
}
float fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)
{
return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
}
#ifdef CLEARCOAT
vec3 getR0RemappedForClearCoat(vec3 f0) {
#ifdef CLEARCOAT_DEFAULTIOR
#ifdef MOBILE
return saturate(f0*(f0*0.526868+0.529324)-0.0482256);
#else
return saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
#endif
#else
vec3 s=sqrt(f0);
vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);
return t*t;
#endif
}
#endif
float normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)
{
float a2=square(alphaG);
float d=NdotH*NdotH*(a2-1.0)+1.0;
return a2/(PI*d*d);
}
#ifdef SHEEN
float normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)
{
float invR=1./alphaG;
float cos2h=NdotH*NdotH;
float sin2h=1.-cos2h;
return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);
}
#endif
#ifdef ANISOTROPIC
float normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {
float a2=alphaTB.x*alphaTB.y;
vec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);
float v2=dot(v,v);
float w2=a2/v2;
return a2*w2*w2*RECIPROCAL_PI;
}
#endif
#ifdef BRDF_V_HEIGHT_CORRELATED
float smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {
#ifdef MOBILE
float GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);
float GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);
return 0.5/(GGXV+GGXL);
#else
float a2=alphaG*alphaG;
float GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);
float GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);
return 0.5/(GGXV+GGXL);
#endif
}
#else
float smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)
{
#ifdef MOBILE
return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
#else
float alphaSquared=alphaG*alphaG;
return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
#endif
}
float smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)
{
float visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);
return visibility;
}
#endif
#ifdef ANISOTROPIC
float smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {
float lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));
float lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));
float v=0.5/(lambdaV+lambdaL);
return v;
}
#endif
#ifdef CLEARCOAT
float visibility_Kelemen(float VdotH) {
return 0.25/(VdotH*VdotH);
}
#endif
#ifdef SHEEN
float visibility_Ashikhmin(float NdotL,float NdotV)
{
return 1./(4.*(NdotL+NdotV-NdotL*NdotV));
}
#endif
float diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {
float diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));
float diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));
float diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;
float fresnel =
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);
return fresnel/PI;
}
#ifdef SS_TRANSLUCENCY
vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {
vec3 S=1./maxEps(diffusionDistance);
vec3 temp=exp((-0.333333333*thickness)*S);
return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);
}
float computeWrappedDiffuseNdotL(float NdotL,float w) {
float t=1.0+w;
float invt2=1.0/square(t);
return saturate((NdotL+w)*invt2);
}
#endif
`;
ShaderStore.IncludesShadersStore[name$1l] = shader$1l;
var name$1k = "hdrFilteringFunctions"
, shader$1k = `#ifdef NUM_SAMPLES
#if NUM_SAMPLES>0
#if defined(WEBGL2) || defined(WEBGPU)
float radicalInverse_VdC(uint bits)
{
bits=(bits << 16u) | (bits >> 16u);
bits=((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
bits=((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
bits=((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
bits=((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
return float(bits)*2.3283064365386963e-10;
}
vec2 hammersley(uint i,uint N)
{
return vec2(float(i)/float(N),radicalInverse_VdC(i));
}
#else
float vanDerCorpus(int n,int base)
{
float invBase=1.0/float(base);
float denom=1.0;
float result=0.0;
for(int i=0; i<32; ++i)
{
if(n>0)
{
denom=mod(float(n),2.0);
result+=denom*invBase;
invBase=invBase/2.0;
n=int(float(n)/2.0);
}
}
return result;
}
vec2 hammersley(int i,int N)
{
return vec2(float(i)/float(N),vanDerCorpus(i,2));
}
#endif
float log4(float x) {
return log2(x)/2.;
}
const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);
const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;
const float K=4.;
#define inline
vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
{
vec3 n=normalize(inputN);
vec3 result=vec3(0.0);
vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
tangent=normalize(cross(tangent,n));
vec3 bitangent=cross(n,tangent);
mat3 tbn=mat3(tangent,bitangent,n);
float maxLevel=filteringInfo.y;
float dim0=filteringInfo.x;
float omegaP=(4.*PI)/(6.*dim0*dim0);
#if defined(WEBGL2) || defined(WEBGPU)
for(uint i=0u; i0.) {
float pdf_inversed=PI/NoL;
float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
float l=log4(omegaS)-log4(omegaP)+log4(K);
float mipLevel=clamp(l,0.0,maxLevel);
vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;
#ifdef GAMMA_INPUT
c=toLinearSpace(c);
#endif
result+=c;
}
}
result=result*NUM_SAMPLES_FLOAT_INVERSED;
return result;
}
#define inline
vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
{
vec3 n=normalize(inputN);
if (alphaG == 0.) {
vec3 c=textureCube(inputTexture,n).rgb;
#ifdef GAMMA_INPUT
c=toLinearSpace(c);
#endif
return c;
} else {
vec3 result=vec3(0.);
vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
tangent=normalize(cross(tangent,n));
vec3 bitangent=cross(n,tangent);
mat3 tbn=mat3(tangent,bitangent,n);
float maxLevel=filteringInfo.y;
float dim0=filteringInfo.x;
float omegaP=(4.*PI)/(6.*dim0*dim0);
float weight=0.;
#if defined(WEBGL2) || defined(WEBGPU)
for(uint i=0u; i0.) {
float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);
float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
float l=log4(omegaS)-log4(omegaP)+log4(K);
float mipLevel=clamp(float(l),0.0,maxLevel);
weight+=NoL;
vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;
#ifdef GAMMA_INPUT
c=toLinearSpace(c);
#endif
result+=c*NoL;
}
}
result=result/weight;
return result;
}
}
#endif
#endif`;
ShaderStore.IncludesShadersStore[name$1k] = shader$1k;
var name$1j = "pbrDirectLightingFunctions"
, shader$1j = `#define CLEARCOATREFLECTANCE90 1.0
struct lightingInfo
{
vec3 diffuse;
#ifdef SPECULARTERM
vec3 specular;
#endif
#ifdef CLEARCOAT
vec4 clearCoat;
#endif
#ifdef SHEEN
vec3 sheen;
#endif
};
float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {
#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
float lightRoughness=lightRadius/lightDistance;
float totalRoughness=saturate(lightRoughness+roughness);
return totalRoughness;
#else
return roughness;
#endif
}
vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {
return mix(groundColor,lightColor,info.NdotL);
}
vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {
float diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);
return diffuseTerm*info.attenuation*info.NdotL*lightColor;
}
#define inline
vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){
vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);
strq/=strq.w;
vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;
return toLinearSpace(textureColor);
}
#ifdef SS_TRANSLUCENCY
vec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {
float NdotL=absEps(info.NdotLUnclamped);
float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);
float trAdapt=step(0.,info.NdotLUnclamped);
vec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);
float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);
return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;
}
#endif
#ifdef SPECULARTERM
vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
float NdotH=saturateEps(dot(N,info.H));
float roughness=max(info.roughness,geometricRoughnessFactor);
float alphaG=convertRoughnessToAverageSlope(roughness);
vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
#ifdef BRDF_V_HEIGHT_CORRELATED
float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
#else
float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
#endif
vec3 specTerm=fresnel*distribution*smithVisibility;
return specTerm*info.attenuation*info.NdotL*lightColor;
}
#endif
#ifdef ANISOTROPIC
vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
float NdotH=saturateEps(dot(N,info.H));
float TdotH=dot(T,info.H);
float BdotH=dot(B,info.H);
float TdotV=dot(T,V);
float BdotV=dot(B,V);
float TdotL=dot(T,info.L);
float BdotL=dot(B,info.L);
float alphaG=convertRoughnessToAverageSlope(info.roughness);
vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);
alphaTB=max(alphaTB,square(geometricRoughnessFactor));
vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);
float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);
vec3 specTerm=fresnel*distribution*smithVisibility;
return specTerm*info.attenuation*info.NdotL*lightColor;
}
#endif
#ifdef CLEARCOAT
vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {
float NccdotL=saturateEps(dot(Ncc,info.L));
float NccdotH=saturateEps(dot(Ncc,info.H));
float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);
float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
fresnel*=clearCoatIntensity;
float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);
float kelemenVisibility=visibility_Kelemen(info.VdotH);
float clearCoatTerm=fresnel*distribution*kelemenVisibility;
return vec4(
clearCoatTerm*info.attenuation*NccdotL*lightColor,
1.0-fresnel
);
}
vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);
float NdotLRefract=saturateEps(dot(Ncc,LRefract));
vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);
return absorption;
}
#endif
#ifdef SHEEN
vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
float NdotH=saturateEps(dot(N,info.H));
float roughness=max(info.roughness,geometricRoughnessFactor);
float alphaG=convertRoughnessToAverageSlope(roughness);
float fresnel=1.;
float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);
float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);
float sheenTerm=fresnel*distribution*visibility;
return sheenTerm*info.attenuation*info.NdotL*lightColor;
}
#endif
`;
ShaderStore.IncludesShadersStore[name$1j] = shader$1j;
var name$1i = "pbrIBLFunctions"
, shader$1i = `#if defined(REFLECTION) || defined(SS_REFRACTION)
float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {
float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;
float lod=log2(microsurfaceAverageSlopeTexels);
return lod;
}
float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {
float lod=log2(cubeMapDimensionPixels)*roughness;
return lod;
}
#endif
#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {
float temp=NdotVUnclamped+ambientOcclusion;
return saturate(square(temp)-1.0+ambientOcclusion);
}
#endif
#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {
vec3 reflection=reflect(view,normal);
float temp=saturate(1.0+1.1*dot(reflection,geometricNormal));
return square(temp);
}
#endif
#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
#define UNPACK_LOD(x) (1.0-x)*255.0
float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {
float microsurfaceAverageSlope=alphaG;
microsurfaceAverageSlope*=sqrt(abs(NdotV));
return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);
}
#endif`;
ShaderStore.IncludesShadersStore[name$1i] = shader$1i;
var name$1h = "pbrBlockAlbedoOpacity"
, shader$1h = `struct albedoOpacityOutParams
{
vec3 surfaceAlbedo;
float alpha;
};
#define pbr_inline
void albedoOpacityBlock(
in vec4 vAlbedoColor,
#ifdef ALBEDO
in vec4 albedoTexture,
in vec2 albedoInfos,
#endif
#ifdef OPACITY
in vec4 opacityMap,
in vec2 vOpacityInfos,
#endif
#ifdef DETAIL
in vec4 detailColor,
in vec4 vDetailInfos,
#endif
out albedoOpacityOutParams outParams
)
{
vec3 surfaceAlbedo=vAlbedoColor.rgb;
float alpha=vAlbedoColor.a;
#ifdef ALBEDO
#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
alpha*=albedoTexture.a;
#endif
#ifdef GAMMAALBEDO
surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
#else
surfaceAlbedo*=albedoTexture.rgb;
#endif
surfaceAlbedo*=albedoInfos.y;
#endif
#ifdef VERTEXCOLOR
surfaceAlbedo*=vColor.rgb;
#endif
#ifdef DETAIL
float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);
surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
#endif
#define CUSTOM_FRAGMENT_UPDATE_ALBEDO
#ifdef OPACITY
#ifdef OPACITYRGB
alpha=getLuminance(opacityMap.rgb);
#else
alpha*=opacityMap.a;
#endif
alpha*=vOpacityInfos.y;
#endif
#ifdef VERTEXALPHA
alpha*=vColor.a;
#endif
#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
#ifdef ALPHATEST
if (alpha0
vec4 surfaceMetallicColorMap;
vec4 surfaceReflectivityColorMap;
vec2 metallicRoughness;
vec3 metallicF0;
#endif
};
#define pbr_inline
void reflectivityBlock(
in vec4 vReflectivityColor,
#ifdef METALLICWORKFLOW
in vec3 surfaceAlbedo,
in vec4 metallicReflectanceFactors,
#endif
#ifdef REFLECTIVITY
in vec3 reflectivityInfos,
in vec4 surfaceMetallicOrReflectivityColorMap,
#endif
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
in vec3 ambientOcclusionColorIn,
#endif
#ifdef MICROSURFACEMAP
in vec4 microSurfaceTexel,
#endif
#ifdef DETAIL
in vec4 detailColor,
in vec4 vDetailInfos,
#endif
out reflectivityOutParams outParams
)
{
float microSurface=vReflectivityColor.a;
vec3 surfaceReflectivityColor=vReflectivityColor.rgb;
#ifdef METALLICWORKFLOW
vec2 metallicRoughness=surfaceReflectivityColor.rg;
#ifdef REFLECTIVITY
#if DEBUGMODE>0
outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
#endif
#ifdef AOSTOREINMETALMAPRED
vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);
outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
#endif
#ifdef METALLNESSSTOREINMETALMAPBLUE
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
#else
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
#endif
#ifdef ROUGHNESSSTOREINMETALMAPALPHA
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
#else
#ifdef ROUGHNESSSTOREINMETALMAPGREEN
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
#endif
#endif
#endif
#ifdef DETAIL
float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);
float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);
float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);
metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
#endif
#ifdef MICROSURFACEMAP
metallicRoughness.g*=microSurfaceTexel.r;
#endif
#if DEBUGMODE>0
outParams.metallicRoughness=metallicRoughness;
#endif
#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
microSurface=1.0-metallicRoughness.g;
vec3 baseColor=surfaceAlbedo;
#ifdef FROSTBITE_REFLECTANCE
outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);
surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
#else
vec3 metallicF0=metallicReflectanceFactors.rgb;
#if DEBUGMODE>0
outParams.metallicF0=metallicF0;
#endif
outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);
surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
#endif
#else
#ifdef REFLECTIVITY
surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
#if DEBUGMODE>0
outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
#endif
#ifdef MICROSURFACEFROMREFLECTIVITYMAP
microSurface*=surfaceMetallicOrReflectivityColorMap.a;
microSurface*=reflectivityInfos.z;
#else
#ifdef MICROSURFACEAUTOMATIC
microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
#endif
#ifdef MICROSURFACEMAP
microSurface*=microSurfaceTexel.r;
#endif
#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
#endif
#endif
#endif
microSurface=saturate(microSurface);
float roughness=1.-microSurface;
outParams.microSurface=microSurface;
outParams.roughness=roughness;
outParams.surfaceReflectivityColor=surfaceReflectivityColor;
}
`;
ShaderStore.IncludesShadersStore[name$1g] = shader$1g;
var name$1f = "pbrBlockAmbientOcclusion"
, shader$1f = `struct ambientOcclusionOutParams
{
vec3 ambientOcclusionColor;
#if DEBUGMODE>0
vec3 ambientOcclusionColorMap;
#endif
};
#define pbr_inline
void ambientOcclusionBlock(
#ifdef AMBIENT
in vec3 ambientOcclusionColorMap_,
in vec4 vAmbientInfos,
#endif
out ambientOcclusionOutParams outParams
)
{
vec3 ambientOcclusionColor=vec3(1.,1.,1.);
#ifdef AMBIENT
vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
#ifdef AMBIENTINGRAYSCALE
ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
#endif
ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
#if DEBUGMODE>0
outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
#endif
#endif
outParams.ambientOcclusionColor=ambientOcclusionColor;
}
`;
ShaderStore.IncludesShadersStore[name$1f] = shader$1f;
var name$1e = "pbrBlockAlphaFresnel"
, shader$1e = `#ifdef ALPHAFRESNEL
#if defined(ALPHATEST) || defined(ALPHABLEND)
struct alphaFresnelOutParams
{
float alpha;
};
#define pbr_inline
void alphaFresnelBlock(
in vec3 normalW,
in vec3 viewDirectionW,
in float alpha,
in float microSurface,
out alphaFresnelOutParams outParams
)
{
float opacityPerceptual=alpha;
#ifdef LINEARALPHAFRESNEL
float opacity0=opacityPerceptual;
#else
float opacity0=opacityPerceptual*opacityPerceptual;
#endif
float opacity90=fresnelGrazingReflectance(opacity0);
vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);
outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
#ifdef ALPHATEST
if (outParams.alpha0
vec3 anisotropyMapData;
#endif
};
#define pbr_inline
void anisotropicBlock(
in vec3 vAnisotropy,
#ifdef ANISOTROPIC_TEXTURE
in vec3 anisotropyMapData,
#endif
in mat3 TBN,
in vec3 normalW,
in vec3 viewDirectionW,
out anisotropicOutParams outParams
)
{
float anisotropy=vAnisotropy.b;
vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
#ifdef ANISOTROPIC_TEXTURE
anisotropy*=anisotropyMapData.b;
anisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;
#if DEBUGMODE>0
outParams.anisotropyMapData=anisotropyMapData;
#endif
#endif
mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));
vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);
vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));
outParams.anisotropy=anisotropy;
outParams.anisotropicTangent=anisotropicTangent;
outParams.anisotropicBitangent=anisotropicBitangent;
outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);
}
#endif
`;
ShaderStore.IncludesShadersStore[name$1d] = shader$1d;
var name$1c = "pbrBlockReflection"
, shader$1c = `#ifdef REFLECTION
struct reflectionOutParams
{
vec4 environmentRadiance;
vec3 environmentIrradiance;
#ifdef REFLECTIONMAP_3D
vec3 reflectionCoords;
#else
vec2 reflectionCoords;
#endif
#ifdef SS_TRANSLUCENCY
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
vec3 irradianceVector;
#endif
#endif
#endif
};
#define pbr_inline
void createReflectionCoords(
in vec3 vPositionW,
in vec3 normalW,
#ifdef ANISOTROPIC
in anisotropicOutParams anisotropicOut,
#endif
#ifdef REFLECTIONMAP_3D
out vec3 reflectionCoords
#else
out vec2 reflectionCoords
#endif
)
{
#ifdef ANISOTROPIC
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
#else
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
#endif
#ifdef REFLECTIONMAP_OPPOSITEZ
reflectionVector.z*=-1.0;
#endif
#ifdef REFLECTIONMAP_3D
reflectionCoords=reflectionVector;
#else
reflectionCoords=reflectionVector.xy;
#ifdef REFLECTIONMAP_PROJECTION
reflectionCoords/=reflectionVector.z;
#endif
reflectionCoords.y=1.0-reflectionCoords.y;
#endif
}
#define pbr_inline
#define inline
void sampleReflectionTexture(
in float alphaG,
in vec3 vReflectionMicrosurfaceInfos,
in vec2 vReflectionInfos,
in vec3 vReflectionColor,
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
in float NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
in float roughness,
#endif
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSampler,
const vec3 reflectionCoords,
#else
in sampler2D reflectionSampler,
const vec2 reflectionCoords,
#endif
#ifndef LODBASEDMICROSFURACE
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSamplerLow,
in samplerCube reflectionSamplerHigh,
#else
in sampler2D reflectionSamplerLow,
in sampler2D reflectionSamplerHigh,
#endif
#endif
#ifdef REALTIME_FILTERING
in vec2 vReflectionFilteringInfo,
#endif
out vec4 environmentRadiance
)
{
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
#elif defined(LINEARSPECULARREFLECTION)
float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
#else
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
#endif
#ifdef LODBASEDMICROSFURACE
reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
#ifdef LODINREFLECTIONALPHA
float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);
float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
#else
float requestedReflectionLOD=reflectionLOD;
#endif
#ifdef REALTIME_FILTERING
environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
#else
environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
#endif
#else
float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));
float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;
vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);
if (lodReflectionNormalizedDoubled<1.0){
environmentRadiance=mix(
sampleReflection(reflectionSamplerHigh,reflectionCoords),
environmentMid,
lodReflectionNormalizedDoubled
);
} else {
environmentRadiance=mix(
environmentMid,
sampleReflection(reflectionSamplerLow,reflectionCoords),
lodReflectionNormalizedDoubled-1.0
);
}
#endif
#ifdef RGBDREFLECTION
environmentRadiance.rgb=fromRGBD(environmentRadiance);
#endif
#ifdef GAMMAREFLECTION
environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
#endif
environmentRadiance.rgb*=vReflectionInfos.x;
environmentRadiance.rgb*=vReflectionColor.rgb;
}
#define pbr_inline
#define inline
void reflectionBlock(
in vec3 vPositionW,
in vec3 normalW,
in float alphaG,
in vec3 vReflectionMicrosurfaceInfos,
in vec2 vReflectionInfos,
in vec3 vReflectionColor,
#ifdef ANISOTROPIC
in anisotropicOutParams anisotropicOut,
#endif
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
in float NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
in float roughness,
#endif
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSampler,
#else
in sampler2D reflectionSampler,
#endif
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
in vec3 vEnvironmentIrradiance,
#endif
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
in mat4 reflectionMatrix,
#endif
#endif
#ifdef USEIRRADIANCEMAP
#ifdef REFLECTIONMAP_3D
in samplerCube irradianceSampler,
#else
in sampler2D irradianceSampler,
#endif
#endif
#ifndef LODBASEDMICROSFURACE
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSamplerLow,
in samplerCube reflectionSamplerHigh,
#else
in sampler2D reflectionSamplerLow,
in sampler2D reflectionSamplerHigh,
#endif
#endif
#ifdef REALTIME_FILTERING
in vec2 vReflectionFilteringInfo,
#endif
out reflectionOutParams outParams
)
{
vec4 environmentRadiance=vec4(0.,0.,0.,0.);
#ifdef REFLECTIONMAP_3D
vec3 reflectionCoords=vec3(0.);
#else
vec2 reflectionCoords=vec2(0.);
#endif
createReflectionCoords(
vPositionW,
normalW,
#ifdef ANISOTROPIC
anisotropicOut,
#endif
reflectionCoords
);
sampleReflectionTexture(
alphaG,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
roughness,
#endif
#ifdef REFLECTIONMAP_3D
reflectionSampler,
reflectionCoords,
#else
reflectionSampler,
reflectionCoords,
#endif
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
environmentRadiance
);
vec3 environmentIrradiance=vec3(0.,0.,0.);
#ifdef USESPHERICALFROMREFLECTIONMAP
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
environmentIrradiance=vEnvironmentIrradiance;
#else
#ifdef ANISOTROPIC
vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
#else
vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
#endif
#ifdef REFLECTIONMAP_OPPOSITEZ
irradianceVector.z*=-1.0;
#endif
#ifdef INVERTCUBICMAP
irradianceVector.y*=-1.0;
#endif
#if defined(REALTIME_FILTERING)
environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);
#else
environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
#endif
#ifdef SS_TRANSLUCENCY
outParams.irradianceVector=irradianceVector;
#endif
#endif
#elif defined(USEIRRADIANCEMAP)
vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);
environmentIrradiance=environmentIrradiance4.rgb;
#ifdef RGBDREFLECTION
environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
#endif
#ifdef GAMMAREFLECTION
environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
#endif
#endif
environmentIrradiance*=vReflectionColor.rgb;
outParams.environmentRadiance=environmentRadiance;
outParams.environmentIrradiance=environmentIrradiance;
outParams.reflectionCoords=reflectionCoords;
}
#endif
`;
ShaderStore.IncludesShadersStore[name$1c] = shader$1c;
var name$1b = "pbrBlockSheen"
, shader$1b = `#ifdef SHEEN
struct sheenOutParams
{
float sheenIntensity;
vec3 sheenColor;
float sheenRoughness;
#ifdef SHEEN_LINKWITHALBEDO
vec3 surfaceAlbedo;
#endif
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
float sheenAlbedoScaling;
#endif
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
vec3 finalSheenRadianceScaled;
#endif
#if DEBUGMODE>0
vec4 sheenMapData;
vec3 sheenEnvironmentReflectance;
#endif
};
#define pbr_inline
#define inline
void sheenBlock(
in vec4 vSheenColor,
#ifdef SHEEN_ROUGHNESS
in float vSheenRoughness,
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
in vec4 sheenMapRoughnessData,
#endif
#endif
in float roughness,
#ifdef SHEEN_TEXTURE
in vec4 sheenMapData,
in float sheenMapLevel,
#endif
in float reflectance,
#ifdef SHEEN_LINKWITHALBEDO
in vec3 baseColor,
in vec3 surfaceAlbedo,
#endif
#ifdef ENVIRONMENTBRDF
in float NdotV,
in vec3 environmentBrdf,
#endif
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
in vec2 AARoughnessFactors,
in vec3 vReflectionMicrosurfaceInfos,
in vec2 vReflectionInfos,
in vec3 vReflectionColor,
in vec4 vLightingIntensity,
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSampler,
in vec3 reflectionCoords,
#else
in sampler2D reflectionSampler,
in vec2 reflectionCoords,
#endif
in float NdotVUnclamped,
#ifndef LODBASEDMICROSFURACE
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSamplerLow,
in samplerCube reflectionSamplerHigh,
#else
in sampler2D reflectionSamplerLow,
in sampler2D reflectionSamplerHigh,
#endif
#endif
#ifdef REALTIME_FILTERING
in vec2 vReflectionFilteringInfo,
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
in float seo,
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
in float eho,
#endif
#endif
out sheenOutParams outParams
)
{
float sheenIntensity=vSheenColor.a;
#ifdef SHEEN_TEXTURE
#if DEBUGMODE>0
outParams.sheenMapData=sheenMapData;
#endif
#endif
#ifdef SHEEN_LINKWITHALBEDO
float sheenFactor=pow5(1.0-sheenIntensity);
vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);
float sheenRoughness=sheenIntensity;
outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
#ifdef SHEEN_TEXTURE
sheenIntensity*=sheenMapData.a;
#endif
#else
vec3 sheenColor=vSheenColor.rgb;
#ifdef SHEEN_TEXTURE
#ifdef SHEEN_GAMMATEXTURE
sheenColor.rgb*=toLinearSpace(sheenMapData.rgb);
#else
sheenColor.rgb*=sheenMapData.rgb;
#endif
sheenColor.rgb*=sheenMapLevel;
#endif
#ifdef SHEEN_ROUGHNESS
float sheenRoughness=vSheenRoughness;
#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
#if defined(SHEEN_TEXTURE)
sheenRoughness*=sheenMapData.a;
#endif
#elif defined(SHEEN_TEXTURE_ROUGHNESS)
#ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL
sheenRoughness*=sheenMapData.a;
#else
sheenRoughness*=sheenMapRoughnessData.a;
#endif
#endif
#else
float sheenRoughness=roughness;
#ifdef SHEEN_TEXTURE
sheenIntensity*=sheenMapData.a;
#endif
#endif
#if !defined(SHEEN_ALBEDOSCALING)
sheenIntensity*=(1.-reflectance);
#endif
sheenColor*=sheenIntensity;
#endif
#ifdef ENVIRONMENTBRDF
#ifdef SHEEN_ROUGHNESS
vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
#else
vec3 environmentSheenBrdf=environmentBrdf;
#endif
#endif
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
#ifdef SPECULARAA
sheenAlphaG+=AARoughnessFactors.y;
#endif
vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);
sampleReflectionTexture(
sheenAlphaG,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
sheenRoughness,
#endif
reflectionSampler,
reflectionCoords,
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
environmentSheenRadiance
);
vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
sheenEnvironmentReflectance*=seo;
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
sheenEnvironmentReflectance*=eho;
#endif
#if DEBUGMODE>0
outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
#endif
outParams.finalSheenRadianceScaled=
environmentSheenRadiance.rgb *
sheenEnvironmentReflectance *
vLightingIntensity.z;
#endif
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
#endif
outParams.sheenIntensity=sheenIntensity;
outParams.sheenColor=sheenColor;
outParams.sheenRoughness=sheenRoughness;
}
#endif
`;
ShaderStore.IncludesShadersStore[name$1b] = shader$1b;
var name$1a = "pbrBlockClearcoat"
, shader$1a = `struct clearcoatOutParams
{
vec3 specularEnvironmentR0;
float conservationFactor;
vec3 clearCoatNormalW;
vec2 clearCoatAARoughnessFactors;
float clearCoatIntensity;
float clearCoatRoughness;
#ifdef REFLECTION
vec3 finalClearCoatRadianceScaled;
#endif
#ifdef CLEARCOAT_TINT
vec3 absorption;
float clearCoatNdotVRefract;
vec3 clearCoatColor;
float clearCoatThickness;
#endif
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
vec3 energyConservationFactorClearCoat;
#endif
#if DEBUGMODE>0
mat3 TBNClearCoat;
vec2 clearCoatMapData;
vec4 clearCoatTintMapData;
vec4 environmentClearCoatRadiance;
float clearCoatNdotV;
vec3 clearCoatEnvironmentReflectance;
#endif
};
#ifdef CLEARCOAT
#define pbr_inline
#define inline
void clearcoatBlock(
in vec3 vPositionW,
in vec3 geometricNormalW,
in vec3 viewDirectionW,
in vec2 vClearCoatParams,
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
in vec4 clearCoatMapRoughnessData,
#endif
in vec3 specularEnvironmentR0,
#ifdef CLEARCOAT_TEXTURE
in vec2 clearCoatMapData,
#endif
#ifdef CLEARCOAT_TINT
in vec4 vClearCoatTintParams,
in float clearCoatColorAtDistance,
in vec4 vClearCoatRefractionParams,
#ifdef CLEARCOAT_TINT_TEXTURE
in vec4 clearCoatTintMapData,
#endif
#endif
#ifdef CLEARCOAT_BUMP
in vec2 vClearCoatBumpInfos,
in vec4 clearCoatBumpMapData,
in vec2 vClearCoatBumpUV,
#if defined(TANGENT) && defined(NORMAL)
in mat3 vTBN,
#else
in vec2 vClearCoatTangentSpaceParams,
#endif
#ifdef OBJECTSPACE_NORMALMAP
in mat4 normalMatrix,
#endif
#endif
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
in vec3 faceNormal,
#endif
#ifdef REFLECTION
in vec3 vReflectionMicrosurfaceInfos,
in vec2 vReflectionInfos,
in vec3 vReflectionColor,
in vec4 vLightingIntensity,
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSampler,
#else
in sampler2D reflectionSampler,
#endif
#ifndef LODBASEDMICROSFURACE
#ifdef REFLECTIONMAP_3D
in samplerCube reflectionSamplerLow,
in samplerCube reflectionSamplerHigh,
#else
in sampler2D reflectionSamplerLow,
in sampler2D reflectionSamplerHigh,
#endif
#endif
#ifdef REALTIME_FILTERING
in vec2 vReflectionFilteringInfo,
#endif
#endif
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
#ifdef RADIANCEOCCLUSION
in float ambientMonochrome,
#endif
#endif
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
in float frontFacingMultiplier,
#endif
out clearcoatOutParams outParams
)
{
float clearCoatIntensity=vClearCoatParams.x;
float clearCoatRoughness=vClearCoatParams.y;
#ifdef CLEARCOAT_TEXTURE
clearCoatIntensity*=clearCoatMapData.x;
#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
clearCoatRoughness*=clearCoatMapData.y;
#endif
#if DEBUGMODE>0
outParams.clearCoatMapData=clearCoatMapData;
#endif
#endif
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
#ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL
clearCoatRoughness*=clearCoatMapData.y;
#else
clearCoatRoughness*=clearCoatMapRoughnessData.y;
#endif
#endif
outParams.clearCoatIntensity=clearCoatIntensity;
outParams.clearCoatRoughness=clearCoatRoughness;
#ifdef CLEARCOAT_TINT
vec3 clearCoatColor=vClearCoatTintParams.rgb;
float clearCoatThickness=vClearCoatTintParams.a;
#ifdef CLEARCOAT_TINT_TEXTURE
#ifdef CLEARCOAT_TINT_GAMMATEXTURE
clearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);
#else
clearCoatColor*=clearCoatTintMapData.rgb;
#endif
clearCoatThickness*=clearCoatTintMapData.a;
#if DEBUGMODE>0
outParams.clearCoatTintMapData=clearCoatTintMapData;
#endif
#endif
outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);
outParams.clearCoatThickness=clearCoatThickness;
#endif
#ifdef CLEARCOAT_REMAP_F0
vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
#else
vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
#endif
outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);
vec3 clearCoatNormalW=geometricNormalW;
#ifdef CLEARCOAT_BUMP
#ifdef NORMALXYSCALE
float clearCoatNormalScale=1.0;
#else
float clearCoatNormalScale=vClearCoatBumpInfos.y;
#endif
#if defined(TANGENT) && defined(NORMAL)
mat3 TBNClearCoat=vTBN;
#else
vec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;
mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
#endif
#if DEBUGMODE>0
outParams.TBNClearCoat=TBNClearCoat;
#endif
#ifdef OBJECTSPACE_NORMALMAP
clearCoatNormalW=normalize(clearCoatBumpMapData.xyz*2.0-1.0);
clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
#else
clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
#endif
#endif
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
#endif
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
#endif
outParams.clearCoatNormalW=clearCoatNormalW;
outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);
float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);
float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
#if DEBUGMODE>0
outParams.clearCoatNdotV=clearCoatNdotV;
#endif
#ifdef CLEARCOAT_TINT
vec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);
outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
#endif
#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
#endif
#if defined(REFLECTION)
float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
#ifdef SPECULARAA
clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
#endif
vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);
vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
#ifdef REFLECTIONMAP_OPPOSITEZ
clearCoatReflectionVector.z*=-1.0;
#endif
#ifdef REFLECTIONMAP_3D
vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
#else
vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
#ifdef REFLECTIONMAP_PROJECTION
clearCoatReflectionCoords/=clearCoatReflectionVector.z;
#endif
clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
#endif
sampleReflectionTexture(
clearCoatAlphaG,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
clearCoatNdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
clearCoatRoughness,
#endif
reflectionSampler,
clearCoatReflectionCoords,
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
environmentClearCoatRadiance
);
#if DEBUGMODE>0
outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
#endif
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
#ifdef RADIANCEOCCLUSION
float clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);
clearCoatEnvironmentReflectance*=clearCoatSeo;
#endif
#ifdef HORIZONOCCLUSION
#ifdef BUMP
#ifdef REFLECTIONMAP_3D
float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);
clearCoatEnvironmentReflectance*=clearCoatEho;
#endif
#endif
#endif
#else
vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
#endif
clearCoatEnvironmentReflectance*=clearCoatIntensity;
#if DEBUGMODE>0
outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
#endif
outParams.finalClearCoatRadianceScaled=
environmentClearCoatRadiance.rgb *
clearCoatEnvironmentReflectance *
vLightingIntensity.z;
#endif
#if defined(CLEARCOAT_TINT)
outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
#endif
float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
fresnelIBLClearCoat*=clearCoatIntensity;
outParams.conservationFactor=(1.-fresnelIBLClearCoat);
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
#endif
}
#endif
`;
ShaderStore.IncludesShadersStore[name$1a] = shader$1a;
var name$19 = "pbrBlockSubSurface"
, shader$19 = `struct subSurfaceOutParams
{
vec3 specularEnvironmentReflectance;
#ifdef SS_REFRACTION
vec3 finalRefraction;
vec3 surfaceAlbedo;
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
float alpha;
#endif
#ifdef REFLECTION
float refractionFactorForIrradiance;
#endif
#endif
#ifdef SS_TRANSLUCENCY
vec3 transmittance;
float translucencyIntensity;
#ifdef REFLECTION
vec3 refractionIrradiance;
#endif
#endif
#if DEBUGMODE>0
vec4 thicknessMap;
vec4 environmentRefraction;
vec3 refractionTransmittance;
#endif
};
#ifdef SUBSURFACE
#define pbr_inline
#define inline
void subSurfaceBlock(
in vec3 vSubSurfaceIntensity,
in vec2 vThicknessParam,
in vec4 vTintColor,
in vec3 normalW,
in vec3 specularEnvironmentReflectance,
#ifdef SS_THICKNESSANDMASK_TEXTURE
in vec4 thicknessMap,
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
in vec4 refractionIntensityMap,
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
in vec4 translucencyIntensityMap,
#endif
#ifdef REFLECTION
#ifdef SS_TRANSLUCENCY
in mat4 reflectionMatrix,
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
in vec3 irradianceVector_,
#endif
#if defined(REALTIME_FILTERING)
in samplerCube reflectionSampler,
in vec2 vReflectionFilteringInfo,
#endif
#endif
#ifdef USEIRRADIANCEMAP
#ifdef REFLECTIONMAP_3D
in samplerCube irradianceSampler,
#else
in sampler2D irradianceSampler,
#endif
#endif
#endif
#endif
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
in vec3 surfaceAlbedo,
#endif
#ifdef SS_REFRACTION
in vec3 vPositionW,
in vec3 viewDirectionW,
in mat4 view,
in vec4 vRefractionInfos,
in mat4 refractionMatrix,
in vec4 vRefractionMicrosurfaceInfos,
in vec4 vLightingIntensity,
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
in float alpha,
#endif
#ifdef SS_LODINREFRACTIONALPHA
in float NdotVUnclamped,
#endif
#ifdef SS_LINEARSPECULARREFRACTION
in float roughness,
#endif
in float alphaG,
#ifdef SS_REFRACTIONMAP_3D
in samplerCube refractionSampler,
#ifndef LODBASEDMICROSFURACE
in samplerCube refractionSamplerLow,
in samplerCube refractionSamplerHigh,
#endif
#else
in sampler2D refractionSampler,
#ifndef LODBASEDMICROSFURACE
in sampler2D refractionSamplerLow,
in sampler2D refractionSamplerHigh,
#endif
#endif
#ifdef ANISOTROPIC
in anisotropicOutParams anisotropicOut,
#endif
#ifdef REALTIME_FILTERING
in vec2 vRefractionFilteringInfo,
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
in vec3 refractionPosition,
in vec3 refractionSize,
#endif
#endif
#ifdef SS_TRANSLUCENCY
in vec3 vDiffusionDistance,
#endif
out subSurfaceOutParams outParams
)
{
outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
#ifdef SS_REFRACTION
float refractionIntensity=vSubSurfaceIntensity.x;
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
refractionIntensity*=(1.0-alpha);
outParams.alpha=1.0;
#endif
#endif
#ifdef SS_TRANSLUCENCY
float translucencyIntensity=vSubSurfaceIntensity.y;
#endif
#ifdef SS_THICKNESSANDMASK_TEXTURE
#if defined(SS_USE_GLTF_TEXTURES)
float thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
#else
float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
#endif
#if DEBUGMODE>0
outParams.thicknessMap=thicknessMap;
#endif
#ifdef SS_MASK_FROM_THICKNESS_TEXTURE
#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE)
#if defined(SS_USE_GLTF_TEXTURES)
refractionIntensity*=thicknessMap.r;
#else
refractionIntensity*=thicknessMap.g;
#endif
#endif
#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE)
translucencyIntensity*=thicknessMap.b;
#endif
#endif
#else
float thickness=vThicknessParam.y;
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
#ifdef SS_USE_GLTF_TEXTURES
refractionIntensity*=refractionIntensityMap.r;
#else
refractionIntensity*=refractionIntensityMap.g;
#endif
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
translucencyIntensity*=translucencyIntensityMap.b;
#endif
#ifdef SS_TRANSLUCENCY
thickness=maxEps(thickness);
vec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);
transmittance*=translucencyIntensity;
outParams.transmittance=transmittance;
outParams.translucencyIntensity=translucencyIntensity;
#endif
#ifdef SS_REFRACTION
vec4 environmentRefraction=vec4(0.,0.,0.,0.);
#ifdef ANISOTROPIC
vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);
#else
vec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);
#endif
#ifdef SS_REFRACTIONMAP_OPPOSITEZ
refractionVector.z*=-1.0;
#endif
#ifdef SS_REFRACTIONMAP_3D
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
#endif
refractionVector.y=refractionVector.y*vRefractionInfos.w;
vec3 refractionCoords=refractionVector;
refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
#else
#ifdef SS_USE_THICKNESS_AS_DEPTH
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));
#else
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
#endif
vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
refractionCoords.y=1.0-refractionCoords.y;
#endif
#ifdef SS_HAS_THICKNESS
float ior=vRefractionInfos.y;
#else
float ior=vRefractionMicrosurfaceInfos.w;
#endif
#ifdef SS_LODINREFRACTIONALPHA
float refractionAlphaG=alphaG;
refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));
float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
#elif defined(SS_LINEARSPECULARREFRACTION)
float refractionRoughness=alphaG;
refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));
float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
#else
float refractionAlphaG=alphaG;
refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));
float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
#endif
#ifdef LODBASEDMICROSFURACE
refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
#ifdef SS_LODINREFRACTIONALPHA
float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);
float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
#else
float requestedRefractionLOD=refractionLOD;
#endif
#ifdef REALTIME_FILTERING
environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
#else
environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
#endif
#else
float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));
float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;
vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);
if (lodRefractionNormalizedDoubled<1.0){
environmentRefraction=mix(
sampleRefraction(refractionSamplerHigh,refractionCoords),
environmentRefractionMid,
lodRefractionNormalizedDoubled
);
} else {
environmentRefraction=mix(
environmentRefractionMid,
sampleRefraction(refractionSamplerLow,refractionCoords),
lodRefractionNormalizedDoubled-1.0
);
}
#endif
#ifdef SS_RGBDREFRACTION
environmentRefraction.rgb=fromRGBD(environmentRefraction);
#endif
#ifdef SS_GAMMAREFRACTION
environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
#endif
environmentRefraction.rgb*=vRefractionInfos.x;
#endif
#ifdef SS_REFRACTION
vec3 refractionTransmittance=vec3(refractionIntensity);
#ifdef SS_THICKNESSANDMASK_TEXTURE
vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);
vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);
environmentRefraction.rgb*=volumeAlbedo;
#else
vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
#endif
#ifdef SS_ALBEDOFORREFRACTIONTINT
environmentRefraction.rgb*=surfaceAlbedo.rgb;
#endif
outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);
#ifdef REFLECTION
outParams.refractionFactorForIrradiance=(1.-refractionIntensity);
#endif
#ifdef UNUSED_MULTIPLEBOUNCES
vec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);
outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
#endif
refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;
#if DEBUGMODE>0
outParams.refractionTransmittance=refractionTransmittance;
#endif
outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;
#if DEBUGMODE>0
outParams.environmentRefraction=environmentRefraction;
#endif
#endif
#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
#ifdef REFLECTIONMAP_OPPOSITEZ
irradianceVector.z*=-1.0;
#endif
#ifdef INVERTCUBICMAP
irradianceVector.y*=-1.0;
#endif
#else
vec3 irradianceVector=irradianceVector_;
#endif
#if defined(USESPHERICALFROMREFLECTIONMAP)
#if defined(REALTIME_FILTERING)
vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);
#else
vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
#endif
#elif defined(USEIRRADIANCEMAP)
#ifdef REFLECTIONMAP_3D
vec3 irradianceCoords=irradianceVector;
#else
vec2 irradianceCoords=irradianceVector.xy;
#ifdef REFLECTIONMAP_PROJECTION
irradianceCoords/=irradianceVector.z;
#endif
irradianceCoords.y=1.0-irradianceCoords.y;
#endif
vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
#ifdef RGBDREFLECTION
refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
#endif
#ifdef GAMMAREFLECTION
refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
#endif
#else
vec4 refractionIrradiance=vec4(0.);
#endif
refractionIrradiance.rgb*=transmittance;
#ifdef SS_ALBEDOFORTRANSLUCENCYTINT
refractionIrradiance.rgb*=surfaceAlbedo.rgb;
#endif
outParams.refractionIrradiance=refractionIrradiance.rgb;
#endif
}
#endif
`;
ShaderStore.IncludesShadersStore[name$19] = shader$19;
var name$18 = "pbrBlockNormalGeometric"
, shader$18 = `vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
#ifdef NORMAL
vec3 normalW=normalize(vNormalW);
#else
vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
#endif
vec3 geometricNormalW=normalW;
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;
#endif
`;
ShaderStore.IncludesShadersStore[name$18] = shader$18;
var name$17 = "pbrBlockNormalFinal"
, shader$17 = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
#if defined(TWOSIDEDLIGHTING)
faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
#endif
normalW*=sign(dot(normalW,faceNormal));
#endif
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
normalW=gl_FrontFacing ? normalW : -normalW;
#endif
`;
ShaderStore.IncludesShadersStore[name$17] = shader$17;
var name$16 = "pbrBlockLightmapInit"
, shader$16 = `#ifdef LIGHTMAP
vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
#ifdef RGBDLIGHTMAP
lightmapColor.rgb=fromRGBD(lightmapColor);
#endif
#ifdef GAMMALIGHTMAP
lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
#endif
lightmapColor.rgb*=vLightmapInfos.y;
#endif
`;
ShaderStore.IncludesShadersStore[name$16] = shader$16;
var name$15 = "pbrBlockGeometryInfo"
, shader$15 = `float NdotVUnclamped=dot(normalW,viewDirectionW);
float NdotV=absEps(NdotVUnclamped);
float alphaG=convertRoughnessToAverageSlope(roughness);
vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
#ifdef SPECULARAA
alphaG+=AARoughnessFactors.y;
#endif
#if defined(ENVIRONMENTBRDF)
vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
#endif
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
#ifdef RADIANCEOCCLUSION
#ifdef AMBIENTINGRAYSCALE
float ambientMonochrome=aoOut.ambientOcclusionColor.r;
#else
float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
#endif
float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
#endif
#ifdef HORIZONOCCLUSION
#ifdef BUMP
#ifdef REFLECTIONMAP_3D
float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
#endif
#endif
#endif
#endif
`;
ShaderStore.IncludesShadersStore[name$15] = shader$15;
var name$14 = "pbrBlockReflectance0"
, shader$14 = `float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);
vec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;
#ifdef METALLICWORKFLOW
vec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);
#else
vec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);
#endif
#ifdef ALPHAFRESNEL
float reflectance90=fresnelGrazingReflectance(reflectance);
specularEnvironmentR90=specularEnvironmentR90*reflectance90;
#endif
`;
ShaderStore.IncludesShadersStore[name$14] = shader$14;
var name$13 = "pbrBlockReflectance"
, shader$13 = `#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
vec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);
#ifdef RADIANCEOCCLUSION
specularEnvironmentReflectance*=seo;
#endif
#ifdef HORIZONOCCLUSION
#ifdef BUMP
#ifdef REFLECTIONMAP_3D
specularEnvironmentReflectance*=eho;
#endif
#endif
#endif
#else
vec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));
#endif
#ifdef CLEARCOAT
specularEnvironmentReflectance*=clearcoatOut.conservationFactor;
#if defined(CLEARCOAT_TINT)
specularEnvironmentReflectance*=clearcoatOut.absorption;
#endif
#endif
`;
ShaderStore.IncludesShadersStore[name$13] = shader$13;
var name$12 = "pbrBlockDirectLighting"
, shader$12 = `vec3 diffuseBase=vec3(0.,0.,0.);
#ifdef SPECULARTERM
vec3 specularBase=vec3(0.,0.,0.);
#endif
#ifdef CLEARCOAT
vec3 clearCoatBase=vec3(0.,0.,0.);
#endif
#ifdef SHEEN
vec3 sheenBase=vec3(0.,0.,0.);
#endif
preLightingInfo preInfo;
lightingInfo info;
float shadow=1.;
#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
vec3 absorption=vec3(0.);
#endif
`;
ShaderStore.IncludesShadersStore[name$12] = shader$12;
var name$11 = "pbrBlockFinalLitComponents"
, shader$11 = `
#if defined(ENVIRONMENTBRDF)
#ifdef MS_BRDF_ENERGY_CONSERVATION
vec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
#endif
#endif
#ifndef METALLICWORKFLOW
#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
surfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;
#endif
#endif
#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
#endif
#ifdef REFLECTION
vec3 finalIrradiance=reflectionOut.environmentIrradiance;
#if defined(CLEARCOAT)
finalIrradiance*=clearcoatOut.conservationFactor;
#if defined(CLEARCOAT_TINT)
finalIrradiance*=clearcoatOut.absorption;
#endif
#endif
#if defined(SS_REFRACTION)
finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;
#endif
#if defined(SS_TRANSLUCENCY)
finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);
finalIrradiance+=subSurfaceOut.refractionIrradiance;
#endif
finalIrradiance*=surfaceAlbedo.rgb;
finalIrradiance*=vLightingIntensity.z;
finalIrradiance*=aoOut.ambientOcclusionColor;
#endif
#ifdef SPECULARTERM
vec3 finalSpecular=specularBase;
finalSpecular=max(finalSpecular,0.0);
vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
finalSpecularScaled*=energyConservationFactor;
#endif
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
#endif
#endif
#ifdef REFLECTION
vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;
finalRadiance*=subSurfaceOut.specularEnvironmentReflectance;
vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
finalRadianceScaled*=energyConservationFactor;
#endif
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
#endif
#endif
#ifdef SHEEN
vec3 finalSheen=sheenBase*sheenOut.sheenColor;
finalSheen=max(finalSheen,0.0);
vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
#if defined(CLEARCOAT_TINT)
sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
#endif
#endif
#endif
#ifdef CLEARCOAT
vec3 finalClearCoat=clearCoatBase;
finalClearCoat=max(finalClearCoat,0.0);
vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
#endif
#ifdef SS_REFRACTION
subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
#ifdef CLEARCOAT_TINT
subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
#endif
#endif
#endif
#ifdef ALPHABLEND
float luminanceOverAlpha=0.0;
#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
luminanceOverAlpha+=getLuminance(finalRadianceScaled);
#if defined(CLEARCOAT)
luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
#endif
#endif
#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
luminanceOverAlpha+=getLuminance(finalSpecularScaled);
#endif
#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
#endif
#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
#endif
#endif
`;
ShaderStore.IncludesShadersStore[name$11] = shader$11;
var name$10 = "pbrBlockFinalUnlitComponents"
, shader$10 = `
vec3 finalDiffuse=diffuseBase;
finalDiffuse*=surfaceAlbedo.rgb;
finalDiffuse=max(finalDiffuse,0.0);
finalDiffuse*=vLightingIntensity.x;
vec3 finalAmbient=vAmbientColor;
finalAmbient*=surfaceAlbedo.rgb;
vec3 finalEmissive=vEmissiveColor;
#ifdef EMISSIVE
vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;
#ifdef GAMMAEMISSIVE
finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
#else
finalEmissive*=emissiveColorTex.rgb;
#endif
finalEmissive*=vEmissiveInfos.y;
#endif
finalEmissive*=vLightingIntensity.y;
#ifdef AMBIENT
vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
#else
vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
#endif
finalAmbient*=aoOut.ambientOcclusionColor;
finalDiffuse*=ambientOcclusionForDirectDiffuse;
`;
ShaderStore.IncludesShadersStore[name$10] = shader$10;
var name$$ = "pbrBlockFinalColorComposition"
, shader$$ = `vec4 finalColor=vec4(
finalAmbient +
finalDiffuse +
#ifndef UNLIT
#ifdef REFLECTION
finalIrradiance +
#endif
#ifdef SPECULARTERM
finalSpecularScaled +
#endif
#ifdef SHEEN
finalSheenScaled +
#endif
#ifdef CLEARCOAT
finalClearCoatScaled +
#endif
#ifdef REFLECTION
finalRadianceScaled +
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
sheenOut.finalSheenRadianceScaled +
#endif
#ifdef CLEARCOAT
clearcoatOut.finalClearCoatRadianceScaled +
#endif
#endif
#ifdef SS_REFRACTION
subSurfaceOut.finalRefraction +
#endif
#endif
finalEmissive,
alpha);
#ifdef LIGHTMAP
#ifndef LIGHTMAPEXCLUDED
#ifdef USELIGHTMAPASSHADOWMAP
finalColor.rgb*=lightmapColor.rgb;
#else
finalColor.rgb+=lightmapColor.rgb;
#endif
#endif
#endif
#define CUSTOM_FRAGMENT_BEFORE_FOG
finalColor=max(finalColor,0.0);
`;
ShaderStore.IncludesShadersStore[name$$] = shader$$;
var name$_ = "pbrBlockImageProcessing"
, shader$_ = `#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
#if !defined(SKIPFINALCOLORCLAMP)
finalColor.rgb=clamp(finalColor.rgb,0.,30.0);
#endif
#else
finalColor=applyImageProcessing(finalColor);
#endif
finalColor.a*=visibility;
#ifdef PREMULTIPLYALPHA
finalColor.rgb*=finalColor.a;
#endif
`;
ShaderStore.IncludesShadersStore[name$_] = shader$_;
var name$Z = "pbrDebug"
, shader$Z = `#if DEBUGMODE>0
if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {
#if DEBUGMODE == 1
gl_FragColor.rgb=vPositionW.rgb;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 2 && defined(NORMAL)
gl_FragColor.rgb=vNormalW.rgb;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 3 && defined(BUMP) || DEBUGMODE == 3 && defined(PARALLAX) || DEBUGMODE == 3 && defined(ANISOTROPIC)
gl_FragColor.rgb=TBN[0];
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 4 && defined(BUMP) || DEBUGMODE == 4 && defined(PARALLAX) || DEBUGMODE == 4 && defined(ANISOTROPIC)
gl_FragColor.rgb=TBN[1];
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 5
gl_FragColor.rgb=normalW;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 6 && defined(MAINUV1)
gl_FragColor.rgb=vec3(vMainUV1,0.0);
#elif DEBUGMODE == 7 && defined(MAINUV2)
gl_FragColor.rgb=vec3(vMainUV2,0.0);
#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 10 && defined(CLEARCOAT)
gl_FragColor.rgb=clearcoatOut.clearCoatNormalW;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 11 && defined(ANISOTROPIC)
gl_FragColor.rgb=anisotropicOut.anisotropicNormal;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 12 && defined(ANISOTROPIC)
gl_FragColor.rgb=anisotropicOut.anisotropicTangent;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 13 && defined(ANISOTROPIC)
gl_FragColor.rgb=anisotropicOut.anisotropicBitangent;
#define DEBUGMODE_NORMALIZE
#elif DEBUGMODE == 20 && defined(ALBEDO)
gl_FragColor.rgb=albedoTexture.rgb;
#elif DEBUGMODE == 21 && defined(AMBIENT)
gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;
#elif DEBUGMODE == 22 && defined(OPACITY)
gl_FragColor.rgb=opacityMap.rgb;
#elif DEBUGMODE == 23 && defined(EMISSIVE)
gl_FragColor.rgb=emissiveColorTex.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 24 && defined(LIGHTMAP)
gl_FragColor.rgb=lightmapColor.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;
#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);
#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;
#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
gl_FragColor.rgb=sheenOut.sheenMapData.rgb;
#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;
#elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;
#elif DEBUGMODE == 40 && defined(SS_REFRACTION)
gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 41 && defined(REFLECTION)
gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)
gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 50
gl_FragColor.rgb=diffuseBase.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 51 && defined(SPECULARTERM)
gl_FragColor.rgb=specularBase.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 52 && defined(CLEARCOAT)
gl_FragColor.rgb=clearCoatBase.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 53 && defined(SHEEN)
gl_FragColor.rgb=sheenBase.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 54 && defined(REFLECTION)
gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 60
gl_FragColor.rgb=surfaceAlbedo.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 61
gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 62 && defined(METALLICWORKFLOW)
gl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);
#elif DEBUGMODE == 71 && defined(METALLICWORKFLOW)
gl_FragColor.rgb=reflectivityOut.metallicF0;
#elif DEBUGMODE == 63
gl_FragColor.rgb=vec3(roughness);
#elif DEBUGMODE == 64
gl_FragColor.rgb=vec3(alphaG);
#elif DEBUGMODE == 65
gl_FragColor.rgb=vec3(NdotV);
#elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 67 && defined(CLEARCOAT)
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);
#elif DEBUGMODE == 68 && defined(CLEARCOAT)
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);
#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
gl_FragColor.rgb=subSurfaceOut.transmittance;
#elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
gl_FragColor.rgb=subSurfaceOut.refractionTransmittance;
#elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION)
gl_FragColor.rgb=vec3(seo);
#elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION)
gl_FragColor.rgb=vec3(eho);
#elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION)
gl_FragColor.rgb=vec3(energyConservationFactor);
#elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
gl_FragColor.rgb=specularEnvironmentReflectance;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION)
gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;
#define DEBUGMODE_GAMMA
#elif DEBUGMODE == 86 && defined(ALPHABLEND)
gl_FragColor.rgb=vec3(luminanceOverAlpha);
#elif DEBUGMODE == 87
gl_FragColor.rgb=vec3(alpha);
#endif
gl_FragColor.rgb*=vDebugMode.y;
#ifdef DEBUGMODE_NORMALIZE
gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;
#endif
#ifdef DEBUGMODE_GAMMA
gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);
#endif
gl_FragColor.a=1.0;
#ifdef PREPASS
gl_FragData[0]=toLinearSpace(gl_FragColor);
gl_FragData[1]=vec4(0.,0.,0.,0.);
#endif
return;
}
#endif`;
ShaderStore.IncludesShadersStore[name$Z] = shader$Z;
var name$Y = "pbrPixelShader"
, shader$Y = `#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
#extension GL_OES_standard_derivatives : enable
#endif
#ifdef LODBASEDMICROSFURACE
#extension GL_EXT_shader_texture_lod : enable
#endif
#define CUSTOM_FRAGMENT_BEGIN
#ifdef LOGARITHMICDEPTH
#extension GL_EXT_frag_depth : enable
#endif
#include[SCENE_MRT_COUNT]
precision highp float;
#include
#ifndef FROMLINEARSPACE
#define FROMLINEARSPACE
#endif
#include<__decl__pbrFragment>
#include
#include<__decl__lightFragment>[0..maxSimultaneousLights]
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef REFLECTION
#include
#endif
#define CUSTOM_FRAGMENT_DEFINITIONS
#include
#include
#include
#include
#include
#include
#include
#include
#include
void main(void) {
#define CUSTOM_FRAGMENT_MAIN_BEGIN
#include
#include
#include
#include
#include
albedoOpacityOutParams albedoOpacityOut;
#ifdef ALBEDO
vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
#endif
#ifdef OPACITY
vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
#endif
albedoOpacityBlock(
vAlbedoColor,
#ifdef ALBEDO
albedoTexture,
vAlbedoInfos,
#endif
#ifdef OPACITY
opacityMap,
vOpacityInfos,
#endif
#ifdef DETAIL
detailColor,
vDetailInfos,
#endif
albedoOpacityOut
);
vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;
float alpha=albedoOpacityOut.alpha;
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
#include
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
ambientOcclusionOutParams aoOut;
#ifdef AMBIENT
vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
#endif
ambientOcclusionBlock(
#ifdef AMBIENT
ambientOcclusionColorMap,
vAmbientInfos,
#endif
aoOut
);
#include
#ifdef UNLIT
vec3 diffuseBase=vec3(1.,1.,1.);
#else
vec3 baseColor=surfaceAlbedo;
reflectivityOutParams reflectivityOut;
#if defined(REFLECTIVITY)
vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);
vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
#ifndef METALLICWORKFLOW
#ifdef REFLECTIVITY_GAMMA
surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
#endif
surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
#endif
#endif
#if defined(MICROSURFACEMAP)
vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
#endif
#ifdef METALLICWORKFLOW
vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
#ifdef REFLECTANCE
vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);
#ifdef REFLECTANCE_GAMMA
reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
#endif
metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
#endif
#ifdef METALLIC_REFLECTANCE
vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
#ifdef METALLIC_REFLECTANCE_GAMMA
metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
#endif
#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
#endif
metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
#endif
#endif
reflectivityBlock(
vReflectivityColor,
#ifdef METALLICWORKFLOW
surfaceAlbedo,
metallicReflectanceFactors,
#endif
#ifdef REFLECTIVITY
vReflectivityInfos,
surfaceMetallicOrReflectivityColorMap,
#endif
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
aoOut.ambientOcclusionColor,
#endif
#ifdef MICROSURFACEMAP
microSurfaceTexel,
#endif
#ifdef DETAIL
detailColor,
vDetailInfos,
#endif
reflectivityOut
);
float microSurface=reflectivityOut.microSurface;
float roughness=reflectivityOut.roughness;
#ifdef METALLICWORKFLOW
surfaceAlbedo=reflectivityOut.surfaceAlbedo;
#endif
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
#endif
#ifdef ALPHAFRESNEL
#if defined(ALPHATEST) || defined(ALPHABLEND)
alphaFresnelOutParams alphaFresnelOut;
alphaFresnelBlock(
normalW,
viewDirectionW,
alpha,
microSurface,
alphaFresnelOut
);
alpha=alphaFresnelOut.alpha;
#endif
#endif
#include
#ifdef ANISOTROPIC
anisotropicOutParams anisotropicOut;
#ifdef ANISOTROPIC_TEXTURE
vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
#endif
anisotropicBlock(
vAnisotropy,
#ifdef ANISOTROPIC_TEXTURE
anisotropyMapData,
#endif
TBN,
normalW,
viewDirectionW,
anisotropicOut
);
#endif
#ifdef REFLECTION
reflectionOutParams reflectionOut;
reflectionBlock(
vPositionW,
normalW,
alphaG,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
#ifdef ANISOTROPIC
anisotropicOut,
#endif
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
NdotVUnclamped,
#endif
#ifdef LINEARSPECULARREFLECTION
roughness,
#endif
reflectionSampler,
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
vEnvironmentIrradiance,
#endif
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
reflectionMatrix,
#endif
#endif
#ifdef USEIRRADIANCEMAP
irradianceSampler,
#endif
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
reflectionOut
);
#endif
#include
#ifdef SHEEN
sheenOutParams sheenOut;
#ifdef SHEEN_TEXTURE
vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);
#endif
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
#endif
sheenBlock(
vSheenColor,
#ifdef SHEEN_ROUGHNESS
vSheenRoughness,
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
sheenMapRoughnessData,
#endif
#endif
roughness,
#ifdef SHEEN_TEXTURE
sheenMapData,
vSheenInfos.y,
#endif
reflectance,
#ifdef SHEEN_LINKWITHALBEDO
baseColor,
surfaceAlbedo,
#endif
#ifdef ENVIRONMENTBRDF
NdotV,
environmentBrdf,
#endif
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
AARoughnessFactors,
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
vLightingIntensity,
reflectionSampler,
reflectionOut.reflectionCoords,
NdotVUnclamped,
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
seo,
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
eho,
#endif
#endif
sheenOut
);
#ifdef SHEEN_LINKWITHALBEDO
surfaceAlbedo=sheenOut.surfaceAlbedo;
#endif
#endif
clearcoatOutParams clearcoatOut;
#ifdef CLEARCOAT
#ifdef CLEARCOAT_TEXTURE
vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
#endif
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
#endif
#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
#endif
#ifdef CLEARCOAT_BUMP
vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
#endif
clearcoatBlock(
vPositionW,
geometricNormalW,
viewDirectionW,
vClearCoatParams,
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
clearCoatMapRoughnessData,
#endif
specularEnvironmentR0,
#ifdef CLEARCOAT_TEXTURE
clearCoatMapData,
#endif
#ifdef CLEARCOAT_TINT
vClearCoatTintParams,
clearCoatColorAtDistance,
vClearCoatRefractionParams,
#ifdef CLEARCOAT_TINT_TEXTURE
clearCoatTintMapData,
#endif
#endif
#ifdef CLEARCOAT_BUMP
vClearCoatBumpInfos,
clearCoatBumpMapData,
vClearCoatBumpUV,
#if defined(TANGENT) && defined(NORMAL)
vTBN,
#else
vClearCoatTangentSpaceParams,
#endif
#ifdef OBJECTSPACE_NORMALMAP
normalMatrix,
#endif
#endif
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
faceNormal,
#endif
#ifdef REFLECTION
vReflectionMicrosurfaceInfos,
vReflectionInfos,
vReflectionColor,
vLightingIntensity,
reflectionSampler,
#ifndef LODBASEDMICROSFURACE
reflectionSamplerLow,
reflectionSamplerHigh,
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#endif
#endif
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
#ifdef RADIANCEOCCLUSION
ambientMonochrome,
#endif
#endif
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
(gl_FrontFacing ? 1. : -1.),
#endif
clearcoatOut
);
#else
clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
#endif
#include
subSurfaceOutParams subSurfaceOut;
#ifdef SUBSURFACE
#ifdef SS_THICKNESSANDMASK_TEXTURE
vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
#endif
subSurfaceBlock(
vSubSurfaceIntensity,
vThicknessParam,
vTintColor,
normalW,
specularEnvironmentReflectance,
#ifdef SS_THICKNESSANDMASK_TEXTURE
thicknessMap,
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
refractionIntensityMap,
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
translucencyIntensityMap,
#endif
#ifdef REFLECTION
#ifdef SS_TRANSLUCENCY
reflectionMatrix,
#ifdef USESPHERICALFROMREFLECTIONMAP
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
reflectionOut.irradianceVector,
#endif
#if defined(REALTIME_FILTERING)
reflectionSampler,
vReflectionFilteringInfo,
#endif
#endif
#ifdef USEIRRADIANCEMAP
irradianceSampler,
#endif
#endif
#endif
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
surfaceAlbedo,
#endif
#ifdef SS_REFRACTION
vPositionW,
viewDirectionW,
view,
vRefractionInfos,
refractionMatrix,
vRefractionMicrosurfaceInfos,
vLightingIntensity,
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
alpha,
#endif
#ifdef SS_LODINREFRACTIONALPHA
NdotVUnclamped,
#endif
#ifdef SS_LINEARSPECULARREFRACTION
roughness,
#endif
alphaG,
refractionSampler,
#ifndef LODBASEDMICROSFURACE
refractionSamplerLow,
refractionSamplerHigh,
#endif
#ifdef ANISOTROPIC
anisotropicOut,
#endif
#ifdef REALTIME_FILTERING
vRefractionFilteringInfo,
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
vRefractionPosition,
vRefractionSize,
#endif
#endif
#ifdef SS_TRANSLUCENCY
vDiffusionDistance,
#endif
subSurfaceOut
);
#ifdef SS_REFRACTION
surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
alpha=subSurfaceOut.alpha;
#endif
#endif
#else
subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
#endif
#include
#include[0..maxSimultaneousLights]
#include
#endif
#include
#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
#include
#include
#include(color,finalColor)
#include
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
#ifdef PREPASS
float writeGeometryInfo=finalColor.a>0.4 ? 1.0 : 0.0;
#ifdef PREPASS_POSITION
gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
#endif
#ifdef PREPASS_VELOCITY
vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
vec2 velocity=abs(a-b);
velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
#endif
#ifdef PREPASS_ALBEDO_SQRT
vec3 sqAlbedo=sqrt(surfaceAlbedo);
#endif
#ifdef PREPASS_IRRADIANCE
vec3 irradiance=finalDiffuse;
#ifndef UNLIT
#ifdef REFLECTION
irradiance+=finalIrradiance;
#endif
#endif
#ifdef SS_SCATTERING
gl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a);
irradiance/=sqAlbedo;
#else
gl_FragData[0]=finalColor;
float scatteringDiffusionProfile=255.;
#endif
gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.);
#else
gl_FragData[0]=vec4(finalColor.rgb,finalColor.a);
#endif
#ifdef PREPASS_DEPTH
gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
#endif
#ifdef PREPASS_NORMAL
gl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo);
#endif
#ifdef PREPASS_ALBEDO_SQRT
gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo);
#endif
#ifdef PREPASS_REFLECTIVITY
#if defined(REFLECTIVITY)
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,baseReflectivity.a*writeGeometryInfo);
#else
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
#endif
#endif
#endif
#if !defined(PREPASS) || defined(WEBGL2)
gl_FragColor=finalColor;
#endif
#if ORDER_INDEPENDENT_TRANSPARENCY
if (fragDepth == nearestDepth) {
frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;
frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);
} else {
backColor+=finalColor;
}
#endif
#include
}
`;
ShaderStore.ShadersStore[name$Y] = shader$Y;
var name$X = "pbrVertexDeclaration"
, shader$X = `uniform mat4 view;
uniform mat4 viewProjection;
#ifdef ALBEDO
uniform mat4 albedoMatrix;
uniform vec2 vAlbedoInfos;
#endif
#ifdef AMBIENT
uniform mat4 ambientMatrix;
uniform vec4 vAmbientInfos;
#endif
#ifdef OPACITY
uniform mat4 opacityMatrix;
uniform vec2 vOpacityInfos;
#endif
#ifdef EMISSIVE
uniform vec2 vEmissiveInfos;
uniform mat4 emissiveMatrix;
#endif
#ifdef LIGHTMAP
uniform vec2 vLightmapInfos;
uniform mat4 lightmapMatrix;
#endif
#ifdef REFLECTIVITY
uniform vec3 vReflectivityInfos;
uniform mat4 reflectivityMatrix;
#endif
#ifdef METALLIC_REFLECTANCE
uniform vec2 vMetallicReflectanceInfos;
uniform mat4 metallicReflectanceMatrix;
#endif
#ifdef REFLECTANCE
uniform vec2 vReflectanceInfos;
uniform mat4 reflectanceMatrix;
#endif
#ifdef MICROSURFACEMAP
uniform vec2 vMicroSurfaceSamplerInfos;
uniform mat4 microSurfaceSamplerMatrix;
#endif
#ifdef BUMP
uniform vec3 vBumpInfos;
uniform mat4 bumpMatrix;
#endif
#ifdef POINTSIZE
uniform float pointSize;
#endif
#ifdef REFLECTION
uniform vec2 vReflectionInfos;
uniform mat4 reflectionMatrix;
#endif
#ifdef CLEARCOAT
#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
uniform vec4 vClearCoatInfos;
#endif
#ifdef CLEARCOAT_TEXTURE
uniform mat4 clearCoatMatrix;
#endif
#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
uniform mat4 clearCoatRoughnessMatrix;
#endif
#ifdef CLEARCOAT_BUMP
uniform vec2 vClearCoatBumpInfos;
uniform mat4 clearCoatBumpMatrix;
#endif
#ifdef CLEARCOAT_TINT_TEXTURE
uniform vec2 vClearCoatTintInfos;
uniform mat4 clearCoatTintMatrix;
#endif
#endif
#ifdef ANISOTROPIC
#ifdef ANISOTROPIC_TEXTURE
uniform vec2 vAnisotropyInfos;
uniform mat4 anisotropyMatrix;
#endif
#endif
#ifdef SHEEN
#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
uniform vec4 vSheenInfos;
#endif
#ifdef SHEEN_TEXTURE
uniform mat4 sheenMatrix;
#endif
#ifdef SHEEN_TEXTURE_ROUGHNESS
uniform mat4 sheenRoughnessMatrix;
#endif
#endif
#ifdef SUBSURFACE
#ifdef SS_REFRACTION
uniform vec4 vRefractionInfos;
uniform mat4 refractionMatrix;
#endif
#ifdef SS_THICKNESSANDMASK_TEXTURE
uniform vec2 vThicknessInfos;
uniform mat4 thicknessMatrix;
#endif
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
uniform vec2 vRefractionIntensityInfos;
uniform mat4 refractionIntensityMatrix;
#endif
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
uniform vec2 vTranslucencyIntensityInfos;
uniform mat4 translucencyIntensityMatrix;
#endif
#endif
#ifdef NORMAL
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
#ifdef USESPHERICALFROMREFLECTIONMAP
#ifdef SPHERICAL_HARMONICS
uniform vec3 vSphericalL00;
uniform vec3 vSphericalL1_1;
uniform vec3 vSphericalL10;
uniform vec3 vSphericalL11;
uniform vec3 vSphericalL2_2;
uniform vec3 vSphericalL2_1;
uniform vec3 vSphericalL20;
uniform vec3 vSphericalL21;
uniform vec3 vSphericalL22;
#else
uniform vec3 vSphericalX;
uniform vec3 vSphericalY;
uniform vec3 vSphericalZ;
uniform vec3 vSphericalXX_ZZ;
uniform vec3 vSphericalYY_ZZ;
uniform vec3 vSphericalZZ;
uniform vec3 vSphericalXY;
uniform vec3 vSphericalYZ;
uniform vec3 vSphericalZX;
#endif
#endif
#endif
#endif
#ifdef DETAIL
uniform vec4 vDetailInfos;
uniform mat4 detailMatrix;
#endif`;
ShaderStore.IncludesShadersStore[name$X] = shader$X;
var name$W = "pbrVertexShader"
, shader$W = `precision highp float;
#include<__decl__pbrVertex>
#define CUSTOM_VERTEX_BEGIN
attribute vec3 position;
#ifdef NORMAL
attribute vec3 normal;
#endif
#ifdef TANGENT
attribute vec4 tangent;
#endif
#ifdef UV1
attribute vec2 uv;
#endif
#include[2..7]
#include[1..7]
#ifdef VERTEXCOLOR
attribute vec4 color;
#endif
#include
#include
#include
#include
#include
#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)
#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity)
#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler)
#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance)
#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance)
#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
#ifdef CLEARCOAT
#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat)
#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump)
#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint)
#endif
#ifdef SHEEN
#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen)
#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
#endif
#ifdef ANISOTROPIC
#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy)
#endif
#ifdef SUBSURFACE
#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness)
#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity)
#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity)
#endif
varying vec3 vPositionW;
#if DEBUGMODE>0
varying vec4 vClipSpacePosition;
#endif
#ifdef NORMAL
varying vec3 vNormalW;
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
varying vec3 vEnvironmentIrradiance;
#include
#endif
#endif
#ifdef VERTEXCOLOR
varying vec4 vColor;
#endif
#include
#include
#include
#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
#include
#include[0..maxSimultaneousMorphTargets]
#ifdef REFLECTIONMAP_SKYBOX
varying vec3 vPositionUVW;
#endif
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
varying vec3 vDirectionW;
#endif
#include
#define CUSTOM_VERTEX_DEFINITIONS
void main(void) {
#define CUSTOM_VERTEX_MAIN_BEGIN
vec3 positionUpdated=position;
#ifdef NORMAL
vec3 normalUpdated=normal;
#endif
#ifdef TANGENT
vec4 tangentUpdated=tangent;
#endif
#ifdef UV1
vec2 uvUpdated=uv;
#endif
#include