Файловый менеджер - Редактировать - /home/jogoso94/public_html/jogos/classic_bowling/js/main.js
�азад
/* screenfull v3.3.3 - 2018-09-04 (c) Sindre Sorhus; MIT License Platform.js <https://mths.be/platform> Copyright 2014-2018 Benjamin Tan <https://bnjmnt4n.now.sh/> Copyright 2011-2013 John-David Dalton Available under MIT license <https://mths.be/mit> */ (function() { var n = "undefined" !== typeof window && "undefined" !== typeof window.document ? window.document : {}, d = "undefined" !== typeof module && module.exports, g = "undefined" !== typeof Element && "ALLOW_KEYBOARD_INPUT" in Element, l = function() { for (var a, b = ["requestFullscreen exitFullscreen fullscreenElement fullscreenEnabled fullscreenchange fullscreenerror".split(" "), "webkitRequestFullscreen webkitExitFullscreen webkitFullscreenElement webkitFullscreenEnabled webkitfullscreenchange webkitfullscreenerror".split(" "), "webkitRequestFullScreen webkitCancelFullScreen webkitCurrentFullScreenElement webkitCancelFullScreen webkitfullscreenchange webkitfullscreenerror".split(" "), "mozRequestFullScreen mozCancelFullScreen mozFullScreenElement mozFullScreenEnabled mozfullscreenchange mozfullscreenerror".split(" "), "msRequestFullscreen msExitFullscreen msFullscreenElement msFullscreenEnabled MSFullscreenChange MSFullscreenError".split(" ") ], c = 0, h = b.length, k = {}; c < h; c++) if ((a = b[c]) && a[1] in n) { for (c = 0; c < a.length; c++) k[b[0][c]] = a[c]; return k } return !1 }(), b = { change: l.fullscreenchange, error: l.fullscreenerror }, c = { request: function(a) { var b = l.requestFullscreen; a = a || n.documentElement; if (/ Version\/5\.1(?:\.\d+)? Safari\//.test(navigator.userAgent)) a[b](); else a[b](g ? Element.ALLOW_KEYBOARD_INPUT : {}) }, exit: function() { n[l.exitFullscreen]() }, toggle: function(a) { this.isFullscreen ? this.exit() : this.request(a) }, onchange: function(a) { this.on("change", a) }, onerror: function(a) { this.on("error", a) }, on: function(a, c) { var p = b[a]; p && n.addEventListener(p, c, !1) }, off: function(a, c) { var p = b[a]; p && n.removeEventListener(p, c, !1) }, raw: l }; l ? (Object.defineProperties(c, { isFullscreen: { get: function() { return !!n[l.fullscreenElement] } }, element: { enumerable: !0, get: function() { return n[l.fullscreenElement] } }, enabled: { enumerable: !0, get: function() { return !!n[l.fullscreenEnabled] } } }), d ? module.exports = c : window.screenfull = c) : d ? module.exports = !1 : window.screenfull = !1 })(); (function() { function n(a) { a = String(a); return a.charAt(0).toUpperCase() + a.slice(1) } function d(a, b) { var e = -1, f = a ? a.length : 0; if ("number" == typeof f && -1 < f && f <= m) for (; ++e < f;) b(a[e], e, a); else l(a, b) } function g(a) { a = String(a).replace(/^ +| +$/g, ""); return /^(?:webOS|i(?:OS|P))/.test(a) ? a : n(a) } function l(a, b) { for (var e in a) r.call(a, e) && b(a[e], e, a) } function b(a) { return null == a ? n(a) : w.call(a).slice(8, -1) } function c(a, b) { var e = null != a ? typeof a[b] : "number"; return !/^(?:boolean|number|string|undefined)$/.test(e) && ("object" == e ? !!a[b] : !0) } function a(a) { return String(a).replace(/([ -])(?!$)/g, "$1?") } function q(a, b) { var e = null; d(a, function(f, m) { e = b(e, f, m, a) }); return e } function p(e) { function f(b) { return q(b, function(b, f) { var m = f.pattern || a(f); !b && (b = RegExp("\\b" + m + " *\\d+[.\\w_]*", "i").exec(e) || RegExp("\\b" + m + " *\\w+-[\\w]*", "i").exec(e) || RegExp("\\b" + m + "(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)", "i").exec(e)) && ((b = String(f.label && !RegExp(m, "i").test(f.label) ? f.label : b).split("/"))[1] && !/[\d.]+/.test(b[0]) && (b[0] += " " + b[1]), f = f.label || f, b = g(b[0].replace(RegExp(m, "i"), f).replace(RegExp("; *(?:" + f + "[_-])?", "i"), " ").replace(RegExp("(" + f + ")[-_.]?(\\w)", "i"), "$1 $2"))); return b }) } function m(a) { return q(a, function(a, b) { return a || (RegExp(b + "(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)", "i").exec(e) || 0)[1] || null }) } var h = k, d = e && "object" == typeof e && "String" != b(e); d && (h = e, e = null); var r = h.navigator || {}, n = r.userAgent || ""; e || (e = n); var v = d ? !!r.likeChrome : /\bChrome\b/.test(e) && !/internal|\n/i.test(w.toString()), y = d ? "Object" : "ScriptBridgingProxyObject", U = d ? "Object" : "Environment", R = d && h.java ? "JavaPackage" : b(h.java), P = d ? "Object" : "RuntimeObject"; U = (R = /\bJava/.test(R) && h.java) && b(h.environment) == U; var J = R ? "a" : "\u03b1", L = R ? "b" : "\u03b2", M = h.document || {}, O = h.operamini || h.opera, X = t.test(X = d && O ? O["[[Class]]"] : b(O)) ? X : O = null, u, Q = e; d = []; var E = null, T = e == n; n = T && O && "function" == typeof O.version && O.version(); var I = function(b) { return q(b, function(b, f) { return b || RegExp("\\b" + (f.pattern || a(f)) + "\\b", "i").exec(e) && (f.label || f) }) }([{ label: "EdgeHTML", pattern: "Edge" }, "Trident", { label: "WebKit", pattern: "AppleWebKit" }, "iCab", "Presto", "NetFront", "Tasman", "KHTML", "Gecko"]), F = function(b) { return q(b, function(b, f) { return b || RegExp("\\b" + (f.pattern || a(f)) + "\\b", "i").exec(e) && (f.label || f) }) }(["Adobe AIR", "Arora", "Avant Browser", "Breach", "Camino", "Electron", "Epiphany", "Fennec", "Flock", "Galeon", "GreenBrowser", "iCab", "Iceweasel", "K-Meleon", "Konqueror", "Lunascape", "Maxthon", { label: "Microsoft Edge", pattern: "Edge" }, "Midori", "Nook Browser", "PaleMoon", "PhantomJS", "Raven", "Rekonq", "RockMelt", { label: "Samsung Internet", pattern: "SamsungBrowser" }, "SeaMonkey", { label: "Silk", pattern: "(?:Cloud9|Silk-Accelerated)" }, "Sleipnir", "SlimBrowser", { label: "SRWare Iron", pattern: "Iron" }, "Sunrise", "Swiftfox", "Waterfox", "WebPositive", "Opera Mini", { label: "Opera Mini", pattern: "OPiOS" }, "Opera", { label: "Opera", pattern: "OPR" }, "Chrome", { label: "Chrome Mobile", pattern: "(?:CriOS|CrMo)" }, { label: "Firefox", pattern: "(?:Firefox|Minefield)" }, { label: "Firefox for iOS", pattern: "FxiOS" }, { label: "IE", pattern: "IEMobile" }, { label: "IE", pattern: "MSIE" }, "Safari" ]), K = f([{ label: "BlackBerry", pattern: "BB10" }, "BlackBerry", { label: "Galaxy S", pattern: "GT-I9000" }, { label: "Galaxy S2", pattern: "GT-I9100" }, { label: "Galaxy S3", pattern: "GT-I9300" }, { label: "Galaxy S4", pattern: "GT-I9500" }, { label: "Galaxy S5", pattern: "SM-G900" }, { label: "Galaxy S6", pattern: "SM-G920" }, { label: "Galaxy S6 Edge", pattern: "SM-G925" }, { label: "Galaxy S7", pattern: "SM-G930" }, { label: "Galaxy S7 Edge", pattern: "SM-G935" }, "Google TV", "Lumia", "iPad", "iPod", "iPhone", "Kindle", { label: "Kindle Fire", pattern: "(?:Cloud9|Silk-Accelerated)" }, "Nexus", "Nook", "PlayBook", "PlayStation Vita", "PlayStation", "TouchPad", "Transformer", { label: "Wii U", pattern: "WiiU" }, "Wii", "Xbox One", { label: "Xbox 360", pattern: "Xbox" }, "Xoom" ]), z = function(b) { return q(b, function(b, f, m) { return b || (f[K] || f[/^[a-z]+(?: +[a-z]+\b)*/i.exec(K)] || RegExp("\\b" + a(m) + "(?:\\b|\\w*\\d)", "i").exec(e)) && m }) }({ Apple: { iPad: 1, iPhone: 1, iPod: 1 }, Archos: {}, Amazon: { Kindle: 1, "Kindle Fire": 1 }, Asus: { Transformer: 1 }, "Barnes & Noble": { Nook: 1 }, BlackBerry: { PlayBook: 1 }, Google: { "Google TV": 1, Nexus: 1 }, HP: { TouchPad: 1 }, HTC: {}, LG: {}, Microsoft: { Xbox: 1, "Xbox One": 1 }, Motorola: { Xoom: 1 }, Nintendo: { "Wii U": 1, Wii: 1 }, Nokia: { Lumia: 1 }, Samsung: { "Galaxy S": 1, "Galaxy S2": 1, "Galaxy S3": 1, "Galaxy S4": 1 }, Sony: { PlayStation: 1, "PlayStation Vita": 1 } }), D = function(b) { return q(b, function(b, f) { var m = f.pattern || a(f); if (!b && (b = RegExp("\\b" + m + "(?:/[\\d.]+|[ \\w.]*)", "i").exec(e))) { var c = b, h = f.label || f, k = { "10.0": "10", "6.4": "10 Technical Preview", "6.3": "8.1", "6.2": "8", "6.1": "Server 2008 R2 / 7", "6.0": "Server 2008 / Vista", "5.2": "Server 2003 / XP 64-bit", "5.1": "XP", "5.01": "2000 SP1", "5.0": "2000", "4.0": "NT", "4.90": "ME" }; m && h && /^Win/i.test(c) && !/^Windows Phone /i.test(c) && (k = k[/[\d.]+$/.exec(c)]) && (c = "Windows " + k); c = String(c); m && h && (c = c.replace(RegExp(m, "i"), h)); b = c = g(c.replace(/ ce$/i, " CE").replace(/\bhpw/i, "web").replace(/\bMacintosh\b/, "Mac OS").replace(/_PowerPC\b/i, " OS").replace(/\b(OS X) [^ \d]+/i, "$1").replace(/\bMac (OS X)\b/, "$1").replace(/\/(\d)/, " $1").replace(/_/g, ".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, "").replace(/\bx86\.64\b/gi, "x86_64").replace(/\b(Windows Phone) OS\b/, "$1").replace(/\b(Chrome OS \w+) [\d.]+\b/, "$1").split(" on ")[0]) } return b }) }(["Windows Phone", "Android", "CentOS", { label: "Chrome OS", pattern: "CrOS" }, "Debian", "Fedora", "FreeBSD", "Gentoo", "Haiku", "Kubuntu", "Linux Mint", "OpenBSD", "Red Hat", "SuSE", "Ubuntu", "Xubuntu", "Cygwin", "Symbian OS", "hpwOS", "webOS ", "webOS", "Tablet OS", "Tizen", "Linux", "Mac OS X", "Macintosh", "Mac", "Windows 98;", "Windows " ]); I && (I = [I]); z && !K && (K = f([z])); if (u = /\bGoogle TV\b/.exec(K)) K = u[0]; /\bSimulator\b/i.test(e) && (K = (K ? K + " " : "") + "Simulator"); "Opera Mini" == F && /\bOPiOS\b/.test(e) && d.push("running in Turbo/Uncompressed mode"); "IE" == F && /\blike iPhone OS\b/.test(e) ? (u = p(e.replace(/like iPhone OS/, "")), z = u.manufacturer, K = u.product) : /^iP/.test(K) ? (F || (F = "Safari"), D = "iOS" + ((u = / OS ([\d_]+)/i.exec(e)) ? " " + u[1].replace(/_/g, ".") : "")) : "Konqueror" != F || /buntu/i.test(D) ? z && "Google" != z && (/Chrome/.test(F) && !/\bMobile Safari\b/i.test(e) || /\bVita\b/.test(K)) || /\bAndroid\b/.test(D) && /^Chrome/.test(F) && /\bVersion\//i.test(e) ? (F = "Android Browser", D = /\bAndroid\b/.test(D) ? D : "Android") : "Silk" == F ? (/\bMobi/i.test(e) || (D = "Android", d.unshift("desktop mode")), /Accelerated *= *true/i.test(e) && d.unshift("accelerated")) : "PaleMoon" == F && (u = /\bFirefox\/([\d.]+)\b/.exec(e)) ? d.push("identifying as Firefox " + u[1]) : "Firefox" == F && (u = /\b(Mobile|Tablet|TV)\b/i.exec(e)) ? (D || (D = "Firefox OS"), K || (K = u[1])) : !F || (u = !/\bMinefield\b/i.test(e) && /\b(?:Firefox|Safari)\b/.exec(F)) ? (F && !K && /[\/,]|^[^(]+?\)/.test(e.slice(e.indexOf(u + "/") + 8)) && (F = null), (u = K || z || D) && (K || z || /\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(D)) && (F = /[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(D) ? D : u) + " Browser")) : "Electron" == F && (u = (/\bChrome\/([\d.]+)\b/.exec(e) || 0)[1]) && d.push("Chromium " + u) : D = "Kubuntu"; n || (n = m(["(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))", "Version", a(F), "(?:Firefox|Minefield|NetFront)"])); if (u = "iCab" == I && 3 < parseFloat(n) && "WebKit" || /\bOpera\b/.test(F) && (/\bOPR\b/.test(e) ? "Blink" : "Presto") || /\b(?:Midori|Nook|Safari)\b/i.test(e) && !/^(?:Trident|EdgeHTML)$/.test(I) && "WebKit" || !I && /\bMSIE\b/i.test(e) && ("Mac OS" == D ? "Tasman" : "Trident") || "WebKit" == I && /\bPlayStation\b(?! Vita\b)/i.test(F) && "NetFront") I = [u]; "IE" == F && (u = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e) || 0)[1]) ? (F += " Mobile", D = "Windows Phone " + (/\+$/.test(u) ? u : u + ".x"), d.unshift("desktop mode")) : /\bWPDesktop\b/i.test(e) ? (F = "IE Mobile", D = "Windows Phone 8.x", d.unshift("desktop mode"), n || (n = (/\brv:([\d.]+)/.exec(e) || 0)[1])) : "IE" != F && "Trident" == I && (u = /\brv:([\d.]+)/.exec(e)) && (F && d.push("identifying as " + F + (n ? " " + n : "")), F = "IE", n = u[1]); if (T) { if (c(h, "global")) if (R && (u = R.lang.System, Q = u.getProperty("os.arch"), D = D || u.getProperty("os.name") + " " + u.getProperty("os.version")), U) { try { n = h.require("ringo/engine").version.join("."), F = "RingoJS" } catch (aa) { (u = h.system) && u.global.system == h.system && (F = "Narwhal", D || (D = u[0].os || null)) } F || (F = "Rhino") } else "object" == typeof h.process && !h.process.browser && (u = h.process) && ("object" == typeof u.versions && ("string" == typeof u.versions.electron ? (d.push("Node " + u.versions.node), F = "Electron", n = u.versions.electron) : "string" == typeof u.versions.nw && (d.push("Chromium " + n, "Node " + u.versions.node), F = "NW.js", n = u.versions.nw)), F || (F = "Node.js", Q = u.arch, D = u.platform, n = (n = /[\d.]+/.exec(u.version)) ? n[0] : null)); else b(u = h.runtime) == y ? (F = "Adobe AIR", D = u.flash.system.Capabilities.os) : b(u = h.phantom) == P ? (F = "PhantomJS", n = (u = u.version || null) && u.major + "." + u.minor + "." + u.patch) : "number" == typeof M.documentMode && (u = /\bTrident\/(\d+)/i.exec(e)) ? (n = [n, M.documentMode], (u = +u[1] + 4) != n[1] && (d.push("IE " + n[1] + " mode"), I && (I[1] = ""), n[1] = u), n = "IE" == F ? String(n[1].toFixed(1)) : n[0]) : "number" == typeof M.documentMode && /^(?:Chrome|Firefox)\b/.test(F) && (d.push("masking as " + F + " " + n), F = "IE", n = "11.0", I = ["Trident"], D = "Windows"); D = D && g(D) } n && (u = /(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(n) || /(?:alpha|beta)(?: ?\d)?/i.exec(e + ";" + (T && r.appMinorVersion)) || /\bMinefield\b/i.test(e) && "a") && (E = /b/i.test(u) ? "beta" : "alpha", n = n.replace(RegExp(u + "\\+?$"), "") + ("beta" == E ? L : J) + (/\d+\+?/.exec(u) || "")); if ("Fennec" == F || "Firefox" == F && /\b(?:Android|Firefox OS)\b/.test(D)) F = "Firefox Mobile"; else if ("Maxthon" == F && n) n = n.replace(/\.[\d.]+/, ".x"); else if (/\bXbox\b/i.test(K)) "Xbox 360" == K && (D = null), "Xbox 360" == K && /\bIEMobile\b/.test(e) && d.unshift("mobile mode"); else if (!/^(?:Chrome|IE|Opera)$/.test(F) && (!F || K || /Browser|Mobi/.test(F)) || "Windows CE" != D && !/Mobi/i.test(e)) if ("IE" == F && T) try { null === h.external && d.unshift("platform preview") } catch (aa) { d.unshift("embedded") } else(/\bBlackBerry\b/.test(K) || /\bBB10\b/.test(e)) && (u = (RegExp(K.replace(/ +/g, " *") + "/([.\\d]+)", "i").exec(e) || 0)[1] || n) ? (u = [u, /BB10/.test(e)], D = (u[1] ? (K = null, z = "BlackBerry") : "Device Software") + " " + u[0], n = null) : this != l && "Wii" != K && (T && O || /Opera/.test(F) && /\b(?:MSIE|Firefox)\b/i.test(e) || "Firefox" == F && /\bOS X (?:\d+\.){2,}/.test(D) || "IE" == F && (D && !/^Win/.test(D) && 5.5 < n || /\bWindows XP\b/.test(D) && 8 < n || 8 == n && !/\bTrident\b/.test(e))) && !t.test(u = p.call(l, e.replace(t, "") + ";")) && u.name && (u = "ing as " + u.name + ((u = u.version) ? " " + u : ""), t.test(F) ? (/\bIE\b/.test(u) && "Mac OS" == D && (D = null), u = "identify" + u) : (u = "mask" + u, F = X ? g(X.replace(/([a-z])([A-Z])/g, "$1 $2")) : "Opera", /\bIE\b/.test(u) && (D = null), T || (n = null)), I = ["Presto"], d.push(u)); else F += " Mobile"; if (u = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(e) || 0)[1]) { u = [parseFloat(u.replace(/\.(\d)$/, ".0$1")), u]; if ("Safari" == F && "+" == u[1].slice(-1)) F = "WebKit Nightly", E = "alpha", n = u[1].slice(0, -1); else if (n == u[1] || n == (u[2] = (/\bSafari\/([\d.]+\+?)/i.exec(e) || 0)[1])) n = null; u[1] = (/\bChrome\/([\d.]+)/i.exec(e) || 0)[1]; 537.36 == u[0] && 537.36 == u[2] && 28 <= parseFloat(u[1]) && "WebKit" == I && (I = ["Blink"]); T && (v || u[1]) ? (I && (I[1] = "like Chrome"), u = u[1] || (u = u[0], 530 > u ? 1 : 532 > u ? 2 : 532.05 > u ? 3 : 533 > u ? 4 : 534.03 > u ? 5 : 534.07 > u ? 6 : 534.1 > u ? 7 : 534.13 > u ? 8 : 534.16 > u ? 9 : 534.24 > u ? 10 : 534.3 > u ? 11 : 535.01 > u ? 12 : 535.02 > u ? "13+" : 535.07 > u ? 15 : 535.11 > u ? 16 : 535.19 > u ? 17 : 536.05 > u ? 18 : 536.1 > u ? 19 : 537.01 > u ? 20 : 537.11 > u ? "21+" : 537.13 > u ? 23 : 537.18 > u ? 24 : 537.24 > u ? 25 : 537.36 > u ? 26 : "Blink" != I ? "27" : "28")) : (I && (I[1] = "like Safari"), u = (u = u[0], 400 > u ? 1 : 500 > u ? 2 : 526 > u ? 3 : 533 > u ? 4 : 534 > u ? "4+" : 535 > u ? 5 : 537 > u ? 6 : 538 > u ? 7 : 601 > u ? 8 : "8")); I && (I[1] += " " + (u += "number" == typeof u ? ".x" : /[.+]/.test(u) ? "" : "+")); "Safari" == F && (!n || 45 < parseInt(n)) && (n = u) } "Opera" == F && (u = /\bzbov|zvav$/.exec(D)) ? (F += " ", d.unshift("desktop mode"), "zvav" == u ? (F += "Mini", n = null) : F += "Mobile", D = D.replace(RegExp(" *" + u + "$"), "")) : "Safari" == F && /\bChrome\b/.exec(I && I[1]) && (d.unshift("desktop mode"), F = "Chrome Mobile", n = null, /\bOS X\b/.test(D) ? (z = "Apple", D = "iOS 4.3+") : D = null); n && 0 == n.indexOf(u = /[\d.]+$/.exec(D)) && -1 < e.indexOf("/" + u + "-") && (D = String(D.replace(u, "")).replace(/^ +| +$/g, "")); I && !/\b(?:Avant|Nook)\b/.test(F) && (/Browser|Lunascape|Maxthon/.test(F) || "Safari" != F && /^iOS/.test(D) && /\bSafari\b/.test(I[1]) || /^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(F) && I[1]) && (u = I[I.length - 1]) && d.push(u); d.length && (d = ["(" + d.join("; ") + ")"]); z && K && 0 > K.indexOf(z) && d.push("on " + z); K && d.push((/^on /.test(d[d.length - 1]) ? "" : "on ") + K); if (D) { var V = (u = / ([\d.+]+)$/.exec(D)) && "/" == D.charAt(D.length - u[0].length - 1); D = { architecture: 32, family: u && !V ? D.replace(u[0], "") : D, version: u ? u[1] : null, toString: function() { var a = this.version; return this.family + (a && !V ? " " + a : "") + (64 == this.architecture ? " 64-bit" : "") } } }(u = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(Q)) && !/\bi686\b/i.test(Q) ? (D && (D.architecture = 64, D.family = D.family.replace(RegExp(" *" + u), "")), F && (/\bWOW64\b/i.test(e) || T && /\w(?:86|32)$/.test(r.cpuClass || r.platform) && !/\bWin64; x64\b/i.test(e)) && d.unshift("32-bit")) : D && /^OS X/.test(D.family) && "Chrome" == F && 39 <= parseFloat(n) && (D.architecture = 64); e || (e = null); h = {}; h.description = e; h.layout = I && I[0]; h.manufacturer = z; h.name = F; h.prerelease = E; h.product = K; h.ua = e; h.version = F && n; h.os = D || { architecture: null, family: null, version: null, toString: function() { return "null" } }; h.parse = p; h.toString = function() { return this.description || "" }; h.version && d.unshift(n); h.name && d.unshift(F); D && F && (D != String(D).split(" ")[0] || D != F.split(" ")[0] && !K) && d.push(K ? "(" + D + ")" : "on " + D); d.length && (h.description = d.join(" ")); return h } var h = { "function": !0, object: !0 }, k = h[typeof window] && window || this, f = h[typeof exports] && exports; h = h[typeof module] && module && !module.nodeType && module; var e = f && h && "object" == typeof global && global; !e || e.global !== e && e.window !== e && e.self !== e || (k = e); var m = Math.pow(2, 53) - 1, t = /\bOpera/; e = Object.prototype; var r = e.hasOwnProperty, w = e.toString, v = p(); "function" == typeof define && "object" == typeof define.amd && define.amd ? (k.platform = v, define(function() { return v })) : f && h ? l(v, function(a, b) { f[b] = a }) : k.platform = v }).call(this); function buildIOSMeta() { for (var n = [{ name: "viewport", content: "width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" }, { name: "apple-mobile-web-app-capable", content: "yes" }, { name: "apple-mobile-web-app-status-bar-style", content: "black" }], d = 0; d < n.length; d++) { var g = document.createElement("meta"); g.name = n[d].name; g.content = n[d].content; var l = window.document.head.querySelector('meta[name="' + g.name + '"]'); l && l.parentNode.removeChild(l); window.document.head.appendChild(g) } } function hideIOSFullscreenPanel() { jQuery(".xxx-ios-fullscreen-message").css("display", "none"); jQuery(".xxx-ios-fullscreen-scroll").css("display", "none"); jQuery(".xxx-game-iframe-full").removeClass("xxx-game-iframe-iphone-se") } function buildIOSFullscreenPanel() { jQuery("body").append('<div class="xxx-ios-fullscreen-message"><div class="xxx-ios-fullscreen-swipe"></div></div><div class="xxx-ios-fullscreen-scroll"></div>') } function showIOSFullscreenPanel() { jQuery(".xxx-ios-fullscreen-message").css("display", "block"); jQuery(".xxx-ios-fullscreen-scroll").css("display", "block") } function __iosResize() { window.scrollTo(0, 0); if ("iPhone" === platform.product) switch (window.devicePixelRatio) { case 2: switch (window.innerWidth) { case 568: 320 !== window.innerHeight && jQuery(".xxx-game-iframe-full").addClass("xxx-game-iframe-iphone-se"); break; case 667: 375 === window.innerHeight ? hideIOSFullscreenPanel() : showIOSFullscreenPanel(); break; default: hideIOSFullscreenPanel() } break; case 3: switch (window.innerWidth) { case 736: 414 === window.innerHeight ? hideIOSFullscreenPanel() : showIOSFullscreenPanel(); break; case 724: 375 === window.innerHeight ? hideIOSFullscreenPanel() : showIOSFullscreenPanel(); break; default: hideIOSFullscreenPanel() } break; default: hideIOSFullscreenPanel() } } function iosResize() { __iosResize(); setTimeout(function() { __iosResize() }, 500) } $(document).ready(function() { platform && "iPhone" === platform.product && (buildIOSFullscreenPanel(), buildIOSMeta()) }); jQuery(window).resize(function() { platform && "iPhone" === platform.product && iosResize() }); var s_iScaleFactor = 1, s_bIsIphone = !1, s_iOffsetX, s_iOffsetY, s_fInverseScaling = 0, s_fScaleCanvas = 0; (function(n) { (jQuery.browser = jQuery.browser || {}).mobile = /android|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(ad|hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|tablet|treo|up\.(browser|link)|vodafone|wap|webos|windows (ce|phone)|xda|xiino/i.test(n) || /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|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|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|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(n.substr(0, 4)) })(navigator.userAgent || navigator.vendor || window.opera); $(window).resize(function() { sizeHandler() }); function trace(n) { console.log(n) } function isChrome() { return /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor) } function isIOS() { var n = "iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";"); for (-1 !== navigator.userAgent.toLowerCase().indexOf("iphone") && (s_bIsIphone = !0); n.length;) if (navigator.platform === n.pop()) return !0; return s_bIsIphone = !1 } window.addEventListener("orientationchange", onOrientationChange); function onOrientationChange() { window.matchMedia("(orientation: portrait)").matches && sizeHandler(); window.matchMedia("(orientation: landscape)").matches && sizeHandler() } function getSize(n) { var d = n.toLowerCase(), g = window.document, l = g.documentElement; if (void 0 === window["inner" + n]) n = l["client" + n]; else if (window["inner" + n] != l["client" + n]) { var b = g.createElement("body"); b.id = "vpw-test-b"; b.style.cssText = "overflow:scroll"; var c = g.createElement("div"); c.id = "vpw-test-d"; c.style.cssText = "position:absolute;top:-1000px"; c.innerHTML = "<style>@media(" + d + ":" + l["client" + n] + "px){body#vpw-test-b div#vpw-test-d{" + d + ":7px!important}}</style>"; b.appendChild(c); l.insertBefore(b, g.head); n = 7 == c["offset" + n] ? l["client" + n] : window["inner" + n]; l.removeChild(b) } else n = window["inner" + n]; return n } function getIOSWindowHeight() { return document.documentElement.clientWidth / window.innerWidth * window.innerHeight } function getHeightOfIOSToolbars() { var n = (0 === window.orientation ? screen.height : screen.width) - getIOSWindowHeight(); return 1 < n ? n : 0 } function sizeHandler() { window.scrollTo(0, 1); if ($("#canvas")) { var n = navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? getIOSWindowHeight() : getSize("Height"); var d = getSize("Width"); _checkOrientation(d, n); s_iScaleFactor = s_fScaleCanvas = Math.min(n / CANVAS_HEIGHT, d / CANVAS_WIDTH); var g = CANVAS_WIDTH * s_iScaleFactor, l = CANVAS_HEIGHT * s_iScaleFactor; if (l < n) { var b = n - l; l += b; g += CANVAS_WIDTH / CANVAS_HEIGHT * b } else g < d && (b = d - g, g += b, l += CANVAS_HEIGHT / CANVAS_WIDTH * b); b = n / 2 - l / 2; var c = d / 2 - g / 2, a = CANVAS_WIDTH / g; if (c * a < -EDGEBOARD_X || b * a < -EDGEBOARD_Y) s_iScaleFactor = Math.min(n / (CANVAS_HEIGHT - 2 * EDGEBOARD_Y), d / (CANVAS_WIDTH - 2 * EDGEBOARD_X)), g = CANVAS_WIDTH * s_iScaleFactor, l = CANVAS_HEIGHT * s_iScaleFactor, b = (n - l) / 2, c = (d - g) / 2, a = CANVAS_WIDTH / g; s_fInverseScaling = a; s_iOffsetX = -1 * c * a; s_iOffsetY = -1 * b * a; 0 <= b && (s_iOffsetY = 0); 0 <= c && (s_iOffsetX = 0); null !== s_oInterface && s_oInterface.refreshButtonPos(s_iOffsetX, s_iOffsetY); null !== s_oMenu && s_oMenu.refreshButtonPos(s_iOffsetX, s_iOffsetY); s_bIsIphone ? (canvas = document.getElementById("canvas"), s_oStage.canvas.width = 2 * g, s_oStage.canvas.height = 2 * l, canvas.style.width = g + "px", canvas.style.height = l + "px", s_oStage.scaleX = s_oStage.scaleY = 2 * Math.min(g / CANVAS_WIDTH, l / CANVAS_HEIGHT)) : (s_bMobile || isChrome() || (s_oStage.canvas.width = g, s_oStage.canvas.height = l, s_iScaleFactor = Math.min(g / CANVAS_WIDTH, l / CANVAS_HEIGHT), s_oStage.scaleX = s_oStage.scaleY = s_iScaleFactor), $("#canvas").css("width", g + "px"), $("#canvas").css("height", l + "px")); 0 > b ? ($("#canvas").css("top", b + "px"), s_iCanvasOffsetHeight = b) : (b = (n - l) / 2, $("#canvas").css("top", b + "px"), s_iCanvasOffsetHeight = 0); $("#canvas").css("left", c + "px"); resizeCanvas3D(); s_iCanvasResizeWidth = g; s_iCanvasResizeHeight = l; s_iCanvasOffsetWidth = c; fullscreenHandler() } } function _checkOrientation(n, d) { s_bMobile && ENABLE_CHECK_ORIENTATION && (n > d ? "landscape" === $(".orientation-msg-container").attr("data-orientation") ? ($(".orientation-msg-container").css("display", "none"), s_oMain.startUpdate()) : ($(".orientation-msg-container").css("display", "block"), s_oMain.stopUpdate()) : "portrait" === $(".orientation-msg-container").attr("data-orientation") ? ($(".orientation-msg-container").css("display", "none"), s_oMain.startUpdate()) : ($(".orientation-msg-container").css("display", "block"), s_oMain.stopUpdate())) } function createBitmap(n, d, g) { var l = new createjs.Bitmap(n), b = new createjs.Shape; d && g ? b.graphics.beginFill("#fff").drawRect(-d / 2, -g / 2, d, g) : b.graphics.beginFill("#ff0").drawRect(0, 0, n.width, n.height); l.hitArea = b; return l } function createSprite(n, d, g, l, b, c) { n = null !== d ? new createjs.Sprite(n, d) : new createjs.Sprite(n); d = new createjs.Shape; d.graphics.beginFill("#000000").drawRect(-g, -l, b, c); n.hitArea = d; return n } function randomFloatBetween(n, d, g) { "undefined" === typeof g && (g = 2); return parseFloat(Math.min(n + Math.random() * (d - n), d).toFixed(g)) } function shuffle(n) { for (var d = n.length, g, l; 0 !== d;) l = Math.floor(Math.random() * d), --d, g = n[d], n[d] = n[l], n[l] = g; return n } function formatTime(n) { n /= 1E3; var d = Math.floor(n / 60); n = parseFloat(n - 60 * d).toFixed(1); var g = ""; g = 10 > d ? g + ("0" + d + ":") : g + (d + ":"); return 10 > n ? g + ("0" + n) : g + n } function degreesToRadians(n) { return n * Math.PI / 180 } function checkRectCollision(n, d) { var g = getBounds(n, .9); var l = getBounds(d, .98); return calculateIntersection(g, l) } function calculateIntersection(n, d) { var g, l, b, c; var a = n.x + (g = n.width / 2); var q = n.y + (l = n.height / 2); var p = d.x + (b = d.width / 2); var h = d.y + (c = d.height / 2); a = Math.abs(a - p) - (g + b); q = Math.abs(q - h) - (l + c); return 0 > a && 0 > q ? (a = Math.min(Math.min(n.width, d.width), -a), q = Math.min(Math.min(n.height, d.height), -q), { x: Math.max(n.x, d.x), y: Math.max(n.y, d.y), width: a, height: q, rect1: n, rect2: d }) : null } function getBounds(n, d) { var g = { x: Infinity, y: Infinity, width: 0, height: 0 }; if (n instanceof createjs.Container) { g.x2 = -Infinity; g.y2 = -Infinity; var l = n.children, b = l.length, c; for (c = 0; c < b; c++) { var a = getBounds(l[c], 1); a.x < g.x && (g.x = a.x); a.y < g.y && (g.y = a.y); a.x + a.width > g.x2 && (g.x2 = a.x + a.width); a.y + a.height > g.y2 && (g.y2 = a.y + a.height) } Infinity == g.x && (g.x = 0); Infinity == g.y && (g.y = 0); Infinity == g.x2 && (g.x2 = 0); Infinity == g.y2 && (g.y2 = 0); g.width = g.x2 - g.x; g.height = g.y2 - g.y; delete g.x2; delete g.y2 } else { if (n instanceof createjs.Bitmap) { b = n.sourceRect || n.image; c = b.width * d; var q = b.height * d } else if (n instanceof createjs.Sprite) if (n.spriteSheet._frames && n.spriteSheet._frames[n.currentFrame] && n.spriteSheet._frames[n.currentFrame].image) { b = n.spriteSheet.getFrame(n.currentFrame); c = b.rect.width; q = b.rect.height; l = b.regX; var p = b.regY } else g.x = n.x || 0, g.y = n.y || 0; else g.x = n.x || 0, g.y = n.y || 0; l = l || 0; c = c || 0; p = p || 0; q = q || 0; g.regX = l; g.regY = p; b = n.localToGlobal(0 - l, 0 - p); a = n.localToGlobal(c - l, q - p); c = n.localToGlobal(c - l, 0 - p); l = n.localToGlobal(0 - l, q - p); g.x = Math.min(Math.min(Math.min(b.x, a.x), c.x), l.x); g.y = Math.min(Math.min(Math.min(b.y, a.y), c.y), l.y); g.width = Math.max(Math.max(Math.max(b.x, a.x), c.x), l.x) - g.x; g.height = Math.max(Math.max(Math.max(b.y, a.y), c.y), l.y) - g.y } return g } function NoClickDelay(n) { this.element = n; window.Touch && this.element.addEventListener("touchstart", this, !1) } NoClickDelay.prototype = { handleEvent: function(n) { switch (n.type) { case "touchstart": this.onTouchStart(n); break; case "touchmove": this.onTouchMove(n); break; case "touchend": this.onTouchEnd(n) } }, onTouchStart: function(n) { n.preventDefault(); this.moved = !1; this.element.addEventListener("touchmove", this, !1); this.element.addEventListener("touchend", this, !1) }, onTouchMove: function(n) { this.moved = !0 }, onTouchEnd: function(n) { this.element.removeEventListener("touchmove", this, !1); this.element.removeEventListener("touchend", this, !1); if (!this.moved) { n = document.elementFromPoint(n.changedTouches[0].clientX, n.changedTouches[0].clientY); 3 == n.nodeType && (n = n.parentNode); var d = document.createEvent("MouseEvents"); d.initEvent("click", !0, !0); n.dispatchEvent(d) } } }; (function() { function n(g) { var n = { focus: "visible", focusin: "visible", pageshow: "visible", blur: "hidden", focusout: "hidden", pagehide: "hidden" }; g = g || window.event; g.type in n ? document.body.className = n[g.type] : (document.body.className = this[d] ? "hidden" : "visible", "hidden" === document.body.className ? s_oMain.stopUpdate() : s_oMain.startUpdate()) } var d = "hidden"; d in document ? document.addEventListener("visibilitychange", n) : (d = "mozHidden") in document ? document.addEventListener("mozvisibilitychange", n) : (d = "webkitHidden") in document ? document.addEventListener("webkitvisibilitychange", n) : (d = "msHidden") in document ? document.addEventListener("msvisibilitychange", n) : "onfocusin" in document ? document.onfocusin = document.onfocusout = n : window.onpageshow = window.onpagehide = window.onfocus = window.onblur = n })(); function playSound(n, d, g) { return !1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile ? (s_aSounds[n].play(), s_aSounds[n].volume(d), s_aSounds[n].loop(g), s_aSounds[n]) : null } function stopSound(n) { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || s_aSounds[n].stop() } function setVolume(n, d) { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || s_aSounds[n].volume(d) } function setMute(n, d) { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || s_aSounds[n].mute(d) } function fadeSound(n, d, g, l) { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || s_aSounds[l].fade(n, d, g) } function ctlArcadeResume() { null !== s_oMain && s_oMain.startUpdate() } function ctlArcadePause() { null !== s_oMain && s_oMain.stopUpdate() } function getParamValue(n) { for (var d = window.location.search.substring(1).split("&"), g = 0; g < d.length; g++) { var l = d[g].split("="); if (l[0] == n) return l[1] } } function rotateVector2D(n, d) { return { x: d.x * Math.cos(n) + d.y * Math.sin(n), y: d.x * -Math.sin(n) + d.y * Math.cos(n) } } function normalize(n, d) { 0 < d && (n.x /= d, n.y /= d); return n } function findNearestIntersectingObject(n, d, g, l) { var b = CANVAS_RESIZE_WIDTH + 2 * OFFSET_WIDTH, c = CANVAS_RESIZE_HEIGHT + 2 * OFFSET_HEIGHT, a = new THREE.Raycaster, q = new THREE.Vector3; q.x = n / b * 2 - 1; q.y = 2 * -(d / c) + 1; q.z = .5; a.setFromCamera(q, g); n = a.intersectObjects(l, !0); d = !1; 0 < n.length && (d = n[0]); return d } function distance(n, d, g, l) { n -= g; d -= l; return Math.sqrt(n * n + d * d) } function distance2(n, d, g, l) { n -= g; d -= l; return n * n + d * d } function resizeCanvas3D() { $("canvas").each(function() { "#canvas" != $(this).attr("id") && ($(this).css("width", $("#canvas").css("width")), $(this).css("height", $("#canvas").css("height")), $(this).css("position", $("#canvas").css("position")), $(this).css("left", $("#canvas").css("left")), $(this).css("top", $("#canvas").css("top"))) }) } function createOrthoGraphicCamera() { var n = new THREE.PerspectiveCamera(FOV, CANVAS_WIDTH / CANVAS_HEIGHT, NEAR, FAR); n.rotation.x = Math.PI / 180 * CAMERA_PROPERTIES.rot_x; n.rotation.y = Math.PI / 180 * CAMERA_PROPERTIES.rot_y; n.rotation.z = Math.PI / 180 * CAMERA_PROPERTIES.rot_z; n.position.set(CAMERA_PROPERTIES.x, CAMERA_PROPERTIES.y, CAMERA_PROPERTIES.z); n.updateProjectionMatrix(); n.updateMatrixWorld(); return n } function rotateVector2D(n, d) { return { x: d.x * Math.cos(n) + d.y * Math.sin(n), y: d.x * -Math.sin(n) + d.y * Math.cos(n), z: 0 } } Math.radians = function(n) { return n * Math.PI / 180 }; Math.degrees = function(n) { return 180 / Math.PI * n }; function distanceV3(n, d, g, l, b, c) { n -= l; d -= b; g -= c; return Math.sqrt(n * n + d * d + g * g) } function distanceV2(n, d) { var g = n.x - d.x, l = n.y - d.y; return Math.sqrt(g * g + l * l) } function saveItem(n, d) { localStorage.setItem(n, d) } function getItem(n) { return localStorage.getItem(n) } function clearAllItem() { localStorage.clear() } function fullscreenHandler() { ENABLE_FULLSCREEN && screenfull.enabled && (s_bFullscreen = screenfull.isFullscreen, null !== s_oInterface && s_oInterface.resetFullscreenBut(), null !== s_oMenu && s_oMenu.resetFullscreenBut()) } if (screenfull.enabled) screenfull.on("change", function() { s_bFullscreen = screenfull.isFullscreen; null !== s_oInterface && s_oInterface.resetFullscreenBut(); null !== s_oMenu && s_oMenu.resetFullscreenBut() }); function CSpriteLibrary() { var n = {}, d, g, l, b, c, a; this.init = function(q, p, h) { d = {}; l = g = 0; b = q; c = p; a = h }; this.addSprite = function(a, b) { if (!n.hasOwnProperty(a)) { var c = new Image; n[a] = d[a] = { szPath: b, oSprite: c, bLoaded: !1 }; g++ } }; this.getSprite = function(a) { return n.hasOwnProperty(a) ? n[a].oSprite : null }; this._onSpritesLoaded = function() { g = 0; c.call(a) }; this._onSpriteLoaded = function() { b.call(a); ++l === g && this._onSpritesLoaded() }; this.loadSprites = function() { for (var a in d) d[a].oSprite.oSpriteLibrary = this, d[a].oSprite.szKey = a, d[a].oSprite.onload = function() { this.oSpriteLibrary.setLoaded(this.szKey); this.oSpriteLibrary._onSpriteLoaded(this.szKey) }, d[a].oSprite.onerror = function(a) { var b = a.currentTarget; setTimeout(function() { d[b.szKey].oSprite.src = d[b.szKey].szPath }, 500) }, d[a].oSprite.src = d[a].szPath }; this.setLoaded = function(a) { n[a].bLoaded = !0 }; this.isLoaded = function(a) { return n[a].bLoaded }; this.getNumSprites = function() { return g } } var CANVAS_WIDTH = 790, CANVAS_HEIGHT = 1410, CANVAS_WIDTH_HALF = .5 * CANVAS_WIDTH, CANVAS_HEIGHT_HALF = .5 * CANVAS_HEIGHT, EDGEBOARD_X = 150, EDGEBOARD_Y = 212, DISABLE_SOUND_MOBILE = !1, FONT_GAME = "Arial", SECONDARY_FONT = "blackplotanregular", MS_FADE_SOUNDTRACK = 750, FPS = 30, FPS_DESKTOP = 60, FPS_TIME = 1 / FPS, ROLL_BALL_RATE = 60 / FPS, TIME_REFRESH_DIRECTION = .05, TIME_RESET_LAUNCH = 3, DIRECTION_VELOCITY = -2, DIRECTION_CHARACTER_VELOCITY = 6, LAUNCH_TURN = 10, TURNS_BOARD_POS = { x: 0, y: 362 }, NUM_SPRITE_MONITOR = 52, NUM_SPRITE_PLAYER = 36, CHARACTER_START_POS = { x: 40, y: 702 }, STATE_LOADING = 0, STATE_MENU = 1, STATE_HELP = 1, STATE_GAME = 3, ON_MOUSE_DOWN = 0, ON_MOUSE_UP = 1, ON_MOUSE_OVER = 2, ON_MOUSE_OUT = 3, ON_DRAG_START = 4, ON_DRAG_END = 5, ON_TWEEN_ENDED = 6, ON_BUT_NO_DOWN = 7, ON_BUT_YES_DOWN = 8, STEP_RATE = 1, TEXT_SIZE = [80, 100, 130], TEXT_EXCELLENT_COLOR = ["#fff", "#5d96fe"], TEXT_COLOR = "#ffffff", TEXT_COLOR_STROKE = "#000000", TIME_INTERVAL_STROBE = .2, PHYSICS_ACCURACY = 3, BALL_VELOCITY_MULTIPLIER = 1, PHYSICS_STEP = 1 / (FPS * STEP_RATE), STATE_INIT = 0, STATE_PLAY = 1, STATE_FINISH = 2, STATE_PAUSE = 3, TIME_REFRESH_POSITION, MONITOR_STRIKE = 0, MONITOR_SPARE = 1, MONITOR_GUTTER = 2, BALL_MASS = 49, BALL_RADIUS = 12.5, BALL = 0, PINS = 1, WALL = 2, FLOOR = 3, CHANNEL = 4, PINS_FLOOR = 4, WALL_TRACK = 5, SIDE_PINS_FLOOR = 6, BALL_LINEAR_DAMPING = 0, OFFSET_BALL_POS_X = 10, OBJECT, MIN_BALL_VEL_ROTATION = .1, FOV = 40, INTERVAL_SHOOT = 1, DIRECTION = 0, POWER = 1, EFFECT = 2, EFFECT_POWER_RATE = -(.4 * STEP_RATE), MIN_FORCE_BALL_GUTTER = -30, MAX_EFFECT_ANGLE = 45, MONITOR_WAIT_TIME = 1, LIMIT_HAND_RANGE_POS = { x: 35.2 }, POSITION_BALL = { x: 0, y: 900, z: -7 + BALL_RADIUS }, GOAL_LINE_POS = { x: 0, y: 31, z: -2.7 }, HAND_KEEPER_SIZE = { width: 1.8, depth: .5, height: 1.5 }, WALL_PINS_SIZE = { width: 80, depth: 1, height: 150 }, WALL_PINS_DOWN_SIZE = { width: 80, depth: 100, height: 1 }, WALL_PINS_FORWARD_SIZE = { width: 80, depth: 2, height: 77 }, WALL_PINS_POSITION = { x: 0, y: -1105, z: -27 }, WALL_TRACK_POSITION = { x: 0, y: 0, z: 20 }, WALL_TRACK_SIZE = { width: 1, depth: 905, height: 100, offsetX: 82 }, ROOF_TRACK_SIZE = { width: 82, depth: 70, height: 1, offsetY: -835 }, SIDE_WALL_PINS_SIZE = { width: 1, depth: 100, height: 150 }, FLOOR_PINS_SIZE = { width: 53, depth: 875, height: 20 }, FLOOR_WALL_PINS_SIZE = { width: 80, depth: 1, height: 100 }, FLOOR_WALL_PINS_POSITION = { x: 0, y: -765, z: 20 }, FLOOR_PINS_POSITION = { x: 0, y: -39, z: -29 }, PINS_BINDER_PROPERTIES = { width: 75, depth: 2, height: 25 }, PINS_BINDER_POSITION = { x: 0, y: -750, z: 10 }, SENSOR_POSITION = { x: 0, y: -1005, z: -175 }, SENSOR_SIZE = { width: 75, depth: 95, height: 1 }, WALL_TRACK_DEPTH_SIZE = { width: 100, depth: 1, height: 100 }, WALL_TRACK_DEPTH_POSITION = { x: 0, y: -914, z: 0 }, FLOOR_PINS_SIDE_PROPERTIES = { width: 15, depth: FLOOR_PINS_SIZE.depth, height: 1, rot: Math.radians(0) }, PIN_PROPERTY = { radius_top: 8, radius_bottom: 7, height: 50, segments: 7, mass: 2.52015625, linearDamping: .01, angularDamping: .5 }, PIN_DIAMETER = 2 * PIN_PROPERTY.radius_top, BALL_PROPERTY = { mass: BALL_MASS, linearDamping: 0, angularDamping: .05 }, OFFSET_TRACK_POSITION = { x: 0, y: 0, z: -9 }, PINS_POSITION_Z = OFFSET_TRACK_POSITION.z + .5 * PIN_PROPERTY.height, FIRST_PIN_POSITION = -810, DISTANCE_PIN_OFFSET = .75, MIN_VELOCITY_PINS = .1, DISTANCE_PIN_Y = -5, PIN_BINDER_TO_Y = -950, PINS_POSITION = [{ x: 0, y: FIRST_PIN_POSITION, z: PINS_POSITION_Z }, { x: PIN_DIAMETER * DISTANCE_PIN_OFFSET, y: FIRST_PIN_POSITION + DISTANCE_PIN_Y - PIN_DIAMETER, z: PINS_POSITION_Z }, { x: -PIN_DIAMETER * DISTANCE_PIN_OFFSET, y: FIRST_PIN_POSITION + DISTANCE_PIN_Y - PIN_DIAMETER, z: PINS_POSITION_Z }, { x: -PIN_DIAMETER * DISTANCE_PIN_OFFSET * 2, y: FIRST_PIN_POSITION + 2 * (DISTANCE_PIN_Y - PIN_DIAMETER), z: PINS_POSITION_Z }, { x: 0, y: FIRST_PIN_POSITION + 2 * (DISTANCE_PIN_Y - PIN_DIAMETER), z: PINS_POSITION_Z }, { x: PIN_DIAMETER * DISTANCE_PIN_OFFSET * 2, y: FIRST_PIN_POSITION + 2 * (DISTANCE_PIN_Y - PIN_DIAMETER), z: PINS_POSITION_Z }, { x: PIN_DIAMETER * DISTANCE_PIN_OFFSET * 3, y: FIRST_PIN_POSITION + 3 * (DISTANCE_PIN_Y - PIN_DIAMETER), z: PINS_POSITION_Z }, { x: PIN_DIAMETER * DISTANCE_PIN_OFFSET, y: FIRST_PIN_POSITION + 3 * (DISTANCE_PIN_Y - PIN_DIAMETER), z: PINS_POSITION_Z }, { x: -PIN_DIAMETER * DISTANCE_PIN_OFFSET, y: FIRST_PIN_POSITION + 3 * (DISTANCE_PIN_Y - PIN_DIAMETER), z: PINS_POSITION_Z }, { x: -PIN_DIAMETER * DISTANCE_PIN_OFFSET * 3, y: FIRST_PIN_POSITION + 3 * (DISTANCE_PIN_Y - PIN_DIAMETER), z: PINS_POSITION_Z }], OFFSET_FIELD_Y = 35, OFFSET_FIELD_X = 35, MAX_LAUNCH_FORCE = 200 * BALL_MASS, MIN_LAUNCH_FORCE = .8 * BALL_MASS, FORCE_RATE = 2.5 * BALL_MASS, PINS_REFLECTION_LIMIT = .35, BALL_SCALE_FACTOR = .14, PIN_ALPHA_FACTOR = .9, PIN_SCALE_FACTOR = .3, SHADOW_SCALE_FACTOR = 18.5, FADE_PIN_FACTOR = WALL_TRACK_DEPTH_POSITION.y - .01, BOARD_SCALE_F = .25, PIN_REF_REGY_FACTOR = 20, BUFFER_ANIM_MONITOR = FPS / 30 * 20, BUFFER_ANIM_PLAYER = FPS / 20, SHOW_3D_RENDER = !1, SHOW_DEPTH_TRACK_MODEL = !1, CAMERA_TEST_TRACKBALL = !0, CAMERA_TEST_TRANSFORM = !1, PIN_TEST = !1, SHOW_PROXY_COLLISION = !1, CAMERA_TEST_LOOK_AT = { x: 0, y: -500, z: -100 }, OPACITY_INTENSITY_3D = 1, PINS_PROPERTIES_TEST = { x: 0, y: 250, z: PINS_POSITION_Z + 20 }, BALL_Z_FORCE_RANGE = { min: 3, max: 10 }, CAMERA_PROPERTIES = { x: 0, y: 1500, z: 300, rot_x: 105, rot_y: 180, rot_z: 0 }, NEAR = 10, FAR = 4E3, ENABLE_FULLSCREEN, ENABLE_CHECK_ORIENTATION, TEXT_PRELOADER_CONTINUE = "START", TEXT_GAMEOVER = "GAME OVER", TEXT_SCORE = "TOTAL SCORE", TEXT_HELP1_PC = "PRESS SPACE BAR TO SWITCH", TEXT_HELP1_MOBILE = "TOUCH DISPLAY TO SWITCH", TEXT_POWER = "POWER", TEXT_EFFECT = "EFFECT", TEXT_TOTAL = "TOTAL", TEXT_ARE_SURE = "ARE YOU SURE?", TEXT_CREDITS_DEVELOPED = "DEVELOPED BY", TEXT_LINK1 = "WWW.CODETHISLAB.COM", TEXT_MOVE = "MOVE", TEXT_PERFECT = "PERFECT SCORE", TEXT_SHARE_IMAGE = "200x200.jpg", TEXT_SHARE_TITLE = "Congratulations!", TEXT_SHARE_MSG1 = "You collected <strong>", TEXT_SHARE_MSG2 = " points</strong>!<br><br>Share your score with your friends!", TEXT_SHARE_SHARE1 = "My score is ", TEXT_SHARE_SHARE2 = " points! Can you do better?"; function CPreloader() { var n, d, g, l, b, c, a, q, p, h; this._init = function() { s_oSpriteLibrary.init(this._onImagesLoaded, this._onAllImagesLoaded, this); s_oSpriteLibrary.addSprite("progress_bar", "./sprites/progress_bar.png"); s_oSpriteLibrary.addSprite("200x200", "./sprites/200x200.jpg"); s_oSpriteLibrary.addSprite("but_start", "./sprites/but_start.png"); s_oSpriteLibrary.loadSprites(); h = new createjs.Container; s_oStage.addChild(h) }; this.unload = function() { h.removeAllChildren(); p.unload() }; this._onImagesLoaded = function() {}; this._onAllImagesLoaded = function() { this.attachSprites(); s_oMain.preloaderReady() }; this.attachSprites = function() { var k = new createjs.Shape; k.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); h.addChild(k); k = s_oSpriteLibrary.getSprite("200x200"); a = createBitmap(k); a.regX = .5 * k.width; a.regY = .5 * k.height; a.x = CANVAS_WIDTH / 2; a.y = CANVAS_HEIGHT / 2 - 180; h.addChild(a); q = new createjs.Shape; q.graphics.beginFill("rgba(0,0,0,0.01)").drawRoundRect(a.x - 100, a.y - 100, 200, 200, 10); h.addChild(q); a.mask = q; k = s_oSpriteLibrary.getSprite("progress_bar"); l = createBitmap(k); l.x = CANVAS_WIDTH / 2 - k.width / 2; l.y = CANVAS_HEIGHT / 2 + 50; h.addChild(l); n = k.width; d = k.height; b = new createjs.Shape; b.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(l.x, l.y, 1, d); h.addChild(b); l.mask = b; g = new createjs.Text("", "30px " + FONT_GAME, "#fff"); g.x = CANVAS_WIDTH / 2; g.y = CANVAS_HEIGHT / 2 + 100; g.textBaseline = "alphabetic"; g.textAlign = "center"; h.addChild(g); k = s_oSpriteLibrary.getSprite("but_start"); p = new CTextButton(CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2, k, TEXT_PRELOADER_CONTINUE, "Arial", "#000", 50, h); p.addEventListener(ON_MOUSE_UP, this._onButStartRelease, this); p.setVisible(!1); c = new createjs.Shape; c.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); h.addChild(c); createjs.Tween.get(c).to({ alpha: 0 }, 500).call(function() { createjs.Tween.removeTweens(c); h.removeChild(c) }) }; this._onButStartRelease = function() { s_oMain._onRemovePreloader() }; this.refreshLoader = function(a) { g.text = a + "%"; 100 === a && (p.setVisible(!0), g.visible = !1, l.visible = !1); b.graphics.clear(); a = Math.floor(a * n / 100); b.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(l.x, l.y, a, d) }; this._init() } function CMain(n) { var d, g = 0, l = 0, b = STATE_LOADING, c, a; this.initContainer = function() { var a = document.getElementById("canvas"); s_oStage = new createjs.Stage(a); createjs.Touch.enable(s_oStage); s_oStage.preventSelection = !1; s_bMobile = jQuery.browser.mobile; !1 === s_bMobile ? (s_oStage.enableMouseOver(20), $("body").on("contextmenu", "#canvas", function(a) { return !1 }), FPS = FPS_DESKTOP, FPS_TIME = 1 / FPS, BUFFER_ANIM_MONITOR = FPS / 30 * 20, PHYSICS_STEP = 1 / (FPS * STEP_RATE), ROLL_BALL_RATE = 60 / FPS) : BALL_VELOCITY_MULTIPLIER = .8; s_iPrevTime = (new Date).getTime(); createjs.Ticker.addEventListener("tick", this._update); createjs.Ticker.framerate = FPS; navigator.userAgent.match(/Windows Phone/i) && (DISABLE_SOUND_MOBILE = !0); s_oSpriteLibrary = new CSpriteLibrary; c = new CPreloader; d = !0 }; this.soundLoaded = function() { g++; c.refreshLoader(Math.floor(g / l * 100)) }; this._initSounds = function() { s_aSoundsInfo = []; s_aSoundsInfo.push({ path: "./sounds/", filename: "ball_hitting", loop: !1, volume: 1, ingamename: "ball_hitting" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "click", loop: !1, volume: 1, ingamename: "click" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "ball_crash", loop: !1, volume: 1, ingamename: "ball_crash" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "binder", loop: !1, volume: 1, ingamename: "binder" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "pin_hitted", loop: !1, volume: 1, ingamename: "pin_hitted" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "gingle_gutterball", loop: !1, volume: 1, ingamename: "gingle_gutterball" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "gingle_spare", loop: !1, volume: 1, ingamename: "gingle_spare" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "gingle_strike", loop: !1, volume: 1, ingamename: "gingle_strike" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "ambience", loop: !0, volume: 1, ingamename: "ambience" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "soundtrack", loop: !0, volume: 1, ingamename: "soundtrack" }); l += s_aSoundsInfo.length; s_aSounds = []; for (var a = 0; a < s_aSoundsInfo.length; a++) this.tryToLoadSound(s_aSoundsInfo[a], !1) }; this.tryToLoadSound = function(a, b) { setTimeout(function() { s_aSounds[a.ingamename] = new Howl({ src: [a.path + a.filename + ".mp3"], autoplay: !1, preload: !0, loop: a.loop, volume: a.volume, onload: s_oMain.soundLoaded, onloaderror: function(a, b) { for (var e = 0; e < s_aSoundsInfo.length; e++) if (a === s_aSounds[s_aSoundsInfo[e].ingamename]._sounds[0]._id) { s_oMain.tryToLoadSound(s_aSoundsInfo[e], !0); break } } }) }, b ? 200 : 0) }; this._loadImages = function() { s_oSpriteLibrary.init(this._onImagesLoaded, this._onAllImagesLoaded, this); s_oSpriteLibrary.addSprite("but_play", "./sprites/but_play.png"); s_oSpriteLibrary.addSprite("but_exit", "./sprites/but_exit.png"); s_oSpriteLibrary.addSprite("bg_menu", "./sprites/bg_menu.jpg"); s_oSpriteLibrary.addSprite("msg_box", "./sprites/msg_box.png"); s_oSpriteLibrary.addSprite("audio_icon", "./sprites/audio_icon.png"); s_oSpriteLibrary.addSprite("but_home", "./sprites/but_home.png"); s_oSpriteLibrary.addSprite("but_restart", "./sprites/but_restart.png"); s_oSpriteLibrary.addSprite("ball", "./sprites/ball.png"); s_oSpriteLibrary.addSprite("but_continue", "./sprites/but_continue.png"); s_oSpriteLibrary.addSprite("but_yes", "./sprites/but_yes.png"); s_oSpriteLibrary.addSprite("but_no", "./sprites/but_no.png"); s_oSpriteLibrary.addSprite("but_info", "./sprites/but_info.png"); s_oSpriteLibrary.addSprite("logo_ctl", "./sprites/logo_ctl.png"); s_oSpriteLibrary.addSprite("arrow_right", "./sprites/arrow_right.png"); s_oSpriteLibrary.addSprite("arrow_left", "./sprites/arrow_left.png"); s_oSpriteLibrary.addSprite("ball_shadow", "./sprites/ball_shadow.png"); s_oSpriteLibrary.addSprite("pin", "./sprites/pin.png"); s_oSpriteLibrary.addSprite("ball_ref", "./sprites/ball_ref.png"); s_oSpriteLibrary.addSprite("bg_help", "./sprites/bg_help.png"); s_oSpriteLibrary.addSprite("power_bar_bg", "./sprites/power_bar_bg.png"); s_oSpriteLibrary.addSprite("power_bar_fill", "./sprites/power_bar_fill.png"); s_oSpriteLibrary.addSprite("power_bar_frame", "./sprites/power_bar_frame.png"); s_oSpriteLibrary.addSprite("effect_arrow", "./sprites/effect_arrow.png"); s_oSpriteLibrary.addSprite("key_left", "./sprites/key_left.png"); s_oSpriteLibrary.addSprite("key_right", "./sprites/key_right.png"); s_oSpriteLibrary.addSprite("turn_board", "./sprites/turn_board.png"); s_oSpriteLibrary.addSprite("bowling_track", "./sprites/bowling_track.png"); s_oSpriteLibrary.addSprite("monitor", "./sprites/monitor.jpg"); s_oSpriteLibrary.addSprite("pattern_monitor", "./sprites/pattern_monitor.png"); s_oSpriteLibrary.addSprite("pin_binder", "./sprites/pin_binder.png"); s_oSpriteLibrary.addSprite("semaphore", "./sprites/semaphore.png"); s_oSpriteLibrary.addSprite("total_board", "./sprites/total_board.png"); s_oSpriteLibrary.addSprite("last_turn_board", "./sprites/last_turn_board.png"); s_oSpriteLibrary.addSprite("but_fullscreen", "./sprites/but_fullscreen.png"); for (var a = 0; a < NUM_SPRITE_MONITOR; a++) s_oSpriteLibrary.addSprite("monitor_strike_" + a, "./sprites/monitor_strike/monitor_strike_" + a + ".jpg"), s_oSpriteLibrary.addSprite("monitor_spare_" + a, "./sprites/monitor_spare/monitor_spare_" + a + ".jpg"), s_oSpriteLibrary.addSprite("monitor_gutterball_" + a, "./sprites/monitor_gutterball/monitor_gutterball_" + a + ".jpg"); for (a = 0; a < NUM_SPRITE_PLAYER; a++) s_oSpriteLibrary.addSprite("player_" + a, "./sprites/player_anim/player_" + a + ".png"); l += s_oSpriteLibrary.getNumSprites(); s_oSpriteLibrary.loadSprites() }; this._onImagesLoaded = function() { g++; c.refreshLoader(Math.floor(g / l * 100)) }; this._onAllImagesLoaded = function() {}; this.preloaderReady = function() { this._loadImages(); !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || this._initSounds(); d = !0 }; this._onRemovePreloader = function() { c.unload(); s_oSoundTrack = playSound("soundtrack", 1, !0); this.gotoMenu() }; this.gotoMenu = function() { new CMenu; b = STATE_MENU }; this.gotoGame = function() { a = new CGame(q); b = STATE_GAME }; this.gotoHelp = function() { new CHelp; b = STATE_HELP }; this.stopUpdate = function() { d = !1; createjs.Ticker.paused = !0; $("#block_game").css("display", "block"); !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || Howler.mute(!0) }; this.startUpdate = function() { s_iPrevTime = (new Date).getTime(); d = !0; createjs.Ticker.paused = !1; $("#block_game").css("display", "none"); (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) && s_bAudioActive && Howler.mute(!1) }; this._update = function(c) { if (!1 !== d) { var h = (new Date).getTime(); s_iTimeElaps = h - s_iPrevTime; s_iCntTime += s_iTimeElaps; s_iCntFps++; s_iPrevTime = h; 1E3 <= s_iCntTime && (s_iCurFps = s_iCntFps, s_iCntTime -= 1E3, s_iCntFps = 0); b === STATE_GAME && a.update(); s_oStage.update(c) } }; s_oMain = this; var q = n; ENABLE_CHECK_ORIENTATION = n.check_orientation; ENABLE_FULLSCREEN = n.fullscreen; this.initContainer() } var s_bMobile, s_bAudioActive = !0, s_iCntTime = 0, s_iTimeElaps = 0, s_iPrevTime = 0, s_iCntFps = 0, s_iCurFps = 0, s_iCanvasResizeHeight, s_iCanvasResizeWidth, s_iCanvasOffsetHeight, s_iCanvasOffsetWidth, s_iAdsLevel = 1, s_oDrawLayer, s_oStage, s_oMain, s_oSpriteLibrary, s_oSoundTrack = null, s_bFullscreen = !1, s_aSounds, s_aSoundsInfo; function CTextButton(n, d, g, l, b, c, a, q) { var p, h, k, f, e; this._init = function(a, b, e, f, c, d, q, g) { p = []; h = []; var m = createBitmap(e), r = Math.ceil(q / 20), t = new createjs.Text(f, "bold " + q + "px " + c, "#000000"); t.textAlign = "center"; t.textBaseline = "alphabetic"; var n = t.getBounds(); t.x = e.width / 2 + r; t.y = Math.floor(e.height / 2) + n.height / 3 + r; f = new createjs.Text(f, "bold " + q + "px " + c, d); f.textAlign = "center"; f.textBaseline = "alphabetic"; n = f.getBounds(); f.x = e.width / 2; f.y = Math.floor(e.height / 2) + n.height / 3; k = new createjs.Container; k.x = a; k.y = b; k.regX = e.width / 2; k.regY = e.height / 2; k.addChild(m, f); s_bMobile || (k.cursor = "pointer"); g.addChild(k); this._initListener() }; this.unload = function() { k.off("mousedown", f); k.off("pressup", e); q.removeChild(k) }; this.setVisible = function(a) { k.visible = a }; this._initListener = function() { f = k.on("mousedown", this.buttonDown); e = k.on("pressup", this.buttonRelease) }; this.addEventListener = function(a, b, e) { p[a] = b; h[a] = e }; this.buttonRelease = function() { k.scaleX = 1; k.scaleY = 1; playSound("click", 1, !1); p[ON_MOUSE_UP] && p[ON_MOUSE_UP].call(h[ON_MOUSE_UP]) }; this.buttonDown = function() { k.scaleX = .9; k.scaleY = .9; p[ON_MOUSE_DOWN] && p[ON_MOUSE_DOWN].call(h[ON_MOUSE_DOWN]) }; this.setPosition = function(a, b) { k.x = a; k.y = b }; this.setX = function(a) { k.x = a }; this.setY = function(a) { k.y = a }; this.getButtonImage = function() { return k }; this.getX = function() { return k.x }; this.getY = function() { return k.y }; this._init(n, d, g, l, b, c, a, q); return this } function CToggle(n, d, g, l, b) { var c, a, q, p, h, k, f; this._init = function(b, f, k, d, g) { h = void 0 !== g ? g : s_oStage; a = []; q = []; g = new createjs.SpriteSheet({ images: [k], frames: { width: k.width / 2, height: k.height, regX: k.width / 2 / 2, regY: k.height / 2 }, animations: { state_true: [0], state_false: [1] } }); c = d; p = createSprite(g, "state_" + c, k.width / 2 / 2, k.height / 2, k.width / 2, k.height); p.x = b; p.y = f; p.stop(); s_bMobile || (p.cursor = "pointer"); h.addChild(p); this._initListener() }; this.unload = function() { p.off("mousedown", k); p.off("pressup", f); h.removeChild(p) }; this._initListener = function() { k = p.on("mousedown", this.buttonDown); f = p.on("pressup", this.buttonRelease) }; this.addEventListener = function(b, f, c) { a[b] = f; q[b] = c }; this.setCursorType = function(a) { p.cursor = a }; this.setActive = function(a) { c = a; p.gotoAndStop("state_" + c) }; this.buttonRelease = function() { p.scaleX = 1; p.scaleY = 1; playSound("click", 1, !1); c = !c; p.gotoAndStop("state_" + c); a[ON_MOUSE_UP] && a[ON_MOUSE_UP].call(q[ON_MOUSE_UP], c) }; this.buttonDown = function() { p.scaleX = .9; p.scaleY = .9; a[ON_MOUSE_DOWN] && a[ON_MOUSE_DOWN].call(q[ON_MOUSE_DOWN]) }; this.setPosition = function(a, b) { p.x = a; p.y = b }; this._init(n, d, g, l, b) } function CGfxButton(n, d, g, l) { var b, c, a, q, p, h, k, f, e = !1; this._init = function(e, f, k) { b = []; c = []; q = []; a = createBitmap(k); a.x = e; a.y = f; h = p = 1; a.regX = k.width / 2; a.regY = k.height / 2; s_bMobile || (a.cursor = "pointer"); m.addChild(a); this._initListener() }; this.unload = function() { a.off("mousedown", k); a.off("pressup", f); m.removeChild(a) }; this.setVisible = function(b) { a.visible = b }; this.setCursorType = function(b) { a.cursor = b }; this._initListener = function() { k = a.on("mousedown", this.buttonDown); f = a.on("pressup", this.buttonRelease) }; this.addEventListener = function(a, e, f) { b[a] = e; c[a] = f }; this.addEventListenerWithParams = function(a, e, f, m) { b[a] = e; c[a] = f; q[a] = m }; this.buttonRelease = function() { e || (a.scaleX = 0 < p ? 1 : -1, a.scaleY = 1, playSound("click", 1, !1), b[ON_MOUSE_UP] && b[ON_MOUSE_UP].call(c[ON_MOUSE_UP], q[ON_MOUSE_UP])) }; this.buttonDown = function() { e || (a.scaleX = 0 < p ? .9 : -.9, a.scaleY = .9, b[ON_MOUSE_DOWN] && b[ON_MOUSE_DOWN].call(c[ON_MOUSE_DOWN], q[ON_MOUSE_DOWN])) }; this.rotation = function(b) { a.rotation = b }; this.getButton = function() { return a }; this.setPosition = function(b, e) { a.x = b; a.y = e }; this.setX = function(b) { a.x = b }; this.setY = function(b) { a.y = b }; this.getButtonImage = function() { return a }; this.block = function(b) { e = b; a.scaleX = p; a.scaleY = h }; this.setScaleX = function(b) { p = a.scaleX = b }; this.getX = function() { return a.x }; this.getY = function() { return a.y }; this.pulseAnimation = function() { createjs.Tween.get(a).to({ scaleX: .9 * p, scaleY: .9 * h }, 850, createjs.Ease.quadOut).to({ scaleX: p, scaleY: h }, 650, createjs.Ease.quadIn).call(function() { t.pulseAnimation() }) }; this.trebleAnimation = function() { createjs.Tween.get(a).to({ rotation: 5 }, 75, createjs.Ease.quadOut).to({ rotation: -5 }, 140, createjs.Ease.quadIn).to({ rotation: 0 }, 75, createjs.Ease.quadIn).wait(750).call(function() { t.trebleAnimation() }) }; this.removeAllTweens = function() { createjs.Tween.removeTweens(a) }; var m = void 0 !== l ? l : s_oStage; this._init(n, d, g); var t = this; return this } function CMenu() { var n, d, g, l, b, c, a, q, p, h, k, f, e, m, t, r = null, w = null; this._init = function() { p = createBitmap(s_oSpriteLibrary.getSprite("bg_menu")); s_oStage.addChild(p); var v = s_oSpriteLibrary.getSprite("but_play"); b = CANVAS_WIDTH / 2; c = CANVAS_HEIGHT - 340; h = createBitmap(v); h.x = b; h.y = c; h.regX = .5 * v.width; h.regY = .5 * v.height; s_oStage.addChild(h); k = new createjs.Shape; k.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(b - h.regX, c - h.regY, 184, 184); k.on("mousedown", this._onMouseDownHitArea, this, !0); k.on("pressup", this._onButPlayRelease, this, !0); k.cursor = "pointer"; s_oStage.addChild(k); if (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) v = s_oSpriteLibrary.getSprite("audio_icon"), a = CANVAS_WIDTH - v.height / 2 - 10, q = v.height / 2 + 10, m = new CToggle(a, q, v, s_bAudioActive), m.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this); v = s_oSpriteLibrary.getSprite("but_info"); g = v.height / 2 + 10; l = v.height / 2 + 10; f = new CGfxButton(g, l, v, s_oStage); f.addEventListener(ON_MOUSE_UP, this._onButInfoRelease, this); v = window.document; var y = v.documentElement; r = y.requestFullscreen || y.mozRequestFullScreen || y.webkitRequestFullScreen || y.msRequestFullscreen; w = v.exitFullscreen || v.mozCancelFullScreen || v.webkitExitFullscreen || v.msExitFullscreen; !1 === ENABLE_FULLSCREEN && (r = !1); r && screenfull.enabled && (v = s_oSpriteLibrary.getSprite("but_fullscreen"), n = g + v.width / 2 + 10, d = v.height / 2 + 10, t = new CToggle(n, d, v, s_bFullscreen, s_oStage), t.addEventListener(ON_MOUSE_UP, this._onFullscreenRelease, this)); e = new createjs.Shape; e.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); s_oStage.addChild(e); createjs.Tween.get(e).to({ alpha: 0 }, 1E3).call(function() { e.visible = !1 }); this.refreshButtonPos(s_iOffsetX, s_iOffsetY) }; this._onMouseDownHitArea = function() { h.scaleX = h.scaleY = .9 }; this.refreshButtonPos = function(b, e) { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || m.setPosition(a - b, e + q); r && screenfull.enabled && t.setPosition(n + b, d + e); f.setPosition(g + b, l + e) }; this.unload = function() { k.removeAllEventListeners(); k = null; if (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) m.unload(), m = null; r && screenfull.enabled && t.unload(); f.unload(); s_oStage.removeAllChildren(); s_oMenu = null }; this._onButPlayRelease = function() { h.scaleX = h.scaleY = 1; this.unload(); playSound("click", 1, !1); s_oMain.gotoGame() }; this._onAudioToggle = function() { Howler.mute(s_bAudioActive); s_bAudioActive = !s_bAudioActive }; this._onButInfoRelease = function() { new CCreditsPanel }; this.resetFullscreenBut = function() { r && screenfull.enabled && t.setActive(s_bFullscreen) }; this._onFullscreenRelease = function() { s_bFullscreen ? w.call(window.document) : r.call(window.document.documentElement); sizeHandler() }; s_oMenu = this; this._init() } var s_oMenu = null; function CGame(n) { function d(a) { C || W !== STATE_PLAY || v || (T === DIRECTION && (37 === a.keyCode ? (s_oGame.onLeft(), C = !0) : 39 === a.keyCode && (s_oGame.onRight(), C = !0)), 32 === a.keyCode && (s_oGame.manageControl(), C = !0)); a.preventDefault(); return !1 } function g(a) { C && W === STATE_PLAY && (T === DIRECTION && (37 === a.keyCode ? (C = !1, s_oGame.dirKeyUp()) : 39 === a.keyCode && (C = !1, s_oGame.dirKeyUp())), 32 === a.keyCode && (C = !1)); a.preventDefault(); return !1 } var l, b, c, a, q, p, h, k, f, e, m, t, r, w, v = !1, y = !1, B = !1, C = !1, A = !1, x = !1, G = !1, N = !1, H = !1, S = !1, U = !1, R = !1, P = !1, J = !0, L = !1, M = !1, O = !1, X = !1, u, Q = 1, E = 0, T = DIRECTION, I, F, K, z, D, V, aa, Y, W = STATE_INIT, Z = null; this._init = function() { this.pause(!0); F = I = u = 0; $(s_oMain).trigger("start_session"); $(s_oMain).trigger("start_level", 1); K = []; z = []; playSound("ambience", 1, !0); this.resetScoreStageArray(); m = new createjs.Container; s_oStage.addChild(m); f = new CScenario; q = new createjs.Shape; q.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, 460); m.addChild(q); b = new CTrack(0, 362, s_oSpriteLibrary.getSprite("bowling_track"), f.getTrackBodyDepth(), m); K.push(b); t = new CPowerBar(100, CANVAS_HEIGHT_HALF + 225, s_oStage); t.setVisible(!1); var n = s_oSpriteLibrary.getSprite("effect_arrow"); r = new CEffectArray(CANVAS_WIDTH + 10, CANVAS_HEIGHT_HALF + 430, n, s_oStage); r.setVisible(!1); Z = SHOW_3D_RENDER ? camera : createOrthoGraphicCamera(); f.ballBody().mass = 0; n = s_oSpriteLibrary.getSprite("pin"); for (var w = 0; w < PINS_POSITION.length; w++) z[w] = new CPin(0, 0, n, f.getPinByID(w), m), K.push(z[w]), z[w].setPosRef(OFFSET_TRACK_POSITION.z); PIN_TEST && (z.push(new CPin(0, 0, n, f.getPinByID(w), m)), K.push(z[z.length - 1]), z[z.length - 1].getPhysics().quaternion.setFromEuler(Math.radians(0), Math.radians(0), Math.radians(0), "XYZ"), z[z.length - 1].getPhysics().mass = 0); n = s_oSpriteLibrary.getSprite("ball"); e = new CBall(0, 0, n, f.ballBody(), m); e.setVisible(!1); K.push(e); resizeCanvas3D(); n = s_oSpriteLibrary.getSprite("pin_binder"); p = new CPinDragger(397, 470, n, m); p.setVisible(!1); p.changeState("throw_pins_0"); fadeSound(1, 0, MS_FADE_SOUNDTRACK, "soundtrack"); n = s_oSpriteLibrary.getSprite("monitor"); c = createBitmap(n); c.y = 225; m.addChild(c); n = s_oSpriteLibrary.getSprite("semaphore"); h = new CSemaphore(CANVAS_WIDTH_HALF + 3, 381, n, m); k = new CCharacter(CHARACTER_START_POS.x, CHARACTER_START_POS.y, m); l = new CInterface; a = new CAnimMonitor(0, 291, l.getContainerBoard()); s_bMobile || (document.onkeydown = d, document.onkeyup = g); if (SHOW_3D_RENDER) this.onExitHelp(); else l.createHelpPanel() }; this.resetScoreStageArray = function() { D = []; V = []; for (var a = 0; a < LAUNCH_TURN; a++) { D[a] = []; if (9 !== a) for (var b = 0; 3 > b; b++) D[a][b] = 0; else for (b = 0; 4 > b; b++) D[a][b] = 0; V[a] = 0 } }; this.refreshPos = function(a, b) { t.setPosition(t.getStartPos().x + a, t.getStartPos().y - b); r.setPosition(r.getStartPos().x - a, r.getStartPos().y - b) }; this.startPinsPosition = function() { this.updatePinsPosition(); for (var a = 0; a < z.length; a++) z[a].setStartPos(z[a].getX(), z[a].getY()) }; this.onMouseDown = function() { T === DIRECTION ? (s_oGame.deactiveEventMouseMove(), s_oGame.activeStateLaunchPower()) : T === POWER ? (t.removeTweensMask(), s_oGame.activeStateLaunchEffect()) : T === EFFECT && (s_oGame.launchBall(), T = DIRECTION) }; this.manageControl = function() { v || (T === DIRECTION ? (l.dirArrowsVisibility(!1), G = !1, s_oGame.activeStateLaunchPower()) : T === POWER ? (t.removeTweensMask(), s_oGame.activeStateLaunchEffect()) : T === EFFECT && (r.stopAnimation(), r.removeAllEventListeners(), L = !0, y = !1, v = !0, T = DIRECTION)) }; this.dirKeyUp = function() { G = !1 }; this.onLeft = function() { w = s_oGame.onLeft; G = !0; aa = TIME_REFRESH_DIRECTION; var a = f.ballBody(); a.position.x -= DIRECTION_VELOCITY; a.position.x > LIMIT_HAND_RANGE_POS.x ? a.position.x = LIMIT_HAND_RANGE_POS.x : k.setPosition(k.getX() - DIRECTION_CHARACTER_VELOCITY, k.getY()) }; this.onRight = function() { w = s_oGame.onRight; G = !0; aa = TIME_REFRESH_DIRECTION; var a = f.ballBody(); a.position.x += DIRECTION_VELOCITY; a.position.x < -LIMIT_HAND_RANGE_POS.x ? a.position.x = -LIMIT_HAND_RANGE_POS.x : k.setPosition(k.getX() + DIRECTION_CHARACTER_VELOCITY, k.getY()) }; this.sortDepth = function(a, b) { null !== a && null !== b && (a.getDepthPos() < b.getDepthPos() ? m.getChildIndex(a.getObject()) > m.getChildIndex(b.getObject()) && m.swapChildren(a.getObject(), b.getObject()) : a.getDepthPos() > b.getDepthPos() && m.getChildIndex(b.getObject()) > m.getChildIndex(a.getObject()) && m.swapChildren(b.getObject(), a.getObject())) }; this.onExitHelp = function() { this.pause(!1); l.onExitFromHelp() }; this.ballPosition = function() { var a = f.ballBody(), b = this.convert3dPosTo2dScreen(a.position, Z), c = b.z * (BALL_SCALE_FACTOR - e.getStartScale()) + e.getStartScale(); e.setPosition(b.x, b.y); e.scale(c); s_bMobile || this.refreshShadowCast(e, a, c) }; this.refreshShadowCast = function(a, b, e) { var c = f.getTrackBody(); if (b.position.z - BALL_RADIUS < c.position.z) a.scaleShadow(0); else { var m = this.convert3dPosTo2dScreen({ x: b.position.x, y: b.position.y, z: c.position.z }, Z); b = -(b.position.z - BALL_RADIUS) + c.position.z + 1; a.scaleShadow(b * e); a.setAlphaByHeight(b); a.setPositionShadow(m.x, m.y) } }; this.launchBall = function() { e.setVisible(!0); var a = t.getMaskValue() / t.getMaskHeight() * 100; a < MIN_LAUNCH_FORCE && (a = MIN_LAUNCH_FORCE); s_oGame.addImpulseToBall(-a * FORCE_RATE); s_oGame.addAngularVelocityToBall(r.getStoppedFrame() * EFFECT_POWER_RATE) }; this.activeStateLaunchPower = function() { T = POWER; t.setVisible(!0); t.animFade(1); t.animateMask(TIME_POWER_BAR) }; this.activeStateLaunchEffect = function() { T = EFFECT; r.animFade(1); r.animArrow(); r.setVisible(!0) }; this.addAngularVelocityToBall = function(a) { a = { x: 0, y: a, z: 0 }; f.setElementAngularVelocity(f.ballBody(), a) }; this.completeLaunch = function() { y || (B = y = !0, e.animFade(0), e.playSound(), createjs.Tween.get(this).wait(1500).call(function() { k.animFade(0) }), Y = TIME_RESET_LAUNCH) }; this.isAwakwePins = function(a) { X = a }; this.awakePins = function() { if (X) for (var a = 0; a < z.length; a++) z[a].getPhysics().position.y > b.getDepthPos() && z[a].isDownYet() ? z[a].getPhysics().wakeUp() : z[a].getPhysics().position.y > b.getDepthPos() && 1 === Q && z[a].getPhysics().wakeUp() }; this.onStopAllPin = function() { var a = this.countPinDown(); I += a; this.controlTurnResult(a); t.mask(0); r.animFade(0); t.animFade(0) }; this.setPinsPhysicsMovement = function(a) { J = a }; this.nextStage = function() { this.resetScene(); p.setVisible(!1); f.getPinsBinder().collisionResponse = 0; f.getPinsBinder().position.y = PINS_BINDER_POSITION.y; F = 0; this.activeControl() }; this.pinBinderAction = function() { p.setVisible(!0); f.getPinsBinder().collisionResponse = 1; p.animThrowPins() }; this.repositionPins = function() { for (var a = 0; a < z.length; a++) z[a].resetState(), z[a].setPosition(z[a].getX(), z[a].getY() - 100), z[a].animReposition(z[a].getStartPos().y, function() {}) }; this.controlTurnResult = function(a) { this.addBonusScoreToPreviousStage(a); var b = M ? this.addExtraScore(a) : this.addScoreNormalTurns(a); u += a; 9 !== E ? (D[E][Q - 1] = a, D[E][2] += a, l.refreshTurnsBoard(E, Q, D[E][2], b.point, !1)) : (D[E][Q - 1] = a, D[E][3] += a, l.refreshTurnsBoard(E, Q, D[E][3], b.point, !0)); 9 !== E && (x && (V[E] += 2), A && (V[E] += 1)); b.next ? (this.nextTurn(), I < z.length ? (p.setVisible(!0), 4 > Q && p.takeRemainPinsAndRepos(), f.getPinsBinder().collisionResponse = 1, P = !0) : I = 0) : 9 !== E ? (I = 0, E++, Q = 1, l.setStateTurnBoard(E, "on")) : this.gameOver(); l.refresTotalBoard(u); F = 0; A = x = O = N = R = !1 }; this.gameOver = function() { W = STATE_FINISH; l.createEndPanel(u) }; this.addExtraScore = function(a) { var b = { next: !0, point: a }; a >= z.length ? M ? b = this.strikeResult() : 2 === Q && M && (b = this.spareResult()) : a < z.length && (b = this.aritmeticResult(a)); return b }; this.addScoreNormalTurns = function(a) { var b = { next: !0, point: a }; I === z.length ? 1 !== Q || M ? 2 !== Q || M || (b = this.spareResult()) : b = this.strikeResult() : I < z.length && 2 === Q && (b = this.aritmeticResult(a)); return b }; this.aritmeticResult = function(a) { this.pinBinderAction(); return { next: M, point: a } }; this.spareResult = function() { var b = !1; A = !0; 9 === E && (b = M = !0); this.pinBinderAction(); S = !0; playSound("gingle_spare", 1, !1); a.setVisibleMonitorSpare(!0); return { next: b, point: "/" } }; this.strikeResult = function() { var b = !1; x = !0; a.setVisibleMonitorStrike(!0); H = !0; playSound("gingle_strike", 1, !1); 9 === E && (b = M = !0); this.pinBinderAction(); return { next: b, point: "X" } }; this.nextTurn = function() { M ? 3 === Q && this.gameOver() : 9 === E && 2 === Q && this.gameOver(); Q++ }; this.addBonusScoreToPreviousStage = function(a) { for (var b = 0; b < LAUNCH_TURN; b++) 0 < V[b] && (V[b]--, D[b][2] += a, u += a, l.refreshTurnsBoard(b, null, D[b][2], null)) }; this.activeControl = function() { h.changeState("green"); v = !1; l.dirArrowsVisibility(!0); k.setPosition(CHARACTER_START_POS.x, CHARACTER_START_POS.y); k.animFade(1); k.setVisible(!0) }; this.countPinDown = function() { for (var a = F, e = 0; e < z.length; e++) if (!z[e].isDownYet()) { var f = new CANNON.Vec3; z[e].getPhysics().quaternion.toEuler(f); f.x = Math.ceil(Math.degrees(f.x)); f.y = Math.ceil(Math.degrees(f.y)); f.z = Math.ceil(Math.degrees(f.z)); if (20 < f.x || -20 > f.x || 20 < f.y || -20 > f.y || z[e].getPhysics().position.z < b.getHeightPos()) a++, z[e].setDown(!0) } return a }; this.animUpRemainPins = function() { for (var a = 0; a < z.length; a++) z[a].isDownYet() || z[a].animTake(z[a].getStartPos().y - 100) }; this.repositionRemainPins = function() { for (var a = 0; a < z.length; a++) if (z[a].isDownYet()) z[a].setVisible(!1); else { z[a].getPhysics().position.set(PINS_POSITION[a].x, PINS_POSITION[a].y, PINS_POSITION[a].z); z[a].getPhysics().quaternion.setFromEuler(0, 0, 0, "XYZ"); z[a].getPhysics().angularVelocity.set(0, 0, 0); z[a].getPhysics().velocity.set(0, 0, 0); z[a].getPhysics().mass = PIN_PROPERTY.mass; z[a].setPosition(z[a].getStartPos().x, z[a].getStartPos().y - 100); z[a].setPlayedSound(!1); var b = this.pinReflection(a, z[a].getPhysics().position); z[a].setAlphaByHeight(0); z[a].animReposition(z[a].getStartPos().y, b); b = this.convert3dPosTo2dScreen(z[a].getPhysics().position, Z); this.pinScale(a, b); z[a].setVisible(!0); z[a].pinRotation() } P = !1 }; this.unload = function() { s_oStage.removeAllChildren(); l.unload(); f.destroyWorld(); f = null }; this.addImpulseToBall = function(a) { if (W === STATE_PLAY) { f.ballBody().mass = BALL_MASS; a = { x: 0, y: a, z: 0 }; var b = f.ballBody(); f.addImpulse(b, a); f.setElementAngularVelocity(b, { x: 0, y: 0, z: 0 }); v = !0; h.changeState("red") } }; this.pause = function(a) { W = a ? STATE_PAUSE : STATE_PLAY; createjs.Ticker.paused = a }; this.setPinDown = function(a, b, e) { z[a].isDownYet() === b || P || (e !== WALL || z[a].isDownYet() ? e === SIDE_PINS_FLOOR && z[a].setPosRef(f.getSideFloorPins(0).position.z) : z[a].setVisibleRef(!1), z[a].setDown(b), b ? F++ : F--) }; this.onExit = function() { this.unload(); $(s_oMain).trigger("end_level"); $(s_oMain).trigger("show_interlevel_ad"); $(s_oMain).trigger("end_session"); fadeSound(0, 1, MS_FADE_SOUNDTRACK, "soundtrack"); stopSound("ambience"); s_oMain.gotoMenu() }; this.restartGame = function() { this.resetValues(); this.resetScene(); W = STATE_PLAY; $(s_oMain).trigger("restart_level", 1) }; this.resetValues = function() { F = I = u = E = 0; Q = 1; P = R = U = S = O = H = N = G = x = A = C = B = y = v = !1; J = !0; M = L = !1; this.resetScoreStageArray(); for (var b = 0; b < LAUNCH_TURN - 1; b++) for (var e = 0; 2 > e; e++) 0 === e ? l.refreshTurnsBoard(b, e + 1, u, 0, !1) : l.refreshTurnsBoard(b, e + 1, u, "", !1), l.setStateTurnBoard(b, "off"); for (e = 0; 3 > e; e++) 0 === e ? l.refreshTurnsBoard(LAUNCH_TURN - 1, e + 1, u, 0, !0) : l.refreshTurnsBoard(LAUNCH_TURN - 1, e + 1, u, "", !0), l.setStateTurnBoard(LAUNCH_TURN - 1, "off"); l.setStateTurnBoard(0, "on"); l.refresTotalBoard(0); a.disableRunningMonitor() }; this.resetBallPosition = function() { var a = f.ballBody(); a.mass = 0; a.position.set(POSITION_BALL.x, POSITION_BALL.y, POSITION_BALL.z); f.setElementVelocity(a, { x: 0, y: 0, z: 0 }); f.setElementAngularVelocity(a, { x: 0, y: 0, z: 0 }); e.setPlayedSound(!1) }; this._updateInit = function() { f.update(); this._updateBall2DPosition(); W = STATE_PLAY }; this.convert2dScreenPosTo3d = function(a, b) { var e = new THREE.Vector3(a.x / s_iCanvasResizeWidth * 2 - 1, 2 * -(a.y / s_iCanvasResizeHeight) + 1, -1); e.unproject(Z); e.sub(Z.position); e.normalize(); var f = b.position.y; e.multiply(new THREE.Vector3(f, 1, f)); return e }; this.convert3dPosTo2dScreen = function(a, b) { var e = (new THREE.Vector3(a.x, a.y, a.z)).project(b), f = .5 * Math.floor(s_iCanvasResizeWidth), c = .5 * Math.floor(s_iCanvasResizeHeight); e.x = (e.x * f + f) * s_fInverseScaling; e.y = (-(e.y * c) + c) * s_fInverseScaling; return e }; this.resetScene = function() { this.resetPinsPosition(); this.resetBallPosition() }; this.resetPinsPosition = function() { for (var a = 0; a < z.length; a++) { var b = z[a].getPhysics(); b.position.set(PINS_POSITION[a].x, PINS_POSITION[a].y, PINS_POSITION[a].z); b.quaternion.setFromEuler(0, 0, 0, "XYZ"); b.angularVelocity.set(0, 0, 0); b.velocity.set(0, 0, 0); b.collisionResponse = 1; b.mass = PIN_PROPERTY.mass; z[a].setPosRef(f.getTrackBody().position.z); b = this.convert3dPosTo2dScreen(b.position, Z); this.pinScale(a, b); z[a].setDown(!1); z[a].setVisible(!0); z[a].setPlayedSound(!1); z[a].setVisibleRef(!0) } }; this._onEnd = function() { this.onExit() }; this.swapChildrenIndex = function() { for (var a = 0; a < K.length - 1; a++) for (var b = a + 1; b < K.length; b++) K[a].getObject().visible && K[b].getObject().visible && this.sortDepth(K[a], K[b]) }; this.updatePinsPosition = function() { for (var a = 0; a < z.length; a++) if (z[a].getVisible()) { var b = this.pinPosition(a); this.pinScale(a, b); z[a].isVisibleRef && this.pinReflection(a, z[a].getPhysics().position); this.pinFade(a); PIN_TEST || z[a].pinRotation() } }; this.pinFade = function(a) { if (z[a].getPhysics().position.y < b.getDepthPos()) { var e = 1 - (z[a].getPhysics().position.y - b.getDepthPos()) * (FADE_PIN_FACTOR - b.getDepthPos()); z[a].setAlpha(e) } }; this.pinScale = function(a, b) { var e = b.z * (PIN_SCALE_FACTOR - z[a].getStartScale()) + z[a].getStartScale(); z[a].scale(e); return e }; this.pinReflection = function(a, e) { if (e.y < b.getDepthPos()) z[a].setAlphaByHeight(0); else { var c = { x: e.x, y: e.y, z: z[a].getPosRef() }; c = this.convert3dPosTo2dScreen(c, Z); var m = e.z + f.getTrackBody().position.z, h = m * (PIN_ALPHA_FACTOR - 1) + 1; h > PINS_REFLECTION_LIMIT && (h = PINS_REFLECTION_LIMIT); m = m * (PIN_REF_REGY_FACTOR - z[a].getRegYRef()) + z[a].getRegYRef(); z[a].setRegYRef(m); z[a].setAlphaByHeight(h); z[a].setPositionReflection(c.x, c.y); return h } }; this.setPinCollide = function() { N = !0 }; this.pinPosition = function(a) { var b = z[a].getPhysics(); b = this.convert3dPosTo2dScreen(b.position, Z); z[a].setPosition(b.x, b.y); return b }; this.movementKeyDown = function() { G && (0 > aa ? (aa = TIME_REFRESH_DIRECTION, w()) : aa -= FPS_TIME) }; this.pinsMovementDetect = function() { if (B) { for (var a = z.length, b = 0; b < z.length; b++) { var e = z[b].getPhysics().velocity; Math.abs(e.x) < MIN_VELOCITY_PINS && Math.abs(e.y) < MIN_VELOCITY_PINS && (s_oScenario.setElementVelocity(z[b].getPhysics(), { x: 0, y: 0, z: 0 }), a--) } 0 === a ? (this.onStopAllPin(), B = !1) : 0 > Y ? (this.stopAllPin(), this.onStopAllPin(), B = !1) : Y -= FPS_TIME } }; this.gutterBall = function() { R || N || (U = !0, a.setVisibleMonitorGutter(!0), R = !0, playSound("gingle_gutterball", 1, !1)) }; this.stopAllPin = function() { for (var a = 0; a < z.length; a++) s_oScenario.setElementVelocity(z[a].getPhysics(), { x: 0, y: 0, z: 0 }) }; this.pinTest = function() { z[z.length - 1].pinRotation(); console.log(z[z.length - 1].getPhysics().position) }; this.animMonitor = function() { H ? H = a.animMonitor(a.getStrikeArray()) : S ? S = a.animMonitor(a.getSpareArray()) : U && ((U = a.animMonitor(a.getGutterArray())) || this.completeLaunch()) }; this.pinSoundCollision = function(a) { z[a].playAudio() }; this.twoPinsSoundCollision = function(a, b) { createjs.Tween.get(this).wait(Math.floor(50 * Math.random())).call(function() { z[a].playAudio() }); createjs.Tween.get(this).wait(Math.floor(50 * Math.random())).call(function() { z[b].playAudio() }) }; this.ballHitFloor = function() { O || (O = !0, playSound("ball_hitting", 1, !1)) }; this.channelForceApply = function() { R && f.ballBody().velocity.y > MIN_FORCE_BALL_GUTTER && f.ballBody().applyForce({ x: 0, y: -100, z: 0 }, new CANNON.Vec3(0, 0, 0)) }; this.characterAnimation = function() { L && (L = k.animCharacter(), 24 === k.getFrame() && this.launchBall()) }; this._updatePlay = function() { for (var a = 0; a < PHYSICS_ACCURACY; a++) f.update(), this.awakePins(); this._updateBall2DPosition(); J && this.updatePinsPosition(); this.swapChildrenIndex(); this.movementKeyDown(); this.pinsMovementDetect(); this.channelForceApply(); this.characterAnimation(); PIN_TEST && this.pinTest(); this.animMonitor() }; this.update = function() { switch (W) { case STATE_INIT: this._updateInit(); break; case STATE_PLAY: this._updatePlay(); break; case STATE_FINISH: f.update(), this.animMonitor(), J && this.updatePinsPosition() } }; this._updateBall2DPosition = function() { this.ballPosition(); Z.updateProjectionMatrix(); Z.updateMatrixWorld() }; s_oGame = this; TIME_POWER_BAR = n.time_power_bar; SPEED_EFFECT_ARROW = n.speed_effect_arrow; NUM_LEVEL_FOR_ADS = n.num_levels_for_ads; this._init() } var s_oGame; function CInterface() { var n, d, g, l, b, c, a, q = null, p, h, k, f, e, m, t = null, r, w = null, v = null, y; this._init = function() { e = new createjs.Container; y = e.y = 161; e.regY = s_oSpriteLibrary.getSprite("monitor_strike_0").height + s_oSpriteLibrary.getSprite("turn_board").height; s_oStage.addChild(e); k = new CTurnsBoard(TURNS_BOARD_POS.x, TURNS_BOARD_POS.y, e); var m = s_oSpriteLibrary.getSprite("total_board"); f = new CTotalScoreBoard(k.getLastX(), TURNS_BOARD_POS.y, m, e); t = new CController; m = s_oSpriteLibrary.getSprite("but_exit"); n = CANVAS_WIDTH - m.height / 2 - 10; d = m.height / 2 + 10; a = new CGfxButton(n, d, m); a.addEventListener(ON_MOUSE_UP, this._onExit, this); if (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) m = s_oSpriteLibrary.getSprite("audio_icon"), b = n - m.height - 10, c = d, p = new CToggle(b, c, m, s_bAudioActive), p.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this); m = window.document; var h = m.documentElement; w = h.requestFullscreen || h.mozRequestFullScreen || h.webkitRequestFullScreen || h.msRequestFullscreen; v = m.exitFullscreen || m.mozCancelFullScreen || m.webkitExitFullscreen || m.msExitFullscreen; !1 === ENABLE_FULLSCREEN && (w = !1); w && screenfull.enabled && (m = s_oSpriteLibrary.getSprite("but_fullscreen"), g = m.width / 4 + 10, l = m.height / 2 + 10, r = new CToggle(g, l, m, s_bFullscreen, s_oStage), r.addEventListener(ON_MOUSE_UP, this._onFullscreenRelease, this)); this.refreshButtonPos(s_iOffsetX, s_iOffsetY) }; this.refreshButtonPos = function(f, m) { a.setPosition(n - f, m + d); !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || p.setPosition(b - f, m + c); w && screenfull.enabled && r.setPosition(g + f, l + m); e.x = f; e.y = y - -.5 * f + 1; e.scaleX = e.scaleY = .5 * f / EDGEBOARD_X * (BOARD_SCALE_F - 1) + 1; s_oGame.refreshPos(f, m); if (null !== t) { var h = t.getStartPositionControlLeft(); t.setPositionControlLeft(h.x + f, h.y - m); h = t.getStartPositionControlRight(); t.setPositionControlRight(h.x - f, h.y - m) } }; this.unload = function() { a.unload(); a = null; this.onExitFromHelp(); if (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) p.unload(), p = null; w && screenfull.enabled && r.unload(); s_oInterface = null }; this.getContainerBoard = function() { return e }; this.onExitFromHelp = function() { null !== q && (q.unload(), q = null) }; this.createHelpPanel = function() { q = new CHelpPanel(0, 0, s_oSpriteLibrary.getSprite("bg_help")) }; this.createEndPanel = function(a) { m = new CEndPanel(s_oSpriteLibrary.getSprite("msg_box")); m.show(a) }; this.resetTurnsBoard = function() { k.resetAllTurnBoard() }; this.refreshTurnsBoard = function(a, b, e, f, m) { a = k.getTurnBoard(a); null !== b && a.refreshTextByID(b - 1, f); m ? a.refreshTextByID(3, e) : a.refreshTextByID(2, e) }; this.refresTotalBoard = function(a) { f.refreshText(a) }; this.setStateTurnBoard = function(a, b) { k.stateTurnBoard(a, b) }; this._onAudioToggle = function() { Howler.mute(s_bAudioActive); s_bAudioActive = !s_bAudioActive }; this._onExit = function() { (new CAreYouSurePanel(s_oStage)).show() }; this.unloadPause = function() { h.unload(); h = null }; this.dirArrowsVisibility = function(a) { null !== t && t.arrowVisibility(a) }; this.onButPauseRelease = function() { playSound("click", 1, !1); h = new CPause }; this.resetFullscreenBut = function() { w && screenfull.enabled && r.setActive(s_bFullscreen) }; this._onFullscreenRelease = function() { s_bFullscreen ? v.call(window.document) : w.call(window.document.documentElement); sizeHandler() }; s_oInterface = this; this._init(); return this } var s_oInterface = null; function CHelpPanel(n, d, g) { var l, b, c, a, q, p, h, k, f, e, m, t, r = !1; this._init = function(a, b, c) { createjs.Ticker.paused = !1; f = new createjs.Container; f.x = a; f.y = b; s_oStage.addChild(f); k = new createjs.Shape; k.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); k.alpha = .7; f.addChild(k); h = createBitmap(c); h.x = CANVAS_WIDTH_HALF; h.y = CANVAS_HEIGHT_HALF - 30; h.regX = .5 * c.width; h.regY = .5 * c.height; f.addChild(h); t = new createjs.Container; t.y = -60; f.addChild(t); a = TEXT_HELP1_PC; b = "key_left"; c = "key_right"; var d = 26, p = .7; s_bMobile && (a = TEXT_HELP1_MOBILE, b = "arrow_left", c = "arrow_right", p = .5, d = 30); l = new createjs.Text(a, d + "px " + FONT_GAME, TEXT_COLOR); l.textAlign = "center"; l.lineWidth = 400; l.x = .5 * CANVAS_WIDTH; l.y = .5 * CANVAS_HEIGHT - 360; f.addChild(l); this.directionControl(b, c, p); this.powerBarControl(); this.effectArrow(); a = s_oSpriteLibrary.getSprite("but_continue"); m = new CGfxButton(CANVAS_WIDTH / 2, CANVAS_HEIGHT_HALF + 400, a, t); m.addEventListener(ON_MOUSE_UP, this._onExitHelp, this); m.pulseAnimation(); var q = this; e = f.on("pressup", function() { q._onExitHelp() }); f.cursor = "pointer" }; this.directionControl = function(e, f, m) { e = s_oSpriteLibrary.getSprite(e); c = createBitmap(e); c.x = CANVAS_WIDTH_HALF - 150; c.y = CANVAS_HEIGHT_HALF - 170; c.regX = .5 * e.width; c.regY = .5 * e.height; c.scaleX = c.scaleY = m; t.addChild(c); f = s_oSpriteLibrary.getSprite(f); b = createBitmap(f); b.x = CANVAS_WIDTH_HALF + 150; b.y = CANVAS_HEIGHT_HALF - 170; b.regX = .5 * f.width; b.regY = .5 * f.height; b.scaleX = b.scaleY = m; t.addChild(b); m = s_oSpriteLibrary.getSprite("ball"); a = createBitmap(m); a.x = CANVAS_WIDTH_HALF; a.y = CANVAS_HEIGHT_HALF - 170; a.regX = .5 * m.width; a.regY = .5 * m.height; t.addChild(a); m = new createjs.Text(TEXT_MOVE, "36px " + FONT_GAME, TEXT_COLOR); m.textAlign = "center"; m.lineWidth = 300; m.x = .5 * CANVAS_WIDTH; m.y = CANVAS_HEIGHT_HALF - 115; t.addChild(m); this.animArrowControl() }; this.powerBarControl = function() { q = new CPowerBar(CANVAS_WIDTH_HALF - 135, CANVAS_HEIGHT_HALF - 50, t); q.animateMask(TIME_POWER_BAR) }; this.effectArrow = function() { var a = s_oSpriteLibrary.getSprite("effect_arrow"); p = new CEffectArray(CANVAS_WIDTH_HALF + 250, CANVAS_HEIGHT_HALF + 155, a, t); p.animArrow() }; this.animArrowControl = function() { var e = this; c.scaleX = c.scaleY = .8; createjs.Tween.get(a).to({ x: CANVAS_WIDTH_HALF - 25 }, 750).call(function() { c.scaleX = c.scaleY = 1; b.scaleX = b.scaleY = .8; createjs.Tween.get(a).to({ x: CANVAS_WIDTH_HALF + 25 }, 750).call(function() { b.scaleX = b.scaleY = 1; e.animArrowControl() }) }) }; this.unload = function() { createjs.Tween.get(f).to({ alpha: 0 }, 500, createjs.Ease.cubicIn).call(function() { s_oStage.removeChild(f) }); f.off("pressup", e) }; this._onExitHelp = function() { r || (r = !0, this.unload(), s_oGame.onExitHelp()) }; this._init(n, d, g) }! function(n) { if ("object" == typeof exports && "undefined" != typeof module) module.exports = n(); else { var d; "undefined" != typeof window ? d = window : "undefined" != typeof global ? d = global : "undefined" != typeof self && (d = self); d.CANNON = n() } }(function() { return function b(d, g, l) { function c(p, h) { if (!g[p]) { if (!d[p]) { var k = "function" == typeof require && require; if (!h && k) return k(p, !0); if (a) return a(p, !0); throw Error("Cannot find module '" + p + "'"); } k = g[p] = { exports: {} }; d[p][0].call(k.exports, function(a) { var b = d[p][1][a]; return c(b ? b : a) }, k, k.exports, b, d, g, l) } return g[p].exports } for (var a = "function" == typeof require && require, q = 0; q < l.length; q++) c(l[q]); return c }({ 1: [function(d, g, l) { g.exports = { name: "cannon", version: "0.6.2", description: "A lightweight 3D physics engine written in JavaScript.", homepage: "https://github.com/schteppe/cannon.js", author: "Stefan Hedman <schteppe@gmail.com> (http://steffe.se)", keywords: ["cannon.js", "cannon", "physics", "engine", "3d"], main: "./build/cannon.js", engines: { node: "*" }, repository: { type: "git", url: "https://github.com/schteppe/cannon.js.git" }, bugs: { url: "https://github.com/schteppe/cannon.js/issues" }, licenses: [{ type: "MIT" }], devDependencies: { jshint: "latest", "uglify-js": "latest", nodeunit: "^0.9.0", grunt: "~0.4.0", "grunt-contrib-jshint": "~0.1.1", "grunt-contrib-nodeunit": "^0.4.1", "grunt-contrib-concat": "~0.1.3", "grunt-contrib-uglify": "^0.5.1", "grunt-browserify": "^2.1.4", "grunt-contrib-yuidoc": "^0.5.2", browserify: "*" }, dependencies: {} } }, {}], 2: [function(d, g, l) { g.exports = { version: d("../package.json").version, AABB: d("./collision/AABB"), ArrayCollisionMatrix: d("./collision/ArrayCollisionMatrix"), Body: d("./objects/Body"), Box: d("./shapes/Box"), Broadphase: d("./collision/Broadphase"), Constraint: d("./constraints/Constraint"), ContactEquation: d("./equations/ContactEquation"), Narrowphase: d("./world/Narrowphase"), ConeTwistConstraint: d("./constraints/ConeTwistConstraint"), ContactMaterial: d("./material/ContactMaterial"), ConvexPolyhedron: d("./shapes/ConvexPolyhedron"), Cylinder: d("./shapes/Cylinder"), DistanceConstraint: d("./constraints/DistanceConstraint"), Equation: d("./equations/Equation"), EventTarget: d("./utils/EventTarget"), FrictionEquation: d("./equations/FrictionEquation"), GSSolver: d("./solver/GSSolver"), GridBroadphase: d("./collision/GridBroadphase"), Heightfield: d("./shapes/Heightfield"), HingeConstraint: d("./constraints/HingeConstraint"), LockConstraint: d("./constraints/LockConstraint"), Mat3: d("./math/Mat3"), Material: d("./material/Material"), NaiveBroadphase: d("./collision/NaiveBroadphase"), ObjectCollisionMatrix: d("./collision/ObjectCollisionMatrix"), Pool: d("./utils/Pool"), Particle: d("./shapes/Particle"), Plane: d("./shapes/Plane"), PointToPointConstraint: d("./constraints/PointToPointConstraint"), Quaternion: d("./math/Quaternion"), Ray: d("./collision/Ray"), RaycastVehicle: d("./objects/RaycastVehicle"), RaycastResult: d("./collision/RaycastResult"), RigidVehicle: d("./objects/RigidVehicle"), RotationalEquation: d("./equations/RotationalEquation"), RotationalMotorEquation: d("./equations/RotationalMotorEquation"), SAPBroadphase: d("./collision/SAPBroadphase"), SPHSystem: d("./objects/SPHSystem"), Shape: d("./shapes/Shape"), Solver: d("./solver/Solver"), Sphere: d("./shapes/Sphere"), SplitSolver: d("./solver/SplitSolver"), Spring: d("./objects/Spring"), Trimesh: d("./shapes/Trimesh"), Vec3: d("./math/Vec3"), Vec3Pool: d("./utils/Vec3Pool"), World: d("./world/World") } }, { "../package.json": 1, "./collision/AABB": 3, "./collision/ArrayCollisionMatrix": 4, "./collision/Broadphase": 5, "./collision/GridBroadphase": 6, "./collision/NaiveBroadphase": 7, "./collision/ObjectCollisionMatrix": 8, "./collision/Ray": 9, "./collision/RaycastResult": 10, "./collision/SAPBroadphase": 11, "./constraints/ConeTwistConstraint": 12, "./constraints/Constraint": 13, "./constraints/DistanceConstraint": 14, "./constraints/HingeConstraint": 15, "./constraints/LockConstraint": 16, "./constraints/PointToPointConstraint": 17, "./equations/ContactEquation": 19, "./equations/Equation": 20, "./equations/FrictionEquation": 21, "./equations/RotationalEquation": 22, "./equations/RotationalMotorEquation": 23, "./material/ContactMaterial": 24, "./material/Material": 25, "./math/Mat3": 27, "./math/Quaternion": 28, "./math/Vec3": 30, "./objects/Body": 31, "./objects/RaycastVehicle": 32, "./objects/RigidVehicle": 33, "./objects/SPHSystem": 34, "./objects/Spring": 35, "./shapes/Box": 37, "./shapes/ConvexPolyhedron": 38, "./shapes/Cylinder": 39, "./shapes/Heightfield": 40, "./shapes/Particle": 41, "./shapes/Plane": 42, "./shapes/Shape": 43, "./shapes/Sphere": 44, "./shapes/Trimesh": 45, "./solver/GSSolver": 46, "./solver/Solver": 47, "./solver/SplitSolver": 48, "./utils/EventTarget": 49, "./utils/Pool": 51, "./utils/Vec3Pool": 54, "./world/Narrowphase": 55, "./world/World": 56 }], 3: [function(d, g, l) { function b(a) { a = a || {}; this.lowerBound = new c; a.lowerBound && this.lowerBound.copy(a.lowerBound); this.upperBound = new c; a.upperBound && this.upperBound.copy(a.upperBound) } var c = d("../math/Vec3"); d("../utils/Utils"); g.exports = b; var a = new c; b.prototype.setFromPoints = function(b, c, k, f) { var e = this.lowerBound, m = this.upperBound; e.copy(b[0]); k && k.vmult(e, e); m.copy(e); for (var h = 1; h < b.length; h++) { var d = b[h]; k && (k.vmult(d, a), d = a); d.x > m.x && (m.x = d.x); d.x < e.x && (e.x = d.x); d.y > m.y && (m.y = d.y); d.y < e.y && (e.y = d.y); d.z > m.z && (m.z = d.z); d.z < e.z && (e.z = d.z) } c && (c.vadd(e, e), c.vadd(m, m)); f && (e.x -= f, e.y -= f, e.z -= f, m.x += f, m.y += f, m.z += f); return this }; b.prototype.copy = function(a) { this.lowerBound.copy(a.lowerBound); this.upperBound.copy(a.upperBound); return this }; b.prototype.clone = function() { return (new b).copy(this) }; b.prototype.extend = function(a) { var b = a.lowerBound.x; this.lowerBound.x > b && (this.lowerBound.x = b); b = a.upperBound.x; this.upperBound.x < b && (this.upperBound.x = b); b = a.lowerBound.y; this.lowerBound.y > b && (this.lowerBound.y = b); b = a.upperBound.y; this.upperBound.y < b && (this.upperBound.y = b); b = a.lowerBound.z; this.lowerBound.z > b && (this.lowerBound.z = b); b = a.upperBound.z; this.upperBound.z < b && (this.upperBound.z = b) }; b.prototype.overlaps = function(a) { var b = this.lowerBound, c = this.upperBound, f = a.lowerBound; a = a.upperBound; return (f.x <= c.x && c.x <= a.x || b.x <= a.x && a.x <= c.x) && (f.y <= c.y && c.y <= a.y || b.y <= a.y && a.y <= c.y) && (f.z <= c.z && c.z <= a.z || b.z <= a.z && a.z <= c.z) }; b.prototype.contains = function(a) { var b = this.lowerBound, c = this.upperBound, f = a.lowerBound; a = a.upperBound; return b.x <= f.x && c.x >= a.x && b.y <= f.y && c.y >= a.y && b.z <= f.z && c.z >= a.z }; b.prototype.getCorners = function(a, b, c, f, e, m, d, q) { var h = this.lowerBound, k = this.upperBound; a.copy(h); b.set(k.x, h.y, h.z); c.set(k.x, k.y, h.z); f.set(h.x, k.y, k.z); e.set(k.x, h.y, h.z); m.set(h.x, k.y, h.z); d.set(h.x, h.y, k.z); q.copy(k) }; var q = [new c, new c, new c, new c, new c, new c, new c, new c]; b.prototype.toLocalFrame = function(a, b) { this.getCorners(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]); for (var c = 0; 8 !== c; c++) { var f = q[c]; a.pointToLocal(f, f) } return b.setFromPoints(q) }; b.prototype.toWorldFrame = function(a, b) { this.getCorners(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]); for (var c = 0; 8 !== c; c++) { var f = q[c]; a.pointToWorld(f, f) } return b.setFromPoints(q) } }, { "../math/Vec3": 30, "../utils/Utils": 53 }], 4: [function(d, g, l) { function b() { this.matrix = [] } g.exports = b; b.prototype.get = function(b, a) { b = b.index; a = a.index; if (a > b) { var c = a; a = b; b = c } return this.matrix[(b * (b + 1) >> 1) + a - 1] }; b.prototype.set = function(b, a, d) { b = b.index; a = a.index; if (a > b) { var c = a; a = b; b = c } this.matrix[(b * (b + 1) >> 1) + a - 1] = d ? 1 : 0 }; b.prototype.reset = function() { for (var b = 0, a = this.matrix.length; b !== a; b++) this.matrix[b] = 0 }; b.prototype.setNumObjects = function(b) { this.matrix.length = b * (b - 1) >> 1 } }, {}], 5: [function(d, g, l) { function b() { this.world = null; this.useBoundingBoxes = !1; this.dirty = !0 } var c = d("../objects/Body"); l = d("../math/Vec3"); var a = d("../math/Quaternion"); d("../shapes/Shape"); d("../shapes/Plane"); g.exports = b; b.prototype.collisionPairs = function(a, b, e) { throw Error("collisionPairs not implemented for this BroadPhase class!"); }; var q = c.STATIC | c.KINEMATIC; b.prototype.needBroadphaseCollision = function(a, b) { return 0 !== (a.collisionFilterGroup & b.collisionFilterMask) && 0 !== (b.collisionFilterGroup & a.collisionFilterMask) && (0 === (a.type & q) && a.sleepState !== c.SLEEPING || 0 === (b.type & q) && b.sleepState !== c.SLEEPING) ? !0 : !1 }; b.prototype.intersectionTest = function(a, b, e, f) { this.useBoundingBoxes ? this.doBoundingBoxBroadphase(a, b, e, f) : this.doBoundingSphereBroadphase(a, b, e, f) }; var p = new l; new l; new a; new l; b.prototype.doBoundingSphereBroadphase = function(a, b, e, f) { b.position.vsub(a.position, p); var m = Math.pow(a.boundingRadius + b.boundingRadius, 2); p.norm2() < m && (e.push(a), f.push(b)) }; b.prototype.doBoundingBoxBroadphase = function(a, b, e, f) { a.aabbNeedsUpdate && a.computeAABB(); b.aabbNeedsUpdate && b.computeAABB(); a.aabb.overlaps(b.aabb) && (e.push(a), f.push(b)) }; var h = { keys: [] }, k = [], f = []; b.prototype.makePairsUnique = function(a, b) { for (var e = a.length, c = 0; c !== e; c++) k[c] = a[c], f[c] = b[c]; a.length = 0; for (c = b.length = 0; c !== e; c++) { var m = k[c].id, d = f[c].id; m = m < d ? m + "," + d : d + "," + m; h[m] = c; h.keys.push(m) } for (c = 0; c !== h.keys.length; c++) m = h.keys.pop(), e = h[m], a.push(k[e]), b.push(f[e]), delete h[m] }; b.prototype.setWorld = function(a) {}; var e = new l; b.boundingSphereCheck = function(a, b) { a.position.vsub(b.position, e); return Math.pow(a.shape.boundingSphereRadius + b.shape.boundingSphereRadius, 2) > e.norm2() }; b.prototype.aabbQuery = function(a, b, e) { console.warn(".aabbQuery is not implemented in this Broadphase subclass."); return [] } }, { "../math/Quaternion": 28, "../math/Vec3": 30, "../objects/Body": 31, "../shapes/Plane": 42, "../shapes/Shape": 43 }], 6: [function(d, g, l) { function b(b, k, f, e, m) { c.apply(this); this.nx = f || 10; this.ny = e || 10; this.nz = m || 10; this.aabbMin = b || new a(100, 100, 100); this.aabbMax = k || new a(-100, -100, -100); b = this.nx * this.ny * this.nz; if (0 >= b) throw "GridBroadphase: Each dimension's n must be >0"; this.bins = []; this.binLengths = []; this.bins.length = b; this.binLengths.length = b; for (k = 0; k < b; k++) this.bins[k] = [], this.binLengths[k] = 0 } g.exports = b; var c = d("./Broadphase"), a = d("../math/Vec3"), q = d("../shapes/Shape"); b.prototype = new c; b.prototype.constructor = b; var p = new a; new a; b.prototype.collisionPairs = function(a, b, f) { function e(a, b, e, f, c, m, h) { a = (a - N) * U | 0; b = (b - H) * R | 0; e = (e - S) * P | 0; f = Q((f - N) * U); c = Q((c - H) * R); m = Q((m - S) * P); 0 > a ? a = 0 : a >= d && (a = d - 1); 0 > b ? b = 0 : b >= g && (b = g - 1); 0 > e ? e = 0 : e >= l && (e = l - 1); 0 > f ? f = 0 : f >= d && (f = d - 1); 0 > c ? c = 0 : c >= g && (c = g - 1); 0 > m ? m = 0 : m >= l && (m = l - 1); a *= B; b *= C; e *= 1; f *= B; c *= C; for (m *= 1; a <= f; a += B) for (var k = b; k <= c; k += C) for (var q = e; q <= m; q += 1) { var p = a + k + q; X[p][u[p]++] = h } } var c = a.numObjects(); a = a.bodies; var h = this.aabbMax, k = this.aabbMin, d = this.nx, g = this.ny, l = this.nz, B = g * l, C = l, A = h.x, x = h.y, G = h.z, N = k.x, H = k.y, S = k.z, U = d / (A - N), R = g / (x - H), P = l / (G - S); A = (A - N) / d; var J = (x - H) / g; G = (G - S) / l; var L = .5 * Math.sqrt(A * A + J * J + G * G); x = q.types; var M = x.SPHERE, O = x.PLANE, X = this.bins, u = this.binLengths; x = this.bins.length; for (k = 0; k !== x; k++) u[k] = 0; var Q = Math.ceil; k = Math.min; h = Math.max; for (k = 0; k !== c; k++) { h = a[k]; var E = h.shape; switch (E.type) { case M: var T = h.position.x, I = h.position.y, F = h.position.z; E = E.radius; e(T - E, I - E, F - E, T + E, I + E, F + E, h); break; case O: E.worldNormalNeedsUpdate && E.computeWorldNormal(h.quaternion); F = E.worldNormal; E = H + .5 * J - h.position.y; var K = S + .5 * G - h.position.z, z = p; z.set(N + .5 * A - h.position.x, E, K); for (var D = T = 0; T !== d; T++, D += B, z.y = E, z.x += A) for (var V = I = 0; I !== g; I++, V += C, z.z = K, z.y += J) for (var aa = 0, Y = 0; aa !== l; aa++, Y += 1, z.z += G) if (z.dot(F) < L) { var W = D + V + Y; X[W][u[W]++] = h } break; default: h.aabbNeedsUpdate && h.computeAABB(), e(h.aabb.lowerBound.x, h.aabb.lowerBound.y, h.aabb.lowerBound.z, h.aabb.upperBound.x, h.aabb.upperBound.y, h.aabb.upperBound.z, h) } } for (k = 0; k !== x; k++) if (c = u[k], 1 < c) for (a = X[k], T = 0; T !== c; T++) for (h = a[T], I = 0; I !== T; I++) A = a[I], this.needBroadphaseCollision(h, A) && this.intersectionTest(h, A, b, f); this.makePairsUnique(b, f) } }, { "../math/Vec3": 30, "../shapes/Shape": 43, "./Broadphase": 5 }], 7: [function(d, g, l) { function b() { c.apply(this) } g.exports = b; var c = d("./Broadphase"); d = d("./AABB"); b.prototype = new c; b.prototype.constructor = b; b.prototype.collisionPairs = function(a, b, c) { a = a.bodies; var h = a.length, k, f; for (k = 0; k !== h; k++) for (f = 0; f !== k; f++) { var e = a[k]; var m = a[f]; this.needBroadphaseCollision(e, m) && this.intersectionTest(e, m, b, c) } }; new d; b.prototype.aabbQuery = function(a, b, c) { c = c || []; for (var h = 0; h < a.bodies.length; h++) { var k = a.bodies[h]; k.aabbNeedsUpdate && k.computeAABB(); k.aabb.overlaps(b) && c.push(k) } return c } }, { "./AABB": 3, "./Broadphase": 5 }], 8: [function(d, g, l) { function b() { this.matrix = {} } g.exports = b; b.prototype.get = function(b, a) { b = b.id; a = a.id; if (a > b) { var c = a; a = b; b = c } return b + "-" + a in this.matrix }; b.prototype.set = function(b, a, d) { b = b.id; a = a.id; if (a > b) { var c = a; a = b; b = c } d ? this.matrix[b + "-" + a] = !0 : delete this.matrix[b + "-" + a] }; b.prototype.reset = function() { this.matrix = {} }; b.prototype.setNumObjects = function(b) {} }, {}], 9: [function(d, g, l) { function b(e, f) { this.from = e ? e.clone() : new a; this.to = f ? f.clone() : new a; this._direction = new a; this.precision = 1E-4; this.checkCollisionResponse = !0; this.skipBackfaces = !1; this.collisionFilterGroup = this.collisionFilterMask = -1; this.mode = b.ANY; this.result = new p; this.hasHit = !1; this.callback = function(a) {} } function c(a, b, c, m) { m.vsub(b, M); c.vsub(b, f); a.vsub(b, e); a = M.dot(M); b = M.dot(f); c = M.dot(e); m = f.dot(f); var h = f.dot(e), k, d; return 0 <= (k = m * c - b * h) && 0 <= (d = a * h - b * c) && k + d < a * m - b * b } g.exports = b; var a = d("../math/Vec3"); g = d("../math/Quaternion"); var q = d("../math/Transform"); d("../shapes/ConvexPolyhedron"); d("../shapes/Box"); var p = d("../collision/RaycastResult"); l = d("../shapes/Shape"); d = d("../collision/AABB"); b.prototype.constructor = b; b.CLOSEST = 1; b.ANY = 2; b.ALL = 4; var h = new d, k = []; b.prototype.intersectWorld = function(a, e) { this.mode = e.mode || b.ANY; this.result = e.result || new p; this.skipBackfaces = !!e.skipBackfaces; this.collisionFilterMask = "undefined" !== typeof e.collisionFilterMask ? e.collisionFilterMask : -1; this.collisionFilterGroup = "undefined" !== typeof e.collisionFilterGroup ? e.collisionFilterGroup : -1; e.from && this.from.copy(e.from); e.to && this.to.copy(e.to); this.callback = e.callback || function() {}; this.hasHit = !1; this.result.reset(); this._updateDirection(); this.getAABB(h); k.length = 0; a.broadphase.aabbQuery(a, h, k); this.intersectBodies(k); return this.hasHit }; var f = new a, e = new a; b.pointInTriangle = c; var m = new a, t = new g; b.prototype.intersectBody = function(a, b) { b && (this.result = b, this._updateDirection()); var e = this.checkCollisionResponse; if ((!e || a.collisionResponse) && 0 !== (this.collisionFilterGroup & a.collisionFilterMask) && 0 !== (a.collisionFilterGroup & this.collisionFilterMask)) for (var f = 0, c = a.shapes.length; f < c; f++) { var h = a.shapes[f]; if (!e || h.collisionResponse) if (a.quaternion.mult(a.shapeOrientations[f], t), a.quaternion.vmult(a.shapeOffsets[f], m), m.vadd(a.position, m), this.intersectShape(h, t, m, a), this.result._shouldStop) break } }; b.prototype.intersectBodies = function(a, b) { b && (this.result = b, this._updateDirection()); for (var e = 0, f = a.length; !this.result._shouldStop && e < f; e++) this.intersectBody(a[e]) }; b.prototype._updateDirection = function() { this.to.vsub(this.from, this._direction); this._direction.normalize() }; b.prototype.intersectShape = function(a, b, e, f) { var c = this.from, m = this._direction; e.vsub(c, M); var h = M.dot(m); m.mult(h, O); O.vadd(c, O); e.distanceTo(O) > a.boundingSphereRadius || (c = this[a.type]) && c.call(this, a, b, e, f) }; new a; new a; var r = new a, w = new a, v = new a, y = new a; new a; new p; b.prototype.intersectBox = function(a, b, e, f) { return this.intersectConvex(a.convexPolyhedronRepresentation, b, e, f) }; b.prototype[l.types.BOX] = b.prototype.intersectBox; b.prototype.intersectPlane = function(b, e, f, c) { var m = this.from, h = this.to, k = this._direction, d = new a(0, 0, 1); e.vmult(d, d); var q = new a; m.vsub(f, q); e = q.dot(d); h.vsub(f, q); q = q.dot(d); if (!(0 < e * q || m.distanceTo(h) < e || (q = d.dot(k), Math.abs(q) < this.precision))) { var p = new a; h = new a; e = new a; m.vsub(f, p); f = -d.dot(p) / q; k.scale(f, h); m.vadd(h, e); this.reportIntersection(d, e, b, c, -1) } }; b.prototype[l.types.PLANE] = b.prototype.intersectPlane; b.prototype.getAABB = function(a) { var b = this.to, e = this.from; a.lowerBound.x = Math.min(b.x, e.x); a.lowerBound.y = Math.min(b.y, e.y); a.lowerBound.z = Math.min(b.z, e.z); a.upperBound.x = Math.max(b.x, e.x); a.upperBound.y = Math.max(b.y, e.y); a.upperBound.z = Math.max(b.z, e.z) }; var B = { faceList: [0] }; b.prototype.intersectHeightfield = function(e, f, c, m) { var h = new a, k = new b(this.from, this.to); q.pointToLocalFrame(c, f, k.from, k.from); q.pointToLocalFrame(c, f, k.to, k.to); var d = [], p = null, r = null, t = null, g = null, l = e.getIndexOfPosition(k.from.x, k.from.y, d, !1); l && (p = d[0], r = d[1], t = d[0], g = d[1]); if (l = e.getIndexOfPosition(k.to.x, k.to.y, d, !1)) { if (null === p || d[0] < p) p = d[0]; if (null === t || d[0] > t) t = d[0]; if (null === r || d[1] < r) r = d[1]; if (null === g || d[1] > g) g = d[1] } if (null !== p) for (e.getRectMinMax(p, r, t, g, []), k = p; k <= t; k++) for (d = r; d <= g; d++) { if (this.result._shouldStop) return; e.getConvexTrianglePillar(k, d, !1); q.pointToWorldFrame(c, f, e.pillarOffset, h); this.intersectConvex(e.pillarConvex, f, h, m, B); if (this.result._shouldStop) return; e.getConvexTrianglePillar(k, d, !0); q.pointToWorldFrame(c, f, e.pillarOffset, h); this.intersectConvex(e.pillarConvex, f, h, m, B) } }; b.prototype[l.types.HEIGHTFIELD] = b.prototype.intersectHeightfield; var C = new a, A = new a; b.prototype.intersectSphere = function(a, b, e, f) { b = this.from; var c = this.to, m = Math.pow(c.x - b.x, 2) + Math.pow(c.y - b.y, 2) + Math.pow(c.z - b.z, 2), h = 2 * ((c.x - b.x) * (b.x - e.x) + (c.y - b.y) * (b.y - e.y) + (c.z - b.z) * (b.z - e.z)), k = Math.pow(h, 2) - 4 * m * (Math.pow(b.x - e.x, 2) + Math.pow(b.y - e.y, 2) + Math.pow(b.z - e.z, 2) - Math.pow(a.radius, 2)); if (!(0 > k)) if (0 === k) b.lerp(c, k, C), C.vsub(e, A), A.normalize(), this.reportIntersection(A, C, a, f, -1); else { var d = (-h - Math.sqrt(k)) / (2 * m); m = (-h + Math.sqrt(k)) / (2 * m); 0 <= d && 1 >= d && (b.lerp(c, d, C), C.vsub(e, A), A.normalize(), this.reportIntersection(A, C, a, f, -1)); !this.result._shouldStop && 0 <= m && 1 >= m && (b.lerp(c, m, C), C.vsub(e, A), A.normalize(), this.reportIntersection(A, C, a, f, -1)) } }; b.prototype[l.types.SPHERE] = b.prototype.intersectSphere; var x = new a; new a; new a; var G = new a; b.prototype.intersectConvex = function(a, b, e, f, m) { m = m && m.faceList || null; for (var h = a.faces, k = a.vertices, d = a.faceNormals, q = this._direction, p = this.from, t = p.distanceTo(this.to), g = m ? m.length : h.length, l = this.result, u = 0; !l._shouldStop && u < g; u++) { var O = m ? m[u] : u, A = h[O], Q = d[O], E = b, H = e; G.copy(k[A[0]]); E.vmult(G, G); G.vadd(H, G); G.vsub(p, G); E.vmult(Q, x); Q = q.dot(x); if (!(Math.abs(Q) < this.precision || (Q = x.dot(G) / Q, 0 > Q))) for (q.mult(Q, r), r.vadd(p, r), w.copy(k[A[0]]), E.vmult(w, w), H.vadd(w, w), Q = 1; !l._shouldStop && Q < A.length - 1; Q++) { v.copy(k[A[Q]]); y.copy(k[A[Q + 1]]); E.vmult(v, v); E.vmult(y, y); H.vadd(v, v); H.vadd(y, y); var B = r.distanceTo(p); !c(r, w, v, y) && !c(r, v, w, y) || B > t || this.reportIntersection(x, r, a, f, O) } } }; b.prototype[l.types.CONVEXPOLYHEDRON] = b.prototype.intersectConvex; var N = new a, H = new a, S = new a, U = new a, R = new a, P = new a; new d; var J = [], L = new q; b.prototype.intersectTrimesh = function(a, b, e, f, m) { m = a.indices; var h = this.from, k = this.to, d = this._direction; L.position.copy(e); L.quaternion.copy(b); q.vectorToLocalFrame(e, b, d, H); q.pointToLocalFrame(e, b, h, S); q.pointToLocalFrame(e, b, k, U); h = S.distanceSquared(U); a.tree.rayQuery(this, L, J); k = 0; for (d = J.length; !this.result._shouldStop && k !== d; k++) { var p = J[k]; a.getNormal(p, N); a.getVertex(m[3 * p], w); w.vsub(S, G); var t = H.dot(N); t = N.dot(G) / t; 0 > t || (H.scale(t, r), r.vadd(S, r), a.getVertex(m[3 * p + 1], v), a.getVertex(m[3 * p + 2], y), t = r.distanceSquared(S), !c(r, v, w, y) && !c(r, w, v, y) || t > h || (q.vectorToWorldFrame(b, N, R), q.pointToWorldFrame(e, b, r, P), this.reportIntersection(R, P, a, f, p))) } J.length = 0 }; b.prototype[l.types.TRIMESH] = b.prototype.intersectTrimesh; b.prototype.reportIntersection = function(a, e, f, c, m) { var h = this.from, k = this.to, d = h.distanceTo(e), q = this.result; if (!(this.skipBackfaces && 0 < a.dot(this._direction))) switch (q.hitFaceIndex = "undefined" !== typeof m ? m : -1, this.mode) { case b.ALL: this.hasHit = !0; q.set(h, k, a, e, f, c, d); q.hasHit = !0; this.callback(q); break; case b.CLOSEST: if (d < q.distance || !q.hasHit) this.hasHit = !0, q.hasHit = !0, q.set(h, k, a, e, f, c, d); break; case b.ANY: this.hasHit = !0, q.hasHit = !0, q.set(h, k, a, e, f, c, d), q._shouldStop = !0 } }; var M = new a, O = new a }, { "../collision/AABB": 3, "../collision/RaycastResult": 10, "../math/Quaternion": 28, "../math/Transform": 29, "../math/Vec3": 30, "../shapes/Box": 37, "../shapes/ConvexPolyhedron": 38, "../shapes/Shape": 43 }], 10: [function(d, g, l) { function b() { this.rayFromWorld = new c; this.rayToWorld = new c; this.hitNormalWorld = new c; this.hitPointWorld = new c; this.hasHit = !1; this.body = this.shape = null; this.distance = this.hitFaceIndex = -1; this._shouldStop = !1 } var c = d("../math/Vec3"); g.exports = b; b.prototype.reset = function() { this.rayFromWorld.setZero(); this.rayToWorld.setZero(); this.hitNormalWorld.setZero(); this.hitPointWorld.setZero(); this.hasHit = !1; this.body = this.shape = null; this.distance = this.hitFaceIndex = -1; this._shouldStop = !1 }; b.prototype.abort = function() { this._shouldStop = !0 }; b.prototype.set = function(a, b, c, h, k, f, e) { this.rayFromWorld.copy(a); this.rayToWorld.copy(b); this.hitNormalWorld.copy(c); this.hitPointWorld.copy(h); this.shape = k; this.body = f; this.distance = e } }, { "../math/Vec3": 30 }], 11: [function(d, g, l) { function b(a) { c.apply(this); this.axisList = []; this.world = null; this.axisIndex = 0; var b = this.axisList; this._addBodyHandler = function(a) { b.push(a.body) }; this._removeBodyHandler = function(a) { a = b.indexOf(a.body); - 1 !== a && b.splice(a, 1) }; a && this.setWorld(a) } d("../shapes/Shape"); var c = d("../collision/Broadphase"); g.exports = b; b.prototype = new c; b.prototype.setWorld = function(a) { for (var b = this.axisList.length = 0; b < a.bodies.length; b++) this.axisList.push(a.bodies[b]); a.removeEventListener("addBody", this._addBodyHandler); a.removeEventListener("removeBody", this._removeBodyHandler); a.addEventListener("addBody", this._addBodyHandler); a.addEventListener("removeBody", this._removeBodyHandler); this.world = a; this.dirty = !0 }; b.insertionSortX = function(a) { for (var b = 1, c = a.length; b < c; b++) { for (var h = a[b], k = b - 1; 0 <= k && !(a[k].aabb.lowerBound.x <= h.aabb.lowerBound.x); k--) a[k + 1] = a[k]; a[k + 1] = h } return a }; b.insertionSortY = function(a) { for (var b = 1, c = a.length; b < c; b++) { for (var h = a[b], k = b - 1; 0 <= k && !(a[k].aabb.lowerBound.y <= h.aabb.lowerBound.y); k--) a[k + 1] = a[k]; a[k + 1] = h } return a }; b.insertionSortZ = function(a) { for (var b = 1, c = a.length; b < c; b++) { for (var h = a[b], k = b - 1; 0 <= k && !(a[k].aabb.lowerBound.z <= h.aabb.lowerBound.z); k--) a[k + 1] = a[k]; a[k + 1] = h } return a }; b.prototype.collisionPairs = function(a, c, d) { a = this.axisList; var h = a.length, k = this.axisIndex, f, e; this.dirty && (this.sortList(), this.dirty = !1); for (f = 0; f !== h; f++) { var m = a[f]; for (e = f + 1; e < h; e++) { var q = a[e]; if (this.needBroadphaseCollision(m, q)) { if (!b.checkBounds(m, q, k)) break; this.intersectionTest(m, q, c, d) } } } }; b.prototype.sortList = function() { for (var a = this.axisList, c = this.axisIndex, d = a.length, h = 0; h !== d; h++) { var k = a[h]; k.aabbNeedsUpdate && k.computeAABB() } 0 === c ? b.insertionSortX(a) : 1 === c ? b.insertionSortY(a) : 2 === c && b.insertionSortZ(a) }; b.checkBounds = function(a, b, c) { if (0 === c) { var h = a.position.x; var k = b.position.x } else 1 === c ? (h = a.position.y, k = b.position.y) : 2 === c && (h = a.position.z, k = b.position.z); return k - b.boundingRadius < h + a.boundingRadius }; b.prototype.autoDetectAxis = function() { for (var a = 0, b = 0, c = 0, h = 0, k = 0, f = 0, e = this.axisList, m = e.length, d = 1 / m, r = 0; r !== m; r++) { var g = e[r], l = g.position.x; a += l; b += l * l; l = g.position.y; c += l; h += l * l; g = g.position.z; k += g; f += g * g } a = b - a * a * d; c = h - c * c * d; k = f - k * k * d; this.axisIndex = a > c ? a > k ? 0 : 2 : c > k ? 1 : 2 }; b.prototype.aabbQuery = function(a, b, c) { c = c || []; this.dirty && (this.sortList(), this.dirty = !1); a = this.axisList; for (var h = 0; h < a.length; h++) { var k = a[h]; k.aabbNeedsUpdate && k.computeAABB(); k.aabb.overlaps(b) && c.push(k) } return c } }, { "../collision/Broadphase": 5, "../shapes/Shape": 43 }], 12: [function(d, g, l) { function b(b, k, f) { f = f || {}; var e = "undefined" !== typeof f.maxForce ? f.maxForce : 1E6, m = f.pivotA ? f.pivotA.clone() : new p, h = f.pivotB ? f.pivotB.clone() : new p; this.axisA = f.axisA ? f.axisA.clone() : new p; this.axisB = f.axisB ? f.axisB.clone() : new p; c.call(this, b, m, k, h, e); this.collideConnected = !!f.collideConnected; this.angle = "undefined" !== typeof f.angle ? f.angle : 0; m = this.coneEquation = new a(b, k, f); b = this.twistEquation = new q(b, k, f); this.twistAngle = "undefined" !== typeof f.twistAngle ? f.twistAngle : 0; m.maxForce = 0; m.minForce = -e; b.maxForce = 0; b.minForce = -e; this.equations.push(m, b) } g.exports = b; d("./Constraint"); var c = d("./PointToPointConstraint"), a = d("../equations/ConeEquation"), q = d("../equations/RotationalEquation"); d("../equations/ContactEquation"); var p = d("../math/Vec3"); b.prototype = new c; b.constructor = b; new p; new p; b.prototype.update = function() { var a = this.bodyA, b = this.bodyB, f = this.coneEquation, e = this.twistEquation; c.prototype.update.call(this); a.vectorToWorldFrame(this.axisA, f.axisA); b.vectorToWorldFrame(this.axisB, f.axisB); this.axisA.tangents(e.axisA, e.axisA); a.vectorToWorldFrame(e.axisA, e.axisA); this.axisB.tangents(e.axisB, e.axisB); b.vectorToWorldFrame(e.axisB, e.axisB); f.angle = this.angle; e.maxAngle = this.twistAngle } }, { "../equations/ConeEquation": 18, "../equations/ContactEquation": 19, "../equations/RotationalEquation": 22, "../math/Vec3": 30, "./Constraint": 13, "./PointToPointConstraint": 17 }], 13: [function(d, g, l) { function b(a, d, p) { p = c.defaults(p, { collideConnected: !0, wakeUpBodies: !0 }); this.equations = []; this.bodyA = a; this.bodyB = d; this.id = b.idCounter++; this.collideConnected = p.collideConnected; p.wakeUpBodies && (a && a.wakeUp(), d && d.wakeUp()) } g.exports = b; var c = d("../utils/Utils"); b.prototype.update = function() { throw Error("method update() not implmemented in this Constraint subclass!"); }; b.prototype.enable = function() { for (var a = this.equations, b = 0; b < a.length; b++) a[b].enabled = !0 }; b.prototype.disable = function() { for (var a = this.equations, b = 0; b < a.length; b++) a[b].enabled = !1 }; b.idCounter = 0 }, { "../utils/Utils": 53 }], 14: [function(d, g, l) { function b(b, d, h, k) { c.call(this, b, d); "undefined" === typeof h && (h = b.position.distanceTo(d.position)); "undefined" === typeof k && (k = 1E6); this.distance = h; b = this.distanceEquation = new a(b, d); this.equations.push(b); b.minForce = -k; b.maxForce = k } g.exports = b; var c = d("./Constraint"), a = d("../equations/ContactEquation"); b.prototype = new c; b.prototype.update = function() { var a = this.distanceEquation, b = .5 * this.distance, c = a.ni; this.bodyB.position.vsub(this.bodyA.position, c); c.normalize(); c.mult(b, a.ri); c.mult(-b, a.rj) } }, { "../equations/ContactEquation": 19, "./Constraint": 13 } ], 15: [function(d, g, l) { function b(b, e, m) { m = m || {}; var f = "undefined" !== typeof m.maxForce ? m.maxForce : 1E6, k = m.pivotA ? m.pivotA.clone() : new p, h = m.pivotB ? m.pivotB.clone() : new p; c.call(this, b, k, e, h, f); (this.axisA = m.axisA ? m.axisA.clone() : new p(1, 0, 0)).normalize(); (this.axisB = m.axisB ? m.axisB.clone() : new p(1, 0, 0)).normalize(); k = this.rotationalEquation1 = new a(b, e, m); m = this.rotationalEquation2 = new a(b, e, m); b = this.motorEquation = new q(b, e, f); b.enabled = !1; this.equations.push(k, m, b) } g.exports = b; d("./Constraint"); var c = d("./PointToPointConstraint"), a = d("../equations/RotationalEquation"), q = d("../equations/RotationalMotorEquation"); d("../equations/ContactEquation"); var p = d("../math/Vec3"); b.prototype = new c; b.constructor = b; b.prototype.enableMotor = function() { this.motorEquation.enabled = !0 }; b.prototype.disableMotor = function() { this.motorEquation.enabled = !1 }; b.prototype.setMotorSpeed = function(a) { this.motorEquation.targetVelocity = a }; b.prototype.setMotorMaxForce = function(a) { this.motorEquation.maxForce = a; this.motorEquation.minForce = -a }; var h = new p, k = new p; b.prototype.update = function() { var a = this.bodyA, b = this.bodyB, m = this.motorEquation, d = this.rotationalEquation1, q = this.rotationalEquation2, p = this.axisA, g = this.axisB; c.prototype.update.call(this); a.quaternion.vmult(p, h); b.quaternion.vmult(g, k); h.tangents(d.axisA, q.axisA); d.axisB.copy(k); q.axisB.copy(k); this.motorEquation.enabled && (a.quaternion.vmult(this.axisA, m.axisA), b.quaternion.vmult(this.axisB, m.axisB)) } }, { "../equations/ContactEquation": 19, "../equations/RotationalEquation": 22, "../equations/RotationalMotorEquation": 23, "../math/Vec3": 30, "./Constraint": 13, "./PointToPointConstraint": 17 }], 16: [function(d, g, l) { function b(b, h, k) { k = k || {}; var f = "undefined" !== typeof k.maxForce ? k.maxForce : 1E6, e = new q, m = new q, d = new q; b.position.vadd(h.position, d); d.scale(.5, d); h.pointToLocalFrame(d, m); b.pointToLocalFrame(d, e); c.call(this, b, e, h, m, f); f = this.rotationalEquation1 = new a(b, h, k); e = this.rotationalEquation2 = new a(b, h, k); b = this.rotationalEquation3 = new a(b, h, k); this.equations.push(f, e, b) } g.exports = b; d("./Constraint"); var c = d("./PointToPointConstraint"), a = d("../equations/RotationalEquation"); d("../equations/RotationalMotorEquation"); d("../equations/ContactEquation"); var q = d("../math/Vec3"); b.prototype = new c; b.constructor = b; new q; new q; b.prototype.update = function() { var a = this.bodyA, b = this.bodyB, k = this.rotationalEquation1, f = this.rotationalEquation2, e = this.rotationalEquation3; c.prototype.update.call(this); a.vectorToWorldFrame(q.UNIT_X, k.axisA); b.vectorToWorldFrame(q.UNIT_Y, k.axisB); a.vectorToWorldFrame(q.UNIT_Y, f.axisA); b.vectorToWorldFrame(q.UNIT_Z, f.axisB); a.vectorToWorldFrame(q.UNIT_Z, e.axisA); b.vectorToWorldFrame(q.UNIT_X, e.axisB) } }, { "../equations/ContactEquation": 19, "../equations/RotationalEquation": 22, "../equations/RotationalMotorEquation": 23, "../math/Vec3": 30, "./Constraint": 13, "./PointToPointConstraint": 17 }], 17: [function(d, g, l) { function b(b, d, k, f, e) { c.call(this, b, k); e = "undefined" !== typeof e ? e : 1E6; this.pivotA = d ? d.clone() : new q; this.pivotB = f ? f.clone() : new q; d = this.equationX = new a(b, k); f = this.equationY = new a(b, k); b = this.equationZ = new a(b, k); this.equations.push(d, f, b); d.minForce = f.minForce = b.minForce = -e; d.maxForce = f.maxForce = b.maxForce = e; d.ni.set(1, 0, 0); f.ni.set(0, 1, 0); b.ni.set(0, 0, 1) } g.exports = b; var c = d("./Constraint"), a = d("../equations/ContactEquation"), q = d("../math/Vec3"); b.prototype = new c; b.prototype.update = function() { var a = this.bodyB, b = this.equationX, c = this.equationY, f = this.equationZ; this.bodyA.quaternion.vmult(this.pivotA, b.ri); a.quaternion.vmult(this.pivotB, b.rj); c.ri.copy(b.ri); c.rj.copy(b.rj); f.ri.copy(b.ri); f.rj.copy(b.rj) } }, { "../equations/ContactEquation": 19, "../math/Vec3": 30, "./Constraint": 13 }], 18: [function(d, g, l) { function b(b, d, f) { f = f || {}; var e = "undefined" !== typeof f.maxForce ? f.maxForce : 1E6; a.call(this, b, d, -e, e); this.axisA = f.axisA ? f.axisA.clone() : new c(1, 0, 0); this.axisB = f.axisB ? f.axisB.clone() : new c(0, 1, 0); this.angle = "undefined" !== typeof f.angle ? f.angle : 0 } g.exports = b; var c = d("../math/Vec3"); d("../math/Mat3"); var a = d("./Equation"); b.prototype = new a; b.prototype.constructor = b; var q = new c, p = new c; b.prototype.computeB = function(a) { var b = this.a, f = this.b, e = this.axisA, c = this.axisB, d = this.jacobianElementA, h = this.jacobianElementB; e.cross(c, q); c.cross(e, p); d.rotational.copy(p); h.rotational.copy(q); e = Math.cos(this.angle) - e.dot(c); c = this.computeGW(); d = this.computeGiMf(); return -e * b - c * f - a * d } }, { "../math/Mat3": 27, "../math/Vec3": 30, "./Equation": 20 }], 19: [function(d, g, l) { function b(b, e, f) { c.call(this, b, e, 0, "undefined" !== typeof f ? f : 1E6); this.restitution = 0; this.ri = new a; this.rj = new a; this.ni = new a } g.exports = b; var c = d("./Equation"), a = d("../math/Vec3"); d("../math/Mat3"); b.prototype = new c; b.prototype.constructor = b; var q = new a, p = new a, h = new a; b.prototype.computeB = function(a) { var b = this.a, e = this.b, c = this.bi, f = this.bj, m = this.ri, d = this.rj, k = c.velocity, g = c.angularVelocity, r = f.velocity, t = f.angularVelocity, l = this.jacobianElementA, U = this.jacobianElementB, R = this.ni; m.cross(R, q); d.cross(R, p); R.negate(l.spatial); q.negate(l.rotational); U.spatial.copy(R); U.rotational.copy(p); h.copy(f.position); h.vadd(d, h); h.vsub(c.position, h); h.vsub(m, h); c = R.dot(h); f = this.restitution + 1; k = f * r.dot(R) - f * k.dot(R) + t.dot(p) - g.dot(q); g = this.computeGiMf(); return -c * b - k * e - a * g }; var k = new a, f = new a, e = new a, m = new a, t = new a; b.prototype.getImpactVelocityAlongNormal = function() { this.bi.position.vadd(this.ri, e); this.bj.position.vadd(this.rj, m); this.bi.getVelocityAtWorldPoint(e, k); this.bj.getVelocityAtWorldPoint(m, f); k.vsub(f, t); return this.ni.dot(t) } }, { "../math/Mat3": 27, "../math/Vec3": 30, "./Equation": 20 }], 20: [function(d, g, l) { function b(a, e, f, d) { this.id = b.id++; this.minForce = "undefined" === typeof f ? -1E6 : f; this.maxForce = "undefined" === typeof d ? 1E6 : d; this.bi = a; this.bj = e; this.eps = this.b = this.a = 0; this.jacobianElementA = new c; this.jacobianElementB = new c; this.enabled = !0; this.setSpookParams(1E7, 4, 1 / 60) } g.exports = b; var c = d("../math/JacobianElement"); d = d("../math/Vec3"); b.prototype.constructor = b; b.id = 0; b.prototype.setSpookParams = function(a, b, e) { this.a = 4 / (e * (1 + 4 * b)); this.b = 4 * b / (1 + 4 * b); this.eps = 4 / (e * e * a * (1 + 4 * b)) }; b.prototype.computeB = function(a, b, e) { var f = this.computeGW(), c = this.computeGq(), m = this.computeGiMf(); return -c * a - f * b - m * e }; b.prototype.computeGq = function() { var a = this.jacobianElementB, b = this.bj.position; return this.jacobianElementA.spatial.dot(this.bi.position) + a.spatial.dot(b) }; var a = new d; b.prototype.computeGW = function() { var b = this.jacobianElementB, e = this.bi, f = this.bj, c = f.velocity; f = f.angularVelocity || a; return this.jacobianElementA.multiplyVectors(e.velocity, e.angularVelocity || a) + b.multiplyVectors(c, f) }; b.prototype.computeGWlambda = function() { var b = this.jacobianElementB, e = this.bi, f = this.bj, c = f.vlambda; f = f.wlambda || a; return this.jacobianElementA.multiplyVectors(e.vlambda, e.wlambda || a) + b.multiplyVectors(c, f) }; var q = new d, p = new d, h = new d, k = new d; b.prototype.computeGiMf = function() { var a = this.jacobianElementA, b = this.jacobianElementB, e = this.bi, f = this.bj, c = e.force, d = e.torque, g = f.force, l = f.torque, A = e.invMassSolve, x = f.invMassSolve; e.invInertiaWorldSolve ? e.invInertiaWorldSolve.vmult(d, h) : h.set(0, 0, 0); f.invInertiaWorldSolve ? f.invInertiaWorldSolve.vmult(l, k) : k.set(0, 0, 0); c.mult(A, q); g.mult(x, p); return a.multiplyVectors(q, h) + b.multiplyVectors(p, k) }; var f = new d; b.prototype.computeGiMGt = function() { var a = this.jacobianElementA, b = this.jacobianElementB, e = this.bi, c = this.bj, d = e.invInertiaWorldSolve, k = c.invInertiaWorldSolve; e = e.invMassSolve + c.invMassSolve; d && (d.vmult(a.rotational, f), e += f.dot(a.rotational)); k && (k.vmult(b.rotational, f), e += f.dot(b.rotational)); return e }; var e = new d; new d; new d; new d; new d; new d; b.prototype.addToWlambda = function(a) { var b = this.jacobianElementA, f = this.jacobianElementB, c = this.bi, m = this.bj; b.spatial.mult(c.invMassSolve * a, e); c.vlambda.vadd(e, c.vlambda); f.spatial.mult(m.invMassSolve * a, e); m.vlambda.vadd(e, m.vlambda); c.invInertiaWorldSolve && (c.invInertiaWorldSolve.vmult(b.rotational, e), e.mult(a, e), c.wlambda.vadd(e, c.wlambda)); m.invInertiaWorldSolve && (m.invInertiaWorldSolve.vmult(f.rotational, e), e.mult(a, e), m.wlambda.vadd(e, m.wlambda)) }; b.prototype.computeC = function() { return this.computeGiMGt() + this.eps } }, { "../math/JacobianElement": 26, "../math/Vec3": 30 }], 21: [function(d, g, l) { function b(b, d, f) { c.call(this, b, d, -f, f); this.ri = new a; this.rj = new a; this.t = new a } g.exports = b; var c = d("./Equation"), a = d("../math/Vec3"); d("../math/Mat3"); b.prototype = new c; b.prototype.constructor = b; var q = new a, p = new a; b.prototype.computeB = function(a) { var b = this.b, f = this.rj, e = this.t; this.ri.cross(e, q); f.cross(e, p); f = this.jacobianElementA; var c = this.jacobianElementB; e.negate(f.spatial); q.negate(f.rotational); c.spatial.copy(e); c.rotational.copy(p); e = this.computeGW(); f = this.computeGiMf(); return -e * b - a * f } }, { "../math/Mat3": 27, "../math/Vec3": 30, "./Equation": 20 }], 22: [function(d, g, l) { function b(b, d, f) { f = f || {}; var e = "undefined" !== typeof f.maxForce ? f.maxForce : 1E6; a.call(this, b, d, -e, e); this.axisA = f.axisA ? f.axisA.clone() : new c(1, 0, 0); this.axisB = f.axisB ? f.axisB.clone() : new c(0, 1, 0); this.maxAngle = Math.PI / 2 } g.exports = b; var c = d("../math/Vec3"); d("../math/Mat3"); var a = d("./Equation"); b.prototype = new a; b.prototype.constructor = b; var q = new c, p = new c; b.prototype.computeB = function(a) { var b = this.a, f = this.b, e = this.axisA, c = this.axisB, d = this.jacobianElementA, h = this.jacobianElementB; e.cross(c, q); c.cross(e, p); d.rotational.copy(p); h.rotational.copy(q); e = Math.cos(this.maxAngle) - e.dot(c); c = this.computeGW(); d = this.computeGiMf(); return -e * b - c * f - a * d } }, { "../math/Mat3": 27, "../math/Vec3": 30, "./Equation": 20 }], 23: [function(d, g, l) { function b(b, d, h) { h = "undefined" !== typeof h ? h : 1E6; a.call(this, b, d, -h, h); this.axisA = new c; this.axisB = new c; this.targetVelocity = 0 } g.exports = b; var c = d("../math/Vec3"); d("../math/Mat3"); var a = d("./Equation"); b.prototype = new a; b.prototype.constructor = b; b.prototype.computeB = function(a) { var b = this.b, c = this.axisB, d = this.jacobianElementB; this.jacobianElementA.rotational.copy(this.axisA); c.negate(d.rotational); c = this.computeGW() - this.targetVelocity; d = this.computeGiMf(); return -c * b - a * d } }, { "../math/Mat3": 27, "../math/Vec3": 30, "./Equation": 20 }], 24: [function(d, g, l) { function b(a, d, p) { p = c.defaults(p, { friction: .3, restitution: .3, contactEquationStiffness: 1E7, contactEquationRelaxation: 3, frictionEquationStiffness: 1E7, frictionEquationRelaxation: 3 }); this.id = b.idCounter++; this.materials = [a, d]; this.friction = p.friction; this.restitution = p.restitution; this.contactEquationStiffness = p.contactEquationStiffness; this.contactEquationRelaxation = p.contactEquationRelaxation; this.frictionEquationStiffness = p.frictionEquationStiffness; this.frictionEquationRelaxation = p.frictionEquationRelaxation } var c = d("../utils/Utils"); g.exports = b; b.idCounter = 0 }, { "../utils/Utils": 53 }], 25: [function(d, g, l) { function b(c) { var a = ""; c = c || {}; "string" === typeof c ? (a = c, c = {}) : "object" === typeof c && (a = ""); this.name = a; this.id = b.idCounter++; this.friction = "undefined" !== typeof c.friction ? c.friction : -1; this.restitution = "undefined" !== typeof c.restitution ? c.restitution : -1 } g.exports = b; b.idCounter = 0 }, {}], 26: [function(d, g, l) { function b() { this.spatial = new c; this.rotational = new c } g.exports = b; var c = d("./Vec3"); b.prototype.multiplyElement = function(a) { return a.spatial.dot(this.spatial) + a.rotational.dot(this.rotational) }; b.prototype.multiplyVectors = function(a, b) { return a.dot(this.spatial) + b.dot(this.rotational) } }, { "./Vec3": 30 } ], 27: [function(d, g, l) { function b(a) { this.elements = a ? a : [0, 0, 0, 0, 0, 0, 0, 0, 0] } g.exports = b; var c = d("./Vec3"); b.prototype.identity = function() { var a = this.elements; a[0] = 1; a[1] = 0; a[2] = 0; a[3] = 0; a[4] = 1; a[5] = 0; a[6] = 0; a[7] = 0; a[8] = 1 }; b.prototype.setZero = function() { var a = this.elements; a[0] = 0; a[1] = 0; a[2] = 0; a[3] = 0; a[4] = 0; a[5] = 0; a[6] = 0; a[7] = 0; a[8] = 0 }; b.prototype.setTrace = function(a) { var b = this.elements; b[0] = a.x; b[4] = a.y; b[8] = a.z }; b.prototype.getTrace = function(a) { a = a || new c; var b = this.elements; a.x = b[0]; a.y = b[4]; a.z = b[8] }; b.prototype.vmult = function(a, b) { b = b || new c; var d = this.elements, h = a.x, k = a.y, f = a.z; b.x = d[0] * h + d[1] * k + d[2] * f; b.y = d[3] * h + d[4] * k + d[5] * f; b.z = d[6] * h + d[7] * k + d[8] * f; return b }; b.prototype.smult = function(a) { for (var b = 0; b < this.elements.length; b++) this.elements[b] *= a }; b.prototype.mmult = function(a, c) { for (var d = c || new b, h = 0; 3 > h; h++) for (var k = 0; 3 > k; k++) { for (var f = 0, e = 0; 3 > e; e++) f += a.elements[h + 3 * e] * this.elements[e + 3 * k]; d.elements[h + 3 * k] = f } return d }; b.prototype.scale = function(a, c) { c = c || new b; for (var d = this.elements, h = c.elements, k = 0; 3 !== k; k++) h[3 * k] = a.x * d[3 * k], h[3 * k + 1] = a.y * d[3 * k + 1], h[3 * k + 2] = a.z * d[3 * k + 2]; return c }; b.prototype.solve = function(a, b) { b = b || new c; for (var d = [], h = 0; 12 > h; h++) d.push(0); var k; for (h = 0; 3 > h; h++) for (k = 0; 3 > k; k++) d[h + 4 * k] = this.elements[h + 3 * k]; d[3] = a.x; d[7] = a.y; d[11] = a.z; var f = 3, e = f; do { h = e - f; if (0 === d[h + 4 * h]) for (k = h + 1; k < e; k++) if (0 !== d[h + 4 * k]) { var m = 4; do { var q = 4 - m; d[q + 4 * h] += d[q + 4 * k] } while (--m); break } if (0 !== d[h + 4 * h]) for (k = h + 1; k < e; k++) { var g = d[h + 4 * k] / d[h + 4 * h]; m = 4; do q = 4 - m, d[q + 4 * k] = q <= h ? 0 : d[q + 4 * k] - d[q + 4 * h] * g; while (--m) } } while (--f); b.z = d[11] / d[10]; b.y = (d[7] - d[6] * b.z) / d[5]; b.x = (d[3] - d[2] * b.z - d[1] * b.y) / d[0]; if (isNaN(b.x) || isNaN(b.y) || isNaN(b.z) || Infinity === b.x || Infinity === b.y || Infinity === b.z) throw "Could not solve equation! Got x=[" + b.toString() + "], b=[" + a.toString() + "], A=[" + this.toString() + "]"; return b }; b.prototype.e = function(a, b, c) { if (void 0 === c) return this.elements[b + 3 * a]; this.elements[b + 3 * a] = c }; b.prototype.copy = function(a) { for (var b = 0; b < a.elements.length; b++) this.elements[b] = a.elements[b]; return this }; b.prototype.toString = function() { for (var a = "", b = 0; 9 > b; b++) a += this.elements[b] + ","; return a }; b.prototype.reverse = function(a) { a = a || new b; for (var c = [], d = 0; 18 > d; d++) c.push(0); var h; for (d = 0; 3 > d; d++) for (h = 0; 3 > h; h++) c[d + 6 * h] = this.elements[d + 3 * h]; c[3] = 1; c[9] = 0; c[15] = 0; c[4] = 0; c[10] = 1; c[16] = 0; c[5] = 0; c[11] = 0; c[17] = 1; var k = 3, f = k; do { d = f - k; if (0 === c[d + 6 * d]) for (h = d + 1; h < f; h++) if (0 !== c[d + 6 * h]) { var e = 6; do { var m = 6 - e; c[m + 6 * d] += c[m + 6 * h] } while (--e); break } if (0 !== c[d + 6 * d]) for (h = d + 1; h < f; h++) { var g = c[d + 6 * h] / c[d + 6 * d]; e = 6; do m = 6 - e, c[m + 6 * h] = m <= d ? 0 : c[m + 6 * h] - c[m + 6 * d] * g; while (--e) } } while (--k); d = 2; do { h = d - 1; do { g = c[d + 6 * h] / c[d + 6 * d]; e = 6; do m = 6 - e, c[m + 6 * h] -= c[m + 6 * d] * g; while (--e) } while (h--) } while (--d); d = 2; do { g = 1 / c[d + 6 * d]; e = 6; do m = 6 - e, c[m + 6 * d] *= g; while (--e) } while (d--); d = 2; do { h = 2; do { m = c[3 + h + 6 * d]; if (isNaN(m) || Infinity === m) throw "Could not reverse! A=[" + this.toString() + "]"; a.e(d, h, m) } while (h--) } while (d--); return a }; b.prototype.setRotationFromQuaternion = function(a) { var b = a.x, c = a.y, d = a.z, k = a.w, f = b + b, e = c + c, m = d + d; a = b * f; var g = b * e; b *= m; var r = c * e; c *= m; d *= m; f *= k; e *= k; k *= m; m = this.elements; m[0] = 1 - (r + d); m[1] = g - k; m[2] = b + e; m[3] = g + k; m[4] = 1 - (a + d); m[5] = c - f; m[6] = b - e; m[7] = c + f; m[8] = 1 - (a + r); return this }; b.prototype.transpose = function(a) { a = a || new b; for (var c = a.elements, d = this.elements, h = 0; 3 !== h; h++) for (var k = 0; 3 !== k; k++) c[3 * h + k] = d[3 * k + h]; return a } }, { "./Vec3": 30 }], 28: [function(d, g, l) { function b(a, b, c, d) { this.x = void 0 !== a ? a : 0; this.y = void 0 !== b ? b : 0; this.z = void 0 !== c ? c : 0; this.w = void 0 !== d ? d : 1 } g.exports = b; var c = d("./Vec3"); b.prototype.set = function(a, b, c, d) { this.x = a; this.y = b; this.z = c; this.w = d }; b.prototype.toString = function() { return this.x + "," + this.y + "," + this.z + "," + this.w }; b.prototype.toArray = function() { return [this.x, this.y, this.z, this.w] }; b.prototype.setFromAxisAngle = function(a, b) { var e = Math.sin(.5 * b); this.x = a.x * e; this.y = a.y * e; this.z = a.z * e; this.w = Math.cos(.5 * b) }; b.prototype.toAxisAngle = function(a) { a = a || new c; this.normalize(); var b = 2 * Math.acos(this.w), f = Math.sqrt(1 - this.w * this.w); .001 > f ? (a.x = this.x, a.y = this.y, a.z = this.z) : (a.x = this.x / f, a.y = this.y / f, a.z = this.z / f); return [a, b] }; var a = new c, q = new c; b.prototype.setFromVectors = function(b, e) { if (b.isAntiparallelTo(e)) b.tangents(a, q), this.setFromAxisAngle(a, Math.PI); else { var c = b.cross(e); this.x = c.x; this.y = c.y; this.z = c.z; this.w = Math.sqrt(Math.pow(b.norm(), 2) * Math.pow(e.norm(), 2)) + b.dot(e); this.normalize() } }; var p = new c, h = new c, k = new c; b.prototype.mult = function(a, e) { e = e || new b; var c = this.w; p.set(this.x, this.y, this.z); h.set(a.x, a.y, a.z); e.w = c * a.w - p.dot(h); p.cross(h, k); e.x = c * h.x + a.w * p.x + k.x; e.y = c * h.y + a.w * p.y + k.y; e.z = c * h.z + a.w * p.z + k.z; return e }; b.prototype.inverse = function(a) { var e = this.x, c = this.y, d = this.z, f = this.w; a = a || new b; this.conjugate(a); e = 1 / (e * e + c * c + d * d + f * f); a.x *= e; a.y *= e; a.z *= e; a.w *= e; return a }; b.prototype.conjugate = function(a) { a = a || new b; a.x = -this.x; a.y = -this.y; a.z = -this.z; a.w = this.w; return a }; b.prototype.normalize = function() { var a = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); 0 === a ? this.w = this.z = this.y = this.x = 0 : (a = 1 / a, this.x *= a, this.y *= a, this.z *= a, this.w *= a) }; b.prototype.normalizeFast = function() { var a = (3 - (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)) / 2; 0 === a ? this.w = this.z = this.y = this.x = 0 : (this.x *= a, this.y *= a, this.z *= a, this.w *= a) }; b.prototype.vmult = function(a, b) { b = b || new c; var e = a.x, d = a.y, f = a.z, k = this.x, h = this.y, g = this.z, q = this.w, l = q * e + h * f - g * d, p = q * d + g * e - k * f, x = q * f + k * d - h * e; e = -k * e - h * d - g * f; b.x = l * q + e * -k + p * -g - x * -h; b.y = p * q + e * -h + x * -k - l * -g; b.z = x * q + e * -g + l * -h - p * -k; return b }; b.prototype.copy = function(a) { this.x = a.x; this.y = a.y; this.z = a.z; this.w = a.w; return this }; b.prototype.toEuler = function(a, b) { b = b || "YZX"; var e = this.x, c = this.y, d = this.z, f = this.w; switch (b) { case "YZX": var k = e * c + d * f; if (.499 < k) { var h = 2 * Math.atan2(e, f); var g = Math.PI / 2; var q = 0 } - .499 > k && (h = -2 * Math.atan2(e, f), g = -Math.PI / 2, q = 0); isNaN(h) && (q = d * d, h = Math.atan2(2 * c * f - 2 * e * d, 1 - 2 * c * c - 2 * q), g = Math.asin(2 * k), q = Math.atan2(2 * e * f - 2 * c * d, 1 - 2 * e * e - 2 * q)); break; default: throw Error("Euler order " + b + " not supported yet."); } a.y = h; a.z = g; a.x = q }; b.prototype.setFromEuler = function(a, b, c, d) { d = d || "XYZ"; var e = Math.cos(a / 2), f = Math.cos(b / 2), k = Math.cos(c / 2); a = Math.sin(a / 2); b = Math.sin(b / 2); c = Math.sin(c / 2); "XYZ" === d ? (this.x = a * f * k + e * b * c, this.y = e * b * k - a * f * c, this.z = e * f * c + a * b * k, this.w = e * f * k - a * b * c) : "YXZ" === d ? (this.x = a * f * k + e * b * c, this.y = e * b * k - a * f * c, this.z = e * f * c - a * b * k, this.w = e * f * k + a * b * c) : "ZXY" === d ? (this.x = a * f * k - e * b * c, this.y = e * b * k + a * f * c, this.z = e * f * c + a * b * k, this.w = e * f * k - a * b * c) : "ZYX" === d ? (this.x = a * f * k - e * b * c, this.y = e * b * k + a * f * c, this.z = e * f * c - a * b * k, this.w = e * f * k + a * b * c) : "YZX" === d ? (this.x = a * f * k + e * b * c, this.y = e * b * k + a * f * c, this.z = e * f * c - a * b * k, this.w = e * f * k - a * b * c) : "XZY" === d && (this.x = a * f * k - e * b * c, this.y = e * b * k - a * f * c, this.z = e * f * c + a * b * k, this.w = e * f * k + a * b * c); return this }; b.prototype.clone = function() { return new b(this.x, this.y, this.z, this.w) } }, { "./Vec3": 30 }], 29: [function(d, g, l) { function b(b) { b = b || {}; this.position = new c; b.position && this.position.copy(b.position); this.quaternion = new a; b.quaternion && this.quaternion.copy(b.quaternion) } var c = d("./Vec3"), a = d("./Quaternion"); g.exports = b; var q = new a; b.pointToLocalFrame = function(a, b, d, f) { f = f || new c; d.vsub(a, f); b.conjugate(q); q.vmult(f, f); return f }; b.prototype.pointToLocal = function(a, c) { return b.pointToLocalFrame(this.position, this.quaternion, a, c) }; b.pointToWorldFrame = function(a, b, d, f) { f = f || new c; b.vmult(d, f); f.vadd(a, f); return f }; b.prototype.pointToWorld = function(a, c) { return b.pointToWorldFrame(this.position, this.quaternion, a, c) }; b.prototype.vectorToWorldFrame = function(a, b) { b = b || new c; this.quaternion.vmult(a, b); return b }; b.vectorToWorldFrame = function(a, b, c) { a.vmult(b, c); return c }; b.vectorToLocalFrame = function(a, b, d, f) { f = f || new c; b.w *= -1; b.vmult(d, f); b.w *= -1; return f } }, { "./Quaternion": 28, "./Vec3": 30 }], 30: [function(d, g, l) { function b(a, b, c) { this.x = a || 0; this.y = b || 0; this.z = c || 0 } g.exports = b; var c = d("./Mat3"); b.ZERO = new b(0, 0, 0); b.UNIT_X = new b(1, 0, 0); b.UNIT_Y = new b(0, 1, 0); b.UNIT_Z = new b(0, 0, 1); b.prototype.cross = function(a, c) { var d = a.x, e = a.y, k = a.z, h = this.x, g = this.y, q = this.z; c = c || new b; c.x = g * k - q * e; c.y = q * d - h * k; c.z = h * e - g * d; return c }; b.prototype.set = function(a, b, c) { this.x = a; this.y = b; this.z = c; return this }; b.prototype.setZero = function() { this.x = this.y = this.z = 0 }; b.prototype.vadd = function(a, c) { if (c) c.x = a.x + this.x, c.y = a.y + this.y, c.z = a.z + this.z; else return new b(this.x + a.x, this.y + a.y, this.z + a.z) }; b.prototype.vsub = function(a, c) { if (c) c.x = this.x - a.x, c.y = this.y - a.y, c.z = this.z - a.z; else return new b(this.x - a.x, this.y - a.y, this.z - a.z) }; b.prototype.crossmat = function() { return new c([0, -this.z, this.y, this.z, 0, -this.x, -this.y, this.x, 0]) }; b.prototype.normalize = function() { var a = this.x, b = this.y, c = this.z; a = Math.sqrt(a * a + b * b + c * c); 0 < a ? (b = 1 / a, this.x *= b, this.y *= b, this.z *= b) : this.z = this.y = this.x = 0; return a }; b.prototype.unit = function(a) { a = a || new b; var c = this.x, d = this.y, e = this.z, m = Math.sqrt(c * c + d * d + e * e); 0 < m ? (m = 1 / m, a.x = c * m, a.y = d * m, a.z = e * m) : (a.x = 1, a.y = 0, a.z = 0); return a }; b.prototype.norm = function() { var a = this.x, b = this.y, c = this.z; return Math.sqrt(a * a + b * b + c * c) }; b.prototype.length = b.prototype.norm; b.prototype.norm2 = function() { return this.dot(this) }; b.prototype.lengthSquared = b.prototype.norm2; b.prototype.distanceTo = function(a) { var b = this.x, c = this.y, e = this.z, d = a.x, h = a.y; a = a.z; return Math.sqrt((d - b) * (d - b) + (h - c) * (h - c) + (a - e) * (a - e)) }; b.prototype.distanceSquared = function(a) { var b = this.x, c = this.y, e = this.z, d = a.x, h = a.y; a = a.z; return (d - b) * (d - b) + (h - c) * (h - c) + (a - e) * (a - e) }; b.prototype.mult = function(a, c) { c = c || new b; var d = this.y, e = this.z; c.x = a * this.x; c.y = a * d; c.z = a * e; return c }; b.prototype.scale = b.prototype.mult; b.prototype.dot = function(a) { return this.x * a.x + this.y * a.y + this.z * a.z }; b.prototype.isZero = function() { return 0 === this.x && 0 === this.y && 0 === this.z }; b.prototype.negate = function(a) { a = a || new b; a.x = -this.x; a.y = -this.y; a.z = -this.z; return a }; var a = new b, q = new b; b.prototype.tangents = function(b, c) { var d = this.norm(); 0 < d ? (d = 1 / d, a.set(this.x * d, this.y * d, this.z * d), .9 > Math.abs(a.x) ? q.set(1, 0, 0) : q.set(0, 1, 0), a.cross(q, b), a.cross(b, c)) : (b.set(1, 0, 0), c.set(0, 1, 0)) }; b.prototype.toString = function() { return this.x + "," + this.y + "," + this.z }; b.prototype.toArray = function() { return [this.x, this.y, this.z] }; b.prototype.copy = function(a) { this.x = a.x; this.y = a.y; this.z = a.z; return this }; b.prototype.lerp = function(a, b, c) { var e = this.x, d = this.y, f = this.z; c.x = e + (a.x - e) * b; c.y = d + (a.y - d) * b; c.z = f + (a.z - f) * b }; b.prototype.almostEquals = function(a, b) { void 0 === b && (b = 1E-6); return Math.abs(this.x - a.x) > b || Math.abs(this.y - a.y) > b || Math.abs(this.z - a.z) > b ? !1 : !0 }; b.prototype.almostZero = function(a) { void 0 === a && (a = 1E-6); return Math.abs(this.x) > a || Math.abs(this.y) > a || Math.abs(this.z) > a ? !1 : !0 }; var p = new b; b.prototype.isAntiparallelTo = function(a, b) { this.negate(p); return p.almostEquals(a, b) }; b.prototype.clone = function() { return new b(this.x, this.y, this.z) } }, { "./Mat3": 27 }], 31: [function(d, g, l) { function b(e) { e = e || {}; c.apply(this); this.id = b.idCounter++; this.postStep = this.preStep = this.world = null; this.vlambda = new a; this.collisionFilterGroup = "number" === typeof e.collisionFilterGroup ? e.collisionFilterGroup : 1; this.collisionFilterMask = "number" === typeof e.collisionFilterMask ? e.collisionFilterMask : 1; this.collisionResponse = !0; this.position = new a; e.position && this.position.copy(e.position); this.previousPosition = new a; this.initPosition = new a; this.velocity = new a; e.velocity && this.velocity.copy(e.velocity); this.initVelocity = new a; this.force = new a; var d = "number" === typeof e.mass ? e.mass : 0; this.mass = d; this.invMass = 0 < d ? 1 / d : 0; this.material = e.material || null; this.linearDamping = "number" === typeof e.linearDamping ? e.linearDamping : .01; this.type = 0 >= d ? b.STATIC : b.DYNAMIC; typeof e.type === typeof b.STATIC && (this.type = e.type); this.allowSleep = "undefined" !== typeof e.allowSleep ? e.allowSleep : !0; this.sleepState = 0; this.sleepSpeedLimit = "undefined" !== typeof e.sleepSpeedLimit ? e.sleepSpeedLimit : .1; this.sleepTimeLimit = "undefined" !== typeof e.sleepTimeLimit ? e.sleepTimeLimit : 1; this.timeLastSleepy = 0; this._wakeUpAfterNarrowphase = !1; this.torque = new a; this.quaternion = new p; e.quaternion && this.quaternion.copy(e.quaternion); this.initQuaternion = new p; this.angularVelocity = new a; e.angularVelocity && this.angularVelocity.copy(e.angularVelocity); this.initAngularVelocity = new a; this.interpolatedPosition = new a; this.interpolatedQuaternion = new p; this.shapes = []; this.shapeOffsets = []; this.shapeOrientations = []; this.inertia = new a; this.invInertia = new a; this.invInertiaWorld = new q; this.invMassSolve = 0; this.invInertiaSolve = new a; this.invInertiaWorldSolve = new q; this.fixedRotation = "undefined" !== typeof e.fixedRotation ? e.fixedRotation : !1; this.angularDamping = "undefined" !== typeof e.angularDamping ? e.angularDamping : .01; this.userData = "undefined" !== typeof e.userData ? e.userData : null; this.aabb = new h; this.aabbNeedsUpdate = !0; this.wlambda = new a; e.shape && this.addShape(e.shape); this.updateMassProperties() } g.exports = b; var c = d("../utils/EventTarget"); d("../shapes/Shape"); var a = d("../math/Vec3"), q = d("../math/Mat3"), p = d("../math/Quaternion"); d("../material/Material"); var h = d("../collision/AABB"), k = d("../shapes/Box"); b.prototype = new c; b.prototype.constructor = b; b.DYNAMIC = 1; b.STATIC = 2; b.KINEMATIC = 4; b.AWAKE = 0; b.SLEEPY = 1; b.SLEEPING = 2; b.idCounter = 0; b.prototype.wakeUp = function() { var a = this.sleepState; this.sleepState = 0; a === b.SLEEPING && this.dispatchEvent({ type: "wakeup" }) }; b.prototype.sleep = function() { this.sleepState = b.SLEEPING; this.velocity.set(0, 0, 0); this.angularVelocity.set(0, 0, 0) }; b.sleepyEvent = { type: "sleepy" }; b.sleepEvent = { type: "sleep" }; b.prototype.sleepTick = function(a) { if (this.allowSleep) { var e = this.sleepState, c = this.velocity.norm2() + this.angularVelocity.norm2(), d = Math.pow(this.sleepSpeedLimit, 2); e === b.AWAKE && c < d ? (this.sleepState = b.SLEEPY, this.timeLastSleepy = a, this.dispatchEvent(b.sleepyEvent)) : e === b.SLEEPY && c > d ? this.wakeUp() : e === b.SLEEPY && a - this.timeLastSleepy > this.sleepTimeLimit && (this.sleep(), this.dispatchEvent(b.sleepEvent)) } }; b.prototype.updateSolveMassProperties = function() { this.sleepState === b.SLEEPING || this.type === b.KINEMATIC ? (this.invMassSolve = 0, this.invInertiaSolve.setZero(), this.invInertiaWorldSolve.setZero()) : (this.invMassSolve = this.invMass, this.invInertiaSolve.copy(this.invInertia), this.invInertiaWorldSolve.copy(this.invInertiaWorld)) }; b.prototype.pointToLocalFrame = function(b, e) { e = e || new a; b.vsub(this.position, e); this.quaternion.conjugate().vmult(e, e); return e }; b.prototype.vectorToLocalFrame = function(b, e) { e = e || new a; this.quaternion.conjugate().vmult(b, e); return e }; b.prototype.pointToWorldFrame = function(b, e) { e = e || new a; this.quaternion.vmult(b, e); e.vadd(this.position, e); return e }; b.prototype.vectorToWorldFrame = function(b, e) { e = e || new a; this.quaternion.vmult(b, e); return e }; var f = new a, e = new p; b.prototype.addShape = function(b, e, c) { var d = new a, f = new p; e && d.copy(e); c && f.copy(c); this.shapes.push(b); this.shapeOffsets.push(d); this.shapeOrientations.push(f); this.updateMassProperties(); this.updateBoundingRadius(); this.aabbNeedsUpdate = !0; return this }; b.prototype.updateBoundingRadius = function() { for (var a = this.shapes, b = this.shapeOffsets, e = a.length, c = 0, d = 0; d !== e; d++) { var f = a[d]; f.updateBoundingSphereRadius(); var m = b[d].norm(); f = f.boundingSphereRadius; m + f > c && (c = m + f) } this.boundingRadius = c }; var m = new h; b.prototype.computeAABB = function() { for (var a = this.shapes, b = this.shapeOffsets, c = this.shapeOrientations, d = a.length, k = this.quaternion, h = this.aabb, g = 0; g !== d; g++) { var q = a[g]; c[g].mult(k, e); e.vmult(b[g], f); f.vadd(this.position, f); q.calculateWorldAABB(f, e, m.lowerBound, m.upperBound); 0 === g ? h.copy(m) : h.extend(m) } this.aabbNeedsUpdate = !1 }; var t = new q, r = new q; new q; b.prototype.updateInertiaWorld = function(a) { var b = this.invInertia; if (b.x !== b.y || b.y !== b.z || a) t.setRotationFromQuaternion(this.quaternion), t.transpose(r), t.scale(b, t), t.mmult(r, this.invInertiaWorld) }; var w = new a, v = new a; b.prototype.applyForce = function(a, e) { this.type === b.DYNAMIC && (e.vsub(this.position, w), w.cross(a, v), this.force.vadd(a, this.force), this.torque.vadd(v, this.torque)) }; var y = new a, B = new a; b.prototype.applyLocalForce = function(a, e) { this.type === b.DYNAMIC && (this.vectorToWorldFrame(a, y), this.pointToWorldFrame(e, B), this.applyForce(y, B)) }; var C = new a, A = new a, x = new a; b.prototype.applyImpulse = function(a, e) { this.type === b.DYNAMIC && (e.vsub(this.position, C), A.copy(a), A.mult(this.invMass, A), this.velocity.vadd(A, this.velocity), C.cross(a, x), this.invInertiaWorld.vmult(x, x), this.angularVelocity.vadd(x, this.angularVelocity)) }; var G = new a, N = new a; b.prototype.applyLocalImpulse = function(a, e) { this.type === b.DYNAMIC && (this.vectorToWorldFrame(a, G), this.pointToWorldFrame(e, N), this.applyImpulse(G, N)) }; var H = new a; b.prototype.updateMassProperties = function() { this.invMass = 0 < this.mass ? 1 / this.mass : 0; var a = this.inertia, b = this.fixedRotation; this.computeAABB(); H.set((this.aabb.upperBound.x - this.aabb.lowerBound.x) / 2, (this.aabb.upperBound.y - this.aabb.lowerBound.y) / 2, (this.aabb.upperBound.z - this.aabb.lowerBound.z) / 2); k.calculateInertia(H, this.mass, a); this.invInertia.set(0 < a.x && !b ? 1 / a.x : 0, 0 < a.y && !b ? 1 / a.y : 0, 0 < a.z && !b ? 1 / a.z : 0); this.updateInertiaWorld(!0) }; b.prototype.getVelocityAtWorldPoint = function(b, e) { var c = new a; b.vsub(this.position, c); this.angularVelocity.cross(c, e); this.velocity.vadd(e, e); return e } }, { "../collision/AABB": 3, "../material/Material": 25, "../math/Mat3": 27, "../math/Quaternion": 28, "../math/Vec3": 30, "../shapes/Box": 37, "../shapes/Shape": 43, "../utils/EventTarget": 49 }], 32: [function(d, g, l) { function b(a) { this.chassisBody = a.chassisBody; this.wheelInfos = []; this.sliding = !1; this.world = null; this.indexRightAxis = "undefined" !== typeof a.indexRightAxis ? a.indexRightAxis : 1; this.indexForwardAxis = "undefined" !== typeof a.indexForwardAxis ? a.indexForwardAxis : 0; this.indexUpAxis = "undefined" !== typeof a.indexUpAxis ? a.indexUpAxis : 2 } function c(a, b, e) { var c = A, d = x, f = G, m = N; b.vsub(a.position, c); c.cross(e, d); a.invInertiaWorld.vmult(d, m); m.cross(c, f); return a.invMass + e.dot(f) } d("./Body"); var a = d("../math/Vec3"), q = d("../math/Quaternion"); d("../collision/RaycastResult"); l = d("../collision/Ray"); var p = d("../objects/WheelInfo"); g.exports = b; new a; new a; new a; var h = new a, k = new a, f = new a; new l; b.prototype.addWheel = function(a) { a = a || {}; a = new p(a); var b = this.wheelInfos.length; this.wheelInfos.push(a); return b }; b.prototype.setSteeringValue = function(a, b) { this.wheelInfos[b].steering = a }; new a; b.prototype.applyEngineForce = function(a, b) { this.wheelInfos[b].engineForce = a }; b.prototype.setBrake = function(a, b) { this.wheelInfos[b].brake = a }; b.prototype.addToWorld = function(a) { a.add(this.chassisBody); var b = this; this.preStepCallback = function() { b.updateVehicle(a.dt) }; a.addEventListener("preStep", this.preStepCallback); this.world = a }; b.prototype.getVehicleAxisWorld = function(a, b) { b.set(0 === a ? 1 : 0, 1 === a ? 1 : 0, 2 === a ? 1 : 0); this.chassisBody.vectorToWorldFrame(b, b) }; b.prototype.updateVehicle = function(b) { for (var e = this.wheelInfos, c = e.length, d = this.chassisBody, f = 0; f < c; f++) this.updateWheelTransform(f); this.currentVehicleSpeedKmHour = 3.6 * d.velocity.norm(); f = new a; this.getVehicleAxisWorld(this.indexForwardAxis, f); 0 > f.dot(d.velocity) && (this.currentVehicleSpeedKmHour *= -1); for (f = 0; f < c; f++) this.castRay(e[f]); this.updateSuspension(b); var m = new a, k = new a; for (f = 0; f < c; f++) { var h = e[f], g = h.suspensionForce; g > h.maxSuspensionForce && (g = h.maxSuspensionForce); h.raycastResult.hitNormalWorld.scale(g * b, m); h.raycastResult.hitPointWorld.vsub(d.position, k); d.applyImpulse(m, h.raycastResult.hitPointWorld) } this.updateFriction(b); m = new a; k = new a; g = new a; for (f = 0; f < c; f++) { h = e[f]; d.getVelocityAtWorldPoint(h.chassisConnectionPointWorld, g); var q = 1; switch (this.indexUpAxis) { case 1: q = -1 } if (h.isInContact) { this.getVehicleAxisWorld(this.indexForwardAxis, k); var l = k.dot(h.raycastResult.hitNormalWorld); h.raycastResult.hitNormalWorld.scale(l, m); k.vsub(m, k); l = k.dot(g); h.deltaRotation = q * l * b / h.radius }!h.sliding && h.isInContact || 0 === h.engineForce || !h.useCustomSlidingRotationalSpeed || (h.deltaRotation = (0 < h.engineForce ? 1 : -1) * h.customSlidingRotationalSpeed * b); Math.abs(h.brake) > Math.abs(h.engineForce) && (h.deltaRotation = 0); h.rotation += h.deltaRotation; h.deltaRotation *= .99 } }; b.prototype.updateSuspension = function(a) { a = this.chassisBody.mass; for (var b = this.wheelInfos, e = b.length, c = 0; c < e; c++) { var d = b[c]; if (d.isInContact) { var f = d.suspensionStiffness * (d.suspensionRestLength - d.suspensionLength) * d.clippedInvContactDotSuspension; var m = d.suspensionRelativeVelocity; f -= (0 > m ? d.dampingCompression : d.dampingRelaxation) * m; d.suspensionForce = f * a; 0 > d.suspensionForce && (d.suspensionForce = 0) } else d.suspensionForce = 0 } }; b.prototype.removeFromWorld = function(a) { a.remove(this.chassisBody); a.removeEventListener("preStep", this.preStepCallback); this.world = null }; var e = new a, m = new a; b.prototype.castRay = function(b) { this.updateWheelTransformWorld(b); var c = this.chassisBody, d = -1; b.directionWorld.scale(b.suspensionRestLength + b.radius, e); var f = b.chassisConnectionPointWorld; f.vadd(e, m); var k = b.raycastResult; k.reset(); var h = c.collisionResponse; c.collisionResponse = !1; this.world.rayTest(f, m, k); c.collisionResponse = h; f = k.body; b.raycastResult.groundObject = 0; f ? (d = k.distance, b.raycastResult.hitNormalWorld = k.hitNormalWorld, b.isInContact = !0, b.suspensionLength = k.distance - b.radius, k = b.suspensionRestLength - b.maxSuspensionTravel, f = b.suspensionRestLength + b.maxSuspensionTravel, b.suspensionLength < k && (b.suspensionLength = k), b.suspensionLength > f && (b.suspensionLength = f, b.raycastResult.reset()), k = b.raycastResult.hitNormalWorld.dot(b.directionWorld), f = new a, c.getVelocityAtWorldPoint(b.raycastResult.hitPointWorld, f), c = b.raycastResult.hitNormalWorld.dot(f), -.1 <= k ? (b.suspensionRelativeVelocity = 0, b.clippedInvContactDotSuspension = 10) : (k = -1 / k, b.suspensionRelativeVelocity = c * k, b.clippedInvContactDotSuspension = k)) : (b.suspensionLength = b.suspensionRestLength + 0 * b.maxSuspensionTravel, b.suspensionRelativeVelocity = 0, b.directionWorld.scale(-1, b.raycastResult.hitNormalWorld), b.clippedInvContactDotSuspension = 1); return d }; b.prototype.updateWheelTransformWorld = function(a) { a.isInContact = !1; var b = this.chassisBody; b.pointToWorldFrame(a.chassisConnectionPointLocal, a.chassisConnectionPointWorld); b.vectorToWorldFrame(a.directionLocal, a.directionWorld); b.vectorToWorldFrame(a.axleLocal, a.axleWorld) }; b.prototype.updateWheelTransform = function(a) { a = this.wheelInfos[a]; this.updateWheelTransformWorld(a); a.directionLocal.scale(-1, h); k.copy(a.axleLocal); h.cross(k, f); f.normalize(); k.normalize(); var b = a.steering, e = new q; e.setFromAxisAngle(h, b); b = new q; b.setFromAxisAngle(k, a.rotation); var c = a.worldTransform.quaternion; this.chassisBody.quaternion.mult(e, c); c.mult(b, c); c.normalize(); e = a.worldTransform.position; e.copy(a.directionWorld); e.scale(a.suspensionLength, e); e.vadd(a.chassisConnectionPointWorld, e) }; var t = [new a(1, 0, 0), new a(0, 1, 0), new a(0, 0, 1)]; b.prototype.getWheelTransformWorld = function(a) { return this.wheelInfos[a].worldTransform }; var r = new a, w = [], v = []; b.prototype.updateFriction = function(b) { for (var e = this.wheelInfos, d = e.length, f = this.chassisBody, k = 0, m = 0; m < d; m++) { var h = e[m], g = h.raycastResult.body; g && k++; h.sideImpulse = 0; h.forwardImpulse = 0; v[m] || (v[m] = new a); w[m] || (w[m] = new a) } for (m = 0; m < d; m++) if (h = e[m], g = h.raycastResult.body) { var q = w[m]; this.getWheelTransformWorld(m).vectorToWorldFrame(t[this.indexRightAxis], q); k = h.raycastResult.hitNormalWorld; var l = q.dot(k); k.scale(l, r); q.vsub(r, q); q.normalize(); k.cross(q, v[m]); v[m].normalize(); k = h; l = f; var p = h.raycastResult.hitPointWorld, A = h.raycastResult.hitPointWorld; if (1.1 < q.norm2()) g = 0; else { var G = H, x = S, z = U; l.getVelocityAtWorldPoint(p, G); g.getVelocityAtWorldPoint(A, x); G.vsub(x, z); g = -.2 * q.dot(z) * (1 / (l.invMass + g.invMass)) } k.sideImpulse = g; h.sideImpulse *= 1 } this.sliding = !1; for (m = 0; m < d; m++) { h = e[m]; g = h.raycastResult.body; l = 0; h.slipInfo = 1; if (g) { k = h.brake ? h.brake : 0; G = f; p = g; A = h.raycastResult.hitPointWorld; q = v[m]; l = k; x = A; z = y; var N = B, V = C; G.getVelocityAtWorldPoint(x, z); p.getVelocityAtWorldPoint(x, N); z.vsub(N, V); x = q.dot(V); G = c(G, A, q); p = c(p, A, q); p = 1 / (G + p) * -x; l < p && (p = l); p < -l && (p = -l); l = p; l += h.engineForce * b; k /= l; h.slipInfo *= k } h.forwardImpulse = 0; h.skidInfo = 1; g && (h.skidInfo = 1, g = h.suspensionForce * b * h.frictionSlip, k = g * g, h.forwardImpulse = l, l = .5 * h.forwardImpulse, p = 1 * h.sideImpulse, l = l * l + p * p, h.sliding = !1, l > k && (this.sliding = !0, h.sliding = !0, k = g / Math.sqrt(l), h.skidInfo *= k)) } if (this.sliding) for (m = 0; m < d; m++) h = e[m], 0 !== h.sideImpulse && 1 > h.skidInfo && (h.forwardImpulse *= h.skidInfo, h.sideImpulse *= h.skidInfo); for (m = 0; m < d; m++) h = e[m], b = new a, b.copy(h.raycastResult.hitPointWorld), 0 !== h.forwardImpulse && (g = new a, v[m].scale(h.forwardImpulse, g), f.applyImpulse(g, b)), 0 !== h.sideImpulse && (g = h.raycastResult.body, k = new a, k.copy(h.raycastResult.hitPointWorld), l = new a, w[m].scale(h.sideImpulse, l), f.pointToLocalFrame(b, b), b["xyz" [this.indexUpAxis]] *= h.rollInfluence, f.pointToWorldFrame(b, b), f.applyImpulse(l, b), l.scale(-1, l), g.applyImpulse(l, k)) }; var y = new a, B = new a, C = new a, A = new a, x = new a, G = new a, N = new a, H = new a, S = new a, U = new a }, { "../collision/Ray": 9, "../collision/RaycastResult": 10, "../math/Quaternion": 28, "../math/Vec3": 30, "../objects/WheelInfo": 36, "./Body": 31 } ], 33: [function(d, g, l) { function b(a) { this.wheelBodies = []; this.coordinateSystem = "undefined" === typeof a.coordinateSystem ? new p(1, 2, 3) : a.coordinateSystem.clone(); this.chassisBody = a.chassisBody; this.chassisBody || (a = new q(new p(5, 2, .5)), this.chassisBody = new c(1, a)); this.constraints = []; this.wheelAxes = []; this.wheelForces = [] } var c = d("./Body"), a = d("../shapes/Sphere"), q = d("../shapes/Box"), p = d("../math/Vec3"), h = d("../constraints/HingeConstraint"); g.exports = b; b.prototype.addWheel = function(b) { b = b || {}; var e = b.body; e || (e = new c(1, new a(1.2))); this.wheelBodies.push(e); this.wheelForces.push(0); new p; var d = "undefined" !== typeof b.position ? b.position.clone() : new p, f = new p; this.chassisBody.pointToWorldFrame(d, f); e.position.set(f.x, f.y, f.z); b = "undefined" !== typeof b.axis ? b.axis.clone() : new p(0, 1, 0); this.wheelAxes.push(b); e = new h(this.chassisBody, e, { pivotA: d, axisA: b, pivotB: p.ZERO, axisB: b, collideConnected: !1 }); this.constraints.push(e); return this.wheelBodies.length - 1 }; b.prototype.setSteeringValue = function(a, b) { var e = this.wheelAxes[b], c = Math.cos(a), d = Math.sin(a), f = e.x; e = e.y; this.constraints[b].axisA.set(c * f - d * e, d * f + c * e, 0) }; b.prototype.setMotorSpeed = function(a, b) { var e = this.constraints[b]; e.enableMotor(); e.motorTargetVelocity = a }; b.prototype.disableMotor = function(a) { this.constraints[a].disableMotor() }; var k = new p; b.prototype.setWheelForce = function(a, b) { this.wheelForces[b] = a }; b.prototype.applyWheelForce = function(a, b) { var e = this.wheelBodies[b], c = e.torque; this.wheelAxes[b].scale(a, k); e.vectorToWorldFrame(k, k); c.vadd(k, c) }; b.prototype.addToWorld = function(a) { for (var b = this.constraints, e = this.wheelBodies.concat([this.chassisBody]), c = 0; c < e.length; c++) a.add(e[c]); for (c = 0; c < b.length; c++) a.addConstraint(b[c]); a.addEventListener("preStep", this._update.bind(this)) }; b.prototype._update = function() { for (var a = this.wheelForces, b = 0; b < a.length; b++) this.applyWheelForce(a[b], b) }; b.prototype.removeFromWorld = function(a) { for (var b = this.constraints, e = this.wheelBodies.concat([this.chassisBody]), c = 0; c < e.length; c++) a.remove(e[c]); for (c = 0; c < b.length; c++) a.removeConstraint(b[c]) }; var f = new p; b.prototype.getWheelSpeed = function(a) { var b = this.wheelBodies[a].angularVelocity; this.chassisBody.vectorToWorldFrame(this.wheelAxes[a], f); return b.dot(f) } }, { "../constraints/HingeConstraint": 15, "../math/Vec3": 30, "../shapes/Box": 37, "../shapes/Sphere": 44, "./Body": 31 }], 34: [function(d, g, l) { function b() { this.particles = []; this.speedOfSound = this.smoothingRadius = this.density = 1; this.viscosity = .01; this.eps = 1E-6; this.pressures = []; this.densities = []; this.neighbors = [] } g.exports = b; d("../shapes/Shape"); g = d("../math/Vec3"); d("../math/Quaternion"); d("../shapes/Particle"); d("../objects/Body"); d("../material/Material"); b.prototype.add = function(a) { this.particles.push(a); this.neighbors.length < this.particles.length && this.neighbors.push([]) }; b.prototype.remove = function(a) { a = this.particles.indexOf(a); - 1 !== a && (this.particles.splice(a, 1), this.neighbors.length > this.particles.length && this.neighbors.pop()) }; var c = new g; b.prototype.getNeighbors = function(a, b) { for (var e = this.particles.length, d = a.id, f = this.smoothingRadius * this.smoothingRadius, k = 0; k !== e; k++) { var m = this.particles[k]; m.position.vsub(a.position, c); d !== m.id && c.norm2() < f && b.push(m) } }; var a = new g, q = new g, p = new g, h = new g, k = new g, f = new g; b.prototype.update = function() { for (var b = this.particles.length, c = this.speedOfSound, d = this.eps, g = 0; g !== b; g++) { var l = this.particles[g], v = this.neighbors[g]; v.length = 0; this.getNeighbors(l, v); v.push(this.particles[g]); for (var y = v.length, B = 0, C = 0; C !== y; C++) { l.position.vsub(v[C].position, a); var A = a.norm(); A = this.w(A); B += v[C].mass * A } this.densities[g] = B; this.pressures[g] = c * c * (this.densities[g] - this.density) } for (g = 0; g !== b; g++) { c = this.particles[g]; q.set(0, 0, 0); p.set(0, 0, 0); v = this.neighbors[g]; y = v.length; for (C = 0; C !== y; C++) B = v[C], c.position.vsub(B.position, k), A = k.norm(), l = -B.mass * (this.pressures[g] / (this.densities[g] * this.densities[g] + d) + this.pressures[C] / (this.densities[C] * this.densities[C] + d)), this.gradw(k, h), h.mult(l, h), q.vadd(h, q), B.velocity.vsub(c.velocity, f), f.mult(1 / (1E-4 + this.densities[g] * this.densities[C]) * this.viscosity * B.mass, f), l = this.nablaw(A), f.mult(l, f), p.vadd(f, p); p.mult(c.mass, p); q.mult(c.mass, q); c.force.vadd(p, c.force); c.force.vadd(q, c.force) } }; b.prototype.w = function(a) { var b = this.smoothingRadius; return 315 / (64 * Math.PI * Math.pow(b, 9)) * Math.pow(b * b - a * a, 3) }; b.prototype.gradw = function(a, b) { var c = a.norm(), e = this.smoothingRadius; a.mult(945 / (32 * Math.PI * Math.pow(e, 9)) * Math.pow(e * e - c * c, 2), b) }; b.prototype.nablaw = function(a) { var b = this.smoothingRadius; return 945 / (32 * Math.PI * Math.pow(b, 9)) * (b * b - a * a) * (7 * a * a - 3 * b * b) } }, { "../material/Material": 25, "../math/Quaternion": 28, "../math/Vec3": 30, "../objects/Body": 31, "../shapes/Particle": 41, "../shapes/Shape": 43 }], 35: [function(d, g, l) { function b(a, b, e) { e = e || {}; this.restLength = "number" === typeof e.restLength ? e.restLength : 1; this.stiffness = e.stiffness || 100; this.damping = e.damping || 1; this.bodyA = a; this.bodyB = b; this.localAnchorA = new c; this.localAnchorB = new c; e.localAnchorA && this.localAnchorA.copy(e.localAnchorA); e.localAnchorB && this.localAnchorB.copy(e.localAnchorB); e.worldAnchorA && this.setWorldAnchorA(e.worldAnchorA); e.worldAnchorB && this.setWorldAnchorB(e.worldAnchorB) } var c = d("../math/Vec3"); g.exports = b; b.prototype.setWorldAnchorA = function(a) { this.bodyA.pointToLocalFrame(a, this.localAnchorA) }; b.prototype.setWorldAnchorB = function(a) { this.bodyB.pointToLocalFrame(a, this.localAnchorB) }; b.prototype.getWorldAnchorA = function(a) { this.bodyA.pointToWorldFrame(this.localAnchorA, a) }; b.prototype.getWorldAnchorB = function(a) { this.bodyB.pointToWorldFrame(this.localAnchorB, a) }; var a = new c, q = new c, p = new c, h = new c, k = new c, f = new c, e = new c, m = new c, t = new c, r = new c, w = new c; b.prototype.applyForce = function() { var b = this.stiffness, c = this.damping, d = this.restLength, g = this.bodyA, l = this.bodyB; this.getWorldAnchorA(k); this.getWorldAnchorB(f); k.vsub(g.position, e); f.vsub(l.position, m); f.vsub(k, a); var x = a.norm(); q.copy(a); q.normalize(); l.velocity.vsub(g.velocity, p); l.angularVelocity.cross(m, w); p.vadd(w, p); g.angularVelocity.cross(e, w); p.vsub(w, p); q.mult(-b * (x - d) - c * p.dot(q), h); g.force.vsub(h, g.force); l.force.vadd(h, l.force); e.cross(h, t); m.cross(h, r); g.torque.vsub(t, g.torque); l.torque.vadd(r, l.torque) } }, { "../math/Vec3": 30 }], 36: [function(d, g, l) { function b(b) { b = p.defaults(b, { chassisConnectionPointLocal: new c, chassisConnectionPointWorld: new c, directionLocal: new c, directionWorld: new c, axleLocal: new c, axleWorld: new c, suspensionRestLength: 1, suspensionMaxLength: 2, radius: 1, suspensionStiffness: 100, dampingCompression: 10, dampingRelaxation: 10, frictionSlip: 1E4, steering: 0, rotation: 0, deltaRotation: 0, rollInfluence: .01, maxSuspensionForce: Number.MAX_VALUE, isFrontWheel: !0, clippedInvContactDotSuspension: 1, suspensionRelativeVelocity: 0, suspensionForce: 0, skidInfo: 0, suspensionLength: 0, maxSuspensionTravel: 1, useCustomSlidingRotationalSpeed: !1, customSlidingRotationalSpeed: -.1 }); this.maxSuspensionTravel = b.maxSuspensionTravel; this.customSlidingRotationalSpeed = b.customSlidingRotationalSpeed; this.useCustomSlidingRotationalSpeed = b.useCustomSlidingRotationalSpeed; this.sliding = !1; this.chassisConnectionPointLocal = b.chassisConnectionPointLocal.clone(); this.chassisConnectionPointWorld = b.chassisConnectionPointWorld.clone(); this.directionLocal = b.directionLocal.clone(); this.directionWorld = b.directionWorld.clone(); this.axleLocal = b.axleLocal.clone(); this.axleWorld = b.axleWorld.clone(); this.suspensionRestLength = b.suspensionRestLength; this.suspensionMaxLength = b.suspensionMaxLength; this.radius = b.radius; this.suspensionStiffness = b.suspensionStiffness; this.dampingCompression = b.dampingCompression; this.dampingRelaxation = b.dampingRelaxation; this.frictionSlip = b.frictionSlip; this.deltaRotation = this.rotation = this.steering = 0; this.rollInfluence = b.rollInfluence; this.maxSuspensionForce = b.maxSuspensionForce; this.brake = this.engineForce = 0; this.isFrontWheel = b.isFrontWheel; this.clippedInvContactDotSuspension = 1; this.forwardImpulse = this.sideImpulse = this.suspensionLength = this.skidInfo = this.suspensionForce = this.suspensionRelativeVelocity = 0; this.raycastResult = new q; this.worldTransform = new a; this.isInContact = !1 } var c = d("../math/Vec3"), a = d("../math/Transform"), q = d("../collision/RaycastResult"), p = d("../utils/Utils"); g.exports = b; var h = new c, k = new c; h = new c; b.prototype.updateWheel = function(a) { var b = this.raycastResult; if (this.isInContact) { var c = b.hitNormalWorld.dot(b.directionWorld); b.hitPointWorld.vsub(a.position, k); a.getVelocityAtWorldPoint(k, h); a = b.hitNormalWorld.dot(h); - .1 <= c ? (this.suspensionRelativeVelocity = 0, this.clippedInvContactDotSuspension = 10) : (c = -1 / c, this.suspensionRelativeVelocity = a * c, this.clippedInvContactDotSuspension = c) } else b.suspensionLength = this.suspensionRestLength, this.suspensionRelativeVelocity = 0, b.directionWorld.scale(-1, b.hitNormalWorld), this.clippedInvContactDotSuspension = 1 } }, { "../collision/RaycastResult": 10, "../math/Transform": 29, "../math/Vec3": 30, "../utils/Utils": 53 }], 37: [function(d, g, l) { function b(a) { c.call(this); this.type = c.types.BOX; this.halfExtents = a; this.convexPolyhedronRepresentation = null; this.updateConvexPolyhedronRepresentation(); this.updateBoundingSphereRadius() } g.exports = b; var c = d("./Shape"), a = d("../math/Vec3"), q = d("./ConvexPolyhedron"); b.prototype = new c; b.prototype.constructor = b; b.prototype.updateConvexPolyhedronRepresentation = function() { var b = this.halfExtents.x, c = this.halfExtents.y, e = this.halfExtents.z; b = [new a(-b, -c, -e), new a(b, -c, -e), new a(b, c, -e), new a(-b, c, -e), new a(-b, -c, e), new a(b, -c, e), new a(b, c, e), new a(-b, c, e)]; new a(0, 0, 1); new a(0, 1, 0); new a(1, 0, 0); this.convexPolyhedronRepresentation = b = new q(b, [ [3, 2, 1, 0], [4, 5, 6, 7], [5, 4, 0, 1], [2, 3, 7, 6], [0, 4, 7, 3], [1, 2, 6, 5] ]); b.material = this.material }; b.prototype.calculateLocalInertia = function(c, d) { d = d || new a; b.calculateInertia(this.halfExtents, c, d); return d }; b.calculateInertia = function(a, b, c) { c.x = 1 / 12 * b * (4 * a.y * a.y + 4 * a.z * a.z); c.y = 1 / 12 * b * (4 * a.x * a.x + 4 * a.z * a.z); c.z = 1 / 12 * b * (4 * a.y * a.y + 4 * a.x * a.x) }; b.prototype.getSideNormals = function(a, b) { var c = this.halfExtents; a[0].set(c.x, 0, 0); a[1].set(0, c.y, 0); a[2].set(0, 0, c.z); a[3].set(-c.x, 0, 0); a[4].set(0, -c.y, 0); a[5].set(0, 0, -c.z); if (void 0 !== b) for (c = 0; c !== a.length; c++) b.vmult(a[c], a[c]); return a }; b.prototype.volume = function() { return 8 * this.halfExtents.x * this.halfExtents.y * this.halfExtents.z }; b.prototype.updateBoundingSphereRadius = function() { this.boundingSphereRadius = this.halfExtents.norm() }; var p = new a; new a; b.prototype.forEachWorldCorner = function(a, b, c) { var e = this.halfExtents; e = [ [e.x, e.y, e.z], [-e.x, e.y, e.z], [-e.x, -e.y, e.z], [-e.x, -e.y, -e.z], [e.x, -e.y, -e.z], [e.x, e.y, -e.z], [-e.x, e.y, -e.z], [e.x, -e.y, e.z] ]; for (var d = 0; d < e.length; d++) p.set(e[d][0], e[d][1], e[d][2]), b.vmult(p, p), a.vadd(p, p), c(p.x, p.y, p.z) }; var h = [new a, new a, new a, new a, new a, new a, new a, new a ]; b.prototype.calculateWorldAABB = function(a, b, c, d) { var e = this.halfExtents; h[0].set(e.x, e.y, e.z); h[1].set(-e.x, e.y, e.z); h[2].set(-e.x, -e.y, e.z); h[3].set(-e.x, -e.y, -e.z); h[4].set(e.x, -e.y, -e.z); h[5].set(e.x, e.y, -e.z); h[6].set(-e.x, e.y, -e.z); h[7].set(e.x, -e.y, e.z); var f = h[0]; b.vmult(f, f); a.vadd(f, f); d.copy(f); c.copy(f); for (e = 1; 8 > e; e++) { f = h[e]; b.vmult(f, f); a.vadd(f, f); var k = f.x, m = f.y; f = f.z; k > d.x && (d.x = k); m > d.y && (d.y = m); f > d.z && (d.z = f); k < c.x && (c.x = k); m < c.y && (c.y = m); f < c.z && (c.z = f) } } }, { "../math/Vec3": 30, "./ConvexPolyhedron": 38, "./Shape": 43 }], 38: [function(d, g, l) { function b(a, b, e) { c.call(this); this.type = c.types.CONVEXPOLYHEDRON; this.vertices = a || []; this.worldVertices = []; this.worldVerticesNeedsUpdate = !0; this.faces = b || []; this.faceNormals = []; this.computeNormals(); this.worldFaceNormalsNeedsUpdate = !0; this.worldFaceNormals = []; this.uniqueEdges = []; this.uniqueAxes = e ? e.slice() : null; this.computeEdges(); this.updateBoundingSphereRadius() } g.exports = b; var c = d("./Shape"), a = d("../math/Vec3"); d("../math/Quaternion"); var q = d("../math/Transform"); b.prototype = new c; b.prototype.constructor = b; var p = new a; b.prototype.computeEdges = function() { for (var a = this.faces, b = this.vertices, c = this.uniqueEdges, e = c.length = 0; e !== a.length; e++) for (var d = a[e], f = d.length, k = 0; k !== f; k++) { b[d[k]].vsub(b[d[(k + 1) % f]], p); p.normalize(); for (var h = !1, m = 0; m !== c.length; m++) if (c[m].almostEquals(p) || c[m].almostEquals(p)) { h = !0; break } h || c.push(p.clone()) } }; b.prototype.computeNormals = function() { this.faceNormals.length = this.faces.length; for (var b = 0; b < this.faces.length; b++) { for (var c = 0; c < this.faces[b].length; c++) if (!this.vertices[this.faces[b][c]]) throw Error("Vertex " + this.faces[b][c] + " not found!"); c = this.faceNormals[b] || new a; this.getFaceNormal(b, c); c.negate(c); this.faceNormals[b] = c; if (0 > c.dot(this.vertices[this.faces[b][0]])) for (console.error(".faceNormals[" + b + "] = Vec3(" + c.toString() + ") looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule."), c = 0; c < this.faces[b].length; c++) console.warn(".vertices[" + this.faces[b][c] + "] = Vec3(" + this.vertices[this.faces[b][c]].toString() + ")") } }; var h = new a, k = new a; b.computeNormal = function(a, b, c, e) { b.vsub(a, k); c.vsub(b, h); h.cross(k, e); e.isZero() || e.normalize() }; b.prototype.getFaceNormal = function(a, c) { var e = this.faces[a]; return b.computeNormal(this.vertices[e[0]], this.vertices[e[1]], this.vertices[e[2]], c) }; var f = new a; b.prototype.clipAgainstHull = function(b, c, e, d, k, h, m, g, q) { for (var l = -1, p = -Number.MAX_VALUE, r = 0; r < e.faces.length; r++) { f.copy(e.faceNormals[r]); k.vmult(f, f); var t = f.dot(h); t > p && (p = t, l = r) } p = []; r = e.faces[l]; t = r.length; for (var u = 0; u < t; u++) { var v = e.vertices[r[u]], w = new a; w.copy(v); k.vmult(w, w); d.vadd(w, w); p.push(w) } 0 <= l && this.clipFaceAgainstHull(h, b, c, p, m, g, q) }; var e = new a, m = new a, t = new a, r = new a, w = new a, v = new a; b.prototype.findSeparatingAxis = function(a, b, c, d, f, k, h, g) { var q = Number.MAX_VALUE, l = 0; if (this.uniqueAxes) for (u = 0; u !== this.uniqueAxes.length; u++) { c.vmult(this.uniqueAxes[u], e); A = this.testSepAxis(e, a, b, c, d, f); if (!1 === A) return !1; A < q && (q = A, k.copy(e)) } else for (var p = h ? h.length : this.faces.length, u = 0; u < p; u++) { A = h ? h[u] : u; e.copy(this.faceNormals[A]); c.vmult(e, e); var A = this.testSepAxis(e, a, b, c, d, f); if (!1 === A) return !1; A < q && (q = A, k.copy(e)) } if (a.uniqueAxes) for (u = 0; u !== a.uniqueAxes.length; u++) { f.vmult(a.uniqueAxes[u], m); l++; A = this.testSepAxis(m, a, b, c, d, f); if (!1 === A) return !1; A < q && (q = A, k.copy(m)) } else for (h = g ? g.length : a.faces.length, u = 0; u < h; u++) { A = g ? g[u] : u; m.copy(a.faceNormals[A]); f.vmult(m, m); l++; A = this.testSepAxis(m, a, b, c, d, f); if (!1 === A) return !1; A < q && (q = A, k.copy(m)) } for (g = 0; g !== this.uniqueEdges.length; g++) for (c.vmult(this.uniqueEdges[g], r), l = 0; l !== a.uniqueEdges.length; l++) if (f.vmult(a.uniqueEdges[l], w), r.cross(w, v), !v.almostZero()) { v.normalize(); u = this.testSepAxis(v, a, b, c, d, f); if (!1 === u) return !1; u < q && (q = u, k.copy(v)) } d.vsub(b, t); 0 < t.dot(k) && k.negate(k); return !0 }; var y = [], B = []; b.prototype.testSepAxis = function(a, c, e, d, f, k) { b.project(this, a, e, d, y); b.project(c, a, f, k, B); e = y[0]; a = y[1]; c = B[0]; d = B[1]; if (e < d || c < a) return !1; e -= d; a = c - a; return e < a ? e : a }; var C = new a, A = new a; b.prototype.calculateLocalInertia = function(a, b) { this.computeLocalAABB(C, A); var c = A.x - C.x, e = A.y - C.y, d = A.z - C.z; b.x = 1 / 12 * a * (4 * e * e + 4 * d * d); b.y = 1 / 12 * a * (4 * c * c + 4 * d * d); b.z = 1 / 12 * a * (4 * e * e + 4 * c * c) }; b.prototype.getPlaneConstantOfFace = function(a) { return -this.faceNormals[a].dot(this.vertices[this.faces[a][0]]) }; var x = new a, G = new a, N = new a, H = new a, S = new a, U = new a, R = new a, P = new a; b.prototype.clipFaceAgainstHull = function(a, b, c, e, d, f, k) { for (var h = [], m = -1, g = Number.MAX_VALUE, q = 0; q < this.faces.length; q++) { x.copy(this.faceNormals[q]); c.vmult(x, x); var l = x.dot(a); l < g && (g = l, m = q) } if (!(0 > m)) { a = this.faces[m]; a.connectedFaces = []; for (g = 0; g < this.faces.length; g++) for (q = 0; q < this.faces[g].length; q++) - 1 !== a.indexOf(this.faces[g][q]) && g !== m && -1 === a.connectedFaces.indexOf(g) && a.connectedFaces.push(g); g = a.length; for (q = 0; q < g; q++) { l = this.vertices[a[q]]; l.vsub(this.vertices[a[(q + 1) % g]], G); N.copy(G); c.vmult(N, N); b.vadd(N, N); H.copy(this.faceNormals[m]); c.vmult(H, H); b.vadd(H, H); N.cross(H, S); S.negate(S); U.copy(l); c.vmult(U, U); b.vadd(U, U); U.dot(S); l = a.connectedFaces[q]; R.copy(this.faceNormals[l]); l = this.getPlaneConstantOfFace(l); P.copy(R); c.vmult(P, P); l -= P.dot(b); for (this.clipFaceAgainstPlane(e, h, P, l); e.length;) e.shift(); for (; h.length;) e.push(h.shift()) } R.copy(this.faceNormals[m]); l = this.getPlaneConstantOfFace(m); P.copy(R); c.vmult(P, P); l -= P.dot(b); for (g = 0; g < e.length; g++) b = P.dot(e[g]) + l, b <= d && (console.log("clamped: depth=" + b + " to minDist=" + (d + "")), b = d), b <= f && (c = e[g], 0 >= b && k.push({ point: c, normal: P, depth: b })) } }; b.prototype.clipFaceAgainstPlane = function(b, c, e, d) { var f = b.length; if (2 > f) return c; var k = b[b.length - 1]; var h = e.dot(k) + d; for (var m = 0; m < f; m++) { var g = b[m]; var q = e.dot(g) + d; if (0 > h) { if (0 > q) { var l = new a; l.copy(g) } else l = new a, k.lerp(g, h / (h - q), l); c.push(l) } else 0 > q && (l = new a, k.lerp(g, h / (h - q), l), c.push(l), c.push(g)); k = g; h = q } return c }; b.prototype.computeWorldVertices = function(b, c) { for (var e = this.vertices.length; this.worldVertices.length < e;) this.worldVertices.push(new a); for (var d = this.vertices, f = this.worldVertices, k = 0; k !== e; k++) c.vmult(d[k], f[k]), b.vadd(f[k], f[k]); this.worldVerticesNeedsUpdate = !1 }; new a; b.prototype.computeLocalAABB = function(a, b) { var c = this.vertices.length, e = this.vertices; a.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); b.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); for (var d = 0; d < c; d++) { var f = e[d]; f.x < a.x ? a.x = f.x : f.x > b.x && (b.x = f.x); f.y < a.y ? a.y = f.y : f.y > b.y && (b.y = f.y); f.z < a.z ? a.z = f.z : f.z > b.z && (b.z = f.z) } }; b.prototype.computeWorldFaceNormals = function(b) { for (var c = this.faceNormals.length; this.worldFaceNormals.length < c;) this.worldFaceNormals.push(new a); for (var e = this.faceNormals, d = this.worldFaceNormals, f = 0; f !== c; f++) b.vmult(e[f], d[f]); this.worldFaceNormalsNeedsUpdate = !1 }; b.prototype.updateBoundingSphereRadius = function() { for (var a = 0, b = this.vertices, c = 0, e = b.length; c !== e; c++) { var d = b[c].norm2(); d > a && (a = d) } this.boundingSphereRadius = Math.sqrt(a) }; var J = new a; b.prototype.calculateWorldAABB = function(a, b, c, e) { for (var d = this.vertices.length, f = this.vertices, k, h, m, g, q, l, p = 0; p < d; p++) { J.copy(f[p]); b.vmult(J, J); a.vadd(J, J); var r = J; if (r.x < k || void 0 === k) k = r.x; else if (r.x > g || void 0 === g) g = r.x; if (r.y < h || void 0 === h) h = r.y; else if (r.y > q || void 0 === q) q = r.y; if (r.z < m || void 0 === m) m = r.z; else if (r.z > l || void 0 === l) l = r.z } c.set(k, h, m); e.set(g, q, l) }; b.prototype.volume = function() { return 4 * Math.PI * this.boundingSphereRadius / 3 }; b.prototype.getAveragePointLocal = function(b) { b = b || new a; for (var c = this.vertices.length, e = this.vertices, d = 0; d < c; d++) b.vadd(e[d], b); b.mult(1 / c, b); return b }; b.prototype.transformAllPoints = function(a, b) { var c = this.vertices.length, e = this.vertices; if (b) { for (var d = 0; d < c; d++) { var f = e[d]; b.vmult(f, f) } for (d = 0; d < this.faceNormals.length; d++) f = this.faceNormals[d], b.vmult(f, f) } if (a) for (d = 0; d < c; d++) f = e[d], f.vadd(a, f) }; var L = new a, M = new a, O = new a; b.prototype.pointIsInside = function(a) { var b = this.vertices, c = this.faces, e = this.faceNormals, d = this.faces.length; this.getAveragePointLocal(L); for (var f = 0; f < d; f++) { var k = e[f]; var h = b[c[f][0]], m = M; a.vsub(h, m); m = k.dot(m); var g = O; L.vsub(h, g); k = k.dot(g); if (0 > m && 0 < k || 0 < m && 0 > k) return !1 } return -1 }; new a; var X = new a, u = new a; b.project = function(a, b, c, e, d) { var f = a.vertices.length; a = a.vertices; u.setZero(); q.vectorToLocalFrame(c, e, b, X); q.pointToLocalFrame(c, e, u, u); e = u.dot(X); c = b = a[0].dot(X); for (var k = 1; k < f; k++) { var h = a[k].dot(X); h > b && (b = h); h < c && (c = h) } c -= e; b -= e; c > b && (f = c, c = b, b = f); d[0] = b; d[1] = c } }, { "../math/Quaternion": 28, "../math/Transform": 29, "../math/Vec3": 30, "./Shape": 43 }], 39: [function(d, g, l) { function b(b, d, k, f) { var e = [], h = [], g = [], l = [], p = [], v = Math.cos, y = Math.sin; e.push(new a(d * v(0), d * y(0), .5 * -k)); l.push(0); e.push(new a(b * v(0), b * y(0), .5 * k)); p.push(1); for (var B = 0; B < f; B++) { var C = 2 * Math.PI / f * (B + 1), A = 2 * Math.PI / f * (B + .5); B < f - 1 ? (e.push(new a(d * v(C), d * y(C), .5 * -k)), l.push(2 * B + 2), e.push(new a(b * v(C), b * y(C), .5 * k)), p.push(2 * B + 3), g.push([2 * B + 2, 2 * B + 3, 2 * B + 1, 2 * B])) : g.push([0, 1, 2 * B + 1, 2 * B]); (1 === f % 2 || B < f / 2) && h.push(new a(v(A), y(A), 0)) } g.push(p); h.push(new a(0, 0, 1)); b = []; for (B = 0; B < l.length; B++) b.push(l[l.length - B - 1]); g.push(b); this.type = c.types.CONVEXPOLYHEDRON; q.call(this, e, g, h) } g.exports = b; var c = d("./Shape"), a = d("../math/Vec3"); d("../math/Quaternion"); var q = d("./ConvexPolyhedron"); b.prototype = new q }, { "../math/Quaternion": 28, "../math/Vec3": 30, "./ConvexPolyhedron": 38, "./Shape": 43 }], 40: [function(d, g, l) { function b(b, d) { d = p.defaults(d, { maxValue: null, minValue: null, elementSize: 1 }); this.data = b; this.maxValue = d.maxValue; this.minValue = d.minValue; this.elementSize = d.elementSize; null === d.minValue && this.updateMinValue(); null === d.maxValue && this.updateMaxValue(); this.cacheEnabled = !0; c.call(this); this.pillarConvex = new a; this.pillarOffset = new q; this.type = c.types.HEIGHTFIELD; this.updateBoundingSphereRadius(); this._cachedPillars = {} } var c = d("./Shape"), a = d("./ConvexPolyhedron"), q = d("../math/Vec3"), p = d("../utils/Utils"); g.exports = b; b.prototype = new c; b.prototype.update = function() { this._cachedPillars = {} }; b.prototype.updateMinValue = function() { for (var a = this.data, b = a[0][0], c = 0; c !== a.length; c++) for (var e = 0; e !== a[c].length; e++) { var d = a[c][e]; d < b && (b = d) } this.minValue = b }; b.prototype.updateMaxValue = function() { for (var a = this.data, b = a[0][0], c = 0; c !== a.length; c++) for (var e = 0; e !== a[c].length; e++) { var d = a[c][e]; d > b && (b = d) } this.maxValue = b }; b.prototype.setHeightValueAtIndex = function(a, b, c) { this.data[a][b] = c; this.clearCachedConvexTrianglePillar(a, b, !1); 0 < a && (this.clearCachedConvexTrianglePillar(a - 1, b, !0), this.clearCachedConvexTrianglePillar(a - 1, b, !1)); 0 < b && (this.clearCachedConvexTrianglePillar(a, b - 1, !0), this.clearCachedConvexTrianglePillar(a, b - 1, !1)); 0 < b && 0 < a && this.clearCachedConvexTrianglePillar(a - 1, b - 1, !0) }; b.prototype.getRectMinMax = function(a, b, c, e, d) { d = d || []; for (var f = this.data, k = this.minValue; a <= c; a++) for (var h = b; h <= e; h++) { var m = f[a][h]; m > k && (k = m) } d[0] = this.minValue; d[1] = k }; b.prototype.getIndexOfPosition = function(a, b, c, e) { var d = this.elementSize, f = this.data; a = Math.floor(a / d); b = Math.floor(b / d); c[0] = a; c[1] = b; e && (0 > a && (a = 0), 0 > b && (b = 0), a >= f.length - 1 && (a = f.length - 1), b >= f[0].length - 1 && (b = f[0].length - 1)); return 0 > a || 0 > b || a >= f.length - 1 || b >= f[0].length - 1 ? !1 : !0 }; b.prototype.getHeightAt = function(a, b, c) { var e = []; this.getIndexOfPosition(a, b, e, c); a = []; this.getRectMinMax(e[0], e[1] + 1, e[0], e[1] + 1, a); return (a[0] + a[1]) / 2 }; b.prototype.getCacheConvexTrianglePillarKey = function(a, b, c) { return a + "_" + b + "_" + (c ? 1 : 0) }; b.prototype.getCachedConvexTrianglePillar = function(a, b, c) { return this._cachedPillars[this.getCacheConvexTrianglePillarKey(a, b, c)] }; b.prototype.setCachedConvexTrianglePillar = function(a, b, c, e, d) { this._cachedPillars[this.getCacheConvexTrianglePillarKey(a, b, c)] = { convex: e, offset: d } }; b.prototype.clearCachedConvexTrianglePillar = function(a, b, c) { delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(a, b, c)] }; b.prototype.getConvexTrianglePillar = function(b, c, d) { var e = this.pillarConvex, f = this.pillarOffset; if (this.cacheEnabled) { var k = this.getCachedConvexTrianglePillar(b, c, d); if (k) { this.pillarConvex = k.convex; this.pillarOffset = k.offset; return } e = new a; f = new q; this.pillarConvex = e; this.pillarOffset = f } k = this.data; var h = this.elementSize, g = e.faces; e.vertices.length = 6; for (var l = 0; 6 > l; l++) e.vertices[l] || (e.vertices[l] = new q); g.length = 5; for (l = 0; 5 > l; l++) g[l] || (g[l] = []); l = e.vertices; var p = (Math.min(k[b][c], k[b + 1][c], k[b][c + 1], k[b + 1][c + 1]) - this.minValue) / 2 + this.minValue; d ? (f.set((b + .75) * h, (c + .75) * h, p), l[0].set(.25 * h, .25 * h, k[b + 1][c + 1] - p), l[1].set(-.75 * h, .25 * h, k[b][c + 1] - p), l[2].set(.25 * h, -.75 * h, k[b + 1][c] - p), l[3].set(.25 * h, .25 * h, -p - 1), l[4].set(-.75 * h, .25 * h, -p - 1), l[5].set(.25 * h, -.75 * h, -p - 1), g[0][0] = 0, g[0][1] = 1, g[0][2] = 2, g[1][0] = 5, g[1][1] = 4, g[1][2] = 3, g[2][0] = 2, g[2][1] = 5, g[2][2] = 3, g[2][3] = 0, g[3][0] = 3, g[3][1] = 4, g[3][2] = 1, g[3][3] = 0, g[4][0] = 1, g[4][1] = 4, g[4][2] = 5, g[4][3] = 2) : (f.set((b + .25) * h, (c + .25) * h, p), l[0].set(-.25 * h, -.25 * h, k[b][c] - p), l[1].set(.75 * h, -.25 * h, k[b + 1][c] - p), l[2].set(-.25 * h, .75 * h, k[b][c + 1] - p), l[3].set(-.25 * h, -.25 * h, -p - 1), l[4].set(.75 * h, -.25 * h, -p - 1), l[5].set(-.25 * h, .75 * h, -p - 1), g[0][0] = 0, g[0][1] = 1, g[0][2] = 2, g[1][0] = 5, g[1][1] = 4, g[1][2] = 3, g[2][0] = 0, g[2][1] = 2, g[2][2] = 5, g[2][3] = 3, g[3][0] = 1, g[3][1] = 0, g[3][2] = 3, g[3][3] = 4, g[4][0] = 4, g[4][1] = 5, g[4][2] = 2, g[4][3] = 1); e.computeNormals(); e.computeEdges(); e.updateBoundingSphereRadius(); this.setCachedConvexTrianglePillar(b, c, d, e, f) }; b.prototype.calculateLocalInertia = function(a, b) { b = b || new q; b.set(0, 0, 0); return b }; b.prototype.volume = function() { return Number.MAX_VALUE }; b.prototype.calculateWorldAABB = function(a, b, c, e) { c.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); e.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE) }; b.prototype.updateBoundingSphereRadius = function() { var a = this.data, b = this.elementSize; this.boundingSphereRadius = (new q(a.length * b, a[0].length * b, Math.max(Math.abs(this.maxValue), Math.abs(this.minValue)))).norm() } }, { "../math/Vec3": 30, "../utils/Utils": 53, "./ConvexPolyhedron": 38, "./Shape": 43 } ], 41: [function(d, g, l) { function b() { c.call(this); this.type = c.types.PARTICLE } g.exports = b; var c = d("./Shape"), a = d("../math/Vec3"); b.prototype = new c; b.prototype.constructor = b; b.prototype.calculateLocalInertia = function(b, c) { c = c || new a; c.set(0, 0, 0); return c }; b.prototype.volume = function() { return 0 }; b.prototype.updateBoundingSphereRadius = function() { this.boundingSphereRadius = 0 }; b.prototype.calculateWorldAABB = function(a, b, c, d) { c.copy(a); d.copy(a) } }, { "../math/Vec3": 30, "./Shape": 43 }], 42: [function(d, g, l) { function b() { c.call(this); this.type = c.types.PLANE; this.worldNormal = new a; this.worldNormalNeedsUpdate = !0; this.boundingSphereRadius = Number.MAX_VALUE } g.exports = b; var c = d("./Shape"), a = d("../math/Vec3"); b.prototype = new c; b.prototype.constructor = b; b.prototype.computeWorldNormal = function(a) { var b = this.worldNormal; b.set(0, 0, 1); a.vmult(b, b); this.worldNormalNeedsUpdate = !1 }; b.prototype.calculateLocalInertia = function(b, c) { return c = c || new a }; b.prototype.volume = function() { return Number.MAX_VALUE }; var q = new a; b.prototype.calculateWorldAABB = function(a, b, c, d) { q.set(0, 0, 1); b.vmult(q, q); b = Number.MAX_VALUE; c.set(-b, -b, -b); d.set(b, b, b); 1 === q.x && (d.x = a.x); 1 === q.y && (d.y = a.y); 1 === q.z && (d.z = a.z); - 1 === q.x && (c.x = a.x); - 1 === q.y && (c.y = a.y); - 1 === q.z && (c.z = a.z) }; b.prototype.updateBoundingSphereRadius = function() { this.boundingSphereRadius = Number.MAX_VALUE } }, { "../math/Vec3": 30, "./Shape": 43 }], 43: [function(d, g, l) { function b() { this.id = b.idCounter++; this.boundingSphereRadius = this.type = 0; this.collisionResponse = !0; this.material = null } g.exports = b; b = d("./Shape"); d("../math/Vec3"); d("../math/Quaternion"); d("../material/Material"); b.prototype.constructor = b; b.prototype.updateBoundingSphereRadius = function() { throw "computeBoundingSphereRadius() not implemented for shape type " + this.type; }; b.prototype.volume = function() { throw "volume() not implemented for shape type " + this.type; }; b.prototype.calculateLocalInertia = function(b, a) { throw "calculateLocalInertia() not implemented for shape type " + this.type; }; b.idCounter = 0; b.types = { SPHERE: 1, PLANE: 2, BOX: 4, COMPOUND: 8, CONVEXPOLYHEDRON: 16, HEIGHTFIELD: 32, PARTICLE: 64, CYLINDER: 128, TRIMESH: 256 } }, { "../material/Material": 25, "../math/Quaternion": 28, "../math/Vec3": 30, "./Shape": 43 }], 44: [function(d, g, l) { function b(a) { c.call(this); this.radius = void 0 !== a ? Number(a) : 1; this.type = c.types.SPHERE; if (0 > this.radius) throw Error("The sphere radius cannot be negative."); this.updateBoundingSphereRadius() } g.exports = b; var c = d("./Shape"), a = d("../math/Vec3"); b.prototype = new c; b.prototype.constructor = b; b.prototype.calculateLocalInertia = function(b, c) { c = c || new a; var d = 2 * b * this.radius * this.radius / 5; c.x = d; c.y = d; c.z = d; return c }; b.prototype.volume = function() { return 4 * Math.PI * this.radius / 3 }; b.prototype.updateBoundingSphereRadius = function() { this.boundingSphereRadius = this.radius }; b.prototype.calculateWorldAABB = function(a, b, c, d) { b = this.radius; for (var f = ["x", "y", "z"], e = 0; e < f.length; e++) { var k = f[e]; c[k] = a[k] - b; d[k] = a[k] + b } } }, { "../math/Vec3": 30, "./Shape": 43 }], 45: [function(d, g, l) { function b(b, e) { c.call(this); this.type = c.types.TRIMESH; this.vertices = new Float32Array(b); this.indices = new Int16Array(e); this.normals = new Float32Array(e.length); this.aabb = new p; this.edges = null; this.scale = new a(1, 1, 1); this.tree = new h; this.updateEdges(); this.updateNormals(); this.updateAABB(); this.updateBoundingSphereRadius(); this.updateTree() } g.exports = b; var c = d("./Shape"), a = d("../math/Vec3"); d("../math/Quaternion"); var q = d("../math/Transform"), p = d("../collision/AABB"), h = d("../utils/Octree"); b.prototype = new c; b.prototype.constructor = b; var k = new a; b.prototype.updateTree = function() { var b = this.tree; b.reset(); b.aabb.copy(this.aabb); var c = this.scale; b.aabb.lowerBound.x *= 1 / c.x; b.aabb.lowerBound.y *= 1 / c.y; b.aabb.lowerBound.z *= 1 / c.z; b.aabb.upperBound.x *= 1 / c.x; b.aabb.upperBound.y *= 1 / c.y; b.aabb.upperBound.z *= 1 / c.z; c = new p; for (var e = new a, d = new a, f = new a, k = [e, d, f], h = 0; h < this.indices.length / 3; h++) { var m = 3 * h; this._getUnscaledVertex(this.indices[m], e); this._getUnscaledVertex(this.indices[m + 1], d); this._getUnscaledVertex(this.indices[m + 2], f); c.setFromPoints(k); b.insert(c, h) } b.removeEmptyNodes() }; var f = new p; b.prototype.getTrianglesInAABB = function(a, b) { f.copy(a); var c = this.scale, e = c.x, d = c.y; c = c.z; var k = f.lowerBound, h = f.upperBound; k.x /= e; k.y /= d; k.z /= c; h.x /= e; h.y /= d; h.z /= c; return this.tree.aabbQuery(f, b) }; b.prototype.setScale = function(a) { var b = a.x === a.y === a.z; this.scale.x === this.scale.y === this.scale.z && b || this.updateNormals(); this.scale.copy(a); this.updateAABB(); this.updateBoundingSphereRadius() }; b.prototype.updateNormals = function() { for (var a = this.normals, c = 0; c < this.indices.length / 3; c++) { var e = 3 * c, d = this.indices[e + 1], f = this.indices[e + 2]; this.getVertex(this.indices[e], w); this.getVertex(d, v); this.getVertex(f, y); b.computeNormal(v, w, y, k); a[e] = k.x; a[e + 1] = k.y; a[e + 2] = k.z } }; b.prototype.updateEdges = function() { for (var a = {}, b = function(b, c) { a[d < f ? d + "_" + f : f + "_" + d] = !0 }, c = 0; c < this.indices.length / 3; c++) { var e = 3 * c, d = this.indices[e], f = this.indices[e + 1]; e = this.indices[e + 2]; b(d, f); b(f, e); b(e, d) } b = Object.keys(a); this.edges = new Int16Array(2 * b.length); for (c = 0; c < b.length; c++) e = b[c].split("_"), this.edges[2 * c] = parseInt(e[0], 10), this.edges[2 * c + 1] = parseInt(e[1], 10) }; b.prototype.getEdgeVertex = function(a, b, c) { this.getVertex(this.edges[2 * a + (b ? 1 : 0)], c) }; var e = new a, m = new a; b.prototype.getEdgeVector = function(a, b) { this.getEdgeVertex(a, 0, e); this.getEdgeVertex(a, 1, m); m.vsub(e, b) }; var t = new a, r = new a; b.computeNormal = function(a, b, c, e) { b.vsub(a, r); c.vsub(b, t); t.cross(r, e); e.isZero() || e.normalize() }; var w = new a, v = new a, y = new a; b.prototype.getVertex = function(a, b) { var c = this.scale; this._getUnscaledVertex(a, b); b.x *= c.x; b.y *= c.y; b.z *= c.z; return b }; b.prototype._getUnscaledVertex = function(a, b) { var c = 3 * a, e = this.vertices; return b.set(e[c], e[c + 1], e[c + 2]) }; b.prototype.getWorldVertex = function(a, b, c, e) { this.getVertex(a, e); q.pointToWorldFrame(b, c, e, e); return e }; b.prototype.getTriangleVertices = function(a, b, c, e) { a *= 3; this.getVertex(this.indices[a], b); this.getVertex(this.indices[a + 1], c); this.getVertex(this.indices[a + 2], e) }; b.prototype.getNormal = function(a, b) { var c = 3 * a; return b.set(this.normals[c], this.normals[c + 1], this.normals[c + 2]) }; var B = new p; b.prototype.calculateLocalInertia = function(a, b) { this.computeLocalAABB(B); var c = B.upperBound.x - B.lowerBound.x, e = B.upperBound.y - B.lowerBound.y, d = B.upperBound.z - B.lowerBound.z; return b.set(1 / 12 * a * (4 * e * e + 4 * d * d), 1 / 12 * a * (4 * c * c + 4 * d * d), 1 / 12 * a * (4 * e * e + 4 * c * c)) }; var C = new a; b.prototype.computeLocalAABB = function(a) { var b = a.lowerBound; a = a.upperBound; var c = this.vertices.length; this.getVertex(0, C); b.copy(C); a.copy(C); for (var e = 0; e !== c; e++) this.getVertex(e, C), C.x < b.x ? b.x = C.x : C.x > a.x && (a.x = C.x), C.y < b.y ? b.y = C.y : C.y > a.y && (a.y = C.y), C.z < b.z ? b.z = C.z : C.z > a.z && (a.z = C.z) }; b.prototype.updateAABB = function() { this.computeLocalAABB(this.aabb) }; b.prototype.updateBoundingSphereRadius = function() { var b = 0, c = this.vertices, e = new a, d = 0; for (c = c.length / 3; d !== c; d++) { this.getVertex(d, e); var f = e.norm2(); f > b && (b = f) } this.boundingSphereRadius = Math.sqrt(b) }; new a; var A = new q, x = new p; b.prototype.calculateWorldAABB = function(a, b, c, e) { A.position = a; A.quaternion = b; this.aabb.toWorldFrame(A, x); c.copy(x.lowerBound); e.copy(x.upperBound) }; b.prototype.volume = function() { return 4 * Math.PI * this.boundingSphereRadius / 3 }; b.createTorus = function(a, c, e, d, f) { a = a || 1; c = c || .5; e = e || 8; d = d || 6; f = f || 2 * Math.PI; for (var k = [], h = [], m = 0; m <= e; m++) for (var g = 0; g <= d; g++) { var l = g / d * f, q = m / e * Math.PI * 2; k.push((a + c * Math.cos(q)) * Math.cos(l), (a + c * Math.cos(q)) * Math.sin(l), c * Math.sin(q)) } for (m = 1; m <= e; m++) for (g = 1; g <= d; g++) a = (d + 1) * (m - 1) + g - 1, c = (d + 1) * (m - 1) + g, f = (d + 1) * m + g, h.push((d + 1) * m + g - 1, a, f), h.push(a, c, f); return new b(k, h) } }, { "../collision/AABB": 3, "../math/Quaternion": 28, "../math/Transform": 29, "../math/Vec3": 30, "../utils/Octree": 50, "./Shape": 43 }], 46: [function(d, g, l) { function b() { c.call(this); this.iterations = 10; this.tolerance = 1E-7 } g.exports = b; d("../math/Vec3"); d("../math/Quaternion"); var c = d("./Solver"); b.prototype = new c; var a = [], q = [], p = []; b.prototype.solve = function(b, c) { var d = 0, e = this.iterations, k = this.tolerance * this.tolerance, h = this.equations, g = h.length, l = c.bodies, v = l.length, y; if (0 !== g) for (y = 0; y !== v; y++) l[y].updateSolveMassProperties(); q.length = g; p.length = g; a.length = g; for (y = 0; y !== g; y++) { var B = h[y]; a[y] = 0; p[y] = B.computeB(b); q[y] = 1 / B.computeC() } if (0 !== g) { for (y = 0; y !== v; y++) B = l[y], d = B.wlambda, B.vlambda.set(0, 0, 0), d && d.set(0, 0, 0); for (d = 0; d !== e; d++) { for (var C = y = 0; C !== g; C++) { B = h[C]; var A = p[C]; var x = q[C]; var G = a[C]; var N = B.computeGWlambda(); A = x * (A - N - B.eps * G); G + A < B.minForce ? A = B.minForce - G : G + A > B.maxForce && (A = B.maxForce - G); a[C] += A; y += 0 < A ? A : -A; B.addToWlambda(A) } if (y * y < k) break } for (y = 0; y !== v; y++) B = l[y], e = B.velocity, k = B.angularVelocity, e.vadd(B.vlambda, e), k && k.vadd(B.wlambda, k) } return d } }, { "../math/Quaternion": 28, "../math/Vec3": 30, "./Solver": 47 }], 47: [function(d, g, l) { function b() { this.equations = [] } g.exports = b; b.prototype.solve = function(b, a) { return 0 }; b.prototype.addEquation = function(b) { b.enabled && this.equations.push(b) }; b.prototype.removeEquation = function(b) { var a = this.equations; b = a.indexOf(b); - 1 !== b && a.splice(b, 1) }; b.prototype.removeAllEquations = function() { this.equations.length = 0 } }, {}], 48: [function(d, g, l) { function b(a, b, c) { p.call(this); this.iterations = b; this.tolerance = c; this.subsolver = a; this.nodes = []; for (this.nodePool = []; 128 > this.nodePool.length;) this.nodePool.push(this.createNode()) } function c(a) { for (var b = a.length, c = 0; c !== b; c++) { var d = a[c]; if (!(d.visited || d.body.type & e)) return d } return !1 } function a(a, b, c) { b.push(a.body); b = a.eqs.length; for (var e = 0; e !== b; e++) { var d = a.eqs[e]; - 1 === c.indexOf(d) && c.push(d) } } function q(a, b) { return b.id - a.id } g.exports = b; d("../math/Vec3"); d("../math/Quaternion"); var p = d("./Solver"); d = d("../objects/Body"); b.prototype = new p; var h = [], k = [], f = { bodies: [] }, e = d.STATIC, m = []; b.prototype.createNode = function() { return { body: null, children: [], eqs: [], visited: !1 } }; b.prototype.solve = function(b, e) { for (var d = this.nodePool, g = e.bodies, l = this.equations, p = l.length, r = g.length, t = this.subsolver; d.length < r;) d.push(this.createNode()); h.length = r; for (var x = 0; x < r; x++) h[x] = d[x]; for (x = 0; x !== r; x++) d = h[x], d.body = g[x], d.children.length = 0, d.eqs.length = 0, d.visited = !1; for (r = 0; r !== p; r++) { d = l[r]; x = g.indexOf(d.bi); var G = g.indexOf(d.bj); x = h[x]; G = h[G]; x.children.push(G); x.eqs.push(d); G.children.push(x); G.eqs.push(d) } g = 0; l = k; t.tolerance = this.tolerance; for (t.iterations = this.iterations; x = c(h);) { l.length = 0; f.bodies.length = 0; d = x; x = a; p = f.bodies; r = l; m.push(d); d.visited = !0; for (x(d, p, r); m.length;) for (d = m.pop(); G = c(d.children);) G.visited = !0, x(G, p, r), m.push(G); p = l.length; l = l.sort(q); for (x = 0; x !== p; x++) t.addEquation(l[x]); t.solve(b, f); t.removeAllEquations(); g++ } return g } }, { "../math/Quaternion": 28, "../math/Vec3": 30, "../objects/Body": 31, "./Solver": 47 }], 49: [function(d, g, l) { d = function() {}; g.exports = d; d.prototype = { constructor: d, addEventListener: function(b, c) { void 0 === this._listeners && (this._listeners = {}); var a = this._listeners; void 0 === a[b] && (a[b] = []); - 1 === a[b].indexOf(c) && a[b].push(c); return this }, hasEventListener: function(b, c) { if (void 0 === this._listeners) return !1; var a = this._listeners; return void 0 !== a[b] && -1 !== a[b].indexOf(c) ? !0 : !1 }, removeEventListener: function(b, c) { if (void 0 === this._listeners) return this; var a = this._listeners; if (void 0 === a[b]) return this; var d = a[b].indexOf(c); - 1 !== d && a[b].splice(d, 1); return this }, dispatchEvent: function(b) { if (void 0 === this._listeners) return this; var c = this._listeners[b.type]; if (void 0 !== c) { b.target = this; for (var a = 0, d = c.length; a < d; a++) c[a].call(this, b) } return this } } }, {}], 50: [function(d, g, l) { function b(b) { b = b || {}; this.root = b.root || null; this.aabb = b.aabb ? b.aabb.clone() : new a; this.data = []; this.children = [] } function c(a, c) { c = c || {}; c.root = null; c.aabb = a; b.call(this, c); this.maxDepth = "undefined" !== typeof c.maxDepth ? c.maxDepth : 8 } var a = d("../collision/AABB"), q = d("../math/Vec3"); g.exports = c; c.prototype = new b; b.prototype.reset = function(a, b) { this.children.length = this.data.length = 0 }; b.prototype.insert = function(a, b, c) { var e = this.data; c = c || 0; if (!this.aabb.contains(a)) return !1; var d = this.children; if (c < (this.maxDepth || this.root.maxDepth)) { var f = !1; d.length || (this.subdivide(), f = !0); for (var k = 0; 8 !== k; k++) if (d[k].insert(a, b, c + 1)) return !0; f && (d.length = 0) } e.push(b); return !0 }; var p = new q; b.prototype.subdivide = function() { var c = this.aabb, d = c.lowerBound, e = c.upperBound; c = this.children; c.push(new b({ aabb: new a({ lowerBound: new q(0, 0, 0) }) }), new b({ aabb: new a({ lowerBound: new q(1, 0, 0) }) }), new b({ aabb: new a({ lowerBound: new q(1, 1, 0) }) }), new b({ aabb: new a({ lowerBound: new q(1, 1, 1) }) }), new b({ aabb: new a({ lowerBound: new q(0, 1, 1) }) }), new b({ aabb: new a({ lowerBound: new q(0, 0, 1) }) }), new b({ aabb: new a({ lowerBound: new q(1, 0, 1) }) }), new b({ aabb: new a({ lowerBound: new q(0, 1, 0) }) })); e.vsub(d, p); p.scale(.5, p); e = this.root || this; for (var h = 0; 8 !== h; h++) { var g = c[h]; g.root = e; var l = g.aabb.lowerBound; l.x *= p.x; l.y *= p.y; l.z *= p.z; l.vadd(d, l); l.vadd(p, g.aabb.upperBound) } }; b.prototype.aabbQuery = function(a, b) { for (var c = [this]; c.length;) { var d = c.pop(); d.aabb.overlaps(a) && Array.prototype.push.apply(b, d.data); Array.prototype.push.apply(c, d.children) } return b }; var h = new a; b.prototype.rayQuery = function(a, b, c) { a.getAABB(h); h.toLocalFrame(b, h); this.aabbQuery(h, c); return c }; b.prototype.removeEmptyNodes = function() { for (var a = [this]; a.length;) { for (var b = a.pop(), c = b.children.length - 1; 0 <= c; c--) b.children[c].data.length || b.children.splice(c, 1); Array.prototype.push.apply(a, b.children) } } }, { "../collision/AABB": 3, "../math/Vec3": 30 }], 51: [function(d, g, l) { function b() { this.objects = []; this.type = Object } g.exports = b; b.prototype.release = function() { for (var b = arguments.length, a = 0; a !== b; a++) this.objects.push(arguments[a]) }; b.prototype.get = function() { return 0 === this.objects.length ? this.constructObject() : this.objects.pop() }; b.prototype.constructObject = function() { throw Error("constructObject() not implemented in this Pool subclass yet!"); } }, {}], 52: [function(d, g, l) { function b() { this.data = { keys: [] } } g.exports = b; b.prototype.get = function(b, a) { if (b > a) { var c = a; a = b; b = c } return this.data[b + "-" + a] }; b.prototype.set = function(b, a, d) { if (b > a) { var c = a; a = b; b = c } c = b + "-" + a; this.get(b, a) || this.data.keys.push(c); this.data[c] = d }; b.prototype.reset = function() { for (var b = this.data, a = b.keys; 0 < a.length;) { var d = a.pop(); delete b[d] } } }, {}], 53: [function(d, g, l) { function b() {} g.exports = b; b.defaults = function(b, a) { b = b || {}; for (var c in a) c in b || (b[c] = a[c]); return b } }, {} ], 54: [function(d, g, l) { function b() { a.call(this); this.type = c } g.exports = b; var c = d("../math/Vec3"), a = d("./Pool"); b.prototype = new a; b.prototype.constructObject = function() { return new c } }, { "../math/Vec3": 30, "./Pool": 51 }], 55: [function(d, g, l) { function b(a) { this.contactPointPool = []; this.frictionEquationPool = []; this.result = []; this.frictionResult = []; this.v3pool = new h; this.world = a; this.currentContactMaterial = null; this.enableFrictionReduction = !1 } g.exports = b; g = d("../collision/AABB"); l = d("../shapes/Shape"); var c = d("../collision/Ray"), a = d("../math/Vec3"), q = d("../math/Transform"); d("../shapes/ConvexPolyhedron"); var p = d("../math/Quaternion"); d("../solver/Solver"); var h = d("../utils/Vec3Pool"), k = d("../equations/ContactEquation"), f = d("../equations/FrictionEquation"); b.prototype.createContactEquation = function(a, b, c, e, d, f) { if (this.contactPointPool.length) { var h = this.contactPointPool.pop(); h.bi = a; h.bj = b } else h = new k(a, b); h.enabled = a.collisionResponse && b.collisionResponse && c.collisionResponse && e.collisionResponse; var g = this.currentContactMaterial; h.restitution = g.restitution; h.setSpookParams(g.contactEquationStiffness, g.contactEquationRelaxation, this.world.dt); a = c.material || a.material; b = e.material || b.material; a && b && 0 <= a.restitution && 0 <= b.restitution && (h.restitution = a.restitution * b.restitution); h.si = d || c; h.sj = f || e; return h }; b.prototype.createFrictionEquationsFromContact = function(a, b) { var c = a.bi, e = a.bj, d = this.world, h = this.currentContactMaterial, k = h.friction, g = a.si.material || c.material, m = a.sj.material || e.material; g && m && 0 <= g.friction && 0 <= m.friction && (k = g.friction * m.friction); if (0 < k) { k *= d.gravity.length(); g = c.invMass + e.invMass; 0 < g && (g = 1 / g); var l = this.frictionEquationPool; m = l.length ? l.pop() : new f(c, e, k * g); l = l.length ? l.pop() : new f(c, e, k * g); m.bi = l.bi = c; m.bj = l.bj = e; m.minForce = l.minForce = -k * g; m.maxForce = l.maxForce = k * g; m.ri.copy(a.ri); m.rj.copy(a.rj); l.ri.copy(a.ri); l.rj.copy(a.rj); a.ni.tangents(m.t, l.t); m.setSpookParams(h.frictionEquationStiffness, h.frictionEquationRelaxation, d.dt); l.setSpookParams(h.frictionEquationStiffness, h.frictionEquationRelaxation, d.dt); m.enabled = l.enabled = a.enabled; b.push(m, l); return !0 } return !1 }; var e = new a, m = new a, t = new a; b.prototype.createFrictionFromAverage = function(a) { var b = this.result[this.result.length - 1]; if (this.createFrictionEquationsFromContact(b, this.frictionResult) && 1 !== a) { var c = this.frictionResult[this.frictionResult.length - 2], d = this.frictionResult[this.frictionResult.length - 1]; e.setZero(); m.setZero(); t.setZero(); for (var f = b.bi, h = 0; h !== a; h++) b = this.result[this.result.length - 1 - h], b.bodyA !== f ? (e.vadd(b.ni, e), m.vadd(b.ri, m), t.vadd(b.rj, t)) : (e.vsub(b.ni, e), m.vadd(b.rj, m), t.vadd(b.ri, t)); a = 1 / a; m.scale(a, c.ri); t.scale(a, c.rj); d.ri.copy(c.ri); d.rj.copy(c.rj); e.normalize(); e.tangents(c.t, d.t) } }; var r = new a, w = new a, v = new p, y = new p; b.prototype.getContacts = function(a, b, c, e, d, f, h) { this.contactPointPool = d; this.frictionEquationPool = h; this.result = e; this.frictionResult = f; e = 0; for (d = a.length; e !== d; e++) { f = a[e]; h = b[e]; var g = null; f.material && h.material && (g = c.getContactMaterial(f.material, h.material) || null); for (var k = 0; k < f.shapes.length; k++) { f.quaternion.mult(f.shapeOrientations[k], v); f.quaternion.vmult(f.shapeOffsets[k], r); r.vadd(f.position, r); for (var m = f.shapes[k], l = 0; l < h.shapes.length; l++) { h.quaternion.mult(h.shapeOrientations[l], y); h.quaternion.vmult(h.shapeOffsets[l], w); w.vadd(h.position, w); var q = h.shapes[l]; if (!(r.distanceTo(w) > m.boundingSphereRadius + q.boundingSphereRadius)) { var p = null; m.material && q.material && (p = c.getContactMaterial(m.material, q.material) || null); this.currentContactMaterial = p || g || c.defaultContactMaterial; (p = this[m.type | q.type]) && (m.type < q.type ? p.call(this, m, q, r, w, v, y, f, h, m, q) : p.call(this, q, m, w, r, y, v, h, f, m, q)) } } } } }; b.prototype[l.types.BOX | l.types.BOX] = b.prototype.boxBox = function(a, b, c, e, d, f, h, k) { a.convexPolyhedronRepresentation.material = a.material; b.convexPolyhedronRepresentation.material = b.material; a.convexPolyhedronRepresentation.collisionResponse = a.collisionResponse; b.convexPolyhedronRepresentation.collisionResponse = b.collisionResponse; this.convexConvex(a.convexPolyhedronRepresentation, b.convexPolyhedronRepresentation, c, e, d, f, h, k, a, b) }; b.prototype[l.types.BOX | l.types.CONVEXPOLYHEDRON] = b.prototype.boxConvex = function(a, b, c, e, d, f, h, k) { a.convexPolyhedronRepresentation.material = a.material; a.convexPolyhedronRepresentation.collisionResponse = a.collisionResponse; this.convexConvex(a.convexPolyhedronRepresentation, b, c, e, d, f, h, k, a, b) }; b.prototype[l.types.BOX | l.types.PARTICLE] = b.prototype.boxParticle = function(a, b, c, e, d, f, h, k) { a.convexPolyhedronRepresentation.material = a.material; a.convexPolyhedronRepresentation.collisionResponse = a.collisionResponse; this.convexParticle(a.convexPolyhedronRepresentation, b, c, e, d, f, h, k, a, b) }; b.prototype[l.types.SPHERE] = b.prototype.sphereSphere = function(a, b, c, e, d, f, h, k) { d = this.createContactEquation(h, k, a, b); e.vsub(c, d.ni); d.ni.normalize(); d.ri.copy(d.ni); d.rj.copy(d.ni); d.ri.mult(a.radius, d.ri); d.rj.mult(-b.radius, d.rj); d.ri.vadd(c, d.ri); d.ri.vsub(h.position, d.ri); d.rj.vadd(e, d.rj); d.rj.vsub(k.position, d.rj); this.result.push(d); this.createFrictionEquationsFromContact(d, this.frictionResult) }; var B = new a, C = new a, A = new a; b.prototype[l.types.PLANE | l.types.TRIMESH] = b.prototype.planeTrimesh = function(b, c, e, d, f, h, k, g) { var m = new a; B.set(0, 0, 1); f.vmult(B, B); for (f = 0; f < c.vertices.length / 3; f++) { c.getVertex(f, m); var l = new a; l.copy(m); q.pointToWorldFrame(d, h, l, m); l = C; m.vsub(e, l); if (0 >= B.dot(l)) { var p = this.createContactEquation(k, g, b, c); p.ni.copy(B); var r = A; B.scale(l.dot(B), r); m.vsub(r, r); p.ri.copy(r); p.ri.vsub(k.position, p.ri); p.rj.copy(m); p.rj.vsub(g.position, p.rj); this.result.push(p); this.createFrictionEquationsFromContact(p, this.frictionResult) } } }; var x = new a, G = new a; new a; var N = new a, H = new a, S = new a, U = new a, R = new a, P = new a, J = new a, L = new a, M = new a, O = new a, X = new a, u = new g, Q = []; b.prototype[l.types.SPHERE | l.types.TRIMESH] = b.prototype.sphereTrimesh = function(a, b, e, d, f, h, k, g) { q.pointToLocalFrame(d, h, e, J); f = a.radius; u.lowerBound.set(J.x - f, J.y - f, J.z - f); u.upperBound.set(J.x + f, J.y + f, J.z + f); b.getTrianglesInAABB(u, Q); var m = a.radius * a.radius; for (f = 0; f < Q.length; f++) for (var l = 0; 3 > l; l++) if (b.getVertex(b.indices[3 * Q[f] + l], N), N.vsub(J, G), G.norm2() <= m) { H.copy(N); q.pointToWorldFrame(d, h, H, N); N.vsub(e, G); var p = this.createContactEquation(k, g, a, b); p.ni.copy(G); p.ni.normalize(); p.ri.copy(p.ni); p.ri.scale(a.radius, p.ri); p.ri.vadd(e, p.ri); p.ri.vsub(k.position, p.ri); p.rj.copy(N); p.rj.vsub(g.position, p.rj); this.result.push(p); this.createFrictionEquationsFromContact(p, this.frictionResult) } for (f = 0; f < Q.length; f++) for (l = 0; 3 > l; l++) b.getVertex(b.indices[3 * Q[f] + l], S), b.getVertex(b.indices[3 * Q[f] + (l + 1) % 3], U), U.vsub(S, R), J.vsub(U, L), e = L.dot(R), J.vsub(S, L), p = L.dot(R), 0 < p && 0 > e && (J.vsub(S, L), P.copy(R), P.normalize(), p = L.dot(P), P.scale(p, L), L.vadd(S, L), e = L.distanceTo(J), e < a.radius && (p = this.createContactEquation(k, g, a, b), L.vsub(J, p.ni), p.ni.normalize(), p.ni.scale(a.radius, p.ri), q.pointToWorldFrame(d, h, L, L), L.vsub(g.position, p.rj), q.vectorToWorldFrame(h, p.ni, p.ni), q.vectorToWorldFrame(h, p.ri, p.ri), this.result.push(p), this.createFrictionEquationsFromContact(p, this.frictionResult))); f = 0; for (l = Q.length; f !== l; f++) b.getTriangleVertices(Q[f], M, O, X), b.getNormal(Q[f], x), J.vsub(M, L), e = L.dot(x), x.scale(e, L), J.vsub(L, L), e = L.distanceTo(J), c.pointInTriangle(L, M, O, X) && e < a.radius && (p = this.createContactEquation(k, g, a, b), L.vsub(J, p.ni), p.ni.normalize(), p.ni.scale(a.radius, p.ri), q.pointToWorldFrame(d, h, L, L), L.vsub(g.position, p.rj), q.vectorToWorldFrame(h, p.ni, p.ni), q.vectorToWorldFrame(h, p.ri, p.ri), this.result.push(p), this.createFrictionEquationsFromContact(p, this.frictionResult)); Q.length = 0 }; var E = new a, T = new a; b.prototype[l.types.SPHERE | l.types.PLANE] = b.prototype.spherePlane = function(a, b, c, e, d, f, h, k) { b = this.createContactEquation(h, k, a, b); b.ni.set(0, 0, 1); f.vmult(b.ni, b.ni); b.ni.negate(b.ni); b.ni.normalize(); b.ni.mult(a.radius, b.ri); c.vsub(e, E); b.ni.mult(b.ni.dot(E), T); E.vsub(T, b.rj); - E.dot(b.ni) <= a.radius && (a = b.ri, f = b.rj, a.vadd(c, a), a.vsub(h.position, a), f.vadd(e, f), f.vsub(k.position, f), this.result.push(b), this.createFrictionEquationsFromContact(b, this.frictionResult)) }; var I = new a, F = new a, K = new a, z = new a, D = new a, V = new a, aa = new a, Y = [new a, new a, new a, new a, new a, new a], W = new a, Z = new a, ba = new a, na = new a; b.prototype[l.types.SPHERE | l.types.BOX] = b.prototype.sphereBox = function(a, b, c, e, d, f, h, k) { d = this.v3pool; c.vsub(e, z); b.getSideNormals(Y, f); f = a.radius; for (var g = !1, m = null, l = 0, q = 0, p = 0, r = null, t = 0, u = Y.length; t !== u && !1 === g; t++) { var v = D; v.copy(Y[t]); var A = v.norm(); v.normalize(); var w = z.dot(v); if (w < A + f && 0 < w) { var O = V, x = aa; O.copy(Y[(t + 1) % 3]); x.copy(Y[(t + 2) % 3]); var y = O.norm(), H = x.norm(); O.normalize(); x.normalize(); var B = z.dot(O), C = z.dot(x); B < y && B > -y && C < H && C > -H && (w = Math.abs(w - A - f), null === r || w < r) && (r = w, q = B, p = C, m = A, Z.copy(v), ba.copy(O), na.copy(x), l++) } } l && (g = !0, l = this.createContactEquation(h, k, a, b), Z.mult(-f, l.ri), l.ni.copy(Z), l.ni.negate(l.ni), Z.mult(m, Z), ba.mult(q, ba), Z.vadd(ba, Z), na.mult(p, na), Z.vadd(na, l.rj), l.ri.vadd(c, l.ri), l.ri.vsub(h.position, l.ri), l.rj.vadd(e, l.rj), l.rj.vsub(k.position, l.rj), this.result.push(l), this.createFrictionEquationsFromContact(l, this.frictionResult)); w = d.get(); for (m = 0; 2 !== m && !g; m++) for (q = 0; 2 !== q && !g; q++) for (p = 0; 2 !== p && !g; p++) w.set(0, 0, 0), m ? w.vadd(Y[0], w) : w.vsub(Y[0], w), q ? w.vadd(Y[1], w) : w.vsub(Y[1], w), p ? w.vadd(Y[2], w) : w.vsub(Y[2], w), e.vadd(w, W), W.vsub(c, W), W.norm2() < f * f && (g = !0, l = this.createContactEquation(h, k, a, b), l.ri.copy(W), l.ri.normalize(), l.ni.copy(l.ri), l.ri.mult(f, l.ri), l.rj.copy(w), l.ri.vadd(c, l.ri), l.ri.vsub(h.position, l.ri), l.rj.vadd(e, l.rj), l.rj.vsub(k.position, l.rj), this.result.push(l), this.createFrictionEquationsFromContact(l, this.frictionResult)); d.release(w); r = d.get(); t = d.get(); l = d.get(); u = d.get(); w = d.get(); v = Y.length; for (m = 0; m !== v && !g; m++) for (q = 0; q !== v && !g; q++) if (m % 3 !== q % 3) { Y[q].cross(Y[m], r); r.normalize(); Y[m].vadd(Y[q], t); l.copy(c); l.vsub(t, l); l.vsub(e, l); A = l.dot(r); r.mult(A, u); for (p = 0; p === m % 3 || p === q % 3;) p++; w.copy(c); w.vsub(u, w); w.vsub(t, w); w.vsub(e, w); A = Math.abs(A); O = w.norm(); A < Y[p].norm() && O < f && (g = !0, p = this.createContactEquation(h, k, a, b), t.vadd(u, p.rj), p.rj.copy(p.rj), w.negate(p.ni), p.ni.normalize(), p.ri.copy(p.rj), p.ri.vadd(e, p.ri), p.ri.vsub(c, p.ri), p.ri.normalize(), p.ri.mult(f, p.ri), p.ri.vadd(c, p.ri), p.ri.vsub(h.position, p.ri), p.rj.vadd(e, p.rj), p.rj.vsub(k.position, p.rj), this.result.push(p), this.createFrictionEquationsFromContact(p, this.frictionResult)) } d.release(r, t, l, u, w) }; var xa = new a, ya = new a, za = new a, Aa = new a, Ba = new a, Ca = new a, Da = new a, Ea = new a, Fa = new a, Ga = new a; b.prototype[l.types.SPHERE | l.types.CONVEXPOLYHEDRON] = b.prototype.sphereConvex = function(a, b, c, e, d, f, h, k) { d = this.v3pool; c.vsub(e, xa); for (var g = b.faceNormals, m = b.faces, l = b.vertices, q = a.radius, p = 0; p !== l.length; p++) { var r = Ba; f.vmult(l[p], r); e.vadd(r, r); var t = Aa; r.vsub(c, t); if (t.norm2() < q * q) { a = this.createContactEquation(h, k, a, b); a.ri.copy(t); a.ri.normalize(); a.ni.copy(a.ri); a.ri.mult(q, a.ri); r.vsub(e, a.rj); a.ri.vadd(c, a.ri); a.ri.vsub(h.position, a.ri); a.rj.vadd(e, a.rj); a.rj.vsub(k.position, a.rj); this.result.push(a); this.createFrictionEquationsFromContact(a, this.frictionResult); return } } p = 0; for (r = m.length; p !== r; p++) { t = m[p]; var u = Ca; f.vmult(g[p], u); var v = Da; f.vmult(l[t[0]], v); v.vadd(e, v); var w = Ea; u.mult(-q, w); c.vadd(w, w); var A = Fa; w.vsub(v, A); w = A.dot(u); A = Ga; c.vsub(v, A); if (0 > w && 0 < A.dot(u)) { v = []; A = 0; for (var O = t.length; A !== O; A++) { var x = d.get(); f.vmult(l[t[A]], x); e.vadd(x, x); v.push(x) } a: { A = v;O = u;x = c; for (var y = null, H = A.length, B = 0; B !== H; B++) { var z = A[B], C = I; A[(B + 1) % H].vsub(z, C); var G = F; C.cross(O, G); C = K; x.vsub(z, C); z = G.dot(C); if (null === y || 0 < z && !0 === y || 0 >= z && !1 === y) null === y && (y = 0 < z); else { A = !1; break a } } A = !0 } if (A) { a = this.createContactEquation(h, k, a, b); u.mult(-q, a.ri); u.negate(a.ni); b = d.get(); u.mult(-w, b); f = d.get(); u.mult(-q, f); c.vsub(e, a.rj); a.rj.vadd(f, a.rj); a.rj.vadd(b, a.rj); a.rj.vadd(e, a.rj); a.rj.vsub(k.position, a.rj); a.ri.vadd(c, a.ri); a.ri.vsub(h.position, a.ri); d.release(b); d.release(f); this.result.push(a); this.createFrictionEquationsFromContact(a, this.frictionResult); A = 0; for (t = v.length; A !== t; A++) d.release(v[A]); break } else for (A = 0; A !== t.length; A++) { u = d.get(); w = d.get(); f.vmult(l[t[(A + 1) % t.length]], u); f.vmult(l[t[(A + 2) % t.length]], w); e.vadd(u, u); e.vadd(w, w); H = ya; w.vsub(u, H); y = za; H.unit(y); O = d.get(); x = d.get(); c.vsub(u, x); B = x.dot(y); y.mult(B, O); O.vadd(u, O); y = d.get(); O.vsub(c, y); if (0 < B && B * B < H.norm2() && y.norm2() < q * q) { a = this.createContactEquation(h, k, a, b); O.vsub(e, a.rj); O.vsub(c, a.ni); a.ni.normalize(); a.ni.mult(q, a.ri); a.rj.vadd(e, a.rj); a.rj.vsub(k.position, a.rj); a.ri.vadd(c, a.ri); a.ri.vsub(h.position, a.ri); this.result.push(a); this.createFrictionEquationsFromContact(a, this.frictionResult); A = 0; for (t = v.length; A !== t; A++) d.release(v[A]); d.release(u); d.release(w); d.release(O); d.release(y); d.release(x); return } d.release(u); d.release(w); d.release(O); d.release(y); d.release(x) } A = 0; for (t = v.length; A !== t; A++) d.release(v[A]) } } }; new a; new a; b.prototype[l.types.PLANE | l.types.BOX] = b.prototype.planeBox = function(a, b, c, e, d, f, h, k) { b.convexPolyhedronRepresentation.material = b.material; b.convexPolyhedronRepresentation.collisionResponse = b.collisionResponse; this.planeConvex(a, b.convexPolyhedronRepresentation, c, e, d, f, h, k) }; var ca = new a, da = new a, qa = new a, Ha = new a; b.prototype[l.types.PLANE | l.types.CONVEXPOLYHEDRON] = b.prototype.planeConvex = function(a, b, c, e, d, f, h, k) { da.set(0, 0, 1); d.vmult(da, da); for (var g = d = 0; g !== b.vertices.length; g++) if (ca.copy(b.vertices[g]), f.vmult(ca, ca), e.vadd(ca, ca), ca.vsub(c, qa), 0 >= da.dot(qa)) { var m = this.createContactEquation(h, k, a, b), l = Ha; da.mult(da.dot(qa), l); ca.vsub(l, l); l.vsub(c, m.ri); m.ni.copy(da); ca.vsub(e, m.rj); m.ri.vadd(c, m.ri); m.ri.vsub(h.position, m.ri); m.rj.vadd(e, m.rj); m.rj.vsub(k.position, m.rj); this.result.push(m); d++; this.enableFrictionReduction || this.createFrictionEquationsFromContact(m, this.frictionResult) } this.enableFrictionReduction && d && this.createFrictionFromAverage(d) }; var ra = new a, oa = new a; b.prototype[l.types.CONVEXPOLYHEDRON] = b.prototype.convexConvex = function(a, b, c, e, d, f, h, k, g, m, l, q) { if (!(c.distanceTo(e) > a.boundingSphereRadius + b.boundingSphereRadius) && a.findSeparatingAxis(b, c, d, e, f, ra, l, q)) { l = []; a.clipAgainstHull(c, d, b, e, f, ra, -100, 100, l); for (f = d = 0; f !== l.length; f++) { q = this.createContactEquation(h, k, a, b, g, m); var p = q.ri, r = q.rj; ra.negate(q.ni); l[f].normal.negate(oa); oa.mult(l[f].depth, oa); l[f].point.vadd(oa, p); r.copy(l[f].point); p.vsub(c, p); r.vsub(e, r); p.vadd(c, p); p.vsub(h.position, p); r.vadd(e, r); r.vsub(k.position, r); this.result.push(q); d++; this.enableFrictionReduction || this.createFrictionEquationsFromContact(q, this.frictionResult) } this.enableFrictionReduction && d && this.createFrictionFromAverage(d) } }; var ea = new a, ta = new a, pa = new a; b.prototype[l.types.PLANE | l.types.PARTICLE] = b.prototype.planeParticle = function(a, b, c, e, d, f, h, k) { ea.set(0, 0, 1); h.quaternion.vmult(ea, ea); e.vsub(h.position, ta); 0 >= ea.dot(ta) && (a = this.createContactEquation(k, h, b, a), a.ni.copy(ea), a.ni.negate(a.ni), a.ri.set(0, 0, 0), ea.mult(ea.dot(e), pa), e.vsub(pa, pa), a.rj.copy(pa), this.result.push(a), this.createFrictionEquationsFromContact(a, this.frictionResult)) }; var ia = new a; b.prototype[l.types.PARTICLE | l.types.SPHERE] = b.prototype.sphereParticle = function(a, b, c, e, d, f, h, k) { ia.set(0, 0, 1); e.vsub(c, ia); ia.norm2() <= a.radius * a.radius && (b = this.createContactEquation(k, h, b, a), ia.normalize(), b.rj.copy(ia), b.rj.mult(a.radius, b.rj), b.ni.copy(ia), b.ni.negate(b.ni), b.ri.set(0, 0, 0), this.result.push(b), this.createFrictionEquationsFromContact(b, this.frictionResult)) }; var ua = new p, ja = new a; new a; var sa = new a, va = new a, ka = new a; b.prototype[l.types.PARTICLE | l.types.CONVEXPOLYHEDRON] = b.prototype.convexParticle = function(a, b, c, e, d, f, h, k) { var g = -1; f = null; var m = 0; ja.copy(e); ja.vsub(c, ja); d.conjugate(ua); ua.vmult(ja, ja); if (a.pointIsInside(ja)) { a.worldVerticesNeedsUpdate && a.computeWorldVertices(c, d); a.worldFaceNormalsNeedsUpdate && a.computeWorldFaceNormals(d); d = 0; for (var l = a.faces.length; d !== l; d++) { var q = a.worldFaceNormals[d]; e.vsub(a.worldVertices[a.faces[d][0]], va); var p = -q.dot(va); if (null === f || Math.abs(p) < Math.abs(f)) f = p, g = d, sa.copy(q), m++ } - 1 !== g ? (a = this.createContactEquation(k, h, b, a), sa.mult(f, ka), ka.vadd(e, ka), ka.vsub(c, ka), a.rj.copy(ka), sa.negate(a.ni), a.ri.set(0, 0, 0), b = a.ri, f = a.rj, b.vadd(e, b), b.vsub(k.position, b), f.vadd(c, f), f.vsub(h.position, f), this.result.push(a), this.createFrictionEquationsFromContact(a, this.frictionResult)) : console.warn("Point found inside convex, but did not find penetrating face!") } }; b.prototype[l.types.BOX | l.types.HEIGHTFIELD] = b.prototype.boxHeightfield = function(a, b, c, e, d, f, h, k) { a.convexPolyhedronRepresentation.material = a.material; a.convexPolyhedronRepresentation.collisionResponse = a.collisionResponse; this.convexHeightfield(a.convexPolyhedronRepresentation, b, c, e, d, f, h, k) }; var fa = new a, la = new a, wa = [0]; b.prototype[l.types.CONVEXPOLYHEDRON | l.types.HEIGHTFIELD] = b.prototype.convexHeightfield = function(a, b, c, e, d, f, h, k) { var g = b.data, m = b.elementSize, l = a.boundingSphereRadius; q.pointToLocalFrame(e, f, c, fa); var p = Math.floor((fa.x - l) / m) - 1, r = Math.ceil((fa.x + l) / m) + 1, t = Math.floor((fa.y - l) / m) - 1; m = Math.ceil((fa.y + l) / m) + 1; if (!(0 > r || 0 > m || p > g.length || t > g[0].length)) { 0 > p && (p = 0); 0 > r && (r = 0); 0 > t && (t = 0); 0 > m && (m = 0); p >= g.length && (p = g.length - 1); r >= g.length && (r = g.length - 1); m >= g[0].length && (m = g[0].length - 1); t >= g[0].length && (t = g[0].length - 1); g = []; b.getRectMinMax(p, t, r, m, g); var u = g[0]; if (!(fa.z - l > g[1] || fa.z + l < u)) for (l = p; l < r; l++) for (p = t; p < m; p++) b.getConvexTrianglePillar(l, p, !1), q.pointToWorldFrame(e, f, b.pillarOffset, la), c.distanceTo(la) < b.pillarConvex.boundingSphereRadius + a.boundingSphereRadius && this.convexConvex(a, b.pillarConvex, c, la, d, f, h, k, null, null, wa, null), b.getConvexTrianglePillar(l, p, !0), q.pointToWorldFrame(e, f, b.pillarOffset, la), c.distanceTo(la) < b.pillarConvex.boundingSphereRadius + a.boundingSphereRadius && this.convexConvex(a, b.pillarConvex, c, la, d, f, h, k, null, null, wa, null) } }; var ha = new a, ma = new a; b.prototype[l.types.SPHERE | l.types.HEIGHTFIELD] = b.prototype.sphereHeightfield = function(a, b, c, e, d, f, h, k) { var g = b.data, m = a.radius, l = b.elementSize; q.pointToLocalFrame(e, f, c, ha); var p = Math.floor((ha.x - m) / l) - 1, r = Math.ceil((ha.x + m) / l) + 1, t = Math.floor((ha.y - m) / l) - 1; l = Math.ceil((ha.y + m) / l) + 1; if (!(0 > r || 0 > l || p > g.length || l > g[0].length)) { 0 > p && (p = 0); 0 > r && (r = 0); 0 > t && (t = 0); 0 > l && (l = 0); p >= g.length && (p = g.length - 1); r >= g.length && (r = g.length - 1); l >= g[0].length && (l = g[0].length - 1); t >= g[0].length && (t = g[0].length - 1); g = []; b.getRectMinMax(p, t, r, l, g); var u = g[0]; if (!(ha.z - m > g[1] || ha.z + m < u)) for (m = this.result; p < r; p++) for (g = t; g < l; g++) if (u = m.length, b.getConvexTrianglePillar(p, g, !1), q.pointToWorldFrame(e, f, b.pillarOffset, ma), c.distanceTo(ma) < b.pillarConvex.boundingSphereRadius + a.boundingSphereRadius && this.sphereConvex(a, b.pillarConvex, c, ma, d, f, h, k), b.getConvexTrianglePillar(p, g, !0), q.pointToWorldFrame(e, f, b.pillarOffset, ma), c.distanceTo(ma) < b.pillarConvex.boundingSphereRadius + a.boundingSphereRadius && this.sphereConvex(a, b.pillarConvex, c, ma, d, f, h, k), 2 < m.length - u) return } } }, { "../collision/AABB": 3, "../collision/Ray": 9, "../equations/ContactEquation": 19, "../equations/FrictionEquation": 21, "../math/Quaternion": 28, "../math/Transform": 29, "../math/Vec3": 30, "../shapes/ConvexPolyhedron": 38, "../shapes/Shape": 43, "../solver/Solver": 47, "../utils/Vec3Pool": 54 }], 56: [function(d, g, l) { function b() { p.apply(this); this.dt = -1; this.allowSleep = !1; this.contacts = []; this.frictionEquations = []; this.quatNormalizeSkip = 0; this.quatNormalizeFast = !1; this.stepnumber = this.time = 0; this.default_dt = 1 / 60; this.nextId = 0; this.gravity = new c; this.broadphase = new w; this.bodies = []; this.solver = new a; this.constraints = []; this.narrowphase = new q(this); this.collisionMatrix = new h; this.collisionMatrixPrevious = new h; this.materials = []; this.contactmaterials = []; this.contactMaterialTable = new m; this.defaultMaterial = new k("default"); this.defaultContactMaterial = new f(this.defaultMaterial, this.defaultMaterial, { friction: .3, restitution: 0 }); this.doProfiling = !1; this.profile = { solve: 0, makeContactConstraints: 0, broadphase: 0, integrate: 0, narrowphase: 0 }; this.subsystems = []; this.addBodyEvent = { type: "addBody", body: null }; this.removeBodyEvent = { type: "removeBody", body: null } } g.exports = b; d("../shapes/Shape"); var c = d("../math/Vec3"); g = d("../math/Quaternion"); var a = d("../solver/GSSolver"); d("../utils/Vec3Pool"); d("../equations/ContactEquation"); d("../equations/FrictionEquation"); var q = d("./Narrowphase"), p = d("../utils/EventTarget"), h = d("../collision/ArrayCollisionMatrix"), k = d("../material/Material"), f = d("../material/ContactMaterial"), e = d("../objects/Body"), m = d("../utils/TupleDictionary"), t = d("../collision/RaycastResult"); l = d("../collision/AABB"); var r = d("../collision/Ray"), w = d("../collision/NaiveBroadphase"); b.prototype = new p; new l; var v = new r; b.prototype.getContactMaterial = function(a, b) { return this.contactMaterialTable.get(a.id, b.id) }; b.prototype.numObjects = function() { return this.bodies.length }; b.prototype.collisionMatrixTick = function() { var a = this.collisionMatrixPrevious; this.collisionMatrixPrevious = this.collisionMatrix; this.collisionMatrix = a; this.collisionMatrix.reset() }; b.prototype.add = b.prototype.addBody = function(a) { -1 === this.bodies.indexOf(a) && (a.index = this.bodies.length, this.bodies.push(a), a.world = this, a.initPosition.copy(a.position), a.initVelocity.copy(a.velocity), a.timeLastSleepy = this.time, a instanceof e && (a.initAngularVelocity.copy(a.angularVelocity), a.initQuaternion.copy(a.quaternion)), this.collisionMatrix.setNumObjects(this.bodies.length), this.addBodyEvent.body = a, this.dispatchEvent(this.addBodyEvent)) }; b.prototype.addConstraint = function(a) { this.constraints.push(a) }; b.prototype.removeConstraint = function(a) { a = this.constraints.indexOf(a); - 1 !== a && this.constraints.splice(a, 1) }; b.prototype.rayTest = function(a, b, c) { c instanceof t ? this.raycastClosest(a, b, { skipBackfaces: !0 }, c) : this.raycastAll(a, b, { skipBackfaces: !0 }, c) }; b.prototype.raycastAll = function(a, b, c, e) { c.mode = r.ALL; c.from = a; c.to = b; c.callback = e; return v.intersectWorld(this, c) }; b.prototype.raycastAny = function(a, b, c, e) { c.mode = r.ANY; c.from = a; c.to = b; c.result = e; return v.intersectWorld(this, c) }; b.prototype.raycastClosest = function(a, b, c, e) { c.mode = r.CLOSEST; c.from = a; c.to = b; c.result = e; return v.intersectWorld(this, c) }; b.prototype.remove = function(a) { a.world = null; var b = this.bodies.length - 1, c = this.bodies, e = c.indexOf(a); if (-1 !== e) { c.splice(e, 1); for (e = 0; e !== c.length; e++) c[e].index = e; this.collisionMatrix.setNumObjects(b); this.removeBodyEvent.body = a; this.dispatchEvent(this.removeBodyEvent) } }; b.prototype.removeBody = b.prototype.remove; b.prototype.addMaterial = function(a) { this.materials.push(a) }; b.prototype.addContactMaterial = function(a) { this.contactmaterials.push(a); this.contactMaterialTable.set(a.materials[0].id, a.materials[1].id, a) }; "undefined" === typeof performance && (performance = {}); if (!performance.now) { var y = Date.now(); performance.timing && performance.timing.navigationStart && (y = performance.timing.navigationStart); performance.now = function() { return Date.now() - y } } var B = new c; b.prototype.step = function(a, b, c) { c = c || 10; b = b || 0; if (0 === b) this.internalStep(a), this.time += a; else { var d = Math.floor((this.time + b) / a) - Math.floor(this.time / a); d = Math.min(d, c); c = performance.now(); for (var f = 0; f !== d && !(this.internalStep(a), performance.now() - c > 1E3 * a); f++); this.time += b; a = this.time % a / a; b = this.bodies; for (d = 0; d !== b.length; d++) c = b[d], c.type !== e.STATIC && c.sleepState !== e.SLEEPING ? (c.position.vsub(c.previousPosition, B), B.scale(a, B), c.position.vadd(B, c.interpolatedPosition)) : (c.interpolatedPosition.copy(c.position), c.interpolatedQuaternion.copy(c.quaternion)) } }; var C = { type: "postStep" }, A = { type: "preStep" }, x = { type: "collide", body: null, contact: null }, G = [], N = [], H = [], S = []; new c; new c; new c; new c; new c; new c; new c; new c; new c; new g; var U = new g, R = new g, P = new c; b.prototype.internalStep = function(a) { this.dt = a; var b = this.contacts, c = this.numObjects(), d = this.bodies, f = this.solver, h = this.gravity, g = this.doProfiling, k = this.profile, m = e.DYNAMIC, l, p = this.constraints; h.norm(); var q = h.x, r = h.y, t = h.z; g && (l = performance.now()); for (h = 0; h !== c; h++) { var v = d[h]; if (v.type & m) { var w = v.force; v = v.mass; w.x += v * q; w.y += v * r; w.z += v * t } } h = 0; for (v = this.subsystems.length; h !== v; h++) this.subsystems[h].update(); g && (l = performance.now()); H.length = 0; S.length = 0; this.broadphase.collisionPairs(this, H, S); g && (k.broadphase = performance.now() - l); v = p.length; for (h = 0; h !== v; h++) if (q = p[h], !q.collideConnected) for (r = H.length - 1; 0 <= r; --r) if (q.bodyA === H[r] && q.bodyB === S[r] || q.bodyB === H[r] && q.bodyA === S[r]) H.splice(r, 1), S.splice(r, 1); this.collisionMatrixTick(); g && (l = performance.now()); v = b.length; for (h = 0; h !== v; h++) G.push(b[h]); b.length = 0; v = this.frictionEquations.length; for (h = 0; h !== v; h++) N.push(this.frictionEquations[h]); this.frictionEquations.length = 0; this.narrowphase.getContacts(H, S, this, b, G, this.frictionEquations, N); g && (k.narrowphase = performance.now() - l); g && (l = performance.now()); for (h = 0; h < this.frictionEquations.length; h++) f.addEquation(this.frictionEquations[h]); h = b.length; for (r = 0; r !== h; r++) q = b[r], v = q.bi, t = q.bj, v.material && t.material && this.getContactMaterial(v.material, t.material), v.material && t.material && 0 <= v.material.restitution && 0 <= t.material.restitution && (q.restitution = v.material.restitution * t.material.restitution), f.addEquation(q), v.allowSleep && v.type === e.DYNAMIC && v.sleepState === e.SLEEPING && t.sleepState === e.AWAKE && t.type !== e.STATIC && t.velocity.norm2() + t.angularVelocity.norm2() >= 2 * Math.pow(t.sleepSpeedLimit, 2) && (v._wakeUpAfterNarrowphase = !0), t.allowSleep && t.type === e.DYNAMIC && t.sleepState === e.SLEEPING && v.sleepState === e.AWAKE && v.type !== e.STATIC && v.velocity.norm2() + v.angularVelocity.norm2() >= 2 * Math.pow(v.sleepSpeedLimit, 2) && (t._wakeUpAfterNarrowphase = !0), this.collisionMatrix.set(v, t, !0), this.collisionMatrixPrevious.get(v, t) || (x.body = t, x.contact = q, v.dispatchEvent(x), x.body = v, t.dispatchEvent(x)); g && (k.makeContactConstraints = performance.now() - l, l = performance.now()); for (h = 0; h !== c; h++) v = d[h], v._wakeUpAfterNarrowphase && (v.wakeUp(), v._wakeUpAfterNarrowphase = !1); v = p.length; for (h = 0; h !== v; h++) for (q = p[h], q.update(), r = 0, b = q.equations.length; r !== b; r++) f.addEquation(q.equations[r]); f.solve(a, this); g && (k.solve = performance.now() - l); f.removeAllEquations(); f = Math.pow; for (h = 0; h !== c; h++) if (v = d[h], v.type & m && (p = f(1 - v.linearDamping, a), b = v.velocity, b.mult(p, b), p = v.angularVelocity)) b = f(1 - v.angularDamping, a), p.mult(b, p); this.dispatchEvent(A); for (h = 0; h !== c; h++) v = d[h], v.preStep && v.preStep.call(v); g && (l = performance.now()); m = e.DYNAMIC | e.KINEMATIC; f = 0 === this.stepnumber % (this.quatNormalizeSkip + 1); p = this.quatNormalizeFast; b = .5 * a; for (h = 0; h !== c; h++) if (v = d[h], q = v.force, r = v.torque, v.type & m && v.sleepState !== e.SLEEPING) { t = v.velocity; w = v.angularVelocity; var y = v.position, B = v.quaternion, Z = v.invMass, ba = v.invInertiaWorld; t.x += q.x * Z * a; t.y += q.y * Z * a; t.z += q.z * Z * a; v.angularVelocity && (ba.vmult(r, P), P.mult(a, P), P.vadd(w, w)); y.x += t.x * a; y.y += t.y * a; y.z += t.z * a; v.angularVelocity && (U.set(w.x, w.y, w.z, 0), U.mult(B, R), B.x += b * R.x, B.y += b * R.y, B.z += b * R.z, B.w += b * R.w, f && (p ? B.normalizeFast() : B.normalize())); v.aabb && (v.aabbNeedsUpdate = !0); v.updateInertiaWorld && v.updateInertiaWorld() } this.clearForces(); this.broadphase.dirty = !0; g && (k.integrate = performance.now() - l); this.time += a; this.stepnumber += 1; this.dispatchEvent(C); for (h = 0; h !== c; h++) v = d[h], (a = v.postStep) && a.call(v); if (this.allowSleep) for (h = 0; h !== c; h++) d[h].sleepTick(this.time) }; b.prototype.clearForces = function() { for (var a = this.bodies, b = a.length, c = 0; c !== b; c++) { var e = a[c]; e.force.set(0, 0, 0); e.torque.set(0, 0, 0) } } }, { "../collision/AABB": 3, "../collision/ArrayCollisionMatrix": 4, "../collision/NaiveBroadphase": 7, "../collision/Ray": 9, "../collision/RaycastResult": 10, "../equations/ContactEquation": 19, "../equations/FrictionEquation": 21, "../material/ContactMaterial": 24, "../material/Material": 25, "../math/Quaternion": 28, "../math/Vec3": 30, "../objects/Body": 31, "../shapes/Shape": 43, "../solver/GSSolver": 46, "../utils/EventTarget": 49, "../utils/TupleDictionary": 52, "../utils/Vec3Pool": 54, "./Narrowphase": 55 }] }, {}, [2])(2) }); CANNON = CANNON || {}; var camera, scene, renderer, controls = null, s_oRender; CANNON.Demo = function(n) { function d() { if (C) { for (var a in C.__controllers) C.__controllers[a].updateDisplay(); for (var b in C.__folders) for (a in C.__folders[b].__controllers) C.__folders[b].__controllers[a].updateDisplay() } } function g(a) { function b(a, c) { a.material && (a.material = c); for (var e = 0; e < a.children.length; e++) b(a.children[e], c) } if (-1 === T.indexOf(a)) throw Error("Render mode " + a + " not found!"); switch (a) { case "solid": m.currentMaterial = H; I.intensity = 1; F.color.setHex(2236962); break; case "wireframe": m.currentMaterial = S, I.intensity = 0, F.color.setHex(16777215) } for (var c = 0; c < y.length; c++) b(y[c], m.currentMaterial); r.rendermode = a } function l() { for (var a = v.length, b = 0; b < a; b++) { var c = v[b]; c.position.copy(c.initPosition); c.velocity.copy(c.initVelocity); c.initAngularVelocity && (c.angularVelocity.copy(c.initAngularVelocity), c.quaternion.copy(c.initQuaternion)) } } function b(a) { 0 === a.x && (a.x = 1E-6); 0 === a.y && (a.y = 1E-6); 0 === a.z && (a.z = 1E-6) } function c() { for (var a = v.length, c = 0; c < a; c++) { var e = v[c], d = y[c]; d.position.copy(e.position); e.quaternion && d.quaternion.copy(e.quaternion) } R.restart(); if (r.contacts) for (c = 0; c < E.contacts.length; c++) for (a = 0; 2 > a; a++) { d = R.request(); var f = E.contacts[c]; e = 0 === a ? f.bi : f.bj; var h = 0 === a ? f.ri : f.rj; d.position.set(e.position.x + h.x, e.position.y + h.y, e.position.z + h.z) } R.hideCached(); P.restart(); if (r.cm2contact) for (c = 0; c < E.contacts.length; c++) for (a = 0; 2 > a; a++) d = P.request(), f = E.contacts[c], e = 0 === a ? f.bi : f.bj, h = 0 === a ? f.ri : f.rj, d.scale.set(h.x, h.y, h.z), b(d.scale), d.position.copy(e.position); P.hideCached(); O.restart(); X.restart(); if (r.constraints) { for (c = 0; c < E.constraints.length; c++) f = E.constraints[c], f instanceof CANNON.DistanceConstraint && (e = f.equations.normal, a = e.bi, e = e.bj, d = O.request(), e = e.position ? e.position : e, d.scale.set(e.x - a.position.x, e.y - a.position.y, e.z - a.position.z), b(d.scale), d.position.copy(a.position)); for (c = 0; c < E.constraints.length; c++) if (f = E.constraints[c], f instanceof CANNON.PointToPointConstraint) { h = f.equations.normal; a = h.bi; e = h.bj; d = X.request(); f = X.request(); var g = X.request(); d.scale.set(h.ri.x, h.ri.y, h.ri.z); f.scale.set(h.rj.x, h.rj.y, h.rj.z); g.scale.set(-h.penetrationVec.x, -h.penetrationVec.y, -h.penetrationVec.z); b(d.scale); b(f.scale); b(g.scale); d.position.copy(a.position); f.position.copy(e.position); h.bj.position.vadd(h.rj, g.position) } } X.hideCached(); O.hideCached(); u.restart(); if (r.normals) for (c = 0; c < E.contacts.length; c++) f = E.contacts[c], a = f.bi, d = u.request(), h = f.ni, e = a, d.scale.set(h.x, h.y, h.z), b(d.scale), d.position.copy(e.position), f.ri.vadd(d.position, d.position); u.hideCached(); Q.restart(); if (r.axes) for (a = 0; a < v.length; a++) e = v[a], d = Q.request(), d.position.copy(e.position), e.quaternion && d.quaternion.copy(e.quaternion); Q.hideCached(); M.restart(); if (r.aabbs) for (c = 0; c < v.length; c++) e = v[c], e.computeAABB && (e.aabbNeedsUpdate && e.computeAABB(), isFinite(e.aabb.lowerBound.x) && isFinite(e.aabb.lowerBound.y) && isFinite(e.aabb.lowerBound.z) && isFinite(e.aabb.upperBound.x) && isFinite(e.aabb.upperBound.y) && isFinite(e.aabb.upperBound.z) && 0 != e.aabb.lowerBound.x - e.aabb.upperBound.x && 0 != e.aabb.lowerBound.y - e.aabb.upperBound.y && 0 != e.aabb.lowerBound.z - e.aabb.upperBound.z && (d = M.request(), d.scale.set(e.aabb.lowerBound.x - e.aabb.upperBound.x, e.aabb.lowerBound.y - e.aabb.upperBound.y, e.aabb.lowerBound.z - e.aabb.upperBound.z), d.position.set(.5 * (e.aabb.lowerBound.x + e.aabb.upperBound.x), .5 * (e.aabb.lowerBound.y + e.aabb.upperBound.y), .5 * (e.aabb.lowerBound.z + e.aabb.upperBound.z)))); M.hideCached() } function a() { requestAnimationFrame(a); r.paused || c(); h(); K.update() } function q(a) { mouseX = a.clientX - Y; mouseY = a.clientY - W } function p(a) { D = s_iCanvasResizeWidth + 2 * s_iCanvasOffsetWidth; V = s_iCanvasResizeHeight + 2 * s_iCanvasOffsetHeight; CAMERA_TEST_TRACKBALL && (controls.screen.width = D, controls.screen.height = V) } function h() { (CAMERA_TEST_TRACKBALL || CAMERA_TEST_TRANSFORM && null !== controls) && controls.update(); renderer.clear(); renderer.render(m.scene, camera) } function k(a) { m.dispatchEvent({ type: "destroy" }); r.paused = !1; d(); f(a) } function f(a) { for (var b = y.length, c = 0; c < b; c++) { E.remove(v.pop()); var e = y.pop(); m.scene.remove(e) } for (; E.constraints.length;) E.removeConstraint(E.constraints[0]); B[a](); r.iterations = E.solver.iterations; r.gx = E.gravity.x + 0; r.gy = E.gravity.y + 0; r.gz = E.gravity.z + 0; r.quatNormalizeSkip = E.quatNormalizeSkip; r.quatNormalizeFast = E.quatNormalizeFast; d(); R.restart(); R.hideCached(); P.restart(); P.hideCached(); O.restart(); O.hideCached(); u.restart(); u.hideCached() } function e(a) { var b = [], c = []; this.request = function() { geo = b.length ? b.pop() : a(); scene.add(geo); c.push(geo); return geo }; this.restart = function() { for (; c.length;) b.push(c.pop()) }; this.hideCached = function() { for (var a = 0; a < b.length; a++) scene.remove(b[a]) } } var m = this; this.addScene = function(a, b) { if ("string" !== typeof a) throw Error("1st argument of Demo.addScene(title,initfunc) must be a string!"); if ("function" !== typeof b) throw Error("2nd argument of Demo.addScene(title,initfunc) must be a function!"); B.push(b); var c = B.length - 1; G[a] = function() { k(c) }; t.add(G, a) }; this.restartCurrentScene = l; this.changeScene = k; this.start = function() { f(0) }; var t, r = this.settings = { stepFrequency: 60, quatNormalizeSkip: 2, quatNormalizeFast: !0, gx: 0, gy: 0, gz: 0, iterations: 3, tolerance: 1E-4, k: 1E6, d: 3, scene: 0, paused: !1, rendermode: "solid", constraints: !1, contacts: !1, cm2contact: !1, normals: !1, axes: !1, particleSize: .1, shadows: !1, aabbs: !1, profiling: !1, maxSubSteps: 3 }; n = n || {}; for (var w in n) w in r && (r[w] = n[w]); if (0 !== r.stepFrequency % 60) throw Error("stepFrequency must be a multiple of 60."); var v = this.bodies = [], y = this.visuals = [], B = [], C = null, A = null, x = null, G = {}, N = new THREE.SphereGeometry(.1, 6, 6); this.particleGeo = new THREE.SphereGeometry(1, 16, 8); var H = new THREE.MeshPhongMaterial({ color: 11184810, specular: 1118481, shininess: 50 }), S = new THREE.MeshLambertMaterial({ color: 16777215, wireframe: !0 }); this.currentMaterial = H; var U = new THREE.MeshPhongMaterial({ color: 16711680 }); this.particleMaterial = new THREE.MeshLambertMaterial({ color: 16711680 }); var R = new e(function() { return new THREE.Mesh(N, U) }), P = new e(function() { var a = new THREE.Geometry; a.vertices.push(new THREE.Vector3(0, 0, 0)); a.vertices.push(new THREE.Vector3(1, 1, 1)); return new THREE.Line(a, new THREE.LineBasicMaterial({ color: 16711680 })) }), J = new THREE.BoxGeometry(1, 1, 1), L = new THREE.MeshBasicMaterial({ color: 11184810, wireframe: !0 }), M = new e(function() { return new THREE.Mesh(J, L) }), O = new e(function() { var a = new THREE.Geometry; a.vertices.push(new THREE.Vector3(0, 0, 0)); a.vertices.push(new THREE.Vector3(1, 1, 1)); return new THREE.Line(a, new THREE.LineBasicMaterial({ color: 16711680 })) }), X = new e(function() { var a = new THREE.Geometry; a.vertices.push(new THREE.Vector3(0, 0, 0)); a.vertices.push(new THREE.Vector3(1, 1, 1)); return new THREE.Line(a, new THREE.LineBasicMaterial({ color: 16711680 })) }), u = new e(function() { var a = new THREE.Geometry; a.vertices.push(new THREE.Vector3(0, 0, 0)); a.vertices.push(new THREE.Vector3(1, 1, 1)); return new THREE.Line(a, new THREE.LineBasicMaterial({ color: 65280 })) }), Q = new e(function() { var a = new THREE.Object3D, b = new THREE.Vector3(0, 0, 0), c = new THREE.Geometry, e = new THREE.Geometry, d = new THREE.Geometry; c.vertices.push(b); e.vertices.push(b); d.vertices.push(b); c.vertices.push(new THREE.Vector3(1, 0, 0)); e.vertices.push(new THREE.Vector3(0, 1, 0)); d.vertices.push(new THREE.Vector3(0, 0, 1)); b = new THREE.Line(c, new THREE.LineBasicMaterial({ color: 16711680 })); e = new THREE.Line(e, new THREE.LineBasicMaterial({ color: 65280 })); d = new THREE.Line(d, new THREE.LineBasicMaterial({ color: 255 })); a.add(b); a.add(e); a.add(d); return a }), E = this.world = new CANNON.World; E.broadphase = new CANNON.NaiveBroadphase; var T = ["solid", "wireframe"], I, F, K, z; Detector.webgl || Detector.addGetWebGLMessage(); var D = s_iCanvasResizeWidth + s_iCanvasOffsetWidth, V = s_iCanvasResizeHeight + s_iCanvasOffsetHeight, aa, Y = D / 2, W = V / 2; (function() { aa = document.createElement("div"); document.body.appendChild(aa); CAMERA_TEST_TRACKBALL ? (NEAR = 5, camera = new THREE.PerspectiveCamera(45, D / V, NEAR, FAR), camera.lookAt(new THREE.Vector3(CAMERA_TEST_LOOK_AT.x, CAMERA_TEST_LOOK_AT.y, CAMERA_TEST_LOOK_AT.z)), camera.position.set(0, 500, 500), camera.up.set(0, 0, 1)) : camera = createOrthoGraphicCamera(); scene = m.scene = new THREE.Scene; scene.fog = new THREE.Fog(8306926, .5 * FAR, FAR); F = new THREE.AmbientLight(4473924); scene.add(F); I = new THREE.DirectionalLight(16777164, 1); I.position.set(180, 0, 180); I.target.position.set(0, 0, 0); I.castShadow = !0; I.shadow.camera.near = 10; I.shadow.camera.far = 100; I.shadow.camera.fov = 30; I.shadowMapBias = .0139; I.shadowMapDarkness = .1; I.shadow.mapSize.width = 1024; I.shadow.mapSize.height = 1024; scene.add(I); scene.add(camera); renderer = SHOW_3D_RENDER ? new THREE.WebGLRenderer({ clearColor: 0, clearAlpha: .5, antialias: !0, alpha: !0 }) : new THREE.CanvasRenderer({ clearColor: 0, clearAlpha: .5, antialias: !1, alpha: !0 }); renderer.setSize(D, V); renderer.domElement.style.position = "relative"; renderer.domElement.style.top = "0px"; renderer.domElement.style.opacity = OPACITY_INTENSITY_3D; aa.appendChild(renderer.domElement); z = document.createElement("div"); z.style.position = "absolute"; z.style.top = "10px"; z.style.width = "100%"; z.style.textAlign = "center"; z.innerHTML = '<a href="http://github.com/schteppe/cannon.js">cannon.js</a> - javascript 3d physics'; aa.appendChild(z); document.addEventListener("mousemove", q); window.addEventListener("resize", p); renderer.setClearColor(scene.fog.color, 1); renderer.autoClear = !1; x = document.createElement("canvas"); x.width = D; x.height = V; x.style.opacity = .5; x.style.position = "absolute"; x.style.top = "0px"; x.style.zIndex = 90; aa.appendChild(x); A = new SmoothieChart({ labelOffsetY: 50, maxDataSetLength: 100, millisPerPixel: 2, grid: { strokeStyle: "none", fillStyle: "none", lineWidth: 1, millisPerLine: 250, verticalSections: 6 }, labels: { fillStyle: "rgb(180, 180, 180)" } }); A.streamTo(x); var a = {}, b = [ [255, 0, 0], [0, 255, 0], [0, 0, 255], [255, 255, 0], [255, 0, 255], [0, 255, 255] ], c = 0, e; for (e in E.profile) { var d = b[c % b.length]; a[e] = new TimeSeries({ label: e, fillStyle: "rgb(" + d[0] + "," + d[1] + "," + d[2] + ")", maxDataLength: 500 }); c++ } E.addEventListener("postStep", function(b) { for (var c in E.profile) a[c].append(1E3 * E.time, E.profile[c]) }); c = 0; for (e in E.profile) d = b[c % b.length], A.addTimeSeries(a[e], { strokeStyle: "rgb(" + d[0] + "," + d[1] + "," + d[2] + ")", lineWidth: 2 }), c++; E.doProfiling = !1; A.stop(); x.style.display = "none"; K = new Stats; K.domElement.style.position = "absolute"; K.domElement.style.top = "0px"; K.domElement.style.zIndex = 100; aa.appendChild(K.domElement); void 0 != window.dat && (C = new dat.GUI, C.domElement.parentNode.style.zIndex = 120, b = C.addFolder("Rendering"), b.add(r, "rendermode", { Solid: "solid", Wireframe: "wireframe" }).onChange(function(a) { g(a) }), b.add(r, "contacts"), b.add(r, "cm2contact"), b.add(r, "normals"), b.add(r, "constraints"), b.add(r, "axes"), b.add(r, "particleSize").min(0).max(1).onChange(function(a) { for (var b = 0; b < y.length; b++) v[b] instanceof CANNON.Particle && y[b].scale.set(a, a, a) }), b.add(r, "shadows").onChange(function(a) { a ? renderer.shadowMapAutoUpdate = !0 : (renderer.shadowMapAutoUpdate = !1, renderer.clearTarget(I.shadowMap)) }), b.add(r, "aabbs"), b.add(r, "profiling").onChange(function(a) { a ? (E.doProfiling = !0, A.start(), x.style.display = "block") : (E.doProfiling = !1, A.stop(), x.style.display = "none") }), b = C.addFolder("World"), b.add(r, "paused").onChange(function(a) {}), b.add(r, "stepFrequency", 60, 600).step(60), b.add(r, "gx", -100, 100).onChange(function(a) { isNaN(a) || E.gravity.set(a, r.gy, r.gz) }), b.add(r, "gy", -100, 100).onChange(function(a) { isNaN(a) || E.gravity.set(r.gx, a, r.gz) }), b.add(r, "gz", -100, 100).onChange(function(a) { isNaN(a) || E.gravity.set(r.gx, r.gy, a) }), b.add(r, "quatNormalizeSkip", 0, 50).step(1).onChange(function(a) { isNaN(a) || (E.quatNormalizeSkip = a) }), b.add(r, "quatNormalizeFast").onChange(function(a) { E.quatNormalizeFast = !!a }), b = C.addFolder("Solver"), b.add(r, "iterations", 1, 50).step(1).onChange(function(a) { E.solver.iterations = a }), b.add(r, "k", 10, 1E7).onChange(function(a) { m.setGlobalSpookParams(r.k, r.d, 1 / r.stepFrequency) }), b.add(r, "d", 0, 20).step(.1).onChange(function(a) { m.setGlobalSpookParams(r.k, r.d, 1 / r.stepFrequency) }), b.add(r, "tolerance", 0, 10).step(.01).onChange(function(a) { E.solver.tolerance = a }), t = C.addFolder("Scenes"), t.open()); CAMERA_TEST_TRACKBALL && (controls = new THREE.TrackballControls(camera, renderer.domElement), controls.rotateSpeed = 1, controls.zoomSpeed = 1.2, controls.panSpeed = .2, controls.noZoom = !1, controls.noPan = !1, controls.staticMoving = !1, controls.dynamicDampingFactor = .3, controls.minDistance = 0, controls.maxDistance = 1E5, controls.keys = [65, 83, 68], controls.screen.width = D, controls.screen.height = V) })(); a(); s_oRender = h; document.addEventListener("keypress", function(a) { if (a.keyCode) switch (a.keyCode) { case 32: l(); break; case 104: "none" == K.domElement.style.display ? (K.domElement.style.display = "block", z.style.display = "block") : (K.domElement.style.display = "none", z.style.display = "none"); break; case 97: r.aabbs = !r.aabbs; d(); break; case 99: r.constraints = !r.constraints; d(); break; case 112: r.paused = !r.paused; d(); break; case 115: E.step(1 / r.stepFrequency); c(); break; case 109: a = T.indexOf(r.rendermode); a++; a %= T.length; g(T[a]); d(); break; case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: B.length > a.keyCode - 49 && !document.activeElement.localName.match(/input/) && k(a.keyCode - 49) } }) }; CANNON.Demo.prototype = new CANNON.EventTarget; CANNON.Demo.constructor = CANNON.Demo; CANNON.Demo.prototype.setGlobalSpookParams = function(n, d, g) { for (var l = this.world, b = 0; b < l.constraints.length; b++) for (var c = l.constraints[b], a = 0; a < c.equations.length; a++) c.equations[a].setSpookParams(n, d, g); for (b = 0; b < l.contactmaterials.length; b++) g = l.contactmaterials[b], g.contactEquationStiffness = n, g.frictionEquationStiffness = n, g.contactEquationRelaxation = d, g.frictionEquationRelaxation = d; l.defaultContactMaterial.contactEquationStiffness = n; l.defaultContactMaterial.frictionEquationStiffness = n; l.defaultContactMaterial.contactEquationRelaxation = d; l.defaultContactMaterial.frictionEquationRelaxation = d }; CANNON.Demo.prototype.createTransformControl = function(n, d) { controls = new THREE.TransformControls(camera, renderer.domElement); scene.add(n); controls.attach(n, d); scene.add(controls); console.log("CREATE"); window.addEventListener("keydown", function(d) { switch (d.keyCode) { case 81: controls.setSpace("local" === controls.space ? "world" : "local"); break; case 17: controls.setTranslationSnap(100); controls.setRotationSnap(THREE.Math.degToRad(15)); break; case 87: controls.setMode("translate"); break; case 69: controls.setMode("rotate"); break; case 82: controls.setMode("scale"); break; case 187: case 107: controls.setSize(controls.size + .1); break; case 189: case 109: controls.setSize(Math.max(controls.size - .1, .1)) } }); window.addEventListener("keyup", function(d) { switch (d.keyCode) { case 17: controls.setTranslationSnap(null), controls.setRotationSnap(null) } }) }; CANNON.Demo.prototype.getWorld = function() { return this.world }; CANNON.Demo.prototype.addVisual = function(n, d) { var g; n instanceof CANNON.Body && (g = this.shape2mesh(n, d)); g && (this.bodies.push(n), this.visuals.push(g), n.visualref = g, n.visualref.visualId = this.bodies.length - 1, this.scene.add(g)); return g }; CANNON.Demo.prototype.addVisuals = function(n) { for (var d = 0; d < n.length; d++) this.addVisual(n[d]) }; CANNON.Demo.prototype.removeVisual = function(n) { if (n.visualref) { for (var d = this.bodies, g = this.visuals, l = [], b = [], c = d.length, a = 0; a < c; a++) l.unshift(d.pop()), b.unshift(g.pop()); c = n.visualref.visualId; for (var q = 0; q < l.length; q++) q !== c && (a = q > c ? q - 1 : q, d[a] = l[q], g[a] = b[q], d[a].visualref = l[q].visualref, d[a].visualref.visualId = a); n.visualref.visualId = null; this.scene.remove(n.visualref); n.visualref = null } }; CANNON.Demo.prototype.removeAllVisuals = function() { for (; this.bodies.length;) this.removeVisual(this.bodies[0]) }; CANNON.Demo.prototype.shape2mesh = function(n, d) { for (var g = new THREE.Object3D, l = 0; l < n.shapes.length; l++) { var b = n.shapes[l]; switch (b.type) { case CANNON.Shape.types.SPHERE: var c = new THREE.SphereGeometry(b.radius, 8, 8); b = void 0 === d ? new THREE.Mesh(c, this.currentMaterial) : new THREE.Mesh(c, d); b.castShadow = !0; break; case CANNON.Shape.types.PARTICLE: b = new THREE.Mesh(this.particleGeo, this.particleMaterial); c = this.settings; b.scale.set(c.particleSize, c.particleSize, c.particleSize); break; case CANNON.Shape.types.PLANE: var a = new THREE.PlaneGeometry(10, 10, 4, 4); b = new THREE.Object3D; c = new THREE.Object3D; a = void 0 === d ? new THREE.Mesh(a, this.currentMaterial) : new THREE.Mesh(a, d); a.scale.set(100, 100, 100); c.add(a); a.castShadow = !1; a.receiveShadow = !0; b.add(c); break; case CANNON.Shape.types.BOX: c = new THREE.BoxGeometry(2 * b.halfExtents.x, 2 * b.halfExtents.y, 2 * b.halfExtents.z); b = void 0 === d ? new THREE.Mesh(c, this.currentMaterial) : new THREE.Mesh(c, d); break; case CANNON.Shape.types.CONVEXPOLYHEDRON: a = new THREE.Geometry; for (c = 0; c < b.vertices.length; c++) { var q = b.vertices[c]; a.vertices.push(new THREE.Vector3(q.x, q.y, q.z)) } for (c = 0; c < b.faces.length; c++) { var p = b.faces[c], h = p[0]; for (q = 1; q < p.length - 1; q++) a.faces.push(new THREE.Face3(h, p[q], p[q + 1])) } a.computeBoundingSphere(); a.computeFaceNormals(); b = void 0 === d ? new THREE.Mesh(a, this.currentMaterial) : new THREE.Mesh(a, d); break; case CANNON.Shape.types.HEIGHTFIELD: a = new THREE.Geometry; p = new CANNON.Vec3; h = new CANNON.Vec3; var k = new CANNON.Vec3; for (q = 0; q < b.data.length - 1; q++) for (var f = 0; f < b.data[q].length - 1; f++) for (var e = 0; 2 > e; e++) b.getConvexTrianglePillar(q, f, 0 === e), p.copy(b.pillarConvex.vertices[0]), h.copy(b.pillarConvex.vertices[1]), k.copy(b.pillarConvex.vertices[2]), p.vadd(b.pillarOffset, p), h.vadd(b.pillarOffset, h), k.vadd(b.pillarOffset, k), a.vertices.push(new THREE.Vector3(p.x, p.y, p.z), new THREE.Vector3(h.x, h.y, h.z), new THREE.Vector3(k.x, k.y, k.z)), c = a.vertices.length - 3, a.faces.push(new THREE.Face3(c, c + 1, c + 2)); a.computeBoundingSphere(); a.computeFaceNormals(); b = void 0 === d ? new THREE.Mesh(a, this.currentMaterial) : new THREE.Mesh(a, d); break; case CANNON.Shape.types.TRIMESH: a = new THREE.Geometry; p = new CANNON.Vec3; h = new CANNON.Vec3; k = new CANNON.Vec3; for (c = 0; c < b.indices.length / 3; c++) b.getTriangleVertices(c, p, h, k), a.vertices.push(new THREE.Vector3(p.x, p.y, p.z), new THREE.Vector3(h.x, h.y, h.z), new THREE.Vector3(k.x, k.y, k.z)), q = a.vertices.length - 3, a.faces.push(new THREE.Face3(q, q + 1, q + 2)); a.computeBoundingSphere(); a.computeFaceNormals(); b = void 0 === d ? new THREE.Mesh(a, this.currentMaterial) : new THREE.Mesh(a, d); break; default: throw "Visual type not recognized: " + b.type; } b.receiveShadow = !0; b.castShadow = !0; if (b.children) for (c = 0; c < b.children.length; c++) if (b.children[c].castShadow = !0, b.children[c].receiveShadow = !0, b.children[c]) for (q = 0; q < b.children[c].length; q++) b.children[c].children[q].castShadow = !0, b.children[c].children[q].receiveShadow = !0; c = n.shapeOffsets[l]; a = n.shapeOrientations[l]; b.position.set(c.x, c.y, c.z); b.quaternion.set(a.x, a.y, a.z, a.w); g.add(b) } this.camera = function() { return camera }; this.getScene = function() { return scene }; return g }; function CBall(n, d, g, l, b) { var c, a, q, p, h = null, k = !1; this._init = function(b, d, f) { p = new createjs.Container; e.addChild(p); c = createBitmap(f); c.x = b; c.y = d; c.regX = .5 * f.width; c.regY = .5 * f.height; f = s_oSpriteLibrary.getSprite("ball_ref"); a = createBitmap(f); a.x = b; a.y = d; a.regX = .5 * f.width; a.regY = .5 * -f.height + 15; a.alpha = .75; f = s_oSpriteLibrary.getSprite("ball_shadow"); q = createBitmap(f); q.x = b; q.y = d; q.regX = .5 * f.width; q.regY = .5 * f.height; p.addChild(q, c, a) }; this.unload = function() { c.removeAllEventListeners(); e.removeChild(c) }; this.setVisible = function(a) { p.visible = a }; this.startPosShadowY = function(a) { h = a }; this.getStartShadowYPos = function() { return h }; this.tweenFade = function(a, b, c) { createjs.Tween.get(p).wait(c).to({ alpha: a }, b).call(function() {}) }; this.playSound = function() { k || (playSound("ball_crash", 1, !1), k = !0) }; this.setPlayedSound = function(a) { k = a }; this.animFade = function(a) { createjs.Tween.get(p).to({ alpha: a }, 250, createjs.Ease.circleOut).call(function() { 0 === a && (p.visible = !1, p.alpha = 1, s_oGame.resetBallPosition()) }) }; this.setPositionShadow = function(a, b) { q.x = a; q.y = b }; this.setPosition = function(b, e) { a.x = c.x = b; a.y = c.y = e }; this.getPhysics = function() { return f }; this.setAngle = function(b) { a.rotation = c.rotation = b }; this.getX = function() { return c.x }; this.getY = function() { return c.y }; this.getStartScale = function() { return 36 }; this.scale = function(b) { a.scaleX = c.scaleX = b; a.scaleY = c.scaleY = b }; this.scaleShadow = function(a) { .08 < a ? (q.scaleX = a, q.scaleY = a) : (q.scaleX = .08, q.scaleY = .08) }; this.setAlphaByHeight = function(a) { q.alpha = a }; this.getScale = function() { return c.scaleX }; this.getObject = function() { return p }; this.getDepthPos = function() { return f.position.y }; var f = l; var e = b; this._init(n, d, g); return this } function CScenario() { var n, d, g, l, b, c, a, q, p, h, k, f, e, m, t, r, w, v, y, B; if (SHOW_3D_RENDER) var C = new CANNON.Demo; this.getDemo = function() { return C }; this._init = function() { y = []; B = []; n = SHOW_3D_RENDER ? C.getWorld() : new CANNON.World; var a = new CANNON.GSSolver; a.iterations = 10; a.tolerance = 1E-4; n.allowSleep = !0; n.gravity.set(0, 0, -(19.52 * STEP_RATE)); n.broadphase = new CANNON.NaiveBroadphase; n.solver = new CANNON.SplitSolver(a, 20, 1E-4); d = new CANNON.Material; g = new CANNON.Material; l = new CANNON.Material; b = new CANNON.Material; a = new CANNON.ContactMaterial(g, l, { friction: .1, restitution: .1 }); var c = new CANNON.ContactMaterial(g, d, { friction: .01, restitution: .1 }), e = new CANNON.ContactMaterial(g, b, { friction: .1, restitution: .3 }), f = new CANNON.ContactMaterial(d, b, { friction: .2, restitution: .3 }), h = new CANNON.ContactMaterial(b, b, { friction: .01, restitution: .1 }), k = new CANNON.ContactMaterial(b, l, { friction: .01, restitution: .1 }); n.addContactMaterial(a); n.addContactMaterial(c); n.addContactMaterial(e); n.addContactMaterial(f); n.addContactMaterial(h); n.addContactMaterial(k); s_oScenario._createBallBody(); for (a = 0; a < PINS_POSITION.length; a++) y[a] = s_oScenario.createPin(PINS_POSITION[a], a, !1); s_oScenario.importFBXTrack(); s_oScenario.createWallPins(); s_oScenario.createFloorPins(); s_oScenario.createPinsBinder(); s_oScenario.createWallFloorPins(); s_oScenario.createSideWallTrack(); s_oScenario.createSensorPinFloor(); SHOW_DEPTH_TRACK_MODEL && s_oScenario.createDepthTrack(); PIN_TEST && y.push(s_oScenario.createPin(PINS_PROPERTIES_TEST, -1, !0)); B.push(s_oScenario.createAFloorSidePins({ x: FLOOR_PINS_POSITION.x + (FLOOR_PINS_SIZE.width + FLOOR_PINS_SIDE_PROPERTIES.width - 2.7), y: FLOOR_PINS_POSITION.y, z: FLOOR_PINS_POSITION.z + FLOOR_PINS_SIZE.height - 9 }, FLOOR_PINS_SIDE_PROPERTIES.rot)); B.push(s_oScenario.createAFloorSidePins({ x: FLOOR_PINS_POSITION.x + (-FLOOR_PINS_SIZE.width - FLOOR_PINS_SIDE_PROPERTIES.width + 2.7), y: FLOOR_PINS_POSITION.y, z: FLOOR_PINS_POSITION.z + FLOOR_PINS_SIZE.height - 9 }, -FLOOR_PINS_SIDE_PROPERTIES.rot)) }; this.importFBXTrack = function() { var a = new THREE.LoadingManager; a.onProgress = function(a, b, c) { console.log(a, b, c) }; (new THREE.FBXLoader(a)).load("models/stage.txt", function(a) { s_oScenario.parseFile(a); s_oGame.ballPosition(); s_oGame.startPinsPosition() }, function(a) { a.lengthComputable && console.log(Math.round(a.loaded / a.total * 100, 2) + "% downloaded") }, function(a) {}) }; this.parseFile = function(a) { for (var b = 0; b < a.children.length; b++) { var c = a.children[b]; console.log("oMesh.name: " + c.name); "floor" === c.name ? (p = s_oScenario._createFieldBody(c, FLOOR), p.addEventListener("collide", function(a) { s_oScenario.floorCollision(a) })) : "channel_left" === c.name ? (h = s_oScenario._createFieldBody(c, CHANNEL), h.addEventListener("collide", function(a) { s_oScenario.channelCollision(a) })) : "channel_right" === c.name && (k = s_oScenario._createFieldBody(c, CHANNEL), k.addEventListener("collide", function(a) { s_oScenario.channelCollision(a) })) } }; this.createSensorPinFloor = function() { var a = new CANNON.Box(new CANNON.Vec3(SENSOR_SIZE.width, SENSOR_SIZE.depth, SENSOR_SIZE.height)); v = new CANNON.Body({ mass: 0, material: l, userData: { type: WALL } }); v.addShape(a); v.addEventListener("collide", function(a) { s_oScenario.sensorCollision(a) }); v.position.set(SENSOR_POSITION.x, SENSOR_POSITION.y, SENSOR_POSITION.z); n.addBody(v); SHOW_3D_RENDER && (a = new THREE.MeshPhongMaterial({ color: 5570645, specular: 1118481, shininess: 50 }), C.addVisual(v, a)) }; this.createAFloorSidePins = function(a, b) { var c = new CANNON.Box(new CANNON.Vec3(FLOOR_PINS_SIDE_PROPERTIES.width, FLOOR_PINS_SIDE_PROPERTIES.depth, FLOOR_PINS_SIDE_PROPERTIES.height)); var e = new CANNON.Body({ mass: 0, material: d, userData: { type: PINS_FLOOR }, collisionFilterGroup: PINS_FLOOR, collisionFilterMask: PINS }); e.addShape(c); e.quaternion.y = b; e.position.set(a.x, a.y, a.z); e.addEventListener("collide", function(a) { s_oScenario.sideWallCollision(a) }); n.addBody(e); SHOW_3D_RENDER && SHOW_PROXY_COLLISION && (c = new THREE.MeshPhongMaterial({ color: 34816, specular: 1118481, shininess: 50 }), C.addVisual(e, c)); return e }; this.createDepthTrack = function() { var a = new CANNON.Box(new CANNON.Vec3(WALL_TRACK_DEPTH_SIZE.width, WALL_TRACK_DEPTH_SIZE.depth, WALL_TRACK_DEPTH_SIZE.height)); t = new CANNON.Body({ mass: 0, material: l }); t.collisionResponse = 0; t.addShape(a); t.position.set(WALL_TRACK_DEPTH_POSITION.x, WALL_TRACK_DEPTH_POSITION.y, WALL_TRACK_DEPTH_POSITION.z); n.addBody(t); SHOW_3D_RENDER && (a = new THREE.MeshPhongMaterial({ color: 8947712, specular: 1118481, shininess: 50 }), C.addVisual(t, a)) }; this.createFloorPins = function() { var a = new CANNON.Box(new CANNON.Vec3(FLOOR_PINS_SIZE.width, FLOOR_PINS_SIZE.depth, FLOOR_PINS_SIZE.height)); f = new CANNON.Body({ mass: 0, material: d, userData: { type: PINS_FLOOR }, collisionFilterGroup: PINS_FLOOR, collisionFilterMask: PINS }); f.addShape(a); f.position.set(FLOOR_PINS_POSITION.x, FLOOR_PINS_POSITION.y, FLOOR_PINS_POSITION.z); n.addBody(f); SHOW_3D_RENDER && SHOW_PROXY_COLLISION && (a = new THREE.MeshPhongMaterial({ color: 136, specular: 1118481, shininess: 50 }), C.addVisual(f, a)) }; this.createWallFloorPins = function() { var a = new CANNON.Box(new CANNON.Vec3(FLOOR_WALL_PINS_SIZE.width, FLOOR_WALL_PINS_SIZE.depth, FLOOR_WALL_PINS_SIZE.height)); e = new CANNON.Body({ mass: 0, material: d, userData: { type: PINS_FLOOR }, collisionFilterGroup: PINS_FLOOR, collisionFilterMask: PINS }); e.addShape(a); e.position.set(FLOOR_WALL_PINS_POSITION.x, FLOOR_WALL_PINS_POSITION.y, FLOOR_WALL_PINS_POSITION.z); n.addBody(e); SHOW_3D_RENDER && SHOW_PROXY_COLLISION && (a = new THREE.MeshPhongMaterial({ color: 8912896, specular: 16776960, shininess: 10 }), C.addVisual(e, a)) }; this.createPinsBinder = function() { var a = new CANNON.Box(new CANNON.Vec3(PINS_BINDER_PROPERTIES.width, PINS_BINDER_PROPERTIES.depth, PINS_BINDER_PROPERTIES.height)); r = new CANNON.Body({ mass: 0, material: l, userData: { type: PINS_FLOOR }, collisionFilterGroup: PINS_FLOOR, collisionFilterMask: PINS, fixedRotation: !0, allowSleep: !1, sleepTimeLimit: 1 }); r.addShape(a); r.position.set(PINS_BINDER_POSITION.x, PINS_BINDER_POSITION.y, PINS_BINDER_POSITION.z); n.addBody(r); r.collisionResponse = 0; SHOW_3D_RENDER && (a = new THREE.MeshPhongMaterial({ color: 5592405, specular: 1118481, shininess: 50 }), C.addVisual(r, a)) }; this._createFieldBody = function(a, b) { var c = this.__extractMeshData(a), e = new CANNON.Body({ mass: 0, material: d, userData: { type: b } }); e.addShape(c); c = new CANNON.Vec3(a.position.x + OFFSET_TRACK_POSITION.x, a.position.y + OFFSET_TRACK_POSITION.y, a.position.z + OFFSET_TRACK_POSITION.z); e.position.copy(c); n.addBody(e); SHOW_3D_RENDER && (c = new THREE.MeshPhongMaterial({ color: 14596231, specular: 0, shininess: 100 }), C.addVisual(e, c)); return e }; this.__extractMeshData = function(a) { var b = a.geometry.faces; a = a.geometry.vertices; for (var c = 0; c < b.length; c++); var e = [], d = []; for (c = 0; c < a.length; c++) e.push(1 * a[c].x), e.push(1 * a[c].y), e.push(1 * a[c].z); for (c = 0; c < b.length; c++) d.push(b[c].a), d.push(b[c].b), d.push(b[c].c); return new CANNON.Trimesh(e, d) }; this.createPin = function(a, c, e) { var d = new CANNON.Cylinder(PIN_PROPERTY.radius_top, PIN_PROPERTY.radius_bottom, PIN_PROPERTY.height, PIN_PROPERTY.segments); c = new CANNON.Body({ mass: PIN_PROPERTY.mass, material: b, linearDamping: PIN_PROPERTY.linearDamping, angularDamping: PIN_PROPERTY.angularDamping, userData: { type: PINS, id: c }, collisionFilterGroup: PINS, collisionFilterMask: -1, allowSleep: !0, sleepTimeLimit: 1 }); c.addShape(d); c.position.set(a.x, a.y, a.z); c.addEventListener("collide", function(a) { s_oScenario.pinCollision(a) }); n.addBody(c); SHOW_3D_RENDER && (a = new THREE.MeshPhongMaterial({ color: 16777215, specular: 1118481, shininess: 100 }), a = C.addVisual(c, a), e && CAMERA_TEST_TRANSFORM && !CAMERA_TEST_TRACKBALL && C.createTransformControl(a, c)); return c }; this.createWallPins = function() { var a = new CANNON.Box(new CANNON.Vec3(WALL_PINS_SIZE.width, WALL_PINS_SIZE.depth, WALL_PINS_SIZE.height)), b = new CANNON.Box(new CANNON.Vec3(SIDE_WALL_PINS_SIZE.width, SIDE_WALL_PINS_SIZE.depth, SIDE_WALL_PINS_SIZE.height)), c = new CANNON.Box(new CANNON.Vec3(WALL_PINS_DOWN_SIZE.width, WALL_PINS_DOWN_SIZE.depth, WALL_PINS_DOWN_SIZE.height)), e = new CANNON.Box(new CANNON.Vec3(WALL_PINS_FORWARD_SIZE.width, WALL_PINS_FORWARD_SIZE.depth, WALL_PINS_FORWARD_SIZE.height)); m = new CANNON.Body({ mass: 0, material: l, userData: { type: WALL } }); m.addShape(a); m.addShape(b, new CANNON.Vec3(WALL_PINS_SIZE.width, SIDE_WALL_PINS_SIZE.depth, 0)); m.addShape(b, new CANNON.Vec3(-WALL_PINS_SIZE.width, SIDE_WALL_PINS_SIZE.depth, 0)); m.addShape(c, new CANNON.Vec3(0, SIDE_WALL_PINS_SIZE.depth, -SIDE_WALL_PINS_SIZE.height)); m.addShape(e, new CANNON.Vec3(0, 2 * WALL_PINS_DOWN_SIZE.depth, -WALL_PINS_SIZE.height + WALL_PINS_FORWARD_SIZE.height)); m.addShape(c, new CANNON.Vec3(0, SIDE_WALL_PINS_SIZE.depth, .9 * WALL_PINS_SIZE.height)); m.addEventListener("collide", function(a) { s_oScenario.wallCollision(a) }); m.position.set(WALL_PINS_POSITION.x, WALL_PINS_POSITION.y, WALL_PINS_POSITION.z); n.addBody(m); SHOW_3D_RENDER && (a = new THREE.MeshPhongMaterial({ color: 3355443, specular: 1118481, shininess: 50 }), C.addVisual(m, a)) }; this.createSideWallTrack = function() { var a = new CANNON.Box(new CANNON.Vec3(WALL_TRACK_SIZE.width, WALL_TRACK_SIZE.depth, WALL_TRACK_SIZE.height)), b = new CANNON.Box(new CANNON.Vec3(ROOF_TRACK_SIZE.width, ROOF_TRACK_SIZE.depth, ROOF_TRACK_SIZE.height)); w = new CANNON.Body({ mass: 0, material: l, userData: { type: WALL_TRACK } }); w.addShape(a, new CANNON.Vec3(WALL_TRACK_SIZE.offsetX, 0, 0)); w.addShape(a, new CANNON.Vec3(-WALL_TRACK_SIZE.offsetX, 0, 0)); w.addShape(b, new CANNON.Vec3(0, ROOF_TRACK_SIZE.offsetY, .85 * WALL_TRACK_SIZE.height)); w.position.set(WALL_TRACK_POSITION.x, WALL_TRACK_POSITION.y, WALL_TRACK_POSITION.z); n.addBody(w); SHOW_3D_RENDER && SHOW_PROXY_COLLISION && (a = new THREE.MeshPhongMaterial({ color: 11184810, specular: 16777215, shininess: 15 }), C.addVisual(w, a)) }; this._createBallBody = function() { c = new CANNON.Sphere(BALL_RADIUS); a = new CANNON.Body({ mass: BALL_PROPERTY.mass, material: g, linearDamping: BALL_PROPERTY.linearDamping, allowSleep: !1, angularDamping: BALL_PROPERTY.angularDamping, userData: { type: BALL } }); var b = new CANNON.Vec3(POSITION_BALL.x, POSITION_BALL.y, POSITION_BALL.z); a.position.copy(b); a.addEventListener("collide", function(a) { s_oScenario.ballCollision(a) }); a.addShape(c); n.add(a); SHOW_3D_RENDER && (b = new THREE.MeshPhongMaterial({ color: 11184810, specular: 1118481, shininess: 100 }), q = C.addVisual(a, b)) }; this.addImpulse = function(a, b) { var c = new CANNON.Vec3(0, 0, BALL_RADIUS), e = new CANNON.Vec3(b.x, b.y, b.z); a.applyImpulse(e, c) }; this.addForce = function(a, b) { var c = new CANNON.Vec3(0, 0, 0), e = new CANNON.Vec3(b.x, b.y, b.z); a.applyForce(e, c) }; this.getBodyVelocity = function(a) { return a.velocity }; this.ballBody = function() { return a }; this.ballMesh = function() { return q }; this.ballCollision = function(a) { (a.contact.bi.userData.type === BALL && a.contact.bj.userData.type === PINS || a.contact.bj.userData.type === BALL && a.contact.bi.userData.type === PINS) && s_oGame.setPinCollide() }; this.getCamera = function() { return C.camera() }; this.floorCollision = function(a) { (a.contact.bi.userData.type === BALL && a.contact.bj.userData.type === FLOOR || a.contact.bj.userData.type === BALL && a.contact.bi.userData.type === FLOOR) && s_oGame.ballHitFloor() }; this.channelCollision = function(a) { (a.contact.bi.userData.type === BALL && a.contact.bj.userData.type === CHANNEL || a.contact.bj.userData.type === BALL && a.contact.bi.userData.type === CHANNEL) && s_oGame.gutterBall() }; this.getPinsBinder = function() { return r }; this.getPinByID = function(a) { return y[a] }; this.setElementAngularVelocity = function(a, b) { a.angularVelocity.set(b.x, b.y, b.z) }; this.setElementVelocity = function(a, b) { var c = new CANNON.Vec3(b.x, b.y, b.z); a.velocity = c }; this.setElementLinearDamping = function(a, b) { a.linearDamping = b }; this.getTrackBody = function() { return p }; this.getTrackBodyDepth = function() { return t }; this.update = function() { n.step(PHYSICS_STEP) }; this.resetPinsPosition = function() { for (var a = 0; a < y.length; a++) y[a].position.set(PINS_POSITION[a].x, PINS_POSITION[a].y, PINS_POSITION[a].z), y[a].quaternion.setFromEuler(0, 0, 0, "XYZ"), y[a].angularVelocity.set(0, 0, 0), y[a].velocity.set(0, 0, 0) }; this.getSideFloorPins = function(a) { return B[a] }; this.pinCollision = function(a) { a.contact.bi.userData.type === PINS && a.contact.bj.userData.type === BALL ? s_oGame.pinSoundCollision(a.contact.bi.userData.id) : a.contact.bj.userData.type === PINS && a.contact.bi.userData.type === BALL ? s_oGame.pinSoundCollision(a.contact.bj.userData.id) : a.contact.bj.userData.type === PINS && a.contact.bi.userData.type === PINS && s_oGame.twoPinsSoundCollision(a.contact.bj.userData.id, a.contact.bi.userData.id) }; this.sideWallCollision = function(a) { s_oGame.setPinDown(a.contact.bj.userData.id, !0, SIDE_PINS_FLOOR) }; this.sensorCollision = function(a) { a.contact.bj.sleep(); a.contact.bj.userData.type === PINS && s_oGame.setPinDown(a.contact.bj.userData.id, !0, SIDE_PINS_FLOOR) }; this.wallCollision = function(a) { a.contact.bi.userData.type === BALL && a.contact.bj.userData.type === WALL || a.contact.bj.userData.type === BALL && a.contact.bi.userData.type === WALL ? s_oGame.completeLaunch() : a.contact.bj.userData.type === PINS && a.contact.bi.userData.type === WALL && s_oGame.setPinDown(a.contact.bj.userData.id, !0, WALL) }; this.destroyWorld = function() { for (var a = n.bodies, b = 0; b < a.length; b++) n.remove(a[b]); n = null }; s_oScenario = this; SHOW_3D_RENDER ? (C.addScene("bowling", this._init), C.start()) : this._init() } var s_oScenario; Detector = { canvas: !!window.CanvasRenderingContext2D, webgl: function() { try { return !!window.WebGLRenderingContext && !!document.createElement("canvas").getContext("experimental-webgl") } catch (n) { return !1 } }(), workers: !!window.Worker, fileapi: window.File && window.FileReader && window.FileList && window.Blob, getWebGLErrorMessage: function() { var n = document.createElement("div"); n.id = "webgl-error-message"; n.style.fontFamily = "monospace"; n.style.fontSize = "13px"; n.style.fontWeight = "normal"; n.style.textAlign = "center"; n.style.background = "#fff"; n.style.color = "#000"; n.style.padding = "1.5em"; n.style.width = "400px"; n.style.margin = "5em auto 0"; this.webgl || (n.innerHTML = window.WebGLRenderingContext ? 'Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br />\nFind out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.' : 'Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br/>\nFind out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'); return n }, addGetWebGLMessage: function(n) { n = n || {}; var d = void 0 !== n.parent ? n.parent : document.body; n = void 0 !== n.id ? n.id : "oldie"; var g = Detector.getWebGLErrorMessage(); g.id = n; d.appendChild(g) } }; function TimeSeries(n) { n = n || {}; n.resetBoundsInterval = n.resetBoundsInterval || 3E3; n.resetBounds = void 0 === n.resetBounds ? !0 : n.resetBounds; this.options = n; this.data = []; this.label = n.label || ""; this.maxDataLength = n.maxDataLength || 1E3; this.dataPool = []; this.minValue = this.maxValue = Number.NaN; n.resetBounds && (this.boundsTimer = setInterval(function(d) { return function() { d.resetBounds() } }(this), n.resetBoundsInterval)) } TimeSeries.prototype.resetBounds = function() { this.minValue = this.maxValue = Number.NaN; for (var n = 0; n < this.data.length; n++) this.maxValue = isNaN(this.maxValue) ? this.data[n][1] : Math.max(this.maxValue, this.data[n][1]), this.minValue = isNaN(this.minValue) ? this.data[n][1] : Math.min(this.minValue, this.data[n][1]) }; TimeSeries.prototype.append = function(n, d) { this.lastTimeStamp = n; var g = this.dataPool.length ? this.dataPool.pop() : [n, d]; g[0] = n; g[1] = d; this.data.push(g); this.maxValue = isNaN(this.maxValue) ? d : Math.max(this.maxValue, d); for (this.minValue = isNaN(this.minValue) ? d : Math.min(this.minValue, d); this.data.length > this.maxDataLength;) this.dataPool.push(this.data.shift()) }; function SmoothieChart(n) { n = n || {}; n.grid = n.grid || { fillStyle: "#000000", strokeStyle: "#777777", lineWidth: 1, millisPerLine: 1E3, verticalSections: 2 }; n.millisPerPixel = n.millisPerPixel || 20; n.fps = n.fps || 50; n.maxValueScale = n.maxValueScale || 1; n.minValue = n.minValue; n.maxValue = n.maxValue; n.labels = n.labels || { fillStyle: "#ffffff" }; n.interpolation = n.interpolation || "bezier"; n.scaleSmoothing = n.scaleSmoothing || .125; n.maxDataSetLength = n.maxDataSetLength || 2; n.timestampFormatter = n.timestampFormatter || null; this.options = n; this.seriesSet = []; this.currentValueRange = 1; this.currentVisMinValue = 0 } SmoothieChart.prototype.addTimeSeries = function(n, d) { this.seriesSet.push({ timeSeries: n, options: d || {} }) }; SmoothieChart.prototype.removeTimeSeries = function(n) { this.seriesSet.splice(this.seriesSet.indexOf(n), 1) }; SmoothieChart.prototype.streamTo = function(n, d) { var g = this; this.render_on_tick = function() { g.render(n, g.seriesSet[0].timeSeries.lastTimeStamp) }; this.start() }; SmoothieChart.prototype.start = function() { this.timer || (this.timer = setInterval(this.render_on_tick, 1E3 / this.options.fps)) }; SmoothieChart.prototype.stop = function() { this.timer && (clearInterval(this.timer), this.timer = void 0) }; SmoothieChart.timeFormatter = function(n) { function d(d) { return (10 > d ? "0" : "") + d } return d(n.getHours()) + ":" + d(n.getMinutes()) + ":" + d(n.getSeconds()) }; SmoothieChart.prototype.render = function(n, d) { var g = n.getContext("2d"), l = this.options, b = n.clientWidth, c = n.clientHeight; g.save(); d -= d % l.millisPerPixel; g.translate(0, 0); g.beginPath(); g.rect(0, 0, b, c); g.clip(); g.save(); g.fillStyle = l.grid.fillStyle; g.clearRect(0, 0, b, c); g.fillRect(0, 0, b, c); g.restore(); g.save(); g.lineWidth = l.grid.lineWidth || 1; g.strokeStyle = l.grid.strokeStyle || "#ffffff"; if (0 < l.grid.millisPerLine) for (var a = d - d % l.grid.millisPerLine; a >= d - b * l.millisPerPixel; a -= l.grid.millisPerLine) { g.beginPath(); var q = Math.round(b - (d - a) / l.millisPerPixel); g.moveTo(q, 0); g.lineTo(q, c); g.stroke(); if (l.timestampFormatter) { var p = l.timestampFormatter(new Date(a)), h = g.measureText(p).width / 2 + g.measureText(y).width + 4; q < b - h && (g.fillStyle = l.labels.fillStyle, g.fillText(p, q - g.measureText(p).width / 2, c - 2)) } g.closePath() } for (y = 1; y < l.grid.verticalSections; y++) a = Math.round(y * c / l.grid.verticalSections), g.beginPath(), g.moveTo(0, a), g.lineTo(b, a), g.stroke(), g.closePath(); g.beginPath(); g.strokeRect(0, 0, b, c); g.closePath(); g.restore(); y = q = Number.NaN; for (p = 0; p < this.seriesSet.length; p++) { var k = this.seriesSet[p].timeSeries; isNaN(k.maxValue) || (q = isNaN(q) ? k.maxValue : Math.max(q, k.maxValue)); isNaN(k.minValue) || (y = isNaN(y) ? k.minValue : Math.min(y, k.minValue)) } if (!isNaN(q) || !isNaN(y)) { q = null != l.maxValue ? l.maxValue : q * l.maxValueScale; null != l.minValue && (y = l.minValue); this.currentValueRange += l.scaleSmoothing * (q - y - this.currentValueRange); this.currentVisMinValue += l.scaleSmoothing * (y - this.currentVisMinValue); h = this.currentValueRange; var f = this.currentVisMinValue; for (p = 0; p < this.seriesSet.length; p++) { g.save(); k = this.seriesSet[p].timeSeries; k = k.data; for (var e = this.seriesSet[p].options; k.length >= l.maxDataSetLength && k[1][0] < d - b * l.millisPerPixel;) k.splice(0, 1); g.lineWidth = e.lineWidth || 1; g.fillStyle = e.fillStyle; g.strokeStyle = e.strokeStyle || "#ffffff"; g.beginPath(); var m = 0, t = 0, r = 0; for (a = 0; a < k.length; a++) { var w = Math.round(b - (d - k[a][0]) / l.millisPerPixel), v = k[a][1] - f; v = Math.max(Math.min(c - (h ? Math.round(v / h * c) : 0), c - 1), 1); if (0 == a) m = w, g.moveTo(w, v); else switch (l.interpolation) { case "line": g.lineTo(w, v); break; default: g.bezierCurveTo(Math.round((t + w) / 2), r, Math.round(t + w) / 2, v, w, v) } t = w; r = v } 0 < k.length && e.fillStyle && (g.lineTo(b + e.lineWidth + 1, r), g.lineTo(b + e.lineWidth + 1, c + e.lineWidth + 1), g.lineTo(m, c + e.lineWidth), g.fill()); g.stroke(); g.closePath(); g.restore() } if (!l.labels.disabled) { l.labelOffsetY || (l.labelOffsetY = 0); g.fillStyle = l.labels.fillStyle; a = parseFloat(q).toFixed(2); var y = parseFloat(y).toFixed(2); g.fillText(a, b - g.measureText(a).width - 2, 10); g.fillText(y, b - g.measureText(y).width - 2, c - 2); for (a = 0; a < this.seriesSet.length; a++) k = this.seriesSet[a].timeSeries, b = k.label, g.fillStyle = k.options.fillStyle || "rgb(255,255,255)", b && g.fillText(b, 2, 10 * (a + 1) + l.labelOffsetY) } } g.restore() }; var Stats = function() { var n = 0, d = 0, g = Date.now(), l = g, b = g, c = 0, a = 1E3, q = 0, p = [ [16, 16, 48], [0, 255, 255] ], h = 0, k = 1E3, f = 0, e = [ [16, 48, 16], [0, 255, 0] ]; var m = document.createElement("div"); m.style.cursor = "pointer"; m.style.width = "80px"; m.style.opacity = "0.9"; m.style.zIndex = "10001"; m.addEventListener("mousedown", function(a) { a.preventDefault(); n = (n + 1) % 2; 0 == n ? (t.style.display = "block", y.style.display = "none") : (t.style.display = "none", y.style.display = "block") }, !1); var t = document.createElement("div"); t.style.textAlign = "left"; t.style.lineHeight = "1.2em"; t.style.backgroundColor = "rgb(" + Math.floor(p[0][0] / 2) + "," + Math.floor(p[0][1] / 2) + "," + Math.floor(p[0][2] / 2) + ")"; t.style.padding = "0 0 3px 3px"; m.appendChild(t); var r = document.createElement("div"); r.style.fontFamily = "Helvetica, Arial, sans-serif"; r.style.fontSize = "9px"; r.style.color = "rgb(" + p[1][0] + "," + p[1][1] + "," + p[1][2] + ")"; r.style.fontWeight = "bold"; r.innerHTML = "FPS"; t.appendChild(r); var w = document.createElement("div"); w.style.position = "relative"; w.style.width = "74px"; w.style.height = "30px"; w.style.backgroundColor = "rgb(" + p[1][0] + "," + p[1][1] + "," + p[1][2] + ")"; for (t.appendChild(w); 74 > w.children.length;) { var v = document.createElement("span"); v.style.width = "1px"; v.style.height = "30px"; v.style.cssFloat = "left"; v.style.backgroundColor = "rgb(" + p[0][0] + "," + p[0][1] + "," + p[0][2] + ")"; w.appendChild(v) } var y = document.createElement("div"); y.style.textAlign = "left"; y.style.lineHeight = "1.2em"; y.style.backgroundColor = "rgb(" + Math.floor(e[0][0] / 2) + "," + Math.floor(e[0][1] / 2) + "," + Math.floor(e[0][2] / 2) + ")"; y.style.padding = "0 0 3px 3px"; y.style.display = "none"; m.appendChild(y); var B = document.createElement("div"); B.style.fontFamily = "Helvetica, Arial, sans-serif"; B.style.fontSize = "9px"; B.style.color = "rgb(" + e[1][0] + "," + e[1][1] + "," + e[1][2] + ")"; B.style.fontWeight = "bold"; B.innerHTML = "MS"; y.appendChild(B); var C = document.createElement("div"); C.style.position = "relative"; C.style.width = "74px"; C.style.height = "30px"; C.style.backgroundColor = "rgb(" + e[1][0] + "," + e[1][1] + "," + e[1][2] + ")"; for (y.appendChild(C); 74 > C.children.length;) v = document.createElement("span"), v.style.width = "1px", v.style.height = 30 * Math.random() + "px", v.style.cssFloat = "left", v.style.backgroundColor = "rgb(" + e[0][0] + "," + e[0][1] + "," + e[0][2] + ")", C.appendChild(v); return { domElement: m, update: function() { g = Date.now(); h = g - l; k = Math.min(k, h); f = Math.max(f, h); B.textContent = h + " MS (" + k + "-" + f + ")"; var e = Math.min(30, 30 - h / 200 * 30); C.appendChild(C.firstChild).style.height = e + "px"; l = g; d++; g > b + 1E3 && (c = Math.round(1E3 * d / (g - b)), a = Math.min(a, c), q = Math.max(q, c), r.textContent = c + " FPS (" + a + "-" + q + ")", e = Math.min(30, 30 - c / 100 * 30), w.appendChild(w.firstChild).style.height = e + "px", b = g, d = 0) } } }; THREE.TrackballControls = function(n, d) { function g(b) { !1 !== a.enabled && (window.removeEventListener("keydown", g), k = h, h === q.NONE) && (b.keyCode !== a.keys[q.ROTATE] || a.noRotate ? b.keyCode !== a.keys[q.ZOOM] || a.noZoom ? b.keyCode !== a.keys[q.PAN] || a.noPan || (h = q.PAN) : h = q.ZOOM : h = q.ROTATE) } function l(b) { !1 !== a.enabled && (b.preventDefault(), b.stopPropagation(), h !== q.ROTATE || a.noRotate ? h !== q.ZOOM || a.noZoom ? h !== q.PAN || a.noPan || B.copy(G(b.pageX, b.pageY)) : r.copy(G(b.pageX, b.pageY)) : m.copy(N(b.pageX, b.pageY))) } function b(c) { !1 !== a.enabled && (c.preventDefault(), c.stopPropagation(), h = q.NONE, document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", b), a.dispatchEvent(x)) } function c(b) { if (!1 !== a.enabled) { b.preventDefault(); b.stopPropagation(); var c = 0; b.wheelDelta ? c = b.wheelDelta / 40 : b.detail && (c = -b.detail / 3); t.y += .01 * c; a.dispatchEvent(A); a.dispatchEvent(x) } } var a = this, q = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 }; this.object = n; this.domElement = void 0 !== d ? d : document; this.enabled = !0; this.screen = { left: 0, top: 0, width: 0, height: 0 }; this.rotateSpeed = 1; this.zoomSpeed = 1.2; this.panSpeed = .3; this.staticMoving = this.noRoll = this.noPan = this.noZoom = this.noRotate = !1; this.dynamicDampingFactor = .2; this.minDistance = 0; this.maxDistance = Infinity; this.keys = [65, 83, 68]; this.target = new THREE.Vector3; var p = new THREE.Vector3, h = q.NONE, k = q.NONE, f = new THREE.Vector3, e = new THREE.Vector3, m = new THREE.Vector3, t = new THREE.Vector2, r = new THREE.Vector2, w = 0, v = 0, y = new THREE.Vector2, B = new THREE.Vector2; this.target0 = this.target.clone(); this.position0 = this.object.position.clone(); this.up0 = this.object.up.clone(); var C = { type: "change" }, A = { type: "start" }, x = { type: "end" }; this.handleResize = function() { if (this.domElement === document) this.screen.left = 0, this.screen.top = 0, this.screen.width = window.innerWidth, this.screen.height = window.innerHeight; else { var a = this.domElement.getBoundingClientRect(), b = this.domElement.ownerDocument.documentElement; this.screen.left = a.left + window.pageXOffset - b.clientLeft; this.screen.top = a.top + window.pageYOffset - b.clientTop; this.screen.width = a.width; this.screen.height = a.height } }; this.handleEvent = function(a) { if ("function" == typeof this[a.type]) this[a.type](a) }; var G = function() { var b = new THREE.Vector2; return function(c, e) { b.set((c - a.screen.left) / a.screen.width, (e - a.screen.top) / a.screen.height); return b } }(), N = function() { var b = new THREE.Vector3, c = new THREE.Vector3, e = new THREE.Vector3; return function(d, h) { e.set((d - .5 * a.screen.width - a.screen.left) / (.5 * a.screen.width), (.5 * a.screen.height + a.screen.top - h) / (.5 * a.screen.height), 0); var g = e.length(); a.noRoll ? e.z = g < Math.SQRT1_2 ? Math.sqrt(1 - g * g) : .5 / g : 1 < g ? e.normalize() : e.z = Math.sqrt(1 - g * g); f.copy(a.object.position).sub(a.target); b.copy(a.object.up).setLength(e.y); b.add(c.copy(a.object.up).cross(f).setLength(e.x)); b.add(f.setLength(e.z)); return b } }(); this.rotateCamera = function() { var b = new THREE.Vector3, c = new THREE.Quaternion; return function() { var d = Math.acos(e.dot(m) / e.length() / m.length()); d && (b.crossVectors(e, m).normalize(), d *= a.rotateSpeed, c.setFromAxisAngle(b, -d), f.applyQuaternion(c), a.object.up.applyQuaternion(c), m.applyQuaternion(c), a.staticMoving ? e.copy(m) : (c.setFromAxisAngle(b, d * (a.dynamicDampingFactor - 1)), e.applyQuaternion(c))) } }(); this.zoomCamera = function() { if (h === q.TOUCH_ZOOM_PAN) { var b = w / v; w = v; f.multiplyScalar(b) } else b = 1 + (r.y - t.y) * a.zoomSpeed, 1 !== b && 0 < b && (f.multiplyScalar(b), a.staticMoving ? t.copy(r) : t.y += (r.y - t.y) * this.dynamicDampingFactor) }; this.panCamera = function() { var b = new THREE.Vector2, c = new THREE.Vector3, e = new THREE.Vector3; return function() { b.copy(B).sub(y); b.lengthSq() && (b.multiplyScalar(f.length() * a.panSpeed), e.copy(f).cross(a.object.up).setLength(b.x), e.add(c.copy(a.object.up).setLength(b.y)), a.object.position.add(e), a.target.add(e), a.staticMoving ? y.copy(B) : y.add(b.subVectors(B, y).multiplyScalar(a.dynamicDampingFactor))) } }(); this.checkDistances = function() { a.noZoom && a.noPan || (f.lengthSq() > a.maxDistance * a.maxDistance && a.object.position.addVectors(a.target, f.setLength(a.maxDistance)), f.lengthSq() < a.minDistance * a.minDistance && a.object.position.addVectors(a.target, f.setLength(a.minDistance))) }; this.update = function() { f.subVectors(a.object.position, a.target); a.noRotate || a.rotateCamera(); a.noZoom || a.zoomCamera(); a.noPan || a.panCamera(); a.object.position.addVectors(a.target, f); a.checkDistances(); a.object.lookAt(a.target); 1E-6 < p.distanceToSquared(a.object.position) && (a.dispatchEvent(C), p.copy(a.object.position)) }; this.reset = function() { k = h = q.NONE; a.target.copy(a.target0); a.object.position.copy(a.position0); a.object.up.copy(a.up0); f.subVectors(a.object.position, a.target); a.object.lookAt(a.target); a.dispatchEvent(C); p.copy(a.object.position) }; this.domElement.addEventListener("contextmenu", function(a) { a.preventDefault() }, !1); this.domElement.addEventListener("mousedown", function(c) { !1 !== a.enabled && (c.preventDefault(), c.stopPropagation(), h === q.NONE && (h = c.button), h !== q.ROTATE || a.noRotate ? h !== q.ZOOM || a.noZoom ? h !== q.PAN || a.noPan || (y.copy(G(c.pageX, c.pageY)), B.copy(y)) : (t.copy(G(c.pageX, c.pageY)), r.copy(t)) : (e.copy(N(c.pageX, c.pageY)), m.copy(e)), document.addEventListener("mousemove", l, !1), document.addEventListener("mouseup", b, !1), a.dispatchEvent(A)) }, !1); this.domElement.addEventListener("mousewheel", c, !1); this.domElement.addEventListener("DOMMouseScroll", c, !1); this.domElement.addEventListener("touchstart", function(b) { if (!1 !== a.enabled) { switch (b.touches.length) { case 1: h = q.TOUCH_ROTATE; e.copy(N(b.touches[0].pageX, b.touches[0].pageY)); m.copy(e); break; case 2: h = q.TOUCH_ZOOM_PAN; var c = b.touches[0].pageX - b.touches[1].pageX, d = b.touches[0].pageY - b.touches[1].pageY; v = w = Math.sqrt(c * c + d * d); y.copy(G((b.touches[0].pageX + b.touches[1].pageX) / 2, (b.touches[0].pageY + b.touches[1].pageY) / 2)); B.copy(y); break; default: h = q.NONE } a.dispatchEvent(A) } }, !1); this.domElement.addEventListener("touchend", function(b) { if (!1 !== a.enabled) { switch (b.touches.length) { case 1: m.copy(N(b.touches[0].pageX, b.touches[0].pageY)); e.copy(m); break; case 2: w = v = 0, B.copy(G((b.touches[0].pageX + b.touches[1].pageX) / 2, (b.touches[0].pageY + b.touches[1].pageY) / 2)), y.copy(B) } h = q.NONE; a.dispatchEvent(x) } }, !1); this.domElement.addEventListener("touchmove", function(b) { if (!1 !== a.enabled) switch (b.preventDefault(), b.stopPropagation(), b.touches.length) { case 1: m.copy(N(b.touches[0].pageX, b.touches[0].pageY)); break; case 2: var c = b.touches[0].pageX - b.touches[1].pageX, e = b.touches[0].pageY - b.touches[1].pageY; v = Math.sqrt(c * c + e * e); B.copy(G((b.touches[0].pageX + b.touches[1].pageX) / 2, (b.touches[0].pageY + b.touches[1].pageY) / 2)); break; default: h = q.NONE } }, !1); window.addEventListener("keydown", g, !1); window.addEventListener("keyup", function(b) { !1 !== a.enabled && (h = k, window.addEventListener("keydown", g, !1)) }, !1); this.handleResize(); this.update() }; THREE.TrackballControls.prototype = Object.create(THREE.EventDispatcher.prototype); var dat = dat || {}; dat.gui = dat.gui || {}; dat.utils = dat.utils || {}; dat.controllers = dat.controllers || {}; dat.dom = dat.dom || {}; dat.color = dat.color || {}; dat.utils.css = function() { return { load: function(n, d) { d = d || document; var g = d.createElement("link"); g.type = "text/css"; g.rel = "stylesheet"; g.href = n; d.getElementsByTagName("head")[0].appendChild(g) }, inject: function(n, d) { d = d || document; var g = document.createElement("style"); g.type = "text/css"; g.innerHTML = n; d.getElementsByTagName("head")[0].appendChild(g) } } }(); dat.utils.common = function() { var n = Array.prototype.forEach, d = Array.prototype.slice; return { BREAK: {}, extend: function(g) { this.each(d.call(arguments, 1), function(d) { for (var b in d) this.isUndefined(d[b]) || (g[b] = d[b]) }, this); return g }, defaults: function(g) { this.each(d.call(arguments, 1), function(d) { for (var b in d) this.isUndefined(g[b]) && (g[b] = d[b]) }, this); return g }, compose: function() { var g = d.call(arguments); return function() { for (var l = d.call(arguments), b = g.length - 1; 0 <= b; b--) l = [g[b].apply(this, l)]; return l[0] } }, each: function(d, l, b) { if (n && d.forEach === n) d.forEach(l, b); else if (d.length === d.length + 0) for (var c = 0, a = d.length; c < a && !(c in d && l.call(b, d[c], c) === this.BREAK); c++); else for (c in d) if (l.call(b, d[c], c) === this.BREAK) break }, defer: function(d) { setTimeout(d, 0) }, toArray: function(g) { return g.toArray ? g.toArray() : d.call(g) }, isUndefined: function(d) { return void 0 === d }, isNull: function(d) { return null === d }, isNaN: function(d) { return d !== d }, isArray: Array.isArray || function(d) { return d.constructor === Array }, isObject: function(d) { return d === Object(d) }, isNumber: function(d) { return d === d + 0 }, isString: function(d) { return d === d + "" }, isBoolean: function(d) { return !1 === d || !0 === d }, isFunction: function(d) { return "[object Function]" === Object.prototype.toString.call(d) } } }(); dat.controllers.Controller = function(n) { var d = function(d, l) { this.initialValue = d[l]; this.domElement = document.createElement("div"); this.object = d; this.property = l; this.__onFinishChange = this.__onChange = void 0 }; n.extend(d.prototype, { onChange: function(d) { this.__onChange = d; return this }, onFinishChange: function(d) { this.__onFinishChange = d; return this }, setValue: function(d) { this.object[this.property] = d; this.__onChange && this.__onChange.call(this, d); this.updateDisplay(); return this }, getValue: function() { return this.object[this.property] }, updateDisplay: function() { return this }, isModified: function() { return this.initialValue !== this.getValue() } }); return d }(dat.utils.common); dat.dom.dom = function(n) { function d(b) { if ("0" === b || n.isUndefined(b)) return 0; b = b.match(l); return n.isNull(b) ? 0 : parseFloat(b[1]) } var g = {}; n.each({ HTMLEvents: ["change"], MouseEvents: ["click", "mousemove", "mousedown", "mouseup", "mouseover"], KeyboardEvents: ["keydown"] }, function(b, a) { n.each(b, function(b) { g[b] = a }) }); var l = /(\d+(\.\d+)?)px/, b = { makeSelectable: function(b, a) { void 0 !== b && void 0 !== b.style && (b.onselectstart = a ? function() { return !1 } : function() {}, b.style.MozUserSelect = a ? "auto" : "none", b.style.KhtmlUserSelect = a ? "auto" : "none", b.unselectable = a ? "on" : "off") }, makeFullscreen: function(b, a, d) { n.isUndefined(a) && (a = !0); n.isUndefined(d) && (d = !0); b.style.position = "absolute"; a && (b.style.left = 0, b.style.right = 0); d && (b.style.top = 0, b.style.bottom = 0) }, fakeEvent: function(b, a, d, l) { d = d || {}; var c = g[a]; if (!c) throw Error("Event type " + a + " not supported."); var k = document.createEvent(c); switch (c) { case "MouseEvents": k.initMouseEvent(a, d.bubbles || !1, d.cancelable || !0, window, d.clickCount || 1, 0, 0, d.x || d.clientX || 0, d.y || d.clientY || 0, !1, !1, !1, !1, 0, null); break; case "KeyboardEvents": c = k.initKeyboardEvent || k.initKeyEvent; n.defaults(d, { cancelable: !0, ctrlKey: !1, altKey: !1, shiftKey: !1, metaKey: !1, keyCode: void 0, charCode: void 0 }); c(a, d.bubbles || !1, d.cancelable, window, d.ctrlKey, d.altKey, d.shiftKey, d.metaKey, d.keyCode, d.charCode); break; default: k.initEvent(a, d.bubbles || !1, d.cancelable || !0) } n.defaults(k, l); b.dispatchEvent(k) }, bind: function(c, a, d, g) { c.addEventListener ? c.addEventListener(a, d, g || !1) : c.attachEvent && c.attachEvent("on" + a, d); return b }, unbind: function(c, a, d, g) { c.removeEventListener ? c.removeEventListener(a, d, g || !1) : c.detachEvent && c.detachEvent("on" + a, d); return b }, addClass: function(c, a) { if (void 0 === c.className) c.className = a; else if (c.className !== a) { var d = c.className.split(/ +/); - 1 == d.indexOf(a) && (d.push(a), c.className = d.join(" ").replace(/^\s+/, "").replace(/\s+$/, "")) } return b }, removeClass: function(c, a) { if (a) { if (void 0 !== c.className) if (c.className === a) c.removeAttribute("class"); else { var d = c.className.split(/ +/), g = d.indexOf(a); - 1 != g && (d.splice(g, 1), c.className = d.join(" ")) } } else c.className = void 0; return b }, hasClass: function(b, a) { return (new RegExp("(?:^|\\s+)" + a + "(?:\\s+|$)")).test(b.className) || !1 }, getWidth: function(b) { b = getComputedStyle(b); return d(b["border-left-width"]) + d(b["border-right-width"]) + d(b["padding-left"]) + d(b["padding-right"]) + d(b.width) }, getHeight: function(b) { b = getComputedStyle(b); return d(b["border-top-width"]) + d(b["border-bottom-width"]) + d(b["padding-top"]) + d(b["padding-bottom"]) + d(b.height) }, getOffset: function(b) { var a = { left: 0, top: 0 }; if (b.offsetParent) { do a.left += b.offsetLeft, a.top += b.offsetTop; while (b = b.offsetParent) } return a }, isActive: function(b) { return b === document.activeElement && (b.type || b.href) } }; return b }(dat.utils.common); dat.controllers.OptionController = function(n, d, g) { var l = function(b, c, a) { l.superclass.call(this, b, c); var q = this; this.__select = document.createElement("select"); if (g.isArray(a)) { var p = {}; g.each(a, function(a) { p[a] = a }); a = p } g.each(a, function(a, b) { var c = document.createElement("option"); c.innerHTML = b; c.setAttribute("value", a); q.__select.appendChild(c) }); this.updateDisplay(); d.bind(this.__select, "change", function() { q.setValue(this.options[this.selectedIndex].value) }); this.domElement.appendChild(this.__select) }; l.superclass = n; g.extend(l.prototype, n.prototype, { setValue: function(b) { b = l.superclass.prototype.setValue.call(this, b); this.__onFinishChange && this.__onFinishChange.call(this, this.getValue()); return b }, updateDisplay: function() { this.__select.value = this.getValue(); return l.superclass.prototype.updateDisplay.call(this) } }); return l }(dat.controllers.Controller, dat.dom.dom, dat.utils.common); dat.controllers.NumberController = function(n, d) { var g = function(l, b, c) { g.superclass.call(this, l, b); c = c || {}; this.__min = c.min; this.__max = c.max; this.__step = c.step; d.isUndefined(this.__step) ? this.__impliedStep = 0 == this.initialValue ? 1 : Math.pow(10, Math.floor(Math.log(this.initialValue) / Math.LN10)) / 10 : this.__impliedStep = this.__step; l = this.__impliedStep; l = l.toString(); l = -1 < l.indexOf(".") ? l.length - l.indexOf(".") - 1 : 0; this.__precision = l }; g.superclass = n; d.extend(g.prototype, n.prototype, { setValue: function(d) { void 0 !== this.__min && d < this.__min ? d = this.__min : void 0 !== this.__max && d > this.__max && (d = this.__max); void 0 !== this.__step && 0 != d % this.__step && (d = Math.round(d / this.__step) * this.__step); return g.superclass.prototype.setValue.call(this, d) }, min: function(d) { this.__min = d; return this }, max: function(d) { this.__max = d; return this }, step: function(d) { this.__step = d; return this } }); return g }(dat.controllers.Controller, dat.utils.common); dat.controllers.NumberControllerBox = function(n, d, g) { var l = function(b, c, a) { function q() { var a = parseFloat(k.__input.value); g.isNaN(a) || k.setValue(a) } function p(a) { var b = f - a.clientY; k.setValue(k.getValue() + b * k.__impliedStep); f = a.clientY } function h() { d.unbind(window, "mousemove", p); d.unbind(window, "mouseup", h) } this.__truncationSuspended = !1; l.superclass.call(this, b, c, a); var k = this, f; this.__input = document.createElement("input"); this.__input.setAttribute("type", "text"); d.bind(this.__input, "change", q); d.bind(this.__input, "blur", function() { q(); k.__onFinishChange && k.__onFinishChange.call(k, k.getValue()) }); d.bind(this.__input, "mousedown", function(a) { d.bind(window, "mousemove", p); d.bind(window, "mouseup", h); f = a.clientY }); d.bind(this.__input, "keydown", function(a) { 13 === a.keyCode && (k.__truncationSuspended = !0, this.blur(), k.__truncationSuspended = !1) }); this.updateDisplay(); this.domElement.appendChild(this.__input) }; l.superclass = n; g.extend(l.prototype, n.prototype, { updateDisplay: function() { var b = this.__input; if (this.__truncationSuspended) var c = this.getValue(); else { c = this.getValue(); var a = Math.pow(10, this.__precision); c = Math.round(c * a) / a } b.value = c; return l.superclass.prototype.updateDisplay.call(this) } }); return l }(dat.controllers.NumberController, dat.dom.dom, dat.utils.common); dat.controllers.NumberControllerSlider = function(n, d, g, l, b) { function c(a, b, c, d, f) { return d + (a - b) / (c - b) * (f - d) } var a = function(b, g, h, k, f) { function e(a) { a.preventDefault(); var b = d.getOffset(l.__background), e = d.getWidth(l.__background); l.setValue(c(a.clientX, b.left, b.left + e, l.__min, l.__max)); return !1 } function m() { d.unbind(window, "mousemove", e); d.unbind(window, "mouseup", m); l.__onFinishChange && l.__onFinishChange.call(l, l.getValue()) } a.superclass.call(this, b, g, { min: h, max: k, step: f }); var l = this; this.__background = document.createElement("div"); this.__foreground = document.createElement("div"); d.bind(this.__background, "mousedown", function(a) { d.bind(window, "mousemove", e); d.bind(window, "mouseup", m); e(a) }); d.addClass(this.__background, "slider"); d.addClass(this.__foreground, "slider-fg"); this.updateDisplay(); this.__background.appendChild(this.__foreground); this.domElement.appendChild(this.__background) }; a.superclass = n; a.useDefaultStyles = function() { g.inject(b) }; l.extend(a.prototype, n.prototype, { updateDisplay: function() { var b = (this.getValue() - this.__min) / (this.__max - this.__min); this.__foreground.style.width = 100 * b + "%"; return a.superclass.prototype.updateDisplay.call(this) } }); return a }(dat.controllers.NumberController, dat.dom.dom, dat.utils.css, dat.utils.common, ".slider {\n box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);\n height: 1em;\n border-radius: 1em;\n background-color: #eee;\n padding: 0 0.5em;\n overflow: hidden;\n}\n\n.slider-fg {\n padding: 1px 0 2px 0;\n background-color: #aaa;\n height: 1em;\n margin-left: -0.5em;\n padding-right: 0.5em;\n border-radius: 1em 0 0 1em;\n}\n\n.slider-fg:after {\n display: inline-block;\n border-radius: 1em;\n background-color: #fff;\n border: 1px solid #aaa;\n content: '';\n float: right;\n margin-right: -1em;\n margin-top: -1px;\n height: 0.9em;\n width: 0.9em;\n}"); dat.controllers.FunctionController = function(n, d, g) { var l = function(b, c, a) { l.superclass.call(this, b, c); var g = this; this.__button = document.createElement("div"); this.__button.innerHTML = void 0 === a ? "Fire" : a; d.bind(this.__button, "click", function(a) { a.preventDefault(); g.fire(); return !1 }); d.addClass(this.__button, "button"); this.domElement.appendChild(this.__button) }; l.superclass = n; g.extend(l.prototype, n.prototype, { fire: function() { this.__onChange && this.__onChange.call(this); this.__onFinishChange && this.__onFinishChange.call(this, this.getValue()); this.getValue().call(this.object) } }); return l }(dat.controllers.Controller, dat.dom.dom, dat.utils.common); dat.controllers.BooleanController = function(n, d, g) { var l = function(b, c) { l.superclass.call(this, b, c); var a = this; this.__prev = this.getValue(); this.__checkbox = document.createElement("input"); this.__checkbox.setAttribute("type", "checkbox"); d.bind(this.__checkbox, "change", function() { a.setValue(!a.__prev) }, !1); this.domElement.appendChild(this.__checkbox); this.updateDisplay() }; l.superclass = n; g.extend(l.prototype, n.prototype, { setValue: function(b) { b = l.superclass.prototype.setValue.call(this, b); this.__onFinishChange && this.__onFinishChange.call(this, this.getValue()); this.__prev = this.getValue(); return b }, updateDisplay: function() { !0 === this.getValue() ? (this.__checkbox.setAttribute("checked", "checked"), this.__checkbox.checked = !0) : this.__checkbox.checked = !1; return l.superclass.prototype.updateDisplay.call(this) } }); return l }(dat.controllers.Controller, dat.dom.dom, dat.utils.common); dat.color.toString = function(n) { return function(d) { if (1 == d.a || n.isUndefined(d.a)) { for (d = d.hex.toString(16); 6 > d.length;) d = "0" + d; return "#" + d } return "rgba(" + Math.round(d.r) + "," + Math.round(d.g) + "," + Math.round(d.b) + "," + d.a + ")" } }(dat.utils.common); dat.color.interpret = function(n, d) { var g, l, b = [{ litmus: d.isString, conversions: { THREE_CHAR_HEX: { read: function(b) { b = b.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i); return null === b ? !1 : { space: "HEX", hex: parseInt("0x" + b[1].toString() + b[1].toString() + b[2].toString() + b[2].toString() + b[3].toString() + b[3].toString()) } }, write: n }, SIX_CHAR_HEX: { read: function(b) { b = b.match(/^#([A-F0-9]{6})$/i); return null === b ? !1 : { space: "HEX", hex: parseInt("0x" + b[1].toString()) } }, write: n }, CSS_RGB: { read: function(b) { b = b.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/); return null === b ? !1 : { space: "RGB", r: parseFloat(b[1]), g: parseFloat(b[2]), b: parseFloat(b[3]) } }, write: n }, CSS_RGBA: { read: function(b) { b = b.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/); return null === b ? !1 : { space: "RGB", r: parseFloat(b[1]), g: parseFloat(b[2]), b: parseFloat(b[3]), a: parseFloat(b[4]) } }, write: n } } }, { litmus: d.isNumber, conversions: { HEX: { read: function(b) { return { space: "HEX", hex: b, conversionName: "HEX" } }, write: function(b) { return b.hex } } } }, { litmus: d.isArray, conversions: { RGB_ARRAY: { read: function(b) { return 3 != b.length ? !1 : { space: "RGB", r: b[0], g: b[1], b: b[2] } }, write: function(b) { return [b.r, b.g, b.b] } }, RGBA_ARRAY: { read: function(b) { return 4 != b.length ? !1 : { space: "RGB", r: b[0], g: b[1], b: b[2], a: b[3] } }, write: function(b) { return [b.r, b.g, b.b, b.a] } } } }, { litmus: d.isObject, conversions: { RGBA_OBJ: { read: function(b) { return d.isNumber(b.r) && d.isNumber(b.g) && d.isNumber(b.b) && d.isNumber(b.a) ? { space: "RGB", r: b.r, g: b.g, b: b.b, a: b.a } : !1 }, write: function(b) { return { r: b.r, g: b.g, b: b.b, a: b.a } } }, RGB_OBJ: { read: function(b) { return d.isNumber(b.r) && d.isNumber(b.g) && d.isNumber(b.b) ? { space: "RGB", r: b.r, g: b.g, b: b.b } : !1 }, write: function(b) { return { r: b.r, g: b.g, b: b.b } } }, HSVA_OBJ: { read: function(b) { return d.isNumber(b.h) && d.isNumber(b.s) && d.isNumber(b.v) && d.isNumber(b.a) ? { space: "HSV", h: b.h, s: b.s, v: b.v, a: b.a } : !1 }, write: function(b) { return { h: b.h, s: b.s, v: b.v, a: b.a } } }, HSV_OBJ: { read: function(b) { return d.isNumber(b.h) && d.isNumber(b.s) && d.isNumber(b.v) ? { space: "HSV", h: b.h, s: b.s, v: b.v } : !1 }, write: function(b) { return { h: b.h, s: b.s, v: b.v } } } } }]; return function() { l = !1; var c = 1 < arguments.length ? d.toArray(arguments) : arguments[0]; d.each(b, function(a) { if (a.litmus(c)) return d.each(a.conversions, function(a, b) { g = a.read(c); if (!1 === l && !1 !== g) return l = g, g.conversionName = b, g.conversion = a, d.BREAK }), d.BREAK }); return l } }(dat.color.toString, dat.utils.common); dat.GUI = dat.gui.GUI = function(n, d, g, l, b, c, a, q, p, h, k, f, e, m, t) { function r(a, c, d, e) { if (void 0 === c[d]) throw Error("Object " + c + ' has no property "' + d + '"'); e.color ? c = new k(c, d) : (c = [c, d].concat(e.factoryArgs), c = l.apply(a, c)); e.before instanceof b && (e.before = e.before.__li); y(a, c); m.addClass(c.domElement, "c"); d = document.createElement("span"); m.addClass(d, "property-name"); d.innerHTML = c.property; var f = document.createElement("div"); f.appendChild(d); f.appendChild(c.domElement); e = w(a, f, e.before); m.addClass(e, M.CLASS_CONTROLLER_ROW); m.addClass(e, typeof c.getValue()); v(a, e, c); a.__controllers.push(c); return c } function w(a, b, c) { var d = document.createElement("li"); b && d.appendChild(b); c ? a.__ul.insertBefore(d, params.before) : a.__ul.appendChild(d); a.onResize(); return d } function v(b, d, e) { e.__li = d; e.__gui = b; t.extend(e, { options: function(a) { if (1 < arguments.length) return e.remove(), r(b, e.object, e.property, { before: e.__li.nextElementSibling, factoryArgs: [t.toArray(arguments)] }); if (t.isArray(a) || t.isObject(a)) return e.remove(), r(b, e.object, e.property, { before: e.__li.nextElementSibling, factoryArgs: [a] }) }, name: function(a) { e.__li.firstElementChild.firstElementChild.innerHTML = a; return e }, listen: function() { e.__gui.listen(e); return e }, remove: function() { e.__gui.remove(e); return e } }); if (e instanceof p) { var f = new q(e.object, e.property, { min: e.__min, max: e.__max, step: e.__step }); t.each(["updateDisplay", "onChange", "onFinishChange"], function(a) { var b = e[a], c = f[a]; e[a] = f[a] = function() { var a = Array.prototype.slice.call(arguments); b.apply(e, a); return c.apply(f, a) } }); m.addClass(d, "has-slider"); e.domElement.insertBefore(f.domElement, e.domElement.firstElementChild) } else if (e instanceof q) { var h = function(a) { return t.isNumber(e.__min) && t.isNumber(e.__max) ? (e.remove(), r(b, e.object, e.property, { before: e.__li.nextElementSibling, factoryArgs: [e.__min, e.__max, e.__step] })) : a }; e.min = t.compose(h, e.min); e.max = t.compose(h, e.max) } else e instanceof c ? (m.bind(d, "click", function() { m.fakeEvent(e.__checkbox, "click") }), m.bind(e.__checkbox, "click", function(a) { a.stopPropagation() })) : e instanceof a ? (m.bind(d, "click", function() { m.fakeEvent(e.__button, "click") }), m.bind(d, "mouseover", function() { m.addClass(e.__button, "hover") }), m.bind(d, "mouseout", function() { m.removeClass(e.__button, "hover") })) : e instanceof k && (m.addClass(d, "color"), e.updateDisplay = t.compose(function(a) { d.style.borderLeftColor = e.__color.toString(); return a }, e.updateDisplay), e.updateDisplay()); e.setValue = t.compose(function(a) { b.getRoot().__preset_select && e.isModified() && N(b.getRoot(), !0); return a }, e.setValue) } function y(a, b) { var c = a.getRoot(), e = c.__rememberedObjects.indexOf(b.object); if (-1 != e) { var d = c.__rememberedObjectIndecesToControllers[e]; void 0 === d && (d = {}, c.__rememberedObjectIndecesToControllers[e] = d); d[b.property] = b; if (c.load && c.load.remembered) { c = c.load.remembered; if (c[a.preset]) c = c[a.preset]; else if (c.Default) c = c.Default; else return; c[e] && void 0 !== c[e][b.property] && (e = c[e][b.property], b.initialValue = e, b.setValue(e)) } } } function B(a) { var b = a.__save_row = document.createElement("li"); m.addClass(a.domElement, "has-save"); a.__ul.insertBefore(b, a.__ul.firstChild); m.addClass(b, "save-row"); var c = document.createElement("span"); c.innerHTML = " "; m.addClass(c, "button gears"); var e = document.createElement("span"); e.innerHTML = "Save"; m.addClass(e, "button"); m.addClass(e, "save"); var d = document.createElement("span"); d.innerHTML = "New"; m.addClass(d, "button"); m.addClass(d, "save-as"); var f = document.createElement("span"); f.innerHTML = "Revert"; m.addClass(f, "button"); m.addClass(f, "revert"); var h = a.__preset_select = document.createElement("select"); a.load && a.load.remembered ? t.each(a.load.remembered, function(b, c) { G(a, c, c == a.preset) }) : G(a, "Default", !1); m.bind(h, "change", function() { for (var b = 0; b < a.__preset_select.length; b++) a.__preset_select[b].innerHTML = a.__preset_select[b].value; a.preset = this.value }); b.appendChild(h); b.appendChild(c); b.appendChild(e); b.appendChild(d); b.appendChild(f); if (S) { var k = function() { g.style.display = a.useLocalStorage ? "block" : "none" }; b = document.getElementById("dg-save-locally"); var g = document.getElementById("dg-local-explain"); b.style.display = "block"; b = document.getElementById("dg-local-storage"); "true" === localStorage.getItem(document.location.href + ".isLocal") && b.setAttribute("checked", "checked"); k(); m.bind(b, "change", function() { a.useLocalStorage = !a.useLocalStorage; k() }) } var l = document.getElementById("dg-new-constructor"); m.bind(l, "keydown", function(a) { !a.metaKey || 67 !== a.which && 67 != a.keyCode || U.hide() }); m.bind(c, "click", function() { l.innerHTML = JSON.stringify(a.getSaveObject(), void 0, 2); U.show(); l.focus(); l.select() }); m.bind(e, "click", function() { a.save() }); m.bind(d, "click", function() { var b = prompt("Enter a new preset name."); b && a.saveAs(b) }); m.bind(f, "click", function() { a.revert() }) } function C(a) { function b(b) { b.preventDefault(); d = b.clientX; m.addClass(a.__closeButton, M.CLASS_DRAG); m.bind(window, "mousemove", c); m.bind(window, "mouseup", e); return !1 } function c(b) { b.preventDefault(); a.width += d - b.clientX; a.onResize(); d = b.clientX; return !1 } function e() { m.removeClass(a.__closeButton, M.CLASS_DRAG); m.unbind(window, "mousemove", c); m.unbind(window, "mouseup", e) } a.__resize_handle = document.createElement("div"); t.extend(a.__resize_handle.style, { width: "6px", marginLeft: "-3px", height: "200px", cursor: "ew-resize", position: "absolute" }); var d; m.bind(a.__resize_handle, "mousedown", b); m.bind(a.__closeButton, "mousedown", b); a.domElement.insertBefore(a.__resize_handle, a.domElement.firstElementChild) } function A(a, b) { a.domElement.style.width = b + "px"; a.__save_row && a.autoPlace && (a.__save_row.style.width = b + "px"); a.__closeButton && (a.__closeButton.style.width = b + "px") } function x(a, b) { var c = {}; t.each(a.__rememberedObjects, function(e, d) { var f = {}; t.each(a.__rememberedObjectIndecesToControllers[d], function(a, c) { f[c] = b ? a.initialValue : a.getValue() }); c[d] = f }); return c } function G(a, b, c) { var e = document.createElement("option"); e.innerHTML = b; e.value = b; a.__preset_select.appendChild(e); c && (a.__preset_select.selectedIndex = a.__preset_select.length - 1) } function N(a, b) { var c = a.__preset_select[a.__preset_select.selectedIndex]; c.innerHTML = b ? c.value + "*" : c.value } function H(a) { 0 != a.length && f(function() { H(a) }); t.each(a, function(a) { a.updateDisplay() }) } n.inject(g); try { var S = "localStorage" in window && null !== window.localStorage } catch (O) { S = !1 } var U, R = !0, P, J = !1, L = [], M = function(a) { function b() { localStorage.setItem(document.location.href + ".gui", JSON.stringify(e.getSaveObject())) } function c() { var a = e.getRoot(); a.width += 1; t.defer(function() { --a.width }) } var e = this; this.domElement = document.createElement("div"); this.__ul = document.createElement("ul"); this.domElement.appendChild(this.__ul); m.addClass(this.domElement, "dg"); this.__folders = {}; this.__controllers = []; this.__rememberedObjects = []; this.__rememberedObjectIndecesToControllers = []; this.__listening = []; a = a || {}; a = t.defaults(a, { autoPlace: !0, width: M.DEFAULT_WIDTH }); a = t.defaults(a, { resizable: a.autoPlace, hideable: a.autoPlace }); t.isUndefined(a.load) ? a.load = { preset: "Default" } : a.preset && (a.load.preset = a.preset); t.isUndefined(a.parent) && a.hideable && L.push(this); a.resizable = t.isUndefined(a.parent) && a.resizable; a.autoPlace && t.isUndefined(a.scrollable) && (a.scrollable = !0); var d = S && "true" === localStorage.getItem(document.location.href + ".isLocal"); Object.defineProperties(this, { parent: { get: function() { return a.parent } }, scrollable: { get: function() { return a.scrollable } }, autoPlace: { get: function() { return a.autoPlace } }, preset: { get: function() { return e.parent ? e.getRoot().preset : a.load.preset }, set: function(b) { e.parent ? e.getRoot().preset = b : a.load.preset = b; for (b = 0; b < this.__preset_select.length; b++) this.__preset_select[b].value == this.preset && (this.__preset_select.selectedIndex = b); e.revert() } }, width: { get: function() { return a.width }, set: function(b) { a.width = b; A(e, b) } }, name: { get: function() { return a.name }, set: function(b) { a.name = b; h && (h.innerHTML = a.name) } }, closed: { get: function() { return a.closed }, set: function(b) { a.closed = b; a.closed ? m.addClass(e.__ul, M.CLASS_CLOSED) : m.removeClass(e.__ul, M.CLASS_CLOSED); this.onResize(); e.__closeButton && (e.__closeButton.innerHTML = b ? M.TEXT_OPEN : M.TEXT_CLOSED) } }, load: { get: function() { return a.load } }, useLocalStorage: { get: function() { return d }, set: function(a) { S && ((d = a) ? m.bind(window, "unload", b) : m.unbind(window, "unload", b), localStorage.setItem(document.location.href + ".isLocal", a)) } } }); if (t.isUndefined(a.parent)) { a.closed = !1; m.addClass(this.domElement, M.CLASS_MAIN); m.makeSelectable(this.domElement, !1); if (S && d) { e.useLocalStorage = !0; var f = localStorage.getItem(document.location.href + ".gui"); f && (a.load = JSON.parse(f)) } this.__closeButton = document.createElement("div"); this.__closeButton.innerHTML = M.TEXT_CLOSED; m.addClass(this.__closeButton, M.CLASS_CLOSE_BUTTON); this.domElement.appendChild(this.__closeButton); m.bind(this.__closeButton, "click", function() { e.closed = !e.closed }) } else { void 0 === a.closed && (a.closed = !0); var h = document.createTextNode(a.name); m.addClass(h, "controller-name"); f = w(e, h); m.addClass(this.__ul, M.CLASS_CLOSED); m.addClass(f, "title"); m.bind(f, "click", function(a) { a.preventDefault(); e.closed = !e.closed; return !1 }); a.closed || (this.closed = !1) } a.autoPlace && (t.isUndefined(a.parent) && (R && (P = document.createElement("div"), m.addClass(P, "dg"), m.addClass(P, M.CLASS_AUTO_PLACE_CONTAINER), document.body.appendChild(P), R = !1), P.appendChild(this.domElement), m.addClass(this.domElement, M.CLASS_AUTO_PLACE)), this.parent || A(e, a.width)); m.bind(window, "resize", function() { e.onResize() }); m.bind(this.__ul, "webkitTransitionEnd", function() { e.onResize() }); m.bind(this.__ul, "transitionend", function() { e.onResize() }); m.bind(this.__ul, "oTransitionEnd", function() { e.onResize() }); this.onResize(); a.resizable && C(this); e.getRoot(); a.parent || c() }; M.toggleHide = function() { J = !J; t.each(L, function(a) { a.domElement.style.zIndex = J ? -999 : 999; a.domElement.style.opacity = J ? 0 : 1 }) }; M.CLASS_AUTO_PLACE = "a"; M.CLASS_AUTO_PLACE_CONTAINER = "ac"; M.CLASS_MAIN = "main"; M.CLASS_CONTROLLER_ROW = "cr"; M.CLASS_TOO_TALL = "taller-than-window"; M.CLASS_CLOSED = "closed"; M.CLASS_CLOSE_BUTTON = "close-button"; M.CLASS_DRAG = "drag"; M.DEFAULT_WIDTH = 245; M.TEXT_CLOSED = "Close Controls"; M.TEXT_OPEN = "Open Controls"; m.bind(window, "keydown", function(a) { "text" === document.activeElement.type || 72 !== a.which && 72 != a.keyCode || M.toggleHide() }, !1); t.extend(M.prototype, { add: function(a, b) { return r(this, a, b, { factoryArgs: Array.prototype.slice.call(arguments, 2) }) }, addColor: function(a, b) { return r(this, a, b, { color: !0 }) }, remove: function(a) { this.__ul.removeChild(a.__li); this.__controllers.slice(this.__controllers.indexOf(a), 1); var b = this; t.defer(function() { b.onResize() }) }, destroy: function() { this.autoPlace && P.removeChild(this.domElement) }, addFolder: function(a) { if (void 0 !== this.__folders[a]) throw Error('You already have a folder in this GUI by the name "' + a + '"'); var b = { name: a, parent: this }; b.autoPlace = this.autoPlace; this.load && this.load.folders && this.load.folders[a] && (b.closed = this.load.folders[a].closed, b.load = this.load.folders[a]); b = new M(b); this.__folders[a] = b; a = w(this, b.domElement); m.addClass(a, "folder"); return b }, open: function() { this.closed = !1 }, close: function() { this.closed = !0 }, onResize: function() { var a = this.getRoot(); if (a.scrollable) { var b = m.getOffset(a.__ul).top, c = 0; t.each(a.__ul.childNodes, function(b) { a.autoPlace && b === a.__save_row || (c += m.getHeight(b)) }); window.innerHeight - b - 20 < c ? (m.addClass(a.domElement, M.CLASS_TOO_TALL), a.__ul.style.height = window.innerHeight - b - 20 + "px") : (m.removeClass(a.domElement, M.CLASS_TOO_TALL), a.__ul.style.height = "auto") } a.__resize_handle && t.defer(function() { a.__resize_handle.style.height = a.__ul.offsetHeight + "px" }); a.__closeButton && (a.__closeButton.style.width = a.width + "px") }, remember: function() { t.isUndefined(U) && (U = new e, U.domElement.innerHTML = d); if (this.parent) throw Error("You can only call remember on a top level GUI."); var a = this; t.each(Array.prototype.slice.call(arguments), function(b) { 0 == a.__rememberedObjects.length && B(a); - 1 == a.__rememberedObjects.indexOf(b) && a.__rememberedObjects.push(b) }); this.autoPlace && A(this, this.width) }, getRoot: function() { for (var a = this; a.parent;) a = a.parent; return a }, getSaveObject: function() { var a = this.load; a.closed = this.closed; 0 < this.__rememberedObjects.length && (a.preset = this.preset, a.remembered || (a.remembered = {}), a.remembered[this.preset] = x(this)); a.folders = {}; t.each(this.__folders, function(b, c) { a.folders[c] = b.getSaveObject() }); return a }, save: function() { this.load.remembered || (this.load.remembered = {}); this.load.remembered[this.preset] = x(this); N(this, !1) }, saveAs: function(a) { this.load.remembered || (this.load.remembered = {}, this.load.remembered.Default = x(this, !0)); this.load.remembered[a] = x(this); this.preset = a; G(this, a, !0) }, revert: function(a) { t.each(this.__controllers, function(b) { this.getRoot().load.remembered ? y(a || this.getRoot(), b) : b.setValue(b.initialValue) }, this); t.each(this.__folders, function(a) { a.revert(a) }); a || N(this.getRoot(), !1) }, listen: function(a) { var b = 0 == this.__listening.length; this.__listening.push(a); b && H(this.__listening) } }); return M }(dat.utils.css, '<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n \n </div>\n \n </div>\n\n</div>', ".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save ul{margin-top:27px}.dg.a.has-save ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height 0.1s ease-out;-o-transition:height 0.1s ease-out;-moz-transition:height 0.1s ease-out;transition:height 0.1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li > *{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n", dat.controllers.factory = function(n, d, g, l, b, c, a) { return function(q, p, h, k) { var f = q[p]; if (a.isArray(h) || a.isObject(h)) return new n(q, p, h); if (a.isNumber(f)) return a.isNumber(h) && a.isNumber(k) ? new g(q, p, h, k) : new d(q, p, { min: h, max: k }); if (a.isString(f)) return new l(q, p); if (a.isFunction(f)) return new b(q, p, ""); if (a.isBoolean(f)) return new c(q, p) } }(dat.controllers.OptionController, dat.controllers.NumberControllerBox, dat.controllers.NumberControllerSlider, dat.controllers.StringController = function(n, d, g) { var l = function(b, c) { function a() { g.setValue(g.__input.value) } l.superclass.call(this, b, c); var g = this; this.__input = document.createElement("input"); this.__input.setAttribute("type", "text"); d.bind(this.__input, "keyup", a); d.bind(this.__input, "change", a); d.bind(this.__input, "blur", function() { g.__onFinishChange && g.__onFinishChange.call(g, g.getValue()) }); d.bind(this.__input, "keydown", function(a) { 13 === a.keyCode && this.blur() }); this.updateDisplay(); this.domElement.appendChild(this.__input) }; l.superclass = n; g.extend(l.prototype, n.prototype, { updateDisplay: function() { d.isActive(this.__input) || (this.__input.value = this.getValue()); return l.superclass.prototype.updateDisplay.call(this) } }); return l }(dat.controllers.Controller, dat.dom.dom, dat.utils.common), dat.controllers.FunctionController, dat.controllers.BooleanController, dat.utils.common), dat.controllers.Controller, dat.controllers.BooleanController, dat.controllers.FunctionController, dat.controllers.NumberControllerBox, dat.controllers.NumberControllerSlider, dat.controllers.OptionController, dat.controllers.ColorController = function(n, d, g, l, b) { function c(a, c, d, e) { a.style.background = ""; b.each(p, function(b) { a.style.cssText += "background: " + b + "linear-gradient(" + c + ", " + d + " 0%, " + e + " 100%); " }) } function a(a) { a.style.background = ""; a.style.cssText += "background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);"; a.style.cssText += "background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"; a.style.cssText += "background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"; a.style.cssText += "background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"; a.style.cssText += "background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);" } var q = function(h, k) { function f(a) { n(a); d.bind(window, "mousemove", n); d.bind(window, "mouseup", e) } function e() { d.unbind(window, "mousemove", n); d.unbind(window, "mouseup", e) } function m() { var a = l(this.value); !1 !== a ? (v.__color.__state = a, v.setValue(v.__color.toOriginal())) : this.value = v.__color.toString() } function p() { d.unbind(window, "mousemove", w); d.unbind(window, "mouseup", p) } function n(a) { a.preventDefault(); var b = d.getWidth(v.__saturation_field), c = d.getOffset(v.__saturation_field), e = (a.clientX - c.left + document.body.scrollLeft) / b; a = 1 - (a.clientY - c.top + document.body.scrollTop) / b; 1 < a ? a = 1 : 0 > a && (a = 0); 1 < e ? e = 1 : 0 > e && (e = 0); v.__color.v = a; v.__color.s = e; v.setValue(v.__color.toOriginal()); return !1 } function w(a) { a.preventDefault(); var b = d.getHeight(v.__hue_field), c = d.getOffset(v.__hue_field); a = 1 - (a.clientY - c.top + document.body.scrollTop) / b; 1 < a ? a = 1 : 0 > a && (a = 0); v.__color.h = 360 * a; v.setValue(v.__color.toOriginal()); return !1 } q.superclass.call(this, h, k); this.__color = new g(this.getValue()); this.__temp = new g(0); var v = this; this.domElement = document.createElement("div"); d.makeSelectable(this.domElement, !1); this.__selector = document.createElement("div"); this.__selector.className = "selector"; this.__saturation_field = document.createElement("div"); this.__saturation_field.className = "saturation-field"; this.__field_knob = document.createElement("div"); this.__field_knob.className = "field-knob"; this.__field_knob_border = "2px solid "; this.__hue_knob = document.createElement("div"); this.__hue_knob.className = "hue-knob"; this.__hue_field = document.createElement("div"); this.__hue_field.className = "hue-field"; this.__input = document.createElement("input"); this.__input.type = "text"; this.__input_textShadow = "0 1px 1px "; d.bind(this.__input, "keydown", function(a) { 13 === a.keyCode && m.call(this) }); d.bind(this.__input, "blur", m); d.bind(this.__selector, "mousedown", function(a) { d.addClass(this, "drag").bind(window, "mouseup", function(a) { d.removeClass(v.__selector, "drag") }) }); var y = document.createElement("div"); b.extend(this.__selector.style, { width: "122px", height: "102px", padding: "3px", backgroundColor: "#222", boxShadow: "0px 1px 3px rgba(0,0,0,0.3)" }); b.extend(this.__field_knob.style, { position: "absolute", width: "12px", height: "12px", border: this.__field_knob_border + (.5 > this.__color.v ? "#fff" : "#000"), boxShadow: "0px 1px 3px rgba(0,0,0,0.5)", borderRadius: "12px", zIndex: 1 }); b.extend(this.__hue_knob.style, { position: "absolute", width: "15px", height: "2px", borderRight: "4px solid #fff", zIndex: 1 }); b.extend(this.__saturation_field.style, { width: "100px", height: "100px", border: "1px solid #555", marginRight: "3px", display: "inline-block", cursor: "pointer" }); b.extend(y.style, { width: "100%", height: "100%", background: "none" }); c(y, "top", "rgba(0,0,0,0)", "#000"); b.extend(this.__hue_field.style, { width: "15px", height: "100px", display: "inline-block", border: "1px solid #555", cursor: "ns-resize" }); a(this.__hue_field); b.extend(this.__input.style, { outline: "none", textAlign: "center", color: "#fff", border: 0, fontWeight: "bold", textShadow: this.__input_textShadow + "rgba(0,0,0,0.7)" }); d.bind(this.__saturation_field, "mousedown", f); d.bind(this.__field_knob, "mousedown", f); d.bind(this.__hue_field, "mousedown", function(a) { w(a); d.bind(window, "mousemove", w); d.bind(window, "mouseup", p) }); this.__saturation_field.appendChild(y); this.__selector.appendChild(this.__field_knob); this.__selector.appendChild(this.__saturation_field); this.__selector.appendChild(this.__hue_field); this.__hue_field.appendChild(this.__hue_knob); this.domElement.appendChild(this.__input); this.domElement.appendChild(this.__selector); this.updateDisplay() }; q.superclass = n; b.extend(q.prototype, n.prototype, { updateDisplay: function() { var a = l(this.getValue()); if (!1 !== a) { var d = !1; b.each(g.COMPONENTS, function(c) { if (!b.isUndefined(a[c]) && !b.isUndefined(this.__color.__state[c]) && a[c] !== this.__color.__state[c]) return d = !0, {} }, this); d && b.extend(this.__color.__state, a) } b.extend(this.__temp.__state, this.__color.__state); this.__temp.a = 1; var f = .5 > this.__color.v || .5 < this.__color.s ? 255 : 0, e = 255 - f; b.extend(this.__field_knob.style, { marginLeft: 100 * this.__color.s - 7 + "px", marginTop: 100 * (1 - this.__color.v) - 7 + "px", backgroundColor: this.__temp.toString(), border: this.__field_knob_border + "rgb(" + f + "," + f + "," + f + ")" }); this.__hue_knob.style.marginTop = 100 * (1 - this.__color.h / 360) + "px"; this.__temp.s = 1; this.__temp.v = 1; c(this.__saturation_field, "left", "#fff", this.__temp.toString()); b.extend(this.__input.style, { backgroundColor: this.__input.value = this.__color.toString(), color: "rgb(" + f + "," + f + "," + f + ")", textShadow: this.__input_textShadow + "rgba(" + e + "," + e + "," + e + ",.7)" }) } }); var p = ["-moz-", "-o-", "-webkit-", "-ms-", ""]; return q }(dat.controllers.Controller, dat.dom.dom, dat.color.Color = function(n, d, g, l) { function b(b, c, d) { Object.defineProperty(b, c, { get: function() { if ("RGB" === this.__state.space) return this.__state[c]; a(this, c, d); return this.__state[c] }, set: function(b) { "RGB" !== this.__state.space && (a(this, c, d), this.__state.space = "RGB"); this.__state[c] = b } }) } function c(a, b) { Object.defineProperty(a, b, { get: function() { if ("HSV" === this.__state.space) return this.__state[b]; q(this); return this.__state[b] }, set: function(a) { "HSV" !== this.__state.space && (q(this), this.__state.space = "HSV"); this.__state[b] = a } }) } function a(a, b, c) { if ("HEX" === a.__state.space) a.__state[b] = d.component_from_hex(a.__state.hex, c); else if ("HSV" === a.__state.space) l.extend(a.__state, d.hsv_to_rgb(a.__state.h, a.__state.s, a.__state.v)); else throw "Corrupted color state"; } function q(a) { var b = d.rgb_to_hsv(a.r, a.g, a.b); l.extend(a.__state, { s: b.s, v: b.v }); l.isNaN(b.h) ? l.isUndefined(a.__state.h) && (a.__state.h = 0) : a.__state.h = b.h } var p = function() { this.__state = n.apply(this, arguments); if (!1 === this.__state) throw "Failed to interpret color arguments"; this.__state.a = this.__state.a || 1 }; p.COMPONENTS = "r g b h s v hex a".split(" "); l.extend(p.prototype, { toString: function() { return g(this) }, toOriginal: function() { return this.__state.conversion.write(this) } }); b(p.prototype, "r", 2); b(p.prototype, "g", 1); b(p.prototype, "b", 0); c(p.prototype, "h"); c(p.prototype, "s"); c(p.prototype, "v"); Object.defineProperty(p.prototype, "a", { get: function() { return this.__state.a }, set: function(a) { this.__state.a = a } }); Object.defineProperty(p.prototype, "hex", { get: function() { this.__state.hex = d.rgb_to_hex(this.r, this.g, this.b); return this.__state.hex }, set: function(a) { this.__state.space = "HEX"; this.__state.hex = a } }); return p }(dat.color.interpret, dat.color.math = function() { var n; return { hsv_to_rgb: function(d, g, l) { var b = d / 60 - Math.floor(d / 60), c = l * (1 - g), a = l * (1 - b * g); g = l * (1 - (1 - b) * g); d = [ [l, g, c], [a, l, c], [c, l, g], [c, a, l], [g, c, l], [l, c, a] ][Math.floor(d / 60) % 6]; return { r: 255 * d[0], g: 255 * d[1], b: 255 * d[2] } }, rgb_to_hsv: function(d, g, l) { var b = Math.max(d, g, l), c = b - Math.min(d, g, l); if (0 == b) return { h: NaN, s: 0, v: 0 }; d = (d == b ? (g - l) / c : g == b ? 2 + (l - d) / c : 4 + (d - g) / c) / 6; 0 > d && (d += 1); return { h: 360 * d, s: c / b, v: b / 255 } }, rgb_to_hex: function(d, g, l) { d = this.hex_with_component(0, 2, d); d = this.hex_with_component(d, 1, g); return d = this.hex_with_component(d, 0, l) }, component_from_hex: function(d, g) { return d >> 8 * g & 255 }, hex_with_component: function(d, g, l) { return l << (n = 8 * g) | d & ~(255 << n) } } }(), dat.color.toString, dat.utils.common), dat.color.interpret, dat.utils.common), dat.utils.requestAnimationFrame = function() { return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(n, d) { window.setTimeout(n, 1E3 / 60) } }(), dat.dom.CenteredDiv = function(n, d) { var g = function() { this.backgroundElement = document.createElement("div"); d.extend(this.backgroundElement.style, { backgroundColor: "rgba(0,0,0,0.8)", top: 0, left: 0, display: "none", zIndex: "1000", opacity: 0, WebkitTransition: "opacity 0.2s linear" }); n.makeFullscreen(this.backgroundElement); this.backgroundElement.style.position = "fixed"; this.domElement = document.createElement("div"); d.extend(this.domElement.style, { position: "fixed", display: "none", zIndex: "1001", opacity: 0, WebkitTransition: "-webkit-transform 0.2s ease-out, opacity 0.2s linear" }); document.body.appendChild(this.backgroundElement); document.body.appendChild(this.domElement); var g = this; n.bind(this.backgroundElement, "click", function() { g.hide() }) }; g.prototype.show = function() { var g = this; this.backgroundElement.style.display = "block"; this.domElement.style.display = "block"; this.domElement.style.opacity = 0; this.domElement.style.webkitTransform = "scale(1.1)"; this.layout(); d.defer(function() { g.backgroundElement.style.opacity = 1; g.domElement.style.opacity = 1; g.domElement.style.webkitTransform = "scale(1)" }) }; g.prototype.hide = function() { var d = this, b = function() { d.domElement.style.display = "none"; d.backgroundElement.style.display = "none"; n.unbind(d.domElement, "webkitTransitionEnd", b); n.unbind(d.domElement, "transitionend", b); n.unbind(d.domElement, "oTransitionEnd", b) }; n.bind(this.domElement, "webkitTransitionEnd", b); n.bind(this.domElement, "transitionend", b); n.bind(this.domElement, "oTransitionEnd", b); this.backgroundElement.style.opacity = 0; this.domElement.style.opacity = 0; this.domElement.style.webkitTransform = "scale(1.1)" }; g.prototype.layout = function() { this.domElement.style.left = window.innerWidth / 2 - n.getWidth(this.domElement) / 2 + "px"; this.domElement.style.top = window.innerHeight / 2 - n.getHeight(this.domElement) / 2 + "px" }; return g }(dat.dom.dom, dat.utils.common), dat.dom.dom, dat.utils.common); function CAreYouSurePanel(n) { var d, g, l, b, c, a; this._init = function() { c = new createjs.Container; c.alpha = 0; q.addChild(c); a = new createjs.Shape; a.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); a.alpha = .5; a.on("click", function() {}); c.addChild(a); var p = s_oSpriteLibrary.getSprite("msg_box"); d = createBitmap(p); d.x = CANVAS_WIDTH_HALF; d.y = CANVAS_HEIGHT_HALF + 100; d.regX = .5 * p.width; d.regY = .5 * p.height; c.addChild(d); g = new createjs.Text(TEXT_ARE_SURE, "50px " + FONT_GAME, "#ffffff"); g.x = CANVAS_WIDTH / 2; g.y = CANVAS_HEIGHT_HALF - 50; g.textAlign = "center"; g.textBaseline = "middle"; c.addChild(g); l = new CGfxButton(CANVAS_WIDTH / 2 + 180, .5 * CANVAS_HEIGHT + 120, s_oSpriteLibrary.getSprite("but_yes"), c); l.addEventListener(ON_MOUSE_UP, this._onButYes, this); b = new CGfxButton(CANVAS_WIDTH / 2 - 180, .5 * CANVAS_HEIGHT + 120, s_oSpriteLibrary.getSprite("but_no"), c); b.addEventListener(ON_MOUSE_UP, this._onButNo, this) }; this.show = function() { createjs.Tween.get(c).to({ alpha: 1 }, 150, createjs.quartOut).call(function() { s_oGame.pause(!0) }) }; this.unload = function() { createjs.Tween.get(c).to({ alpha: 0 }, 150, createjs.quartOut).call(function() { q.removeChild(c, a) }) }; this._onButYes = function() { createjs.Ticker.paused = !1; this.unload(); s_oGame.onExit(); a.removeAllEventListeners() }; this._onButNo = function() { s_oGame.pause(!1); this.unload(); c.visible = !1; a.removeAllEventListeners() }; var q = n; this._init() } function CCreditsPanel() { var n, d, g, l, b, c, a, q, p; this._init = function() { p = new createjs.Container; s_oStage.addChild(p); var h = s_oSpriteLibrary.getSprite("msg_box"); c = new createjs.Shape; c.graphics.beginFill("#000").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); c.alpha = .8; a = c.on("click", this._onLogoButRelease); c.cursor = "pointer"; p.addChild(c); d = createBitmap(h); d.x = CANVAS_WIDTH_HALF; d.y = CANVAS_HEIGHT_HALF + 95; d.regX = .5 * h.width; d.regY = .5 * h.height; p.addChild(d); h = s_oSpriteLibrary.getSprite("but_exit"); n = .5 * CANVAS_WIDTH + 205; l = new CGfxButton(n, 593, h, p); l.addEventListener(ON_MOUSE_UP, this.unload, this); b = new createjs.Text(TEXT_CREDITS_DEVELOPED, "42px " + SECONDARY_FONT, "#ffffff"); b.textAlign = "center"; b.textBaseline = "alphabetic"; b.x = CANVAS_WIDTH / 2; b.y = CANVAS_HEIGHT_HALF - 50; p.addChild(b); h = s_oSpriteLibrary.getSprite("logo_ctl"); g = createBitmap(h); g.regX = h.width / 2; g.regY = h.height / 2; g.x = CANVAS_WIDTH / 2; g.y = CANVAS_HEIGHT_HALF + 25; p.addChild(g); q = new createjs.Text(TEXT_LINK1, "42px " + SECONDARY_FONT, "#ffffff"); q.textAlign = "center"; q.textBaseline = "alphabetic"; q.x = CANVAS_WIDTH / 2; q.y = g.y + 100; p.addChild(q) }; this.unload = function() { c.off("click", a); l.unload(); l = null; s_oStage.removeChild(p) }; this._onLogoButRelease = function() { window.open("http://www.codethislab.com/index.php?&l=en", "_blank") }; this._init() } function CPin(n, d, g, l, b) { var c, a, q, p, h = null, k, f, e, m = !1, t = !1; this._init = function(b, c, d) { p = new createjs.Container; w.addChild(p); a = this.createPin(b, c, d); q = this.createPin(b, c, d); q.scaleY = -1; e = q.regY += PIN_REF_REGY_FACTOR + .5; this.scale(190); f = new CANNON.Vec3; p.addChild(q, a) }; this.createPin = function() { var a = new createjs.SpriteSheet({ images: [g], frames: { width: g.width / 10, height: g.height / 8, regX: g.width / 10 / 2, regY: g.height / 8 / 2 } }); a = createSprite(a, 0, g.width / 10 / 2, g.height / 8 / 2, g.width / 10, g.height / 8); a.stop(); a.x = n; a.y = d; return a }; this.setStartPos = function(a, b) { c = { x: a, y: b } }; this.getStartPos = function() { return c }; this.resetState = function() { a.gotoAndStop(0); this.setPosition(c.x, c.y); p.alpha = 1 }; this.isDownYet = function() { return m }; this.setDown = function(a) { (m = a) && createjs.Tween.get(this).wait(750).call(function() { s_oScenario.setElementVelocity(r, { x: 0, y: 0, z: 0 }) }) }; this.animReposition = function(b, c) { createjs.Tween.get(a).to({ y: b }, 500); createjs.Tween.get(q).wait(250).to({ alpha: c }, 200) }; this.animTake = function(b) { createjs.Tween.get(a).to({ y: b }, 500).call(function() { p.visible = !1 }); createjs.Tween.get(q).to({ alpha: 0 }, 200) }; this.unload = function() { w.removeChild(p) }; this.startPosShadowY = function(a) { h = a }; this.getStartShadowYPos = function() { return h }; this.tweenFade = function(a, b, c) { createjs.Tween.get(p).wait(c).to({ alpha: a }, b).call(function() {}) }; this.playAudio = function() { t || (playSound("pin_hitted", 1, !1), t = !0) }; this.setPlayedSound = function(a) { t = a }; this.pinRotation = function() { r.quaternion.y = 0; r.quaternion.toEuler(f); r.shapes[0].getAveragePointLocal(f); f.x = Math.round(Math.degrees(2 * f.x)); f.y = Math.round(Math.degrees(2 * f.y)); f.z = Math.round(Math.degrees(2 * f.z)); if (0 === f.x) a.gotoAndStop(0), q.gotoAndStop(0); else if (9 >= f.y && 7 < f.y || -9 < f.y && -7 > f.y) - 2 <= f.x && 3 >= f.x ? a.gotoAndStop(29) : 4 <= f.x && 7 >= f.x ? a.gotoAndStop(19) : 8 <= f.x && 12 >= f.x ? a.gotoAndStop(9) : 13 <= f.x && 15 >= f.x ? a.gotoAndStop(79) : 16 <= f.x && 18 >= f.x || -16 >= f.x && -18 <= f.x ? a.gotoAndStop(69) : -15 <= f.x && -12 >= f.x ? a.gotoAndStop(59) : -11 <= f.x && -6 >= f.x ? a.gotoAndStop(49) : -5 <= f.x && -2 >= f.x && a.gotoAndStop(39); else if (-3 <= f.z && 3 >= f.z) if (-8 <= f.y && 8 >= f.y) 0 === f.x ? a.gotoAndStop(0) : 1 === f.x ? a.gotoAndStop(1) : 2 === f.x ? a.gotoAndStop(2) : 3 === f.x ? a.gotoAndStop(3) : 4 === f.x ? a.gotoAndStop(4) : 5 === f.x ? a.gotoAndStop(5) : 6 === f.x ? a.gotoAndStop(6) : 7 === f.x ? a.gotoAndStop(7) : 8 === f.x ? a.gotoAndStop(8) : 9 === f.x ? a.gotoAndStop(9) : -1 === f.x ? a.gotoAndStop(41) : -2 === f.x ? a.gotoAndStop(42) : -3 === f.x ? a.gotoAndStop(43) : -4 === f.x ? a.gotoAndStop(44) : -5 === f.x ? a.gotoAndStop(45) : -6 === f.x ? a.gotoAndStop(46) : -7 === f.x ? a.gotoAndStop(47) : -8 === f.x ? a.gotoAndStop(48) : -9 === f.x && a.gotoAndStop(49); else { if (-8 >= f.y && -18 <= f.y || 18 >= f.y && 11 <= f.y) 0 === f.x ? a.gotoAndStop(0) : 1 === f.x ? a.gotoAndStop(41) : 2 === f.x ? a.gotoAndStop(42) : 3 === f.x ? a.gotoAndStop(43) : 4 === f.x ? a.gotoAndStop(44) : 5 === f.x ? a.gotoAndStop(45) : 6 === f.x ? a.gotoAndStop(46) : 7 === f.x ? a.gotoAndStop(47) : 8 === f.x ? a.gotoAndStop(48) : 9 === f.x ? a.gotoAndStop(49) : -1 === f.x ? a.gotoAndStop(1) : -2 === f.x ? a.gotoAndStop(2) : -3 === f.x ? a.gotoAndStop(3) : -4 === f.x ? a.gotoAndStop(4) : -5 === f.x ? a.gotoAndStop(5) : -6 === f.x ? a.gotoAndStop(6) : -7 === f.x ? a.gotoAndStop(7) : -8 === f.x ? a.gotoAndStop(8) : -9 === f.x && a.gotoAndStop(9) } else if (4 <= f.z && 7 >= f.z) if (-8 <= f.y && 8 >= f.y) 0 === f.x ? a.gotoAndStop(10) : 1 === f.x ? a.gotoAndStop(11) : 2 === f.x ? a.gotoAndStop(12) : 3 === f.x ? a.gotoAndStop(13) : 4 === f.x ? a.gotoAndStop(14) : 5 === f.x ? a.gotoAndStop(15) : 6 === f.x ? a.gotoAndStop(16) : 7 === f.x ? a.gotoAndStop(17) : 8 === f.x ? a.gotoAndStop(18) : 9 === f.x ? a.gotoAndStop(19) : -1 === f.x ? a.gotoAndStop(51) : -2 === f.x ? a.gotoAndStop(52) : -3 === f.x ? a.gotoAndStop(53) : -4 === f.x ? a.gotoAndStop(54) : -5 === f.x ? a.gotoAndStop(55) : -6 === f.x ? a.gotoAndStop(56) : -7 === f.x ? a.gotoAndStop(57) : -8 === f.x ? a.gotoAndStop(58) : -9 === f.x && a.gotoAndStop(59); else { if (-8 >= f.y && -18 <= f.y || 18 >= f.y && 10 <= f.y) 0 === f.x ? a.gotoAndStop(0) : 1 === f.x ? a.gotoAndStop(31) : 2 === f.x ? a.gotoAndStop(32) : 3 === f.x ? a.gotoAndStop(33) : 4 === f.x ? a.gotoAndStop(34) : 5 === f.x ? a.gotoAndStop(35) : 6 === f.x ? a.gotoAndStop(36) : 7 === f.x ? a.gotoAndStop(37) : 8 === f.x ? a.gotoAndStop(38) : 9 === f.x ? a.gotoAndStop(39) : -1 === f.x ? a.gotoAndStop(71) : -2 === f.x ? a.gotoAndStop(72) : -3 === f.x ? a.gotoAndStop(73) : -4 === f.x ? a.gotoAndStop(74) : -5 === f.x ? a.gotoAndStop(75) : -6 === f.x ? a.gotoAndStop(76) : -7 === f.x ? a.gotoAndStop(77) : -8 === f.x ? a.gotoAndStop(78) : -9 === f.x && a.gotoAndStop(79) } else if (8 <= f.z && 10 >= f.z) 0 === f.x ? a.gotoAndStop(20) : 1 === f.x ? a.gotoAndStop(21) : 2 === f.x ? a.gotoAndStop(22) : 3 === f.x ? a.gotoAndStop(23) : 4 === f.x ? a.gotoAndStop(24) : 5 === f.x ? a.gotoAndStop(25) : 6 === f.x ? a.gotoAndStop(26) : 7 === f.x ? a.gotoAndStop(27) : 8 === f.x ? a.gotoAndStop(28) : 9 === f.x ? a.gotoAndStop(29) : -1 === f.x ? a.gotoAndStop(61) : -2 === f.x ? a.gotoAndStop(62) : -3 === f.x ? a.gotoAndStop(63) : -4 === f.x ? a.gotoAndStop(64) : -5 === f.x ? a.gotoAndStop(65) : -6 === f.x ? a.gotoAndStop(66) : -7 === f.x ? a.gotoAndStop(67) : -8 === f.x ? a.gotoAndStop(68) : -9 === f.x && a.gotoAndStop(69); else if (-4 >= f.z && -7 <= f.z) if (-10 <= f.y && 10 >= f.y) 0 === f.x ? a.gotoAndStop(70) : 1 === f.x ? a.gotoAndStop(71) : 2 === f.x ? a.gotoAndStop(72) : 3 === f.x ? a.gotoAndStop(73) : 4 === f.x ? a.gotoAndStop(74) : 5 === f.x ? a.gotoAndStop(75) : 6 === f.x ? a.gotoAndStop(76) : 7 === f.x ? a.gotoAndStop(77) : 8 === f.x ? a.gotoAndStop(78) : 9 === f.x ? a.gotoAndStop(79) : -1 === f.x ? a.gotoAndStop(31) : -2 === f.x ? a.gotoAndStop(32) : -3 === f.x ? a.gotoAndStop(33) : -4 === f.x ? a.gotoAndStop(34) : -5 === f.x ? a.gotoAndStop(35) : -6 === f.x ? a.gotoAndStop(36) : -7 === f.x ? a.gotoAndStop(37) : -8 === f.x ? a.gotoAndStop(38) : -9 === f.x && a.gotoAndStop(39); else { if (-11 >= f.y && -18 <= f.y || 18 >= f.y && 11 <= f.y) 0 === f.x ? a.gotoAndStop(50) : 1 === f.x ? a.gotoAndStop(51) : 2 === f.x ? a.gotoAndStop(52) : 3 === f.x ? a.gotoAndStop(53) : 4 === f.x ? a.gotoAndStop(54) : 5 === f.x ? a.gotoAndStop(55) : 6 === f.x ? a.gotoAndStop(56) : 7 === f.x ? a.gotoAndStop(57) : 8 === f.x ? a.gotoAndStop(58) : 9 === f.x ? a.gotoAndStop(59) : -1 === f.x ? a.gotoAndStop(11) : -2 === f.x ? a.gotoAndStop(12) : -3 === f.x ? a.gotoAndStop(13) : -4 === f.x ? a.gotoAndStop(14) : -5 === f.x ? a.gotoAndStop(15) : -6 === f.x ? a.gotoAndStop(16) : -7 === f.x ? a.gotoAndStop(17) : -8 === f.x ? a.gotoAndStop(18) : -9 === f.x && a.gotoAndStop(19) } else - 8 === f.z && (0 === f.x ? a.gotoAndStop(60) : 1 === f.x ? a.gotoAndStop(61) : 2 === f.x ? a.gotoAndStop(62) : 3 === f.x ? a.gotoAndStop(63) : 4 === f.x ? a.gotoAndStop(64) : 5 === f.x ? a.gotoAndStop(65) : 6 === f.x ? a.gotoAndStop(66) : 7 === f.x ? a.gotoAndStop(67) : 8 === f.x ? a.gotoAndStop(68) : 9 === f.x ? a.gotoAndStop(69) : -1 === f.x ? a.gotoAndStop(21) : -2 === f.x ? a.gotoAndStop(22) : -3 === f.x ? a.gotoAndStop(23) : -4 === f.x ? a.gotoAndStop(24) : -5 === f.x ? a.gotoAndStop(25) : -6 === f.x ? a.gotoAndStop(26) : -7 === f.x ? a.gotoAndStop(27) : -8 === f.x ? a.gotoAndStop(28) : -9 === f.x && a.gotoAndStop(29)); q.gotoAndStop(a.currentFrame) }; this.getPosRef = function() { return k }; this.setPosRef = function(a) { k = a }; this.setRegYRef = function(a) { q.regY = a }; this.getRegYRef = function() { return e }; this.setPositionReflection = function(a, b) { q.x = a; q.y = b }; this.setPosition = function(b, c) { a.x = b; a.y = c }; this.getPhysics = function() { return r }; this.setAlpha = function(a) { p.alpha = a }; this.setAngle = function(b) { a.rotation = b }; this.setVisible = function(a) { p.visible = a }; this.setVisibleRef = function(a) { q.visible = a }; this.getVisible = function() { return p.visible }; this.isVisibleRef = function() { return q.visible }; this.getX = function() { return a.x }; this.getY = function() { return a.y }; this.getStartScale = function() { return 190 }; this.scale = function(b) { a.scaleX = b; a.scaleY = b; q.scaleX = b; q.scaleY = -b }; this.setAlphaByHeight = function(a) { q.alpha = a }; this.getAlphaRef = function() { return q.alpha }; this.getScale = function() { return a.scaleX }; this.getObject = function() { return p }; this.getDepthPos = function() { return r.position.y }; var r = l; var w = b; this._init(n, d, g); return this } function CPowerBar(n, d, g) { var l, b, c, a, q, p, h, k, f; this._init = function(d, f) { b = { x: d, y: f }; l = new createjs.Container; l.x = d; l.y = f; e.addChild(l); var g = s_oSpriteLibrary.getSprite("power_bar_bg"); a = createBitmap(g); a.regX = .5 * g.width; a.regY = g.height; l.addChild(a); q = createBitmap(s_oSpriteLibrary.getSprite("power_bar_fill")); q.regX = .5 * g.width; q.regY = g.height; l.addChild(q); h = g.width; k = g.height; c = new createjs.Shape; c.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(a.x, a.y, h, 0); c.regX = .5 * h; c.regY = k; l.addChild(c); g = s_oSpriteLibrary.getSprite("power_bar_frame"); p = createBitmap(g); p.regX = .5 * g.width; p.regY = g.height; l.addChild(p); l.scaleY = -1; q.mask = c; this.createTextPower() }; this.unload = function() { e.removeChild(l) }; this.setVisible = function(a) { l.visible = a }; this.createTextPower = function() { f = new createjs.Text(TEXT_POWER, "36px " + FONT_GAME, "#ffffff"); f.textAlign = "center"; f.textBaseline = "middle"; f.y = -k - 50; f.scaleY = -1; l.addChild(f) }; this.setPosition = function(a, b) { l.x = a; l.y = b }; this.setX = function(a) { l.x = a }; this.setY = function(a) { l.y = a }; this.getX = function() { return l.x }; this.getY = function() { return l.y }; this.getStartPos = function() { return b }; this.removeTweensMask = function() { createjs.Tween.removeTweens(c.graphics.command) }; this.removeTweensContainer = function() { createjs.Tween.removeTweens(l) }; this.animFade = function(a) { createjs.Tween.get(l).to({ alpha: a }, 250, createjs.Ease.circleOut).call(function() { 0 === a && (l.visible = !1) }) }; this.getMaskValue = function() { return c.graphics.command.h }; this.getMaskHeight = function() { return k }; this.getAngle = function() { return l.rotation }; this.mask = function(b) { c.graphics.clear(); b = Math.floor(b * k / 100); c.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(a.x, a.y, h, b) }; this.animateMask = function(a) { var b = this; createjs.Tween.get(c.graphics.command).to({ h: k }, a, createjs.Ease.cubicIn).call(function() { createjs.Tween.get(c.graphics.command).to({ h: 0 }, a, createjs.Ease.cubicOut).call(function() { b.animateMask(a) }) }) }; this.animateRotation = function(a) { var b = this; createjs.Tween.get(l).to({ rotation: MAX_EFFECT_ANGLE }, a, createjs.Ease.cubicInOut).call(function() { createjs.Tween.get(l).to({ rotation: -MAX_EFFECT_ANGLE }, a, createjs.Ease.cubicInOut).call(function() { b.animateRotation(a) }) }) }; var e = g; this._init(n, d); return this } function CTurnsBoard(n, d, g) { var l, b, c, a; this._init = function(d, p) { l = { x: d, y: p }; b = new createjs.Container; b.x = l.x; b.y = l.y; g.addChild(b); c = []; d = 4; var h = s_oSpriteLibrary.getSprite("turn_board"), k = s_oSpriteLibrary.getSprite("last_turn_board"); b.regY = h.height; for (var f = 0; f < LAUNCH_TURN - 1; f++) c.push(new CTurnBoard(d, 0, h, !1, b)), d += .5 * h.width; c.push(new CTurnBoard(d, 0, k, !0, b)); a = d += .5 * h.width; c[0].changeState("on") }; this.getTurnBoard = function(a) { return c[a] }; this.getStartPos = function() { return l }; this.getLastX = function() { return a }; this.setPosition = function(a, c) { b.x = a; b.y = c }; this.stateTurnBoard = function(a, b) { c[a].changeState(b) }; this.scaleFactor = function(a) { b.scaleX = b.scaleY = .5 * a / EDGEBOARD_X * (TURNSBOARD_SCALE_F - 1) + 1 }; this.unload = function() { g.removeChild(b) }; this._init(n, d); return this } function CTurnBoard(n, d, g, l, b) { var c, a, q; this._init = function(d, h, g, f) { a = new createjs.Container; a.x = d; a.y = h; b.addChild(a); q = []; d = new createjs.SpriteSheet({ images: [f], frames: { width: f.width / 2, height: f.height, regX: 0, regY: 0 }, animations: { on: [0], off: [1] } }); c = createSprite(d, "off", 0, 0, f.width / 2, f.height); a.addChild(c); g ? (a.addChild(q[0] = this.createText(13, 21, "0", 30, "center")), a.addChild(q[1] = this.createText(35, 21, "", 30, "center")), a.addChild(q[2] = this.createText(58, 21, "", 30, "center")), a.addChild(q[3] = this.createText(63, 56, "0", 30, "right"))) : (a.addChild(q[0] = this.createText(19, 21, "0", 30, "center")), a.addChild(q[1] = this.createText(54, 21, "", 30, "center")), a.addChild(q[2] = this.createText(63, 56, "0", 30, "right"))) }; this.changeState = function(a) { c.gotoAndStop(a) }; this.refreshTextByID = function(a, b) { q[a].text = b }; this.createText = function(a, b, c, d, e) { c = new createjs.Text(c, d + "px " + FONT_GAME, "#ffffff"); c.textAlign = e; c.textBaseline = "middle"; c.x = a; c.y = b; return c }; this.unload = function() { b.removeChild(a) }; this.setVisible = function(b) { a.visible = b }; this._init(n, d, l, g); return this } function CTrack(n, d, g, l, b) { var c; this._init = function(a, b, d) { c = createBitmap(d); c.x = a; c.y = b; q.addChild(c) }; this.setPosition = function(a, b) { c.x = a; c.y = b }; this.getPhysics = function() { return a }; this.getObject = function() { return c }; this.getDepthPos = function() { return WALL_TRACK_DEPTH_POSITION.y }; this.getHeightPos = function() { return WALL_TRACK_DEPTH_POSITION.z }; var a = l; var q = b; this._init(n, d, g); return this } function CEffectArray(n, d, g, l) { var b, c, a, q, p, h; this._init = function(a, d, e, g) { b = { x: a, y: d }; q = new createjs.Container; q.x = a; q.y = d; p = g; p.addChild(q); a = SPEED_EFFECT_ARROW / FPS; a = new createjs.SpriteSheet({ images: [e], frames: { width: e.width / 10, height: e.height / 2, regX: e.width / 2 / 10, regY: e.height / 2 / 2 }, animations: { normal: [0, 19, "reverse", a], reverse: { frames: [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], speed: a } } }); c = createSprite(a, "normal", e.width / 2 / 10, e.height / 2 / 2, e.width / 10, e.height / 2); c.y = -30; h = c.regX = e.width / 2 / 10; this.stopAnimation(); q.addChild(c); this.createTextEffect(e) }; this.getX = function() { return c.x }; this.getY = function() { return c.y }; this.getStartPos = function() { return b }; this.playAnimation = function() { c.play() }; this.stopAnimation = function() { c.stop() }; this.getStoppedFrame = function() { return c.currentFrame * c.scaleX }; this.removeAllEventListeners = function() { c.removeAllEventListeners() }; this.setPosition = function(a, b) { q.x = a; q.y = b }; this.setVisible = function(a) { q.visible = a }; this.getScaleX = function() { return c.scaleX }; this.createTextEffect = function(b) { a = new createjs.Text(TEXT_EFFECT, "36px " + FONT_GAME, "#ffffff"); a.textAlign = "center"; a.textBaseline = "middle"; a.x = 1.6 * -h; a.y = b.height / 4; q.addChild(a) }; this.animArrow = function() { var a = this; c.gotoAndPlay("normal"); this.onFinishAnimation(function() { c.gotoAndPlay("reverse"); c.removeAllEventListeners(); a.onFinishAnimation(function() { c.scaleX *= -1; c.regX = -1 === c.scaleX ? 2 * -h - 14 : h; c.removeAllEventListeners(); a.animArrow() }) }) }; this.changeState = function(a) { var b = this; c.gotoAndPlay(a); this.onFinishAnimation(function() { b.loopAnimArray() }) }; this.animFade = function(a) { createjs.Tween.get(c).to({ alpha: a }, 250, createjs.Ease.circleOut).call(function() { 0 === a && (q.visible = !1) }) }; this.onFinishAnimation = function(a) { c.on("animationend", function() { a() }) }; this.unload = function() { c.removeAllEventListeners(); p.removeChild(q) }; this._init(n, d, g, l); return this } function CCharacter(n, d, g) { var l, b = [], c, a = 0, q = 0; this._init = function(a, d) { l = { x: a, y: d }; c = new createjs.Container; c.x = l.x; c.y = l.y; c.regX = 20; g.addChild(c); for (var h = 0; h < NUM_SPRITE_PLAYER; h++) b.push(createBitmap(s_oSpriteLibrary.getSprite("player_" + h))), b[h].visible = !1, c.addChild(b[h]); b[0].visible = !0 }; this.setPosition = function(a, b) { c.x = a; c.y = b }; this.getX = function() { return c.x }; this.getY = function() { return c.y }; this.getStartPos = function() { return l }; this.setVisible = function(a) { c.visible = a }; this.animFade = function(b) { var d = this; createjs.Tween.get(c).to({ alpha: b }, 250).call(function() { 0 === b && (c.visible = !1, d.hideCharacter(NUM_SPRITE_PLAYER - 1), d.viewCharacter(a)) }) }; this.viewCharacter = function(a) { b[a].visible = !0 }; this.hideCharacter = function(a) { b[a].visible = !1 }; this.getFrame = function() { return a }; this.animCharacter = function() { q++; if (q >= BUFFER_ANIM_PLAYER) { this.hideCharacter(a); if (a + 1 < NUM_SPRITE_PLAYER) this.viewCharacter(a + 1), a++; else return this.viewCharacter(a), q = a = 0, !1; q = 0 } return !0 }; this._init(n, d); s_oAnimMonitor = this; return this } var s_oAnimMonitor = null; function CAnimMonitor(n, d, g) { var l, b = [], c = [], a = [], q, p, h, k, f, e = 0, m = 0; this._init = function(e, d) { l = { x: e, y: d }; p = new createjs.Container; p.x = l.x; p.y = l.y; g.addChild(p); h = new createjs.Container; p.addChild(h); h.visible = !1; k = new createjs.Container; p.addChild(k); k.visible = !1; f = new createjs.Container; p.addChild(f); f.visible = !1; for (var m = s_oSpriteLibrary.getSprite("pattern_monitor"), n = 0; n < NUM_SPRITE_MONITOR; n++) b.push(createBitmap(s_oSpriteLibrary.getSprite("monitor_strike_" + n))), b[n].visible = !1, h.addChild(b[n]), c.push(createBitmap(s_oSpriteLibrary.getSprite("monitor_spare_" + n))), c[n].visible = !1, k.addChild(c[n]), a.push(createBitmap(s_oSpriteLibrary.getSprite("monitor_gutterball_" + n))), a[n].visible = !1, f.addChild(a[n]); b[0].visible = !0; c[0].visible = !0; a[0].visible = !0; n = new createjs.Matrix2D; n.a = n.d = .16; q = new createjs.Shape; q.graphics.beginBitmapFill(m, "repeat", n).drawRect(0, 0, 790, 88); q.y = 1; q.alpha = .65; p.addChild(q); p.regY = s_oSpriteLibrary.getSprite("monitor_strike_0").height }; this.setPosition = function(a, b) { p.x = a; p.y = b }; this.getStartPos = function() { return l }; this.setVisibleMonitorStrike = function(a) { h.visible = a }; this.setVisibleMonitorSpare = function(a) { k.visible = a }; this.setVisibleMonitorGutter = function(a) { f.visible = a }; this.viewMonitor = function(a, b) { a[b].visible = !0 }; this.hideMonitor = function(a, b) { a[b].visible = !1 }; this.getStrikeArray = function() { return b }; this.getSpareArray = function() { return c }; this.getGutterArray = function() { return a }; this.scaleFactor = function(a) { p.scaleX = p.scaleY = .5 * a / EDGEBOARD_X * (ANIM_MONITOR_SCALE_F - 1) + 1 }; this.disableRunningMonitor = function() { h.visible = !1; k.visible = !1; f.visible = !1 }; this.animMonitor = function(a) { m += s_iTimeElaps; if (m > BUFFER_ANIM_MONITOR) { this.hideMonitor(a, e); if (e + 1 < NUM_SPRITE_MONITOR) this.viewMonitor(a, e + 1), e++; else return this.disableRunningMonitor(), m = e = 0, this.viewMonitor(a, e), !1; m = 0 } return !0 }; this._init(n, d); s_oAnimMonitor = this; return this } s_oAnimMonitor = null; function CPinDragger(n, d, g, l) { var b, c; this._init = function(a, d, g, h) { c = h; h = 30 / FPS; h = new createjs.SpriteSheet({ images: [g], frames: { width: g.width / 8, height: g.height / 4, regX: g.width / 2 / 8, regY: g.height / 2 / 4 }, animations: { up: { frames: [8, 7, 6, 5, 4, 3, 2, 1, 0], speed: h }, down: [0, 8, 8, h - .15], throw_pins_0: [0, 8, "throw_pins_1", h], throw_pins_1: [9, 31, 31, h] } }); b = createSprite(h, "run", g.width / 2 / 10, g.height / 2 / 4, g.width / 10, g.height / 6); b.x = a; b.y = d; c.addChild(b) }; this.getX = function() { return b.x }; this.getY = function() { return b.y }; this.animThrowPins = function() { var a = this; b.gotoAndPlay("throw_pins_0"); this.onFinishAnimation(function() { var c = s_oScenario.getPinsBinder(); createjs.Tween.get(c.position).to({ y: PIN_BINDER_TO_Y }, 900).call(function() { s_oGame.isAwakwePins(!1) }); s_oGame.isAwakwePins(!0); b.gotoAndPlay("throw_pins_1"); playSound("binder", 1, !1); b.removeAllEventListeners(); a.onFinishAnimation(function() { b.gotoAndStop(31); b.removeAllEventListeners(); createjs.Tween.get(this).wait(500).call(function() { s_oGame.setPinsPhysicsMovement(!1); s_oGame.repositionPins(); s_oGame.resetScene(); createjs.Tween.get(this).wait(200).call(function() { b.gotoAndPlay("down"); a.onFinishAnimation(function() { b.gotoAndStop(8); createjs.Tween.get(this).wait(200).call(function() { b.gotoAndPlay("up"); s_oGame.updatePinsPosition(); b.removeAllEventListeners(); a.onFinishAnimation(function() { b.visible = !1; s_oGame.setPinsPhysicsMovement(!0); s_oGame.nextStage(); b.removeAllEventListeners() }) }) }) }) }) }) }) }; this.takeRemainPinsAndRepos = function() { var a = this; b.gotoAndPlay("down"); a.onFinishAnimation(function() { createjs.Tween.get(a).wait(200).call(function() { b.gotoAndPlay("up"); s_oGame.setPinsPhysicsMovement(!1); s_oGame.animUpRemainPins(); b.removeAllEventListeners(); a.onFinishAnimation(function() { b.gotoAndPlay("throw_pins_0"); b.removeAllEventListeners(); a.onFinishAnimation(function() { var c = s_oScenario.getPinsBinder(); createjs.Tween.get(c.position).to({ y: PIN_BINDER_TO_Y }, 900).call(function() { s_oGame.isAwakwePins(!1) }); s_oGame.isAwakwePins(!0); b.gotoAndPlay("throw_pins_1"); playSound("binder", 1, !1); s_oGame.setPinsPhysicsMovement(!0); b.removeAllEventListeners(); a.onFinishAnimation(function() { b.gotoAndStop(31); b.removeAllEventListeners(); createjs.Tween.get(this).wait(500).call(function() { s_oScenario.getPinsBinder().collisionResponse = 0; createjs.Tween.get(this).wait(200).call(function() { b.gotoAndPlay("down"); s_oGame.setPinsPhysicsMovement(!1); s_oGame.repositionRemainPins(); a.onFinishAnimation(function() { b.gotoAndStop(8); createjs.Tween.get(this).wait(200).call(function() { b.gotoAndPlay("up"); b.removeAllEventListeners(); a.onFinishAnimation(function() { b.visible = !1; s_oScenario.getPinsBinder().position.y = PINS_BINDER_POSITION.y; s_oGame.activeControl(); s_oGame.setPinsPhysicsMovement(!0); b.removeAllEventListeners() }) }) }) }) }) }) }) }) }) }) }; this.setPosition = function(a, c) { b.x = a; b.y = c }; this.setVisible = function(a) { b.visible = a }; this.changeState = function(a) { b.gotoAndPlay(a) }; this.onFinishAnimation = function(a) { b.on("animationend", function() { a() }) }; s_oPinBinder = this; this._init(n, d, g, l) } var s_oPinBinder; function CSemaphore(n, d, g, l) { var b, c; this._init = function(d, g, h) { b = this.createSemaphore(d, g, h); c = this.createSemaphore(d, g, h); c.y += 155; c.scaleY = -.95; c.alpha = .25; a.addChild(b); a.addChildAt(c, 13) }; this.createSemaphore = function(a, b, c) { var d = new createjs.SpriteSheet({ images: [c], frames: { width: c.width / 2, height: c.height, regX: c.width / 2 / 2, regY: c.height / 2 }, animations: { green: 1, red: 0 } }); c = createSprite(d, 1, c.width / 2 / 2, c.height / 2, c.width / 2, c.height); c.stop(); c.x = a; c.y = b; return c }; this.changeState = function(a) { b.gotoAndStop(a); c.gotoAndStop(a) }; this.unload = function() { a.removeChild(b, c) }; this.setPositionShadow = function(a, b) { c.x = a; c.y = b }; this.setPosition = function(a, c) { b.x = a; b.y = c }; this.setVisible = function(a) { b.visible = a; c.visible = a }; this.getX = function() { return b.x }; this.getY = function() { return b.y }; var a = l; this._init(n, d, g); return this } function CTotalScoreBoard(n, d, g, l) { var b, c, a; this._init = function(d, g, h) { c = new createjs.Container; c.x = d; c.y = g; l.addChild(c); b = createBitmap(h); c.regY = h.height; c.addChild(b); c.addChild(this.createText(.5 * h.width, 17, TEXT_TOTAL, 18, "center")); c.addChild(a = this.createText(.5 * h.width, .7 * h.height, "0", 30, "center")) }; this.refreshText = function(b) { a.text = b }; this.createText = function(a, b, c, d, f) { c = new createjs.Text(c, d + "px " + FONT_GAME, "#ffffff"); c.textAlign = f; c.textBaseline = "middle"; c.x = a; c.y = b; return c }; this.unload = function() { l.removeChild(c) }; this.setVisible = function(a) { c.visible = a }; this._init(n, d, g); return this } function CEndPanel(n) { var d, g, l, b, c, a, q, p; this._init = function(h) { l = new createjs.Shape; l.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); l.alpha = .7; p = l.on("click", function() {}); d = createBitmap(h); d.x = CANVAS_WIDTH_HALF; d.y = CANVAS_HEIGHT_HALF + 95; d.regX = .5 * h.width; d.regY = .5 * h.height; l.on("click", function() {}, null, !0); b = new createjs.Text("", "72px " + SECONDARY_FONT, "#fff"); b.x = CANVAS_WIDTH / 2; b.y = CANVAS_HEIGHT / 2 - 50; b.textAlign = "center"; b.textBaseline = "alphabetic"; b.lineHeight = 60; b.lineWidth = 450; c = new createjs.Text("", "45px " + SECONDARY_FONT, "#fff"); c.x = CANVAS_WIDTH / 2; c.y = CANVAS_HEIGHT / 2 + 30; c.textAlign = "center"; c.textBaseline = "alphabetic"; c.lineHeight = 60; c.lineWidth = 470; g = new createjs.Container; g.alpha = 0; g.visible = !1; g.addChild(l, d, c, b); h = s_oSpriteLibrary.getSprite("but_restart"); a = new CGfxButton(CANVAS_WIDTH / 2 + 170, CANVAS_HEIGHT_HALF + 120, h, g); h = s_oSpriteLibrary.getSprite("but_home"); q = new CGfxButton(CANVAS_WIDTH / 2 - 170, CANVAS_HEIGHT_HALF + 120, h, g); s_oStage.addChild(g) }; this.unload = function() { l.off("click", p); createjs.Tween.get(g).to({ alpha: 0 }, 500).call(function() { q.unload(); a.unload(); s_oStage.removeChild(g) }) }; this._initListener = function() { q.addEventListener(ON_MOUSE_UP, this._onExit, this); a.addEventListener(ON_MOUSE_UP, this._onRestart, this) }; this.show = function(a) { b.text = 300 > a ? TEXT_GAMEOVER : TEXT_PERFECT; c.text = TEXT_SCORE + ": " + a; g.visible = !0; var d = this; createjs.Tween.get(g).to({ alpha: 1 }, 500).call(function() { d._initListener(); s_iAdsLevel === NUM_LEVEL_FOR_ADS ? ($(s_oMain).trigger("show_interlevel_ad"), s_iAdsLevel = 1) : s_iAdsLevel++ }); $(s_oMain).trigger("share_event", a); $(s_oMain).trigger("save_score", a) }; this._onRestart = function() { this.unload(); s_oGame.restartGame() }; this._onExit = function() { this.unload(); s_oGame.onExit() }; this._init(n); return this } function CController() { var n, d, g, l, b, c; this._init = function() { c = new createjs.Shape; c.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); c.on("mousedown", s_oGame.manageControl, s_oGame); s_oStage.addChild(c); b = new createjs.Container; s_oStage.addChild(b); n = { x: CANVAS_WIDTH_HALF + 310, y: CANVAS_HEIGHT - EDGEBOARD_Y + 50 }; d = { x: CANVAS_WIDTH_HALF - 310, y: CANVAS_HEIGHT - EDGEBOARD_Y + 50 }; var a = s_oSpriteLibrary.getSprite("arrow_left"); g = new CGfxButton(d.x, d.y, a, b); g.addEventListener(ON_MOUSE_DOWN, s_oGame.onLeft, this); g.addEventListener(ON_MOUSE_UP, s_oGame.dirKeyUp, this); a = s_oSpriteLibrary.getSprite("arrow_right"); l = new CGfxButton(n.x, n.y, a, b); l.addEventListener(ON_MOUSE_DOWN, s_oGame.onRight, this); l.addEventListener(ON_MOUSE_UP, s_oGame.dirKeyUp, this) }; this.getStartPositionControlRight = function() { return n }; this.getStartPositionControlLeft = function() { return d }; this.setPositionControlRight = function(a, b) { l.setPosition(a, b) }; this.setPositionControlLeft = function(a, b) { g.setPosition(a, b) }; this.arrowVisibility = function(a) { b.visible = a }; this.unload = function() { g.unload(); g = null; l.unload(); l = null }; this._init(); return this } (function() { function n() {} function d() {} function g() { this.skinIndices = []; this.skinWeights = []; this.matrices = [] } function l() { this.hierarchy = [] } function b() { this.id = this.name = this.node = null; this.vertices = []; this.indices = []; this.normals = []; this.uvs = []; this.bones = []; this.skins = null } function c() { this.index = this.node = this.ref = this.map = this.uv = null } function a() { this.index = this.node = this.ref = this.map = this.normal = null } function q() { this.attrData = this.attrFlag = this.values = this.times = this.internalId = this.id = this.version = null } function p() { this.attr = this.id = null; this.attrZ = this.attrY = this.attrX = !1; this.curveIdx = this.containerBoneId = this.containerInternalId = this.internalId = null; this.curves = [] } function h() { this.curves = {}; this.length = 0; this.fps = 30; this.frames = 0 } function k() { this.textures = []; this.perGeoMap = {} } function f() { this.name = this.fileName = ""; this.id = null; this.parentIds = [] } THREE.FBXLoader = function(a, b) { THREE.Loader.call(this, a); this.manager = void 0 !== b ? b : THREE.DefaultLoadingManager; this.textureBasePath = this.textureLoader = null }; THREE.FBXLoader.prototype = Object.create(THREE.Loader.prototype); THREE.FBXLoader.prototype.constructor = THREE.FBXLoader; THREE.FBXLoader.prototype.load = function(a, b, c, d) { var e = this; (new THREE.XHRLoader(e.manager)).load(a, function(c) { e.isFbxFormatASCII(c) ? e.isFbxVersionSupported(c) ? (e.textureBasePath = e.extractUrlBase(a), b(e.parse(c))) : console.warn("FBXLoader: !!! FBX Version below 7 not supported !!!") : console.warn("FBXLoader: !!! FBX Binary format not supported !!!") }, c, d) }; THREE.FBXLoader.prototype.setCrossOrigin = function(a) { this.crossOrigin = a }; THREE.FBXLoader.prototype.isFbxFormatASCII = function(a) { CORRECT = "Kaydara\\FBX\\Binary\\\\".split(""); for (var b = 0, c = 0; c < CORRECT.length; ++c) { var e = a[0]; a = a.slice(b + 1); b++; num = e; if (num == CORRECT[c]) return !1 } return !0 }; THREE.FBXLoader.prototype.isFbxVersionSupported = function(a) { return (match = a.match(/FBXVersion: (\d+)/)) ? (a = parseInt(match[1]), console.log("FBXLoader: FBX version " + a), 7E3 <= a) : !1 }; THREE.FBXLoader.prototype.parse = function(a) { console.time("FBXLoader"); console.time("FBXLoader: TextParser"); a = (new d).parse(a); console.timeEnd("FBXLoader: TextParser"); console.time("FBXLoader: ObjectParser"); this.hierarchy = (new l).parseHierarchy(a); this.weights = (new g).parse(a, this.hierarchy); this.animations = (new h).parse(a, this.hierarchy); this.textures = (new k).parse(a, this.hierarchy); console.timeEnd("FBXLoader: ObjectParser"); console.time("FBXLoader: GeometryParser"); geometries = this.parseGeometries(a); console.timeEnd("FBXLoader: GeometryParser"); a = new THREE.Group; for (var b = 0; b < geometries.length; ++b) void 0 !== geometries[b] && a.add(geometries[b]); console.timeEnd("FBXLoader"); return a }; THREE.FBXLoader.prototype.parseGeometries = function(a) { if (!("Geometry" in a.Objects.subNodes)) return []; var b = 0, c; for (c in a.Objects.subNodes.Geometry) c.match(/^\d+$/) && b++; var d = []; if (0 < b) for (c in a.Objects.subNodes.Geometry) "Mesh" === a.Objects.subNodes.Geometry[c].attrType && d.push(this.parseGeometry(a.Objects.subNodes.Geometry[c], a)); else d.push(this.parseGeometry(a.Objects.subNodes.Geometry, a)); return d }; THREE.FBXLoader.prototype.parseGeometry = function(a, c) { geo = (new b).parse(a); geo.addBones(this.hierarchy.hierarchy); var d = new THREE.BufferGeometry; d.name = geo.name; d.addAttribute("position", new THREE.BufferAttribute(new Float32Array(geo.vertices), 3)); void 0 !== geo.normals && 0 < geo.normals.length && d.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(geo.normals), 3)); void 0 !== geo.uvs && 0 < geo.uvs.length && d.addAttribute("uv", new THREE.BufferAttribute(new Float32Array(geo.uvs), 2)); void 0 !== geo.indices && 65535 < geo.indices.length ? d.setIndex(new THREE.BufferAttribute(new Uint32Array(geo.indices), 1)) : void 0 !== geo.indices && d.setIndex(new THREE.BufferAttribute(new Uint16Array(geo.indices), 1)); d.verticesNeedUpdate = !0; d.computeBoundingSphere(); d.computeBoundingBox(); var e = this.textures.getById(c.searchConnectionParent(geo.id)); if (void 0 !== e && 0 < e.length) { null === this.textureLoader && (this.textureLoader = new THREE.TextureLoader); var f = this.textureLoader.load(this.textureBasePath + "/" + e[0].fileName) } f = void 0 !== f ? new THREE.MeshBasicMaterial({ map: f }) : new THREE.MeshBasicMaterial({ color: 3342591 }); d = (new THREE.Geometry).fromBufferGeometry(d); d.bones = geo.bones; d.skinIndices = this.weights.skinIndices; d.skinWeights = this.weights.skinWeights; if (void 0 === geo.bones || void 0 === geo.skins || void 0 === this.animations || 0 === this.animations.length) { d = new THREE.Mesh(d, f); e = c.Connections.properties.connections; var g = c.Objects.subNodes.Model; for (f = 0; f < e.length; f++) if (e[f][0] === a.id) { d.name = g[e[f][1]].attrName; if (g[e[f][1]].properties.Lcl_Translation) { e = g[e[f][1]].properties.Lcl_Translation.value.split(","); for (f = 0; f < e.length; f++) e[f] = parseFloat(e[f]); d.position.x = e[0]; d.position.y = e[1]; d.position.z = e[2] } break } } else f.skinning = !0, d = new THREE.SkinnedMesh(d, f), this.addAnimation(d, this.weights.matrices, this.animations); return d }; THREE.FBXLoader.prototype.addAnimation = function(a, b, c) { b = { name: "animationtest", fps: 30, length: c.length, hierarchy: [] }; for (var d = 0; d < a.geometry.bones.length; ++d) { var e = a.geometry.bones[d].name; e = e.replace(/.*:/, ""); b.hierarchy.push({ parent: a.geometry.bones[d].parent, name: e, keys: [] }) } var f = function(a, b) { if (void 0 === a) return !1; switch (b) { case "S": if (void 0 === a.S) return !1; var c = a.S; break; case "R": if (void 0 === a.R) return !1; c = a.R; break; case "T": if (void 0 === a.T) return !1; c = a.T } return void 0 === c.curves.x || void 0 === c.curves.y || void 0 === c.curves.z ? !1 : !0 }, g = function(a, b) { var c = void 0 !== a.curves.y.values[b], d = void 0 !== a.curves.z.values[b]; return void 0 !== a.curves.x.values[b] && c && d }; e = function(a, b) { var d = {}; d.time = frame / c.fps; d.pos = b.pos; d.rot = b.rotq; d.scl = b.scl; if (void 0 === a) return d; try { if (f(a, "T") && g(a.T, frame)) { var e = new THREE.Vector3(a.T.curves.x.values[frame], a.T.curves.y.values[frame], a.T.curves.z.values[frame]); d.pos = [e.x, e.y, e.z] } else delete d.pos; if (f(a, "R") && g(a.R, frame)) { var h = degToRad(a.R.curves.x.values[frame]), k = degToRad(a.R.curves.y.values[frame]), l = degToRad(a.R.curves.z.values[frame]), m = new THREE.Vector3(h, k, l), p = quatFromVec(m.x, m.y, m.z); d.rot = [p.x, p.y, p.z, p.w] } else delete d.rot; if (f(a, "S") && g(a.S, frame)) { var q = new THREE.Vector3(a.S.curves.x.values[frame], a.S.curves.y.values[frame], a.S.curves.z.values[frame]); d.scl = [q.x, q.y, q.z] } else delete d.scl } catch (O) { console.log(b), console.log(O) } return d }; var h = a.geometry.bones; for (frame = 0; frame < c.frames; frame++) for (d = 0; d < h.length; d++) for (var k = h[d], l = c.curves[d], m = 0; m < b.hierarchy.length; m++) b.hierarchy[m].name === k.name && b.hierarchy[m].keys.push(e(l, k)); void 0 === a.geometry.animations && (a.geometry.animations = []); a.geometry.animations.push(THREE.AnimationClip.parseAnimation(b, a.geometry.bones)) }; THREE.FBXLoader.prototype.parseMaterials = function(a) { if (!("Material" in a.subNodes)) return []; var b = 0, c; for (c in a.subNodes.Materials) c.match(/^\d+$/) && b++; var d = []; if (0 < b) for (c in a.subNodes.Material) d.push(parseMaterial(a.subNodes.Material[c])); else d.push(parseMaterial(a.subNodes.Material)); return d }; THREE.FBXLoader.prototype.parseMaterial = function(a) {}; THREE.FBXLoader.prototype.loadFile = function(a, b, c, d, f) { var e = new THREE.XHRLoader(this.manager); e.setResponseType(f); return e.load(a, function(a) { b(a) }, c, d) }; THREE.FBXLoader.prototype.loadFileAsBuffer = function(a, b, c, d) { this.loadFile(a, onLoad, c, d, "arraybuffer") }; THREE.FBXLoader.prototype.loadFileAsText = function(a, b, c, d) { this.loadFile(a, b, c, d, "text") }; n.prototype.add = function(a, b) { this[a] = b }; n.prototype.searchConnectionParent = function(a) { void 0 === this.__cache_search_connection_parent && (this.__cache_search_connection_parent = []); if (void 0 !== this.__cache_search_connection_parent[a]) return this.__cache_search_connection_parent[a]; this.__cache_search_connection_parent[a] = []; for (var b = this.Connections.properties.connections, c = [], d = 0; d < b.length; ++d) b[d][0] == a && c.push(0 === b[d][1] ? -1 : b[d][1]); if (0 < c.length) return this.__cache_search_connection_parent[a] = this.__cache_search_connection_parent[a].concat(c), c; this.__cache_search_connection_parent[a] = [-1]; return [-1] }; n.prototype.searchConnectionChildren = function(a) { void 0 === this.__cache_search_connection_children && (this.__cache_search_connection_children = []); if (void 0 !== this.__cache_search_connection_children[a]) return this.__cache_search_connection_children[a]; this.__cache_search_connection_children[a] = []; for (var b = this.Connections.properties.connections, c = [], d = 0; d < b.length; ++d) b[d][1] == a && c.push(0 === b[d][0] ? -1 : b[d][0]); if (0 < c.length) return this.__cache_search_connection_children[a] = this.__cache_search_connection_children[a].concat(c), c; this.__cache_search_connection_children[a] = [-1]; return [-1] }; n.prototype.searchConnectionType = function(a, b) { var c = a + "," + b; void 0 === this.__cache_search_connection_type && (this.__cache_search_connection_type = ""); if (void 0 !== this.__cache_search_connection_type[c]) return this.__cache_search_connection_type[c]; this.__cache_search_connection_type[c] = ""; for (var d = this.Connections.properties.connections, e = 0; e < d.length; ++e) if (d[e][0] == a && d[e][1] == b) return this.__cache_search_connection_type[c] = d[e][2], d[e][2]; return this.__cache_search_connection_type[a] = null }; d.prototype = { getPrevNode: function() { return this.nodeStack[this.currentIndent - 2] }, getCurrentNode: function() { return this.nodeStack[this.currentIndent - 1] }, getCurrentProp: function() { return this.currentProp }, pushStack: function(a) { this.nodeStack.push(a); this.currentIndent += 1 }, popStack: function() { this.nodeStack.pop(); --this.currentIndent }, setCurrentProp: function(a, b) { this.currentProp = a; this.currentPropName = b }, parse: function(a) { this.currentIndent = 0; this.allNodes = new n; this.nodeStack = []; this.currentProp = []; this.currentPropName = ""; a = a.split("\n"); for (var b in a) { var c = a[b]; if (!c.match(/^[\s\t]*;/) && !c.match(/^[\s\t]*$/)) if (match = c.match(new RegExp("^\\t{" + this.currentIndent + "}(\\w+):(.*){", ""))) { var d = match[1].trim().replace(/^"/, "").replace(/"$/, ""), e = match[2].split(",").map(function(a) { return a.trim().replace(/^"/, "").replace(/"$/, "") }); this.parseNodeBegin(c, d, e || null) } else(match = c.match(new RegExp("^\\t{" + this.currentIndent + "}(\\w+):[\\s\\t\\r\\n](.*)"))) ? (d = match[1].replace(/^"/, "").replace(/"$/, "").trim(), e = match[2].replace(/^"/, "").replace(/"$/, "").trim(), this.parseNodeProperty(c, d, e)) : c.match(new RegExp("^\\t{" + (this.currentIndent - 1) + "}}")) ? this.nodeEnd() : c.match(/^[^\s\t}]/) && this.parseNodePropertyContinued(c) } return this.allNodes }, parseNodeBegin: function(a, b, c) { a = { name: b, properties: {}, subNodes: {} }; var d = this.parseNodeAttr(c), e = this.getCurrentNode(); if (0 === this.currentIndent) this.allNodes.add(b, a); else if (b in e.subNodes) { var f = e.subNodes[b]; this.isFlattenNode(e.subNodes[b]) && ("" === d.id ? (e.subNodes[b] = [], e.subNodes[b].push(f)) : (e.subNodes[b] = {}, e.subNodes[b][f.id] = f)); "" === d.id ? e.subNodes[b].push(a) : e.subNodes[b][d.id] = a } else e.subNodes[b] = a; c && (a.id = d.id, a.attrName = d.name, a.attrType = d.type); this.pushStack(a) }, parseNodeAttr: function(a) { var b = a[0]; "" !== a[0] && (b = parseInt(a[0]), isNaN(b) && (b = a[0])); if (1 < a.length) { var c = a[1].replace(/^(\w+)::/, ""); var d = a[2] } return { id: b, name: c || "", type: d || "" } }, parseNodeProperty: function(a, b, c) { var d = this.getCurrentNode(), e = d.name; if (void 0 !== e && e.match(/Properties(\d)+/)) this.parseNodeSpecialProperty(a, b, c); else { if ("C" == b) { b = c.split(",").slice(1); a = parseInt(b[0]); e = parseInt(b[1]); var f = c.split(",").slice(3); b = "connections"; c = [a, e]; c = c.concat(f); void 0 === d.properties[b] && (d.properties[b] = []) } "Node" == b && (a = parseInt(c), d.properties.id = a, d.id = a); b in d.properties ? Array.isArray(d.properties[b]) ? d.properties[b].push(c) : d.properties[b] += c : Array.isArray(d.properties[b]) ? d.properties[b].push(c) : d.properties[b] = c; this.setCurrentProp(d.properties, b) } }, parseNodePropertyContinued: function(a) { this.currentProp[this.currentPropName] += a }, parseNodeSpecialProperty: function(a, b, c) { var d = c.split('",').map(function(a) { return a.trim().replace(/^"/, "").replace(/\s/, "_") }); a = d[0]; b = d[1]; c = d[2]; var e = d[3]; d = d[4]; switch (b) { case "int": d = parseInt(d); break; case "double": d = parseFloat(d); break; case "ColorRGB": case "Vector3D": d = d.split(","), d = new THREE.Vector3(d[0], d[1], d[2]) } this.getPrevNode().properties[a] = { type: b, type2: c, flag: e, value: d }; this.setCurrentProp(this.getPrevNode().properties, a) }, nodeEnd: function(a) { this.popStack() }, isFlattenNode: function(a) { return "subNodes" in a && "properties" in a ? !0 : !1 } }; g.prototype.parseCluster = function(a, b, c) { a = a.searchConnectionParent(b); var d = toInt(c.subNodes.Indexes.properties.a.split(",")), e = toFloat(c.subNodes.Weights.properties.a.split(",")), f = toMat44(toFloat(c.subNodes.Transform.properties.a.split(","))), g = toMat44(toFloat(c.subNodes.TransformLink.properties.a.split(","))); return { parent: a, id: parseInt(b), indices: d, weights: e, transform: f, transformlink: g, linkMode: c.properties.Mode } }; g.prototype.parse = function(a, b) { this.skinIndices = []; this.skinWeights = []; this.matrices = []; var c = a.Objects.subNodes.Deformer, d = {}; for (g in c) if ("Cluster" === c[g].attrType && "Indexes" in c[g].subNodes) { var e = this.parseCluster(a, g, c[g]), f = a.searchConnectionChildren(e.id)[0]; d[f] = e } c = []; var g = b.hierarchy; for (e = 0; e < g.length; ++e) if (f = g[e].internalId, void 0 === d[f]) this.matrices.push(new THREE.Matrix4); else { f = d[f]; this.matrices.push(f.transform); for (var h = 0; h < f.indices.length; ++h) { void 0 === c[f.indices[h]] && (c[f.indices[h]] = {}, c[f.indices[h]].joint = [], c[f.indices[h]].weight = []); var k = a.searchConnectionChildren(f.id); 1 < k.length && console.warn("FBXLoader: node " + f.id + " have many weight kids: " + k); c[f.indices[h]].joint.push(b.getBoneIdfromInternalId(a, k[0])); c[f.indices[h]].weight.push(f.weights[h]) } } for (d = 0; d < c.length; d++) g = new THREE.Vector4(c[d].joint[0] ? c[d].joint[0] : 0, c[d].joint[1] ? c[d].joint[1] : 0, c[d].joint[2] ? c[d].joint[2] : 0, c[d].joint[3] ? c[d].joint[3] : 0), e = new THREE.Vector4(c[d].weight[0] ? c[d].weight[0] : 0, c[d].weight[1] ? c[d].weight[1] : 0, c[d].weight[2] ? c[d].weight[2] : 0, c[d].weight[3] ? c[d].weight[3] : 0), this.skinIndices.push(g), this.skinWeights.push(e); return this }; l.prototype.parseHierarchy = function(a) { var b = a.Objects.subNodes.Model, c = []; for (d in b) void 0 !== b[d].attrType && c.push(b[d]); this.hierarchy = []; for (b = 0; b < c.length; ++b) { var d = c[b]; var e = a.searchConnectionParent(d.id)[0], f = [0, 0, 0], g = [0, 0, 0, 1], h = [1, 1, 1]; "Lcl_Translation" in d.properties && (f = toFloat(d.properties.Lcl_Translation.value.split(","))); if ("Lcl_Rotation" in d.properties) { g = toRad(toFloat(d.properties.Lcl_Rotation.value.split(","))); var k = new THREE.Quaternion; k.setFromEuler(new THREE.Euler(g[0], g[1], g[2], "ZYX")); g = [k.x, k.y, k.z, k.w] } "Lcl_Scaling" in d.properties && (h = toFloat(d.properties.Lcl_Scaling.value.split(","))); k = d.attrName; k = k.replace(/:/, ""); k = k.replace(/_/, ""); k = k.replace(/-/, ""); this.hierarchy.push({ parent: e, name: k, pos: f, rotq: g, scl: h, internalId: d.id }) } this.reindexParentId(); this.restoreBindPose(a); return this }; l.prototype.reindexParentId = function() { for (var a = 0; a < this.hierarchy.length; a++) for (var b = 0; b < this.hierarchy.length; ++b) if (this.hierarchy[a].parent == this.hierarchy[b].internalId) { this.hierarchy[a].parent = b; break } }; l.prototype.restoreBindPose = function(a) { var b = a.Objects.subNodes.Pose; if (void 0 !== b) { var c = b.subNodes.PoseNode; b = {}; for (var d = {}, e = 0; e < c.length; ++e) { var f = toMat44(c[e].subNodes.Matrix.properties.a.split(",")), g = toMat44(c[e].subNodes.Matrix.properties.a.split(",")); b[c[e].id] = f; d[c[e].id] = g } for (c = 0; c < this.hierarchy.length; ++c) if (e = this.hierarchy[c], f = e.internalId, void 0 !== d[f]) { g = new THREE.Vector3(0, 0, 0); for (var h = new THREE.Quaternion, k = new THREE.Vector3(1, 1, 1), l, p = a.searchConnectionParent(f), q = 0; q < p.length; ++q) if (this.isBoneNode(p[q])) { l = p[q]; break } void 0 !== l && void 0 !== b[l] && (p = new THREE.Matrix4, p.getInverse(d[l]), p.multiply(b[f]), b[f] = p); b[f].decompose(g, h, k); e.pos = [g.x, g.y, g.z]; e.rotq = [h.x, h.y, h.z, h.w]; e.scl = [k.x, k.y, k.z] } } }; l.prototype.searchRealId = function(a) { for (var b = 0; b < this.hierarchy.length; b++) if (a == this.hierarchy[b].internalId) return b; return -1 }; l.prototype.getByInternalId = function(a) { for (var b = 0; b < this.hierarchy.length; b++) if (a == this.hierarchy[b].internalId) return this.hierarchy[b]; return null }; l.prototype.isBoneNode = function(a) { for (var b = 0; b < this.hierarchy.length; ++b) if (a === this.hierarchy[b].internalId) return !0; return !1 }; l.prototype.getBoneIdfromInternalId = function(a, b) { void 0 === a.__cache_get_boneid_from_internalid && (a.__cache_get_boneid_from_internalid = []); if (void 0 !== a.__cache_get_boneid_from_internalid[b]) return a.__cache_get_boneid_from_internalid[b]; for (var c = 0; c < this.hierarchy.length; ++c) if (this.hierarchy[c].internalId == b) return a.__cache_get_boneid_from_internalid[b] = c; return -1 }; b.prototype.parse = function(b) { this.node = b; this.name = b.attrName; this.id = b.id; this.vertices = this.getVertices(); if (void 0 === this.vertices) console.log("FBXLoader: Geometry.parse(): pass" + this.node.id); else return this.indices = this.getPolygonVertexIndices(), this.uvs = (new c).parse(this.node, this), this.normals = (new a).parse(this.node, this), 3 < this.getPolygonTopologyMax() && (this.indices = this.convertPolyIndicesToTri(this.indices, this.getPolygonTopologyArray())), this }; b.prototype.getVertices = function() { if (this.node.__cache_vertices) return this.node.__cache_vertices; if (void 0 === this.node.subNodes.Vertices) return console.warn("this.node: " + this.node.attrName + "(" + this.node.id + ") does not have Vertices"), this.node.__cache_vertices = void 0, null; var a = this.node.subNodes.Vertices.properties.a.split(",").map(function(a) { return parseFloat(a) }); this.node.__cache_vertices = a; return this.node.__cache_vertices }; b.prototype.getPolygonVertexIndices = function() { if (this.node.__cache_indices && this.node.__cache_poly_topology_max) return this.node.__cache_indices; if (void 0 === this.node.subNodes) console.error("this.node.subNodes undefined"), console.log(this.node); else if (void 0 === this.node.subNodes.PolygonVertexIndex) console.warn("this.node: " + this.node.attrName + "(" + this.node.id + ") does not have PolygonVertexIndex "), this.node.__cache_indices = void 0; else { for (var a = this.node.subNodes.PolygonVertexIndex.properties.a.split(","), b = 1, c = null, d = [], f = 0; f < a.length; ++f) { var g = parseInt(a[f]); 0 > g ? (b > c && (c = b), a[f] = g ^ -1, d.push(b), b = 1) : (a[f] = g, b++) } null === c && (console.warn("FBXLoader: topology N not found: " + this.node.attrName), console.warn(this.node), c = 3); this.node.__cache_poly_topology_max = c; this.node.__cache_poly_topology_arr = d; this.node.__cache_indices = a; return this.node.__cache_indices } }; b.prototype.getPolygonTopologyMax = function() { if (this.node.__cache_indices && this.node.__cache_poly_topology_max) return this.node.__cache_poly_topology_max; this.getPolygonVertexIndices(this.node); return this.node.__cache_poly_topology_max }; b.prototype.getPolygonTopologyArray = function() { if (this.node.__cache_indices && this.node.__cache_poly_topology_max) return this.node.__cache_poly_topology_arr; this.getPolygonVertexIndices(this.node); return this.node.__cache_poly_topology_arr }; b.prototype.convertPolyIndicesToTri = function(a, b) { for (var c = [], d = 0, e = 0, f; d < a.length;) { f = b[e]; for (var g = 0; g <= f - 3; g++) c.push(a[d]), c.push(a[d + (f - 2 - g)]), c.push(a[d + (f - 1 - g)]); e++; d += f } return c }; b.prototype.addBones = function(a) { this.bones = a }; c.prototype.getUV = function(a) { return this.node && this.uv && this.map && this.ref ? this.uv : this._parseText(a) }; c.prototype.getMap = function(a) { this.node && this.uv && this.map && this.ref || this._parseText(a); return this.map }; c.prototype.getRef = function(a) { this.node && this.uv && this.map && this.ref || this._parseText(a); return this.ref }; c.prototype.getIndex = function(a) { this.node && this.uv && this.map && this.ref || this._parseText(a); return this.index }; c.prototype.getNode = function(a) { return null !== this.node ? this.node : this.node = a.subNodes.LayerElementUV }; c.prototype._parseText = function(a) { a = this.getNode(a); if (void 0 === a) return []; var b = 0; for (c in a) c.match(/^\d+$/) && b++; 0 < b && (console.warn("multi uv not supported"), a = a[c]); var c = a.subNodes.UVIndex.properties.a; b = a.properties.MappingInformationType; var d = a.properties.ReferenceInformationType; this.uv = toFloat(a.subNodes.UV.properties.a.split(",")); this.index = toInt(c.split(",")); this.map = b; this.ref = d; return this.uv }; c.prototype.parse = function(a, b) { this.uvNode = this.getNode(a); this.uv = this.getUV(a); var c = this.getMap(a), d = this.getRef(a), e = this.getIndex(a), f = b.getPolygonTopologyArray(); switch (c) { case "ByPolygonVertex": switch (d) { case "Direct": this.uv = this.parseUV_ByPolygonVertex_Direct(this.uv, e, f, 2); break; case "IndexToDirect": this.uv = this.parseUV_ByPolygonVertex_IndexToDirect(this.uv, e) } var g = this.uv, h = b.getPolygonVertexIndices(a); c = {}; d = []; for (f = e = 0; f < h.length; ++f) if (!(h[f] in c)) { c[h[f]] = {}; for (var k = 0; 2 > k; ++k) c[h[f]][k] = g[2 * f + k]; e = e < h[f] ? h[f] : e } try { for (f = 0; f <= e; f++) for (g = 0; 2 > g; g++) d.push(c[f][g]) } catch (A) {} this.uv = d; break; case "ByPolygon": switch (d) { case "Direct": this.uv = this.parseUV_ByPolygon_Direct(); break; case "IndexToDirect": this.uv = this.parseUV_ByPolygon_IndexToDirect() } } return this.uv }; c.prototype.parseUV_ByPolygonVertex_Direct = function(a, b, c, d) { return parse_Data_ByPolygonVertex_Direct(a, b, c, d) }; c.prototype.parseUV_ByPolygonVertex_IndexToDirect = function(a, b) { for (var c = [], d = 0; d < b.length; ++d) for (var e = 0; 2 > e; ++e) c.push(a[2 * b[d] + e]); return c }; c.prototype.parseUV_ByPolygon_Direct = function(a) { console.warn("not implemented"); return a }; c.prototype.parseUV_ByPolygon_IndexToDirect = function(a) { console.warn("not implemented"); return a }; c.prototype.parseUV_ByVertex_Direct = function(a) { console.warn("not implemented"); return a }; a.prototype.getNormal = function(a) { this.node && this.normal && this.map && this.ref || this._parseText(a); return this.normal }; a.prototype.getMap = function(a) { this.node && this.normal && this.map && this.ref || this._parseText(a); return this.map }; a.prototype.getRef = function(a) { this.node && this.normal && this.map && this.ref || this._parseText(a); return this.ref }; a.prototype.getNode = function(a) { return this.node ? this.node : this.node = a.subNodes.LayerElementNormal }; a.prototype._parseText = function(a) { var b = this.getNode(a); if (void 0 === b) console.warn("node: " + a.attrName + "(" + a.id + ") does not have LayerElementNormal"); else { a = b.properties.MappingInformationType; var c = b.properties.ReferenceInformationType; this.normal = toFloat(b.subNodes.Normals.properties.a.split(",")); this.map = a; this.ref = c } }; a.prototype.parse = function(a, b) { var c = this.getNormal(a); this.getNode(a); var d = this.getMap(a), e = this.getRef(a), f = b.getPolygonVertexIndices(a), g = b.getPolygonTopologyArray(a); switch (d) { case "ByPolygonVertex": switch (e) { case "Direct": c = this.parseNormal_ByPolygonVertex_Direct(c, f, g, 3); break; case "IndexToDirect": c = this.parseNormal_ByPolygonVertex_IndexToDirect() } break; case "ByPolygon": switch (e) { case "Direct": c = this.parseNormal_ByPolygon_Direct(); break; case "IndexToDirect": c = this.parseNormal_ByPolygon_IndexToDirect() } } return c }; a.prototype.parseNormal_ByPolygonVertex_Direct = function(a, b, c, d) { return parse_Data_ByPolygonVertex_Direct(a, b, c, d) }; a.prototype.parseNormal_ByPolygonVertex_IndexToDirect = function(a) { console.warn("not implemented"); return a }; a.prototype.parseNormal_ByPolygon_Direct = function(a) { console.warn("not implemented"); return a }; a.prototype.parseNormal_ByPolygon_IndexToDirect = function(a) { console.warn("not implemented"); return a }; a.prototype.parseNormal_ByVertex_Direct = function(a) { console.warn("not implemented"); return a }; q.prototype.fromNode = function(a) { this.internalId = this.id = a.id; this.times = a.subNodes.KeyTime.properties.a; this.values = a.subNodes.KeyValueFloat.properties.a; this.attrFlag = a.subNodes.KeyAttrFlags.properties.a; this.attrData = a.subNodes.KeyAttrDataFloat.properties.a; this.times = toFloat(this.times.split(",")); this.values = toFloat(this.values.split(",")); this.attrData = toFloat(this.attrData.split(",")); this.attrFlag = toInt(this.attrFlag.split(",")); this.times = this.times.map(function(a) { return a / 46186158E3 }); return this }; q.prototype.getLength = function() { return this.times[this.times.length - 1] }; p.prototype.fromNode = function(a, b, c) { this.id = b.id; this.attr = b.attrName; this.internalId = b.id; if (this.attr.match(/S|R|T/)) for (var d in b.properties) d.match(/X/) && (this.attrX = !0), d.match(/Y/) && (this.attrY = !0), d.match(/Z/) && (this.attrZ = !0); else return null; this.containerIndices = a.searchConnectionParent(this.id); this.curveIdx = a.searchConnectionChildren(this.id); for (a = this.containerIndices.length - 1; 0 <= a && !(b = c.searchRealId(this.containerIndices[a]), 0 <= b && (this.containerBoneId = b, this.containerId = this.containerIndices[a]), 0 <= b); --a); return this }; p.prototype.setCurve = function(a) { this.curves.push(a) }; h.prototype.parse = function(a, b) { var c = a.Objects.subNodes.AnimationCurveNode, d = a.Objects.subNodes.AnimationCurve, e = [], f; for (f in c) if (f.match(/\d+/)) { var g = (new p).fromNode(a, c[f], b); e.push(g) } c = {}; for (g = 0; g < e.length; ++g) null !== e[g] && (c[e[g].id] = e[g]); g = []; e = 0; for (f in d) if (f.match(/\d+/)) { var h = (new q).fromNode(d[f]); g.push(h); e = h.getLength() ? h.getLength() : e; var k = a.searchConnectionParent(h.id)[0], l = a.searchConnectionType(h.id, k); l.match(/X/) && (l = "x"); l.match(/Y/) && (l = "y"); l.match(/Z/) && (l = "z"); c[k].curves[l] = h } for (var m in c) d = c[m].containerBoneId, void 0 === this.curves[d] && (this.curves[d] = {}), this.curves[d][c[m].attr] = c[m]; this.length = e; this.frames = this.length * this.fps; return this }; k.prototype.add = function(a) { void 0 === this.textures && (this.textures = []); this.textures.push(a); for (var b = 0; b < a.parentIds.length; ++b) void 0 === this.perGeoMap[a.parentIds[b]] && (this.perGeoMap[a.parentIds[b]] = []), this.perGeoMap[a.parentIds[b]].push(this.textures[this.textures.length - 1]) }; k.prototype.parse = function(a, b) { var c = a.Objects.subNodes.Texture, d; for (d in c) { var e = (new f).parse(c[d], a); this.add(e) } return this }; k.prototype.getById = function(a) { return this.perGeoMap[a] }; f.prototype.parse = function(a, b) { this.id = a.id; this.name = a.attrName; this.fileName = this.parseFileName(a.properties.FileName); this.parentIds = this.searchParents(this.id, b); return this }; f.prototype.parseFileName = function(a) { if (void 0 === a) return ""; var b = a.split(/[\\\/]/); return 0 < b.length ? b[b.length - 1] : a }; f.prototype.searchParents = function(a, b) { return b.searchConnectionParent(a) }; parse_Data_ByPolygonVertex_Direct = function(a, b, c, d) { c = []; for (var e = 0, f = 0; f < b.length; ++f) { c[b[f]] = []; for (var g = 0; g < d; ++g) c[b[f]][g] = a[e + g]; e += d } a = []; for (b = 0; b < c.length; ++b) if (void 0 !== c[b]) for (e = 0; e < d; ++e) void 0 !== c[b][e] && a.push(c[b][e]); return a }; degToRad = function(a) { return a * Math.PI / 180 }; radToDeg = function(a) { return 180 * a / Math.PI }; quatFromVec = function(a, b, c) { a = new THREE.Euler(a, b, c, "ZYX"); b = new THREE.Quaternion; b.setFromEuler(a); return b }; toInt = function(a) { return a.map(function(a) { return parseInt(a) }) }; toFloat = function(a) { return a.map(function(a) { return parseFloat(a) }) }; toRad = function(a) { return a.map(function(a) { return degToRad(a) }) }; toMat44 = function(a) { var b = new THREE.Matrix4; b.set(a[0], a[4], a[8], a[12], a[1], a[5], a[9], a[13], a[2], a[6], a[10], a[14], a[3], a[7], a[11], a[15]); return b } })(); (function() { var n = function(d) { THREE.MeshBasicMaterial.call(this); this.depthWrite = this.depthTest = !1; this.side = THREE.FrontSide; this.transparent = !0; this.setValues(d); this.oldColor = this.color.clone(); this.oldOpacity = this.opacity; this.highlight = function(b) { b ? (this.color.setRGB(1, 1, 0), this.opacity = 1) : (this.color.copy(this.oldColor), this.opacity = this.oldOpacity) } }; n.prototype = Object.create(THREE.MeshBasicMaterial.prototype); n.prototype.constructor = n; var d = function(d) { THREE.LineBasicMaterial.call(this); this.depthWrite = this.depthTest = !1; this.transparent = !0; this.linewidth = 1; this.setValues(d); this.oldColor = this.color.clone(); this.oldOpacity = this.opacity; this.highlight = function(b) { b ? (this.color.setRGB(1, 1, 0), this.opacity = 1) : (this.color.copy(this.oldColor), this.opacity = this.oldOpacity) } }; d.prototype = Object.create(THREE.LineBasicMaterial.prototype); d.prototype.constructor = d; var g = new n({ visible: !1, transparent: !1 }); THREE.TransformGizmo = function() { this.init = function() { THREE.Object3D.call(this); this.handles = new THREE.Object3D; this.pickers = new THREE.Object3D; this.planes = new THREE.Object3D; this.add(this.handles); this.add(this.pickers); this.add(this.planes); var d = new THREE.PlaneBufferGeometry(50, 50, 2, 2), b = new THREE.MeshBasicMaterial({ visible: !1, side: THREE.DoubleSide }); d = { XY: new THREE.Mesh(d, b), YZ: new THREE.Mesh(d, b), XZ: new THREE.Mesh(d, b), XYZE: new THREE.Mesh(d, b) }; this.activePlane = d.XYZE; d.YZ.rotation.set(0, Math.PI / 2, 0); d.XZ.rotation.set(-Math.PI / 2, 0, 0); for (var c in d) d[c].name = c, this.planes.add(d[c]), this.planes[c] = d[c]; d = function(a, b) { for (var d in a) for (c = a[d].length; c--;) { var g = a[d][c][0], k = a[d][c][1], f = a[d][c][2]; g.name = d; k && g.position.set(k[0], k[1], k[2]); f && g.rotation.set(f[0], f[1], f[2]); b.add(g) } }; d(this.handleGizmos, this.handles); d(this.pickerGizmos, this.pickers); this.traverse(function(a) { if (a instanceof THREE.Mesh) { a.updateMatrix(); var b = a.geometry.clone(); b.applyMatrix(a.matrix); a.geometry = b; a.position.set(0, 0, 0); a.rotation.set(0, 0, 0); a.scale.set(1, 1, 1) } }) }; this.highlight = function(d) { this.traverse(function(b) { b.material && b.material.highlight && (b.name === d ? b.material.highlight(!0) : b.material.highlight(!1)) }) } }; THREE.TransformGizmo.prototype = Object.create(THREE.Object3D.prototype); THREE.TransformGizmo.prototype.constructor = THREE.TransformGizmo; THREE.TransformGizmo.prototype.update = function(d, b) { var c = new THREE.Vector3(0, 0, 0), a = new THREE.Vector3(0, 1, 0), g = new THREE.Matrix4; this.traverse(function(l) { -1 !== l.name.search("E") ? l.quaternion.setFromRotationMatrix(g.lookAt(b, c, a)) : (-1 !== l.name.search("X") || -1 !== l.name.search("Y") || -1 !== l.name.search("Z")) && l.quaternion.setFromEuler(d) }) }; THREE.TransformGizmoTranslate = function() { THREE.TransformGizmo.call(this); var l = new THREE.Geometry, b = new THREE.Mesh(new THREE.CylinderGeometry(0, .05, .2, 12, 1, !1)); b.position.y = .5; b.updateMatrix(); l.merge(b.geometry, b.matrix); b = new THREE.BufferGeometry; b.addAttribute("position", new THREE.Float32Attribute([0, 0, 0, 1, 0, 0], 3)); var c = new THREE.BufferGeometry; c.addAttribute("position", new THREE.Float32Attribute([0, 0, 0, 0, 1, 0], 3)); var a = new THREE.BufferGeometry; a.addAttribute("position", new THREE.Float32Attribute([0, 0, 0, 0, 0, 1], 3)); this.handleGizmos = { X: [ [new THREE.Mesh(l, new n({ color: 16711680 })), [.5, 0, 0], [0, 0, -Math.PI / 2] ], [new THREE.Line(b, new d({ color: 16711680 }))] ], Y: [ [new THREE.Mesh(l, new n({ color: 65280 })), [0, .5, 0]], [new THREE.Line(c, new d({ color: 65280 }))] ], Z: [ [new THREE.Mesh(l, new n({ color: 255 })), [0, 0, .5], [Math.PI / 2, 0, 0] ], [new THREE.Line(a, new d({ color: 255 }))] ], XYZ: [ [new THREE.Mesh(new THREE.OctahedronGeometry(.1, 0), new n({ color: 16777215, opacity: .25 })), [0, 0, 0], [0, 0, 0] ] ], XY: [ [new THREE.Mesh(new THREE.PlaneBufferGeometry(.29, .29), new n({ color: 16776960, opacity: .25 })), [.15, .15, 0]] ], YZ: [ [new THREE.Mesh(new THREE.PlaneBufferGeometry(.29, .29), new n({ color: 65535, opacity: .25 })), [0, .15, .15], [0, Math.PI / 2, 0] ] ], XZ: [ [new THREE.Mesh(new THREE.PlaneBufferGeometry(.29, .29), new n({ color: 16711935, opacity: .25 })), [.15, 0, .15], [-Math.PI / 2, 0, 0] ] ] }; this.pickerGizmos = { X: [ [new THREE.Mesh(new THREE.CylinderBufferGeometry(.2, 0, 1, 4, 1, !1), g), [.6, 0, 0], [0, 0, -Math.PI / 2] ] ], Y: [ [new THREE.Mesh(new THREE.CylinderBufferGeometry(.2, 0, 1, 4, 1, !1), g), [0, .6, 0]] ], Z: [ [new THREE.Mesh(new THREE.CylinderBufferGeometry(.2, 0, 1, 4, 1, !1), g), [0, 0, .6], [Math.PI / 2, 0, 0] ] ], XYZ: [ [new THREE.Mesh(new THREE.OctahedronGeometry(.2, 0), g)] ], XY: [ [new THREE.Mesh(new THREE.PlaneBufferGeometry(.4, .4), g), [.2, .2, 0]] ], YZ: [ [new THREE.Mesh(new THREE.PlaneBufferGeometry(.4, .4), g), [0, .2, .2], [0, Math.PI / 2, 0] ] ], XZ: [ [new THREE.Mesh(new THREE.PlaneBufferGeometry(.4, .4), g), [.2, 0, .2], [-Math.PI / 2, 0, 0] ] ] }; this.setActivePlane = function(a, b) { var c = new THREE.Matrix4; b.applyMatrix4(c.getInverse(c.extractRotation(this.planes.XY.matrixWorld))); "X" === a && (this.activePlane = this.planes.XY, Math.abs(b.y) > Math.abs(b.z) && (this.activePlane = this.planes.XZ)); "Y" === a && (this.activePlane = this.planes.XY, Math.abs(b.x) > Math.abs(b.z) && (this.activePlane = this.planes.YZ)); "Z" === a && (this.activePlane = this.planes.XZ, Math.abs(b.x) > Math.abs(b.y) && (this.activePlane = this.planes.YZ)); "XYZ" === a && (this.activePlane = this.planes.XYZE); "XY" === a && (this.activePlane = this.planes.XY); "YZ" === a && (this.activePlane = this.planes.YZ); "XZ" === a && (this.activePlane = this.planes.XZ) }; this.init() }; THREE.TransformGizmoTranslate.prototype = Object.create(THREE.TransformGizmo.prototype); THREE.TransformGizmoTranslate.prototype.constructor = THREE.TransformGizmoTranslate; THREE.TransformGizmoRotate = function() { THREE.TransformGizmo.call(this); var l = function(b, c, a) { var d = new THREE.BufferGeometry, g = []; a = a ? a : 1; for (var h = 0; h <= 64 * a; ++h) "x" === c && g.push(0, Math.cos(h / 32 * Math.PI) * b, Math.sin(h / 32 * Math.PI) * b), "y" === c && g.push(Math.cos(h / 32 * Math.PI) * b, 0, Math.sin(h / 32 * Math.PI) * b), "z" === c && g.push(Math.sin(h / 32 * Math.PI) * b, Math.cos(h / 32 * Math.PI) * b, 0); d.addAttribute("position", new THREE.Float32Attribute(g, 3)); return d }; this.handleGizmos = { X: [ [new THREE.Line(new l(1, "x", .5), new d({ color: 16711680 }))] ], Y: [ [new THREE.Line(new l(1, "y", .5), new d({ color: 65280 }))] ], Z: [ [new THREE.Line(new l(1, "z", .5), new d({ color: 255 }))] ], E: [ [new THREE.Line(new l(1.25, "z", 1), new d({ color: 13421568 }))] ], XYZE: [ [new THREE.Line(new l(1, "z", 1), new d({ color: 7895160 }))] ] }; this.pickerGizmos = { X: [ [new THREE.Mesh(new THREE.TorusBufferGeometry(1, .12, 4, 12, Math.PI), g), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2] ] ], Y: [ [new THREE.Mesh(new THREE.TorusBufferGeometry(1, .12, 4, 12, Math.PI), g), [0, 0, 0], [Math.PI / 2, 0, 0] ] ], Z: [ [new THREE.Mesh(new THREE.TorusBufferGeometry(1, .12, 4, 12, Math.PI), g), [0, 0, 0], [0, 0, -Math.PI / 2] ] ], E: [ [new THREE.Mesh(new THREE.TorusBufferGeometry(1.25, .12, 2, 24), g)] ], XYZE: [ [new THREE.Mesh(new THREE.Geometry)] ] }; this.setActivePlane = function(b) { "E" === b && (this.activePlane = this.planes.XYZE); "X" === b && (this.activePlane = this.planes.YZ); "Y" === b && (this.activePlane = this.planes.XZ); "Z" === b && (this.activePlane = this.planes.XY) }; this.update = function(b, c) { THREE.TransformGizmo.prototype.update.apply(this, arguments); var a = new THREE.Matrix4, d = new THREE.Euler(0, 0, 1), g = new THREE.Quaternion, h = new THREE.Vector3(1, 0, 0), k = new THREE.Vector3(0, 1, 0), f = new THREE.Vector3(0, 0, 1), e = new THREE.Quaternion, l = new THREE.Quaternion, n = new THREE.Quaternion, r = c.clone(); d.copy(this.planes.XY.rotation); g.setFromEuler(d); a.makeRotationFromQuaternion(g).getInverse(a); r.applyMatrix4(a); this.traverse(function(a) { g.setFromEuler(d); "X" === a.name && (e.setFromAxisAngle(h, Math.atan2(-r.y, r.z)), g.multiplyQuaternions(g, e), a.quaternion.copy(g)); "Y" === a.name && (l.setFromAxisAngle(k, Math.atan2(r.x, r.z)), g.multiplyQuaternions(g, l), a.quaternion.copy(g)); "Z" === a.name && (n.setFromAxisAngle(f, Math.atan2(r.y, r.x)), g.multiplyQuaternions(g, n), a.quaternion.copy(g)) }) }; this.init() }; THREE.TransformGizmoRotate.prototype = Object.create(THREE.TransformGizmo.prototype); THREE.TransformGizmoRotate.prototype.constructor = THREE.TransformGizmoRotate; THREE.TransformGizmoScale = function() { THREE.TransformGizmo.call(this); var l = new THREE.Geometry, b = new THREE.Mesh(new THREE.BoxGeometry(.125, .125, .125)); b.position.y = .5; b.updateMatrix(); l.merge(b.geometry, b.matrix); b = new THREE.BufferGeometry; b.addAttribute("position", new THREE.Float32Attribute([0, 0, 0, 1, 0, 0], 3)); var c = new THREE.BufferGeometry; c.addAttribute("position", new THREE.Float32Attribute([0, 0, 0, 0, 1, 0], 3)); var a = new THREE.BufferGeometry; a.addAttribute("position", new THREE.Float32Attribute([0, 0, 0, 0, 0, 1], 3)); this.handleGizmos = { X: [ [new THREE.Mesh(l, new n({ color: 16711680 })), [.5, 0, 0], [0, 0, -Math.PI / 2] ], [new THREE.Line(b, new d({ color: 16711680 }))] ], Y: [ [new THREE.Mesh(l, new n({ color: 65280 })), [0, .5, 0]], [new THREE.Line(c, new d({ color: 65280 }))] ], Z: [ [new THREE.Mesh(l, new n({ color: 255 })), [0, 0, .5], [Math.PI / 2, 0, 0] ], [new THREE.Line(a, new d({ color: 255 }))] ], XYZ: [ [new THREE.Mesh(new THREE.BoxBufferGeometry(.125, .125, .125), new n({ color: 16777215, opacity: .25 }))] ] }; this.pickerGizmos = { X: [ [new THREE.Mesh(new THREE.CylinderBufferGeometry(.2, 0, 1, 4, 1, !1), g), [.6, 0, 0], [0, 0, -Math.PI / 2] ] ], Y: [ [new THREE.Mesh(new THREE.CylinderBufferGeometry(.2, 0, 1, 4, 1, !1), g), [0, .6, 0]] ], Z: [ [new THREE.Mesh(new THREE.CylinderBufferGeometry(.2, 0, 1, 4, 1, !1), g), [0, 0, .6], [Math.PI / 2, 0, 0] ] ], XYZ: [ [new THREE.Mesh(new THREE.BoxBufferGeometry(.4, .4, .4), g)] ] }; this.setActivePlane = function(a, b) { var c = new THREE.Matrix4; b.applyMatrix4(c.getInverse(c.extractRotation(this.planes.XY.matrixWorld))); "X" === a && (this.activePlane = this.planes.XY, Math.abs(b.y) > Math.abs(b.z) && (this.activePlane = this.planes.XZ)); "Y" === a && (this.activePlane = this.planes.XY, Math.abs(b.x) > Math.abs(b.z) && (this.activePlane = this.planes.YZ)); "Z" === a && (this.activePlane = this.planes.XZ, Math.abs(b.x) > Math.abs(b.y) && (this.activePlane = this.planes.YZ)); "XYZ" === a && (this.activePlane = this.planes.XYZE) }; this.init() }; THREE.TransformGizmoScale.prototype = Object.create(THREE.TransformGizmo.prototype); THREE.TransformGizmoScale.prototype.constructor = THREE.TransformGizmoScale; THREE.TransformControls = function(d, b) { function c(a) { if (void 0 !== k.object && !0 !== e && (void 0 === a.button || 0 === a.button)) { var b = h(a.changedTouches ? a.changedTouches[0] : a, m[f].pickers.children), c = null; b && (c = b.object.name, a.preventDefault()); k.axis !== c && (k.axis = c, k.update(), k.dispatchEvent(w)) } } function a(a) { if (void 0 !== k.object && !0 !== e && (void 0 === a.button || 0 === a.button)) { var b = a.changedTouches ? a.changedTouches[0] : a; if (0 === b.button || void 0 === b.button) { var c = h(b, m[f].pickers.children); c && (a.preventDefault(), a.stopPropagation(), k.dispatchEvent(v), k.axis = c.object.name, k.update(), R.copy(Z).sub(aa).normalize(), m[f].setActivePlane(k.axis, R), a = h(b, [m[f].activePlane])) && (F.copy(k.object.position), K.copy(k.object.scale), z.extractRotation(k.object.matrix), W.extractRotation(k.object.matrixWorld), D.extractRotation(k.object.parent.matrixWorld), V.setFromMatrixScale(P.getInverse(k.object.parent.matrixWorld)), G.copy(a.point)) } e = !0 } } function g(a) { if (void 0 !== k.object && null !== k.axis && !1 !== e && (void 0 === a.button || 0 === a.button)) { var b = h(a.changedTouches ? a.changedTouches[0] : a, [m[f].activePlane]); if (!1 !== b) { a.preventDefault(); a.stopPropagation(); x.copy(b.point); if ("translate" === f) { x.sub(G); x.multiply(V); "local" === k.space && (x.applyMatrix4(P.getInverse(W)), -1 === k.axis.search("X") && (x.x = 0), -1 === k.axis.search("Y") && (x.y = 0), -1 === k.axis.search("Z") && (x.z = 0), x.applyMatrix4(z), k.object.position.copy(F), k.object.position.add(x), k.body.position.copy(k.object.position)); if ("world" === k.space || -1 !== k.axis.search("XYZ")) - 1 === k.axis.search("X") && (x.x = 0), -1 === k.axis.search("Y") && (x.y = 0), -1 === k.axis.search("Z") && (x.z = 0), x.applyMatrix4(P.getInverse(D)), k.object.position.copy(F), k.object.position.add(x), k.body.position.copy(k.object.position); null !== k.translationSnap && ("local" === k.space && k.object.position.applyMatrix4(P.getInverse(W)), -1 !== k.axis.search("X") && (k.object.position.x = Math.round(k.object.position.x / k.translationSnap) * k.translationSnap), -1 !== k.axis.search("Y") && (k.object.position.y = Math.round(k.object.position.y / k.translationSnap) * k.translationSnap), -1 !== k.axis.search("Z") && (k.object.position.z = Math.round(k.object.position.z / k.translationSnap) * k.translationSnap), "local" === k.space && k.object.position.applyMatrix4(W)) } else "scale" === f ? (x.sub(G), x.multiply(V), "local" === k.space && ("XYZ" === k.axis ? (S = 1 + x.y / Math.max(K.x, K.y, K.z), k.object.scale.x = K.x * S, k.object.scale.y = K.y * S, k.object.scale.z = K.z * S) : (x.applyMatrix4(P.getInverse(W)), "X" === k.axis && (k.object.scale.x = K.x * (1 + x.x / K.x)), "Y" === k.axis && (k.object.scale.y = K.y * (1 + x.y / K.y)), "Z" === k.axis && (k.object.scale.z = K.z * (1 + x.z / K.z))))) : "rotate" === f && (x.sub(aa), x.multiply(V), J.copy(G).sub(aa), J.multiply(V), "E" === k.axis ? (x.applyMatrix4(P.getInverse(U)), J.applyMatrix4(P.getInverse(U)), N.set(Math.atan2(x.z, x.y), Math.atan2(x.x, x.z), Math.atan2(x.y, x.x)), H.set(Math.atan2(J.z, J.y), Math.atan2(J.x, J.z), Math.atan2(J.y, J.x)), L.setFromRotationMatrix(P.getInverse(D)), I.setFromAxisAngle(R, N.z - H.z), u.setFromRotationMatrix(W), L.multiplyQuaternions(L, I), L.multiplyQuaternions(L, u), k.object.quaternion.copy(L), k.body.quaternion.copy(L)) : "XYZE" === k.axis ? (I.setFromEuler(x.clone().cross(J).normalize()), L.setFromRotationMatrix(P.getInverse(D)), Q.setFromAxisAngle(I, -x.clone().angleTo(J)), u.setFromRotationMatrix(W), L.multiplyQuaternions(L, Q), L.multiplyQuaternions(L, u), k.object.quaternion.copy(L), k.body.quaternion.copy(L)) : "local" === k.space ? (x.applyMatrix4(P.getInverse(W)), J.applyMatrix4(P.getInverse(W)), N.set(Math.atan2(x.z, x.y), Math.atan2(x.x, x.z), Math.atan2(x.y, x.x)), H.set(Math.atan2(J.z, J.y), Math.atan2(J.x, J.z), Math.atan2(J.y, J.x)), u.setFromRotationMatrix(z), null !== k.rotationSnap ? (Q.setFromAxisAngle(M, Math.round((N.x - H.x) / k.rotationSnap) * k.rotationSnap), E.setFromAxisAngle(O, Math.round((N.y - H.y) / k.rotationSnap) * k.rotationSnap), T.setFromAxisAngle(X, Math.round((N.z - H.z) / k.rotationSnap) * k.rotationSnap)) : (Q.setFromAxisAngle(M, N.x - H.x), E.setFromAxisAngle(O, N.y - H.y), T.setFromAxisAngle(X, N.z - H.z)), "X" === k.axis && u.multiplyQuaternions(u, Q), "Y" === k.axis && u.multiplyQuaternions(u, E), "Z" === k.axis && u.multiplyQuaternions(u, T), k.object.quaternion.copy(u), k.body.quaternion.copy(u)) : "world" === k.space && (N.set(Math.atan2(x.z, x.y), Math.atan2(x.x, x.z), Math.atan2(x.y, x.x)), H.set(Math.atan2(J.z, J.y), Math.atan2(J.x, J.z), Math.atan2(J.y, J.x)), L.setFromRotationMatrix(P.getInverse(D)), null !== k.rotationSnap ? (Q.setFromAxisAngle(M, Math.round((N.x - H.x) / k.rotationSnap) * k.rotationSnap), E.setFromAxisAngle(O, Math.round((N.y - H.y) / k.rotationSnap) * k.rotationSnap), T.setFromAxisAngle(X, Math.round((N.z - H.z) / k.rotationSnap) * k.rotationSnap)) : (Q.setFromAxisAngle(M, N.x - H.x), E.setFromAxisAngle(O, N.y - H.y), T.setFromAxisAngle(X, N.z - H.z)), u.setFromRotationMatrix(W), "X" === k.axis && L.multiplyQuaternions(L, Q), "Y" === k.axis && L.multiplyQuaternions(L, E), "Z" === k.axis && L.multiplyQuaternions(L, T), L.multiplyQuaternions(L, u), k.object.quaternion.copy(L), k.body.quaternion.copy(L))); k.update(); k.dispatchEvent(w); k.dispatchEvent(B) } } } function l(a) { a.preventDefault(); if (void 0 === a.button || 0 === a.button) e && null !== k.axis && (y.mode = f, k.dispatchEvent(y)), e = !1, a instanceof TouchEvent ? (k.axis = null, k.update(), k.dispatchEvent(w)) : c(a) } function h(a, c) { var e = b.getBoundingClientRect(); A.set((a.clientX - e.left) / e.width * 2 - 1, -((a.clientY - e.top) / e.height * 2) + 1); C.setFromCamera(A, d); e = C.intersectObjects(c, !0); return e[0] ? e[0] : !1 } THREE.Object3D.call(this); b = void 0 !== b ? b : document; this.object = this.body = void 0; this.visible = !1; this.rotationSnap = this.translationSnap = null; this.space = "world"; this.size = 1; this.axis = null; var k = this, f = "translate", e = !1, m = { translate: new THREE.TransformGizmoTranslate, rotate: new THREE.TransformGizmoRotate, scale: new THREE.TransformGizmoScale }, n; for (n in m) { var r = m[n]; r.visible = n === f; this.add(r) } var w = { type: "change" }, v = { type: "mouseDown" }, y = { type: "mouseUp", mode: f }, B = { type: "objectChange" }, C = new THREE.Raycaster, A = new THREE.Vector2, x = new THREE.Vector3, G = new THREE.Vector3, N = new THREE.Vector3, H = new THREE.Vector3, S = 1, U = new THREE.Matrix4, R = new THREE.Vector3, P = new THREE.Matrix4, J = new THREE.Vector3, L = new THREE.Quaternion, M = new THREE.Vector3(1, 0, 0), O = new THREE.Vector3(0, 1, 0), X = new THREE.Vector3(0, 0, 1), u = new THREE.Quaternion, Q = new THREE.Quaternion, E = new THREE.Quaternion, T = new THREE.Quaternion, I = new THREE.Quaternion, F = new THREE.Vector3, K = new THREE.Vector3, z = new THREE.Matrix4, D = new THREE.Matrix4, V = new THREE.Vector3, aa = new THREE.Vector3, Y = new THREE.Euler, W = new THREE.Matrix4, Z = new THREE.Vector3, ba = new THREE.Euler; b.addEventListener("mousedown", a, !1); b.addEventListener("touchstart", a, !1); b.addEventListener("mousemove", c, !1); b.addEventListener("touchmove", c, !1); b.addEventListener("mousemove", g, !1); b.addEventListener("touchmove", g, !1); b.addEventListener("mouseup", l, !1); b.addEventListener("mouseout", l, !1); b.addEventListener("touchend", l, !1); b.addEventListener("touchcancel", l, !1); b.addEventListener("touchleave", l, !1); this.dispose = function() { b.removeEventListener("mousedown", a); b.removeEventListener("touchstart", a); b.removeEventListener("mousemove", c); b.removeEventListener("touchmove", c); b.removeEventListener("mousemove", g); b.removeEventListener("touchmove", g); b.removeEventListener("mouseup", l); b.removeEventListener("mouseout", l); b.removeEventListener("touchend", l); b.removeEventListener("touchcancel", l); b.removeEventListener("touchleave", l) }; this.attach = function(a, b) { this.body = b; this.object = a; this.visible = !0; this.update() }; this.detach = function() { this.object = this.body = void 0; this.visible = !1; this.axis = null }; this.getMode = function() { return f }; this.setMode = function(a) { f = a ? a : f; "scale" === f && (k.space = "local"); for (var b in m) m[b].visible = b === f; this.update(); k.dispatchEvent(w) }; this.setTranslationSnap = function(a) { k.translationSnap = a }; this.setRotationSnap = function(a) { k.rotationSnap = a }; this.setSize = function(a) { k.size = a; this.update(); k.dispatchEvent(w) }; this.setSpace = function(a) { k.space = a; this.update(); k.dispatchEvent(w) }; this.update = function() { void 0 !== k.object && (k.object.updateMatrixWorld(), aa.setFromMatrixPosition(k.object.matrixWorld), Y.setFromRotationMatrix(P.extractRotation(k.object.matrixWorld)), d.updateMatrixWorld(), Z.setFromMatrixPosition(d.matrixWorld), ba.setFromRotationMatrix(P.extractRotation(d.matrixWorld)), S = aa.distanceTo(Z) / 6 * k.size, this.position.copy(aa), this.scale.set(S, S, S), R.copy(Z).sub(aa).normalize(), "local" === k.space ? m[f].update(Y, R) : "world" === k.space && m[f].update(new THREE.Euler, R), m[f].highlight(k.axis)) } }; THREE.TransformControls.prototype = Object.create(THREE.Object3D.prototype); THREE.TransformControls.prototype.constructor = THREE.TransformControls })(); function extractHostname(n) { n = -1 < n.indexOf("://") ? n.split("/")[2] : n.split("/")[0]; n = n.split(":")[0]; return n = n.split("?")[0] } function extractRootDomain(n) { n = extractHostname(n); var d = n.split("."), g = d.length; 2 < g && (n = d[g - 2] + "." + d[g - 1]); return n } var getClosestTop = function() { var n = window, d = !1; try { for (; n.parent.document !== n.document;) if (n.parent.document) n = n.parent; else { d = !0; break } } catch (g) { d = !0 } return { topFrame: n, err: d } }, getBestPageUrl = function(n) { var d = n.topFrame, g = ""; if (n.err) try { try { g = window.top.location.href } catch (b) { var l = window.location.ancestorOrigins; g = l[l.length - 1] } } catch (b) { g = d.document.referrer } else g = d.location.href; return g }, TOPFRAMEOBJ = getClosestTop(), PAGE_URL = getBestPageUrl(TOPFRAMEOBJ); function seekAndDestroy() { for (var n = extractRootDomain(PAGE_URL), d = [String.fromCharCode(99, 111, 100, 101, 116, 104, 105, 115, 108, 97, 98, 46, 99, 111, 109), String.fromCharCode(101, 110, 118, 97, 116, 111, 46, 99, 111, 109), String.fromCharCode(99, 111, 100, 101, 99, 97, 110, 121, 111, 110, 46, 99, 111, 109), String.fromCharCode(99, 111, 100, 101, 99, 97, 110, 121, 111, 110, 46, 110, 101, 116)], g = 0; g < d.length; g++) if (d[g] === n) return !0; return !1 };
| ver. 1.4 |
Github
|
.
| PHP 8.2.29 | Генераци� �траницы: 0.01 |
proxy
|
phpinfo
|
�а�тройка