/**
* This script includes a bundle of videojs plugins designed for hooverhigh
* HooverHighVideoPlayer 2
* Copyright oxmc.
*/
/*! @name videojs-errors @version 6.0.0 @license Apache-2.0 */
! function(e, o) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = o(require("video.js")) : "function" == typeof define && define.amd ? define(["video.js"], o) : (e = "undefined" != typeof globalThis ? globalThis : e || self).videojsErrors = o(e.videojs)
}(this, (function(e) {
"use strict";
function o(e) {
return e && "object" == typeof e && "default" in e ? e : {
default: e
}
}
var t = o(e),
i = "6.0.0";
const n = t.default.getComponent("Flash"),
r = !t.default.browser.IS_IPHONE,
s = t.default.registerPlugin || t.default.plugin,
d = {
header: "",
code: "",
message: "",
timeout: 45e3,
backgroundTimeout: 3e5,
dismiss: r,
errors: {
1: {
type: "MEDIA_ERR_ABORTED",
headline: "The video download was cancelled"
},
2: {
type: "MEDIA_ERR_NETWORK",
headline: "The video connection was lost, please confirm you are connected to the internet"
},
3: {
type: "MEDIA_ERR_DECODE",
headline: "The video is bad or in a format that cannot be played on your browser"
},
4: {
type: "MEDIA_ERR_SRC_NOT_SUPPORTED",
headline: "This video is either unavailable or not supported in this browser"
},
5: {
type: "MEDIA_ERR_ENCRYPTED",
headline: "The video you are trying to watch is encrypted and we do not know how to decrypt it"
},
unknown: {
type: "MEDIA_ERR_UNKNOWN",
headline: "An unanticipated problem was encountered, check back soon and try again"
},
"-1": {
type: "PLAYER_ERR_NO_SRC",
headline: "No video has been loaded"
},
"-2": {
type: "PLAYER_ERR_TIMEOUT",
headline: "It looks like you're having playback issues. Reloading the video may help."
},
PLAYER_ERR_DOMAIN_RESTRICTED: {
headline: "This video is restricted from playing on your current domain"
},
PLAYER_ERR_IP_RESTRICTED: {
headline: "This video is restricted at your current IP address"
},
PLAYER_ERR_GEO_RESTRICTED: {
headline: "This video is restricted from playing in your current geographic region"
},
FLASHLS_ERR_CROSS_DOMAIN: {
headline: "The video could not be loaded: crossdomain access denied."
}
}
},
a = function(e, o) {
let r, s, l;
const c = [],
u = function(e) {
o.errors = t.default.mergeOptions(o.errors, e), Object.keys(o.errors).forEach((e => {
const t = o.errors[e];
t.type || (t.type = e)
}))
};
u();
const f = function() {
e.error() && -2 === e.error().code && e.error(null), e.clearTimeout(s), e.clearTimeout(r), l && (l = !1, e.removeClass("vjs-waiting"));
const t = [1 / 0, -1],
i = (e, o) => -1 !== e.indexOf(o);
"hidden" === document.visibilityState && (e.muted() || i(t, o.backgroundTimeout)) || "visible" === document.visibilityState && i(t, o.timeout) || (s = e.setTimeout((function() {
e.error() || e.paused() || e.ended() || (l = !0, e.addClass("vjs-waiting"))
}), 1e3), r = e.setTimeout((function() {
e.error() || e.paused() || e.ended() || e.error({
code: -2,
type: "PLAYER_ERR_TIMEOUT"
})
}), "hidden" === document.visibilityState ? o.backgroundTimeout : o.timeout))
},
h = function() {
let o;
for (; c.length;) o = c.shift(), e.off(o[0], o[1]);
e.clearTimeout(r), e.clearTimeout(s)
},
p = function() {
let o = 0;
h(), f(),
function(o, t) {
const i = function() {
if (!e.error()) {
const o = e.$(".vjs-tech");
if (o && "application/x-shockwave-flash" === o.type && !o.vjs_getProperty) return void e.error({
code: -2,
type: "PLAYER_ERR_TIMEOUT"
});
if (e.paused()) return f();
if (e.ended()) return f()
}
t.call(this)
};
e.on(o, i), c.push([o, i])
}(["timeupdate", "adtimeupdate"], (function() {
const t = e.currentTime();
t !== o && (o = t, f())
})), e.off(document, "visibilitychange", p), e.on(document, "visibilitychange", p)
},
m = function() {
e.currentSrc() || e.error({
code: -1,
type: "PLAYER_ERR_NO_SRC"
})
},
v = function() {
let i = "",
r = e.error();
const s = document.createElement("div");
let d = "";
if (!r) return;
if (e.off(document, "visibilitychange", p), r = t.default.mergeOptions(r, o.errors[r.code || r.type || 0]), r.message && (i = `
${e.localize("Technical details")}\n :
${e.localize(r.message)}
\n
`), 4 === r.code && n && !n.isSupported()) {
i += `${e.localize("If you are using an older browser please try upgrading or installing Flash.")}`
}
const a = e.getChild("errorDisplay");
s.className = "vjs-errors-dialog";
const l = `
${this.localize("Error Code")}: ${r.type||r.code}
`,
c = -2 === r.code;
d = `
\n
${this.localize(r.headline)}
\n ${c?"":l}\n ${c?"":i}\n
`;
const u = a.closeable(!("dismiss" in r) || r.dismiss);
if (c) {
d += `
\n \n \n
`, s.innerHTML = d, a.fillWith(s), a.getChild("closeButton").hide();
const o = a.el().querySelector(".vjs-errors-timeout-button-container > button:first-child"),
t = a.el().querySelector(".vjs-errors-timeout-button-container > button:last-child");
e.on(o, "click", (function() {
const o = e.currentSource();
e.reset(), e.src(o)
})), e.on(t, "click", (function() {
a.close()
})), a.one("modalclose", (() => {
e.off(o), e.off(t)
}))
} else if (u) {
d += `
\n \n
`, s.innerHTML = d, a.fillWith(s), a.contentEl().firstChild.appendChild(a.getChild("closeButton").el());
const o = a.el().querySelector(".vjs-errors-ok-button");
e.on(o, "click", (function() {
a.close()
}))
} else s.innerHTML = d, a.fillWith(s);
(e.currentWidth() <= 600 || e.currentHeight() <= 250) && a.addClass("vjs-xs"), a.one("modalclose", (() => e.error(null)))
},
y = function() {
h(), e.removeClass("vjs-errors"), e.off("play", p), e.off(document, "visibilitychange", p), e.off("play", m), e.off("dispose", y), e.off(["aderror", "error"], v)
},
R = function(o) {
y(), a(e, t.default.mergeOptions(d, o))
};
R.extend = e => u(e), R.getAll = () => t.default.mergeOptions(o.errors), R.timeout = function(t) {
if (void 0 === t) return o.timeout;
t !== o.timeout && (o.timeout = t, e.paused() || p())
}, R.backgroundTimeout = function(t) {
if (void 0 === t) return o.backgroundTimeout;
t !== o.backgroundTimeout && (o.backgroundTimeout = t, e.paused() || p())
}, R.disableProgress = () => {}, e.on("play", p), e.on("play", m), e.on("dispose", y), e.on(["aderror", "contenterror", "error"], v), e.ready((() => {
e.addClass("vjs-errors")
})), e.paused() || p(), R.VERSION = i, e.errors = R
},
l = function(e) {
a(this, t.default.mergeOptions(d, e))
};
return ["extend", "getAll"].forEach((e => {
l[e] = function() {
t.default.log.warn(`The errors.${e}() method is not available until the plugin has been initialized!`)
}
})), l.VERSION = i, s("errors", l), l
}));
/* videojs-hotkeys v0.2.28 - https://github.com/ctd1500/videojs-hotkeys */
! function(e, t) {
if ("undefined" != typeof window && window.videojs) t(window.videojs);
else if ("function" == typeof define && define.amd) define("videojs-hotkeys", ["video.js"], function(e) {
return t(e.default || e)
});
else if ("undefined" != typeof module && module.exports) {
var n = require("video.js");
module.exports = t(n.default || n)
}
}(0, function(x) {
"use strict";
"undefined" != typeof window && (window.videojs_hotkeys = {
version: "0.2.28"
});
(x.registerPlugin || x.plugin)("hotkeys", function(m) {
var f = this,
y = f.el(),
v = document,
e = {
volumeStep: .1,
seekStep: 5,
enableMute: !0,
enableVolumeScroll: !0,
enableHoverScroll: !1,
enableFullscreen: !0,
enableNumbers: !0,
enableJogStyle: !1,
alwaysCaptureHotkeys: !1,
captureDocumentHotkeys: !1,
documentHotkeysFocusElementFilter: function() {
return !1
},
enableModifiersForNumbers: !0,
enableInactiveFocus: !0,
skipInitialFocus: !1,
playPauseKey: function(e) {
return 32 === e.which || 179 === e.which
},
rewindKey: function(e) {
return 37 === e.which || 177 === e.which
},
forwardKey: function(e) {
return 39 === e.which || 176 === e.which
},
volumeUpKey: function(e) {
return 38 === e.which
},
volumeDownKey: function(e) {
return 40 === e.which
},
muteKey: function(e) {
return 77 === e.which
},
fullscreenKey: function(e) {
return 70 === e.which
},
customKeys: {}
},
t = x.mergeOptions || x.util.mergeOptions,
d = (m = t(e, m || {})).volumeStep,
n = m.seekStep,
p = m.enableMute,
o = m.enableVolumeScroll,
r = m.enableHoverScroll,
b = m.enableFullscreen,
h = m.enableNumbers,
w = m.enableJogStyle,
k = m.alwaysCaptureHotkeys,
S = m.captureDocumentHotkeys,
K = m.documentHotkeysFocusElementFilter,
F = m.enableModifiersForNumbers,
u = m.enableInactiveFocus,
l = m.skipInitialFocus,
i = x.VERSION;
y.hasAttribute("tabIndex") || y.setAttribute("tabIndex", "-1"), y.style.outline = "none", !k && f.autoplay() || l || f.one("play", function() {
y.focus()
}), u && f.on("userinactive", function() {
var n = function() {
clearTimeout(e)
},
e = setTimeout(function() {
f.off("useractive", n);
var e = v.activeElement,
t = y.querySelector(".vjs-control-bar");
e && e.parentElement == t && y.focus()
}, 10);
f.one("useractive", n)
}), f.on("play", function() {
var e = y.querySelector(".iframeblocker");
e && "" === e.style.display && (e.style.display = "block", e.style.bottom = "39px")
});
var c = function(e) {
var t, n, o = e.which,
r = e.preventDefault.bind(e),
u = f.duration();
if (f.controls()) {
var l = v.activeElement;
if (k || S && K(l) || l == y || l == y.querySelector(".vjs-tech") || l == y.querySelector(".vjs-control-bar") || l == y.querySelector(".iframeblocker")) switch (j(e, f)) {
case 1:
r(), (k || S) && e.stopPropagation(), f.paused() ? E(f.play()) : f.pause();
break;
case 2:
t = !f.paused(), r(), t && f.pause(), (n = f.currentTime() - T(e)) <= 0 && (n = 0), f.currentTime(n), t && E(f.play());
break;
case 3:
t = !f.paused(), r(), t && f.pause(), u <= (n = f.currentTime() + T(e)) && (n = t ? u - .001 : u), f.currentTime(n), t && E(f.play());
break;
case 5:
r(), w ? (n = f.currentTime() - 1, f.currentTime() <= 1 && (n = 0), f.currentTime(n)) : f.volume(f.volume() - d);
break;
case 4:
r(), w ? (u <= (n = f.currentTime() + 1) && (n = u), f.currentTime(n)) : f.volume(f.volume() + d);
break;
case 6:
p && f.muted(!f.muted());
break;
case 7:
b && (f.isFullscreen() ? f.exitFullscreen() : f.requestFullscreen());
break;
default:
if ((47 < o && o < 59 || 95 < o && o < 106) && (F || !(e.metaKey || e.ctrlKey || e.altKey)) && h) {
var i = 48;
95 < o && (i = 96);
var c = o - i;
r(), f.currentTime(f.duration() * c * .1)
}
for (var a in m.customKeys) {
var s = m.customKeys[a];
s && s.key && s.handler && s.key(e) && (r(), s.handler(f, m, e))
}
}
}
},
a = !1,
s = y.querySelector(".vjs-volume-menu-button") || y.querySelector(".vjs-volume-panel");
null != s && (s.onmouseover = function() {
a = !0
}, s.onmouseout = function() {
a = !1
});
var q = function(e) {
if (r) var t = 0;
else t = v.activeElement;
if (f.controls() && (k || t == y || t == y.querySelector(".vjs-tech") || t == y.querySelector(".iframeblocker") || t == y.querySelector(".vjs-control-bar") || a) && o) {
e = window.event || e;
var n = Math.max(-1, Math.min(1, e.wheelDelta || -e.detail));
e.preventDefault(), 1 == n ? f.volume(f.volume() + d) : -1 == n && f.volume(f.volume() - d)
}
},
j = function(e, t) {
return m.playPauseKey(e, t) ? 1 : m.rewindKey(e, t) ? 2 : m.forwardKey(e, t) ? 3 : m.volumeUpKey(e, t) ? 4 : m.volumeDownKey(e, t) ? 5 : m.muteKey(e, t) ? 6 : m.fullscreenKey(e, t) ? 7 : void 0
};
function T(e) {
return "function" == typeof n ? n(e) : n
}
function E(e) {
null != e && "function" == typeof e.then && e.then(null, function(e) {})
}
if (S) {
var g = function(e) {
c(e)
};
document.addEventListener("keydown", g), this.dispose = function() {
document.removeEventListener("keydown", g)
}
} else f.on("keydown", c);
return f.on("dblclick", function(e) {
if (null != i && i <= "7.1.0" && f.controls()) {
var t = e.relatedTarget || e.toElement || v.activeElement;
t != y && t != y.querySelector(".vjs-tech") && t != y.querySelector(".iframeblocker") || b && (f.isFullscreen() ? f.exitFullscreen() : f.requestFullscreen())
}
}), f.on("mousewheel", q), f.on("DOMMouseScroll", q), this
})
});
/*! @name videojs-contrib-ads @version 6.9.0 @license Apache-2.0 */
! function(e, t) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = t(require("video.js"), require("global/window"), require("global/document")) : "function" == typeof define && define.amd ? define(["video.js", "global/window", "global/document"], t) : (e = e || self).videojsContribAds = t(e.videojs, e.window, e.document)
}(this, function(e, t, n) {
"use strict";
e = e && e.hasOwnProperty("default") ? e.default : e, t = t && t.hasOwnProperty("default") ? t.default : t, n = n && n.hasOwnProperty("default") ? n.default : n;
var a = "6.9.0";
var o = function(e, t) {
t.isImmediatePropagationStopped = function() {
return !0
}, t.cancelBubble = !0, t.isPropagationStopped = function() {
return !0
}
},
r = function(e, t, n) {
o(0, n), e.trigger({
type: t + n.type,
originalEvent: n
})
},
i = function(e, t) {
e.ads.isInAdMode() && (e.ads.isContentResuming() ? e.ads._contentEnding && r(e, "content", t) : r(e, "ad", t))
},
s = function(e, t) {
e.ads.isInAdMode() ? e.ads.isContentResuming() ? (o(0, t), e.trigger("resumeended")) : r(e, "ad", t) : e.ads._contentHasEnded || e.ads.stitchedAds() || (r(e, "content", t), e.trigger("readyforpostroll"))
},
d = function(e, t) {
if (!("loadstart" === t.type && !e.ads._hasThereBeenALoadStartDuringPlayerLife || "loadeddata" === t.type && !e.ads._hasThereBeenALoadedData || "loadedmetadata" === t.type && !e.ads._hasThereBeenALoadedMetaData))
if (e.ads.inAdBreak()) r(e, "ad", t);
else {
if (e.currentSrc() !== e.ads.contentSrc) return;
r(e, "content", t)
}
},
l = function(e, t) {
e.ads.inAdBreak() ? r(e, "ad", t) : e.ads.isContentResuming() && r(e, "content", t)
};
function u(e) {
"playing" === e.type ? i(this, e) : "ended" === e.type ? s(this, e) : "loadstart" === e.type || "loadeddata" === e.type || "loadedmetadata" === e.type ? d(this, e) : "play" === e.type ? l(this, e) : this.ads.isInAdMode() && (this.ads.isContentResuming() ? r(this, "content", e) : r(this, "ad", e))
}
var c = {},
f = function() {
! function(n) {
if (e.dom.isInFrame() && "function" != typeof t.__tcfapi) {
for (var a, o = t, r = {}; o;) {
try {
if (o.frames.__tcfapiLocator) {
a = o;
break
}
} catch (e) {}
if (o === t.top) break;
o = o.parent
}
if (!a) return;
t.__tcfapi = function(e, t, n, o) {
var i = Math.random() + "",
s = {
__tcfapiCall: {
command: e,
parameter: o,
version: t,
callId: i
}
};
r[i] = n, a.postMessage(s, "*")
}, t.addEventListener("message", function(e) {
var t = {};
try {
t = "string" == typeof e.data ? JSON.parse(e.data) : e.data
} catch (e) {}
var n = t.__tcfapiReturn;
n && "function" == typeof r[n.callId] && (r[n.callId](n.returnValue, n.success), r[n.callId] = null)
}, !1)
}
}(), "function" == typeof t.__tcfapi && t.__tcfapi("addEventListener", 2, function(e, t) {
t && (c = e)
})
},
h = function(e, t) {
return t ? encodeURIComponent(e) : e
},
p = function(e, t, n) {
if (e && e[n])
for (var a = e[n], o = Object.keys(a), r = 0; r < o.length; r++) {
t["{mediainfo." + n + "." + o[r] + "}"] = a[o[r]]
}
};
var g = {
processMetadataTracks: function(e, t) {
for (var n = e.textTracks(), a = function(n) {
"metadata" === n.kind && (e.ads.cueTextTracks.setMetadataTrackMode(n), t(e, n))
}, o = 0; o < n.length; o++) a(n[o]);
n.addEventListener("addtrack", function(e) {
a(e.track)
})
},
setMetadataTrackMode: function(e) {},
getSupportedAdCue: function(e, t) {
return t
},
isSupportedAdCue: function(e, t) {
return !0
},
getCueId: function(e, t) {
return t.id
}
},
y = function(e, t) {
return void 0 !== t && e.ads.includedCues[t]
},
v = function(e, t) {
void 0 !== t && "" !== t && (e.ads.includedCues[t] = !0)
};
function m() {
!1 !== this.ads._shouldBlockPlay && (this.paused() || (this.ads.debug("Playback was canceled by cancelContentPlay"), this.pause()), this.ads._cancelledPlay = !0)
}
g.processAdTrack = function(t, n, a, o) {
t.ads.includedCues = {};
for (var r = 0; r < n.length; r++) {
var i = n[r],
s = this.getSupportedAdCue(t, i);
if (!this.isSupportedAdCue(t, i)) return void e.log.warn("Skipping as this is not a supported ad cue.", i);
var d = this.getCueId(t, i),
l = i.startTime;
if (y(t, d)) return void e.log("Skipping ad already seen with ID " + d);
o && o(t, s, d, l), a(t, s, d, l), v(t, d)
}
};
var A = {},
S = e;
A.isMiddlewareMediatorSupported = function() {
return !S.browser.IS_IOS && !S.browser.IS_ANDROID && !!(S.use && S.middleware && S.middleware.TERMINATOR)
}, A.playMiddleware = function(t) {
return {
setSource: function(e, t) {
t(null, e)
},
callPlay: function() {
if (t.ads && !0 === t.ads._shouldBlockPlay) return t.ads.debug("Using playMiddleware to block content playback"), t.ads._playBlocked = !0, S.middleware.TERMINATOR
},
play: function(n, a) {
t.ads && t.ads._playBlocked && n ? (t.ads.debug("Play call to Tech was terminated."), t.trigger("play"), t.addClass("vjs-has-started"), t.ads._playBlocked = !1) : a && a.catch && a.catch(function(n) {
"NotAllowedError" !== n.name || e.browser.IS_SAFARI || t.trigger("pause")
})
}
}
}, A.testHook = function(e) {
S = e
};
var _ = A.playMiddleware,
P = A.isMiddlewareMediatorSupported,
b = function() {
if (e.getPlugin) return Boolean(e.getPlugin("ads"));
var t = e.getComponent("Player");
return Boolean(t && t.prototype.ads)
};
var k = function() {
function e() {}
return e.getState = function(t) {
if (t) return e.states_ && e.states_[t] ? e.states_[t] : void 0
}, e.registerState = function(t, n) {
if ("string" != typeof t || !t) throw new Error('Illegal state name, "' + t + '"; must be a non-empty string.');
return e.states_ || (e.states_ = {}), e.states_[t] = n, n
}, e
}(),
C = function() {
function t(e) {
this.player = e
}
t._getName = function() {
return "Anonymous State"
};
var n = t.prototype;
return n.transitionTo = function(e) {
var t = this.player;
this.cleanup(t);
var n = new e(t);
t.ads._state = n, t.ads.debug(this.constructor._getName() + " -> " + n.constructor._getName());
for (var a = arguments.length, o = new Array(a > 1 ? a - 1 : 0), r = 1; r < a; r++) o[r - 1] = arguments[r];
n.init.apply(n, [t].concat(o))
}, n.init = function() {}, n.cleanup = function() {}, n.onPlay = function() {}, n.onPlaying = function() {}, n.onEnded = function() {}, n.onAdEnded = function() {}, n.onAdsReady = function() {
e.log.warn("Unexpected adsready event")
}, n.onAdsError = function() {}, n.onAdsCanceled = function() {}, n.onAdTimeout = function() {}, n.onAdStarted = function() {}, n.onContentChanged = function() {}, n.onContentResumed = function() {}, n.onReadyForPostroll = function() {
e.log.warn("Unexpected readyforpostroll event")
}, n.onNoPreroll = function() {}, n.onNoPostroll = function() {}, n.startLinearAdMode = function() {
e.log.warn("Unexpected startLinearAdMode invocation (State via " + this.constructor._getName() + ")")
}, n.endLinearAdMode = function() {
e.log.warn("Unexpected endLinearAdMode invocation (State via " + this.constructor._getName() + ")")
}, n.skipLinearAdMode = function() {
e.log.warn("Unexpected skipLinearAdMode invocation (State via " + this.constructor._getName() + ")")
}, n.isAdState = function() {
throw new Error("isAdState unimplemented for " + this.constructor._getName())
}, n.isWaitingForAdBreak = function() {
return !1
}, n.isContentResuming = function() {
return !1
}, n.inAdBreak = function() {
return !1
}, n.handleEvent = function(e) {
var t = this.player;
"play" === e ? this.onPlay(t) : "adsready" === e ? this.onAdsReady(t) : "adserror" === e ? this.onAdsError(t) : "adscanceled" === e ? this.onAdsCanceled(t) : "adtimeout" === e ? this.onAdTimeout(t) : "ads-ad-started" === e ? this.onAdStarted(t) : "contentchanged" === e ? this.onContentChanged(t) : "contentresumed" === e ? this.onContentResumed(t) : "readyforpostroll" === e ? this.onReadyForPostroll(t) : "playing" === e ? this.onPlaying(t) : "ended" === e ? this.onEnded(t) : "nopreroll" === e ? this.onNoPreroll(t) : "nopostroll" === e ? this.onNoPostroll(t) : "adended" === e && this.onAdEnded(t)
}, t
}();
function T(e, t) {
e.prototype = Object.create(t.prototype), e.prototype.constructor = e, e.__proto__ = t
}
k.registerState("State", C);
var w = function(e) {
function t(t) {
var n;
return (n = e.call(this, t) || this).contentResuming = !1, n.waitingForAdBreak = !1, n
}
T(t, e);
var n = t.prototype;
return n.isAdState = function() {
return !0
}, n.onPlaying = function() {
var e = k.getState("ContentPlayback");
this.contentResuming && this.transitionTo(e)
}, n.onContentResumed = function() {
var e = k.getState("ContentPlayback");
this.contentResuming && this.transitionTo(e)
}, n.isWaitingForAdBreak = function() {
return this.waitingForAdBreak
}, n.isContentResuming = function() {
return this.contentResuming
}, n.inAdBreak = function() {
return !0 === this.player.ads._inLinearAdMode
}, t
}(C);
k.registerState("AdState", w);
var R = function(e) {
function t() {
return e.apply(this, arguments) || this
}
T(t, e);
var n = t.prototype;
return n.isAdState = function() {
return !1
}, n.onContentChanged = function(e) {
var t = k.getState("BeforePreroll"),
n = k.getState("Preroll");
e.ads.debug("Received contentchanged event (ContentState)"), e.paused() ? this.transitionTo(t) : (this.transitionTo(n, !1), e.pause(), e.ads._pausedOnContentupdate = !0)
}, t
}(C);
k.registerState("ContentState", R);
var L, B = function(t) {
function n() {
return t.apply(this, arguments) || this
}
T(n, t), n._getName = function() {
return "AdsDone"
};
var a = n.prototype;
return a.init = function(e) {
e.ads._contentHasEnded = !0, e.trigger("ended")
}, a.startLinearAdMode = function() {
e.log.warn("Unexpected startLinearAdMode invocation (AdsDone)")
}, n
}(k.getState("ContentState"));
k.registerState("AdsDone", B);
var M = {
start: function(t) {
t.ads.debug("Starting ad break"), t.ads._inLinearAdMode = !0, t.trigger("adstart"), t.ads.shouldTakeSnapshots() && (t.ads.snapshot = function(t) {
var n;
n = e.browser.IS_IOS && t.ads.isLive(t) && t.seekable().length > 0 ? t.currentTime() - t.seekable().end(0) : t.currentTime();
var a = t.$(".vjs-tech"),
o = t.textTracks ? t.textTracks() : [],
r = [],
i = {
ended: t.ended(),
currentSrc: t.currentSrc(),
sources: t.currentSources(),
src: t.tech_.src(),
currentTime: n,
type: t.currentType()
};
a && (i.style = a.getAttribute("style"));
for (var s = 0; s < o.length; s++) {
var d = o[s];
r.push({
track: d,
mode: d.mode
}), d.mode = "disabled"
}
return i.suppressedTracks = r, i
}(t)), t.ads.shouldPlayContentBehindAd(t) && (t.ads.preAdVolume_ = t.volume(), t.volume(0)), t.addClass("vjs-ad-playing"), t.hasClass("vjs-live") && t.removeClass("vjs-live"), t.ads.removeNativePoster()
},
end: function(t, n) {
t.ads.debug("Ending ad break"), void 0 === n && (n = function() {}), t.ads.adType = null, t.ads._inLinearAdMode = !1, t.trigger("adend"), t.removeClass("vjs-ad-playing"), t.ads.isLive(t) && t.addClass("vjs-live"), t.ads.shouldTakeSnapshots() ? function(t, n) {
var a = t.ads.snapshot;
if (void 0 === n && (n = function() {}), !0 === t.ads.disableNextSnapshotRestore) return t.ads.disableNextSnapshotRestore = !1, delete t.ads.snapshot, void n();
var o, r = t.$(".vjs-tech"),
i = 20,
s = a.suppressedTracks,
d = function() {
for (var e = 0; e < s.length; e++)(o = s[e]).track.mode = o.mode
},
l = function() {
var n;
if (e.browser.IS_IOS && t.ads.isLive(t)) {
if (a.currentTime < 0 && (n = t.seekable().length > 0 ? t.seekable().end(0) + a.currentTime : t.currentTime(), t.currentTime(n)), t.paused()) {
var o = t.play();
o && o.catch && o.catch(function(t) {
e.log.warn("Play promise rejected in IOS snapshot resume", t)
})
}
} else if (a.ended) t.currentTime(t.duration());
else {
t.currentTime(a.currentTime);
var r = t.play();
r && r.catch && r.catch(function(t) {
e.log.warn("Play promise rejected in snapshot resume", t)
})
}
t.ads.shouldRemoveAutoplay_ && (t.autoplay(!1), t.ads.shouldRemoveAutoplay_ = !1)
},
u = function n() {
if (t.off("contentcanplay", n), L && t.clearTimeout(L), (r = t.el().querySelector(".vjs-tech")).readyState > 1) return l();
if (void 0 === r.seekable) return l();
if (r.seekable.length > 0) return l();
if (i--) t.setTimeout(n, 50);
else try {
l()
} catch (t) {
e.log.warn("Failed to resume the content after an advertisement", t)
}
};
if ("style" in a && r.setAttribute("style", a.style || ""), t.ads.videoElementRecycled()) t.one("resumeended", function() {
delete t.ads.snapshot, n()
}), t.one("contentloadedmetadata", d), e.browser.IS_IOS && !t.autoplay() && (t.autoplay(!0), t.ads.shouldRemoveAutoplay_ = !0), t.src(a.sources), t.one("contentcanplay", u), L = t.setTimeout(u, 2e3);
else {
if (d(), !t.ended()) {
var c = t.play();
c && c.catch && c.catch(function(t) {
e.log.warn("Play promise rejected in snapshot restore", t)
})
}
delete t.ads.snapshot, n()
}
}(t, n) : (t.volume(t.ads.preAdVolume_), n())
}
},
j = function(t) {
function n() {
return t.apply(this, arguments) || this
}
T(n, t), n._getName = function() {
return "Preroll"
};
var a = n.prototype;
return a.init = function(e, t, n) {
if (this.waitingForAdBreak = !0, e.addClass("vjs-ad-loading"), n || e.ads.nopreroll_) return this.resumeAfterNoPreroll(e);
var a = e.ads.settings.timeout;
"number" == typeof e.ads.settings.prerollTimeout && (a = e.ads.settings.prerollTimeout), this._timeout = e.setTimeout(function() {
e.trigger("adtimeout")
}, a), t ? this.handleAdsReady() : this.adsReady = !1
}, a.onAdsReady = function(t) {
t.ads.inAdBreak() ? e.log.warn("Unexpected adsready event (Preroll)") : (t.ads.debug("Received adsready event (Preroll)"), this.handleAdsReady())
}, a.handleAdsReady = function() {
this.adsReady = !0, this.readyForPreroll()
}, a.afterLoadStart = function(e) {
var t = this.player;
t.ads._hasThereBeenALoadStartDuringPlayerLife ? e() : (t.ads.debug("Waiting for loadstart..."), t.one("loadstart", function() {
t.ads.debug("Received loadstart event"), e()
}))
}, a.noPreroll = function() {
var e = this;
this.afterLoadStart(function() {
e.player.ads.debug("Skipping prerolls due to nopreroll event (Preroll)"), e.resumeAfterNoPreroll(e.player)
})
}, a.readyForPreroll = function() {
var e = this.player;
this.afterLoadStart(function() {
e.ads.debug("Triggered readyforpreroll event (Preroll)"), e.trigger("readyforpreroll")
})
}, a.onAdsCanceled = function(e) {
var t = this;
e.ads.debug("adscanceled (Preroll)"), this.afterLoadStart(function() {
t.resumeAfterNoPreroll(e)
})
}, a.onAdsError = function(t) {
var n = this;
e.log("adserror (Preroll)"), this.inAdBreak() ? t.ads.endLinearAdMode() : this.afterLoadStart(function() {
n.resumeAfterNoPreroll(t)
})
}, a.startLinearAdMode = function() {
var t = this.player;
!this.adsReady || t.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected startLinearAdMode invocation (Preroll)") : (this.clearTimeout(t), t.ads.adType = "preroll", this.waitingForAdBreak = !1, M.start(t), t.ads._shouldBlockPlay = !1)
}, a.onAdStarted = function(e) {
e.removeClass("vjs-ad-loading")
}, a.endLinearAdMode = function() {
var e = this.player;
this.inAdBreak() && (e.removeClass("vjs-ad-loading"), e.addClass("vjs-ad-content-resuming"), this.contentResuming = !0, M.end(e))
}, a.skipLinearAdMode = function() {
var t = this,
n = this.player;
n.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected skipLinearAdMode invocation") : this.afterLoadStart(function() {
n.trigger("adskip"), n.ads.debug("skipLinearAdMode (Preroll)"), t.resumeAfterNoPreroll(n)
})
}, a.onAdTimeout = function(e) {
var t = this;
this.afterLoadStart(function() {
e.ads.debug("adtimeout (Preroll)"), t.resumeAfterNoPreroll(e)
})
}, a.onNoPreroll = function(t) {
t.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected nopreroll event (Preroll)") : this.noPreroll()
}, a.resumeAfterNoPreroll = function(e) {
if (this.contentResuming = !0, e.ads._shouldBlockPlay = !1, this.cleanupPartial(e), e.ads._playRequested || e.ads._pausedOnContentupdate)
if (e.paused()) {
e.ads.debug("resumeAfterNoPreroll: attempting to resume playback (Preroll)");
var t = e.play();
t && t.then && t.then(null, function(e) {})
} else e.ads.debug("resumeAfterNoPreroll: already playing (Preroll)"), e.trigger("play"), e.trigger("playing")
}, a.cleanup = function(t) {
t.ads._hasThereBeenALoadStartDuringPlayerLife || e.log.warn("Leaving Preroll state before loadstart event can cause issues."), this.cleanupPartial(t)
}, a.cleanupPartial = function(e) {
e.removeClass("vjs-ad-loading"), e.removeClass("vjs-ad-content-resuming"), this.clearTimeout(e)
}, a.clearTimeout = function(e) {
e.clearTimeout(this._timeout), this._timeout = null
}, n
}(k.getState("AdState"));
k.registerState("Preroll", j);
var I = function(e) {
function t() {
return e.apply(this, arguments) || this
}
T(t, e), t._getName = function() {
return "BeforePreroll"
};
var n = t.prototype;
return n.init = function(e) {
this.adsReady = !1, this.shouldResumeToContent = !1, e.ads._shouldBlockPlay = !e.ads.settings.allowVjsAutoplay || !e.autoplay()
}, n.onAdsReady = function(e) {
e.ads.debug("Received adsready event (BeforePreroll)"), this.adsReady = !0
}, n.onPlay = function(e) {
var t = k.getState("Preroll");
e.ads.debug("Received play event (BeforePreroll)"), this.transitionTo(t, this.adsReady, this.shouldResumeToContent)
}, n.onAdsCanceled = function(e) {
e.ads.debug("adscanceled (BeforePreroll)"), this.shouldResumeToContent = !0
}, n.onAdsError = function() {
this.player.ads.debug("adserror (BeforePreroll)"), this.shouldResumeToContent = !0
}, n.onNoPreroll = function() {
this.player.ads.debug("Skipping prerolls due to nopreroll event (BeforePreroll)"), this.shouldResumeToContent = !0
}, n.skipLinearAdMode = function() {
var e = this.player;
e.trigger("adskip"), e.ads.debug("skipLinearAdMode (BeforePreroll)"), this.shouldResumeToContent = !0
}, n.onContentChanged = function() {
this.init(this.player)
}, t
}(k.getState("ContentState"));
k.registerState("BeforePreroll", I);
var N = function(e) {
function t() {
return e.apply(this, arguments) || this
}
T(t, e), t._getName = function() {
return "Midroll"
};
var n = t.prototype;
return n.init = function(e) {
e.ads.adType = "midroll", M.start(e), e.addClass("vjs-ad-loading")
}, n.onAdStarted = function(e) {
e.removeClass("vjs-ad-loading")
}, n.endLinearAdMode = function() {
var e = this.player;
this.inAdBreak() && (this.contentResuming = !0, e.addClass("vjs-ad-content-resuming"), e.removeClass("vjs-ad-loading"), M.end(e))
}, n.onAdsError = function(e) {
this.inAdBreak() && e.ads.endLinearAdMode()
}, n.cleanup = function(e) {
e.removeClass("vjs-ad-loading"), e.removeClass("vjs-ad-content-resuming")
}, t
}(k.getState("AdState"));
k.registerState("Midroll", N);
var E = function(t) {
function n() {
return t.apply(this, arguments) || this
}
T(n, t), n._getName = function() {
return "Postroll"
};
var a = n.prototype;
return a.init = function(e) {
if (this.waitingForAdBreak = !0, e.ads._contentEnding = !0, e.ads.nopostroll_) {
this.resumeContent(e);
var t = k.getState("AdsDone");
this.transitionTo(t)
} else {
e.addClass("vjs-ad-loading");
var n = e.ads.settings.timeout;
"number" == typeof e.ads.settings.postrollTimeout && (n = e.ads.settings.postrollTimeout), this._postrollTimeout = e.setTimeout(function() {
e.trigger("adtimeout")
}, n)
}
}, a.startLinearAdMode = function() {
var t = this.player;
t.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected startLinearAdMode invocation (Postroll)") : (t.ads.adType = "postroll", t.clearTimeout(this._postrollTimeout), this.waitingForAdBreak = !1, M.start(t))
}, a.onAdStarted = function(e) {
e.removeClass("vjs-ad-loading")
}, a.endLinearAdMode = function() {
var e = this,
t = this.player,
n = k.getState("AdsDone");
this.inAdBreak() && (t.removeClass("vjs-ad-loading"), this.resumeContent(t), M.end(t, function() {
e.transitionTo(n)
}))
}, a.skipLinearAdMode = function() {
var t = this.player;
t.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected skipLinearAdMode invocation") : (t.ads.debug("Postroll abort (skipLinearAdMode)"), t.trigger("adskip"), this.abort(t))
}, a.onAdTimeout = function(e) {
e.ads.debug("Postroll abort (adtimeout)"), this.abort(e)
}, a.onAdsError = function(e) {
e.ads.debug("Postroll abort (adserror)"), e.ads.inAdBreak() ? e.ads.endLinearAdMode() : this.abort(e)
}, a.onContentChanged = function(e) {
if (this.isContentResuming()) {
var t = k.getState("BeforePreroll");
this.transitionTo(t)
} else if (!this.inAdBreak()) {
var n = k.getState("Preroll");
this.transitionTo(n)
}
}, a.onNoPostroll = function(t) {
this.isContentResuming() || this.inAdBreak() ? e.log.warn("Unexpected nopostroll event (Postroll)") : this.abort(t)
}, a.resumeContent = function(e) {
this.contentResuming = !0, e.addClass("vjs-ad-content-resuming")
}, a.abort = function(e) {
var t = k.getState("AdsDone");
this.resumeContent(e), e.removeClass("vjs-ad-loading"), this.transitionTo(t)
}, a.cleanup = function(e) {
e.removeClass("vjs-ad-content-resuming"), e.clearTimeout(this._postrollTimeout), e.ads._contentEnding = !1
}, n
}(k.getState("AdState"));
k.registerState("Postroll", E);
var x = function(e) {
function t() {
return e.apply(this, arguments) || this
}
T(t, e), t._getName = function() {
return "ContentPlayback"
};
var n = t.prototype;
return n.init = function(e) {
e.ads._shouldBlockPlay = !1
}, n.onAdsReady = function(e) {
e.ads.debug("Received adsready event (ContentPlayback)"), e.ads.nopreroll_ || (e.ads.debug("Triggered readyforpreroll event (ContentPlayback)"), e.trigger("readyforpreroll"))
}, n.onReadyForPostroll = function(e) {
var t = k.getState("Postroll");
e.ads.debug("Received readyforpostroll event"), this.transitionTo(t)
}, n.startLinearAdMode = function() {
var e = k.getState("Midroll");
this.transitionTo(e)
}, t
}(k.getState("ContentState"));
k.registerState("ContentPlayback", x);
var D = function(e) {
function t() {
return e.apply(this, arguments) || this
}
T(t, e), t._getName = function() {
return "StitchedContentPlayback"
};
var n = t.prototype;
return n.init = function() {
this.player.ads._shouldBlockPlay = !1
}, n.onContentChanged = function() {
this.player.ads.debug("Received contentchanged event (" + this.constructor._getName() + ")")
}, n.startLinearAdMode = function() {
var e = k.getState("StitchedAdRoll");
this.transitionTo(e)
}, t
}(k.getState("ContentState"));
k.registerState("StitchedContentPlayback", D);
var O = function(e) {
function t() {
return e.apply(this, arguments) || this
}
T(t, e), t._getName = function() {
return "StitchedAdRoll"
};
var n = t.prototype;
return n.init = function() {
this.waitingForAdBreak = !1, this.contentResuming = !1, this.player.ads.adType = "stitched", M.start(this.player)
}, n.onPlaying = function() {}, n.onContentResumed = function() {}, n.onAdEnded = function() {
this.endLinearAdMode(), this.player.trigger("ended")
}, n.endLinearAdMode = function() {
var e = k.getState("StitchedContentPlayback");
M.end(this.player), this.transitionTo(e)
}, t
}(k.getState("AdState"));
k.registerState("StitchedAdRoll", O);
var F = A.isMiddlewareMediatorSupported,
U = e.getTech("Html5").Events,
V = {
timeout: 5e3,
prerollTimeout: void 0,
postrollTimeout: void 0,
debug: !1,
stitchedAds: !1,
contentIsLive: void 0,
liveCuePoints: !0,
allowVjsAutoplay: e.options.normalizeAutoplay || !1
},
q = function(o) {
var r = this,
i = e.mergeOptions(V, o),
s = [];
U.concat(["firstplay", "loadedalldata"]).forEach(function(e) {
-1 === s.indexOf(e) && s.push(e)
}), r.on(s, u), F() || function(t, n) {
n && e.log("Using cancelContentPlay to block content playback"), t.on("play", m)
}(r, i.debug), r.setTimeout(function() {
r.ads._hasThereBeenALoadStartDuringPlayerLife || "" === r.src() || e.log.error("videojs-contrib-ads has not seen a loadstart event 5 seconds after being initialized, but a source is present. This indicates that videojs-contrib-ads was initialized too late. It must be initialized immediately after video.js in the same tick. As a result, some ads will not play and some media events will be incorrect. For more information, see http://videojs.github.io/videojs-contrib-ads/integrator/getting-started.html")
}, 5e3), r.on("ended", function() {
r.hasClass("vjs-has-started") || r.addClass("vjs-has-started")
}), r.on("contenttimeupdate", function() {
r.removeClass("vjs-waiting")
}), r.on(["addurationchange", "adcanplay"], function() {
if (!r.ads.settings.stitchedAds && !r.hasStarted() && (!r.ads.snapshot || r.currentSrc() !== r.ads.snapshot.currentSrc) && r.ads.inAdBreak()) {
var t = r.play();
t && t.catch && t.catch(function(t) {
e.log.warn("Play promise rejected when playing ad", t)
})
}
}), r.on("nopreroll", function() {
r.ads.debug("Received nopreroll event"), r.ads.nopreroll_ = !0
}), r.on("nopostroll", function() {
r.ads.debug("Received nopostroll event"), r.ads.nopostroll_ = !0
}), r.on("playing", function() {
r.ads._cancelledPlay = !1, r.ads._pausedOnContentupdate = !1
}), r.on("play", function() {
r.ads._playRequested = !0
}), r.one("loadstart", function() {
r.ads._hasThereBeenALoadStartDuringPlayerLife = !0
}), r.on("loadeddata", function() {
r.ads._hasThereBeenALoadedData = !0
}), r.on("loadedmetadata", function() {
r.ads._hasThereBeenALoadedMetaData = !0
}), r.ads = function(t) {
return {
disableNextSnapshotRestore: !1,
_contentEnding: !1,
_contentHasEnded: !1,
_hasThereBeenALoadStartDuringPlayerLife: !1,
_hasThereBeenALoadedData: !1,
_hasThereBeenALoadedMetaData: !1,
_inLinearAdMode: !1,
_shouldBlockPlay: !1,
_playBlocked: !1,
_playRequested: !1,
adType: null,
VERSION: a,
reset: function() {
t.ads.disableNextSnapshotRestore = !1, t.ads._contentEnding = !1, t.ads._contentHasEnded = !1, t.ads.snapshot = null, t.ads.adType = null, t.ads._hasThereBeenALoadedData = !1, t.ads._hasThereBeenALoadedMetaData = !1, t.ads._cancelledPlay = !1, t.ads._shouldBlockPlay = !1, t.ads._playBlocked = !1, t.ads.nopreroll_ = !1, t.ads.nopostroll_ = !1, t.ads._playRequested = !1
},
startLinearAdMode: function() {
t.ads._state.startLinearAdMode()
},
endLinearAdMode: function() {
t.ads._state.endLinearAdMode()
},
skipLinearAdMode: function() {
t.ads._state.skipLinearAdMode()
},
stitchedAds: function(t) {
return void 0 !== t && (e.log.warn("Using player.ads.stitchedAds() as a setter is deprecated, it should be set as an option upon initialization of contrib-ads."), this.settings.stitchedAds = !!t), this.settings.stitchedAds
},
videoElementRecycled: function() {
if (t.ads.shouldPlayContentBehindAd(t)) return !1;
if (!this.snapshot) throw new Error("You cannot use videoElementRecycled while there is no snapshot.");
var e = t.tech_.src() !== this.snapshot.src,
n = t.currentSrc() !== this.snapshot.currentSrc;
return e || n
},
isLive: function(n) {
return void 0 === n && (n = t), "boolean" == typeof n.ads.settings.contentIsLive ? n.ads.settings.contentIsLive : n.duration() === 1 / 0 || "8" === e.browser.IOS_VERSION && 0 === n.duration()
},
shouldPlayContentBehindAd: function(n) {
if (void 0 === n && (n = t), n) return !!n.ads.settings.liveCuePoints && !e.browser.IS_IOS && !e.browser.IS_ANDROID && n.duration() === 1 / 0;
throw new Error("shouldPlayContentBehindAd requires a player as a param")
},
shouldTakeSnapshots: function(e) {
return void 0 === e && (e = t), !this.shouldPlayContentBehindAd(e) && !this.stitchedAds()
},
isInAdMode: function() {
return this._state.isAdState()
},
isWaitingForAdBreak: function() {
return this._state.isWaitingForAdBreak()
},
isContentResuming: function() {
return this._state.isContentResuming()
},
isAdPlaying: function() {
return this._state.inAdBreak()
},
inAdBreak: function() {
return this._state.inAdBreak()
},
removeNativePoster: function() {
var e = t.$(".vjs-tech");
e && e.removeAttribute("poster")
},
debug: function() {
if (this.settings.debug) {
for (var t = arguments.length, n = new Array(t), a = 0; a < t; a++) n[a] = arguments[a];
1 === n.length && "string" == typeof n[0] ? e.log("ADS: " + n[0]) : e.log.apply(e, ["ADS:"].concat(n))
}
}
}
}(r), r.ads.settings = i, i.stitchedAds = !!i.stitchedAds, i.stitchedAds ? r.ads._state = new(k.getState("StitchedContentPlayback"))(r) : r.ads._state = new(k.getState("BeforePreroll"))(r), r.ads._state.init(r), r.ads.cueTextTracks = g, r.ads.adMacroReplacement = function(a, o, r) {
var i = this,
s = {};
a = a.replace(/{([^}=]+)=([^}]+)}/g, function(e, t, n) {
return s["{" + t + "}"] = n, "{" + t + "}"
}), void 0 === o && (o = !1);
var d = {};
for (var l in void 0 !== r && (d = r), d["{player.id}"] = this.options_["data-player"] || this.id_, d["{player.height}"] = this.currentHeight(), d["{player.width}"] = this.currentWidth(), d["{mediainfo.id}"] = this.mediainfo ? this.mediainfo.id : "", d["{mediainfo.name}"] = this.mediainfo ? this.mediainfo.name : "", d["{mediainfo.duration}"] = this.mediainfo ? this.mediainfo.duration : "", d["{player.duration}"] = this.duration(), d["{player.pageUrl}"] = e.dom.isInFrame() ? n.referrer : t.location.href, d["{playlistinfo.id}"] = this.playlistinfo ? this.playlistinfo.id : "", d["{playlistinfo.name}"] = this.playlistinfo ? this.playlistinfo.name : "", d["{timestamp}"] = (new Date).getTime(), d["{document.referrer}"] = n.referrer, d["{window.location.href}"] = t.location.href, d["{random}"] = Math.floor(1e12 * Math.random()), ["description", "tags", "reference_id", "ad_keys"].forEach(function(e) {
i.mediainfo && i.mediainfo[e] ? d["{mediainfo." + e + "}"] = i.mediainfo[e] : s["{mediainfo." + e + "}"] ? d["{mediainfo." + e + "}"] = s["{mediainfo." + e + "}"] : d["{mediainfo." + e + "}"] = ""
}), p(this.mediainfo, d, "custom_fields"), p(this.mediainfo, d, "customFields"), Object.keys(c).forEach(function(e) {
d["{tcf." + e + "}"] = c[e]
}), d["{tcf.gdprAppliesInt}"] = c.gdprApplies ? 1 : 0, d) a = a.split(l).join(h(d[l], o));
for (var u in a = a.replace(/{pageVariable\.([^}]+)}/g, function(n, a) {
for (var r, i = t, d = a.split("."), l = 0; l < d.length; l++) l === d.length - 1 ? r = i[d[l]] : i = i[d[l]];
var u = typeof r;
return null === r ? "null" : void 0 === r ? s["{pageVariable." + a + "}"] ? s["{pageVariable." + a + "}"] : (e.log.warn('Page variable "' + a + '" not found'), "") : "string" !== u && "number" !== u && "boolean" !== u ? (e.log.warn('Page variable "' + a + '" is not a supported type'), "") : h(String(r), o)
}), s) a = a.replace(u, s[u]);
return a
}.bind(r),
function(e) {
e.ads.contentSrc = e.currentSrc(), e.ads._seenInitialLoadstart = !1, e.on("loadstart", function() {
if (!e.ads.inAdBreak()) {
var t = e.currentSrc();
t !== e.ads.contentSrc && (e.ads._seenInitialLoadstart && e.trigger({
type: "contentchanged"
}), e.trigger({
type: "contentupdate",
oldValue: e.ads.contentSrc,
newValue: t
}), e.ads.contentSrc = t), e.ads._seenInitialLoadstart = !0
}
})
}(r), r.on("contentchanged", r.ads.reset);
var d = function() {
var t = r.textTracks();
if (!r.ads.shouldPlayContentBehindAd(r) && r.ads.inAdBreak() && r.tech_.featuresNativeTextTracks && e.browser.IS_IOS && !Array.isArray(r.textTracks()))
for (var n = 0; n < t.length; n++) {
var a = t[n];
"showing" === a.mode && (a.mode = "disabled")
}
};
r.ready(function() {
r.textTracks().addEventListener("change", d)
}), r.on(["play", "playing", "ended", "adsready", "adscanceled", "adskip", "adserror", "adtimeout", "adended", "ads-ad-started", "contentchanged", "dispose", "contentresumed", "readyforpostroll", "nopreroll", "nopostroll"], function(e) {
r.ads._state.handleEvent(e.type)
}), r.on("dispose", function() {
r.ads.reset(), r.textTracks().removeEventListener("change", d)
}), f(), r.ads.listenToTcf = f
};
return q.VERSION = a,
function(t) {
!b(e) && ((e.registerPlugin || e.plugin)("ads", t), P() && !e.usingContribAdsMiddleware_ && (e.use("*", _), e.usingContribAdsMiddleware_ = !0, e.log.debug("Play middleware has been registered with videojs")))
}(q), q
});
/*! @name @viostream/videojs-overlay @version v2.1.6-f.97-master @license Apache-2.0 */
! function(t, e) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = e(require("video.js")) : "function" == typeof define && define.amd ? define(["video.js"], e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).videojsOverlay = e(t.videojs)
}(this, (function(t) {
"use strict";
function e(t) {
return t && "object" == typeof t && "default" in t ? t : {
default: t
}
}
var n = e(t);
function i(t, e, n) {
return t(n = {
path: e,
exports: {},
require: function(t, e) {
return function() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")
}(null == e && n.path)
}
}, n.exports), n.exports
}
var o = i((function(t) {
t.exports = function(t) {
if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return t
}, t.exports.default = t.exports, t.exports.__esModule = !0
})),
r = i((function(t) {
function e(n, i) {
return t.exports = e = Object.setPrototypeOf || function(t, e) {
return t.__proto__ = e, t
}, t.exports.default = t.exports, t.exports.__esModule = !0, e(n, i)
}
t.exports = e, t.exports.default = t.exports, t.exports.__esModule = !0
})),
s = i((function(t) {
t.exports = function(t, e) {
t.prototype = Object.create(e.prototype), t.prototype.constructor = t, r(t, e)
}, t.exports.default = t.exports, t.exports.__esModule = !0
})),
a = {
align: "top-left",
class: "",
content: "This overlay will show up while the video is playing",
debug: !1,
showBackground: !0,
attachToControlBar: !1,
overlays: [{
start: "playing",
end: "paused"
}]
},
h = n.default.getComponent("Component"),
d = n.default.dom || n.default,
l = n.default.registerPlugin || n.default.plugin,
u = function(t) {
return "number" == typeof t && t == t
},
p = function(t) {
return "string" == typeof t && /^\S+$/.test(t)
},
c = function(t) {
function e(n, i) {
var r;
return (r = t.call(this, n, i) || this).isVisible = !0, ["start", "end"].forEach((function(t) {
var e = r.options_[t];
if (u(e)) r[t + "Event_"] = "timeupdate";
else if (p(e)) r[t + "Event_"] = e;
else if ("start" === t) throw new Error('invalid "start" option; expected number or string')
})), ["endListener_", "rewindListener_", "startListener_"].forEach((function(t) {
r[t] = function(n) {
return e.prototype[t].call(o(r), n)
}
})), "timeupdate" === r.startEvent_ && r.on(n, "timeupdate", r.rewindListener_), r.debug('created, listening to "' + r.startEvent_ + '" for "start" and "' + (r.endEvent_ || "nothing") + '" for "end"'), r.hide(), r
}
s(e, t);
var i = e.prototype;
return i.createEl = function() {
var t = this.options_,
e = t.content,
n = t.showBackground ? "vjs-overlay-background" : "vjs-overlay-no-background",
i = d.createEl("div", {
className: "\n vjs-overlay\n vjs-overlay-" + t.align + "\n " + t.class + "\n " + n + "\n vjs-hidden\n "
});
return "string" == typeof e ? i.innerHTML = e : e instanceof window.DocumentFragment ? i.appendChild(e) : d.appendContent(i, e), i
}, i.debug = function() {
if (this.options_.debug) {
for (var t = n.default.log, e = t, i = arguments.length, o = new Array(i), r = 0; r < i; r++) o[r] = arguments[r];
t.hasOwnProperty(o[0]) && "function" == typeof t[o[0]] && (e = t[o.shift()]), e.apply(void 0, ["overlay#" + this.id() + ": "].concat(o))
}
}, i.hide = function() {
if (!1 !== this.isVisible) return t.prototype.hide.call(this), this.isVisible = !1, this.debug("hidden"), this.debug('bound `startListener_` to "' + this.startEvent_ + '"'), u(this.options_.end) && (this.player().paused() || this.player().trigger("hide-overlay", {
id: this.options_.cta_id,
align: this.options_.align
})), this.endEvent_ && (this.debug('unbound `endListener_` from "' + this.endEvent_ + '"'), this.off(this.player(), this.endEvent_, this.endListener_)), this.on(this.player(), this.startEvent_, this.startListener_), this
}, i.shouldHide_ = function(t, e) {
var n = this.options_.end;
return u(n) ? t >= n : n === e
}, i.show = function() {
return t.prototype.show.call(this), this.isVisible = !0, this.off(this.player(), this.startEvent_, this.startListener_), this.debug("shown"), this.debug('unbound `startListener_` from "' + this.startEvent_ + '"'), u(this.options_.start) && (this.player().paused() && 0 !== this.options_.start || this.player().trigger("show-overlay", {
id: this.options_.cta_id,
align: this.options_.align
})), this.endEvent_ && (this.debug('bound `endListener_` to "' + this.endEvent_ + '"'), this.on(this.player(), this.endEvent_, this.endListener_)), this
}, i.shouldShow_ = function(t, e) {
var n = this.options_.start,
i = this.options_.end;
return u(n) ? u(i) ? t >= n && t < i : this.hasShownSinceSeek_ ? Math.floor(t) === n : (this.hasShownSinceSeek_ = !0, t >= n) : n === e
}, i.startListener_ = function(t) {
var e = this.player().currentTime();
this.shouldShow_(e, t.type) && this.show()
}, i.endListener_ = function(t) {
var e = this.player().currentTime();
this.shouldHide_(e, t.type) && this.hide()
}, i.rewindListener_ = function(t) {
var e = this.player().currentTime(),
n = this.previousTime_,
i = this.options_.start,
o = this.options_.end;
e < n && (this.debug("rewind detected"), u(o) && !this.shouldShow_(e) ? (this.debug("hiding; " + o + " is an integer and overlay should not show at this time"), this.hasShownSinceSeek_ = !1, this.hide()) : p(o) && e < i && (this.debug("hiding; show point (" + i + ") is before now (" + e + ") and end point (" + o + ") is an event"), this.hasShownSinceSeek_ = !1, this.hide())), this.previousTime_ = e
}, e
}(h);
n.default.registerComponent("Overlay", c);
var f = function(t) {
var e = this,
i = n.default.mergeOptions(a, t);
Array.isArray(this.overlays_) && this.overlays_.forEach((function(t) {
e.removeChild(t), e.controlBar && e.controlBar.removeChild(t), t.dispose()
}));
var o = i.overlays;
delete i.overlays, this.overlays_ = o.map((function(t) {
var o = n.default.mergeOptions(i, t),
r = "string" == typeof o.attachToControlBar || !0 === o.attachToControlBar;
if (!e.controls() || !e.controlBar) return e.addChild("overlay", o);
if (r && -1 !== o.align.indexOf("bottom")) {
var s = e.controlBar.children()[0];
if (void 0 !== e.controlBar.getChild(o.attachToControlBar) && (s = e.controlBar.getChild(o.attachToControlBar)), s) {
var a = e.controlBar.children().indexOf(s);
return e.controlBar.addChild("overlay", o, a)
}
}
var h = e.addChild("overlay", o);
return e.el().insertBefore(h.el(), e.controlBar.el()), h
}))
};
return f.VERSION = "v2.1.6-f.97-master", l("overlay", f), f
}));
/**
* videojs-share
* @version 3.2.1
* @copyright 2019 Mikhail Khazov
* @license MIT
*/
! function(t, e) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = e(require("video.js")) : "function" == typeof define && define.amd ? define(["video.js"], e) : t.videojsShare = e(t.videojs)
}(this, function(t) {
"use strict";
function e(t, e) {
return e = {
exports: {}
}, t(e, e.exports), e.exports
}
function n(t) {
var e;
if ("SELECT" === t.nodeName) t.focus(), e = t.value;
else if ("INPUT" === t.nodeName || "TEXTAREA" === t.nodeName) {
var n = t.hasAttribute("readonly");
n || t.setAttribute("readonly", ""), t.select(), t.setSelectionRange(0, t.value.length), n || t.removeAttribute("readonly"), e = t.value
} else {
t.hasAttribute("contenteditable") && t.focus();
var i = window.getSelection(),
o = document.createRange();
o.selectNodeContents(t), i.removeAllRanges(), i.addRange(o), e = i.toString()
}
return e
}
function i() {}
function o(t, e) {
for (; t && t.nodeType !== G;) {
if ("function" == typeof t.matches && t.matches(e)) return t;
t = t.parentNode
}
}
function r(t, e, n, i, o) {
var r = l.apply(this, arguments);
return t.addEventListener(n, r, o), {
destroy: function() {
t.removeEventListener(n, r, o)
}
}
}
function a(t, e, n, i, o) {
return "function" == typeof t.addEventListener ? r.apply(null, arguments) : "function" == typeof n ? r.bind(null, document).apply(null, arguments) : ("string" == typeof t && (t = document.querySelectorAll(t)), Array.prototype.map.call(t, function(t) {
return r(t, e, n, i, o)
}))
}
function l(t, e, n, i) {
return function(n) {
n.delegateTarget = K(n.target, e), n.delegateTarget && i.call(t, n)
}
}
function s(t, e, n) {
if (!t && !e && !n) throw new Error("Missing required arguments");
if (!X.string(e)) throw new TypeError("Second argument must be a String");
if (!X.fn(n)) throw new TypeError("Third argument must be a Function");
if (X.node(t)) return c(t, e, n);
if (X.nodeList(t)) return u(t, e, n);
if (X.string(t)) return h(t, e, n);
throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")
}
function c(t, e, n) {
return t.addEventListener(e, n), {
destroy: function() {
t.removeEventListener(e, n)
}
}
}
function u(t, e, n) {
return Array.prototype.forEach.call(t, function(t) {
t.addEventListener(e, n)
}), {
destroy: function() {
Array.prototype.forEach.call(t, function(t) {
t.removeEventListener(e, n)
})
}
}
}
function h(t, e, n) {
return Q(document.body, t, e, n)
}
function d(t) {
return Object.keys(t).filter(function(e) {
return void 0 !== t[e] && "" !== t[e]
}).map(function(e) {
return encodeURIComponent(e) + "=" + encodeURIComponent(t[e])
}).join("&")
}
function f() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.fbAppId,
n = t.url,
i = t.redirectUri;
if (!e) throw new Error("fbAppId is not defined");
var o = d({
app_id: e,
display: "popup",
redirect_uri: i,
link: n
});
return window.open("https://www.facebook.com/dialog/feed?" + o, "_blank", tt)
}
function p() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.fbAppId,
n = t.url,
i = t.hashtag,
o = t.redirectUri;
if (!e) throw new Error("fbAppId is not defined");
var r = d({
app_id: e,
display: "popup",
redirect_uri: o,
href: n,
hashtag: i
});
return window.open("https://www.facebook.com/dialog/share?" + r, "_blank", tt)
}
function v() {
var t = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).url;
if (!t) throw new Error("url is not defined");
var e = d({
kid_directed_site: "0",
sdk: "joey",
u: t,
display: "popup",
ref: "plugin",
src: "share_button"
});
return window.open("https://www.facebook.com/sharer/sharer.php?" + e, "_blank", tt)
}
function g() {
var t = d({
url: (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).url
});
return window.open("https://plus.google.com/share?" + t, "_blank", tt)
}
function w() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = d({
share_url: t.url,
title: t.title,
description: t.description,
imageurl: t.image
});
return window.open("http://connect.mail.ru/share?" + e, "_blank", tt)
}
function m() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.url,
n = t.title,
i = t.description,
o = (n || "") + "\r\n" + (i || "") + "\r\n" + (e || ""),
r = "mailto:?body=" + encodeURIComponent(o);
return window.location.assign(r)
}
function y() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = d({
"st.cmd": "addShare",
"st._surl": t.url,
title: t.title
});
return window.open("https://ok.ru/dk?" + e, "_blank", tt)
}
function b() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = d({
url: t.url,
text: t.title
});
return window.open("https://t.me/share/url?" + e, "_blank", tt)
}
function k() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.title,
n = t.url,
i = t.hashtags,
o = d({
text: e,
url: n,
hashtags: (void 0 === i ? [] : i).join(",")
});
return window.open("https://twitter.com/intent/tweet?" + o, "_blank", tt)
}
function _() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = d({
url: t.url,
title: t.title
});
return window.open("https://www.reddit.com/submit?" + e, "_blank", tt)
}
function C() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.description,
n = d({
url: t.url,
description: e,
media: t.media
});
return window.open("https://pinterest.com/pin/create/button/?" + n, "_blank", tt)
}
function x() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.url,
n = t.title,
i = t.caption,
o = t.tags,
r = void 0 === o ? [] : o,
a = t.posttype,
l = void 0 === a ? "link" : a,
s = d({
canonicalUrl: e,
title: n,
caption: i,
tags: r.join(","),
posttype: l
});
return window.open("https://www.tumblr.com/widgets/share/tool?" + s, "_blank", tt)
}
function E() {
return !!window.navigator.userAgent.match(/Version\/[\d.]+.*Safari/)
}
function S(t) {
return E() ? window.open(t) : window.location.assign(t)
}
function j() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.url,
n = t.title;
if (!e && !n) throw new Error("url and title not specified");
return S("viber://forward?" + d({
text: [n, e].filter(function(t) {
return t
}).join(" ")
}))
}
function F() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.url,
n = t.image,
i = t.isVkParse,
o = t.description,
r = t.title;
o && o.length > et && (o = o.substr(0, et) + "..."), r && r.length > et && (r = r.substr(0, et) + "...");
return "https://vk.com/share.php?" + d(i ? {
url: e
} : {
url: e,
title: r,
description: o,
image: n,
noparse: !0
})
}
function A() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
return window.open(F(t), "_blank", tt)
}
function T() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.phone,
n = d({
text: [t.title, t.url].filter(function(t) {
return t
}).join(" "),
phone: e
});
return window.open("https://api.whatsapp.com/send?" + n, "_blank", tt)
}
function z() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.title,
n = t.url,
i = d({
title: e,
summary: t.description,
url: n
});
return window.open("https://www.linkedin.com/shareArticle?mini=true&" + i, "_blank", tt)
}
function M() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.fbAppId,
n = t.url;
if (!e) throw new Error("fbAppId is not defined");
var i = d({
app_id: e,
link: n
});
return window.location.assign("fb-messenger://share?" + i)
}
function O() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
e = t.title,
n = t.url;
if (!n) throw new Error("url is not defined");
var i = encodeURIComponent("" + n);
return e && (i = "" + encodeURIComponent(e + " ") + i), window.open("https://line.me/R/msg/text/?" + i, "_blank", tt)
}
function L() {
return "ontouchstart" in window || navigator.MaxTouchPoints > 0 || navigator.msMaxTouchPoints > 0
}
function V() {
return /Android/.test(window.navigator.userAgent) || /iP(hone|ad|od)/i.test(window.navigator.userAgent)
}
function H() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [];
return !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1] ? V() ? t : t.filter(function(t) {
return !it.includes(t)
}) : t
}
t = t && t.hasOwnProperty("default") ? t.default : t;
var I = function() {
return "undefined" == typeof window ? "" : window.location.href
}(),
P = {
mobileVerification: !0,
title: "Video",
url: I,
socials: ["fbFeed", "tw", "reddit", "gp", "messenger", "linkedin", "vk", "ok", "mail", "email", "telegram", "whatsapp", "viber"],
embedCode: function() {
return ""
}(),
redirectUri: function() {
return I + "#close_window"
}()
},
R = function(t, e) {
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
},
U = function() {
function t(t, e) {
for (var n = 0; n < e.length; n++) {
var i = e[n];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
}
}
return function(e, n, i) {
return n && t(e.prototype, n), i && t(e, i), e
}
}(),
N = function(t, e) {
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function, not " + typeof e);
t.prototype = Object.create(e && e.prototype, {
constructor: {
value: t,
enumerable: !1,
writable: !0,
configurable: !0
}
}), e && (Object.setPrototypeOf ? Object.setPrototypeOf(t, e) : t.__proto__ = e)
},
B = function(t, e) {
if (!t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return !e || "object" != typeof e && "function" != typeof e ? t : e
},
q = function(t) {
function e(n, i) {
R(this, e);
var o = B(this, t.call(this, n, i));
return o.addClass("vjs-menu-button"), o.addClass("vjs-share-control"), o.addClass("vjs-icon-share"), o.controlText(n.localize("Share")), o
}
return N(e, t), e.prototype.handleClick = function() {
this.player().getChild("ShareOverlay").open()
}, e
}(t.getComponent("Button")),
D = ("undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self && self, n),
Y = e(function(t, e) {
! function(e, n) {
n(t, D)
}(0, function(t, e) {
function n(t, e) {
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
}
var i = function(t) {
return t && t.__esModule ? t : {
default: t
}
}(e),
o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
return typeof t
} : function(t) {
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
},
r = function() {
function t(t, e) {
for (var n = 0; n < e.length; n++) {
var i = e[n];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
}
}
return function(e, n, i) {
return n && t(e.prototype, n), i && t(e, i), e
}
}(),
a = function() {
function t(e) {
n(this, t), this.resolveOptions(e), this.initSelection()
}
return r(t, [{
key: "resolveOptions",
value: function() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
this.action = t.action, this.container = t.container, this.emitter = t.emitter, this.target = t.target, this.text = t.text, this.trigger = t.trigger, this.selectedText = ""
}
}, {
key: "initSelection",
value: function() {
this.text ? this.selectFake() : this.target && this.selectTarget()
}
}, {
key: "selectFake",
value: function() {
var t = this,
e = "rtl" == document.documentElement.getAttribute("dir");
this.removeFake(), this.fakeHandlerCallback = function() {
return t.removeFake()
}, this.fakeHandler = this.container.addEventListener("click", this.fakeHandlerCallback) || !0, this.fakeElem = document.createElement("textarea"), this.fakeElem.style.fontSize = "12pt", this.fakeElem.style.border = "0", this.fakeElem.style.padding = "0", this.fakeElem.style.margin = "0", this.fakeElem.style.position = "absolute", this.fakeElem.style[e ? "right" : "left"] = "-9999px";
var n = window.pageYOffset || document.documentElement.scrollTop;
this.fakeElem.style.top = n + "px", this.fakeElem.setAttribute("readonly", ""), this.fakeElem.value = this.text, this.container.appendChild(this.fakeElem), this.selectedText = (0, i.default)(this.fakeElem), this.copyText()
}
}, {
key: "removeFake",
value: function() {
this.fakeHandler && (this.container.removeEventListener("click", this.fakeHandlerCallback), this.fakeHandler = null, this.fakeHandlerCallback = null), this.fakeElem && (this.container.removeChild(this.fakeElem), this.fakeElem = null)
}
}, {
key: "selectTarget",
value: function() {
this.selectedText = (0, i.default)(this.target), this.copyText()
}
}, {
key: "copyText",
value: function() {
var t = void 0;
try {
t = document.execCommand(this.action)
} catch (e) {
t = !1
}
this.handleResult(t)
}
}, {
key: "handleResult",
value: function(t) {
this.emitter.emit(t ? "success" : "error", {
action: this.action,
text: this.selectedText,
trigger: this.trigger,
clearSelection: this.clearSelection.bind(this)
})
}
}, {
key: "clearSelection",
value: function() {
this.trigger && this.trigger.focus(), window.getSelection().removeAllRanges()
}
}, {
key: "destroy",
value: function() {
this.removeFake()
}
}, {
key: "action",
set: function() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "copy";
if (this._action = t, "copy" !== this._action && "cut" !== this._action) throw new Error('Invalid "action" value, use either "copy" or "cut"')
},
get: function() {
return this._action
}
}, {
key: "target",
set: function(t) {
if (void 0 !== t) {
if (!t || "object" !== (void 0 === t ? "undefined" : o(t)) || 1 !== t.nodeType) throw new Error('Invalid "target" value, use a valid Element');
if ("copy" === this.action && t.hasAttribute("disabled")) throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
if ("cut" === this.action && (t.hasAttribute("readonly") || t.hasAttribute("disabled"))) throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
this._target = t
}
},
get: function() {
return this._target
}
}]), t
}();
t.exports = a
})
});
i.prototype = {
on: function(t, e, n) {
var i = this.e || (this.e = {});
return (i[t] || (i[t] = [])).push({
fn: e,
ctx: n
}), this
},
once: function(t, e, n) {
function i() {
o.off(t, i), e.apply(n, arguments)
}
var o = this;
return i._ = e, this.on(t, i, n)
},
emit: function(t) {
var e = [].slice.call(arguments, 1),
n = ((this.e || (this.e = {}))[t] || []).slice(),
i = 0,
o = n.length;
for (i; i < o; i++) n[i].fn.apply(n[i].ctx, e);
return this
},
off: function(t, e) {
var n = this.e || (this.e = {}),
i = n[t],
o = [];
if (i && e)
for (var r = 0, a = i.length; r < a; r++) i[r].fn !== e && i[r].fn._ !== e && o.push(i[r]);
return o.length ? n[t] = o : delete n[t], this
}
};
var W = i,
X = e(function(t, e) {
e.node = function(t) {
return void 0 !== t && t instanceof HTMLElement && 1 === t.nodeType
}, e.nodeList = function(t) {
var n = Object.prototype.toString.call(t);
return void 0 !== t && ("[object NodeList]" === n || "[object HTMLCollection]" === n) && "length" in t && (0 === t.length || e.node(t[0]))
}, e.string = function(t) {
return "string" == typeof t || t instanceof String
}, e.fn = function(t) {
return "[object Function]" === Object.prototype.toString.call(t)
}
}),
G = 9;
if ("undefined" != typeof Element && !Element.prototype.matches) {
var J = Element.prototype;
J.matches = J.matchesSelector || J.mozMatchesSelector || J.msMatchesSelector || J.oMatchesSelector || J.webkitMatchesSelector
}
var K = o,
Q = a,
Z = s,
$ = function(t) {
return t && t.__esModule ? t.default : t
}(e(function(t, e) {
! function(e, n) {
n(t, Y, W, Z)
}(0, function(t, e, n, i) {
function o(t) {
return t && t.__esModule ? t : {
default: t
}
}
function r(t, e) {
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
}
function a(t, e) {
if (!t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return !e || "object" != typeof e && "function" != typeof e ? t : e
}
function l(t, e) {
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function, not " + typeof e);
t.prototype = Object.create(e && e.prototype, {
constructor: {
value: t,
enumerable: !1,
writable: !0,
configurable: !0
}
}), e && (Object.setPrototypeOf ? Object.setPrototypeOf(t, e) : t.__proto__ = e)
}
function s(t, e) {
var n = "data-clipboard-" + t;
if (e.hasAttribute(n)) return e.getAttribute(n)
}
var c = o(e),
u = o(n),
h = o(i),
d = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
return typeof t
} : function(t) {
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
},
f = function() {
function t(t, e) {
for (var n = 0; n < e.length; n++) {
var i = e[n];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
}
}
return function(e, n, i) {
return n && t(e.prototype, n), i && t(e, i), e
}
}(),
p = function(t) {
function e(t, n) {
r(this, e);
var i = a(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this));
return i.resolveOptions(n), i.listenClick(t), i
}
return l(e, t), f(e, [{
key: "resolveOptions",
value: function() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
this.action = "function" == typeof t.action ? t.action : this.defaultAction, this.target = "function" == typeof t.target ? t.target : this.defaultTarget, this.text = "function" == typeof t.text ? t.text : this.defaultText, this.container = "object" === d(t.container) ? t.container : document.body
}
}, {
key: "listenClick",
value: function(t) {
var e = this;
this.listener = (0, h.default)(t, "click", function(t) {
return e.onClick(t)
})
}
}, {
key: "onClick",
value: function(t) {
var e = t.delegateTarget || t.currentTarget;
this.clipboardAction && (this.clipboardAction = null), this.clipboardAction = new c.default({
action: this.action(e),
target: this.target(e),
text: this.text(e),
container: this.container,
trigger: e,
emitter: this
})
}
}, {
key: "defaultAction",
value: function(t) {
return s("action", t)
}
}, {
key: "defaultTarget",
value: function(t) {
var e = s("target", t);
if (e) return document.querySelector(e)
}
}, {
key: "defaultText",
value: function(t) {
return s("text", t)
}
}, {
key: "destroy",
value: function() {
this.listener.destroy(), this.clipboardAction && (this.clipboardAction.destroy(), this.clipboardAction = null)
}
}], [{
key: "isSupported",
value: function() {
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : ["copy", "cut"],
e = "string" == typeof t ? [t] : t,
n = !!document.queryCommandSupported;
return e.forEach(function(t) {
n = n && !!document.queryCommandSupported(t)
}), n
}
}]), e
}(u.default);
t.exports = p
})
})),
tt = "scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=550, height=440, toolbar=0, status=0",
et = 80,
nt = (Object.freeze || Object)({
fbFeed: f,
fbShare: p,
fbButton: v,
gp: g,
mail: w,
email: m,
ok: y,
telegram: b,
tw: k,
reddit: _,
pinterest: C,
tumblr: x,
viber: j,
getVkUrl: F,
vk: A,
whatsapp: T,
linkedin: z,
messenger: M,
line: O
}),
it = ["whatsapp", "viber", "messenger"],
ot = {
fbFeed: '\n',
tw: '\n',
reddit: '\n',
gp: '\n',
messenger: '\n',
linkedin: '\n',
vk: '\n',
ok: '\n',
mail: '\n',
email: '\n',
telegram: '\n',
whatsapp: '\n',
viber: '\n'
},
rt = function() {
function t(e, n) {
R(this, t), this.player = e, this.options = n, this.socials = H(n.socials, n.mobileVerification), this.copyBtnTextClass = "vjs-share__btn-text", this.socialBtnClass = "vjs-share__social", this._createContent(), this._initToggle(), this._initClipboard(), this._initSharing()
}
return t.prototype.getContent = function() {
return this.content
}, t.prototype._createContent = function() {
var t = '\n \n ' + this.player.localize("Copy") + "\n ",
e = document.createElement("div"),
n = "";
this.options.embedCode && (n = '\n
' + this.player.localize("Embed Code") + ':
\n
\n \n
\n ' + t + "\n
\n
"), e.innerHTML = '
\n
\n
' + this.player.localize("Share") + '
\n
\n\n
\n
' + this.player.localize("Direct Link") + ':
\n
\n \n
\n ' + t + "\n
\n
\n\n " + n + '\n
\n\n
\n
\n ' + this._getSocialItems().join("") + "\n
\n
\n
", this.content = e.firstChild
}, t.prototype._initClipboard = function() {
var t = this;
new $(".vjs-share__btn", {
target: function(t) {
return t.previousElementSibling
}
}).on("success", function(e) {
var n = e.trigger.querySelector("." + t.copyBtnTextClass),
i = function() {
n.innerText = t.player.localize("Copy"), e.clearSelection()
};
n.innerText = t.player.localize("Copied"), L() ? setTimeout(i, 1e3) : n.parentElement.addEventListener("mouseleave", function() {
setTimeout(i, 300)
})
})
}, t.prototype._initSharing = function() {
var t = this,
e = this.content.querySelectorAll("." + this.socialBtnClass);
Array.from(e).forEach(function(e) {
e.addEventListener("click", function(e) {
var n = e.currentTarget.getAttribute("data-social"),
i = nt[n];
"function" == typeof i && i(t.socialOptions)
})
})
}, t.prototype._initToggle = function() {
var t = this.content.querySelector(".vjs-share__socials");
this.socials.length > 10 || window.innerWidth <= 180 && this.socials.length > 6 ? t.style.height = "calc((2em + 5px) * 2)" : t.classList.add("horizontal")
}, t.prototype._getSocialItems = function() {
var t = [];
return this.socials.forEach(function(e) {
ot[e] && t.push('\n \n ")
}), t
}, U(t, [{
key: "socialOptions",
get: function() {
var t = this.options;
return {
url: t.url,
title: t.title,
description: t.description,
image: t.image,
fbAppId: t.fbAppId,
isVkParse: t.isVkParse,
redirectUri: t.redirectUri
}
}
}]), t
}(),
at = function(t) {
function e(n, i) {
R(this, e);
var o = B(this, t.call(this, n, i));
return o.playerClassName = "vjs-videojs-share_open", o
}
return N(e, t), e.prototype.open = function() {
var e = this.player();
e.addClass(this.playerClassName), t.prototype.open.call(this), e.trigger("sharing:opened")
}, e.prototype.close = function() {
var e = this.player();
e.removeClass(this.playerClassName), t.prototype.close.call(this), e.trigger("sharing:closed")
}, e
}(t.getComponent("ModalDialog")),
lt = function(t) {
function e(n, i) {
R(this, e);
var o = B(this, t.call(this, n, i));
return o.player = n, o.options = i, o
}
return N(e, t), e.prototype._createModal = function() {
var t = new rt(this.player, this.options).getContent();
this.modal = new at(this.player, {
content: t,
temporary: !0
}), this.el = this.modal.contentEl(), this.player.addChild(this.modal)
}, e.prototype.open = function() {
this._createModal(), this.modal.open()
}, e
}(t.getComponent("Component")),
st = function(e) {
function n(i, o) {
R(this, n);
var r = B(this, e.call(this, i));
return r.options = t.mergeOptions(P, o), r.player.ready(function() {
r.player.addClass("vjs-share"), i.addClass("vjs-videojs-share"), i.getChild("controlBar").addChild("ShareButton", o), i.addChild("ShareOverlay", o)
}), r
}
return N(n, e), n
}(t.getPlugin("plugin"));
return st.defaultState = {}, st.VERSION = "3.2.1", t.registerComponent("ShareButton", q), t.registerComponent("ShareOverlay", lt), t.registerPlugin("share", st), st
});
/**
* videojs-watermark
* @version 2.0.0
* @copyright 2017 Brooks Lyrette
* @license Apache-2.0
*/
! function(e) {
if ("object" == typeof exports && "undefined" != typeof module) module.exports = e();
else if ("function" == typeof define && define.amd) define([], e);
else {
var n;
n = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this, n.videojsWatermark = e()
}
}(function() {
return function e(n, t, i) {
function o(d, a) {
if (!t[d]) {
if (!n[d]) {
var f = "function" == typeof require && require;
if (!a && f) return f(d, !0);
if (r) return r(d, !0);
var u = new Error("Cannot find module '" + d + "'");
throw u.code = "MODULE_NOT_FOUND", u
}
var l = t[d] = {
exports: {}
};
n[d][0].call(l.exports, function(e) {
var t = n[d][1][e];
return o(t || e)
}, l, l.exports, e, n, t, i)
}
return t[d].exports
}
for (var r = "function" == typeof require && require, d = 0; d < i.length; d++) o(i[d]);
return o
}({
1: [function(e, n, t) {
(function(e) {
"use strict";
Object.defineProperty(t, "__esModule", {
value: !0
});
var i = "undefined" != typeof window ? window.videojs : void 0 !== e ? e.videojs : null,
o = function(e) {
return e && e.__esModule ? e : {
default: e
}
}(i),
r = {
position: "top-right",
fadeTime: 3e3,
url: void 0,
image: void 0
},
d = function(e, n) {
var t = e.el(),
i = document.createElement("div"),
o = document.createElement("img");
if (i.classList.add("vjs-watermark-content"), i.classList.add("vjs-watermark-" + n.position), o.src = n.image, n.url) {
var r = document.createElement("a");
r.href = n.url, r.onclick = function(t) {
t.preventDefault(), e.pause(), window.open(n.url)
}, r.appendChild(o), i.appendChild(r)
} else i.appendChild(o);
t.appendChild(i)
},
a = function(e) {
setTimeout(function() {
return document.getElementsByClassName("vjs-watermark-content")[0].classList.add("vjs-watermark-fade")
}, e.fadeTime)
},
f = function(e, n) {
e.addClass("vjs-watermark"), n.image && (d(e, n), null !== n.fadeTime && e.on("play", function() {
return a(n)
}))
},
u = function(e) {
var n = this;
this.ready(function() {
f(n, o.default.mergeOptions(r, e))
})
};
o.default.registerPlugin("watermark", u), u.VERSION = "2.0.0", t.default = u, n.exports = t.default
}).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {})
}, {}]
}, {}, [1])(1)
});
/*! @name videojs-vr @version 1.10.1 @license MIT */
! function(t, e) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = e(require("global/window"), require("global/document"), require("video.js")) : "function" == typeof define && define.amd ? define(["global/window", "global/document", "video.js"], e) : (t = t || self).videojsVr = e(t.window, t.document, t.videojs)
}(this, (function(t, e, n) {
"use strict";
t = t && t.hasOwnProperty("default") ? t.default : t, e = e && e.hasOwnProperty("default") ? e.default : e, n = n && n.hasOwnProperty("default") ? n.default : n;
var i = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
function r(t) {
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t
}
function o(t, e) {
return t(e = {
exports: {}
}, e.exports), e.exports
}
var s = r(o((function(t) {
t.exports = function(t) {
if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return t
}, t.exports.default = t.exports, t.exports.__esModule = !0
}))),
a = o((function(t) {
function e(n, i) {
return t.exports = e = Object.setPrototypeOf || function(t, e) {
return t.__proto__ = e, t
}, t.exports.default = t.exports, t.exports.__esModule = !0, e(n, i)
}
t.exports = e, t.exports.default = t.exports, t.exports.__esModule = !0
}));
r(a);
var l = r(o((function(t) {
t.exports = function(t, e) {
t.prototype = Object.create(e.prototype), t.prototype.constructor = t, a(t, e)
}, t.exports.default = t.exports, t.exports.__esModule = !0
}))),
c = r(o((function(t, e) {
/**
* @license
* webvr-polyfill
* Copyright (c) 2015-2017 Google
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license
* cardboard-vr-display
* Copyright (c) 2015-2017 Google
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license
* webvr-polyfill-dpdb
* Copyright (c) 2017 Google
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license
* wglu-preserve-state
* Copyright (c) 2016, Brandon Jones.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @license
* nosleep.js
* Copyright (c) 2017, Rich Tibbett
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
t.exports = function() {
var t, e = "undefined" != typeof window ? window : void 0 !== i ? i : "undefined" != typeof self ? self : {},
n = function() {
return /Android/i.test(navigator.userAgent) || /iPhone|iPad|iPod/i.test(navigator.userAgent)
},
r = function(t, e) {
for (var n = 0, i = t.length; n < i; n++) e[n] = t[n]
},
o = function(t, e) {
for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
return t
},
s = (t = function(t, e) {
return t(e = {
exports: {}
}, e.exports), e.exports
}((function(t, n) {
/**
* @license
* cardboard-vr-display
* Copyright (c) 2015-2017 Google
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license
* gl-preserve-state
* Copyright (c) 2016, Brandon Jones.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @license
* webvr-polyfill-dpdb
* Copyright (c) 2015-2017 Google
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license
* nosleep.js
* Copyright (c) 2017, Rich Tibbett
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
t.exports = function() {
var t, n, i, r = function() {
function t(t, e) {
for (var n = 0; n < e.length; n++) {
var i = e[n];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
}
}
return function(e, n, i) {
return n && t(e.prototype, n), i && t(e, i), e
}
}(),
o = function(t, e) {
if (Array.isArray(t)) return t;
if (Symbol.iterator in Object(t)) return function(t, e) {
var n = [],
i = !0,
r = !1,
o = void 0;
try {
for (var s, a = t[Symbol.iterator](); !(i = (s = a.next()).done) && (n.push(s.value), !e || n.length !== e); i = !0);
} catch (t) {
r = !0, o = t
} finally {
try {
!i && a.return && a.return()
} finally {
if (r) throw o
}
}
return n
}(t, e);
throw new TypeError("Invalid attempt to destructure non-iterable instance")
},
s = function(t, e, n) {
return t + (e - t) * n
},
a = function() {
var t = /iPad|iPhone|iPod/.test(navigator.platform);
return function() {
return t
}
}(),
l = function() {
var t = -1 !== navigator.userAgent.indexOf("Version") && -1 !== navigator.userAgent.indexOf("Android") && -1 !== navigator.userAgent.indexOf("Chrome");
return function() {
return t
}
}(),
c = function() {
var t = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
return function() {
return t
}
}(),
h = function() {
var t = -1 !== navigator.userAgent.indexOf("Firefox") && -1 !== navigator.userAgent.indexOf("Android");
return function() {
return t
}
}(),
u = (n = navigator.userAgent.match(/.*Chrome\/([0-9]+)/), i = n ? parseInt(n[1], 10) : null, function() {
return i
}),
d = function() {
var t;
return t = a() && c() && -1 !== navigator.userAgent.indexOf("13_4"),
function() {
return t
}
}(),
p = function() {
var t = !1;
if (65 === u()) {
var e = navigator.userAgent.match(/.*Chrome\/([0-9\.]*)/);
if (e) {
var n = e[1].split("."),
i = o(n, 4),
r = (i[0], i[1], i[2]),
s = i[3];
t = 3325 === parseInt(r, 10) && parseInt(s, 10) < 148
}
}
return function() {
return t
}
}(),
f = function() {
var t = -1 !== navigator.userAgent.indexOf("R7 Build");
return function() {
return t
}
}(),
m = function() {
var t = 90 == window.orientation || -90 == window.orientation;
return f() ? !t : t
},
g = function() {
return Math.max(window.screen.width, window.screen.height) * window.devicePixelRatio
},
v = function() {
return Math.min(window.screen.width, window.screen.height) * window.devicePixelRatio
},
y = function() {
if (document.exitFullscreen) document.exitFullscreen();
else if (document.webkitExitFullscreen) document.webkitExitFullscreen();
else if (document.mozCancelFullScreen) document.mozCancelFullScreen();
else {
if (!document.msExitFullscreen) return !1;
document.msExitFullscreen()
}
return !0
},
A = function(t, e, n, i) {
var r = t.createShader(t.VERTEX_SHADER);
t.shaderSource(r, e), t.compileShader(r);
var o = t.createShader(t.FRAGMENT_SHADER);
t.shaderSource(o, n), t.compileShader(o);
var s = t.createProgram();
for (var a in t.attachShader(s, r), t.attachShader(s, o), i) t.bindAttribLocation(s, i[a], a);
return t.linkProgram(s), t.deleteShader(r), t.deleteShader(o), s
},
x = function(t, e) {
for (var n = {}, i = t.getProgramParameter(e, t.ACTIVE_UNIFORMS), r = "", o = 0; o < i; o++) n[r = t.getActiveUniform(e, o).name.replace("[0]", "")] = t.getUniformLocation(e, r);
return n
},
_ = function() {
var t, e = !1;
return t = navigator.userAgent || navigator.vendor || window.opera, (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0, 4))) && (e = !0), e
},
b = function(t, e) {
for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
return t
},
w = function(t) {
if (a()) {
var e = t.style.width,
n = t.style.height;
t.style.width = parseInt(e) + 1 + "px", t.style.height = parseInt(n) + "px", setTimeout((function() {
t.style.width = e, t.style.height = n
}), 100)
}
window.canvas = t
},
M = function() {
var t = Math.PI / 180,
e = .25 * Math.PI,
n = new Float32Array([0, 0, 0, 1]),
i = new Float32Array([0, 0, 0]);
function r(r, o, s, a, l, c) {
! function(n, i, r, o) {
var s = Math.tan(i ? i.upDegrees * t : e),
a = Math.tan(i ? i.downDegrees * t : e),
l = Math.tan(i ? i.leftDegrees * t : e),
c = Math.tan(i ? i.rightDegrees * t : e),
h = 2 / (l + c),
u = 2 / (s + a);
n[0] = h, n[1] = 0, n[2] = 0, n[3] = 0, n[4] = 0, n[5] = u, n[6] = 0, n[7] = 0, n[8] = -(l - c) * h * .5, n[9] = (s - a) * u * .5, n[10] = o / (r - o), n[11] = -1, n[12] = 0, n[13] = 0, n[14] = o * r / (r - o), n[15] = 0
}(r, a || null, c.depthNear, c.depthFar);
var h, u, d, p, f, m, g, v, y, A, x, _, b, w, M, E, S, T, L, R = s.orientation || n,
C = s.position || i;
h = o, d = C, p = (u = R)[0], f = u[1], m = u[2], g = u[3], x = p * (v = p + p), _ = p * (y = f + f), b = p * (A = m + m), w = f * y, M = f * A, E = m * A, S = g * v, T = g * y, L = g * A, h[0] = 1 - (w + E), h[1] = _ + L, h[2] = b - T, h[3] = 0, h[4] = _ - L, h[5] = 1 - (x + E), h[6] = M + S, h[7] = 0, h[8] = b + T, h[9] = M - S, h[10] = 1 - (x + w), h[11] = 0, h[12] = d[0], h[13] = d[1], h[14] = d[2], h[15] = 1, l && function(t, e, n) {
var i, r, o, s, a, l, c, h, u, d, p, f, m = n[0],
g = n[1],
v = n[2];
e === t ? (t[12] = e[0] * m + e[4] * g + e[8] * v + e[12], t[13] = e[1] * m + e[5] * g + e[9] * v + e[13], t[14] = e[2] * m + e[6] * g + e[10] * v + e[14], t[15] = e[3] * m + e[7] * g + e[11] * v + e[15]) : (i = e[0], r = e[1], o = e[2], s = e[3], a = e[4], l = e[5], c = e[6], h = e[7], u = e[8], d = e[9], p = e[10], f = e[11], t[0] = i, t[1] = r, t[2] = o, t[3] = s, t[4] = a, t[5] = l, t[6] = c, t[7] = h, t[8] = u, t[9] = d, t[10] = p, t[11] = f, t[12] = i * m + a * g + u * v + e[12], t[13] = r * m + l * g + d * v + e[13], t[14] = o * m + c * g + p * v + e[14], t[15] = s * m + h * g + f * v + e[15])
}(o, o, l),
function(t, e) {
var n = e[0],
i = e[1],
r = e[2],
o = e[3],
s = e[4],
a = e[5],
l = e[6],
c = e[7],
h = e[8],
u = e[9],
d = e[10],
p = e[11],
f = e[12],
m = e[13],
g = e[14],
v = e[15],
y = n * a - i * s,
A = n * l - r * s,
x = n * c - o * s,
_ = i * l - r * a,
b = i * c - o * a,
w = r * c - o * l,
M = h * m - u * f,
E = h * g - d * f,
S = h * v - p * f,
T = u * g - d * m,
L = u * v - p * m,
R = d * v - p * g,
C = y * R - A * L + x * T + _ * S - b * E + w * M;
C && (C = 1 / C, t[0] = (a * R - l * L + c * T) * C, t[1] = (r * L - i * R - o * T) * C, t[2] = (m * w - g * b + v * _) * C, t[3] = (d * b - u * w - p * _) * C, t[4] = (l * S - s * R - c * E) * C, t[5] = (n * R - r * S + o * E) * C, t[6] = (g * x - f * w - v * A) * C, t[7] = (h * w - d * x + p * A) * C, t[8] = (s * L - a * S + c * M) * C, t[9] = (i * S - n * L - o * M) * C, t[10] = (f * b - m * x + v * y) * C, t[11] = (u * x - h * b - p * y) * C, t[12] = (a * E - s * T - l * M) * C, t[13] = (n * T - i * E + r * M) * C, t[14] = (m * A - f * _ - g * y) * C, t[15] = (h * _ - u * A + d * y) * C)
}(o, o)
}
return function(t, e, n) {
return !(!t || !e || (t.pose = e, t.timestamp = e.timestamp, r(t.leftProjectionMatrix, t.leftViewMatrix, e, n._getFieldOfView("left"), n._getEyeOffset("left"), n), r(t.rightProjectionMatrix, t.rightViewMatrix, e, n._getFieldOfView("right"), n._getEyeOffset("right"), n), 0))
}
}(),
E = function(t) {
var e, n = t.indexOf("://");
e = -1 !== n ? n + 3 : 0;
var i = t.indexOf("/", e);
return -1 === i && (i = t.length), t.substring(0, i)
},
S = (t = {}, function(e, n) {
void 0 === t[e] && (console.warn("webvr-polyfill: " + n), t[e] = !0)
}),
T = function(t, e) {
S(t, t + " has been deprecated. This may not work on native WebVR displays. " + (e ? "Please use " + e + " instead." : ""))
},
L = function(t, e, n) {
if (e) {
for (var i = [], r = null, o = 0; o < e.length; ++o) switch (s = e[o]) {
case t.TEXTURE_BINDING_2D:
case t.TEXTURE_BINDING_CUBE_MAP:
if ((l = e[++o]) < t.TEXTURE0 || l > t.TEXTURE31) {
console.error("TEXTURE_BINDING_2D or TEXTURE_BINDING_CUBE_MAP must be followed by a valid texture unit"), i.push(null, null);
break
}
r || (r = t.getParameter(t.ACTIVE_TEXTURE)), t.activeTexture(l), i.push(t.getParameter(s), null);
break;
case t.ACTIVE_TEXTURE:
r = t.getParameter(t.ACTIVE_TEXTURE), i.push(null);
break;
default:
i.push(t.getParameter(s))
}
for (n(t), o = 0; o < e.length; ++o) {
var s = e[o],
a = i[o];
switch (s) {
case t.ACTIVE_TEXTURE:
break;
case t.ARRAY_BUFFER_BINDING:
t.bindBuffer(t.ARRAY_BUFFER, a);
break;
case t.COLOR_CLEAR_VALUE:
t.clearColor(a[0], a[1], a[2], a[3]);
break;
case t.COLOR_WRITEMASK:
t.colorMask(a[0], a[1], a[2], a[3]);
break;
case t.CURRENT_PROGRAM:
t.useProgram(a);
break;
case t.ELEMENT_ARRAY_BUFFER_BINDING:
t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, a);
break;
case t.FRAMEBUFFER_BINDING:
t.bindFramebuffer(t.FRAMEBUFFER, a);
break;
case t.RENDERBUFFER_BINDING:
t.bindRenderbuffer(t.RENDERBUFFER, a);
break;
case t.TEXTURE_BINDING_2D:
if ((l = e[++o]) < t.TEXTURE0 || l > t.TEXTURE31) break;
t.activeTexture(l), t.bindTexture(t.TEXTURE_2D, a);
break;
case t.TEXTURE_BINDING_CUBE_MAP:
var l;
if ((l = e[++o]) < t.TEXTURE0 || l > t.TEXTURE31) break;
t.activeTexture(l), t.bindTexture(t.TEXTURE_CUBE_MAP, a);
break;
case t.VIEWPORT:
t.viewport(a[0], a[1], a[2], a[3]);
break;
case t.BLEND:
case t.CULL_FACE:
case t.DEPTH_TEST:
case t.SCISSOR_TEST:
case t.STENCIL_TEST:
a ? t.enable(s) : t.disable(s);
break;
default:
console.log("No GL restore behavior for 0x" + s.toString(16))
}
r && t.activeTexture(r)
}
} else n(t)
},
R = ["attribute vec2 position;", "attribute vec3 texCoord;", "varying vec2 vTexCoord;", "uniform vec4 viewportOffsetScale[2];", "void main() {", " vec4 viewport = viewportOffsetScale[int(texCoord.z)];", " vTexCoord = (texCoord.xy * viewport.zw) + viewport.xy;", " gl_Position = vec4( position, 1.0, 1.0 );", "}"].join("\n"),
C = ["precision mediump float;", "uniform sampler2D diffuse;", "varying vec2 vTexCoord;", "void main() {", " gl_FragColor = texture2D(diffuse, vTexCoord);", "}"].join("\n");
function P(t, e, n, i) {
this.gl = t, this.cardboardUI = e, this.bufferScale = n, this.dirtySubmitFrameBindings = i, this.ctxAttribs = t.getContextAttributes(), this.instanceExt = t.getExtension("ANGLE_instanced_arrays"), this.meshWidth = 20, this.meshHeight = 20, this.bufferWidth = t.drawingBufferWidth, this.bufferHeight = t.drawingBufferHeight, this.realBindFramebuffer = t.bindFramebuffer, this.realEnable = t.enable, this.realDisable = t.disable, this.realColorMask = t.colorMask, this.realClearColor = t.clearColor, this.realViewport = t.viewport, a() || (this.realCanvasWidth = Object.getOwnPropertyDescriptor(t.canvas.__proto__, "width"), this.realCanvasHeight = Object.getOwnPropertyDescriptor(t.canvas.__proto__, "height")), this.isPatched = !1, this.lastBoundFramebuffer = null, this.cullFace = !1, this.depthTest = !1, this.blend = !1, this.scissorTest = !1, this.stencilTest = !1, this.viewport = [0, 0, 0, 0], this.colorMask = [!0, !0, !0, !0], this.clearColor = [0, 0, 0, 0], this.attribs = {
position: 0,
texCoord: 1
}, this.program = A(t, R, C, this.attribs), this.uniforms = x(t, this.program), this.viewportOffsetScale = new Float32Array(8), this.setTextureBounds(), this.vertexBuffer = t.createBuffer(), this.indexBuffer = t.createBuffer(), this.indexCount = 0, this.renderTarget = t.createTexture(), this.framebuffer = t.createFramebuffer(), this.depthStencilBuffer = null, this.depthBuffer = null, this.stencilBuffer = null, this.ctxAttribs.depth && this.ctxAttribs.stencil ? this.depthStencilBuffer = t.createRenderbuffer() : this.ctxAttribs.depth ? this.depthBuffer = t.createRenderbuffer() : this.ctxAttribs.stencil && (this.stencilBuffer = t.createRenderbuffer()), this.patch(), this.onResize()
}
P.prototype.destroy = function() {
var t = this.gl;
this.unpatch(), t.deleteProgram(this.program), t.deleteBuffer(this.vertexBuffer), t.deleteBuffer(this.indexBuffer), t.deleteTexture(this.renderTarget), t.deleteFramebuffer(this.framebuffer), this.depthStencilBuffer && t.deleteRenderbuffer(this.depthStencilBuffer), this.depthBuffer && t.deleteRenderbuffer(this.depthBuffer), this.stencilBuffer && t.deleteRenderbuffer(this.stencilBuffer), this.cardboardUI && this.cardboardUI.destroy()
}, P.prototype.onResize = function() {
var t = this.gl,
e = this,
n = [t.RENDERBUFFER_BINDING, t.TEXTURE_BINDING_2D, t.TEXTURE0];
L(t, n, (function(t) {
e.realBindFramebuffer.call(t, t.FRAMEBUFFER, null), e.scissorTest && e.realDisable.call(t, t.SCISSOR_TEST), e.realColorMask.call(t, !0, !0, !0, !0), e.realViewport.call(t, 0, 0, t.drawingBufferWidth, t.drawingBufferHeight), e.realClearColor.call(t, 0, 0, 0, 1), t.clear(t.COLOR_BUFFER_BIT), e.realBindFramebuffer.call(t, t.FRAMEBUFFER, e.framebuffer), t.bindTexture(t.TEXTURE_2D, e.renderTarget), t.texImage2D(t.TEXTURE_2D, 0, e.ctxAttribs.alpha ? t.RGBA : t.RGB, e.bufferWidth, e.bufferHeight, 0, e.ctxAttribs.alpha ? t.RGBA : t.RGB, t.UNSIGNED_BYTE, null), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, e.renderTarget, 0), e.ctxAttribs.depth && e.ctxAttribs.stencil ? (t.bindRenderbuffer(t.RENDERBUFFER, e.depthStencilBuffer), t.renderbufferStorage(t.RENDERBUFFER, t.DEPTH_STENCIL, e.bufferWidth, e.bufferHeight), t.framebufferRenderbuffer(t.FRAMEBUFFER, t.DEPTH_STENCIL_ATTACHMENT, t.RENDERBUFFER, e.depthStencilBuffer)) : e.ctxAttribs.depth ? (t.bindRenderbuffer(t.RENDERBUFFER, e.depthBuffer), t.renderbufferStorage(t.RENDERBUFFER, t.DEPTH_COMPONENT16, e.bufferWidth, e.bufferHeight), t.framebufferRenderbuffer(t.FRAMEBUFFER, t.DEPTH_ATTACHMENT, t.RENDERBUFFER, e.depthBuffer)) : e.ctxAttribs.stencil && (t.bindRenderbuffer(t.RENDERBUFFER, e.stencilBuffer), t.renderbufferStorage(t.RENDERBUFFER, t.STENCIL_INDEX8, e.bufferWidth, e.bufferHeight), t.framebufferRenderbuffer(t.FRAMEBUFFER, t.STENCIL_ATTACHMENT, t.RENDERBUFFER, e.stencilBuffer)), !t.checkFramebufferStatus(t.FRAMEBUFFER) === t.FRAMEBUFFER_COMPLETE && console.error("Framebuffer incomplete!"), e.realBindFramebuffer.call(t, t.FRAMEBUFFER, e.lastBoundFramebuffer), e.scissorTest && e.realEnable.call(t, t.SCISSOR_TEST), e.realColorMask.apply(t, e.colorMask), e.realViewport.apply(t, e.viewport), e.realClearColor.apply(t, e.clearColor)
})), this.cardboardUI && this.cardboardUI.onResize()
}, P.prototype.patch = function() {
if (!this.isPatched) {
var t = this,
e = this.gl.canvas,
n = this.gl;
a() || (e.width = g() * this.bufferScale, e.height = v() * this.bufferScale, Object.defineProperty(e, "width", {
configurable: !0,
enumerable: !0,
get: function() {
return t.bufferWidth
},
set: function(n) {
t.bufferWidth = n, t.realCanvasWidth.set.call(e, n), t.onResize()
}
}), Object.defineProperty(e, "height", {
configurable: !0,
enumerable: !0,
get: function() {
return t.bufferHeight
},
set: function(n) {
t.bufferHeight = n, t.realCanvasHeight.set.call(e, n), t.onResize()
}
})), this.lastBoundFramebuffer = n.getParameter(n.FRAMEBUFFER_BINDING), null == this.lastBoundFramebuffer && (this.lastBoundFramebuffer = this.framebuffer, this.gl.bindFramebuffer(n.FRAMEBUFFER, this.framebuffer)), this.gl.bindFramebuffer = function(e, i) {
t.lastBoundFramebuffer = i || t.framebuffer, t.realBindFramebuffer.call(n, e, t.lastBoundFramebuffer)
}, this.cullFace = n.getParameter(n.CULL_FACE), this.depthTest = n.getParameter(n.DEPTH_TEST), this.blend = n.getParameter(n.BLEND), this.scissorTest = n.getParameter(n.SCISSOR_TEST), this.stencilTest = n.getParameter(n.STENCIL_TEST), n.enable = function(e) {
switch (e) {
case n.CULL_FACE:
t.cullFace = !0;
break;
case n.DEPTH_TEST:
t.depthTest = !0;
break;
case n.BLEND:
t.blend = !0;
break;
case n.SCISSOR_TEST:
t.scissorTest = !0;
break;
case n.STENCIL_TEST:
t.stencilTest = !0
}
t.realEnable.call(n, e)
}, n.disable = function(e) {
switch (e) {
case n.CULL_FACE:
t.cullFace = !1;
break;
case n.DEPTH_TEST:
t.depthTest = !1;
break;
case n.BLEND:
t.blend = !1;
break;
case n.SCISSOR_TEST:
t.scissorTest = !1;
break;
case n.STENCIL_TEST:
t.stencilTest = !1
}
t.realDisable.call(n, e)
}, this.colorMask = n.getParameter(n.COLOR_WRITEMASK), n.colorMask = function(e, i, r, o) {
t.colorMask[0] = e, t.colorMask[1] = i, t.colorMask[2] = r, t.colorMask[3] = o, t.realColorMask.call(n, e, i, r, o)
}, this.clearColor = n.getParameter(n.COLOR_CLEAR_VALUE), n.clearColor = function(e, i, r, o) {
t.clearColor[0] = e, t.clearColor[1] = i, t.clearColor[2] = r, t.clearColor[3] = o, t.realClearColor.call(n, e, i, r, o)
}, this.viewport = n.getParameter(n.VIEWPORT), n.viewport = function(e, i, r, o) {
t.viewport[0] = e, t.viewport[1] = i, t.viewport[2] = r, t.viewport[3] = o, t.realViewport.call(n, e, i, r, o)
}, this.isPatched = !0, w(e)
}
}, P.prototype.unpatch = function() {
if (this.isPatched) {
var t = this.gl,
e = this.gl.canvas;
a() || (Object.defineProperty(e, "width", this.realCanvasWidth), Object.defineProperty(e, "height", this.realCanvasHeight)), e.width = this.bufferWidth, e.height = this.bufferHeight, t.bindFramebuffer = this.realBindFramebuffer, t.enable = this.realEnable, t.disable = this.realDisable, t.colorMask = this.realColorMask, t.clearColor = this.realClearColor, t.viewport = this.realViewport, this.lastBoundFramebuffer == this.framebuffer && t.bindFramebuffer(t.FRAMEBUFFER, null), this.isPatched = !1, setTimeout((function() {
w(e)
}), 1)
}
}, P.prototype.setTextureBounds = function(t, e) {
t || (t = [0, 0, .5, 1]), e || (e = [.5, 0, .5, 1]), this.viewportOffsetScale[0] = t[0], this.viewportOffsetScale[1] = t[1], this.viewportOffsetScale[2] = t[2], this.viewportOffsetScale[3] = t[3], this.viewportOffsetScale[4] = e[0], this.viewportOffsetScale[5] = e[1], this.viewportOffsetScale[6] = e[2], this.viewportOffsetScale[7] = e[3]
}, P.prototype.submitFrame = function() {
var t = this.gl,
e = this,
n = [];
if (this.dirtySubmitFrameBindings || n.push(t.CURRENT_PROGRAM, t.ARRAY_BUFFER_BINDING, t.ELEMENT_ARRAY_BUFFER_BINDING, t.TEXTURE_BINDING_2D, t.TEXTURE0), L(t, n, (function(t) {
e.realBindFramebuffer.call(t, t.FRAMEBUFFER, null);
var n = 0,
i = 0;
e.instanceExt && (n = t.getVertexAttrib(e.attribs.position, e.instanceExt.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE), i = t.getVertexAttrib(e.attribs.texCoord, e.instanceExt.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)), e.cullFace && e.realDisable.call(t, t.CULL_FACE), e.depthTest && e.realDisable.call(t, t.DEPTH_TEST), e.blend && e.realDisable.call(t, t.BLEND), e.scissorTest && e.realDisable.call(t, t.SCISSOR_TEST), e.stencilTest && e.realDisable.call(t, t.STENCIL_TEST), e.realColorMask.call(t, !0, !0, !0, !0), e.realViewport.call(t, 0, 0, t.drawingBufferWidth, t.drawingBufferHeight), (e.ctxAttribs.alpha || a()) && (e.realClearColor.call(t, 0, 0, 0, 1), t.clear(t.COLOR_BUFFER_BIT)), t.useProgram(e.program), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, e.indexBuffer), t.bindBuffer(t.ARRAY_BUFFER, e.vertexBuffer), t.enableVertexAttribArray(e.attribs.position), t.enableVertexAttribArray(e.attribs.texCoord), t.vertexAttribPointer(e.attribs.position, 2, t.FLOAT, !1, 20, 0), t.vertexAttribPointer(e.attribs.texCoord, 3, t.FLOAT, !1, 20, 8), e.instanceExt && (0 != n && e.instanceExt.vertexAttribDivisorANGLE(e.attribs.position, 0), 0 != i && e.instanceExt.vertexAttribDivisorANGLE(e.attribs.texCoord, 0)), t.activeTexture(t.TEXTURE0), t.uniform1i(e.uniforms.diffuse, 0), t.bindTexture(t.TEXTURE_2D, e.renderTarget), t.uniform4fv(e.uniforms.viewportOffsetScale, e.viewportOffsetScale), t.drawElements(t.TRIANGLES, e.indexCount, t.UNSIGNED_SHORT, 0), e.cardboardUI && e.cardboardUI.renderNoState(), e.realBindFramebuffer.call(e.gl, t.FRAMEBUFFER, e.framebuffer), e.ctxAttribs.preserveDrawingBuffer || (e.realClearColor.call(t, 0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT)), e.dirtySubmitFrameBindings || e.realBindFramebuffer.call(t, t.FRAMEBUFFER, e.lastBoundFramebuffer), e.cullFace && e.realEnable.call(t, t.CULL_FACE), e.depthTest && e.realEnable.call(t, t.DEPTH_TEST), e.blend && e.realEnable.call(t, t.BLEND), e.scissorTest && e.realEnable.call(t, t.SCISSOR_TEST), e.stencilTest && e.realEnable.call(t, t.STENCIL_TEST), e.realColorMask.apply(t, e.colorMask), e.realViewport.apply(t, e.viewport), !e.ctxAttribs.alpha && e.ctxAttribs.preserveDrawingBuffer || e.realClearColor.apply(t, e.clearColor), e.instanceExt && (0 != n && e.instanceExt.vertexAttribDivisorANGLE(e.attribs.position, n), 0 != i && e.instanceExt.vertexAttribDivisorANGLE(e.attribs.texCoord, i))
})), a()) {
var i = t.canvas;
i.width == e.bufferWidth && i.height == e.bufferHeight || (e.bufferWidth = i.width, e.bufferHeight = i.height, e.onResize())
}
}, P.prototype.updateDeviceInfo = function(t) {
var e = this.gl,
n = this,
i = [e.ARRAY_BUFFER_BINDING, e.ELEMENT_ARRAY_BUFFER_BINDING];
L(e, i, (function(e) {
var i = n.computeMeshVertices_(n.meshWidth, n.meshHeight, t);
if (e.bindBuffer(e.ARRAY_BUFFER, n.vertexBuffer), e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW), !n.indexCount) {
var r = n.computeMeshIndices_(n.meshWidth, n.meshHeight);
e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n.indexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, r, e.STATIC_DRAW), n.indexCount = r.length
}
}))
}, P.prototype.computeMeshVertices_ = function(t, e, n) {
for (var i = new Float32Array(2 * t * e * 5), r = n.getLeftEyeVisibleTanAngles(), o = n.getLeftEyeNoLensTanAngles(), a = n.getLeftEyeVisibleScreenRect(o), l = 0, c = 0; c < 2; c++) {
for (var h = 0; h < e; h++)
for (var u = 0; u < t; u++, l++) {
var d = u / (t - 1),
p = h / (e - 1),
f = d,
m = p,
g = s(r[0], r[2], d),
v = s(r[3], r[1], p),
y = Math.sqrt(g * g + v * v),
A = n.distortion.distortInverse(y),
x = v * A / y;
d = (g * A / y - o[0]) / (o[2] - o[0]), p = (x - o[3]) / (o[1] - o[3]), d = 2 * (a.x + d * a.width - .5), p = 2 * (a.y + p * a.height - .5), i[5 * l + 0] = d, i[5 * l + 1] = p, i[5 * l + 2] = f, i[5 * l + 3] = m, i[5 * l + 4] = c
}
var _ = r[2] - r[0];
r[0] = -(_ + r[0]), r[2] = _ - r[2], _ = o[2] - o[0], o[0] = -(_ + o[0]), o[2] = _ - o[2], a.x = 1 - (a.x + a.width)
}
return i
}, P.prototype.computeMeshIndices_ = function(t, e) {
for (var n = new Uint16Array(2 * (t - 1) * (e - 1) * 6), i = t / 2, r = e / 2, o = 0, s = 0, a = 0; a < 2; a++)
for (var l = 0; l < e; l++)
for (var c = 0; c < t; c++, o++) 0 != c && 0 != l && (c <= i == l <= r ? (n[s++] = o, n[s++] = o - t - 1, n[s++] = o - t, n[s++] = o - t - 1, n[s++] = o, n[s++] = o - 1) : (n[s++] = o - 1, n[s++] = o - t, n[s++] = o, n[s++] = o - t, n[s++] = o - 1, n[s++] = o - t - 1));
return n
}, P.prototype.getOwnPropertyDescriptor_ = function(t, e) {
var n = Object.getOwnPropertyDescriptor(t, e);
return void 0 !== n.get && void 0 !== n.set || (n.configurable = !0, n.enumerable = !0, n.get = function() {
return this.getAttribute(e)
}, n.set = function(t) {
this.setAttribute(e, t)
}), n
};
var D = ["attribute vec2 position;", "uniform mat4 projectionMat;", "void main() {", " gl_Position = projectionMat * vec4( position, -1.0, 1.0 );", "}"].join("\n"),
I = ["precision mediump float;", "uniform vec4 color;", "void main() {", " gl_FragColor = color;", "}"].join("\n"),
O = Math.PI / 180;
function N(t) {
this.gl = t, this.attribs = {
position: 0
}, this.program = A(t, D, I, this.attribs), this.uniforms = x(t, this.program), this.vertexBuffer = t.createBuffer(), this.gearOffset = 0, this.gearVertexCount = 0, this.arrowOffset = 0, this.arrowVertexCount = 0, this.projMat = new Float32Array(16), this.listener = null, this.onResize()
}
function B(t) {
this.coefficients = t
}
N.prototype.destroy = function() {
var t = this.gl;
this.listener && t.canvas.removeEventListener("click", this.listener, !1), t.deleteProgram(this.program), t.deleteBuffer(this.vertexBuffer)
}, N.prototype.listen = function(t, e) {
var n = this.gl.canvas;
this.listener = function(i) {
var r = n.clientWidth / 2;
i.clientX > r - 42 && i.clientX < r + 42 && i.clientY > n.clientHeight - 42 ? t(i) : i.clientX < 42 && i.clientY < 42 && e(i)
}, n.addEventListener("click", this.listener, !1)
}, N.prototype.onResize = function() {
var t = this.gl,
e = this,
n = [t.ARRAY_BUFFER_BINDING];
L(t, n, (function(t) {
var n = [],
i = t.drawingBufferWidth / 2,
r = Math.max(screen.width, screen.height) * window.devicePixelRatio,
o = t.drawingBufferWidth / r * window.devicePixelRatio,
s = 4 * o / 2,
a = 42 * o,
l = 28 * o / 2,
c = 14 * o;
function h(t, e) {
var r = (90 - t) * O,
o = Math.cos(r),
s = Math.sin(r);
n.push(.3125 * o * l + i, .3125 * s * l + l), n.push(e * o * l + i, e * s * l + l)
}
n.push(i - s, a), n.push(i - s, t.drawingBufferHeight), n.push(i + s, a), n.push(i + s, t.drawingBufferHeight), e.gearOffset = n.length / 2;
for (var u = 0; u <= 6; u++) {
var d = 60 * u;
h(d, 1), h(d + 12, 1), h(d + 20, .75), h(d + 40, .75), h(d + 48, 1)
}
function p(e, i) {
n.push(c + e, t.drawingBufferHeight - c - i)
}
e.gearVertexCount = n.length / 2 - e.gearOffset, e.arrowOffset = n.length / 2;
var f = s / Math.sin(45 * O);
p(0, l), p(l, 0), p(l + f, f), p(f, l + f), p(f, l - f), p(0, l), p(l, 2 * l), p(l + f, 2 * l - f), p(f, l - f), p(0, l), p(f, l - s), p(28 * o, l - s), p(f, l + s), p(28 * o, l + s), e.arrowVertexCount = n.length / 2 - e.arrowOffset, t.bindBuffer(t.ARRAY_BUFFER, e.vertexBuffer), t.bufferData(t.ARRAY_BUFFER, new Float32Array(n), t.STATIC_DRAW)
}))
}, N.prototype.render = function() {
var t = this.gl,
e = this,
n = [t.CULL_FACE, t.DEPTH_TEST, t.BLEND, t.SCISSOR_TEST, t.STENCIL_TEST, t.COLOR_WRITEMASK, t.VIEWPORT, t.CURRENT_PROGRAM, t.ARRAY_BUFFER_BINDING];
L(t, n, (function(t) {
t.disable(t.CULL_FACE), t.disable(t.DEPTH_TEST), t.disable(t.BLEND), t.disable(t.SCISSOR_TEST), t.disable(t.STENCIL_TEST), t.colorMask(!0, !0, !0, !0), t.viewport(0, 0, t.drawingBufferWidth, t.drawingBufferHeight), e.renderNoState()
}))
}, N.prototype.renderNoState = function() {
var t, e, n, i, r, o, s, a, l, c, h = this.gl;
h.useProgram(this.program), h.bindBuffer(h.ARRAY_BUFFER, this.vertexBuffer), h.enableVertexAttribArray(this.attribs.position), h.vertexAttribPointer(this.attribs.position, 2, h.FLOAT, !1, 8, 0), h.uniform4f(this.uniforms.color, 1, 1, 1, 1), t = this.projMat, e = 0, n = h.drawingBufferWidth, i = 0, r = h.drawingBufferHeight, a = 1 / (e - n), l = 1 / (i - r), c = 1 / ((o = .1) - (s = 1024)), t[0] = -2 * a, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = -2 * l, t[6] = 0, t[7] = 0, t[8] = 0, t[9] = 0, t[10] = 2 * c, t[11] = 0, t[12] = (e + n) * a, t[13] = (r + i) * l, t[14] = (s + o) * c, t[15] = 1, h.uniformMatrix4fv(this.uniforms.projectionMat, !1, this.projMat), h.drawArrays(h.TRIANGLE_STRIP, 0, 4), h.drawArrays(h.TRIANGLE_STRIP, this.gearOffset, this.gearVertexCount), h.drawArrays(h.TRIANGLE_STRIP, this.arrowOffset, this.arrowVertexCount)
}, B.prototype.distortInverse = function(t) {
for (var e = 0, n = 1, i = t - this.distort(e); Math.abs(n - e) > 1e-4;) {
var r = t - this.distort(n),
o = n - r * ((n - e) / (r - i));
e = n, n = o, i = r
}
return n
}, B.prototype.distort = function(t) {
for (var e = t * t, n = 0, i = 0; i < this.coefficients.length; i++) n = e * (n + this.coefficients[i]);
return (n + 1) * t
};
var F = Math.PI / 180,
z = 180 / Math.PI,
U = function(t, e, n) {
this.x = t || 0, this.y = e || 0, this.z = n || 0
};
U.prototype = {
constructor: U,
set: function(t, e, n) {
return this.x = t, this.y = e, this.z = n, this
},
copy: function(t) {
return this.x = t.x, this.y = t.y, this.z = t.z, this
},
length: function() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z)
},
normalize: function() {
var t = this.length();
if (0 !== t) {
var e = 1 / t;
this.multiplyScalar(e)
} else this.x = 0, this.y = 0, this.z = 0;
return this
},
multiplyScalar: function(t) {
this.x *= t, this.y *= t, this.z *= t
},
applyQuaternion: function(t) {
var e = this.x,
n = this.y,
i = this.z,
r = t.x,
o = t.y,
s = t.z,
a = t.w,
l = a * e + o * i - s * n,
c = a * n + s * e - r * i,
h = a * i + r * n - o * e,
u = -r * e - o * n - s * i;
return this.x = l * a + u * -r + c * -s - h * -o, this.y = c * a + u * -o + h * -r - l * -s, this.z = h * a + u * -s + l * -o - c * -r, this
},
dot: function(t) {
return this.x * t.x + this.y * t.y + this.z * t.z
},
crossVectors: function(t, e) {
var n = t.x,
i = t.y,
r = t.z,
o = e.x,
s = e.y,
a = e.z;
return this.x = i * a - r * s, this.y = r * o - n * a, this.z = n * s - i * o, this
}
};
var H, G, V = function(t, e, n, i) {
this.x = t || 0, this.y = e || 0, this.z = n || 0, this.w = void 0 !== i ? i : 1
};
function k(t) {
this.width = t.width || g(), this.height = t.height || v(), this.widthMeters = t.widthMeters, this.heightMeters = t.heightMeters, this.bevelMeters = t.bevelMeters
}
V.prototype = {
constructor: V,
set: function(t, e, n, i) {
return this.x = t, this.y = e, this.z = n, this.w = i, this
},
copy: function(t) {
return this.x = t.x, this.y = t.y, this.z = t.z, this.w = t.w, this
},
setFromEulerXYZ: function(t, e, n) {
var i = Math.cos(t / 2),
r = Math.cos(e / 2),
o = Math.cos(n / 2),
s = Math.sin(t / 2),
a = Math.sin(e / 2),
l = Math.sin(n / 2);
return this.x = s * r * o + i * a * l, this.y = i * a * o - s * r * l, this.z = i * r * l + s * a * o, this.w = i * r * o - s * a * l, this
},
setFromEulerYXZ: function(t, e, n) {
var i = Math.cos(t / 2),
r = Math.cos(e / 2),
o = Math.cos(n / 2),
s = Math.sin(t / 2),
a = Math.sin(e / 2),
l = Math.sin(n / 2);
return this.x = s * r * o + i * a * l, this.y = i * a * o - s * r * l, this.z = i * r * l - s * a * o, this.w = i * r * o + s * a * l, this
},
setFromAxisAngle: function(t, e) {
var n = e / 2,
i = Math.sin(n);
return this.x = t.x * i, this.y = t.y * i, this.z = t.z * i, this.w = Math.cos(n), this
},
multiply: function(t) {
return this.multiplyQuaternions(this, t)
},
multiplyQuaternions: function(t, e) {
var n = t.x,
i = t.y,
r = t.z,
o = t.w,
s = e.x,
a = e.y,
l = e.z,
c = e.w;
return this.x = n * c + o * s + i * l - r * a, this.y = i * c + o * a + r * s - n * l, this.z = r * c + o * l + n * a - i * s, this.w = o * c - n * s - i * a - r * l, this
},
inverse: function() {
return this.x *= -1, this.y *= -1, this.z *= -1, this.normalize(), this
},
normalize: function() {
var t = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
return 0 === t ? (this.x = 0, this.y = 0, this.z = 0, this.w = 1) : (t = 1 / t, this.x = this.x * t, this.y = this.y * t, this.z = this.z * t, this.w = this.w * t), this
},
slerp: function(t, e) {
if (0 === e) return this;
if (1 === e) return this.copy(t);
var n = this.x,
i = this.y,
r = this.z,
o = this.w,
s = o * t.w + n * t.x + i * t.y + r * t.z;
if (s < 0 ? (this.w = -t.w, this.x = -t.x, this.y = -t.y, this.z = -t.z, s = -s) : this.copy(t), s >= 1) return this.w = o, this.x = n, this.y = i, this.z = r, this;
var a = Math.acos(s),
l = Math.sqrt(1 - s * s);
if (Math.abs(l) < .001) return this.w = .5 * (o + this.w), this.x = .5 * (n + this.x), this.y = .5 * (i + this.y), this.z = .5 * (r + this.z), this;
var c = Math.sin((1 - e) * a) / l,
h = Math.sin(e * a) / l;
return this.w = o * c + this.w * h, this.x = n * c + this.x * h, this.y = i * c + this.y * h, this.z = r * c + this.z * h, this
},
setFromUnitVectors: function(t, e) {
return void 0 === H && (H = new U), (G = t.dot(e) + 1) < 1e-6 ? (G = 0, Math.abs(t.x) > Math.abs(t.z) ? H.set(-t.y, t.x, 0) : H.set(0, -t.z, t.y)) : H.crossVectors(t, e), this.x = H.x, this.y = H.y, this.z = H.z, this.w = G, this.normalize(), this
}
};
var W = new k({
widthMeters: .11,
heightMeters: .062,
bevelMeters: .004
}),
j = new k({
widthMeters: .1038,
heightMeters: .0584,
bevelMeters: .004
}),
X = {
CardboardV1: new Y({
id: "CardboardV1",
label: "Cardboard I/O 2014",
fov: 40,
interLensDistance: .06,
baselineLensDistance: .035,
screenLensDistance: .042,
distortionCoefficients: [.441, .156],
inverseCoefficients: [-.4410035, .42756155, -.4804439, .5460139, -.58821183, .5733938, -.48303202, .33299083, -.17573841, .0651772, -.01488963, .001559834]
}),
CardboardV2: new Y({
id: "CardboardV2",
label: "Cardboard I/O 2015",
fov: 60,
interLensDistance: .064,
baselineLensDistance: .035,
screenLensDistance: .039,
distortionCoefficients: [.34, .55],
inverseCoefficients: [-.33836704, -.18162185, .862655, -1.2462051, 1.0560602, -.58208317, .21609078, -.05444823, .009177956, -.0009904169, 6183535e-11, -16981803e-13]
})
};
function q(t, e) {
this.viewer = X.CardboardV2, this.updateDeviceParams(t), this.distortion = new B(this.viewer.distortionCoefficients);
for (var n = 0; n < e.length; n++) {
var i = e[n];
X[i.id] = new Y(i)
}
}
function Y(t) {
this.id = t.id, this.label = t.label, this.fov = t.fov, this.interLensDistance = t.interLensDistance, this.baselineLensDistance = t.baselineLensDistance, this.screenLensDistance = t.screenLensDistance, this.distortionCoefficients = t.distortionCoefficients, this.inverseCoefficients = t.inverseCoefficients
}
q.prototype.updateDeviceParams = function(t) {
this.device = this.determineDevice_(t) || this.device
}, q.prototype.getDevice = function() {
return this.device
}, q.prototype.setViewer = function(t) {
this.viewer = t, this.distortion = new B(this.viewer.distortionCoefficients)
}, q.prototype.determineDevice_ = function(t) {
if (!t) return a() ? (console.warn("Using fallback iOS device measurements."), j) : (console.warn("Using fallback Android device measurements."), W);
var e = .0254 / t.xdpi,
n = .0254 / t.ydpi;
return new k({
widthMeters: e * g(),
heightMeters: n * v(),
bevelMeters: .001 * t.bevelMm
})
}, q.prototype.getDistortedFieldOfViewLeftEye = function() {
var t = this.viewer,
e = this.device,
n = this.distortion,
i = t.screenLensDistance,
r = (e.widthMeters - t.interLensDistance) / 2,
o = t.interLensDistance / 2,
s = t.baselineLensDistance - e.bevelMeters,
a = e.heightMeters - s,
l = z * Math.atan(n.distort(r / i)),
c = z * Math.atan(n.distort(o / i)),
h = z * Math.atan(n.distort(s / i)),
u = z * Math.atan(n.distort(a / i));
return {
leftDegrees: Math.min(l, t.fov),
rightDegrees: Math.min(c, t.fov),
downDegrees: Math.min(h, t.fov),
upDegrees: Math.min(u, t.fov)
}
}, q.prototype.getLeftEyeVisibleTanAngles = function() {
var t = this.viewer,
e = this.device,
n = this.distortion,
i = Math.tan(-F * t.fov),
r = Math.tan(F * t.fov),
o = Math.tan(F * t.fov),
s = Math.tan(-F * t.fov),
a = e.widthMeters / 4,
l = e.heightMeters / 2,
c = t.baselineLensDistance - e.bevelMeters - l,
h = t.interLensDistance / 2 - a,
u = -c,
d = t.screenLensDistance,
p = n.distort((h - a) / d),
f = n.distort((u + l) / d),
m = n.distort((h + a) / d),
g = n.distort((u - l) / d),
v = new Float32Array(4);
return v[0] = Math.max(i, p), v[1] = Math.min(r, f), v[2] = Math.min(o, m), v[3] = Math.max(s, g), v
}, q.prototype.getLeftEyeNoLensTanAngles = function() {
var t = this.viewer,
e = this.device,
n = this.distortion,
i = new Float32Array(4),
r = n.distortInverse(Math.tan(-F * t.fov)),
o = n.distortInverse(Math.tan(F * t.fov)),
s = n.distortInverse(Math.tan(F * t.fov)),
a = n.distortInverse(Math.tan(-F * t.fov)),
l = e.widthMeters / 4,
c = e.heightMeters / 2,
h = t.baselineLensDistance - e.bevelMeters - c,
u = t.interLensDistance / 2 - l,
d = -h,
p = t.screenLensDistance,
f = (u - l) / p,
m = (d + c) / p,
g = (u + l) / p,
v = (d - c) / p;
return i[0] = Math.max(r, f), i[1] = Math.min(o, m), i[2] = Math.min(s, g), i[3] = Math.max(a, v), i
}, q.prototype.getLeftEyeVisibleScreenRect = function(t) {
var e = this.viewer,
n = this.device,
i = e.screenLensDistance,
r = (n.widthMeters - e.interLensDistance) / 2,
o = e.baselineLensDistance - n.bevelMeters,
s = (t[0] * i + r) / n.widthMeters,
a = (t[1] * i + o) / n.heightMeters,
l = (t[2] * i + r) / n.widthMeters,
c = (t[3] * i + o) / n.heightMeters;
return {
x: s,
y: c,
width: l - s,
height: a - c
}
}, q.prototype.getFieldOfViewLeftEye = function(t) {
return t ? this.getUndistortedFieldOfViewLeftEye() : this.getDistortedFieldOfViewLeftEye()
}, q.prototype.getFieldOfViewRightEye = function(t) {
var e = this.getFieldOfViewLeftEye(t);
return {
leftDegrees: e.rightDegrees,
rightDegrees: e.leftDegrees,
upDegrees: e.upDegrees,
downDegrees: e.downDegrees
}
}, q.prototype.getUndistortedFieldOfViewLeftEye = function() {
var t = this.getUndistortedParams_();
return {
leftDegrees: z * Math.atan(t.outerDist),
rightDegrees: z * Math.atan(t.innerDist),
downDegrees: z * Math.atan(t.bottomDist),
upDegrees: z * Math.atan(t.topDist)
}
}, q.prototype.getUndistortedViewportLeftEye = function() {
var t = this.getUndistortedParams_(),
e = this.viewer,
n = this.device,
i = e.screenLensDistance,
r = n.widthMeters / i,
o = n.heightMeters / i,
s = n.width / r,
a = n.height / o,
l = Math.round((t.eyePosX - t.outerDist) * s),
c = Math.round((t.eyePosY - t.bottomDist) * a);
return {
x: l,
y: c,
width: Math.round((t.eyePosX + t.innerDist) * s) - l,
height: Math.round((t.eyePosY + t.topDist) * a) - c
}
}, q.prototype.getUndistortedParams_ = function() {
var t = this.viewer,
e = this.device,
n = this.distortion,
i = t.screenLensDistance,
r = t.interLensDistance / 2 / i,
o = e.widthMeters / i,
s = e.heightMeters / i,
a = o / 2 - r,
l = (t.baselineLensDistance - e.bevelMeters) / i,
c = t.fov,
h = n.distortInverse(Math.tan(F * c)),
u = Math.min(a, h),
d = Math.min(r, h),
p = Math.min(l, h);
return {
outerDist: u,
innerDist: d,
topDist: Math.min(s - l, h),
bottomDist: p,
eyePosX: a,
eyePosY: l
}
}, q.Viewers = X;
var Q = {
format: 1,
last_updated: "2019-11-09T17:36:14Z",
devices: [{
type: "android",
rules: [{
mdmh: "asus/*/Nexus 7/*"
}, {
ua: "Nexus 7"
}],
dpi: [320.8, 323],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "asus/*/ASUS_X00PD/*"
}, {
ua: "ASUS_X00PD"
}],
dpi: 245,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "asus/*/ASUS_X008D/*"
}, {
ua: "ASUS_X008D"
}],
dpi: 282,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "asus/*/ASUS_Z00AD/*"
}, {
ua: "ASUS_Z00AD"
}],
dpi: [403, 404.6],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Google/*/Pixel 2 XL/*"
}, {
ua: "Pixel 2 XL"
}],
dpi: 537.9,
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Google/*/Pixel 3 XL/*"
}, {
ua: "Pixel 3 XL"
}],
dpi: [558.5, 553.8],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Google/*/Pixel XL/*"
}, {
ua: "Pixel XL"
}],
dpi: [537.9, 533],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Google/*/Pixel 3/*"
}, {
ua: "Pixel 3"
}],
dpi: 442.4,
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Google/*/Pixel 2/*"
}, {
ua: "Pixel 2"
}],
dpi: 441,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "Google/*/Pixel/*"
}, {
ua: "Pixel"
}],
dpi: [432.6, 436.7],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "HTC/*/HTC6435LVW/*"
}, {
ua: "HTC6435LVW"
}],
dpi: [449.7, 443.3],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "HTC/*/HTC One XL/*"
}, {
ua: "HTC One XL"
}],
dpi: [315.3, 314.6],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "htc/*/Nexus 9/*"
}, {
ua: "Nexus 9"
}],
dpi: 289,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "HTC/*/HTC One M9/*"
}, {
ua: "HTC One M9"
}],
dpi: [442.5, 443.3],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "HTC/*/HTC One_M8/*"
}, {
ua: "HTC One_M8"
}],
dpi: [449.7, 447.4],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "HTC/*/HTC One/*"
}, {
ua: "HTC One"
}],
dpi: 472.8,
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Huawei/*/Nexus 6P/*"
}, {
ua: "Nexus 6P"
}],
dpi: [515.1, 518],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Huawei/*/BLN-L24/*"
}, {
ua: "HONORBLN-L24"
}],
dpi: 480,
bw: 4,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "Huawei/*/BKL-L09/*"
}, {
ua: "BKL-L09"
}],
dpi: 403,
bw: 3.47,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "LENOVO/*/Lenovo PB2-690Y/*"
}, {
ua: "Lenovo PB2-690Y"
}],
dpi: [457.2, 454.713],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "LGE/*/Nexus 5X/*"
}, {
ua: "Nexus 5X"
}],
dpi: [422, 419.9],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "LGE/*/LGMS345/*"
}, {
ua: "LGMS345"
}],
dpi: [221.7, 219.1],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "LGE/*/LG-D800/*"
}, {
ua: "LG-D800"
}],
dpi: [422, 424.1],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "LGE/*/LG-D850/*"
}, {
ua: "LG-D850"
}],
dpi: [537.9, 541.9],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "LGE/*/VS985 4G/*"
}, {
ua: "VS985 4G"
}],
dpi: [537.9, 535.6],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "LGE/*/Nexus 5/*"
}, {
ua: "Nexus 5 B"
}],
dpi: [442.4, 444.8],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "LGE/*/Nexus 4/*"
}, {
ua: "Nexus 4"
}],
dpi: [319.8, 318.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "LGE/*/LG-P769/*"
}, {
ua: "LG-P769"
}],
dpi: [240.6, 247.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "LGE/*/LGMS323/*"
}, {
ua: "LGMS323"
}],
dpi: [206.6, 204.6],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "LGE/*/LGLS996/*"
}, {
ua: "LGLS996"
}],
dpi: [403.4, 401.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Micromax/*/4560MMX/*"
}, {
ua: "4560MMX"
}],
dpi: [240, 219.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Micromax/*/A250/*"
}, {
ua: "Micromax A250"
}],
dpi: [480, 446.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Micromax/*/Micromax AQ4501/*"
}, {
ua: "Micromax AQ4501"
}],
dpi: 240,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "motorola/*/G5/*"
}, {
ua: "Moto G (5) Plus"
}],
dpi: [403.4, 403],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "motorola/*/DROID RAZR/*"
}, {
ua: "DROID RAZR"
}],
dpi: [368.1, 256.7],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT830C/*"
}, {
ua: "XT830C"
}],
dpi: [254, 255.9],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1021/*"
}, {
ua: "XT1021"
}],
dpi: [254, 256.7],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1023/*"
}, {
ua: "XT1023"
}],
dpi: [254, 256.7],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1028/*"
}, {
ua: "XT1028"
}],
dpi: [326.6, 327.6],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1034/*"
}, {
ua: "XT1034"
}],
dpi: [326.6, 328.4],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1053/*"
}, {
ua: "XT1053"
}],
dpi: [315.3, 316.1],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1562/*"
}, {
ua: "XT1562"
}],
dpi: [403.4, 402.7],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "motorola/*/Nexus 6/*"
}, {
ua: "Nexus 6 B"
}],
dpi: [494.3, 489.7],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1063/*"
}, {
ua: "XT1063"
}],
dpi: [295, 296.6],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1064/*"
}, {
ua: "XT1064"
}],
dpi: [295, 295.6],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1092/*"
}, {
ua: "XT1092"
}],
dpi: [422, 424.1],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "motorola/*/XT1095/*"
}, {
ua: "XT1095"
}],
dpi: [422, 423.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "motorola/*/G4/*"
}, {
ua: "Moto G (4)"
}],
dpi: 401,
bw: 4,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/A0001/*"
}, {
ua: "A0001"
}],
dpi: [403.4, 401],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONE E1001/*"
}, {
ua: "ONE E1001"
}],
dpi: [442.4, 441.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONE E1003/*"
}, {
ua: "ONE E1003"
}],
dpi: [442.4, 441.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONE E1005/*"
}, {
ua: "ONE E1005"
}],
dpi: [442.4, 441.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONE A2001/*"
}, {
ua: "ONE A2001"
}],
dpi: [391.9, 405.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONE A2003/*"
}, {
ua: "ONE A2003"
}],
dpi: [391.9, 405.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONE A2005/*"
}, {
ua: "ONE A2005"
}],
dpi: [391.9, 405.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONEPLUS A3000/*"
}, {
ua: "ONEPLUS A3000"
}],
dpi: 401,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONEPLUS A3003/*"
}, {
ua: "ONEPLUS A3003"
}],
dpi: 401,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONEPLUS A3010/*"
}, {
ua: "ONEPLUS A3010"
}],
dpi: 401,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONEPLUS A5000/*"
}, {
ua: "ONEPLUS A5000 "
}],
dpi: [403.411, 399.737],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONE A5010/*"
}, {
ua: "ONEPLUS A5010"
}],
dpi: [403, 400],
bw: 2,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONEPLUS A6000/*"
}, {
ua: "ONEPLUS A6000"
}],
dpi: 401,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONEPLUS A6003/*"
}, {
ua: "ONEPLUS A6003"
}],
dpi: 401,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONEPLUS A6010/*"
}, {
ua: "ONEPLUS A6010"
}],
dpi: 401,
bw: 2,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "OnePlus/*/ONEPLUS A6013/*"
}, {
ua: "ONEPLUS A6013"
}],
dpi: 401,
bw: 2,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "OPPO/*/X909/*"
}, {
ua: "X909"
}],
dpi: [442.4, 444.1],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/GT-I9082/*"
}, {
ua: "GT-I9082"
}],
dpi: [184.7, 185.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G360P/*"
}, {
ua: "SM-G360P"
}],
dpi: [196.7, 205.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/Nexus S/*"
}, {
ua: "Nexus S"
}],
dpi: [234.5, 229.8],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/GT-I9300/*"
}, {
ua: "GT-I9300"
}],
dpi: [304.8, 303.9],
bw: 5,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-T230NU/*"
}, {
ua: "SM-T230NU"
}],
dpi: 216,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SGH-T399/*"
}, {
ua: "SGH-T399"
}],
dpi: [217.7, 231.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SGH-M919/*"
}, {
ua: "SGH-M919"
}],
dpi: [440.8, 437.7],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-N9005/*"
}, {
ua: "SM-N9005"
}],
dpi: [386.4, 387],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SAMSUNG-SM-N900A/*"
}, {
ua: "SAMSUNG-SM-N900A"
}],
dpi: [386.4, 387.7],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/GT-I9500/*"
}, {
ua: "GT-I9500"
}],
dpi: [442.5, 443.3],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/GT-I9505/*"
}, {
ua: "GT-I9505"
}],
dpi: 439.4,
bw: 4,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G900F/*"
}, {
ua: "SM-G900F"
}],
dpi: [415.6, 431.6],
bw: 5,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G900M/*"
}, {
ua: "SM-G900M"
}],
dpi: [415.6, 431.6],
bw: 5,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G800F/*"
}, {
ua: "SM-G800F"
}],
dpi: 326.8,
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G906S/*"
}, {
ua: "SM-G906S"
}],
dpi: [562.7, 572.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/GT-I9300/*"
}, {
ua: "GT-I9300"
}],
dpi: [306.7, 304.8],
bw: 5,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-T535/*"
}, {
ua: "SM-T535"
}],
dpi: [142.6, 136.4],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-N920C/*"
}, {
ua: "SM-N920C"
}],
dpi: [515.1, 518.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-N920P/*"
}, {
ua: "SM-N920P"
}],
dpi: [386.3655, 390.144],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-N920W8/*"
}, {
ua: "SM-N920W8"
}],
dpi: [515.1, 518.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/GT-I9300I/*"
}, {
ua: "GT-I9300I"
}],
dpi: [304.8, 305.8],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/GT-I9195/*"
}, {
ua: "GT-I9195"
}],
dpi: [249.4, 256.7],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SPH-L520/*"
}, {
ua: "SPH-L520"
}],
dpi: [249.4, 255.9],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SAMSUNG-SGH-I717/*"
}, {
ua: "SAMSUNG-SGH-I717"
}],
dpi: 285.8,
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SPH-D710/*"
}, {
ua: "SPH-D710"
}],
dpi: [217.7, 204.2],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/GT-N7100/*"
}, {
ua: "GT-N7100"
}],
dpi: 265.1,
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SCH-I605/*"
}, {
ua: "SCH-I605"
}],
dpi: 265.1,
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/Galaxy Nexus/*"
}, {
ua: "Galaxy Nexus"
}],
dpi: [315.3, 314.2],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-N910H/*"
}, {
ua: "SM-N910H"
}],
dpi: [515.1, 518],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-N910C/*"
}, {
ua: "SM-N910C"
}],
dpi: [515.2, 520.2],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G130M/*"
}, {
ua: "SM-G130M"
}],
dpi: [165.9, 164.8],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G928I/*"
}, {
ua: "SM-G928I"
}],
dpi: [515.1, 518.4],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G920F/*"
}, {
ua: "SM-G920F"
}],
dpi: 580.6,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G920P/*"
}, {
ua: "SM-G920P"
}],
dpi: [522.5, 577],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G925F/*"
}, {
ua: "SM-G925F"
}],
dpi: 580.6,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G925V/*"
}, {
ua: "SM-G925V"
}],
dpi: [522.5, 576.6],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G930F/*"
}, {
ua: "SM-G930F"
}],
dpi: 576.6,
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G935F/*"
}, {
ua: "SM-G935F"
}],
dpi: 533,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G950F/*"
}, {
ua: "SM-G950F"
}],
dpi: [562.707, 565.293],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G955U/*"
}, {
ua: "SM-G955U"
}],
dpi: [522.514, 525.762],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G955F/*"
}, {
ua: "SM-G955F"
}],
dpi: [522.514, 525.762],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G960F/*"
}, {
ua: "SM-G960F"
}],
dpi: [569.575, 571.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G9600/*"
}, {
ua: "SM-G9600"
}],
dpi: [569.575, 571.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G960T/*"
}, {
ua: "SM-G960T"
}],
dpi: [569.575, 571.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G960N/*"
}, {
ua: "SM-G960N"
}],
dpi: [569.575, 571.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G960U/*"
}, {
ua: "SM-G960U"
}],
dpi: [569.575, 571.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G9608/*"
}, {
ua: "SM-G9608"
}],
dpi: [569.575, 571.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G960FD/*"
}, {
ua: "SM-G960FD"
}],
dpi: [569.575, 571.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G960W/*"
}, {
ua: "SM-G960W"
}],
dpi: [569.575, 571.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G965F/*"
}, {
ua: "SM-G965F"
}],
dpi: 529,
bw: 2,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Sony/*/C6903/*"
}, {
ua: "C6903"
}],
dpi: [442.5, 443.3],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "Sony/*/D6653/*"
}, {
ua: "D6653"
}],
dpi: [428.6, 427.6],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Sony/*/E6653/*"
}, {
ua: "E6653"
}],
dpi: [428.6, 425.7],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Sony/*/E6853/*"
}, {
ua: "E6853"
}],
dpi: [403.4, 401.9],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Sony/*/SGP321/*"
}, {
ua: "SGP321"
}],
dpi: [224.7, 224.1],
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "TCT/*/ALCATEL ONE TOUCH Fierce/*"
}, {
ua: "ALCATEL ONE TOUCH Fierce"
}],
dpi: [240, 247.5],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "THL/*/thl 5000/*"
}, {
ua: "thl 5000"
}],
dpi: [480, 443.3],
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Fly/*/IQ4412/*"
}, {
ua: "IQ4412"
}],
dpi: 307.9,
bw: 3,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "ZTE/*/ZTE Blade L2/*"
}, {
ua: "ZTE Blade L2"
}],
dpi: 240,
bw: 3,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "BENEVE/*/VR518/*"
}, {
ua: "VR518"
}],
dpi: 480,
bw: 3,
ac: 500
}, {
type: "ios",
rules: [{
res: [640, 960]
}],
dpi: [325.1, 328.4],
bw: 4,
ac: 1e3
}, {
type: "ios",
rules: [{
res: [640, 1136]
}],
dpi: [317.1, 320.2],
bw: 3,
ac: 1e3
}, {
type: "ios",
rules: [{
res: [750, 1334]
}],
dpi: 326.4,
bw: 4,
ac: 1e3
}, {
type: "ios",
rules: [{
res: [1242, 2208]
}],
dpi: [453.6, 458.4],
bw: 4,
ac: 1e3
}, {
type: "ios",
rules: [{
res: [1125, 2001]
}],
dpi: [410.9, 415.4],
bw: 4,
ac: 1e3
}, {
type: "ios",
rules: [{
res: [1125, 2436]
}],
dpi: 458,
bw: 4,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "Huawei/*/EML-L29/*"
}, {
ua: "EML-L29"
}],
dpi: 428,
bw: 3.45,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "Nokia/*/Nokia 7.1/*"
}, {
ua: "Nokia 7.1"
}],
dpi: [432, 431.9],
bw: 3,
ac: 500
}, {
type: "ios",
rules: [{
res: [1242, 2688]
}],
dpi: 458,
bw: 4,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G570M/*"
}, {
ua: "SM-G570M"
}],
dpi: 320,
bw: 3.684,
ac: 1e3
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G970F/*"
}, {
ua: "SM-G970F"
}],
dpi: 438,
bw: 2.281,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G973F/*"
}, {
ua: "SM-G973F"
}],
dpi: 550,
bw: 2.002,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G975F/*"
}, {
ua: "SM-G975F"
}],
dpi: 522,
bw: 2.054,
ac: 500
}, {
type: "android",
rules: [{
mdmh: "samsung/*/SM-G977F/*"
}, {
ua: "SM-G977F"
}],
dpi: 505,
bw: 2.334,
ac: 500
}, {
type: "ios",
rules: [{
res: [828, 1792]
}],
dpi: 326,
bw: 5,
ac: 500
}]
};
function Z(t, e) {
if (this.dpdb = Q, this.recalculateDeviceParams_(), t) {
this.onDeviceParamsUpdated = e;
var n = new XMLHttpRequest,
i = this;
n.open("GET", t, !0), n.addEventListener("load", (function() {
i.loading = !1, n.status >= 200 && n.status <= 299 ? (i.dpdb = JSON.parse(n.response), i.recalculateDeviceParams_()) : console.error("Error loading online DPDB!")
})), n.send()
}
}
function J(t) {
this.xdpi = t.xdpi, this.ydpi = t.ydpi, this.bevelMm = t.bevelMm
}
function K(t, e) {
this.set(t, e)
}
function $(t, e) {
this.kFilter = t, this.isDebug = e, this.currentAccelMeasurement = new K, this.currentGyroMeasurement = new K, this.previousGyroMeasurement = new K, a() ? this.filterQ = new V(-1, 0, 0, 1) : this.filterQ = new V(1, 0, 0, 1), this.previousFilterQ = new V, this.previousFilterQ.copy(this.filterQ), this.accelQ = new V, this.isOrientationInitialized = !1, this.estimatedGravity = new U, this.measuredGravity = new U, this.gyroIntegralQ = new V
}
function tt(t, e) {
this.predictionTimeS = t, this.isDebug = e, this.previousQ = new V, this.previousTimestampS = null, this.deltaQ = new V, this.outQ = new V
}
function et(t, e, n, i) {
this.yawOnly = n, this.accelerometer = new U, this.gyroscope = new U, this.filter = new $(t, i), this.posePredictor = new tt(e, i), this.isFirefoxAndroid = h(), this.isIOS = a();
var r = u();
this.isDeviceMotionInRadians = !this.isIOS && r && r < 66, this.isWithoutDeviceMotion = p() || d(), this.filterToWorldQ = new V, a() ? this.filterToWorldQ.setFromAxisAngle(new U(1, 0, 0), Math.PI / 2) : this.filterToWorldQ.setFromAxisAngle(new U(1, 0, 0), -Math.PI / 2), this.inverseWorldToScreenQ = new V, this.worldToScreenQ = new V, this.originalPoseAdjustQ = new V, this.originalPoseAdjustQ.setFromAxisAngle(new U(0, 0, 1), -window.orientation * Math.PI / 180), this.setScreenTransform_(), m() && this.filterToWorldQ.multiply(this.inverseWorldToScreenQ), this.resetQ = new V, this.orientationOut_ = new Float32Array(4), this.start()
}
Z.prototype.getDeviceParams = function() {
return this.deviceParams
}, Z.prototype.recalculateDeviceParams_ = function() {
var t = this.calcDeviceParams_();
t ? (this.deviceParams = t, this.onDeviceParamsUpdated && this.onDeviceParamsUpdated(this.deviceParams)) : console.error("Failed to recalculate device parameters.")
}, Z.prototype.calcDeviceParams_ = function() {
var t = this.dpdb;
if (!t) return console.error("DPDB not available."), null;
if (1 != t.format) return console.error("DPDB has unexpected format version."), null;
if (!t.devices || !t.devices.length) return console.error("DPDB does not have a devices section."), null;
var e = navigator.userAgent || navigator.vendor || window.opera,
n = g(),
i = v();
if (!t.devices) return console.error("DPDB has no devices section."), null;
for (var r = 0; r < t.devices.length; r++) {
var o = t.devices[r];
if (o.rules)
if ("ios" == o.type || "android" == o.type) {
if (a() == ("ios" == o.type)) {
for (var s = !1, l = 0; l < o.rules.length; l++) {
var c = o.rules[l];
if (this.ruleMatches_(c, e, n, i)) {
s = !0;
break
}
}
if (s) return new J({
xdpi: o.dpi[0] || o.dpi,
ydpi: o.dpi[1] || o.dpi,
bevelMm: o.bw
})
}
} else console.warn("Device[" + r + "] has invalid type.");
else console.warn("Device[" + r + "] has no rules section.")
}
return console.warn("No DPDB device match."), null
}, Z.prototype.ruleMatches_ = function(t, e, n, i) {
if (!t.ua && !t.res) return !1;
if (t.ua && "SM" === t.ua.substring(0, 2) && (t.ua = t.ua.substring(0, 7)), t.ua && e.indexOf(t.ua) < 0) return !1;
if (t.res) {
if (!t.res[0] || !t.res[1]) return !1;
var r = t.res[0],
o = t.res[1];
if (Math.min(n, i) != Math.min(r, o) || Math.max(n, i) != Math.max(r, o)) return !1
}
return !0
}, K.prototype.set = function(t, e) {
this.sample = t, this.timestampS = e
}, K.prototype.copy = function(t) {
this.set(t.sample, t.timestampS)
}, $.prototype.addAccelMeasurement = function(t, e) {
this.currentAccelMeasurement.set(t, e)
}, $.prototype.addGyroMeasurement = function(t, e) {
this.currentGyroMeasurement.set(t, e);
var n, i = e - this.previousGyroMeasurement.timestampS;
n = i, isNaN(n) || n <= .001 || n > 1 || this.run_(), this.previousGyroMeasurement.copy(this.currentGyroMeasurement)
}, $.prototype.run_ = function() {
if (!this.isOrientationInitialized) return this.accelQ = this.accelToQuaternion_(this.currentAccelMeasurement.sample), this.previousFilterQ.copy(this.accelQ), void(this.isOrientationInitialized = !0);
var t = this.currentGyroMeasurement.timestampS - this.previousGyroMeasurement.timestampS,
e = this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample, t);
this.gyroIntegralQ.multiply(e), this.filterQ.copy(this.previousFilterQ), this.filterQ.multiply(e);
var n = new V;
n.copy(this.filterQ), n.inverse(), this.estimatedGravity.set(0, 0, -1), this.estimatedGravity.applyQuaternion(n), this.estimatedGravity.normalize(), this.measuredGravity.copy(this.currentAccelMeasurement.sample), this.measuredGravity.normalize();
var i, r = new V;
r.setFromUnitVectors(this.estimatedGravity, this.measuredGravity), r.inverse(), this.isDebug && console.log("Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)", z * ((i = r).w > 1 ? (console.warn("getQuaternionAngle: w > 1"), 0) : 2 * Math.acos(i.w)), this.estimatedGravity.x.toFixed(1), this.estimatedGravity.y.toFixed(1), this.estimatedGravity.z.toFixed(1), this.measuredGravity.x.toFixed(1), this.measuredGravity.y.toFixed(1), this.measuredGravity.z.toFixed(1));
var o = new V;
o.copy(this.filterQ), o.multiply(r), this.filterQ.slerp(o, 1 - this.kFilter), this.previousFilterQ.copy(this.filterQ)
}, $.prototype.getOrientation = function() {
return this.filterQ
}, $.prototype.accelToQuaternion_ = function(t) {
var e = new U;
e.copy(t), e.normalize();
var n = new V;
return n.setFromUnitVectors(new U(0, 0, -1), e), n.inverse(), n
}, $.prototype.gyroToQuaternionDelta_ = function(t, e) {
var n = new V,
i = new U;
return i.copy(t), i.normalize(), n.setFromAxisAngle(i, t.length() * e), n
}, tt.prototype.getPrediction = function(t, e, n) {
if (!this.previousTimestampS) return this.previousQ.copy(t), this.previousTimestampS = n, t;
var i = new U;
i.copy(e), i.normalize();
var r = e.length();
if (r < 20 * F) return this.isDebug && console.log("Moving slowly, at %s deg/s: no prediction", (z * r).toFixed(1)), this.outQ.copy(t), this.previousQ.copy(t), this.outQ;
var o = r * this.predictionTimeS;
return this.deltaQ.setFromAxisAngle(i, o), this.outQ.copy(this.previousQ), this.outQ.multiply(this.deltaQ), this.previousQ.copy(t), this.previousTimestampS = n, this.outQ
}, et.prototype.getPosition = function() {
return null
}, et.prototype.getOrientation = function() {
var t = void 0;
if (this.isWithoutDeviceMotion && this._deviceOrientationQ) return this.deviceOrientationFixQ = this.deviceOrientationFixQ || (n = (new V).setFromAxisAngle(new U(0, 0, -1), 0), i = new V, -90 === window.orientation ? i.setFromAxisAngle(new U(0, 1, 0), Math.PI / -2) : i.setFromAxisAngle(new U(0, 1, 0), Math.PI / 2), n.multiply(i)), this.deviceOrientationFilterToWorldQ = this.deviceOrientationFilterToWorldQ || ((e = new V).setFromAxisAngle(new U(1, 0, 0), -Math.PI / 2), e), t = this._deviceOrientationQ, (r = new V).copy(t), r.multiply(this.deviceOrientationFilterToWorldQ), r.multiply(this.resetQ), r.multiply(this.worldToScreenQ), r.multiplyQuaternions(this.deviceOrientationFixQ, r), this.yawOnly && (r.x = 0, r.z = 0, r.normalize()), this.orientationOut_[0] = r.x, this.orientationOut_[1] = r.y, this.orientationOut_[2] = r.z, this.orientationOut_[3] = r.w, this.orientationOut_;
var e, n, i, r, o = this.filter.getOrientation();
return t = this.posePredictor.getPrediction(o, this.gyroscope, this.previousTimestampS), (r = new V).copy(this.filterToWorldQ), r.multiply(this.resetQ), r.multiply(t), r.multiply(this.worldToScreenQ), this.yawOnly && (r.x = 0, r.z = 0, r.normalize()), this.orientationOut_[0] = r.x, this.orientationOut_[1] = r.y, this.orientationOut_[2] = r.z, this.orientationOut_[3] = r.w, this.orientationOut_
}, et.prototype.resetPose = function() {
this.resetQ.copy(this.filter.getOrientation()), this.resetQ.x = 0, this.resetQ.y = 0, this.resetQ.z *= -1, this.resetQ.normalize(), m() && this.resetQ.multiply(this.inverseWorldToScreenQ), this.resetQ.multiply(this.originalPoseAdjustQ)
}, et.prototype.onDeviceOrientation_ = function(t) {
this._deviceOrientationQ = this._deviceOrientationQ || new V;
var e = t.alpha,
n = t.beta,
i = t.gamma;
e = (e || 0) * Math.PI / 180, n = (n || 0) * Math.PI / 180, i = (i || 0) * Math.PI / 180, this._deviceOrientationQ.setFromEulerYXZ(n, e, -i)
}, et.prototype.onDeviceMotion_ = function(t) {
this.updateDeviceMotion_(t)
}, et.prototype.updateDeviceMotion_ = function(t) {
var e = t.accelerationIncludingGravity,
n = t.rotationRate,
i = t.timeStamp / 1e3,
r = i - this.previousTimestampS;
return r < 0 ? (S("fusion-pose-sensor:invalid:non-monotonic", "Invalid timestamps detected: non-monotonic timestamp from devicemotion"), void(this.previousTimestampS = i)) : r <= .001 || r > 1 ? (S("fusion-pose-sensor:invalid:outside-threshold", "Invalid timestamps detected: Timestamp from devicemotion outside expected range."), void(this.previousTimestampS = i)) : (this.accelerometer.set(-e.x, -e.y, -e.z), n && (f() ? this.gyroscope.set(-n.beta, n.alpha, n.gamma) : this.gyroscope.set(n.alpha, n.beta, n.gamma), this.isDeviceMotionInRadians || this.gyroscope.multiplyScalar(Math.PI / 180), this.filter.addGyroMeasurement(this.gyroscope, i)), this.filter.addAccelMeasurement(this.accelerometer, i), void(this.previousTimestampS = i))
}, et.prototype.onOrientationChange_ = function(t) {
this.setScreenTransform_()
}, et.prototype.onMessage_ = function(t) {
var e = t.data;
e && e.type && "devicemotion" === e.type.toLowerCase() && this.updateDeviceMotion_(e.deviceMotionEvent)
}, et.prototype.setScreenTransform_ = function() {
switch (this.worldToScreenQ.set(0, 0, 0, 1), window.orientation) {
case 0:
break;
case 90:
this.worldToScreenQ.setFromAxisAngle(new U(0, 0, 1), -Math.PI / 2);
break;
case -90:
this.worldToScreenQ.setFromAxisAngle(new U(0, 0, 1), Math.PI / 2)
}
this.inverseWorldToScreenQ.copy(this.worldToScreenQ), this.inverseWorldToScreenQ.inverse()
}, et.prototype.start = function() {
var t, e, n;
this.onDeviceMotionCallback_ = this.onDeviceMotion_.bind(this), this.onOrientationChangeCallback_ = this.onOrientationChange_.bind(this), this.onMessageCallback_ = this.onMessage_.bind(this), this.onDeviceOrientationCallback_ = this.onDeviceOrientation_.bind(this), a() && (t = window.self !== window.top, e = E(document.referrer), n = E(window.location.href), t && e !== n) && window.addEventListener("message", this.onMessageCallback_), window.addEventListener("orientationchange", this.onOrientationChangeCallback_), this.isWithoutDeviceMotion ? window.addEventListener("deviceorientation", this.onDeviceOrientationCallback_) : window.addEventListener("devicemotion", this.onDeviceMotionCallback_)
}, et.prototype.stop = function() {
window.removeEventListener("devicemotion", this.onDeviceMotionCallback_), window.removeEventListener("deviceorientation", this.onDeviceOrientationCallback_), window.removeEventListener("orientationchange", this.onOrientationChangeCallback_), window.removeEventListener("message", this.onMessageCallback_)
};
var nt = new U(1, 0, 0),
it = new U(0, 0, 1),
rt = new V;
rt.setFromAxisAngle(nt, -Math.PI / 2), rt.multiply((new V).setFromAxisAngle(it, Math.PI / 2));
var ot = function() {
function t(e) {
! function(t, e) {
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
}(this, t), this.config = e, this.sensor = null, this.fusionSensor = null, this._out = new Float32Array(4), this.api = null, this.errors = [], this._sensorQ = new V, this._outQ = new V, this._onSensorRead = this._onSensorRead.bind(this), this._onSensorError = this._onSensorError.bind(this), this.init()
}
return r(t, [{
key: "init",
value: function() {
var t = null;
try {
(t = new RelativeOrientationSensor({
frequency: 60,
referenceFrame: "screen"
})).addEventListener("error", this._onSensorError)
} catch (t) {
this.errors.push(t), "SecurityError" === t.name ? (console.error("Cannot construct sensors due to the Feature Policy"), console.warn('Attempting to fall back using "devicemotion"; however this will fail in the future without correct permissions.'), this.useDeviceMotion()) : "ReferenceError" === t.name ? this.useDeviceMotion() : console.error(t)
}
t && (this.api = "sensor", this.sensor = t, this.sensor.addEventListener("reading", this._onSensorRead), this.sensor.start())
}
}, {
key: "useDeviceMotion",
value: function() {
this.api = "devicemotion", this.fusionSensor = new et(this.config.K_FILTER, this.config.PREDICTION_TIME_S, this.config.YAW_ONLY, this.config.DEBUG), this.sensor && (this.sensor.removeEventListener("reading", this._onSensorRead), this.sensor.removeEventListener("error", this._onSensorError), this.sensor = null)
}
}, {
key: "getOrientation",
value: function() {
if (this.fusionSensor) return this.fusionSensor.getOrientation();
if (!this.sensor || !this.sensor.quaternion) return this._out[0] = this._out[1] = this._out[2] = 0, this._out[3] = 1, this._out;
var t = this.sensor.quaternion;
this._sensorQ.set(t[0], t[1], t[2], t[3]);
var e = this._outQ;
return e.copy(rt), e.multiply(this._sensorQ), this.config.YAW_ONLY && (e.x = e.z = 0, e.normalize()), this._out[0] = e.x, this._out[1] = e.y, this._out[2] = e.z, this._out[3] = e.w, this._out
}
}, {
key: "_onSensorError",
value: function(t) {
this.errors.push(t.error), "NotAllowedError" === t.error.name ? console.error("Permission to access sensor was denied") : "NotReadableError" === t.error.name ? console.error("Sensor could not be read") : console.error(t.error), this.useDeviceMotion()
}
}, {
key: "_onSensorRead",
value: function() {}
}]), t
}();
function st() {
this.loadIcon_();
var t = document.createElement("div");
(o = t.style).position = "fixed", o.top = 0, o.right = 0, o.bottom = 0, o.left = 0, o.backgroundColor = "gray", o.fontFamily = "sans-serif", o.zIndex = 1e6;
var e = document.createElement("img");
e.src = this.icon, (o = e.style).marginLeft = "25%", o.marginTop = "25%", o.width = "50%", t.appendChild(e);
var n = document.createElement("div");
(o = n.style).textAlign = "center", o.fontSize = "16px", o.lineHeight = "24px", o.margin = "24px 25%", o.width = "50%", n.innerHTML = "Place your phone into your Cardboard viewer.", t.appendChild(n);
var i = document.createElement("div");
(o = i.style).backgroundColor = "#CFD8DC", o.position = "fixed", o.bottom = 0, o.width = "100%", o.height = "48px", o.padding = "14px 24px", o.boxSizing = "border-box", o.color = "#656A6B", t.appendChild(i);
var r = document.createElement("div");
r.style.float = "left", r.innerHTML = "No Cardboard viewer?";
var o, s = document.createElement("a");
s.href = "https://www.google.com/get/cardboard/get-cardboard/", s.innerHTML = "get one", s.target = "_blank", (o = s.style).float = "right", o.fontWeight = 600, o.textTransform = "uppercase", o.borderLeft = "1px solid gray", o.paddingLeft = "24px", o.textDecoration = "none", o.color = "#656A6B", i.appendChild(r), i.appendChild(s), this.overlay = t, this.text = n, this.hide()
}
function at(t) {
try {
this.selectedKey = localStorage.getItem("WEBVR_CARDBOARD_VIEWER")
} catch (t) {
console.error("Failed to load viewer profile: %s", t)
}
this.selectedKey || (this.selectedKey = t || "CardboardV1"), this.dialog = this.createDialog_(q.Viewers), this.root = null, this.onChangeCallbacks_ = []
}
st.prototype.show = function(t) {
t || this.overlay.parentElement ? t && (this.overlay.parentElement && this.overlay.parentElement != t && this.overlay.parentElement.removeChild(this.overlay), t.appendChild(this.overlay)) : document.body.appendChild(this.overlay), this.overlay.style.display = "block";
var e = this.overlay.querySelector("img").style;
m() ? (e.width = "20%", e.marginLeft = "40%", e.marginTop = "3%") : (e.width = "50%", e.marginLeft = "25%", e.marginTop = "25%")
}, st.prototype.hide = function() {
this.overlay.style.display = "none"
}, st.prototype.showTemporarily = function(t, e) {
this.show(e), this.timer = setTimeout(this.hide.bind(this), t)
}, st.prototype.disableShowTemporarily = function() {
clearTimeout(this.timer)
}, st.prototype.update = function() {
this.disableShowTemporarily(), !m() && _() ? this.show() : this.hide()
}, st.prototype.loadIcon_ = function() {
this.icon = "data:image/svg+xml," + encodeURIComponent("")
}, at.prototype.show = function(t) {
this.root = t, t.appendChild(this.dialog), this.dialog.querySelector("#" + this.selectedKey).checked = !0, this.dialog.style.display = "block"
}, at.prototype.hide = function() {
this.root && this.root.contains(this.dialog) && this.root.removeChild(this.dialog), this.dialog.style.display = "none"
}, at.prototype.getCurrentViewer = function() {
return q.Viewers[this.selectedKey]
}, at.prototype.getSelectedKey_ = function() {
var t = this.dialog.querySelector("input[name=field]:checked");
return t ? t.id : null
}, at.prototype.onChange = function(t) {
this.onChangeCallbacks_.push(t)
}, at.prototype.fireOnChange_ = function(t) {
for (var e = 0; e < this.onChangeCallbacks_.length; e++) this.onChangeCallbacks_[e](t)
}, at.prototype.onSave_ = function() {
if (this.selectedKey = this.getSelectedKey_(), this.selectedKey && q.Viewers[this.selectedKey]) {
this.fireOnChange_(q.Viewers[this.selectedKey]);
try {
localStorage.setItem("WEBVR_CARDBOARD_VIEWER", this.selectedKey)
} catch (t) {
console.error("Failed to save viewer profile: %s", t)
}
this.hide()
} else console.error("ViewerSelector.onSave_: this should never happen!")
}, at.prototype.createDialog_ = function(t) {
var e = document.createElement("div");
e.classList.add("webvr-polyfill-viewer-selector"), e.style.display = "none";
var n = document.createElement("div");
(r = n.style).position = "fixed", r.left = 0, r.top = 0, r.width = "100%", r.height = "100%", r.background = "rgba(0, 0, 0, 0.3)", n.addEventListener("click", this.hide.bind(this));
var i = document.createElement("div"),
r = i.style;
for (var o in r.boxSizing = "border-box", r.position = "fixed", r.top = "24px", r.left = "50%", r.marginLeft = "-140px", r.width = "280px", r.padding = "24px", r.overflow = "hidden", r.background = "#fafafa", r.fontFamily = "'Roboto', sans-serif", r.boxShadow = "0px 5px 20px #666", i.appendChild(this.createH1_("Select your viewer")), t) i.appendChild(this.createChoice_(o, t[o].label));
return i.appendChild(this.createButton_("Save", this.onSave_.bind(this))), e.appendChild(n), e.appendChild(i), e
}, at.prototype.createH1_ = function(t) {
var e = document.createElement("h1"),
n = e.style;
return n.color = "black", n.fontSize = "20px", n.fontWeight = "bold", n.marginTop = 0, n.marginBottom = "24px", e.innerHTML = t, e
}, at.prototype.createChoice_ = function(t, e) {
var n = document.createElement("div");
n.style.marginTop = "8px", n.style.color = "black";
var i = document.createElement("input");
i.style.fontSize = "30px", i.setAttribute("id", t), i.setAttribute("type", "radio"), i.setAttribute("value", t), i.setAttribute("name", "field");
var r = document.createElement("label");
return r.style.marginLeft = "4px", r.setAttribute("for", t), r.innerHTML = e, n.appendChild(i), n.appendChild(r), n
}, at.prototype.createButton_ = function(t, e) {
var n = document.createElement("button");
n.innerHTML = t;
var i = n.style;
return i.float = "right", i.textTransform = "uppercase", i.color = "#1094f7", i.fontSize = "14px", i.letterSpacing = 0, i.border = 0, i.background = "none", i.marginTop = "16px", n.addEventListener("click", e), n
}, "undefined" != typeof window ? window : void 0 !== e || "undefined" != typeof self && self;
var lt, ct = (lt = function(t, e) {
return t(e = {
exports: {}
}, e.exports), e.exports
}((function(t, e) {
! function(e, n) {
t.exports = n()
}(0, (function() {
return function(t) {
var e = {};
function n(i) {
if (e[i]) return e[i].exports;
var r = e[i] = {
i: i,
l: !1,
exports: {}
};
return t[i].call(r.exports, r, r.exports, n), r.l = !0, r.exports
}
return n.m = t, n.c = e, n.d = function(t, e, i) {
n.o(t, e) || Object.defineProperty(t, e, {
configurable: !1,
enumerable: !0,
get: i
})
}, n.n = function(t) {
var e = t && t.__esModule ? function() {
return t.default
} : function() {
return t
};
return n.d(e, "a", e), e
}, n.o = function(t, e) {
return Object.prototype.hasOwnProperty.call(t, e)
}, n.p = "", n(n.s = 0)
}([function(t, e, n) {
var i = function() {
function t(t, e) {
for (var n = 0; n < e.length; n++) {
var i = e[n];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i)
}
}
return function(e, n, i) {
return n && t(e.prototype, n), i && t(e, i), e
}
}(),
r = n(1),
o = "undefined" != typeof navigator && parseFloat(("" + (/CPU.*OS ([0-9_]{3,4})[0-9_]{0,1}|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0, ""])[1]).replace("undefined", "3_2").replace("_", ".").replace("_", "")) < 10 && !window.MSStream,
s = function() {
function t() {
! function(t, e) {
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
}(this, t), o ? this.noSleepTimer = null : (this.noSleepVideo = document.createElement("video"), this.noSleepVideo.setAttribute("playsinline", ""), this.noSleepVideo.setAttribute("src", r), this.noSleepVideo.addEventListener("timeupdate", function(t) {
this.noSleepVideo.currentTime > .5 && (this.noSleepVideo.currentTime = Math.random())
}.bind(this)))
}
return i(t, [{
key: "enable",
value: function() {
o ? (this.disable(), this.noSleepTimer = window.setInterval((function() {
window.location.href = "/", window.setTimeout(window.stop, 0)
}), 15e3)) : this.noSleepVideo.play()
}
}, {
key: "disable",
value: function() {
o ? this.noSleepTimer && (window.clearInterval(this.noSleepTimer), this.noSleepTimer = null) : this.noSleepVideo.pause()
}
}]), t
}();
t.exports = s
}, function(t, e, n) {
t.exports = "data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACKBtZGF0AAAC8wYF///v3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0MiByMjQ3OSBkZDc5YTYxIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTEgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibWU9MiBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0wIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MCA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0wIHRocmVhZHM9NiBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJhbWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdlaWdodHA9MSBrZXlpbnQ9MzAwIGtleWludF9taW49MzAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD0xMCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIwLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IHZidl9tYXhyYXRlPTIwMDAwIHZidl9idWZzaXplPTI1MDAwIGNyZl9tYXg9MC4wIG5hbF9ocmQ9bm9uZSBmaWxsZXI9MCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAAAOWWIhAA3//p+C7v8tDDSTjf97w55i3SbRPO4ZY+hkjD5hbkAkL3zpJ6h/LR1CAABzgB1kqqzUorlhQAAAAxBmiQYhn/+qZYADLgAAAAJQZ5CQhX/AAj5IQADQGgcIQADQGgcAAAACQGeYUQn/wALKCEAA0BoHAAAAAkBnmNEJ/8ACykhAANAaBwhAANAaBwAAAANQZpoNExDP/6plgAMuSEAA0BoHAAAAAtBnoZFESwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBnqVEJ/8ACykhAANAaBwAAAAJAZ6nRCf/AAsoIQADQGgcIQADQGgcAAAADUGarDRMQz/+qZYADLghAANAaBwAAAALQZ7KRRUsK/8ACPkhAANAaBwAAAAJAZ7pRCf/AAsoIQADQGgcIQADQGgcAAAACQGe60Qn/wALKCEAA0BoHAAAAA1BmvA0TEM//qmWAAy5IQADQGgcIQADQGgcAAAAC0GfDkUVLCv/AAj5IQADQGgcAAAACQGfLUQn/wALKSEAA0BoHCEAA0BoHAAAAAkBny9EJ/8ACyghAANAaBwAAAANQZs0NExDP/6plgAMuCEAA0BoHAAAAAtBn1JFFSwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBn3FEJ/8ACyghAANAaBwAAAAJAZ9zRCf/AAsoIQADQGgcIQADQGgcAAAADUGbeDRMQz/+qZYADLkhAANAaBwAAAALQZ+WRRUsK/8ACPghAANAaBwhAANAaBwAAAAJAZ+1RCf/AAspIQADQGgcAAAACQGft0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bm7w0TEM//qmWAAy4IQADQGgcAAAAC0Gf2kUVLCv/AAj5IQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHAAAAAkBn/tEJ/8ACykhAANAaBwAAAANQZvgNExDP/6plgAMuSEAA0BoHCEAA0BoHAAAAAtBnh5FFSwr/wAI+CEAA0BoHAAAAAkBnj1EJ/8ACyghAANAaBwhAANAaBwAAAAJAZ4/RCf/AAspIQADQGgcAAAADUGaJDRMQz/+qZYADLghAANAaBwAAAALQZ5CRRUsK/8ACPkhAANAaBwhAANAaBwAAAAJAZ5hRCf/AAsoIQADQGgcAAAACQGeY0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bmmg0TEM//qmWAAy5IQADQGgcAAAAC0GehkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGepUQn/wALKSEAA0BoHAAAAAkBnqdEJ/8ACyghAANAaBwAAAANQZqsNExDP/6plgAMuCEAA0BoHCEAA0BoHAAAAAtBnspFFSwr/wAI+SEAA0BoHAAAAAkBnulEJ/8ACyghAANAaBwhAANAaBwAAAAJAZ7rRCf/AAsoIQADQGgcAAAADUGa8DRMQz/+qZYADLkhAANAaBwhAANAaBwAAAALQZ8ORRUsK/8ACPkhAANAaBwAAAAJAZ8tRCf/AAspIQADQGgcIQADQGgcAAAACQGfL0Qn/wALKCEAA0BoHAAAAA1BmzQ0TEM//qmWAAy4IQADQGgcAAAAC0GfUkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGfcUQn/wALKCEAA0BoHAAAAAkBn3NEJ/8ACyghAANAaBwhAANAaBwAAAANQZt4NExC//6plgAMuSEAA0BoHAAAAAtBn5ZFFSwr/wAI+CEAA0BoHCEAA0BoHAAAAAkBn7VEJ/8ACykhAANAaBwAAAAJAZ+3RCf/AAspIQADQGgcAAAADUGbuzRMQn/+nhAAYsAhAANAaBwhAANAaBwAAAAJQZ/aQhP/AAspIQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHAAACiFtb292AAAAbG12aGQAAAAA1YCCX9WAgl8AAAPoAAAH/AABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAGGlvZHMAAAAAEICAgAcAT////v7/AAAF+XRyYWsAAABcdGtoZAAAAAPVgIJf1YCCXwAAAAEAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAygAAAMoAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAB9AAABdwAAEAAAAABXFtZGlhAAAAIG1kaGQAAAAA1YCCX9WAgl8AAV+QAAK/IFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAUcbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAE3HN0YmwAAACYc3RzZAAAAAAAAAABAAAAiGF2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAygDKAEgAAABIAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAAyYXZjQwFNQCj/4QAbZ01AKOyho3ySTUBAQFAAAAMAEAAr8gDxgxlgAQAEaO+G8gAAABhzdHRzAAAAAAAAAAEAAAA8AAALuAAAABRzdHNzAAAAAAAAAAEAAAABAAAB8GN0dHMAAAAAAAAAPAAAAAEAABdwAAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAAC7gAAAAAQAAF3AAAAABAAAAAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAEEc3RzegAAAAAAAAAAAAAAPAAAAzQAAAAQAAAADQAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAANAAAADQAAAQBzdGNvAAAAAAAAADwAAAAwAAADZAAAA3QAAAONAAADoAAAA7kAAAPQAAAD6wAAA/4AAAQXAAAELgAABEMAAARcAAAEbwAABIwAAAShAAAEugAABM0AAATkAAAE/wAABRIAAAUrAAAFQgAABV0AAAVwAAAFiQAABaAAAAW1AAAFzgAABeEAAAX+AAAGEwAABiwAAAY/AAAGVgAABnEAAAaEAAAGnQAABrQAAAbPAAAG4gAABvUAAAcSAAAHJwAAB0AAAAdTAAAHcAAAB4UAAAeeAAAHsQAAB8gAAAfjAAAH9gAACA8AAAgmAAAIQQAACFQAAAhnAAAIhAAACJcAAAMsdHJhawAAAFx0a2hkAAAAA9WAgl/VgIJfAAAAAgAAAAAAAAf8AAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAACsm1kaWEAAAAgbWRoZAAAAADVgIJf1YCCXwAArEQAAWAAVcQAAAAAACdoZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU3RlcmVvAAAAAmNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAidzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAADDUAAAAAABYCAgAISEAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAABYAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAAGAAAAWAAAAXBzdGNvAAAAAAAAAFgAAAOBAAADhwAAA5oAAAOtAAADswAAA8oAAAPfAAAD5QAAA/gAAAQLAAAEEQAABCgAAAQ9AAAEUAAABFYAAARpAAAEgAAABIYAAASbAAAErgAABLQAAATHAAAE3gAABPMAAAT5AAAFDAAABR8AAAUlAAAFPAAABVEAAAVXAAAFagAABX0AAAWDAAAFmgAABa8AAAXCAAAFyAAABdsAAAXyAAAF+AAABg0AAAYgAAAGJgAABjkAAAZQAAAGZQAABmsAAAZ+AAAGkQAABpcAAAauAAAGwwAABskAAAbcAAAG7wAABwYAAAcMAAAHIQAABzQAAAc6AAAHTQAAB2QAAAdqAAAHfwAAB5IAAAeYAAAHqwAAB8IAAAfXAAAH3QAAB/AAAAgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA="
}])
}))
}))) && lt.__esModule && Object.prototype.hasOwnProperty.call(lt, "default") ? lt.default : lt,
ht = 1e3,
ut = [0, 0, .5, 1],
dt = [.5, 0, .5, 1],
pt = window.requestAnimationFrame,
ft = window.cancelAnimationFrame;
function mt(t) {
Object.defineProperties(this, {
hasPosition: {
writable: !1,
enumerable: !0,
value: t.hasPosition
},
hasExternalDisplay: {
writable: !1,
enumerable: !0,
value: t.hasExternalDisplay
},
canPresent: {
writable: !1,
enumerable: !0,
value: t.canPresent
},
maxLayers: {
writable: !1,
enumerable: !0,
value: t.maxLayers
},
hasOrientation: {
enumerable: !0,
get: function() {
return T("VRDisplayCapabilities.prototype.hasOrientation", "VRDisplay.prototype.getFrameData"), t.hasOrientation
}
}
})
}
function gt(t) {
var e = !("wakelock" in (t = t || {})) || t.wakelock;
this.isPolyfilled = !0, this.displayId = ht++, this.displayName = "", this.depthNear = .01, this.depthFar = 1e4, this.isPresenting = !1, Object.defineProperty(this, "isConnected", {
get: function() {
return T("VRDisplay.prototype.isConnected", "VRDisplayCapabilities.prototype.hasExternalDisplay"), !1
}
}), this.capabilities = new mt({
hasPosition: !1,
hasOrientation: !1,
hasExternalDisplay: !1,
canPresent: !1,
maxLayers: 1
}), this.stageParameters = null, this.waitingForPresent_ = !1, this.layer_ = null, this.originalParent_ = null, this.fullscreenElement_ = null, this.fullscreenWrapper_ = null, this.fullscreenElementCachedStyle_ = null, this.fullscreenEventTarget_ = null, this.fullscreenChangeHandler_ = null, this.fullscreenErrorHandler_ = null, e && _() && (this.wakelock_ = new ct)
}
gt.prototype.getFrameData = function(t) {
return M(t, this._getPose(), this)
}, gt.prototype.getPose = function() {
return T("VRDisplay.prototype.getPose", "VRDisplay.prototype.getFrameData"), this._getPose()
}, gt.prototype.resetPose = function() {
return T("VRDisplay.prototype.resetPose"), this._resetPose()
}, gt.prototype.getImmediatePose = function() {
return T("VRDisplay.prototype.getImmediatePose", "VRDisplay.prototype.getFrameData"), this._getPose()
}, gt.prototype.requestAnimationFrame = function(t) {
return pt(t)
}, gt.prototype.cancelAnimationFrame = function(t) {
return ft(t)
}, gt.prototype.wrapForFullscreen = function(t) {
if (a()) return t;
if (!this.fullscreenWrapper_) {
this.fullscreenWrapper_ = document.createElement("div");
var e = ["height: " + Math.min(screen.height, screen.width) + "px !important", "top: 0 !important", "left: 0 !important", "right: 0 !important", "border: 0", "margin: 0", "padding: 0", "z-index: 999999 !important", "position: fixed"];
this.fullscreenWrapper_.setAttribute("style", e.join("; ") + ";"), this.fullscreenWrapper_.classList.add("webvr-polyfill-fullscreen-wrapper")
}
if (this.fullscreenElement_ == t) return this.fullscreenWrapper_;
if (this.fullscreenElement_ && (this.originalParent_ ? this.originalParent_.appendChild(this.fullscreenElement_) : this.fullscreenElement_.parentElement.removeChild(this.fullscreenElement_)), this.fullscreenElement_ = t, this.originalParent_ = t.parentElement, this.originalParent_ || document.body.appendChild(t), !this.fullscreenWrapper_.parentElement) {
var n = this.fullscreenElement_.parentElement;
n.insertBefore(this.fullscreenWrapper_, this.fullscreenElement_), n.removeChild(this.fullscreenElement_)
}
this.fullscreenWrapper_.insertBefore(this.fullscreenElement_, this.fullscreenWrapper_.firstChild), this.fullscreenElementCachedStyle_ = this.fullscreenElement_.getAttribute("style");
var i = this;
return function() {
if (i.fullscreenElement_) {
var t = ["position: absolute", "top: 0", "left: 0", "width: " + Math.max(screen.width, screen.height) + "px", "height: " + Math.min(screen.height, screen.width) + "px", "border: 0", "margin: 0", "padding: 0"];
i.fullscreenElement_.setAttribute("style", t.join("; ") + ";")
}
}(), this.fullscreenWrapper_
}, gt.prototype.removeFullscreenWrapper = function() {
if (this.fullscreenElement_) {
var t = this.fullscreenElement_;
this.fullscreenElementCachedStyle_ ? t.setAttribute("style", this.fullscreenElementCachedStyle_) : t.removeAttribute("style"), this.fullscreenElement_ = null, this.fullscreenElementCachedStyle_ = null;
var e = this.fullscreenWrapper_.parentElement;
return this.fullscreenWrapper_.removeChild(t), this.originalParent_ === e ? e.insertBefore(t, this.fullscreenWrapper_) : this.originalParent_ && this.originalParent_.appendChild(t), e.removeChild(this.fullscreenWrapper_), t
}
}, gt.prototype.requestPresent = function(t) {
var e = this.isPresenting,
n = this;
return t instanceof Array || (T("VRDisplay.prototype.requestPresent with non-array argument", "an array of VRLayers as the first argument"), t = [t]), new Promise((function(i, r) {
if (n.capabilities.canPresent)
if (0 == t.length || t.length > n.capabilities.maxLayers) r(new Error("Invalid number of layers."));
else {
var o = t[0];
if (o.source) {
var s = o.leftBounds || ut,
c = o.rightBounds || dt;
if (e) {
var h = n.layer_;
h.source !== o.source && (h.source = o.source);
for (var u = 0; u < 4; u++) h.leftBounds[u] = s[u], h.rightBounds[u] = c[u];
return n.wrapForFullscreen(n.layer_.source), n.updatePresent_(), void i()
}
if (n.layer_ = {
predistorted: o.predistorted,
source: o.source,
leftBounds: s.slice(0),
rightBounds: c.slice(0)
}, n.waitingForPresent_ = !1, n.layer_ && n.layer_.source) {
var d = n.wrapForFullscreen(n.layer_.source);
n.addFullscreenListeners_(d, (function() {
var t = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement;
n.isPresenting = d === t, n.isPresenting ? (screen.orientation && screen.orientation.lock && screen.orientation.lock("landscape-primary").catch((function(t) {
console.error("screen.orientation.lock() failed due to", t.message)
})), n.waitingForPresent_ = !1, n.beginPresent_(), i()) : (screen.orientation && screen.orientation.unlock && screen.orientation.unlock(), n.removeFullscreenWrapper(), n.disableWakeLock(), n.endPresent_(), n.removeFullscreenListeners_()), n.fireVRDisplayPresentChange_()
}), (function() {
n.waitingForPresent_ && (n.removeFullscreenWrapper(), n.removeFullscreenListeners_(), n.disableWakeLock(), n.waitingForPresent_ = !1, n.isPresenting = !1, r(new Error("Unable to present.")))
})),
function(t) {
if (l()) return !1;
if (t.requestFullscreen) t.requestFullscreen();
else if (t.webkitRequestFullscreen) t.webkitRequestFullscreen();
else if (t.mozRequestFullScreen) t.mozRequestFullScreen();
else {
if (!t.msRequestFullscreen) return !1;
t.msRequestFullscreen()
}
return !0
}(d) ? (n.enableWakeLock(), n.waitingForPresent_ = !0) : (a() || l()) && (n.enableWakeLock(), n.isPresenting = !0, n.beginPresent_(), n.fireVRDisplayPresentChange_(), i())
}
n.waitingForPresent_ || a() || (y(), r(new Error("Unable to present.")))
} else i()
}
else r(new Error("VRDisplay is not capable of presenting."))
}))
}, gt.prototype.exitPresent = function() {
var t = this.isPresenting,
e = this;
return this.isPresenting = !1, this.layer_ = null, this.disableWakeLock(), new Promise((function(n, i) {
t ? (!y() && a() && (e.endPresent_(), e.fireVRDisplayPresentChange_()), l() && (e.removeFullscreenWrapper(), e.removeFullscreenListeners_(), e.endPresent_(), e.fireVRDisplayPresentChange_()), n()) : i(new Error("Was not presenting to VRDisplay."))
}))
}, gt.prototype.getLayers = function() {
return this.layer_ ? [this.layer_] : []
}, gt.prototype.fireVRDisplayPresentChange_ = function() {
var t = new CustomEvent("vrdisplaypresentchange", {
detail: {
display: this
}
});
window.dispatchEvent(t)
}, gt.prototype.fireVRDisplayConnect_ = function() {
var t = new CustomEvent("vrdisplayconnect", {
detail: {
display: this
}
});
window.dispatchEvent(t)
}, gt.prototype.addFullscreenListeners_ = function(t, e, n) {
this.removeFullscreenListeners_(), this.fullscreenEventTarget_ = t, this.fullscreenChangeHandler_ = e, this.fullscreenErrorHandler_ = n, e && (document.fullscreenEnabled ? t.addEventListener("fullscreenchange", e, !1) : document.webkitFullscreenEnabled ? t.addEventListener("webkitfullscreenchange", e, !1) : document.mozFullScreenEnabled ? document.addEventListener("mozfullscreenchange", e, !1) : document.msFullscreenEnabled && t.addEventListener("msfullscreenchange", e, !1)), n && (document.fullscreenEnabled ? t.addEventListener("fullscreenerror", n, !1) : document.webkitFullscreenEnabled ? t.addEventListener("webkitfullscreenerror", n, !1) : document.mozFullScreenEnabled ? document.addEventListener("mozfullscreenerror", n, !1) : document.msFullscreenEnabled && t.addEventListener("msfullscreenerror", n, !1))
}, gt.prototype.removeFullscreenListeners_ = function() {
if (this.fullscreenEventTarget_) {
var t = this.fullscreenEventTarget_;
if (this.fullscreenChangeHandler_) {
var e = this.fullscreenChangeHandler_;
t.removeEventListener("fullscreenchange", e, !1), t.removeEventListener("webkitfullscreenchange", e, !1), document.removeEventListener("mozfullscreenchange", e, !1), t.removeEventListener("msfullscreenchange", e, !1)
}
if (this.fullscreenErrorHandler_) {
var n = this.fullscreenErrorHandler_;
t.removeEventListener("fullscreenerror", n, !1), t.removeEventListener("webkitfullscreenerror", n, !1), document.removeEventListener("mozfullscreenerror", n, !1), t.removeEventListener("msfullscreenerror", n, !1)
}
this.fullscreenEventTarget_ = null, this.fullscreenChangeHandler_ = null, this.fullscreenErrorHandler_ = null
}
}, gt.prototype.enableWakeLock = function() {
this.wakelock_ && this.wakelock_.enable()
}, gt.prototype.disableWakeLock = function() {
this.wakelock_ && this.wakelock_.disable()
}, gt.prototype.beginPresent_ = function() {}, gt.prototype.endPresent_ = function() {}, gt.prototype.submitFrame = function(t) {}, gt.prototype.getEyeParameters = function(t) {
return null
};
var vt = {
ADDITIONAL_VIEWERS: [],
DEFAULT_VIEWER: "",
MOBILE_WAKE_LOCK: !0,
DEBUG: !1,
DPDB_URL: "https://dpdb.webvr.rocks/dpdb.json",
K_FILTER: .98,
PREDICTION_TIME_S: .04,
CARDBOARD_UI_DISABLED: !1,
ROTATE_INSTRUCTIONS_DISABLED: !1,
YAW_ONLY: !1,
BUFFER_SCALE: .5,
DIRTY_SUBMIT_FRAME_BINDINGS: !1
},
yt = "left",
At = "right";
function xt(t) {
var e = b({}, vt);
t = b(e, t || {}), gt.call(this, {
wakelock: t.MOBILE_WAKE_LOCK
}), this.config = t, this.displayName = "Cardboard VRDisplay", this.capabilities = new mt({
hasPosition: !1,
hasOrientation: !0,
hasExternalDisplay: !1,
canPresent: !0,
maxLayers: 1
}), this.stageParameters = null, this.bufferScale_ = this.config.BUFFER_SCALE, this.poseSensor_ = new ot(this.config), this.distorter_ = null, this.cardboardUI_ = null, this.dpdb_ = new Z(this.config.DPDB_URL, this.onDeviceParamsUpdated_.bind(this)), this.deviceInfo_ = new q(this.dpdb_.getDeviceParams(), t.ADDITIONAL_VIEWERS), this.viewerSelector_ = new at(t.DEFAULT_VIEWER), this.viewerSelector_.onChange(this.onViewerChanged_.bind(this)), this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer()), this.config.ROTATE_INSTRUCTIONS_DISABLED || (this.rotateInstructions_ = new st), a() && window.addEventListener("resize", this.onResize_.bind(this))
}
return xt.prototype = Object.create(gt.prototype), xt.prototype._getPose = function() {
return {
position: null,
orientation: this.poseSensor_.getOrientation(),
linearVelocity: null,
linearAcceleration: null,
angularVelocity: null,
angularAcceleration: null
}
}, xt.prototype._resetPose = function() {
this.poseSensor_.resetPose && this.poseSensor_.resetPose()
}, xt.prototype._getFieldOfView = function(t) {
var e;
if (t == yt) e = this.deviceInfo_.getFieldOfViewLeftEye();
else {
if (t != At) return console.error("Invalid eye provided: %s", t), null;
e = this.deviceInfo_.getFieldOfViewRightEye()
}
return e
}, xt.prototype._getEyeOffset = function(t) {
var e;
if (t == yt) e = [.5 * -this.deviceInfo_.viewer.interLensDistance, 0, 0];
else {
if (t != At) return console.error("Invalid eye provided: %s", t), null;
e = [.5 * this.deviceInfo_.viewer.interLensDistance, 0, 0]
}
return e
}, xt.prototype.getEyeParameters = function(t) {
var e = this._getEyeOffset(t),
n = this._getFieldOfView(t),
i = {
offset: e,
renderWidth: .5 * this.deviceInfo_.device.width * this.bufferScale_,
renderHeight: this.deviceInfo_.device.height * this.bufferScale_
};
return Object.defineProperty(i, "fieldOfView", {
enumerable: !0,
get: function() {
return T("VRFieldOfView", "VRFrameData's projection matrices"), n
}
}), i
}, xt.prototype.onDeviceParamsUpdated_ = function(t) {
this.config.DEBUG && console.log("DPDB reported that device params were updated."), this.deviceInfo_.updateDeviceParams(t), this.distorter_ && this.distorter_.updateDeviceInfo(this.deviceInfo_)
}, xt.prototype.updateBounds_ = function() {
this.layer_ && this.distorter_ && (this.layer_.leftBounds || this.layer_.rightBounds) && this.distorter_.setTextureBounds(this.layer_.leftBounds, this.layer_.rightBounds)
}, xt.prototype.beginPresent_ = function() {
var t = this.layer_.source.getContext("webgl");
t || (t = this.layer_.source.getContext("experimental-webgl")), t || (t = this.layer_.source.getContext("webgl2")), t && (this.layer_.predistorted ? this.config.CARDBOARD_UI_DISABLED || (t.canvas.width = g() * this.bufferScale_, t.canvas.height = v() * this.bufferScale_, this.cardboardUI_ = new N(t)) : (this.config.CARDBOARD_UI_DISABLED || (this.cardboardUI_ = new N(t)), this.distorter_ = new P(t, this.cardboardUI_, this.config.BUFFER_SCALE, this.config.DIRTY_SUBMIT_FRAME_BINDINGS), this.distorter_.updateDeviceInfo(this.deviceInfo_)), this.cardboardUI_ && this.cardboardUI_.listen(function(t) {
this.viewerSelector_.show(this.layer_.source.parentElement), t.stopPropagation(), t.preventDefault()
}.bind(this), function(t) {
this.exitPresent(), t.stopPropagation(), t.preventDefault()
}.bind(this)), this.rotateInstructions_ && (m() && _() ? this.rotateInstructions_.showTemporarily(3e3, this.layer_.source.parentElement) : this.rotateInstructions_.update()), this.orientationHandler = this.onOrientationChange_.bind(this), window.addEventListener("orientationchange", this.orientationHandler), this.vrdisplaypresentchangeHandler = this.updateBounds_.bind(this), window.addEventListener("vrdisplaypresentchange", this.vrdisplaypresentchangeHandler), this.fireVRDisplayDeviceParamsChange_())
}, xt.prototype.endPresent_ = function() {
this.distorter_ && (this.distorter_.destroy(), this.distorter_ = null), this.cardboardUI_ && (this.cardboardUI_.destroy(), this.cardboardUI_ = null), this.rotateInstructions_ && this.rotateInstructions_.hide(), this.viewerSelector_.hide(), window.removeEventListener("orientationchange", this.orientationHandler), window.removeEventListener("vrdisplaypresentchange", this.vrdisplaypresentchangeHandler)
}, xt.prototype.updatePresent_ = function() {
this.endPresent_(), this.beginPresent_()
}, xt.prototype.submitFrame = function(t) {
if (this.distorter_) this.updateBounds_(), this.distorter_.submitFrame();
else if (this.cardboardUI_ && this.layer_) {
var e = this.layer_.source.getContext("webgl");
e || (e = this.layer_.source.getContext("experimental-webgl")), e || (e = this.layer_.source.getContext("webgl2"));
var n = e.canvas;
n.width == this.lastWidth && n.height == this.lastHeight || this.cardboardUI_.onResize(), this.lastWidth = n.width, this.lastHeight = n.height, this.cardboardUI_.render()
}
}, xt.prototype.onOrientationChange_ = function(t) {
this.viewerSelector_.hide(), this.rotateInstructions_ && this.rotateInstructions_.update(), this.onResize_()
}, xt.prototype.onResize_ = function(t) {
if (this.layer_) {
var e = this.layer_.source.getContext("webgl");
e || (e = this.layer_.source.getContext("experimental-webgl")), e || (e = this.layer_.source.getContext("webgl2")), e.canvas.setAttribute("style", ["position: absolute", "top: 0", "left: 0", "width: 100vw", "height: 100vh", "border: 0", "margin: 0", "padding: 0px", "box-sizing: content-box"].join("; ") + ";"), w(e.canvas)
}
}, xt.prototype.onViewerChanged_ = function(t) {
this.deviceInfo_.setViewer(t), this.distorter_ && this.distorter_.updateDeviceInfo(this.deviceInfo_), this.fireVRDisplayDeviceParamsChange_()
}, xt.prototype.fireVRDisplayDeviceParamsChange_ = function() {
var t = new CustomEvent("vrdisplaydeviceparamschange", {
detail: {
vrdisplay: this,
deviceInfo: this.deviceInfo_
}
});
window.dispatchEvent(t)
}, xt.VRFrameData = function() {
this.leftProjectionMatrix = new Float32Array(16), this.leftViewMatrix = new Float32Array(16), this.rightProjectionMatrix = new Float32Array(16), this.rightViewMatrix = new Float32Array(16), this.pose = null
}, xt.VRDisplay = gt, xt
}()
}))) && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t,
a = {
ADDITIONAL_VIEWERS: [],
DEFAULT_VIEWER: "",
PROVIDE_MOBILE_VRDISPLAY: !0,
MOBILE_WAKE_LOCK: !0,
DEBUG: !1,
DPDB_URL: "https://dpdb.webvr.rocks/dpdb.json",
K_FILTER: .98,
PREDICTION_TIME_S: .04,
CARDBOARD_UI_DISABLED: !1,
ROTATE_INSTRUCTIONS_DISABLED: !1,
YAW_ONLY: !1,
BUFFER_SCALE: .5,
DIRTY_SUBMIT_FRAME_BINDINGS: !1
};
function l(t) {
this.config = o(o({}, a), t), this.polyfillDisplays = [], this.enabled = !1, this.hasNative = "getVRDisplays" in navigator, this.native = {}, this.native.getVRDisplays = navigator.getVRDisplays, this.native.VRFrameData = window.VRFrameData, this.native.VRDisplay = window.VRDisplay, (!this.hasNative || this.config.PROVIDE_MOBILE_VRDISPLAY && n()) && (this.enable(), this.getVRDisplays().then((function(t) {
t && t[0] && t[0].fireVRDisplayConnect_ && t[0].fireVRDisplayConnect_()
})))
}
l.prototype.getPolyfillDisplays = function() {
if (this._polyfillDisplaysPopulated) return this.polyfillDisplays;
if (n()) {
var t = new s({
ADDITIONAL_VIEWERS: this.config.ADDITIONAL_VIEWERS,
DEFAULT_VIEWER: this.config.DEFAULT_VIEWER,
MOBILE_WAKE_LOCK: this.config.MOBILE_WAKE_LOCK,
DEBUG: this.config.DEBUG,
DPDB_URL: this.config.DPDB_URL,
CARDBOARD_UI_DISABLED: this.config.CARDBOARD_UI_DISABLED,
K_FILTER: this.config.K_FILTER,
PREDICTION_TIME_S: this.config.PREDICTION_TIME_S,
ROTATE_INSTRUCTIONS_DISABLED: this.config.ROTATE_INSTRUCTIONS_DISABLED,
YAW_ONLY: this.config.YAW_ONLY,
BUFFER_SCALE: this.config.BUFFER_SCALE,
DIRTY_SUBMIT_FRAME_BINDINGS: this.config.DIRTY_SUBMIT_FRAME_BINDINGS
});
this.polyfillDisplays.push(t)
}
return this._polyfillDisplaysPopulated = !0, this.polyfillDisplays
}, l.prototype.enable = function() {
if (this.enabled = !0, this.hasNative && this.native.VRFrameData) {
var t = this.native.VRFrameData,
e = new this.native.VRFrameData,
n = this.native.VRDisplay.prototype.getFrameData;
window.VRDisplay.prototype.getFrameData = function(i) {
i instanceof t ? n.call(this, i) : (n.call(this, e), i.pose = e.pose, r(e.leftProjectionMatrix, i.leftProjectionMatrix), r(e.rightProjectionMatrix, i.rightProjectionMatrix), r(e.leftViewMatrix, i.leftViewMatrix), r(e.rightViewMatrix, i.rightViewMatrix))
}
}
navigator.getVRDisplays = this.getVRDisplays.bind(this), window.VRDisplay = s.VRDisplay, window.VRFrameData = s.VRFrameData
}, l.prototype.getVRDisplays = function() {
var t = this;
return this.config, this.hasNative ? this.native.getVRDisplays.call(navigator).then((function(e) {
return e.length > 0 ? e : t.getPolyfillDisplays()
})) : Promise.resolve(this.getPolyfillDisplays())
}, l.version = "0.10.12", l.VRFrameData = s.VRFrameData, l.VRDisplay = s.VRDisplay;
var c = Object.freeze({
default: l
}),
h = c && l || c;
return void 0 !== e && e.window && (e.document || (e.document = e.window.document), e.navigator || (e.navigator = e.window.navigator)), h
}()
})));
const h = 0,
u = 1,
d = 2;
function p() {}
Object.assign(p.prototype, {
addEventListener: function(t, e) {
void 0 === this._listeners && (this._listeners = {});
const n = this._listeners;
void 0 === n[t] && (n[t] = []), -1 === n[t].indexOf(e) && n[t].push(e)
},
hasEventListener: function(t, e) {
if (void 0 === this._listeners) return !1;
const n = this._listeners;
return void 0 !== n[t] && -1 !== n[t].indexOf(e)
},
removeEventListener: function(t, e) {
if (void 0 === this._listeners) return;
const n = this._listeners[t];
if (void 0 !== n) {
const t = n.indexOf(e); - 1 !== t && n.splice(t, 1)
}
},
dispatchEvent: function(t) {
if (void 0 === this._listeners) return;
const e = this._listeners[t.type];
if (void 0 !== e) {
t.target = this;
const n = e.slice(0);
for (let e = 0, i = n.length; e < i; e++) n[e].call(this, t)
}
}
});
const f = [];
for (let t = 0; t < 256; t++) f[t] = (t < 16 ? "0" : "") + t.toString(16);
let m = 1234567;
const g = {
DEG2RAD: Math.PI / 180,
RAD2DEG: 180 / Math.PI,
generateUUID: function() {
const t = 4294967295 * Math.random() | 0,
e = 4294967295 * Math.random() | 0,
n = 4294967295 * Math.random() | 0,
i = 4294967295 * Math.random() | 0;
return (f[255 & t] + f[t >> 8 & 255] + f[t >> 16 & 255] + f[t >> 24 & 255] + "-" + f[255 & e] + f[e >> 8 & 255] + "-" + f[e >> 16 & 15 | 64] + f[e >> 24 & 255] + "-" + f[63 & n | 128] + f[n >> 8 & 255] + "-" + f[n >> 16 & 255] + f[n >> 24 & 255] + f[255 & i] + f[i >> 8 & 255] + f[i >> 16 & 255] + f[i >> 24 & 255]).toUpperCase()
},
clamp: function(t, e, n) {
return Math.max(e, Math.min(n, t))
},
euclideanModulo: function(t, e) {
return (t % e + e) % e
},
mapLinear: function(t, e, n, i, r) {
return i + (t - e) * (r - i) / (n - e)
},
lerp: function(t, e, n) {
return (1 - n) * t + n * e
},
damp: function(t, e, n, i) {
return g.lerp(t, e, 1 - Math.exp(-n * i))
},
pingpong: function(t, e = 1) {
return e - Math.abs(g.euclideanModulo(t, 2 * e) - e)
},
smoothstep: function(t, e, n) {
return t <= e ? 0 : t >= n ? 1 : (t = (t - e) / (n - e)) * t * (3 - 2 * t)
},
smootherstep: function(t, e, n) {
return t <= e ? 0 : t >= n ? 1 : (t = (t - e) / (n - e)) * t * t * (t * (6 * t - 15) + 10)
},
randInt: function(t, e) {
return t + Math.floor(Math.random() * (e - t + 1))
},
randFloat: function(t, e) {
return t + Math.random() * (e - t)
},
randFloatSpread: function(t) {
return t * (.5 - Math.random())
},
seededRandom: function(t) {
return void 0 !== t && (m = t % 2147483647), m = 16807 * m % 2147483647, (m - 1) / 2147483646
},
degToRad: function(t) {
return t * g.DEG2RAD
},
radToDeg: function(t) {
return t * g.RAD2DEG
},
isPowerOfTwo: function(t) {
return 0 == (t & t - 1) && 0 !== t
},
ceilPowerOfTwo: function(t) {
return Math.pow(2, Math.ceil(Math.log(t) / Math.LN2))
},
floorPowerOfTwo: function(t) {
return Math.pow(2, Math.floor(Math.log(t) / Math.LN2))
},
setQuaternionFromProperEuler: function(t, e, n, i, r) {
const o = Math.cos,
s = Math.sin,
a = o(n / 2),
l = s(n / 2),
c = o((e + i) / 2),
h = s((e + i) / 2),
u = o((e - i) / 2),
d = s((e - i) / 2),
p = o((i - e) / 2),
f = s((i - e) / 2);
switch (r) {
case "XYX":
t.set(a * h, l * u, l * d, a * c);
break;
case "YZY":
t.set(l * d, a * h, l * u, a * c);
break;
case "ZXZ":
t.set(l * u, l * d, a * h, a * c);
break;
case "XZX":
t.set(a * h, l * f, l * p, a * c);
break;
case "YXY":
t.set(l * p, a * h, l * f, a * c);
break;
case "ZYZ":
t.set(l * f, l * p, a * h, a * c);
break;
default:
console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + r)
}
}
};
class v {
constructor(t = 0, e = 0) {
Object.defineProperty(this, "isVector2", {
value: !0
}), this.x = t, this.y = e
}
get width() {
return this.x
}
set width(t) {
this.x = t
}
get height() {
return this.y
}
set height(t) {
this.y = t
}
set(t, e) {
return this.x = t, this.y = e, this
}
setScalar(t) {
return this.x = t, this.y = t, this
}
setX(t) {
return this.x = t, this
}
setY(t) {
return this.y = t, this
}
setComponent(t, e) {
switch (t) {
case 0:
this.x = e;
break;
case 1:
this.y = e;
break;
default:
throw new Error("index is out of range: " + t)
}
return this
}
getComponent(t) {
switch (t) {
case 0:
return this.x;
case 1:
return this.y;
default:
throw new Error("index is out of range: " + t)
}
}
clone() {
return new this.constructor(this.x, this.y)
}
copy(t) {
return this.x = t.x, this.y = t.y, this
}
add(t, e) {
return void 0 !== e ? (console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(t, e)) : (this.x += t.x, this.y += t.y, this)
}
addScalar(t) {
return this.x += t, this.y += t, this
}
addVectors(t, e) {
return this.x = t.x + e.x, this.y = t.y + e.y, this
}
addScaledVector(t, e) {
return this.x += t.x * e, this.y += t.y * e, this
}
sub(t, e) {
return void 0 !== e ? (console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(t, e)) : (this.x -= t.x, this.y -= t.y, this)
}
subScalar(t) {
return this.x -= t, this.y -= t, this
}
subVectors(t, e) {
return this.x = t.x - e.x, this.y = t.y - e.y, this
}
multiply(t) {
return this.x *= t.x, this.y *= t.y, this
}
multiplyScalar(t) {
return this.x *= t, this.y *= t, this
}
divide(t) {
return this.x /= t.x, this.y /= t.y, this
}
divideScalar(t) {
return this.multiplyScalar(1 / t)
}
applyMatrix3(t) {
const e = this.x,
n = this.y,
i = t.elements;
return this.x = i[0] * e + i[3] * n + i[6], this.y = i[1] * e + i[4] * n + i[7], this
}
min(t) {
return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this
}
max(t) {
return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this
}
clamp(t, e) {
return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this
}
clampScalar(t, e) {
return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this
}
clampLength(t, e) {
const n = this.length();
return this.divideScalar(n || 1).multiplyScalar(Math.max(t, Math.min(e, n)))
}
floor() {
return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this
}
ceil() {
return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this
}
round() {
return this.x = Math.round(this.x), this.y = Math.round(this.y), this
}
roundToZero() {
return this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this
}
negate() {
return this.x = -this.x, this.y = -this.y, this
}
dot(t) {
return this.x * t.x + this.y * t.y
}
cross(t) {
return this.x * t.y - this.y * t.x
}
lengthSq() {
return this.x * this.x + this.y * this.y
}
length() {
return Math.sqrt(this.x * this.x + this.y * this.y)
}
manhattanLength() {
return Math.abs(this.x) + Math.abs(this.y)
}
normalize() {
return this.divideScalar(this.length() || 1)
}
angle() {
return Math.atan2(-this.y, -this.x) + Math.PI
}
distanceTo(t) {
return Math.sqrt(this.distanceToSquared(t))
}
distanceToSquared(t) {
const e = this.x - t.x,
n = this.y - t.y;
return e * e + n * n
}
manhattanDistanceTo(t) {
return Math.abs(this.x - t.x) + Math.abs(this.y - t.y)
}
setLength(t) {
return this.normalize().multiplyScalar(t)
}
lerp(t, e) {
return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this
}
lerpVectors(t, e, n) {
return this.x = t.x + (e.x - t.x) * n, this.y = t.y + (e.y - t.y) * n, this
}
equals(t) {
return t.x === this.x && t.y === this.y
}
fromArray(t, e = 0) {
return this.x = t[e], this.y = t[e + 1], this
}
toArray(t = [], e = 0) {
return t[e] = this.x, t[e + 1] = this.y, t
}
fromBufferAttribute(t, e, n) {
return void 0 !== n && console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."), this.x = t.getX(e), this.y = t.getY(e), this
}
rotateAround(t, e) {
const n = Math.cos(e),
i = Math.sin(e),
r = this.x - t.x,
o = this.y - t.y;
return this.x = r * n - o * i + t.x, this.y = r * i + o * n + t.y, this
}
random() {
return this.x = Math.random(), this.y = Math.random(), this
}
}
class y {
constructor() {
Object.defineProperty(this, "isMatrix3", {
value: !0
}), this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1], arguments.length > 0 && console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")
}
set(t, e, n, i, r, o, s, a, l) {
const c = this.elements;
return c[0] = t, c[1] = i, c[2] = s, c[3] = e, c[4] = r, c[5] = a, c[6] = n, c[7] = o, c[8] = l, this
}
identity() {
return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this
}
clone() {
return (new this.constructor).fromArray(this.elements)
}
copy(t) {
const e = this.elements,
n = t.elements;
return e[0] = n[0], e[1] = n[1], e[2] = n[2], e[3] = n[3], e[4] = n[4], e[5] = n[5], e[6] = n[6], e[7] = n[7], e[8] = n[8], this
}
extractBasis(t, e, n) {
return t.setFromMatrix3Column(this, 0), e.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this
}
setFromMatrix4(t) {
const e = t.elements;
return this.set(e[0], e[4], e[8], e[1], e[5], e[9], e[2], e[6], e[10]), this
}
multiply(t) {
return this.multiplyMatrices(this, t)
}
premultiply(t) {
return this.multiplyMatrices(t, this)
}
multiplyMatrices(t, e) {
const n = t.elements,
i = e.elements,
r = this.elements,
o = n[0],
s = n[3],
a = n[6],
l = n[1],
c = n[4],
h = n[7],
u = n[2],
d = n[5],
p = n[8],
f = i[0],
m = i[3],
g = i[6],
v = i[1],
y = i[4],
A = i[7],
x = i[2],
_ = i[5],
b = i[8];
return r[0] = o * f + s * v + a * x, r[3] = o * m + s * y + a * _, r[6] = o * g + s * A + a * b, r[1] = l * f + c * v + h * x, r[4] = l * m + c * y + h * _, r[7] = l * g + c * A + h * b, r[2] = u * f + d * v + p * x, r[5] = u * m + d * y + p * _, r[8] = u * g + d * A + p * b, this
}
multiplyScalar(t) {
const e = this.elements;
return e[0] *= t, e[3] *= t, e[6] *= t, e[1] *= t, e[4] *= t, e[7] *= t, e[2] *= t, e[5] *= t, e[8] *= t, this
}
determinant() {
const t = this.elements,
e = t[0],
n = t[1],
i = t[2],
r = t[3],
o = t[4],
s = t[5],
a = t[6],
l = t[7],
c = t[8];
return e * o * c - e * s * l - n * r * c + n * s * a + i * r * l - i * o * a
}
invert() {
const t = this.elements,
e = t[0],
n = t[1],
i = t[2],
r = t[3],
o = t[4],
s = t[5],
a = t[6],
l = t[7],
c = t[8],
h = c * o - s * l,
u = s * a - c * r,
d = l * r - o * a,
p = e * h + n * u + i * d;
if (0 === p) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
const f = 1 / p;
return t[0] = h * f, t[1] = (i * l - c * n) * f, t[2] = (s * n - i * o) * f, t[3] = u * f, t[4] = (c * e - i * a) * f, t[5] = (i * r - s * e) * f, t[6] = d * f, t[7] = (n * a - l * e) * f, t[8] = (o * e - n * r) * f, this
}
transpose() {
let t;
const e = this.elements;
return t = e[1], e[1] = e[3], e[3] = t, t = e[2], e[2] = e[6], e[6] = t, t = e[5], e[5] = e[7], e[7] = t, this
}
getNormalMatrix(t) {
return this.setFromMatrix4(t).copy(this).invert().transpose()
}
transposeIntoArray(t) {
const e = this.elements;
return t[0] = e[0], t[1] = e[3], t[2] = e[6], t[3] = e[1], t[4] = e[4], t[5] = e[7], t[6] = e[2], t[7] = e[5], t[8] = e[8], this
}
setUvTransform(t, e, n, i, r, o, s) {
const a = Math.cos(r),
l = Math.sin(r);
return this.set(n * a, n * l, -n * (a * o + l * s) + o + t, -i * l, i * a, -i * (-l * o + a * s) + s + e, 0, 0, 1), this
}
scale(t, e) {
const n = this.elements;
return n[0] *= t, n[3] *= t, n[6] *= t, n[1] *= e, n[4] *= e, n[7] *= e, this
}
rotate(t) {
const e = Math.cos(t),
n = Math.sin(t),
i = this.elements,
r = i[0],
o = i[3],
s = i[6],
a = i[1],
l = i[4],
c = i[7];
return i[0] = e * r + n * a, i[3] = e * o + n * l, i[6] = e * s + n * c, i[1] = -n * r + e * a, i[4] = -n * o + e * l, i[7] = -n * s + e * c, this
}
translate(t, e) {
const n = this.elements;
return n[0] += t * n[2], n[3] += t * n[5], n[6] += t * n[8], n[1] += e * n[2], n[4] += e * n[5], n[7] += e * n[8], this
}
equals(t) {
const e = this.elements,
n = t.elements;
for (let t = 0; t < 9; t++)
if (e[t] !== n[t]) return !1;
return !0
}
fromArray(t, e = 0) {
for (let n = 0; n < 9; n++) this.elements[n] = t[n + e];
return this
}
toArray(t = [], e = 0) {
const n = this.elements;
return t[e] = n[0], t[e + 1] = n[1], t[e + 2] = n[2], t[e + 3] = n[3], t[e + 4] = n[4], t[e + 5] = n[5], t[e + 6] = n[6], t[e + 7] = n[7], t[e + 8] = n[8], t
}
}
let A;
const x = {
getDataURL: function(t) {
if (/^data:/i.test(t.src)) return t.src;
if ("undefined" == typeof HTMLCanvasElement) return t.src;
let e;
if (t instanceof HTMLCanvasElement) e = t;
else {
void 0 === A && (A = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas")), A.width = t.width, A.height = t.height;
const n = A.getContext("2d");
t instanceof ImageData ? n.putImageData(t, 0, 0) : n.drawImage(t, 0, 0, t.width, t.height), e = A
}
return e.width > 2048 || e.height > 2048 ? e.toDataURL("image/jpeg", .6) : e.toDataURL("image/png")
}
};
let _ = 0;
function b(t = b.DEFAULT_IMAGE, e = b.DEFAULT_MAPPING, n = 1001, i = 1001, r = 1006, o = 1008, s = 1023, a = 1009, l = 1, c = 3e3) {
Object.defineProperty(this, "id", {
value: _++
}), this.uuid = g.generateUUID(), this.name = "", this.image = t, this.mipmaps = [], this.mapping = e, this.wrapS = n, this.wrapT = i, this.magFilter = r, this.minFilter = o, this.anisotropy = l, this.format = s, this.internalFormat = null, this.type = a, this.offset = new v(0, 0), this.repeat = new v(1, 1), this.center = new v(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new y, this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.encoding = c, this.version = 0, this.onUpdate = null
}
function w(t) {
return "undefined" != typeof HTMLImageElement && t instanceof HTMLImageElement || "undefined" != typeof HTMLCanvasElement && t instanceof HTMLCanvasElement || "undefined" != typeof ImageBitmap && t instanceof ImageBitmap ? x.getDataURL(t) : t.data ? {
data: Array.prototype.slice.call(t.data),
width: t.width,
height: t.height,
type: t.data.constructor.name
} : (console.warn("THREE.Texture: Unable to serialize Texture."), {})
}
b.DEFAULT_IMAGE = void 0, b.DEFAULT_MAPPING = 300, b.prototype = Object.assign(Object.create(p.prototype), {
constructor: b,
isTexture: !0,
updateMatrix: function() {
this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y)
},
clone: function() {
return (new this.constructor).copy(this)
},
copy: function(t) {
return this.name = t.name, this.image = t.image, this.mipmaps = t.mipmaps.slice(0), this.mapping = t.mapping, this.wrapS = t.wrapS, this.wrapT = t.wrapT, this.magFilter = t.magFilter, this.minFilter = t.minFilter, this.anisotropy = t.anisotropy, this.format = t.format, this.internalFormat = t.internalFormat, this.type = t.type, this.offset.copy(t.offset), this.repeat.copy(t.repeat), this.center.copy(t.center), this.rotation = t.rotation, this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrix.copy(t.matrix), this.generateMipmaps = t.generateMipmaps, this.premultiplyAlpha = t.premultiplyAlpha, this.flipY = t.flipY, this.unpackAlignment = t.unpackAlignment, this.encoding = t.encoding, this
},
toJSON: function(t) {
const e = void 0 === t || "string" == typeof t;
if (!e && void 0 !== t.textures[this.uuid]) return t.textures[this.uuid];
const n = {
metadata: {
version: 4.5,
type: "Texture",
generator: "Texture.toJSON"
},
uuid: this.uuid,
name: this.name,
mapping: this.mapping,
repeat: [this.repeat.x, this.repeat.y],
offset: [this.offset.x, this.offset.y],
center: [this.center.x, this.center.y],
rotation: this.rotation,
wrap: [this.wrapS, this.wrapT],
format: this.format,
type: this.type,
encoding: this.encoding,
minFilter: this.minFilter,
magFilter: this.magFilter,
anisotropy: this.anisotropy,
flipY: this.flipY,
premultiplyAlpha: this.premultiplyAlpha,
unpackAlignment: this.unpackAlignment
};
if (void 0 !== this.image) {
const i = this.image;
if (void 0 === i.uuid && (i.uuid = g.generateUUID()), !e && void 0 === t.images[i.uuid]) {
let e;
if (Array.isArray(i)) {
e = [];
for (let t = 0, n = i.length; t < n; t++) i[t].isDataTexture ? e.push(w(i[t].image)) : e.push(w(i[t]))
} else e = w(i);
t.images[i.uuid] = {
uuid: i.uuid,
url: e
}
}
n.image = i.uuid
}
return e || (t.textures[this.uuid] = n), n
},
dispose: function() {
this.dispatchEvent({
type: "dispose"
})
},
transformUv: function(t) {
if (300 !== this.mapping) return t;
if (t.applyMatrix3(this.matrix), t.x < 0 || t.x > 1) switch (this.wrapS) {
case 1e3:
t.x = t.x - Math.floor(t.x);
break;
case 1001:
t.x = t.x < 0 ? 0 : 1;
break;
case 1002:
1 === Math.abs(Math.floor(t.x) % 2) ? t.x = Math.ceil(t.x) - t.x : t.x = t.x - Math.floor(t.x)
}
if (t.y < 0 || t.y > 1) switch (this.wrapT) {
case 1e3:
t.y = t.y - Math.floor(t.y);
break;
case 1001:
t.y = t.y < 0 ? 0 : 1;
break;
case 1002:
1 === Math.abs(Math.floor(t.y) % 2) ? t.y = Math.ceil(t.y) - t.y : t.y = t.y - Math.floor(t.y)
}
return this.flipY && (t.y = 1 - t.y), t
}
}), Object.defineProperty(b.prototype, "needsUpdate", {
set: function(t) {
!0 === t && this.version++
}
});
class M {
constructor(t = 0, e = 0, n = 0, i = 1) {
Object.defineProperty(this, "isVector4", {
value: !0
}), this.x = t, this.y = e, this.z = n, this.w = i
}
get width() {
return this.z
}
set width(t) {
this.z = t
}
get height() {
return this.w
}
set height(t) {
this.w = t
}
set(t, e, n, i) {
return this.x = t, this.y = e, this.z = n, this.w = i, this
}
setScalar(t) {
return this.x = t, this.y = t, this.z = t, this.w = t, this
}
setX(t) {
return this.x = t, this
}
setY(t) {
return this.y = t, this
}
setZ(t) {
return this.z = t, this
}
setW(t) {
return this.w = t, this
}
setComponent(t, e) {
switch (t) {
case 0:
this.x = e;
break;
case 1:
this.y = e;
break;
case 2:
this.z = e;
break;
case 3:
this.w = e;
break;
default:
throw new Error("index is out of range: " + t)
}
return this
}
getComponent(t) {
switch (t) {
case 0:
return this.x;
case 1:
return this.y;
case 2:
return this.z;
case 3:
return this.w;
default:
throw new Error("index is out of range: " + t)
}
}
clone() {
return new this.constructor(this.x, this.y, this.z, this.w)
}
copy(t) {
return this.x = t.x, this.y = t.y, this.z = t.z, this.w = void 0 !== t.w ? t.w : 1, this
}
add(t, e) {
return void 0 !== e ? (console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(t, e)) : (this.x += t.x, this.y += t.y, this.z += t.z, this.w += t.w, this)
}
addScalar(t) {
return this.x += t, this.y += t, this.z += t, this.w += t, this
}
addVectors(t, e) {
return this.x = t.x + e.x, this.y = t.y + e.y, this.z = t.z + e.z, this.w = t.w + e.w, this
}
addScaledVector(t, e) {
return this.x += t.x * e, this.y += t.y * e, this.z += t.z * e, this.w += t.w * e, this
}
sub(t, e) {
return void 0 !== e ? (console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(t, e)) : (this.x -= t.x, this.y -= t.y, this.z -= t.z, this.w -= t.w, this)
}
subScalar(t) {
return this.x -= t, this.y -= t, this.z -= t, this.w -= t, this
}
subVectors(t, e) {
return this.x = t.x - e.x, this.y = t.y - e.y, this.z = t.z - e.z, this.w = t.w - e.w, this
}
multiply(t) {
return this.x *= t.x, this.y *= t.y, this.z *= t.z, this.w *= t.w, this
}
multiplyScalar(t) {
return this.x *= t, this.y *= t, this.z *= t, this.w *= t, this
}
applyMatrix4(t) {
const e = this.x,
n = this.y,
i = this.z,
r = this.w,
o = t.elements;
return this.x = o[0] * e + o[4] * n + o[8] * i + o[12] * r, this.y = o[1] * e + o[5] * n + o[9] * i + o[13] * r, this.z = o[2] * e + o[6] * n + o[10] * i + o[14] * r, this.w = o[3] * e + o[7] * n + o[11] * i + o[15] * r, this
}
divideScalar(t) {
return this.multiplyScalar(1 / t)
}
setAxisAngleFromQuaternion(t) {
this.w = 2 * Math.acos(t.w);
const e = Math.sqrt(1 - t.w * t.w);
return e < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = t.x / e, this.y = t.y / e, this.z = t.z / e), this
}
setAxisAngleFromRotationMatrix(t) {
let e, n, i, r;
const o = t.elements,
s = o[0],
a = o[4],
l = o[8],
c = o[1],
h = o[5],
u = o[9],
d = o[2],
p = o[6],
f = o[10];
if (Math.abs(a - c) < .01 && Math.abs(l - d) < .01 && Math.abs(u - p) < .01) {
if (Math.abs(a + c) < .1 && Math.abs(l + d) < .1 && Math.abs(u + p) < .1 && Math.abs(s + h + f - 3) < .1) return this.set(1, 0, 0, 0), this;
e = Math.PI;
const t = (s + 1) / 2,
o = (h + 1) / 2,
m = (f + 1) / 2,
g = (a + c) / 4,
v = (l + d) / 4,
y = (u + p) / 4;
return t > o && t > m ? t < .01 ? (n = 0, i = .707106781, r = .707106781) : (n = Math.sqrt(t), i = g / n, r = v / n) : o > m ? o < .01 ? (n = .707106781, i = 0, r = .707106781) : (i = Math.sqrt(o), n = g / i, r = y / i) : m < .01 ? (n = .707106781, i = .707106781, r = 0) : (r = Math.sqrt(m), n = v / r, i = y / r), this.set(n, i, r, e), this
}
let m = Math.sqrt((p - u) * (p - u) + (l - d) * (l - d) + (c - a) * (c - a));
return Math.abs(m) < .001 && (m = 1), this.x = (p - u) / m, this.y = (l - d) / m, this.z = (c - a) / m, this.w = Math.acos((s + h + f - 1) / 2), this
}
min(t) {
return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this.w = Math.min(this.w, t.w), this
}
max(t) {
return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this.w = Math.max(this.w, t.w), this
}
clamp(t, e) {
return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this.z = Math.max(t.z, Math.min(e.z, this.z)), this.w = Math.max(t.w, Math.min(e.w, this.w)), this
}
clampScalar(t, e) {
return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this.z = Math.max(t, Math.min(e, this.z)), this.w = Math.max(t, Math.min(e, this.w)), this
}
clampLength(t, e) {
const n = this.length();
return this.divideScalar(n || 1).multiplyScalar(Math.max(t, Math.min(e, n)))
}
floor() {
return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this.w = Math.floor(this.w), this
}
ceil() {
return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this.w = Math.ceil(this.w), this
}
round() {
return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this.w = Math.round(this.w), this
}
roundToZero() {
return this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z), this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w), this
}
negate() {
return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this
}
dot(t) {
return this.x * t.x + this.y * t.y + this.z * t.z + this.w * t.w
}
lengthSq() {
return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
}
length() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
}
manhattanLength() {
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w)
}
normalize() {
return this.divideScalar(this.length() || 1)
}
setLength(t) {
return this.normalize().multiplyScalar(t)
}
lerp(t, e) {
return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this.z += (t.z - this.z) * e, this.w += (t.w - this.w) * e, this
}
lerpVectors(t, e, n) {
return this.x = t.x + (e.x - t.x) * n, this.y = t.y + (e.y - t.y) * n, this.z = t.z + (e.z - t.z) * n, this.w = t.w + (e.w - t.w) * n, this
}
equals(t) {
return t.x === this.x && t.y === this.y && t.z === this.z && t.w === this.w
}
fromArray(t, e = 0) {
return this.x = t[e], this.y = t[e + 1], this.z = t[e + 2], this.w = t[e + 3], this
}
toArray(t = [], e = 0) {
return t[e] = this.x, t[e + 1] = this.y, t[e + 2] = this.z, t[e + 3] = this.w, t
}
fromBufferAttribute(t, e, n) {
return void 0 !== n && console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."), this.x = t.getX(e), this.y = t.getY(e), this.z = t.getZ(e), this.w = t.getW(e), this
}
random() {
return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this
}
}
class E extends p {
constructor(t, e, n) {
super(), Object.defineProperty(this, "isWebGLRenderTarget", {
value: !0
}), this.width = t, this.height = e, this.scissor = new M(0, 0, t, e), this.scissorTest = !1, this.viewport = new M(0, 0, t, e), n = n || {}, this.texture = new b(void 0, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.encoding), this.texture.image = {}, this.texture.image.width = t, this.texture.image.height = e, this.texture.generateMipmaps = void 0 !== n.generateMipmaps && n.generateMipmaps, this.texture.minFilter = void 0 !== n.minFilter ? n.minFilter : 1006, this.depthBuffer = void 0 === n.depthBuffer || n.depthBuffer, this.stencilBuffer = void 0 !== n.stencilBuffer && n.stencilBuffer, this.depthTexture = void 0 !== n.depthTexture ? n.depthTexture : null
}
setSize(t, e) {
this.width === t && this.height === e || (this.width = t, this.height = e, this.texture.image.width = t, this.texture.image.height = e, this.dispose()), this.viewport.set(0, 0, t, e), this.scissor.set(0, 0, t, e)
}
clone() {
return (new this.constructor).copy(this)
}
copy(t) {
return this.width = t.width, this.height = t.height, this.viewport.copy(t.viewport), this.texture = t.texture.clone(), this.depthBuffer = t.depthBuffer, this.stencilBuffer = t.stencilBuffer, this.depthTexture = t.depthTexture, this
}
dispose() {
this.dispatchEvent({
type: "dispose"
})
}
}
class S {
constructor(t = 0, e = 0, n = 0, i = 1) {
Object.defineProperty(this, "isQuaternion", {
value: !0
}), this._x = t, this._y = e, this._z = n, this._w = i
}
static slerp(t, e, n, i) {
return n.copy(t).slerp(e, i)
}
static slerpFlat(t, e, n, i, r, o, s) {
let a = n[i + 0],
l = n[i + 1],
c = n[i + 2],
h = n[i + 3];
const u = r[o + 0],
d = r[o + 1],
p = r[o + 2],
f = r[o + 3];
if (h !== f || a !== u || l !== d || c !== p) {
let t = 1 - s;
const e = a * u + l * d + c * p + h * f,
n = e >= 0 ? 1 : -1,
i = 1 - e * e;
if (i > Number.EPSILON) {
const r = Math.sqrt(i),
o = Math.atan2(r, e * n);
t = Math.sin(t * o) / r, s = Math.sin(s * o) / r
}
const r = s * n;
if (a = a * t + u * r, l = l * t + d * r, c = c * t + p * r, h = h * t + f * r, t === 1 - s) {
const t = 1 / Math.sqrt(a * a + l * l + c * c + h * h);
a *= t, l *= t, c *= t, h *= t
}
}
t[e] = a, t[e + 1] = l, t[e + 2] = c, t[e + 3] = h
}
static multiplyQuaternionsFlat(t, e, n, i, r, o) {
const s = n[i],
a = n[i + 1],
l = n[i + 2],
c = n[i + 3],
h = r[o],
u = r[o + 1],
d = r[o + 2],
p = r[o + 3];
return t[e] = s * p + c * h + a * d - l * u, t[e + 1] = a * p + c * u + l * h - s * d, t[e + 2] = l * p + c * d + s * u - a * h, t[e + 3] = c * p - s * h - a * u - l * d, t
}
get x() {
return this._x
}
set x(t) {
this._x = t, this._onChangeCallback()
}
get y() {
return this._y
}
set y(t) {
this._y = t, this._onChangeCallback()
}
get z() {
return this._z
}
set z(t) {
this._z = t, this._onChangeCallback()
}
get w() {
return this._w
}
set w(t) {
this._w = t, this._onChangeCallback()
}
set(t, e, n, i) {
return this._x = t, this._y = e, this._z = n, this._w = i, this._onChangeCallback(), this
}
clone() {
return new this.constructor(this._x, this._y, this._z, this._w)
}
copy(t) {
return this._x = t.x, this._y = t.y, this._z = t.z, this._w = t.w, this._onChangeCallback(), this
}
setFromEuler(t, e) {
if (!t || !t.isEuler) throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");
const n = t._x,
i = t._y,
r = t._z,
o = t._order,
s = Math.cos,
a = Math.sin,
l = s(n / 2),
c = s(i / 2),
h = s(r / 2),
u = a(n / 2),
d = a(i / 2),
p = a(r / 2);
switch (o) {
case "XYZ":
this._x = u * c * h + l * d * p, this._y = l * d * h - u * c * p, this._z = l * c * p + u * d * h, this._w = l * c * h - u * d * p;
break;
case "YXZ":
this._x = u * c * h + l * d * p, this._y = l * d * h - u * c * p, this._z = l * c * p - u * d * h, this._w = l * c * h + u * d * p;
break;
case "ZXY":
this._x = u * c * h - l * d * p, this._y = l * d * h + u * c * p, this._z = l * c * p + u * d * h, this._w = l * c * h - u * d * p;
break;
case "ZYX":
this._x = u * c * h - l * d * p, this._y = l * d * h + u * c * p, this._z = l * c * p - u * d * h, this._w = l * c * h + u * d * p;
break;
case "YZX":
this._x = u * c * h + l * d * p, this._y = l * d * h + u * c * p, this._z = l * c * p - u * d * h, this._w = l * c * h - u * d * p;
break;
case "XZY":
this._x = u * c * h - l * d * p, this._y = l * d * h - u * c * p, this._z = l * c * p + u * d * h, this._w = l * c * h + u * d * p;
break;
default:
console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + o)
}
return !1 !== e && this._onChangeCallback(), this
}
setFromAxisAngle(t, e) {
const n = e / 2,
i = Math.sin(n);
return this._x = t.x * i, this._y = t.y * i, this._z = t.z * i, this._w = Math.cos(n), this._onChangeCallback(), this
}
setFromRotationMatrix(t) {
const e = t.elements,
n = e[0],
i = e[4],
r = e[8],
o = e[1],
s = e[5],
a = e[9],
l = e[2],
c = e[6],
h = e[10],
u = n + s + h;
if (u > 0) {
const t = .5 / Math.sqrt(u + 1);
this._w = .25 / t, this._x = (c - a) * t, this._y = (r - l) * t, this._z = (o - i) * t
} else if (n > s && n > h) {
const t = 2 * Math.sqrt(1 + n - s - h);
this._w = (c - a) / t, this._x = .25 * t, this._y = (i + o) / t, this._z = (r + l) / t
} else if (s > h) {
const t = 2 * Math.sqrt(1 + s - n - h);
this._w = (r - l) / t, this._x = (i + o) / t, this._y = .25 * t, this._z = (a + c) / t
} else {
const t = 2 * Math.sqrt(1 + h - n - s);
this._w = (o - i) / t, this._x = (r + l) / t, this._y = (a + c) / t, this._z = .25 * t
}
return this._onChangeCallback(), this
}
setFromUnitVectors(t, e) {
let n = t.dot(e) + 1;
return n < 1e-6 ? (n = 0, Math.abs(t.x) > Math.abs(t.z) ? (this._x = -t.y, this._y = t.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -t.z, this._z = t.y, this._w = n)) : (this._x = t.y * e.z - t.z * e.y, this._y = t.z * e.x - t.x * e.z, this._z = t.x * e.y - t.y * e.x, this._w = n), this.normalize()
}
angleTo(t) {
return 2 * Math.acos(Math.abs(g.clamp(this.dot(t), -1, 1)))
}
rotateTowards(t, e) {
const n = this.angleTo(t);
if (0 === n) return this;
const i = Math.min(1, e / n);
return this.slerp(t, i), this
}
identity() {
return this.set(0, 0, 0, 1)
}
invert() {
return this.conjugate()
}
conjugate() {
return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this
}
dot(t) {
return this._x * t._x + this._y * t._y + this._z * t._z + this._w * t._w
}
lengthSq() {
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w
}
length() {
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w)
}
normalize() {
let t = this.length();
return 0 === t ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (t = 1 / t, this._x = this._x * t, this._y = this._y * t, this._z = this._z * t, this._w = this._w * t), this._onChangeCallback(), this
}
multiply(t, e) {
return void 0 !== e ? (console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."), this.multiplyQuaternions(t, e)) : this.multiplyQuaternions(this, t)
}
premultiply(t) {
return this.multiplyQuaternions(t, this)
}
multiplyQuaternions(t, e) {
const n = t._x,
i = t._y,
r = t._z,
o = t._w,
s = e._x,
a = e._y,
l = e._z,
c = e._w;
return this._x = n * c + o * s + i * l - r * a, this._y = i * c + o * a + r * s - n * l, this._z = r * c + o * l + n * a - i * s, this._w = o * c - n * s - i * a - r * l, this._onChangeCallback(), this
}
slerp(t, e) {
if (0 === e) return this;
if (1 === e) return this.copy(t);
const n = this._x,
i = this._y,
r = this._z,
o = this._w;
let s = o * t._w + n * t._x + i * t._y + r * t._z;
if (s < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, s = -s) : this.copy(t), s >= 1) return this._w = o, this._x = n, this._y = i, this._z = r, this;
const a = 1 - s * s;
if (a <= Number.EPSILON) {
const t = 1 - e;
return this._w = t * o + e * this._w, this._x = t * n + e * this._x, this._y = t * i + e * this._y, this._z = t * r + e * this._z, this.normalize(), this._onChangeCallback(), this
}
const l = Math.sqrt(a),
c = Math.atan2(l, s),
h = Math.sin((1 - e) * c) / l,
u = Math.sin(e * c) / l;
return this._w = o * h + this._w * u, this._x = n * h + this._x * u, this._y = i * h + this._y * u, this._z = r * h + this._z * u, this._onChangeCallback(), this
}
equals(t) {
return t._x === this._x && t._y === this._y && t._z === this._z && t._w === this._w
}
fromArray(t, e = 0) {
return this._x = t[e], this._y = t[e + 1], this._z = t[e + 2], this._w = t[e + 3], this._onChangeCallback(), this
}
toArray(t = [], e = 0) {
return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._w, t
}
fromBufferAttribute(t, e) {
return this._x = t.getX(e), this._y = t.getY(e), this._z = t.getZ(e), this._w = t.getW(e), this
}
_onChange(t) {
return this._onChangeCallback = t, this
}
_onChangeCallback() {}
}
class T {
constructor(t = 0, e = 0, n = 0) {
Object.defineProperty(this, "isVector3", {
value: !0
}), this.x = t, this.y = e, this.z = n
}
set(t, e, n) {
return void 0 === n && (n = this.z), this.x = t, this.y = e, this.z = n, this
}
setScalar(t) {
return this.x = t, this.y = t, this.z = t, this
}
setX(t) {
return this.x = t, this
}
setY(t) {
return this.y = t, this
}
setZ(t) {
return this.z = t, this
}
setComponent(t, e) {
switch (t) {
case 0:
this.x = e;
break;
case 1:
this.y = e;
break;
case 2:
this.z = e;
break;
default:
throw new Error("index is out of range: " + t)
}
return this
}
getComponent(t) {
switch (t) {
case 0:
return this.x;
case 1:
return this.y;
case 2:
return this.z;
default:
throw new Error("index is out of range: " + t)
}
}
clone() {
return new this.constructor(this.x, this.y, this.z)
}
copy(t) {
return this.x = t.x, this.y = t.y, this.z = t.z, this
}
add(t, e) {
return void 0 !== e ? (console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(t, e)) : (this.x += t.x, this.y += t.y, this.z += t.z, this)
}
addScalar(t) {
return this.x += t, this.y += t, this.z += t, this
}
addVectors(t, e) {
return this.x = t.x + e.x, this.y = t.y + e.y, this.z = t.z + e.z, this
}
addScaledVector(t, e) {
return this.x += t.x * e, this.y += t.y * e, this.z += t.z * e, this
}
sub(t, e) {
return void 0 !== e ? (console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(t, e)) : (this.x -= t.x, this.y -= t.y, this.z -= t.z, this)
}
subScalar(t) {
return this.x -= t, this.y -= t, this.z -= t, this
}
subVectors(t, e) {
return this.x = t.x - e.x, this.y = t.y - e.y, this.z = t.z - e.z, this
}
multiply(t, e) {
return void 0 !== e ? (console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), this.multiplyVectors(t, e)) : (this.x *= t.x, this.y *= t.y, this.z *= t.z, this)
}
multiplyScalar(t) {
return this.x *= t, this.y *= t, this.z *= t, this
}
multiplyVectors(t, e) {
return this.x = t.x * e.x, this.y = t.y * e.y, this.z = t.z * e.z, this
}
applyEuler(t) {
return t && t.isEuler || console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."), this.applyQuaternion(R.setFromEuler(t))
}
applyAxisAngle(t, e) {
return this.applyQuaternion(R.setFromAxisAngle(t, e))
}
applyMatrix3(t) {
const e = this.x,
n = this.y,
i = this.z,
r = t.elements;
return this.x = r[0] * e + r[3] * n + r[6] * i, this.y = r[1] * e + r[4] * n + r[7] * i, this.z = r[2] * e + r[5] * n + r[8] * i, this
}
applyNormalMatrix(t) {
return this.applyMatrix3(t).normalize()
}
applyMatrix4(t) {
const e = this.x,
n = this.y,
i = this.z,
r = t.elements,
o = 1 / (r[3] * e + r[7] * n + r[11] * i + r[15]);
return this.x = (r[0] * e + r[4] * n + r[8] * i + r[12]) * o, this.y = (r[1] * e + r[5] * n + r[9] * i + r[13]) * o, this.z = (r[2] * e + r[6] * n + r[10] * i + r[14]) * o, this
}
applyQuaternion(t) {
const e = this.x,
n = this.y,
i = this.z,
r = t.x,
o = t.y,
s = t.z,
a = t.w,
l = a * e + o * i - s * n,
c = a * n + s * e - r * i,
h = a * i + r * n - o * e,
u = -r * e - o * n - s * i;
return this.x = l * a + u * -r + c * -s - h * -o, this.y = c * a + u * -o + h * -r - l * -s, this.z = h * a + u * -s + l * -o - c * -r, this
}
project(t) {
return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)
}
unproject(t) {
return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)
}
transformDirection(t) {
const e = this.x,
n = this.y,
i = this.z,
r = t.elements;
return this.x = r[0] * e + r[4] * n + r[8] * i, this.y = r[1] * e + r[5] * n + r[9] * i, this.z = r[2] * e + r[6] * n + r[10] * i, this.normalize()
}
divide(t) {
return this.x /= t.x, this.y /= t.y, this.z /= t.z, this
}
divideScalar(t) {
return this.multiplyScalar(1 / t)
}
min(t) {
return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this
}
max(t) {
return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this
}
clamp(t, e) {
return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this.z = Math.max(t.z, Math.min(e.z, this.z)), this
}
clampScalar(t, e) {
return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this.z = Math.max(t, Math.min(e, this.z)), this
}
clampLength(t, e) {
const n = this.length();
return this.divideScalar(n || 1).multiplyScalar(Math.max(t, Math.min(e, n)))
}
floor() {
return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this
}
ceil() {
return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this
}
round() {
return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this
}
roundToZero() {
return this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z), this
}
negate() {
return this.x = -this.x, this.y = -this.y, this.z = -this.z, this
}
dot(t) {
return this.x * t.x + this.y * t.y + this.z * t.z
}
lengthSq() {
return this.x * this.x + this.y * this.y + this.z * this.z
}
length() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z)
}
manhattanLength() {
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z)
}
normalize() {
return this.divideScalar(this.length() || 1)
}
setLength(t) {
return this.normalize().multiplyScalar(t)
}
lerp(t, e) {
return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this.z += (t.z - this.z) * e, this
}
lerpVectors(t, e, n) {
return this.x = t.x + (e.x - t.x) * n, this.y = t.y + (e.y - t.y) * n, this.z = t.z + (e.z - t.z) * n, this
}
cross(t, e) {
return void 0 !== e ? (console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."), this.crossVectors(t, e)) : this.crossVectors(this, t)
}
crossVectors(t, e) {
const n = t.x,
i = t.y,
r = t.z,
o = e.x,
s = e.y,
a = e.z;
return this.x = i * a - r * s, this.y = r * o - n * a, this.z = n * s - i * o, this
}
projectOnVector(t) {
const e = t.lengthSq();
if (0 === e) return this.set(0, 0, 0);
const n = t.dot(this) / e;
return this.copy(t).multiplyScalar(n)
}
projectOnPlane(t) {
return L.copy(this).projectOnVector(t), this.sub(L)
}
reflect(t) {
return this.sub(L.copy(t).multiplyScalar(2 * this.dot(t)))
}
angleTo(t) {
const e = Math.sqrt(this.lengthSq() * t.lengthSq());
if (0 === e) return Math.PI / 2;
const n = this.dot(t) / e;
return Math.acos(g.clamp(n, -1, 1))
}
distanceTo(t) {
return Math.sqrt(this.distanceToSquared(t))
}
distanceToSquared(t) {
const e = this.x - t.x,
n = this.y - t.y,
i = this.z - t.z;
return e * e + n * n + i * i
}
manhattanDistanceTo(t) {
return Math.abs(this.x - t.x) + Math.abs(this.y - t.y) + Math.abs(this.z - t.z)
}
setFromSpherical(t) {
return this.setFromSphericalCoords(t.radius, t.phi, t.theta)
}
setFromSphericalCoords(t, e, n) {
const i = Math.sin(e) * t;
return this.x = i * Math.sin(n), this.y = Math.cos(e) * t, this.z = i * Math.cos(n), this
}
setFromCylindrical(t) {
return this.setFromCylindricalCoords(t.radius, t.theta, t.y)
}
setFromCylindricalCoords(t, e, n) {
return this.x = t * Math.sin(e), this.y = n, this.z = t * Math.cos(e), this
}
setFromMatrixPosition(t) {
const e = t.elements;
return this.x = e[12], this.y = e[13], this.z = e[14], this
}
setFromMatrixScale(t) {
const e = this.setFromMatrixColumn(t, 0).length(),
n = this.setFromMatrixColumn(t, 1).length(),
i = this.setFromMatrixColumn(t, 2).length();
return this.x = e, this.y = n, this.z = i, this
}
setFromMatrixColumn(t, e) {
return this.fromArray(t.elements, 4 * e)
}
setFromMatrix3Column(t, e) {
return this.fromArray(t.elements, 3 * e)
}
equals(t) {
return t.x === this.x && t.y === this.y && t.z === this.z
}
fromArray(t, e = 0) {
return this.x = t[e], this.y = t[e + 1], this.z = t[e + 2], this
}
toArray(t = [], e = 0) {
return t[e] = this.x, t[e + 1] = this.y, t[e + 2] = this.z, t
}
fromBufferAttribute(t, e, n) {
return void 0 !== n && console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."), this.x = t.getX(e), this.y = t.getY(e), this.z = t.getZ(e), this
}
random() {
return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this
}
}
const L = new T,
R = new S;
class C {
constructor(t, e) {
Object.defineProperty(this, "isBox3", {
value: !0
}), this.min = void 0 !== t ? t : new T(1 / 0, 1 / 0, 1 / 0), this.max = void 0 !== e ? e : new T(-1 / 0, -1 / 0, -1 / 0)
}
set(t, e) {
return this.min.copy(t), this.max.copy(e), this
}
setFromArray(t) {
let e = 1 / 0,
n = 1 / 0,
i = 1 / 0,
r = -1 / 0,
o = -1 / 0,
s = -1 / 0;
for (let a = 0, l = t.length; a < l; a += 3) {
const l = t[a],
c = t[a + 1],
h = t[a + 2];
l < e && (e = l), c < n && (n = c), h < i && (i = h), l > r && (r = l), c > o && (o = c), h > s && (s = h)
}
return this.min.set(e, n, i), this.max.set(r, o, s), this
}
setFromBufferAttribute(t) {
let e = 1 / 0,
n = 1 / 0,
i = 1 / 0,
r = -1 / 0,
o = -1 / 0,
s = -1 / 0;
for (let a = 0, l = t.count; a < l; a++) {
const l = t.getX(a),
c = t.getY(a),
h = t.getZ(a);
l < e && (e = l), c < n && (n = c), h < i && (i = h), l > r && (r = l), c > o && (o = c), h > s && (s = h)
}
return this.min.set(e, n, i), this.max.set(r, o, s), this
}
setFromPoints(t) {
this.makeEmpty();
for (let e = 0, n = t.length; e < n; e++) this.expandByPoint(t[e]);
return this
}
setFromCenterAndSize(t, e) {
const n = I.copy(e).multiplyScalar(.5);
return this.min.copy(t).sub(n), this.max.copy(t).add(n), this
}
setFromObject(t) {
return this.makeEmpty(), this.expandByObject(t)
}
clone() {
return (new this.constructor).copy(this)
}
copy(t) {
return this.min.copy(t.min), this.max.copy(t.max), this
}
makeEmpty() {
return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this
}
isEmpty() {
return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z
}
getCenter(t) {
return void 0 === t && (console.warn("THREE.Box3: .getCenter() target is now required"), t = new T), this.isEmpty() ? t.set(0, 0, 0) : t.addVectors(this.min, this.max).multiplyScalar(.5)
}
getSize(t) {
return void 0 === t && (console.warn("THREE.Box3: .getSize() target is now required"), t = new T), this.isEmpty() ? t.set(0, 0, 0) : t.subVectors(this.max, this.min)
}
expandByPoint(t) {
return this.min.min(t), this.max.max(t), this
}
expandByVector(t) {
return this.min.sub(t), this.max.add(t), this
}
expandByScalar(t) {
return this.min.addScalar(-t), this.max.addScalar(t), this
}
expandByObject(t) {
t.updateWorldMatrix(!1, !1);
const e = t.geometry;
void 0 !== e && (null === e.boundingBox && e.computeBoundingBox(), O.copy(e.boundingBox), O.applyMatrix4(t.matrixWorld), this.union(O));
const n = t.children;
for (let t = 0, e = n.length; t < e; t++) this.expandByObject(n[t]);
return this
}
containsPoint(t) {
return !(t.x < this.min.x || t.x > this.max.x || t.y < this.min.y || t.y > this.max.y || t.z < this.min.z || t.z > this.max.z)
}
containsBox(t) {
return this.min.x <= t.min.x && t.max.x <= this.max.x && this.min.y <= t.min.y && t.max.y <= this.max.y && this.min.z <= t.min.z && t.max.z <= this.max.z
}
getParameter(t, e) {
return void 0 === e && (console.warn("THREE.Box3: .getParameter() target is now required"), e = new T), e.set((t.x - this.min.x) / (this.max.x - this.min.x), (t.y - this.min.y) / (this.max.y - this.min.y), (t.z - this.min.z) / (this.max.z - this.min.z))
}
intersectsBox(t) {
return !(t.max.x < this.min.x || t.min.x > this.max.x || t.max.y < this.min.y || t.min.y > this.max.y || t.max.z < this.min.z || t.min.z > this.max.z)
}
intersectsSphere(t) {
return this.clampPoint(t.center, I), I.distanceToSquared(t.center) <= t.radius * t.radius
}
intersectsPlane(t) {
let e, n;
return t.normal.x > 0 ? (e = t.normal.x * this.min.x, n = t.normal.x * this.max.x) : (e = t.normal.x * this.max.x, n = t.normal.x * this.min.x), t.normal.y > 0 ? (e += t.normal.y * this.min.y, n += t.normal.y * this.max.y) : (e += t.normal.y * this.max.y, n += t.normal.y * this.min.y), t.normal.z > 0 ? (e += t.normal.z * this.min.z, n += t.normal.z * this.max.z) : (e += t.normal.z * this.max.z, n += t.normal.z * this.min.z), e <= -t.constant && n >= -t.constant
}
intersectsTriangle(t) {
if (this.isEmpty()) return !1;
this.getCenter(G), V.subVectors(this.max, G), N.subVectors(t.a, G), B.subVectors(t.b, G), F.subVectors(t.c, G), z.subVectors(B, N), U.subVectors(F, B), H.subVectors(N, F);
let e = [0, -z.z, z.y, 0, -U.z, U.y, 0, -H.z, H.y, z.z, 0, -z.x, U.z, 0, -U.x, H.z, 0, -H.x, -z.y, z.x, 0, -U.y, U.x, 0, -H.y, H.x, 0];
return !!P(e, N, B, F, V) && (e = [1, 0, 0, 0, 1, 0, 0, 0, 1], !!P(e, N, B, F, V) && (k.crossVectors(z, U), e = [k.x, k.y, k.z], P(e, N, B, F, V)))
}
clampPoint(t, e) {
return void 0 === e && (console.warn("THREE.Box3: .clampPoint() target is now required"), e = new T), e.copy(t).clamp(this.min, this.max)
}
distanceToPoint(t) {
return I.copy(t).clamp(this.min, this.max).sub(t).length()
}
getBoundingSphere(t) {
return void 0 === t && console.error("THREE.Box3: .getBoundingSphere() target is now required"), this.getCenter(t.center), t.radius = .5 * this.getSize(I).length(), t
}
intersect(t) {
return this.min.max(t.min), this.max.min(t.max), this.isEmpty() && this.makeEmpty(), this
}
union(t) {
return this.min.min(t.min), this.max.max(t.max), this
}
applyMatrix4(t) {
return this.isEmpty() || (D[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(t), D[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(t), D[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(t), D[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(t), D[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(t), D[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(t), D[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(t), D[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(t), this.setFromPoints(D)), this
}
translate(t) {
return this.min.add(t), this.max.add(t), this
}
equals(t) {
return t.min.equals(this.min) && t.max.equals(this.max)
}
}
function P(t, e, n, i, r) {
for (let o = 0, s = t.length - 3; o <= s; o += 3) {
W.fromArray(t, o);
const s = r.x * Math.abs(W.x) + r.y * Math.abs(W.y) + r.z * Math.abs(W.z),
a = e.dot(W),
l = n.dot(W),
c = i.dot(W);
if (Math.max(-Math.max(a, l, c), Math.min(a, l, c)) > s) return !1
}
return !0
}
const D = [new T, new T, new T, new T, new T, new T, new T, new T],
I = new T,
O = new C,
N = new T,
B = new T,
F = new T,
z = new T,
U = new T,
H = new T,
G = new T,
V = new T,
k = new T,
W = new T,
j = new C;
class X {
constructor(t, e) {
this.center = void 0 !== t ? t : new T, this.radius = void 0 !== e ? e : -1
}
set(t, e) {
return this.center.copy(t), this.radius = e, this
}
setFromPoints(t, e) {
const n = this.center;
void 0 !== e ? n.copy(e) : j.setFromPoints(t).getCenter(n);
let i = 0;
for (let e = 0, r = t.length; e < r; e++) i = Math.max(i, n.distanceToSquared(t[e]));
return this.radius = Math.sqrt(i), this
}
clone() {
return (new this.constructor).copy(this)
}
copy(t) {
return this.center.copy(t.center), this.radius = t.radius, this
}
isEmpty() {
return this.radius < 0
}
makeEmpty() {
return this.center.set(0, 0, 0), this.radius = -1, this
}
containsPoint(t) {
return t.distanceToSquared(this.center) <= this.radius * this.radius
}
distanceToPoint(t) {
return t.distanceTo(this.center) - this.radius
}
intersectsSphere(t) {
const e = this.radius + t.radius;
return t.center.distanceToSquared(this.center) <= e * e
}
intersectsBox(t) {
return t.intersectsSphere(this)
}
intersectsPlane(t) {
return Math.abs(t.distanceToPoint(this.center)) <= this.radius
}
clampPoint(t, e) {
const n = this.center.distanceToSquared(t);
return void 0 === e && (console.warn("THREE.Sphere: .clampPoint() target is now required"), e = new T), e.copy(t), n > this.radius * this.radius && (e.sub(this.center).normalize(), e.multiplyScalar(this.radius).add(this.center)), e
}
getBoundingBox(t) {
return void 0 === t && (console.warn("THREE.Sphere: .getBoundingBox() target is now required"), t = new C), this.isEmpty() ? (t.makeEmpty(), t) : (t.set(this.center, this.center), t.expandByScalar(this.radius), t)
}
applyMatrix4(t) {
return this.center.applyMatrix4(t), this.radius = this.radius * t.getMaxScaleOnAxis(), this
}
translate(t) {
return this.center.add(t), this
}
equals(t) {
return t.center.equals(this.center) && t.radius === this.radius
}
}
const q = new T,
Y = new T,
Q = new T,
Z = new T,
J = new T,
K = new T,
$ = new T;
class tt {
constructor(t, e) {
this.origin = void 0 !== t ? t : new T, this.direction = void 0 !== e ? e : new T(0, 0, -1)
}
set(t, e) {
return this.origin.copy(t), this.direction.copy(e), this
}
clone() {
return (new this.constructor).copy(this)
}
copy(t) {
return this.origin.copy(t.origin), this.direction.copy(t.direction), this
}
at(t, e) {
return void 0 === e && (console.warn("THREE.Ray: .at() target is now required"), e = new T), e.copy(this.direction).multiplyScalar(t).add(this.origin)
}
lookAt(t) {
return this.direction.copy(t).sub(this.origin).normalize(), this
}
recast(t) {
return this.origin.copy(this.at(t, q)), this
}
closestPointToPoint(t, e) {
void 0 === e && (console.warn("THREE.Ray: .closestPointToPoint() target is now required"), e = new T), e.subVectors(t, this.origin);
const n = e.dot(this.direction);
return n < 0 ? e.copy(this.origin) : e.copy(this.direction).multiplyScalar(n).add(this.origin)
}
distanceToPoint(t) {
return Math.sqrt(this.distanceSqToPoint(t))
}
distanceSqToPoint(t) {
const e = q.subVectors(t, this.origin).dot(this.direction);
return e < 0 ? this.origin.distanceToSquared(t) : (q.copy(this.direction).multiplyScalar(e).add(this.origin), q.distanceToSquared(t))
}
distanceSqToSegment(t, e, n, i) {
Y.copy(t).add(e).multiplyScalar(.5), Q.copy(e).sub(t).normalize(), Z.copy(this.origin).sub(Y);
const r = .5 * t.distanceTo(e),
o = -this.direction.dot(Q),
s = Z.dot(this.direction),
a = -Z.dot(Q),
l = Z.lengthSq(),
c = Math.abs(1 - o * o);
let h, u, d, p;
if (c > 0)
if (h = o * a - s, u = o * s - a, p = r * c, h >= 0)
if (u >= -p)
if (u <= p) {
const t = 1 / c;
h *= t, u *= t, d = h * (h + o * u + 2 * s) + u * (o * h + u + 2 * a) + l
} else u = r, h = Math.max(0, -(o * u + s)), d = -h * h + u * (u + 2 * a) + l;
else u = -r, h = Math.max(0, -(o * u + s)), d = -h * h + u * (u + 2 * a) + l;
else u <= -p ? (h = Math.max(0, -(-o * r + s)), u = h > 0 ? -r : Math.min(Math.max(-r, -a), r), d = -h * h + u * (u + 2 * a) + l) : u <= p ? (h = 0, u = Math.min(Math.max(-r, -a), r), d = u * (u + 2 * a) + l) : (h = Math.max(0, -(o * r + s)), u = h > 0 ? r : Math.min(Math.max(-r, -a), r), d = -h * h + u * (u + 2 * a) + l);
else u = o > 0 ? -r : r, h = Math.max(0, -(o * u + s)), d = -h * h + u * (u + 2 * a) + l;
return n && n.copy(this.direction).multiplyScalar(h).add(this.origin), i && i.copy(Q).multiplyScalar(u).add(Y), d
}
intersectSphere(t, e) {
q.subVectors(t.center, this.origin);
const n = q.dot(this.direction),
i = q.dot(q) - n * n,
r = t.radius * t.radius;
if (i > r) return null;
const o = Math.sqrt(r - i),
s = n - o,
a = n + o;
return s < 0 && a < 0 ? null : s < 0 ? this.at(a, e) : this.at(s, e)
}
intersectsSphere(t) {
return this.distanceSqToPoint(t.center) <= t.radius * t.radius
}
distanceToPlane(t) {
const e = t.normal.dot(this.direction);
if (0 === e) return 0 === t.distanceToPoint(this.origin) ? 0 : null;
const n = -(this.origin.dot(t.normal) + t.constant) / e;
return n >= 0 ? n : null
}
intersectPlane(t, e) {
const n = this.distanceToPlane(t);
return null === n ? null : this.at(n, e)
}
intersectsPlane(t) {
const e = t.distanceToPoint(this.origin);
if (0 === e) return !0;
return t.normal.dot(this.direction) * e < 0
}
intersectBox(t, e) {
let n, i, r, o, s, a;
const l = 1 / this.direction.x,
c = 1 / this.direction.y,
h = 1 / this.direction.z,
u = this.origin;
return l >= 0 ? (n = (t.min.x - u.x) * l, i = (t.max.x - u.x) * l) : (n = (t.max.x - u.x) * l, i = (t.min.x - u.x) * l), c >= 0 ? (r = (t.min.y - u.y) * c, o = (t.max.y - u.y) * c) : (r = (t.max.y - u.y) * c, o = (t.min.y - u.y) * c), n > o || r > i ? null : ((r > n || n != n) && (n = r), (o < i || i != i) && (i = o), h >= 0 ? (s = (t.min.z - u.z) * h, a = (t.max.z - u.z) * h) : (s = (t.max.z - u.z) * h, a = (t.min.z - u.z) * h), n > a || s > i ? null : ((s > n || n != n) && (n = s), (a < i || i != i) && (i = a), i < 0 ? null : this.at(n >= 0 ? n : i, e)))
}
intersectsBox(t) {
return null !== this.intersectBox(t, q)
}
intersectTriangle(t, e, n, i, r) {
J.subVectors(e, t), K.subVectors(n, t), $.crossVectors(J, K);
let o, s = this.direction.dot($);
if (s > 0) {
if (i) return null;
o = 1
} else {
if (!(s < 0)) return null;
o = -1, s = -s
}
Z.subVectors(this.origin, t);
const a = o * this.direction.dot(K.crossVectors(Z, K));
if (a < 0) return null;
const l = o * this.direction.dot(J.cross(Z));
if (l < 0) return null;
if (a + l > s) return null;
const c = -o * Z.dot($);
return c < 0 ? null : this.at(c / s, r)
}
applyMatrix4(t) {
return this.origin.applyMatrix4(t), this.direction.transformDirection(t), this
}
equals(t) {
return t.origin.equals(this.origin) && t.direction.equals(this.direction)
}
}
class et {
constructor() {
Object.defineProperty(this, "isMatrix4", {
value: !0
}), this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], arguments.length > 0 && console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")
}
set(t, e, n, i, r, o, s, a, l, c, h, u, d, p, f, m) {
const g = this.elements;
return g[0] = t, g[4] = e, g[8] = n, g[12] = i, g[1] = r, g[5] = o, g[9] = s, g[13] = a, g[2] = l, g[6] = c, g[10] = h, g[14] = u, g[3] = d, g[7] = p, g[11] = f, g[15] = m, this
}
identity() {
return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this
}
clone() {
return (new et).fromArray(this.elements)
}
copy(t) {
const e = this.elements,
n = t.elements;
return e[0] = n[0], e[1] = n[1], e[2] = n[2], e[3] = n[3], e[4] = n[4], e[5] = n[5], e[6] = n[6], e[7] = n[7], e[8] = n[8], e[9] = n[9], e[10] = n[10], e[11] = n[11], e[12] = n[12], e[13] = n[13], e[14] = n[14], e[15] = n[15], this
}
copyPosition(t) {
const e = this.elements,
n = t.elements;
return e[12] = n[12], e[13] = n[13], e[14] = n[14], this
}
setFromMatrix3(t) {
const e = t.elements;
return this.set(e[0], e[3], e[6], 0, e[1], e[4], e[7], 0, e[2], e[5], e[8], 0, 0, 0, 0, 1), this
}
extractBasis(t, e, n) {
return t.setFromMatrixColumn(this, 0), e.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this
}
makeBasis(t, e, n) {
return this.set(t.x, e.x, n.x, 0, t.y, e.y, n.y, 0, t.z, e.z, n.z, 0, 0, 0, 0, 1), this
}
extractRotation(t) {
const e = this.elements,
n = t.elements,
i = 1 / nt.setFromMatrixColumn(t, 0).length(),
r = 1 / nt.setFromMatrixColumn(t, 1).length(),
o = 1 / nt.setFromMatrixColumn(t, 2).length();
return e[0] = n[0] * i, e[1] = n[1] * i, e[2] = n[2] * i, e[3] = 0, e[4] = n[4] * r, e[5] = n[5] * r, e[6] = n[6] * r, e[7] = 0, e[8] = n[8] * o, e[9] = n[9] * o, e[10] = n[10] * o, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this
}
makeRotationFromEuler(t) {
t && t.isEuler || console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
const e = this.elements,
n = t.x,
i = t.y,
r = t.z,
o = Math.cos(n),
s = Math.sin(n),
a = Math.cos(i),
l = Math.sin(i),
c = Math.cos(r),
h = Math.sin(r);
if ("XYZ" === t.order) {
const t = o * c,
n = o * h,
i = s * c,
r = s * h;
e[0] = a * c, e[4] = -a * h, e[8] = l, e[1] = n + i * l, e[5] = t - r * l, e[9] = -s * a, e[2] = r - t * l, e[6] = i + n * l, e[10] = o * a
} else if ("YXZ" === t.order) {
const t = a * c,
n = a * h,
i = l * c,
r = l * h;
e[0] = t + r * s, e[4] = i * s - n, e[8] = o * l, e[1] = o * h, e[5] = o * c, e[9] = -s, e[2] = n * s - i, e[6] = r + t * s, e[10] = o * a
} else if ("ZXY" === t.order) {
const t = a * c,
n = a * h,
i = l * c,
r = l * h;
e[0] = t - r * s, e[4] = -o * h, e[8] = i + n * s, e[1] = n + i * s, e[5] = o * c, e[9] = r - t * s, e[2] = -o * l, e[6] = s, e[10] = o * a
} else if ("ZYX" === t.order) {
const t = o * c,
n = o * h,
i = s * c,
r = s * h;
e[0] = a * c, e[4] = i * l - n, e[8] = t * l + r, e[1] = a * h, e[5] = r * l + t, e[9] = n * l - i, e[2] = -l, e[6] = s * a, e[10] = o * a
} else if ("YZX" === t.order) {
const t = o * a,
n = o * l,
i = s * a,
r = s * l;
e[0] = a * c, e[4] = r - t * h, e[8] = i * h + n, e[1] = h, e[5] = o * c, e[9] = -s * c, e[2] = -l * c, e[6] = n * h + i, e[10] = t - r * h
} else if ("XZY" === t.order) {
const t = o * a,
n = o * l,
i = s * a,
r = s * l;
e[0] = a * c, e[4] = -h, e[8] = l * c, e[1] = t * h + r, e[5] = o * c, e[9] = n * h - i, e[2] = i * h - n, e[6] = s * c, e[10] = r * h + t
}
return e[3] = 0, e[7] = 0, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this
}
makeRotationFromQuaternion(t) {
return this.compose(rt, t, ot)
}
lookAt(t, e, n) {
const i = this.elements;
return lt.subVectors(t, e), 0 === lt.lengthSq() && (lt.z = 1), lt.normalize(), st.crossVectors(n, lt), 0 === st.lengthSq() && (1 === Math.abs(n.z) ? lt.x += 1e-4 : lt.z += 1e-4, lt.normalize(), st.crossVectors(n, lt)), st.normalize(), at.crossVectors(lt, st), i[0] = st.x, i[4] = at.x, i[8] = lt.x, i[1] = st.y, i[5] = at.y, i[9] = lt.y, i[2] = st.z, i[6] = at.z, i[10] = lt.z, this
}
multiply(t, e) {
return void 0 !== e ? (console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."), this.multiplyMatrices(t, e)) : this.multiplyMatrices(this, t)
}
premultiply(t) {
return this.multiplyMatrices(t, this)
}
multiplyMatrices(t, e) {
const n = t.elements,
i = e.elements,
r = this.elements,
o = n[0],
s = n[4],
a = n[8],
l = n[12],
c = n[1],
h = n[5],
u = n[9],
d = n[13],
p = n[2],
f = n[6],
m = n[10],
g = n[14],
v = n[3],
y = n[7],
A = n[11],
x = n[15],
_ = i[0],
b = i[4],
w = i[8],
M = i[12],
E = i[1],
S = i[5],
T = i[9],
L = i[13],
R = i[2],
C = i[6],
P = i[10],
D = i[14],
I = i[3],
O = i[7],
N = i[11],
B = i[15];
return r[0] = o * _ + s * E + a * R + l * I, r[4] = o * b + s * S + a * C + l * O, r[8] = o * w + s * T + a * P + l * N, r[12] = o * M + s * L + a * D + l * B, r[1] = c * _ + h * E + u * R + d * I, r[5] = c * b + h * S + u * C + d * O, r[9] = c * w + h * T + u * P + d * N, r[13] = c * M + h * L + u * D + d * B, r[2] = p * _ + f * E + m * R + g * I, r[6] = p * b + f * S + m * C + g * O, r[10] = p * w + f * T + m * P + g * N, r[14] = p * M + f * L + m * D + g * B, r[3] = v * _ + y * E + A * R + x * I, r[7] = v * b + y * S + A * C + x * O, r[11] = v * w + y * T + A * P + x * N, r[15] = v * M + y * L + A * D + x * B, this
}
multiplyScalar(t) {
const e = this.elements;
return e[0] *= t, e[4] *= t, e[8] *= t, e[12] *= t, e[1] *= t, e[5] *= t, e[9] *= t, e[13] *= t, e[2] *= t, e[6] *= t, e[10] *= t, e[14] *= t, e[3] *= t, e[7] *= t, e[11] *= t, e[15] *= t, this
}
determinant() {
const t = this.elements,
e = t[0],
n = t[4],
i = t[8],
r = t[12],
o = t[1],
s = t[5],
a = t[9],
l = t[13],
c = t[2],
h = t[6],
u = t[10],
d = t[14];
return t[3] * (+r * a * h - i * l * h - r * s * u + n * l * u + i * s * d - n * a * d) + t[7] * (+e * a * d - e * l * u + r * o * u - i * o * d + i * l * c - r * a * c) + t[11] * (+e * l * h - e * s * d - r * o * h + n * o * d + r * s * c - n * l * c) + t[15] * (-i * s * c - e * a * h + e * s * u + i * o * h - n * o * u + n * a * c)
}
transpose() {
const t = this.elements;
let e;
return e = t[1], t[1] = t[4], t[4] = e, e = t[2], t[2] = t[8], t[8] = e, e = t[6], t[6] = t[9], t[9] = e, e = t[3], t[3] = t[12], t[12] = e, e = t[7], t[7] = t[13], t[13] = e, e = t[11], t[11] = t[14], t[14] = e, this
}
setPosition(t, e, n) {
const i = this.elements;
return t.isVector3 ? (i[12] = t.x, i[13] = t.y, i[14] = t.z) : (i[12] = t, i[13] = e, i[14] = n), this
}
invert() {
const t = this.elements,
e = t[0],
n = t[1],
i = t[2],
r = t[3],
o = t[4],
s = t[5],
a = t[6],
l = t[7],
c = t[8],
h = t[9],
u = t[10],
d = t[11],
p = t[12],
f = t[13],
m = t[14],
g = t[15],
v = h * m * l - f * u * l + f * a * d - s * m * d - h * a * g + s * u * g,
y = p * u * l - c * m * l - p * a * d + o * m * d + c * a * g - o * u * g,
A = c * f * l - p * h * l + p * s * d - o * f * d - c * s * g + o * h * g,
x = p * h * a - c * f * a - p * s * u + o * f * u + c * s * m - o * h * m,
_ = e * v + n * y + i * A + r * x;
if (0 === _) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
const b = 1 / _;
return t[0] = v * b, t[1] = (f * u * r - h * m * r - f * i * d + n * m * d + h * i * g - n * u * g) * b, t[2] = (s * m * r - f * a * r + f * i * l - n * m * l - s * i * g + n * a * g) * b, t[3] = (h * a * r - s * u * r - h * i * l + n * u * l + s * i * d - n * a * d) * b, t[4] = y * b, t[5] = (c * m * r - p * u * r + p * i * d - e * m * d - c * i * g + e * u * g) * b, t[6] = (p * a * r - o * m * r - p * i * l + e * m * l + o * i * g - e * a * g) * b, t[7] = (o * u * r - c * a * r + c * i * l - e * u * l - o * i * d + e * a * d) * b, t[8] = A * b, t[9] = (p * h * r - c * f * r - p * n * d + e * f * d + c * n * g - e * h * g) * b, t[10] = (o * f * r - p * s * r + p * n * l - e * f * l - o * n * g + e * s * g) * b, t[11] = (c * s * r - o * h * r - c * n * l + e * h * l + o * n * d - e * s * d) * b, t[12] = x * b, t[13] = (c * f * i - p * h * i + p * n * u - e * f * u - c * n * m + e * h * m) * b, t[14] = (p * s * i - o * f * i - p * n * a + e * f * a + o * n * m - e * s * m) * b, t[15] = (o * h * i - c * s * i + c * n * a - e * h * a - o * n * u + e * s * u) * b, this
}
scale(t) {
const e = this.elements,
n = t.x,
i = t.y,
r = t.z;
return e[0] *= n, e[4] *= i, e[8] *= r, e[1] *= n, e[5] *= i, e[9] *= r, e[2] *= n, e[6] *= i, e[10] *= r, e[3] *= n, e[7] *= i, e[11] *= r, this
}
getMaxScaleOnAxis() {
const t = this.elements,
e = t[0] * t[0] + t[1] * t[1] + t[2] * t[2],
n = t[4] * t[4] + t[5] * t[5] + t[6] * t[6],
i = t[8] * t[8] + t[9] * t[9] + t[10] * t[10];
return Math.sqrt(Math.max(e, n, i))
}
makeTranslation(t, e, n) {
return this.set(1, 0, 0, t, 0, 1, 0, e, 0, 0, 1, n, 0, 0, 0, 1), this
}
makeRotationX(t) {
const e = Math.cos(t),
n = Math.sin(t);
return this.set(1, 0, 0, 0, 0, e, -n, 0, 0, n, e, 0, 0, 0, 0, 1), this
}
makeRotationY(t) {
const e = Math.cos(t),
n = Math.sin(t);
return this.set(e, 0, n, 0, 0, 1, 0, 0, -n, 0, e, 0, 0, 0, 0, 1), this
}
makeRotationZ(t) {
const e = Math.cos(t),
n = Math.sin(t);
return this.set(e, -n, 0, 0, n, e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this
}
makeRotationAxis(t, e) {
const n = Math.cos(e),
i = Math.sin(e),
r = 1 - n,
o = t.x,
s = t.y,
a = t.z,
l = r * o,
c = r * s;
return this.set(l * o + n, l * s - i * a, l * a + i * s, 0, l * s + i * a, c * s + n, c * a - i * o, 0, l * a - i * s, c * a + i * o, r * a * a + n, 0, 0, 0, 0, 1), this
}
makeScale(t, e, n) {
return this.set(t, 0, 0, 0, 0, e, 0, 0, 0, 0, n, 0, 0, 0, 0, 1), this
}
makeShear(t, e, n) {
return this.set(1, e, n, 0, t, 1, n, 0, t, e, 1, 0, 0, 0, 0, 1), this
}
compose(t, e, n) {
const i = this.elements,
r = e._x,
o = e._y,
s = e._z,
a = e._w,
l = r + r,
c = o + o,
h = s + s,
u = r * l,
d = r * c,
p = r * h,
f = o * c,
m = o * h,
g = s * h,
v = a * l,
y = a * c,
A = a * h,
x = n.x,
_ = n.y,
b = n.z;
return i[0] = (1 - (f + g)) * x, i[1] = (d + A) * x, i[2] = (p - y) * x, i[3] = 0, i[4] = (d - A) * _, i[5] = (1 - (u + g)) * _, i[6] = (m + v) * _, i[7] = 0, i[8] = (p + y) * b, i[9] = (m - v) * b, i[10] = (1 - (u + f)) * b, i[11] = 0, i[12] = t.x, i[13] = t.y, i[14] = t.z, i[15] = 1, this
}
decompose(t, e, n) {
const i = this.elements;
let r = nt.set(i[0], i[1], i[2]).length();
const o = nt.set(i[4], i[5], i[6]).length(),
s = nt.set(i[8], i[9], i[10]).length();
this.determinant() < 0 && (r = -r), t.x = i[12], t.y = i[13], t.z = i[14], it.copy(this);
const a = 1 / r,
l = 1 / o,
c = 1 / s;
return it.elements[0] *= a, it.elements[1] *= a, it.elements[2] *= a, it.elements[4] *= l, it.elements[5] *= l, it.elements[6] *= l, it.elements[8] *= c, it.elements[9] *= c, it.elements[10] *= c, e.setFromRotationMatrix(it), n.x = r, n.y = o, n.z = s, this
}
makePerspective(t, e, n, i, r, o) {
void 0 === o && console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");
const s = this.elements,
a = 2 * r / (e - t),
l = 2 * r / (n - i),
c = (e + t) / (e - t),
h = (n + i) / (n - i),
u = -(o + r) / (o - r),
d = -2 * o * r / (o - r);
return s[0] = a, s[4] = 0, s[8] = c, s[12] = 0, s[1] = 0, s[5] = l, s[9] = h, s[13] = 0, s[2] = 0, s[6] = 0, s[10] = u, s[14] = d, s[3] = 0, s[7] = 0, s[11] = -1, s[15] = 0, this
}
makeOrthographic(t, e, n, i, r, o) {
const s = this.elements,
a = 1 / (e - t),
l = 1 / (n - i),
c = 1 / (o - r),
h = (e + t) * a,
u = (n + i) * l,
d = (o + r) * c;
return s[0] = 2 * a, s[4] = 0, s[8] = 0, s[12] = -h, s[1] = 0, s[5] = 2 * l, s[9] = 0, s[13] = -u, s[2] = 0, s[6] = 0, s[10] = -2 * c, s[14] = -d, s[3] = 0, s[7] = 0, s[11] = 0, s[15] = 1, this
}
equals(t) {
const e = this.elements,
n = t.elements;
for (let t = 0; t < 16; t++)
if (e[t] !== n[t]) return !1;
return !0
}
fromArray(t, e = 0) {
for (let n = 0; n < 16; n++) this.elements[n] = t[n + e];
return this
}
toArray(t = [], e = 0) {
const n = this.elements;
return t[e] = n[0], t[e + 1] = n[1], t[e + 2] = n[2], t[e + 3] = n[3], t[e + 4] = n[4], t[e + 5] = n[5], t[e + 6] = n[6], t[e + 7] = n[7], t[e + 8] = n[8], t[e + 9] = n[9], t[e + 10] = n[10], t[e + 11] = n[11], t[e + 12] = n[12], t[e + 13] = n[13], t[e + 14] = n[14], t[e + 15] = n[15], t
}
}
const nt = new T,
it = new et,
rt = new T(0, 0, 0),
ot = new T(1, 1, 1),
st = new T,
at = new T,
lt = new T;
class ct {
constructor(t = 0, e = 0, n = 0, i = ct.DefaultOrder) {
Object.defineProperty(this, "isEuler", {
value: !0
}), this._x = t, this._y = e, this._z = n, this._order = i
}
get x() {
return this._x
}
set x(t) {
this._x = t, this._onChangeCallback()
}
get y() {
return this._y
}
set y(t) {
this._y = t, this._onChangeCallback()
}
get z() {
return this._z
}
set z(t) {
this._z = t, this._onChangeCallback()
}
get order() {
return this._order
}
set order(t) {
this._order = t, this._onChangeCallback()
}
set(t, e, n, i) {
return this._x = t, this._y = e, this._z = n, this._order = i || this._order, this._onChangeCallback(), this
}
clone() {
return new this.constructor(this._x, this._y, this._z, this._order)
}
copy(t) {
return this._x = t._x, this._y = t._y, this._z = t._z, this._order = t._order, this._onChangeCallback(), this
}
setFromRotationMatrix(t, e, n) {
const i = g.clamp,
r = t.elements,
o = r[0],
s = r[4],
a = r[8],
l = r[1],
c = r[5],
h = r[9],
u = r[2],
d = r[6],
p = r[10];
switch (e = e || this._order) {
case "XYZ":
this._y = Math.asin(i(a, -1, 1)), Math.abs(a) < .9999999 ? (this._x = Math.atan2(-h, p), this._z = Math.atan2(-s, o)) : (this._x = Math.atan2(d, c), this._z = 0);
break;
case "YXZ":
this._x = Math.asin(-i(h, -1, 1)), Math.abs(h) < .9999999 ? (this._y = Math.atan2(a, p), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-u, o), this._z = 0);
break;
case "ZXY":
this._x = Math.asin(i(d, -1, 1)), Math.abs(d) < .9999999 ? (this._y = Math.atan2(-u, p), this._z = Math.atan2(-s, c)) : (this._y = 0, this._z = Math.atan2(l, o));
break;
case "ZYX":
this._y = Math.asin(-i(u, -1, 1)), Math.abs(u) < .9999999 ? (this._x = Math.atan2(d, p), this._z = Math.atan2(l, o)) : (this._x = 0, this._z = Math.atan2(-s, c));
break;
case "YZX":
this._z = Math.asin(i(l, -1, 1)), Math.abs(l) < .9999999 ? (this._x = Math.atan2(-h, c), this._y = Math.atan2(-u, o)) : (this._x = 0, this._y = Math.atan2(a, p));
break;
case "XZY":
this._z = Math.asin(-i(s, -1, 1)), Math.abs(s) < .9999999 ? (this._x = Math.atan2(d, c), this._y = Math.atan2(a, o)) : (this._x = Math.atan2(-h, p), this._y = 0);
break;
default:
console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + e)
}
return this._order = e, !1 !== n && this._onChangeCallback(), this
}
setFromQuaternion(t, e, n) {
return ht.makeRotationFromQuaternion(t), this.setFromRotationMatrix(ht, e, n)
}
setFromVector3(t, e) {
return this.set(t.x, t.y, t.z, e || this._order)
}
reorder(t) {
return ut.setFromEuler(this), this.setFromQuaternion(ut, t)
}
equals(t) {
return t._x === this._x && t._y === this._y && t._z === this._z && t._order === this._order
}
fromArray(t) {
return this._x = t[0], this._y = t[1], this._z = t[2], void 0 !== t[3] && (this._order = t[3]), this._onChangeCallback(), this
}
toArray(t = [], e = 0) {
return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._order, t
}
toVector3(t) {
return t ? t.set(this._x, this._y, this._z) : new T(this._x, this._y, this._z)
}
_onChange(t) {
return this._onChangeCallback = t, this
}
_onChangeCallback() {}
}
ct.DefaultOrder = "XYZ", ct.RotationOrders = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
const ht = new et,
ut = new S;
class dt {
constructor() {
this.mask = 1
}
set(t) {
this.mask = 1 << t | 0
}
enable(t) {
this.mask |= 1 << t | 0
}
enableAll() {
this.mask = -1
}
toggle(t) {
this.mask ^= 1 << t | 0
}
disable(t) {
this.mask &= ~(1 << t | 0)
}
disableAll() {
this.mask = 0
}
test(t) {
return 0 != (this.mask & t.mask)
}
}
let pt = 0;
const ft = new T,
mt = new S,
gt = new et,
vt = new T,
yt = new T,
At = new T,
xt = new S,
_t = new T(1, 0, 0),
bt = new T(0, 1, 0),
wt = new T(0, 0, 1),
Mt = {
type: "added"
},
Et = {
type: "removed"
};
function St() {
Object.defineProperty(this, "id", {
value: pt++
}), this.uuid = g.generateUUID(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = St.DefaultUp.clone();
const t = new T,
e = new ct,
n = new S,
i = new T(1, 1, 1);
e._onChange((function() {
n.setFromEuler(e, !1)
})), n._onChange((function() {
e.setFromQuaternion(n, void 0, !1)
})), Object.defineProperties(this, {
position: {
configurable: !0,
enumerable: !0,
value: t
},
rotation: {
configurable: !0,
enumerable: !0,
value: e
},
quaternion: {
configurable: !0,
enumerable: !0,
value: n
},
scale: {
configurable: !0,
enumerable: !0,
value: i
},
modelViewMatrix: {
value: new et
},
normalMatrix: {
value: new y
}
}), this.matrix = new et, this.matrixWorld = new et, this.matrixAutoUpdate = St.DefaultMatrixAutoUpdate, this.matrixWorldNeedsUpdate = !1, this.layers = new dt, this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {}
}
St.DefaultUp = new T(0, 1, 0), St.DefaultMatrixAutoUpdate = !0, St.prototype = Object.assign(Object.create(p.prototype), {
constructor: St,
isObject3D: !0,
onBeforeRender: function() {},
onAfterRender: function() {},
applyMatrix4: function(t) {
this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(t), this.matrix.decompose(this.position, this.quaternion, this.scale)
},
applyQuaternion: function(t) {
return this.quaternion.premultiply(t), this
},
setRotationFromAxisAngle: function(t, e) {
this.quaternion.setFromAxisAngle(t, e)
},
setRotationFromEuler: function(t) {
this.quaternion.setFromEuler(t, !0)
},
setRotationFromMatrix: function(t) {
this.quaternion.setFromRotationMatrix(t)
},
setRotationFromQuaternion: function(t) {
this.quaternion.copy(t)
},
rotateOnAxis: function(t, e) {
return mt.setFromAxisAngle(t, e), this.quaternion.multiply(mt), this
},
rotateOnWorldAxis: function(t, e) {
return mt.setFromAxisAngle(t, e), this.quaternion.premultiply(mt), this
},
rotateX: function(t) {
return this.rotateOnAxis(_t, t)
},
rotateY: function(t) {
return this.rotateOnAxis(bt, t)
},
rotateZ: function(t) {
return this.rotateOnAxis(wt, t)
},
translateOnAxis: function(t, e) {
return ft.copy(t).applyQuaternion(this.quaternion), this.position.add(ft.multiplyScalar(e)), this
},
translateX: function(t) {
return this.translateOnAxis(_t, t)
},
translateY: function(t) {
return this.translateOnAxis(bt, t)
},
translateZ: function(t) {
return this.translateOnAxis(wt, t)
},
localToWorld: function(t) {
return t.applyMatrix4(this.matrixWorld)
},
worldToLocal: function(t) {
return t.applyMatrix4(gt.copy(this.matrixWorld).invert())
},
lookAt: function(t, e, n) {
t.isVector3 ? vt.copy(t) : vt.set(t, e, n);
const i = this.parent;
this.updateWorldMatrix(!0, !1), yt.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? gt.lookAt(yt, vt, this.up) : gt.lookAt(vt, yt, this.up), this.quaternion.setFromRotationMatrix(gt), i && (gt.extractRotation(i.matrixWorld), mt.setFromRotationMatrix(gt), this.quaternion.premultiply(mt.invert()))
},
add: function(t) {
if (arguments.length > 1) {
for (let t = 0; t < arguments.length; t++) this.add(arguments[t]);
return this
}
return t === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", t), this) : (t && t.isObject3D ? (null !== t.parent && t.parent.remove(t), t.parent = this, this.children.push(t), t.dispatchEvent(Mt)) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", t), this)
},
remove: function(t) {
if (arguments.length > 1) {
for (let t = 0; t < arguments.length; t++) this.remove(arguments[t]);
return this
}
const e = this.children.indexOf(t);
return -1 !== e && (t.parent = null, this.children.splice(e, 1), t.dispatchEvent(Et)), this
},
clear: function() {
for (let t = 0; t < this.children.length; t++) {
const e = this.children[t];
e.parent = null, e.dispatchEvent(Et)
}
return this.children.length = 0, this
},
attach: function(t) {
return this.updateWorldMatrix(!0, !1), gt.copy(this.matrixWorld).invert(), null !== t.parent && (t.parent.updateWorldMatrix(!0, !1), gt.multiply(t.parent.matrixWorld)), t.applyMatrix4(gt), t.updateWorldMatrix(!1, !1), this.add(t), this
},
getObjectById: function(t) {
return this.getObjectByProperty("id", t)
},
getObjectByName: function(t) {
return this.getObjectByProperty("name", t)
},
getObjectByProperty: function(t, e) {
if (this[t] === e) return this;
for (let n = 0, i = this.children.length; n < i; n++) {
const i = this.children[n].getObjectByProperty(t, e);
if (void 0 !== i) return i
}
},
getWorldPosition: function(t) {
return void 0 === t && (console.warn("THREE.Object3D: .getWorldPosition() target is now required"), t = new T), this.updateWorldMatrix(!0, !1), t.setFromMatrixPosition(this.matrixWorld)
},
getWorldQuaternion: function(t) {
return void 0 === t && (console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"), t = new S), this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(yt, t, At), t
},
getWorldScale: function(t) {
return void 0 === t && (console.warn("THREE.Object3D: .getWorldScale() target is now required"), t = new T), this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(yt, xt, t), t
},
getWorldDirection: function(t) {
void 0 === t && (console.warn("THREE.Object3D: .getWorldDirection() target is now required"), t = new T), this.updateWorldMatrix(!0, !1);
const e = this.matrixWorld.elements;
return t.set(e[8], e[9], e[10]).normalize()
},
raycast: function() {},
traverse: function(t) {
t(this);
const e = this.children;
for (let n = 0, i = e.length; n < i; n++) e[n].traverse(t)
},
traverseVisible: function(t) {
if (!1 === this.visible) return;
t(this);
const e = this.children;
for (let n = 0, i = e.length; n < i; n++) e[n].traverseVisible(t)
},
traverseAncestors: function(t) {
const e = this.parent;
null !== e && (t(e), e.traverseAncestors(t))
},
updateMatrix: function() {
this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0
},
updateMatrixWorld: function(t) {
this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || t) && (null === this.parent ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, t = !0);
const e = this.children;
for (let n = 0, i = e.length; n < i; n++) e[n].updateMatrixWorld(t)
},
updateWorldMatrix: function(t, e) {
const n = this.parent;
if (!0 === t && null !== n && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), null === this.parent ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), !0 === e) {
const t = this.children;
for (let e = 0, n = t.length; e < n; e++) t[e].updateWorldMatrix(!1, !0)
}
},
toJSON: function(t) {
const e = void 0 === t || "string" == typeof t,
n = {};
e && (t = {
geometries: {},
materials: {},
textures: {},
images: {},
shapes: {},
skeletons: {},
animations: {}
}, n.metadata = {
version: 4.5,
type: "Object",
generator: "Object3D.toJSON"
});
const i = {};
function r(e, n) {
return void 0 === e[n.uuid] && (e[n.uuid] = n.toJSON(t)), n.uuid
}
if (i.uuid = this.uuid, i.type = this.type, "" !== this.name && (i.name = this.name), !0 === this.castShadow && (i.castShadow = !0), !0 === this.receiveShadow && (i.receiveShadow = !0), !1 === this.visible && (i.visible = !1), !1 === this.frustumCulled && (i.frustumCulled = !1), 0 !== this.renderOrder && (i.renderOrder = this.renderOrder), "{}" !== JSON.stringify(this.userData) && (i.userData = this.userData), i.layers = this.layers.mask, i.matrix = this.matrix.toArray(), !1 === this.matrixAutoUpdate && (i.matrixAutoUpdate = !1), this.isInstancedMesh && (i.type = "InstancedMesh", i.count = this.count, i.instanceMatrix = this.instanceMatrix.toJSON()), this.isMesh || this.isLine || this.isPoints) {
i.geometry = r(t.geometries, this.geometry);
const e = this.geometry.parameters;
if (void 0 !== e && void 0 !== e.shapes) {
const n = e.shapes;
if (Array.isArray(n))
for (let e = 0, i = n.length; e < i; e++) {
const i = n[e];
r(t.shapes, i)
} else r(t.shapes, n)
}
}
if (this.isSkinnedMesh && (i.bindMode = this.bindMode, i.bindMatrix = this.bindMatrix.toArray(), void 0 !== this.skeleton && (r(t.skeletons, this.skeleton), i.skeleton = this.skeleton.uuid)), void 0 !== this.material)
if (Array.isArray(this.material)) {
const e = [];
for (let n = 0, i = this.material.length; n < i; n++) e.push(r(t.materials, this.material[n]));
i.material = e
} else i.material = r(t.materials, this.material);
if (this.children.length > 0) {
i.children = [];
for (let e = 0; e < this.children.length; e++) i.children.push(this.children[e].toJSON(t).object)
}
if (this.animations.length > 0) {
i.animations = [];
for (let e = 0; e < this.animations.length; e++) {
const n = this.animations[e];
i.animations.push(r(t.animations, n))
}
}
if (e) {
const e = o(t.geometries),
i = o(t.materials),
r = o(t.textures),
s = o(t.images),
a = o(t.shapes),
l = o(t.skeletons),
c = o(t.animations);
e.length > 0 && (n.geometries = e), i.length > 0 && (n.materials = i), r.length > 0 && (n.textures = r), s.length > 0 && (n.images = s), a.length > 0 && (n.shapes = a), l.length > 0 && (n.skeletons = l), c.length > 0 && (n.animations = c)
}
return n.object = i, n;
function o(t) {
const e = [];
for (const n in t) {
const i = t[n];
delete i.metadata, e.push(i)
}
return e
}
},
clone: function(t) {
return (new this.constructor).copy(this, t)
},
copy: function(t, e = !0) {
if (this.name = t.name, this.up.copy(t.up), this.position.copy(t.position), this.rotation.order = t.rotation.order, this.quaternion.copy(t.quaternion), this.scale.copy(t.scale), this.matrix.copy(t.matrix), this.matrixWorld.copy(t.matrixWorld), this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrixWorldNeedsUpdate = t.matrixWorldNeedsUpdate, this.layers.mask = t.layers.mask, this.visible = t.visible, this.castShadow = t.castShadow, this.receiveShadow = t.receiveShadow, this.frustumCulled = t.frustumCulled, this.renderOrder = t.renderOrder, this.userData = JSON.parse(JSON.stringify(t.userData)), !0 === e)
for (let e = 0; e < t.children.length; e++) {
const n = t.children[e];
this.add(n.clone())
}
return this
}
});
const Tt = new T,
Lt = new T,
Rt = new y;
class Ct {
constructor(t, e) {
Object.defineProperty(this, "isPlane", {
value: !0
}), this.normal = void 0 !== t ? t : new T(1, 0, 0), this.constant = void 0 !== e ? e : 0
}
set(t, e) {
return this.normal.copy(t), this.constant = e, this
}
setComponents(t, e, n, i) {
return this.normal.set(t, e, n), this.constant = i, this
}
setFromNormalAndCoplanarPoint(t, e) {
return this.normal.copy(t), this.constant = -e.dot(this.normal), this
}
setFromCoplanarPoints(t, e, n) {
const i = Tt.subVectors(n, e).cross(Lt.subVectors(t, e)).normalize();
return this.setFromNormalAndCoplanarPoint(i, t), this
}
clone() {
return (new this.constructor).copy(this)
}
copy(t) {
return this.normal.copy(t.normal), this.constant = t.constant, this
}
normalize() {
const t = 1 / this.normal.length();
return this.normal.multiplyScalar(t), this.constant *= t, this
}
negate() {
return this.constant *= -1, this.normal.negate(), this
}
distanceToPoint(t) {
return this.normal.dot(t) + this.constant
}
distanceToSphere(t) {
return this.distanceToPoint(t.center) - t.radius
}
projectPoint(t, e) {
return void 0 === e && (console.warn("THREE.Plane: .projectPoint() target is now required"), e = new T), e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)
}
intersectLine(t, e) {
void 0 === e && (console.warn("THREE.Plane: .intersectLine() target is now required"), e = new T);
const n = t.delta(Tt),
i = this.normal.dot(n);
if (0 === i) return 0 === this.distanceToPoint(t.start) ? e.copy(t.start) : void 0;
const r = -(t.start.dot(this.normal) + this.constant) / i;
return r < 0 || r > 1 ? void 0 : e.copy(n).multiplyScalar(r).add(t.start)
}
intersectsLine(t) {
const e = this.distanceToPoint(t.start),
n = this.distanceToPoint(t.end);
return e < 0 && n > 0 || n < 0 && e > 0
}
intersectsBox(t) {
return t.intersectsPlane(this)
}
intersectsSphere(t) {
return t.intersectsPlane(this)
}
coplanarPoint(t) {
return void 0 === t && (console.warn("THREE.Plane: .coplanarPoint() target is now required"), t = new T), t.copy(this.normal).multiplyScalar(-this.constant)
}
applyMatrix4(t, e) {
const n = e || Rt.getNormalMatrix(t),
i = this.coplanarPoint(Tt).applyMatrix4(t),
r = this.normal.applyMatrix3(n).normalize();
return this.constant = -i.dot(r), this
}
translate(t) {
return this.constant -= t.dot(this.normal), this
}
equals(t) {
return t.normal.equals(this.normal) && t.constant === this.constant
}
}
const Pt = new T,
Dt = new T,
It = new T,
Ot = new T,
Nt = new T,
Bt = new T,
Ft = new T,
zt = new T,
Ut = new T,
Ht = new T;
class Gt {
constructor(t, e, n) {
this.a = void 0 !== t ? t : new T, this.b = void 0 !== e ? e : new T, this.c = void 0 !== n ? n : new T
}
static getNormal(t, e, n, i) {
void 0 === i && (console.warn("THREE.Triangle: .getNormal() target is now required"), i = new T), i.subVectors(n, e), Pt.subVectors(t, e), i.cross(Pt);
const r = i.lengthSq();
return r > 0 ? i.multiplyScalar(1 / Math.sqrt(r)) : i.set(0, 0, 0)
}
static getBarycoord(t, e, n, i, r) {
Pt.subVectors(i, e), Dt.subVectors(n, e), It.subVectors(t, e);
const o = Pt.dot(Pt),
s = Pt.dot(Dt),
a = Pt.dot(It),
l = Dt.dot(Dt),
c = Dt.dot(It),
h = o * l - s * s;
if (void 0 === r && (console.warn("THREE.Triangle: .getBarycoord() target is now required"), r = new T), 0 === h) return r.set(-2, -1, -1);
const u = 1 / h,
d = (l * a - s * c) * u,
p = (o * c - s * a) * u;
return r.set(1 - d - p, p, d)
}
static containsPoint(t, e, n, i) {
return this.getBarycoord(t, e, n, i, Ot), Ot.x >= 0 && Ot.y >= 0 && Ot.x + Ot.y <= 1
}
static getUV(t, e, n, i, r, o, s, a) {
return this.getBarycoord(t, e, n, i, Ot), a.set(0, 0), a.addScaledVector(r, Ot.x), a.addScaledVector(o, Ot.y), a.addScaledVector(s, Ot.z), a
}
static isFrontFacing(t, e, n, i) {
return Pt.subVectors(n, e), Dt.subVectors(t, e), Pt.cross(Dt).dot(i) < 0
}
set(t, e, n) {
return this.a.copy(t), this.b.copy(e), this.c.copy(n), this
}
setFromPointsAndIndices(t, e, n, i) {
return this.a.copy(t[e]), this.b.copy(t[n]), this.c.copy(t[i]), this
}
clone() {
return (new this.constructor).copy(this)
}
copy(t) {
return this.a.copy(t.a), this.b.copy(t.b), this.c.copy(t.c), this
}
getArea() {
return Pt.subVectors(this.c, this.b), Dt.subVectors(this.a, this.b), .5 * Pt.cross(Dt).length()
}
getMidpoint(t) {
return void 0 === t && (console.warn("THREE.Triangle: .getMidpoint() target is now required"), t = new T), t.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3)
}
getNormal(t) {
return Gt.getNormal(this.a, this.b, this.c, t)
}
getPlane(t) {
return void 0 === t && (console.warn("THREE.Triangle: .getPlane() target is now required"), t = new Ct), t.setFromCoplanarPoints(this.a, this.b, this.c)
}
getBarycoord(t, e) {
return Gt.getBarycoord(t, this.a, this.b, this.c, e)
}
getUV(t, e, n, i, r) {
return Gt.getUV(t, this.a, this.b, this.c, e, n, i, r)
}
containsPoint(t) {
return Gt.containsPoint(t, this.a, this.b, this.c)
}
isFrontFacing(t) {
return Gt.isFrontFacing(this.a, this.b, this.c, t)
}
intersectsBox(t) {
return t.intersectsTriangle(this)
}
closestPointToPoint(t, e) {
void 0 === e && (console.warn("THREE.Triangle: .closestPointToPoint() target is now required"), e = new T);
const n = this.a,
i = this.b,
r = this.c;
let o, s;
Nt.subVectors(i, n), Bt.subVectors(r, n), zt.subVectors(t, n);
const a = Nt.dot(zt),
l = Bt.dot(zt);
if (a <= 0 && l <= 0) return e.copy(n);
Ut.subVectors(t, i);
const c = Nt.dot(Ut),
h = Bt.dot(Ut);
if (c >= 0 && h <= c) return e.copy(i);
const u = a * h - c * l;
if (u <= 0 && a >= 0 && c <= 0) return o = a / (a - c), e.copy(n).addScaledVector(Nt, o);
Ht.subVectors(t, r);
const d = Nt.dot(Ht),
p = Bt.dot(Ht);
if (p >= 0 && d <= p) return e.copy(r);
const f = d * l - a * p;
if (f <= 0 && l >= 0 && p <= 0) return s = l / (l - p), e.copy(n).addScaledVector(Bt, s);
const m = c * p - d * h;
if (m <= 0 && h - c >= 0 && d - p >= 0) return Ft.subVectors(r, i), s = (h - c) / (h - c + (d - p)), e.copy(i).addScaledVector(Ft, s);
const g = 1 / (m + f + u);
return o = f * g, s = u * g, e.copy(n).addScaledVector(Nt, o).addScaledVector(Bt, s)
}
equals(t) {
return t.a.equals(this.a) && t.b.equals(this.b) && t.c.equals(this.c)
}
}
const Vt = {
aliceblue: 15792383,
antiquewhite: 16444375,
aqua: 65535,
aquamarine: 8388564,
azure: 15794175,
beige: 16119260,
bisque: 16770244,
black: 0,
blanchedalmond: 16772045,
blue: 255,
blueviolet: 9055202,
brown: 10824234,
burlywood: 14596231,
cadetblue: 6266528,
chartreuse: 8388352,
chocolate: 13789470,
coral: 16744272,
cornflowerblue: 6591981,
cornsilk: 16775388,
crimson: 14423100,
cyan: 65535,
darkblue: 139,
darkcyan: 35723,
darkgoldenrod: 12092939,
darkgray: 11119017,
darkgreen: 25600,
darkgrey: 11119017,
darkkhaki: 12433259,
darkmagenta: 9109643,
darkolivegreen: 5597999,
darkorange: 16747520,
darkorchid: 10040012,
darkred: 9109504,
darksalmon: 15308410,
darkseagreen: 9419919,
darkslateblue: 4734347,
darkslategray: 3100495,
darkslategrey: 3100495,
darkturquoise: 52945,
darkviolet: 9699539,
deeppink: 16716947,
deepskyblue: 49151,
dimgray: 6908265,
dimgrey: 6908265,
dodgerblue: 2003199,
firebrick: 11674146,
floralwhite: 16775920,
forestgreen: 2263842,
fuchsia: 16711935,
gainsboro: 14474460,
ghostwhite: 16316671,
gold: 16766720,
goldenrod: 14329120,
gray: 8421504,
green: 32768,
greenyellow: 11403055,
grey: 8421504,
honeydew: 15794160,
hotpink: 16738740,
indianred: 13458524,
indigo: 4915330,
ivory: 16777200,
khaki: 15787660,
lavender: 15132410,
lavenderblush: 16773365,
lawngreen: 8190976,
lemonchiffon: 16775885,
lightblue: 11393254,
lightcoral: 15761536,
lightcyan: 14745599,
lightgoldenrodyellow: 16448210,
lightgray: 13882323,
lightgreen: 9498256,
lightgrey: 13882323,
lightpink: 16758465,
lightsalmon: 16752762,
lightseagreen: 2142890,
lightskyblue: 8900346,
lightslategray: 7833753,
lightslategrey: 7833753,
lightsteelblue: 11584734,
lightyellow: 16777184,
lime: 65280,
limegreen: 3329330,
linen: 16445670,
magenta: 16711935,
maroon: 8388608,
mediumaquamarine: 6737322,
mediumblue: 205,
mediumorchid: 12211667,
mediumpurple: 9662683,
mediumseagreen: 3978097,
mediumslateblue: 8087790,
mediumspringgreen: 64154,
mediumturquoise: 4772300,
mediumvioletred: 13047173,
midnightblue: 1644912,
mintcream: 16121850,
mistyrose: 16770273,
moccasin: 16770229,
navajowhite: 16768685,
navy: 128,
oldlace: 16643558,
olive: 8421376,
olivedrab: 7048739,
orange: 16753920,
orangered: 16729344,
orchid: 14315734,
palegoldenrod: 15657130,
palegreen: 10025880,
paleturquoise: 11529966,
palevioletred: 14381203,
papayawhip: 16773077,
peachpuff: 16767673,
peru: 13468991,
pink: 16761035,
plum: 14524637,
powderblue: 11591910,
purple: 8388736,
rebeccapurple: 6697881,
red: 16711680,
rosybrown: 12357519,
royalblue: 4286945,
saddlebrown: 9127187,
salmon: 16416882,
sandybrown: 16032864,
seagreen: 3050327,
seashell: 16774638,
sienna: 10506797,
silver: 12632256,
skyblue: 8900331,
slateblue: 6970061,
slategray: 7372944,
slategrey: 7372944,
snow: 16775930,
springgreen: 65407,
steelblue: 4620980,
tan: 13808780,
teal: 32896,
thistle: 14204888,
tomato: 16737095,
turquoise: 4251856,
violet: 15631086,
wheat: 16113331,
white: 16777215,
whitesmoke: 16119285,
yellow: 16776960,
yellowgreen: 10145074
},
kt = {
h: 0,
s: 0,
l: 0
},
Wt = {
h: 0,
s: 0,
l: 0
};
function jt(t, e, n) {
return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? t + 6 * (e - t) * n : n < .5 ? e : n < 2 / 3 ? t + 6 * (e - t) * (2 / 3 - n) : t
}
function Xt(t) {
return t < .04045 ? .0773993808 * t : Math.pow(.9478672986 * t + .0521327014, 2.4)
}
function qt(t) {
return t < .0031308 ? 12.92 * t : 1.055 * Math.pow(t, .41666) - .055
}
class Yt {
constructor(t, e, n) {
return Object.defineProperty(this, "isColor", {
value: !0
}), void 0 === e && void 0 === n ? this.set(t) : this.setRGB(t, e, n)
}
set(t) {
return t && t.isColor ? this.copy(t) : "number" == typeof t ? this.setHex(t) : "string" == typeof t && this.setStyle(t), this
}
setScalar(t) {
return this.r = t, this.g = t, this.b = t, this
}
setHex(t) {
return t = Math.floor(t), this.r = (t >> 16 & 255) / 255, this.g = (t >> 8 & 255) / 255, this.b = (255 & t) / 255, this
}
setRGB(t, e, n) {
return this.r = t, this.g = e, this.b = n, this
}
setHSL(t, e, n) {
if (t = g.euclideanModulo(t, 1), e = g.clamp(e, 0, 1), n = g.clamp(n, 0, 1), 0 === e) this.r = this.g = this.b = n;
else {
const i = n <= .5 ? n * (1 + e) : n + e - n * e,
r = 2 * n - i;
this.r = jt(r, i, t + 1 / 3), this.g = jt(r, i, t), this.b = jt(r, i, t - 1 / 3)
}
return this
}
setStyle(t) {
function e(e) {
void 0 !== e && parseFloat(e) < 1 && console.warn("THREE.Color: Alpha component of " + t + " will be ignored.")
}
let n;
if (n = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)) {
let t;
const i = n[1],
r = n[2];
switch (i) {
case "rgb":
case "rgba":
if (t = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)) return this.r = Math.min(255, parseInt(t[1], 10)) / 255, this.g = Math.min(255, parseInt(t[2], 10)) / 255, this.b = Math.min(255, parseInt(t[3], 10)) / 255, e(t[4]), this;
if (t = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)) return this.r = Math.min(100, parseInt(t[1], 10)) / 100, this.g = Math.min(100, parseInt(t[2], 10)) / 100, this.b = Math.min(100, parseInt(t[3], 10)) / 100, e(t[4]), this;
break;
case "hsl":
case "hsla":
if (t = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)) {
const n = parseFloat(t[1]) / 360,
i = parseInt(t[2], 10) / 100,
r = parseInt(t[3], 10) / 100;
return e(t[4]), this.setHSL(n, i, r)
}
}
} else if (n = /^\#([A-Fa-f\d]+)$/.exec(t)) {
const t = n[1],
e = t.length;
if (3 === e) return this.r = parseInt(t.charAt(0) + t.charAt(0), 16) / 255, this.g = parseInt(t.charAt(1) + t.charAt(1), 16) / 255, this.b = parseInt(t.charAt(2) + t.charAt(2), 16) / 255, this;
if (6 === e) return this.r = parseInt(t.charAt(0) + t.charAt(1), 16) / 255, this.g = parseInt(t.charAt(2) + t.charAt(3), 16) / 255, this.b = parseInt(t.charAt(4) + t.charAt(5), 16) / 255, this
}
return t && t.length > 0 ? this.setColorName(t) : this
}
setColorName(t) {
const e = Vt[t];
return void 0 !== e ? this.setHex(e) : console.warn("THREE.Color: Unknown color " + t), this
}
clone() {
return new this.constructor(this.r, this.g, this.b)
}
copy(t) {
return this.r = t.r, this.g = t.g, this.b = t.b, this
}
copyGammaToLinear(t, e = 2) {
return this.r = Math.pow(t.r, e), this.g = Math.pow(t.g, e), this.b = Math.pow(t.b, e), this
}
copyLinearToGamma(t, e = 2) {
const n = e > 0 ? 1 / e : 1;
return this.r = Math.pow(t.r, n), this.g = Math.pow(t.g, n), this.b = Math.pow(t.b, n), this
}
convertGammaToLinear(t) {
return this.copyGammaToLinear(this, t), this
}
convertLinearToGamma(t) {
return this.copyLinearToGamma(this, t), this
}
copySRGBToLinear(t) {
return this.r = Xt(t.r), this.g = Xt(t.g), this.b = Xt(t.b), this
}
copyLinearToSRGB(t) {
return this.r = qt(t.r), this.g = qt(t.g), this.b = qt(t.b), this
}
convertSRGBToLinear() {
return this.copySRGBToLinear(this), this
}
convertLinearToSRGB() {
return this.copyLinearToSRGB(this), this
}
getHex() {
return 255 * this.r << 16 ^ 255 * this.g << 8 ^ 255 * this.b << 0
}
getHexString() {
return ("000000" + this.getHex().toString(16)).slice(-6)
}
getHSL(t) {
void 0 === t && (console.warn("THREE.Color: .getHSL() target is now required"), t = {
h: 0,
s: 0,
l: 0
});
const e = this.r,
n = this.g,
i = this.b,
r = Math.max(e, n, i),
o = Math.min(e, n, i);
let s, a;
const l = (o + r) / 2;
if (o === r) s = 0, a = 0;
else {
const t = r - o;
switch (a = l <= .5 ? t / (r + o) : t / (2 - r - o), r) {
case e:
s = (n - i) / t + (n < i ? 6 : 0);
break;
case n:
s = (i - e) / t + 2;
break;
case i:
s = (e - n) / t + 4
}
s /= 6
}
return t.h = s, t.s = a, t.l = l, t
}
getStyle() {
return "rgb(" + (255 * this.r | 0) + "," + (255 * this.g | 0) + "," + (255 * this.b | 0) + ")"
}
offsetHSL(t, e, n) {
return this.getHSL(kt), kt.h += t, kt.s += e, kt.l += n, this.setHSL(kt.h, kt.s, kt.l), this
}
add(t) {
return this.r += t.r, this.g += t.g, this.b += t.b, this
}
addColors(t, e) {
return this.r = t.r + e.r, this.g = t.g + e.g, this.b = t.b + e.b, this
}
addScalar(t) {
return this.r += t, this.g += t, this.b += t, this
}
sub(t) {
return this.r = Math.max(0, this.r - t.r), this.g = Math.max(0, this.g - t.g), this.b = Math.max(0, this.b - t.b), this
}
multiply(t) {
return this.r *= t.r, this.g *= t.g, this.b *= t.b, this
}
multiplyScalar(t) {
return this.r *= t, this.g *= t, this.b *= t, this
}
lerp(t, e) {
return this.r += (t.r - this.r) * e, this.g += (t.g - this.g) * e, this.b += (t.b - this.b) * e, this
}
lerpColors(t, e, n) {
return this.r = t.r + (e.r - t.r) * n, this.g = t.g + (e.g - t.g) * n, this.b = t.b + (e.b - t.b) * n, this
}
lerpHSL(t, e) {
this.getHSL(kt), t.getHSL(Wt);
const n = g.lerp(kt.h, Wt.h, e),
i = g.lerp(kt.s, Wt.s, e),
r = g.lerp(kt.l, Wt.l, e);
return this.setHSL(n, i, r), this
}
equals(t) {
return t.r === this.r && t.g === this.g && t.b === this.b
}
fromArray(t, e = 0) {
return this.r = t[e], this.g = t[e + 1], this.b = t[e + 2], this
}
toArray(t = [], e = 0) {
return t[e] = this.r, t[e + 1] = this.g, t[e + 2] = this.b, t
}
fromBufferAttribute(t, e) {
return this.r = t.getX(e), this.g = t.getY(e), this.b = t.getZ(e), !0 === t.normalized && (this.r /= 255, this.g /= 255, this.b /= 255), this
}
toJSON() {
return this.getHex()
}
}
Yt.NAMES = Vt, Yt.prototype.r = 1, Yt.prototype.g = 1, Yt.prototype.b = 1;
class Qt {
constructor(t, e, n, i, r, o = 0) {
this.a = t, this.b = e, this.c = n, this.normal = i && i.isVector3 ? i : new T, this.vertexNormals = Array.isArray(i) ? i : [], this.color = r && r.isColor ? r : new Yt, this.vertexColors = Array.isArray(r) ? r : [], this.materialIndex = o
}
clone() {
return (new this.constructor).copy(this)
}
copy(t) {
this.a = t.a, this.b = t.b, this.c = t.c, this.normal.copy(t.normal), this.color.copy(t.color), this.materialIndex = t.materialIndex;
for (let e = 0, n = t.vertexNormals.length; e < n; e++) this.vertexNormals[e] = t.vertexNormals[e].clone();
for (let e = 0, n = t.vertexColors.length; e < n; e++) this.vertexColors[e] = t.vertexColors[e].clone();
return this
}
}
let Zt = 0;
function Jt() {
Object.defineProperty(this, "id", {
value: Zt++
}), this.uuid = g.generateUUID(), this.name = "", this.type = "Material", this.fog = !0, this.blending = 1, this.side = 0, this.flatShading = !1, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.blendSrc = 204, this.blendDst = 205, this.blendEquation = 100, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.depthFunc = 3, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = 519, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = 7680, this.stencilZFail = 7680, this.stencilZPass = 7680, this.stencilWrite = !1, this.clippingPlanes = null, this.clipIntersection = !1, this.clipShadows = !1, this.shadowSide = null, this.colorWrite = !0, this.precision = null, this.polygonOffset = !1, this.polygonOffsetFactor = 0, this.polygonOffsetUnits = 0, this.dithering = !1, this.alphaTest = 0, this.premultipliedAlpha = !1, this.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0
}
function Kt(t) {
Jt.call(this), this.type = "MeshBasicMaterial", this.color = new Yt(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.combine = 0, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.skinning = !1, this.morphTargets = !1, this.setValues(t)
}
Jt.prototype = Object.assign(Object.create(p.prototype), {
constructor: Jt,
isMaterial: !0,
onBeforeCompile: function() {},
customProgramCacheKey: function() {
return this.onBeforeCompile.toString()
},
setValues: function(t) {
if (void 0 !== t)
for (const e in t) {
const n = t[e];
if (void 0 === n) {
console.warn("THREE.Material: '" + e + "' parameter is undefined.");
continue
}
if ("shading" === e) {
console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."), this.flatShading = 1 === n;
continue
}
const i = this[e];
void 0 !== i ? i && i.isColor ? i.set(n) : i && i.isVector3 && n && n.isVector3 ? i.copy(n) : this[e] = n : console.warn("THREE." + this.type + ": '" + e + "' is not a property of this material.")
}
},
toJSON: function(t) {
const e = void 0 === t || "string" == typeof t;
e && (t = {
textures: {},
images: {}
});
const n = {
metadata: {
version: 4.5,
type: "Material",
generator: "Material.toJSON"
}
};
function i(t) {
const e = [];
for (const n in t) {
const i = t[n];
delete i.metadata, e.push(i)
}
return e
}
if (n.uuid = this.uuid, n.type = this.type, "" !== this.name && (n.name = this.name), this.color && this.color.isColor && (n.color = this.color.getHex()), void 0 !== this.roughness && (n.roughness = this.roughness), void 0 !== this.metalness && (n.metalness = this.metalness), this.sheen && this.sheen.isColor && (n.sheen = this.sheen.getHex()), this.emissive && this.emissive.isColor && (n.emissive = this.emissive.getHex()), this.emissiveIntensity && 1 !== this.emissiveIntensity && (n.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (n.specular = this.specular.getHex()), void 0 !== this.shininess && (n.shininess = this.shininess), void 0 !== this.clearcoat && (n.clearcoat = this.clearcoat), void 0 !== this.clearcoatRoughness && (n.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (n.clearcoatMap = this.clearcoatMap.toJSON(t).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(t).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(t).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.map && this.map.isTexture && (n.map = this.map.toJSON(t).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(t).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(t).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(t).uuid), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(t).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(t).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(t).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(t).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(t).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(t).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(t).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(t).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(t).uuid, n.reflectivity = this.reflectivity, n.refractionRatio = this.refractionRatio, void 0 !== this.combine && (n.combine = this.combine), void 0 !== this.envMapIntensity && (n.envMapIntensity = this.envMapIntensity)), this.gradientMap && this.gradientMap.isTexture && (n.gradientMap = this.gradientMap.toJSON(t).uuid), void 0 !== this.size && (n.size = this.size), void 0 !== this.sizeAttenuation && (n.sizeAttenuation = this.sizeAttenuation), 1 !== this.blending && (n.blending = this.blending), !0 === this.flatShading && (n.flatShading = this.flatShading), 0 !== this.side && (n.side = this.side), this.vertexColors && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), !0 === this.transparent && (n.transparent = this.transparent), n.depthFunc = this.depthFunc, n.depthTest = this.depthTest, n.depthWrite = this.depthWrite, n.stencilWrite = this.stencilWrite, n.stencilWriteMask = this.stencilWriteMask, n.stencilFunc = this.stencilFunc, n.stencilRef = this.stencilRef, n.stencilFuncMask = this.stencilFuncMask, n.stencilFail = this.stencilFail, n.stencilZFail = this.stencilZFail, n.stencilZPass = this.stencilZPass, this.rotation && 0 !== this.rotation && (n.rotation = this.rotation), !0 === this.polygonOffset && (n.polygonOffset = !0), 0 !== this.polygonOffsetFactor && (n.polygonOffsetFactor = this.polygonOffsetFactor), 0 !== this.polygonOffsetUnits && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth && 1 !== this.linewidth && (n.linewidth = this.linewidth), void 0 !== this.dashSize && (n.dashSize = this.dashSize), void 0 !== this.gapSize && (n.gapSize = this.gapSize), void 0 !== this.scale && (n.scale = this.scale), !0 === this.dithering && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), !0 === this.premultipliedAlpha && (n.premultipliedAlpha = this.premultipliedAlpha), !0 === this.wireframe && (n.wireframe = this.wireframe), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), "round" !== this.wireframeLinecap && (n.wireframeLinecap = this.wireframeLinecap), "round" !== this.wireframeLinejoin && (n.wireframeLinejoin = this.wireframeLinejoin), !0 === this.morphTargets && (n.morphTargets = !0), !0 === this.morphNormals && (n.morphNormals = !0), !0 === this.skinning && (n.skinning = !0), !1 === this.visible && (n.visible = !1), !1 === this.toneMapped && (n.toneMapped = !1), "{}" !== JSON.stringify(this.userData) && (n.userData = this.userData), e) {
const e = i(t.textures),
r = i(t.images);
e.length > 0 && (n.textures = e), r.length > 0 && (n.images = r)
}
return n
},
clone: function() {
return (new this.constructor).copy(this)
},
copy: function(t) {
this.name = t.name, this.fog = t.fog, this.blending = t.blending, this.side = t.side, this.flatShading = t.flatShading, this.vertexColors = t.vertexColors, this.opacity = t.opacity, this.transparent = t.transparent, this.blendSrc = t.blendSrc, this.blendDst = t.blendDst, this.blendEquation = t.blendEquation, this.blendSrcAlpha = t.blendSrcAlpha, this.blendDstAlpha = t.blendDstAlpha, this.blendEquationAlpha = t.blendEquationAlpha, this.depthFunc = t.depthFunc, this.depthTest = t.depthTest, this.depthWrite = t.depthWrite, this.stencilWriteMask = t.stencilWriteMask, this.stencilFunc = t.stencilFunc, this.stencilRef = t.stencilRef, this.stencilFuncMask = t.stencilFuncMask, this.stencilFail = t.stencilFail, this.stencilZFail = t.stencilZFail, this.stencilZPass = t.stencilZPass, this.stencilWrite = t.stencilWrite;
const e = t.clippingPlanes;
let n = null;
if (null !== e) {
const t = e.length;
n = new Array(t);
for (let i = 0; i !== t; ++i) n[i] = e[i].clone()
}
return this.clippingPlanes = n, this.clipIntersection = t.clipIntersection, this.clipShadows = t.clipShadows, this.shadowSide = t.shadowSide, this.colorWrite = t.colorWrite, this.precision = t.precision, this.polygonOffset = t.polygonOffset, this.polygonOffsetFactor = t.polygonOffsetFactor, this.polygonOffsetUnits = t.polygonOffsetUnits, this.dithering = t.dithering, this.alphaTest = t.alphaTest, this.premultipliedAlpha = t.premultipliedAlpha, this.visible = t.visible, this.toneMapped = t.toneMapped, this.userData = JSON.parse(JSON.stringify(t.userData)), this
},
dispose: function() {
this.dispatchEvent({
type: "dispose"
})
}
}), Object.defineProperty(Jt.prototype, "needsUpdate", {
set: function(t) {
!0 === t && this.version++
}
}), Kt.prototype = Object.create(Jt.prototype), Kt.prototype.constructor = Kt, Kt.prototype.isMeshBasicMaterial = !0, Kt.prototype.copy = function(t) {
return Jt.prototype.copy.call(this, t), this.color.copy(t.color), this.map = t.map, this.lightMap = t.lightMap, this.lightMapIntensity = t.lightMapIntensity, this.aoMap = t.aoMap, this.aoMapIntensity = t.aoMapIntensity, this.specularMap = t.specularMap, this.alphaMap = t.alphaMap, this.envMap = t.envMap, this.combine = t.combine, this.reflectivity = t.reflectivity, this.refractionRatio = t.refractionRatio, this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.wireframeLinecap = t.wireframeLinecap, this.wireframeLinejoin = t.wireframeLinejoin, this.skinning = t.skinning, this.morphTargets = t.morphTargets, this
};
const $t = new T,
te = new v;
function ee(t, e, n) {
if (Array.isArray(t)) throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
this.name = "", this.array = t, this.itemSize = e, this.count = void 0 !== t ? t.length / e : 0, this.normalized = !0 === n, this.usage = 35044, this.updateRange = {
offset: 0,
count: -1
}, this.version = 0
}
function ne(t, e, n) {
ee.call(this, new Int8Array(t), e, n)
}
function ie(t, e, n) {
ee.call(this, new Uint8Array(t), e, n)
}
function re(t, e, n) {
ee.call(this, new Uint8ClampedArray(t), e, n)
}
function oe(t, e, n) {
ee.call(this, new Int16Array(t), e, n)
}
function se(t, e, n) {
ee.call(this, new Uint16Array(t), e, n)
}
function ae(t, e, n) {
ee.call(this, new Int32Array(t), e, n)
}
function le(t, e, n) {
ee.call(this, new Uint32Array(t), e, n)
}
function ce(t, e, n) {
ee.call(this, new Uint16Array(t), e, n)
}
function he(t, e, n) {
ee.call(this, new Float32Array(t), e, n)
}
function ue(t, e, n) {
ee.call(this, new Float64Array(t), e, n)
}
function de(t) {
if (0 === t.length) return -1 / 0;
let e = t[0];
for (let n = 1, i = t.length; n < i; ++n) t[n] > e && (e = t[n]);
return e
}
Object.defineProperty(ee.prototype, "needsUpdate", {
set: function(t) {
!0 === t && this.version++
}
}), Object.assign(ee.prototype, {
isBufferAttribute: !0,
onUploadCallback: function() {},
setUsage: function(t) {
return this.usage = t, this
},
copy: function(t) {
return this.name = t.name, this.array = new t.array.constructor(t.array), this.itemSize = t.itemSize, this.count = t.count, this.normalized = t.normalized, this.usage = t.usage, this
},
copyAt: function(t, e, n) {
t *= this.itemSize, n *= e.itemSize;
for (let i = 0, r = this.itemSize; i < r; i++) this.array[t + i] = e.array[n + i];
return this
},
copyArray: function(t) {
return this.array.set(t), this
},
copyColorsArray: function(t) {
const e = this.array;
let n = 0;
for (let i = 0, r = t.length; i < r; i++) {
let r = t[i];
void 0 === r && (console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined", i), r = new Yt), e[n++] = r.r, e[n++] = r.g, e[n++] = r.b
}
return this
},
copyVector2sArray: function(t) {
const e = this.array;
let n = 0;
for (let i = 0, r = t.length; i < r; i++) {
let r = t[i];
void 0 === r && (console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined", i), r = new v), e[n++] = r.x, e[n++] = r.y
}
return this
},
copyVector3sArray: function(t) {
const e = this.array;
let n = 0;
for (let i = 0, r = t.length; i < r; i++) {
let r = t[i];
void 0 === r && (console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined", i), r = new T), e[n++] = r.x, e[n++] = r.y, e[n++] = r.z
}
return this
},
copyVector4sArray: function(t) {
const e = this.array;
let n = 0;
for (let i = 0, r = t.length; i < r; i++) {
let r = t[i];
void 0 === r && (console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined", i), r = new M), e[n++] = r.x, e[n++] = r.y, e[n++] = r.z, e[n++] = r.w
}
return this
},
applyMatrix3: function(t) {
if (2 === this.itemSize)
for (let e = 0, n = this.count; e < n; e++) te.fromBufferAttribute(this, e), te.applyMatrix3(t), this.setXY(e, te.x, te.y);
else if (3 === this.itemSize)
for (let e = 0, n = this.count; e < n; e++) $t.fromBufferAttribute(this, e), $t.applyMatrix3(t), this.setXYZ(e, $t.x, $t.y, $t.z);
return this
},
applyMatrix4: function(t) {
for (let e = 0, n = this.count; e < n; e++) $t.x = this.getX(e), $t.y = this.getY(e), $t.z = this.getZ(e), $t.applyMatrix4(t), this.setXYZ(e, $t.x, $t.y, $t.z);
return this
},
applyNormalMatrix: function(t) {
for (let e = 0, n = this.count; e < n; e++) $t.x = this.getX(e), $t.y = this.getY(e), $t.z = this.getZ(e), $t.applyNormalMatrix(t), this.setXYZ(e, $t.x, $t.y, $t.z);
return this
},
transformDirection: function(t) {
for (let e = 0, n = this.count; e < n; e++) $t.x = this.getX(e), $t.y = this.getY(e), $t.z = this.getZ(e), $t.transformDirection(t), this.setXYZ(e, $t.x, $t.y, $t.z);
return this
},
set: function(t, e = 0) {
return this.array.set(t, e), this
},
getX: function(t) {
return this.array[t * this.itemSize]
},
setX: function(t, e) {
return this.array[t * this.itemSize] = e, this
},
getY: function(t) {
return this.array[t * this.itemSize + 1]
},
setY: function(t, e) {
return this.array[t * this.itemSize + 1] = e, this
},
getZ: function(t) {
return this.array[t * this.itemSize + 2]
},
setZ: function(t, e) {
return this.array[t * this.itemSize + 2] = e, this
},
getW: function(t) {
return this.array[t * this.itemSize + 3]
},
setW: function(t, e) {
return this.array[t * this.itemSize + 3] = e, this
},
setXY: function(t, e, n) {
return t *= this.itemSize, this.array[t + 0] = e, this.array[t + 1] = n, this
},
setXYZ: function(t, e, n, i) {
return t *= this.itemSize, this.array[t + 0] = e, this.array[t + 1] = n, this.array[t + 2] = i, this
},
setXYZW: function(t, e, n, i, r) {
return t *= this.itemSize, this.array[t + 0] = e, this.array[t + 1] = n, this.array[t + 2] = i, this.array[t + 3] = r, this
},
onUpload: function(t) {
return this.onUploadCallback = t, this
},
clone: function() {
return new this.constructor(this.array, this.itemSize).copy(this)
},
toJSON: function() {
return {
itemSize: this.itemSize,
type: this.array.constructor.name,
array: Array.prototype.slice.call(this.array),
normalized: this.normalized
}
}
}), ne.prototype = Object.create(ee.prototype), ne.prototype.constructor = ne, ie.prototype = Object.create(ee.prototype), ie.prototype.constructor = ie, re.prototype = Object.create(ee.prototype), re.prototype.constructor = re, oe.prototype = Object.create(ee.prototype), oe.prototype.constructor = oe, se.prototype = Object.create(ee.prototype), se.prototype.constructor = se, ae.prototype = Object.create(ee.prototype), ae.prototype.constructor = ae, le.prototype = Object.create(ee.prototype), le.prototype.constructor = le, ce.prototype = Object.create(ee.prototype), ce.prototype.constructor = ce, ce.prototype.isFloat16BufferAttribute = !0, he.prototype = Object.create(ee.prototype), he.prototype.constructor = he, ue.prototype = Object.create(ee.prototype), ue.prototype.constructor = ue;
const pe = {
Int8Array: Int8Array,
Uint8Array: Uint8Array,
Uint8ClampedArray: "undefined" != typeof Uint8ClampedArray ? Uint8ClampedArray : Uint8Array,
Int16Array: Int16Array,
Uint16Array: Uint16Array,
Int32Array: Int32Array,
Uint32Array: Uint32Array,
Float32Array: Float32Array,
Float64Array: Float64Array
};
function fe(t, e) {
return new pe[t](e)
}
let me = 0;
const ge = new et,
ve = new St,
ye = new T,
Ae = new C,
xe = new C,
_e = new T;
function be() {
Object.defineProperty(this, "id", {
value: me++
}), this.uuid = g.generateUUID(), this.name = "", this.type = "BufferGeometry", this.index = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = {
start: 0,
count: 1 / 0
}, this.userData = {}
}
be.prototype = Object.assign(Object.create(p.prototype), {
constructor: be,
isBufferGeometry: !0,
getIndex: function() {
return this.index
},
setIndex: function(t) {
return Array.isArray(t) ? this.index = new(de(t) > 65535 ? le : se)(t, 1) : this.index = t, this
},
getAttribute: function(t) {
return this.attributes[t]
},
setAttribute: function(t, e) {
return this.attributes[t] = e, this
},
deleteAttribute: function(t) {
return delete this.attributes[t], this
},
hasAttribute: function(t) {
return void 0 !== this.attributes[t]
},
addGroup: function(t, e, n = 0) {
this.groups.push({
start: t,
count: e,
materialIndex: n
})
},
clearGroups: function() {
this.groups = []
},
setDrawRange: function(t, e) {
this.drawRange.start = t, this.drawRange.count = e
},
applyMatrix4: function(t) {
const e = this.attributes.position;
void 0 !== e && (e.applyMatrix4(t), e.needsUpdate = !0);
const n = this.attributes.normal;
if (void 0 !== n) {
const e = (new y).getNormalMatrix(t);
n.applyNormalMatrix(e), n.needsUpdate = !0
}
const i = this.attributes.tangent;
return void 0 !== i && (i.transformDirection(t), i.needsUpdate = !0), null !== this.boundingBox && this.computeBoundingBox(), null !== this.boundingSphere && this.computeBoundingSphere(), this
},
rotateX: function(t) {
return ge.makeRotationX(t), this.applyMatrix4(ge), this
},
rotateY: function(t) {
return ge.makeRotationY(t), this.applyMatrix4(ge), this
},
rotateZ: function(t) {
return ge.makeRotationZ(t), this.applyMatrix4(ge), this
},
translate: function(t, e, n) {
return ge.makeTranslation(t, e, n), this.applyMatrix4(ge), this
},
scale: function(t, e, n) {
return ge.makeScale(t, e, n), this.applyMatrix4(ge), this
},
lookAt: function(t) {
return ve.lookAt(t), ve.updateMatrix(), this.applyMatrix4(ve.matrix), this
},
center: function() {
return this.computeBoundingBox(), this.boundingBox.getCenter(ye).negate(), this.translate(ye.x, ye.y, ye.z), this
},
setFromPoints: function(t) {
const e = [];
for (let n = 0, i = t.length; n < i; n++) {
const i = t[n];
e.push(i.x, i.y, i.z || 0)
}
return this.setAttribute("position", new he(e, 3)), this
},
computeBoundingBox: function() {
null === this.boundingBox && (this.boundingBox = new C);
const t = this.attributes.position,
e = this.morphAttributes.position;
if (t && t.isGLBufferAttribute) return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this), void this.boundingBox.set(new T(-1 / 0, -1 / 0, -1 / 0), new T(1 / 0, 1 / 0, 1 / 0));
if (void 0 !== t) {
if (this.boundingBox.setFromBufferAttribute(t), e)
for (let t = 0, n = e.length; t < n; t++) {
const n = e[t];
Ae.setFromBufferAttribute(n), this.morphTargetsRelative ? (_e.addVectors(this.boundingBox.min, Ae.min), this.boundingBox.expandByPoint(_e), _e.addVectors(this.boundingBox.max, Ae.max), this.boundingBox.expandByPoint(_e)) : (this.boundingBox.expandByPoint(Ae.min), this.boundingBox.expandByPoint(Ae.max))
}
} else this.boundingBox.makeEmpty();
(isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this)
},
computeBoundingSphere: function() {
null === this.boundingSphere && (this.boundingSphere = new X);
const t = this.attributes.position,
e = this.morphAttributes.position;
if (t && t.isGLBufferAttribute) return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this), void this.boundingSphere.set(new T, 1 / 0);
if (t) {
const n = this.boundingSphere.center;
if (Ae.setFromBufferAttribute(t), e)
for (let t = 0, n = e.length; t < n; t++) {
const n = e[t];
xe.setFromBufferAttribute(n), this.morphTargetsRelative ? (_e.addVectors(Ae.min, xe.min), Ae.expandByPoint(_e), _e.addVectors(Ae.max, xe.max), Ae.expandByPoint(_e)) : (Ae.expandByPoint(xe.min), Ae.expandByPoint(xe.max))
}
Ae.getCenter(n);
let i = 0;
for (let e = 0, r = t.count; e < r; e++) _e.fromBufferAttribute(t, e), i = Math.max(i, n.distanceToSquared(_e));
if (e)
for (let r = 0, o = e.length; r < o; r++) {
const o = e[r],
s = this.morphTargetsRelative;
for (let e = 0, r = o.count; e < r; e++) _e.fromBufferAttribute(o, e), s && (ye.fromBufferAttribute(t, e), _e.add(ye)), i = Math.max(i, n.distanceToSquared(_e))
}
this.boundingSphere.radius = Math.sqrt(i), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this)
}
},
computeFaceNormals: function() {},
computeTangents: function() {
const t = this.index,
e = this.attributes;
if (null === t || void 0 === e.position || void 0 === e.normal || void 0 === e.uv) return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");
const n = t.array,
i = e.position.array,
r = e.normal.array,
o = e.uv.array,
s = i.length / 3;
void 0 === e.tangent && this.setAttribute("tangent", new ee(new Float32Array(4 * s), 4));
const a = e.tangent.array,
l = [],
c = [];
for (let t = 0; t < s; t++) l[t] = new T, c[t] = new T;
const h = new T,
u = new T,
d = new T,
p = new v,
f = new v,
m = new v,
g = new T,
y = new T;
function A(t, e, n) {
h.fromArray(i, 3 * t), u.fromArray(i, 3 * e), d.fromArray(i, 3 * n), p.fromArray(o, 2 * t), f.fromArray(o, 2 * e), m.fromArray(o, 2 * n), u.sub(h), d.sub(h), f.sub(p), m.sub(p);
const r = 1 / (f.x * m.y - m.x * f.y);
isFinite(r) && (g.copy(u).multiplyScalar(m.y).addScaledVector(d, -f.y).multiplyScalar(r), y.copy(d).multiplyScalar(f.x).addScaledVector(u, -m.x).multiplyScalar(r), l[t].add(g), l[e].add(g), l[n].add(g), c[t].add(y), c[e].add(y), c[n].add(y))
}
let x = this.groups;
0 === x.length && (x = [{
start: 0,
count: n.length
}]);
for (let t = 0, e = x.length; t < e; ++t) {
const e = x[t],
i = e.start;
for (let t = i, r = i + e.count; t < r; t += 3) A(n[t + 0], n[t + 1], n[t + 2])
}
const _ = new T,
b = new T,
w = new T,
M = new T;
function E(t) {
w.fromArray(r, 3 * t), M.copy(w);
const e = l[t];
_.copy(e), _.sub(w.multiplyScalar(w.dot(e))).normalize(), b.crossVectors(M, e);
const n = b.dot(c[t]) < 0 ? -1 : 1;
a[4 * t] = _.x, a[4 * t + 1] = _.y, a[4 * t + 2] = _.z, a[4 * t + 3] = n
}
for (let t = 0, e = x.length; t < e; ++t) {
const e = x[t],
i = e.start;
for (let t = i, r = i + e.count; t < r; t += 3) E(n[t + 0]), E(n[t + 1]), E(n[t + 2])
}
},
computeVertexNormals: function() {
const t = this.index,
e = this.getAttribute("position");
if (void 0 !== e) {
let n = this.getAttribute("normal");
if (void 0 === n) n = new ee(new Float32Array(3 * e.count), 3), this.setAttribute("normal", n);
else
for (let t = 0, e = n.count; t < e; t++) n.setXYZ(t, 0, 0, 0);
const i = new T,
r = new T,
o = new T,
s = new T,
a = new T,
l = new T,
c = new T,
h = new T;
if (t)
for (let u = 0, d = t.count; u < d; u += 3) {
const d = t.getX(u + 0),
p = t.getX(u + 1),
f = t.getX(u + 2);
i.fromBufferAttribute(e, d), r.fromBufferAttribute(e, p), o.fromBufferAttribute(e, f), c.subVectors(o, r), h.subVectors(i, r), c.cross(h), s.fromBufferAttribute(n, d), a.fromBufferAttribute(n, p), l.fromBufferAttribute(n, f), s.add(c), a.add(c), l.add(c), n.setXYZ(d, s.x, s.y, s.z), n.setXYZ(p, a.x, a.y, a.z), n.setXYZ(f, l.x, l.y, l.z)
} else
for (let t = 0, s = e.count; t < s; t += 3) i.fromBufferAttribute(e, t + 0), r.fromBufferAttribute(e, t + 1), o.fromBufferAttribute(e, t + 2), c.subVectors(o, r), h.subVectors(i, r), c.cross(h), n.setXYZ(t + 0, c.x, c.y, c.z), n.setXYZ(t + 1, c.x, c.y, c.z), n.setXYZ(t + 2, c.x, c.y, c.z);
this.normalizeNormals(), n.needsUpdate = !0
}
},
merge: function(t, e) {
if (!t || !t.isBufferGeometry) return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.", t);
void 0 === e && (e = 0, console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));
const n = this.attributes;
for (const i in n) {
if (void 0 === t.attributes[i]) continue;
const r = n[i].array,
o = t.attributes[i],
s = o.array,
a = o.itemSize * e,
l = Math.min(s.length, r.length - a);
for (let t = 0, e = a; t < l; t++, e++) r[e] = s[t]
}
return this
},
normalizeNormals: function() {
const t = this.attributes.normal;
for (let e = 0, n = t.count; e < n; e++) _e.fromBufferAttribute(t, e), _e.normalize(), t.setXYZ(e, _e.x, _e.y, _e.z)
},
toNonIndexed: function() {
function t(t, e) {
const n = t.array,
i = t.itemSize,
r = t.normalized,
o = new n.constructor(e.length * i);
let s = 0,
a = 0;
for (let t = 0, r = e.length; t < r; t++) {
s = e[t] * i;
for (let t = 0; t < i; t++) o[a++] = n[s++]
}
return new ee(o, i, r)
}
if (null === this.index) return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this;
const e = new be,
n = this.index.array,
i = this.attributes;
for (const r in i) {
const o = t(i[r], n);
e.setAttribute(r, o)
}
const r = this.morphAttributes;
for (const i in r) {
const o = [],
s = r[i];
for (let e = 0, i = s.length; e < i; e++) {
const i = t(s[e], n);
o.push(i)
}
e.morphAttributes[i] = o
}
e.morphTargetsRelative = this.morphTargetsRelative;
const o = this.groups;
for (let t = 0, n = o.length; t < n; t++) {
const n = o[t];
e.addGroup(n.start, n.count, n.materialIndex)
}
return e
},
toJSON: function() {
const t = {
metadata: {
version: 4.5,
type: "BufferGeometry",
generator: "BufferGeometry.toJSON"
}
};
if (t.uuid = this.uuid, t.type = this.type, "" !== this.name && (t.name = this.name), Object.keys(this.userData).length > 0 && (t.userData = this.userData), void 0 !== this.parameters) {
const e = this.parameters;
for (const n in e) void 0 !== e[n] && (t[n] = e[n]);
return t
}
t.data = {
attributes: {}
};
const e = this.index;
null !== e && (t.data.index = {
type: e.array.constructor.name,
array: Array.prototype.slice.call(e.array)
});
const n = this.attributes;
for (const e in n) {
const i = n[e],
r = i.toJSON(t.data);
"" !== i.name && (r.name = i.name), t.data.attributes[e] = r
}
const i = {};
let r = !1;
for (const e in this.morphAttributes) {
const n = this.morphAttributes[e],
o = [];
for (let e = 0, i = n.length; e < i; e++) {
const i = n[e],
r = i.toJSON(t.data);
"" !== i.name && (r.name = i.name), o.push(r)
}
o.length > 0 && (i[e] = o, r = !0)
}
r && (t.data.morphAttributes = i, t.data.morphTargetsRelative = this.morphTargetsRelative);
const o = this.groups;
o.length > 0 && (t.data.groups = JSON.parse(JSON.stringify(o)));
const s = this.boundingSphere;
return null !== s && (t.data.boundingSphere = {
center: s.center.toArray(),
radius: s.radius
}), t
},
clone: function() {
return (new be).copy(this)
},
copy: function(t) {
this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null;
const e = {};
this.name = t.name;
const n = t.index;
null !== n && this.setIndex(n.clone(e));
const i = t.attributes;
for (const t in i) {
const n = i[t];
this.setAttribute(t, n.clone(e))
}
const r = t.morphAttributes;
for (const t in r) {
const n = [],
i = r[t];
for (let t = 0, r = i.length; t < r; t++) n.push(i[t].clone(e));
this.morphAttributes[t] = n
}
this.morphTargetsRelative = t.morphTargetsRelative;
const o = t.groups;
for (let t = 0, e = o.length; t < e; t++) {
const e = o[t];
this.addGroup(e.start, e.count, e.materialIndex)
}
const s = t.boundingBox;
null !== s && (this.boundingBox = s.clone());
const a = t.boundingSphere;
return null !== a && (this.boundingSphere = a.clone()), this.drawRange.start = t.drawRange.start, this.drawRange.count = t.drawRange.count, this.userData = t.userData, this
},
dispose: function() {
this.dispatchEvent({
type: "dispose"
})
}
});
const we = new et,
Me = new tt,
Ee = new X,
Se = new T,
Te = new T,
Le = new T,
Re = new T,
Ce = new T,
Pe = new T,
De = new T,
Ie = new T,
Oe = new T,
Ne = new v,
Be = new v,
Fe = new v,
ze = new T,
Ue = new T;
function He(t = new be, e = new Kt) {
St.call(this), this.type = "Mesh", this.geometry = t, this.material = e, this.updateMorphTargets()
}
function Ge(t, e, n, i, r, o, s, a, l, c, h, u) {
Se.fromBufferAttribute(r, c), Te.fromBufferAttribute(r, h), Le.fromBufferAttribute(r, u);
const d = t.morphTargetInfluences;
if (e.morphTargets && o && d) {
De.set(0, 0, 0), Ie.set(0, 0, 0), Oe.set(0, 0, 0);
for (let t = 0, e = o.length; t < e; t++) {
const e = d[t],
n = o[t];
0 !== e && (Re.fromBufferAttribute(n, c), Ce.fromBufferAttribute(n, h), Pe.fromBufferAttribute(n, u), s ? (De.addScaledVector(Re, e), Ie.addScaledVector(Ce, e), Oe.addScaledVector(Pe, e)) : (De.addScaledVector(Re.sub(Se), e), Ie.addScaledVector(Ce.sub(Te), e), Oe.addScaledVector(Pe.sub(Le), e)))
}
Se.add(De), Te.add(Ie), Le.add(Oe)
}
t.isSkinnedMesh && (t.boneTransform(c, Se), t.boneTransform(h, Te), t.boneTransform(u, Le));
const p = function(t, e, n, i, r, o, s, a) {
let l;
if (l = 1 === e.side ? i.intersectTriangle(s, o, r, !0, a) : i.intersectTriangle(r, o, s, 2 !== e.side, a), null === l) return null;
Ue.copy(a), Ue.applyMatrix4(t.matrixWorld);
const c = n.ray.origin.distanceTo(Ue);
return c < n.near || c > n.far ? null : {
distance: c,
point: Ue.clone(),
object: t
}
}(t, e, n, i, Se, Te, Le, ze);
if (p) {
a && (Ne.fromBufferAttribute(a, c), Be.fromBufferAttribute(a, h), Fe.fromBufferAttribute(a, u), p.uv = Gt.getUV(ze, Se, Te, Le, Ne, Be, Fe, new v)), l && (Ne.fromBufferAttribute(l, c), Be.fromBufferAttribute(l, h), Fe.fromBufferAttribute(l, u), p.uv2 = Gt.getUV(ze, Se, Te, Le, Ne, Be, Fe, new v));
const t = new Qt(c, h, u);
Gt.getNormal(Se, Te, Le, t.normal), p.face = t
}
return p
}
He.prototype = Object.assign(Object.create(St.prototype), {
constructor: He,
isMesh: !0,
copy: function(t) {
return St.prototype.copy.call(this, t), void 0 !== t.morphTargetInfluences && (this.morphTargetInfluences = t.morphTargetInfluences.slice()), void 0 !== t.morphTargetDictionary && (this.morphTargetDictionary = Object.assign({}, t.morphTargetDictionary)), this.material = t.material, this.geometry = t.geometry, this
},
updateMorphTargets: function() {
const t = this.geometry;
if (t.isBufferGeometry) {
const e = t.morphAttributes,
n = Object.keys(e);
if (n.length > 0) {
const t = e[n[0]];
if (void 0 !== t) {
this.morphTargetInfluences = [], this.morphTargetDictionary = {};
for (let e = 0, n = t.length; e < n; e++) {
const n = t[e].name || String(e);
this.morphTargetInfluences.push(0), this.morphTargetDictionary[n] = e
}
}
}
} else {
const e = t.morphTargets;
void 0 !== e && e.length > 0 && console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")
}
},
raycast: function(t, e) {
const n = this.geometry,
i = this.material,
r = this.matrixWorld;
if (void 0 === i) return;
if (null === n.boundingSphere && n.computeBoundingSphere(), Ee.copy(n.boundingSphere), Ee.applyMatrix4(r), !1 === t.ray.intersectsSphere(Ee)) return;
if (we.copy(r).invert(), Me.copy(t.ray).applyMatrix4(we), null !== n.boundingBox && !1 === Me.intersectsBox(n.boundingBox)) return;
let o;
if (n.isBufferGeometry) {
const r = n.index,
s = n.attributes.position,
a = n.morphAttributes.position,
l = n.morphTargetsRelative,
c = n.attributes.uv,
h = n.attributes.uv2,
u = n.groups,
d = n.drawRange;
if (null !== r)
if (Array.isArray(i))
for (let n = 0, p = u.length; n < p; n++) {
const p = u[n],
f = i[p.materialIndex];
for (let n = Math.max(p.start, d.start), i = Math.min(p.start + p.count, d.start + d.count); n < i; n += 3) {
const i = r.getX(n),
u = r.getX(n + 1),
d = r.getX(n + 2);
o = Ge(this, f, t, Me, s, a, l, c, h, i, u, d), o && (o.faceIndex = Math.floor(n / 3), o.face.materialIndex = p.materialIndex, e.push(o))
}
} else {
for (let n = Math.max(0, d.start), u = Math.min(r.count, d.start + d.count); n < u; n += 3) {
const u = r.getX(n),
d = r.getX(n + 1),
p = r.getX(n + 2);
o = Ge(this, i, t, Me, s, a, l, c, h, u, d, p), o && (o.faceIndex = Math.floor(n / 3), e.push(o))
}
} else if (void 0 !== s)
if (Array.isArray(i))
for (let n = 0, r = u.length; n < r; n++) {
const r = u[n],
p = i[r.materialIndex];
for (let n = Math.max(r.start, d.start), i = Math.min(r.start + r.count, d.start + d.count); n < i; n += 3) {
o = Ge(this, p, t, Me, s, a, l, c, h, n, n + 1, n + 2), o && (o.faceIndex = Math.floor(n / 3), o.face.materialIndex = r.materialIndex, e.push(o))
}
} else {
for (let n = Math.max(0, d.start), r = Math.min(s.count, d.start + d.count); n < r; n += 3) {
o = Ge(this, i, t, Me, s, a, l, c, h, n, n + 1, n + 2), o && (o.faceIndex = Math.floor(n / 3), e.push(o))
}
}
} else n.isGeometry && console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")
}
});
class Ve extends be {
constructor(t = 1, e = 1, n = 1, i = 1, r = 1, o = 1) {
super(), this.type = "BoxGeometry", this.parameters = {
width: t,
height: e,
depth: n,
widthSegments: i,
heightSegments: r,
depthSegments: o
};
const s = this;
i = Math.floor(i), r = Math.floor(r), o = Math.floor(o);
const a = [],
l = [],
c = [],
h = [];
let u = 0,
d = 0;
function p(t, e, n, i, r, o, p, f, m, g, v) {
const y = o / m,
A = p / g,
x = o / 2,
_ = p / 2,
b = f / 2,
w = m + 1,
M = g + 1;
let E = 0,
S = 0;
const L = new T;
for (let o = 0; o < M; o++) {
const s = o * A - _;
for (let a = 0; a < w; a++) {
const u = a * y - x;
L[t] = u * i, L[e] = s * r, L[n] = b, l.push(L.x, L.y, L.z), L[t] = 0, L[e] = 0, L[n] = f > 0 ? 1 : -1, c.push(L.x, L.y, L.z), h.push(a / m), h.push(1 - o / g), E += 1
}
}
for (let t = 0; t < g; t++)
for (let e = 0; e < m; e++) {
const n = u + e + w * t,
i = u + e + w * (t + 1),
r = u + (e + 1) + w * (t + 1),
o = u + (e + 1) + w * t;
a.push(n, i, o), a.push(i, r, o), S += 6
}
s.addGroup(d, S, v), d += S, u += E
}
p("z", "y", "x", -1, -1, n, e, t, o, r, 0), p("z", "y", "x", 1, -1, n, e, -t, o, r, 1), p("x", "z", "y", 1, 1, t, n, e, i, o, 2), p("x", "z", "y", 1, -1, t, n, -e, i, o, 3), p("x", "y", "z", 1, -1, t, e, n, i, r, 4), p("x", "y", "z", -1, -1, t, e, -n, i, r, 5), this.setIndex(a), this.setAttribute("position", new he(l, 3)), this.setAttribute("normal", new he(c, 3)), this.setAttribute("uv", new he(h, 2))
}
}
function ke(t) {
const e = {};
for (const n in t) {
e[n] = {};
for (const i in t[n]) {
const r = t[n][i];
r && (r.isColor || r.isMatrix3 || r.isMatrix4 || r.isVector2 || r.isVector3 || r.isVector4 || r.isTexture) ? e[n][i] = r.clone() : Array.isArray(r) ? e[n][i] = r.slice() : e[n][i] = r
}
}
return e
}
function We(t) {
const e = {};
for (let n = 0; n < t.length; n++) {
const i = ke(t[n]);
for (const t in i) e[t] = i[t]
}
return e
}
const je = {
clone: ke,
merge: We
};
function Xe(t) {
Jt.call(this), this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.vertexShader = "void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", this.fragmentShader = "void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}", this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.skinning = !1, this.morphTargets = !1, this.morphNormals = !1, this.extensions = {
derivatives: !1,
fragDepth: !1,
drawBuffers: !1,
shaderTextureLOD: !1
}, this.defaultAttributeValues = {
color: [1, 1, 1],
uv: [0, 0],
uv2: [0, 0]
}, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, void 0 !== t && (void 0 !== t.attributes && console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."), this.setValues(t))
}
function qe() {
St.call(this), this.type = "Camera", this.matrixWorldInverse = new et, this.projectionMatrix = new et, this.projectionMatrixInverse = new et
}
function Ye(t = 50, e = 1, n = .1, i = 2e3) {
qe.call(this), this.type = "PerspectiveCamera", this.fov = t, this.zoom = 1, this.near = n, this.far = i, this.focus = 10, this.aspect = e, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix()
}
Xe.prototype = Object.create(Jt.prototype), Xe.prototype.constructor = Xe, Xe.prototype.isShaderMaterial = !0, Xe.prototype.copy = function(t) {
return Jt.prototype.copy.call(this, t), this.fragmentShader = t.fragmentShader, this.vertexShader = t.vertexShader, this.uniforms = ke(t.uniforms), this.defines = Object.assign({}, t.defines), this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.lights = t.lights, this.clipping = t.clipping, this.skinning = t.skinning, this.morphTargets = t.morphTargets, this.morphNormals = t.morphNormals, this.extensions = Object.assign({}, t.extensions), this.glslVersion = t.glslVersion, this
}, Xe.prototype.toJSON = function(t) {
const e = Jt.prototype.toJSON.call(this, t);
e.glslVersion = this.glslVersion, e.uniforms = {};
for (const n in this.uniforms) {
const i = this.uniforms[n].value;
i && i.isTexture ? e.uniforms[n] = {
type: "t",
value: i.toJSON(t).uuid
} : i && i.isColor ? e.uniforms[n] = {
type: "c",
value: i.getHex()
} : i && i.isVector2 ? e.uniforms[n] = {
type: "v2",
value: i.toArray()
} : i && i.isVector3 ? e.uniforms[n] = {
type: "v3",
value: i.toArray()
} : i && i.isVector4 ? e.uniforms[n] = {
type: "v4",
value: i.toArray()
} : i && i.isMatrix3 ? e.uniforms[n] = {
type: "m3",
value: i.toArray()
} : i && i.isMatrix4 ? e.uniforms[n] = {
type: "m4",
value: i.toArray()
} : e.uniforms[n] = {
value: i
}
}
Object.keys(this.defines).length > 0 && (e.defines = this.defines), e.vertexShader = this.vertexShader, e.fragmentShader = this.fragmentShader;
const n = {};
for (const t in this.extensions) !0 === this.extensions[t] && (n[t] = !0);
return Object.keys(n).length > 0 && (e.extensions = n), e
}, qe.prototype = Object.assign(Object.create(St.prototype), {
constructor: qe,
isCamera: !0,
copy: function(t, e) {
return St.prototype.copy.call(this, t, e), this.matrixWorldInverse.copy(t.matrixWorldInverse), this.projectionMatrix.copy(t.projectionMatrix), this.projectionMatrixInverse.copy(t.projectionMatrixInverse), this
},
getWorldDirection: function(t) {
void 0 === t && (console.warn("THREE.Camera: .getWorldDirection() target is now required"), t = new T), this.updateWorldMatrix(!0, !1);
const e = this.matrixWorld.elements;
return t.set(-e[8], -e[9], -e[10]).normalize()
},
updateMatrixWorld: function(t) {
St.prototype.updateMatrixWorld.call(this, t), this.matrixWorldInverse.copy(this.matrixWorld).invert()
},
updateWorldMatrix: function(t, e) {
St.prototype.updateWorldMatrix.call(this, t, e), this.matrixWorldInverse.copy(this.matrixWorld).invert()
},
clone: function() {
return (new this.constructor).copy(this)
}
}), Ye.prototype = Object.assign(Object.create(qe.prototype), {
constructor: Ye,
isPerspectiveCamera: !0,
copy: function(t, e) {
return qe.prototype.copy.call(this, t, e), this.fov = t.fov, this.zoom = t.zoom, this.near = t.near, this.far = t.far, this.focus = t.focus, this.aspect = t.aspect, this.view = null === t.view ? null : Object.assign({}, t.view), this.filmGauge = t.filmGauge, this.filmOffset = t.filmOffset, this
},
setFocalLength: function(t) {
const e = .5 * this.getFilmHeight() / t;
this.fov = 2 * g.RAD2DEG * Math.atan(e), this.updateProjectionMatrix()
},
getFocalLength: function() {
const t = Math.tan(.5 * g.DEG2RAD * this.fov);
return .5 * this.getFilmHeight() / t
},
getEffectiveFOV: function() {
return 2 * g.RAD2DEG * Math.atan(Math.tan(.5 * g.DEG2RAD * this.fov) / this.zoom)
},
getFilmWidth: function() {
return this.filmGauge * Math.min(this.aspect, 1)
},
getFilmHeight: function() {
return this.filmGauge / Math.max(this.aspect, 1)
},
setViewOffset: function(t, e, n, i, r, o) {
this.aspect = t / e, null === this.view && (this.view = {
enabled: !0,
fullWidth: 1,
fullHeight: 1,
offsetX: 0,
offsetY: 0,
width: 1,
height: 1
}), this.view.enabled = !0, this.view.fullWidth = t, this.view.fullHeight = e, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = o, this.updateProjectionMatrix()
},
clearViewOffset: function() {
null !== this.view && (this.view.enabled = !1), this.updateProjectionMatrix()
},
updateProjectionMatrix: function() {
const t = this.near;
let e = t * Math.tan(.5 * g.DEG2RAD * this.fov) / this.zoom,
n = 2 * e,
i = this.aspect * n,
r = -.5 * i;
const o = this.view;
if (null !== this.view && this.view.enabled) {
const t = o.fullWidth,
s = o.fullHeight;
r += o.offsetX * i / t, e -= o.offsetY * n / s, i *= o.width / t, n *= o.height / s
}
const s = this.filmOffset;
0 !== s && (r += t * s / this.getFilmWidth()), this.projectionMatrix.makePerspective(r, r + i, e, e - n, t, this.far), this.projectionMatrixInverse.copy(this.projectionMatrix).invert()
},
toJSON: function(t) {
const e = St.prototype.toJSON.call(this, t);
return e.object.fov = this.fov, e.object.zoom = this.zoom, e.object.near = this.near, e.object.far = this.far, e.object.focus = this.focus, e.object.aspect = this.aspect, null !== this.view && (e.object.view = Object.assign({}, this.view)), e.object.filmGauge = this.filmGauge, e.object.filmOffset = this.filmOffset, e
}
});
function Qe(t, e, n) {
if (St.call(this), this.type = "CubeCamera", !0 !== n.isWebGLCubeRenderTarget) return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");
this.renderTarget = n;
const i = new Ye(90, 1, t, e);
i.layers = this.layers, i.up.set(0, -1, 0), i.lookAt(new T(1, 0, 0)), this.add(i);
const r = new Ye(90, 1, t, e);
r.layers = this.layers, r.up.set(0, -1, 0), r.lookAt(new T(-1, 0, 0)), this.add(r);
const o = new Ye(90, 1, t, e);
o.layers = this.layers, o.up.set(0, 0, 1), o.lookAt(new T(0, 1, 0)), this.add(o);
const s = new Ye(90, 1, t, e);
s.layers = this.layers, s.up.set(0, 0, -1), s.lookAt(new T(0, -1, 0)), this.add(s);
const a = new Ye(90, 1, t, e);
a.layers = this.layers, a.up.set(0, -1, 0), a.lookAt(new T(0, 0, 1)), this.add(a);
const l = new Ye(90, 1, t, e);
l.layers = this.layers, l.up.set(0, -1, 0), l.lookAt(new T(0, 0, -1)), this.add(l), this.update = function(t, e) {
null === this.parent && this.updateMatrixWorld();
const c = t.xr.enabled,
h = t.getRenderTarget();
t.xr.enabled = !1;
const u = n.texture.generateMipmaps;
n.texture.generateMipmaps = !1, t.setRenderTarget(n, 0), t.render(e, i), t.setRenderTarget(n, 1), t.render(e, r), t.setRenderTarget(n, 2), t.render(e, o), t.setRenderTarget(n, 3), t.render(e, s), t.setRenderTarget(n, 4), t.render(e, a), n.texture.generateMipmaps = u, t.setRenderTarget(n, 5), t.render(e, l), t.setRenderTarget(h), t.xr.enabled = c
}
}
function Ze(t, e, n, i, r, o, s, a, l, c) {
t = void 0 !== t ? t : [], e = void 0 !== e ? e : 301, s = void 0 !== s ? s : 1022, b.call(this, t, e, n, i, r, o, s, a, l, c), this.flipY = !1, this._needsFlipEnvMap = !0
}
Qe.prototype = Object.create(St.prototype), Qe.prototype.constructor = Qe, Ze.prototype = Object.create(b.prototype), Ze.prototype.constructor = Ze, Ze.prototype.isCubeTexture = !0, Object.defineProperty(Ze.prototype, "images", {
get: function() {
return this.image
},
set: function(t) {
this.image = t
}
});
class Je extends E {
constructor(t, e, n) {
Number.isInteger(e) && (console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"), e = n), super(t, t, e), Object.defineProperty(this, "isWebGLCubeRenderTarget", {
value: !0
}), e = e || {}, this.texture = new Ze(void 0, e.mapping, e.wrapS, e.wrapT, e.magFilter, e.minFilter, e.format, e.type, e.anisotropy, e.encoding), this.texture._needsFlipEnvMap = !1
}
fromEquirectangularTexture(t, e) {
this.texture.type = e.type, this.texture.format = 1023, this.texture.encoding = e.encoding, this.texture.generateMipmaps = e.generateMipmaps, this.texture.minFilter = e.minFilter, this.texture.magFilter = e.magFilter;
const n = {
uniforms: {
tEquirect: {
value: null
}
},
vertexShader: "\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",
fragmentShader: "\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"
},
i = new Ve(5, 5, 5),
r = new Xe({
name: "CubemapFromEquirect",
uniforms: ke(n.uniforms),
vertexShader: n.vertexShader,
fragmentShader: n.fragmentShader,
side: 1,
blending: 0
});
r.uniforms.tEquirect.value = e;
const o = new He(i, r),
s = e.minFilter;
1008 === e.minFilter && (e.minFilter = 1006);
return new Qe(1, 10, this).update(t, o), e.minFilter = s, o.geometry.dispose(), o.material.dispose(), this
}
clear(t, e, n, i) {
const r = t.getRenderTarget();
for (let r = 0; r < 6; r++) t.setRenderTarget(this, r), t.clear(e, n, i);
t.setRenderTarget(r)
}
}
function Ke(t, e, n, i, r, o, s, a, l, c, h, u) {
b.call(this, null, o, s, a, l, c, i, r, h, u), this.image = {
data: t || null,
width: e || 1,
height: n || 1
}, this.magFilter = void 0 !== l ? l : 1003, this.minFilter = void 0 !== c ? c : 1003, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.needsUpdate = !0
}
Ke.prototype = Object.create(b.prototype), Ke.prototype.constructor = Ke, Ke.prototype.isDataTexture = !0;
const $e = new X,
tn = new T;
class en {
constructor(t, e, n, i, r, o) {
this.planes = [void 0 !== t ? t : new Ct, void 0 !== e ? e : new Ct, void 0 !== n ? n : new Ct, void 0 !== i ? i : new Ct, void 0 !== r ? r : new Ct, void 0 !== o ? o : new Ct]
}
set(t, e, n, i, r, o) {
const s = this.planes;
return s[0].copy(t), s[1].copy(e), s[2].copy(n), s[3].copy(i), s[4].copy(r), s[5].copy(o), this
}
clone() {
return (new this.constructor).copy(this)
}
copy(t) {
const e = this.planes;
for (let n = 0; n < 6; n++) e[n].copy(t.planes[n]);
return this
}
setFromProjectionMatrix(t) {
const e = this.planes,
n = t.elements,
i = n[0],
r = n[1],
o = n[2],
s = n[3],
a = n[4],
l = n[5],
c = n[6],
h = n[7],
u = n[8],
d = n[9],
p = n[10],
f = n[11],
m = n[12],
g = n[13],
v = n[14],
y = n[15];
return e[0].setComponents(s - i, h - a, f - u, y - m).normalize(), e[1].setComponents(s + i, h + a, f + u, y + m).normalize(), e[2].setComponents(s + r, h + l, f + d, y + g).normalize(), e[3].setComponents(s - r, h - l, f - d, y - g).normalize(), e[4].setComponents(s - o, h - c, f - p, y - v).normalize(), e[5].setComponents(s + o, h + c, f + p, y + v).normalize(), this
}
intersectsObject(t) {
const e = t.geometry;
return null === e.boundingSphere && e.computeBoundingSphere(), $e.copy(e.boundingSphere).applyMatrix4(t.matrixWorld), this.intersectsSphere($e)
}
intersectsSprite(t) {
return $e.center.set(0, 0, 0), $e.radius = .7071067811865476, $e.applyMatrix4(t.matrixWorld), this.intersectsSphere($e)
}
intersectsSphere(t) {
const e = this.planes,
n = t.center,
i = -t.radius;
for (let t = 0; t < 6; t++) {
if (e[t].distanceToPoint(n) < i) return !1
}
return !0
}
intersectsBox(t) {
const e = this.planes;
for (let n = 0; n < 6; n++) {
const i = e[n];
if (tn.x = i.normal.x > 0 ? t.max.x : t.min.x, tn.y = i.normal.y > 0 ? t.max.y : t.min.y, tn.z = i.normal.z > 0 ? t.max.z : t.min.z, i.distanceToPoint(tn) < 0) return !1
}
return !0
}
containsPoint(t) {
const e = this.planes;
for (let n = 0; n < 6; n++)
if (e[n].distanceToPoint(t) < 0) return !1;
return !0
}
}
function nn() {
let t = null,
e = !1,
n = null,
i = null;
function r(e, o) {
n(e, o), i = t.requestAnimationFrame(r)
}
return {
start: function() {
!0 !== e && null !== n && (i = t.requestAnimationFrame(r), e = !0)
},
stop: function() {
t.cancelAnimationFrame(i), e = !1
},
setAnimationLoop: function(t) {
n = t
},
setContext: function(e) {
t = e
}
}
}
function rn(t, e) {
const n = e.isWebGL2,
i = new WeakMap;
return {
get: function(t) {
return t.isInterleavedBufferAttribute && (t = t.data), i.get(t)
},
remove: function(e) {
e.isInterleavedBufferAttribute && (e = e.data);
const n = i.get(e);
n && (t.deleteBuffer(n.buffer), i.delete(e))
},
update: function(e, r) {
if (e.isGLBufferAttribute) {
const t = i.get(e);
return void((!t || t.version < e.version) && i.set(e, {
buffer: e.buffer,
type: e.type,
bytesPerElement: e.elementSize,
version: e.version
}))
}
e.isInterleavedBufferAttribute && (e = e.data);
const o = i.get(e);
void 0 === o ? i.set(e, function(e, i) {
const r = e.array,
o = e.usage,
s = t.createBuffer();
t.bindBuffer(i, s), t.bufferData(i, r, o), e.onUploadCallback();
let a = 5126;
return r instanceof Float32Array ? a = 5126 : r instanceof Float64Array ? console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.") : r instanceof Uint16Array ? e.isFloat16BufferAttribute ? n ? a = 5131 : console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.") : a = 5123 : r instanceof Int16Array ? a = 5122 : r instanceof Uint32Array ? a = 5125 : r instanceof Int32Array ? a = 5124 : r instanceof Int8Array ? a = 5120 : r instanceof Uint8Array && (a = 5121), {
buffer: s,
type: a,
bytesPerElement: r.BYTES_PER_ELEMENT,
version: e.version
}
}(e, r)) : o.version < e.version && (! function(e, i, r) {
const o = i.array,
s = i.updateRange;
t.bindBuffer(r, e), -1 === s.count ? t.bufferSubData(r, 0, o) : (n ? t.bufferSubData(r, s.offset * o.BYTES_PER_ELEMENT, o, s.offset, s.count) : t.bufferSubData(r, s.offset * o.BYTES_PER_ELEMENT, o.subarray(s.offset, s.offset + s.count)), s.count = -1)
}(o.buffer, e, r), o.version = e.version)
}
}
}
class on extends be {
constructor(t = 1, e = 1, n = 1, i = 1) {
super(), this.type = "PlaneGeometry", this.parameters = {
width: t,
height: e,
widthSegments: n,
heightSegments: i
};
const r = t / 2,
o = e / 2,
s = Math.floor(n),
a = Math.floor(i),
l = s + 1,
c = a + 1,
h = t / s,
u = e / a,
d = [],
p = [],
f = [],
m = [];
for (let t = 0; t < c; t++) {
const e = t * u - o;
for (let n = 0; n < l; n++) {
const i = n * h - r;
p.push(i, -e, 0), f.push(0, 0, 1), m.push(n / s), m.push(1 - t / a)
}
}
for (let t = 0; t < a; t++)
for (let e = 0; e < s; e++) {
const n = e + l * t,
i = e + l * (t + 1),
r = e + 1 + l * (t + 1),
o = e + 1 + l * t;
d.push(n, i, o), d.push(i, r, o)
}
this.setIndex(d), this.setAttribute("position", new he(p, 3)), this.setAttribute("normal", new he(f, 3)), this.setAttribute("uv", new he(m, 2))
}
}
const sn = {
alphamap_fragment: "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",
alphamap_pars_fragment: "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",
alphatest_fragment: "#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",
aomap_fragment: "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",
aomap_pars_fragment: "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",
begin_vertex: "vec3 transformed = vec3( position );",
beginnormal_vertex: "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",
bsdfs: "vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",
bumpmap_pars_fragment: "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",
clipping_planes_fragment: "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",
clipping_planes_pars_fragment: "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",
clipping_planes_pars_vertex: "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",
clipping_planes_vertex: "#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",
color_fragment: "#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",
color_pars_fragment: "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",
color_pars_vertex: "#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",
color_vertex: "#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor.xyz *= color.xyz;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",
common: "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",
cube_uv_reflection_fragment: "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",
defaultnormal_vertex: "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",
displacementmap_pars_vertex: "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",
displacementmap_vertex: "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",
emissivemap_fragment: "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",
emissivemap_pars_fragment: "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",
encodings_fragment: "gl_FragColor = linearToOutputTexel( gl_FragColor );",
encodings_pars_fragment: "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",
envmap_fragment: "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",
envmap_common_pars_fragment: "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",
envmap_pars_fragment: "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",
envmap_pars_vertex: "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",
envmap_physical_pars_fragment: "#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",
envmap_vertex: "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",
fog_vertex: "#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",
fog_pars_vertex: "#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",
fog_fragment: "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",
fog_pars_fragment: "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",
gradientmap_pars_fragment: "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",
lightmap_fragment: "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",
lightmap_pars_fragment: "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",
lights_lambert_vertex: "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",
lights_pars_begin: "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",
lights_toon_fragment: "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",
lights_toon_pars_fragment: "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",
lights_phong_fragment: "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",
lights_phong_pars_fragment: "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",
lights_physical_fragment: "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",
lights_physical_pars_fragment: "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",
lights_fragment_begin: "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",
lights_fragment_maps: "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",
lights_fragment_end: "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",
logdepthbuf_fragment: "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",
logdepthbuf_pars_fragment: "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",
logdepthbuf_pars_vertex: "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",
logdepthbuf_vertex: "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",
map_fragment: "#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",
map_pars_fragment: "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",
map_particle_fragment: "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",
map_particle_pars_fragment: "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",
metalnessmap_fragment: "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",
metalnessmap_pars_fragment: "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",
morphnormal_vertex: "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",
morphtarget_pars_vertex: "#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",
morphtarget_vertex: "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",
normal_fragment_begin: "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",
normal_fragment_maps: "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",
normalmap_pars_fragment: "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",
clearcoat_normal_fragment_begin: "#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",
clearcoat_normal_fragment_maps: "#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",
clearcoat_pars_fragment: "#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",
packing: "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",
premultiplied_alpha_fragment: "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",
project_vertex: "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",
dithering_fragment: "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",
dithering_pars_fragment: "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",
roughnessmap_fragment: "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",
roughnessmap_pars_fragment: "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",
shadowmap_pars_fragment: "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",
shadowmap_pars_vertex: "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",
shadowmap_vertex: "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",
shadowmask_pars_fragment: "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",
skinbase_vertex: "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",
skinning_pars_vertex: "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",
skinning_vertex: "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",
skinnormal_vertex: "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",
specularmap_fragment: "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",
specularmap_pars_fragment: "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",
tonemapping_fragment: "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",
tonemapping_pars_fragment: "#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",
transmissionmap_fragment: "#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",
transmissionmap_pars_fragment: "#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",
uv_pars_fragment: "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",
uv_pars_vertex: "#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",
uv_vertex: "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",
uv2_pars_fragment: "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",
uv2_pars_vertex: "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",
uv2_vertex: "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",
worldpos_vertex: "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",
background_frag: "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",
background_vert: "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",
cube_frag: "#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",
cube_vert: "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",
depth_frag: "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",
depth_vert: "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",
distanceRGBA_frag: "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",
distanceRGBA_vert: "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",
equirect_frag: "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",
equirect_vert: "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",
linedashed_frag: "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",
linedashed_vert: "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",
meshbasic_frag: "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",
meshbasic_vert: "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",
meshlambert_frag: "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",
meshlambert_vert: "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",
meshmatcap_frag: "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include